chain-insights 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.cjs +25 -2
- package/dist/apps/claude-view.html +28 -28
- package/dist/claude-desktop-BI_mGkZ6.cjs +42 -0
- package/dist/claude-desktop-CTaBCUIm.mjs +41 -0
- package/dist/claude-desktop-CTaBCUIm.mjs.map +1 -0
- package/dist/cli.cjs +3 -0
- package/dist/cli.mjs +3 -0
- package/dist/cli.mjs.map +1 -1
- package/dist/mcp-proxy.cjs +24 -1
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +24 -1
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/skill-refresh-CWgEw-tQ.cjs +142 -0
- package/dist/skill-refresh-jGwQWlOH.mjs +142 -0
- package/dist/skill-refresh-jGwQWlOH.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- Chain Insights UI
|
|
1
|
+
<!-- Chain Insights UI c5f72b3cc8dce9ea39bb1bb49faedd75fbcff722 (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 j_=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Z_=function(e,t){return new URL(e,t).href},nh={},B_=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=Z_(l,r),l in nh)return;nh[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":j_,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 H_(e){return e}function V_(e){return e}function vs(){return e=>e}function q_(e){}function W_(e){throw new Error("Unexpected value in exhaustive check")}function K_(e){}function es(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 $u(e,t="|"){return e.map(n=>hc(n)).join(t)}function ts(e,t){return typeof t=="bigint"?t.toString():t}class J_{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 pi(e){return new J_(e)}function lc(e){return e==null}function Sn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dc(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 rh=Symbol("evaluating");function im(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==rh)return r===void 0&&(r=rh,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Y_(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $t(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bs(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function sn(e){return bs(e._zod.def)??e._zod.def.shape}function om(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $t(this,t,r),r},enumerable:!0,configurable:!0})}function sm(e,t,n){t in e?$t(e,t,n):e[t]=n}function Gn(e,t,n,r){const i=sn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?om(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):sm(e,o,r?r(s.value,o):s.value))}}function X_(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?om(e,n,()=>t[n]):sm(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 Q_(e){return lt(e._zod.def)}function ek(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function tk(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 nk(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 St(e){return JSON.stringify(e)}function am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const fc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const um=pi(()=>{if(yt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function an(e){if(rr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(rr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function mi(e){return an(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function rk(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const ik=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}`)}},ns=new Set(["string","number","symbol"]),cm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function un(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(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 ok(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 hc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function lm(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const pc={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]},mc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function dm(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 Gn(o,e,ws(e,t)),Ge(e,lt(n,{shape:o,checks:[]}))}function ws(e,t){const n=sn(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 fm(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(ws(e,t)),s={};return Gn(s,e,Reflect.ownKeys(sn(e)).filter(a=>!o.has(a))),Ge(e,lt(n,{shape:s,checks:[]}))}function hm(e,t){if(!an(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=sn(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 Ge(e,lt(e._zod.def,{shape:pm(e,t)}))}function pm(e,t){const n={};return Gn(n,e,Reflect.ownKeys(sn(e))),X_(n,t),n}function mm(e,t){if(!an(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Ge(e,lt(e._zod.def,{shape:pm(e,t)}))}function gm(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={};Gn(n,e,Reflect.ownKeys(sn(e))),Gn(n,t,Reflect.ownKeys(sn(t)));const r=lt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ge(e,r)}function Tu(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(ws(t,n)):void 0,u={};return Gn(u,t,Reflect.ownKeys(sn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),Ge(t,lt(t._zod.def,{shape:u,checks:[]}))}function ym(e,t,n){const r=n?new Set(ws(t,n)):void 0,i={};return Gn(i,t,Reflect.ownKeys(sn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),Ge(t,lt(t._zod.def,{shape:i}))}function bt(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 vm(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 Yn(e){return typeof e=="string"?e:e?.message}function Cu(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:Yn(e.inst?._zod.def?.error?.(e))??Yn(o?.(e))??Yn(t?.error?.(e))??Yn(n.customError?.(e))??Yn(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 sk=/[\uD800-\uDBFF]/;function gi(e){const t=e.length;if(!sk.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 ks(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bm(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 ir(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function ak(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wm(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 _m(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function uk(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return wm(t+n)}function ck(e){return _m(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function lk(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 dk(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class fk{constructor(...t){}}function km(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):hk(e,n,r.value)}}function cn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ss(e,t,n){return cn(e,t,n,!1)}function yi(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return cn(this,n,r(this))},set(i){cn(this,n,i)}})}return t}function hk(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:cn(this,t,n.bind(this))},set(r){cn(this,t,r)}})}function pk(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Ka,bn=!1;const mk={configurable:!0,get(){bn=!0}};function _e(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Ka!==e._zod){Ka=void 0;return}Ka=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,mk);const i=bn;bn=!1;try{const o=n(this);return bn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),bn=bn||i,o}catch(o){throw delete this[t],bn=bn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Sm(e,t,n,r){const i=pk(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 gc="~constantCatch";function yc(e){const t=()=>e;return t[gc]=!0,t}const vc=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:mc,CONSTANT_CATCH:gc,Class:fk,NUMBER_FORMAT_RANGES:pc,aborted:bt,allowsEval:um,assert:K_,assertEqual:H_,assertIs:q_,assertNever:W_,assertNotEqual:V_,assignProp:$t,attachSchema:Cu,base64ToUint8Array:wm,base64urlToUint8Array:uk,cached:pi,captureStackTrace:fc,cleanEnum:ak,cleanRegex:Sn,clone:Ge,cloneDef:Q_,codePointLength:gi,constantCatch:yc,createTransparentProxy:ok,defineLazy:im,defineLazyInternal:_e,derived:yi,esc:St,escapeRegex:un,explicitlyAborted:vm,extend:hm,finalizeIssue:Dt,floatSafeRemainder:dc,getElementAtPath:ek,getEnumValues:es,getLengthableOrigin:ks,getParsedType:ik,getSizableOrigin:_s,hexToUint8Array:lk,hide:Ss,installLazyProp:Sm,isObject:rr,isPlainObject:an,issue:ir,joinValues:$u,jsonStringifyReplacer:ts,members:km,merge:gm,mergeDefs:lt,normalizeParams:N,nullish:lc,numKeys:rk,objectClone:Y_,omit:fm,optionalKeys:lm,own:cn,parsedType:bm,partial:Tu,pick:dm,prefixIssues:zt,primitiveTypes:cm,promiseAllObject:tk,propertyKeyTypes:ns,randomString:nk,rawShape:bs,required:ym,safeExtend:mm,shallowClone:mi,slugify:am,stringifyPrimitive:hc,toZod:vs,uint8ArrayToBase64:_m,uint8ArrayToBase64url:ck,uint8ArrayToHex:dk,unwrapMessage:Yn},Symbol.toStringTag,{value:"Module"}));var ih;const bc=Object.freeze({status:"aborted"}),Ja={value:void 0,enumerable:!1};let oh="captureStackTrace"in Error?Error:null;function gk(e){const t=oh;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return oh=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{Ja.value=new o(h);try{Object.defineProperty(f,"_zod",Ja)}finally{Ja.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),g=f._zod.constr.prototype;let w=m;for(;w&&w!==g;)w=Object.getPrototypeOf(w);const y=w??m;a.has(y)||(a.add(y),km(y,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?gk(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const g of p)g();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 wc=Symbol("zod_brand");class rn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ih=globalThis).__zod_globalConfig??(ih.__zod_globalConfig={});const yt=globalThis.__zod_globalConfig;function Qe(e){return e&&Object.assign(yt,e),yt}function yk(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ts,2)),e.message}function vk(e){this._zod.message=e}const bk={get:yk,set:vk,enumerable:!0,configurable:!0},Ya={value:void 0,enumerable:!1},sh=new WeakSet([Object.prototype,Error.prototype]),xm=(e,t)=>{e.name="$ZodError",Ya.value=t,Object.defineProperty(e,"issues",Ya),Ya.value=void 0,Object.defineProperty(e,"message",bk);const n=Object.getPrototypeOf(e);sh.has(n)||(sh.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})}}))},Em=S("$ZodError",xm),Tt=S("$ZodError",xm,void 0,{Parent:Error});function wk(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 Es(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?wk(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function $s(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 _c(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 $m(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 kc(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 ${$m(r.path)}`);return t.join(`
|
|
10
|
-
`)}function Ts(e,t){return{callee:t?.callee??e,Err:t?.Err}}const vi=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 rn;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Dt(c,s,Qe())));throw fc(u,o?.callee??t),u}return a.value};return t},Au=vi(Tt),bi=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,Qe())));throw fc(u,o?.callee??t),u}return a.value};return t},Iu=bi(Tt),wi=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 rn;return o.issues.length?Cm(e,o.issues,i):{success:!0,data:o.value}},Tm=wi(Tt);function Cm(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Dt(i,n,Qe()))),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?Cm(e,o.issues,i):{success:!0,data:o.value}},_k=_i(Tt),kk=Symbol.for("zod.compile.invalid"),Sk=Symbol.for("zod.compile.fallback"),Cs=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==kk)return!0;if(r.definite===!0&&n===void 0)return!1}return xk(e,t,n)});function xk(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[Sk]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new rn;return o.issues.length===0}const As=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},Sc=e=>{const t=vi(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Ts(n,s))};return n},Ek=Sc(Tt),xc=e=>{const t=vi(e),n=(r,i,o,s)=>t(r,i,o,Ts(n,s));return n},$k=xc(Tt),Ec=e=>{const t=bi(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Ts(n,s))};return n},Tk=Ec(Tt),$c=e=>{const t=bi(e),n=async(r,i,o,s)=>await t(r,i,o,Ts(n,s));return n},Ck=$c(Tt),Tc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return wi(e)(t,n,i)},Ak=Tc(Tt),Cc=e=>(t,n,r)=>wi(e)(t,n,r),Ik=Cc(Tt),Ac=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _i(e)(t,n,i)},Nk=Ac(Tt),Ic=e=>async(t,n,r)=>_i(e)(t,n,r),Rk=Ic(Tt),Am=/^[cC][0-9a-z]{6,}$/,Im=/^[0-9a-z]+$/,Nm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Rm=/^[0-9a-vA-V]{20}$/,zm=/^[A-Za-z0-9]{27}$/,Lm=/^[a-zA-Z0-9_-]{21}$/;function Pm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Dm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zk=/^[-+]?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)?)??$/,Om=/^([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})$/,or=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)$/,Lk=or(4),Pk=or(6),Dk=or(7),Mm=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ok=/^[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])?)*$/,Mk=/^(([^<>()\[\]\\.,;:\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,}))$/,Fm=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Fk=Fm,Uk=/^[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])?)*$/,Gk="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Um(){return new RegExp(Gk,"u")}const Gm=/^(?:(?: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])$/,jm=/^(([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}|:))$/,Zm=e=>{const t=un(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Bm=/^((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])$/,Hm=/^(([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])$/,Vm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Wm=/^(?=.{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])?)*\.?$/,Km=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Nc=/^https?$/,Jm=/^\+[1-9]\d{6,14}$/,Rc=/^\d(?:[ -]?\d){11,18}$/,Ym=/^(?: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)$/,zc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Xm="(?:(?:\\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 jk(e){return new RegExp(`^${e}$`)}const Qm=jk(Xm);function Nu(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 eg(e){return new RegExp(`^${Nu(e)}$`)}function tg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Nu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Nu({precision:e.precision})}`:n;return new RegExp(`^${Xm}T(?:${r})$`)}const ng=/^[\s\S]{0,}$/,rg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ig=/^-?\d+n?$/,Lc=/^-?\d+$/,yr=/^-?\d+(?:\.\d+)?$/,og=/^(?:true|false)$/i,sg=/^null$/i,ag=/^undefined$/i,ug=/^[^A-Z]*$/,cg=/^[^a-z]*$/,lg=/^[0-9a-fA-F]*$/;function ki(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Si(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const Zk=/^[0-9a-fA-F]{32}$/,Bk=ki(22,"=="),Hk=Si(22),Vk=/^[0-9a-fA-F]{40}$/,qk=ki(27,"="),Wk=Si(27),Kk=/^[0-9a-fA-F]{64}$/,Jk=ki(43,"="),Yk=Si(43),Xk=/^[0-9a-fA-F]{96}$/,Qk=ki(64,""),eS=Si(64),tS=/^[0-9a-fA-F]{128}$/,nS=ki(86,"=="),rS=Si(86),Is=Object.freeze(Object.defineProperty({__proto__:null,anyString:ng,base64:Vm,base64url:qm,bigint:ig,boolean:og,browserEmail:Uk,cidrv4:Bm,cidrv6:Hm,creditCard:Rc,cuid:Am,cuid2:Im,currencyCode:Ym,date:Qm,datetime:tg,domain:Km,duration:Dm,e164:Jm,email:Mm,emoji:Um,extendedDuration:zk,guid:Om,hex:lg,hostname:Wm,html5Email:Ok,httpProtocol:Nc,iban:zc,idnEmail:Fk,integer:Lc,ipv4:Gm,ipv6:jm,ksuid:zm,lowercase:ug,mac:Zm,md5_base64:Bk,md5_base64url:Hk,md5_hex:Zk,nanoid:Lm,nanoidOfLength:Pm,null:sg,number:yr,rfc5322Email:Mk,sha1_base64:qk,sha1_base64url:Wk,sha1_hex:Vk,sha256_base64:Jk,sha256_base64url:Yk,sha256_hex:Kk,sha384_base64:Qk,sha384_base64url:eS,sha384_hex:Xk,sha512_base64:nS,sha512_base64url:rS,sha512_hex:tS,string:rg,time:eg,ulid:Nm,undefined:ag,unicodeEmail:Fm,uppercase:cg,uuid:or,uuid4:Lk,uuid6:Pk,uuid7:Dk,xid:Rm},Symbol.toStringTag,{value:"Module"})),je=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pc=e=>{const t=e.value;return!lc(t)&&t.size!==void 0},Dc=e=>{const t=e.value;return!lc(t)&&t.length!==void 0},rs={number:"number",bigint:"bigint",object:"date"},Oc=S("$ZodCheckLessThan",(e,t)=>{je.init(e,t);const n=rs[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:rs[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})}}),Mc=S("$ZodCheckGreaterThan",(e,t)=>{je.init(e,t);const n=rs[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:rs[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})}}),dg=S("$ZodCheckMultipleOf",(e,t)=>{je.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):dc(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})}}),fg=S("$ZodCheckNumberFormat",(e,t)=>{je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=pc[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})}}),hg=S("$ZodCheckBigIntFormat",(e,t)=>{je.init(e,t);const[n,r]=mc[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})}}),pg=S("$ZodCheckMaxSize",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),mg=S("$ZodCheckMinSize",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),gg=S("$ZodCheckSizeEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),yg=S("$ZodCheckMaxLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?gi(i):o)<=t.maximum)return;const a=ks(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),vg=S("$ZodCheckMinLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?gi(i):o)>=t.minimum)return;const a=ks(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),bg=S("$ZodCheckLengthEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?gi(i):o;if(s===t.length)return;const a=ks(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})}}),xi=S("$ZodCheckStringFormat",(e,t)=>{var n,r;je.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=()=>{})}),wg=S("$ZodCheckRegex",(e,t)=>{xi.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})}}),_g=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ug),xi.init(e,t)}),kg=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cg),xi.init(e,t)}),Sg=S("$ZodCheckIncludes",(e,t)=>{je.init(e,t);const n=un(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})}}),xg=S("$ZodCheckStartsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`^${un(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})}}),Eg=S("$ZodCheckEndsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`.*${un(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 is(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues))}const $g=S("$ZodCheckProperty",(e,t)=>{je.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=>is(i,n,t.property));is(r,n,t.property)}}),Tg=S("$ZodCheckProperties",(e,t)=>{je.init(e,t),Ss(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=>is(c,r,s)))):is(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),Cg=S("$ZodCheckMimeType",(e,t)=>{je.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})}}),Ag=S("$ZodCheckOverwrite",(e,t)=>{je.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Fc{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 Z_=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),B_=function(e,t){return new URL(e,t).href},nh={},H_=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=B_(l,r),l in nh)return;nh[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":Z_,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 V_(e){return e}function q_(e){return e}function vs(){return e=>e}function W_(e){}function K_(e){throw new Error("Unexpected value in exhaustive check")}function J_(e){}function es(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 $u(e,t="|"){return e.map(n=>hc(n)).join(t)}function ts(e,t){return typeof t=="bigint"?t.toString():t}class Y_{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 pi(e){return new Y_(e)}function lc(e){return e==null}function Sn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dc(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 rh=Symbol("evaluating");function im(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==rh)return r===void 0&&(r=rh,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function X_(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $t(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bs(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function sn(e){return bs(e._zod.def)??e._zod.def.shape}function om(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $t(this,t,r),r},enumerable:!0,configurable:!0})}function sm(e,t,n){t in e?$t(e,t,n):e[t]=n}function Gn(e,t,n,r){const i=sn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?om(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):sm(e,o,r?r(s.value,o):s.value))}}function Q_(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?om(e,n,()=>t[n]):sm(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 ek(e){return lt(e._zod.def)}function tk(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function nk(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 rk(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 St(e){return JSON.stringify(e)}function am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const fc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const um=pi(()=>{if(yt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function an(e){if(rr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(rr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function mi(e){return an(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function ik(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const ok=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}`)}},ns=new Set(["string","number","symbol"]),cm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function un(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(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 sk(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 hc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function lm(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const pc={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]},mc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function dm(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 Gn(o,e,ws(e,t)),Ge(e,lt(n,{shape:o,checks:[]}))}function ws(e,t){const n=sn(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 fm(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(ws(e,t)),s={};return Gn(s,e,Reflect.ownKeys(sn(e)).filter(a=>!o.has(a))),Ge(e,lt(n,{shape:s,checks:[]}))}function hm(e,t){if(!an(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=sn(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 Ge(e,lt(e._zod.def,{shape:pm(e,t)}))}function pm(e,t){const n={};return Gn(n,e,Reflect.ownKeys(sn(e))),Q_(n,t),n}function mm(e,t){if(!an(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Ge(e,lt(e._zod.def,{shape:pm(e,t)}))}function gm(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={};Gn(n,e,Reflect.ownKeys(sn(e))),Gn(n,t,Reflect.ownKeys(sn(t)));const r=lt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ge(e,r)}function Tu(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(ws(t,n)):void 0,u={};return Gn(u,t,Reflect.ownKeys(sn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),Ge(t,lt(t._zod.def,{shape:u,checks:[]}))}function ym(e,t,n){const r=n?new Set(ws(t,n)):void 0,i={};return Gn(i,t,Reflect.ownKeys(sn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),Ge(t,lt(t._zod.def,{shape:i}))}function bt(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 vm(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 Yn(e){return typeof e=="string"?e:e?.message}function Cu(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:Yn(e.inst?._zod.def?.error?.(e))??Yn(o?.(e))??Yn(t?.error?.(e))??Yn(n.customError?.(e))??Yn(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 ak=/[\uD800-\uDBFF]/;function gi(e){const t=e.length;if(!ak.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 ks(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bm(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 ir(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function uk(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wm(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 _m(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ck(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return wm(t+n)}function lk(e){return _m(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function dk(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 fk(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class hk{constructor(...t){}}function km(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):pk(e,n,r.value)}}function cn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ss(e,t,n){return cn(e,t,n,!1)}function yi(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return cn(this,n,r(this))},set(i){cn(this,n,i)}})}return t}function pk(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:cn(this,t,n.bind(this))},set(r){cn(this,t,r)}})}function mk(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Ka,bn=!1;const gk={configurable:!0,get(){bn=!0}};function _e(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Ka!==e._zod){Ka=void 0;return}Ka=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,gk);const i=bn;bn=!1;try{const o=n(this);return bn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),bn=bn||i,o}catch(o){throw delete this[t],bn=bn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Sm(e,t,n,r){const i=mk(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 gc="~constantCatch";function yc(e){const t=()=>e;return t[gc]=!0,t}const vc=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:mc,CONSTANT_CATCH:gc,Class:hk,NUMBER_FORMAT_RANGES:pc,aborted:bt,allowsEval:um,assert:J_,assertEqual:V_,assertIs:W_,assertNever:K_,assertNotEqual:q_,assignProp:$t,attachSchema:Cu,base64ToUint8Array:wm,base64urlToUint8Array:ck,cached:pi,captureStackTrace:fc,cleanEnum:uk,cleanRegex:Sn,clone:Ge,cloneDef:ek,codePointLength:gi,constantCatch:yc,createTransparentProxy:sk,defineLazy:im,defineLazyInternal:_e,derived:yi,esc:St,escapeRegex:un,explicitlyAborted:vm,extend:hm,finalizeIssue:Dt,floatSafeRemainder:dc,getElementAtPath:tk,getEnumValues:es,getLengthableOrigin:ks,getParsedType:ok,getSizableOrigin:_s,hexToUint8Array:dk,hide:Ss,installLazyProp:Sm,isObject:rr,isPlainObject:an,issue:ir,joinValues:$u,jsonStringifyReplacer:ts,members:km,merge:gm,mergeDefs:lt,normalizeParams:N,nullish:lc,numKeys:ik,objectClone:X_,omit:fm,optionalKeys:lm,own:cn,parsedType:bm,partial:Tu,pick:dm,prefixIssues:zt,primitiveTypes:cm,promiseAllObject:nk,propertyKeyTypes:ns,randomString:rk,rawShape:bs,required:ym,safeExtend:mm,shallowClone:mi,slugify:am,stringifyPrimitive:hc,toZod:vs,uint8ArrayToBase64:_m,uint8ArrayToBase64url:lk,uint8ArrayToHex:fk,unwrapMessage:Yn},Symbol.toStringTag,{value:"Module"}));var ih;const bc=Object.freeze({status:"aborted"}),Ja={value:void 0,enumerable:!1};let oh="captureStackTrace"in Error?Error:null;function yk(e){const t=oh;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return oh=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{Ja.value=new o(h);try{Object.defineProperty(f,"_zod",Ja)}finally{Ja.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),g=f._zod.constr.prototype;let w=m;for(;w&&w!==g;)w=Object.getPrototypeOf(w);const y=w??m;a.has(y)||(a.add(y),km(y,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?yk(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const g of p)g();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 wc=Symbol("zod_brand");class rn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ih=globalThis).__zod_globalConfig??(ih.__zod_globalConfig={});const yt=globalThis.__zod_globalConfig;function Qe(e){return e&&Object.assign(yt,e),yt}function vk(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ts,2)),e.message}function bk(e){this._zod.message=e}const wk={get:vk,set:bk,enumerable:!0,configurable:!0},Ya={value:void 0,enumerable:!1},sh=new WeakSet([Object.prototype,Error.prototype]),xm=(e,t)=>{e.name="$ZodError",Ya.value=t,Object.defineProperty(e,"issues",Ya),Ya.value=void 0,Object.defineProperty(e,"message",wk);const n=Object.getPrototypeOf(e);sh.has(n)||(sh.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})}}))},Em=S("$ZodError",xm),Tt=S("$ZodError",xm,void 0,{Parent:Error});function _k(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 Es(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?_k(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function $s(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 _c(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 $m(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 kc(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 ${$m(r.path)}`);return t.join(`
|
|
10
|
+
`)}function Ts(e,t){return{callee:t?.callee??e,Err:t?.Err}}const vi=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 rn;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Dt(c,s,Qe())));throw fc(u,o?.callee??t),u}return a.value};return t},Au=vi(Tt),bi=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,Qe())));throw fc(u,o?.callee??t),u}return a.value};return t},Iu=bi(Tt),wi=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 rn;return o.issues.length?Cm(e,o.issues,i):{success:!0,data:o.value}},Tm=wi(Tt);function Cm(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Dt(i,n,Qe()))),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?Cm(e,o.issues,i):{success:!0,data:o.value}},kk=_i(Tt),Sk=Symbol.for("zod.compile.invalid"),xk=Symbol.for("zod.compile.fallback"),Cs=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Sk)return!0;if(r.definite===!0&&n===void 0)return!1}return Ek(e,t,n)});function Ek(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[xk]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new rn;return o.issues.length===0}const As=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},Sc=e=>{const t=vi(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Ts(n,s))};return n},$k=Sc(Tt),xc=e=>{const t=vi(e),n=(r,i,o,s)=>t(r,i,o,Ts(n,s));return n},Tk=xc(Tt),Ec=e=>{const t=bi(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Ts(n,s))};return n},Ck=Ec(Tt),$c=e=>{const t=bi(e),n=async(r,i,o,s)=>await t(r,i,o,Ts(n,s));return n},Ak=$c(Tt),Tc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return wi(e)(t,n,i)},Ik=Tc(Tt),Cc=e=>(t,n,r)=>wi(e)(t,n,r),Nk=Cc(Tt),Ac=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _i(e)(t,n,i)},Rk=Ac(Tt),Ic=e=>async(t,n,r)=>_i(e)(t,n,r),zk=Ic(Tt),Am=/^[cC][0-9a-z]{6,}$/,Im=/^[0-9a-z]+$/,Nm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Rm=/^[0-9a-vA-V]{20}$/,zm=/^[A-Za-z0-9]{27}$/,Lm=/^[a-zA-Z0-9_-]{21}$/;function Pm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Dm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Lk=/^[-+]?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)?)??$/,Om=/^([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})$/,or=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)$/,Pk=or(4),Dk=or(6),Ok=or(7),Mm=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mk=/^[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])?)*$/,Fk=/^(([^<>()\[\]\\.,;:\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,}))$/,Fm=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Uk=Fm,Gk=/^[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])?)*$/,jk="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Um(){return new RegExp(jk,"u")}const Gm=/^(?:(?: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])$/,jm=/^(([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}|:))$/,Zm=e=>{const t=un(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Bm=/^((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])$/,Hm=/^(([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])$/,Vm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Wm=/^(?=.{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])?)*\.?$/,Km=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Nc=/^https?$/,Jm=/^\+[1-9]\d{6,14}$/,Rc=/^\d(?:[ -]?\d){11,18}$/,Ym=/^(?: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)$/,zc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Xm="(?:(?:\\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 Zk(e){return new RegExp(`^${e}$`)}const Qm=Zk(Xm);function Nu(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 eg(e){return new RegExp(`^${Nu(e)}$`)}function tg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Nu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Nu({precision:e.precision})}`:n;return new RegExp(`^${Xm}T(?:${r})$`)}const ng=/^[\s\S]{0,}$/,rg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ig=/^-?\d+n?$/,Lc=/^-?\d+$/,yr=/^-?\d+(?:\.\d+)?$/,og=/^(?:true|false)$/i,sg=/^null$/i,ag=/^undefined$/i,ug=/^[^A-Z]*$/,cg=/^[^a-z]*$/,lg=/^[0-9a-fA-F]*$/;function ki(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Si(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const Bk=/^[0-9a-fA-F]{32}$/,Hk=ki(22,"=="),Vk=Si(22),qk=/^[0-9a-fA-F]{40}$/,Wk=ki(27,"="),Kk=Si(27),Jk=/^[0-9a-fA-F]{64}$/,Yk=ki(43,"="),Xk=Si(43),Qk=/^[0-9a-fA-F]{96}$/,eS=ki(64,""),tS=Si(64),nS=/^[0-9a-fA-F]{128}$/,rS=ki(86,"=="),iS=Si(86),Is=Object.freeze(Object.defineProperty({__proto__:null,anyString:ng,base64:Vm,base64url:qm,bigint:ig,boolean:og,browserEmail:Gk,cidrv4:Bm,cidrv6:Hm,creditCard:Rc,cuid:Am,cuid2:Im,currencyCode:Ym,date:Qm,datetime:tg,domain:Km,duration:Dm,e164:Jm,email:Mm,emoji:Um,extendedDuration:Lk,guid:Om,hex:lg,hostname:Wm,html5Email:Mk,httpProtocol:Nc,iban:zc,idnEmail:Uk,integer:Lc,ipv4:Gm,ipv6:jm,ksuid:zm,lowercase:ug,mac:Zm,md5_base64:Hk,md5_base64url:Vk,md5_hex:Bk,nanoid:Lm,nanoidOfLength:Pm,null:sg,number:yr,rfc5322Email:Fk,sha1_base64:Wk,sha1_base64url:Kk,sha1_hex:qk,sha256_base64:Yk,sha256_base64url:Xk,sha256_hex:Jk,sha384_base64:eS,sha384_base64url:tS,sha384_hex:Qk,sha512_base64:rS,sha512_base64url:iS,sha512_hex:nS,string:rg,time:eg,ulid:Nm,undefined:ag,unicodeEmail:Fm,uppercase:cg,uuid:or,uuid4:Pk,uuid6:Dk,uuid7:Ok,xid:Rm},Symbol.toStringTag,{value:"Module"})),je=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pc=e=>{const t=e.value;return!lc(t)&&t.size!==void 0},Dc=e=>{const t=e.value;return!lc(t)&&t.length!==void 0},rs={number:"number",bigint:"bigint",object:"date"},Oc=S("$ZodCheckLessThan",(e,t)=>{je.init(e,t);const n=rs[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:rs[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})}}),Mc=S("$ZodCheckGreaterThan",(e,t)=>{je.init(e,t);const n=rs[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:rs[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})}}),dg=S("$ZodCheckMultipleOf",(e,t)=>{je.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):dc(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})}}),fg=S("$ZodCheckNumberFormat",(e,t)=>{je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=pc[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})}}),hg=S("$ZodCheckBigIntFormat",(e,t)=>{je.init(e,t);const[n,r]=mc[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})}}),pg=S("$ZodCheckMaxSize",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),mg=S("$ZodCheckMinSize",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),gg=S("$ZodCheckSizeEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Pc),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})}}),yg=S("$ZodCheckMaxLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?gi(i):o)<=t.maximum)return;const a=ks(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),vg=S("$ZodCheckMinLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?gi(i):o)>=t.minimum)return;const a=ks(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),bg=S("$ZodCheckLengthEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=Dc),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?gi(i):o;if(s===t.length)return;const a=ks(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})}}),xi=S("$ZodCheckStringFormat",(e,t)=>{var n,r;je.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=()=>{})}),wg=S("$ZodCheckRegex",(e,t)=>{xi.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})}}),_g=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ug),xi.init(e,t)}),kg=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cg),xi.init(e,t)}),Sg=S("$ZodCheckIncludes",(e,t)=>{je.init(e,t);const n=un(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})}}),xg=S("$ZodCheckStartsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`^${un(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})}}),Eg=S("$ZodCheckEndsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`.*${un(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 is(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues))}const $g=S("$ZodCheckProperty",(e,t)=>{je.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=>is(i,n,t.property));is(r,n,t.property)}}),Tg=S("$ZodCheckProperties",(e,t)=>{je.init(e,t),Ss(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=>is(c,r,s)))):is(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),Cg=S("$ZodCheckMimeType",(e,t)=>{je.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})}}),Ag=S("$ZodCheckOverwrite",(e,t)=>{je.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Fc{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 Ig={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=Ig;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=bt(a),d;for(const f of u){if(f._zod.def.when){if(vm(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 rn;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(Cu(a.issues,h,e),l||(l=bt(a,h)))});else{if(a.issues.length===h)continue;Cu(a.issues,h,e),l||(l=bt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(bt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new rn;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 rn;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Ss(this,"~standard",Uc(this))},set"~standard"(e){cn(this,"~standard",e)}}),Ng=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Dt(n,t,Qe()))}:{value:e.value};async function iS(e,t){const n={async:!0};return Ng(await e._zod.run({value:t,issues:[]},n),n)}function Uc(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ng(r,n)}catch{}return iS(e,t)},vendor:"zod",version:1}}const Ei=S("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=t.pattern??ng,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}}),Me=S("$ZodStringFormat",(e,t)=>{xi.init(e,t),Ei.init(e,t)}),Rg=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Om),Me.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=or(r))}else t.pattern??(t.pattern=or());Me.init(e,t)}),Lg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mm),Me.init(e,t)}),Gc=1,ii=2;function jc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Zc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?jc(e)||ii:Pg(e,t)}function Pg(e,t){if(!t.normalize&&t.protocol?.source===Nc.source&&!/^https?:\/\//i.test(e))return Gc;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??ii}return new URL(e)}catch{return ii}}const oS=/[\t\n\r]/g;function os(e){return e.replace(oS,"")}function Bc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Dg=S("$ZodURL",(e,t)=>{Me.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=Zc(r,t);if(i===Gc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===ii){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=os(r);return}t.hostname&&!Bc(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&&!Hc(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:os(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Og=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Um()),Me.init(e,t)}),Mg=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?Lm:Pm(t.length)),Me.init(e,t)}),Fg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Am),Me.init(e,t)}),Ug=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Im),Me.init(e,t)}),Gg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Nm),Me.init(e,t)}),jg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rm),Me.init(e,t)}),Zg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=zm),Me.init(e,t)}),Bg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=tg(t)),Me.init(e,t)}),Hg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qm),Me.init(e,t)}),Vg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=eg(t)),Me.init(e,t)}),qg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Dm),Me.init(e,t)}),Wg=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gm),Me.init(e,t)}),sS=/^[0-9a-fA-F:.]+$/;function Ns(e){return sS.test(e)?jc(`http://[${e}]`):!1}const Kg=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jm),Me.init(e,t),e._zod.check=n=>{Ns(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Jg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Zm(t.delimiter)),Me.init(e,t)}),Yg=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Bm),Me.init(e,t)});function Vc(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:Ns(n)}const Xg=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Hm),Me.init(e,t),e._zod.check=n=>{Vc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Rs(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const qc=/^[0-9a-zA-Z+/]*={0,2}$/,Qg=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qc),Me.init(e,t),e._zod.check=n=>{Rs(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),zs=/^[A-Za-z0-9_-]*$/;function Wc(e){if(!zs.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Rs(n)}const ey=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zs),Me.init(e,t),e._zod.check=n=>{Wc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ty=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jm),Me.init(e,t)}),aS=/[- ]/g;function uS(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 Kc(e){return Rc.test(e)?uS(e.replace(aS,"")):!1}const ny=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Rc),Me.init(e,t),e._zod.check=n=>{Kc(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function cS(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 Jc(e){return zc.test(e)?cS(e):!1}const ry=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=zc),Me.init(e,t),e._zod.check=n=>{Jc(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Yc(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 iy=S("$ZodJWT",(e,t)=>{Me.init(e,t),e._zod.check=n=>{Yc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),oy=S("$ZodCustomStringFormat",(e,t)=>{Me.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})}}),Xc=S("$ZodNumber",(e,t)=>{me.init(e,t),e._zod.pattern=yr,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}}),sy=S("$ZodNumberFormat",(e,t)=>{fg.init(e,t),Xc.init(e,t)}),Qc=S("$ZodBoolean",(e,t)=>{me.init(e,t),e._zod.pattern=og,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}}),el=S("$ZodBigInt",(e,t)=>{me.init(e,t),e._zod.pattern=ig,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}}),ay=S("$ZodBigIntFormat",(e,t)=>{hg.init(e,t),el.init(e,t)}),uy=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}}),cy=S("$ZodUndefined",(e,t)=>{me.init(e,t),e._zod.pattern=ag,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}}),ly=S("$ZodNull",(e,t)=>{me.init(e,t),e._zod.pattern=sg,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}}),dy=S("$ZodAny",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),fy=S("$ZodUnknown",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),hy=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)}),py=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}}),my=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 ah(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}const gy=S("$ZodArray",(e,t)=>{me.init(e,t);const n=yt.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=>ah(d,r,u)));else if(ah(l,r,u),a&&l.issues.length!==0&&bt(l))break}return s.length?Promise.all(s).then(()=>r):r}});function ss(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 lS=[];function yy(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:lS,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=lm(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function vy(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(bt(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(g=>ss(g,n,p,t,d,f))):ss(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 by=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=pi(()=>yy(t));_e(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)||$t(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=rr,s=t.catchall;let a;const u=yt.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 g of a.allKeys){if(p&&c.issues.length!==m){if(bt(c,m))break;m=c.issues.length}if(g==="__proto__")continue;const w=h[g],y=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[g],issues:[]},l);v instanceof Promise?f.push(v.then(k=>ss(k,c,g,d,y,b))):ss(v,c,g,d,y,b)}return s?vy(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),wy=S("$ZodObjectJIT",(e,t)=>{by.init(e,t);const n=e._zod.parse,r=pi(()=>yy(t)),i=yt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,g=new Fc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,y=(k,_)=>`
|
|
14
|
+
};`)(...Object.values(this.closed))}}const Ig={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=Ig;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=bt(a),d;for(const f of u){if(f._zod.def.when){if(vm(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 rn;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(Cu(a.issues,h,e),l||(l=bt(a,h)))});else{if(a.issues.length===h)continue;Cu(a.issues,h,e),l||(l=bt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(bt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new rn;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 rn;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Ss(this,"~standard",Uc(this))},set"~standard"(e){cn(this,"~standard",e)}}),Ng=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Dt(n,t,Qe()))}:{value:e.value};async function oS(e,t){const n={async:!0};return Ng(await e._zod.run({value:t,issues:[]},n),n)}function Uc(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ng(r,n)}catch{}return oS(e,t)},vendor:"zod",version:1}}const Ei=S("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=t.pattern??ng,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}}),Me=S("$ZodStringFormat",(e,t)=>{xi.init(e,t),Ei.init(e,t)}),Rg=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Om),Me.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=or(r))}else t.pattern??(t.pattern=or());Me.init(e,t)}),Lg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mm),Me.init(e,t)}),Gc=1,ii=2;function jc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Zc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?jc(e)||ii:Pg(e,t)}function Pg(e,t){if(!t.normalize&&t.protocol?.source===Nc.source&&!/^https?:\/\//i.test(e))return Gc;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??ii}return new URL(e)}catch{return ii}}const sS=/[\t\n\r]/g;function os(e){return e.replace(sS,"")}function Bc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Dg=S("$ZodURL",(e,t)=>{Me.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=Zc(r,t);if(i===Gc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===ii){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=os(r);return}t.hostname&&!Bc(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&&!Hc(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:os(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Og=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Um()),Me.init(e,t)}),Mg=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?Lm:Pm(t.length)),Me.init(e,t)}),Fg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Am),Me.init(e,t)}),Ug=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Im),Me.init(e,t)}),Gg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Nm),Me.init(e,t)}),jg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rm),Me.init(e,t)}),Zg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=zm),Me.init(e,t)}),Bg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=tg(t)),Me.init(e,t)}),Hg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qm),Me.init(e,t)}),Vg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=eg(t)),Me.init(e,t)}),qg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Dm),Me.init(e,t)}),Wg=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gm),Me.init(e,t)}),aS=/^[0-9a-fA-F:.]+$/;function Ns(e){return aS.test(e)?jc(`http://[${e}]`):!1}const Kg=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jm),Me.init(e,t),e._zod.check=n=>{Ns(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Jg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Zm(t.delimiter)),Me.init(e,t)}),Yg=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Bm),Me.init(e,t)});function Vc(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:Ns(n)}const Xg=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Hm),Me.init(e,t),e._zod.check=n=>{Vc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Rs(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const qc=/^[0-9a-zA-Z+/]*={0,2}$/,Qg=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qc),Me.init(e,t),e._zod.check=n=>{Rs(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),zs=/^[A-Za-z0-9_-]*$/;function Wc(e){if(!zs.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Rs(n)}const ey=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zs),Me.init(e,t),e._zod.check=n=>{Wc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ty=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jm),Me.init(e,t)}),uS=/[- ]/g;function cS(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 Kc(e){return Rc.test(e)?cS(e.replace(uS,"")):!1}const ny=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Rc),Me.init(e,t),e._zod.check=n=>{Kc(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function lS(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 Jc(e){return zc.test(e)?lS(e):!1}const ry=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=zc),Me.init(e,t),e._zod.check=n=>{Jc(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Yc(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 iy=S("$ZodJWT",(e,t)=>{Me.init(e,t),e._zod.check=n=>{Yc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),oy=S("$ZodCustomStringFormat",(e,t)=>{Me.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})}}),Xc=S("$ZodNumber",(e,t)=>{me.init(e,t),e._zod.pattern=yr,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}}),sy=S("$ZodNumberFormat",(e,t)=>{fg.init(e,t),Xc.init(e,t)}),Qc=S("$ZodBoolean",(e,t)=>{me.init(e,t),e._zod.pattern=og,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}}),el=S("$ZodBigInt",(e,t)=>{me.init(e,t),e._zod.pattern=ig,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}}),ay=S("$ZodBigIntFormat",(e,t)=>{hg.init(e,t),el.init(e,t)}),uy=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}}),cy=S("$ZodUndefined",(e,t)=>{me.init(e,t),e._zod.pattern=ag,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}}),ly=S("$ZodNull",(e,t)=>{me.init(e,t),e._zod.pattern=sg,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}}),dy=S("$ZodAny",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),fy=S("$ZodUnknown",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),hy=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)}),py=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}}),my=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 ah(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}const gy=S("$ZodArray",(e,t)=>{me.init(e,t);const n=yt.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=>ah(d,r,u)));else if(ah(l,r,u),a&&l.issues.length!==0&&bt(l))break}return s.length?Promise.all(s).then(()=>r):r}});function ss(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 dS=[];function yy(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:dS,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=lm(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function vy(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(bt(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(g=>ss(g,n,p,t,d,f))):ss(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 by=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=pi(()=>yy(t));_e(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)||$t(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=rr,s=t.catchall;let a;const u=yt.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 g of a.allKeys){if(p&&c.issues.length!==m){if(bt(c,m))break;m=c.issues.length}if(g==="__proto__")continue;const w=h[g],y=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[g],issues:[]},l);v instanceof Promise?f.push(v.then(k=>ss(k,c,g,d,y,b))):ss(v,c,g,d,y,b)}return s?vy(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),wy=S("$ZodObjectJIT",(e,t)=>{by.init(e,t);const n=e._zod.parse,r=pi(()=>yy(t)),i=yt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,g=new Fc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,y=(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];
|
|
@@ -61,13 +61,13 @@ ${n.join(`
|
|
|
61
61
|
newResult[${$}] = ${_}.value;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let s;const a=rr,u=!yt.jitless,l=u&&um.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?vy([],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 uh(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=>!bt(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,Qe())))}),t)}const Ls=S("$ZodUnion",(e,t)=>{me.init(e,t),_e(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),_e(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),_e(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)))}),_e(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=>Sn(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=>uh(a,r,e,i)):uh(s,r,e,i)}});function ch(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,Qe())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const _y=S("$ZodXor",(e,t)=>{Ls.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=>ch(a,r,e,i)):ch(s,r,e,i)}});function tl(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=ky(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 ky(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 Sy=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ls.init(e,t);const n=e._zod.parse;_e(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)||$t(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=bs(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=pi(()=>ky(t));e._zod.parse=(i,o)=>{const s=i.value;if(!rr(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)}}),xy=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])=>lh(n,u,c)):lh(n,o,s)}});function oi(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(an(e)&&an(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=oi(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=oi(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 lh(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=oi(t.value,n.value);if(!u.valid){if(bt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const nl=S("$ZodTuple",(e,t)=>{me.init(e,t);const n=t.items,r=yt.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=dh(n,"optin"),c=dh(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=bt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const g of p){if(d&&i.issues.length!==m){if(bt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:g,issues:[]},o);w instanceof Promise?a.push(w.then(y=>fh(y,i,h))):fh(w,i,h)}}return a.length?Promise.all(a).then(()=>hh(l,i,n,s,c)):hh(l,i,n,s,c)}});function dh(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 fh(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}function hh(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 Ey=S("$ZodRecord",(e,t)=>{me.init(e,t);const n=yt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!an(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,Qe())),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"&&yr.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,Qe())),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}}),$y=S("$ZodMap",(e,t)=>{me.init(e,t);const n=yt.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(bt(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])=>{ph(h,p,r,c,o,e,i)})):ph(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function ph(e,t,n,r,i,o,s){e.issues.length&&(ns.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,Qe()))})),t.issues.length&&(ns.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,Qe()))})),n.value.set(e.value,t.value)}const Ty=S("$ZodSet",(e,t)=>{me.init(e,t);const n=yt.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(bt(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=>mh(d,r))):mh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function mh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Cy=S("$ZodEnum",(e,t)=>{me.init(e,t);const n=es(t.entries),r=new Set(n);e._zod.values=r,_e(e,"pattern",i=>{const o=es(i.def.entries).filter(s=>ns.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>un(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}}),Ay=S("$ZodLiteral",(e,t)=>{me.init(e,t);const n=new Set(t.values);e._zod.values=n,_e(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?un(o):o?un(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}}),Iy=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}}),Ny=S("$ZodTransform",(e,t)=>{me.init(e,t),e._zod.optin="optional",yt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs(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 rn;return n.value=i,n}});function gh(e,t){return e.value=t.issues.length?void 0:t.value,e}const rl=S("$ZodOptional",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_e(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),_e(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sn(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=>gh(n,o)):gh(n,i)}return t.innerType._zod.run(n,r)}}),Ry=S("$ZodExactOptional",(e,t)=>{rl.init(e,t),_e(e,"values",n=>n.def.innerType._zod.values),_e(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),zy=S("$ZodNullable",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin),_e(e,"optout",n=>n.def.innerType._zod.optout),_e(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)}|null)$`):void 0}),_e(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)}),Ly=S("$ZodDefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",_e(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=>yh(o,t)):yh(i,t)}});function yh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Py=S("$ZodPrefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",_e(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))}),Dy=S("$ZodNonOptional",(e,t)=>{me.init(e,t),_e(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=>vh(o,e)):vh(i,e)}});function vh(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 Oy=S("$ZodSuccess",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs("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 bh(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,Qe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const My=S("$ZodCatch",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_e(e,"optout",n=>n.def.innerType._zod.optout),_e(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=>bh(n,o,t,r)):bh(n,i,t,r)}}),Fy=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)}),il=S("$ZodPipe",(e,t)=>{me.init(e,t),_e(e,"values",n=>n.def.in._zod.values),_e(e,"optin",n=>n.def.in._zod.optin),_e(e,"optout",n=>n.def.out._zod.optout),_e(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=>To(s,t.in,r)):To(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>To(o,t.out,r)):To(i,t.out,r)}});function To(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 ol=S("$ZodCodec",(e,t)=>{me.init(e,t),_e(e,"values",n=>n.def.in._zod.values),_e(e,"optin",n=>n.def.in._zod.optin),_e(e,"optout",n=>n.def.out._zod.optout),_e(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=>Co(s,t,r)):Co(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Co(s,t,r)):Co(o,t,r)}}});function Co(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=>Ao(e,o,t.out,n)):Ao(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Ao(e,o,t.in,n)):Ao(e,i,t.in,n)}}function Ao(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Uy=S("$ZodPreprocess",(e,t)=>{il.init(e,t)}),Gy=S("$ZodReadonly",(e,t)=>{me.init(e,t),_e(e,"propValues",n=>n.def.innerType._zod.propValues),_e(e,"values",n=>n.def.innerType._zod.values),_e(e,"optin",n=>n.def.innerType?._zod?.optin),_e(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(wh):wh(i)}});function wh(e){return e.memo||(e.value=Object.freeze(e.value)),e}function dS(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 rg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===yr?Lc:s)?.source}function Ru(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=Ru(r);return n&&i&&o&&o!==i?n.replace(Sn(i),()=>Sn(o)):n}if(t.options){const i=t.options.map(Ru);if(i.every(Boolean))return`^(${i.map(o=>Sn(o)).join("|")})$`}return dS(e)}const jy=S("$ZodTemplateLiteral",(e,t)=>{me.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=Ru(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(Sn(i))}else if(r===null||cm.has(typeof r))n.push(un(`${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)}),Zy=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?Au(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?Au(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 Iu(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await Iu(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 nl({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)),By=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))}),sl=S("$ZodLazy",(e,t)=>{me.init(e,t),im(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),_e(e,"pattern",n=>n.innerType?._zod?.pattern),_e(e,"propValues",n=>n.innerType?._zod?.propValues),_e(e,"optin",n=>n.innerType?._zod?.optin??void 0),_e(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Hy=S("$ZodCustom",(e,t)=>{je.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=>_h(o,n,r,e));_h(i,n,r,e)}});function _h(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(ir(i))}}class Vy extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const zu="~memo",kh=[];function qy(e){return e!==null&&typeof e=="object"}function Xa(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Wy=new WeakMap,tr=0,Yo=1,Qr=2;function ei(e,t,n){const r=Wy.get(e);if(r!==void 0)return r?Qr:tr;if(t.has(e))return Qr;t.add(e);let i=tr;const o=l=>{if(i!==Qr&&l?._zod){const d=ei(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=tr;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?Yo:p.value?._zod?ei(p.value,t,n):tr;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=bs(u);a(l?s(l):Yo),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?ei(l,t,!1):Yo);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),fS(e,i)}function fS(e,t){return t!==Yo&&Wy.set(e,t===Qr),t}function al(e){return ei(e,new Set,!0)!==tr}function hS(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Io;const No=[],pS={alloc(e,t,n){const r=Io;if(!r)return n;Io=void 0;const i={value:n,issues:null};return r.set(t.value,i),No.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"&&ul(o,i.value))throw new Vy;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=ei(e,new Set,!1);if(w===tr)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===Qr||r?n=!0:r=!0}const l=u.value;if(!qy(l))return s(u,c);let d=c[zu];d||(d={buckets:new WeakMap,backEdges:void 0},c[zu]=d);let f;i===c?f=o:(f=hS(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(...Xa(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;Io=f;const p=No.length,m=s(u,c);Io=void 0;const g=No.length>p?No.pop():void 0;return m instanceof Promise?m.then(w=>(g&&(g.issues=w.issues.length?Xa(w.issues):kh),w)):(g&&(g.issues=m.issues.length?Xa(m.issues):kh),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Ps(){return pS}function ul(e,t){const n=e[zu]?.backEdges;return n!==void 0&&qy(t)&&n.has(t)}const cl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Sh;const ll=Symbol("ZodOutput"),dl=Symbol("ZodInput");class Ky{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 Ds(){return new Ky}(Sh=globalThis).__zod_globalRegistry??(Sh.__zod_globalRegistry=Ds());const kt=globalThis.__zod_globalRegistry,vt=Symbol.for("zod.compile.invalid"),xh=Symbol.for("zod.compile.fallback");class ln extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class Te 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 mS(e,t){try{return Ms(e,{assertOnly:!0})}catch{return t}}function fl(e,t){try{const n=Ms(e),r=Os(e,n);return r._zod.bag.validator=mS(e,n),r}catch(n){if(t?.strict)throw n;return e}}function Os(e,t){if(al(e))throw new Te("a schema whose subtree contains a reference cycle");const n=Ge(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[xh]||a&&ul(a,s.value))return i(s,a);const u=t(s.value);return u!==vt?(s.value=u,s):(a&&(a[xh]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||gS(n,e,t),n}function gS(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!==vt?{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!==vt?u:o(s,a)}}}function Ms(e,t){let n=!0;try{n=al(e)}catch{}if(n)throw new Te("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Fc(["input"]),o=Ze(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[vt,...r.constants.values()],u=i.content.join(`
|
|
64
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let s;const a=rr,u=!yt.jitless,l=u&&um.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?vy([],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 uh(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=>!bt(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,Qe())))}),t)}const Ls=S("$ZodUnion",(e,t)=>{me.init(e,t),_e(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),_e(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),_e(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)))}),_e(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=>Sn(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=>uh(a,r,e,i)):uh(s,r,e,i)}});function ch(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,Qe())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const _y=S("$ZodXor",(e,t)=>{Ls.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=>ch(a,r,e,i)):ch(s,r,e,i)}});function tl(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=ky(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 ky(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 Sy=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ls.init(e,t);const n=e._zod.parse;_e(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)||$t(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=bs(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=pi(()=>ky(t));e._zod.parse=(i,o)=>{const s=i.value;if(!rr(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)}}),xy=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])=>lh(n,u,c)):lh(n,o,s)}});function oi(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(an(e)&&an(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=oi(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=oi(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 lh(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=oi(t.value,n.value);if(!u.valid){if(bt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const nl=S("$ZodTuple",(e,t)=>{me.init(e,t);const n=t.items,r=yt.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=dh(n,"optin"),c=dh(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=bt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const g of p){if(d&&i.issues.length!==m){if(bt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:g,issues:[]},o);w instanceof Promise?a.push(w.then(y=>fh(y,i,h))):fh(w,i,h)}}return a.length?Promise.all(a).then(()=>hh(l,i,n,s,c)):hh(l,i,n,s,c)}});function dh(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 fh(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}function hh(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 Ey=S("$ZodRecord",(e,t)=>{me.init(e,t);const n=yt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!an(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,Qe())),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"&&yr.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,Qe())),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}}),$y=S("$ZodMap",(e,t)=>{me.init(e,t);const n=yt.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(bt(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])=>{ph(h,p,r,c,o,e,i)})):ph(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function ph(e,t,n,r,i,o,s){e.issues.length&&(ns.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,Qe()))})),t.issues.length&&(ns.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,Qe()))})),n.value.set(e.value,t.value)}const Ty=S("$ZodSet",(e,t)=>{me.init(e,t);const n=yt.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(bt(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=>mh(d,r))):mh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function mh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Cy=S("$ZodEnum",(e,t)=>{me.init(e,t);const n=es(t.entries),r=new Set(n);e._zod.values=r,_e(e,"pattern",i=>{const o=es(i.def.entries).filter(s=>ns.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>un(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}}),Ay=S("$ZodLiteral",(e,t)=>{me.init(e,t);const n=new Set(t.values);e._zod.values=n,_e(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?un(o):o?un(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}}),Iy=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}}),Ny=S("$ZodTransform",(e,t)=>{me.init(e,t),e._zod.optin="optional",yt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs(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 rn;return n.value=i,n}});function gh(e,t){return e.value=t.issues.length?void 0:t.value,e}const rl=S("$ZodOptional",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_e(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),_e(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sn(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=>gh(n,o)):gh(n,i)}return t.innerType._zod.run(n,r)}}),Ry=S("$ZodExactOptional",(e,t)=>{rl.init(e,t),_e(e,"values",n=>n.def.innerType._zod.values),_e(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),zy=S("$ZodNullable",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin),_e(e,"optout",n=>n.def.innerType._zod.optout),_e(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)}|null)$`):void 0}),_e(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)}),Ly=S("$ZodDefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",_e(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=>yh(o,t)):yh(i,t)}});function yh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Py=S("$ZodPrefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",_e(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))}),Dy=S("$ZodNonOptional",(e,t)=>{me.init(e,t),_e(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=>vh(o,e)):vh(i,e)}});function vh(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 Oy=S("$ZodSuccess",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs("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 bh(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,Qe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const My=S("$ZodCatch",(e,t)=>{me.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_e(e,"optout",n=>n.def.innerType._zod.optout),_e(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=>bh(n,o,t,r)):bh(n,i,t,r)}}),Fy=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)}),il=S("$ZodPipe",(e,t)=>{me.init(e,t),_e(e,"values",n=>n.def.in._zod.values),_e(e,"optin",n=>n.def.in._zod.optin),_e(e,"optout",n=>n.def.out._zod.optout),_e(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=>To(s,t.in,r)):To(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>To(o,t.out,r)):To(i,t.out,r)}});function To(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 ol=S("$ZodCodec",(e,t)=>{me.init(e,t),_e(e,"values",n=>n.def.in._zod.values),_e(e,"optin",n=>n.def.in._zod.optin),_e(e,"optout",n=>n.def.out._zod.optout),_e(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=>Co(s,t,r)):Co(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Co(s,t,r)):Co(o,t,r)}}});function Co(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=>Ao(e,o,t.out,n)):Ao(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Ao(e,o,t.in,n)):Ao(e,i,t.in,n)}}function Ao(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Uy=S("$ZodPreprocess",(e,t)=>{il.init(e,t)}),Gy=S("$ZodReadonly",(e,t)=>{me.init(e,t),_e(e,"propValues",n=>n.def.innerType._zod.propValues),_e(e,"values",n=>n.def.innerType._zod.values),_e(e,"optin",n=>n.def.innerType?._zod?.optin),_e(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(wh):wh(i)}});function wh(e){return e.memo||(e.value=Object.freeze(e.value)),e}function fS(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 rg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===yr?Lc:s)?.source}function Ru(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=Ru(r);return n&&i&&o&&o!==i?n.replace(Sn(i),()=>Sn(o)):n}if(t.options){const i=t.options.map(Ru);if(i.every(Boolean))return`^(${i.map(o=>Sn(o)).join("|")})$`}return fS(e)}const jy=S("$ZodTemplateLiteral",(e,t)=>{me.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=Ru(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(Sn(i))}else if(r===null||cm.has(typeof r))n.push(un(`${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)}),Zy=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?Au(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?Au(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 Iu(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await Iu(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 nl({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)),By=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))}),sl=S("$ZodLazy",(e,t)=>{me.init(e,t),im(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),_e(e,"pattern",n=>n.innerType?._zod?.pattern),_e(e,"propValues",n=>n.innerType?._zod?.propValues),_e(e,"optin",n=>n.innerType?._zod?.optin??void 0),_e(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Hy=S("$ZodCustom",(e,t)=>{je.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=>_h(o,n,r,e));_h(i,n,r,e)}});function _h(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(ir(i))}}class Vy extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const zu="~memo",kh=[];function qy(e){return e!==null&&typeof e=="object"}function Xa(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Wy=new WeakMap,tr=0,Yo=1,Qr=2;function ei(e,t,n){const r=Wy.get(e);if(r!==void 0)return r?Qr:tr;if(t.has(e))return Qr;t.add(e);let i=tr;const o=l=>{if(i!==Qr&&l?._zod){const d=ei(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=tr;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?Yo:p.value?._zod?ei(p.value,t,n):tr;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=bs(u);a(l?s(l):Yo),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?ei(l,t,!1):Yo);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),hS(e,i)}function hS(e,t){return t!==Yo&&Wy.set(e,t===Qr),t}function al(e){return ei(e,new Set,!0)!==tr}function pS(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Io;const No=[],mS={alloc(e,t,n){const r=Io;if(!r)return n;Io=void 0;const i={value:n,issues:null};return r.set(t.value,i),No.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"&&ul(o,i.value))throw new Vy;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=ei(e,new Set,!1);if(w===tr)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===Qr||r?n=!0:r=!0}const l=u.value;if(!qy(l))return s(u,c);let d=c[zu];d||(d={buckets:new WeakMap,backEdges:void 0},c[zu]=d);let f;i===c?f=o:(f=pS(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(...Xa(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;Io=f;const p=No.length,m=s(u,c);Io=void 0;const g=No.length>p?No.pop():void 0;return m instanceof Promise?m.then(w=>(g&&(g.issues=w.issues.length?Xa(w.issues):kh),w)):(g&&(g.issues=m.issues.length?Xa(m.issues):kh),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Ps(){return mS}function ul(e,t){const n=e[zu]?.backEdges;return n!==void 0&&qy(t)&&n.has(t)}const cl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Sh;const ll=Symbol("ZodOutput"),dl=Symbol("ZodInput");class Ky{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 Ds(){return new Ky}(Sh=globalThis).__zod_globalRegistry??(Sh.__zod_globalRegistry=Ds());const kt=globalThis.__zod_globalRegistry,vt=Symbol.for("zod.compile.invalid"),xh=Symbol.for("zod.compile.fallback");class ln extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class Te 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 gS(e,t){try{return Ms(e,{assertOnly:!0})}catch{return t}}function fl(e,t){try{const n=Ms(e),r=Os(e,n);return r._zod.bag.validator=gS(e,n),r}catch(n){if(t?.strict)throw n;return e}}function Os(e,t){if(al(e))throw new Te("a schema whose subtree contains a reference cycle");const n=Ge(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[xh]||a&&ul(a,s.value))return i(s,a);const u=t(s.value);return u!==vt?(s.value=u,s):(a&&(a[xh]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||yS(n,e,t),n}function yS(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!==vt?{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!==vt?u:o(s,a)}}}function Ms(e,t){let n=!0;try{n=al(e)}catch{}if(n)throw new Te("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Fc(["input"]),o=Ze(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[vt,...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 Te(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function de(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 jn(e,t){return e.definite=!1,de(e,t)}function re(e){return`v${e.varCounter++}`}function yS(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return vt;const r=n;return r.issues.length===0?r.value:vt}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 Ze(e,t,n,r,i)}catch(c){if(!(c instanceof Te)||!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,vS(e,t,n,r)}}function vS(e,t,n,r){t.definite=!1;const i=de(t,n),o=de(t,yS),s=re(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const bS=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function wS(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&&!bS.has(a.check))throw new Te('check with a custom "when" condition');switch(a.check){case"greater_than":_S(e,t,a,o);break;case"less_than":kS(e,t,a,o);break;case"multiple_of":SS(e,t,a,o);break;case"number_format":Yy(e,a,o);break;case"min_length":{const u=Pn(a.minimum,"min_length"),c=Qa(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Pn(a.maximum,"max_length"),c=Qa(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Pn(a.length,"length_equals"),c=Qa(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 < ${Pn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Pn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Pn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Xy(e,t,a,o);break;case"custom":o=AS(e,t,s,o);break;case"bigint_format":xS(e,a,o);break;case"mime_type":ES(e,t,a,o);break;case"property":TS(e,t,a,o);break;case"properties":$S(e,t,a,o);break;case"overwrite":{const u=re(t);CS(e,t,s,o,u),o=u;break}default:throw new Te(`check type ${a.check}`)}}return o}function Qa(e,t,n,r){const i=de(t,gi),o=re(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Pn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Te(`${t} bound of type ${typeof e}`);return`${e}`}function Jy(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Te("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Te("comparison check with Invalid Date bound");return de(e,t)}throw new Te(`comparison check bound of type ${typeof t}`)}function _S(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${Jy(t,n.value)}) return INVALID;`)}function kS(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${Jy(t,n.value)}) return INVALID;`)}function SS(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new Te("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=de(t,dc);e.write(`if (${i}(${r}, ${Pn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Yy(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 Te(`number format ${r}`)}}function xS(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 Te(`bigint format ${r}`)}}function ES(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=de(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function $S(e,t,n,r){if(n.when)throw new Te('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"?de(t,o):St(o),a=re(t);e.write(`const ${a} = ${r}[${s}];`),dt(e,t,i[o],a,!1)}}function TS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Ze(e,t,n.schema,i)}function CS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new Te("overwrite check without a transform function");if(Zn(o))throw new ln("z.compile: async overwrite transforms are not supported");const s=de(t,o);e.write(`const ${i} = ${s}(${r});`)}function Lu(){throw new rn}function hl(e){this.issues.push(e)}function AS(e,t,n,r){const i=n._zod.def;if(i.fn){if(Zn(i.fn))throw new ln("z.compile: async .refine() predicates are not supported");const o=jn(t,i.fn),s=de(t,Lu),a=re(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(Zn(n._zod.check))throw new ln("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=jn(t,c=>{const l={value:c,issues:[],addIssue:hl};return o(l)instanceof Promise&&Lu(),l.issues.length===0?l.value:vt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new Te("custom check without a predicate or check function")}const IS=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 Xy(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=de(t,Rs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=de(t,Wc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=de(t,Yc),l=de(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=de(t,Ns);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=de(t,Vc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=de(t,Kc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=de(t,Jc);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=de(t,Zc),l=de(t,n),d=re(t),f=re(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=de(t,Bc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=de(t,Hc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=re(t),p=s.normalize?`${f}.href`:`${de(t,os)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Zn(a))throw new Te(`async string format ${o}`);const c=de(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(IS.has(o)&&n.pattern){const c=de(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 Te("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(${St(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${St(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${St(c)}) return INVALID;`);break}default:throw new Te(`string format ${u}`)}return r}function Ze(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new Te(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=NS(e,t,n,r,a);break;case"number":u=RS(e,n,r);break;case"boolean":u=zS(e,r);break;case"bigint":u=LS(e,n,r);break;case"symbol":u=PS(e,r);break;case"undefined":u=DS(e,r);break;case"null":u=OS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=MS(e,r);break;case"nan":u=FS(e,r);break;case"date":u=US(e,r);break;case"object":u=GS(e,t,n,r,a);break;case"optional":u=jS(e,t,n,r,a);break;case"nullable":u=HS(e,t,n,r,a);break;case"array":u=VS(e,t,n,r,a);break;case"literal":u=qS(e,t,n,r);break;case"enum":u=WS(e,t,n,r);break;case"readonly":{const c=$h(e,t,n,r),l=re(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":$h(e,t,n,r),u="true";break;case"default":case"prefault":u=KS(e,t,n,r);break;case"nonoptional":u=JS(e,t,n,r);break;case"tuple":u=YS(e,t,n,r);break;case"union":u=XS(e,t,n,r);break;case"intersection":u=t0(e,t,n,r);break;case"record":u=n0(e,t,n,r);break;case"map":u=i0(e,t,n,r);break;case"set":u=o0(e,t,n,r);break;case"file":u=s0(e,r);break;case"template_literal":u=a0(e,t,n,r);break;case"lazy":u=u0(e,t,n,r);break;case"pipe":u=c0(e,t,n,r);break;case"custom":u=l0(e,t,n,r);break;case"transform":u=h0(e,t,n,r);break;case"catch":u=f0(e,t,n,r);break;default:throw new Te(`schema type ${s}`)}return u===null?null:wS(e,t,n,u)}function NS(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:Xy(e,t,o,r,i)}function RS(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&&Yy(e,{format:r.format},n),n}function zS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function LS(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 PS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function DS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function OS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function MS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function FS(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function US(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function GS(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=y=>typeof y=="symbol"?de(t,y):St(y),d=y=>typeof y=="symbol"?`[${l(y)}]`:St(y),f=s;if(a.includes("__proto__"))throw new Te('object shape key "__proto__"');const h=new Map;for(const y of c){const b=f[y],v=l(y),k=re(t);if(e.write(`const ${k} = ${r}[${v}];`),b._zod.optin!==void 0){const _=re(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(y,_)}else{BS(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=dt(e,t,b,k,i);_!==null&&h.set(y,_)}}const p=o.catchall;let m="none";if(p){const y=p._zod.def.type;if(y==="never"){const b=a.map(v=>`k !== ${St(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(y==="unknown"||y==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const g=re(t),w=c.some(y=>Eh(f[y])||Pu(f[y]));if(!i){if(m==="schema"){const y=a.length>0?de(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`);const v=re(t);b.write(`const ${v} = ${r}[k];`),dt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${g} = {};`);for(const y of c){const b=l(y),v=h.get(y);Pu(f[y])?e.write(`if (${b} in ${r}) ${g}[${b}] = ${v};`):Eh(f[y])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${g}[${b}] = ${v};`):e.write(`${g}[${b}] = ${v};`)}}else{const y=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${g} = { ${y} };`)}if(m!=="none"){const y=a.length>0?de(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`),m==="passthrough")b.write(`${g}[k] = ${r}[k];`);else{const v=re(t);b.write(`const ${v} = ${r}[k];`);const k=dt(b,t,p,v);b.write(`${g}[k] = ${k};`)}}),e.write("}")}return g}function jS(e,t,n,r,i=!0){const o=n._zod.def;if(ZS(n))return Ze(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=re(t),u=re(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Ze(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=Ze(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?re(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Ze(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function ZS(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function BS(e){return e._zod.optin===void 0&&Dn(e)}function Dn(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?Dn(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?Dn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Dn):!0;case"intersection":return!t.left||!t.right?!0:Dn(t.left)&&Dn(t.right);case"pipe":return t.in?Dn(t.in):!0;default:return!0}}function Pu(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Eh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Xn(e)}function Xn(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?Xn(t.innerType):!0;case"union":return t.options?t.options.some(Xn):!0;case"intersection":return!t.left||!t.right||Xn(t.left)||Xn(t.right);case"pipe":return t.out?Xn(t.out):!0;default:return!0}}function HS(e,t,n,r,i=!0){const o=n._zod.def,s=i?re(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Ze(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function VS(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?re(t):null,a=re(t),u=re(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 qS(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=de(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=de(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${St(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 Te(`literal type ${typeof s}`);return r}function WS(e,t,n,r){const i=n._zod.values;if(!i)throw new Te("enum schema without enumerated values");const o=de(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function $h(e,t,n,r){const i=n._zod.def;return Ze(e,t,i.innerType,r)}function KS(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 Ze(e,t,i.innerType,r);const u=de(t,s),c=re(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Ze(e,t,i.innerType,c)}const a=re(t);if(s){const u=de(t,s),c=de(t,mi);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=Ze(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=Ze(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function JS(e,t,n,r){const i=n._zod.def,o=Ze(e,t,i.innerType,r),s=re(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function YS(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=Th(o,"optin"),u=Th(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=re(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=re(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(Pu(d)){h.write(`${c}.length = ${l};`);return}const p=re(t),m=re(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(g=>{const w=dt(g,t,d,p);g.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=re(t);e.write(`const ${f} = ${r}[${l}];`);const h=dt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=re(t),d=re(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 Th(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 XS(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return QS(e,t,i,r);if(i.inclusive===!1)throw new Te("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Ze(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=de(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=re(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=Ze(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function QS(e,t,n,r){if(n.unionFallback)throw new Te("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=re(t),o=re(t);e.write(`const ${i} = ${r}?.[${St(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 Te("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new Te(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>e0(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Ze(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function e0(e,t,n){if(typeof n=="string")return`${t} === ${St(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=de(e,n);return`${t} === ${r}`}throw new Te(`literal discriminator value ${String(n)}`)}function t0(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=de(t,oi),u=re(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function n0(e,t,n,r){const i=n._zod.def,o=de(t,an);e.write(`if (!${o}(${r})) return INVALID;`);const s=re(t),a=re(t),u=re(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 Te(`record key value ${String(m)}`);const g=typeof m=="number"?m.toString():m;if(g==="__proto__")throw new Te('record key "__proto__"');h.push(g);const w=de(t,m),y=Ze(e,t,i.keyType,w),b=re(t);e.write(`const ${b} = ${r}[${r0(t,g)}];`);const v=dt(e,t,i.valueType,b);e.write(`${s}[${y}] = ${v};`)}const p=de(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=Ms(i.keyType);p.definite===!1&&(t.definite=!1);const m=de(t,p),g=de(t,yr),w=re(t);return Ch(e,t,r,a,y=>{y.write(`let ${w} = ${m}(${a});`),y.write(`if (${w} === INVALID && typeof ${a} === "string" && ${g}.test(${a})) ${w} = ${m}(Number(${a}));`),h?y.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):y.write(`if (${w} === INVALID) return INVALID;`),y.write(`if (${w} === "__proto__") continue;`);const b=re(t);y.write(`const ${b} = ${r}[${a}];`);const v=dt(y,t,i.valueType,b);y.write(`${s}[${w}] = ${v};`)}),s}return Ch(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 Ch(e,t,n,r,i,o){const s=de(t,Object.prototype.propertyIsEnumerable),a=re(t),u=re(t),c=re(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 r0(e,t){return typeof t=="string"?St(t):de(e,t)}function i0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=re(t),s=re(t),a=re(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Ze(u,t,i.keyType,s),l=Ze(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function o0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=re(t),s=re(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Ze(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function s0(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function a0(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=de(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function u0(e,t,n,r){const i=n._zod.def,o=jn(t,i.getter),s=de(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=re(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function c0(e,t,n,r){const i=n._zod.def,o=Ze(e,t,i.in,r);if(i.transform){if(Zn(i.transform))throw new ln("z.compile: async transforms in pipes are not supported");const s=i.transform,u=jn(t,l=>{const d={value:l,issues:[],addIssue:hl},f=s(l,d);return f instanceof Promise?vt:d.issues.length===0?f:vt}),c=re(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Ze(e,t,i.out,c)}else return Ze(e,t,i.out,o)}function Zn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function l0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Zn(i.fn))throw new ln("z.compile: async custom predicates are not supported");const o=jn(t,i.fn),s=de(t,Lu),a=re(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new Te("custom schema without a predicate function");return r}function d0(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return vt;const i=r;return i.issues.length===0?i.value:t()}function f0(e,t,n,r){const i=n._zod.def;if(!i.catchValue[gc])throw new Te("catch with a callback (only a constant catch value compiles)",!1);const o=re(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=dt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=de(t,i.innerType),a=jn(t,i.catchValue),u=de(t,d0);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 h0(e,t,n,r){const i=n._zod.def;if(i.transform){if(Zn(i.transform))throw new ln("z.compile: async transforms are not supported");const o=i.transform,a=jn(t,c=>{const l={value:c,issues:[],addIssue:hl},d=o(c,l);return d instanceof Promise?vt:l.issues.length===0?d:vt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Fs(e){return e.checks&&(e.checks=[...e.checks]),e}function Qy(e,t){return new e(Fs({type:"string",...N(t)}))}function ev(e,t){return new e(Fs({type:"string",coerce:!0,...N(t)}))}function pl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function ml(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function gl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function yl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function Us(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function wl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function _l(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function kl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function Sl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function xl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function El(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function $l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function Tl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function Cl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function tv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}function Al(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function Il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function Nl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function Rl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function zl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function nv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}function rv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...N(t)})}function Ll(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}const Pl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Dl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Ol(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Ml(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Fl(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function iv(e,t){return new e(Fs({type:"number",checks:[],...N(t)}))}function ov(e,t){return new e(Fs({type:"number",coerce:!0,checks:[],...N(t)}))}function sv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function av(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}function uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}function cv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}function lv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}function dv(e,t){return new e({type:"boolean",...N(t)})}function fv(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}function hv(e,t){return new e({type:"bigint",...N(t)})}function pv(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}function mv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}function gv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}function yv(e,t){return new e({type:"symbol",...N(t)})}function vv(e,t){return new e({type:"undefined",...N(t)})}function bv(e,t){return new e({type:"null",...N(t)})}function wv(e){return new e({type:"any"})}function _v(e){return new e({type:"unknown"})}function kv(e,t){return new e({type:"never",...N(t)})}function Sv(e,t){return new e({type:"void",...N(t)})}function xv(e,t){return new e({type:"date",...N(t)})}function Ev(e,t){return new e({type:"date",coerce:!0,...N(t)})}function $v(e,t){return new e({type:"nan",...N(t)})}function dn(e,t){return new Oc({check:"less_than",...N(t),value:e,inclusive:!1})}function xt(e,t){return new Oc({check:"less_than",...N(t),value:e,inclusive:!0})}function fn(e,t){return new Mc({check:"greater_than",...N(t),value:e,inclusive:!1})}function Et(e,t){return new Mc({check:"greater_than",...N(t),value:e,inclusive:!0})}function Gs(e){return fn(0,e)}function js(e){return dn(0,e)}function Zs(e){return xt(0,e)}function Bs(e){return Et(0,e)}function Bn(e,t){return new dg({check:"multiple_of",...N(t),value:e})}function Wn(e,t){return new pg({check:"max_size",...N(t),maximum:e})}function hn(e,t){return new mg({check:"min_size",...N(t),minimum:e})}function vr(e,t){return new gg({check:"size_equals",...N(t),size:e})}function br(e,t){return new yg({check:"max_length",...N(t),maximum:e})}function $n(e,t){return new vg({check:"min_length",...N(t),minimum:e})}function wr(e,t){return new bg({check:"length_equals",...N(t),length:e})}function $i(e,t){return new wg({check:"string_format",format:"regex",...N(t),pattern:e})}function Ti(e){return new _g({check:"string_format",format:"lowercase",...N(e)})}function Ci(e){return new kg({check:"string_format",format:"uppercase",...N(e)})}function Ai(e,t){return new Sg({check:"string_format",format:"includes",...N(t),includes:e})}function Ii(e,t){return new xg({check:"string_format",format:"starts_with",...N(t),prefix:e})}function Ni(e,t){return new Eg({check:"string_format",format:"ends_with",...N(t),suffix:e})}function Hs(e,t,n){return new $g({check:"property",property:e,schema:t,...N(n)})}function Ri(e,t){return new Tg({check:"properties",shape:e,...N(t)})}function zi(e,t){return new Cg({check:"mime_type",mime:e,...N(t)})}function en(e){return new Ag({check:"overwrite",tx:e})}function Li(e){return en(t=>t.normalize(e))}function Pi(){return en(e=>e.trim())}function Di(){return en(e=>e.toLowerCase())}function Oi(){return en(e=>e.toUpperCase())}function Mi(){return en(e=>am(e))}function Tv(e,t,n){return new e({type:"array",element:t,...N(n)})}function p0(e,t,n){return new e({type:"union",options:t,...N(n)})}function m0(e,t,n){return new e({type:"union",options:t,inclusive:!1,...N(n)})}function g0(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...N(r)})}function y0(e,t,n){return new e({type:"intersection",left:t,right:n})}function v0(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 b0(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...N(r)})}function w0(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...N(r)})}function _0(e,t,n){return new e({type:"set",valueType:t,...N(n)})}function k0(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 S0(e,t,n){return new e({type:"enum",entries:t,...N(n)})}function x0(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(n)})}function Cv(e,t){return new e({type:"file",...N(t)})}function E0(e,t){return new e({type:"transform",transform:t})}function $0(e,t){return new e({type:"optional",innerType:t})}function T0(e,t){return new e({type:"nullable",innerType:t})}function C0(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():mi(n)}})}function A0(e,t,n){return new e({type:"nonoptional",innerType:t,...N(n)})}function I0(e,t){return new e({type:"success",innerType:t})}function N0(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:yc(n)})}function R0(e,t,n){return new e({type:"pipe",in:t,out:n})}function z0(e,t){return new e({type:"readonly",innerType:t})}function L0(e,t,n){return new e({type:"template_literal",parts:t,...N(n)})}function P0(e,t){return new e({type:"lazy",getter:t})}function D0(e,t){return new e({type:"promise",innerType:t})}function Av(e,t,n){const r=N(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function Iv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...N(n)})}function Nv(e,t){const n=Rv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(ir(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(ir(o))}},e(r.value,r)),t);return n}function Rv(e,t){const n=new je({check:"custom",...N(t)});return n._zod.check=e,n}function zv(e){const t=new je({check:"describe"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function Lv(e){const t=new je({check:"meta"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,...e})}],t._zod.check=()=>{},t}function Pv(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??ol,u=e.Boolean??Qc,c=e.String??Ei,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 _r(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 ti(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$t(e,r,n[r]);return e}function sr(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??kt,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 tt(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&&ti(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 Ah(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ar(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}/${Ah(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+Ah(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 Te(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function de(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 jn(e,t){return e.definite=!1,de(e,t)}function re(e){return`v${e.varCounter++}`}function vS(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return vt;const r=n;return r.issues.length===0?r.value:vt}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 Ze(e,t,n,r,i)}catch(c){if(!(c instanceof Te)||!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,bS(e,t,n,r)}}function bS(e,t,n,r){t.definite=!1;const i=de(t,n),o=de(t,vS),s=re(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const wS=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function _S(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&&!wS.has(a.check))throw new Te('check with a custom "when" condition');switch(a.check){case"greater_than":kS(e,t,a,o);break;case"less_than":SS(e,t,a,o);break;case"multiple_of":xS(e,t,a,o);break;case"number_format":Yy(e,a,o);break;case"min_length":{const u=Pn(a.minimum,"min_length"),c=Qa(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Pn(a.maximum,"max_length"),c=Qa(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Pn(a.length,"length_equals"),c=Qa(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 < ${Pn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Pn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Pn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Xy(e,t,a,o);break;case"custom":o=IS(e,t,s,o);break;case"bigint_format":ES(e,a,o);break;case"mime_type":$S(e,t,a,o);break;case"property":CS(e,t,a,o);break;case"properties":TS(e,t,a,o);break;case"overwrite":{const u=re(t);AS(e,t,s,o,u),o=u;break}default:throw new Te(`check type ${a.check}`)}}return o}function Qa(e,t,n,r){const i=de(t,gi),o=re(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Pn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Te(`${t} bound of type ${typeof e}`);return`${e}`}function Jy(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Te("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Te("comparison check with Invalid Date bound");return de(e,t)}throw new Te(`comparison check bound of type ${typeof t}`)}function kS(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${Jy(t,n.value)}) return INVALID;`)}function SS(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${Jy(t,n.value)}) return INVALID;`)}function xS(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new Te("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=de(t,dc);e.write(`if (${i}(${r}, ${Pn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Yy(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 Te(`number format ${r}`)}}function ES(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 Te(`bigint format ${r}`)}}function $S(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=de(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function TS(e,t,n,r){if(n.when)throw new Te('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"?de(t,o):St(o),a=re(t);e.write(`const ${a} = ${r}[${s}];`),dt(e,t,i[o],a,!1)}}function CS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Ze(e,t,n.schema,i)}function AS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new Te("overwrite check without a transform function");if(Zn(o))throw new ln("z.compile: async overwrite transforms are not supported");const s=de(t,o);e.write(`const ${i} = ${s}(${r});`)}function Lu(){throw new rn}function hl(e){this.issues.push(e)}function IS(e,t,n,r){const i=n._zod.def;if(i.fn){if(Zn(i.fn))throw new ln("z.compile: async .refine() predicates are not supported");const o=jn(t,i.fn),s=de(t,Lu),a=re(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(Zn(n._zod.check))throw new ln("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=jn(t,c=>{const l={value:c,issues:[],addIssue:hl};return o(l)instanceof Promise&&Lu(),l.issues.length===0?l.value:vt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new Te("custom check without a predicate or check function")}const NS=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 Xy(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=de(t,Rs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=de(t,Wc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=de(t,Yc),l=de(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=de(t,Ns);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=de(t,Vc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=de(t,Kc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=de(t,Jc);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=de(t,Zc),l=de(t,n),d=re(t),f=re(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=de(t,Bc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=de(t,Hc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=re(t),p=s.normalize?`${f}.href`:`${de(t,os)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Zn(a))throw new Te(`async string format ${o}`);const c=de(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(NS.has(o)&&n.pattern){const c=de(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 Te("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(${St(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${St(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${St(c)}) return INVALID;`);break}default:throw new Te(`string format ${u}`)}return r}function Ze(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new Te(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=RS(e,t,n,r,a);break;case"number":u=zS(e,n,r);break;case"boolean":u=LS(e,r);break;case"bigint":u=PS(e,n,r);break;case"symbol":u=DS(e,r);break;case"undefined":u=OS(e,r);break;case"null":u=MS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=FS(e,r);break;case"nan":u=US(e,r);break;case"date":u=GS(e,r);break;case"object":u=jS(e,t,n,r,a);break;case"optional":u=ZS(e,t,n,r,a);break;case"nullable":u=VS(e,t,n,r,a);break;case"array":u=qS(e,t,n,r,a);break;case"literal":u=WS(e,t,n,r);break;case"enum":u=KS(e,t,n,r);break;case"readonly":{const c=$h(e,t,n,r),l=re(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":$h(e,t,n,r),u="true";break;case"default":case"prefault":u=JS(e,t,n,r);break;case"nonoptional":u=YS(e,t,n,r);break;case"tuple":u=XS(e,t,n,r);break;case"union":u=QS(e,t,n,r);break;case"intersection":u=n0(e,t,n,r);break;case"record":u=r0(e,t,n,r);break;case"map":u=o0(e,t,n,r);break;case"set":u=s0(e,t,n,r);break;case"file":u=a0(e,r);break;case"template_literal":u=u0(e,t,n,r);break;case"lazy":u=c0(e,t,n,r);break;case"pipe":u=l0(e,t,n,r);break;case"custom":u=d0(e,t,n,r);break;case"transform":u=p0(e,t,n,r);break;case"catch":u=h0(e,t,n,r);break;default:throw new Te(`schema type ${s}`)}return u===null?null:_S(e,t,n,u)}function RS(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:Xy(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&&Yy(e,{format:r.format},n),n}function LS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function PS(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 DS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function OS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function MS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function FS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function US(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function GS(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function jS(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=y=>typeof y=="symbol"?de(t,y):St(y),d=y=>typeof y=="symbol"?`[${l(y)}]`:St(y),f=s;if(a.includes("__proto__"))throw new Te('object shape key "__proto__"');const h=new Map;for(const y of c){const b=f[y],v=l(y),k=re(t);if(e.write(`const ${k} = ${r}[${v}];`),b._zod.optin!==void 0){const _=re(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(y,_)}else{HS(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=dt(e,t,b,k,i);_!==null&&h.set(y,_)}}const p=o.catchall;let m="none";if(p){const y=p._zod.def.type;if(y==="never"){const b=a.map(v=>`k !== ${St(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(y==="unknown"||y==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const g=re(t),w=c.some(y=>Eh(f[y])||Pu(f[y]));if(!i){if(m==="schema"){const y=a.length>0?de(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`);const v=re(t);b.write(`const ${v} = ${r}[k];`),dt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${g} = {};`);for(const y of c){const b=l(y),v=h.get(y);Pu(f[y])?e.write(`if (${b} in ${r}) ${g}[${b}] = ${v};`):Eh(f[y])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${g}[${b}] = ${v};`):e.write(`${g}[${b}] = ${v};`)}}else{const y=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${g} = { ${y} };`)}if(m!=="none"){const y=a.length>0?de(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`),m==="passthrough")b.write(`${g}[k] = ${r}[k];`);else{const v=re(t);b.write(`const ${v} = ${r}[k];`);const k=dt(b,t,p,v);b.write(`${g}[k] = ${k};`)}}),e.write("}")}return g}function ZS(e,t,n,r,i=!0){const o=n._zod.def;if(BS(n))return Ze(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=re(t),u=re(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Ze(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=Ze(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?re(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Ze(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function BS(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function HS(e){return e._zod.optin===void 0&&Dn(e)}function Dn(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?Dn(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?Dn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Dn):!0;case"intersection":return!t.left||!t.right?!0:Dn(t.left)&&Dn(t.right);case"pipe":return t.in?Dn(t.in):!0;default:return!0}}function Pu(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Eh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Xn(e)}function Xn(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?Xn(t.innerType):!0;case"union":return t.options?t.options.some(Xn):!0;case"intersection":return!t.left||!t.right||Xn(t.left)||Xn(t.right);case"pipe":return t.out?Xn(t.out):!0;default:return!0}}function VS(e,t,n,r,i=!0){const o=n._zod.def,s=i?re(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Ze(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function qS(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?re(t):null,a=re(t),u=re(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 WS(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=de(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=de(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${St(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 Te(`literal type ${typeof s}`);return r}function KS(e,t,n,r){const i=n._zod.values;if(!i)throw new Te("enum schema without enumerated values");const o=de(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function $h(e,t,n,r){const i=n._zod.def;return Ze(e,t,i.innerType,r)}function JS(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 Ze(e,t,i.innerType,r);const u=de(t,s),c=re(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Ze(e,t,i.innerType,c)}const a=re(t);if(s){const u=de(t,s),c=de(t,mi);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=Ze(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=Ze(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function YS(e,t,n,r){const i=n._zod.def,o=Ze(e,t,i.innerType,r),s=re(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function XS(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=Th(o,"optin"),u=Th(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=re(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=re(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(Pu(d)){h.write(`${c}.length = ${l};`);return}const p=re(t),m=re(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(g=>{const w=dt(g,t,d,p);g.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=re(t);e.write(`const ${f} = ${r}[${l}];`);const h=dt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=re(t),d=re(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 Th(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 QS(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return e0(e,t,i,r);if(i.inclusive===!1)throw new Te("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Ze(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=de(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=re(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=Ze(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function e0(e,t,n,r){if(n.unionFallback)throw new Te("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=re(t),o=re(t);e.write(`const ${i} = ${r}?.[${St(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 Te("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new Te(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>t0(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Ze(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function t0(e,t,n){if(typeof n=="string")return`${t} === ${St(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=de(e,n);return`${t} === ${r}`}throw new Te(`literal discriminator value ${String(n)}`)}function n0(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=de(t,oi),u=re(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function r0(e,t,n,r){const i=n._zod.def,o=de(t,an);e.write(`if (!${o}(${r})) return INVALID;`);const s=re(t),a=re(t),u=re(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 Te(`record key value ${String(m)}`);const g=typeof m=="number"?m.toString():m;if(g==="__proto__")throw new Te('record key "__proto__"');h.push(g);const w=de(t,m),y=Ze(e,t,i.keyType,w),b=re(t);e.write(`const ${b} = ${r}[${i0(t,g)}];`);const v=dt(e,t,i.valueType,b);e.write(`${s}[${y}] = ${v};`)}const p=de(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=Ms(i.keyType);p.definite===!1&&(t.definite=!1);const m=de(t,p),g=de(t,yr),w=re(t);return Ch(e,t,r,a,y=>{y.write(`let ${w} = ${m}(${a});`),y.write(`if (${w} === INVALID && typeof ${a} === "string" && ${g}.test(${a})) ${w} = ${m}(Number(${a}));`),h?y.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):y.write(`if (${w} === INVALID) return INVALID;`),y.write(`if (${w} === "__proto__") continue;`);const b=re(t);y.write(`const ${b} = ${r}[${a}];`);const v=dt(y,t,i.valueType,b);y.write(`${s}[${w}] = ${v};`)}),s}return Ch(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 Ch(e,t,n,r,i,o){const s=de(t,Object.prototype.propertyIsEnumerable),a=re(t),u=re(t),c=re(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 i0(e,t){return typeof t=="string"?St(t):de(e,t)}function o0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=re(t),s=re(t),a=re(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Ze(u,t,i.keyType,s),l=Ze(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function s0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=re(t),s=re(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Ze(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function a0(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function u0(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=de(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function c0(e,t,n,r){const i=n._zod.def,o=jn(t,i.getter),s=de(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=re(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function l0(e,t,n,r){const i=n._zod.def,o=Ze(e,t,i.in,r);if(i.transform){if(Zn(i.transform))throw new ln("z.compile: async transforms in pipes are not supported");const s=i.transform,u=jn(t,l=>{const d={value:l,issues:[],addIssue:hl},f=s(l,d);return f instanceof Promise?vt:d.issues.length===0?f:vt}),c=re(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Ze(e,t,i.out,c)}else return Ze(e,t,i.out,o)}function Zn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function d0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Zn(i.fn))throw new ln("z.compile: async custom predicates are not supported");const o=jn(t,i.fn),s=de(t,Lu),a=re(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new Te("custom schema without a predicate function");return r}function f0(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return vt;const i=r;return i.issues.length===0?i.value:t()}function h0(e,t,n,r){const i=n._zod.def;if(!i.catchValue[gc])throw new Te("catch with a callback (only a constant catch value compiles)",!1);const o=re(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=dt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=de(t,i.innerType),a=jn(t,i.catchValue),u=de(t,f0);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 p0(e,t,n,r){const i=n._zod.def;if(i.transform){if(Zn(i.transform))throw new ln("z.compile: async transforms are not supported");const o=i.transform,a=jn(t,c=>{const l={value:c,issues:[],addIssue:hl},d=o(c,l);return d instanceof Promise?vt:l.issues.length===0?d:vt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Fs(e){return e.checks&&(e.checks=[...e.checks]),e}function Qy(e,t){return new e(Fs({type:"string",...N(t)}))}function ev(e,t){return new e(Fs({type:"string",coerce:!0,...N(t)}))}function pl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function ml(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function gl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function yl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function Us(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function wl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function _l(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function kl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function Sl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function xl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function El(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function $l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function Tl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function Cl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function tv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}function Al(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function Il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function Nl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function Rl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function zl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function nv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}function rv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...N(t)})}function Ll(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}const Pl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Dl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Ol(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Ml(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Fl(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function iv(e,t){return new e(Fs({type:"number",checks:[],...N(t)}))}function ov(e,t){return new e(Fs({type:"number",coerce:!0,checks:[],...N(t)}))}function sv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function av(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}function uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}function cv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}function lv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}function dv(e,t){return new e({type:"boolean",...N(t)})}function fv(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}function hv(e,t){return new e({type:"bigint",...N(t)})}function pv(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}function mv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}function gv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}function yv(e,t){return new e({type:"symbol",...N(t)})}function vv(e,t){return new e({type:"undefined",...N(t)})}function bv(e,t){return new e({type:"null",...N(t)})}function wv(e){return new e({type:"any"})}function _v(e){return new e({type:"unknown"})}function kv(e,t){return new e({type:"never",...N(t)})}function Sv(e,t){return new e({type:"void",...N(t)})}function xv(e,t){return new e({type:"date",...N(t)})}function Ev(e,t){return new e({type:"date",coerce:!0,...N(t)})}function $v(e,t){return new e({type:"nan",...N(t)})}function dn(e,t){return new Oc({check:"less_than",...N(t),value:e,inclusive:!1})}function xt(e,t){return new Oc({check:"less_than",...N(t),value:e,inclusive:!0})}function fn(e,t){return new Mc({check:"greater_than",...N(t),value:e,inclusive:!1})}function Et(e,t){return new Mc({check:"greater_than",...N(t),value:e,inclusive:!0})}function Gs(e){return fn(0,e)}function js(e){return dn(0,e)}function Zs(e){return xt(0,e)}function Bs(e){return Et(0,e)}function Bn(e,t){return new dg({check:"multiple_of",...N(t),value:e})}function Wn(e,t){return new pg({check:"max_size",...N(t),maximum:e})}function hn(e,t){return new mg({check:"min_size",...N(t),minimum:e})}function vr(e,t){return new gg({check:"size_equals",...N(t),size:e})}function br(e,t){return new yg({check:"max_length",...N(t),maximum:e})}function $n(e,t){return new vg({check:"min_length",...N(t),minimum:e})}function wr(e,t){return new bg({check:"length_equals",...N(t),length:e})}function $i(e,t){return new wg({check:"string_format",format:"regex",...N(t),pattern:e})}function Ti(e){return new _g({check:"string_format",format:"lowercase",...N(e)})}function Ci(e){return new kg({check:"string_format",format:"uppercase",...N(e)})}function Ai(e,t){return new Sg({check:"string_format",format:"includes",...N(t),includes:e})}function Ii(e,t){return new xg({check:"string_format",format:"starts_with",...N(t),prefix:e})}function Ni(e,t){return new Eg({check:"string_format",format:"ends_with",...N(t),suffix:e})}function Hs(e,t,n){return new $g({check:"property",property:e,schema:t,...N(n)})}function Ri(e,t){return new Tg({check:"properties",shape:e,...N(t)})}function zi(e,t){return new Cg({check:"mime_type",mime:e,...N(t)})}function en(e){return new Ag({check:"overwrite",tx:e})}function Li(e){return en(t=>t.normalize(e))}function Pi(){return en(e=>e.trim())}function Di(){return en(e=>e.toLowerCase())}function Oi(){return en(e=>e.toUpperCase())}function Mi(){return en(e=>am(e))}function Tv(e,t,n){return new e({type:"array",element:t,...N(n)})}function m0(e,t,n){return new e({type:"union",options:t,...N(n)})}function g0(e,t,n){return new e({type:"union",options:t,inclusive:!1,...N(n)})}function y0(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...N(r)})}function v0(e,t,n){return new e({type:"intersection",left:t,right:n})}function b0(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 w0(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...N(r)})}function _0(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...N(r)})}function k0(e,t,n){return new e({type:"set",valueType:t,...N(n)})}function S0(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 x0(e,t,n){return new e({type:"enum",entries:t,...N(n)})}function E0(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(n)})}function Cv(e,t){return new e({type:"file",...N(t)})}function $0(e,t){return new e({type:"transform",transform:t})}function T0(e,t){return new e({type:"optional",innerType:t})}function C0(e,t){return new e({type:"nullable",innerType:t})}function A0(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():mi(n)}})}function I0(e,t,n){return new e({type:"nonoptional",innerType:t,...N(n)})}function N0(e,t){return new e({type:"success",innerType:t})}function R0(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:yc(n)})}function z0(e,t,n){return new e({type:"pipe",in:t,out:n})}function L0(e,t){return new e({type:"readonly",innerType:t})}function P0(e,t,n){return new e({type:"template_literal",parts:t,...N(n)})}function D0(e,t){return new e({type:"lazy",getter:t})}function O0(e,t){return new e({type:"promise",innerType:t})}function Av(e,t,n){const r=N(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function Iv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...N(n)})}function Nv(e,t){const n=Rv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(ir(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(ir(o))}},e(r.value,r)),t);return n}function Rv(e,t){const n=new je({check:"custom",...N(t)});return n._zod.check=e,n}function zv(e){const t=new je({check:"describe"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function Lv(e){const t=new je({check:"meta"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,...e})}],t._zod.check=()=>{},t}function Pv(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??ol,u=e.Boolean??Qc,c=e.String??Ei,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 _r(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 ti(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$t(e,r,n[r]);return e}function sr(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??kt,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 tt(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&&ti(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 Ah(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ar(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}/${Ah(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+Ah(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 Dv(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;Dv(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 Ov=new Set(["type","properties","required","additionalProperties"]),Ih=["oneOf","anyOf"];function Nh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Du(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Ov.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]??Nh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:Du(a)??{allOf:a};$t(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=Nh(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 O0(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Ov)if(i in e)return;const n=t.filter(i=>Ih.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=Du(t);else{const i=n[0],o=Ih.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=>Du([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,ti(e,r))}function ur(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)):ti(c,p),ti(c,l),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(p.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}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())Dv(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)??[])O0(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)}ti(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,$t(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:si(t,"input",e.processors),output:si(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 Mv=(e,t={})=>n=>{const r=sr({...n,processors:t});return De(e,r),ar(r,e),ur(r,e)},si=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=sr({...i??{},target:o,io:t,processors:n});return De(e,s),ar(s,e),ur(s,e)},cr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},lr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rh=(e,t)=>{cr(e,"minimum",t),lr(e,"maximum",t)},Fv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Uv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Gv=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},jv=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},zh=(e,t)=>cr(e,"minimum",t.minimum),Lh=(e,t)=>lr(e,"maximum",t.maximum),Ph=e=>(t,n)=>{jv(t,n.format);const[r,i]=e[n.format];cr(t,"minimum",r),lr(t,"maximum",i)},M0={greater_than:(e,t)=>cr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>lr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Fv(e,t.value),number_format:Ph(pc),bigint_format:Ph(mc),min_length:zh,max_length:Lh,length_equals:(e,t)=>Rh(e,t.length),min_size:zh,max_size:Lh,size_equals:(e,t)=>Rh(e,t.size),string_format:(e,t)=>{jv(e,t.format),t.pattern&&Uv(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)=>Gv(e,t.mime)};function et(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)M0[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&cr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&cr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&lr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&lr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Fv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Gv(t,i.mime);for(const o of i.patterns??[])Uv(t,o);return t}const F0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},U0=new Map([[qc,Vm],[zs,qm]]),Zv=e=>U0.get(e)??e,Bv=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=et(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=F0[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(Zv);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}))])}},Hv=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=et(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)):tt(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...g]=p;m!==void 0&&(i.multipleOf=m),g.length&&(i.allOf=[...i.allOf??[],...g.map(w=>({multipleOf:w}))])}},Vv=(e,t,n,r)=>{n.type="boolean"},qv=(e,t,n,r)=>{tt(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Wv=(e,t,n,r)=>{tt(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Kv=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Jv=(e,t,n,r)=>{tt(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Yv=(e,t,n,r)=>{tt(e,t,n,r,"Void cannot be represented in JSON Schema")},Xv=(e,t,n,r)=>{n.not={}},Qv=(e,t,n,r)=>{},eb=(e,t,n,r)=>{},tb=(e,t,n,r)=>{tt(e,t,n,r,"Date cannot be represented in JSON Schema")},nb=(e,t,n,r)=>{const i=e._zod.def,o=es(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},rb=(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(tt(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(tt(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},ib=(e,t,n,r)=>{tt(e,t,n,r,"NaN cannot be represented in JSON Schema")},ob=(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},sb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=et(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})))},ab=(e,t,n,r)=>{n.type="boolean"},ub=(e,t,n,r)=>{tt(e,t,n,r,"Custom types cannot be represented in JSON Schema")},cb=(e,t,n,r)=>{tt(e,t,n,r,"Function types cannot be represented in JSON Schema")},lb=(e,t,n,r)=>{tt(e,t,n,r,"Transforms cannot be represented in JSON Schema")},db=(e,t,n,r)=>{tt(e,t,n,r,"Map cannot be represented in JSON Schema")},fb=(e,t,n,r)=>{tt(e,t,n,r,"Set cannot be represented in JSON Schema")},hb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=et(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 ai(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ai(t.out):t.type==="catch"?ai(t.innerType):e._zod.optin}const pb=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&tt(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)$t(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"?ai(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)},Ul=(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},mb=(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)},gb=(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,g)=>De(m,t,{...r,path:[...r.path,s,g]})),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"?ai(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}=et(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Ou(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=Ou(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const g=m.map(w=>Ou(e,w,n));g.some((w,y)=>w!==m[y])&&(t={...t,[p]:g})}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")?yr:Lc).source)),h}const Mu=new WeakMap;function G0(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 Mu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Ou(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 yb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=et(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)$t(i.patternProperties,Zv(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=Mu.get(t);l||(l=[],Mu.set(t,l),t.deferred.push(()=>G0(t))),l.push(e)}i.additionalProperties=De(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&ai(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))}},vb=(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"}]},bb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Gl=Symbol();function wb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(tt(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Gl):JSON.parse(s)}const _b=(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=wb(i.defaultValue,e,t,n,r);s!==Gl&&(n.default=s)},kb=(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=wb(i.defaultValue,e,t,n,r);s!==Gl&&(n._prefault=s)},Sb=(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{tt(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},xb=(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},Eb=(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},$b=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},jl=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Tb=(e,t,n,r)=>{const i=e._zod.innerType;De(i,t,r);const o=t.seen.get(e);o.ref=i},Fu={string:Bv,number:Hv,boolean:Vv,bigint:qv,symbol:Wv,null:Kv,undefined:Jv,void:Yv,never:Xv,any:Qv,unknown:eb,date:tb,enum:nb,literal:rb,nan:ib,template_literal:ob,file:sb,success:ab,custom:ub,function:cb,transform:lb,map:db,set:fb,array:hb,object:pb,union:Ul,intersection:mb,tuple:gb,record:yb,nullable:vb,nonoptional:bb,default:_b,prefault:kb,catch:Sb,pipe:xb,readonly:Eb,promise:$b,optional:jl,lazy:Tb};function Zl(e,t){if("_idmap"in e){const r=e,i=sr({...t,processors:Fu}),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;ar(i,l),$t(s,c,ur(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=sr({...t,processors:Fu});return De(e,n),ar(n,e),ur(n,e)}class j0{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=sr({processors:Fu,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,ar(this.ctx,t);const r=ur(this.ctx,t),{"~standard":i,...o}=r;return o}}const Z0=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Cb=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:dy,$ZodArray:gy,$ZodAsyncError:rn,$ZodBase64:Qg,$ZodBase64URL:ey,$ZodBigInt:el,$ZodBigIntFormat:ay,$ZodBoolean:Qc,$ZodCIDRv4:Yg,$ZodCIDRv6:Xg,$ZodCUID:Fg,$ZodCUID2:Ug,$ZodCatch:My,$ZodCheck:je,$ZodCheckBigIntFormat:hg,$ZodCheckEndsWith:Eg,$ZodCheckGreaterThan:Mc,$ZodCheckIncludes:Sg,$ZodCheckLengthEquals:bg,$ZodCheckLessThan:Oc,$ZodCheckLowerCase:_g,$ZodCheckMaxLength:yg,$ZodCheckMaxSize:pg,$ZodCheckMimeType:Cg,$ZodCheckMinLength:vg,$ZodCheckMinSize:mg,$ZodCheckMultipleOf:dg,$ZodCheckNumberFormat:fg,$ZodCheckOverwrite:Ag,$ZodCheckProperties:Tg,$ZodCheckProperty:$g,$ZodCheckRegex:wg,$ZodCheckSizeEquals:gg,$ZodCheckStartsWith:xg,$ZodCheckStringFormat:xi,$ZodCheckUpperCase:kg,$ZodCodec:ol,$ZodCreditCard:ny,$ZodCustom:Hy,$ZodCustomStringFormat:oy,$ZodCyclicError:Vy,$ZodDate:my,$ZodDefault:Ly,$ZodDiscriminatedUnion:Sy,$ZodE164:ty,$ZodEmail:Lg,$ZodEmoji:Og,$ZodEncodeError:xs,$ZodEnum:Cy,$ZodError:Em,$ZodExactOptional:Ry,$ZodFile:Iy,$ZodFunction:Zy,$ZodGUID:Rg,$ZodIBAN:ry,$ZodIPv4:Wg,$ZodIPv6:Kg,$ZodISODate:Hg,$ZodISODateTime:Bg,$ZodISODuration:qg,$ZodISOTime:Vg,$ZodIntersection:xy,$ZodJWT:iy,$ZodKSUID:Zg,$ZodLazy:sl,$ZodLiteral:Ay,$ZodMAC:Jg,$ZodMap:$y,$ZodNaN:Fy,$ZodNanoID:Mg,$ZodNever:hy,$ZodNonOptional:Dy,$ZodNull:ly,$ZodNullable:zy,$ZodNumber:Xc,$ZodNumberFormat:sy,$ZodObject:by,$ZodObjectJIT:wy,$ZodOptional:rl,$ZodPipe:il,$ZodPrefault:Py,$ZodPreprocess:Uy,$ZodPromise:By,$ZodReadonly:Gy,$ZodRealError:Tt,$ZodRecord:Ey,$ZodRegistry:Ky,$ZodSet:Ty,$ZodString:Ei,$ZodStringFormat:Me,$ZodSuccess:Oy,$ZodSymbol:uy,$ZodTemplateLiteral:jy,$ZodTransform:Ny,$ZodTuple:nl,$ZodType:me,$ZodULID:Gg,$ZodURL:Dg,$ZodUUID:zg,$ZodUndefined:cy,$ZodUnion:Ls,$ZodUnknown:fy,$ZodVoid:py,$ZodXID:jg,$ZodXor:_y,$brand:wc,$constructor:S,$input:dl,$output:ll,Doc:Fc,INVALID:vt,JSONSchema:Z0,JSONSchemaGenerator:j0,NEVER:bc,TimePrecision:Pl,URL_BAD_FORMAT:Gc,URL_UNPARSEABLE:ii,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,_any:wv,_array:Tv,_base64:Nl,_base64url:Rl,_bigint:hv,_boolean:dv,_catch:N0,_check:Rv,_cidrv4:Al,_cidrv6:Il,_coercedBigint:pv,_coercedBoolean:fv,_coercedDate:Ev,_coercedNumber:ov,_coercedString:ev,_creditCard:nv,_cuid:kl,_cuid2:Sl,_custom:Av,_date:xv,_decode:xc,_decodeAsync:$c,_default:C0,_discriminatedUnion:g0,_e164:zl,_email:pl,_emoji:wl,_encode:Sc,_encodeAsync:Ec,_endsWith:Ni,_enum:k0,_file:Cv,_float32:av,_float64:uv,_gt:fn,_gte:Et,_guid:ml,_iban:rv,_includes:Ai,_int:sv,_int32:cv,_int64:mv,_intersection:y0,_ipv4:Tl,_ipv6:Cl,_isoDate:Ol,_isoDateTime:Dl,_isoDuration:Fl,_isoTime:Ml,_jwt:Ll,_ksuid:$l,_lazy:P0,_length:wr,_literal:x0,_lowercase:Ti,_lt:dn,_lte:xt,_mac:tv,_map:w0,_max:xt,_maxLength:br,_maxSize:Wn,_mime:zi,_min:Et,_minLength:$n,_minSize:hn,_multipleOf:Bn,_nan:$v,_nanoid:_l,_nativeEnum:S0,_negative:js,_never:kv,_nonnegative:Bs,_nonoptional:A0,_nonpositive:Zs,_normalize:Li,_null:bv,_nullable:T0,_number:iv,_optional:$0,_overwrite:en,_parse:vi,_parseAsync:bi,_pipe:R0,_positive:Gs,_promise:D0,_properties:Ri,_property:Hs,_readonly:z0,_record:b0,_refine:Iv,_regex:$i,_safeDecode:Cc,_safeDecodeAsync:Ic,_safeEncode:Tc,_safeEncodeAsync:Ac,_safeParse:wi,_safeParseAsync:_i,_set:_0,_size:vr,_slugify:Mi,_startsWith:Ii,_string:Qy,_stringFormat:_r,_stringbool:Pv,_success:I0,_superRefine:Nv,_symbol:yv,_templateLiteral:L0,_toLowerCase:Di,_toUpperCase:Oi,_transform:E0,_trim:Pi,_tuple:v0,_uint32:lv,_uint64:gv,_ulid:xl,_undefined:vv,_union:p0,_unknown:_v,_uppercase:Ci,_url:Us,_uuid:gl,_uuidv4:yl,_uuidv6:vl,_uuidv7:bl,_void:Sv,_xid:El,_xor:m0,base64Charset:qc,base64urlCharset:zs,canParseURL:jc,clone:Ge,compile:fl,compileFn:Ms,config:Qe,createStandardJSONSchemaMethod:si,createToJSONSchemaMethod:Mv,decode:$k,decodeAsync:Ck,describe:zv,encode:Ek,encodeAsync:Tk,extractDefs:ar,finalize:ur,flattenError:Es,formatError:$s,getDiscriminatedOption:tl,globalConfig:yt,globalRegistry:kt,handleUnrepresentable:tt,initializeContext:sr,isBackEdge:ul,isRecursiveSchema:al,isValidBase64:Rs,isValidBase64URL:Wc,isValidCIDRv6:Vc,isValidCreditCard:Kc,isValidIBAN:Jc,isValidIPv6:Ns,isValidJWT:Yc,locales:cl,memoizer:Ps,mergeValues:oi,meta:Lv,parse:Au,parseAsync:Iu,parseURLObject:Pg,prettifyError:kc,process:De,processSchema:De,regexes:Is,registry:Ds,safeDecode:Ik,safeDecodeAsync:Rk,safeEncode:Ak,safeEncodeAsync:Nk,safeParse:Tm,safeParseAsync:_k,standardProps:Uc,stripTabAndNewline:os,toDotPath:$m,toJSONSchema:Zl,toZod:vs,treeifyError:_c,urlHostnameOk:Bc,urlProtocolOk:Hc,util:vc,validate:Cs,validateAsync:As,validateURL:Zc,version:Ig,withParser:Os},Symbol.toStringTag,{value:"Module"})),Dh=Symbol("z.visit/resolving");function Bl(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===Dh)return new sl({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,Dh);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?Ge(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:Ge(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?Ge(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:Ge(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:Ge(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?Ge(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:Ge(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:Ge(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:Ge(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:Ge(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return Ge(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 Hl(e){return!!e._zod}function Ab(e,t){return Hl(e)?Tm(e,t):e.safeParse(t)}function B0(e){if(!e)return;let t;if(Hl(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function H0(e){if(Hl(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 V0=()=>{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=bm(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 ${hc(o.values[0])}`:`Invalid option: expected one of ${$u(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":""}: ${$u(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 q0(){return{localeError:V0()}}const W0=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Ni,gt:fn,gte:Et,includes:Ai,length:wr,lowercase:Ti,lt:dn,lte:xt,maxLength:br,maxSize:Wn,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,negative:js,nonnegative:Bs,nonpositive:Zs,normalize:Li,overwrite:en,positive:Gs,properties:Ri,property:Hs,regex:$i,size:vr,slugify:Mi,startsWith:Ii,toLowerCase:Di,toUpperCase:Oi,trim:Pi,uppercase:Ci},Symbol.toStringTag,{value:"Module"})),Oh=new WeakSet([Object.prototype,Error.prototype]);function Ro(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 Ib=(e,t)=>{Em.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Oh.has(n)||(Oh.add(n),Ro(n,"format",r=>i=>$s(r,i)),Ro(n,"flatten",r=>i=>Es(r,i)),Ro(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,ts,2)}),Ro(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,ts,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Nb=S("ZodError",Ib),wt=S("ZodError",Ib,void 0,{Parent:Error}),Vl=vi(wt),ql=bi(wt),Wl=wi(wt),Kl=_i(wt),Jl=Sc(wt),Yl=xc(wt),Xl=Ec(wt),Ql=$c(wt),ed=Tc(wt),td=Cc(wt),nd=Ac(wt),rd=Ic(wt);function K0(){yt.localeError||Qe(q0())}function Kn(){yt.memoizer||Qe({memoizer:Ps()})}const ye=S("ZodType",(e,t)=>(K0(),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 Ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(za(e,t))},superRefine(e,t){return this.check(La(e,t))},overwrite(e){return this.check(en(e))},optional(){return Fe(this)},exactOptional(){return ha(this)},nullable(){return fr(this)},nullish(){return Fe(fr(this))},nonoptional(e){return ba(this,e)},array(){return ue(this)},or(e){return we([this,e])},and(e){return zr(this,e)},transform(e){return ci(this,uo(e))},default(e){return ga(this,e)},prefault(e){return va(this,e)},catch(e){return ka(this,e)},pipe(e){return ci(this,e)},readonly(){return $a(this)},describe(e){const t=this.clone();return kt.add(t,{description:e}),t},meta(...e){if(e.length===0)return kt.get(this);const t=this.clone();return kt.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 Ss(this,"~standard",{...Uc(this),jsonSchema:{input:si(this,"input"),output:si(this,"output")}})},set"~standard"(e){cn(this,"~standard",e)},parse:function e(t,n){return Vl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ql(this,t,n,{callee:e})},safeParse(e,t){return Wl(this,e,t)},async safeParseAsync(e,t){return Kl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){cn(this,"spa",e)},validate(e,t){return Cs(this,e,t)},validateAsync(e,t){return As(this,e,t)},encode:function e(t,n){return Jl(this,t,n,{callee:e})},decode:function e(t,n){return Yl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Xl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ql(this,t,n,{callee:e})},safeEncode(e,t){return ed(this,e,t)},safeDecode(e,t){return td(this,e,t)},async safeEncodeAsync(e,t){return nd(this,e,t)},async safeDecodeAsync(e,t){return rd(this,e,t)},toJSONSchema(e){return Mv(this,{})(e)},get description(){return kt.get(this)?.description},get _def(){return this._zod.def}}),Fi=S("_ZodString",(e,t)=>{Ei.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bv(e,n,r)},yi({format:e=>et(e).format??null,minLength:e=>et(e).minimum??null,maxLength:e=>et(e).maximum??null},{regex(...e){return this.check($i(...e))},includes(...e){return this.check(Ai(...e))},startsWith(...e){return this.check(Ii(...e))},endsWith(...e){return this.check(Ni(...e))},min(...e){return this.check($n(...e))},max(...e){return this.check(br(...e))},length(...e){return this.check(wr(...e))},nonempty(...e){return this.check($n(1,...e))},lowercase(e){return this.check(Ti(e))},uppercase(e){return this.check(Ci(e))},trim(){return this.check(Pi())},normalize(...e){return this.check(Li(...e))},toLowerCase(){return this.check(Di())},toUpperCase(){return this.check(Oi())},slugify(){return this.check(Mi())}})),kr=S("ZodString",(e,t)=>{Ei.init(e,t),Fi.init(e,t)},{email(e){return this.check(pl(Ui,e))},url(e){return this.check(Us(Tr,e))},jwt(e){return this.check(Ll(no,e))},emoji(e){return this.check(wl(ji,e))},guid(e){return this.check(ml(Gi,e))},uuid(e){return this.check(gl(Vt,e))},uuidv4(e){return this.check(yl(Vt,e))},uuidv6(e){return this.check(vl(Vt,e))},uuidv7(e){return this.check(bl(Vt,e))},nanoid(e){return this.check(_l(Zi,e))},cuid(e){return this.check(kl(Bi,e))},cuid2(e){return this.check(Sl(Hi,e))},ulid(e){return this.check(xl(Vi,e))},base64(e){return this.check(Nl(Qi,e))},base64url(e){return this.check(Rl(eo,e))},xid(e){return this.check(El(qi,e))},ksuid(e){return this.check($l(Wi,e))},ipv4(e){return this.check(Tl(Ki,e))},ipv6(e){return this.check(Cl(Ji,e))},cidrv4(e){return this.check(Al(Yi,e))},cidrv6(e){return this.check(Il(Xi,e))},e164(e){return this.check(zl(to,e))},datetime(e){return this.check(Dl(Sr,e))},date(e){return this.check(Ol(xr,e))},time(e){return this.check(Ml(Er,e))},duration(e){return this.check(Fl($r,e))}});function x(e){return Qy(kr,e)}const Pe=S("ZodStringFormat",(e,t)=>{Me.init(e,t),Fi.init(e,t)}),Sr=S("ZodISODateTime",(e,t)=>{Bg.init(e,t),Pe.init(e,t)}),xr=S("ZodISODate",(e,t)=>{Hg.init(e,t),Pe.init(e,t)}),Er=S("ZodISOTime",(e,t)=>{Vg.init(e,t),Pe.init(e,t)}),$r=S("ZodISODuration",(e,t)=>{qg.init(e,t),Pe.init(e,t)}),Ui=S("ZodEmail",(e,t)=>{Lg.init(e,t),Pe.init(e,t)});function id(e){return pl(Ui,e)}const Gi=S("ZodGUID",(e,t)=>{Rg.init(e,t),Pe.init(e,t)});function od(e){return ml(Gi,e)}const Vt=S("ZodUUID",(e,t)=>{zg.init(e,t),Pe.init(e,t)});function sd(e){return gl(Vt,e)}function ad(e){return yl(Vt,e)}function ud(e){return vl(Vt,e)}function cd(e){return bl(Vt,e)}const Tr=S("ZodURL",(e,t)=>{Dg.init(e,t),Pe.init(e,t)});function ld(e){return Us(Tr,e)}function dd(e){return Us(Tr,{protocol:Nc,hostname:Km,...N(e)})}const ji=S("ZodEmoji",(e,t)=>{Og.init(e,t),Pe.init(e,t)});function fd(e){return wl(ji,e)}const Zi=S("ZodNanoID",(e,t)=>{Mg.init(e,t),Pe.init(e,t)});function hd(e){return _l(Zi,e)}const Bi=S("ZodCUID",(e,t)=>{Fg.init(e,t),Pe.init(e,t)});function pd(e){return kl(Bi,e)}const Hi=S("ZodCUID2",(e,t)=>{Ug.init(e,t),Pe.init(e,t)});function md(e){return Sl(Hi,e)}const Vi=S("ZodULID",(e,t)=>{Gg.init(e,t),Pe.init(e,t)});function gd(e){return xl(Vi,e)}const qi=S("ZodXID",(e,t)=>{jg.init(e,t),Pe.init(e,t)});function yd(e){return El(qi,e)}const Wi=S("ZodKSUID",(e,t)=>{Zg.init(e,t),Pe.init(e,t)});function vd(e){return $l(Wi,e)}const Ki=S("ZodIPv4",(e,t)=>{Wg.init(e,t),Pe.init(e,t)});function bd(e){return Tl(Ki,e)}const Vs=S("ZodMAC",(e,t)=>{Jg.init(e,t),Pe.init(e,t)});function wd(e){return tv(Vs,e)}const Ji=S("ZodIPv6",(e,t)=>{Kg.init(e,t),Pe.init(e,t)});function _d(e){return Cl(Ji,e)}const Yi=S("ZodCIDRv4",(e,t)=>{Yg.init(e,t),Pe.init(e,t)});function kd(e){return Al(Yi,e)}const Xi=S("ZodCIDRv6",(e,t)=>{Xg.init(e,t),Pe.init(e,t)});function Sd(e){return Il(Xi,e)}const Qi=S("ZodBase64",(e,t)=>{Qg.init(e,t),Pe.init(e,t)});function xd(e){return Nl(Qi,e)}const eo=S("ZodBase64URL",(e,t)=>{ey.init(e,t),Pe.init(e,t)});function Ed(e){return Rl(eo,e)}const to=S("ZodE164",(e,t)=>{ty.init(e,t),Pe.init(e,t)});function $d(e){return zl(to,e)}const qs=S("ZodCreditCard",(e,t)=>{ny.init(e,t),Pe.init(e,t)});function Td(e){return nv(qs,e)}const Ws=S("ZodIBAN",(e,t)=>{ry.init(e,t),Pe.init(e,t)});function Cd(e){return rv(Ws,e)}const no=S("ZodJWT",(e,t)=>{iy.init(e,t),Pe.init(e,t)});function Ad(e){return Ll(no,e)}const Tn=S("ZodCustomStringFormat",(e,t)=>{oy.init(e,t),Pe.init(e,t)});function Id(e,t,n={}){return _r(Tn,e,t,n)}function Nd(e){return _r(Tn,"hostname",Wm,e)}function Rd(e){return _r(Tn,"hex",lg,e)}function zd(e){return _r(Tn,"currency_code",Ym,e)}function Ld(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Is[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return _r(Tn,r,i,t)}const Cr=S("ZodNumber",(e,t)=>{Xc.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hv(e,n,r,i),e.isFinite=!0},yi({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=et(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=et(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=et(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>et(e).format??null},{gt(e,t){return this.check(fn(e,t))},gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},lt(e,t){return this.check(dn(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(ui(e))},safe(e){return this.check(ui(e))},positive(e){return this.check(fn(0,e))},nonnegative(e){return this.check(Et(0,e))},negative(e){return this.check(dn(0,e))},nonpositive(e){return this.check(xt(0,e))},multipleOf(e,t){return this.check(Bn(e,t))},step(e,t){return this.check(Bn(e,t))},finite(){return this}}));function ge(e){return iv(Cr,e)}const Cn=S("ZodNumberFormat",(e,t)=>{sy.init(e,t),Cr.init(e,t)});function ui(e){return sv(Cn,e)}function Pd(e){return av(Cn,e)}function Dd(e){return uv(Cn,e)}function Od(e){return cv(Cn,e)}function Md(e){return lv(Cn,e)}const Ar=S("ZodBoolean",(e,t)=>{Qc.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r)});function Le(e){return dv(Ar,e)}const Ir=S("ZodBigInt",(e,t)=>{el.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qv(e,n,r,i)},yi({minValue:e=>et(e).minimum??null,maxValue:e=>et(e).maximum??null,format:e=>et(e).format??null},{gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},gt(e,t){return this.check(fn(e,t))},lt(e,t){return this.check(dn(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(fn(BigInt(0),e))},negative(e){return this.check(dn(BigInt(0),e))},nonpositive(e){return this.check(xt(BigInt(0),e))},nonnegative(e){return this.check(Et(BigInt(0),e))},multipleOf(e,t){return this.check(Bn(e,t))}}));function Fd(e){return hv(Ir,e)}const ro=S("ZodBigIntFormat",(e,t)=>{ay.init(e,t),Ir.init(e,t)});function Ud(e){return mv(ro,e)}function Gd(e){return gv(ro,e)}const Ks=S("ZodSymbol",(e,t)=>{uy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wv(e,n,r,i)});function jd(e){return yv(Ks,e)}const Js=S("ZodUndefined",(e,t)=>{cy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jv(e,n,r,i)});function dr(e){return vv(Js,e)}const Ys=S("ZodNull",(e,t)=>{ly.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r)});function io(e){return bv(Ys,e)}const Xs=S("ZodAny",(e,t)=>{dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qv()});function oo(){return wv(Xs)}const Qs=S("ZodUnknown",(e,t)=>{fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eb()});function ze(){return _v(Qs)}const ea=S("ZodNever",(e,t)=>{hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xv(e,n,r)});function Hn(e){return kv(ea,e)}const ta=S("ZodVoid",(e,t)=>{py.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yv(e,n,r,i)});function Zd(e){return Sv(ta,e)}const so=S("ZodDate",(e,t)=>{my.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tb(e,n,r,i),e.min=(n,r)=>e.check(Et(n,r)),e.max=(n,r)=>e.check(xt(n,r))},yi({minDate:e=>{const{minimum:t}=et(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=et(e);return t?new Date(t):null}},{}));function Bd(e){return xv(so,e)}const na=S("ZodArray",(e,t)=>{Kn(),gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hb(e,n,r,i),e.element=t.element},{min(e,t){return this.check($n(e,t))},nonempty(e){return this.check($n(1,e))},max(e,t){return this.check(br(e,t))},length(e,t){return this.check(wr(e,t))},unwrap(){return this.element}});function ue(e,t){return Tv(na,e,t)}function Hd(e){const t=e._zod.def.shape;return ot(Object.keys(t))}const Nr=S("ZodObject",(e,t)=>{Kn(),wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pb(e,n,r,i),Sm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return ot(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:ze()}))},loose(){return this.clone(lt(this._zod.def,{catchall:ze()}))},strict(){return this.clone(lt(this._zod.def,{catchall:Hn()}))},strip(){return this.clone(lt(this._zod.def,{catchall:void 0}))},extend(e){return hm(this,e)},safeExtend(e){return mm(this,e)},merge(e){return gm(this,e)},pick(e){return dm(this,e)},omit(e){return fm(this,e)},partial(...e){return Tu(Lr,this,e[0])},exactPartial(...e){return Tu(co,this,e[0],"exactPartial")},required(...e){return ym(lo,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...N(t)};return new Nr(n)}function Vd(e,t){return new Nr({type:"object",shape:e,catchall:Hn(),...N(t)})}function it(e,t){return new Nr({type:"object",shape:e,catchall:ze(),...N(t)})}const Rr=S("ZodUnion",(e,t)=>{Ls.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ul(e,n,r,i),e.options=t.options});function we(e,t){return new Rr({type:"union",options:e,...N(t)})}const ra=S("ZodXor",(e,t)=>{Rr.init(e,t),_y.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ul(e,n,r,i),e.options=t.options});function qd(e,t){return new ra({type:"union",options:e,inclusive:!1,...N(t)})}const ia=S("ZodDiscriminatedUnion",(e,t)=>{Rr.init(e,t),Sy.init(e,t)});function ao(e,t,n){return new ia({type:"union",options:t,discriminator:e,...N(n)})}const oa=S("ZodIntersection",(e,t)=>{xy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mb(e,n,r,i)});function zr(e,t){return new oa({type:"intersection",left:e,right:t})}const sa=S("ZodTuple",(e,t)=>{Kn(),nl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gb(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 Lr({type:"optional",innerType:t}))})}});function aa(e,t,n){const r=t instanceof me,i=r?n:t,o=r?t:null;return new sa({type:"tuple",items:e,rest:o,...N(i)})}const Vn=S("ZodRecord",(e,t)=>{Kn(),Ey.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function xe(e,t,n){return!t||!t._zod?new Vn({type:"record",keyType:x(),valueType:e,...N(t)}):new Vn({type:"record",keyType:e,valueType:t,...N(n)})}function Wd(e,t,n){return new Vn({type:"record",keyType:e,valueType:t,...N(n),partial:!0})}function Kd(e,t,n){return new Vn({type:"record",keyType:e,valueType:t,mode:"loose",...N(n)})}const ua=S("ZodMap",(e,t)=>{Kn(),$y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>db(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(hn(...n)),e.nonempty=n=>e.check(hn(1,n)),e.max=(...n)=>e.check(Wn(...n)),e.size=(...n)=>e.check(vr(...n))});function Jd(e,t,n){return new ua({type:"map",keyType:e,valueType:t,...N(n)})}const ca=S("ZodSet",(e,t)=>{Kn(),Ty.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fb(e,n,r,i),e.min=(...n)=>e.check(hn(...n)),e.nonempty=n=>e.check(hn(1,n)),e.max=(...n)=>e.check(Wn(...n)),e.size=(...n)=>e.check(vr(...n))});function Yd(e,t){return new ca({type:"set",valueType:e,...N(t)})}const qn=S("ZodEnum",(e,t)=>{Cy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,o)=>nb(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 qn({...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 qn({...t,checks:[],...N(i),entries:o})}});function ot(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new qn({type:"enum",entries:n,...N(t)})}function Xd(e,t){return new qn({type:"enum",entries:e,...N(t)})}const la=S("ZodLiteral",(e,t)=>{Ay.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rb(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 la({type:"literal",values:Array.isArray(e)?e:[e],...N(t)})}const da=S("ZodFile",(e,t)=>{Iy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r),e.min=(n,r)=>e.check(hn(n,r)),e.max=(n,r)=>e.check(Wn(n,r)),e.mime=(n,r)=>e.check(zi(Array.isArray(n)?n:[n],r))});function Qd(e){return Cv(da,e)}const fa=S("ZodTransform",(e,t)=>{Kn(),Ny.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(ir(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(ir(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function uo(e){return new fa({type:"transform",transform:e})}const Lr=S("ZodOptional",(e,t)=>{rl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Fe(e){return new Lr({type:"optional",innerType:e})}const co=S("ZodExactOptional",(e,t)=>{Ry.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ha(e){return new co({type:"optional",innerType:e})}const pa=S("ZodNullable",(e,t)=>{zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function fr(e){return new pa({type:"nullable",innerType:e})}function ef(e){return Fe(fr(e))}const ma=S("ZodDefault",(e,t)=>{Ly.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_b(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ga(e,t){return new ma({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():mi(t)}})}const ya=S("ZodPrefault",(e,t)=>{Py.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e,t){return new ya({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():mi(t)}})}const lo=S("ZodNonOptional",(e,t)=>{Dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ba(e,t){return new lo({type:"nonoptional",innerType:e,...N(t)})}const wa=S("ZodSuccess",(e,t)=>{Oy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r),e.unwrap=()=>e._zod.def.innerType});function tf(e){return new wa({type:"success",innerType:e})}const _a=S("ZodCatch",(e,t)=>{My.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ka(e,t){return new _a({type:"catch",innerType:e,catchValue:typeof t=="function"?t:yc(t)})}const Sa=S("ZodNaN",(e,t)=>{Fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r,i)});function nf(e){return $v(Sa,e)}const Pr=S("ZodPipe",(e,t)=>{il.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xb(e,n,r,i),e.in=t.in,e.out=t.out});function ci(e,t){return new Pr({type:"pipe",in:e,out:t})}const Dr=S("ZodCodec",(e,t)=>{Pr.init(e,t),ol.init(e,t)});function rf(e,t,n){return new Dr({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function of(e){const t=e._zod.def;return new Dr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const xa=S("ZodPreprocess",(e,t)=>{Pr.init(e,t),Uy.init(e,t)}),Ea=S("ZodReadonly",(e,t)=>{Gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Eb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function $a(e){return new Ea({type:"readonly",innerType:e})}const Ta=S("ZodTemplateLiteral",(e,t)=>{jy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r)});function sf(e,t){return new Ta({type:"template_literal",parts:e,...N(t)})}const Ca=S("ZodLazy",(e,t)=>{sl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tb(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function Aa(e){return new Ca({type:"lazy",getter:e})}const Ia=S("ZodPromise",(e,t)=>{By.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$b(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function af(e){return new Ia({type:"promise",innerType:e})}const Na=S("ZodFunction",(e,t)=>{Zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb(e,n,r,i)});function hr(e){return new Na({type:"function",input:Array.isArray(e?.input)?aa(e?.input):e?.input??ue(ze()),output:e?.output??ze()})}const Or=S("ZodCustom",(e,t)=>{Hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r,i)});function uf(e){const t=new je({check:"custom"});return t._zod.check=e,t}function Ra(e,t){return Av(Or,e??(()=>!0),t)}function za(e,t={}){return Iv(Or,e,t)}function La(e,t){return Nv(e,t)}const cf=zv,lf=Lv,Pa=S("ZodInstanceOf",(e,t)=>{Or.init(e,t)},{properties(e,t){return this.check(Ri(e,t))}});function df(e,t={}){const n=new Pa({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 ff=(...e)=>Pv({Codec:Dr,Boolean:Ar,String:kr},...e);function hf(e){const t=Aa(()=>we([x(e),ge(),Le(),io(),ue(t),xe(x(),t)]));return t}function fo(e,t){return new xa({type:"pipe",in:uo(e),out:t})}const J0=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodExactOptional:co,ZodFile:da,ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,codec:rf,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,enum:ot,exactOptional:ha,file:Qd,float32:Pd,float64:Dd,function:hr,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,literal:E,looseObject:it,looseRecord:Kd,mac:wd,map:Jd,meta:lf,nan:nf,nanoid:hd,nativeEnum:Xd,never:Hn,nonoptional:ba,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,partialRecord:Wd,pipe:ci,prefault:va,preprocess:fo,promise:af,readonly:$a,record:xe,refine:za,set:Yd,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,transform:uo,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,url:ld,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,void:Zd,xid:yd,xor:qd},Symbol.toStringTag,{value:"Module"})),Rb={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){Qe({customError:e})}function Lb(){return Qe().customError}var as;as||(as={});function Pb(e){return Dl(Sr,e)}function Y0(e){return Ol(xr,e)}function X0(e){return Ml(Er,e)}function Q0(e){return Fl($r,e)}const pf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,date:Y0,datetime:Pb,duration:Q0,time:X0},Symbol.toStringTag,{value:"Module"})),H={...J0,...W0,iso:pf},ex=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 tx(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 Mh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function nx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function rx(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:nx(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 ix(e,t){return H.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 Uu(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=Uu(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=Uu(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 ox=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),sx=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ni(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ni):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>ox.has(t)?ni(n):!sx.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(ni))}function Fh(e){return e===1?"element":"elements"}function ax(e,t){return H.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=Uu(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 ${Fh(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 ${Fh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function Uh(e,t){if(e!==!1)return e===void 0||e===!0?H.any():gt(e,t)}const ux=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Db(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return H.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 H.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=rx(i,t),s=gt(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 H.null();if(i.length===0)return H.never();if(i.length===1)return H.literal(i[0]);if(i.every(s=>typeof s=="string"))return H.enum(i);const o=i.map(s=>H.literal(s));return o.length<2?o[0]:H.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return H.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return Db(s,t)});return i.length===0?H.never():i.length===1?i[0]:H.union(i)}if(!n)return H.any();let r;switch(n){case"string":{let i=H.string();if(e.format){const o=e.format;o==="email"?i=i.check(H.email()):o==="uri"||o==="uri-reference"?i=i.check(H.url()):o==="uuid"||o==="guid"?i=i.check(H.uuid()):o==="date-time"?i=i.check(H.iso.datetime({offset:!0})):o==="date"?i=i.check(H.iso.date()):o==="time"?i=i.check(H.regex(ux)):o==="duration"?i=i.check(H.iso.duration()):o==="hostname"?i=i.check(H.hostname()):o==="ipv4"?i=i.check(H.ipv4()):o==="ipv6"?i=i.check(H.ipv6()):o==="mac"?i=i.check(H.mac()):o==="cidr"?i=i.check(H.cidrv4()):o==="cidr-v6"?i=i.check(H.cidrv6()):o==="base64"?i=i.check(H.base64()):o==="base64url"?i=i.check(H.base64url()):o==="e164"?i=i.check(H.e164()):o==="credit_card"?i=i.check(H.creditCard()):o==="iban"?i=i.check(H.iban()):o==="jwt"?i=i.check(H.jwt()):o==="emoji"?i=i.check(H.emoji()):o==="nanoid"?i=i.check(H.nanoid()):o==="cuid"?i=i.check(H.cuid()):o==="cuid2"?i=i.check(H.cuid2()):o==="ulid"?i=i.check(H.ulid()):o==="xid"?i=i.check(H.xid()):o==="ksuid"&&(i=i.check(H.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"?H.number().int():H.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=H.boolean();break}case"null":{r=H.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?gt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=gt(f,t);$t(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 g=gt(d[m],t),w=H.string().regex(new RegExp(m));h.push(H.looseRecord(w,g))}const p=[];if(Object.keys(i).length>0&&p.push(H.object(i).passthrough()),p.push(...h),p.length===0)r=H.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=H.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)m=H.intersection(m,p[g]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),g=f.map(y=>new RegExp(y)),w=r;r=r.check(y=>{if(!an(y.value))return;const b=[];for(const v of Object.keys(y.value))m.includes(v)||g.some(k=>k.test(v))||b.push(v);b.length&&y.issues.push({code:"unrecognized_keys",keys:b,input:y.value,inst:w})})}}else{const d=H.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=gt(f,t)}r=ix(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=>gt(d,t)),u=Mh(a,s),c=Array.isArray(o)?void 0:Uh(o,t),l=H.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(H.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>gt(d,t)),u=Mh(a,s),c=Uh(e.additionalItems,t),l=H.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(H.maxLength(e.maxItems)))}else if(o!==void 0){const s=gt(o,t);let a=H.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=H.array(H.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=ax(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?gt(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 gt(e,t){if(typeof e=="boolean")return e?H.any():H.never();let n=Db(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=>gt(c,t)),u=H.union(a);n=r?H.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>gt(c,t)),u=H.xor(a);n=r?H.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:H.any();else{let a=r?n:gt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=H.intersection(a,gt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=H.nullable(n)),e.readOnly===!0&&(n=H.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&&!ni(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&&!ni(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))ex.has(a)||$t(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function Ob(e,t){if(typeof e=="boolean")return e?H.any():H.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=tx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??kt};return gt(n,o)}function Mb(e){return Bl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:we(n.options)}})}function cx(e,t){if(!t?.length)return e;const n=e._zod.def;return Ge(e,lt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Fb(e){return cx(e.out,e.checks)}function lx(e){return e.in._zod.traits.has("$ZodTransform")?Fb(e):e.in}function Ub(e){return Bl(e,{pipe:t=>lx(t._zod.def),default:(t,n)=>n?Fe(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Gb(e){return Bl(e,{pipe:t=>Fb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function dx(e){return ev(kr,e)}function fx(e){return ov(Cr,e)}function hx(e){return fv(Ar,e)}function px(e){return pv(Ir,e)}function mx(e){return Ev(so,e)}const jb=Object.freeze(Object.defineProperty({__proto__:null,bigint:px,boolean:hx,date:mx,number:fx,string:dx},Symbol.toStringTag,{value:"Module"})),Gh=Object.freeze(Object.defineProperty({__proto__:null,$brand:wc,$input:dl,$output:ll,INVALID:vt,NEVER:bc,TimePrecision:Pl,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodError:Nb,ZodExactOptional:co,ZodFile:da,get ZodFirstPartyTypeKind(){return as},ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodIssueCode:Rb,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRealError:wt,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,clone:Ge,codec:rf,coerce:jb,compile:fl,config:Qe,core:Cb,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,decode:Yl,decodeAsync:Ql,deepPartial:Mb,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,encode:Jl,encodeAsync:Xl,endsWith:Ni,enum:ot,exactOptional:ha,file:Qd,flattenError:Es,float32:Pd,float64:Dd,formatError:$s,fromJSONSchema:Ob,function:hr,getDiscriminatedOption:tl,getErrorMap:Lb,globalRegistry:kt,gt:fn,gte:Et,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,includes:Ai,input:Ub,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,iso:pf,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,length:wr,literal:E,locales:cl,looseObject:it,looseRecord:Kd,lowercase:Ti,lt:dn,lte:xt,mac:wd,map:Jd,maxLength:br,maxSize:Wn,memoizer:Ps,meta:lf,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,nan:nf,nanoid:hd,nativeEnum:Xd,negative:js,never:Hn,nonnegative:Bs,nonoptional:ba,nonpositive:Zs,normalize:Li,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,output:Gb,overwrite:en,parse:Vl,parseAsync:ql,partialRecord:Wd,pipe:ci,positive:Gs,prefault:va,preprocess:fo,prettifyError:kc,promise:af,properties:Ri,property:Hs,readonly:$a,record:xe,refine:za,regex:$i,regexes:Is,registry:Ds,safeDecode:td,safeDecodeAsync:rd,safeEncode:ed,safeEncodeAsync:nd,safeParse:Wl,safeParseAsync:Kl,set:Yd,setErrorMap:zb,size:vr,slugify:Mi,startsWith:Ii,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,toJSONSchema:Zl,toLowerCase:Di,toUpperCase:Oi,toZod:vs,transform:uo,treeifyError:_c,trim:Pi,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,uppercase:Ci,url:ld,util:vc,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,validate:Cs,validateAsync:As,void:Zd,withParser:Os,xid:yd,xor:qd},Symbol.toStringTag,{value:"Module"})),gx=Object.freeze(Object.defineProperty({__proto__:null,$brand:wc,$input:dl,$output:ll,INVALID:vt,NEVER:bc,TimePrecision:Pl,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodError:Nb,ZodExactOptional:co,ZodFile:da,get ZodFirstPartyTypeKind(){return as},ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodIssueCode:Rb,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRealError:wt,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,clone:Ge,codec:rf,coerce:jb,compile:fl,config:Qe,core:Cb,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,decode:Yl,decodeAsync:Ql,deepPartial:Mb,default:Gh,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,encode:Jl,encodeAsync:Xl,endsWith:Ni,enum:ot,exactOptional:ha,file:Qd,flattenError:Es,float32:Pd,float64:Dd,formatError:$s,fromJSONSchema:Ob,function:hr,getDiscriminatedOption:tl,getErrorMap:Lb,globalRegistry:kt,gt:fn,gte:Et,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,includes:Ai,input:Ub,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,iso:pf,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,length:wr,literal:E,locales:cl,looseObject:it,looseRecord:Kd,lowercase:Ti,lt:dn,lte:xt,mac:wd,map:Jd,maxLength:br,maxSize:Wn,memoizer:Ps,meta:lf,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,nan:nf,nanoid:hd,nativeEnum:Xd,negative:js,never:Hn,nonnegative:Bs,nonoptional:ba,nonpositive:Zs,normalize:Li,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,output:Gb,overwrite:en,parse:Vl,parseAsync:ql,partialRecord:Wd,pipe:ci,positive:Gs,prefault:va,preprocess:fo,prettifyError:kc,promise:af,properties:Ri,property:Hs,readonly:$a,record:xe,refine:za,regex:$i,regexes:Is,registry:Ds,safeDecode:td,safeDecodeAsync:rd,safeEncode:ed,safeEncodeAsync:nd,safeParse:Wl,safeParseAsync:Kl,set:Yd,setErrorMap:zb,size:vr,slugify:Mi,startsWith:Ii,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,toJSONSchema:Zl,toLowerCase:Di,toUpperCase:Oi,toZod:vs,transform:uo,treeifyError:_c,trim:Pi,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,uppercase:Ci,url:ld,util:vc,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,validate:Cs,validateAsync:As,void:Zd,withParser:Os,xid:yd,xor:qd,z:Gh},Symbol.toStringTag,{value:"Module"})),On="io.modelcontextprotocol/related-task",Da="2.0",Xe=Ra(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Zb=we([x(),ge().int()]),Bb=x();it({ttl:ge().optional(),pollInterval:ge().optional()});const yx=T({ttl:ge().optional()}),vx=T({taskId:x()}),mf=it({progressToken:Zb.optional(),[On]:vx.optional()}),Ct=T({_meta:mf.optional()}),ho=Ct.extend({task:yx.optional()}),bx=e=>ho.safeParse(e).success,st=T({method:x(),params:Ct.loose().optional()}),Ot=T({_meta:mf.optional()}),Mt=T({method:x(),params:Ot.loose().optional()}),at=it({_meta:mf.optional()}),po=we([x(),ge().int()]),Hb=T({jsonrpc:E(Da),id:po,...st.shape}).strict(),jh=e=>Hb.safeParse(e).success,Vb=T({jsonrpc:E(Da),...Mt.shape}).strict(),wx=e=>Vb.safeParse(e).success,gf=T({jsonrpc:E(Da),id:po,result:at}).strict(),zo=e=>gf.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 yf=T({jsonrpc:E(Da),id:po.optional(),error:T({code:ge().int(),message:x(),data:ze().optional()})}).strict(),_x=e=>yf.safeParse(e).success,kx=we([Hb,Vb,gf,yf]);we([gf,yf]);const vf=at.strict(),Sx=Ot.extend({requestId:po.optional(),reason:x().optional()}),bf=Mt.extend({method:E("notifications/cancelled"),params:Sx}),xx=T({src:x(),mimeType:x().optional(),sizes:ue(x()).optional(),theme:ot(["light","dark"]).optional()}),mo=T({icons:ue(xx).optional()}),pr=T({name:x(),title:x().optional()}),Oa=pr.extend({...pr.shape,...mo.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),Ex=zr(T({applyDefaults:Le().optional()}),xe(x(),ze())),$x=fo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,zr(T({form:Ex.optional(),url:Xe.optional()}),xe(x(),ze()).optional())),Tx=it({list:Xe.optional(),cancel:Xe.optional(),requests:it({sampling:it({createMessage:Xe.optional()}).optional(),elicitation:it({create:Xe.optional()}).optional()}).optional()}),Cx=it({list:Xe.optional(),cancel:Xe.optional(),requests:it({tools:it({call:Xe.optional()}).optional()}).optional()}),Ax=T({experimental:xe(x(),Xe).optional(),sampling:T({context:Xe.optional(),tools:Xe.optional()}).optional(),elicitation:$x.optional(),roots:T({listChanged:Le().optional()}).optional(),tasks:Tx.optional(),extensions:xe(x(),Xe).optional()}),Ix=Ct.extend({protocolVersion:x(),capabilities:Ax,clientInfo:Oa}),Nx=st.extend({method:E("initialize"),params:Ix}),Rx=T({experimental:xe(x(),Xe).optional(),logging:Xe.optional(),completions:Xe.optional(),prompts:T({listChanged:Le().optional()}).optional(),resources:T({subscribe:Le().optional(),listChanged:Le().optional()}).optional(),tools:T({listChanged:Le().optional()}).optional(),tasks:Cx.optional(),extensions:xe(x(),Xe).optional()}),zx=at.extend({protocolVersion:x(),capabilities:Rx,serverInfo:Oa,instructions:x().optional()}),Lx=Mt.extend({method:E("notifications/initialized"),params:Ot.optional()}),Ma=st.extend({method:E("ping"),params:Ct.optional()}),Px=T({progress:ge(),total:Fe(ge()),message:Fe(x())}),Dx=T({...Ot.shape,...Px.shape,progressToken:Zb}),wf=Mt.extend({method:E("notifications/progress"),params:Dx}),Ox=Ct.extend({cursor:Bb.optional()}),go=st.extend({params:Ox.optional()}),yo=at.extend({nextCursor:Bb.optional()}),Mx=ot(["working","input_required","completed","failed","cancelled"]),vo=T({taskId:x(),status:Mx,ttl:we([ge(),io()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Fe(ge()),statusMessage:Fe(x())}),_f=at.extend({task:vo}),Fx=Ot.merge(vo),us=Mt.extend({method:E("notifications/tasks/status"),params:Fx}),kf=st.extend({method:E("tasks/get"),params:Ct.extend({taskId:x()})}),Sf=at.merge(vo),xf=st.extend({method:E("tasks/result"),params:Ct.extend({taskId:x()})});at.loose();const Ef=go.extend({method:E("tasks/list")}),$f=yo.extend({tasks:ue(vo)}),Tf=st.extend({method:E("tasks/cancel"),params:Ct.extend({taskId:x()})}),Ux=at.merge(vo),qb=T({uri:x(),mimeType:Fe(x()),_meta:xe(x(),ze()).optional()}),Wb=qb.extend({text:x()}),Cf=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Kb=qb.extend({blob:Cf}),bo=ot(["user","assistant"]),Mr=T({audience:ue(bo).optional(),priority:ge().min(0).max(1).optional(),lastModified:Pb({offset:!0}).optional()}),Jb=T({...pr.shape,...mo.shape,uri:x(),description:Fe(x()),mimeType:Fe(x()),size:Fe(ge()),annotations:Mr.optional(),_meta:Fe(it({}))}),Gx=T({...pr.shape,...mo.shape,uriTemplate:x(),description:Fe(x()),mimeType:Fe(x()),annotations:Mr.optional(),_meta:Fe(it({}))}),jx=go.extend({method:E("resources/list")}),Yb=yo.extend({resources:ue(Jb)}),Zx=go.extend({method:E("resources/templates/list")}),Bx=yo.extend({resourceTemplates:ue(Gx)}),Af=Ct.extend({uri:x()}),Hx=Af,Vx=st.extend({method:E("resources/read"),params:Hx}),Xb=at.extend({contents:ue(we([Wb,Kb]))}),qx=Mt.extend({method:E("notifications/resources/list_changed"),params:Ot.optional()}),Wx=Af,Kx=st.extend({method:E("resources/subscribe"),params:Wx}),Jx=Af,Yx=st.extend({method:E("resources/unsubscribe"),params:Jx}),Xx=Ot.extend({uri:x()}),Qx=Mt.extend({method:E("notifications/resources/updated"),params:Xx}),eE=T({name:x(),description:Fe(x()),required:Fe(Le())}),tE=T({...pr.shape,...mo.shape,description:Fe(x()),arguments:Fe(ue(eE)),_meta:Fe(it({}))}),nE=go.extend({method:E("prompts/list")}),rE=yo.extend({prompts:ue(tE)}),iE=Ct.extend({name:x(),arguments:xe(x(),x()).optional()}),oE=st.extend({method:E("prompts/get"),params:iE}),If=T({type:E("text"),text:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),Nf=T({type:E("image"),data:Cf,mimeType:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),Rf=T({type:E("audio"),data:Cf,mimeType:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),sE=T({type:E("tool_use"),name:x(),id:x(),input:xe(x(),ze()),_meta:xe(x(),ze()).optional()}),Qb=T({type:E("resource"),resource:we([Wb,Kb]),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),ew=Jb.extend({type:E("resource_link")}),wo=we([If,Nf,Rf,ew,Qb]),aE=T({role:bo,content:wo}),uE=at.extend({description:x().optional(),messages:ue(aE)}),cE=Mt.extend({method:E("notifications/prompts/list_changed"),params:Ot.optional()}),lE=T({title:x().optional(),readOnlyHint:Le().optional(),destructiveHint:Le().optional(),idempotentHint:Le().optional(),openWorldHint:Le().optional()}),dE=T({taskSupport:ot(["required","optional","forbidden"]).optional()}),zf=T({...pr.shape,...mo.shape,description:x().optional(),inputSchema:T({type:E("object"),properties:xe(x(),Xe).optional(),required:ue(x()).optional()}).catchall(ze()),outputSchema:T({type:E("object"),properties:xe(x(),Xe).optional(),required:ue(x()).optional()}).catchall(ze()).optional(),annotations:lE.optional(),execution:dE.optional(),_meta:xe(x(),ze()).optional()}),tw=go.extend({method:E("tools/list")}),fE=yo.extend({tools:ue(zf)}),Fa=at.extend({content:ue(wo).default([]),structuredContent:xe(x(),ze()).optional(),isError:Le().optional()});Fa.or(at.extend({toolResult:ze()}));const hE=ho.extend({name:x(),arguments:xe(x(),ze()).optional()}),nw=st.extend({method:E("tools/call"),params:hE}),pE=Mt.extend({method:E("notifications/tools/list_changed"),params:Ot.optional()});T({autoRefresh:Le().default(!0),debounceMs:ge().int().nonnegative().default(300)});const rw=ot(["debug","info","notice","warning","error","critical","alert","emergency"]),mE=Ct.extend({level:rw}),gE=st.extend({method:E("logging/setLevel"),params:mE}),yE=Ot.extend({level:rw,logger:x().optional(),data:ze()}),vE=Mt.extend({method:E("notifications/message"),params:yE}),bE=T({name:x().optional()}),wE=T({hints:ue(bE).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),_E=T({mode:ot(["auto","required","none"]).optional()}),kE=T({type:E("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:ue(wo).default([]),structuredContent:T({}).loose().optional(),isError:Le().optional(),_meta:xe(x(),ze()).optional()}),SE=ao("type",[If,Nf,Rf]),cs=ao("type",[If,Nf,Rf,sE,kE]),xE=T({role:bo,content:we([cs,ue(cs)]),_meta:xe(x(),ze()).optional()}),EE=ho.extend({messages:ue(xE),modelPreferences:wE.optional(),systemPrompt:x().optional(),includeContext:ot(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ue(x()).optional(),metadata:Xe.optional(),tools:ue(zf).optional(),toolChoice:_E.optional()}),$E=st.extend({method:E("sampling/createMessage"),params:EE}),iw=at.extend({model:x(),stopReason:Fe(ot(["endTurn","stopSequence","maxTokens"]).or(x())),role:bo,content:SE}),ow=at.extend({model:x(),stopReason:Fe(ot(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:bo,content:we([cs,ue(cs)])}),TE=T({type:E("boolean"),title:x().optional(),description:x().optional(),default:Le().optional()}),CE=T({type:E("string"),title:x().optional(),description:x().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:ot(["email","uri","date","date-time"]).optional(),default:x().optional()}),AE=T({type:ot(["number","integer"]),title:x().optional(),description:x().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),IE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ue(x()),default:x().optional()}),NE=T({type:E("string"),title:x().optional(),description:x().optional(),oneOf:ue(T({const:x(),title:x()})),default:x().optional()}),RE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ue(x()),enumNames:ue(x()).optional(),default:x().optional()}),zE=we([IE,NE]),LE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({type:E("string"),enum:ue(x())}),default:ue(x()).optional()}),PE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({anyOf:ue(T({const:x(),title:x()}))}),default:ue(x()).optional()}),DE=we([LE,PE]),OE=we([RE,zE,DE]),ME=we([OE,TE,CE,AE]),FE=ho.extend({mode:E("form").optional(),message:x(),requestedSchema:T({type:E("object"),properties:xe(x(),ME),required:ue(x()).optional()})}),UE=ho.extend({mode:E("url"),message:x(),elicitationId:x(),url:x().url()}),GE=we([FE,UE]),jE=st.extend({method:E("elicitation/create"),params:GE}),ZE=Ot.extend({elicitationId:x()}),BE=Mt.extend({method:E("notifications/elicitation/complete"),params:ZE}),HE=at.extend({action:ot(["accept","decline","cancel"]),content:fo(e=>e===null?void 0:e,xe(x(),we([x(),ge(),Le(),ue(x())])).optional())}),VE=T({type:E("ref/resource"),uri:x()}),qE=T({type:E("ref/prompt"),name:x()}),WE=Ct.extend({ref:we([qE,VE]),argument:T({name:x(),value:x()}),context:T({arguments:xe(x(),x()).optional()}).optional()}),KE=st.extend({method:E("completion/complete"),params:WE}),JE=at.extend({completion:it({values:ue(x()).max(100),total:Fe(ge().int()),hasMore:Fe(Le())})}),YE=T({uri:x().startsWith("file://"),name:x().optional(),_meta:xe(x(),ze()).optional()}),XE=st.extend({method:E("roots/list"),params:Ct.optional()}),QE=at.extend({roots:ue(YE)}),e$=Mt.extend({method:E("notifications/roots/list_changed"),params:Ot.optional()});we([Ma,Nx,KE,gE,oE,nE,jx,Zx,Vx,Kx,Yx,nw,tw,kf,xf,Ef,Tf]);we([bf,wf,Lx,e$,us]);we([vf,iw,ow,HE,QE,Sf,$f,_f]);we([Ma,$E,jE,XE,kf,xf,Ef,Tf]);we([bf,wf,vE,Qx,qx,pE,cE,us,BE]);we([vf,zx,JE,uE,rE,Yb,Bx,Xb,Fa,fE,Sf,$f,_f]);class $e 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 t$(i.elicitations,n)}return new $e(t,n,r)}}class t$ extends $e{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Re.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function zn(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Zh(e){const n=B0(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=H0(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Bh(e,t){const n=Ab(e,t);if(!n.success)throw n.error;return n.data}const n$=6e4;class r${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(bf,n=>{this._oncancel(n)}),this.setNotificationHandler(wf,n=>{this._onprogress(n)}),this.setRequestHandler(Ma,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(kf,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new $e(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(xf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new $e(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 $e(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 $e(Re.InvalidParams,`Task not found: ${o}`);if(!zn(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(zn(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[On]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Ef,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 $e(Re.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Tf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new $e(Re.InvalidParams,`Task not found: ${n.params.taskId}`);if(zn(i.status))throw new $e(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 $e(Re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof $e?i:new $e(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),$e.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),zo(o)||_x(o)?this._onresponse(o):jh(o)?this._onrequest(o,s):wx(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=$e.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?.[On]?.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 $e(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(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}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=bx(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,g)=>{if(l.signal.aborted)throw new $e(Re.ConnectionClosed,"Request was cancelled");const w={...g,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const y=w.relatedTask?.taskId??o;return y&&f&&await f.updateTaskStatus(y,"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 $e(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),zo(t))r(t);else{const s=new $e(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(zo(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),zo(t))i(t);else{const s=$e.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 $e?s:new $e(Re.InternalError,String(s))}}return}let o;try{const s=await this.request(t,_f,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new $e(Re.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},zn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new $e(Re.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new $e(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 $e?s:new $e(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=y=>{l(y)};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(y){d(y);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||{},[On]:u}});const p=y=>{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(y)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=y instanceof $e?y:new $e(Re.RequestTimeout,String(y));l(b)};this._responseHandlers.set(f,y=>{if(!r?.signal?.aborted){if(y instanceof Error)return l(y);try{const b=Ab(n,y.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??n$,g=()=>p($e.fromError(Re.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,g,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const y=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,y),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(y=>{this._cleanupTimeout(f),l(y)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Sf,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},$f,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Ux,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||{},[On]: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||{},[On]: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||{},[On]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Zh(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Bh(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=Zh(t);this._notificationHandlers.set(r,i=>{const o=Bh(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 $e(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 $e(Re.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new $e(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 $e(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=us.parse({method:"notifications/tasks/status",params:a});await this.notification(u),zn(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 $e(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(zn(a.status))throw new $e(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=us.parse({method:"notifications/tasks/status",params:u});await this.notification(c),zn(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Hh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function i$(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];Hh(s)&&Hh(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 o$ extends r${_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 s$="2026-01-26",a$="ui/notifications/tool-input-partial";class sw{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=kx.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!==a$&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var u$=we([E("light"),E("dark")]).describe("Color theme preference for the host environment."),li=we([E("inline"),E("fullscreen"),E("pip")]).describe("Display mode for UI presentation."),c$=we([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."),l$=xe(c$.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 Dv(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;Dv(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 Ov=new Set(["type","properties","required","additionalProperties"]),Ih=["oneOf","anyOf"];function Nh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Du(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Ov.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]??Nh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:Du(a)??{allOf:a};$t(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=Nh(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 M0(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Ov)if(i in e)return;const n=t.filter(i=>Ih.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=Du(t);else{const i=n[0],o=Ih.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=>Du([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,ti(e,r))}function ur(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)):ti(c,p),ti(c,l),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(p.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}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())Dv(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)??[])M0(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)}ti(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,$t(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:si(t,"input",e.processors),output:si(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 Mv=(e,t={})=>n=>{const r=sr({...n,processors:t});return De(e,r),ar(r,e),ur(r,e)},si=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=sr({...i??{},target:o,io:t,processors:n});return De(e,s),ar(s,e),ur(s,e)},cr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},lr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rh=(e,t)=>{cr(e,"minimum",t),lr(e,"maximum",t)},Fv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Uv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Gv=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},jv=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},zh=(e,t)=>cr(e,"minimum",t.minimum),Lh=(e,t)=>lr(e,"maximum",t.maximum),Ph=e=>(t,n)=>{jv(t,n.format);const[r,i]=e[n.format];cr(t,"minimum",r),lr(t,"maximum",i)},F0={greater_than:(e,t)=>cr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>lr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Fv(e,t.value),number_format:Ph(pc),bigint_format:Ph(mc),min_length:zh,max_length:Lh,length_equals:(e,t)=>Rh(e,t.length),min_size:zh,max_size:Lh,size_equals:(e,t)=>Rh(e,t.size),string_format:(e,t)=>{jv(e,t.format),t.pattern&&Uv(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)=>Gv(e,t.mime)};function et(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)F0[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&cr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&cr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&lr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&lr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Fv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Gv(t,i.mime);for(const o of i.patterns??[])Uv(t,o);return t}const U0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},G0=new Map([[qc,Vm],[zs,qm]]),Zv=e=>G0.get(e)??e,Bv=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=et(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=U0[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(Zv);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}))])}},Hv=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=et(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)):tt(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...g]=p;m!==void 0&&(i.multipleOf=m),g.length&&(i.allOf=[...i.allOf??[],...g.map(w=>({multipleOf:w}))])}},Vv=(e,t,n,r)=>{n.type="boolean"},qv=(e,t,n,r)=>{tt(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Wv=(e,t,n,r)=>{tt(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Kv=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Jv=(e,t,n,r)=>{tt(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Yv=(e,t,n,r)=>{tt(e,t,n,r,"Void cannot be represented in JSON Schema")},Xv=(e,t,n,r)=>{n.not={}},Qv=(e,t,n,r)=>{},eb=(e,t,n,r)=>{},tb=(e,t,n,r)=>{tt(e,t,n,r,"Date cannot be represented in JSON Schema")},nb=(e,t,n,r)=>{const i=e._zod.def,o=es(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},rb=(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(tt(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(tt(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},ib=(e,t,n,r)=>{tt(e,t,n,r,"NaN cannot be represented in JSON Schema")},ob=(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},sb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=et(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})))},ab=(e,t,n,r)=>{n.type="boolean"},ub=(e,t,n,r)=>{tt(e,t,n,r,"Custom types cannot be represented in JSON Schema")},cb=(e,t,n,r)=>{tt(e,t,n,r,"Function types cannot be represented in JSON Schema")},lb=(e,t,n,r)=>{tt(e,t,n,r,"Transforms cannot be represented in JSON Schema")},db=(e,t,n,r)=>{tt(e,t,n,r,"Map cannot be represented in JSON Schema")},fb=(e,t,n,r)=>{tt(e,t,n,r,"Set cannot be represented in JSON Schema")},hb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=et(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 ai(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ai(t.out):t.type==="catch"?ai(t.innerType):e._zod.optin}const pb=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&tt(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)$t(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"?ai(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)},Ul=(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},mb=(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)},gb=(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,g)=>De(m,t,{...r,path:[...r.path,s,g]})),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"?ai(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}=et(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Ou(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=Ou(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const g=m.map(w=>Ou(e,w,n));g.some((w,y)=>w!==m[y])&&(t={...t,[p]:g})}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")?yr:Lc).source)),h}const Mu=new WeakMap;function j0(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 Mu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Ou(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 yb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=et(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)$t(i.patternProperties,Zv(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=Mu.get(t);l||(l=[],Mu.set(t,l),t.deferred.push(()=>j0(t))),l.push(e)}i.additionalProperties=De(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&ai(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))}},vb=(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"}]},bb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Gl=Symbol();function wb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(tt(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Gl):JSON.parse(s)}const _b=(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=wb(i.defaultValue,e,t,n,r);s!==Gl&&(n.default=s)},kb=(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=wb(i.defaultValue,e,t,n,r);s!==Gl&&(n._prefault=s)},Sb=(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{tt(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},xb=(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},Eb=(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},$b=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},jl=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Tb=(e,t,n,r)=>{const i=e._zod.innerType;De(i,t,r);const o=t.seen.get(e);o.ref=i},Fu={string:Bv,number:Hv,boolean:Vv,bigint:qv,symbol:Wv,null:Kv,undefined:Jv,void:Yv,never:Xv,any:Qv,unknown:eb,date:tb,enum:nb,literal:rb,nan:ib,template_literal:ob,file:sb,success:ab,custom:ub,function:cb,transform:lb,map:db,set:fb,array:hb,object:pb,union:Ul,intersection:mb,tuple:gb,record:yb,nullable:vb,nonoptional:bb,default:_b,prefault:kb,catch:Sb,pipe:xb,readonly:Eb,promise:$b,optional:jl,lazy:Tb};function Zl(e,t){if("_idmap"in e){const r=e,i=sr({...t,processors:Fu}),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;ar(i,l),$t(s,c,ur(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=sr({...t,processors:Fu});return De(e,n),ar(n,e),ur(n,e)}class Z0{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=sr({processors:Fu,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,ar(this.ctx,t);const r=ur(this.ctx,t),{"~standard":i,...o}=r;return o}}const B0=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Cb=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:dy,$ZodArray:gy,$ZodAsyncError:rn,$ZodBase64:Qg,$ZodBase64URL:ey,$ZodBigInt:el,$ZodBigIntFormat:ay,$ZodBoolean:Qc,$ZodCIDRv4:Yg,$ZodCIDRv6:Xg,$ZodCUID:Fg,$ZodCUID2:Ug,$ZodCatch:My,$ZodCheck:je,$ZodCheckBigIntFormat:hg,$ZodCheckEndsWith:Eg,$ZodCheckGreaterThan:Mc,$ZodCheckIncludes:Sg,$ZodCheckLengthEquals:bg,$ZodCheckLessThan:Oc,$ZodCheckLowerCase:_g,$ZodCheckMaxLength:yg,$ZodCheckMaxSize:pg,$ZodCheckMimeType:Cg,$ZodCheckMinLength:vg,$ZodCheckMinSize:mg,$ZodCheckMultipleOf:dg,$ZodCheckNumberFormat:fg,$ZodCheckOverwrite:Ag,$ZodCheckProperties:Tg,$ZodCheckProperty:$g,$ZodCheckRegex:wg,$ZodCheckSizeEquals:gg,$ZodCheckStartsWith:xg,$ZodCheckStringFormat:xi,$ZodCheckUpperCase:kg,$ZodCodec:ol,$ZodCreditCard:ny,$ZodCustom:Hy,$ZodCustomStringFormat:oy,$ZodCyclicError:Vy,$ZodDate:my,$ZodDefault:Ly,$ZodDiscriminatedUnion:Sy,$ZodE164:ty,$ZodEmail:Lg,$ZodEmoji:Og,$ZodEncodeError:xs,$ZodEnum:Cy,$ZodError:Em,$ZodExactOptional:Ry,$ZodFile:Iy,$ZodFunction:Zy,$ZodGUID:Rg,$ZodIBAN:ry,$ZodIPv4:Wg,$ZodIPv6:Kg,$ZodISODate:Hg,$ZodISODateTime:Bg,$ZodISODuration:qg,$ZodISOTime:Vg,$ZodIntersection:xy,$ZodJWT:iy,$ZodKSUID:Zg,$ZodLazy:sl,$ZodLiteral:Ay,$ZodMAC:Jg,$ZodMap:$y,$ZodNaN:Fy,$ZodNanoID:Mg,$ZodNever:hy,$ZodNonOptional:Dy,$ZodNull:ly,$ZodNullable:zy,$ZodNumber:Xc,$ZodNumberFormat:sy,$ZodObject:by,$ZodObjectJIT:wy,$ZodOptional:rl,$ZodPipe:il,$ZodPrefault:Py,$ZodPreprocess:Uy,$ZodPromise:By,$ZodReadonly:Gy,$ZodRealError:Tt,$ZodRecord:Ey,$ZodRegistry:Ky,$ZodSet:Ty,$ZodString:Ei,$ZodStringFormat:Me,$ZodSuccess:Oy,$ZodSymbol:uy,$ZodTemplateLiteral:jy,$ZodTransform:Ny,$ZodTuple:nl,$ZodType:me,$ZodULID:Gg,$ZodURL:Dg,$ZodUUID:zg,$ZodUndefined:cy,$ZodUnion:Ls,$ZodUnknown:fy,$ZodVoid:py,$ZodXID:jg,$ZodXor:_y,$brand:wc,$constructor:S,$input:dl,$output:ll,Doc:Fc,INVALID:vt,JSONSchema:B0,JSONSchemaGenerator:Z0,NEVER:bc,TimePrecision:Pl,URL_BAD_FORMAT:Gc,URL_UNPARSEABLE:ii,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,_any:wv,_array:Tv,_base64:Nl,_base64url:Rl,_bigint:hv,_boolean:dv,_catch:R0,_check:Rv,_cidrv4:Al,_cidrv6:Il,_coercedBigint:pv,_coercedBoolean:fv,_coercedDate:Ev,_coercedNumber:ov,_coercedString:ev,_creditCard:nv,_cuid:kl,_cuid2:Sl,_custom:Av,_date:xv,_decode:xc,_decodeAsync:$c,_default:A0,_discriminatedUnion:y0,_e164:zl,_email:pl,_emoji:wl,_encode:Sc,_encodeAsync:Ec,_endsWith:Ni,_enum:S0,_file:Cv,_float32:av,_float64:uv,_gt:fn,_gte:Et,_guid:ml,_iban:rv,_includes:Ai,_int:sv,_int32:cv,_int64:mv,_intersection:v0,_ipv4:Tl,_ipv6:Cl,_isoDate:Ol,_isoDateTime:Dl,_isoDuration:Fl,_isoTime:Ml,_jwt:Ll,_ksuid:$l,_lazy:D0,_length:wr,_literal:E0,_lowercase:Ti,_lt:dn,_lte:xt,_mac:tv,_map:_0,_max:xt,_maxLength:br,_maxSize:Wn,_mime:zi,_min:Et,_minLength:$n,_minSize:hn,_multipleOf:Bn,_nan:$v,_nanoid:_l,_nativeEnum:x0,_negative:js,_never:kv,_nonnegative:Bs,_nonoptional:I0,_nonpositive:Zs,_normalize:Li,_null:bv,_nullable:C0,_number:iv,_optional:T0,_overwrite:en,_parse:vi,_parseAsync:bi,_pipe:z0,_positive:Gs,_promise:O0,_properties:Ri,_property:Hs,_readonly:L0,_record:w0,_refine:Iv,_regex:$i,_safeDecode:Cc,_safeDecodeAsync:Ic,_safeEncode:Tc,_safeEncodeAsync:Ac,_safeParse:wi,_safeParseAsync:_i,_set:k0,_size:vr,_slugify:Mi,_startsWith:Ii,_string:Qy,_stringFormat:_r,_stringbool:Pv,_success:N0,_superRefine:Nv,_symbol:yv,_templateLiteral:P0,_toLowerCase:Di,_toUpperCase:Oi,_transform:$0,_trim:Pi,_tuple:b0,_uint32:lv,_uint64:gv,_ulid:xl,_undefined:vv,_union:m0,_unknown:_v,_uppercase:Ci,_url:Us,_uuid:gl,_uuidv4:yl,_uuidv6:vl,_uuidv7:bl,_void:Sv,_xid:El,_xor:g0,base64Charset:qc,base64urlCharset:zs,canParseURL:jc,clone:Ge,compile:fl,compileFn:Ms,config:Qe,createStandardJSONSchemaMethod:si,createToJSONSchemaMethod:Mv,decode:Tk,decodeAsync:Ak,describe:zv,encode:$k,encodeAsync:Ck,extractDefs:ar,finalize:ur,flattenError:Es,formatError:$s,getDiscriminatedOption:tl,globalConfig:yt,globalRegistry:kt,handleUnrepresentable:tt,initializeContext:sr,isBackEdge:ul,isRecursiveSchema:al,isValidBase64:Rs,isValidBase64URL:Wc,isValidCIDRv6:Vc,isValidCreditCard:Kc,isValidIBAN:Jc,isValidIPv6:Ns,isValidJWT:Yc,locales:cl,memoizer:Ps,mergeValues:oi,meta:Lv,parse:Au,parseAsync:Iu,parseURLObject:Pg,prettifyError:kc,process:De,processSchema:De,regexes:Is,registry:Ds,safeDecode:Nk,safeDecodeAsync:zk,safeEncode:Ik,safeEncodeAsync:Rk,safeParse:Tm,safeParseAsync:kk,standardProps:Uc,stripTabAndNewline:os,toDotPath:$m,toJSONSchema:Zl,toZod:vs,treeifyError:_c,urlHostnameOk:Bc,urlProtocolOk:Hc,util:vc,validate:Cs,validateAsync:As,validateURL:Zc,version:Ig,withParser:Os},Symbol.toStringTag,{value:"Module"})),Dh=Symbol("z.visit/resolving");function Bl(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===Dh)return new sl({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,Dh);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?Ge(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:Ge(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?Ge(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:Ge(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:Ge(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?Ge(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:Ge(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:Ge(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:Ge(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:Ge(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return Ge(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 Hl(e){return!!e._zod}function Ab(e,t){return Hl(e)?Tm(e,t):e.safeParse(t)}function H0(e){if(!e)return;let t;if(Hl(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function V0(e){if(Hl(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 q0=()=>{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=bm(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 ${hc(o.values[0])}`:`Invalid option: expected one of ${$u(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":""}: ${$u(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 W0(){return{localeError:q0()}}const K0=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Ni,gt:fn,gte:Et,includes:Ai,length:wr,lowercase:Ti,lt:dn,lte:xt,maxLength:br,maxSize:Wn,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,negative:js,nonnegative:Bs,nonpositive:Zs,normalize:Li,overwrite:en,positive:Gs,properties:Ri,property:Hs,regex:$i,size:vr,slugify:Mi,startsWith:Ii,toLowerCase:Di,toUpperCase:Oi,trim:Pi,uppercase:Ci},Symbol.toStringTag,{value:"Module"})),Oh=new WeakSet([Object.prototype,Error.prototype]);function Ro(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 Ib=(e,t)=>{Em.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Oh.has(n)||(Oh.add(n),Ro(n,"format",r=>i=>$s(r,i)),Ro(n,"flatten",r=>i=>Es(r,i)),Ro(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,ts,2)}),Ro(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,ts,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Nb=S("ZodError",Ib),wt=S("ZodError",Ib,void 0,{Parent:Error}),Vl=vi(wt),ql=bi(wt),Wl=wi(wt),Kl=_i(wt),Jl=Sc(wt),Yl=xc(wt),Xl=Ec(wt),Ql=$c(wt),ed=Tc(wt),td=Cc(wt),nd=Ac(wt),rd=Ic(wt);function J0(){yt.localeError||Qe(W0())}function Kn(){yt.memoizer||Qe({memoizer:Ps()})}const ye=S("ZodType",(e,t)=>(J0(),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 Ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(za(e,t))},superRefine(e,t){return this.check(La(e,t))},overwrite(e){return this.check(en(e))},optional(){return Fe(this)},exactOptional(){return ha(this)},nullable(){return fr(this)},nullish(){return Fe(fr(this))},nonoptional(e){return ba(this,e)},array(){return ue(this)},or(e){return we([this,e])},and(e){return zr(this,e)},transform(e){return ci(this,uo(e))},default(e){return ga(this,e)},prefault(e){return va(this,e)},catch(e){return ka(this,e)},pipe(e){return ci(this,e)},readonly(){return $a(this)},describe(e){const t=this.clone();return kt.add(t,{description:e}),t},meta(...e){if(e.length===0)return kt.get(this);const t=this.clone();return kt.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 Ss(this,"~standard",{...Uc(this),jsonSchema:{input:si(this,"input"),output:si(this,"output")}})},set"~standard"(e){cn(this,"~standard",e)},parse:function e(t,n){return Vl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ql(this,t,n,{callee:e})},safeParse(e,t){return Wl(this,e,t)},async safeParseAsync(e,t){return Kl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){cn(this,"spa",e)},validate(e,t){return Cs(this,e,t)},validateAsync(e,t){return As(this,e,t)},encode:function e(t,n){return Jl(this,t,n,{callee:e})},decode:function e(t,n){return Yl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Xl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ql(this,t,n,{callee:e})},safeEncode(e,t){return ed(this,e,t)},safeDecode(e,t){return td(this,e,t)},async safeEncodeAsync(e,t){return nd(this,e,t)},async safeDecodeAsync(e,t){return rd(this,e,t)},toJSONSchema(e){return Mv(this,{})(e)},get description(){return kt.get(this)?.description},get _def(){return this._zod.def}}),Fi=S("_ZodString",(e,t)=>{Ei.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bv(e,n,r)},yi({format:e=>et(e).format??null,minLength:e=>et(e).minimum??null,maxLength:e=>et(e).maximum??null},{regex(...e){return this.check($i(...e))},includes(...e){return this.check(Ai(...e))},startsWith(...e){return this.check(Ii(...e))},endsWith(...e){return this.check(Ni(...e))},min(...e){return this.check($n(...e))},max(...e){return this.check(br(...e))},length(...e){return this.check(wr(...e))},nonempty(...e){return this.check($n(1,...e))},lowercase(e){return this.check(Ti(e))},uppercase(e){return this.check(Ci(e))},trim(){return this.check(Pi())},normalize(...e){return this.check(Li(...e))},toLowerCase(){return this.check(Di())},toUpperCase(){return this.check(Oi())},slugify(){return this.check(Mi())}})),kr=S("ZodString",(e,t)=>{Ei.init(e,t),Fi.init(e,t)},{email(e){return this.check(pl(Ui,e))},url(e){return this.check(Us(Tr,e))},jwt(e){return this.check(Ll(no,e))},emoji(e){return this.check(wl(ji,e))},guid(e){return this.check(ml(Gi,e))},uuid(e){return this.check(gl(Vt,e))},uuidv4(e){return this.check(yl(Vt,e))},uuidv6(e){return this.check(vl(Vt,e))},uuidv7(e){return this.check(bl(Vt,e))},nanoid(e){return this.check(_l(Zi,e))},cuid(e){return this.check(kl(Bi,e))},cuid2(e){return this.check(Sl(Hi,e))},ulid(e){return this.check(xl(Vi,e))},base64(e){return this.check(Nl(Qi,e))},base64url(e){return this.check(Rl(eo,e))},xid(e){return this.check(El(qi,e))},ksuid(e){return this.check($l(Wi,e))},ipv4(e){return this.check(Tl(Ki,e))},ipv6(e){return this.check(Cl(Ji,e))},cidrv4(e){return this.check(Al(Yi,e))},cidrv6(e){return this.check(Il(Xi,e))},e164(e){return this.check(zl(to,e))},datetime(e){return this.check(Dl(Sr,e))},date(e){return this.check(Ol(xr,e))},time(e){return this.check(Ml(Er,e))},duration(e){return this.check(Fl($r,e))}});function x(e){return Qy(kr,e)}const Pe=S("ZodStringFormat",(e,t)=>{Me.init(e,t),Fi.init(e,t)}),Sr=S("ZodISODateTime",(e,t)=>{Bg.init(e,t),Pe.init(e,t)}),xr=S("ZodISODate",(e,t)=>{Hg.init(e,t),Pe.init(e,t)}),Er=S("ZodISOTime",(e,t)=>{Vg.init(e,t),Pe.init(e,t)}),$r=S("ZodISODuration",(e,t)=>{qg.init(e,t),Pe.init(e,t)}),Ui=S("ZodEmail",(e,t)=>{Lg.init(e,t),Pe.init(e,t)});function id(e){return pl(Ui,e)}const Gi=S("ZodGUID",(e,t)=>{Rg.init(e,t),Pe.init(e,t)});function od(e){return ml(Gi,e)}const Vt=S("ZodUUID",(e,t)=>{zg.init(e,t),Pe.init(e,t)});function sd(e){return gl(Vt,e)}function ad(e){return yl(Vt,e)}function ud(e){return vl(Vt,e)}function cd(e){return bl(Vt,e)}const Tr=S("ZodURL",(e,t)=>{Dg.init(e,t),Pe.init(e,t)});function ld(e){return Us(Tr,e)}function dd(e){return Us(Tr,{protocol:Nc,hostname:Km,...N(e)})}const ji=S("ZodEmoji",(e,t)=>{Og.init(e,t),Pe.init(e,t)});function fd(e){return wl(ji,e)}const Zi=S("ZodNanoID",(e,t)=>{Mg.init(e,t),Pe.init(e,t)});function hd(e){return _l(Zi,e)}const Bi=S("ZodCUID",(e,t)=>{Fg.init(e,t),Pe.init(e,t)});function pd(e){return kl(Bi,e)}const Hi=S("ZodCUID2",(e,t)=>{Ug.init(e,t),Pe.init(e,t)});function md(e){return Sl(Hi,e)}const Vi=S("ZodULID",(e,t)=>{Gg.init(e,t),Pe.init(e,t)});function gd(e){return xl(Vi,e)}const qi=S("ZodXID",(e,t)=>{jg.init(e,t),Pe.init(e,t)});function yd(e){return El(qi,e)}const Wi=S("ZodKSUID",(e,t)=>{Zg.init(e,t),Pe.init(e,t)});function vd(e){return $l(Wi,e)}const Ki=S("ZodIPv4",(e,t)=>{Wg.init(e,t),Pe.init(e,t)});function bd(e){return Tl(Ki,e)}const Vs=S("ZodMAC",(e,t)=>{Jg.init(e,t),Pe.init(e,t)});function wd(e){return tv(Vs,e)}const Ji=S("ZodIPv6",(e,t)=>{Kg.init(e,t),Pe.init(e,t)});function _d(e){return Cl(Ji,e)}const Yi=S("ZodCIDRv4",(e,t)=>{Yg.init(e,t),Pe.init(e,t)});function kd(e){return Al(Yi,e)}const Xi=S("ZodCIDRv6",(e,t)=>{Xg.init(e,t),Pe.init(e,t)});function Sd(e){return Il(Xi,e)}const Qi=S("ZodBase64",(e,t)=>{Qg.init(e,t),Pe.init(e,t)});function xd(e){return Nl(Qi,e)}const eo=S("ZodBase64URL",(e,t)=>{ey.init(e,t),Pe.init(e,t)});function Ed(e){return Rl(eo,e)}const to=S("ZodE164",(e,t)=>{ty.init(e,t),Pe.init(e,t)});function $d(e){return zl(to,e)}const qs=S("ZodCreditCard",(e,t)=>{ny.init(e,t),Pe.init(e,t)});function Td(e){return nv(qs,e)}const Ws=S("ZodIBAN",(e,t)=>{ry.init(e,t),Pe.init(e,t)});function Cd(e){return rv(Ws,e)}const no=S("ZodJWT",(e,t)=>{iy.init(e,t),Pe.init(e,t)});function Ad(e){return Ll(no,e)}const Tn=S("ZodCustomStringFormat",(e,t)=>{oy.init(e,t),Pe.init(e,t)});function Id(e,t,n={}){return _r(Tn,e,t,n)}function Nd(e){return _r(Tn,"hostname",Wm,e)}function Rd(e){return _r(Tn,"hex",lg,e)}function zd(e){return _r(Tn,"currency_code",Ym,e)}function Ld(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Is[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return _r(Tn,r,i,t)}const Cr=S("ZodNumber",(e,t)=>{Xc.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hv(e,n,r,i),e.isFinite=!0},yi({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=et(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=et(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=et(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>et(e).format??null},{gt(e,t){return this.check(fn(e,t))},gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},lt(e,t){return this.check(dn(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(ui(e))},safe(e){return this.check(ui(e))},positive(e){return this.check(fn(0,e))},nonnegative(e){return this.check(Et(0,e))},negative(e){return this.check(dn(0,e))},nonpositive(e){return this.check(xt(0,e))},multipleOf(e,t){return this.check(Bn(e,t))},step(e,t){return this.check(Bn(e,t))},finite(){return this}}));function ge(e){return iv(Cr,e)}const Cn=S("ZodNumberFormat",(e,t)=>{sy.init(e,t),Cr.init(e,t)});function ui(e){return sv(Cn,e)}function Pd(e){return av(Cn,e)}function Dd(e){return uv(Cn,e)}function Od(e){return cv(Cn,e)}function Md(e){return lv(Cn,e)}const Ar=S("ZodBoolean",(e,t)=>{Qc.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r)});function Le(e){return dv(Ar,e)}const Ir=S("ZodBigInt",(e,t)=>{el.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qv(e,n,r,i)},yi({minValue:e=>et(e).minimum??null,maxValue:e=>et(e).maximum??null,format:e=>et(e).format??null},{gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},gt(e,t){return this.check(fn(e,t))},lt(e,t){return this.check(dn(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(fn(BigInt(0),e))},negative(e){return this.check(dn(BigInt(0),e))},nonpositive(e){return this.check(xt(BigInt(0),e))},nonnegative(e){return this.check(Et(BigInt(0),e))},multipleOf(e,t){return this.check(Bn(e,t))}}));function Fd(e){return hv(Ir,e)}const ro=S("ZodBigIntFormat",(e,t)=>{ay.init(e,t),Ir.init(e,t)});function Ud(e){return mv(ro,e)}function Gd(e){return gv(ro,e)}const Ks=S("ZodSymbol",(e,t)=>{uy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wv(e,n,r,i)});function jd(e){return yv(Ks,e)}const Js=S("ZodUndefined",(e,t)=>{cy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jv(e,n,r,i)});function dr(e){return vv(Js,e)}const Ys=S("ZodNull",(e,t)=>{ly.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r)});function io(e){return bv(Ys,e)}const Xs=S("ZodAny",(e,t)=>{dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qv()});function oo(){return wv(Xs)}const Qs=S("ZodUnknown",(e,t)=>{fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eb()});function ze(){return _v(Qs)}const ea=S("ZodNever",(e,t)=>{hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xv(e,n,r)});function Hn(e){return kv(ea,e)}const ta=S("ZodVoid",(e,t)=>{py.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yv(e,n,r,i)});function Zd(e){return Sv(ta,e)}const so=S("ZodDate",(e,t)=>{my.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tb(e,n,r,i),e.min=(n,r)=>e.check(Et(n,r)),e.max=(n,r)=>e.check(xt(n,r))},yi({minDate:e=>{const{minimum:t}=et(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=et(e);return t?new Date(t):null}},{}));function Bd(e){return xv(so,e)}const na=S("ZodArray",(e,t)=>{Kn(),gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hb(e,n,r,i),e.element=t.element},{min(e,t){return this.check($n(e,t))},nonempty(e){return this.check($n(1,e))},max(e,t){return this.check(br(e,t))},length(e,t){return this.check(wr(e,t))},unwrap(){return this.element}});function ue(e,t){return Tv(na,e,t)}function Hd(e){const t=e._zod.def.shape;return ot(Object.keys(t))}const Nr=S("ZodObject",(e,t)=>{Kn(),wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pb(e,n,r,i),Sm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return ot(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:ze()}))},loose(){return this.clone(lt(this._zod.def,{catchall:ze()}))},strict(){return this.clone(lt(this._zod.def,{catchall:Hn()}))},strip(){return this.clone(lt(this._zod.def,{catchall:void 0}))},extend(e){return hm(this,e)},safeExtend(e){return mm(this,e)},merge(e){return gm(this,e)},pick(e){return dm(this,e)},omit(e){return fm(this,e)},partial(...e){return Tu(Lr,this,e[0])},exactPartial(...e){return Tu(co,this,e[0],"exactPartial")},required(...e){return ym(lo,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...N(t)};return new Nr(n)}function Vd(e,t){return new Nr({type:"object",shape:e,catchall:Hn(),...N(t)})}function it(e,t){return new Nr({type:"object",shape:e,catchall:ze(),...N(t)})}const Rr=S("ZodUnion",(e,t)=>{Ls.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ul(e,n,r,i),e.options=t.options});function we(e,t){return new Rr({type:"union",options:e,...N(t)})}const ra=S("ZodXor",(e,t)=>{Rr.init(e,t),_y.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ul(e,n,r,i),e.options=t.options});function qd(e,t){return new ra({type:"union",options:e,inclusive:!1,...N(t)})}const ia=S("ZodDiscriminatedUnion",(e,t)=>{Rr.init(e,t),Sy.init(e,t)});function ao(e,t,n){return new ia({type:"union",options:t,discriminator:e,...N(n)})}const oa=S("ZodIntersection",(e,t)=>{xy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mb(e,n,r,i)});function zr(e,t){return new oa({type:"intersection",left:e,right:t})}const sa=S("ZodTuple",(e,t)=>{Kn(),nl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gb(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 Lr({type:"optional",innerType:t}))})}});function aa(e,t,n){const r=t instanceof me,i=r?n:t,o=r?t:null;return new sa({type:"tuple",items:e,rest:o,...N(i)})}const Vn=S("ZodRecord",(e,t)=>{Kn(),Ey.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function xe(e,t,n){return!t||!t._zod?new Vn({type:"record",keyType:x(),valueType:e,...N(t)}):new Vn({type:"record",keyType:e,valueType:t,...N(n)})}function Wd(e,t,n){return new Vn({type:"record",keyType:e,valueType:t,...N(n),partial:!0})}function Kd(e,t,n){return new Vn({type:"record",keyType:e,valueType:t,mode:"loose",...N(n)})}const ua=S("ZodMap",(e,t)=>{Kn(),$y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>db(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(hn(...n)),e.nonempty=n=>e.check(hn(1,n)),e.max=(...n)=>e.check(Wn(...n)),e.size=(...n)=>e.check(vr(...n))});function Jd(e,t,n){return new ua({type:"map",keyType:e,valueType:t,...N(n)})}const ca=S("ZodSet",(e,t)=>{Kn(),Ty.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fb(e,n,r,i),e.min=(...n)=>e.check(hn(...n)),e.nonempty=n=>e.check(hn(1,n)),e.max=(...n)=>e.check(Wn(...n)),e.size=(...n)=>e.check(vr(...n))});function Yd(e,t){return new ca({type:"set",valueType:e,...N(t)})}const qn=S("ZodEnum",(e,t)=>{Cy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,o)=>nb(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 qn({...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 qn({...t,checks:[],...N(i),entries:o})}});function ot(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new qn({type:"enum",entries:n,...N(t)})}function Xd(e,t){return new qn({type:"enum",entries:e,...N(t)})}const la=S("ZodLiteral",(e,t)=>{Ay.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rb(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 la({type:"literal",values:Array.isArray(e)?e:[e],...N(t)})}const da=S("ZodFile",(e,t)=>{Iy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r),e.min=(n,r)=>e.check(hn(n,r)),e.max=(n,r)=>e.check(Wn(n,r)),e.mime=(n,r)=>e.check(zi(Array.isArray(n)?n:[n],r))});function Qd(e){return Cv(da,e)}const fa=S("ZodTransform",(e,t)=>{Kn(),Ny.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new xs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(ir(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(ir(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function uo(e){return new fa({type:"transform",transform:e})}const Lr=S("ZodOptional",(e,t)=>{rl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Fe(e){return new Lr({type:"optional",innerType:e})}const co=S("ZodExactOptional",(e,t)=>{Ry.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ha(e){return new co({type:"optional",innerType:e})}const pa=S("ZodNullable",(e,t)=>{zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function fr(e){return new pa({type:"nullable",innerType:e})}function ef(e){return Fe(fr(e))}const ma=S("ZodDefault",(e,t)=>{Ly.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_b(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ga(e,t){return new ma({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():mi(t)}})}const ya=S("ZodPrefault",(e,t)=>{Py.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e,t){return new ya({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():mi(t)}})}const lo=S("ZodNonOptional",(e,t)=>{Dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ba(e,t){return new lo({type:"nonoptional",innerType:e,...N(t)})}const wa=S("ZodSuccess",(e,t)=>{Oy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r),e.unwrap=()=>e._zod.def.innerType});function tf(e){return new wa({type:"success",innerType:e})}const _a=S("ZodCatch",(e,t)=>{My.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ka(e,t){return new _a({type:"catch",innerType:e,catchValue:typeof t=="function"?t:yc(t)})}const Sa=S("ZodNaN",(e,t)=>{Fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r,i)});function nf(e){return $v(Sa,e)}const Pr=S("ZodPipe",(e,t)=>{il.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xb(e,n,r,i),e.in=t.in,e.out=t.out});function ci(e,t){return new Pr({type:"pipe",in:e,out:t})}const Dr=S("ZodCodec",(e,t)=>{Pr.init(e,t),ol.init(e,t)});function rf(e,t,n){return new Dr({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function of(e){const t=e._zod.def;return new Dr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const xa=S("ZodPreprocess",(e,t)=>{Pr.init(e,t),Uy.init(e,t)}),Ea=S("ZodReadonly",(e,t)=>{Gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Eb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function $a(e){return new Ea({type:"readonly",innerType:e})}const Ta=S("ZodTemplateLiteral",(e,t)=>{jy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r)});function sf(e,t){return new Ta({type:"template_literal",parts:e,...N(t)})}const Ca=S("ZodLazy",(e,t)=>{sl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tb(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function Aa(e){return new Ca({type:"lazy",getter:e})}const Ia=S("ZodPromise",(e,t)=>{By.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$b(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function af(e){return new Ia({type:"promise",innerType:e})}const Na=S("ZodFunction",(e,t)=>{Zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb(e,n,r,i)});function hr(e){return new Na({type:"function",input:Array.isArray(e?.input)?aa(e?.input):e?.input??ue(ze()),output:e?.output??ze()})}const Or=S("ZodCustom",(e,t)=>{Hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r,i)});function uf(e){const t=new je({check:"custom"});return t._zod.check=e,t}function Ra(e,t){return Av(Or,e??(()=>!0),t)}function za(e,t={}){return Iv(Or,e,t)}function La(e,t){return Nv(e,t)}const cf=zv,lf=Lv,Pa=S("ZodInstanceOf",(e,t)=>{Or.init(e,t)},{properties(e,t){return this.check(Ri(e,t))}});function df(e,t={}){const n=new Pa({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 ff=(...e)=>Pv({Codec:Dr,Boolean:Ar,String:kr},...e);function hf(e){const t=Aa(()=>we([x(e),ge(),Le(),io(),ue(t),xe(x(),t)]));return t}function fo(e,t){return new xa({type:"pipe",in:uo(e),out:t})}const Y0=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodExactOptional:co,ZodFile:da,ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,codec:rf,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,enum:ot,exactOptional:ha,file:Qd,float32:Pd,float64:Dd,function:hr,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,literal:E,looseObject:it,looseRecord:Kd,mac:wd,map:Jd,meta:lf,nan:nf,nanoid:hd,nativeEnum:Xd,never:Hn,nonoptional:ba,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,partialRecord:Wd,pipe:ci,prefault:va,preprocess:fo,promise:af,readonly:$a,record:xe,refine:za,set:Yd,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,transform:uo,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,url:ld,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,void:Zd,xid:yd,xor:qd},Symbol.toStringTag,{value:"Module"})),Rb={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){Qe({customError:e})}function Lb(){return Qe().customError}var as;as||(as={});function Pb(e){return Dl(Sr,e)}function X0(e){return Ol(xr,e)}function Q0(e){return Ml(Er,e)}function ex(e){return Fl($r,e)}const pf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,date:X0,datetime:Pb,duration:ex,time:Q0},Symbol.toStringTag,{value:"Module"})),H={...Y0,...K0,iso:pf},tx=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 nx(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 Mh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function rx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ix(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:rx(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 ox(e,t){return H.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 Uu(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=Uu(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=Uu(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 sx=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),ax=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ni(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ni):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>sx.has(t)?ni(n):!ax.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(ni))}function Fh(e){return e===1?"element":"elements"}function ux(e,t){return H.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=Uu(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 ${Fh(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 ${Fh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function Uh(e,t){if(e!==!1)return e===void 0||e===!0?H.any():gt(e,t)}const cx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Db(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return H.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 H.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=ix(i,t),s=gt(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 H.null();if(i.length===0)return H.never();if(i.length===1)return H.literal(i[0]);if(i.every(s=>typeof s=="string"))return H.enum(i);const o=i.map(s=>H.literal(s));return o.length<2?o[0]:H.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return H.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return Db(s,t)});return i.length===0?H.never():i.length===1?i[0]:H.union(i)}if(!n)return H.any();let r;switch(n){case"string":{let i=H.string();if(e.format){const o=e.format;o==="email"?i=i.check(H.email()):o==="uri"||o==="uri-reference"?i=i.check(H.url()):o==="uuid"||o==="guid"?i=i.check(H.uuid()):o==="date-time"?i=i.check(H.iso.datetime({offset:!0})):o==="date"?i=i.check(H.iso.date()):o==="time"?i=i.check(H.regex(cx)):o==="duration"?i=i.check(H.iso.duration()):o==="hostname"?i=i.check(H.hostname()):o==="ipv4"?i=i.check(H.ipv4()):o==="ipv6"?i=i.check(H.ipv6()):o==="mac"?i=i.check(H.mac()):o==="cidr"?i=i.check(H.cidrv4()):o==="cidr-v6"?i=i.check(H.cidrv6()):o==="base64"?i=i.check(H.base64()):o==="base64url"?i=i.check(H.base64url()):o==="e164"?i=i.check(H.e164()):o==="credit_card"?i=i.check(H.creditCard()):o==="iban"?i=i.check(H.iban()):o==="jwt"?i=i.check(H.jwt()):o==="emoji"?i=i.check(H.emoji()):o==="nanoid"?i=i.check(H.nanoid()):o==="cuid"?i=i.check(H.cuid()):o==="cuid2"?i=i.check(H.cuid2()):o==="ulid"?i=i.check(H.ulid()):o==="xid"?i=i.check(H.xid()):o==="ksuid"&&(i=i.check(H.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"?H.number().int():H.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=H.boolean();break}case"null":{r=H.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?gt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=gt(f,t);$t(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 g=gt(d[m],t),w=H.string().regex(new RegExp(m));h.push(H.looseRecord(w,g))}const p=[];if(Object.keys(i).length>0&&p.push(H.object(i).passthrough()),p.push(...h),p.length===0)r=H.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=H.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)m=H.intersection(m,p[g]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),g=f.map(y=>new RegExp(y)),w=r;r=r.check(y=>{if(!an(y.value))return;const b=[];for(const v of Object.keys(y.value))m.includes(v)||g.some(k=>k.test(v))||b.push(v);b.length&&y.issues.push({code:"unrecognized_keys",keys:b,input:y.value,inst:w})})}}else{const d=H.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=gt(f,t)}r=ox(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=>gt(d,t)),u=Mh(a,s),c=Array.isArray(o)?void 0:Uh(o,t),l=H.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(H.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>gt(d,t)),u=Mh(a,s),c=Uh(e.additionalItems,t),l=H.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(H.maxLength(e.maxItems)))}else if(o!==void 0){const s=gt(o,t);let a=H.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=H.array(H.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=ux(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?gt(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 gt(e,t){if(typeof e=="boolean")return e?H.any():H.never();let n=Db(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=>gt(c,t)),u=H.union(a);n=r?H.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>gt(c,t)),u=H.xor(a);n=r?H.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:H.any();else{let a=r?n:gt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=H.intersection(a,gt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=H.nullable(n)),e.readOnly===!0&&(n=H.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&&!ni(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&&!ni(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))tx.has(a)||$t(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function Ob(e,t){if(typeof e=="boolean")return e?H.any():H.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=nx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??kt};return gt(n,o)}function Mb(e){return Bl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:we(n.options)}})}function lx(e,t){if(!t?.length)return e;const n=e._zod.def;return Ge(e,lt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Fb(e){return lx(e.out,e.checks)}function dx(e){return e.in._zod.traits.has("$ZodTransform")?Fb(e):e.in}function Ub(e){return Bl(e,{pipe:t=>dx(t._zod.def),default:(t,n)=>n?Fe(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Gb(e){return Bl(e,{pipe:t=>Fb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function fx(e){return ev(kr,e)}function hx(e){return ov(Cr,e)}function px(e){return fv(Ar,e)}function mx(e){return pv(Ir,e)}function gx(e){return Ev(so,e)}const jb=Object.freeze(Object.defineProperty({__proto__:null,bigint:mx,boolean:px,date:gx,number:hx,string:fx},Symbol.toStringTag,{value:"Module"})),Gh=Object.freeze(Object.defineProperty({__proto__:null,$brand:wc,$input:dl,$output:ll,INVALID:vt,NEVER:bc,TimePrecision:Pl,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodError:Nb,ZodExactOptional:co,ZodFile:da,get ZodFirstPartyTypeKind(){return as},ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodIssueCode:Rb,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRealError:wt,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,clone:Ge,codec:rf,coerce:jb,compile:fl,config:Qe,core:Cb,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,decode:Yl,decodeAsync:Ql,deepPartial:Mb,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,encode:Jl,encodeAsync:Xl,endsWith:Ni,enum:ot,exactOptional:ha,file:Qd,flattenError:Es,float32:Pd,float64:Dd,formatError:$s,fromJSONSchema:Ob,function:hr,getDiscriminatedOption:tl,getErrorMap:Lb,globalRegistry:kt,gt:fn,gte:Et,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,includes:Ai,input:Ub,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,iso:pf,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,length:wr,literal:E,locales:cl,looseObject:it,looseRecord:Kd,lowercase:Ti,lt:dn,lte:xt,mac:wd,map:Jd,maxLength:br,maxSize:Wn,memoizer:Ps,meta:lf,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,nan:nf,nanoid:hd,nativeEnum:Xd,negative:js,never:Hn,nonnegative:Bs,nonoptional:ba,nonpositive:Zs,normalize:Li,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,output:Gb,overwrite:en,parse:Vl,parseAsync:ql,partialRecord:Wd,pipe:ci,positive:Gs,prefault:va,preprocess:fo,prettifyError:kc,promise:af,properties:Ri,property:Hs,readonly:$a,record:xe,refine:za,regex:$i,regexes:Is,registry:Ds,safeDecode:td,safeDecodeAsync:rd,safeEncode:ed,safeEncodeAsync:nd,safeParse:Wl,safeParseAsync:Kl,set:Yd,setErrorMap:zb,size:vr,slugify:Mi,startsWith:Ii,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,toJSONSchema:Zl,toLowerCase:Di,toUpperCase:Oi,toZod:vs,transform:uo,treeifyError:_c,trim:Pi,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,uppercase:Ci,url:ld,util:vc,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,validate:Cs,validateAsync:As,void:Zd,withParser:Os,xid:yd,xor:qd},Symbol.toStringTag,{value:"Module"})),yx=Object.freeze(Object.defineProperty({__proto__:null,$brand:wc,$input:dl,$output:ll,INVALID:vt,NEVER:bc,TimePrecision:Pl,ZodAny:Xs,ZodArray:na,ZodBase64:Qi,ZodBase64URL:eo,ZodBigInt:Ir,ZodBigIntFormat:ro,ZodBoolean:Ar,ZodCIDRv4:Yi,ZodCIDRv6:Xi,ZodCUID:Bi,ZodCUID2:Hi,ZodCatch:_a,ZodCodec:Dr,ZodCompileAsyncError:ln,ZodCompileUnsupportedError:Te,ZodCreditCard:qs,ZodCustom:Or,ZodCustomStringFormat:Tn,ZodDate:so,ZodDefault:ma,ZodDiscriminatedUnion:ia,ZodE164:to,ZodEmail:Ui,ZodEmoji:ji,ZodEnum:qn,ZodError:Nb,ZodExactOptional:co,ZodFile:da,get ZodFirstPartyTypeKind(){return as},ZodFunction:Na,ZodGUID:Gi,ZodIBAN:Ws,ZodIPv4:Ki,ZodIPv6:Ji,ZodISODate:xr,ZodISODateTime:Sr,ZodISODuration:$r,ZodISOTime:Er,ZodInstanceOf:Pa,ZodIntersection:oa,ZodIssueCode:Rb,ZodJWT:no,ZodKSUID:Wi,ZodLazy:Ca,ZodLiteral:la,ZodMAC:Vs,ZodMap:ua,ZodNaN:Sa,ZodNanoID:Zi,ZodNever:ea,ZodNonOptional:lo,ZodNull:Ys,ZodNullable:pa,ZodNumber:Cr,ZodNumberFormat:Cn,ZodObject:Nr,ZodOptional:Lr,ZodPipe:Pr,ZodPrefault:ya,ZodPreprocess:xa,ZodPromise:Ia,ZodReadonly:Ea,ZodRealError:wt,ZodRecord:Vn,ZodSet:ca,ZodString:kr,ZodStringFormat:Pe,ZodSuccess:wa,ZodSymbol:Ks,ZodTemplateLiteral:Ta,ZodTransform:fa,ZodTuple:sa,ZodType:ye,ZodULID:Vi,ZodURL:Tr,ZodUUID:Vt,ZodUndefined:Js,ZodUnion:Rr,ZodUnknown:Qs,ZodVoid:ta,ZodXID:qi,ZodXor:ra,_ZodString:Fi,_default:ga,_function:hr,any:oo,array:ue,base64:xd,base64url:Ed,bigint:Fd,boolean:Le,catch:ka,check:uf,cidrv4:kd,cidrv6:Sd,clone:Ge,codec:rf,coerce:jb,compile:fl,config:Qe,core:Cb,creditCard:Td,cuid:pd,cuid2:md,currencyCode:zd,custom:Ra,date:Bd,decode:Yl,decodeAsync:Ql,deepPartial:Mb,default:Gh,describe:cf,discriminatedUnion:ao,e164:$d,email:id,emoji:fd,encode:Jl,encodeAsync:Xl,endsWith:Ni,enum:ot,exactOptional:ha,file:Qd,flattenError:Es,float32:Pd,float64:Dd,formatError:$s,fromJSONSchema:Ob,function:hr,getDiscriminatedOption:tl,getErrorMap:Lb,globalRegistry:kt,gt:fn,gte:Et,guid:od,hash:Ld,hex:Rd,hostname:Nd,httpUrl:dd,iban:Cd,includes:Ai,input:Ub,instanceof:df,int:ui,int32:Od,int64:Ud,intersection:zr,invertCodec:of,ipv4:bd,ipv6:_d,iso:pf,json:hf,jwt:Ad,keyof:Hd,ksuid:vd,lazy:Aa,length:wr,literal:E,locales:cl,looseObject:it,looseRecord:Kd,lowercase:Ti,lt:dn,lte:xt,mac:wd,map:Jd,maxLength:br,maxSize:Wn,memoizer:Ps,meta:lf,mime:zi,minLength:$n,minSize:hn,multipleOf:Bn,nan:nf,nanoid:hd,nativeEnum:Xd,negative:js,never:Hn,nonnegative:Bs,nonoptional:ba,nonpositive:Zs,normalize:Li,null:io,nullable:fr,nullish:ef,number:ge,object:T,optional:Fe,output:Gb,overwrite:en,parse:Vl,parseAsync:ql,partialRecord:Wd,pipe:ci,positive:Gs,prefault:va,preprocess:fo,prettifyError:kc,promise:af,properties:Ri,property:Hs,readonly:$a,record:xe,refine:za,regex:$i,regexes:Is,registry:Ds,safeDecode:td,safeDecodeAsync:rd,safeEncode:ed,safeEncodeAsync:nd,safeParse:Wl,safeParseAsync:Kl,set:Yd,setErrorMap:zb,size:vr,slugify:Mi,startsWith:Ii,strictObject:Vd,string:x,stringFormat:Id,stringbool:ff,success:tf,superRefine:La,symbol:jd,templateLiteral:sf,toJSONSchema:Zl,toLowerCase:Di,toUpperCase:Oi,toZod:vs,transform:uo,treeifyError:_c,trim:Pi,tuple:aa,uint32:Md,uint64:Gd,ulid:gd,undefined:dr,union:we,unknown:ze,uppercase:Ci,url:ld,util:vc,uuid:sd,uuidv4:ad,uuidv6:ud,uuidv7:cd,validate:Cs,validateAsync:As,void:Zd,withParser:Os,xid:yd,xor:qd,z:Gh},Symbol.toStringTag,{value:"Module"})),On="io.modelcontextprotocol/related-task",Da="2.0",Xe=Ra(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Zb=we([x(),ge().int()]),Bb=x();it({ttl:ge().optional(),pollInterval:ge().optional()});const vx=T({ttl:ge().optional()}),bx=T({taskId:x()}),mf=it({progressToken:Zb.optional(),[On]:bx.optional()}),Ct=T({_meta:mf.optional()}),ho=Ct.extend({task:vx.optional()}),wx=e=>ho.safeParse(e).success,st=T({method:x(),params:Ct.loose().optional()}),Ot=T({_meta:mf.optional()}),Mt=T({method:x(),params:Ot.loose().optional()}),at=it({_meta:mf.optional()}),po=we([x(),ge().int()]),Hb=T({jsonrpc:E(Da),id:po,...st.shape}).strict(),jh=e=>Hb.safeParse(e).success,Vb=T({jsonrpc:E(Da),...Mt.shape}).strict(),_x=e=>Vb.safeParse(e).success,gf=T({jsonrpc:E(Da),id:po,result:at}).strict(),zo=e=>gf.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 yf=T({jsonrpc:E(Da),id:po.optional(),error:T({code:ge().int(),message:x(),data:ze().optional()})}).strict(),kx=e=>yf.safeParse(e).success,Sx=we([Hb,Vb,gf,yf]);we([gf,yf]);const vf=at.strict(),xx=Ot.extend({requestId:po.optional(),reason:x().optional()}),bf=Mt.extend({method:E("notifications/cancelled"),params:xx}),Ex=T({src:x(),mimeType:x().optional(),sizes:ue(x()).optional(),theme:ot(["light","dark"]).optional()}),mo=T({icons:ue(Ex).optional()}),pr=T({name:x(),title:x().optional()}),Oa=pr.extend({...pr.shape,...mo.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),$x=zr(T({applyDefaults:Le().optional()}),xe(x(),ze())),Tx=fo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,zr(T({form:$x.optional(),url:Xe.optional()}),xe(x(),ze()).optional())),Cx=it({list:Xe.optional(),cancel:Xe.optional(),requests:it({sampling:it({createMessage:Xe.optional()}).optional(),elicitation:it({create:Xe.optional()}).optional()}).optional()}),Ax=it({list:Xe.optional(),cancel:Xe.optional(),requests:it({tools:it({call:Xe.optional()}).optional()}).optional()}),Ix=T({experimental:xe(x(),Xe).optional(),sampling:T({context:Xe.optional(),tools:Xe.optional()}).optional(),elicitation:Tx.optional(),roots:T({listChanged:Le().optional()}).optional(),tasks:Cx.optional(),extensions:xe(x(),Xe).optional()}),Nx=Ct.extend({protocolVersion:x(),capabilities:Ix,clientInfo:Oa}),Rx=st.extend({method:E("initialize"),params:Nx}),zx=T({experimental:xe(x(),Xe).optional(),logging:Xe.optional(),completions:Xe.optional(),prompts:T({listChanged:Le().optional()}).optional(),resources:T({subscribe:Le().optional(),listChanged:Le().optional()}).optional(),tools:T({listChanged:Le().optional()}).optional(),tasks:Ax.optional(),extensions:xe(x(),Xe).optional()}),Lx=at.extend({protocolVersion:x(),capabilities:zx,serverInfo:Oa,instructions:x().optional()}),Px=Mt.extend({method:E("notifications/initialized"),params:Ot.optional()}),Ma=st.extend({method:E("ping"),params:Ct.optional()}),Dx=T({progress:ge(),total:Fe(ge()),message:Fe(x())}),Ox=T({...Ot.shape,...Dx.shape,progressToken:Zb}),wf=Mt.extend({method:E("notifications/progress"),params:Ox}),Mx=Ct.extend({cursor:Bb.optional()}),go=st.extend({params:Mx.optional()}),yo=at.extend({nextCursor:Bb.optional()}),Fx=ot(["working","input_required","completed","failed","cancelled"]),vo=T({taskId:x(),status:Fx,ttl:we([ge(),io()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Fe(ge()),statusMessage:Fe(x())}),_f=at.extend({task:vo}),Ux=Ot.merge(vo),us=Mt.extend({method:E("notifications/tasks/status"),params:Ux}),kf=st.extend({method:E("tasks/get"),params:Ct.extend({taskId:x()})}),Sf=at.merge(vo),xf=st.extend({method:E("tasks/result"),params:Ct.extend({taskId:x()})});at.loose();const Ef=go.extend({method:E("tasks/list")}),$f=yo.extend({tasks:ue(vo)}),Tf=st.extend({method:E("tasks/cancel"),params:Ct.extend({taskId:x()})}),Gx=at.merge(vo),qb=T({uri:x(),mimeType:Fe(x()),_meta:xe(x(),ze()).optional()}),Wb=qb.extend({text:x()}),Cf=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Kb=qb.extend({blob:Cf}),bo=ot(["user","assistant"]),Mr=T({audience:ue(bo).optional(),priority:ge().min(0).max(1).optional(),lastModified:Pb({offset:!0}).optional()}),Jb=T({...pr.shape,...mo.shape,uri:x(),description:Fe(x()),mimeType:Fe(x()),size:Fe(ge()),annotations:Mr.optional(),_meta:Fe(it({}))}),jx=T({...pr.shape,...mo.shape,uriTemplate:x(),description:Fe(x()),mimeType:Fe(x()),annotations:Mr.optional(),_meta:Fe(it({}))}),Zx=go.extend({method:E("resources/list")}),Yb=yo.extend({resources:ue(Jb)}),Bx=go.extend({method:E("resources/templates/list")}),Hx=yo.extend({resourceTemplates:ue(jx)}),Af=Ct.extend({uri:x()}),Vx=Af,qx=st.extend({method:E("resources/read"),params:Vx}),Xb=at.extend({contents:ue(we([Wb,Kb]))}),Wx=Mt.extend({method:E("notifications/resources/list_changed"),params:Ot.optional()}),Kx=Af,Jx=st.extend({method:E("resources/subscribe"),params:Kx}),Yx=Af,Xx=st.extend({method:E("resources/unsubscribe"),params:Yx}),Qx=Ot.extend({uri:x()}),eE=Mt.extend({method:E("notifications/resources/updated"),params:Qx}),tE=T({name:x(),description:Fe(x()),required:Fe(Le())}),nE=T({...pr.shape,...mo.shape,description:Fe(x()),arguments:Fe(ue(tE)),_meta:Fe(it({}))}),rE=go.extend({method:E("prompts/list")}),iE=yo.extend({prompts:ue(nE)}),oE=Ct.extend({name:x(),arguments:xe(x(),x()).optional()}),sE=st.extend({method:E("prompts/get"),params:oE}),If=T({type:E("text"),text:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),Nf=T({type:E("image"),data:Cf,mimeType:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),Rf=T({type:E("audio"),data:Cf,mimeType:x(),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),aE=T({type:E("tool_use"),name:x(),id:x(),input:xe(x(),ze()),_meta:xe(x(),ze()).optional()}),Qb=T({type:E("resource"),resource:we([Wb,Kb]),annotations:Mr.optional(),_meta:xe(x(),ze()).optional()}),ew=Jb.extend({type:E("resource_link")}),wo=we([If,Nf,Rf,ew,Qb]),uE=T({role:bo,content:wo}),cE=at.extend({description:x().optional(),messages:ue(uE)}),lE=Mt.extend({method:E("notifications/prompts/list_changed"),params:Ot.optional()}),dE=T({title:x().optional(),readOnlyHint:Le().optional(),destructiveHint:Le().optional(),idempotentHint:Le().optional(),openWorldHint:Le().optional()}),fE=T({taskSupport:ot(["required","optional","forbidden"]).optional()}),zf=T({...pr.shape,...mo.shape,description:x().optional(),inputSchema:T({type:E("object"),properties:xe(x(),Xe).optional(),required:ue(x()).optional()}).catchall(ze()),outputSchema:T({type:E("object"),properties:xe(x(),Xe).optional(),required:ue(x()).optional()}).catchall(ze()).optional(),annotations:dE.optional(),execution:fE.optional(),_meta:xe(x(),ze()).optional()}),tw=go.extend({method:E("tools/list")}),hE=yo.extend({tools:ue(zf)}),Fa=at.extend({content:ue(wo).default([]),structuredContent:xe(x(),ze()).optional(),isError:Le().optional()});Fa.or(at.extend({toolResult:ze()}));const pE=ho.extend({name:x(),arguments:xe(x(),ze()).optional()}),nw=st.extend({method:E("tools/call"),params:pE}),mE=Mt.extend({method:E("notifications/tools/list_changed"),params:Ot.optional()});T({autoRefresh:Le().default(!0),debounceMs:ge().int().nonnegative().default(300)});const rw=ot(["debug","info","notice","warning","error","critical","alert","emergency"]),gE=Ct.extend({level:rw}),yE=st.extend({method:E("logging/setLevel"),params:gE}),vE=Ot.extend({level:rw,logger:x().optional(),data:ze()}),bE=Mt.extend({method:E("notifications/message"),params:vE}),wE=T({name:x().optional()}),_E=T({hints:ue(wE).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),kE=T({mode:ot(["auto","required","none"]).optional()}),SE=T({type:E("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:ue(wo).default([]),structuredContent:T({}).loose().optional(),isError:Le().optional(),_meta:xe(x(),ze()).optional()}),xE=ao("type",[If,Nf,Rf]),cs=ao("type",[If,Nf,Rf,aE,SE]),EE=T({role:bo,content:we([cs,ue(cs)]),_meta:xe(x(),ze()).optional()}),$E=ho.extend({messages:ue(EE),modelPreferences:_E.optional(),systemPrompt:x().optional(),includeContext:ot(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ue(x()).optional(),metadata:Xe.optional(),tools:ue(zf).optional(),toolChoice:kE.optional()}),TE=st.extend({method:E("sampling/createMessage"),params:$E}),iw=at.extend({model:x(),stopReason:Fe(ot(["endTurn","stopSequence","maxTokens"]).or(x())),role:bo,content:xE}),ow=at.extend({model:x(),stopReason:Fe(ot(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:bo,content:we([cs,ue(cs)])}),CE=T({type:E("boolean"),title:x().optional(),description:x().optional(),default:Le().optional()}),AE=T({type:E("string"),title:x().optional(),description:x().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:ot(["email","uri","date","date-time"]).optional(),default:x().optional()}),IE=T({type:ot(["number","integer"]),title:x().optional(),description:x().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),NE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ue(x()),default:x().optional()}),RE=T({type:E("string"),title:x().optional(),description:x().optional(),oneOf:ue(T({const:x(),title:x()})),default:x().optional()}),zE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ue(x()),enumNames:ue(x()).optional(),default:x().optional()}),LE=we([NE,RE]),PE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({type:E("string"),enum:ue(x())}),default:ue(x()).optional()}),DE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({anyOf:ue(T({const:x(),title:x()}))}),default:ue(x()).optional()}),OE=we([PE,DE]),ME=we([zE,LE,OE]),FE=we([ME,CE,AE,IE]),UE=ho.extend({mode:E("form").optional(),message:x(),requestedSchema:T({type:E("object"),properties:xe(x(),FE),required:ue(x()).optional()})}),GE=ho.extend({mode:E("url"),message:x(),elicitationId:x(),url:x().url()}),jE=we([UE,GE]),ZE=st.extend({method:E("elicitation/create"),params:jE}),BE=Ot.extend({elicitationId:x()}),HE=Mt.extend({method:E("notifications/elicitation/complete"),params:BE}),VE=at.extend({action:ot(["accept","decline","cancel"]),content:fo(e=>e===null?void 0:e,xe(x(),we([x(),ge(),Le(),ue(x())])).optional())}),qE=T({type:E("ref/resource"),uri:x()}),WE=T({type:E("ref/prompt"),name:x()}),KE=Ct.extend({ref:we([WE,qE]),argument:T({name:x(),value:x()}),context:T({arguments:xe(x(),x()).optional()}).optional()}),JE=st.extend({method:E("completion/complete"),params:KE}),YE=at.extend({completion:it({values:ue(x()).max(100),total:Fe(ge().int()),hasMore:Fe(Le())})}),XE=T({uri:x().startsWith("file://"),name:x().optional(),_meta:xe(x(),ze()).optional()}),QE=st.extend({method:E("roots/list"),params:Ct.optional()}),e$=at.extend({roots:ue(XE)}),t$=Mt.extend({method:E("notifications/roots/list_changed"),params:Ot.optional()});we([Ma,Rx,JE,yE,sE,rE,Zx,Bx,qx,Jx,Xx,nw,tw,kf,xf,Ef,Tf]);we([bf,wf,Px,t$,us]);we([vf,iw,ow,VE,e$,Sf,$f,_f]);we([Ma,TE,ZE,QE,kf,xf,Ef,Tf]);we([bf,wf,bE,eE,Wx,mE,lE,us,HE]);we([vf,Lx,YE,cE,iE,Yb,Hx,Xb,Fa,hE,Sf,$f,_f]);class $e 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 n$(i.elicitations,n)}return new $e(t,n,r)}}class n$ extends $e{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Re.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function zn(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Zh(e){const n=H0(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=V0(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Bh(e,t){const n=Ab(e,t);if(!n.success)throw n.error;return n.data}const r$=6e4;class i${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(bf,n=>{this._oncancel(n)}),this.setNotificationHandler(wf,n=>{this._onprogress(n)}),this.setRequestHandler(Ma,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(kf,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new $e(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(xf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new $e(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 $e(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 $e(Re.InvalidParams,`Task not found: ${o}`);if(!zn(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(zn(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[On]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Ef,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 $e(Re.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Tf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new $e(Re.InvalidParams,`Task not found: ${n.params.taskId}`);if(zn(i.status))throw new $e(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 $e(Re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof $e?i:new $e(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),$e.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),zo(o)||kx(o)?this._onresponse(o):jh(o)?this._onrequest(o,s):_x(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=$e.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?.[On]?.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 $e(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(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}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=wx(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,g)=>{if(l.signal.aborted)throw new $e(Re.ConnectionClosed,"Request was cancelled");const w={...g,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const y=w.relatedTask?.taskId??o;return y&&f&&await f.updateTaskStatus(y,"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 $e(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),zo(t))r(t);else{const s=new $e(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(zo(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),zo(t))i(t);else{const s=$e.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 $e?s:new $e(Re.InternalError,String(s))}}return}let o;try{const s=await this.request(t,_f,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new $e(Re.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},zn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new $e(Re.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new $e(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 $e?s:new $e(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=y=>{l(y)};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(y){d(y);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||{},[On]:u}});const p=y=>{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(y)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=y instanceof $e?y:new $e(Re.RequestTimeout,String(y));l(b)};this._responseHandlers.set(f,y=>{if(!r?.signal?.aborted){if(y instanceof Error)return l(y);try{const b=Ab(n,y.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??r$,g=()=>p($e.fromError(Re.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,g,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const y=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,y),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(y=>{this._cleanupTimeout(f),l(y)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Sf,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},$f,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Gx,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||{},[On]: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||{},[On]: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||{},[On]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Zh(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Bh(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=Zh(t);this._notificationHandlers.set(r,i=>{const o=Bh(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 $e(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 $e(Re.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new $e(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 $e(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=us.parse({method:"notifications/tasks/status",params:a});await this.notification(u),zn(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 $e(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(zn(a.status))throw new $e(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=us.parse({method:"notifications/tasks/status",params:u});await this.notification(c),zn(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Hh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function o$(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];Hh(s)&&Hh(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 s$ extends i${_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 a$="2026-01-26",u$="ui/notifications/tool-input-partial";class sw{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=Sx.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!==u$&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var c$=we([E("light"),E("dark")]).describe("Color theme preference for the host environment."),li=we([E("inline"),E("fullscreen"),E("pip")]).describe("Display mode for UI presentation."),l$=we([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."),d$=xe(l$.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.).
|
|
@@ -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:E("ui/open-link"),params:T({url:x().describe("URL to open in the host's browser")})});var
|
|
88
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);T({method:E("ui/open-link"),params:T({url:x().describe("URL to open in the host's browser")})});var f$=T({isError:Le().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),h$=T({isError:Le().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),p$=T({isError:Le().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();T({method:E("ui/notifications/sandbox-proxy-ready"),params:T({})});var Lf=T({connectDomains:ue(x()).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:ue(x()).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:ue(x()).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:ue(x()).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'`)")}),Pf=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:E("ui/notifications/size-changed"),params:T({width:ge().optional().describe("New width in pixels."),height:ge().optional().describe("New height in pixels.")})});var
|
|
91
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:ue(x()).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:ue(x()).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:ue(x()).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'`)")}),Pf=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:E("ui/notifications/size-changed"),params:T({width:ge().optional().describe("New width in pixels."),height:ge().optional().describe("New height in pixels.")})});var m$=T({method:E("ui/notifications/tool-input"),params:T({arguments:xe(x(),ze().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),g$=T({method:E("ui/notifications/tool-input-partial"),params:T({arguments:xe(x(),ze().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),y$=T({method:E("ui/notifications/tool-cancelled"),params:T({reason:x().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),v$=T({fonts:x().optional()}),b$=T({variables:d$.optional().describe("CSS variables for theming the app."),css:v$.optional().describe("CSS blocks that apps can inject.")}),w$=T({method:E("ui/resource-teardown"),params:T({})});xe(x(),ze());var Vh=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:E("ui/notifications/request-teardown"),params:T({}).optional()});var _$=T({experimental:xe(x(),xe(x(),oo()).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:Le().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:T({listChanged:Le().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:Pf.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Lf.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Vh.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Vh.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.")}),k$=T({experimental:xe(x(),xe(x(),oo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:T({listChanged:Le().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:ue(li).optional().describe("Display modes the app supports.")});T({method:E("ui/notifications/initialized"),params:T({}).optional()});T({csp:Lf.optional().describe("Content Security Policy configuration for UI resources."),permissions:Pf.optional().describe("Sandbox permissions requested by the UI resource."),domain:x().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:E("ui/request-display-mode"),params:T({mode:li.describe("The display mode being requested.")})});var
|
|
105
|
+
- omitted: host decides border`)});T({method:E("ui/request-display-mode"),params:T({mode:li.describe("The display mode being requested.")})});var S$=T({mode:li.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),x$=we([E("model"),E("app")]).describe("Tool visibility scope - who can access the tool.");T({resourceUri:x().optional(),visibility:ue(x$).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:Hn().optional(),permissions:Hn().optional()});T({mimeTypes:ue(x()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});T({method:E("ui/download-file"),params:T({contents:ue(we([Qb,ew])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});T({method:E("ui/message"),params:T({role:E("user").describe('Message role, currently only "user" is supported.'),content:ue(wo).describe("Message content blocks (text, image, etc.).")})});T({method:E("ui/notifications/sandbox-resource-ready"),params:T({html:x().describe("HTML content to load into the inner iframe."),sandbox:x().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Lf.optional().describe("CSP configuration from resource metadata."),permissions:Pf.optional().describe("Sandbox permissions from resource metadata.")})});var
|
|
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:we([E("web"),E("desktop"),E("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Le().optional().describe("Whether the device supports touch input."),hover:Le().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(),E$=T({method:E("ui/notifications/host-context-changed"),params:aw.describe("Partial context update containing only changed fields.")});T({method:E("ui/update-model-context"),params:T({content:ue(wo).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:xe(x(),ze().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:Oa.describe("App identification (name and version)."),appCapabilities:_$.describe("Features and capabilities this app provides."),protocolVersion:x().describe("Protocol version this app supports.")})});var $$=T({protocolVersion:x().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Oa.describe("Host application identification and version."),hostCapabilities:w$.describe("Features and capabilities provided by the host."),hostContext:aw.describe("Rich context about the host environment.")}).passthrough(),T$={target:"draft-2020-12"};async function qh(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](T$);if(n.vendor==="zod"){let{z:r}=await B_(()=>Promise.resolve().then(()=>gx),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 Wh(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 C$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function A$(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 Df extends o${_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:p$,toolinputpartial:m$,toolresult:x$,toolcancelled:g$,hostcontextchanged:E$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!Df.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||Qe({jitless:!0}),this.setRequestHandler(Ma,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=i$(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 Wh(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 Wh(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 qh(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await qh(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(b$,(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(nw,(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(tw,(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},Fa,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Xb,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Yb,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?ow:iw;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},h$,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},vf,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},d$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},f$,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},k$,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 sw(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:s$}},$$,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 uw=new Map;function I$(e,t){uw.set(e,t)}function Kh(e){return uw.get(e)??null}const N$=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function R$(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 N$.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const z$="http://www.w3.org/2000/svg";let L$=0;function Lo(e){return Math.round(e*10)/10}function P$(e,t,n={}){const r=e.createElementNS(z$,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function Jh(e,t,n,r){const i=`cia-graph-svg-${++L$}`,o=e.ownerDocument,s=(F,Z)=>P$(o,F,Z),a=(F,Z,W)=>{const Q=s("text",{x:0,y:Z,"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":""}),g=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(g,w),l.append(d,h,p,m),e.append(l);const y=new Map,b=new Map,v=new Map;let k=null;function _(){if(k)return k;const F=t.model(),Z=t.positions(),W=new Map;k=W;const Q=F.nodes.length>xT,Y=new Map(F.nodes.map(R=>[R.address,R])),I=Q?[]:mT(F,Z,t.notes());for(const R of F.edges){const U=Y.get(R.from),ie=Y.get(R.to),ce=U&&Z[U.id],te=ie&&Z[ie.id];if(!U||!ie||!ce||!te){W.set(R.id,null);continue}if(Q){W.set(R.id,Zu(ce,te,Fn(U,F.checked_address),Fn(ie,F.checked_address)));continue}const Ce=I.filter(Ae=>Ae.id!==U.id&&Ae.id!==ie.id);W.set(R.id,ET(ce,te,Fn(U,F.checked_address),Fn(ie,F.checked_address),Ce))}return W}function $(F){let Z=y.get(F);if(Z)return Z;Z=`${i}-arrow-${y.size}`;const W=s("marker",{id:Z,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),y.set(F,Z),Z}function O(){return[...t.model().nodes??[]].sort((F,Z)=>String(F.id).localeCompare(String(Z.id)))}function j(){k=null;const F=t.model();g.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const Z=new Map(F.nodes.map(W=>[W.address,W]));for(const W of F.edges){const Q=Z.get(W.from);if(!Q||!Z.get(W.to))continue;const Y=t.colorOf(Q),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Wu(W,t.now())});I.dataset.edgeId=W.id,I.style.setProperty("--edge-tone",Y);const R=TT(),U=s("path",{class:"cia-graph-edge-hit","stroke-width":R.hit.width,"pointer-events":"stroke"}),ie=s("path",{class:"cia-graph-edge-line","stroke-width":R.line.width,"marker-end":`url(#${$(Y)})`,"pointer-events":"none"});I.append(U,ie),I.addEventListener("keydown",ce=>{ip(ce.key)&&(ce.preventDefault(),n.selectEdge(W.id,"keyboard"))}),I.addEventListener("pointerenter",ce=>n.showTooltip(ce,Wu(W,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),g.append(I),v.set(W.id,{group:I,hit:U,line:ie})}for(const W of O())w.append(P(W));se(),ke()}function P(F){const Z=t.model(),W=F.address===Z.checked_address,Q=t.notes().get(F.id),Y=Fr(F,Z.checked_address,Q),I=Y.radius,R=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":qu(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:Y.dot}));for(const U of Y.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=>{ip(U.key)&&(U.preventDefault(),n.selectNode(F.id,"keyboard"))}),R.addEventListener("pointerenter",U=>n.showTooltip(U,qu(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:Z,height:W}=t.dimensions();for(const[Y,I]of b){const R=F[Y]??{x:Z/2,y:W/2};I.setAttribute("transform",`translate(${Lo(R.x)} ${Lo(R.y)})`)}const Q=_();for(const Y of t.model().edges){const I=v.get(Y.id);if(!I)continue;const R=Q.get(Y.id)??null;I.group.style.display=R?"":"none",R&&(I.hit.setAttribute("d",R.d),I.line.setAttribute("d",R.d))}}function be(F){const Z=t.model(),W=t.positions(),Q=W[F],Y=b.get(F);if(!Q||!Y)return;Y.setAttribute("transform",`translate(${Lo(Q.x)} ${Lo(Q.y)})`);const I=Z.nodes.find(U=>U.id===F);if(!I)return;const R=new Map(Z.nodes.map(U=>[U.address,U]));for(const U of Z.edges){if(U.from!==I.address&&U.to!==I.address)continue;const ie=v.get(U.id),ce=R.get(U.from),te=R.get(U.to),Ce=ce&&W[ce.id],Ae=te&&W[te.id];if(!ie||!ce||!te||!Ce||!Ae)continue;const L=Zu(Ce,Ae,Fn(ce,Z.checked_address),Fn(te,Z.checked_address));ie.group.style.display=L?"":"none",L&&(ie.hit.setAttribute("d",L.d),ie.line.setAttribute("d",L.d))}}function ke(){const F=t.model(),Z=t.selected(),W=t.highlighted(),Q=Z?.kind==="node"?F.nodes.find(Y=>Y.id===Z.id)?.address??null:null;for(const Y of F.edges){const I=v.get(Y.id);if(!I)continue;const R=Z?.kind==="edge"&&Z.id===Y.id,U=Z?.kind==="edge"?R?Jt.related:Jt.faded:hw(Y,Q),ie=U===Jt.faded;I.group.setAttribute("opacity",ie?String(U):"1"),I.line.setAttribute("stroke-opacity",ie?"1":String(U)),I.group.dataset.opacity=String(U),I.group.dataset.state=U===Jt.rest?"rest":U===Jt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(R))}for(const[Y,I]of b){const R=Z?.kind==="node"&&Z.id===Y;I.classList.toggle("is-selected",R),I.classList.toggle("is-focused",W===Y),I.setAttribute("aria-pressed",String(R))}}function Ue(){let F=null;for(const Z of _().values())Z?.bounds&&(F=F??{...Z.bounds},F.x1=Math.min(F.x1,Z.bounds.x1),F.y1=Math.min(F.y1,Z.bounds.y1),F.x2=Math.max(F.x2,Z.bounds.x2),F.y2=Math.max(F.y2,Z.bounds.y2));return F}return{kind:"svg",surface:l,build:j,geometry(){k=null,se()},moveNode:be,endMove(){k=null,se()},camera:J,selection:ke,flag(F,Z,W){b.get(F)?.toggleAttribute(`data-flag-${Z}`,W)},theme(){for(const F of t.model().nodes)b.get(F.id)?.style.setProperty("--node-tone",t.colorOf(F))},resize(F,Z){l.setAttribute("viewBox",`0 0 ${F} ${Z}`)},pick:()=>null,linkBounds:Ue,destroy(){l.remove()}}}const D$=.45,O$=2.5,M$=5,F$="chain-insights.flows.v1",Of="cia-graph-model",U$=90,Jt={rest:.6,related:.95,faded:.07},Yh={checked:24,other:19},di=16,G$=[["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"],j$={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},cw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Mf(e){return!!e&&e.schema===F$}function Z$(e){return!!e&&e.kind===Of}function Ke(e){return String(e??"").trim().toLowerCase()}function B$(e){const t=Ke(e);return _o.includes(t)?t:"other"}function gn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Gu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function H$(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Lt(e){return Z$(e)?e:Mf(e)?V$(e):W$(e)}function V$(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:gn(a.usd),tx_count:gn(a.tx_count),first_seen_timestamp:gn(a.first_seen_ms),last_seen_timestamp:gn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=q$(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:Gu(u.labels),taxonomy:[],role:B$(u.role),total_in_usd:gn(u.total_in_usd),total_out_usd:gn(u.total_out_usd),degree_in:gn(u.degree_in),degree_out:gn(u.degree_out)}});return{kind:Of,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function q$(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 g of d.get(m)??[])f.has(g)||(f.set(g,(f.get(m)??0)+1),p.push(g));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 W$(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":H$(r.direction),labels:Gu(r.labels),taxonomy:Gu(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:Of,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function K$(e,t,n){const r=Lt(t),i=Mn(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 Mn(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 fi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Ff(e){return String(e??"").trim().replace(/\s+/g," ")}function ls(e){return Ff(e).replaceAll(" ","").toLowerCase()}function xn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Ff(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Po(e,t){const n=new Set(xn(e).map(ls));return t.some(r=>n.has(ls(r)))}function J$(e){if(e.role&&_o.includes(e.role))return j$[e.role];if(Po(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Po(e,["Victim","Targeted"]))return"target";if(Po(e,["OnMoneyTrail","Mixer"]))return"trail";if(Po(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 Y$={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 X$(e,t=Y$){const n=J$(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function Q$(e){return e.role&&_o.includes(e.role)?We(`role-${e.role}`):X$(e).stroke}function ko(e){if(e.role&&e.role!=="other"&&_o.includes(e.role))return cw[e.role];const t=xn(e);for(const[r,i]of G$)if(t.some(o=>ls(o)===ls(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Ff).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function ju(e){return Math.min(O$,Math.max(D$,e))}function Ua(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Uf(e,t=Ua(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Xh(e,t){return e.address===t?43:e.hop>=2?25:30}function Fn(e,t){return e.address===t?Yh.checked:Yh.other}function Fr(e,t,n){const r=e.address===t,i=Fn(e,t),o=ko(e),s=[];return o&&s.push({kind:"role",text:GT(o),y:i+17}),s.push({kind:"address",text:fi(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 eT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},eu=2;function Gf(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=eT[r.kind],o=[...r.text].length*i.size*i.advance/2+eu;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-eu,x2:o,y2:r.y+i.size*.25+eu}})}return n}function lw(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 dw(e){return lw(Gf(e).map(t=>t.box))}const jf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function tT(e,t,n){const r=Lt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Gf(Fr(o,r.checked_address,jf(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 nT(e,t,n){return lw(tT(e,t,n))}function rT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function iT(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function oT(e,t,n){const r=Lt(e),i={x:t/2,y:n/2},o={},s=Ua(r),a=Uf(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=iT(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=>dw(Fr(u,r)),a=(u,c)=>Math.max(Xh(u,r)+Xh(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=Lt(e),i={x:t/2,y:n/2},o={},s=Ua(r),a=Uf(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 uT(e,t,n,r){const i=Lt(e),o=Ua(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,g=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-g)*.012;f.x-=p/g*w,f.y-=m/g*w,h.x+=p/g*w,h.y+=m/g*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)),g=(m-155)*.003;c!==s&&(d.x+=h/m*g,d.y+=p/m*g),l!==s&&(f.x-=h/m*g,f.y-=p/m*g)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function cT(e,t,n,r=U$){const i=Lt(e),o=aT(i,t,n);for(let s=0;s<r;s++)uT(i,o,t,n);return o}function Do(e,t,n,r){return t==="tree"?oT(e,n,r):cT(e,n,r)}function lT(e,t,n,r,i={}){const o=Lt(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(y=>y.id===n),f=new Map(o.nodes.map(y=>[y.id,y])),h=y=>dw(Fr(y,o.checked_address,jf(i.notes,y.id))),p=o.nodes.flatMap(y=>{const b=t[y.id];if(!b)return[];const v=h(y);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(y=>y.x1)):s.x,g=p.length?Math.max(...p.map(y=>y.x2)):s.x;const w={left:[],right:[]};for(const y of[...r].sort()){const b=f.get(y);if(!b||a[y])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 y of["left","right"]){const b=w[y];for(let v=0;v<b.length;v+=l){const k=b.slice(v,v+l),_=k.map(h),$=Math.max(..._.map(P=>Math.max(-P.x1,P.x2))),O=Math.max(u,Math.max(..._.map(P=>P.y2))-Math.min(..._.map(P=>P.y1))+6),j=y==="left"?m-c-$:g+c+$;k.forEach((P,J)=>{a[P.id]={x:j,y:s.y+(J-(k.length-1)/2)*O}}),y==="left"?m=j-$:g=j+$}}return a}function dT(e,t,n,r=di){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=ju(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 Qh(e,t,n,r=di){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function fT(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 _n(e){return Math.round(e*100)/100}function tu(e,t,n,r,i){const o=s=>`${_n(s.x)},${_n(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function Zu(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 tu("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 tu("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),g=Math.max(m*.45,Math.min(40,m));return tu("vertical",h,{x:h.x,y:h.y+f*g},{x:p.x,y:p.y-f*g},p)}const c=fT(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${_n(l.x)},${_n(l.y)} L${_n(d.x)},${_n(d.y)}`}}const hT=6,nu=hT+3,Kt=14,ep=10,pT=3,tp=6;function mT(e,t,n){const r=Lt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Gf(Fr(o,r.checked_address,jf(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 gT(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 yT(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 vT(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 bT(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 fw(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 wT(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(fw(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(vT(r.points,s))}}return n}function np(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 wT(e,pT))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)&&gT(a,l)<r)return!1}return!0}function _T(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(fw(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(Kt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},g={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},y={x:u.x+g.x*p,y:u.y+g.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:y.x-g.x*p*.55,y:y.y-g.y*p*.55},y]}),o=y}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 kT(e){const t=i=>`${_n(i.x)},${_n(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 rp(e,t,n,r,i){const o=Math.min(e.y,n)-Kt,s=Math.max(e.y,n)+Kt,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 ST(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 xT=120;function ET(e,t,n,r,i,o=4){const s=Zu(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>yT(f,nu));if(np(bT(s),i,a,nu))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<tp?e.y:Math.abs(f-t.y)<tp?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-Kt-1)),u.add(c(Math.round(f.y2)+Kt+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},g=[];for(const w of u){const y=Math.abs(w-p.y)<.01?p.x:rp(p,f,w,Kt,a);if(y===null)continue;const b=Math.abs(w-m.y)<.01?m.x:rp(m,-h,w,Kt+ep,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-y)*h<Kt+ep||Math.abs(w-p.y)<.01&&(b-p.x)*f<Kt)continue;const v=ST([p,{x:y,y:p.y},{x:y,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!$T(v,a))continue;let k=(v.length-2)*Kt,_;for(const $ of v)_&&(k+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;g.push({points:v,length:k})}g.sort((w,y)=>{const b=w.points[2]?.y,v=y.points[2]?.y;return w.length-y.length||(b===void 0||v===void 0?0:b-v)});for(const w of g){const y=_T(w.points);if(!np(y,i,a,nu))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:kT(y),bounds:_}}}return s}function $T(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(rT(i,o))return!1}n=r}return!0}function hw(e,t){if(!t)return Jt.rest;const n=Ke(t);return Ke(e.from)===n||Ke(e.to)===n?Jt.related:Jt.faded}function TT(){return{hit:{stroke:"transparent",width:16},line:{stroke:We("edge"),width:1.6},arrow:{fill:We("edge")}}}function CT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function AT(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 IT(e,t,n,r=M$){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 NT(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 ip(e){return e==="Enter"||e===" "}function RT(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function zT(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=RT(r,i),!0)}function LT(e,t){return e?.pointerId===t?null:e}function PT(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 DT(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 g=p?.closest?.("[data-edge-id]");return g?{kind:"edge",id:g.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=AT(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[g,w]=[...r.values()];g&&w&&(s={distance:Math.hypot(w.x-g.x,w.y-g.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,g]=[...r.values()];m&&g&&t.pinch(s,[m,g],h);return}if(i?.pointerId===h.pointerId){if(i=IT(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=NT(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 OT(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 pw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Bu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Hu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function kn(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 mw(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 Vu(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Bu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function MT(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Bu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Bu(e.total_out_usd)]];return e.role&&_o.includes(e.role)?[["Role",cw[e.role]||"Other"],...t,["Senders",Hu(e.degree_in)],["Receivers",Hu(e.degree_out)],["Labels",xn(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${pw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",kn(e.first_activity_timestamp)],["Last activity (UTC)",kn(e.last_activity_timestamp)],["Labels",xn(e).join(", ")||"No labels"]]}function FT(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Vu(e)],["Transfers",Hu(e.tx_count)],["First seen (UTC)",kn(e.first_seen_timestamp)],["Last seen (UTC)",kn(e.last_seen_timestamp)],["Since last seen",mw(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)",Vu(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)",kn(e.first_seen_timestamp)],["Last seen (UTC)",kn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function gw(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function qu(e){const t=ko(e);if(e.role)return`${e.address}. ${t||"Other"}.${xn(e).length?` Labels: ${xn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${pw(e.risk_level)} risk`,r=xn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Wu(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Vu(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${mw(e.last_seen_timestamp,t)}.`:n}function UT(e,t){return Lt(e).nodes.map(n=>{const r={id:n.address,label:xn(n).join(", ")||ko(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function GT(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function jT(e,t,n={}){const r=e.ownerDocument;let i=Lt(t),o=n.layout??(Mf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Do(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??Q$(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const g={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,D)=>Z(C,D),selectEdge:(C,D)=>W(C,D),showTooltip:(C,D)=>U(C,D),hideTooltip:()=>ie(),lost:()=>le()};function y(C){const D=C==="webgl"?Kh("webgl"):null;if(D)try{return D(e,g,w,{label:n.label})}catch{}return Jh(e,g,w,{label:n.label})}const b=n.renderer??(Kh("webgl")&&R$(r)?"webgl":"svg");let v=y(b);e.dataset.renderer=v.kind;const k=()=>{const C=nT(i,a,u);if(!C)return null;const D=v.linkBounds();return D&&(C.x1=Math.min(C.x1,D.x1),C.y1=Math.min(C.y1,D.y1),C.x2=Math.max(C.x2,D.x2),C.y2=Math.max(C.y2,D.y2)),C},_=()=>{const C=k();return C?dT(C,s.width,s.height,di):{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,j=!1,P=!1;function J(){if(O){j=!0;return}v.build()}function se(){if(O){P=!0;return}l=_(),be()}function be(){v.camera()}function ke(C="program"){const D=UT(i,n.href),ne=d?.kind==="node"?i.nodes.find(pe=>pe.id===d.id)??null:null,Se=d?.kind==="edge"?i.edges.find(pe=>pe.id===d.id)??null:null;if(ne){const pe=i.edges.filter(ct=>ct.from===ne.address||ct.to===ne.address);return{kind:"node",id:ne.id,selectedId:ne.address,nodes:D,title:"Selected address",identity:ne.address,values:MT(ne),related:pe,node:ne,edge:null,source:C}}return Se?{kind:"edge",id:Se.id,selectedId:null,nodes:D,title:"Selected aggregate flow",identity:`${Se.from} → ${Se.to}`,values:FT(Se,p()),related:[Se],node:null,edge:Se,source:C}:{kind:null,id:null,selectedId:null,nodes:D,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Ue(C){const D=ke(C);F(D),n.onSelect?.(D)}function F(C){const D=n.selectionRoot,ne=D?.querySelector("[data-selection-title]"),Se=D?.querySelector("[data-selection-identity]"),pe=D?.querySelector("[data-selection-meta]");!ne||!Se||!pe||(ne.textContent=C.title,Se.textContent=C.identity,pe.replaceChildren(...C.values.map(([ct,At])=>{const Gt=r.createElement("div");Gt.className="meta-item",At!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(ct)&&Gt.classList.add("meta-item--identity"),ct==="Incoming amount (USD)"&&Gt.classList.add("meta-item--incoming"),ct==="Outgoing amount (USD)"&&Gt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(ct)&&Gt.classList.add("meta-item--wide");const Zr=r.createElement("span");Zr.textContent=ct;const In=r.createElement("strong"),mn=["First transaction","Last transaction"].includes(ct)?gw(At):null;if(mn&&n.openLink){const G=n.openLink,ae=r.createElement("button");ae.type="button",ae.className="cia-graph-explorer-link",ae.dataset.explorer=mn,ae.textContent=At,ae.setAttribute("aria-label",`${ct}: ${At} (opens the explorer)`),ae.addEventListener("click",()=>G(mn)),In.append(ae)}else if(mn){const G=r.createElement("a");G.href=mn,G.target="_blank",G.rel="noopener noreferrer",G.textContent=At,G.setAttribute("aria-label",`${ct}: ${At} (opens in new tab)`),In.append(G)}else In.textContent=At;return Gt.append(Zr,In),Gt})))}function Z(C,D="program"){d=C?{kind:"node",id:C}:null,v.selection(),Ue(D)}function W(C,D="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Ue(D)}function Q(C){if(C==null)return Z(null);const D=Mn(i,C);if(D)return Z(D);if(i.edges.some(ne=>ne.id===C))return W(C)}function Y(){l=_(),be()}function I(C,D={x:s.width/2,y:s.height/2}){const ne=ju(l.scale*(1+C)),Se=ne/l.scale;l={x:D.x-(D.x-l.x)*Se,y:D.y-(D.y-l.y)*Se,scale:ne},be()}function R(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(D=>{D.classList.toggle("active",D.dataset.layout===C),D.setAttribute("aria-pressed",String(D.dataset.layout===C))}),n.onLayoutChange?.(C),a=Do(i,o,s.width,s.height),v.geometry(),Y()}function U(C,D){$.textContent=D,$.hidden=!1;const ne=e.getBoundingClientRect();$.style.left=`${Math.min(ne.width-330,Math.max(8,C.clientX-ne.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-ne.top+12)}px`}function ie(){$.hidden=!0}function ce(C){return PT({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const te={point:ce,transform:()=>l,select(C){C.type==="select-node"?Z(C.id,"pointer"):C.type==="select-edge"?W(C.id,"pointer"):Z(Uf(i)?.id??null,"canvas")},drag(C,D,ne){!h&&(h=CT(o,C,D),!h)||zT(a,h,D,ne,l)&&(Ce=!0,v.moveNode(h.id))},endDrag(C){const D=h?.pointerId===C&&Ce;h=LT(h,C),D&&(Ce=!1,v.endMove())},pan(C,D){l={x:C.transform.x+D.x-C.point.x,y:C.transform.y+D.y-C.point.y,scale:l.scale},be()},startPinch(){h=null},pinch(C,[D,ne]){const Se=Math.hypot(ne.x-D.x,ne.y-D.y),pe=ju(C.scale*Se/Math.max(1,C.distance));I(pe/l.scale-1,{x:(D.x+ne.x)/2,y:(D.y+ne.y)/2})}};let Ce=!1;const Ae=C=>{C.preventDefault(),I(C.deltaY>0?-.12:.12,ce(C))},L={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},M=C=>{if(C.target!==v.surface)return;const D=L[C.key];D?(C.preventDefault(),l={...l,x:l.x+D[0],y:l.y+D[1]},be()):C.key==="+"||C.key==="="?I(.18):C.key==="-"?I(-.18):C.key==="0"&&Y()};let q=()=>{};function K(){const C=v.surface,D=ne=>v.pick(ce(ne));q=DT(C,te,v.kind==="svg"?void 0:D),C.addEventListener("wheel",Ae,{passive:!1}),C.addEventListener("keydown",M)}function he(){q(),v.surface.removeEventListener("wheel",Ae),v.surface.removeEventListener("keydown",M)}K();function le(){v.kind!=="svg"&&(he(),v.destroy(),v=Jh(e,g,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),K(),J())}const Ee=n.controls?.querySelector("[data-expand]")??null,Ie=n.panel&&Ee?OT(n.panel,Ee,r.body):null,fe=()=>{Ie?.toggle(),n.onExpansionChange?.(Ie?.isOpen()??!1),requestAnimationFrame(Y)},ee=n.panel??e,Be=C=>{if(C.key==="Tab"&&Ie?.isOpen()&&n.panel){const D=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(pe=>pe.checkVisibility()),ne=D[0],Se=D.at(-1);C.shiftKey&&r.activeElement===ne?(C.preventDefault(),Se?.focus()):!C.shiftKey&&r.activeElement===Se&&(C.preventDefault(),ne?.focus())}if(C.key==="Escape"){if(Ie?.isOpen()){Ie.close(),n.onExpansionChange?.(!1),requestAnimationFrame(Y);return}Z(null,"keyboard")}};ee.addEventListener("keydown",Be);const ut=[],He=(C,D)=>{C&&(C.addEventListener("click",D),ut.push([C,D]))};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']"),Y),Ie&&He(Ee,fe);const Ve=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,D=e.clientHeight;!C||!D||C===s.width&&D===s.height||(s.width=C,s.height=D,v.resize(C,D),Y())});Ve?.observe(e),J(),n.selected&&Q(n.selected);const pt={update(C){const D=a;i=Lt(C);const ne=i.nodes.every(pe=>D[pe.id])?{}:Do(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(pe=>[pe.id,D[pe.id]??ne[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 Se=new Set(i.nodes.map(pe=>pe.id));for(const pe of[...c.keys()])Se.has(pe)||c.delete(pe);J(),se()},merge(C,D){const ne=K$(i,C,D);i=ne.model;const Se=Mn(i,D??Lt(C).checked_address);return a=Se?lT(i,a,Se,ne.added,{notes:u}):{...a,...Do(i,o,s.width,s.height),...a},J(),ne.added.length&&se(),ne.added},batch(C){O++;try{C()}finally{O--,!O&&j&&(j=!1,v.build()),!O&&P&&(P=!1,l=_(),be())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:Q,destroy(){Ve?.disconnect(),he(),ee.removeEventListener("keydown",Be);for(const[C,D]of ut)C.removeEventListener("click",D);Ie?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:Y,zoom:C=>I(C),setLayout:R,markNode(C,D){const ne=Mn(i,C);ne&&(D?u.set(ne,D):u.delete(ne),J())},flagNode(C,D,ne){const Se=Mn(i,C);if(!Se)return;const pe=c.get(Se)??new Set;ne?pe.add(D):pe.delete(D),pe.size?c.set(Se,pe):c.delete(Se),O?j=!0:v.flag(Se,D,ne)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>k(),transform:()=>({...l}),highlight(C){f=C==null?null:Mn(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const D=Mn(i,C),ne=D?a[D]:null;if(!ne)return null;const Se=v.surface.getBoundingClientRect(),pe=Math.min(Se.width/s.width,Se.height/s.height)||1,ct=Se.left+(Se.width-s.width*pe)/2,At=Se.top+(Se.height-s.height*pe)/2;return{x:ct+(ne.x*l.scale+l.x)*pe,y:At+(ne.y*l.scale+l.y)*pe}}};return Object.defineProperty(e,"ciaGraph",{value:pt,configurable:!0}),pt}const yw="chain-insights.flows.v1",Zf="chain-insights.result.v1",vw=5e3,op=6,ZT=3,bw=/^0x[0-9a-fA-F]{40}$/,BT=/^0x[0-9a-fA-F]{64}$/;function HT(e){return typeof e=="string"&&(bw.test(e)||BT.test(e))}function ds(e){return typeof e=="string"&&bw.test(e)}function Ku(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Bf(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(Ku):[]}function VT(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Yt(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 Hf(e){return e<1e11?e*1e3:e}const ww=/^\d{4}-\d{2}-\d{2}$/,qT=Date.UTC(2009,0,1),WT=Date.UTC(2100,0,1);function ru(e){return new Date(Hf(e)).toISOString().slice(0,10)}function sp(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function Vf(e){if(typeof e!="string"||!ww.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 KT=new Set(["day","date","hour","week","month"]),JT=["_timestamp","_time","_at"];function ap(e){return KT.has(e)||JT.some(t=>e.endsWith(t))}function YT(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function XT(e){return Array.isArray(e)?e.some(ds):ds(e)}function QT(e){return e.some(t=>Object.values(t).some(XT))}function eC(e){return e.length>0&&e.every(t=>ds(t.from_address)&&ds(t.to_address))}const tC=/^(\d{4})-(\d{2})$/,nC=/^(\d{4})-W(\d{2})$/,rC=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,iC=/(?:Z|[+-]\d{2}:?\d{2})$/i;function oC(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function up(e){if(typeof e=="string"){const r=e.trim();if(ww.test(r))return Vf(r)?Date.parse(`${r}T00:00:00Z`):null;const i=tC.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=nC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?oC(Number(o[1]),s):null}if(rC.test(r)){const s=r.replace(" ","T"),a=Date.parse(iC.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Yt(e);if(t==null)return null;const n=Hf(t);return n>=qT&&n<WT?n:null}function qf(e,t={}){if(e.length===0||QT(e))return null;const n=YT(e),i=n.filter(ap).find(d=>e.some(f=>up(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(ap(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Yt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,op),a=new Map;let u=0;for(const d of e){const f=up(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 g=Yt(d[p]);g!=null&&(h.sums[m]=(h.sums[m]??0)+g)}),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??ZT)?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(op),skippedRows:e.length-u,failures:[]}}function sC(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 aC=e=>e==null||Yt(e)!=null;function _w(e){const t=kw(e);if(t.length<3||!t.every(c=>Vf(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(aC))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:sC(c.error)})),u=qf(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}function uC(e){return eC(e)?"graph":qf(e)?"chart":"table"}const cC=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function cp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function lC(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 lp=(e,t)=>e==null?t:t==null?e:e+t;function dC(e,t="robinhood"){const n=new Map;for(const d of e)for(const f of new Set([String(d.from_address).toLowerCase(),String(d.to_address).toLowerCase()]))n.set(f,(n.get(f)??0)+1);let r="",i=0;for(const[d,f]of n)f>i&&(r=d,i=f);const o=new Map,s=new Map,a=(d,f,h)=>{const p=o.get(d)??{address:d,labels:[],exchange:!1};for(const m of f)p.labels.some(g=>g.toLowerCase()===m.toLowerCase())||p.labels.push(m);p.exchange=p.exchange||h,o.set(d,p)};r&&o.set(r,{address:r,labels:[],exchange:!1});let u=0;for(const d of e){const f=String(d.from_address).toLowerCase(),h=String(d.to_address).toLowerCase(),p=[f,h].filter((b,v,k)=>!o.has(b)&&k.indexOf(b)===v).length;if(o.size+p>vw||(u++,a(f,cp(d.from_labels),d.from_is_exchange===!0),a(h,cp(d.to_labels),d.to_is_exchange===!0),f===h))continue;const m=`${f}->${h}`,g=s.get(m)??{from:f,to:h,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=lp(g.usd,Yt(d.amount_usd_sum)),g.tx=lp(g.tx,Yt(d.tx_count));const w=Yt(d.first_seen_timestamp),y=Yt(d.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),y!=null&&(g.last=g.last==null?y:Math.max(g.last,y)),typeof d.link_kind=="string"&&d.link_kind&&!g.kinds.includes(d.link_kind)&&g.kinds.push(d.link_kind),s.set(m,g)}const c=[...o.values()].map(d=>({address:d.address,role:lC(d.labels,d.exchange),labels:d.labels})),l=[...s.values()].map(d=>({from:d.from,to:d.to,usd:d.usd,tx_count:d.tx,first_seen_ms:d.first,last_seen_ms:d.last,...d.kinds.length?{link_kind:d.kinds.join(", ")}:{}}));return{view:{schema:yw,network:t,center:r,nodes:c,edges:l,truncated:!1},rowsTotal:e.length,rowsDrawn:u,rowsLeftOut:e.length-u,addresses:o.size}}function kw(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(Ku).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(Ku):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null})):[]}const dp=200;function So(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
109
|
-
`).trim()}function Br(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 Sw(e){if(!e)return null;const t=e.structuredContent,n=Br(t?.error)??Br(t?.facts?.error)??Br(t?.facts?.query?.error);if(!e.isError||n)return n;const r=So(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=Br(i?.error)??Br(i);if(o)return o}catch{}return r||"The tool answered with an error."}const fC=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function xw(e){if(!e||Sw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===yw)return"flows";if(t?.schema===Zf){if(t.tool==="graph_query")return uC(Bf(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":_w(t)?"chart":"batch";if(typeof t.tool=="string"&&fC.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 hC(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:fi(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",()=>{pC(e,t,n,r)}),A(e,"span",{class:"cv-addr-cell"},n,r)}async function pC(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 mC(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?kn(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 gC=160,fp=2e3;function yC(e,t=gC){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 Ew(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>fp?`${n.full.slice(0,fp-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 vC(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,dp),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>dp||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function bC(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):HT(t)?hC(e,t):typeof t=="number"?e.createTextNode(mC(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 hp(e,t,n={}){const r=e.ownerDocument,i=vC(t.structuredContent),o=i.rows.length;if(i.total===0)return Ew(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",{},bC(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 Hr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Oo=e=>typeof e=="string"&&e?e:null;function wC(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Hr(t.allowance_usd),consumedUsd:Hr(t.consumed_usd),windowEnd:Oo(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=Oo(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Hr(r?n.daily_units_used:n.daily_seconds_used),limit:Hr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Hr(r?n.remaining_units:n.remaining_seconds),resetAt:Oo(n.reset_at),identifierKind:Oo(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const pp=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),Mo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function iu(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${kn(t)} UTC`:e}function mp(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 ou(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function _C(e,t){const n=e.ownerDocument,r=wC(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${fi(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[mp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),ou(n,[["Daily allowance",pp(r.allowanceUsd)],["Used today",pp(r.consumedUsd)],["Window ends",iu(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"}),ou(n,[["Daily allowance","No daily limit"],["Used today",Mo(r.used,r.unit)],["Window ends",iu(r.resetAt)]])]:[mp(n,r.used,r.limit,"Share of today's free allowance used"),ou(n,[["Daily allowance",Mo(r.limit,r.unit)],["Used today",Mo(r.used,r.unit)],["Left today",Mo(r.remaining,r.unit)],["Window ends",iu(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:So(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 Ga(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=Sw(t);if(i!=null){Ew(e,yC(i),{kind:"refused",view:"text",full:i});return}const o=So(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 $w(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 kC="http://www.w3.org/2000/svg",Ju=720,SC=320,xC=6,EC=420,gp=4,$C=120,Xr={left:70,right:18,top:6},Yu=18,Tw=16,Cw=6,Aw=26,TC=170,CC=82,AC=28,IC=80,Un=1e3,wn=60*Un,Qn=60*wn,Xt=24*Qn,NC=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Iw(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 RC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),zC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),LC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),hi=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),PC=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),DC=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),Nw=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),OC=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function fs(e,t){if(e==null)return"—";const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?zC.format(e):RC.format(e):t==="count"?hi.format(e):n?DC.format(e):PC.format(e)}function MC(e){return Math.abs(e)<1e3?OC.format(Math.round(e*100)/100):Nw.format(e)}function yp(e,t){return t==="usd"?Math.abs(e)<1e3?fs(e,"usd"):LC.format(e):t==="count"?Math.abs(e)<1e3?hi.format(e):Nw.format(e):MC(e)}function FC(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 Rw(e){return e<=Xt?"time":e<=$C*Xt?"day":"month"}const UC=[Un,2*Un,5*Un,10*Un,15*Un,30*Un,wn,2*wn,5*wn,10*wn,15*wn,30*wn,Qn,2*Qn,3*Qn,6*Qn,12*Qn,Xt],GC=[1,2,3,7,14,30,60].map(e=>e*Xt),jC=[1,2,3,6,12,24,60,120],vp=4*Xt,ZC={time:76,day:84,month:72},BC=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),su=e=>Date.UTC(Math.floor(e/12),e%12,1);function HC(e,t,n){const r=t-e,i=Rw(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 jC){const a=[];let u=BC(e);for(su(u)<e&&u++;su(u)<=t;u++)u%s===0&&a.push(su(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"?UC:GC){const a=s===7*Xt||s===14*Xt?Math.ceil((e-vp)/s)*s+vp:i==="day"?Math.ceil(e/Xt)*Xt: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 VC(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${NC[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%Xt===0?i.slice(0,10):n>0&&n<wn?i.slice(11,19):i.slice(11,16)}function qC(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:Iw(t.column,t.values),total:n,peak:r,peakTime:i}})}const Rt=e=>new Date(e).toISOString(),zw=(e,t)=>Rt(e).slice(0,10)===Rt(t).slice(0,10);function WC(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?`${Rt(t).slice(0,10)} UTC`:`${Rt(t).slice(0,10)} to ${Rt(n).slice(0,10)} UTC`;const r=i=>`${Rt(i).slice(0,10)} ${Rt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:zw(t,n)?`${r(t)} to ${Rt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function KC(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=[WC(e),`${hi.format(r)} ${r===1?"point":"points"}${i>r?` from ${hi.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of qC(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 ${Rt(u.peakTime).slice(0,10)}`:zw(s,a)?`at ${Rt(u.peakTime).slice(11,19)}`:`at ${Rt(u.peakTime).slice(0,10)} ${Rt(u.peakTime).slice(11,16)}`;o.push(`${u.column}: total ${fs(u.total,u.kind)}, peak ${fs(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 JC(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 YC(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 XC(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 QC(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 Lw=e=>`var(--cia-graph-series-${e%xC+1})`;function hs(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 au(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 Pw(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function eA(e){if(e<=1)return TC;const t=Math.floor((EC-Xr.top-Cw-Aw-(e-1)*Tw)/e)-Yu;return Math.max(AC,Math.min(CC,t))}function bp(e,t=Ju,n=new Set){const r=Xr.left,i=t-Xr.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=eA(u.length),l=u.map(({series:p,index:m},g)=>{const w=Xr.top+g*(Yu+c+Tw),y=w+Yu,b=y+c,v=p.values.filter(J=>J!=null),k=Math.min(0,...v),_=Math.max(...v,k+1e-9),$={plotTop:y,plotBottom:b,min:k,max:_},O=[],j=[];let P=[];return p.values.forEach((J,se)=>{if(J==null){P.length&&j.push(P),P=[];return}const be=e.times[se]??o,ke={x:hs(a,be),y:Pw($,J),time:be,value:J,index:se};O.push(ke),P.push(ke)}),P.length&&j.push(P),{column:p.column,index:m,kind:Iw(p.column,p.values),color:Lw(m),top:w,plotTop:y,plotBottom:b,min:k,max:_,runs:j,points:O}}),d=(l[l.length-1]?.plotBottom??Xr.top)+Cw,f=Rw(s-o),h=[];if(e.times.length){const p=HC(o,s,(i-r)/ZC[f]);for(const m of p.times){const g=hs(a,m),w=g-r<34?"start":i-g<34?"end":"middle";h.push({x:g,label:VC(m,p.unit,p.step),anchor:w})}}return{width:t,height:d+Aw,plotLeft:r,plotRight:i,first:o,last:s,unit:f,lanes:l,ticks:h,axisY:d}}function nt(e,t,n={}){const r=e.createElementNS(kC,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const jt=e=>Math.round(e*10)/10;let tA=0;const nA="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 rA(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=Ju,d=t,f=bp(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",Lw(R));const ie=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},U,A(r,"span",{text:I.column}));return ie.addEventListener("click",()=>{const ce=QC(s,I.column,i);ce!==s&&(s=ce,P())}),ie}),m=A(r,"div",{class:"cv-chart-legend",role:"group","aria-label":"Show or hide a series"},...p),g=A(r,"button",{type:"button",class:"cv-chart-reset","data-reset-zoom":"",hidden:!0,text:"Reset zoom"}),w=nt(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),y=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++tA}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),b=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":nA,"aria-describedby":y.id},w),v=A(r,"div",{class:"cv-chart-body"},b,y),k=nt(r,"rect",{class:"cv-chart-brush"}),_=nt(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,g,n.toggle??null),v);e.replaceChildren(O);function j(){const I=[],R=f.lanes[0]?.plotTop??0,U=d.times.length>1?(f.plotRight-f.plotLeft)/(d.times.length-1):24,ie=Math.max(6,Math.min(24,U*.6));for(const te of d.failures){const Ce=hs(f,te.time),Ae=nt(r,"rect",{class:"cv-chart-failure","data-failure":te.day,x:jt(Ce-ie/2),y:R,width:jt(ie),height:Math.max(0,f.axisY-R)});I.push(Ae)}for(const te of f.lanes){const Ce=nt(r,"g",{class:"cv-chart-lane","data-series":te.column}),Ae=nt(r,"rect",{class:"cv-chart-swatch",x:f.plotLeft,y:te.top+4,width:14,height:4,rx:2});Ae.style.fill=te.color;const L=nt(r,"text",{class:"cv-chart-name",x:f.plotLeft+20,y:te.top+11});L.textContent=te.column,Ce.append(Ae,L,nt(r,"line",{class:"cv-chart-grid",x1:f.plotLeft,x2:f.plotRight,y1:te.plotTop,y2:te.plotTop}),nt(r,"line",{class:"cv-chart-base",x1:f.plotLeft,x2:f.plotRight,y1:te.plotBottom,y2:te.plotBottom}));const M=nt(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:te.plotTop+4,"text-anchor":"end"});M.textContent=yp(te.max,te.kind);const q=nt(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:te.plotBottom+4,"text-anchor":"end"});q.textContent=yp(te.min,te.kind),Ce.append(M,q);for(const K of te.runs){if(K.length<2)continue;const he=nt(r,"polyline",{class:"cv-chart-line",points:K.map(le=>`${jt(le.x)},${jt(le.y)}`).join(" "),fill:"none"});he.style.stroke=te.color,Ce.append(he)}if(te.points.length<=IC)for(const K of te.points){const he=nt(r,"circle",{class:"cv-chart-dot",cx:jt(K.x),cy:jt(K.y),r:3,"data-index":a.start+K.index,"data-time":K.time});he.style.fill=te.color,Ce.append(he)}I.push(Ce)}const ce=nt(r,"g",{class:"cv-chart-axis"});for(const te of f.ticks){const Ce=nt(r,"text",{class:"cv-chart-tick",x:jt(te.x),y:f.axisY+14,"text-anchor":te.anchor});Ce.textContent=te.label,ce.append(Ce)}return I.push(ce),I}function P(){d=XC(t,a.start,a.end),f=bp(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,...j(),_),h.textContent=KC(d,s);for(const U of p){const ie=!s.has(U.dataset.series??"");U.setAttribute("aria-pressed",String(ie)),ie&&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;g.hidden=!R,O.dataset.zoomed=String(R),J(),se()}function J(){if(!c||Math.abs(c.to-c.from)<gp){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(jt(R))),k.setAttribute("width",String(jt(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",y.hidden=!0,y.replaceChildren(),delete b.dataset.focus;return}const I=u-a.start,R=d.times[I]??f.first,U=jt(hs(f,R)),ie=f.lanes[0]?.plotTop??0;_.append(nt(r,"line",{class:"cv-chart-crossline",x1:U,x2:U,y1:ie,y2:f.axisY}));const ce=[];for(const Ae of f.lanes){const L=d.series[Ae.index]?.values[I]??null;if(L!=null){const q=nt(r,"circle",{class:"cv-chart-focus",cx:U,cy:jt(Pw(Ae,L)),r:4.5});q.style.fill=Ae.color,_.append(q)}const M=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});M.style.setProperty("--cv-key",Ae.color),ce.push(A(r,"dt",{},M,Ae.column),A(r,"dd",{"data-value":Ae.column,text:fs(L,Ae.kind)}))}_.style.display="",_.dataset.index=String(u),_.dataset.time=String(R),b.dataset.focus=String(u);const te=d.failures.find(Ae=>Ae.time===R),Ce=d.rowCounts[I]??1;y.replaceChildren(...[A(r,"time",{datetime:new Date(R).toISOString(),text:FC(R,d.daily)}),te?A(r,"p",{class:"cv-chart-readout-note","data-failure":te.code,text:`No answer: ${te.code}`}):null,Ce>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":Ce,text:`${hi.format(Ce)} transfers`}):null,A(r,"dl",{},...ce)].filter(Ae=>Ae!=null)),y.hidden=!1,be(U,ie)}function be(I,R){const U=w.getBoundingClientRect(),ie=v.getBoundingClientRect(),ce=U.width>0?U.width/f.width:1,te=U.left-ie.left+I*ce,Ce=I>(f.plotLeft+f.plotRight)/2;y.style.left=`${Math.round(Ce?te-12:te+12)}px`,y.style.top=`${Math.round(U.top-ie.top+R*ce)}px`,y.dataset.side=Ce?"left":"right"}const ke=I=>{const R=w.getBoundingClientRect();return R.width>0?(I-R.left)*f.width/R.width:Number.NaN},Ue=I=>a.start+JC(d.times,au(f,I));b.addEventListener("pointermove",I=>{const R=ke(I.clientX);Number.isFinite(R)&&(c&&(c.to=R,J()),u=Ue(R),se())}),b.addEventListener("pointerdown",I=>{if(I.button!==0)return;const R=ke(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:ie}=c;c=null;try{b.releasePointerCapture(ie)}catch{}if(J(),!I||Math.abs(U-R)<gp)return;const ce=YC(t.times,au(f,R),au(f,U));!ce||ce.start===a.start&&ce.end===a.end||(a=ce,u=Ue(U),P())};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()}),g.addEventListener("click",()=>{a=o,u=null,P(),b.focus({preventScroll:!0})});const Z=()=>{const I=Math.round(b.clientWidth);return I>0?Math.max(SC,I):null},W=()=>{const I=Z();I==null||I===l||(l=I,P())};l=Z()??Ju,P();const Q=r.defaultView?.ResizeObserver,Y=Q?new Q(()=>W()):null;return Y?.observe(b),{root:O,get layout(){return f},refit:W,destroy(){Y?.disconnect()}}}const iA="chain-insights.transfers.v1",oA="graph_expand",sA="2015-01-01";function aA(e,t,n,r){return{network:e,from:t,to:n,day:r}}function uA(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?ru(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?ru(e.last_seen_timestamp):ru(t);return{first:n,last:n&&r<n?n:r}}function Fo(e,t){return e<=(t??sA)}function cA(e){if(!e)return"no answer";const t=So(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:Dw(e.structuredContent)?null:t||"the answer held no transfers"}function Dw(e){const t=e;if(!t||t.schema!==iA||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!Vf(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=Yt(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:Yt(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 dA(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 fA(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 hA(e){return e==null?"—":`${new Date(Hf(e)).toISOString().slice(11,19)} UTC`}function uu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function pA(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=`${uu(l.day)} (UTC)`,u.disabled=l.status==="loading"||Fo(l.day,l.firstDay);const w=Fo(l.day,l.firstDay)?null:sp(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${uu(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 ${uu(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(y=>mA(e,y,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"&&Fo(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 y=++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:oA,arguments:aA(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(y!==d||l!==b)return b;const k=cA(v);if(k)b.status="error",b.transfers=[],b.error=k.length>300?`${k.slice(0,299)}…`:k;else{const _=Dw(v.structuredContent);b.status="ready",b.transfers=lA(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>g.close(),m=()=>{g.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const g={element:c,open(w){const y=uA(w,n());return l={from:w.from,to:w.to,day:y.last,firstDay:y.first,status:"loading",transfers:[],truncated:!1,error:null},h(y.last)},async earlier(){return!l||l.status==="loading"||Fo(l.day,l.firstDay)?null:h(sp(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 g}function mA(e,t,n){const r=gw(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:fi(t.tx_id)}):A(e,"code",{title:t.tx_id,text:fi(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:hA(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${dA(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":fA(t.amount_usd)}),o)}const gA="graph_expand",Uo="too busy to expand",Ow=640,yA=300,cu=.45,vA="Full screen shows the whole graph",wp=400,lu="expanded",Mw=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.",Xu=new Intl.NumberFormat("en-US");function _p(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 wA(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${Xu.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function _A(e,t){return`Not loaded: ${Xu.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${Xu.format(Mw)} addresses. Fold another address to make room.`}const kp=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let kA=0;const SA=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function xA(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function EA(e){const t=So(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Mf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function $A(e,t,n,r=Ow,i=yA){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(cu,Math.min(1,(t-di*2)/o)),u=Math.ceil(n+s*a+di*2),c=Math.min(r,Math.max(i,u));return Qh(e,t,c-n)>=cu?{height:c,fits:!0}:{height:r,fits:Qh(e,t,r-n)>=cu}}function TA(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function CA(e){const t=e.split(`
|
|
110
|
-
`)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function AA(e,t){return`investigator expanded ${e}: ${t} new addresses`}function IA(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&ko({role:n.role??null,labels:n.labels??[]})||"Other"}function Fw(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:_p(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",g=A(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:bA}),w=A(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),y=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}),j=pA(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Ve()}),P=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"},_,$),j.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"}),be=A(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:vA}),ke=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,be,J),Ue=A(r,"span",{class:"cv-muted","data-subtitle":""}),F=`cv-addresses-${++kA}`,Z=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:F,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let W=[],Q=-1;const Y=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}),Ue),n.toggle??null,ke),w,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},Z,y,P),g);e.replaceChildren(Y);function I(){const G=ee.model(),ae=G.truncated?" · more flows than shown":"";Ue.textContent=`${o} · ${IA(t,o)} · ${i} · ${G.nodes.length} addresses${ae}`;const ve=new Set(G.nodes.map(Ne=>Ne.role??"other"));w.replaceChildren(...SA.filter(([Ne])=>ve.has(Ne)).map(([Ne,Je])=>{const It=A(r,"i",{"aria-hidden":"true"});return It.style.background=`var(--cia-graph-role-${Ne})`,A(r,"li",{"data-role":Ne},It,Je)})),R()}function R(){const G=ee.model().nodes,ae=W[Q]??null;W=G.map(Ne=>Ne.address.toLowerCase()),Z.replaceChildren(...G.map((Ne,Je)=>A(r,"div",{role:"option",id:`${F}-${Je}`,"data-list-address":W[Je],"aria-selected":"false",text:`${Ne.address} ${ko({role:Ne.role??null,labels:Ne.labels??[]})||"Other"}`})));const ve=ae?W.indexOf(ae):-1;Q=ve>=0?ve:W.length?Math.min(Math.max(Q,-1),W.length-1):-1,U()}function U(){for(const ae of Z.children)ae.setAttribute("aria-selected",String(ae.id===`${F}-${Q}`));Q>=0?Z.setAttribute("aria-activedescendant",`${F}-${Q}`):Z.removeAttribute("aria-activedescendant");const G=r.activeElement===Z;ee.highlight(G?W[Q]??null:null)}function ie(G){return G?ee.model().nodes.find(ae=>ae.id===G)?.address.toLowerCase()??null:null}const ce=G=>{const ae=G.target,ve=G.key==="Enter"||G.key===" ",Ne=ae?.closest?.("[data-node-id]");if(ve&&G.shiftKey&&Ne){G.preventDefault();const Je=ie(Ne.dataset.nodeId);Je&&ne(Je)}};y.addEventListener("keydown",ce,!0);function te(G){W.length&&(Q=Math.max(0,Math.min(W.length-1,G)),U())}const Ce=()=>{Q<0&&W.length&&(Q=0),U()},Ae=()=>ee.highlight(null),L=G=>{const ae=W[Q];switch(G.key){case"ArrowDown":G.preventDefault(),te(Q+1);return;case"ArrowUp":G.preventDefault(),te(Q-1);return;case"Home":G.preventDefault(),te(0);return;case"End":G.preventDefault(),te(W.length-1);return;case"Escape":Gt();return;case"Enter":case" ":if(G.preventDefault(),!ae)return;G.shiftKey?ne(ae):ee.select(ae);return}};Z.addEventListener("focus",Ce),Z.addEventListener("blur",Ae),Z.addEventListener("keydown",L);function M(){const G=h;if(!G){_.hidden=!0,$.hidden=!0,O.hidden=!0;return}const ae=d.has(G),ve=ae?wA(a.get(G)?.remaining??null):null;O.hidden=!ve,O.textContent=ve??"",_.hidden=!1,_.disabled=u.has(G)||c.has(G),_.textContent=u.has(G)?"Too busy to expand":ae?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${G}`),$.hidden=!(ae&&kp(a.get(G)))}function q(G){const ae=P.hidden;P.hidden=G.kind==null,G.kind==="node"&&G.node?(h=G.node.address.toLowerCase(),v.textContent="Address details",j.close()):(h=null,G.kind==="edge"?v.textContent="Link details":j.close()),M(),ae!==P.hidden&&Ve()}let K=null;function he(){K&&clearTimeout(K),K=null}function le(G){const ae=G.source==="pointer"&&G.kind==="node"&&G.node,ve=G.source!=="program"&&G.kind==="edge"&&G.edge;if(he(),ae){const Ne=G.node.address.toLowerCase(),Je=p();f&&f.address===Ne&&Je-f.at<=wp?(f=null,Gt(),ne(Ne)):(f={address:Ne,at:Je},K=setTimeout(()=>{K=null,q(G)},wp));return}G.kind!=="node"&&(f=null),q(G),ve&&j.open(G.edge)}const Ee=n.height??Ow,Ie=`${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 fe(){return jT(y,t,{layout:"tree",width:n.width??720,height:Ee,now:n.now,controls:ke,selectionRoot:b,onSelect:le,openLink:G=>{n.host.openLink?.({url:G}).catch(()=>{g.textContent="The host did not open the link."})},label:Ie})}let ee=fe();I();let Be=n.displayMode??"inline",ut=n.availableDisplayModes??[];const He=()=>!!n.host.requestDisplayMode&&(ut.length===0||ut.includes("fullscreen"));function Ve(){if(Be==="fullscreen"){Y.style.removeProperty("height"),be.hidden=!0;return}const G=y.clientWidth||n.width||720,ae=Math.max(0,Y.offsetHeight-y.offsetHeight)||140,{height:ve,fits:Ne}=$A(ee.contentBounds(),G,ae);Y.style.height=`${ve}px`,be.hidden=Ne||!He(),Y.dataset.fits=String(Ne),ee.fit()}async function pt(G){try{await n.host.updateModelContext?.({content:[{type:"text",text:G}]})}catch{}}async function C(G,ae=!1){const ve=G.toLowerCase();if(u.has(ve))return g.textContent=`${ve} is ${Uo}.`,{added:[],refused:Uo};if(c.has(ve))return{added:[],refused:null};const Ne=a.get(ve);if(Ne&&!kp(Ne))return g.textContent=`Every recent flow of ${ve} is drawn.`,{added:[],refused:null};c.add(ve),M(),g.textContent=`Loading the flows of ${ve}…`;let Je=null;try{Je=await n.host.callServerTool({name:gA,arguments:xA(i,ve,ae||Ne?Ne?.cursor:null)})}catch(_t){Je={isError:!0,content:[{type:"text",text:_t instanceof Error?_t.message:String(_t)}]}}finally{c.delete(ve)}const It=EA(Je);if(It)return TA(It)?(u.add(ve),ee.markNode(ve,Uo),g.textContent=`${ve} is ${Uo}. The drawing is kept.`):g.textContent=`${ve} could not be expanded: ${CA(It)}. The drawing is kept; try again.`,M(),{added:[],refused:It};const qe=Je.structuredContent,qa=ee.model(),Nn=new Set(qa.nodes.map(_t=>_t.address.toLowerCase())),Wa=new Set;for(const _t of qe.nodes)Nn.has(_t.address.toLowerCase())||Wa.add(_t.address.toLowerCase());for(const _t of qe.edges)for(const $o of[_t.from,_t.to])Nn.has($o.toLowerCase())||Wa.add($o.toLowerCase());if(Nn.size+Wa.size>Mw){const _t=new Set(qa.edges.map(Rn=>`${Rn.from.toLowerCase()}->${Rn.to.toLowerCase()}`)),$o=new Set(qe.edges.map(Rn=>`${Rn.from.toLowerCase()}->${Rn.to.toLowerCase()}`).filter(Rn=>!_t.has(Rn))).size,th=_A($o,ve);return g.textContent=th,M(),{added:[],refused:th}}const Eo=ee.merge(qe,ve);return l.push({address:ve,page:qe}),d.add(ve),ee.flagNode(ve,lu,!0),a.set(ve,{cursor:qe.cursor??null,truncated:!!qe.truncated,remaining:_p(qe)}),I(),Ve(),M(),g.textContent=`${Eo.length} new ${Eo.length===1?"address":"addresses"} linked to ${ve}. Double-click it again to fold them back.`,await pt(AA(ve,Eo.length)),{added:Eo,refused:null}}function D(G){const ae=G.toLowerCase();if(!d.has(ae))return{removed:0};const ve=ee.model().nodes.length;d.delete(ae),a.delete(ae);const Ne=l.filter(qe=>qe.address!==ae),Je=[];ee.batch(()=>{ee.flagNode(ae,lu,!1),ee.update(t);for(const qe of Ne)ee.model().nodes.some(Nn=>Nn.address.toLowerCase()===qe.address)?(ee.merge(qe.page,qe.address),Je.push(qe)):Je.some(Nn=>Nn.address===qe.address)||(ee.flagNode(qe.address,lu,!1),d.delete(qe.address),a.delete(qe.address))}),l=Je;const It=Math.max(0,ve-ee.model().nodes.length);return h&&!ee.model().nodes.some(qe=>qe.address.toLowerCase()===h)&&(P.hidden=!0,h=null),I(),Ve(),M(),g.textContent=`Folded ${ae} back: ${It} ${It===1?"address":"addresses"} removed.`,pt(`investigator collapsed ${ae}: ${It} addresses removed`),{removed:It}}async function ne(G){d.has(G)?D(G):await C(G)}function Se(){he(),ee.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,j.close(),P.hidden=!0,ee=fe(),I(),Ve(),M(),g.textContent="Back to the first answer."}function pe(G,ae){G&&(Be=G),ae&&(ut=ae),Y.dataset.displayMode=Be,J.hidden=!He(),J.textContent=Be==="fullscreen"?"Exit full screen":"Full screen",J.setAttribute("aria-label",Be==="fullscreen"?"Back to the inline view":"Open full screen"),Ve()}pe(Be);const ct=async()=>{const G=Be==="fullscreen"?"inline":"fullscreen";try{const ae=await n.host.requestDisplayMode?.({mode:G});pe(ae?.mode??G)}catch{g.textContent="The host did not change the display mode."}},At=()=>Se();function Gt(){he();const G=!P.hidden;ee.select(null),j.close(),P.hidden=!0,h=null,M(),G&&Ve()}const Zr=()=>Gt(),In=()=>{h&&ne(h)},mn=()=>{h&&C(h,!0)};return J.addEventListener("click",ct),se.addEventListener("click",At),k.addEventListener("click",Zr),_.addEventListener("click",In),$.addEventListener("click",mn),{root:Y,get graph(){return ee},expand:G=>C(G),collapse:D,reset:Se,expanded:()=>[...d],linkPanel:j,openLink(G,ae){const ve=ee.model().edges.find(Ne=>Ne.from===G.toLowerCase()&&Ne.to===ae.toLowerCase());return ve?(ee.select(ve.id),j.open(ve)):Promise.resolve(null)},setTheme(G){ee.setTheme(G)},setDisplayMode:pe,refit:Ve,destroy(){he(),y.removeEventListener("keydown",ce,!0),Z.removeEventListener("focus",Ce),Z.removeEventListener("blur",Ae),Z.removeEventListener("keydown",L),J.removeEventListener("click",ct),se.removeEventListener("click",At),k.removeEventListener("click",Zr),_.removeEventListener("click",In),$.removeEventListener("click",mn),j.destroy(),ee.destroy()}}}function Qu(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function NA(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 Uw=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height});function RA(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(vw)} addresses. The table has the rows.`}function zA(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 LA(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:Zf,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function PA(e){const t=_w(e.structuredContent);if(t)return{model:t.model,table:LA(t.rows,e.structuredContent)};const n=qf(Bf(e.structuredContent));return n?{model:n,table:e}:null}function Gw(e,t,n){const r=e.ownerDocument,i=xw(t),o=i==="chart"?PA(t):null;if(i!=="graph"&&!o)return i==="table"?hp(e,t):Ga(e,t),Qu(i==="table"?"table":"text");const s=t.structuredContent,a=Bf(s),u=o?.table??t,c=A(r,"div",{class:"cv-face","data-face":"picture"}),l=A(r,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(c,l);const d=zA(r,i==="graph"?"Graph":"Chart",g=>m(g));let f=null,h=null,p=!1;if(i==="graph"){const g=dC(a,VT(s));f=Fw(c,g.view,{...Uw(n),title:"Money flow graph",toggle:d.make(),note:RA(g.rowsLeftOut,g.rowsTotal)})}else h=rA(c,o.model,{toggle:d.make()});function m(g){c.hidden=g!=="picture",l.hidden=g!=="table",g==="table"&&!p&&(p=!0,hp(l,u,{toggle:d.make()})),d.set(g),g==="picture"&&(f?.refit(),h?.refit())}return{kind:i,flows:()=>f?[f]:[],setTheme(g){f?.setTheme(g)},setDisplayMode(g,w){f?.setDisplayMode(g,w)},refit(){c.hidden||(f?.refit(),h?.refit())},destroy(){f?.destroy(),h?.destroy()}}}function DA(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:Zf,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 OA(e,t,n){const r=e.ownerDocument,i=kw(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],g=s[p];if(!m||!g)return;d=p,o.forEach((y,b)=>{y.setAttribute("aria-selected",String(b===p)),y.tabIndex=b===p?0:-1}),s.forEach((y,b)=>{y.hidden=b!==p});const w=u[p];if(w)w.refit();else{const y=Gw(g,DA(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l});u[p]=y,g.dataset.view=y.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",g=>{const w=o.length-1,y=g.key==="ArrowRight"?m===w?0:m+1:g.key==="ArrowLeft"?m===0?w:m-1:g.key==="Home"?0:g.key==="End"?w:null;y!=null&&(g.preventDefault(),h(y),o[y]?.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 g of u)g?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function MA(e,t,n){const r=xw(t);if(r==="flows"){const i=Fw(e,t.structuredContent,Uw(n));return NA("flows",()=>i)}return r==="graph"||r==="chart"||r==="table"?Gw(e,t,n):r==="batch"?OA(e,t,n):r==="balance"?(_C(e,t),Qu("balance")):(Ga(e,t),Qu("text"))}function FA(e){return e==="light"||e==="dark"}function UA(e,t=()=>!1){return FA(e?.theme)?e.theme:t()?"dark":"light"}function Wf(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 jw(e,t,n={}){const r=e.documentElement,i=UA(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 GA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Sp;function jA(){if(Sp)return Go.exports;Sp=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)}Go.exports=o,Go.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",j=this._events;if(j!==void 0)O=O&&j.error===void 0;else if(!O)return!1;if(O){var P;if(_.length>0&&(P=_[0]),P instanceof Error)throw P;var J=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw J.context=P,J}var se=j[k];if(se===void 0)return!1;if(typeof se=="function")t(se,this,_);else for(var be=se.length,ke=p(se,be),$=0;$<be;++$)t(ke[$],this,_);return!0};function c(v,k,_,$){var O,j,P;if(a(_),j=v._events,j===void 0?(j=v._events=Object.create(null),v._eventsCount=0):(j.newListener!==void 0&&(v.emit("newListener",k,_.listener?_.listener:_),j=v._events),P=j[k]),P===void 0)P=j[k]=_,++v._eventsCount;else if(typeof P=="function"?P=j[k]=$?[_,P]:[P,_]:$?P.unshift(_):P.push(_),O=u(v),O>0&&P.length>O&&!P.warned){P.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=v,J.type=k,J.count=P.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,j,P,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(j=-1,P=$.length-1;P>=0;P--)if($[P]===_||$[P].listener===_){J=$[P].listener,j=P;break}if(j<0)return this;j===0?$.shift():m($,j),$.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 j=Object.keys($),P;for(O=0;O<j.length;++O)P=j[O],P!=="removeListener"&&this.removeAllListeners(P);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]:_?g(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 g(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(P){v.removeListener(k,j),$(P)}function j(){typeof v.removeListener=="function"&&v.removeListener("error",O),_([].slice.call(arguments))}b(v,k,j,{once:!0}),k!=="error"&&y(v,O,{once:!0})})}function y(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(j){$.once&&v.removeEventListener(k,O),_(j)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Go.exports}var Zw=jA();function ZA(){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 Ye=ZA;typeof Object.assign=="function"&&(Ye=Object.assign);function Pt(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 rt(e){return typeof e=="object"&&e!==null}function Bw(e){let t;for(t in e)return!1;return!0}function Nt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Zt(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 xp(e){return!(!rt(e)||e.attributes&&!Array.isArray(e.attributes))}function BA(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function on(){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 Ur(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Kf extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class V extends Kf{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,V.prototype.constructor)}}class B extends Kf{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,B.prototype.constructor)}}class oe extends Kf{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,oe.prototype.constructor)}}function Hw(e,t){this.key=e,this.attributes=t,this.clear()}Hw.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 Vw(e,t){this.key=e,this.attributes=t,this.clear()}Vw.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function qw(e,t){this.key=e,this.attributes=t,this.clear()}qw.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Gr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Gr.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)};Gr.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};Gr.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]};Gr.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 Ww=0,Kw=1,HA=2,Jw=3;function pn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===Ww){if(a=e._nodes.get(r),!a)throw new B(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===Jw){if(i=""+i,u=e._edges.get(i),!u)throw new B(`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 B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Kw?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function VA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);return s.attributes[a]}}function qA(e,t,n){e.prototype[t]=function(r,i){const[o]=pn(this,t,n,r,i);return o.attributes}}function WA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function KA(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=pn(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 JA(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=pn(this,t,n,r,i,o,s);if(typeof c!="function")throw new V(`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 YA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(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 XA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(!rt(a))throw new V(`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 QA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(!rt(a))throw new V(`Graph.${t}: provided attributes are not a plain object.`);return Ye(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function eI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(typeof a!="function")throw new V(`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 tI=[{name:e=>`get${e}Attribute`,attacher:VA},{name:e=>`get${e}Attributes`,attacher:qA},{name:e=>`has${e}Attribute`,attacher:WA},{name:e=>`set${e}Attribute`,attacher:KA},{name:e=>`update${e}Attribute`,attacher:JA},{name:e=>`remove${e}Attribute`,attacher:YA},{name:e=>`replace${e}Attributes`,attacher:XA},{name:e=>`merge${e}Attributes`,attacher:QA},{name:e=>`update${e}Attributes`,attacher:eI}];function nI(e){tI.forEach(function({name:t,attacher:n}){n(e,t("Node"),Ww),n(e,t("Source"),Kw),n(e,t("Target"),HA),n(e,t("Opposite"),Jw)})}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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function iI(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=Pt(this,o,s,n),!i)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function oI(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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function sI(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=Pt(this,a,u,n),!s)throw new B(`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 B(`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 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=Pt(this,a,u,n),!s)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new V(`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 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=Pt(this,s,a,n),!o)throw new B(`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 B(`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 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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!rt(i))throw new V(`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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!rt(i))throw new V(`Graph.${t}: provided attributes are not a plain object.`);return Ye(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data: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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new V(`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 fI=[{name:e=>`get${e}Attribute`,attacher:rI},{name:e=>`get${e}Attributes`,attacher:iI},{name:e=>`has${e}Attribute`,attacher:oI},{name:e=>`set${e}Attribute`,attacher:sI},{name:e=>`update${e}Attribute`,attacher:aI},{name:e=>`remove${e}Attribute`,attacher:uI},{name:e=>`replace${e}Attributes`,attacher:cI},{name:e=>`merge${e}Attributes`,attacher:lI},{name:e=>`update${e}Attributes`,attacher:dI}];function hI(e){fI.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const pI=[{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 gI(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 du(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 yI(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 vI(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 fu(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 bI(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 Yw(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 wI(e,t){if(e.size===0)return Ur();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 Jf(e,t,n,r,i,o){const s=t?gI: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 _I(e,t,n,r){const i=[];return Jf(!1,e,t,n,r,function(o){i.push(o)}),i}function kI(e,t,n){let r=Ur();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=on(r,du(n.in))),t!=="in"&&typeof n.out<"u"&&(r=on(r,du(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=on(r,du(n.undirected))),r}function Yf(e,t,n,r,i,o,s){const a=n?vI:yI;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 SI(e,t,n,r,i){const o=[];return Yf(!1,e,t,n,r,i,function(s){o.push(s)}),o}function xI(e,t,n,r){let i=Ur();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=on(i,fu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=on(i,fu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=on(i,fu(n.undirected,r))),i}function EI(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 bI(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new B(`Graph.${n}: could not find the "${o}" node in the graph.`);return _I(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 B(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new B(`Graph.${n}: could not find the "${s}" target node in the graph.`);return SI(r,this.multi,i,a,s)}throw new V(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function $I(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,Yw(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${c}" node in the graph.`);return Jf(!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 B(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new B(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Yf(!1,r,this.multi,i,f,l,d)}throw new V(`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,g,w,y,b,v)=>{d[h++]=l(p,m,g,w,y,b,v)})}else d=[],c.push((f,h,p,m,g,w,y)=>{d.push(l(f,h,p,m,g,w,y))});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,g,w,y)=>{l(f,h,p,m,g,w,y)&&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 V(`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 V(`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,g,w,y,b)=>{f=l(f,h,p,m,g,w,y,b)}),this[o].apply(this,c),f}}function TI(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,Yw(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new B(`Graph.${o}: could not find the "${u}" node in the graph.`);return Jf(!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 B(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new B(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Yf(!0,r,this.multi,i,d,c,l)}throw new V(`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,g,w)=>c(d,f,h,p,m,g,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,g,w)=>!c(d,f,h,p,m,g,w)),!this[o].apply(this,u)}}function CI(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 Ur();if(!arguments.length)return wI(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return kI(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new B(`Graph.${o}: could not find the "${a}" target node in the graph.`);return xI(r,i,u,a)}throw new V(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function AI(e){pI.forEach(t=>{EI(e,t),$I(e,t),TI(e,t),CI(e,t)})}const II=[{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 ja(){this.A=null,this.B=null}ja.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};ja.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Vr(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 Xf(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Vr(e,null,r,r.undirected,i);if(typeof n=="string")return Vr(e,null,r,r[n],i)}const o=new ja;let s;if(t!=="undirected"){if(n!=="out"){if(s=Vr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Vr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Vr(e,o,r,r.undirected,i),e&&s))return s}function NI(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 Xf(!1,e,t,n,function(i){r.push(i)}),r}function qr(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 RI(e,t,n){if(e!=="mixed"){if(e==="undirected")return qr(null,n,n.undirected);if(typeof t=="string")return qr(null,n,n[t])}let r=Ur();const i=new ja;return e!=="undirected"&&(t!=="out"&&(r=on(r,qr(i,n,n.in))),t!=="in"&&(r=on(r,qr(i,n,n.out)))),e!=="directed"&&(r=on(r,qr(i,n,n.undirected))),r}function zI(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 B(`Graph.${n}: could not find the "${o}" node in the graph.`);return NI(r==="mixed"?this.type:r,i,s)}}function LI(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 B(`Graph.${o}: could not find the "${c}" node in the graph.`);Xf(!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 V(`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 PI(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 B(`Graph.${s}: could not find the "${c}" node in the graph.`);return Xf(!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 DI(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 Ur();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return RI(r==="mixed"?this.type:r,i,a)}}function OI(e){II.forEach(t=>{zI(e,t),LI(e,t),PI(e,t),DI(e,t)})}function jo(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 MI(e,t){const n={key:e};return Bw(t.attributes)||(n.attributes=Ye({},t.attributes)),n}function FI(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return Bw(n.attributes)||(r.attributes=Ye({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function UI(e){if(!rt(e))throw new V('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 V("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!rt(e.attributes)||e.attributes===null))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function GI(e){if(!rt(e))throw new V('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 V("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!rt(e.attributes)||e.attributes===null))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const jI=BA(),ZI=new Set(["directed","undirected","mixed"]),Ep=new Set(["domain","_events","_eventsCount","_maxListeners"]),BI=[{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"}],HI={allowSelfLoops:!0,multi:!1,type:"mixed"};function VI(e,t,n){if(n&&!rt(n))throw new V(`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 $p(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 Xw(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&&!rt(a))throw new V(`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 B(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new B(`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 Gr(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 qI(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 V(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!rt(a))throw new V(`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 y=[h.key,!1,!1,!1];if(u?!c:!a)return y;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Ye(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return y}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,g=!1;l||(l=$p(e,o,{}),m=!0,o===s&&(d=l,g=!0)),d||(d=$p(e,s,{}),g=!0),f=new Gr(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,g]}function Jn(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 Oe extends Zw.EventEmitter{constructor(t){if(super(),t=Ye({},HI,t),typeof t.multi!="boolean")throw new V(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!ZI.has(t.type))throw new V(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new V(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Hw:t.type==="directed"?Vw:qw;Nt(this,"NodeDataClass",n);const r="geid_"+jI()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Nt(this,"_attributes",{}),Nt(this,"_nodes",new Map),Nt(this,"_edges",new Map),Nt(this,"_directedSize",0),Nt(this,"_undirectedSize",0),Nt(this,"_directedSelfLoopCount",0),Nt(this,"_undirectedSelfLoopCount",0),Nt(this,"_edgeKeyGenerator",o),Nt(this,"_options",t),Ep.forEach(s=>Nt(this,s,this[s])),Zt(this,"order",()=>this._nodes.size),Zt(this,"size",()=>this._edges.size),Zt(this,"directedSize",()=>this._directedSize),Zt(this,"undirectedSize",()=>this._undirectedSize),Zt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Zt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Zt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Zt(this,"multi",this._options.multi),Zt(this,"type",this._options.type),Zt(this,"allowSelfLoops",this._options.allowSelfLoops),Zt(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 V(`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 V(`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 V(`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 B(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return VI(this,t,n).key}mergeNode(t,n){if(n&&!rt(n))throw new V(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ye(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 V(`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 B(`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 Jn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Jn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Jn(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=Pt(this,r,i,this.type),!n)throw new B(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new B(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Jn(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=Pt(this,t,n,"directed");if(!r)throw new B(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Jn(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=Pt(this,t,n,"undirected");if(!r)throw new B(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Jn(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 V("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(!rt(t))throw new V("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(!rt(t))throw new V("Graph.mergeAttributes: provided attributes are not a plain object.");return Ye(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new V("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 V("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!xp(n))throw new V("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 V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!xp(n))throw new V("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 V("Graph.forEachAdjacencyEntry: expecting a callback.");jo(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");jo(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");jo(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");jo(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new V("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 V("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 V("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 V("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 V("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 V("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 V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("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++]=MI(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=FI(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 Oe)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(!rt(t))throw new V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!rt(t.attributes))throw new V("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 V("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],UI(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 V("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],GI(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 Oe(Ye({},this._options,t));return n.replaceAttributes(Ye({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Ye({},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,Xw(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Ye({},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)&&!Ep.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Nt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Oe.prototype[Symbol.for("nodejs.util.inspect.custom")]=Oe.prototype.inspect);BI.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?Xw:qI;e.generateKey?Oe.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Oe.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});nI(Oe);hI(Oe);AI(Oe);OI(Oe);class Qw extends Oe{constructor(t){const n=Ye({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class e_ extends Oe{constructor(t){const n=Ye({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class t_ extends Oe{constructor(t){const n=Ye({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class n_ extends Oe{constructor(t){const n=Ye({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class r_ extends Oe{constructor(t){const n=Ye({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function jr(e){e.from=function(t,n){const r=Ye({},t.options,n),i=new e(r);return i.import(t),i}}jr(Oe);jr(Qw);jr(e_);jr(t_);jr(n_);jr(r_);Oe.Graph=Oe;Oe.DirectedGraph=Qw;Oe.UndirectedGraph=e_;Oe.MultiGraph=t_;Oe.MultiDirectedGraph=n_;Oe.MultiUndirectedGraph=r_;Oe.InvalidArgumentsGraphError=V;Oe.NotFoundGraphError=B;Oe.UsageGraphError=oe;function WI(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 ri(e){var t=WI(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 Tp(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,ri(r.key),r)}}function ht(e,t,n){return t&&Tp(e.prototype,t),n&&Tp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function mr(e){return mr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mr(e)}function i_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(i_=function(){return!!e})()}function KI(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function JI(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 KI(e)}function Ft(e,t,n){return t=mr(t),JI(e,i_()?Reflect.construct(t,n||[],mr(e).constructor):t.apply(e,n))}function ec(e,t){return ec=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ec(e,t)}function Ut(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&&ec(e,t)}function YI(e){if(Array.isArray(e))return e}function XI(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 tc(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 o_(e,t){if(e){if(typeof e=="string")return tc(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)?tc(e,t):void 0}}function QI(){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 gr(e,t){return YI(e)||XI(e,t)||
|
|
107
|
+
- "app": Tool callable by the app from this server only`),csp:Hn().optional(),permissions:Hn().optional()});T({mimeTypes:ue(x()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});T({method:E("ui/download-file"),params:T({contents:ue(we([Qb,ew])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});T({method:E("ui/message"),params:T({role:E("user").describe('Message role, currently only "user" is supported.'),content:ue(wo).describe("Message content blocks (text, image, etc.).")})});T({method:E("ui/notifications/sandbox-resource-ready"),params:T({html:x().describe("HTML content to load into the inner iframe."),sandbox:x().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Lf.optional().describe("CSP configuration from resource metadata."),permissions:Pf.optional().describe("Sandbox permissions from resource metadata.")})});var E$=T({method:E("ui/notifications/tool-result"),params:Fa.describe("Standard MCP tool execution result.")}),aw=T({toolInfo:T({id:po.optional().describe("JSON-RPC id of the tools/call request."),tool:zf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:c$.optional().describe("Current color theme preference."),styles:b$.optional().describe("Style configuration for theming the app."),displayMode:li.optional().describe("How the UI is currently displayed."),availableDisplayModes:ue(li).optional().describe("Display modes the host supports."),containerDimensions:we([T({height:ge().describe("Fixed container height in pixels.")}),T({maxHeight:we([ge(),dr()]).optional().describe("Maximum container height in pixels.")})]).and(we([T({width:ge().describe("Fixed container width in pixels.")}),T({maxWidth:we([ge(),dr()]).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: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:we([E("web"),E("desktop"),E("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Le().optional().describe("Whether the device supports touch input."),hover:Le().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(),$$=T({method:E("ui/notifications/host-context-changed"),params:aw.describe("Partial context update containing only changed fields.")});T({method:E("ui/update-model-context"),params:T({content:ue(wo).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:xe(x(),ze().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:Oa.describe("App identification (name and version)."),appCapabilities:k$.describe("Features and capabilities this app provides."),protocolVersion:x().describe("Protocol version this app supports.")})});var T$=T({protocolVersion:x().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Oa.describe("Host application identification and version."),hostCapabilities:_$.describe("Features and capabilities provided by the host."),hostContext:aw.describe("Rich context about the host environment.")}).passthrough(),C$={target:"draft-2020-12"};async function qh(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](C$);if(n.vendor==="zod"){let{z:r}=await H_(()=>Promise.resolve().then(()=>yx),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 Wh(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 A$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function I$(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 Df extends s${_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:m$,toolinputpartial:g$,toolresult:E$,toolcancelled:y$,hostcontextchanged:$$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!Df.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||Qe({jitless:!0}),this.setRequestHandler(Ma,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=o$(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 Wh(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 Wh(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 qh(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await qh(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(w$,(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(nw,(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(tw,(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},Fa,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Xb,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Yb,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?ow:iw;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},p$,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},vf,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},f$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},h$,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},S$,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 sw(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:a$}},T$,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 uw=new Map;function N$(e,t){uw.set(e,t)}function Kh(e){return uw.get(e)??null}const R$=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function z$(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 R$.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const L$="http://www.w3.org/2000/svg";let P$=0;function Lo(e){return Math.round(e*10)/10}function D$(e,t,n={}){const r=e.createElementNS(L$,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function Jh(e,t,n,r){const i=`cia-graph-svg-${++P$}`,o=e.ownerDocument,s=(F,Z)=>D$(o,F,Z),a=(F,Z,W)=>{const Q=s("text",{x:0,y:Z,"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":""}),g=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(g,w),l.append(d,h,p,m),e.append(l);const y=new Map,b=new Map,v=new Map;let k=null;function _(){if(k)return k;const F=t.model(),Z=t.positions(),W=new Map;k=W;const Q=F.nodes.length>ET,Y=new Map(F.nodes.map(R=>[R.address,R])),I=Q?[]:gT(F,Z,t.notes());for(const R of F.edges){const U=Y.get(R.from),ie=Y.get(R.to),ce=U&&Z[U.id],te=ie&&Z[ie.id];if(!U||!ie||!ce||!te){W.set(R.id,null);continue}if(Q){W.set(R.id,Zu(ce,te,Fn(U,F.checked_address),Fn(ie,F.checked_address)));continue}const Ce=I.filter(Ae=>Ae.id!==U.id&&Ae.id!==ie.id);W.set(R.id,$T(ce,te,Fn(U,F.checked_address),Fn(ie,F.checked_address),Ce))}return W}function $(F){let Z=y.get(F);if(Z)return Z;Z=`${i}-arrow-${y.size}`;const W=s("marker",{id:Z,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),y.set(F,Z),Z}function O(){return[...t.model().nodes??[]].sort((F,Z)=>String(F.id).localeCompare(String(Z.id)))}function j(){k=null;const F=t.model();g.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const Z=new Map(F.nodes.map(W=>[W.address,W]));for(const W of F.edges){const Q=Z.get(W.from);if(!Q||!Z.get(W.to))continue;const Y=t.colorOf(Q),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Wu(W,t.now())});I.dataset.edgeId=W.id,I.style.setProperty("--edge-tone",Y);const R=CT(),U=s("path",{class:"cia-graph-edge-hit","stroke-width":R.hit.width,"pointer-events":"stroke"}),ie=s("path",{class:"cia-graph-edge-line","stroke-width":R.line.width,"marker-end":`url(#${$(Y)})`,"pointer-events":"none"});I.append(U,ie),I.addEventListener("keydown",ce=>{ip(ce.key)&&(ce.preventDefault(),n.selectEdge(W.id,"keyboard"))}),I.addEventListener("pointerenter",ce=>n.showTooltip(ce,Wu(W,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),g.append(I),v.set(W.id,{group:I,hit:U,line:ie})}for(const W of O())w.append(P(W));se(),ke()}function P(F){const Z=t.model(),W=F.address===Z.checked_address,Q=t.notes().get(F.id),Y=Fr(F,Z.checked_address,Q),I=Y.radius,R=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":qu(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:Y.dot}));for(const U of Y.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=>{ip(U.key)&&(U.preventDefault(),n.selectNode(F.id,"keyboard"))}),R.addEventListener("pointerenter",U=>n.showTooltip(U,qu(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:Z,height:W}=t.dimensions();for(const[Y,I]of b){const R=F[Y]??{x:Z/2,y:W/2};I.setAttribute("transform",`translate(${Lo(R.x)} ${Lo(R.y)})`)}const Q=_();for(const Y of t.model().edges){const I=v.get(Y.id);if(!I)continue;const R=Q.get(Y.id)??null;I.group.style.display=R?"":"none",R&&(I.hit.setAttribute("d",R.d),I.line.setAttribute("d",R.d))}}function be(F){const Z=t.model(),W=t.positions(),Q=W[F],Y=b.get(F);if(!Q||!Y)return;Y.setAttribute("transform",`translate(${Lo(Q.x)} ${Lo(Q.y)})`);const I=Z.nodes.find(U=>U.id===F);if(!I)return;const R=new Map(Z.nodes.map(U=>[U.address,U]));for(const U of Z.edges){if(U.from!==I.address&&U.to!==I.address)continue;const ie=v.get(U.id),ce=R.get(U.from),te=R.get(U.to),Ce=ce&&W[ce.id],Ae=te&&W[te.id];if(!ie||!ce||!te||!Ce||!Ae)continue;const L=Zu(Ce,Ae,Fn(ce,Z.checked_address),Fn(te,Z.checked_address));ie.group.style.display=L?"":"none",L&&(ie.hit.setAttribute("d",L.d),ie.line.setAttribute("d",L.d))}}function ke(){const F=t.model(),Z=t.selected(),W=t.highlighted(),Q=Z?.kind==="node"?F.nodes.find(Y=>Y.id===Z.id)?.address??null:null;for(const Y of F.edges){const I=v.get(Y.id);if(!I)continue;const R=Z?.kind==="edge"&&Z.id===Y.id,U=Z?.kind==="edge"?R?Jt.related:Jt.faded:hw(Y,Q),ie=U===Jt.faded;I.group.setAttribute("opacity",ie?String(U):"1"),I.line.setAttribute("stroke-opacity",ie?"1":String(U)),I.group.dataset.opacity=String(U),I.group.dataset.state=U===Jt.rest?"rest":U===Jt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(R))}for(const[Y,I]of b){const R=Z?.kind==="node"&&Z.id===Y;I.classList.toggle("is-selected",R),I.classList.toggle("is-focused",W===Y),I.setAttribute("aria-pressed",String(R))}}function Ue(){let F=null;for(const Z of _().values())Z?.bounds&&(F=F??{...Z.bounds},F.x1=Math.min(F.x1,Z.bounds.x1),F.y1=Math.min(F.y1,Z.bounds.y1),F.x2=Math.max(F.x2,Z.bounds.x2),F.y2=Math.max(F.y2,Z.bounds.y2));return F}return{kind:"svg",surface:l,build:j,geometry(){k=null,se()},moveNode:be,endMove(){k=null,se()},camera:J,selection:ke,flag(F,Z,W){b.get(F)?.toggleAttribute(`data-flag-${Z}`,W)},theme(){for(const F of t.model().nodes)b.get(F.id)?.style.setProperty("--node-tone",t.colorOf(F))},resize(F,Z){l.setAttribute("viewBox",`0 0 ${F} ${Z}`)},pick:()=>null,linkBounds:Ue,destroy(){l.remove()}}}const O$=.45,M$=2.5,F$=5,U$="chain-insights.flows.v1",Of="cia-graph-model",G$=90,Jt={rest:.6,related:.95,faded:.07},Yh={checked:24,other:19},di=16,j$=[["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"],Z$={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},cw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Mf(e){return!!e&&e.schema===U$}function B$(e){return!!e&&e.kind===Of}function Ke(e){return String(e??"").trim().toLowerCase()}function H$(e){const t=Ke(e);return _o.includes(t)?t:"other"}function gn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Gu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function V$(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Lt(e){return B$(e)?e:Mf(e)?q$(e):K$(e)}function q$(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:gn(a.usd),tx_count:gn(a.tx_count),first_seen_timestamp:gn(a.first_seen_ms),last_seen_timestamp:gn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=W$(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:Gu(u.labels),taxonomy:[],role:H$(u.role),total_in_usd:gn(u.total_in_usd),total_out_usd:gn(u.total_out_usd),degree_in:gn(u.degree_in),degree_out:gn(u.degree_out)}});return{kind:Of,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function W$(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 g of d.get(m)??[])f.has(g)||(f.set(g,(f.get(m)??0)+1),p.push(g));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 K$(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":V$(r.direction),labels:Gu(r.labels),taxonomy:Gu(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:Of,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function J$(e,t,n){const r=Lt(t),i=Mn(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 Mn(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 fi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Ff(e){return String(e??"").trim().replace(/\s+/g," ")}function ls(e){return Ff(e).replaceAll(" ","").toLowerCase()}function xn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Ff(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Po(e,t){const n=new Set(xn(e).map(ls));return t.some(r=>n.has(ls(r)))}function Y$(e){if(e.role&&_o.includes(e.role))return Z$[e.role];if(Po(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Po(e,["Victim","Targeted"]))return"target";if(Po(e,["OnMoneyTrail","Mixer"]))return"trail";if(Po(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 X$={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 Q$(e,t=X$){const n=Y$(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function eT(e){return e.role&&_o.includes(e.role)?We(`role-${e.role}`):Q$(e).stroke}function ko(e){if(e.role&&e.role!=="other"&&_o.includes(e.role))return cw[e.role];const t=xn(e);for(const[r,i]of j$)if(t.some(o=>ls(o)===ls(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Ff).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function ju(e){return Math.min(M$,Math.max(O$,e))}function Ua(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Uf(e,t=Ua(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Xh(e,t){return e.address===t?43:e.hop>=2?25:30}function Fn(e,t){return e.address===t?Yh.checked:Yh.other}function Fr(e,t,n){const r=e.address===t,i=Fn(e,t),o=ko(e),s=[];return o&&s.push({kind:"role",text:jT(o),y:i+17}),s.push({kind:"address",text:fi(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 tT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},eu=2;function Gf(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=tT[r.kind],o=[...r.text].length*i.size*i.advance/2+eu;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-eu,x2:o,y2:r.y+i.size*.25+eu}})}return n}function lw(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 dw(e){return lw(Gf(e).map(t=>t.box))}const jf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function nT(e,t,n){const r=Lt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Gf(Fr(o,r.checked_address,jf(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 rT(e,t,n){return lw(nT(e,t,n))}function iT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function oT(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function sT(e,t,n){const r=Lt(e),i={x:t/2,y:n/2},o={},s=Ua(r),a=Uf(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=oT(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,aT(l,m,i.y,r.checked_address))}return o}function aT(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=>dw(Fr(u,r)),a=(u,c)=>Math.max(Xh(u,r)+Xh(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 uT(e,t,n){const r=Lt(e),i={x:t/2,y:n/2},o={},s=Ua(r),a=Uf(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 cT(e,t,n,r){const i=Lt(e),o=Ua(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,g=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-g)*.012;f.x-=p/g*w,f.y-=m/g*w,h.x+=p/g*w,h.y+=m/g*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)),g=(m-155)*.003;c!==s&&(d.x+=h/m*g,d.y+=p/m*g),l!==s&&(f.x-=h/m*g,f.y-=p/m*g)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function lT(e,t,n,r=G$){const i=Lt(e),o=uT(i,t,n);for(let s=0;s<r;s++)cT(i,o,t,n);return o}function Do(e,t,n,r){return t==="tree"?sT(e,n,r):lT(e,n,r)}function dT(e,t,n,r,i={}){const o=Lt(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(y=>y.id===n),f=new Map(o.nodes.map(y=>[y.id,y])),h=y=>dw(Fr(y,o.checked_address,jf(i.notes,y.id))),p=o.nodes.flatMap(y=>{const b=t[y.id];if(!b)return[];const v=h(y);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(y=>y.x1)):s.x,g=p.length?Math.max(...p.map(y=>y.x2)):s.x;const w={left:[],right:[]};for(const y of[...r].sort()){const b=f.get(y);if(!b||a[y])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 y of["left","right"]){const b=w[y];for(let v=0;v<b.length;v+=l){const k=b.slice(v,v+l),_=k.map(h),$=Math.max(..._.map(P=>Math.max(-P.x1,P.x2))),O=Math.max(u,Math.max(..._.map(P=>P.y2))-Math.min(..._.map(P=>P.y1))+6),j=y==="left"?m-c-$:g+c+$;k.forEach((P,J)=>{a[P.id]={x:j,y:s.y+(J-(k.length-1)/2)*O}}),y==="left"?m=j-$:g=j+$}}return a}function fT(e,t,n,r=di){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=ju(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 Qh(e,t,n,r=di){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function hT(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 _n(e){return Math.round(e*100)/100}function tu(e,t,n,r,i){const o=s=>`${_n(s.x)},${_n(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function Zu(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 tu("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 tu("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),g=Math.max(m*.45,Math.min(40,m));return tu("vertical",h,{x:h.x,y:h.y+f*g},{x:p.x,y:p.y-f*g},p)}const c=hT(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${_n(l.x)},${_n(l.y)} L${_n(d.x)},${_n(d.y)}`}}const pT=6,nu=pT+3,Kt=14,ep=10,mT=3,tp=6;function gT(e,t,n){const r=Lt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Gf(Fr(o,r.checked_address,jf(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 yT(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 vT(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 bT(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 wT(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 fw(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 _T(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(fw(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(bT(r.points,s))}}return n}function np(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 _T(e,mT))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)&&yT(a,l)<r)return!1}return!0}function kT(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(fw(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(Kt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},g={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},y={x:u.x+g.x*p,y:u.y+g.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:y.x-g.x*p*.55,y:y.y-g.y*p*.55},y]}),o=y}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 ST(e){const t=i=>`${_n(i.x)},${_n(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 rp(e,t,n,r,i){const o=Math.min(e.y,n)-Kt,s=Math.max(e.y,n)+Kt,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 xT(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 ET=120;function $T(e,t,n,r,i,o=4){const s=Zu(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>vT(f,nu));if(np(wT(s),i,a,nu))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<tp?e.y:Math.abs(f-t.y)<tp?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-Kt-1)),u.add(c(Math.round(f.y2)+Kt+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},g=[];for(const w of u){const y=Math.abs(w-p.y)<.01?p.x:rp(p,f,w,Kt,a);if(y===null)continue;const b=Math.abs(w-m.y)<.01?m.x:rp(m,-h,w,Kt+ep,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-y)*h<Kt+ep||Math.abs(w-p.y)<.01&&(b-p.x)*f<Kt)continue;const v=xT([p,{x:y,y:p.y},{x:y,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!TT(v,a))continue;let k=(v.length-2)*Kt,_;for(const $ of v)_&&(k+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;g.push({points:v,length:k})}g.sort((w,y)=>{const b=w.points[2]?.y,v=y.points[2]?.y;return w.length-y.length||(b===void 0||v===void 0?0:b-v)});for(const w of g){const y=kT(w.points);if(!np(y,i,a,nu))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:ST(y),bounds:_}}}return s}function TT(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(iT(i,o))return!1}n=r}return!0}function hw(e,t){if(!t)return Jt.rest;const n=Ke(t);return Ke(e.from)===n||Ke(e.to)===n?Jt.related:Jt.faded}function CT(){return{hit:{stroke:"transparent",width:16},line:{stroke:We("edge"),width:1.6},arrow:{fill:We("edge")}}}function AT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function IT(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 NT(e,t,n,r=F$){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 RT(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 ip(e){return e==="Enter"||e===" "}function zT(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function LT(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=zT(r,i),!0)}function PT(e,t){return e?.pointerId===t?null:e}function DT(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 OT(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 g=p?.closest?.("[data-edge-id]");return g?{kind:"edge",id:g.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=IT(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[g,w]=[...r.values()];g&&w&&(s={distance:Math.hypot(w.x-g.x,w.y-g.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,g]=[...r.values()];m&&g&&t.pinch(s,[m,g],h);return}if(i?.pointerId===h.pointerId){if(i=NT(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=RT(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 MT(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 pw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Bu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Hu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function kn(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 mw(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 Vu(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Bu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function FT(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Bu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Bu(e.total_out_usd)]];return e.role&&_o.includes(e.role)?[["Role",cw[e.role]||"Other"],...t,["Senders",Hu(e.degree_in)],["Receivers",Hu(e.degree_out)],["Labels",xn(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${pw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",kn(e.first_activity_timestamp)],["Last activity (UTC)",kn(e.last_activity_timestamp)],["Labels",xn(e).join(", ")||"No labels"]]}function UT(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Vu(e)],["Transfers",Hu(e.tx_count)],["First seen (UTC)",kn(e.first_seen_timestamp)],["Last seen (UTC)",kn(e.last_seen_timestamp)],["Since last seen",mw(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)",Vu(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)",kn(e.first_seen_timestamp)],["Last seen (UTC)",kn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function gw(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function qu(e){const t=ko(e);if(e.role)return`${e.address}. ${t||"Other"}.${xn(e).length?` Labels: ${xn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${pw(e.risk_level)} risk`,r=xn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Wu(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Vu(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${mw(e.last_seen_timestamp,t)}.`:n}function GT(e,t){return Lt(e).nodes.map(n=>{const r={id:n.address,label:xn(n).join(", ")||ko(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function jT(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function ZT(e,t,n={}){const r=e.ownerDocument;let i=Lt(t),o=n.layout??(Mf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Do(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??eT(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const g={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,D)=>Z(C,D),selectEdge:(C,D)=>W(C,D),showTooltip:(C,D)=>U(C,D),hideTooltip:()=>ie(),lost:()=>le()};function y(C){const D=C==="webgl"?Kh("webgl"):null;if(D)try{return D(e,g,w,{label:n.label})}catch{}return Jh(e,g,w,{label:n.label})}const b=n.renderer??(Kh("webgl")&&z$(r)?"webgl":"svg");let v=y(b);e.dataset.renderer=v.kind;const k=()=>{const C=rT(i,a,u);if(!C)return null;const D=v.linkBounds();return D&&(C.x1=Math.min(C.x1,D.x1),C.y1=Math.min(C.y1,D.y1),C.x2=Math.max(C.x2,D.x2),C.y2=Math.max(C.y2,D.y2)),C},_=()=>{const C=k();return C?fT(C,s.width,s.height,di):{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,j=!1,P=!1;function J(){if(O){j=!0;return}v.build()}function se(){if(O){P=!0;return}l=_(),be()}function be(){v.camera()}function ke(C="program"){const D=GT(i,n.href),ne=d?.kind==="node"?i.nodes.find(pe=>pe.id===d.id)??null:null,Se=d?.kind==="edge"?i.edges.find(pe=>pe.id===d.id)??null:null;if(ne){const pe=i.edges.filter(ct=>ct.from===ne.address||ct.to===ne.address);return{kind:"node",id:ne.id,selectedId:ne.address,nodes:D,title:"Selected address",identity:ne.address,values:FT(ne),related:pe,node:ne,edge:null,source:C}}return Se?{kind:"edge",id:Se.id,selectedId:null,nodes:D,title:"Selected aggregate flow",identity:`${Se.from} → ${Se.to}`,values:UT(Se,p()),related:[Se],node:null,edge:Se,source:C}:{kind:null,id:null,selectedId:null,nodes:D,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Ue(C){const D=ke(C);F(D),n.onSelect?.(D)}function F(C){const D=n.selectionRoot,ne=D?.querySelector("[data-selection-title]"),Se=D?.querySelector("[data-selection-identity]"),pe=D?.querySelector("[data-selection-meta]");!ne||!Se||!pe||(ne.textContent=C.title,Se.textContent=C.identity,pe.replaceChildren(...C.values.map(([ct,At])=>{const Gt=r.createElement("div");Gt.className="meta-item",At!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(ct)&&Gt.classList.add("meta-item--identity"),ct==="Incoming amount (USD)"&&Gt.classList.add("meta-item--incoming"),ct==="Outgoing amount (USD)"&&Gt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(ct)&&Gt.classList.add("meta-item--wide");const Zr=r.createElement("span");Zr.textContent=ct;const In=r.createElement("strong"),mn=["First transaction","Last transaction"].includes(ct)?gw(At):null;if(mn&&n.openLink){const G=n.openLink,ae=r.createElement("button");ae.type="button",ae.className="cia-graph-explorer-link",ae.dataset.explorer=mn,ae.textContent=At,ae.setAttribute("aria-label",`${ct}: ${At} (opens the explorer)`),ae.addEventListener("click",()=>G(mn)),In.append(ae)}else if(mn){const G=r.createElement("a");G.href=mn,G.target="_blank",G.rel="noopener noreferrer",G.textContent=At,G.setAttribute("aria-label",`${ct}: ${At} (opens in new tab)`),In.append(G)}else In.textContent=At;return Gt.append(Zr,In),Gt})))}function Z(C,D="program"){d=C?{kind:"node",id:C}:null,v.selection(),Ue(D)}function W(C,D="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Ue(D)}function Q(C){if(C==null)return Z(null);const D=Mn(i,C);if(D)return Z(D);if(i.edges.some(ne=>ne.id===C))return W(C)}function Y(){l=_(),be()}function I(C,D={x:s.width/2,y:s.height/2}){const ne=ju(l.scale*(1+C)),Se=ne/l.scale;l={x:D.x-(D.x-l.x)*Se,y:D.y-(D.y-l.y)*Se,scale:ne},be()}function R(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(D=>{D.classList.toggle("active",D.dataset.layout===C),D.setAttribute("aria-pressed",String(D.dataset.layout===C))}),n.onLayoutChange?.(C),a=Do(i,o,s.width,s.height),v.geometry(),Y()}function U(C,D){$.textContent=D,$.hidden=!1;const ne=e.getBoundingClientRect();$.style.left=`${Math.min(ne.width-330,Math.max(8,C.clientX-ne.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-ne.top+12)}px`}function ie(){$.hidden=!0}function ce(C){return DT({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const te={point:ce,transform:()=>l,select(C){C.type==="select-node"?Z(C.id,"pointer"):C.type==="select-edge"?W(C.id,"pointer"):Z(Uf(i)?.id??null,"canvas")},drag(C,D,ne){!h&&(h=AT(o,C,D),!h)||LT(a,h,D,ne,l)&&(Ce=!0,v.moveNode(h.id))},endDrag(C){const D=h?.pointerId===C&&Ce;h=PT(h,C),D&&(Ce=!1,v.endMove())},pan(C,D){l={x:C.transform.x+D.x-C.point.x,y:C.transform.y+D.y-C.point.y,scale:l.scale},be()},startPinch(){h=null},pinch(C,[D,ne]){const Se=Math.hypot(ne.x-D.x,ne.y-D.y),pe=ju(C.scale*Se/Math.max(1,C.distance));I(pe/l.scale-1,{x:(D.x+ne.x)/2,y:(D.y+ne.y)/2})}};let Ce=!1;const Ae=C=>{C.preventDefault(),I(C.deltaY>0?-.12:.12,ce(C))},L={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},M=C=>{if(C.target!==v.surface)return;const D=L[C.key];D?(C.preventDefault(),l={...l,x:l.x+D[0],y:l.y+D[1]},be()):C.key==="+"||C.key==="="?I(.18):C.key==="-"?I(-.18):C.key==="0"&&Y()};let q=()=>{};function K(){const C=v.surface,D=ne=>v.pick(ce(ne));q=OT(C,te,v.kind==="svg"?void 0:D),C.addEventListener("wheel",Ae,{passive:!1}),C.addEventListener("keydown",M)}function he(){q(),v.surface.removeEventListener("wheel",Ae),v.surface.removeEventListener("keydown",M)}K();function le(){v.kind!=="svg"&&(he(),v.destroy(),v=Jh(e,g,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),K(),J())}const Ee=n.controls?.querySelector("[data-expand]")??null,Ie=n.panel&&Ee?MT(n.panel,Ee,r.body):null,fe=()=>{Ie?.toggle(),n.onExpansionChange?.(Ie?.isOpen()??!1),requestAnimationFrame(Y)},ee=n.panel??e,Be=C=>{if(C.key==="Tab"&&Ie?.isOpen()&&n.panel){const D=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(pe=>pe.checkVisibility()),ne=D[0],Se=D.at(-1);C.shiftKey&&r.activeElement===ne?(C.preventDefault(),Se?.focus()):!C.shiftKey&&r.activeElement===Se&&(C.preventDefault(),ne?.focus())}if(C.key==="Escape"){if(Ie?.isOpen()){Ie.close(),n.onExpansionChange?.(!1),requestAnimationFrame(Y);return}Z(null,"keyboard")}};ee.addEventListener("keydown",Be);const ut=[],He=(C,D)=>{C&&(C.addEventListener("click",D),ut.push([C,D]))};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']"),Y),Ie&&He(Ee,fe);const Ve=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,D=e.clientHeight;!C||!D||C===s.width&&D===s.height||(s.width=C,s.height=D,v.resize(C,D),Y())});Ve?.observe(e),J(),n.selected&&Q(n.selected);const pt={update(C){const D=a;i=Lt(C);const ne=i.nodes.every(pe=>D[pe.id])?{}:Do(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(pe=>[pe.id,D[pe.id]??ne[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 Se=new Set(i.nodes.map(pe=>pe.id));for(const pe of[...c.keys()])Se.has(pe)||c.delete(pe);J(),se()},merge(C,D){const ne=J$(i,C,D);i=ne.model;const Se=Mn(i,D??Lt(C).checked_address);return a=Se?dT(i,a,Se,ne.added,{notes:u}):{...a,...Do(i,o,s.width,s.height),...a},J(),ne.added.length&&se(),ne.added},batch(C){O++;try{C()}finally{O--,!O&&j&&(j=!1,v.build()),!O&&P&&(P=!1,l=_(),be())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:Q,destroy(){Ve?.disconnect(),he(),ee.removeEventListener("keydown",Be);for(const[C,D]of ut)C.removeEventListener("click",D);Ie?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:Y,zoom:C=>I(C),setLayout:R,markNode(C,D){const ne=Mn(i,C);ne&&(D?u.set(ne,D):u.delete(ne),J())},flagNode(C,D,ne){const Se=Mn(i,C);if(!Se)return;const pe=c.get(Se)??new Set;ne?pe.add(D):pe.delete(D),pe.size?c.set(Se,pe):c.delete(Se),O?j=!0:v.flag(Se,D,ne)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>k(),transform:()=>({...l}),highlight(C){f=C==null?null:Mn(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const D=Mn(i,C),ne=D?a[D]:null;if(!ne)return null;const Se=v.surface.getBoundingClientRect(),pe=Math.min(Se.width/s.width,Se.height/s.height)||1,ct=Se.left+(Se.width-s.width*pe)/2,At=Se.top+(Se.height-s.height*pe)/2;return{x:ct+(ne.x*l.scale+l.x)*pe,y:At+(ne.y*l.scale+l.y)*pe}}};return Object.defineProperty(e,"ciaGraph",{value:pt,configurable:!0}),pt}const yw="chain-insights.flows.v1",Zf="chain-insights.result.v1",vw=5e3,op=6,BT=3,bw=/^0x[0-9a-fA-F]{40}$/,HT=/^0x[0-9a-fA-F]{64}$/;function VT(e){return typeof e=="string"&&(bw.test(e)||HT.test(e))}function ds(e){return typeof e=="string"&&bw.test(e)}function Ku(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Bf(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(Ku):[]}function qT(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Yt(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 Hf(e){return e<1e11?e*1e3:e}const ww=/^\d{4}-\d{2}-\d{2}$/,WT=Date.UTC(2009,0,1),KT=Date.UTC(2100,0,1);function ru(e){return new Date(Hf(e)).toISOString().slice(0,10)}function sp(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function Vf(e){if(typeof e!="string"||!ww.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 JT=new Set(["day","date","hour","week","month"]),YT=["_timestamp","_time","_at"];function ap(e){return JT.has(e)||YT.some(t=>e.endsWith(t))}function XT(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function QT(e){return Array.isArray(e)?e.some(ds):ds(e)}function eC(e){return e.some(t=>Object.values(t).some(QT))}function tC(e){return e.length>0&&e.every(t=>ds(t.from_address)&&ds(t.to_address))}const nC=/^(\d{4})-(\d{2})$/,rC=/^(\d{4})-W(\d{2})$/,iC=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,oC=/(?:Z|[+-]\d{2}:?\d{2})$/i;function sC(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function up(e){if(typeof e=="string"){const r=e.trim();if(ww.test(r))return Vf(r)?Date.parse(`${r}T00:00:00Z`):null;const i=nC.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=rC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?sC(Number(o[1]),s):null}if(iC.test(r)){const s=r.replace(" ","T"),a=Date.parse(oC.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Yt(e);if(t==null)return null;const n=Hf(t);return n>=WT&&n<KT?n:null}function qf(e,t={}){if(e.length===0||eC(e))return null;const n=XT(e),i=n.filter(ap).find(d=>e.some(f=>up(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(ap(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Yt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,op),a=new Map;let u=0;for(const d of e){const f=up(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 g=Yt(d[p]);g!=null&&(h.sums[m]=(h.sums[m]??0)+g)}),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??BT)?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(op),skippedRows:e.length-u,failures:[]}}function aC(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 uC=e=>e==null||Yt(e)!=null;function _w(e){const t=kw(e);if(t.length<3||!t.every(c=>Vf(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(uC))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:aC(c.error)})),u=qf(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}function cC(e){return tC(e)?"graph":qf(e)?"chart":"table"}const lC=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function cp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function dC(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 lp=(e,t)=>e==null?t:t==null?e:e+t;function fC(e,t="robinhood"){const n=new Map;for(const d of e)for(const f of new Set([String(d.from_address).toLowerCase(),String(d.to_address).toLowerCase()]))n.set(f,(n.get(f)??0)+1);let r="",i=0;for(const[d,f]of n)f>i&&(r=d,i=f);const o=new Map,s=new Map,a=(d,f,h)=>{const p=o.get(d)??{address:d,labels:[],exchange:!1};for(const m of f)p.labels.some(g=>g.toLowerCase()===m.toLowerCase())||p.labels.push(m);p.exchange=p.exchange||h,o.set(d,p)};r&&o.set(r,{address:r,labels:[],exchange:!1});let u=0;for(const d of e){const f=String(d.from_address).toLowerCase(),h=String(d.to_address).toLowerCase(),p=[f,h].filter((b,v,k)=>!o.has(b)&&k.indexOf(b)===v).length;if(o.size+p>vw||(u++,a(f,cp(d.from_labels),d.from_is_exchange===!0),a(h,cp(d.to_labels),d.to_is_exchange===!0),f===h))continue;const m=`${f}->${h}`,g=s.get(m)??{from:f,to:h,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=lp(g.usd,Yt(d.amount_usd_sum)),g.tx=lp(g.tx,Yt(d.tx_count));const w=Yt(d.first_seen_timestamp),y=Yt(d.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),y!=null&&(g.last=g.last==null?y:Math.max(g.last,y)),typeof d.link_kind=="string"&&d.link_kind&&!g.kinds.includes(d.link_kind)&&g.kinds.push(d.link_kind),s.set(m,g)}const c=[...o.values()].map(d=>({address:d.address,role:dC(d.labels,d.exchange),labels:d.labels})),l=[...s.values()].map(d=>({from:d.from,to:d.to,usd:d.usd,tx_count:d.tx,first_seen_ms:d.first,last_seen_ms:d.last,...d.kinds.length?{link_kind:d.kinds.join(", ")}:{}}));return{view:{schema:yw,network:t,center:r,nodes:c,edges:l,truncated:!1},rowsTotal:e.length,rowsDrawn:u,rowsLeftOut:e.length-u,addresses:o.size}}function kw(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(Ku).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(Ku):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null})):[]}const dp=200;function So(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
109
|
+
`).trim()}function Br(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 Sw(e){if(!e)return null;const t=e.structuredContent,n=Br(t?.error)??Br(t?.facts?.error)??Br(t?.facts?.query?.error);if(!e.isError||n)return n;const r=So(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=Br(i?.error)??Br(i);if(o)return o}catch{}return r||"The tool answered with an error."}const hC=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function xw(e){if(!e||Sw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===yw)return"flows";if(t?.schema===Zf){if(t.tool==="graph_query")return cC(Bf(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":_w(t)?"chart":"batch";if(typeof t.tool=="string"&&hC.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 pC(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:fi(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 gC(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?kn(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 yC=160,fp=2e3;function vC(e,t=yC){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 Ew(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>fp?`${n.full.slice(0,fp-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 bC(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,dp),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>dp||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function wC(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):VT(t)?pC(e,t):typeof t=="number"?e.createTextNode(gC(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 hp(e,t,n={}){const r=e.ownerDocument,i=bC(t.structuredContent),o=i.rows.length;if(i.total===0)return Ew(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",{},wC(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 Hr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Oo=e=>typeof e=="string"&&e?e:null;function _C(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Hr(t.allowance_usd),consumedUsd:Hr(t.consumed_usd),windowEnd:Oo(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=Oo(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Hr(r?n.daily_units_used:n.daily_seconds_used),limit:Hr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Hr(r?n.remaining_units:n.remaining_seconds),resetAt:Oo(n.reset_at),identifierKind:Oo(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const pp=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),Mo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function iu(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${kn(t)} UTC`:e}function mp(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 ou(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function kC(e,t){const n=e.ownerDocument,r=_C(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${fi(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[mp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),ou(n,[["Daily allowance",pp(r.allowanceUsd)],["Used today",pp(r.consumedUsd)],["Window ends",iu(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"}),ou(n,[["Daily allowance","No daily limit"],["Used today",Mo(r.used,r.unit)],["Window ends",iu(r.resetAt)]])]:[mp(n,r.used,r.limit,"Share of today's free allowance used"),ou(n,[["Daily allowance",Mo(r.limit,r.unit)],["Used today",Mo(r.used,r.unit)],["Left today",Mo(r.remaining,r.unit)],["Window ends",iu(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:So(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 Ga(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=Sw(t);if(i!=null){Ew(e,vC(i),{kind:"refused",view:"text",full:i});return}const o=So(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 $w(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 SC="http://www.w3.org/2000/svg",Ju=720,xC=320,EC=6,$C=420,gp=4,TC=120,Xr={left:70,right:18,top:6},Yu=18,Tw=16,Cw=6,Aw=26,CC=170,AC=82,IC=28,NC=80,Un=1e3,wn=60*Un,Qn=60*wn,Xt=24*Qn,RC=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Iw(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 zC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),LC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),PC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),hi=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),DC=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),Nw=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),Rw=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),OC=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function fs(e,t){if(e==null)return"—";const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?LC.format(e):zC.format(e):t==="count"?hi.format(e):n?Nw.format(e):DC.format(e)}function MC(e){return e!==0&&Math.abs(e)<.01?Nw.format(e):Math.abs(e)<1e3?OC.format(Math.round(e*100)/100):Rw.format(e)}function yp(e,t){return t==="usd"?Math.abs(e)<1e3?fs(e,"usd"):PC.format(e):t==="count"?Math.abs(e)<1e3?hi.format(e):Rw.format(e):MC(e)}function FC(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 zw(e){return e<=Xt?"time":e<=TC*Xt?"day":"month"}const UC=[Un,2*Un,5*Un,10*Un,15*Un,30*Un,wn,2*wn,5*wn,10*wn,15*wn,30*wn,Qn,2*Qn,3*Qn,6*Qn,12*Qn,Xt],GC=[1,2,3,7,14,30,60].map(e=>e*Xt),jC=[1,2,3,6,12,24,60,120],vp=4*Xt,ZC={time:76,day:84,month:72},BC=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),su=e=>Date.UTC(Math.floor(e/12),e%12,1);function HC(e,t,n){const r=t-e,i=zw(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 jC){const a=[];let u=BC(e);for(su(u)<e&&u++;su(u)<=t;u++)u%s===0&&a.push(su(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"?UC:GC){const a=s===7*Xt||s===14*Xt?Math.ceil((e-vp)/s)*s+vp:i==="day"?Math.ceil(e/Xt)*Xt: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 VC(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${RC[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%Xt===0?i.slice(0,10):n>0&&n<wn?i.slice(11,19):i.slice(11,16)}function qC(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:Iw(t.column,t.values),total:n,peak:r,peakTime:i}})}const Rt=e=>new Date(e).toISOString(),Lw=(e,t)=>Rt(e).slice(0,10)===Rt(t).slice(0,10);function WC(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?`${Rt(t).slice(0,10)} UTC`:`${Rt(t).slice(0,10)} to ${Rt(n).slice(0,10)} UTC`;const r=i=>`${Rt(i).slice(0,10)} ${Rt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:Lw(t,n)?`${r(t)} to ${Rt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function KC(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=[WC(e),`${hi.format(r)} ${r===1?"point":"points"}${i>r?` from ${hi.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of qC(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 ${Rt(u.peakTime).slice(0,10)}`:Lw(s,a)?`at ${Rt(u.peakTime).slice(11,19)}`:`at ${Rt(u.peakTime).slice(0,10)} ${Rt(u.peakTime).slice(11,16)}`;o.push(`${u.column}: total ${fs(u.total,u.kind)}, peak ${fs(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 JC(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 YC(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 XC(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 QC(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 Pw=e=>`var(--cia-graph-series-${e%EC+1})`;function hs(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 au(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 Dw(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function eA(e){if(e<=1)return CC;const t=Math.floor(($C-Xr.top-Cw-Aw-(e-1)*Tw)/e)-Yu;return Math.max(IC,Math.min(AC,t))}function bp(e,t=Ju,n=new Set){const r=Xr.left,i=t-Xr.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=eA(u.length),l=u.map(({series:p,index:m},g)=>{const w=Xr.top+g*(Yu+c+Tw),y=w+Yu,b=y+c,v=p.values.filter(J=>J!=null),k=Math.min(0,...v),_=Math.max(...v,k+1e-9),$={plotTop:y,plotBottom:b,min:k,max:_},O=[],j=[];let P=[];return p.values.forEach((J,se)=>{if(J==null){P.length&&j.push(P),P=[];return}const be=e.times[se]??o,ke={x:hs(a,be),y:Dw($,J),time:be,value:J,index:se};O.push(ke),P.push(ke)}),P.length&&j.push(P),{column:p.column,index:m,kind:Iw(p.column,p.values),color:Pw(m),top:w,plotTop:y,plotBottom:b,min:k,max:_,runs:j,points:O}}),d=(l[l.length-1]?.plotBottom??Xr.top)+Cw,f=zw(s-o),h=[];if(e.times.length){const p=HC(o,s,(i-r)/ZC[f]);for(const m of p.times){const g=hs(a,m),w=g-r<34?"start":i-g<34?"end":"middle";h.push({x:g,label:VC(m,p.unit,p.step),anchor:w})}}return{width:t,height:d+Aw,plotLeft:r,plotRight:i,first:o,last:s,unit:f,lanes:l,ticks:h,axisY:d}}function nt(e,t,n={}){const r=e.createElementNS(SC,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const jt=e=>Math.round(e*10)/10;let tA=0;const nA="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 rA(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=Ju,d=t,f=bp(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",Pw(R));const ie=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},U,A(r,"span",{text:I.column}));return ie.addEventListener("click",()=>{const ce=QC(s,I.column,i);ce!==s&&(s=ce,P())}),ie}),m=A(r,"div",{class:"cv-chart-legend",role:"group","aria-label":"Show or hide a series"},...p),g=A(r,"button",{type:"button",class:"cv-chart-reset","data-reset-zoom":"",hidden:!0,text:"Reset zoom"}),w=nt(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),y=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++tA}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),b=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":nA,"aria-describedby":y.id},w),v=A(r,"div",{class:"cv-chart-body"},b,y),k=nt(r,"rect",{class:"cv-chart-brush"}),_=nt(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,g,n.toggle??null),v);e.replaceChildren(O);function j(){const I=[],R=f.lanes[0]?.plotTop??0,U=d.times.length>1?(f.plotRight-f.plotLeft)/(d.times.length-1):24,ie=Math.max(6,Math.min(24,U*.6));for(const te of d.failures){const Ce=hs(f,te.time),Ae=nt(r,"rect",{class:"cv-chart-failure","data-failure":te.day,x:jt(Ce-ie/2),y:R,width:jt(ie),height:Math.max(0,f.axisY-R)});I.push(Ae)}for(const te of f.lanes){const Ce=nt(r,"g",{class:"cv-chart-lane","data-series":te.column}),Ae=nt(r,"rect",{class:"cv-chart-swatch",x:f.plotLeft,y:te.top+4,width:14,height:4,rx:2});Ae.style.fill=te.color;const L=nt(r,"text",{class:"cv-chart-name",x:f.plotLeft+20,y:te.top+11});L.textContent=te.column,Ce.append(Ae,L,nt(r,"line",{class:"cv-chart-grid",x1:f.plotLeft,x2:f.plotRight,y1:te.plotTop,y2:te.plotTop}),nt(r,"line",{class:"cv-chart-base",x1:f.plotLeft,x2:f.plotRight,y1:te.plotBottom,y2:te.plotBottom}));const M=nt(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:te.plotTop+4,"text-anchor":"end"});M.textContent=yp(te.max,te.kind);const q=nt(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:te.plotBottom+4,"text-anchor":"end"});q.textContent=yp(te.min,te.kind),Ce.append(M,q);for(const K of te.runs){if(K.length<2)continue;const he=nt(r,"polyline",{class:"cv-chart-line",points:K.map(le=>`${jt(le.x)},${jt(le.y)}`).join(" "),fill:"none"});he.style.stroke=te.color,Ce.append(he)}if(te.points.length<=NC)for(const K of te.points){const he=nt(r,"circle",{class:"cv-chart-dot",cx:jt(K.x),cy:jt(K.y),r:3,"data-index":a.start+K.index,"data-time":K.time});he.style.fill=te.color,Ce.append(he)}I.push(Ce)}const ce=nt(r,"g",{class:"cv-chart-axis"});for(const te of f.ticks){const Ce=nt(r,"text",{class:"cv-chart-tick",x:jt(te.x),y:f.axisY+14,"text-anchor":te.anchor});Ce.textContent=te.label,ce.append(Ce)}return I.push(ce),I}function P(){d=XC(t,a.start,a.end),f=bp(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,...j(),_),h.textContent=KC(d,s);for(const U of p){const ie=!s.has(U.dataset.series??"");U.setAttribute("aria-pressed",String(ie)),ie&&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;g.hidden=!R,O.dataset.zoomed=String(R),J(),se()}function J(){if(!c||Math.abs(c.to-c.from)<gp){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(jt(R))),k.setAttribute("width",String(jt(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",y.hidden=!0,y.replaceChildren(),delete b.dataset.focus;return}const I=u-a.start,R=d.times[I]??f.first,U=jt(hs(f,R)),ie=f.lanes[0]?.plotTop??0;_.append(nt(r,"line",{class:"cv-chart-crossline",x1:U,x2:U,y1:ie,y2:f.axisY}));const ce=[];for(const Ae of f.lanes){const L=d.series[Ae.index]?.values[I]??null;if(L!=null){const q=nt(r,"circle",{class:"cv-chart-focus",cx:U,cy:jt(Dw(Ae,L)),r:4.5});q.style.fill=Ae.color,_.append(q)}const M=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});M.style.setProperty("--cv-key",Ae.color),ce.push(A(r,"dt",{},M,Ae.column),A(r,"dd",{"data-value":Ae.column,text:fs(L,Ae.kind)}))}_.style.display="",_.dataset.index=String(u),_.dataset.time=String(R),b.dataset.focus=String(u);const te=d.failures.find(Ae=>Ae.time===R),Ce=d.rowCounts[I]??1;y.replaceChildren(...[A(r,"time",{datetime:new Date(R).toISOString(),text:FC(R,d.daily)}),te?A(r,"p",{class:"cv-chart-readout-note","data-failure":te.code,text:`No answer: ${te.code}`}):null,Ce>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":Ce,text:`${hi.format(Ce)} transfers`}):null,A(r,"dl",{},...ce)].filter(Ae=>Ae!=null)),y.hidden=!1,be(U,ie)}function be(I,R){const U=w.getBoundingClientRect(),ie=v.getBoundingClientRect(),ce=U.width>0?U.width/f.width:1,te=U.left-ie.left+I*ce,Ce=I>(f.plotLeft+f.plotRight)/2;y.style.left=`${Math.round(Ce?te-12:te+12)}px`,y.style.top=`${Math.round(U.top-ie.top+R*ce)}px`,y.dataset.side=Ce?"left":"right"}const ke=I=>{const R=w.getBoundingClientRect();return R.width>0?(I-R.left)*f.width/R.width:Number.NaN},Ue=I=>a.start+JC(d.times,au(f,I));b.addEventListener("pointermove",I=>{const R=ke(I.clientX);Number.isFinite(R)&&(c&&(c.to=R,J()),u=Ue(R),se())}),b.addEventListener("pointerdown",I=>{if(I.button!==0)return;const R=ke(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:ie}=c;c=null;try{b.releasePointerCapture(ie)}catch{}if(J(),!I||Math.abs(U-R)<gp)return;const ce=YC(t.times,au(f,R),au(f,U));!ce||ce.start===a.start&&ce.end===a.end||(a=ce,u=Ue(U),P())};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()}),g.addEventListener("click",()=>{a=o,u=null,P(),b.focus({preventScroll:!0})});const Z=()=>{const I=Math.round(b.clientWidth);return I>0?Math.max(xC,I):null},W=()=>{const I=Z();I==null||I===l||(l=I,P())};l=Z()??Ju,P();const Q=r.defaultView?.ResizeObserver,Y=Q?new Q(()=>W()):null;return Y?.observe(b),{root:O,get layout(){return f},refit:W,destroy(){Y?.disconnect()}}}const iA="chain-insights.transfers.v1",oA="graph_expand",sA="2015-01-01";function aA(e,t,n,r){return{network:e,from:t,to:n,day:r}}function uA(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?ru(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?ru(e.last_seen_timestamp):ru(t);return{first:n,last:n&&r<n?n:r}}function Fo(e,t){return e<=(t??sA)}function cA(e){if(!e)return"no answer";const t=So(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:Ow(e.structuredContent)?null:t||"the answer held no transfers"}function Ow(e){const t=e;if(!t||t.schema!==iA||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!Vf(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=Yt(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:Yt(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 dA(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 fA(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 hA(e){return e==null?"—":`${new Date(Hf(e)).toISOString().slice(11,19)} UTC`}function uu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function pA(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=`${uu(l.day)} (UTC)`,u.disabled=l.status==="loading"||Fo(l.day,l.firstDay);const w=Fo(l.day,l.firstDay)?null:sp(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${uu(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 ${uu(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(y=>mA(e,y,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"&&Fo(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 y=++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:oA,arguments:aA(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(y!==d||l!==b)return b;const k=cA(v);if(k)b.status="error",b.transfers=[],b.error=k.length>300?`${k.slice(0,299)}…`:k;else{const _=Ow(v.structuredContent);b.status="ready",b.transfers=lA(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>g.close(),m=()=>{g.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const g={element:c,open(w){const y=uA(w,n());return l={from:w.from,to:w.to,day:y.last,firstDay:y.first,status:"loading",transfers:[],truncated:!1,error:null},h(y.last)},async earlier(){return!l||l.status==="loading"||Fo(l.day,l.firstDay)?null:h(sp(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 g}function mA(e,t,n){const r=gw(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:fi(t.tx_id)}):A(e,"code",{title:t.tx_id,text:fi(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:hA(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${dA(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":fA(t.amount_usd)}),o)}const gA="graph_expand",Uo="too busy to expand",Mw=640,yA=300,cu=.45,vA="Full screen shows the whole graph",wp=400,lu="expanded",Fw=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.",Xu=new Intl.NumberFormat("en-US");function _p(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 wA(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${Xu.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function _A(e,t){return`Not loaded: ${Xu.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${Xu.format(Fw)} addresses. Fold another address to make room.`}const kp=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let kA=0;const SA=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function xA(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function EA(e){const t=So(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Mf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function $A(e,t,n,r=Mw,i=yA){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(cu,Math.min(1,(t-di*2)/o)),u=Math.ceil(n+s*a+di*2),c=Math.min(r,Math.max(i,u));return Qh(e,t,c-n)>=cu?{height:c,fits:!0}:{height:r,fits:Qh(e,t,r-n)>=cu}}function TA(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function CA(e){const t=e.split(`
|
|
110
|
+
`)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function AA(e,t){return`investigator expanded ${e}: ${t} new addresses`}function IA(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&ko({role:n.role??null,labels:n.labels??[]})||"Other"}function Uw(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:_p(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",g=A(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:bA}),w=A(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),y=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}),j=pA(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Ve()}),P=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"},_,$),j.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"}),be=A(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:vA}),ke=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,be,J),Ue=A(r,"span",{class:"cv-muted","data-subtitle":""}),F=`cv-addresses-${++kA}`,Z=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:F,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let W=[],Q=-1;const Y=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}),Ue),n.toggle??null,ke),w,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},Z,y,P),g);e.replaceChildren(Y);function I(){const G=ee.model(),ae=G.truncated?" · more flows than shown":"";Ue.textContent=`${o} · ${IA(t,o)} · ${i} · ${G.nodes.length} addresses${ae}`;const ve=new Set(G.nodes.map(Ne=>Ne.role??"other"));w.replaceChildren(...SA.filter(([Ne])=>ve.has(Ne)).map(([Ne,Je])=>{const It=A(r,"i",{"aria-hidden":"true"});return It.style.background=`var(--cia-graph-role-${Ne})`,A(r,"li",{"data-role":Ne},It,Je)})),R()}function R(){const G=ee.model().nodes,ae=W[Q]??null;W=G.map(Ne=>Ne.address.toLowerCase()),Z.replaceChildren(...G.map((Ne,Je)=>A(r,"div",{role:"option",id:`${F}-${Je}`,"data-list-address":W[Je],"aria-selected":"false",text:`${Ne.address} ${ko({role:Ne.role??null,labels:Ne.labels??[]})||"Other"}`})));const ve=ae?W.indexOf(ae):-1;Q=ve>=0?ve:W.length?Math.min(Math.max(Q,-1),W.length-1):-1,U()}function U(){for(const ae of Z.children)ae.setAttribute("aria-selected",String(ae.id===`${F}-${Q}`));Q>=0?Z.setAttribute("aria-activedescendant",`${F}-${Q}`):Z.removeAttribute("aria-activedescendant");const G=r.activeElement===Z;ee.highlight(G?W[Q]??null:null)}function ie(G){return G?ee.model().nodes.find(ae=>ae.id===G)?.address.toLowerCase()??null:null}const ce=G=>{const ae=G.target,ve=G.key==="Enter"||G.key===" ",Ne=ae?.closest?.("[data-node-id]");if(ve&&G.shiftKey&&Ne){G.preventDefault();const Je=ie(Ne.dataset.nodeId);Je&&ne(Je)}};y.addEventListener("keydown",ce,!0);function te(G){W.length&&(Q=Math.max(0,Math.min(W.length-1,G)),U())}const Ce=()=>{Q<0&&W.length&&(Q=0),U()},Ae=()=>ee.highlight(null),L=G=>{const ae=W[Q];switch(G.key){case"ArrowDown":G.preventDefault(),te(Q+1);return;case"ArrowUp":G.preventDefault(),te(Q-1);return;case"Home":G.preventDefault(),te(0);return;case"End":G.preventDefault(),te(W.length-1);return;case"Escape":Gt();return;case"Enter":case" ":if(G.preventDefault(),!ae)return;G.shiftKey?ne(ae):ee.select(ae);return}};Z.addEventListener("focus",Ce),Z.addEventListener("blur",Ae),Z.addEventListener("keydown",L);function M(){const G=h;if(!G){_.hidden=!0,$.hidden=!0,O.hidden=!0;return}const ae=d.has(G),ve=ae?wA(a.get(G)?.remaining??null):null;O.hidden=!ve,O.textContent=ve??"",_.hidden=!1,_.disabled=u.has(G)||c.has(G),_.textContent=u.has(G)?"Too busy to expand":ae?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${G}`),$.hidden=!(ae&&kp(a.get(G)))}function q(G){const ae=P.hidden;P.hidden=G.kind==null,G.kind==="node"&&G.node?(h=G.node.address.toLowerCase(),v.textContent="Address details",j.close()):(h=null,G.kind==="edge"?v.textContent="Link details":j.close()),M(),ae!==P.hidden&&Ve()}let K=null;function he(){K&&clearTimeout(K),K=null}function le(G){const ae=G.source==="pointer"&&G.kind==="node"&&G.node,ve=G.source!=="program"&&G.kind==="edge"&&G.edge;if(he(),ae){const Ne=G.node.address.toLowerCase(),Je=p();f&&f.address===Ne&&Je-f.at<=wp?(f=null,Gt(),ne(Ne)):(f={address:Ne,at:Je},K=setTimeout(()=>{K=null,q(G)},wp));return}G.kind!=="node"&&(f=null),q(G),ve&&j.open(G.edge)}const Ee=n.height??Mw,Ie=`${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 fe(){return ZT(y,t,{layout:"tree",width:n.width??720,height:Ee,now:n.now,controls:ke,selectionRoot:b,onSelect:le,openLink:G=>{n.host.openLink?.({url:G}).catch(()=>{g.textContent="The host did not open the link."})},label:Ie})}let ee=fe();I();let Be=n.displayMode??"inline",ut=n.availableDisplayModes??[];const He=()=>!!n.host.requestDisplayMode&&(ut.length===0||ut.includes("fullscreen"));function Ve(){if(Be==="fullscreen"){Y.style.removeProperty("height"),be.hidden=!0;return}const G=y.clientWidth||n.width||720,ae=Math.max(0,Y.offsetHeight-y.offsetHeight)||140,{height:ve,fits:Ne}=$A(ee.contentBounds(),G,ae);Y.style.height=`${ve}px`,be.hidden=Ne||!He(),Y.dataset.fits=String(Ne),ee.fit()}async function pt(G){try{await n.host.updateModelContext?.({content:[{type:"text",text:G}]})}catch{}}async function C(G,ae=!1){const ve=G.toLowerCase();if(u.has(ve))return g.textContent=`${ve} is ${Uo}.`,{added:[],refused:Uo};if(c.has(ve))return{added:[],refused:null};const Ne=a.get(ve);if(Ne&&!kp(Ne))return g.textContent=`Every recent flow of ${ve} is drawn.`,{added:[],refused:null};c.add(ve),M(),g.textContent=`Loading the flows of ${ve}…`;let Je=null;try{Je=await n.host.callServerTool({name:gA,arguments:xA(i,ve,ae||Ne?Ne?.cursor:null)})}catch(_t){Je={isError:!0,content:[{type:"text",text:_t instanceof Error?_t.message:String(_t)}]}}finally{c.delete(ve)}const It=EA(Je);if(It)return TA(It)?(u.add(ve),ee.markNode(ve,Uo),g.textContent=`${ve} is ${Uo}. The drawing is kept.`):g.textContent=`${ve} could not be expanded: ${CA(It)}. The drawing is kept; try again.`,M(),{added:[],refused:It};const qe=Je.structuredContent,qa=ee.model(),Nn=new Set(qa.nodes.map(_t=>_t.address.toLowerCase())),Wa=new Set;for(const _t of qe.nodes)Nn.has(_t.address.toLowerCase())||Wa.add(_t.address.toLowerCase());for(const _t of qe.edges)for(const $o of[_t.from,_t.to])Nn.has($o.toLowerCase())||Wa.add($o.toLowerCase());if(Nn.size+Wa.size>Fw){const _t=new Set(qa.edges.map(Rn=>`${Rn.from.toLowerCase()}->${Rn.to.toLowerCase()}`)),$o=new Set(qe.edges.map(Rn=>`${Rn.from.toLowerCase()}->${Rn.to.toLowerCase()}`).filter(Rn=>!_t.has(Rn))).size,th=_A($o,ve);return g.textContent=th,M(),{added:[],refused:th}}const Eo=ee.merge(qe,ve);return l.push({address:ve,page:qe}),d.add(ve),ee.flagNode(ve,lu,!0),a.set(ve,{cursor:qe.cursor??null,truncated:!!qe.truncated,remaining:_p(qe)}),I(),Ve(),M(),g.textContent=`${Eo.length} new ${Eo.length===1?"address":"addresses"} linked to ${ve}. Double-click it again to fold them back.`,await pt(AA(ve,Eo.length)),{added:Eo,refused:null}}function D(G){const ae=G.toLowerCase();if(!d.has(ae))return{removed:0};const ve=ee.model().nodes.length;d.delete(ae),a.delete(ae);const Ne=l.filter(qe=>qe.address!==ae),Je=[];ee.batch(()=>{ee.flagNode(ae,lu,!1),ee.update(t);for(const qe of Ne)ee.model().nodes.some(Nn=>Nn.address.toLowerCase()===qe.address)?(ee.merge(qe.page,qe.address),Je.push(qe)):Je.some(Nn=>Nn.address===qe.address)||(ee.flagNode(qe.address,lu,!1),d.delete(qe.address),a.delete(qe.address))}),l=Je;const It=Math.max(0,ve-ee.model().nodes.length);return h&&!ee.model().nodes.some(qe=>qe.address.toLowerCase()===h)&&(P.hidden=!0,h=null),I(),Ve(),M(),g.textContent=`Folded ${ae} back: ${It} ${It===1?"address":"addresses"} removed.`,pt(`investigator collapsed ${ae}: ${It} addresses removed`),{removed:It}}async function ne(G){d.has(G)?D(G):await C(G)}function Se(){he(),ee.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,j.close(),P.hidden=!0,ee=fe(),I(),Ve(),M(),g.textContent="Back to the first answer."}function pe(G,ae){G&&(Be=G),ae&&(ut=ae),Y.dataset.displayMode=Be,J.hidden=!He(),J.textContent=Be==="fullscreen"?"Exit full screen":"Full screen",J.setAttribute("aria-label",Be==="fullscreen"?"Back to the inline view":"Open full screen"),Ve()}pe(Be);const ct=async()=>{const G=Be==="fullscreen"?"inline":"fullscreen";try{const ae=await n.host.requestDisplayMode?.({mode:G});pe(ae?.mode??G)}catch{g.textContent="The host did not change the display mode."}},At=()=>Se();function Gt(){he();const G=!P.hidden;ee.select(null),j.close(),P.hidden=!0,h=null,M(),G&&Ve()}const Zr=()=>Gt(),In=()=>{h&&ne(h)},mn=()=>{h&&C(h,!0)};return J.addEventListener("click",ct),se.addEventListener("click",At),k.addEventListener("click",Zr),_.addEventListener("click",In),$.addEventListener("click",mn),{root:Y,get graph(){return ee},expand:G=>C(G),collapse:D,reset:Se,expanded:()=>[...d],linkPanel:j,openLink(G,ae){const ve=ee.model().edges.find(Ne=>Ne.from===G.toLowerCase()&&Ne.to===ae.toLowerCase());return ve?(ee.select(ve.id),j.open(ve)):Promise.resolve(null)},setTheme(G){ee.setTheme(G)},setDisplayMode:pe,refit:Ve,destroy(){he(),y.removeEventListener("keydown",ce,!0),Z.removeEventListener("focus",Ce),Z.removeEventListener("blur",Ae),Z.removeEventListener("keydown",L),J.removeEventListener("click",ct),se.removeEventListener("click",At),k.removeEventListener("click",Zr),_.removeEventListener("click",In),$.removeEventListener("click",mn),j.destroy(),ee.destroy()}}}function Qu(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function NA(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 Gw=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height});function RA(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(vw)} addresses. The table has the rows.`}function zA(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 LA(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:Zf,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function PA(e){const t=_w(e.structuredContent);if(t)return{model:t.model,table:LA(t.rows,e.structuredContent)};const n=qf(Bf(e.structuredContent));return n?{model:n,table:e}:null}function jw(e,t,n){const r=e.ownerDocument,i=xw(t),o=i==="chart"?PA(t):null;if(i!=="graph"&&!o)return i==="table"?hp(e,t):Ga(e,t),Qu(i==="table"?"table":"text");const s=t.structuredContent,a=Bf(s),u=o?.table??t,c=A(r,"div",{class:"cv-face","data-face":"picture"}),l=A(r,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(c,l);const d=zA(r,i==="graph"?"Graph":"Chart",g=>m(g));let f=null,h=null,p=!1;if(i==="graph"){const g=fC(a,qT(s));f=Uw(c,g.view,{...Gw(n),title:"Money flow graph",toggle:d.make(),note:RA(g.rowsLeftOut,g.rowsTotal)})}else h=rA(c,o.model,{toggle:d.make()});function m(g){c.hidden=g!=="picture",l.hidden=g!=="table",g==="table"&&!p&&(p=!0,hp(l,u,{toggle:d.make()})),d.set(g),g==="picture"&&(f?.refit(),h?.refit())}return{kind:i,flows:()=>f?[f]:[],setTheme(g){f?.setTheme(g)},setDisplayMode(g,w){f?.setDisplayMode(g,w)},refit(){c.hidden||(f?.refit(),h?.refit())},destroy(){f?.destroy(),h?.destroy()}}}function DA(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:Zf,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 OA(e,t,n){const r=e.ownerDocument,i=kw(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],g=s[p];if(!m||!g)return;d=p,o.forEach((y,b)=>{y.setAttribute("aria-selected",String(b===p)),y.tabIndex=b===p?0:-1}),s.forEach((y,b)=>{y.hidden=b!==p});const w=u[p];if(w)w.refit();else{const y=jw(g,DA(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l});u[p]=y,g.dataset.view=y.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",g=>{const w=o.length-1,y=g.key==="ArrowRight"?m===w?0:m+1:g.key==="ArrowLeft"?m===0?w:m-1:g.key==="Home"?0:g.key==="End"?w:null;y!=null&&(g.preventDefault(),h(y),o[y]?.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 g of u)g?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function MA(e,t,n){const r=xw(t);if(r==="flows"){const i=Uw(e,t.structuredContent,Gw(n));return NA("flows",()=>i)}return r==="graph"||r==="chart"||r==="table"?jw(e,t,n):r==="batch"?OA(e,t,n):r==="balance"?(kC(e,t),Qu("balance")):(Ga(e,t),Qu("text"))}function FA(e){return e==="light"||e==="dark"}function UA(e,t=()=>!1){return FA(e?.theme)?e.theme:t()?"dark":"light"}function Wf(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 Zw(e,t,n={}){const r=e.documentElement,i=UA(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 GA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Go={exports:{}},Sp;function jA(){if(Sp)return Go.exports;Sp=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)}Go.exports=o,Go.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",j=this._events;if(j!==void 0)O=O&&j.error===void 0;else if(!O)return!1;if(O){var P;if(_.length>0&&(P=_[0]),P instanceof Error)throw P;var J=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw J.context=P,J}var se=j[k];if(se===void 0)return!1;if(typeof se=="function")t(se,this,_);else for(var be=se.length,ke=p(se,be),$=0;$<be;++$)t(ke[$],this,_);return!0};function c(v,k,_,$){var O,j,P;if(a(_),j=v._events,j===void 0?(j=v._events=Object.create(null),v._eventsCount=0):(j.newListener!==void 0&&(v.emit("newListener",k,_.listener?_.listener:_),j=v._events),P=j[k]),P===void 0)P=j[k]=_,++v._eventsCount;else if(typeof P=="function"?P=j[k]=$?[_,P]:[P,_]:$?P.unshift(_):P.push(_),O=u(v),O>0&&P.length>O&&!P.warned){P.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=v,J.type=k,J.count=P.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,j,P,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(j=-1,P=$.length-1;P>=0;P--)if($[P]===_||$[P].listener===_){J=$[P].listener,j=P;break}if(j<0)return this;j===0?$.shift():m($,j),$.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 j=Object.keys($),P;for(O=0;O<j.length;++O)P=j[O],P!=="removeListener"&&this.removeAllListeners(P);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]:_?g(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 g(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(P){v.removeListener(k,j),$(P)}function j(){typeof v.removeListener=="function"&&v.removeListener("error",O),_([].slice.call(arguments))}b(v,k,j,{once:!0}),k!=="error"&&y(v,O,{once:!0})})}function y(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(j){$.once&&v.removeEventListener(k,O),_(j)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Go.exports}var Bw=jA();function ZA(){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 Ye=ZA;typeof Object.assign=="function"&&(Ye=Object.assign);function Pt(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 rt(e){return typeof e=="object"&&e!==null}function Hw(e){let t;for(t in e)return!1;return!0}function Nt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Zt(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 xp(e){return!(!rt(e)||e.attributes&&!Array.isArray(e.attributes))}function BA(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function on(){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 Ur(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Kf extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class V extends Kf{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,V.prototype.constructor)}}class B extends Kf{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,B.prototype.constructor)}}class oe extends Kf{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,oe.prototype.constructor)}}function Vw(e,t){this.key=e,this.attributes=t,this.clear()}Vw.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 qw(e,t){this.key=e,this.attributes=t,this.clear()}qw.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Ww(e,t){this.key=e,this.attributes=t,this.clear()}Ww.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Gr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Gr.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)};Gr.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};Gr.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]};Gr.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 Kw=0,Jw=1,HA=2,Yw=3;function pn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===Kw){if(a=e._nodes.get(r),!a)throw new B(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===Yw){if(i=""+i,u=e._edges.get(i),!u)throw new B(`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 B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Jw?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function VA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);return s.attributes[a]}}function qA(e,t,n){e.prototype[t]=function(r,i){const[o]=pn(this,t,n,r,i);return o.attributes}}function WA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function KA(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=pn(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 JA(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=pn(this,t,n,r,i,o,s);if(typeof c!="function")throw new V(`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 YA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(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 XA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(!rt(a))throw new V(`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 QA(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(!rt(a))throw new V(`Graph.${t}: provided attributes are not a plain object.`);return Ye(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function eI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=pn(this,t,n,r,i,o);if(typeof a!="function")throw new V(`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 tI=[{name:e=>`get${e}Attribute`,attacher:VA},{name:e=>`get${e}Attributes`,attacher:qA},{name:e=>`has${e}Attribute`,attacher:WA},{name:e=>`set${e}Attribute`,attacher:KA},{name:e=>`update${e}Attribute`,attacher:JA},{name:e=>`remove${e}Attribute`,attacher:YA},{name:e=>`replace${e}Attributes`,attacher:XA},{name:e=>`merge${e}Attributes`,attacher:QA},{name:e=>`update${e}Attributes`,attacher:eI}];function nI(e){tI.forEach(function({name:t,attacher:n}){n(e,t("Node"),Kw),n(e,t("Source"),Jw),n(e,t("Target"),HA),n(e,t("Opposite"),Yw)})}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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function iI(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=Pt(this,o,s,n),!i)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function oI(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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function sI(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=Pt(this,a,u,n),!s)throw new B(`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 B(`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 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=Pt(this,a,u,n),!s)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new V(`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 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=Pt(this,s,a,n),!o)throw new B(`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 B(`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 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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!rt(i))throw new V(`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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!rt(i))throw new V(`Graph.${t}: provided attributes are not a plain object.`);return Ye(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data: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=Pt(this,s,a,n),!o)throw new B(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new V(`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 fI=[{name:e=>`get${e}Attribute`,attacher:rI},{name:e=>`get${e}Attributes`,attacher:iI},{name:e=>`has${e}Attribute`,attacher:oI},{name:e=>`set${e}Attribute`,attacher:sI},{name:e=>`update${e}Attribute`,attacher:aI},{name:e=>`remove${e}Attribute`,attacher:uI},{name:e=>`replace${e}Attributes`,attacher:cI},{name:e=>`merge${e}Attributes`,attacher:lI},{name:e=>`update${e}Attributes`,attacher:dI}];function hI(e){fI.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const pI=[{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 gI(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 du(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 yI(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 vI(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 fu(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 bI(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 Xw(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 wI(e,t){if(e.size===0)return Ur();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 Jf(e,t,n,r,i,o){const s=t?gI: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 _I(e,t,n,r){const i=[];return Jf(!1,e,t,n,r,function(o){i.push(o)}),i}function kI(e,t,n){let r=Ur();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=on(r,du(n.in))),t!=="in"&&typeof n.out<"u"&&(r=on(r,du(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=on(r,du(n.undirected))),r}function Yf(e,t,n,r,i,o,s){const a=n?vI:yI;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 SI(e,t,n,r,i){const o=[];return Yf(!1,e,t,n,r,i,function(s){o.push(s)}),o}function xI(e,t,n,r){let i=Ur();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=on(i,fu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=on(i,fu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=on(i,fu(n.undirected,r))),i}function EI(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 bI(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new B(`Graph.${n}: could not find the "${o}" node in the graph.`);return _I(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 B(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new B(`Graph.${n}: could not find the "${s}" target node in the graph.`);return SI(r,this.multi,i,a,s)}throw new V(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function $I(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,Xw(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${c}" node in the graph.`);return Jf(!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 B(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new B(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Yf(!1,r,this.multi,i,f,l,d)}throw new V(`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,g,w,y,b,v)=>{d[h++]=l(p,m,g,w,y,b,v)})}else d=[],c.push((f,h,p,m,g,w,y)=>{d.push(l(f,h,p,m,g,w,y))});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,g,w,y)=>{l(f,h,p,m,g,w,y)&&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 V(`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 V(`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,g,w,y,b)=>{f=l(f,h,p,m,g,w,y,b)}),this[o].apply(this,c),f}}function TI(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,Xw(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new B(`Graph.${o}: could not find the "${u}" node in the graph.`);return Jf(!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 B(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new B(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Yf(!0,r,this.multi,i,d,c,l)}throw new V(`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,g,w)=>c(d,f,h,p,m,g,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,g,w)=>!c(d,f,h,p,m,g,w)),!this[o].apply(this,u)}}function CI(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 Ur();if(!arguments.length)return wI(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return kI(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new B(`Graph.${o}: could not find the "${a}" target node in the graph.`);return xI(r,i,u,a)}throw new V(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function AI(e){pI.forEach(t=>{EI(e,t),$I(e,t),TI(e,t),CI(e,t)})}const II=[{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 ja(){this.A=null,this.B=null}ja.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};ja.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Vr(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 Xf(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Vr(e,null,r,r.undirected,i);if(typeof n=="string")return Vr(e,null,r,r[n],i)}const o=new ja;let s;if(t!=="undirected"){if(n!=="out"){if(s=Vr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Vr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Vr(e,o,r,r.undirected,i),e&&s))return s}function NI(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 Xf(!1,e,t,n,function(i){r.push(i)}),r}function qr(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 RI(e,t,n){if(e!=="mixed"){if(e==="undirected")return qr(null,n,n.undirected);if(typeof t=="string")return qr(null,n,n[t])}let r=Ur();const i=new ja;return e!=="undirected"&&(t!=="out"&&(r=on(r,qr(i,n,n.in))),t!=="in"&&(r=on(r,qr(i,n,n.out)))),e!=="directed"&&(r=on(r,qr(i,n,n.undirected))),r}function zI(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 B(`Graph.${n}: could not find the "${o}" node in the graph.`);return NI(r==="mixed"?this.type:r,i,s)}}function LI(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 B(`Graph.${o}: could not find the "${c}" node in the graph.`);Xf(!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 V(`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 PI(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 B(`Graph.${s}: could not find the "${c}" node in the graph.`);return Xf(!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 DI(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 Ur();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return RI(r==="mixed"?this.type:r,i,a)}}function OI(e){II.forEach(t=>{zI(e,t),LI(e,t),PI(e,t),DI(e,t)})}function jo(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 MI(e,t){const n={key:e};return Hw(t.attributes)||(n.attributes=Ye({},t.attributes)),n}function FI(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return Hw(n.attributes)||(r.attributes=Ye({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function UI(e){if(!rt(e))throw new V('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 V("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!rt(e.attributes)||e.attributes===null))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function GI(e){if(!rt(e))throw new V('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 V("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!rt(e.attributes)||e.attributes===null))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const jI=BA(),ZI=new Set(["directed","undirected","mixed"]),Ep=new Set(["domain","_events","_eventsCount","_maxListeners"]),BI=[{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"}],HI={allowSelfLoops:!0,multi:!1,type:"mixed"};function VI(e,t,n){if(n&&!rt(n))throw new V(`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 $p(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 Qw(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&&!rt(a))throw new V(`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 B(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new B(`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 Gr(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 qI(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 V(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!rt(a))throw new V(`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 y=[h.key,!1,!1,!1];if(u?!c:!a)return y;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Ye(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return y}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,g=!1;l||(l=$p(e,o,{}),m=!0,o===s&&(d=l,g=!0)),d||(d=$p(e,s,{}),g=!0),f=new Gr(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,g]}function Jn(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 Oe extends Bw.EventEmitter{constructor(t){if(super(),t=Ye({},HI,t),typeof t.multi!="boolean")throw new V(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!ZI.has(t.type))throw new V(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new V(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Vw:t.type==="directed"?qw:Ww;Nt(this,"NodeDataClass",n);const r="geid_"+jI()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Nt(this,"_attributes",{}),Nt(this,"_nodes",new Map),Nt(this,"_edges",new Map),Nt(this,"_directedSize",0),Nt(this,"_undirectedSize",0),Nt(this,"_directedSelfLoopCount",0),Nt(this,"_undirectedSelfLoopCount",0),Nt(this,"_edgeKeyGenerator",o),Nt(this,"_options",t),Ep.forEach(s=>Nt(this,s,this[s])),Zt(this,"order",()=>this._nodes.size),Zt(this,"size",()=>this._edges.size),Zt(this,"directedSize",()=>this._directedSize),Zt(this,"undirectedSize",()=>this._undirectedSize),Zt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Zt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Zt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Zt(this,"multi",this._options.multi),Zt(this,"type",this._options.type),Zt(this,"allowSelfLoops",this._options.allowSelfLoops),Zt(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 V(`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 V(`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 V(`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 B(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return VI(this,t,n).key}mergeNode(t,n){if(n&&!rt(n))throw new V(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ye(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 V(`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 B(`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 Jn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Jn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Jn(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=Pt(this,r,i,this.type),!n)throw new B(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new B(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Jn(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=Pt(this,t,n,"directed");if(!r)throw new B(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Jn(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=Pt(this,t,n,"undirected");if(!r)throw new B(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Jn(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 V("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(!rt(t))throw new V("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(!rt(t))throw new V("Graph.mergeAttributes: provided attributes are not a plain object.");return Ye(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new V("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 V("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!xp(n))throw new V("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 V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!xp(n))throw new V("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 V("Graph.forEachAdjacencyEntry: expecting a callback.");jo(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");jo(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");jo(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");jo(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new V("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 V("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 V("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 V("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 V("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 V("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 V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("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++]=MI(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=FI(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 Oe)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(!rt(t))throw new V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!rt(t.attributes))throw new V("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 V("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],UI(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 V("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],GI(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 Oe(Ye({},this._options,t));return n.replaceAttributes(Ye({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Ye({},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,Qw(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Ye({},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)&&!Ep.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Nt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Oe.prototype[Symbol.for("nodejs.util.inspect.custom")]=Oe.prototype.inspect);BI.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?Qw:qI;e.generateKey?Oe.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Oe.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});nI(Oe);hI(Oe);AI(Oe);OI(Oe);class e_ extends Oe{constructor(t){const n=Ye({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class t_ extends Oe{constructor(t){const n=Ye({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class n_ extends Oe{constructor(t){const n=Ye({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class r_ extends Oe{constructor(t){const n=Ye({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class i_ extends Oe{constructor(t){const n=Ye({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function jr(e){e.from=function(t,n){const r=Ye({},t.options,n),i=new e(r);return i.import(t),i}}jr(Oe);jr(e_);jr(t_);jr(n_);jr(r_);jr(i_);Oe.Graph=Oe;Oe.DirectedGraph=e_;Oe.UndirectedGraph=t_;Oe.MultiGraph=n_;Oe.MultiDirectedGraph=r_;Oe.MultiUndirectedGraph=i_;Oe.InvalidArgumentsGraphError=V;Oe.NotFoundGraphError=B;Oe.UsageGraphError=oe;function WI(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 ri(e){var t=WI(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 Tp(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,ri(r.key),r)}}function ht(e,t,n){return t&&Tp(e.prototype,t),n&&Tp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function mr(e){return mr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mr(e)}function o_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(o_=function(){return!!e})()}function KI(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function JI(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 KI(e)}function Ft(e,t,n){return t=mr(t),JI(e,o_()?Reflect.construct(t,n||[],mr(e).constructor):t.apply(e,n))}function ec(e,t){return ec=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ec(e,t)}function Ut(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&&ec(e,t)}function YI(e){if(Array.isArray(e))return e}function XI(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 tc(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 s_(e,t){if(e){if(typeof e=="string")return tc(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)?tc(e,t):void 0}}function QI(){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 gr(e,t){return YI(e)||XI(e,t)||s_(e,t)||QI()}var hu={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"},a_=new Int8Array(4),Xo=new Int32Array(a_.buffer,0,1),u_=new Float32Array(a_.buffer,0,1),eN=/^\s*rgba?\s*\(/,tN=/^\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(eN.test(e)){var o=e.match(tN);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 nr={};for(var Zo in hu)nr[Zo]=An(hu[Zo]),nr[hu[Zo]]=nr[Zo];function c_(e,t,n,r,i){return Xo[0]=r<<24|n<<16|t<<8|e,Xo[0]=Xo[0]&4278190079,u_[0]}function An(e){if(e=e.toLowerCase(),typeof nr[e]<"u")return nr[e];var t=nN(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=c_(n,r,i,o);return nr[e]=s,s}function rN(e,t){u_[0]=An(e);var n=Xo[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var pu={};function l_(e){if(typeof pu[e]<"u")return pu[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=c_(t,n,r,i);return pu[e]=o,o}function Cp(e,t,n,r){return n+(t<<8)+(e<<16)}function Ap(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=gr(u,4),l=c[0],d=c[1],f=c[2],h=c[3];return[l,d,f,h]}function z(e,t,n){return(t=ri(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ip(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?Ip(Object(n),!0).forEach(function(r){z(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ip(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function iN(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=mr(e))!==null;);return e}function nc(){return nc=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=iN(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},nc.apply(null,arguments)}function d_(e,t,n,r){var i=nc(mr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function oN(e){return e.normalized?1:e.size}function mu(e){var t=0;return e.forEach(function(n){return t+=oN(n)}),t}function f_(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 sN(e,t){return
|
|
114
|
-
`,cN=z(z(z(z(z(z(z(z({},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),
|
|
113
|
+
`).concat(n))}return i}function sN(e,t){return f_("VERTEX",e,t)}function aN(e,t){return f_("FRAGMENT",e,t)}function uN(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 Np(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 Rp(e){return e%1===0?e.toFixed(1):e.toString()}var zp=`#define PICKING_MODE
|
|
114
|
+
`,cN=z(z(z(z(z(z(z(z({},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),h_=(function(){function e(t,n,r){ft(this,e),z(this,"array",new Float32Array),z(this,"constantArray",new Float32Array),z(this,"capacity",0),z(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=mu(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=mu(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(){Np(this.normalProgram),this.pickProgram&&(Np(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=sN(r,i),l=aN(r,o),d=uN(r,[c,l]),f={};a.UNIFORMS.forEach(function(m){var g=r.getUniformLocation(d,m);g&&(f[m]=g)});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=cN[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:mu(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)}}}])})(),p_=(function(e){function t(){return ft(this,t),Ft(this,t,arguments)}return Ut(t,e),ht(t,[{key:"kill",value:function(){d_(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(l_(r),s,o)}}])})(h_),Za=(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=Ft(this,t,[].concat(i)),z(n,"drawLabel",void 0),n}return Ut(t,e),ht(t,[{key:"kill",value:function(){d_(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(l_(r),u,o,s,a)}}])})(h_);function lN(e,t){return(function(){function n(r,i,o){ft(this,n),z(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 dN(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,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+b*b);if(!(v<l+d)){f+=y*l/v,h+=b*l/v,p-=y*d/v,m-=b*d/v,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+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 $;y>0?b>0?$=Math.acos(y/v):$=Math.asin(b/v):b>0?$=Math.acos(y/v)+Math.PI:$=Math.asin(y/v)+Math.PI/2,e.save(),e.translate(g,w),e.rotate($),e.fillText(c,-k/2,t.size/2+o),e.restore()}}}function m_(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 fN(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,m_(e,t,n)}var hN=`
|
|
115
115
|
precision highp float;
|
|
116
116
|
|
|
117
117
|
varying vec4 v_color;
|
|
@@ -184,7 +184,7 @@ void main() {
|
|
|
184
184
|
|
|
185
185
|
v_color.a *= bias;
|
|
186
186
|
}
|
|
187
|
-
`,gN=mN,
|
|
187
|
+
`,gN=mN,g_=WebGLRenderingContext,Lp=g_.UNSIGNED_BYTE,gu=g_.FLOAT,yN=["u_sizeRatio","u_correctionRatio","u_matrix"],Ba=(function(e){function t(){return ft(this,t),Ft(this,t,arguments)}return Ut(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:gN,FRAGMENT_SHADER_SOURCE:pN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:yN,ATTRIBUTES:[{name:"a_position",size:2,type:gu},{name:"a_size",size:1,type:gu},{name:"a_color",size:4,type:Lp,normalized:!0},{name:"a_id",size:4,type:Lp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:gu}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=An(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)}}])})(p_);z(Ba,"ANGLE_1",0);z(Ba,"ANGLE_2",2*Math.PI/3);z(Ba,"ANGLE_3",4*Math.PI/3);var vN=`
|
|
188
188
|
precision mediump float;
|
|
189
189
|
|
|
190
190
|
varying vec4 v_color;
|
|
@@ -258,7 +258,7 @@ void main() {
|
|
|
258
258
|
|
|
259
259
|
v_color.a *= bias;
|
|
260
260
|
}
|
|
261
|
-
`,_N=wN,
|
|
261
|
+
`,_N=wN,y_=WebGLRenderingContext,Pp=y_.UNSIGNED_BYTE,Bo=y_.FLOAT,kN=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Ha={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function v_(e){var t=X(X({},Ha),e||{});return(function(n){function r(){return ft(this,r),Ft(this,r,arguments)}return Ut(r,n),ht(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:_N,FRAGMENT_SHADER_SOURCE:bN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:kN,ATTRIBUTES:[{name:"a_position",size:2,type:Bo},{name:"a_normal",size:2,type:Bo},{name:"a_radius",size:1,type:Bo},{name:"a_color",size:4,type:Pp,normalized:!0},{name:"a_id",size:4,type:Pp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Bo}],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,g=u.y,w=An(c.color),y=m-h,b=g-p,v=y*y+b*b,k=0,_=0;v&&(v=1/Math.sqrt(v),k=-b*v*d,_=y*v*d);var $=this.array;$[s++]=m,$[s++]=g,$[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)}}])})(Za)}v_();var SN=`
|
|
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
|
+
`,b_=SN,xN=`
|
|
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
|
-
`,EN=xN,
|
|
355
|
+
`,EN=xN,w_=WebGLRenderingContext,Dp=w_.UNSIGNED_BYTE,Ln=w_.FLOAT,$N=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],TN={lengthToThicknessRatio:Ha.lengthToThicknessRatio};function __(e){var t=X(X({},TN),e||{});return(function(n){function r(){return ft(this,r),Ft(this,r,arguments)}return Ut(r,n),ht(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:EN,FRAGMENT_SHADER_SOURCE:b_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$N,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ln},{name:"a_positionEnd",size:2,type:Ln},{name:"a_normal",size:2,type:Ln},{name:"a_color",size:4,type:Dp,normalized:!0},{name:"a_id",size:4,type:Dp,normalized:!0},{name:"a_radius",size:1,type:Ln}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ln},{name:"a_normalCoef",size:1,type:Ln},{name:"a_radiusCoef",size:1,type:Ln}],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=An(c.color),g=h-d,w=p-f,y=u.size||1,b=g*g+w*w,v=0,k=0;b&&(b=1/Math.sqrt(b),v=-w*b*l,k=g*b*l);var _=this.array;_[s++]=d,_[s++]=f,_[s++]=h,_[s++]=p,_[s++]=v,_[s++]=k,_[s++]=m,_[s++]=o,_[s++]=y}},{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,g=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(g,t.lengthToThicknessRatio)}}])})(Za)}__();function k_(e){return lN([__(e),v_(e)])}var CN=k_(),AN=CN,IN=`
|
|
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
|
-
`,NN=IN,k_=WebGLRenderingContext,Op=k_.UNSIGNED_BYTE,Wr=k_.FLOAT,RN=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],zN=(function(e){function t(){return ft(this,t),Ft(this,t,arguments)}return Ut(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:NN,FRAGMENT_SHADER_SOURCE:v_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:RN,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Wr},{name:"a_positionEnd",size:2,type:Wr},{name:"a_normal",size:2,type:Wr},{name:"a_color",size:4,type:Op,normalized:!0},{name:"a_id",size:4,type:Op,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Wr},{name:"a_normalCoef",size:1,type:Wr}],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=An(a.color),p=d-c,m=f-l,g=p*p+m*m,w=0,y=0;g&&(g=1/Math.sqrt(g),w=-m*g*u,y=p*g*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=y,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)}}])})(Za),Qf=(function(e){function t(){var n;return ft(this,t),n=Ft(this,t),n.rawEmitter=n,n}return Ut(t,e),ht(t)})(Zw.EventEmitter),yu,Mp;function LN(){return Mp||(Mp=1,yu=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),yu}var PN=LN();const DN=GA(PN);var ON=function(t){return t},MN=function(t){return t*t},FN=function(t){return t*(2-t)},UN=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},GN=function(t){return t*t*t},jN=function(t){return--t*t*t+1},ZN=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},BN={linear:ON,quadraticIn:MN,quadraticOut:FN,quadraticInOut:UN,cubicIn:GN,cubicOut:jN,cubicInOut:ZN},HN={easing:"quadraticInOut",duration:150};function Bt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ho(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Fp(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 Up(e,t,n){return e[6]=t,e[7]=n,e}function yn(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],g=t[5],w=t[6],y=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+g*u,e[4]=p*r+m*s+g*c,e[5]=p*i+m*a+g*l,e[6]=w*n+y*o+b*u,e[7]=w*r+y*s+b*c,e[8]=w*i+y*a+b*l,e}function rc(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 VN(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 Kr(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=Bt(),f=Math.min(c,l)-2*r,h=VN(t,n);return i?(yn(d,Up(Bt(),a,u)),yn(d,Ho(Bt(),s)),yn(d,Fp(Bt(),o)),yn(d,Ho(Bt(),c/f/2/h,l/f/2/h))):(yn(d,Ho(Bt(),2*(f/c)*h,2*(f/l)*h)),yn(d,Fp(Bt(),-o)),yn(d,Ho(Bt(),1/s)),yn(d,Up(Bt(),-a,-u))),d}function qN(e,t,n){var r=rc(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 WN(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 KN(e){if(!DN(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 JN(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 Gp(){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 Zp(e){var t=gr(e.x,2),n=t[0],r=t[1],i=gr(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 ic(e){"@babel/helpers - typeof";return ic=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},ic(e)}function Bp(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 vu(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 eh={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:dN,defaultDrawNodeLabel:p_,defaultDrawNodeHover:fN,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:{}},YN={circle:Ba},XN={arrow:AN,line:zN};function bu(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 QN(e){var t=vu({},eh,e);return t.nodeProgramClasses=vu({},YN,t.nodeProgramClasses),t.edgeProgramClasses=vu({},XN,t.edgeProgramClasses),t}var Vo=1.5,Hp=(function(e){function t(){var n;return ft(this,t),n=Ft(this,t),z(n,"x",.5),z(n,"y",.5),z(n,"angle",0),z(n,"ratio",1),z(n,"minRatio",null),z(n,"maxRatio",null),z(n,"enabledZooming",!0),z(n,"enabledPanning",!0),z(n,"enabledRotation",!0),z(n,"clean",null),z(n,"nextFrame",null),z(n,"previousState",null),z(n,"enabled",!0),n.previousState=n.getState(),n}return Ut(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({},HN),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:BN[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),g={};typeof u.x=="number"&&(g.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(g.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(g.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(g.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(g),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||Vo)},r):this.animate({ratio:this.ratio/Vo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Vo)},r):this.animate({ratio:this.ratio*Vo})}},{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)}}])})(Qf);function Ht(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function tn(e,t){var n=X(X({},Ht(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Jr(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 e1(e,t){return X(X({},tn(e,t)),{},{delta:S_(e)})}var t1=2;function Qo(e){for(var t=[],n=0,r=Math.min(e.length,t1);n<r;n++)t.push(e[n]);return t}function Yr(e,t,n){var r={touches:Qo(e.touches).map(function(i){return Ht(i,n)}),previousTouches:t.map(function(i){return Ht(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function S_(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 x_=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t),i.container=n,i.renderer=r,i}return Ut(t,e),ht(t)})(Qf),n1=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],r1=n1.reduce(function(e,t){return X(X({},e),{},z({},t,eh[t]))},{}),i1=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t,[n,r]),z(i,"enabled",!0),z(i,"draggedEvents",0),z(i,"downStartTime",null),z(i,"lastMouseX",null),z(i,"lastMouseY",null),z(i,"isMouseDown",!1),z(i,"isMoving",!1),z(i,"movingTimeout",null),z(i,"startCameraState",null),z(i,"clicks",0),z(i,"doubleClickTimeout",null),z(i,"currentWheelDirection",0),z(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 Ut(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",tn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",tn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=tn(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(Ht(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=Ht(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",tn(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=Ht(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",tn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=tn(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=Ht(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,g=p.y+h;s.setState({x:m,y:g}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",tn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",tn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=S_(r);if(s){var a=e1(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(Ht(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}}])})(x_),o1=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],s1=o1.reduce(function(e,t){return X(X({},e),{},z({},t,eh[t]))},{}),a1=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t,[n,r]),z(i,"enabled",!0),z(i,"isMoving",!1),z(i,"hasMoved",!1),z(i,"touchMode",0),z(i,"startTouchesPositions",[]),z(i,"lastTouches",[]),z(i,"lastTap",null),z(i,"settings",s1),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 Ut(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=Qo(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Ht(h,i.container)}),this.touchMode===2){var s=gr(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",Yr(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",Yr(r,this.lastTouches,this.container)),!r.touches.length){var a=Ht(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=Yr(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=Yr(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=Qo(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Qo(r.touches),s=o.map(function(I){return Ht(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=Yr(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]),g=m.x,w=m.y;c.setState({x:l.x+h-g,y:l.y+p-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,k=b.y,_=s[1],$=_.x,O=_.y,j=Math.atan2(O-k,$-v)-this.startTouchesAngle,P=Math.hypot(O-k,$-v)/this.startTouchesDistance,J=c.getBoundedRatio(l.ratio/P);y.ratio=J,y.angle=l.angle+j;var se=this.getDimensions(),be=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),ke=Math.min(se.width,se.height)-2*d,Ue=ke/se.width,F=ke/se.height,Z=J/ke,W=v-ke/2/Ue,Q=k-ke/2/F,Y=[W*Math.cos(-y.angle)-Q*Math.sin(-y.angle),Q*Math.cos(-y.angle)+W*Math.sin(-y.angle)];W=Y[0],Q=Y[1],y.x=be.x-W*Z,y.y=be.y+Q*Z,c.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(x_);function u1(e){if(Array.isArray(e))return tc(e)}function c1(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 Vp(e){return u1(e)||c1(e)||o_(e)||l1()}function d1(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 wu(e,t){if(e==null)return{};var n,r,i=d1(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 qp=(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}}])})(),Wp=(function(){function e(){ft(this,e),z(this,"width",0),z(this,"height",0),z(this,"cellSize",0),z(this,"columns",0),z(this,"rows",0),z(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 qp(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(qp.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 f1(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 Kp=150,Jp=50,nn=Object.prototype.hasOwnProperty;function h1(e,t,n){if(!nn.call(n,"x")||!nn.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),nn.call(n,"hidden")||(n.hidden=!1),nn.call(n,"highlighted")||(n.highlighted=!1),nn.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function p1(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),nn.call(n,"hidden")||(n.hidden=!1),nn.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=Ft(this,t),z(i,"elements",{}),z(i,"canvasContexts",{}),z(i,"webGLContexts",{}),z(i,"pickingLayers",new Set),z(i,"textures",{}),z(i,"frameBuffers",{}),z(i,"activeListeners",{}),z(i,"labelGrid",new Wp),z(i,"nodeDataCache",{}),z(i,"edgeDataCache",{}),z(i,"nodeProgramIndex",{}),z(i,"edgeProgramIndex",{}),z(i,"nodesWithForcedLabels",new Set),z(i,"edgesWithForcedLabels",new Set),z(i,"nodeExtent",{x:[0,1],y:[0,1]}),z(i,"nodeZExtent",[1/0,-1/0]),z(i,"edgeZExtent",[1/0,-1/0]),z(i,"matrix",Bt()),z(i,"invMatrix",Bt()),z(i,"correctionRatio",1),z(i,"customBBox",null),z(i,"normalizationFunction",Zp({x:[0,1],y:[0,1]})),z(i,"graphToViewportRatio",1),z(i,"itemIDsIndex",{}),z(i,"nodeIndices",{}),z(i,"edgeIndices",{}),z(i,"width",0),z(i,"height",0),z(i,"pixelRatio",Gp()),z(i,"pickingDownSizingRatio",2*i.pixelRatio),z(i,"displayedNodeLabels",new Set),z(i,"displayedEdgeLabels",new Set),z(i,"highlightedNodes",new Set),z(i,"hoveredNode",null),z(i,"hoveredEdge",null),z(i,"renderFrame",null),z(i,"renderHighlightedNodesFrame",null),z(i,"needToProcess",!1),z(i,"checkEdgesEventsFrame",null),z(i,"nodePrograms",{}),z(i,"nodeHoverPrograms",{}),z(i,"edgePrograms",{}),i.settings=QN(o),bu(i.settings),KN(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 Hp,i.bindCameraHandlers(),i.mouseCaptor=new i1(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new a1(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ut(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=wu(i,[r].map(ri));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=wu(a,[r].map(ri));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=wu(i,[r].map(ri));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=Ap(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=Cp.apply(void 0,Vp(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=Jr(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=Jr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Jr(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=Jr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",X({},a))};var i=function(s){return function(a){var u=Jr(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=Ap(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=Cp.apply(void 0,Vp(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=WN(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=Zp(this.customBBox||this.nodeExtent);var f=new Hp,h=Kr(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},g={},w={},y=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 j in this.nodePrograms){if(!nn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(p[j]||0),p[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=jp(this.nodeZExtent,function(ce){return r.nodeDataCache[ce].zIndex},b));for(var P=0,J=b.length;P<J;P++){var se=b[P];m[se]=y,w[m[se]]={type:"node",id:se},y++;var be=this.nodeDataCache[se];this.addNodeToProgram(se,m[se],p[be.type]++)}for(var ke={},Ue=i.edges(),F=0,Z=Ue.length;F<Z;F++){var W=Ue[F],Q=this.edgeDataCache[W];ke[Q.type]=(ke[Q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Ue=jp(this.edgeZExtent,function(ce){return r.edgeDataCache[ce].zIndex},Ue));for(var Y in this.edgePrograms){if(!nn.call(this.edgePrograms,Y))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Y,'"!'));this.edgePrograms[Y].reallocate(ke[Y]||0),ke[Y]=0}for(var I=0,R=Ue.length;I<R;I++){var U=Ue[I];g[U]=y,w[g[U]]={type:"edge",id:U},y++;var ie=this.edgeDataCache[U];this.addEdgeToProgram(U,g[U],ke[ie.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=g,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&&ic(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=gr(c.x,2),d=l[0],f=l[1],h=gr(c.y,2),p=h[0],m=h[1],g=[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,y=-1/0,b=1/0,v=-1/0;g.forEach(function(ke){var Ue=ke.x,F=ke.y;w=Math.min(w,Ue),y=Math.max(y,Ue),b=Math.min(b,F),v=Math.max(v,F)});var k=y-w,_=v-b,$=this.getDimensions(),O=$.width,j=$.height,P=0,J=0;if(k>=O?y<O-s?P=y-(O-s):w>s&&(P=w-s):y>O+s?P=y-(O+s):w<-s&&(P=w+s),_>=j?v<j-s?J=v-(j-s):b>s&&(J=b-s):v>j+s?J=v-(j+s):b<-s&&(J=b+s),P||J){var se=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),be=this.viewportToFramedGraph({x:P,y:J},{cameraState:r});P=be.x-se.x,J=be.y-se.y,u.x+=P,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);Bp(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<-Kp||d>this.width+Kp||f<-Jp||f>this.height+Jp)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],g=m?.drawLabel||p;g(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=f1({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Bp(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),g=m.x,w=m.y,y=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:y,x:g,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(g){return r.resetWebGLTexture(g)}),!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=Kr(a,u,c,l),this.invMatrix=Kr(a,u,c,l,!0),this.correctionRatio=qN(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=h1(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=p1(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 Wp,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=JN(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,bu(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),bu(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=Gp(),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)||[],g=0,w=m.length;g<w;g++){var y=m[g];if(this.updateEdge(y),o){var b=this.edgeProgramIndex[y];if(b===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],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),g=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-g.x)*(1-h)+u,y:(m.y-g.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?Kr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=rc(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?Kr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=rc(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}}])})(Qf),g1=m1;function y1(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 E_(e){var t=y1(e,"string");return typeof t=="symbol"?t:t+""}function $_(e,t,n){return(t=E_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yp(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 ps(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Yp(Object(n),!0).forEach(function(r){$_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function v1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b1(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,E_(r.key),r)}}function w1(e,t,n){return t&&b1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ms(e){return ms=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ms(e)}function T_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(T_=function(){return!!e})()}function C_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _1(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 C_(e)}function k1(e,t,n){return t=ms(t),_1(e,T_()?Reflect.construct(t,n||[],ms(e).constructor):t.apply(e,n))}function oc(e,t){return oc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},oc(e,t)}function S1(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&&oc(e,t)}function sc(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 x1(e){if(Array.isArray(e))return sc(e)}function E1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $1(e,t){if(e){if(typeof e=="string")return sc(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)?sc(e,t):void 0}}function T1(){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 _u(e){return x1(e)||E1(e)||$1(e)||T1()}function
|
|
420
|
+
`,NN=IN,S_=WebGLRenderingContext,Op=S_.UNSIGNED_BYTE,Wr=S_.FLOAT,RN=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],zN=(function(e){function t(){return ft(this,t),Ft(this,t,arguments)}return Ut(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:NN,FRAGMENT_SHADER_SOURCE:b_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:RN,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Wr},{name:"a_positionEnd",size:2,type:Wr},{name:"a_normal",size:2,type:Wr},{name:"a_color",size:4,type:Op,normalized:!0},{name:"a_id",size:4,type:Op,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Wr},{name:"a_normalCoef",size:1,type:Wr}],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=An(a.color),p=d-c,m=f-l,g=p*p+m*m,w=0,y=0;g&&(g=1/Math.sqrt(g),w=-m*g*u,y=p*g*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=y,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)}}])})(Za),Qf=(function(e){function t(){var n;return ft(this,t),n=Ft(this,t),n.rawEmitter=n,n}return Ut(t,e),ht(t)})(Bw.EventEmitter),yu,Mp;function LN(){return Mp||(Mp=1,yu=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),yu}var PN=LN();const DN=GA(PN);var ON=function(t){return t},MN=function(t){return t*t},FN=function(t){return t*(2-t)},UN=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},GN=function(t){return t*t*t},jN=function(t){return--t*t*t+1},ZN=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},BN={linear:ON,quadraticIn:MN,quadraticOut:FN,quadraticInOut:UN,cubicIn:GN,cubicOut:jN,cubicInOut:ZN},HN={easing:"quadraticInOut",duration:150};function Bt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ho(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Fp(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 Up(e,t,n){return e[6]=t,e[7]=n,e}function yn(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],g=t[5],w=t[6],y=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+g*u,e[4]=p*r+m*s+g*c,e[5]=p*i+m*a+g*l,e[6]=w*n+y*o+b*u,e[7]=w*r+y*s+b*c,e[8]=w*i+y*a+b*l,e}function rc(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 VN(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 Kr(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=Bt(),f=Math.min(c,l)-2*r,h=VN(t,n);return i?(yn(d,Up(Bt(),a,u)),yn(d,Ho(Bt(),s)),yn(d,Fp(Bt(),o)),yn(d,Ho(Bt(),c/f/2/h,l/f/2/h))):(yn(d,Ho(Bt(),2*(f/c)*h,2*(f/l)*h)),yn(d,Fp(Bt(),-o)),yn(d,Ho(Bt(),1/s)),yn(d,Up(Bt(),-a,-u))),d}function qN(e,t,n){var r=rc(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 WN(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 KN(e){if(!DN(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 JN(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 Gp(){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 Zp(e){var t=gr(e.x,2),n=t[0],r=t[1],i=gr(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 ic(e){"@babel/helpers - typeof";return ic=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},ic(e)}function Bp(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 vu(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 eh={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:dN,defaultDrawNodeLabel:m_,defaultDrawNodeHover:fN,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:{}},YN={circle:Ba},XN={arrow:AN,line:zN};function bu(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 QN(e){var t=vu({},eh,e);return t.nodeProgramClasses=vu({},YN,t.nodeProgramClasses),t.edgeProgramClasses=vu({},XN,t.edgeProgramClasses),t}var Vo=1.5,Hp=(function(e){function t(){var n;return ft(this,t),n=Ft(this,t),z(n,"x",.5),z(n,"y",.5),z(n,"angle",0),z(n,"ratio",1),z(n,"minRatio",null),z(n,"maxRatio",null),z(n,"enabledZooming",!0),z(n,"enabledPanning",!0),z(n,"enabledRotation",!0),z(n,"clean",null),z(n,"nextFrame",null),z(n,"previousState",null),z(n,"enabled",!0),n.previousState=n.getState(),n}return Ut(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({},HN),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:BN[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),g={};typeof u.x=="number"&&(g.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(g.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(g.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(g.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(g),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||Vo)},r):this.animate({ratio:this.ratio/Vo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Vo)},r):this.animate({ratio:this.ratio*Vo})}},{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)}}])})(Qf);function Ht(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function tn(e,t){var n=X(X({},Ht(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Jr(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 e1(e,t){return X(X({},tn(e,t)),{},{delta:x_(e)})}var t1=2;function Qo(e){for(var t=[],n=0,r=Math.min(e.length,t1);n<r;n++)t.push(e[n]);return t}function Yr(e,t,n){var r={touches:Qo(e.touches).map(function(i){return Ht(i,n)}),previousTouches:t.map(function(i){return Ht(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function x_(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 E_=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t),i.container=n,i.renderer=r,i}return Ut(t,e),ht(t)})(Qf),n1=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],r1=n1.reduce(function(e,t){return X(X({},e),{},z({},t,eh[t]))},{}),i1=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t,[n,r]),z(i,"enabled",!0),z(i,"draggedEvents",0),z(i,"downStartTime",null),z(i,"lastMouseX",null),z(i,"lastMouseY",null),z(i,"isMouseDown",!1),z(i,"isMoving",!1),z(i,"movingTimeout",null),z(i,"startCameraState",null),z(i,"clicks",0),z(i,"doubleClickTimeout",null),z(i,"currentWheelDirection",0),z(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 Ut(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",tn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",tn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=tn(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(Ht(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=Ht(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",tn(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=Ht(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",tn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=tn(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=Ht(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,g=p.y+h;s.setState({x:m,y:g}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",tn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",tn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=x_(r);if(s){var a=e1(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(Ht(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}}])})(E_),o1=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],s1=o1.reduce(function(e,t){return X(X({},e),{},z({},t,eh[t]))},{}),a1=(function(e){function t(n,r){var i;return ft(this,t),i=Ft(this,t,[n,r]),z(i,"enabled",!0),z(i,"isMoving",!1),z(i,"hasMoved",!1),z(i,"touchMode",0),z(i,"startTouchesPositions",[]),z(i,"lastTouches",[]),z(i,"lastTap",null),z(i,"settings",s1),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 Ut(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=Qo(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Ht(h,i.container)}),this.touchMode===2){var s=gr(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",Yr(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",Yr(r,this.lastTouches,this.container)),!r.touches.length){var a=Ht(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=Yr(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=Yr(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=Qo(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Qo(r.touches),s=o.map(function(I){return Ht(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=Yr(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]),g=m.x,w=m.y;c.setState({x:l.x+h-g,y:l.y+p-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,k=b.y,_=s[1],$=_.x,O=_.y,j=Math.atan2(O-k,$-v)-this.startTouchesAngle,P=Math.hypot(O-k,$-v)/this.startTouchesDistance,J=c.getBoundedRatio(l.ratio/P);y.ratio=J,y.angle=l.angle+j;var se=this.getDimensions(),be=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),ke=Math.min(se.width,se.height)-2*d,Ue=ke/se.width,F=ke/se.height,Z=J/ke,W=v-ke/2/Ue,Q=k-ke/2/F,Y=[W*Math.cos(-y.angle)-Q*Math.sin(-y.angle),Q*Math.cos(-y.angle)+W*Math.sin(-y.angle)];W=Y[0],Q=Y[1],y.x=be.x-W*Z,y.y=be.y+Q*Z,c.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(E_);function u1(e){if(Array.isArray(e))return tc(e)}function c1(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 Vp(e){return u1(e)||c1(e)||s_(e)||l1()}function d1(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 wu(e,t){if(e==null)return{};var n,r,i=d1(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 qp=(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}}])})(),Wp=(function(){function e(){ft(this,e),z(this,"width",0),z(this,"height",0),z(this,"cellSize",0),z(this,"columns",0),z(this,"rows",0),z(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 qp(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(qp.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 f1(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 Kp=150,Jp=50,nn=Object.prototype.hasOwnProperty;function h1(e,t,n){if(!nn.call(n,"x")||!nn.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),nn.call(n,"hidden")||(n.hidden=!1),nn.call(n,"highlighted")||(n.highlighted=!1),nn.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function p1(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),nn.call(n,"hidden")||(n.hidden=!1),nn.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=Ft(this,t),z(i,"elements",{}),z(i,"canvasContexts",{}),z(i,"webGLContexts",{}),z(i,"pickingLayers",new Set),z(i,"textures",{}),z(i,"frameBuffers",{}),z(i,"activeListeners",{}),z(i,"labelGrid",new Wp),z(i,"nodeDataCache",{}),z(i,"edgeDataCache",{}),z(i,"nodeProgramIndex",{}),z(i,"edgeProgramIndex",{}),z(i,"nodesWithForcedLabels",new Set),z(i,"edgesWithForcedLabels",new Set),z(i,"nodeExtent",{x:[0,1],y:[0,1]}),z(i,"nodeZExtent",[1/0,-1/0]),z(i,"edgeZExtent",[1/0,-1/0]),z(i,"matrix",Bt()),z(i,"invMatrix",Bt()),z(i,"correctionRatio",1),z(i,"customBBox",null),z(i,"normalizationFunction",Zp({x:[0,1],y:[0,1]})),z(i,"graphToViewportRatio",1),z(i,"itemIDsIndex",{}),z(i,"nodeIndices",{}),z(i,"edgeIndices",{}),z(i,"width",0),z(i,"height",0),z(i,"pixelRatio",Gp()),z(i,"pickingDownSizingRatio",2*i.pixelRatio),z(i,"displayedNodeLabels",new Set),z(i,"displayedEdgeLabels",new Set),z(i,"highlightedNodes",new Set),z(i,"hoveredNode",null),z(i,"hoveredEdge",null),z(i,"renderFrame",null),z(i,"renderHighlightedNodesFrame",null),z(i,"needToProcess",!1),z(i,"checkEdgesEventsFrame",null),z(i,"nodePrograms",{}),z(i,"nodeHoverPrograms",{}),z(i,"edgePrograms",{}),i.settings=QN(o),bu(i.settings),KN(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 Hp,i.bindCameraHandlers(),i.mouseCaptor=new i1(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new a1(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ut(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=wu(i,[r].map(ri));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=wu(a,[r].map(ri));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=wu(i,[r].map(ri));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=Ap(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=Cp.apply(void 0,Vp(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=Jr(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=Jr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Jr(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=Jr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",X({},a))};var i=function(s){return function(a){var u=Jr(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=Ap(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=Cp.apply(void 0,Vp(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=WN(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=Zp(this.customBBox||this.nodeExtent);var f=new Hp,h=Kr(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},g={},w={},y=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 j in this.nodePrograms){if(!nn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(p[j]||0),p[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=jp(this.nodeZExtent,function(ce){return r.nodeDataCache[ce].zIndex},b));for(var P=0,J=b.length;P<J;P++){var se=b[P];m[se]=y,w[m[se]]={type:"node",id:se},y++;var be=this.nodeDataCache[se];this.addNodeToProgram(se,m[se],p[be.type]++)}for(var ke={},Ue=i.edges(),F=0,Z=Ue.length;F<Z;F++){var W=Ue[F],Q=this.edgeDataCache[W];ke[Q.type]=(ke[Q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Ue=jp(this.edgeZExtent,function(ce){return r.edgeDataCache[ce].zIndex},Ue));for(var Y in this.edgePrograms){if(!nn.call(this.edgePrograms,Y))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Y,'"!'));this.edgePrograms[Y].reallocate(ke[Y]||0),ke[Y]=0}for(var I=0,R=Ue.length;I<R;I++){var U=Ue[I];g[U]=y,w[g[U]]={type:"edge",id:U},y++;var ie=this.edgeDataCache[U];this.addEdgeToProgram(U,g[U],ke[ie.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=g,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&&ic(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=gr(c.x,2),d=l[0],f=l[1],h=gr(c.y,2),p=h[0],m=h[1],g=[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,y=-1/0,b=1/0,v=-1/0;g.forEach(function(ke){var Ue=ke.x,F=ke.y;w=Math.min(w,Ue),y=Math.max(y,Ue),b=Math.min(b,F),v=Math.max(v,F)});var k=y-w,_=v-b,$=this.getDimensions(),O=$.width,j=$.height,P=0,J=0;if(k>=O?y<O-s?P=y-(O-s):w>s&&(P=w-s):y>O+s?P=y-(O+s):w<-s&&(P=w+s),_>=j?v<j-s?J=v-(j-s):b>s&&(J=b-s):v>j+s?J=v-(j+s):b<-s&&(J=b+s),P||J){var se=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),be=this.viewportToFramedGraph({x:P,y:J},{cameraState:r});P=be.x-se.x,J=be.y-se.y,u.x+=P,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);Bp(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<-Kp||d>this.width+Kp||f<-Jp||f>this.height+Jp)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],g=m?.drawLabel||p;g(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=f1({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Bp(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),g=m.x,w=m.y,y=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:y,x:g,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(g){return r.resetWebGLTexture(g)}),!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=Kr(a,u,c,l),this.invMatrix=Kr(a,u,c,l,!0),this.correctionRatio=qN(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=h1(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=p1(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 Wp,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=JN(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,bu(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),bu(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=Gp(),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)||[],g=0,w=m.length;g<w;g++){var y=m[g];if(this.updateEdge(y),o){var b=this.edgeProgramIndex[y];if(b===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],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),g=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-g.x)*(1-h)+u,y:(m.y-g.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?Kr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=rc(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?Kr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=rc(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}}])})(Qf),g1=m1;function y1(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 $_(e){var t=y1(e,"string");return typeof t=="symbol"?t:t+""}function T_(e,t,n){return(t=$_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yp(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 ps(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Yp(Object(n),!0).forEach(function(r){T_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function v1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b1(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,$_(r.key),r)}}function w1(e,t,n){return t&&b1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ms(e){return ms=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ms(e)}function C_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(C_=function(){return!!e})()}function A_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _1(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 A_(e)}function k1(e,t,n){return t=ms(t),_1(e,C_()?Reflect.construct(t,n||[],ms(e).constructor):t.apply(e,n))}function oc(e,t){return oc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},oc(e,t)}function S1(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&&oc(e,t)}function sc(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 x1(e){if(Array.isArray(e))return sc(e)}function E1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $1(e,t){if(e){if(typeof e=="string")return sc(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)?sc(e,t):void 0}}function T1(){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 _u(e){return x1(e)||E1(e)||$1(e)||T1()}function I_(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 C1(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=I_((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 A1(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 g=!i||a.x<u.x,w=g?a.x:u.x,y=g?a.y:u.y,b=g?u.x:a.x,v=g?u.y:a.y,k=(w+b)/2,_=(y+v)/2,$=b-w,O=v-y,j=Math.sqrt(Math.pow($,2)+Math.pow(O,2)),P=g?1:-1,J=k+O*d*P,se=_-$*d*P,be=s.size*.7+5,ke={x:se-y,y:-(J-w)},Ue=Math.sqrt(Math.pow(ke.x,2)+Math.pow(ke.y,2)),F={x:v-se,y:-(b-J)},Z=Math.sqrt(Math.pow(F.x,2)+Math.pow(F.y,2));w+=be*ke.x/Ue,y+=be*ke.y/Ue,b+=be*F.x/Z,v+=be*F.y/Z,J+=be*O/j,se-=be*$/j;var W={x:J,y:se},Q={x:w,y},Y={x:b,y:v},I=C1(Q,W,Y);if(!(I<a.size+u.size)){var R=o.measureText(m).width,U=I-a.size-u.size;if(R>U){var ie="…";for(m=m+ie,R=o.measureText(m).width;R>U&&m.length>1;)m=m.slice(0,-2)+ie,R=o.measureText(m).width;if(m.length<4)return}for(var ce={},te=0,Ce=m.length;te<Ce;te++){var Ae=m[te];ce[Ae]||(ce[Ae]=o.measureText(Ae).width*(1+d*.35))}for(var L=.5-R/I/2,M=0,q=m.length;M<q;M++){var K=m[M],he=I_(L,Q,W,Y),le=2*(1-L)*(J-w)+2*L*(b-J),Ee=2*(1-L)*(se-y)+2*L*(v-se),Ie=Math.atan2(Ee,le);o.save(),o.translate(he.x,he.y),o.rotate(Ie),o.fillText(K,0,0),o.restore(),L+=ce[K]/I}}}}}function I1(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;
|
|
@@ -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 D1(e,t){return z1(e)||L1(e,t)||
|
|
609
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ku(e){return B1(e)||H1(e)||
|
|
607
|
+
`);return i}var N_=.25,R1={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:N_},R_=WebGLRenderingContext,Xp=R_.UNSIGNED_BYTE,vn=R_.FLOAT;function Va(e){var t=ps(ps({},R1),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(_u(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){S1(l,c);function l(){var d;v1(this,l);for(var f=arguments.length,h=new Array(f),p=0;p<f;p++)h[p]=arguments[p];return d=k1(this,l,[].concat(h)),T_(A_(d),"drawLabel",o||A1(t)),d}return w1(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:N1(t),FRAGMENT_SHADER_SOURCE:I1(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:vn},{name:"a_target",size:2,type:vn}].concat(_u(s?[{name:"a_targetSize",size:1,type:vn}]:[]),_u(a?[{name:"a_sourceSize",size:1,type:vn}]:[]),[{name:"a_thickness",size:1,type:vn},{name:"a_curvature",size:1,type:vn},{name:"a_color",size:4,type:Xp,normalized:!0},{name:"a_id",size:4,type:Xp,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:vn},{name:"a_direction",size:1,type:vn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(f,h,p,m,g){var w,y=g.size||1,b=p.x,v=p.y,k=m.x,_=m.y,$=An(g.color),O=(w=g[i])!==null&&w!==void 0?w:N_,j=this.array;j[h++]=b,j[h++]=v,j[h++]=k,j[h++]=_,s&&(j[h++]=m.size),a&&(j[h++]=p.size),j[h++]=y,j[h++]=O,j[h++]=$,j[h++]=f}},{key:"setUniforms",value:function(f,h){var p=h.gl,m=h.uniformLocations,g=m.u_matrix,w=m.u_pixelRatio,y=m.u_feather,b=m.u_sizeRatio,v=m.u_dimensions,k=m.u_minEdgeThickness;if(p.uniformMatrix3fv(g,!1,f.matrix),p.uniform1f(w,f.pixelRatio),p.uniform1f(b,f.sizeRatio),p.uniform1f(y,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})(Za)}Va();Va({arrowHead:Ha});Va({arrowHead:ps(ps({},Ha),{},{extremity:"both"})});function z1(e){if(Array.isArray(e))return e}function L1(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 ac(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 z_(e,t){if(e){if(typeof e=="string")return ac(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)?ac(e,t):void 0}}function P1(){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 D1(e,t){return z1(e)||L1(e,t)||z_(e,t)||P1()}function O1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function M1(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 L_(e){var t=M1(e,"string");return typeof t=="symbol"?t:t+""}function F1(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,L_(r.key),r)}}function U1(e,t,n){return t&&F1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function gs(e){return gs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},gs(e)}function P_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(P_=function(){return!!e})()}function uc(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function G1(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 uc(e)}function j1(e,t,n){return t=gs(t),G1(e,P_()?Reflect.construct(t,n||[],gs(e).constructor):t.apply(e,n))}function cc(e,t){return cc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},cc(e,t)}function Z1(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&&cc(e,t)}function er(e,t,n){return(t=L_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B1(e){if(Array.isArray(e))return ac(e)}function H1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function V1(){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 ku(e){return B1(e)||H1(e)||z_(e)||V1()}function Qp(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 em(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Qp(Object(n),!0).forEach(function(r){er(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var q1="relative",W1={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},K1="#000000";function J1(e){var t=e.borders,n=Rp(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;
|
|
@@ -716,7 +716,7 @@ void main() {
|
|
|
716
716
|
`),`
|
|
717
717
|
#endif
|
|
718
718
|
}
|
|
719
|
-
`);return n}var P_=WebGLRenderingContext,tm=P_.UNSIGNED_BYTE,qo=P_.FLOAT;function D_(e){var t,n=em(em({},W1),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(ku(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){Z1(u,a);function u(){var c;O1(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=j1(this,u,[].concat(d)),er(uc(c),"drawLabel",i),er(uc(c),"drawHover",o),c}return U1(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Y1(n),FRAGMENT_SHADER_SOURCE:J1(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:qo},{name:"a_id",size:4,type:tm,normalized:!0},{name:"a_size",size:1,type:qo}].concat(ku(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:tm,normalized:!0}]:[]})),ku(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:qo}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:qo}],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++]=An(f[m.attribute]||m.defaultValue||K1))}),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,g=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(g,!1,l.matrix),r.forEach(function(w,y){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(y+1)],k=rN(b.value),_=D1(k,4),$=_[0],O=_[1],j=_[2],P=_[3];f.uniform4f(v,$/255,O/255,j/255,P/255)}})}}]),u})(h_),er(t,"ANGLE_1",0),er(t,"ANGLE_2",2*Math.PI/3),er(t,"ANGLE_3",4*Math.PI/3),t}D_();const ys=.18,X1=500,Q1=2,eR=3,Wo={rest:2,selected:4,expanded:5},tR=6,Su=2,nR=8,nm=6,xu=400,rR=2e3,iR={x:[0,1e3],y:[0,1e3]},Eu=1e3,rm=500,oR={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 Ko(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Wt(e,t=1){return`#${Ko(e.r)}${Ko(e.g)}${Ko(e.b)}${Ko(e.a*t*255)}`}function O_(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 M_(e,t,n=ys){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 F_(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 sR(e,t,n,r=ys){const i=M_(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=O_(t,i,n,a/12);o=Math.min(o,F_(e,s,u)),s=u}return o}function aR(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(L){const M=u.get(L);if(M)return M;a.style.color="",a.style.color=L;const q=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],K={r:q[0]??0,g:q[1]??0,b:q[2]??0,a:q[3]??1};return u.set(L,K),K}const l=L=>c(`var(--cia-graph-${L})`);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(L,M){if(!M.texts?.length||!M.outer)return;const q=M.size/M.outer;L.textAlign="center",L.textBaseline="alphabetic",L.lineJoin="round";for(const K of M.texts){const he=oR[K.kind],le=he.size*q;if(le<nm)continue;L.font=he.font(le);const Ee=M.y+K.y*q;L.lineWidth=4*q,L.strokeStyle=M.haloColor??"#000",L.strokeText(K.text,M.x,Ee),L.fillStyle=K.kind==="role"?M.toneColor??"#fff":K.kind==="address"?M.mutedColor??"#aaa":M.textColor??"#fff",L.fillText(K.text,M.x,Ee)}}const p=()=>{},m=D_({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}),g=Va({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=__({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let y=new Oe({type:"directed",multi:!1,allowSelfLoops:!1});const b=new g1(y,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:L=>L,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:nm,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:g,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(iR);const v=b.getMouseCaptor(),k=b.getTouchCaptor();v.removeAllListeners(),k.removeAllListeners(),v.enabled=!1,k.enabled=!1;const _=new Map;let $=ys;function O(L){const M=t.flags().get(L),q=t.selected();return M?.has("expanded")?{width:Wo.expanded,color:d.expanded}:q?.kind==="node"&&q.id===L||t.highlighted()===L?{width:Wo.selected,color:d.selected}:{width:Wo.rest,color:c(t.colorOf(_.get(L)))}}function j(L,M,q){const K=t.model(),he=t.notes().get(L.id)??null,le=Fr(L,K.checked_address,he),Ee=c(t.colorOf(L)),Ie=O(L.id),fe=le.radius+Ie.width/2,ee=le.ring?le.radius+tR+Su/2:fe,Be=le.ring?Su/ee:0,ut=le.ring?Math.max(0,ee-Su-fe)/ee:0,He=t.selected(),Ve=le.ring||Ie.width!==Wo.rest||He?.kind==="node"&&He.id===L.id;return{x:M.x,y:-M.y,size:ee,label:le.texts.find(pt=>pt.kind==="address")?.text??L.address,color:Wt(Ee),forceLabel:!q||Ve,ringColor:Wt(d.edge),ringSize:Be,gapSize:ut,strokeColor:Wt(Ie.color,he?.5:1),strokeSize:Ie.width/ee,bodyColor:Wt(d.node),dotColor:Wt(Ee),dotSize:le.dot/ee,outer:ee,texts:le.texts,toneColor:Wt(Ee),mutedColor:Wt(d.muted),textColor:Wt(d.text),haloColor:Wt(d.halo)}}function P(L,M){const q=t.selected(),K=q?.kind==="node"?_.get(q.id)?.address??null:null,he=q?.kind==="edge"&&q.id===L.id,le=q?.kind==="edge"?he?Jt.related:Jt.faded:hw(L,K);return{size:he?eR:Q1,color:Wt(c(t.colorOf(M)),le),curvature:$,type:$?"link":"straight"}}function J(){const L=t.model(),M=t.positions(),{width:q,height:K}=t.dimensions();_.clear();for(const fe of L.nodes)_.set(fe.id,fe);const he=L.nodes.length>xu;$=L.edges.length>X1?0:ys;const le=new Oe({type:"directed",multi:!1,allowSelfLoops:!1}),Ee=new Map(L.nodes.map(fe=>[fe.address,fe]));for(const fe of L.nodes)le.addNode(fe.id,j(fe,M[fe.id]??{x:q/2,y:K/2},he));for(const fe of L.edges){const ee=Ee.get(fe.from),Be=Ee.get(fe.to);!ee||!Be||ee.id===Be.id||le.hasEdge(fe.id)||le.hasDirectedEdge(ee.id,Be.id)||le.addDirectedEdgeWithKey(fe.id,ee.id,Be.id,P(fe,ee))}y=le;const Ie=t.selected();ke=[Ie?.kind==="node"?Ie.id:null,t.highlighted()].filter(fe=>!!fe),b.setGraph(y),Z()}function se(){const M=t.model().nodes.length>xu,q=t.positions();y.updateEachNodeAttributes((K,he)=>{const le=_.get(K);return le?j(le,q[K]??{x:he.x,y:-he.y},M):he}),F()}function be(L){const M=L?_.get(L):null;if(!M||!y.hasNode(M.id))return;const q=t.positions()[M.id],K=y.getNodeAttributes(M.id);y.replaceNodeAttributes(M.id,j(M,q??{x:K.x,y:-K.y},t.model().nodes.length>xu))}let ke=[];function Ue(){const L=t.selected(),M=[L?.kind==="node"?L.id:null,t.highlighted()].filter(q=>!!q);for(const q of new Set([...ke,...M]))be(q);ke=M,F()}function F(){const L=t.model(),M=new Map(L.nodes.map(K=>[K.address,K])),q=new Map(L.edges.map(K=>[K.id,K]));y.updateEachEdgeAttributes((K,he)=>{const le=q.get(K),Ee=le&&M.get(le.from);return le&&Ee?P(le,Ee):he})}function Z(){const{width:L,height:M}=t.dimensions(),q=b.getDimensions();if(!q.width||!q.height)return;const K=Math.min(q.width/L,q.height/M),he=t.transform(),le=he.scale*K,Ee=(q.width-L*K)/2+he.x*K,Ie=(q.height-M*K)/2+he.y*K,fe={x:.5,y:.5,ratio:1,angle:0},ee=b.framedGraphToViewport({x:.5,y:.5},{cameraState:fe}),Be=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:fe}).x-ee.x)/.1,ut=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:fe}).y-ee.y)/.1,He=Be/(Eu*le);b.getCamera().setState({ratio:He,angle:0,x:.5-rm/Eu-(Ee-ee.x)*He/Be,y:.5-rm/Eu-(Ie-ee.y)*He/ut})}function W(L){const M=t.transform(),q={x:(L.x-M.x)/M.scale,y:(L.y-M.y)/M.scale},K=t.positions();let he=null,le=1/0;if(y.forEachNode((ee,Be)=>{const ut=K[ee];if(!ut)return;const He=Math.hypot(q.x-ut.x,q.y-ut.y);He<=Be.size+1/M.scale&&He<le&&(he=ee,le=He)}),he)return{kind:"node",id:he};const Ee=nR/M.scale;let Ie=null,fe=1/0;return y.forEachEdge((ee,Be,ut,He)=>{const Ve=K[ut],pt=K[He];if(!Ve||!pt)return;const C=Math.hypot(pt.x-Ve.x,pt.y-Ve.y)*(.5+$)+Ee;if(Math.hypot(q.x-(Ve.x+pt.x)/2,q.y-(Ve.y+pt.y)/2)>C)return;const D=$?sR(q,Ve,pt,$):F_(q,Ve,pt);D<=Ee&&D<fe&&(Ie=ee,fe=D)}),Ie?{kind:"edge",id:Ie}:{kind:"canvas",id:null}}let Q=0,Y=null,I=null;const R=L=>{L.buttons||(I=L,!Q&&(Q=o.requestAnimationFrame(()=>{Q=0;const M=I;if(!M)return;const q=s.getBoundingClientRect(),{width:K,height:he}=t.dimensions(),le=Math.min(q.width/K,q.height/he)||1,Ee=W({x:(M.clientX-q.left-(q.width-K*le)/2)/le,y:(M.clientY-q.top-(q.height-he*le)/2)/le}),Ie=Ee.kind==="canvas"?null:`${Ee.kind}:${Ee.id}`;if(s.style.cursor=Ie?"pointer":"",Ie!==Y){if(Y=Ie,!Ie){n.hideTooltip();return}if(Ee.kind==="node"){const fe=_.get(Ee.id);fe&&n.showTooltip(M,qu(fe))}else{const fe=t.model().edges.find(ee=>ee.id===Ee.id);fe&&n.showTooltip(M,Wu(fe,t.now()))}}})))},U=()=>{Y=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",R),s.addEventListener("pointerleave",U);let ie=null;const ce=L=>{L.preventDefault(),!ie&&(ie=setTimeout(()=>{ie=null,n.lost()},rR))},te=()=>{ie&&clearTimeout(ie),ie=null,n.lost()},Ce=Object.values(b.getCanvases());for(const L of Ce)L.addEventListener("webglcontextlost",ce),L.addEventListener("webglcontextrestored",te);function Ae(){const L=t.positions();let M=null;return y.forEachEdge((q,K,he,le)=>{const Ee=L[he],Ie=L[le];if(!Ee||!Ie||!$)return;const fe=O_(Ee,M_(Ee,Ie,$),Ie,.5);M=M??{x1:fe.x,y1:fe.y,x2:fe.x,y2:fe.y},M.x1=Math.min(M.x1,fe.x),M.y1=Math.min(M.y1,fe.y),M.x2=Math.max(M.x2,fe.x),M.y2=Math.max(M.y2,fe.y)}),M}return{kind:"webgl",surface:s,build:J,geometry(){const L=t.positions();y.updateEachNodeAttributes((M,q)=>{const K=L[M];return K?{...q,x:K.x,y:-K.y}:q},{attributes:["x","y"]}),Z()},moveNode(L){const M=t.positions()[L];M&&y.hasNode(L)&&y.mergeNodeAttributes(L,{x:M.x,y:-M.y})},endMove(){},camera:Z,selection:Ue,flag:L=>be(L),theme(){f(),se()},resize(){b.resize(!0),Z()},pick:W,linkBounds:Ae,destroy(){ie&&clearTimeout(ie),Q&&o.cancelAnimationFrame(Q),s.removeEventListener("pointermove",R),s.removeEventListener("pointerleave",U);for(const L of Ce)L.removeEventListener("webglcontextlost",ce),L.removeEventListener("webglcontextrestored",te);b.kill(),s.remove()}}}I$("webgl",aR);const xo=document.getElementById("view"),U_=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let En={},Jo=jw(document,En,{prefersDark:U_}),qt=null;$w(xo);const Qt=new Df({name:"chain-insights-view",version:"1.0.0"},{});function G_(e){const t=Jo;Jo=jw(document,e,{prefersDark:U_,applyVariables:(n,r)=>C$(n,r),applyFonts:A$}),qt&&Jo!==t&&qt.setTheme(Jo),qt?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function uR(e){qt?.destroy(),qt=null;const t=Wf(Qt.getHostContext(),En);qt=MA(xo,e,{host:Qt,availableDisplayModes:t.availableDisplayModes,displayMode:t.displayMode}),document.documentElement.dataset.view=qt.kind}Qt.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;qt||$w(xo,t?`Loading the graph of ${t}`:"Loading the Chain Insights view")};Qt.ontoolresult=e=>{uR(e)};Qt.ontoolcancelled=()=>{qt||Ga(xo,null,"The tool call was cancelled. Nothing to draw.")};Qt.onhostcontextchanged=e=>{En=Wf(En,e),G_(En)};Qt.onteardown=async()=>(qt?.destroy(),qt=null,{});Qt.onerror=e=>{console.warn("chain-insights-view:",e)};Qt.connect(new sw(window.parent,window.parent)).then(()=>{En=Wf(En,Qt.getHostContext()),G_(En)},e=>{console.warn("chain-insights-view: no host answered",e),Ga(xo,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
|
|
719
|
+
`);return n}var D_=WebGLRenderingContext,tm=D_.UNSIGNED_BYTE,qo=D_.FLOAT;function O_(e){var t,n=em(em({},W1),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(ku(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){Z1(u,a);function u(){var c;O1(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=j1(this,u,[].concat(d)),er(uc(c),"drawLabel",i),er(uc(c),"drawHover",o),c}return U1(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Y1(n),FRAGMENT_SHADER_SOURCE:J1(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:qo},{name:"a_id",size:4,type:tm,normalized:!0},{name:"a_size",size:1,type:qo}].concat(ku(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:tm,normalized:!0}]:[]})),ku(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:qo}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:qo}],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++]=An(f[m.attribute]||m.defaultValue||K1))}),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,g=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(g,!1,l.matrix),r.forEach(function(w,y){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(y+1)],k=rN(b.value),_=D1(k,4),$=_[0],O=_[1],j=_[2],P=_[3];f.uniform4f(v,$/255,O/255,j/255,P/255)}})}}]),u})(p_),er(t,"ANGLE_1",0),er(t,"ANGLE_2",2*Math.PI/3),er(t,"ANGLE_3",4*Math.PI/3),t}O_();const ys=.18,X1=500,Q1=2,eR=3,Wo={rest:2,selected:4,expanded:5},tR=6,Su=2,nR=8,nm=6,xu=400,rR=2e3,iR={x:[0,1e3],y:[0,1e3]},Eu=1e3,rm=500,oR={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 Ko(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Wt(e,t=1){return`#${Ko(e.r)}${Ko(e.g)}${Ko(e.b)}${Ko(e.a*t*255)}`}function M_(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 F_(e,t,n=ys){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 U_(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 sR(e,t,n,r=ys){const i=F_(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=M_(t,i,n,a/12);o=Math.min(o,U_(e,s,u)),s=u}return o}function aR(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(L){const M=u.get(L);if(M)return M;a.style.color="",a.style.color=L;const q=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],K={r:q[0]??0,g:q[1]??0,b:q[2]??0,a:q[3]??1};return u.set(L,K),K}const l=L=>c(`var(--cia-graph-${L})`);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(L,M){if(!M.texts?.length||!M.outer)return;const q=M.size/M.outer;L.textAlign="center",L.textBaseline="alphabetic",L.lineJoin="round";for(const K of M.texts){const he=oR[K.kind],le=he.size*q;if(le<nm)continue;L.font=he.font(le);const Ee=M.y+K.y*q;L.lineWidth=4*q,L.strokeStyle=M.haloColor??"#000",L.strokeText(K.text,M.x,Ee),L.fillStyle=K.kind==="role"?M.toneColor??"#fff":K.kind==="address"?M.mutedColor??"#aaa":M.textColor??"#fff",L.fillText(K.text,M.x,Ee)}}const p=()=>{},m=O_({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}),g=Va({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=k_({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let y=new Oe({type:"directed",multi:!1,allowSelfLoops:!1});const b=new g1(y,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:L=>L,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:nm,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:g,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(iR);const v=b.getMouseCaptor(),k=b.getTouchCaptor();v.removeAllListeners(),k.removeAllListeners(),v.enabled=!1,k.enabled=!1;const _=new Map;let $=ys;function O(L){const M=t.flags().get(L),q=t.selected();return M?.has("expanded")?{width:Wo.expanded,color:d.expanded}:q?.kind==="node"&&q.id===L||t.highlighted()===L?{width:Wo.selected,color:d.selected}:{width:Wo.rest,color:c(t.colorOf(_.get(L)))}}function j(L,M,q){const K=t.model(),he=t.notes().get(L.id)??null,le=Fr(L,K.checked_address,he),Ee=c(t.colorOf(L)),Ie=O(L.id),fe=le.radius+Ie.width/2,ee=le.ring?le.radius+tR+Su/2:fe,Be=le.ring?Su/ee:0,ut=le.ring?Math.max(0,ee-Su-fe)/ee:0,He=t.selected(),Ve=le.ring||Ie.width!==Wo.rest||He?.kind==="node"&&He.id===L.id;return{x:M.x,y:-M.y,size:ee,label:le.texts.find(pt=>pt.kind==="address")?.text??L.address,color:Wt(Ee),forceLabel:!q||Ve,ringColor:Wt(d.edge),ringSize:Be,gapSize:ut,strokeColor:Wt(Ie.color,he?.5:1),strokeSize:Ie.width/ee,bodyColor:Wt(d.node),dotColor:Wt(Ee),dotSize:le.dot/ee,outer:ee,texts:le.texts,toneColor:Wt(Ee),mutedColor:Wt(d.muted),textColor:Wt(d.text),haloColor:Wt(d.halo)}}function P(L,M){const q=t.selected(),K=q?.kind==="node"?_.get(q.id)?.address??null:null,he=q?.kind==="edge"&&q.id===L.id,le=q?.kind==="edge"?he?Jt.related:Jt.faded:hw(L,K);return{size:he?eR:Q1,color:Wt(c(t.colorOf(M)),le),curvature:$,type:$?"link":"straight"}}function J(){const L=t.model(),M=t.positions(),{width:q,height:K}=t.dimensions();_.clear();for(const fe of L.nodes)_.set(fe.id,fe);const he=L.nodes.length>xu;$=L.edges.length>X1?0:ys;const le=new Oe({type:"directed",multi:!1,allowSelfLoops:!1}),Ee=new Map(L.nodes.map(fe=>[fe.address,fe]));for(const fe of L.nodes)le.addNode(fe.id,j(fe,M[fe.id]??{x:q/2,y:K/2},he));for(const fe of L.edges){const ee=Ee.get(fe.from),Be=Ee.get(fe.to);!ee||!Be||ee.id===Be.id||le.hasEdge(fe.id)||le.hasDirectedEdge(ee.id,Be.id)||le.addDirectedEdgeWithKey(fe.id,ee.id,Be.id,P(fe,ee))}y=le;const Ie=t.selected();ke=[Ie?.kind==="node"?Ie.id:null,t.highlighted()].filter(fe=>!!fe),b.setGraph(y),Z()}function se(){const M=t.model().nodes.length>xu,q=t.positions();y.updateEachNodeAttributes((K,he)=>{const le=_.get(K);return le?j(le,q[K]??{x:he.x,y:-he.y},M):he}),F()}function be(L){const M=L?_.get(L):null;if(!M||!y.hasNode(M.id))return;const q=t.positions()[M.id],K=y.getNodeAttributes(M.id);y.replaceNodeAttributes(M.id,j(M,q??{x:K.x,y:-K.y},t.model().nodes.length>xu))}let ke=[];function Ue(){const L=t.selected(),M=[L?.kind==="node"?L.id:null,t.highlighted()].filter(q=>!!q);for(const q of new Set([...ke,...M]))be(q);ke=M,F()}function F(){const L=t.model(),M=new Map(L.nodes.map(K=>[K.address,K])),q=new Map(L.edges.map(K=>[K.id,K]));y.updateEachEdgeAttributes((K,he)=>{const le=q.get(K),Ee=le&&M.get(le.from);return le&&Ee?P(le,Ee):he})}function Z(){const{width:L,height:M}=t.dimensions(),q=b.getDimensions();if(!q.width||!q.height)return;const K=Math.min(q.width/L,q.height/M),he=t.transform(),le=he.scale*K,Ee=(q.width-L*K)/2+he.x*K,Ie=(q.height-M*K)/2+he.y*K,fe={x:.5,y:.5,ratio:1,angle:0},ee=b.framedGraphToViewport({x:.5,y:.5},{cameraState:fe}),Be=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:fe}).x-ee.x)/.1,ut=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:fe}).y-ee.y)/.1,He=Be/(Eu*le);b.getCamera().setState({ratio:He,angle:0,x:.5-rm/Eu-(Ee-ee.x)*He/Be,y:.5-rm/Eu-(Ie-ee.y)*He/ut})}function W(L){const M=t.transform(),q={x:(L.x-M.x)/M.scale,y:(L.y-M.y)/M.scale},K=t.positions();let he=null,le=1/0;if(y.forEachNode((ee,Be)=>{const ut=K[ee];if(!ut)return;const He=Math.hypot(q.x-ut.x,q.y-ut.y);He<=Be.size+1/M.scale&&He<le&&(he=ee,le=He)}),he)return{kind:"node",id:he};const Ee=nR/M.scale;let Ie=null,fe=1/0;return y.forEachEdge((ee,Be,ut,He)=>{const Ve=K[ut],pt=K[He];if(!Ve||!pt)return;const C=Math.hypot(pt.x-Ve.x,pt.y-Ve.y)*(.5+$)+Ee;if(Math.hypot(q.x-(Ve.x+pt.x)/2,q.y-(Ve.y+pt.y)/2)>C)return;const D=$?sR(q,Ve,pt,$):U_(q,Ve,pt);D<=Ee&&D<fe&&(Ie=ee,fe=D)}),Ie?{kind:"edge",id:Ie}:{kind:"canvas",id:null}}let Q=0,Y=null,I=null;const R=L=>{L.buttons||(I=L,!Q&&(Q=o.requestAnimationFrame(()=>{Q=0;const M=I;if(!M)return;const q=s.getBoundingClientRect(),{width:K,height:he}=t.dimensions(),le=Math.min(q.width/K,q.height/he)||1,Ee=W({x:(M.clientX-q.left-(q.width-K*le)/2)/le,y:(M.clientY-q.top-(q.height-he*le)/2)/le}),Ie=Ee.kind==="canvas"?null:`${Ee.kind}:${Ee.id}`;if(s.style.cursor=Ie?"pointer":"",Ie!==Y){if(Y=Ie,!Ie){n.hideTooltip();return}if(Ee.kind==="node"){const fe=_.get(Ee.id);fe&&n.showTooltip(M,qu(fe))}else{const fe=t.model().edges.find(ee=>ee.id===Ee.id);fe&&n.showTooltip(M,Wu(fe,t.now()))}}})))},U=()=>{Y=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",R),s.addEventListener("pointerleave",U);let ie=null;const ce=L=>{L.preventDefault(),!ie&&(ie=setTimeout(()=>{ie=null,n.lost()},rR))},te=()=>{ie&&clearTimeout(ie),ie=null,n.lost()},Ce=Object.values(b.getCanvases());for(const L of Ce)L.addEventListener("webglcontextlost",ce),L.addEventListener("webglcontextrestored",te);function Ae(){const L=t.positions();let M=null;return y.forEachEdge((q,K,he,le)=>{const Ee=L[he],Ie=L[le];if(!Ee||!Ie||!$)return;const fe=M_(Ee,F_(Ee,Ie,$),Ie,.5);M=M??{x1:fe.x,y1:fe.y,x2:fe.x,y2:fe.y},M.x1=Math.min(M.x1,fe.x),M.y1=Math.min(M.y1,fe.y),M.x2=Math.max(M.x2,fe.x),M.y2=Math.max(M.y2,fe.y)}),M}return{kind:"webgl",surface:s,build:J,geometry(){const L=t.positions();y.updateEachNodeAttributes((M,q)=>{const K=L[M];return K?{...q,x:K.x,y:-K.y}:q},{attributes:["x","y"]}),Z()},moveNode(L){const M=t.positions()[L];M&&y.hasNode(L)&&y.mergeNodeAttributes(L,{x:M.x,y:-M.y})},endMove(){},camera:Z,selection:Ue,flag:L=>be(L),theme(){f(),se()},resize(){b.resize(!0),Z()},pick:W,linkBounds:Ae,destroy(){ie&&clearTimeout(ie),Q&&o.cancelAnimationFrame(Q),s.removeEventListener("pointermove",R),s.removeEventListener("pointerleave",U);for(const L of Ce)L.removeEventListener("webglcontextlost",ce),L.removeEventListener("webglcontextrestored",te);b.kill(),s.remove()}}}N$("webgl",aR);const xo=document.getElementById("view"),G_=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let En={},Jo=Zw(document,En,{prefersDark:G_}),qt=null;$w(xo);const Qt=new Df({name:"chain-insights-view",version:"1.0.0"},{});function j_(e){const t=Jo;Jo=Zw(document,e,{prefersDark:G_,applyVariables:(n,r)=>A$(n,r),applyFonts:I$}),qt&&Jo!==t&&qt.setTheme(Jo),qt?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function uR(e){qt?.destroy(),qt=null;const t=Wf(Qt.getHostContext(),En);qt=MA(xo,e,{host:Qt,availableDisplayModes:t.availableDisplayModes,displayMode:t.displayMode}),document.documentElement.dataset.view=qt.kind}Qt.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;qt||$w(xo,t?`Loading the graph of ${t}`:"Loading the Chain Insights view")};Qt.ontoolresult=e=>{uR(e)};Qt.ontoolcancelled=()=>{qt||Ga(xo,null,"The tool call was cancelled. Nothing to draw.")};Qt.onhostcontextchanged=e=>{En=Wf(En,e),j_(En)};Qt.onteardown=async()=>(qt?.destroy(),qt=null,{});Qt.onerror=e=>{console.warn("chain-insights-view:",e)};Qt.connect(new sw(window.parent,window.parent)).then(()=>{En=Wf(En,Qt.getHostContext()),j_(En)},e=>{console.warn("chain-insights-view: no host answered",e),Ga(xo,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
|
|
720
720
|
</script>
|
|
721
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}}
|
|
722
722
|
</style>
|