const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-DrMhJinb.js","assets/index-C4inJ1rU.js","assets/max-Cf6xo70m.js","assets/consumer-registry-BEMotsU4.js","assets/variants-BxtUhUrZ.js","assets/git-branch-Dnk0SYSJ.js","assets/clock-BOSF_clE.js","assets/badge-colors-Dl76Mz8m.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/layers-B_54Ow0Q.js","assets/search-qUivGgU1.js","assets/settings-2-BHdXfxPS.js","assets/rotate-ccw-CGkNWEop.js","assets/chevron-right-CU8UihKL.js","assets/target-C8oxWH8W.js","assets/network-DX08B81j.js","assets/index-DuWodFP7.css"])))=>i.map(i=>d[i]);
var cL=Object.defineProperty;var uL=(i,e,t)=>e in i?cL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>uL(i,typeof e!="symbol"?e+"":e,t);import{e as rp,r as U,_ as m0,br as un,cy as mg,dC as dL,dD as hL,j as f,ay as fL,az as g0,bK as Vl,c as oh,bY as pL,dE as mL,m as ma,a4 as ey,cb as gL,a6 as gg,dF as PS,dG as jh,dH as NS,aq as hd,dI as _L,dJ as yL,d as Jc,dK as bL,aN as vL,dL as xL,dM as wL,dN as SL,dO as EL,dP as CL,dQ as TL,dR as kL,aa as AL,cS as IL,dS as LL,V as Ge,Z as Xt,dT as _0,$ as Bi,ar as be,cu as RL,dU as PL,dB as NL,R as _g,d7 as fd,aA as y0,dV as DL,aB as Pc,dW as ML,a$ as BL,dX as OL,dY as FL,B as ty,c4 as zL,a5 as UL,a7 as $L,dZ as jL}from"./index-C4inJ1rU.js";import{m as b0,t as yg,a as HL,b as VL,e as Rn,u as GL,G as WL,c as YL,E as qL}from"./max-Cf6xo70m.js";import{u as XL,r as KL,f as v0,g as ZL,e as QL}from"./consumer-registry-BEMotsU4.js";import{s as JL,M as DS,a as x0,b as iy}from"./variants-BxtUhUrZ.js";import{G as Wp}from"./git-branch-Dnk0SYSJ.js";import{C as eR}from"./clock-BOSF_clE.js";import{N as tR,a as iR}from"./badge-colors-Dl76Mz8m.js";import{e as nR,f as w0,g as sR}from"./meshcore-tx-constants-DgpFTAmf.js";import{L as S0}from"./layers-B_54Ow0Q.js";import{S as E0}from"./search-qUivGgU1.js";import{S as C0}from"./settings-2-BHdXfxPS.js";import{R as T0}from"./rotate-ccw-CGkNWEop.js";import{C as Yp}from"./chevron-right-CU8UihKL.js";import{T as rR}from"./target-C8oxWH8W.js";import{N as MS}from"./network-DX08B81j.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oR=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],aR=rp("arrow-right-left",oR);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lR=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],cR=rp("focus",lR);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const uR=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],dR=rp("group",uR);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const hR=[["path",{d:"M3.704 14.467A10 8 0 0 1 2 10a10 8 0 0 1 20 0 10 8 0 0 1-10 8 10 8 0 0 1-5.181-1.158",key:"1yant3"}],["path",{d:"M7 22a5 5 0 0 1-2-3.994",key:"1xp6a4"}],["circle",{cx:"5",cy:"16",r:"2",key:"18csp3"}]],BS=rp("lasso",hR);function ll(i,e){return i==null||e==null?NaN:i<e?-1:i>e?1:i>=e?0:NaN}function fR(i,e){return i==null||e==null?NaN:e<i?-1:e>i?1:e>=i?0:NaN}function ny(i){let e,t,n;i.length!==2?(e=ll,t=(a,l)=>ll(i(a),l),n=(a,l)=>i(a)-l):(e=i===ll||i===fR?i:pR,t=i,n=i);function s(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const d=c+u>>>1;t(a[d],l)<0?c=d+1:u=d}while(c<u)}return c}function r(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const d=c+u>>>1;t(a[d],l)<=0?c=d+1:u=d}while(c<u)}return c}function o(a,l,c=0,u=a.length){const d=s(a,l,c,u-1);return d>c&&n(a[d-1],l)>-n(a[d],l)?d-1:d}return{left:s,center:o,right:r}}function pR(){return 0}function mR(i){return i===null?NaN:+i}function*gR(i,e){for(let t of i)t!=null&&(t=+t)>=t&&(yield t)}const _R=ny(ll),OS=_R.right;ny(mR).center;class k0 extends Map{constructor(e,t=vR){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[n,s]of e)this.set(n,s)}get(e){return super.get(A0(this,e))}has(e){return super.has(A0(this,e))}set(e,t){return super.set(yR(this,e),t)}delete(e){return super.delete(bR(this,e))}}function A0({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):t}function yR({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):(i.set(n,t),t)}function bR({_intern:i,_key:e},t){const n=e(t);return i.has(n)&&(t=i.get(n),i.delete(n)),t}function vR(i){return i!==null&&typeof i=="object"?i.valueOf():i}function xR(i=ll){if(i===ll)return FS;if(typeof i!="function")throw new TypeError("compare is not a function");return(e,t)=>{const n=i(e,t);return n||n===0?n:(i(t,t)===0)-(i(e,e)===0)}}function FS(i,e){return(i==null||!(i>=i))-(e==null||!(e>=e))||(i<e?-1:i>e?1:0)}function I0(i,e){let t;for(const n of i)n!=null&&(t>n||t===void 0&&n>=n)&&(t=n);return t}function zS(i,e,t=0,n=1/0,s){if(e=Math.floor(e),t=Math.floor(Math.max(0,t)),n=Math.floor(Math.min(i.length-1,n)),!(t<=e&&e<=n))return i;for(s=s===void 0?FS:xR(s);n>t;){if(n-t>600){const l=n-t+1,c=e-t+1,u=Math.log(l),d=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),p=Math.max(t,Math.floor(e-c*d/l+h)),m=Math.min(n,Math.floor(e+(l-c)*d/l+h));zS(i,e,p,m,s)}const r=i[e];let o=t,a=n;for(oc(i,t,e),s(i[n],r)>0&&oc(i,t,n);o<a;){for(oc(i,o,a),++o,--a;s(i[o],r)<0;)++o;for(;s(i[a],r)>0;)--a}s(i[t],r)===0?oc(i,t,a):(++a,oc(i,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}return i}function oc(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function El(i,e,t){if(i=Float64Array.from(gR(i)),!(!(n=i.length)||isNaN(e=+e))){if(e<=0||n<2)return I0(i);if(e>=1)return b0(i);var n,s=(n-1)*e,r=Math.floor(s),o=b0(zS(i,r).subarray(0,r+1)),a=I0(i.subarray(r+1));return o+(a-o)*(s-r)}}const wR=U.createContext(null);function sy(){return U.useContext(wR)}var SR=Object.defineProperty,ER=(i,e,t)=>e in i?SR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,$=(i,e,t)=>ER(i,typeof e!="symbol"?e+"":e,t),bg="http://www.w3.org/1999/xhtml";const L0={svg:"http://www.w3.org/2000/svg",xhtml:bg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function op(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),L0.hasOwnProperty(e)?{space:L0[e],local:i}:i}function CR(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bg&&e.documentElement.namespaceURI===bg?e.createElement(i):e.createElementNS(t,i)}}function TR(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function US(i){var e=op(i);return(e.local?TR:CR)(e)}function kR(){}function ry(i){return i==null?kR:function(){return this.querySelector(i)}}function AR(i){typeof i!="function"&&(i=ry(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=new Array(o),l,c,u=0;u<o;++u)(l=r[u])&&(c=i.call(l,l.__data__,u,r))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new Yn(n,this._parents)}function IR(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function LR(){return[]}function $S(i){return i==null?LR:function(){return this.querySelectorAll(i)}}function RR(i){return function(){return IR(i.apply(this,arguments))}}function PR(i){typeof i=="function"?i=RR(i):i=$S(i);for(var e=this._groups,t=e.length,n=[],s=[],r=0;r<t;++r)for(var o=e[r],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(n.push(i.call(l,l.__data__,c,o)),s.push(l));return new Yn(n,s)}function jS(i){return function(){return this.matches(i)}}function HS(i){return function(e){return e.matches(i)}}var NR=Array.prototype.find;function DR(i){return function(){return NR.call(this.children,i)}}function MR(){return this.firstElementChild}function BR(i){return this.select(i==null?MR:DR(typeof i=="function"?i:HS(i)))}var OR=Array.prototype.filter;function FR(){return Array.from(this.children)}function zR(i){return function(){return OR.call(this.children,i)}}function UR(i){return this.selectAll(i==null?FR:zR(typeof i=="function"?i:HS(i)))}function $R(i){typeof i!="function"&&(i=jS(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&i.call(l,l.__data__,c,r)&&a.push(l);return new Yn(n,this._parents)}function VS(i){return new Array(i.length)}function jR(){return new Yn(this._enter||this._groups.map(VS),this._parents)}function Hh(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}Hh.prototype={constructor:Hh,appendChild:function(i){return this._parent.insertBefore(i,this._next)},insertBefore:function(i,e){return this._parent.insertBefore(i,e)},querySelector:function(i){return this._parent.querySelector(i)},querySelectorAll:function(i){return this._parent.querySelectorAll(i)}};function HR(i){return function(){return i}}function VR(i,e,t,n,s,r){for(var o=0,a,l=e.length,c=r.length;o<c;++o)(a=e[o])?(a.__data__=r[o],n[o]=a):t[o]=new Hh(i,r[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function GR(i,e,t,n,s,r,o){var a,l,c=new Map,u=e.length,d=r.length,h=new Array(u),p;for(a=0;a<u;++a)(l=e[a])&&(h[a]=p=o.call(l,l.__data__,a,e)+"",c.has(p)?s[a]=l:c.set(p,l));for(a=0;a<d;++a)p=o.call(i,r[a],a,r)+"",(l=c.get(p))?(n[a]=l,l.__data__=r[a],c.delete(p)):t[a]=new Hh(i,r[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(h[a])===l&&(s[a]=l)}function WR(i){return i.__data__}function YR(i,e){if(!arguments.length)return Array.from(this,WR);var t=e?GR:VR,n=this._parents,s=this._groups;typeof i!="function"&&(i=HR(i));for(var r=s.length,o=new Array(r),a=new Array(r),l=new Array(r),c=0;c<r;++c){var u=n[c],d=s[c],h=d.length,p=qR(i.call(u,u&&u.__data__,c,n)),m=p.length,y=a[c]=new Array(m),g=o[c]=new Array(m),_=l[c]=new Array(h);t(u,d,y,g,_,p,e);for(var S=0,E=0,x,T;S<m;++S)if(x=y[S]){for(S>=E&&(E=S+1);!(T=g[E])&&++E<m;);x._next=T||null}}return o=new Yn(o,n),o._enter=a,o._exit=l,o}function qR(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function XR(){return new Yn(this._exit||this._groups.map(VS),this._parents)}function KR(i,e,t){var n=this.enter(),s=this,r=this.exit();return typeof i=="function"?(n=i(n),n&&(n=n.selection())):n=n.append(i+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?r.remove():t(r),n&&s?n.merge(s).order():s}function ZR(i){for(var e=i.selection?i.selection():i,t=this._groups,n=e._groups,s=t.length,r=n.length,o=Math.min(s,r),a=new Array(s),l=0;l<o;++l)for(var c=t[l],u=n[l],d=c.length,h=a[l]=new Array(d),p,m=0;m<d;++m)(p=c[m]||u[m])&&(h[m]=p);for(;l<s;++l)a[l]=t[l];return new Yn(a,this._parents)}function QR(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var n=i[e],s=n.length-1,r=n[s],o;--s>=0;)(o=n[s])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function JR(i){i||(i=e4);function e(d,h){return d&&h?i(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r){for(var o=t[r],a=o.length,l=s[r]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new Yn(s,this._parents).order()}function e4(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function t4(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function i4(){return Array.from(this)}function n4(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,r=n.length;s<r;++s){var o=n[s];if(o)return o}return null}function s4(){let i=0;for(const e of this)++i;return i}function r4(){return!this.node()}function o4(i){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,o=s.length,a;r<o;++r)(a=s[r])&&i.call(a,a.__data__,r,s);return this}function a4(i){return function(){this.removeAttribute(i)}}function l4(i){return function(){this.removeAttributeNS(i.space,i.local)}}function c4(i,e){return function(){this.setAttribute(i,e)}}function u4(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function d4(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function h4(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(i.space,i.local):this.setAttributeNS(i.space,i.local,t)}}function f4(i,e){var t=op(i);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?l4:a4:typeof e=="function"?t.local?h4:d4:t.local?u4:c4)(t,e))}function GS(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function p4(i){return function(){this.style.removeProperty(i)}}function m4(i,e,t){return function(){this.style.setProperty(i,e,t)}}function g4(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function _4(i,e,t){return arguments.length>1?this.each((e==null?p4:typeof e=="function"?g4:m4)(i,e,t??"")):Cl(this.node(),i)}function Cl(i,e){return i.style.getPropertyValue(e)||GS(i).getComputedStyle(i,null).getPropertyValue(e)}function y4(i){return function(){delete this[i]}}function b4(i,e){return function(){this[i]=e}}function v4(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function x4(i,e){return arguments.length>1?this.each((e==null?y4:typeof e=="function"?v4:b4)(i,e)):this.node()[i]}function WS(i){return i.trim().split(/^|\s+/)}function oy(i){return i.classList||new YS(i)}function YS(i){this._node=i,this._names=WS(i.getAttribute("class")||"")}YS.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function qS(i,e){for(var t=oy(i),n=-1,s=e.length;++n<s;)t.add(e[n])}function XS(i,e){for(var t=oy(i),n=-1,s=e.length;++n<s;)t.remove(e[n])}function w4(i){return function(){qS(this,i)}}function S4(i){return function(){XS(this,i)}}function E4(i,e){return function(){(e.apply(this,arguments)?qS:XS)(this,i)}}function C4(i,e){var t=WS(i+"");if(arguments.length<2){for(var n=oy(this.node()),s=-1,r=t.length;++s<r;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?E4:e?w4:S4)(t,e))}function T4(){this.textContent=""}function k4(i){return function(){this.textContent=i}}function A4(i){return function(){var e=i.apply(this,arguments);this.textContent=e??""}}function I4(i){return arguments.length?this.each(i==null?T4:(typeof i=="function"?A4:k4)(i)):this.node().textContent}function L4(){this.innerHTML=""}function R4(i){return function(){this.innerHTML=i}}function P4(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e??""}}function N4(i){return arguments.length?this.each(i==null?L4:(typeof i=="function"?P4:R4)(i)):this.node().innerHTML}function D4(){this.nextSibling&&this.parentNode.appendChild(this)}function M4(){return this.each(D4)}function B4(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function O4(){return this.each(B4)}function F4(i){var e=typeof i=="function"?i:US(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function z4(){return null}function U4(i,e){var t=typeof i=="function"?i:US(i),n=e==null?z4:typeof e=="function"?e:ry(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function $4(){var i=this.parentNode;i&&i.removeChild(this)}function j4(){return this.each($4)}function H4(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function V4(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function G4(i){return this.select(i?V4:H4)}function W4(i){return arguments.length?this.property("__data__",i):this.node().__data__}function Y4(i){return function(e){i.call(this,e,this.__data__)}}function q4(i){return i.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function X4(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,r;t<s;++t)r=e[t],(!i.type||r.type===i.type)&&r.name===i.name?this.removeEventListener(r.type,r.listener,r.options):e[++n]=r;++n?e.length=n:delete this.__on}}}function K4(i,e,t){return function(){var n=this.__on,s,r=Y4(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===i.type&&s.name===i.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=t),s.value=e;return}}this.addEventListener(i.type,r,t),s={type:i.type,name:i.name,value:e,listener:r,options:t},n?n.push(s):this.__on=[s]}}function Z4(i,e,t){var n=q4(i+""),s,r=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(s=0,u=a[l];s<r;++s)if((o=n[s]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?K4:X4,s=0;s<r;++s)this.each(a(n[s],e,t));return this}function KS(i,e,t){var n=GS(i),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),i.dispatchEvent(s)}function Q4(i,e){return function(){return KS(this,i,e)}}function J4(i,e){return function(){return KS(this,i,e.apply(this,arguments))}}function e5(i,e){return this.each((typeof e=="function"?J4:Q4)(i,e))}function*t5(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,r=n.length,o;s<r;++s)(o=n[s])&&(yield o)}var ZS=[null];function Yn(i,e){this._groups=i,this._parents=e}function ju(){return new Yn([[document.documentElement]],ZS)}function i5(){return this}Yn.prototype=ju.prototype={constructor:Yn,select:AR,selectAll:PR,selectChild:BR,selectChildren:UR,filter:$R,data:YR,enter:jR,exit:XR,join:KR,merge:ZR,selection:i5,order:QR,sort:JR,call:t4,nodes:i4,node:n4,size:s4,empty:r4,each:o4,attr:f4,style:_4,property:x4,classed:C4,text:I4,html:N4,raise:M4,lower:O4,append:F4,insert:U4,remove:j4,clone:G4,datum:W4,on:Z4,dispatch:e5,[Symbol.iterator]:t5};function wi(i){return typeof i=="string"?new Yn([[document.querySelector(i)]],[document.documentElement]):new Yn([[i]],ZS)}function n5(i){let e;for(;e=i.sourceEvent;)i=e;return i}function Yr(i,e){if(i=n5(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=i.clientX,n.y=i.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[i.clientX-s.left-e.clientLeft,i.clientY-s.top-e.clientTop]}}return[i.pageX,i.pageY]}var s5={value:()=>{}};function ap(){for(var i=0,e=arguments.length,t={},n;i<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new ah(t)}function ah(i){this._=i}function r5(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}ah.prototype=ap.prototype={constructor:ah,on:function(i,e){var t=this._,n=r5(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(i=n[r]).type)&&(s=o5(t[s],i.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<o;)if(s=(i=n[r]).type)t[s]=R0(t[s],i.name,e);else if(e==null)for(s in t)t[s]=R0(t[s],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new ah(i)},call:function(i,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,r;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(r=this._[i],n=0,s=r.length;n<s;++n)r[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],s=0,r=n.length;s<r;++s)n[s].value.apply(e,t)}};function o5(i,e){for(var t=0,n=i.length,s;t<n;++t)if((s=i[t]).name===e)return s.value}function R0(i,e,t){for(var n=0,s=i.length;n<s;++n)if(i[n].name===e){i[n]=s5,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var Tl=0,Nc=0,ac=0,QS=1e3,Vh,Dc,Gh=0,ga=0,lp=0,du=typeof performance=="object"&&performance.now?performance:Date,JS=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function ay(){return ga||(JS(a5),ga=du.now()+lp)}function a5(){ga=0}function Wh(){this._call=this._time=this._next=null}Wh.prototype=e2.prototype={constructor:Wh,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?ay():+t)+(e==null?0:+e),!this._next&&Dc!==this&&(Dc?Dc._next=this:Vh=this,Dc=this),this._call=i,this._time=t,vg()},stop:function(){this._call&&(this._call=null,this._time=1/0,vg())}};function e2(i,e,t){var n=new Wh;return n.restart(i,e,t),n}function l5(){ay(),++Tl;for(var i=Vh,e;i;)(e=ga-i._time)>=0&&i._call.call(null,e),i=i._next;--Tl}function P0(){ga=(Gh=du.now())+lp,Tl=Nc=0;try{l5()}finally{Tl=0,u5(),ga=0}}function c5(){var i=du.now(),e=i-Gh;e>QS&&(lp-=e,Gh=i)}function u5(){for(var i,e=Vh,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:Vh=t);Dc=i,vg(n)}function vg(i){if(!Tl){Nc&&(Nc=clearTimeout(Nc));var e=i-ga;e>24?(i<1/0&&(Nc=setTimeout(P0,i-du.now()-lp)),ac&&(ac=clearInterval(ac))):(ac||(Gh=du.now(),ac=setInterval(c5,QS)),Tl=1,JS(P0))}}function N0(i,e,t){var n=new Wh;return e=e==null?0:+e,n.restart(s=>{n.stop(),i(s+e)},e,t),n}var d5=ap("start","end","cancel","interrupt"),h5=[],t2=0,D0=1,xg=2,lh=3,M0=4,wg=5,ch=6;function cp(i,e,t,n,s,r){var o=i.__transition;if(!o)i.__transition={};else if(t in o)return;f5(i,t,{name:e,index:n,group:s,on:d5,tween:h5,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:t2})}function ly(i,e){var t=Gs(i,e);if(t.state>t2)throw new Error("too late; already scheduled");return t}function kr(i,e){var t=Gs(i,e);if(t.state>lh)throw new Error("too late; already running");return t}function Gs(i,e){var t=i.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function f5(i,e,t){var n=i.__transition,s;n[e]=t,t.timer=e2(r,0,t.time);function r(c){t.state=D0,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,d,h,p;if(t.state!==D0)return l();for(u in n)if(p=n[u],p.name===t.name){if(p.state===lh)return N0(o);p.state===M0?(p.state=ch,p.timer.stop(),p.on.call("interrupt",i,i.__data__,p.index,p.group),delete n[u]):+u<e&&(p.state=ch,p.timer.stop(),p.on.call("cancel",i,i.__data__,p.index,p.group),delete n[u])}if(N0(function(){t.state===lh&&(t.state=M0,t.timer.restart(a,t.delay,t.time),a(c))}),t.state=xg,t.on.call("start",i,i.__data__,t.index,t.group),t.state===xg){for(t.state=lh,s=new Array(h=t.tween.length),u=0,d=-1;u<h;++u)(p=t.tween[u].value.call(i,i.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function a(c){for(var u=c<t.duration?t.ease.call(null,c/t.duration):(t.timer.restart(l),t.state=wg,1),d=-1,h=s.length;++d<h;)s[d].call(i,u);t.state===wg&&(t.on.call("end",i,i.__data__,t.index,t.group),l())}function l(){t.state=ch,t.timer.stop(),delete n[e];for(var c in n)return;delete i.__transition}}function uh(i,e){var t=i.__transition,n,s,r=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){r=!1;continue}s=n.state>xg&&n.state<wg,n.state=ch,n.timer.stop(),n.on.call(s?"interrupt":"cancel",i,i.__data__,n.index,n.group),delete t[o]}r&&delete i.__transition}}function p5(i){return this.each(function(){uh(this,i)})}function cy(i,e,t){i.prototype=e.prototype=t,t.constructor=i}function i2(i,e){var t=Object.create(i.prototype);for(var n in e)t[n]=e[n];return t}function Hu(){}var hu=.7,Yh=1/hu,cl="\\s*([+-]?\\d+)\\s*",fu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",m5=/^#([0-9a-f]{3,8})$/,g5=new RegExp(`^rgb\\(${cl},${cl},${cl}\\)$`),_5=new RegExp(`^rgb\\(${xr},${xr},${xr}\\)$`),y5=new RegExp(`^rgba\\(${cl},${cl},${cl},${fu}\\)$`),b5=new RegExp(`^rgba\\(${xr},${xr},${xr},${fu}\\)$`),v5=new RegExp(`^hsl\\(${fu},${xr},${xr}\\)$`),x5=new RegExp(`^hsla\\(${fu},${xr},${xr},${fu}\\)$`),B0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};cy(Hu,jo,{copy(i){return Object.assign(new this.constructor,this,i)},displayable(){return this.rgb().displayable()},hex:O0,formatHex:O0,formatHex8:w5,formatHsl:S5,formatRgb:F0,toString:F0});function O0(){return this.rgb().formatHex()}function w5(){return this.rgb().formatHex8()}function S5(){return n2(this).formatHsl()}function F0(){return this.rgb().formatRgb()}function jo(i){var e,t;return i=(i+"").trim().toLowerCase(),(e=m5.exec(i))?(t=e[1].length,e=parseInt(e[1],16),t===6?z0(e):t===3?new In(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?pd(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?pd(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=g5.exec(i))?new In(e[1],e[2],e[3],1):(e=_5.exec(i))?new In(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=y5.exec(i))?pd(e[1],e[2],e[3],e[4]):(e=b5.exec(i))?pd(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=v5.exec(i))?j0(e[1],e[2]/100,e[3]/100,1):(e=x5.exec(i))?j0(e[1],e[2]/100,e[3]/100,e[4]):B0.hasOwnProperty(i)?z0(B0[i]):i==="transparent"?new In(NaN,NaN,NaN,0):null}function z0(i){return new In(i>>16&255,i>>8&255,i&255,1)}function pd(i,e,t,n){return n<=0&&(i=e=t=NaN),new In(i,e,t,n)}function E5(i){return i instanceof Hu||(i=jo(i)),i?(i=i.rgb(),new In(i.r,i.g,i.b,i.opacity)):new In}function Sg(i,e,t,n){return arguments.length===1?E5(i):new In(i,e,t,n??1)}function In(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}cy(In,Sg,i2(Hu,{brighter(i){return i=i==null?Yh:Math.pow(Yh,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?hu:Math.pow(hu,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new In(ca(this.r),ca(this.g),ca(this.b),qh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:U0,formatHex:U0,formatHex8:C5,formatRgb:$0,toString:$0}));function U0(){return`#${ra(this.r)}${ra(this.g)}${ra(this.b)}`}function C5(){return`#${ra(this.r)}${ra(this.g)}${ra(this.b)}${ra((isNaN(this.opacity)?1:this.opacity)*255)}`}function $0(){const i=qh(this.opacity);return`${i===1?"rgb(":"rgba("}${ca(this.r)}, ${ca(this.g)}, ${ca(this.b)}${i===1?")":`, ${i})`}`}function qh(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function ca(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function ra(i){return i=ca(i),(i<16?"0":"")+i.toString(16)}function j0(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Us(i,e,t,n)}function n2(i){if(i instanceof Us)return new Us(i.h,i.s,i.l,i.opacity);if(i instanceof Hu||(i=jo(i)),!i)return new Us;if(i instanceof Us)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=NaN,a=r-s,l=(r+s)/2;return a?(e===r?o=(t-n)/a+(t<n)*6:t===r?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?r+s:2-r-s,o*=60):a=l>0&&l<1?0:o,new Us(o,a,l,i.opacity)}function T5(i,e,t,n){return arguments.length===1?n2(i):new Us(i,e,t,n??1)}function Us(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}cy(Us,T5,i2(Hu,{brighter(i){return i=i==null?Yh:Math.pow(Yh,i),new Us(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?hu:Math.pow(hu,i),new Us(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new In(qp(i>=240?i-240:i+120,s,n),qp(i,s,n),qp(i<120?i+240:i-120,s,n),this.opacity)},clamp(){return new Us(H0(this.h),md(this.s),md(this.l),qh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=qh(this.opacity);return`${i===1?"hsl(":"hsla("}${H0(this.h)}, ${md(this.s)*100}%, ${md(this.l)*100}%${i===1?")":`, ${i})`}`}}));function H0(i){return i=(i||0)%360,i<0?i+360:i}function md(i){return Math.max(0,Math.min(1,i||0))}function qp(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const uy=i=>()=>i;function k5(i,e){return function(t){return i+t*e}}function A5(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function I5(i){return(i=+i)==1?s2:function(e,t){return t-e?A5(e,t,i):uy(isNaN(e)?t:e)}}function s2(i,e){var t=e-i;return t?k5(i,t):uy(isNaN(i)?e:i)}const Xh=(function i(e){var t=I5(e);function n(s,r){var o=t((s=Sg(s)).r,(r=Sg(r)).r),a=t(s.g,r.g),l=t(s.b,r.b),c=s2(s.opacity,r.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return n.gamma=i,n})(1);function L5(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),s;return function(r){for(s=0;s<t;++s)n[s]=i[s]*(1-r)+e[s]*r;return n}}function R5(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function P5(i,e){var t=e?e.length:0,n=i?Math.min(t,i.length):0,s=new Array(n),r=new Array(t),o;for(o=0;o<n;++o)s[o]=dy(i[o],e[o]);for(;o<t;++o)r[o]=e[o];return function(a){for(o=0;o<n;++o)r[o]=s[o](a);return r}}function N5(i,e){var t=new Date;return i=+i,e=+e,function(n){return t.setTime(i*(1-n)+e*n),t}}function Fs(i,e){return i=+i,e=+e,function(t){return i*(1-t)+e*t}}function D5(i,e){var t={},n={},s;(i===null||typeof i!="object")&&(i={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in i?t[s]=dy(i[s],e[s]):n[s]=e[s];return function(r){for(s in t)n[s]=t[s](r);return n}}var Eg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xp=new RegExp(Eg.source,"g");function M5(i){return function(){return i}}function B5(i){return function(e){return i(e)+""}}function r2(i,e){var t=Eg.lastIndex=Xp.lastIndex=0,n,s,r,o=-1,a=[],l=[];for(i=i+"",e=e+"";(n=Eg.exec(i))&&(s=Xp.exec(e));)(r=s.index)>t&&(r=e.slice(t,r),a[o]?a[o]+=r:a[++o]=r),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:Fs(n,s)})),t=Xp.lastIndex;return t<e.length&&(r=e.slice(t),a[o]?a[o]+=r:a[++o]=r),a.length<2?l[0]?B5(l[0].x):M5(e):(e=l.length,function(c){for(var u=0,d;u<e;++u)a[(d=l[u]).i]=d.x(c);return a.join("")})}function dy(i,e){var t=typeof e,n;return e==null||t==="boolean"?uy(e):(t==="number"?Fs:t==="string"?(n=jo(e))?(e=n,Xh):r2:e instanceof jo?Xh:e instanceof Date?N5:R5(e)?L5:Array.isArray(e)?P5:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?D5:Fs)(i,e)}function O5(i,e){return i=+i,e=+e,function(t){return Math.round(i*(1-t)+e*t)}}var V0=180/Math.PI,o2={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function a2(i,e,t,n,s,r){var o,a,l;return(o=Math.sqrt(i*i+e*e))&&(i/=o,e/=o),(l=i*t+e*n)&&(t-=i*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),i*n<e*t&&(i=-i,e=-e,l=-l,o=-o),{translateX:s,translateY:r,rotate:Math.atan2(e,i)*V0,skewX:Math.atan(l)*V0,scaleX:o,scaleY:a}}var gd;function F5(i){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(i+"");return e.isIdentity?o2:a2(e.a,e.b,e.c,e.d,e.e,e.f)}function z5(i){return i==null||(gd||(gd=document.createElementNS("http://www.w3.org/2000/svg","g")),gd.setAttribute("transform",i),!(i=gd.transform.baseVal.consolidate()))?o2:(i=i.matrix,a2(i.a,i.b,i.c,i.d,i.e,i.f))}function l2(i,e,t,n){function s(c){return c.length?c.pop()+" ":""}function r(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push("translate(",null,e,null,t);m.push({i:y-4,x:Fs(c,d)},{i:y-2,x:Fs(u,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(c,u,d,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:Fs(c,u)})):u&&d.push(s(d)+"rotate("+u+n)}function a(c,u,d,h){c!==u?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:Fs(c,u)}):u&&d.push(s(d)+"skewX("+u+n)}function l(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push(s(p)+"scale(",null,",",null,")");m.push({i:y-4,x:Fs(c,d)},{i:y-2,x:Fs(u,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=i(c),u=i(u),r(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var m=-1,y=h.length,g;++m<y;)d[(g=h[m]).i]=g.x(p);return d.join("")}}}var U5=l2(F5,"px, ","px)","deg)"),$5=l2(z5,", ",")",")"),j5=1e-12;function G0(i){return((i=Math.exp(i))+1/i)/2}function H5(i){return((i=Math.exp(i))-1/i)/2}function V5(i){return((i=Math.exp(2*i))-1)/(i+1)}const G5=(function i(e,t,n){function s(r,o){var a=r[0],l=r[1],c=r[2],u=o[0],d=o[1],h=o[2],p=u-a,m=d-l,y=p*p+m*m,g,_;if(y<j5)_=Math.log(h/c)/e,g=function(O){return[a+O*p,l+O*m,c*Math.exp(e*O*_)]};else{var S=Math.sqrt(y),E=(h*h-c*c+n*y)/(2*c*t*S),x=(h*h-c*c-n*y)/(2*h*t*S),T=Math.log(Math.sqrt(E*E+1)-E),I=Math.log(Math.sqrt(x*x+1)-x);_=(I-T)/e,g=function(O){var H=O*_,Q=G0(T),re=c/(t*S)*(Q*V5(e*H+T)-H5(T));return[a+re*p,l+re*m,c*Q/G0(e*H+T)]}}return g.duration=_*1e3*e/Math.SQRT2,g}return s.rho=function(r){var o=Math.max(.001,+r),a=o*o,l=a*a;return i(o,a,l)},s})(Math.SQRT2,2,4);function W5(i,e){var t,n;return function(){var s=kr(this,i),r=s.tween;if(r!==t){n=t=r;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function Y5(i,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var r=kr(this,i),o=r.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,c=s.length;l<c;++l)if(s[l].name===e){s[l]=a;break}l===c&&s.push(a)}r.tween=s}}function q5(i,e){var t=this._id;if(i+="",arguments.length<2){for(var n=Gs(this.node(),t).tween,s=0,r=n.length,o;s<r;++s)if((o=n[s]).name===i)return o.value;return null}return this.each((e==null?W5:Y5)(t,i,e))}function hy(i,e,t){var n=i._id;return i.each(function(){var s=kr(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Gs(s,n).value[e]}}function c2(i,e){var t;return(typeof e=="number"?Fs:e instanceof jo?Xh:(t=jo(e))?(e=t,Xh):r2)(i,e)}function X5(i){return function(){this.removeAttribute(i)}}function K5(i){return function(){this.removeAttributeNS(i.space,i.local)}}function Z5(i,e,t){var n,s=t+"",r;return function(){var o=this.getAttribute(i);return o===s?null:o===n?r:r=e(n=o,t)}}function Q5(i,e,t){var n,s=t+"",r;return function(){var o=this.getAttributeNS(i.space,i.local);return o===s?null:o===n?r:r=e(n=o,t)}}function J5(i,e,t){var n,s,r;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(i):(o=this.getAttribute(i),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function eP(i,e,t){var n,s,r;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(i.space,i.local):(o=this.getAttributeNS(i.space,i.local),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function tP(i,e){var t=op(i),n=t==="transform"?$5:c2;return this.attrTween(i,typeof e=="function"?(t.local?eP:J5)(t,n,hy(this,"attr."+i,e)):e==null?(t.local?K5:X5)(t):(t.local?Q5:Z5)(t,n,e))}function iP(i,e){return function(t){this.setAttribute(i,e.call(this,t))}}function nP(i,e){return function(t){this.setAttributeNS(i.space,i.local,e.call(this,t))}}function sP(i,e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&nP(i,r)),t}return s._value=e,s}function rP(i,e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&iP(i,r)),t}return s._value=e,s}function oP(i,e){var t="attr."+i;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=op(i);return this.tween(t,(n.local?sP:rP)(n,e))}function aP(i,e){return function(){ly(this,i).delay=+e.apply(this,arguments)}}function lP(i,e){return e=+e,function(){ly(this,i).delay=e}}function cP(i){var e=this._id;return arguments.length?this.each((typeof i=="function"?aP:lP)(e,i)):Gs(this.node(),e).delay}function uP(i,e){return function(){kr(this,i).duration=+e.apply(this,arguments)}}function dP(i,e){return e=+e,function(){kr(this,i).duration=e}}function hP(i){var e=this._id;return arguments.length?this.each((typeof i=="function"?uP:dP)(e,i)):Gs(this.node(),e).duration}function fP(i,e){if(typeof e!="function")throw new Error;return function(){kr(this,i).ease=e}}function pP(i){var e=this._id;return arguments.length?this.each(fP(e,i)):Gs(this.node(),e).ease}function mP(i,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;kr(this,i).ease=t}}function gP(i){if(typeof i!="function")throw new Error;return this.each(mP(this._id,i))}function _P(i){typeof i!="function"&&(i=jS(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&i.call(l,l.__data__,c,r)&&a.push(l);return new lo(n,this._parents,this._name,this._id)}function yP(i){if(i._id!==this._id)throw new Error;for(var e=this._groups,t=i._groups,n=e.length,s=t.length,r=Math.min(n,s),o=new Array(n),a=0;a<r;++a)for(var l=e[a],c=t[a],u=l.length,d=o[a]=new Array(u),h,p=0;p<u;++p)(h=l[p]||c[p])&&(d[p]=h);for(;a<n;++a)o[a]=e[a];return new lo(o,this._parents,this._name,this._id)}function bP(i){return(i+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function vP(i,e,t){var n,s,r=bP(e)?ly:kr;return function(){var o=r(this,i),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function xP(i,e){var t=this._id;return arguments.length<2?Gs(this.node(),t).on.on(i):this.each(vP(t,i,e))}function wP(i){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==i)return;e&&e.removeChild(this)}}function SP(){return this.on("end.remove",wP(this._id))}function EP(i){var e=this._name,t=this._id;typeof i!="function"&&(i=ry(i));for(var n=this._groups,s=n.length,r=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,c=r[o]=new Array(l),u,d,h=0;h<l;++h)(u=a[h])&&(d=i.call(u,u.__data__,h,a))&&("__data__"in u&&(d.__data__=u.__data__),c[h]=d,cp(c[h],e,t,h,c,Gs(u,t)));return new lo(r,this._parents,e,t)}function CP(i){var e=this._name,t=this._id;typeof i!="function"&&(i=$S(i));for(var n=this._groups,s=n.length,r=[],o=[],a=0;a<s;++a)for(var l=n[a],c=l.length,u,d=0;d<c;++d)if(u=l[d]){for(var h=i.call(u,u.__data__,d,l),p,m=Gs(u,t),y=0,g=h.length;y<g;++y)(p=h[y])&&cp(p,e,t,y,h,m);r.push(h),o.push(u)}return new lo(r,o,e,t)}var TP=ju.prototype.constructor;function kP(){return new TP(this._groups,this._parents)}function AP(i,e){var t,n,s;return function(){var r=Cl(this,i),o=(this.style.removeProperty(i),Cl(this,i));return r===o?null:r===t&&o===n?s:s=e(t=r,n=o)}}function u2(i){return function(){this.style.removeProperty(i)}}function IP(i,e,t){var n,s=t+"",r;return function(){var o=Cl(this,i);return o===s?null:o===n?r:r=e(n=o,t)}}function LP(i,e,t){var n,s,r;return function(){var o=Cl(this,i),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(i),Cl(this,i))),o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a))}}function RP(i,e){var t,n,s,r="style."+e,o="end."+r,a;return function(){var l=kr(this,i),c=l.on,u=l.value[r]==null?a||(a=u2(e)):void 0;(c!==t||s!==u)&&(n=(t=c).copy()).on(o,s=u),l.on=n}}function PP(i,e,t){var n=(i+="")=="transform"?U5:c2;return e==null?this.styleTween(i,AP(i,n)).on("end.style."+i,u2(i)):typeof e=="function"?this.styleTween(i,LP(i,n,hy(this,"style."+i,e))).each(RP(this._id,i)):this.styleTween(i,IP(i,n,e),t).on("end.style."+i,null)}function NP(i,e,t){return function(n){this.style.setProperty(i,e.call(this,n),t)}}function DP(i,e,t){var n,s;function r(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&NP(i,o,t)),n}return r._value=e,r}function MP(i,e,t){var n="style."+(i+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,DP(i,e,t??""))}function BP(i){return function(){this.textContent=i}}function OP(i){return function(){var e=i(this);this.textContent=e??""}}function FP(i){return this.tween("text",typeof i=="function"?OP(hy(this,"text",i)):BP(i==null?"":i+""))}function zP(i){return function(e){this.textContent=i.call(this,e)}}function UP(i){var e,t;function n(){var s=i.apply(this,arguments);return s!==t&&(e=(t=s)&&zP(s)),e}return n._value=i,n}function $P(i){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(i==null)return this.tween(e,null);if(typeof i!="function")throw new Error;return this.tween(e,UP(i))}function jP(){for(var i=this._name,e=this._id,t=d2(),n=this._groups,s=n.length,r=0;r<s;++r)for(var o=n[r],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=Gs(l,e);cp(l,i,t,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new lo(n,this._parents,i,t)}function HP(){var i,e,t=this,n=t._id,s=t.size();return new Promise(function(r,o){var a={value:o},l={value:function(){--s===0&&r()}};t.each(function(){var c=kr(this,n),u=c.on;u!==i&&(e=(i=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),s===0&&r()})}var VP=0;function lo(i,e,t,n){this._groups=i,this._parents=e,this._name=t,this._id=n}function d2(){return++VP}var $r=ju.prototype;lo.prototype={constructor:lo,select:EP,selectAll:CP,selectChild:$r.selectChild,selectChildren:$r.selectChildren,filter:_P,merge:yP,selection:kP,transition:jP,call:$r.call,nodes:$r.nodes,node:$r.node,size:$r.size,empty:$r.empty,each:$r.each,on:xP,attr:tP,attrTween:oP,style:PP,styleTween:MP,text:FP,textTween:$P,remove:SP,tween:q5,delay:cP,duration:hP,ease:pP,easeVarying:gP,end:HP,[Symbol.iterator]:$r[Symbol.iterator]};function GP(i){return i*i}function WP(i){return i*(2-i)}function YP(i){return((i*=2)<=1?i*i:--i*(2-i)+1)/2}function qP(i){return((i*=2)<=1?i*i*i:(i-=2)*i*i+2)/2}var XP={time:null,delay:0,duration:250,ease:qP};function KP(i,e){for(var t;!(t=i.__transition)||!(t=t[e]);)if(!(i=i.parentNode))throw new Error(`transition ${e} not found`);return t}function ZP(i){var e,t;i instanceof lo?(e=i._id,i=i._name):(e=d2(),(t=XP).time=ay(),i=i==null?null:i+"");for(var n=this._groups,s=n.length,r=0;r<s;++r)for(var o=n[r],a=o.length,l,c=0;c<a;++c)(l=o[c])&&cp(l,i,e,c,o,t||KP(l,e));return new lo(n,this._parents,i,e)}ju.prototype.interrupt=p5;ju.prototype.transition=ZP;function W0(){let i;if(typeof window<"u"&&window.performance)i=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();i=e[0]*1e3+e[1]/1e6}else i=Date.now();return i}class Y0{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=W0(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(W0()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class QP{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:n}=e;let s=this.stats[t];return s||(e instanceof Y0?s=e:s=new Y0(t,n),this.stats[t]=s),s}}class JP{constructor(){$(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new QP({id:e})),this.stats.get(e)}}const h2=new JP,Kp=globalThis,_d=globalThis.process||{},Ite=globalThis.navigator||{};function eN(i){var e,t;if(typeof window<"u"&&((e=window.process)==null?void 0:e.type)==="renderer"||typeof process<"u"&&(t=process.versions)!=null&&t.electron)return!0;const n=typeof navigator<"u"&&navigator.userAgent;return!!(n&&n.indexOf("Electron")>=0)}function Vu(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||eN()}const f2="4.1.0";function tN(i){try{const e=window[i],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class iN{constructor(e,t,n="sessionStorage"){this.storage=tN(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function nN(i){let e;return i<10?e=`${i.toFixed(2)}ms`:i<100?e=`${i.toFixed(1)}ms`:i<1e3?e=`${i.toFixed(0)}ms`:e=`${(i/1e3).toFixed(2)}s`,e}function sN(i,e=8){const t=Math.max(e-i.length,0);return`${" ".repeat(t)}${i}`}var Kh;(function(i){i[i.BLACK=30]="BLACK",i[i.RED=31]="RED",i[i.GREEN=32]="GREEN",i[i.YELLOW=33]="YELLOW",i[i.BLUE=34]="BLUE",i[i.MAGENTA=35]="MAGENTA",i[i.CYAN=36]="CYAN",i[i.WHITE=37]="WHITE",i[i.BRIGHT_BLACK=90]="BRIGHT_BLACK",i[i.BRIGHT_RED=91]="BRIGHT_RED",i[i.BRIGHT_GREEN=92]="BRIGHT_GREEN",i[i.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",i[i.BRIGHT_BLUE=94]="BRIGHT_BLUE",i[i.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",i[i.BRIGHT_CYAN=96]="BRIGHT_CYAN",i[i.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Kh||(Kh={}));const rN=10;function q0(i){return typeof i!="string"?i:(i=i.toUpperCase(),Kh[i]||Kh.WHITE)}function oN(i,e,t){return!Vu&&typeof i=="string"&&(e&&(i=`\x1B[${q0(e)}m${i}\x1B[39m`),t&&(i=`\x1B[${q0(t)+rN}m${i}\x1B[49m`)),i}function aN(i,e=["constructor"]){const t=Object.getPrototypeOf(i),n=Object.getOwnPropertyNames(t),s=i;for(const r of n){const o=s[r];typeof o=="function"&&(e.find(a=>r===a)||(s[r]=o.bind(i)))}}function fy(i,e){if(!i)throw new Error("Assertion failed")}function Pa(){var i,e,t;let n;if(Vu()&&Kp.performance)n=(e=(i=Kp==null?void 0:Kp.performance)==null?void 0:i.now)==null?void 0:e.call(i);else if("hrtime"in _d){const s=(t=_d==null?void 0:_d.hrtime)==null?void 0:t.call(_d);n=s[0]*1e3+s[1]/1e6}else n=Date.now();return n}const Na={debug:Vu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},lN={enabled:!0,level:0};function Da(){}const X0={},K0={once:!0};class p2{constructor({id:e}={id:""}){this.VERSION=f2,this._startTs=Pa(),this._deltaTs=Pa(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new iN(`__probe-${this.id}__`,lN),this.timeStamp(`${this.id} started`),aN(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Pa()-this._startTs).toPrecision(10))}getDelta(){return Number((Pa()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,Na.warn,arguments,K0)}error(e){return this._getLogFunction(0,e,Na.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Na.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Na.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Na.debug||Na.info,arguments,K0)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Da,n&&[n],{tag:uN(t)}):Da}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Da)}group(e,t,n={collapsed:!1}){const s=Z0({logLevel:e,message:t,opts:n}),{collapsed:r}=n;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Da)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=m2(e)}_getLogFunction(e,t,n,s,r){if(this._shouldLog(e)){r=Z0({logLevel:e,message:t,args:s,opts:r}),n=n||r.method,fy(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Pa();const o=r.tag||r.message;if(r.once&&o)if(!X0[o])X0[o]=Pa();else return Da;return t=cN(this.id,r.message,r),n.bind(console,t,...r.args)}return Da}}p2.VERSION=f2;function m2(i){if(!i)return 0;let e;switch(typeof i){case"number":e=i;break;case"object":e=i.logLevel||i.priority||0;break;default:return 0}return fy(Number.isFinite(e)&&e>=0),e}function Z0(i){const{logLevel:e,message:t}=i;i.logLevel=m2(e);const n=i.args?Array.from(i.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),i.message=e;break;case"object":Object.assign(i,e);break}typeof i.message=="function"&&(i.message=i.message());const s=typeof i.message;return fy(s==="string"||s==="object"),Object.assign(i,{args:n},i.opts)}function cN(i,e,t){if(typeof e=="string"){const n=t.time?sN(nN(t.total)):"";e=t.time?`${i}: ${n}  ${e}`:`${i}: ${e}`,e=oN(e,t.color,t.background)}return e}function uN(i){for(const e in i)for(const t in i[e])return t||"untitled";return"empty"}const le=new p2({id:"luma.gl"}),Zp={};function py(i="id"){Zp[i]=Zp[i]||1;const e=Zp[i]++;return`${i}-${e}`}class yn{constructor(e,t,n){if($(this,"id"),$(this,"props"),$(this,"userData",{}),$(this,"_device"),$(this,"destroyed",!1),$(this,"allocatedBytes",0),$(this,"_attachedResources",new Set),!e)throw new Error("no device");this._device=e,this.props=dN(t,n);const s=this.props.id!=="undefined"?this.props.id:py(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}$(yn,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function dN(i,e){const t={...e};for(const n in i)i[n]!==void 0&&(t[n]=i[n]);return t}const Un=class dh extends yn{constructor(e,t){const n={...t};(t.usage||0)&dh.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,dh.defaultProps),$(this,"usage"),$(this,"indexType"),$(this,"updateTimestamp"),$(this,"debugData",new ArrayBuffer(0)),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(e){return this.device.createBuffer({...this.props,...e})}_setDebugData(e,t,n){const s=ArrayBuffer.isView(e)?e.buffer:e,r=Math.min(e?e.byteLength:n,dh.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(r):t===0&&n===s.byteLength?this.debugData=s.slice(0,r):this.debugData=s.slice(t,t+r)}};$(Un,"INDEX",16),$(Un,"VERTEX",32),$(Un,"UNIFORM",64),$(Un,"STORAGE",128),$(Un,"INDIRECT",256),$(Un,"QUERY_RESOLVE",512),$(Un,"MAP_READ",1),$(Un,"MAP_WRITE",2),$(Un,"COPY_SRC",4),$(Un,"COPY_DST",8),$(Un,"DEBUG_DATA_MAX_LENGTH",32),$(Un,"defaultProps",{...yn.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let me=Un;function g2(i){const[e,t,n]=my[i],s=i.includes("norm"),r=!s&&!i.startsWith("float"),o=i.startsWith("s");return{signedType:e,primitiveType:t,byteLength:n,normalized:s,integer:r,signed:o}}function hN(i){const e=i;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function fN(i,e){switch(e){case 1:return i;case 2:return i+i%2;default:return i+(4-i%4)%4}}function pN(i){const e=ArrayBuffer.isView(i)?i.constructor:i;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(my).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function mN(i){const[,,,,e]=my[i];return e}const my={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function gy(i){let e;i.endsWith("-webgl")&&(i.replace("-webgl",""),e=!0);const[t,n]=i.split("x"),s=t,r=n?parseInt(n):1,o=g2(s),a={type:s,components:r,byteLength:o.byteLength*r,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function gN(i,e,t){const n=t?hN(i):i;switch(n){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${n}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${n}x${e}`;default:return e===1?n:`${n}x${e}`}}function _N(i,e,t){if(!e||e>4)throw new Error(`size ${e}`);const n=e,s=pN(i);return gN(s,n,t)}function yN(i){let e;switch(i.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return i.components<=2?"float16x2":"float16x4"}return i.components===1?e:`${e}x${i.components}`}const Vi="texture-compression-bc",Ft="texture-compression-astc",nr="texture-compression-etc2",bN="texture-compression-etc1-webgl",yd="texture-compression-pvrtc-webgl",Qp="texture-compression-atc-webgl",bd="float32-renderable-webgl",Jp="float16-renderable-webgl",vN="rgb9e5ufloat-renderable-webgl",em="snorm8-renderable-webgl",lc="norm16-renderable-webgl",tm="snorm16-renderable-webgl",vd="float32-filterable",Q0="float16-filterable-webgl";function _2(i){const e=SN[i];if(!e)throw new Error(`Unsupported texture format ${i}`);return e}const xN={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:em},rg8snorm:{render:em},"rgb8snorm-webgl":{},rgba8snorm:{render:em},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:lc},rg16unorm:{render:lc},"rgb16unorm-webgl":{f:lc},rgba16unorm:{render:lc},r16snorm:{f:tm},rg16snorm:{render:tm},"rgb16snorm-webgl":{f:lc},rgba16snorm:{render:tm},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Jp,filter:"float16-filterable-webgl"},rg16float:{render:Jp,filter:Q0},rgba16float:{render:Jp,filter:Q0},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:bd,filter:vd},rg32float:{render:!1,filter:vd},"rgb32float-webgl":{render:bd,filter:vd},rgba32float:{render:bd,filter:vd},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:vN},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:bd},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},wN={"bc1-rgb-unorm-webgl":{f:Vi},"bc1-rgb-unorm-srgb-webgl":{f:Vi},"bc1-rgba-unorm":{f:Vi},"bc1-rgba-unorm-srgb":{f:Vi},"bc2-rgba-unorm":{f:Vi},"bc2-rgba-unorm-srgb":{f:Vi},"bc3-rgba-unorm":{f:Vi},"bc3-rgba-unorm-srgb":{f:Vi},"bc4-r-unorm":{f:Vi},"bc4-r-snorm":{f:Vi},"bc5-rg-unorm":{f:Vi},"bc5-rg-snorm":{f:Vi},"bc6h-rgb-ufloat":{f:Vi},"bc6h-rgb-float":{f:Vi},"bc7-rgba-unorm":{f:Vi},"bc7-rgba-unorm-srgb":{f:Vi},"etc2-rgb8unorm":{f:nr},"etc2-rgb8unorm-srgb":{f:nr},"etc2-rgb8a1unorm":{f:nr},"etc2-rgb8a1unorm-srgb":{f:nr},"etc2-rgba8unorm":{f:nr},"etc2-rgba8unorm-srgb":{f:nr},"eac-r11unorm":{f:nr},"eac-r11snorm":{f:nr},"eac-rg11unorm":{f:nr},"eac-rg11snorm":{f:nr},"astc-4x4-unorm":{f:Ft},"astc-4x4-unorm-srgb":{f:Ft},"astc-5x4-unorm":{f:Ft},"astc-5x4-unorm-srgb":{f:Ft},"astc-5x5-unorm":{f:Ft},"astc-5x5-unorm-srgb":{f:Ft},"astc-6x5-unorm":{f:Ft},"astc-6x5-unorm-srgb":{f:Ft},"astc-6x6-unorm":{f:Ft},"astc-6x6-unorm-srgb":{f:Ft},"astc-8x5-unorm":{f:Ft},"astc-8x5-unorm-srgb":{f:Ft},"astc-8x6-unorm":{f:Ft},"astc-8x6-unorm-srgb":{f:Ft},"astc-8x8-unorm":{f:Ft},"astc-8x8-unorm-srgb":{f:Ft},"astc-10x5-unorm":{f:Ft},"astc-10x5-unorm-srgb":{f:Ft},"astc-10x6-unorm":{f:Ft},"astc-10x6-unorm-srgb":{f:Ft},"astc-10x8-unorm":{f:Ft},"astc-10x8-unorm-srgb":{f:Ft},"astc-10x10-unorm":{f:Ft},"astc-10x10-unorm-srgb":{f:Ft},"astc-12x10-unorm":{f:Ft},"astc-12x10-unorm-srgb":{f:Ft},"astc-12x12-unorm":{f:Ft},"astc-12x12-unorm-srgb":{f:Ft},"pvrtc-rgb4unorm-webgl":{f:yd},"pvrtc-rgba4unorm-webgl":{f:yd},"pvrtc-rbg2unorm-webgl":{f:yd},"pvrtc-rgba2unorm-webgl":{f:yd},"etc1-rbg-unorm-webgl":{f:bN},"atc-rgb-unorm-webgl":{f:Qp},"atc-rgba-unorm-webgl":{f:Qp},"atc-rgbai-unorm-webgl":{f:Qp}},SN={...xN,...wN},EN=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],CN=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class TN{getInfo(e){return J0(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return EN.some(t=>e.startsWith(t))}getCapabilities(e){const t=_2(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=J0(e),r=e.startsWith("depth")||e.startsWith("stencil"),o=s==null?void 0:s.signed,a=s==null?void 0:s.integer,l=s==null?void 0:s.webgl;return n.render&&(n.render=!o),n.filter&&(n.filter=!r&&!o&&!a&&!l),n}}const eu=new TN;function J0(i){let e=kN(i);if(eu.isCompressed(i)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const n=AN(i);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}const t=CN.exec(i);if(t){const[,n,s,r,o,a]=t,l=`${r}${s}`,c=g2(l),u=c.byteLength*8,d=n.length,h=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];e={format:i,attachment:e.attachment,dataType:c.signedType,components:d,channels:n,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return i.endsWith("-webgl")&&(e.webgl=!0),i.endsWith("-srgb")&&(e.srgb=!0),e}function kN(i){var e;const t=_2(i),n=t.bytesPerPixel||1,s=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:i,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||((e=t.channels)==null?void 0:e.length)||1,bytesPerPixel:n,bitsPerChannel:s,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function AN(i){const e=/.*-(\d+)x(\d+)-.*/.exec(i);if(e){const[,t,n]=e;return{blockWidth:Number(t),blockHeight:Number(n)}}return null}function IN(i){return typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement||typeof VideoFrame<"u"&&i instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas}function LN(i){if(typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height};if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement)return{width:i.naturalWidth,height:i.naturalHeight};if(typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement)return{width:i.videoWidth,height:i.videoHeight};if(typeof VideoFrame<"u"&&i instanceof VideoFrame)return{width:i.displayWidth,height:i.displayHeight};throw new Error("Unknown image type")}class Lte{}class Rte{constructor(e=[],t){$(this,"features"),$(this,"disabledFeatures"),this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const y2=class b2{constructor(e){$(this,"id"),$(this,"props"),$(this,"userData",{}),$(this,"statsManager",h2),$(this,"timestamp",0),$(this,"_reused",!1),$(this,"_lumaData",{}),$(this,"_textureCaps",{}),this.props={...b2.defaultProps,...e},this.id=this.props.id||py(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return gy(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return eu.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){const s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return IN(e)}getExternalImageSize(e){return LN(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return eu.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){return this.props.onError(e,t)?()=>{}:le.error(e.message,t,...n)}debug(){if(this.props.debug)debugger;else le.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=eu.getCapabilities(e),n=r=>(typeof r=="string"?this.features.has(r):r)??!0,s=n(t.create);return{format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&me.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};$(y2,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(i,e)=>{},onResize:(i,e)=>{const[t,n]=i.getDevicePixelSize();le.log(1,`${i} resized => ${t}x${n}px`)()},onPositionChange:(i,e)=>{const[t,n]=i.getPosition();le.log(1,`${i} repositioned => ${t},${n}`)()},onVisibilityChange:i=>le.log(1,`${i} Visibility changed ${i.isVisible}`)(),onDevicePixelRatioChange:(i,e)=>le.log(1,`${i} DPR changed ${e.oldRatio} => ${i.devicePixelRatio}`)(),debug:le.get("debug")||void 0,debugShaders:le.get("debug-shaders")||void 0,debugFramebuffers:!!le.get("debug-framebuffers"),debugFactories:!!le.get("debug-factories"),debugWebGL:!!le.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let Cg=y2;const RN="set luma.log.level=1 (or higher) to trace rendering",ex="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",v2=class Tg{constructor(){if($(this,"stats",h2),$(this,"log",le),$(this,"VERSION","9.2.5"),$(this,"spector"),$(this,"preregisteredAdapters",new Map),globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw le.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),le.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");le.error("This version of luma.gl has already been initialized")()}le.log(1,`${this.VERSION} - ${RN}`)(),globalThis.luma=this}async createDevice(e={}){const t={...Tg.defaultProps,...e},n=this.selectAdapter(t.type,t.adapters);if(!n)throw new Error(ex);return t.waitForPageLoad&&await n.pageLoaded,await n.create(t)}async attachDevice(e,t){var n;const s=this._getTypeFromHandle(e,t.adapters),r=s&&this.selectAdapter(s,t.adapters);if(!r)throw new Error(ex);return await((n=r==null?void 0:r.attach)==null?void 0:n.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>{var s;return(s=n.isSupported)==null?void 0:s.call(n)}).map(n=>n.type)}getBestAvailableAdapterType(e=[]){var t,n;const s=["webgpu","webgl","null"],r=this._getAdapterMap(e);for(const o of s)if((n=(t=r.get(o))==null?void 0:t.isSupported)!=null&&n.call(t))return o;return null}selectAdapter(e,t=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(t));const s=this._getAdapterMap(t);return n&&s.get(n)||null}enforceWebGL2(e=!0,t=[]){var n;const s=this._getAdapterMap(t).get("webgl");s||le.warn("enforceWebGL2: webgl adapter not found")(),(n=s==null?void 0:s.enforceWebGL2)==null||n.call(s,e)}setDefaultDeviceProps(e){Object.assign(Tg.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?le.warn("WebGL1 is not supported",e)():le.warn("Unknown handle type",e)(),null)}};$(v2,"defaultProps",{...Cg.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let PN=v2;const NN=new PN;class DN{get pageLoaded(){return ON()}}const MN=Vu()&&typeof document<"u",BN=()=>MN&&document.readyState==="complete";let xd=null;function ON(){return xd||(BN()||typeof window>"u"?xd=Promise.resolve():xd=new Promise(i=>window.addEventListener("load",()=>i()))),xd}const x2=class kg extends yn{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=kg.normalizeProps(e,t),super(e,t,kg.defaultProps)}static normalizeProps(e,t){return t}};$(x2,"defaultProps",{...yn.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let _y=x2;const FN={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},En=class Mc extends yn{constructor(e,t){if(t=Mc.normalizeProps(e,t),super(e,t,Mc.defaultProps),$(this,"dimension"),$(this,"baseDimension"),$(this,"format"),$(this,"width"),$(this,"height"),$(this,"depth"),$(this,"mipLevels"),$(this,"updateTimestamp"),this.dimension=this.props.dimension,this.baseDimension=FN[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){const n=e.getExternalImageSize(t.data);this.width=(n==null?void 0:n.width)||1,this.height=(n==null?void 0:n.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&le.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(e){this.sampler=e instanceof _y?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){const n={...t},{width:s,height:r}=n;return typeof s=="number"&&(n.width=Math.max(1,Math.ceil(s))),typeof r=="number"&&(n.height=Math.max(1,Math.ceil(r))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){const{width:t,height:n,depth:s}=this,r={...Mc.defaultCopyDataOptions,width:t,height:n,depth:s,...e},o=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return r.bytesPerRow=e.bytesPerRow||t*(o.bytesPerPixel||4),r.rowsPerImage=e.rowsPerImage||n,r}_normalizeCopyExternalImageOptions(e){const t=this.device.getExternalImageSize(e.image),n={...Mc.defaultCopyExternalImageOptions,...t,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}};$(En,"SAMPLE",4),$(En,"STORAGE",8),$(En,"RENDER",16),$(En,"COPY_SRC",1),$(En,"COPY_DST",2),$(En,"TEXTURE",4),$(En,"RENDER_ATTACHMENT",16),$(En,"defaultProps",{...yn.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:En.TEXTURE|En.RENDER_ATTACHMENT|En.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),$(En,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),$(En,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let lt=En;const w2=class S2 extends yn{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,S2.defaultProps)}};$(w2,"defaultProps",{...yn.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let zN=w2;function UN(i,e,t){let n="";const s=e.split(/\r?\n/),r=i.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(n+=E2(s[a-1],a,t);r.length>o&&r[o].lineNum===a;){const l=r[o++];n+=im(l,s,l.lineNum,{...t,inlineSource:!1})}for(;r.length>o;){const a=r[o++];n+=im(a,[],0,{...t,inlineSource:!1})}return n;case"issues":case"no":for(const a of i)n+=im(a,s,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return n}}function im(i,e,t,n){if(n!=null&&n.inlineSource){const r=$N(e,t),o=i.linePos>0?`${" ".repeat(i.linePos+5)}^^^
`:"";return`
${r}${o}${i.type.toUpperCase()}: ${i.message}

`}const s=i.type==="error"?"red":"#8B4000";return n!=null&&n.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${i.type.toUpperCase()}: ${i.message}</b></div>`:`${i.type.toUpperCase()}: ${i.message}`}function $N(i,e,t){let n="";for(let s=e-2;s<=e;s++){const r=i[s-1];r!==void 0&&(n+=E2(r,e,t))}return n}function E2(i,e,t){const n=t!=null&&t.html?HN(i):i;return`${jN(String(e),4)}: ${n}${t!=null&&t.html?"<br/>":`
`}`}function jN(i,e){let t="";for(let n=i.length;n<e;++n)t+=" ";return t+i}function HN(i){return i.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}const C2=class T2 extends yn{constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:GN(t),...t},T2.defaultProps),$(this,"stage"),$(this,"source"),$(this,"compilationStatus","pending"),this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break}const t=await this.getCompilationInfo();e==="warnings"&&(t==null?void 0:t.length)===0||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){var n;if(typeof document>"u"||!(document!=null&&document.createElement))return;const s=t,r=`${this.stage} shader "${s}"`;let o=UN(e,this.source,{showSourceCode:"all",html:!0});const a=this.getTranslatedSource();a&&(o+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${a}</pre></code>`);const l=document.createElement("Button");l.innerHTML=`
<h1>Compilation error in ${r}</h1><br /><br />
<code style="user-select:text;"><pre>
${o}
</pre></code>`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};$(C2,"defaultProps",{...yn.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let VN=C2;function GN(i){return WN(i.source)||i.id||py(`unnamed ${i.stage}-shader`)}function WN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const k2=class A2 extends yn{constructor(e,t){super(e,t,A2.defaultProps),$(this,"shaderLayout"),$(this,"bufferLayout"),$(this,"linkStatus","pending"),$(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};$(k2,"defaultProps",{...yn.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Zh=k2;const I2=class L2 extends yn{constructor(e,t){super(e,t,L2.defaultProps),$(this,"hash",""),$(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};$(I2,"defaultProps",{...yn.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let tx=I2;function YN(i){return ZN[i]}function qN(i){const[e,t]=KN[i],n=e==="i32"||e==="u32",s=e!=="u32",r=XN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const XN={f32:4,f16:2,i32:4,u32:4},KN={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},ZN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function R2(i,e){const t={};for(const n of i.attributes){const s=QN(i,e,n.name);s&&(t[n.name]=s)}return t}function Pte(i,e,t=16){const n=R2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function QN(i,e,t){const n=JN(i,t),s=eD(e,t);if(!n)return null;const r=qN(n.type),o=yN(r),a=(s==null?void 0:s.vertexFormat)||o,l=gy(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function JN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function eD(i,e){tD(i);let t=iD(i,e);return t||(t=nD(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function tD(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function iD(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function nD(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=gy(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let wd;function P2(i){return(!wd||wd.byteLength<i)&&(wd=new ArrayBuffer(i)),wd}function Nte(i,e){const t=P2(i.BYTES_PER_ELEMENT*e);return new i(t,0,e)}function sD(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Qh(i){return Array.isArray(i)?i.length===0||typeof i[0]=="number":sD(i)}const rD=1024;class oD{constructor(e,t={}){$(this,"layout",{}),$(this,"byteLength");let n=0;for(const[r,o]of Object.entries(e)){const a=YN(o),{type:l,components:c}=a,u=c*((t==null?void 0:t[r])??1);n=fN(n,u);const d=n;n+=u,this.layout[r]={type:l,size:u,offset:d}}n+=(4-n%4)%4;const s=n*4;this.byteLength=Math.max(s,rD)}getData(e){const t=P2(this.byteLength),n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[s,r]of Object.entries(e)){const o=this.layout[s];if(!o){le.warn(`Supplied uniform value ${s} not present in uniform block layout`)();continue}const{type:a,size:l,offset:c}=o,u=n[a];if(l===1){if(typeof r!="number"&&typeof r!="boolean"){le.warn(`Supplied value for single component uniform ${s} is not a number: ${r}`)();continue}u[c]=Number(r)}else{if(!Qh(r)){le.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${r}`)();continue}u.set(r,c)}}return new Uint8Array(t,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}function aD(i,e,t=16){if(i!==e)return!1;const n=i,s=e;if(!Qh(n))return!1;if(Qh(s)&&n.length===s.length){for(let r=0;r<n.length;++r)if(s[r]!==n[r])return!1}return!0}function lD(i){return Qh(i)?i.slice():i}class cD{constructor(e){$(this,"name"),$(this,"uniforms",{}),$(this,"modifiedUniforms",{}),$(this,"modified",!0),$(this,"bindingLayout",{}),$(this,"needsRedraw","initialized");var t;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&e!=null&&e.shaderLayout){const n=(t=e==null?void 0:e.shaderLayout.bindings)==null?void 0:t.find(r=>r.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){aD(this.uniforms[e],t)||(this.uniforms[e]=lD(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ai=class{constructor(e){$(this,"uniformBlocks",new Map),$(this,"uniformBufferLayouts",new Map),$(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new oD(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new cD({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:me.UNIFORM|me.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Bo;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Bo||(Bo={}));const uD={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},dD=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),hD=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),fD=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function pD(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&mD(s),s}return this.originalGetContext(t,n)}}function mD(i){i.getExtension("EXT_color_buffer_float");const e={...uD,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:dD(i),OES_vertex_array_object:hD(i),ANGLE_instanced_arrays:fD(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function N2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const gD=1;let fi=null,ix=!1;const yy={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function _D(i){if(!globalThis.SPECTOR)try{await N2(i.debugSpectorJSUrl||yy.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function Mte(i){var e;if(i={...yy,...i},!i.debugSpectorJS)return null;if(!fi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(gD,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;fi=new t,globalThis.luma&&(globalThis.luma.spector=fi)}if(!fi)return null;if(ix||(ix=!0,fi.spyCanvases(),fi==null||fi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),fi==null||fi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),fi==null||fi.getResultUI(),fi==null||fi.resultView.display(),fi==null||fi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;fi==null||fi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),fi==null||fi.stopCapture()})}return fi}const yD="https://unpkg.com/webgl-debug@2.0.1/index.js";function D2(i){return i.luma=i.luma||{},i.luma}async function bD(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await N2(yD))}function Bte(i,e={}){return e.debugWebGL||e.traceWebGL?xD(i,e):vD(i)}function vD(i){const e=D2(i);return e.realContext?e.realContext:i}function xD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=D2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Bo,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,wD.bind(null,e),SD.bind(null,e));for(const o in Bo)!(o in n)&&typeof Bo[o]=="number"&&(n[o]=Bo[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function nx(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function wD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function SD(i,e,t){let n="";le.level>=1&&(n=nx(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||nx(e,t);debugger}}const Sd=1;class ED extends DN{constructor(){super(),$(this,"type","webgl"),Cg.defaultProps={...Cg.defaultProps,...yy}}enforceWebGL2(e){pD(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await m0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-DrMhJinb.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!CD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await m0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-DrMhJinb.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));le.groupCollapsed(Sd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(bD()),e.debugSpectorJS&&n.push(_D(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(Sd,o)(),le.table(Sd,r.info)(),r}finally{le.groupEnd(Sd)()}}}function CD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const TD=new ED,kD="#b3b3b3",AD=void 0,Ag=void 0,ID=1,LD=4,RD="#666666",PD=.1,ND=1,DD=1,M2="#222222",fe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},MD=.7,BD=.95,OD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:B2,setPrototypeOf:sx,isFrozen:FD,getPrototypeOf:zD,getOwnPropertyDescriptor:UD}=Object;let{freeze:fn,seal:gs,create:O2}=Object,{apply:Ig,construct:Lg}=typeof Reflect<"u"&&Reflect;fn||(fn=function(i){return i});gs||(gs=function(i){return i});Ig||(Ig=function(i,e,t){return i.apply(e,t)});Lg||(Lg=function(i,e){return new i(...e)});const Ed=pn(Array.prototype.forEach),$D=pn(Array.prototype.lastIndexOf),rx=pn(Array.prototype.pop),cc=pn(Array.prototype.push),jD=pn(Array.prototype.splice),hh=pn(String.prototype.toLowerCase),nm=pn(String.prototype.toString),ox=pn(String.prototype.match),uc=pn(String.prototype.replace),HD=pn(String.prototype.indexOf),VD=pn(String.prototype.trim),Ms=pn(Object.prototype.hasOwnProperty),rn=pn(RegExp.prototype.test),dc=GD(TypeError);function pn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return Ig(i,e,n)}}function GD(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Lg(i,t)}}function rt(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hh;sx&&sx(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(FD(e)||(e[n]=r),s=r)}i[s]=!0}return i}function WD(i){for(let e=0;e<i.length;e++)Ms(i,e)||(i[e]=null);return i}function Gr(i){const e=O2(null);for(const[t,n]of B2(i))Ms(i,t)&&(Array.isArray(n)?e[t]=WD(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Gr(n):e[t]=n);return e}function hc(i,e){for(;i!==null;){const n=UD(i,e);if(n){if(n.get)return pn(n.get);if(typeof n.value=="function")return pn(n.value)}i=zD(i)}function t(){return null}return t}const ax=fn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),sm=fn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rm=fn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),YD=fn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),om=fn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),qD=fn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lx=fn(["#text"]),cx=fn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),am=fn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ux=fn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Cd=fn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),XD=gs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),KD=gs(/<%[\w\W]*|[\w\W]*%>/gm),ZD=gs(/\$\{[\w\W]*/gm),QD=gs(/^data-[\-\w.\u00B7-\uFFFF]+$/),JD=gs(/^aria-[\-\w]+$/),F2=gs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),eM=gs(/^(?:\w+script|data):/i),tM=gs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),z2=gs(/^html$/i),iM=gs(/^[a-z][.\w]*(-[.\w]+)+$/i);var dx=Object.freeze({__proto__:null,ARIA_ATTR:JD,ATTR_WHITESPACE:tM,CUSTOM_ELEMENT:iM,DATA_ATTR:QD,DOCTYPE_NAME:z2,ERB_EXPR:KD,IS_ALLOWED_URI:F2,IS_SCRIPT_OR_DATA:eM,MUSTACHE_EXPR:XD,TMPLIT_EXPR:ZD});const fc={element:1,text:3,progressingInstruction:7,comment:8,document:9},nM=function(){return typeof window>"u"?null:window},sM=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},hx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function U2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nM();const e=L=>U2(L);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==fc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=hc(m,"cloneNode"),g=hc(m,"remove"),_=hc(m,"nextSibling"),S=hc(m,"childNodes"),E=hc(m,"parentNode");if(typeof o=="function"){const L=t.createElement("template");L.content&&L.content.ownerDocument&&(t=L.content.ownerDocument)}let x,T="";const{implementation:I,createNodeIterator:O,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:re}=n;let D=hx();e.isSupported=typeof B2=="function"&&typeof E=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:de,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:ee,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:te,CUSTOM_ELEMENT:Z}=dx;let{IS_ALLOWED_URI:ae}=dx,J=null;const Se=rt({},[...ax,...sm,...rm,...om,...lx]);let xe=null;const et=rt({},[...cx,...am,...ux,...Cd]);let he=Object.seal(O2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),yt=null,Xe=null,dt=!0,ie=!0,Ce=!1,Pe=!0,X=!1,We=!0,He=!1,bt=!1,Vt=!1,pe=!1,it=!1,si=!1,yi=!0,Zs=!1;const Zn="user-content-";let wo=!0,Bn=!1,di={},tn=null;const bi=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Qn=null;const Ss=rt({},["audio","video","img","source","image","track"]);let Qs=null;const On=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Es="http://www.w3.org/1998/Math/MathML",nn="http://www.w3.org/2000/svg",Ti="http://www.w3.org/1999/xhtml";let Qt=Ti,$i=!1,vn=null;const So=rt({},[Es,nn,Ti],nm);let Mr=rt({},["mi","mo","mn","ms","mtext"]),ji=rt({},["annotation-xml"]);const Br=rt({},["title","style","font","a","script"]);let Cs=null;const Js=["application/xhtml+xml","text/html"],ic="text/html";let Jt=null,At=null;const Jn=t.createElement("form"),Ut=function(L){return L instanceof RegExp||L instanceof Function},Ts=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(At&&At===L)){if((!L||typeof L!="object")&&(L={}),L=Gr(L),Cs=Js.indexOf(L.PARSER_MEDIA_TYPE)===-1?ic:L.PARSER_MEDIA_TYPE,Jt=Cs==="application/xhtml+xml"?nm:hh,J=Ms(L,"ALLOWED_TAGS")?rt({},L.ALLOWED_TAGS,Jt):Se,xe=Ms(L,"ALLOWED_ATTR")?rt({},L.ALLOWED_ATTR,Jt):et,vn=Ms(L,"ALLOWED_NAMESPACES")?rt({},L.ALLOWED_NAMESPACES,nm):So,Qs=Ms(L,"ADD_URI_SAFE_ATTR")?rt(Gr(On),L.ADD_URI_SAFE_ATTR,Jt):On,Qn=Ms(L,"ADD_DATA_URI_TAGS")?rt(Gr(Ss),L.ADD_DATA_URI_TAGS,Jt):Ss,tn=Ms(L,"FORBID_CONTENTS")?rt({},L.FORBID_CONTENTS,Jt):bi,yt=Ms(L,"FORBID_TAGS")?rt({},L.FORBID_TAGS,Jt):Gr({}),Xe=Ms(L,"FORBID_ATTR")?rt({},L.FORBID_ATTR,Jt):Gr({}),di=Ms(L,"USE_PROFILES")?L.USE_PROFILES:!1,dt=L.ALLOW_ARIA_ATTR!==!1,ie=L.ALLOW_DATA_ATTR!==!1,Ce=L.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,X=L.SAFE_FOR_TEMPLATES||!1,We=L.SAFE_FOR_XML!==!1,He=L.WHOLE_DOCUMENT||!1,pe=L.RETURN_DOM||!1,it=L.RETURN_DOM_FRAGMENT||!1,si=L.RETURN_TRUSTED_TYPE||!1,Vt=L.FORCE_BODY||!1,yi=L.SANITIZE_DOM!==!1,Zs=L.SANITIZE_NAMED_PROPS||!1,wo=L.KEEP_CONTENT!==!1,Bn=L.IN_PLACE||!1,ae=L.ALLOWED_URI_REGEXP||F2,Qt=L.NAMESPACE||Ti,Mr=L.MATHML_TEXT_INTEGRATION_POINTS||Mr,ji=L.HTML_INTEGRATION_POINTS||ji,he=L.CUSTOM_ELEMENT_HANDLING||{},L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(he.tagNameCheck=L.CUSTOM_ELEMENT_HANDLING.tagNameCheck),L.CUSTOM_ELEMENT_HANDLING&&Ut(L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(he.attributeNameCheck=L.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),L.CUSTOM_ELEMENT_HANDLING&&typeof L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=L.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&(ie=!1),it&&(pe=!0),di&&(J=rt({},lx),xe=[],di.html===!0&&(rt(J,ax),rt(xe,cx)),di.svg===!0&&(rt(J,sm),rt(xe,am),rt(xe,Cd)),di.svgFilters===!0&&(rt(J,rm),rt(xe,am),rt(xe,Cd)),di.mathMl===!0&&(rt(J,om),rt(xe,ux),rt(xe,Cd))),L.ADD_TAGS&&(J===Se&&(J=Gr(J)),rt(J,L.ADD_TAGS,Jt)),L.ADD_ATTR&&(xe===et&&(xe=Gr(xe)),rt(xe,L.ADD_ATTR,Jt)),L.ADD_URI_SAFE_ATTR&&rt(Qs,L.ADD_URI_SAFE_ATTR,Jt),L.FORBID_CONTENTS&&(tn===bi&&(tn=Gr(tn)),rt(tn,L.FORBID_CONTENTS,Jt)),wo&&(J["#text"]=!0),He&&rt(J,["html","head","body"]),J.table&&(rt(J,["tbody"]),delete yt.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw dc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw dc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=L.TRUSTED_TYPES_POLICY,T=x.createHTML("")}else x===void 0&&(x=sM(p,s)),x!==null&&typeof T=="string"&&(T=x.createHTML(""));fn&&fn(L),At=L}},er=rt({},[...sm,...rm,...YD]),Or=rt({},[...om,...qD]),Eo=function(L){let V=E(L);(!V||!V.tagName)&&(V={namespaceURI:Qt,tagName:"template"});const C=hh(L.tagName),G=hh(V.tagName);return vn[L.namespaceURI]?L.namespaceURI===nn?V.namespaceURI===Ti?C==="svg":V.namespaceURI===Es?C==="svg"&&(G==="annotation-xml"||Mr[G]):!!er[C]:L.namespaceURI===Es?V.namespaceURI===Ti?C==="math":V.namespaceURI===nn?C==="math"&&ji[G]:!!Or[C]:L.namespaceURI===Ti?V.namespaceURI===nn&&!ji[G]||V.namespaceURI===Es&&!Mr[G]?!1:!Or[C]&&(Br[C]||!er[C]):!!(Cs==="application/xhtml+xml"&&vn[L.namespaceURI]):!1},es=function(L){cc(e.removed,{element:L});try{E(L).removeChild(L)}catch{g(L)}},hi=function(L,V){try{cc(e.removed,{attribute:V.getAttributeNode(L),from:V})}catch{cc(e.removed,{attribute:null,from:V})}if(V.removeAttribute(L),L==="is")if(pe||it)try{es(V)}catch{}else try{V.setAttribute(L,"")}catch{}},xn=function(L){let V=null,C=null;if(Vt)L="<remove></remove>"+L;else{const Te=ox(L,/^[\r\n\t ]+/);C=Te&&Te[0]}Cs==="application/xhtml+xml"&&Qt===Ti&&(L='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+L+"</body></html>");const G=x?x.createHTML(L):L;if(Qt===Ti)try{V=new h().parseFromString(G,Cs)}catch{}if(!V||!V.documentElement){V=I.createDocument(Qt,"template",null);try{V.documentElement.innerHTML=$i?T:G}catch{}}const ne=V.body||V.documentElement;return L&&C&&ne.insertBefore(t.createTextNode(C),ne.childNodes[0]||null),Qt===Ti?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},ks=function(L){return O.call(L.ownerDocument||L,L,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ct=function(L){return L instanceof d&&(typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||!(L.attributes instanceof u)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function")},Fr=function(L){return typeof a=="function"&&L instanceof a};function nt(L,V,C){Ed(L,G=>{G.call(e,V,C,At)})}const wn=function(L){let V=null;if(nt(D.beforeSanitizeElements,L,null),ct(L))return es(L),!0;const C=Jt(L.nodeName);if(nt(D.uponSanitizeElement,L,{tagName:C,allowedTags:J}),We&&L.hasChildNodes()&&!Fr(L.firstElementChild)&&rn(/<[/\w!]/g,L.innerHTML)&&rn(/<[/\w!]/g,L.textContent)||L.nodeType===fc.progressingInstruction||We&&L.nodeType===fc.comment&&rn(/<[/\w]/g,L.data))return es(L),!0;if(!J[C]||yt[C]){if(!yt[C]&&tr(C)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C)))return!1;if(wo&&!tn[C]){const G=E(L)||L.parentNode,ne=S(L)||L.childNodes;if(ne&&G){const Te=ne.length;for(let It=Te-1;It>=0;--It){const st=y(ne[It],!0);st.__removalCount=(L.__removalCount||0)+1,G.insertBefore(st,_(L))}}}return es(L),!0}return L instanceof l&&!Eo(L)||(C==="noscript"||C==="noembed"||C==="noframes")&&rn(/<\/no(script|embed|frames)/i,L.innerHTML)?(es(L),!0):(X&&L.nodeType===fc.text&&(V=L.textContent,Ed([de,se,R],G=>{V=uc(V,G," ")}),L.textContent!==V&&(cc(e.removed,{element:L.cloneNode()}),L.textContent=V)),nt(D.afterSanitizeElements,L,null),!1)},zr=function(L,V,C){if(yi&&(V==="id"||V==="name")&&(C in t||C in Jn))return!1;if(!(ie&&!Xe[V]&&rn(ee,V))&&!(dt&&rn(F,V))){if(!xe[V]||Xe[V]){if(!(tr(L)&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,L)||he.tagNameCheck instanceof Function&&he.tagNameCheck(L))&&(he.attributeNameCheck instanceof RegExp&&rn(he.attributeNameCheck,V)||he.attributeNameCheck instanceof Function&&he.attributeNameCheck(V))||V==="is"&&he.allowCustomizedBuiltInElements&&(he.tagNameCheck instanceof RegExp&&rn(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C))))return!1}else if(!Qs[V]&&!rn(ae,uc(C,te,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&L!=="script"&&HD(C,"data:")===0&&Qn[L])&&!(Ce&&!rn(q,uc(C,te,"")))&&C)return!1}return!0},tr=function(L){return L!=="annotation-xml"&&ox(L,Z)},Fn=function(L){nt(D.beforeSanitizeAttributes,L,null);const{attributes:V}=L;if(!V||ct(L))return;const C={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Te,namespaceURI:It,value:st}=ne,Je=Jt(Te),vi=st;let ht=Te==="value"?vi:VD(vi);if(C.attrName=Je,C.attrValue=ht,C.keepAttr=!0,C.forceKeepAttr=void 0,nt(D.uponSanitizeAttribute,L,C),ht=C.attrValue,Zs&&(Je==="id"||Je==="name")&&(hi(Te,L),ht=Zn+ht),We&&rn(/((--!?|])>)|<\/(style|title)/i,ht)){hi(Te,L);continue}if(C.forceKeepAttr)continue;if(!C.keepAttr){hi(Te,L);continue}if(!Pe&&rn(/\/>/i,ht)){hi(Te,L);continue}X&&Ed([de,se,R],Lt=>{ht=uc(ht,Lt," ")});const ir=Jt(L.nodeName);if(!zr(ir,Je,ht)){hi(Te,L);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!It)switch(p.getAttributeType(ir,Je)){case"TrustedHTML":{ht=x.createHTML(ht);break}case"TrustedScriptURL":{ht=x.createScriptURL(ht);break}}if(ht!==vi)try{It?L.setAttributeNS(It,Te,ht):L.setAttribute(Te,ht),ct(L)?es(L):rx(e.removed)}catch{hi(Te,L)}}nt(D.afterSanitizeAttributes,L,null)},sn=function L(V){let C=null;const G=ks(V);for(nt(D.beforeSanitizeShadowDOM,V,null);C=G.nextNode();)nt(D.uponSanitizeShadowNode,C,null),wn(C),Fn(C),C.content instanceof r&&L(C.content);nt(D.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(L){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,G=null,ne=null,Te=null;if($i=!L,$i&&(L="<!-->"),typeof L!="string"&&!Fr(L))if(typeof L.toString=="function"){if(L=L.toString(),typeof L!="string")throw dc("dirty is not a string, aborting")}else throw dc("toString is not a function");if(!e.isSupported)return L;if(bt||Ts(V),e.removed=[],typeof L=="string"&&(Bn=!1),Bn){if(L.nodeName){const Je=Jt(L.nodeName);if(!J[Je]||yt[Je])throw dc("root node is forbidden and cannot be sanitized in-place")}}else if(L instanceof a)C=xn("<!---->"),G=C.ownerDocument.importNode(L,!0),G.nodeType===fc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?C=G:C.appendChild(G);else{if(!pe&&!X&&!He&&L.indexOf("<")===-1)return x&&si?x.createHTML(L):L;if(C=xn(L),!C)return pe?null:si?T:""}C&&Vt&&es(C.firstChild);const It=ks(Bn?L:C);for(;ne=It.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&sn(ne.content);if(Bn)return L;if(pe){if(it)for(Te=H.call(C.ownerDocument);C.firstChild;)Te.appendChild(C.firstChild);else Te=C;return(xe.shadowroot||xe.shadowrootmode)&&(Te=re.call(n,Te,!0)),Te}let st=He?C.outerHTML:C.innerHTML;return He&&J["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&rn(z2,C.ownerDocument.doctype.name)&&(st="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
`+st),X&&Ed([de,se,R],Je=>{st=uc(st,Je," ")}),x&&si?x.createHTML(st):st},e.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ts(L),bt=!0},e.clearConfig=function(){At=null,bt=!1},e.isValidAttribute=function(L,V,C){At||Ts({});const G=Jt(L),ne=Jt(V);return zr(G,ne,C)},e.addHook=function(L,V){typeof V=="function"&&cc(D[L],V)},e.removeHook=function(L,V){if(V!==void 0){const C=$D(D[L],V);return C===-1?void 0:jD(D[L],C,1)[0]}return rx(D[L])},e.removeHooks=function(L){D[L]=[]},e.removeAllHooks=function(){D=hx()},e}var rM=U2();const oM=i=>typeof i=="function",$2=i=>Array.isArray(i),aM=i=>i instanceof Object,lM=i=>i instanceof Object?i.constructor.name!=="Function"&&i.constructor.name!=="Object":!1,fx=i=>aM(i)&&!$2(i)&&!oM(i)&&!lM(i);function Oo(i){let e;if($2(i))e=i;else{const t=jo(i),n=t==null?void 0:t.rgb();e=[(n==null?void 0:n.r)||0,(n==null?void 0:n.g)||0,(n==null?void 0:n.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function cM(i,e,t){return .2126*i+.7152*e+.0722*t}function jn(i,e,t=0,n=0,s,r){return i.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:n,sourceWidth:s,sourceHeight:r})}function uM(i,e,t){return Math.min(Math.max(i,e),t)}function ss(i){return i!=null&&!Number.isNaN(i)}function dM(i,e){return rM.sanitize(i,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class hM{constructor(){this.enableSimulation=fe.enableSimulation,this.backgroundColor=M2,this.spaceSize=fe.spaceSize,this.pointColor=kD,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=AD,this.pointGreyoutColor=Ag,this.pointSize=LD,this.pointDefaultSize=void 0,this.pointOpacity=ID,this.pointSizeScale=fe.pointSizeScale,this.hoveredPointCursor=fe.hoveredPointCursor,this.hoveredLinkCursor=fe.hoveredLinkCursor,this.renderHoveredPointRing=fe.renderHoveredPointRing,this.hoveredPointRingColor=fe.hoveredPointRingColor,this.focusedPointRingColor=fe.focusedPointRingColor,this.focusedPointIndex=fe.focusedPointIndex,this.linkColor=RD,this.linkDefaultColor=void 0,this.linkOpacity=ND,this.linkGreyoutOpacity=PD,this.linkWidth=DD,this.linkDefaultWidth=void 0,this.linkWidthScale=fe.linkWidthScale,this.hoveredLinkColor=fe.hoveredLinkColor,this.hoveredLinkWidthIncrease=fe.hoveredLinkWidthIncrease,this.renderLinks=fe.renderLinks,this.curvedLinks=fe.curvedLinks,this.curvedLinkSegments=fe.curvedLinkSegments,this.curvedLinkWeight=fe.curvedLinkWeight,this.curvedLinkControlPointDistance=fe.curvedLinkControlPointDistance,this.linkArrows=fe.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=fe.linkArrowsSizeScale,this.scaleLinksOnZoom=fe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=fe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=fe.linkVisibilityMinTransparency,this.simulationDecay=fe.simulation.decay,this.simulationGravity=fe.simulation.gravity,this.simulationCenter=fe.simulation.center,this.simulationRepulsion=fe.simulation.repulsion,this.simulationRepulsionTheta=fe.simulation.repulsionTheta,this.simulationLinkSpring=fe.simulation.linkSpring,this.simulationLinkDistance=fe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=fe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=fe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=fe.enableRightClickRepulsion,this.simulationFriction=fe.simulation.friction,this.simulationCluster=fe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=fe.showFPSMonitor,this.pixelRatio=fe.pixelRatio,this.scalePointsOnZoom=fe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=fe.enableZoom,this.enableSimulationDuringZoom=fe.enableSimulationDuringZoom,this.enableDrag=fe.enableDrag,this.fitViewOnInit=fe.fitViewOnInit,this.fitViewDelay=fe.fitViewDelay,this.fitViewPadding=fe.fitViewPadding,this.fitViewDuration=fe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=fe.pointSamplingDistance,this.attribution=fe.attribution,this.rescalePositions=fe.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,n){fx(e[n])&&fx(t[n])?Object.keys(t[n]).forEach(s=>{this.deepMergeConfig(e[n],t[n],s)}):e[n]=t[n]}getConfig(){return this}}function by(i,e){if(!i)throw new Error(e||"shadertools: assertion failed.")}const lm={number:{type:"number",validate(i,e){return Number.isFinite(i)&&typeof e=="object"&&(e.max===void 0||i<=e.max)&&(e.min===void 0||i>=e.min)}},array:{type:"array",validate(i,e){return Array.isArray(i)||ArrayBuffer.isView(i)}}};function fM(i){const e={};for(const[t,n]of Object.entries(i))e[t]=pM(n);return e}function pM(i){let e=px(i);if(e!=="object")return{value:i,...lm[e],type:e};if(typeof i=="object")return i?i.type!==void 0?{...i,...lm[i.type],type:i.type}:i.value===void 0?{type:"object",value:i}:(e=px(i.value),{...i,...lm[e],type:e}):{type:"object",value:null};throw new Error("props")}function px(i){return Array.isArray(i)||ArrayBuffer.isView(i)?"array":typeof i}const mM=`#ifdef MODULE_LOGDEPTH
  logdepth_adjustPosition(gl_Position);
#endif
`,gM=`#ifdef MODULE_MATERIAL
  fragColor = material_filterColor(fragColor);
#endif

#ifdef MODULE_LIGHTING
  fragColor = lighting_filterColor(fragColor);
#endif

#ifdef MODULE_FOG
  fragColor = fog_filterColor(fragColor);
#endif

#ifdef MODULE_PICKING
  fragColor = picking_filterHighlightColor(fragColor);
  fragColor = picking_filterPickingColor(fragColor);
#endif

#ifdef MODULE_LOGDEPTH
  logdepth_setFragDepth();
#endif
`,_M={vertex:mM,fragment:gM},mx=/void\s+main\s*\([^)]*\)\s*\{\n?/,gx=/}\n?[^{}]*$/,cm=[],fh="__LUMA_INJECT_DECLARATIONS__";function yM(i){const e={vertex:{},fragment:{}};for(const t in i){let n=i[t];const s=bM(t);typeof n=="string"&&(n={order:0,injection:n}),e[s][t]=n}return e}function bM(i){const e=i.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function Jh(i,e,t,n=!1){const s=e==="vertex";for(const r in t){const o=t[r];o.sort((l,c)=>l.order-c.order),cm.length=o.length;for(let l=0,c=o.length;l<c;++l)cm[l]=o[l].injection;const a=`${cm.join(`
`)}
`;switch(r){case"vs:#decl":s&&(i=i.replace(fh,a));break;case"vs:#main-start":s&&(i=i.replace(mx,l=>l+a));break;case"vs:#main-end":s&&(i=i.replace(gx,l=>a+l));break;case"fs:#decl":s||(i=i.replace(fh,a));break;case"fs:#main-start":s||(i=i.replace(mx,l=>l+a));break;case"fs:#main-end":s||(i=i.replace(gx,l=>a+l));break;default:i=i.replace(r,l=>l+a)}}return i=i.replace(fh,""),n&&(i=i.replace(/\}\s*$/,r=>r+_M[e])),i}function ef(i){i.map(e=>vM(e))}function vM(i){if(i.instance)return;ef(i.dependencies||[]);const{propTypes:e={},deprecations:t=[],inject:n={}}=i,s={normalizedInjections:yM(n),parsedDeprecations:xM(t)};e&&(s.propValidators=fM(e)),i.instance=s;let r={};e&&(r=Object.entries(e).reduce((o,[a,l])=>{const c=l==null?void 0:l.value;return c&&(o[a]=c),o},{})),i.defaultUniforms={...i.defaultUniforms,...r}}function j2(i,e,t){var n;(n=i.deprecations)==null||n.forEach(s=>{var r;(r=s.regex)!=null&&r.test(e)&&(s.deprecated?t.deprecated(s.old,s.new)():t.removed(s.old,s.new)())})}function xM(i){return i.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),i}function vy(i){ef(i);const e={},t={};H2({modules:i,level:0,moduleMap:e,moduleDepth:t});const n=Object.keys(t).sort((s,r)=>t[r]-t[s]).map(s=>e[s]);return ef(n),n}function H2(i){const{modules:e,level:t,moduleMap:n,moduleDepth:s}=i;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(const r of e)n[r.name]=r,(s[r.name]===void 0||s[r.name]<t)&&(s[r.name]=t);for(const r of e)r.dependencies&&H2({modules:r.dependencies,level:t+1,moduleMap:n,moduleDepth:s})}function wM(i){switch(i==null?void 0:i.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
// Apple optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"nvidia":return`#define NVIDIA_GPU
// Nvidia optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
`;case"intel":return`#define INTEL_GPU
// Intel optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
// Intel's built-in 'tan' function doesn't have acceptable precision
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"amd":return`#define AMD_GPU
`;default:return`#define DEFAULT_GPU
// Prevent driver from optimizing away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
// Headless Chrome's software shader 'tan' function doesn't have acceptable precision
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// If the GPU doesn't have full 32 bits precision, will causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`}}function SM(i,e){var t;if(Number(((t=i.match(/^#version[ \t]+(\d+)/m))==null?void 0:t[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return i=_x(i,EM),i;case"fragment":return i=_x(i,CM),i;default:throw new Error(e)}}const V2=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],EM=[...V2,[Rg("attribute"),"in $1"],[Rg("varying"),"out $1"]],CM=[...V2,[Rg("varying"),"in $1"]];function _x(i,e){for(const[t,n]of e)i=i.replace(t,n);return i}function Rg(i){return new RegExp(`\\b${i}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function G2(i,e){let t="";for(const n in i){const s=i[n];if(t+=`void ${s.signature} {
`,s.header&&(t+=`  ${s.header}`),e[n]){const r=e[n];r.sort((o,a)=>o.order-a.order);for(const o of r)t+=`  ${o.injection}
`}s.footer&&(t+=`  ${s.footer}`),t+=`}
`}return t}function W2(i){const e={vertex:{},fragment:{}};for(const t of i){let n,s;typeof t!="string"?(n=t,s=n.hook):(n={},s=t),s=s.trim();const[r,o]=s.split(":"),a=s.replace(/\(.+/,""),l=Object.assign(n,{signature:o});switch(r){case"vs":e.vertex[a]=l;break;case"fs":e.fragment[a]=l;break;default:throw new Error(r)}}return e}function TM(i,e){return{name:kM(i,e),language:"glsl",version:AM(i)}}function kM(i,e="unnamed"){const t=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(i);return t?t[1]:e}function AM(i){let e=100;const t=i.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){const n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}const Y2=`

${fh}
`,IM=`precision highp float;
`;function LM(i){const e=vy(i.modules||[]);return{source:PM(i.platformInfo,{...i,source:i.source,stage:"vertex",modules:e}),getUniforms:q2(e)}}function RM(i){const{vs:e,fs:t}=i,n=vy(i.modules||[]);return{vs:yx(i.platformInfo,{...i,source:e,stage:"vertex",modules:n}),fs:yx(i.platformInfo,{...i,source:t,stage:"fragment",modules:n}),getUniforms:q2(n)}}function PM(i,e){var t;const{source:n,stage:s,modules:r,hookFunctions:o=[],inject:a={},log:l}=e;by(typeof n=="string","shader source must be a string");const c=n;let u="";const d=W2(o),h={},p={},m={};for(const g in a){const _=typeof a[g]=="string"?{injection:a[g],order:0}:a[g],S=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(S){const E=S[2],x=S[3];E?x==="decl"?p[g]=[_]:m[g]=[_]:h[g]=[_]}else m[g]=[_]}const y=r;for(const g of y){l&&j2(g,c,l);const _=X2(g,"wgsl");u+=_;const S=((t=g.injections)==null?void 0:t[s])||{};for(const E in S){const x=/^(v|f)s:#([\w-]+)$/.exec(E);if(x){const T=x[2]==="decl"?p:m;T[E]=T[E]||[],T[E].push(S[E])}else h[E]=h[E]||[],h[E].push(S[E])}}return u+=Y2,u=Jh(u,s,p),u+=G2(d[s],h),u+=c,u=Jh(u,s,m),u}function yx(i,e){var t;const{source:n,stage:s,language:r="glsl",modules:o,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:d}=e;by(typeof n=="string","shader source must be a string");const h=r==="glsl"?TM(n).version:-1,p=i.shaderLanguageVersion,m=h===100?"#version 100":"#version 300 es",y=n.split(`
`).slice(1).join(`
`),g={};o.forEach(I=>{Object.assign(g,I.defines)}),Object.assign(g,a);let _="";switch(r){case"wgsl":break;case"glsl":_=u?`${m}

// ----- PROLOGUE -------------------------
${`#define SHADER_TYPE_${s.toUpperCase()}`}

${wM(i)}
${s==="fragment"?IM:""}

// ----- APPLICATION DEFINES -------------------------

${NM(g)}

`:`${m}
`;break}const S=W2(l),E={},x={},T={};for(const I in c){const O=typeof c[I]=="string"?{injection:c[I],order:0}:c[I],H=/^(v|f)s:(#)?([\w-]+)$/.exec(I);if(H){const Q=H[2],re=H[3];Q?re==="decl"?x[I]=[O]:T[I]=[O]:E[I]=[O]}else T[I]=[O]}for(const I of o){d&&j2(I,y,d);const O=X2(I,s);_+=O;const H=((t=I.instance)==null?void 0:t.normalizedInjections[s])||{};for(const Q in H){const re=/^(v|f)s:#([\w-]+)$/.exec(Q);if(re){const D=re[2]==="decl"?x:T;D[Q]=D[Q]||[],D[Q].push(H[Q])}else E[Q]=E[Q]||[],E[Q].push(H[Q])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Y2,_=Jh(_,s,x),_+=G2(S[s],E),_+=y,_=Jh(_,s,T),r==="glsl"&&h!==p&&(_=SM(_,s)),_.trim()}function q2(i){return function(e){var t;const n={};for(const s of i){const r=(t=s.getUniforms)==null?void 0:t.call(s,e,n);Object.assign(n,r)}return n}}function NM(i={}){let e="";for(const t in i){const n=i[t];(n||Number.isFinite(n))&&(e+=`#define ${t.toUpperCase()} ${i[t]}
`)}return e}function X2(i,e){let t;switch(e){case"vertex":t=i.vs||"";break;case"fragment":t=i.fs||"";break;case"wgsl":t=i.source||"";break;default:by(!1)}if(!i.name)throw new Error("Shader module must have a name");const n=i.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let s=`// ----- MODULE ${i.name} ---------------

`;return e!=="wgsl"&&(s+=`#define MODULE_${n}
`),s+=`${t}
`,s}const DM=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,MM=/^\s*\#\s*endif\s*$/;function BM(i,e){var t;const n=i.split(`
`),s=[];let r=!0,o=null;for(const a of n){const l=a.match(DM),c=a.match(MM);l?(o=l[1],r=!!((t=void 0)!=null&&t[o])):c?r=!0:r&&s.push(a)}return s.join(`
`)}const K2=class Bc{constructor(){$(this,"_hookFunctions",[]),$(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return Bc.defaultShaderAssembler=Bc.defaultShaderAssembler||new Bc,Bc.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:r}=LM({...e,source:e.source,modules:t,hookFunctions:n});return{source:e.platformInfo.shaderLanguage==="wgsl"?BM(s):s,getUniforms:r,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions;return{...RM({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let s=0;for(let r=0,o=this._defaultModules.length;r<o;++r){const a=this._defaultModules[r],l=a.name;t[s++]=a,n[l]=!0}for(let r=0,o=e.length;r<o;++r){const a=e[r],l=a.name;n[l]||(t[s++]=a,n[l]=!0)}return t.length=s,ef(t),t}};$(K2,"defaultShaderAssembler");let OM=K2;class ms{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class bx{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Fo extends ms{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Uo extends ms{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class Pg extends ms{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class _a extends ms{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}}var No;(i=>{i[i.Uniform=0]="Uniform",i[i.Storage=1]="Storage",i[i.Texture=2]="Texture",i[i.Sampler=3]="Sampler",i[i.StorageTexture=4]="StorageTexture"})(No||(No={}));class Td{constructor(e,t,n,s,r,o,a){this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=r,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class FM{constructor(e,t){this.name=e,this.type=t}}class zM{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}}class vx{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}}class UM{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}}class $M{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class jM{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}}class HM{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function VM(i){var e=(32768&i)>>15,t=(31744&i)>>10,n=1023&i;return t==0?(e?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):t==31?n?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,t-15)*(1+n/Math.pow(2,10))}const Z2=new Float32Array(1),GM=new Int32Array(Z2.buffer),Gi=new Uint16Array(1);function WM(i){Z2[0]=i;const e=GM[0],t=e>>31&1;let n=e>>23&255,s=8388607&e;if(n===255)return Gi[0]=t<<15|31744|(s!==0?512:0),Gi[0];if(n===0){if(s===0)return Gi[0]=t<<15,Gi[0];s|=8388608;let r=113;for(;!(8388608&s);)s<<=1,r--;return n=127-r,s&=8388607,n>0?(s=(s>>126-n)+(s>>127-n&1),Gi[0]=t<<15|n<<10|s>>13,Gi[0]):(Gi[0]=t<<15,Gi[0])}return n=n-127+15,n>=31?(Gi[0]=t<<15|31744,Gi[0]):n<=0?n<-10?(Gi[0]=t<<15,Gi[0]):(s=(8388608|s)>>1-n,Gi[0]=t<<15|s>>13,Gi[0]):(s>>=13,Gi[0]=t<<15|n<<10|s,Gi[0])}const xy=new Uint32Array(1),Q2=new Float32Array(xy.buffer,0,1);function xx(i){const e=112+(i>>6&31)<<23|(63&i)<<17;return xy[0]=e,Q2[0]}function YM(i,e,t,n,s,r,o,a,l){const c=n*(o>>=s)*(r>>=s)+t*o+e*a;switch(l){case"r8unorm":return[Et(i,c,"8unorm",1)[0]];case"r8snorm":return[Et(i,c,"8snorm",1)[0]];case"r8uint":return[Et(i,c,"8uint",1)[0]];case"r8sint":return[Et(i,c,"8sint",1)[0]];case"rg8unorm":{const u=Et(i,c,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=Et(i,c,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=Et(i,c,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=Et(i,c,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=Et(i,c,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=Et(i,c,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=Et(i,c,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=Et(i,c,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=Et(i,c,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[Et(i,c,"16uint",1)[0]];case"r16sint":return[Et(i,c,"16sint",1)[0]];case"r16float":return[Et(i,c,"16float",1)[0]];case"rg16uint":{const u=Et(i,c,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=Et(i,c,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=Et(i,c,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=Et(i,c,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=Et(i,c,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=Et(i,c,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[Et(i,c,"32uint",1)[0]];case"r32sint":return[Et(i,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Et(i,c,"32float",1)[0]];case"rg32uint":{const u=Et(i,c,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=Et(i,c,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=Et(i,c,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=Et(i,c,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=Et(i,c,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=Et(i,c,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(i.buffer,c,1)[0],d=(4192256&u)>>11,h=(4290772992&u)>>22;return[xx(2047&u),xx(d),(function(p){const m=112+(p>>5&31)<<23|(31&p)<<18;return xy[0]=m,Q2[0]})(h),1]}}return null}function Et(i,e,t,n){const s=[0,0,0,0];for(let r=0;r<n;++r)switch(t){case"8unorm":s[r]=i[e]/255,e++;break;case"8snorm":s[r]=i[e]/255*2-1,e++;break;case"8uint":s[r]=i[e],e++;break;case"8sint":s[r]=i[e]-127,e++;break;case"16uint":s[r]=i[e]|i[e+1]<<8,e+=2;break;case"16sint":s[r]=(i[e]|i[e+1]<<8)-32768,e+=2;break;case"16float":s[r]=VM(i[e]|i[e+1]<<8),e+=2;break;case"32uint":case"32sint":s[r]=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24,e+=4;break;case"32float":s[r]=new Float32Array(i.buffer,e,1)[0],e+=4}return s}function Rt(i,e,t,n,s){for(let r=0;r<n;++r)switch(t){case"8unorm":i[e]=255*s[r],e++;break;case"8snorm":i[e]=.5*(s[r]+1)*255,e++;break;case"8uint":i[e]=s[r],e++;break;case"8sint":i[e]=s[r]+127,e++;break;case"16uint":new Uint16Array(i.buffer,e,1)[0]=s[r],e+=2;break;case"16sint":new Int16Array(i.buffer,e,1)[0]=s[r],e+=2;break;case"16float":{const o=WM(s[r]);new Uint16Array(i.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(i.buffer,e,1)[0]=s[r],e+=4;break;case"32sint":new Int32Array(i.buffer,e,1)[0]=s[r],e+=4;break;case"32float":new Float32Array(i.buffer,e,1)[0]=s[r],e+=4}return s}const um={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class ws{constructor(){this.id=ws._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(tf.instance);for(const n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(nf.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}ws._id=0;class tf extends ws{}tf.instance=new tf;class nf extends ws{}nf.instance=new nf;const J2=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class Zt extends ws{constructor(){super()}}class pu extends Zt{constructor(e,t,n,s,r,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=s,this.startLine=r,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class qM extends Zt{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class eE extends Zt{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Ng extends Zt{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class tE extends Zt{constructor(e,t,n,s){super(),this.init=e,this.condition=t,this.increment=n,this.body=s}get astNodeType(){return"for"}search(e){var t,n,s;(t=this.init)===null||t===void 0||t.search(e),(n=this.condition)===null||n===void 0||n.search(e),(s=this.increment)===null||s===void 0||s.search(e),this.searchBlock(this.body,e)}}class Jr extends Zt{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class wy extends Zt{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class tu extends Zt{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class ph extends Zt{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}var tl,Oc,z,P;(i=>{i.increment="++",i.decrement="--"})(tl||(tl={})),(i=>{i.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return i[t]}})(tl||(tl={}));class iE extends Zt{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(i=>{i.assign="=",i.addAssign="+=",i.subtractAssin="-=",i.multiplyAssign="*=",i.divideAssign="/=",i.moduloAssign="%=",i.andAssign="&=",i.orAssign="|=",i.xorAssign="^=",i.shiftLeftAssign="<<=",i.shiftRightAssign=">>="})(Oc||(Oc={})),(i=>{i.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(Oc||(Oc={}));class nE extends Zt{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Sy extends Zt{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return J2.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class sE extends Zt{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),(t=this.continuing)===null||t===void 0||t.search(e)}}class rE extends Zt{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class oE extends Zt{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class aE extends Zt{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class XM extends Zt{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class KM extends Zt{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class lE extends Zt{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class Ey extends Zt{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class ZM extends Zt{constructor(){super()}get astNodeType(){return"discard"}}class cE extends Zt{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}let uE=class extends Zt{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}},Y=class mh extends Zt{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){const s=mh._priority.get(t.name);mh._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?mh.i32:t}getTypeName(){return this.name}};Y.x32=new Y("x32"),Y.f32=new Y("f32"),Y.i32=new Y("i32"),Y.u32=new Y("u32"),Y.f16=new Y("f16"),Y.bool=new Y("bool"),Y.void=new Y("void"),Y._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class wx extends Y{constructor(e){super(e)}}class Kr extends Y{constructor(e,t,n,s){super(e),this.members=t,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}let B=class extends Y{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}};B.vec2f=new B("vec2",Y.f32,null),B.vec3f=new B("vec3",Y.f32,null),B.vec4f=new B("vec4",Y.f32,null),B.vec2i=new B("vec2",Y.i32,null),B.vec3i=new B("vec3",Y.i32,null),B.vec4i=new B("vec4",Y.i32,null),B.vec2u=new B("vec2",Y.u32,null),B.vec3u=new B("vec3",Y.u32,null),B.vec4u=new B("vec4",Y.u32,null),B.vec2h=new B("vec2",Y.f16,null),B.vec3h=new B("vec3",Y.f16,null),B.vec4h=new B("vec4",Y.f16,null),B.vec2b=new B("vec2",Y.bool,null),B.vec3b=new B("vec3",Y.bool,null),B.vec4b=new B("vec4",Y.bool,null),B.mat2x2f=new B("mat2x2",Y.f32,null),B.mat2x3f=new B("mat2x3",Y.f32,null),B.mat2x4f=new B("mat2x4",Y.f32,null),B.mat3x2f=new B("mat3x2",Y.f32,null),B.mat3x3f=new B("mat3x3",Y.f32,null),B.mat3x4f=new B("mat3x4",Y.f32,null),B.mat4x2f=new B("mat4x2",Y.f32,null),B.mat4x3f=new B("mat4x3",Y.f32,null),B.mat4x4f=new B("mat4x4",Y.f32,null),B.mat2x2h=new B("mat2x2",Y.f16,null),B.mat2x3h=new B("mat2x3",Y.f16,null),B.mat2x4h=new B("mat2x4",Y.f16,null),B.mat3x2h=new B("mat3x2",Y.f16,null),B.mat3x3h=new B("mat3x3",Y.f16,null),B.mat3x4h=new B("mat3x4",Y.f16,null),B.mat4x2h=new B("mat4x2",Y.f16,null),B.mat4x3h=new B("mat4x3",Y.f16,null),B.mat4x4h=new B("mat4x4",Y.f16,null),B.mat2x2i=new B("mat2x2",Y.i32,null),B.mat2x3i=new B("mat2x3",Y.i32,null),B.mat2x4i=new B("mat2x4",Y.i32,null),B.mat3x2i=new B("mat3x2",Y.i32,null),B.mat3x3i=new B("mat3x3",Y.i32,null),B.mat3x4i=new B("mat3x4",Y.i32,null),B.mat4x2i=new B("mat4x2",Y.i32,null),B.mat4x3i=new B("mat4x3",Y.i32,null),B.mat4x4i=new B("mat4x4",Y.i32,null),B.mat2x2u=new B("mat2x2",Y.u32,null),B.mat2x3u=new B("mat2x3",Y.u32,null),B.mat2x4u=new B("mat2x4",Y.u32,null),B.mat3x2u=new B("mat3x2",Y.u32,null),B.mat3x3u=new B("mat3x3",Y.u32,null),B.mat3x4u=new B("mat3x4",Y.u32,null),B.mat4x2u=new B("mat4x2",Y.u32,null),B.mat4x3u=new B("mat4x3",Y.u32,null),B.mat4x4u=new B("mat4x4",Y.u32,null);class gh extends Y{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return"pointer"}}class iu extends Y{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}}class Fc extends Y{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}}class Ws extends ws{constructor(){super(),this.postfix=null}}class ya extends Ws{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class ur extends Ws{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class Cy extends Ws{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return J2.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class Hn extends Ws{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class dE extends Ws{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const n=e.evalExpression(this.initializer,e.context);return n!==null&&this.postfix?n.getSubData(e,this.postfix,e.context):n}return null}search(e){this.initializer.search(e)}}class xi extends Ws{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof M}get isVector(){return this.value instanceof k||this.value instanceof Ue}get scalarValue(){return this.value instanceof M?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof k||this.value instanceof Ue?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class hE extends Ws{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class kl extends Ws{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class fE extends Ws{constructor(){super()}}class mi extends fE{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Ds extends fE{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?Y.f32:e.name==="u32"||t.name==="u32"?Y.u32:Y.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class pE extends ws{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class _h extends Ws{constructor(){super()}get astNodeType(){return"default"}}class mE extends pE{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class gE extends pE{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Sx extends ws{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}}class QM extends ws{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Ex extends ws{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}}class _E extends ws{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class _s{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=_s._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}_s._id=0;class Dg extends _s{constructor(){super(new ms("void",null),null)}toString(){return"void"}}Dg.void=new Dg;class Ma extends _s{constructor(e){super(new Pg("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}let M=class zc extends _s{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new zc(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new zc(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new zc(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return void console.error("SetDataValue: Scalar data does not support postfix",n);if(!(t instanceof zc))return void console.error("SetDataValue: Invalid value",t);let r=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?r=Math.floor(r):this.typeInfo.name==="bool"&&(r=r?1:0),this.data[0]=r}getSubData(e,t,n){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}};function JM(i,e,t){const n=e.length;return n===2?t==="f32"?new k(new Float32Array(e),i.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new k(new Int32Array(e),i.getTypeInfo("vec2i")):t==="u32"?new k(new Uint32Array(e),i.getTypeInfo("vec2u")):t==="f16"?new k(new Float32Array(e),i.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):n===3?t==="f32"?new k(new Float32Array(e),i.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new k(new Int32Array(e),i.getTypeInfo("vec3i")):t==="u32"?new k(new Uint32Array(e),i.getTypeInfo("vec3u")):t==="f16"?new k(new Float32Array(e),i.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):n===4?t==="f32"?new k(new Float32Array(e),i.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new k(new Int32Array(e),i.getTypeInfo("vec4i")):t==="u32"?new k(new Uint32Array(e),i.getTypeInfo("vec4u")):t==="f16"?new k(new Float32Array(e),i.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}let k=class Uc extends _s{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const s=this.typeInfo.name;s==="vec2f"||s==="vec3f"||s==="vec4f"?this.data=new Float32Array(e):s==="vec2i"||s==="vec3i"||s==="vec4i"?this.data=new Int32Array(e):s==="vec2u"||s==="vec3u"||s==="vec4u"?this.data=new Uint32Array(e):s==="vec2h"||s==="vec3h"||s==="vec4h"?this.data=new Float32Array(e):s==="vec2b"||s==="vec3b"||s==="vec4b"?this.data=new Int32Array(e):s==="vec2"||s==="vec3"||s==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${s}`)}}clone(){if(this.data instanceof Float32Array)return new Uc(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Uc(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Uc(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,n,s){n instanceof ya?console.error("TODO: Set vector postfix"):t instanceof Uc?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;let s=e.getTypeInfo("f32");if(this.typeInfo instanceof _a)s=this.typeInfo.format||s;else{const o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?s=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?s=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?s=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?s=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?s=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let r=this;for(;t!==null&&r!==null;){if(t instanceof kl){const o=t.index;let a=-1;if(o instanceof xi){if(!(o.value instanceof M))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const l=e.evalExpression(o,n);if(!(l instanceof M))return console.error("GetSubData: Unknown index type",o),null;a=l.value}if(a<0||a>=r.data.length)return console.error("GetSubData: Index out of range",a),null;if(r.data instanceof Float32Array){const l=new Float32Array(r.data.buffer,r.data.byteOffset+4*a,1);return new M(l,s)}if(r.data instanceof Int32Array){const l=new Int32Array(r.data.buffer,r.data.byteOffset+4*a,1);return new M(l,s)}if(r.data instanceof Uint32Array){const l=new Uint32Array(r.data.buffer,r.data.byteOffset+4*a,1);return new M(l,s)}throw"GetSubData: Invalid data type"}if(!(t instanceof ya))return console.error("GetSubData: Unknown postfix",t),null;{const o=t.value.toLowerCase();if(o.length===1){let l=0;if(o==="x"||o==="r")l=0;else if(o==="y"||o==="g")l=1;else if(o==="z"||o==="b")l=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;l=3}if(this.data instanceof Float32Array){let c=new Float32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new M(c,s,this)}if(this.data instanceof Int32Array){let c=new Int32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new M(c,s,this)}if(this.data instanceof Uint32Array){let c=new Uint32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new M(c,s,this)}}const a=[];for(const l of o)l==="x"||l==="r"?a.push(this.data[0]):l==="y"||l==="g"?a.push(this.data[1]):l==="z"||l==="b"?a.push(this.data[2]):l==="w"||l==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${l}`);r=JM(e,a,s.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}},Ue=class Mg extends _s{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new Mg(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,s){n instanceof ya?console.error("TODO: Set matrix postfix"):t instanceof Mg?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;const s=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof _a)this.typeInfo.format;else if(s.endsWith("f"))e.getTypeInfo("f32");else if(s.endsWith("i"))e.getTypeInfo("i32");else if(s.endsWith("u"))e.getTypeInfo("u32");else{if(!s.endsWith("h"))return console.error(`GetDataValue: Unknown type ${s}`),null;e.getTypeInfo("f16")}if(t instanceof kl){const r=t.index;let o=-1;if(r instanceof xi){if(!(r.value instanceof M))return console.error(`GetDataValue: Invalid array index ${r.value}`),null;o=r.value.value}else{const c=e.evalExpression(r,n);if(!(c instanceof M))return console.error("GetDataValue: Unknown index type",r),null;o=c.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const a=s.endsWith("h")?"h":"f";let l;if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h"||s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h")l=new k(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h"||s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h")l=new k(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(s!=="mat2x4"&&s!=="mat2x4f"&&s!=="mat2x4h"&&s!=="mat3x4"&&s!=="mat3x4f"&&s!=="mat3x4h"&&s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${s}`),null;l=new k(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?l.getSubData(e,t.postfix,n):l}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}};class oi extends _s{constructor(e,t,n=0,s=null){super(t,s),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new oi(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,n,s){if(t===null)return void console.log("setDataValue: NULL data.");let r=this.offset,o=this.typeInfo;for(;n;){if(n instanceof kl)if(o instanceof Uo){const a=n.index;if(a instanceof xi){if(!(a.value instanceof M))return void console.error(`SetDataValue: Invalid index type ${a.value}`);r+=a.value.value*o.stride}else{const l=e.evalExpression(a,s);if(!(l instanceof M))return void console.error("SetDataValue: Unknown index type",a);r+=l.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(n instanceof ya))return void console.error("SetDataValue: Unknown postfix type",n);{const a=n.value;if(o instanceof Fo){let l=!1;for(const c of o.members)if(c.name===a){r+=c.offset,o=c.type,l=!0;break}if(!l)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof ms){const l=o.getTypeName();let c=0;if(a==="x"||a==="r")c=0;else if(a==="y"||a==="g")c=1;else if(a==="z"||a==="b")c=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);c=3}if(!(t instanceof M))return void console.error("SetDataValue: Invalid value",t);const u=t.value;return l==="vec2f"?void(new Float32Array(this.buffer,r,2)[c]=u):l==="vec3f"?void(new Float32Array(this.buffer,r,3)[c]=u):l==="vec4f"?void(new Float32Array(this.buffer,r,4)[c]=u):l==="vec2i"?void(new Int32Array(this.buffer,r,2)[c]=u):l==="vec3i"?void(new Int32Array(this.buffer,r,3)[c]=u):l==="vec4i"?void(new Int32Array(this.buffer,r,4)[c]=u):l==="vec2u"?void(new Uint32Array(this.buffer,r,2)[c]=u):l==="vec3u"?void(new Uint32Array(this.buffer,r,3)[c]=u):l==="vec4u"?void(new Uint32Array(this.buffer,r,4)[c]=u):void console.error(`SetDataValue: Type ${l} is not a struct`)}}}n=n.postfix}this.setData(e,t,o,r,s)}setData(e,t,n,s,r){const o=n.getTypeName();if(o!=="f32"&&o!=="f16")if(o!=="i32"&&o!=="atomic<i32>"&&o!=="x32")if(o!=="u32"&&o!=="atomic<u32>")if(o!=="bool"){if(o==="vec2f"||o==="vec2h"){const a=new Float32Array(this.buffer,s,2);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,s,3);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,s,4);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,s,2);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,s,3);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,s,4);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,s,2);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,s,3);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,s,4);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,s,2);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,s,3);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,s,4);return void(t instanceof k?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,s,4);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,s,6);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,s,8);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,s,6);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,s,9);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,s,12);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,s,8);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,s,12);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,s,16);return void(t instanceof Ue?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]))}if(t instanceof oi){if(n===t.typeInfo)return void new Uint8Array(this.buffer,s,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof M&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof M&&(new Uint32Array(this.buffer,s,1)[0]=t.value);else t instanceof M&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof M&&(new Float32Array(this.buffer,s,1)[0]=t.value)}getSubData(e,t,n){var s,r,o;if(t===null)return this;let a=this.offset,l=this.typeInfo;for(;t;){if(t instanceof kl){const u=t.index,d=u instanceof Ws?e.evalExpression(u,n):u;let h=0;if(d instanceof M?h=d.value:typeof d=="number"?h=d:console.error("GetDataValue: Invalid index type",u),l instanceof Uo)a+=h*l.stride,l=l.format;else{const p=l.getTypeName();p==="mat4x4"||p==="mat4x4f"||p==="mat4x4h"?(a+=16*h,l=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${l.getTypeName()} is not an array`)}}else{if(!(t instanceof ya))return console.error("GetDataValue: Unknown postfix type",t),null;{const u=t.value;if(l instanceof Fo){let d=!1;for(const h of l.members)if(h.name===u){a+=h.offset,l=h.type,d=!0;break}if(!d)return console.error(`GetDataValue: Member ${u} not found`),null}else if(l instanceof ms){const d=l.getTypeName();if(d==="vec2f"||d==="vec3f"||d==="vec4f"||d==="vec2i"||d==="vec3i"||d==="vec4i"||d==="vec2u"||d==="vec3u"||d==="vec4u"||d==="vec2b"||d==="vec3b"||d==="vec4b"||d==="vec2h"||d==="vec3h"||d==="vec4h"||d==="vec2"||d==="vec3"||d==="vec4"){if(u.length>0&&u.length<5){let h="f";const p=[];for(let m=0;m<u.length;++m){const y=u[m].toLowerCase();let g=0;if(y==="x"||y==="r")g=0;else if(y==="y"||y==="g")g=1;else if(y==="z"||y==="b")g=2;else{if(y!=="w"&&y!=="a")return console.error(`Unknown member ${u}`),null;g=3}if(u.length===1){if(d.endsWith("f"))return this.buffer.byteLength<a+4*g+4?(console.log("Insufficient buffer data"),null):new M(new Float32Array(this.buffer,a+4*g,1),e.getTypeInfo("f32"),this);if(d.endsWith("h"))return new M(new Float32Array(this.buffer,a+4*g,1),e.getTypeInfo("f16"),this);if(d.endsWith("i"))return new M(new Int32Array(this.buffer,a+4*g,1),e.getTypeInfo("i32"),this);if(d.endsWith("b"))return new M(new Int32Array(this.buffer,a+4*g,1),e.getTypeInfo("bool"),this);if(d.endsWith("u"))return new M(new Uint32Array(this.buffer,a+4*g,1),e.getTypeInfo("i32"),this)}if(d==="vec2f")p.push(new Float32Array(this.buffer,a,2)[g]);else if(d==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const _=new Float32Array(this.buffer,a,3);p.push(_[g])}else if(d==="vec4f")p.push(new Float32Array(this.buffer,a,4)[g]);else if(d==="vec2i")h="i",p.push(new Int32Array(this.buffer,a,2)[g]);else if(d==="vec3i")h="i",p.push(new Int32Array(this.buffer,a,3)[g]);else if(d==="vec4i")h="i",p.push(new Int32Array(this.buffer,a,4)[g]);else if(d==="vec2u"){h="u";const _=new Uint32Array(this.buffer,a,2);p.push(_[g])}else d==="vec3u"?(h="u",p.push(new Uint32Array(this.buffer,a,3)[g])):d==="vec4u"&&(h="u",p.push(new Uint32Array(this.buffer,a,4)[g]))}return p.length===2?l=e.getTypeInfo(`vec2${h}`):p.length===3?l=e.getTypeInfo(`vec3${h}`):p.length===4?l=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${p.length}`),new k(p,l,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${d} is not a struct`),null}}}t=t.postfix}const c=l.getTypeName();return c==="f32"?new M(new Float32Array(this.buffer,a,1),l,this):c==="i32"?new M(new Int32Array(this.buffer,a,1),l,this):c==="u32"?new M(new Uint32Array(this.buffer,a,1),l,this):c==="vec2f"?new k(new Float32Array(this.buffer,a,2),l,this):c==="vec3f"?new k(new Float32Array(this.buffer,a,3),l,this):c==="vec4f"?new k(new Float32Array(this.buffer,a,4),l,this):c==="vec2i"?new k(new Int32Array(this.buffer,a,2),l,this):c==="vec3i"?new k(new Int32Array(this.buffer,a,3),l,this):c==="vec4i"?new k(new Int32Array(this.buffer,a,4),l,this):c==="vec2u"?new k(new Uint32Array(this.buffer,a,2),l,this):c==="vec3u"?new k(new Uint32Array(this.buffer,a,3),l,this):c==="vec4u"?new k(new Uint32Array(this.buffer,a,4),l,this):l instanceof _a&&l.name==="atomic"?((s=l.format)===null||s===void 0?void 0:s.name)==="u32"?new M(new Uint32Array(this.buffer,a,1)[0],l.format,this):((r=l.format)===null||r===void 0?void 0:r.name)==="i32"?new M(new Int32Array(this.buffer,a,1)[0],l.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=l.format)===null||o===void 0?void 0:o.name}`),null):new oi(this.buffer,l,a,this)}toString(){let e="";if(this.typeInfo instanceof Uo)if(this.typeInfo.format.name==="f32"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="i32"){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="u32"){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="vec2f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let n=1;n<t.length/2;++n)e+=`, [${t[2*n]}, ${t[2*n+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}, ${t[n+3]}]`}else e="[...]";else this.typeInfo instanceof Fo?e+="{...}":e="[...]";return e}}class Zr extends _s{constructor(e,t,n,s){super(t,null),this.data=e,this.descriptor=n,this.view=s}clone(){return new Zr(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>0?(e=n[0])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.width)!==null&&t!==void 0?t:0}get height(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>1?(e=n[1])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>2?(e=n[2])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n<t.length;++n)t[n]=Math.max(1,t[n]>>e);return t}get texelByteSize(){const e=this.format,t=um[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=um[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=um[e],n=this.width;if(!e||n<=0||!t)return-1;const s=this.height,r=this.depthOrArrayLayers,o=this.dimension;return n/t.blockWidth*(o==="1d"?1:s/t.blockHeight)*t.bytesPerBlock*r}getPixel(e,t,n=0,s=0){const r=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[s];return YM(new Uint8Array(l),e,t,n,s,a,o,r,this.format)}setPixel(e,t,n,s,r){const o=this.texelByteSize,a=this.bytesPerRow,l=this.height,c=this.data[s];(function(u,d,h,p,m,y,g,_,S,E){const x=p*(g>>=m)*(y>>=m)+h*g+d*_;switch(S){case"r8unorm":return void Rt(u,x,"8unorm",1,E);case"r8snorm":return void Rt(u,x,"8snorm",1,E);case"r8uint":return void Rt(u,x,"8uint",1,E);case"r8sint":return void Rt(u,x,"8sint",1,E);case"rg8unorm":return void Rt(u,x,"8unorm",2,E);case"rg8snorm":return void Rt(u,x,"8snorm",2,E);case"rg8uint":return void Rt(u,x,"8uint",2,E);case"rg8sint":return void Rt(u,x,"8sint",2,E);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Rt(u,x,"8unorm",4,E);case"rgba8snorm":return void Rt(u,x,"8snorm",4,E);case"rgba8uint":return void Rt(u,x,"8uint",4,E);case"rgba8sint":return void Rt(u,x,"8sint",4,E);case"r16uint":return void Rt(u,x,"16uint",1,E);case"r16sint":return void Rt(u,x,"16sint",1,E);case"r16float":return void Rt(u,x,"16float",1,E);case"rg16uint":return void Rt(u,x,"16uint",2,E);case"rg16sint":return void Rt(u,x,"16sint",2,E);case"rg16float":return void Rt(u,x,"16float",2,E);case"rgba16uint":return void Rt(u,x,"16uint",4,E);case"rgba16sint":return void Rt(u,x,"16sint",4,E);case"rgba16float":return void Rt(u,x,"16float",4,E);case"r32uint":return void Rt(u,x,"32uint",1,E);case"r32sint":return void Rt(u,x,"32sint",1,E);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Rt(u,x,"32float",1,E);case"rg32uint":return void Rt(u,x,"32uint",2,E);case"rg32sint":return void Rt(u,x,"32sint",2,E);case"rg32float":return void Rt(u,x,"32float",2,E);case"rgba32uint":return void Rt(u,x,"32uint",4,E);case"rgba32sint":return void Rt(u,x,"32sint",4,E);case"rgba32float":return void Rt(u,x,"32float",4,E);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(c),e,t,n,s,l,a,o,this.format,r)}}(i=>{i[i.token=0]="token",i[i.keyword=1]="keyword",i[i.reserved=2]="reserved"})(P||(P={}));let N=class{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}},w=class{};z=w,w.none=new N("",P.reserved,""),w.eof=new N("EOF",P.token,""),w.reserved={asm:new N("asm",P.reserved,"asm"),bf16:new N("bf16",P.reserved,"bf16"),do:new N("do",P.reserved,"do"),enum:new N("enum",P.reserved,"enum"),f16:new N("f16",P.reserved,"f16"),f64:new N("f64",P.reserved,"f64"),handle:new N("handle",P.reserved,"handle"),i8:new N("i8",P.reserved,"i8"),i16:new N("i16",P.reserved,"i16"),i64:new N("i64",P.reserved,"i64"),mat:new N("mat",P.reserved,"mat"),premerge:new N("premerge",P.reserved,"premerge"),regardless:new N("regardless",P.reserved,"regardless"),typedef:new N("typedef",P.reserved,"typedef"),u8:new N("u8",P.reserved,"u8"),u16:new N("u16",P.reserved,"u16"),u64:new N("u64",P.reserved,"u64"),unless:new N("unless",P.reserved,"unless"),using:new N("using",P.reserved,"using"),vec:new N("vec",P.reserved,"vec"),void:new N("void",P.reserved,"void")},w.keywords={array:new N("array",P.keyword,"array"),atomic:new N("atomic",P.keyword,"atomic"),bool:new N("bool",P.keyword,"bool"),f32:new N("f32",P.keyword,"f32"),i32:new N("i32",P.keyword,"i32"),mat2x2:new N("mat2x2",P.keyword,"mat2x2"),mat2x3:new N("mat2x3",P.keyword,"mat2x3"),mat2x4:new N("mat2x4",P.keyword,"mat2x4"),mat3x2:new N("mat3x2",P.keyword,"mat3x2"),mat3x3:new N("mat3x3",P.keyword,"mat3x3"),mat3x4:new N("mat3x4",P.keyword,"mat3x4"),mat4x2:new N("mat4x2",P.keyword,"mat4x2"),mat4x3:new N("mat4x3",P.keyword,"mat4x3"),mat4x4:new N("mat4x4",P.keyword,"mat4x4"),ptr:new N("ptr",P.keyword,"ptr"),sampler:new N("sampler",P.keyword,"sampler"),sampler_comparison:new N("sampler_comparison",P.keyword,"sampler_comparison"),struct:new N("struct",P.keyword,"struct"),texture_1d:new N("texture_1d",P.keyword,"texture_1d"),texture_2d:new N("texture_2d",P.keyword,"texture_2d"),texture_2d_array:new N("texture_2d_array",P.keyword,"texture_2d_array"),texture_3d:new N("texture_3d",P.keyword,"texture_3d"),texture_cube:new N("texture_cube",P.keyword,"texture_cube"),texture_cube_array:new N("texture_cube_array",P.keyword,"texture_cube_array"),texture_multisampled_2d:new N("texture_multisampled_2d",P.keyword,"texture_multisampled_2d"),texture_storage_1d:new N("texture_storage_1d",P.keyword,"texture_storage_1d"),texture_storage_2d:new N("texture_storage_2d",P.keyword,"texture_storage_2d"),texture_storage_2d_array:new N("texture_storage_2d_array",P.keyword,"texture_storage_2d_array"),texture_storage_3d:new N("texture_storage_3d",P.keyword,"texture_storage_3d"),texture_depth_2d:new N("texture_depth_2d",P.keyword,"texture_depth_2d"),texture_depth_2d_array:new N("texture_depth_2d_array",P.keyword,"texture_depth_2d_array"),texture_depth_cube:new N("texture_depth_cube",P.keyword,"texture_depth_cube"),texture_depth_cube_array:new N("texture_depth_cube_array",P.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new N("texture_depth_multisampled_2d",P.keyword,"texture_depth_multisampled_2d"),texture_external:new N("texture_external",P.keyword,"texture_external"),u32:new N("u32",P.keyword,"u32"),vec2:new N("vec2",P.keyword,"vec2"),vec3:new N("vec3",P.keyword,"vec3"),vec4:new N("vec4",P.keyword,"vec4"),bitcast:new N("bitcast",P.keyword,"bitcast"),block:new N("block",P.keyword,"block"),break:new N("break",P.keyword,"break"),case:new N("case",P.keyword,"case"),continue:new N("continue",P.keyword,"continue"),continuing:new N("continuing",P.keyword,"continuing"),default:new N("default",P.keyword,"default"),diagnostic:new N("diagnostic",P.keyword,"diagnostic"),discard:new N("discard",P.keyword,"discard"),else:new N("else",P.keyword,"else"),enable:new N("enable",P.keyword,"enable"),fallthrough:new N("fallthrough",P.keyword,"fallthrough"),false:new N("false",P.keyword,"false"),fn:new N("fn",P.keyword,"fn"),for:new N("for",P.keyword,"for"),function:new N("function",P.keyword,"function"),if:new N("if",P.keyword,"if"),let:new N("let",P.keyword,"let"),const:new N("const",P.keyword,"const"),loop:new N("loop",P.keyword,"loop"),while:new N("while",P.keyword,"while"),private:new N("private",P.keyword,"private"),read:new N("read",P.keyword,"read"),read_write:new N("read_write",P.keyword,"read_write"),return:new N("return",P.keyword,"return"),requires:new N("requires",P.keyword,"requires"),storage:new N("storage",P.keyword,"storage"),switch:new N("switch",P.keyword,"switch"),true:new N("true",P.keyword,"true"),alias:new N("alias",P.keyword,"alias"),type:new N("type",P.keyword,"type"),uniform:new N("uniform",P.keyword,"uniform"),var:new N("var",P.keyword,"var"),override:new N("override",P.keyword,"override"),workgroup:new N("workgroup",P.keyword,"workgroup"),write:new N("write",P.keyword,"write"),r8unorm:new N("r8unorm",P.keyword,"r8unorm"),r8snorm:new N("r8snorm",P.keyword,"r8snorm"),r8uint:new N("r8uint",P.keyword,"r8uint"),r8sint:new N("r8sint",P.keyword,"r8sint"),r16uint:new N("r16uint",P.keyword,"r16uint"),r16sint:new N("r16sint",P.keyword,"r16sint"),r16float:new N("r16float",P.keyword,"r16float"),rg8unorm:new N("rg8unorm",P.keyword,"rg8unorm"),rg8snorm:new N("rg8snorm",P.keyword,"rg8snorm"),rg8uint:new N("rg8uint",P.keyword,"rg8uint"),rg8sint:new N("rg8sint",P.keyword,"rg8sint"),r32uint:new N("r32uint",P.keyword,"r32uint"),r32sint:new N("r32sint",P.keyword,"r32sint"),r32float:new N("r32float",P.keyword,"r32float"),rg16uint:new N("rg16uint",P.keyword,"rg16uint"),rg16sint:new N("rg16sint",P.keyword,"rg16sint"),rg16float:new N("rg16float",P.keyword,"rg16float"),rgba8unorm:new N("rgba8unorm",P.keyword,"rgba8unorm"),rgba8unorm_srgb:new N("rgba8unorm_srgb",P.keyword,"rgba8unorm_srgb"),rgba8snorm:new N("rgba8snorm",P.keyword,"rgba8snorm"),rgba8uint:new N("rgba8uint",P.keyword,"rgba8uint"),rgba8sint:new N("rgba8sint",P.keyword,"rgba8sint"),bgra8unorm:new N("bgra8unorm",P.keyword,"bgra8unorm"),bgra8unorm_srgb:new N("bgra8unorm_srgb",P.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new N("rgb10a2unorm",P.keyword,"rgb10a2unorm"),rg11b10float:new N("rg11b10float",P.keyword,"rg11b10float"),rg32uint:new N("rg32uint",P.keyword,"rg32uint"),rg32sint:new N("rg32sint",P.keyword,"rg32sint"),rg32float:new N("rg32float",P.keyword,"rg32float"),rgba16uint:new N("rgba16uint",P.keyword,"rgba16uint"),rgba16sint:new N("rgba16sint",P.keyword,"rgba16sint"),rgba16float:new N("rgba16float",P.keyword,"rgba16float"),rgba32uint:new N("rgba32uint",P.keyword,"rgba32uint"),rgba32sint:new N("rgba32sint",P.keyword,"rgba32sint"),rgba32float:new N("rgba32float",P.keyword,"rgba32float"),static_assert:new N("static_assert",P.keyword,"static_assert")},w.tokens={decimal_float_literal:new N("decimal_float_literal",P.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new N("hex_float_literal",P.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new N("int_literal",P.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new N("uint_literal",P.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new N("name",P.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new N("ident",P.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new N("and",P.token,"&"),and_and:new N("and_and",P.token,"&&"),arrow:new N("arrow ",P.token,"->"),attr:new N("attr",P.token,"@"),forward_slash:new N("forward_slash",P.token,"/"),bang:new N("bang",P.token,"!"),bracket_left:new N("bracket_left",P.token,"["),bracket_right:new N("bracket_right",P.token,"]"),brace_left:new N("brace_left",P.token,"{"),brace_right:new N("brace_right",P.token,"}"),colon:new N("colon",P.token,":"),comma:new N("comma",P.token,","),equal:new N("equal",P.token,"="),equal_equal:new N("equal_equal",P.token,"=="),not_equal:new N("not_equal",P.token,"!="),greater_than:new N("greater_than",P.token,">"),greater_than_equal:new N("greater_than_equal",P.token,">="),shift_right:new N("shift_right",P.token,">>"),less_than:new N("less_than",P.token,"<"),less_than_equal:new N("less_than_equal",P.token,"<="),shift_left:new N("shift_left",P.token,"<<"),modulo:new N("modulo",P.token,"%"),minus:new N("minus",P.token,"-"),minus_minus:new N("minus_minus",P.token,"--"),period:new N("period",P.token,"."),plus:new N("plus",P.token,"+"),plus_plus:new N("plus_plus",P.token,"++"),or:new N("or",P.token,"|"),or_or:new N("or_or",P.token,"||"),paren_left:new N("paren_left",P.token,"("),paren_right:new N("paren_right",P.token,")"),semicolon:new N("semicolon",P.token,";"),star:new N("star",P.token,"*"),tilde:new N("tilde",P.token,"~"),underscore:new N("underscore",P.token,"_"),xor:new N("xor",P.token,"^"),plus_equal:new N("plus_equal",P.token,"+="),minus_equal:new N("minus_equal",P.token,"-="),times_equal:new N("times_equal",P.token,"*="),division_equal:new N("division_equal",P.token,"/="),modulo_equal:new N("modulo_equal",P.token,"%="),and_equal:new N("and_equal",P.token,"&="),or_equal:new N("or_equal",P.token,"|="),xor_equal:new N("xor_equal",P.token,"^="),shift_right_equal:new N("shift_right_equal",P.token,">>="),shift_left_equal:new N("shift_left_equal",P.token,"<<=")},w.simpleTokens={"@":z.tokens.attr,"{":z.tokens.brace_left,"}":z.tokens.brace_right,":":z.tokens.colon,",":z.tokens.comma,"(":z.tokens.paren_left,")":z.tokens.paren_right,";":z.tokens.semicolon},w.literalTokens={"&":z.tokens.and,"&&":z.tokens.and_and,"->":z.tokens.arrow,"/":z.tokens.forward_slash,"!":z.tokens.bang,"[":z.tokens.bracket_left,"]":z.tokens.bracket_right,"=":z.tokens.equal,"==":z.tokens.equal_equal,"!=":z.tokens.not_equal,">":z.tokens.greater_than,">=":z.tokens.greater_than_equal,">>":z.tokens.shift_right,"<":z.tokens.less_than,"<=":z.tokens.less_than_equal,"<<":z.tokens.shift_left,"%":z.tokens.modulo,"-":z.tokens.minus,"--":z.tokens.minus_minus,".":z.tokens.period,"+":z.tokens.plus,"++":z.tokens.plus_plus,"|":z.tokens.or,"||":z.tokens.or_or,"*":z.tokens.star,"~":z.tokens.tilde,_:z.tokens.underscore,"^":z.tokens.xor,"+=":z.tokens.plus_equal,"-=":z.tokens.minus_equal,"*=":z.tokens.times_equal,"/=":z.tokens.division_equal,"%=":z.tokens.modulo_equal,"&=":z.tokens.and_equal,"|=":z.tokens.or_equal,"^=":z.tokens.xor_equal,">>=":z.tokens.shift_right_equal,"<<=":z.tokens.shift_left_equal},w.regexTokens={decimal_float_literal:z.tokens.decimal_float_literal,hex_float_literal:z.tokens.hex_float_literal,int_literal:z.tokens.int_literal,uint_literal:z.tokens.uint_literal,ident:z.tokens.ident},w.storage_class=[z.keywords.function,z.keywords.private,z.keywords.workgroup,z.keywords.uniform,z.keywords.storage],w.access_mode=[z.keywords.read,z.keywords.write,z.keywords.read_write],w.sampler_type=[z.keywords.sampler,z.keywords.sampler_comparison],w.sampled_texture_type=[z.keywords.texture_1d,z.keywords.texture_2d,z.keywords.texture_2d_array,z.keywords.texture_3d,z.keywords.texture_cube,z.keywords.texture_cube_array],w.multisampled_texture_type=[z.keywords.texture_multisampled_2d],w.storage_texture_type=[z.keywords.texture_storage_1d,z.keywords.texture_storage_2d,z.keywords.texture_storage_2d_array,z.keywords.texture_storage_3d],w.depth_texture_type=[z.keywords.texture_depth_2d,z.keywords.texture_depth_2d_array,z.keywords.texture_depth_cube,z.keywords.texture_depth_cube_array,z.keywords.texture_depth_multisampled_2d],w.texture_external_type=[z.keywords.texture_external],w.any_texture_type=[...z.sampled_texture_type,...z.multisampled_texture_type,...z.storage_texture_type,...z.depth_texture_type,...z.texture_external_type],w.texel_format=[z.keywords.r8unorm,z.keywords.r8snorm,z.keywords.r8uint,z.keywords.r8sint,z.keywords.r16uint,z.keywords.r16sint,z.keywords.r16float,z.keywords.rg8unorm,z.keywords.rg8snorm,z.keywords.rg8uint,z.keywords.rg8sint,z.keywords.r32uint,z.keywords.r32sint,z.keywords.r32float,z.keywords.rg16uint,z.keywords.rg16sint,z.keywords.rg16float,z.keywords.rgba8unorm,z.keywords.rgba8unorm_srgb,z.keywords.rgba8snorm,z.keywords.rgba8uint,z.keywords.rgba8sint,z.keywords.bgra8unorm,z.keywords.bgra8unorm_srgb,z.keywords.rgb10a2unorm,z.keywords.rg11b10float,z.keywords.rg32uint,z.keywords.rg32sint,z.keywords.rg32float,z.keywords.rgba16uint,z.keywords.rgba16sint,z.keywords.rgba16float,z.keywords.rgba32uint,z.keywords.rgba32sint,z.keywords.rgba32float],w.const_literal=[z.tokens.int_literal,z.tokens.uint_literal,z.tokens.decimal_float_literal,z.tokens.hex_float_literal,z.keywords.true,z.keywords.false],w.literal_or_ident=[z.tokens.ident,z.tokens.int_literal,z.tokens.uint_literal,z.tokens.decimal_float_literal,z.tokens.hex_float_literal,z.tokens.name],w.element_count_expression=[z.tokens.int_literal,z.tokens.uint_literal,z.tokens.ident],w.template_types=[z.keywords.vec2,z.keywords.vec3,z.keywords.vec4,z.keywords.mat2x2,z.keywords.mat2x3,z.keywords.mat2x4,z.keywords.mat3x2,z.keywords.mat3x3,z.keywords.mat3x4,z.keywords.mat4x2,z.keywords.mat4x3,z.keywords.mat4x4,z.keywords.atomic,z.keywords.bitcast,...z.any_texture_type],w.attribute_name=[z.tokens.ident,z.keywords.block,z.keywords.diagnostic],w.assignment_operators=[z.tokens.equal,z.tokens.plus_equal,z.tokens.minus_equal,z.tokens.times_equal,z.tokens.division_equal,z.tokens.modulo_equal,z.tokens.and_equal,z.tokens.or_equal,z.tokens.xor_equal,z.tokens.shift_right_equal,z.tokens.shift_left_equal],w.increment_operators=[z.tokens.plus_plus,z.tokens.minus_minus];class Cx{constructor(e,t,n,s,r){this.type=e,this.lexeme=t,this.line=n,this.start=s,this.end=r}toString(){return this.lexeme}isTemplateType(){return w.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==w.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class eB{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Cx(w.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if(this._peekAhead()=="*"){this._advance();let o=1;for(;o>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}const t=w.simpleTokens[e];if(t)return this._addToken(t),!0;let n=w.none;const s=this._isAlpha(e),r=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(s){const o=w.keywords[e];if(o)return this._addToken(o),!0}if(s||r)return this._addToken(w.tokens.ident),!0;for(;;){let o=this._findType(e);const a=this._peekAhead();if(e=="-"&&this._tokens.length>0){if(a=="=")return this._current++,e+=a,this._addToken(w.tokens.minus_equal),!0;if(a=="-")return this._current++,e+=a,this._addToken(w.tokens.minus_minus),!0;const l=this._tokens.length-1;if((w.literal_or_ident.indexOf(this._tokens[l].type)!=-1||this._tokens[l].type==w.tokens.paren_right)&&a!=">")return this._addToken(o),!0}if(e==">"&&(a==">"||a=="=")){let l=!1,c=this._tokens.length-1;for(let u=0;u<5&&c>=0&&w.assignment_operators.indexOf(this._tokens[c].type)===-1;++u,--c)if(this._tokens[c].type===w.tokens.less_than){c>0&&this._tokens[c-1].isArrayOrTemplateType()&&(l=!0);break}if(l)return this._addToken(o),!0}if(o===w.none){let l=e,c=0;const u=2;for(let d=0;d<u;++d)if(l+=this._peekAhead(d),o=this._findType(l),o!==w.none){c=d;break}if(o===w.none)return n!==w.none&&(this._current--,this._addToken(n),!0);e=l,this._current+=c+1}if(n=o,this._isAtEnd())break;e+=this._advance()}return n!==w.none&&(this._addToken(n),!0)}_findType(e){for(const t in w.regexTokens){const n=w.regexTokens[t];if(this._match(e,n.rule))return n}return w.literalTokens[e]||w.none}_match(e,t){const n=t.exec(e);return n&&n.index==0&&n[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&e!=="_"&&e!=="."&&e!=="("&&e!==")"&&e!=="["&&e!=="]"&&e!=="{"&&e!=="}"&&e!==","&&e!==";"&&e!==":"&&e!=="="&&e!=="!"&&e!=="<"&&e!==">"&&e!=="+"&&e!=="-"&&e!=="*"&&e!=="/"&&e!=="%"&&e!=="&"&&e!=="|"&&e!=="^"&&e!=="~"&&e!=="@"&&e!=="#"&&e!=="?"&&e!=="'"&&e!=="`"&&e!=='"'&&e!=="\\"&&e!==`
`&&e!=="\r"&&e!=="	"&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e=="	"||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Cx(e,t,this._line,this._start,this._current))}}function ce(i){return Array.isArray(i)||(i==null?void 0:i.buffer)instanceof ArrayBuffer}const sf=new Float32Array(1),tB=new Uint32Array(sf.buffer),iB=new Uint32Array(sf.buffer),rf=new Int32Array(1),nB=new Float32Array(rf.buffer),sB=new Uint32Array(rf.buffer),of=new Uint32Array(1),rB=new Float32Array(of.buffer),oB=new Int32Array(of.buffer);function Tx(i,e,t){if(e===t)return i;if(e==="f32"){if(t==="i32"||t==="x32")return sf[0]=i,tB[0];if(t==="u32")return sf[0]=i,iB[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return rf[0]=i,nB[0];if(t==="u32")return rf[0]=i,sB[0]}else if(e==="u32"){if(t==="f32")return of[0]=i,rB[0];if(t==="i32"||t==="x32")return of[0]=i,oB[0]}return console.error(`Unsupported cast from ${e} to ${t}`),i}class aB{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class kd{constructor(e,t){this.align=e,this.size=t}}class mr{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new HM,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(const t of e)t instanceof pu&&this._functions.set(t.name,new aB(t));for(const t of e)if(t instanceof Kr){const n=this.getTypeInfo(t,null);n instanceof Fo&&this.structs.push(n)}for(const t of e)if(t instanceof Ey)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof wy){const n=t,s=this._getAttributeNum(n.attributes,"id",0),r=n.type!=null?this.getTypeInfo(n.type,n.attributes):null;this.overrides.push(new UM(n.name,r,n.attributes,s));continue}if(this._isUniformVar(t)){const n=t,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Td(n.name,o,s,r,n.attributes,No.Uniform,n.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){const n=t,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),l=new Td(n.name,o,s,r,n.attributes,a?No.StorageTexture:No.Storage,n.access);l.access||(l.access="read"),this.storage.push(l);continue}if(this._isTextureVar(t)){const n=t,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),l=new Td(n.name,o,s,r,n.attributes,a?No.StorageTexture:No.Texture,n.access);l.access||(l.access="read"),a?this.storage.push(l):this.textures.push(l);continue}if(this._isSamplerVar(t)){const n=t,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Td(n.name,o,s,r,n.attributes,No.Sampler,n.access);this.samplers.push(a);continue}}for(const t of e)if(t instanceof pu){const n=this._getAttribute(t,"vertex"),s=this._getAttribute(t,"fragment"),r=this._getAttribute(t,"compute"),o=n||s||r,a=new jM(t.name,o==null?void 0:o.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(l=>new $M(l.name,this.getTypeInfo(l.type,l.attributes),l.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(n=>{var s,r,o;if(n instanceof _E){if(n.value)if(ce(n.value))for(const a of n.value)for(const l of this.overrides)a===l.name&&((s=t.info)===null||s===void 0||s.overrides.push(l));else for(const a of this.overrides)n.value===a.name&&((r=t.info)===null||r===void 0||r.overrides.push(a))}else if(n instanceof Hn)for(const a of this.overrides)n.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var n;for(const s of e.calls){const r=(n=this._functions.get(s.name))===null||n===void 0?void 0:n.info;r&&t.add(r)}}findResource(e,t,n){if(n){for(const s of this.entry.compute)if(s.name===n){for(const r of s.resources)if(r.group==e&&r.binding==t)return r}for(const s of this.entry.vertex)if(s.name===n){for(const r of s.resources)if(r.group==e&&r.binding==t)return r}for(const s of this.entry.fragment)if(s.name===n){for(const r of s.resources)if(r.group==e&&r.binding==t)return r}}for(const s of this.uniforms)if(s.group==e&&s.binding==t)return s;for(const s of this.storage)if(s.group==e&&s.binding==t)return s;for(const s of this.textures)if(s.group==e&&s.binding==t)return s;for(const s of this.samplers)if(s.group==e&&s.binding==t)return s;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const n=[],s=this,r=[];return e.search(o=>{if(o instanceof tf)r.push({});else if(o instanceof nf)r.pop();else if(o instanceof Jr){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),r.length>0&&(r[r.length-1][a.name]=a)}else if(o instanceof ur){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof tu){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),r.length>0&&(r[r.length-1][a.name]=a)}else if(o instanceof Hn){const a=o;if(r.length>0&&r[r.length-1][a.name])return;const l=s._findResource(a.name);l&&n.push(l)}else if(o instanceof Cy){const a=o,l=s._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=s._findResources(l.node,t)),n.push(...l.resources))}else if(o instanceof Sy){const a=o,l=s._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=s._findResources(l.node,t)),n.push(...l.resources))}}),[...new Map(n.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function t(n,s){n>=e.length&&(e.length=n+1),e[n]===void 0&&(e[n]=[]),s>=e[n].length&&(e[n].length=s+1)}for(const n of this.uniforms)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.storage)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.textures)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.samplers)t(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof Kr)this._getStructOutputs(e,t);else{const n=this._getOutputInfo(e);n!==null&&t.push(n)}return t}_getStructOutputs(e,t){for(const n of e.members)if(n.type instanceof Kr)this._getStructOutputs(n.type,t);else{const s=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(s!==null){const r=this.getTypeInfo(n.type,n.type.attributes),o=this._parseInt(s.value),a=new vx(n.name,r,s.name,o);t.push(a)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const n=this.getTypeInfo(e,e.attributes),s=this._parseInt(t.value);return new vx("",n,t.name,s)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(const n of e)if(n.type instanceof Kr)this._getStructInputs(n.type,t);else{const s=this._getInputInfo(n);s!==null&&t.push(s)}return t}_getStructInputs(e,t){for(const n of e.members)if(n.type instanceof Kr)this._getStructInputs(n.type,t);else{const s=this._getInputInfo(n);s!==null&&t.push(s)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const n=this._getAttribute(e,"interpolation"),s=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(t.value),o=new zM(e.name,s,t.name,r);return n!==null&&(o.interpolation=this._parseString(n.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new FM(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof gh){const s=e.type?this.getTypeInfo(e.type,e.attributes):null,r=new Pg(e.name,s,t);return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof iu){const s=e,r=s.format?this.getTypeInfo(s.format,s.attributes):null,o=new Uo(s.name,t);return o.format=r,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof Kr){const s=e,r=new Fo(s.name,t);r.startLine=s.startLine,r.endLine=s.endLine;for(const o of s.members){const a=this.getTypeInfo(o.type,o.attributes);r.members.push(new bx(o.name,a,o.attributes))}return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof Fc){const s=e,r=s.format instanceof Y,o=s.format?r?this.getTypeInfo(s.format,null):new ms(s.format,null):null,a=new _a(s.name,o,t,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof B){const s=e,r=s.format?this.getTypeInfo(s.format,null):null,o=new _a(s.name,r,t,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const n=new ms(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,s;const r=this._getTypeSize(e);if(e.size=(t=r==null?void 0:r.size)!==null&&t!==void 0?t:0,e instanceof Uo&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((n=o==null?void 0:o.size)!==null&&n!==void 0?n:0,(s=o==null?void 0:o.align)!==null&&s!==void 0?s:0),this._updateTypeInfo(e.format)}e instanceof Pg&&this._updateTypeInfo(e.format),e instanceof Fo&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,s=0,r=0,o=0;for(let a=0,l=e.members.length;a<l;++a){const c=e.members[a],u=this._getTypeSize(c);if(!u)continue;(t=this._getAlias(c.type.name))!==null&&t!==void 0||c.type;const d=u.align,h=u.size;n=this._roundUp(d,n+s),s=h,r=n,o=Math.max(o,d),c.offset=n,c.size=h,this._updateTypeInfo(c.type)}e.size=this._roundUp(o,r+s),e.align=o}_getTypeSize(e){var t,n;if(e==null)return null;const s=this._getAttributeNum(e.attributes,"size",0),r=this._getAttributeNum(e.attributes,"align",0);if(e instanceof bx&&(e=e.type),e instanceof ms){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=mr._typeInfo[e.name];if(o!==void 0){const a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new kd(Math.max(r,o.align/a),Math.max(s,o.size/a))}}{const o=mr._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new kd(Math.max(r,o.align/a),Math.max(s,o.size/a))}}if(e instanceof Uo){let o=e,a=8,l=8;const c=this._getTypeSize(o.format);return c!==null&&(l=c.size,a=c.align),l=o.count*this._getAttributeNum((n=e==null?void 0:e.attributes)!==null&&n!==void 0?n:null,"stride",this._roundUp(a,l)),s&&(l=s),new kd(Math.max(r,a),Math.max(s,l))}if(e instanceof Fo){let o=0,a=0,l=0,c=0,u=0;for(const d of e.members){const h=this._getTypeSize(d.type);h!==null&&(o=Math.max(h.align,o),l=this._roundUp(h.align,l+c),c=h.size,u=l)}return a=this._roundUp(o,u+c),new kd(Math.max(r,o),Math.max(s,a))}return null}_isUniformVar(e){return e instanceof Jr&&e.storage=="uniform"}_isStorageVar(e){return e instanceof Jr&&e.storage=="storage"}_isTextureVar(e){return e instanceof Jr&&e.type!==null&&mr._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof Jr&&e.type!==null&&mr._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){const n=e;if(!n||!n.attributes)return null;const s=n.attributes;for(let r of s)if(r.name==t)return r;return null}_getAttributeNum(e,t,n){if(e===null)return n;for(let s of e)if(s.name==t){let r=s!==null&&s.value!==null?s.value:n;return r instanceof Array&&(r=r[0]),typeof r=="number"?r:typeof r=="string"?parseInt(r):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}}mr._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},mr._textureTypes=w.any_texture_type.map(i=>i.name),mr._samplerTypes=w.sampler_type.map(i=>i.name);let Ty=0;class ky{constructor(e,t,n){this.id=Ty++,this.name=e,this.value=t,this.node=n}clone(){return new ky(this.name,this.value,this.node)}}class Ay{constructor(e){this.id=Ty++,this.name=e.name,this.node=e}clone(){return new Ay(this.node)}}class Iy{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=Ty++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,n){this.variables.set(e,new ky(e,t,n??null))}setVariable(e,t,n){const s=this.getVariable(e);s!==null?s.value=t:this.createVariable(e,t,n)}getVariableValue(e){var t;const n=this.getVariable(e);return(t=n==null?void 0:n.value)!==null&&t!==void 0?t:null}clone(){return new Iy(this)}}class lB{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class cB{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const n=this.exec.evalExpression(e.args[0],t);let s=!0;if(n instanceof k)return n.data.forEach(r=>{r||(s=!1)}),new M(s?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k){const s=n.data.some(r=>r);return new M(s?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const n=this.exec.evalExpression(e.args[2],t);if(!(n instanceof M))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.evalExpression(n,t);if(s instanceof oi&&s.typeInfo.size===0){const r=s.typeInfo,o=s.buffer.byteLength/r.stride;return new M(o,this.getTypeInfo("u32"))}return new M(s.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.abs(r)),n.typeInfo);const s=n;return new M(Math.abs(s.value),s.typeInfo)}Acos(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.acos(r)),n.typeInfo);const s=n;return new M(Math.acos(s.value),n.typeInfo)}Acosh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.acosh(r)),n.typeInfo);const s=n;return new M(Math.acosh(s.value),n.typeInfo)}Asin(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.asin(r)),n.typeInfo);const s=n;return new M(Math.asin(s.value),n.typeInfo)}Asinh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.asinh(r)),n.typeInfo);const s=n;return new M(Math.asinh(s.value),n.typeInfo)}Atan(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.atan(r)),n.typeInfo);const s=n;return new M(Math.atan(s.value),n.typeInfo)}Atanh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.atanh(r)),n.typeInfo);const s=n;return new M(Math.atanh(s.value),n.typeInfo)}Atan2(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k)return new k(n.data.map((a,l)=>Math.atan2(a,s.data[l])),n.typeInfo);const r=n,o=s;return new M(Math.atan2(r.value,o.value),n.typeInfo)}Ceil(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.ceil(r)),n.typeInfo);const s=n;return new M(Math.ceil(s.value),n.typeInfo)}_clamp(e,t,n){return Math.min(Math.max(e,t),n)}Clamp(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof k&&s instanceof k&&r instanceof k)return new k(n.data.map((c,u)=>this._clamp(c,s.data[u],r.data[u])),n.typeInfo);const o=n,a=s,l=r;return new M(this._clamp(o.value,a.value,l.value),n.typeInfo)}Cos(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.cos(r)),n.typeInfo);const s=n;return new M(Math.cos(s.value),n.typeInfo)}Cosh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.cosh(r)),n.typeInfo);const s=n;return new M(Math.cos(s.value),n.typeInfo)}CountLeadingZeros(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.clz32(r)),n.typeInfo);const s=n;return new M(Math.clz32(s.value),n.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>this._countOneBits(r)),n.typeInfo);const s=n;return new M(this._countOneBits(s.value),n.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>this._countTrailingZeros(r)),n.typeInfo);const s=n;return new M(this._countTrailingZeros(s.value),n.typeInfo)}Cross(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k){if(n.data.length!==3||s.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const r=n.data,o=s.data;return new k([r[1]*o[2]-o[1]*r[2],r[2]*o[0]-o[2]*r[0],r[0]*o[1]-o[0]*r[1]],n.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const n=this.exec.evalExpression(e.args[0],t),s=180/Math.PI;return n instanceof k?new k(n.data.map(r=>r*s),n.typeInfo):new M(n.value*s,this.getTypeInfo("f32"))}Determinant(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Ue){const s=n.data,r=n.typeInfo.getTypeName(),o=r.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(r==="mat2x2"||r==="mat2x2f"||r==="mat2x2h")return new M(s[0]*s[3]-s[1]*s[2],o);if(r==="mat2x3"||r==="mat2x3f"||r==="mat2x3h")return new M(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);if(r==="mat2x4"||r==="mat2x4f"||r==="mat2x4h")console.error(`TODO: Determinant for ${r}`);else if(r==="mat3x2"||r==="mat3x2f"||r==="mat3x2h")console.error(`TODO: Determinant for ${r}`);else{if(r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h")return new M(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);r==="mat3x4"||r==="mat3x4f"||r==="mat3x4h"||r==="mat4x2"||r==="mat4x2f"||r==="mat4x2h"||r==="mat4x3"||r==="mat4x3f"||r==="mat4x3h"?console.error(`TODO: Determinant for ${r}`):r!=="mat4x4"&&r!=="mat4x4f"&&r!=="mat4x4h"||console.error(`TODO: Determinant for ${r}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k){let a=0;for(let l=0;l<n.data.length;++l)a+=(n.data[l]-s.data[l])*(n.data[l]-s.data[l]);return new M(Math.sqrt(a),this.getTypeInfo("f32"))}const r=n,o=s;return new M(Math.abs(r.value-o.value),n.typeInfo)}_dot(e,t){let n=0;for(let s=0;s<e.length;++s)n+=t[s]*e[s];return n}Dot(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);return n instanceof k&&s instanceof k?new M(this._dot(n.data,s.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.exp(r)),n.typeInfo);const s=n;return new M(Math.exp(s.value),n.typeInfo)}Exp2(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.pow(2,r)),n.typeInfo);const s=n;return new M(Math.pow(2,s.value),n.typeInfo)}ExtractBits(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=s.value,a=r.value;if(n instanceof k)return new k(n.data.map(c=>c>>o&(1<<a)-1),n.typeInfo);if(n.typeInfo.name!=="i32"&&n.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;const l=n.value;return new M(l>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof k&&s instanceof k&&r instanceof k){const o=this._dot(s.data,r.data);return new k(o<0?Array.from(n.data):n.data.map(a=>-a),n.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>this._firstLeadingBit(r)),n.typeInfo);const s=n;return new M(this._firstLeadingBit(s.value),n.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>this._firstTrailingBit(r)),n.typeInfo);const s=n;return new M(this._firstTrailingBit(s.value),n.typeInfo)}Floor(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.floor(r)),n.typeInfo);const s=n;return new M(Math.floor(s.value),n.typeInfo)}Fma(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof k&&s instanceof k&&r instanceof k)return n.data.length!==s.data.length||n.data.length!==r.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new k(n.data.map((c,u)=>c*s.data[u]+r.data[u]),n.typeInfo);const o=n,a=s,l=r;return new M(o.value*a.value+l.value,o.typeInfo)}Fract(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>r-Math.floor(r)),n.typeInfo);const s=n;return new M(s.value-Math.floor(s.value),n.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const a=r.value,l=(1<<o.value)-1<<a,c=~l;if(n instanceof k&&s instanceof k)return new k(n.data.map((h,p)=>h&c|s.data[p]<<a&l),n.typeInfo);const u=n.value,d=s.value;return new M(u&c|d<<a&l,n.typeInfo)}InverseSqrt(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>1/Math.sqrt(r)),n.typeInfo);const s=n;return new M(1/Math.sqrt(s.value),n.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k){let r=0;return n.data.forEach(o=>{r+=o*o}),new M(Math.sqrt(r),this.getTypeInfo("f32"))}const s=n;return new M(Math.abs(s.value),n.typeInfo)}Log(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.log(r)),n.typeInfo);const s=n;return new M(Math.log(s.value),n.typeInfo)}Log2(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.log2(r)),n.typeInfo);const s=n;return new M(Math.log2(s.value),n.typeInfo)}Max(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k)return new k(n.data.map((a,l)=>Math.max(a,s.data[l])),n.typeInfo);const r=n,o=s;return new M(Math.max(r.value,o.value),n.typeInfo)}Min(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k)return new k(n.data.map((a,l)=>Math.min(a,s.data[l])),n.typeInfo);const r=n,o=s;return new M(Math.min(r.value,o.value),n.typeInfo)}Mix(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof k&&s instanceof k&&r instanceof k)return new k(n.data.map((l,c)=>n.data[c]*(1-r.data[c])+s.data[c]*r.data[c]),n.typeInfo);const o=s,a=r;return new M(n.value*(1-a.value)+o.value*a.value,n.typeInfo)}Modf(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k)return new k(n.data.map((o,a)=>o%s.data[a]),n.typeInfo);const r=s;return new M(n.value%r.value,n.typeInfo)}Normalize(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k){const s=this.Length(e,t).value;return new k(n.data.map(r=>r/s),n.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k)return new k(n.data.map((a,l)=>Math.pow(a,s.data[l])),n.typeInfo);const r=n,o=s;return new M(Math.pow(r.value,o.value),n.typeInfo)}QuantizeToF16(e,t){const n=this.exec.evalExpression(e.args[0],t);return n instanceof k?new k(n.data.map(s=>s),n.typeInfo):new M(n.value,n.typeInfo)}Radians(e,t){const n=this.exec.evalExpression(e.args[0],t);return n instanceof k?new k(n.data.map(s=>s*Math.PI/180),n.typeInfo):new M(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof k&&s instanceof k){const r=this._dot(n.data,s.data);return new k(n.data.map((o,a)=>o-2*r*s.data[a]),n.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof k&&s instanceof k&&r instanceof M){const o=this._dot(s.data,n.data);return new k(n.data.map((a,l)=>{const c=1-r.value*r.value*(1-o*o);if(c<0)return 0;const u=Math.sqrt(c);return r.value*a-(r.value*o+u)*s.data[l]}),n.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.round(r)),n.typeInfo);const s=n;return new M(Math.round(s.value),n.typeInfo)}Saturate(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.min(Math.max(r,0),1)),n.typeInfo);const s=n;return new M(Math.min(Math.max(s.value,0),1),n.typeInfo)}Sign(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.sign(r)),n.typeInfo);const s=n;return new M(Math.sign(s.value),n.typeInfo)}Sin(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.sin(r)),n.typeInfo);const s=n;return new M(Math.sin(s.value),n.typeInfo)}Sinh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.sinh(r)),n.typeInfo);const s=n;return new M(Math.sinh(s.value),n.typeInfo)}_smoothstep(e,t,n){const s=Math.min(Math.max((n-e)/(t-e),0),1);return s*s*(3-2*s)}SmoothStep(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(r instanceof k&&n instanceof k&&s instanceof k)return new k(r.data.map((c,u)=>this._smoothstep(n.data[u],s.data[u],c)),r.typeInfo);const o=n,a=s,l=r;return new M(this._smoothstep(o.value,a.value,l.value),r.typeInfo)}Sqrt(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.sqrt(r)),n.typeInfo);const s=n;return new M(Math.sqrt(s.value),n.typeInfo)}Step(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(s instanceof k&&n instanceof k)return new k(s.data.map((o,a)=>o<n.data[a]?0:1),s.typeInfo);const r=n;return new M(s.value<r.value?0:1,r.typeInfo)}Tan(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.tan(r)),n.typeInfo);const s=n;return new M(Math.tan(s.value),n.typeInfo)}Tanh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.tanh(r)),n.typeInfo);const s=n;return new M(Math.tanh(s.value),n.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const n=this.exec.evalExpression(e.args[0],t);if(!(n instanceof Ue))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const s=this._getTransposeType(n.typeInfo);if(n.typeInfo.name==="mat2x2"||n.typeInfo.name==="mat2x2f"||n.typeInfo.name==="mat2x2h"){const r=n.data;return new Ue([r[0],r[2],r[1],r[3]],s)}if(n.typeInfo.name==="mat2x3"||n.typeInfo.name==="mat2x3f"||n.typeInfo.name==="mat2x3h"){const r=n.data;return new Ue([r[0],r[3],r[6],r[1],r[4],r[7]],s)}if(n.typeInfo.name==="mat2x4"||n.typeInfo.name==="mat2x4f"||n.typeInfo.name==="mat2x4h"){const r=n.data;return new Ue([r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13]],s)}if(n.typeInfo.name==="mat3x2"||n.typeInfo.name==="mat3x2f"||n.typeInfo.name==="mat3x2h"){const r=n.data;return new Ue([r[0],r[3],r[1],r[4],r[2],r[5]],s)}if(n.typeInfo.name==="mat3x3"||n.typeInfo.name==="mat3x3f"||n.typeInfo.name==="mat3x3h"){const r=n.data;return new Ue([r[0],r[3],r[6],r[1],r[4],r[7],r[2],r[5],r[8]],s)}if(n.typeInfo.name==="mat3x4"||n.typeInfo.name==="mat3x4f"||n.typeInfo.name==="mat3x4h"){const r=n.data;return new Ue([r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14]],s)}if(n.typeInfo.name==="mat4x2"||n.typeInfo.name==="mat4x2f"||n.typeInfo.name==="mat4x2h"){const r=n.data;return new Ue([r[0],r[4],r[1],r[5],r[2],r[6]],s)}if(n.typeInfo.name==="mat4x3"||n.typeInfo.name==="mat4x3f"||n.typeInfo.name==="mat4x3h"){const r=n.data;return new Ue([r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]],s)}if(n.typeInfo.name==="mat4x4"||n.typeInfo.name==="mat4x4f"||n.typeInfo.name==="mat4x4h"){const r=n.data;return new Ue([r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15]],s)}return console.error(`Invalid matrix type ${n.typeInfo.name}`),null}Trunc(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof k)return new k(n.data.map(r=>Math.trunc(r)),n.typeInfo);const s=n;return new M(Math.trunc(s.value),n.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const n=e.args[0],s=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof Hn){const r=n.name,o=t.getVariableValue(r);if(o instanceof Zr){if(s<0||s>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const a=o.getMipLevelSize(s),l=o.dimension;return l==="1d"?new M(a[0],this.getTypeInfo("u32")):l==="3d"?new k(a,this.getTypeInfo("vec3u")):l==="2d"?new k(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${l} not found. Line ${e.line}`),null)}return console.error(`Texture ${r} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const n=e.args[0],s=this.exec.evalExpression(e.args[1],t),r=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(s instanceof k)||s.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(n instanceof Hn){const o=n.name,a=t.getVariableValue(o);if(a instanceof Zr){const l=Math.floor(s.data[0]),c=Math.floor(s.data[1]);if(l<0||l>=a.width||c<0||c>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const u=a.getPixel(l,c,0,r);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new k(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const n=e.args[0];if(n instanceof Hn){const s=n.name,r=t.getVariableValue(s);return r instanceof Zr?new M(r.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const n=e.args[0];if(n instanceof Hn){const s=n.name,r=t.getVariableValue(s);return r instanceof Zr?new M(r.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const n=e.args[0];if(n instanceof Hn){const s=n.name,r=t.getVariableValue(s);return r instanceof Zr?new M(r.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const n=e.args[0],s=this.exec.evalExpression(e.args[1],t),r=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(s instanceof k)||s.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(n instanceof Hn){const a=n.name,l=t.getVariableValue(a);if(l instanceof Zr){const c=l.getMipLevelSize(0),u=Math.floor(s.data[0]),d=Math.floor(s.data[1]);return u<0||u>=c[0]||d<0||d>=c[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(l.setPixel(u,d,0,r,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t);return t.getVariable(s).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t);return l instanceof M&&a instanceof M&&(l.value=a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value+=a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicSub(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value-=a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicMax(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=Math.max(l.value,a.value)),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicMin(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=Math.min(l.value,a.value)),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicAnd(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=l.value&a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicOr(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=l.value|a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicXor(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=l.value^a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicExchange(e,t){let n=e.args[0];n instanceof mi&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=r.value.getSubData(this.exec,n.postfix,t),c=new M(l.value,l.typeInfo);return l instanceof M&&a instanceof M&&(l.value=a.value),r.value instanceof oi&&r.value.setDataValue(this.exec,l,n.postfix,t),c}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const dm={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},on={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class qi extends lB{constructor(e,t){var n;super(),this.ast=e??[],this.reflection=new mr,this.reflection.updateAST(this.ast),this.context=(n=t==null?void 0:t.clone())!==null&&n!==void 0?n:new Iy,this.builtins=new cB(this),this.typeInfo={bool:this.getTypeInfo(Y.bool),i32:this.getTypeInfo(Y.i32),u32:this.getTypeInfo(Y.u32),f32:this.getTypeInfo(Y.f32),f16:this.getTypeInfo(Y.f16),vec2f:this.getTypeInfo(B.vec2f),vec2u:this.getTypeInfo(B.vec2u),vec2i:this.getTypeInfo(B.vec2i),vec2h:this.getTypeInfo(B.vec2h),vec3f:this.getTypeInfo(B.vec3f),vec3u:this.getTypeInfo(B.vec3u),vec3i:this.getTypeInfo(B.vec3i),vec3h:this.getTypeInfo(B.vec3h),vec4f:this.getTypeInfo(B.vec4f),vec4u:this.getTypeInfo(B.vec4u),vec4i:this.getTypeInfo(B.vec4i),vec4h:this.getTypeInfo(B.vec4h),mat2x2f:this.getTypeInfo(B.mat2x2f),mat2x3f:this.getTypeInfo(B.mat2x3f),mat2x4f:this.getTypeInfo(B.mat2x4f),mat3x2f:this.getTypeInfo(B.mat3x2f),mat3x3f:this.getTypeInfo(B.mat3x3f),mat3x4f:this.getTypeInfo(B.mat3x4f),mat4x2f:this.getTypeInfo(B.mat4x2f),mat4x3f:this.getTypeInfo(B.mat4x3f),mat4x4f:this.getTypeInfo(B.mat4x4f)}}getVariableValue(e){var t,n;const s=(n=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:null;if(s===null)return null;if(s instanceof M)return s.value;if(s instanceof k||s instanceof Ue)return Array.from(s.data);if(s instanceof oi&&s.typeInfo instanceof Uo){if(s.typeInfo.format.name==="u32")return Array.from(new Uint32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="i32")return Array.from(new Int32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="f32")return Array.from(new Float32Array(s.buffer,s.offset,s.typeInfo.count))}return console.error(`Unsupported return variable type ${s.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,n,s){const r=this.context.clone();(s=s??{}).constants&&this._setOverrides(s.constants,r),this._execStatements(this.ast,r);const o=r.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const a=t[0],l=t[1],c=t[2],u=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new k(t,u));const d=this.reflection.getFunctionInfo(e);d===null&&console.error(`Function ${e} not found in reflection data`);for(const h in n)for(const p in n[h]){const m=n[h][p];r.variables.forEach(y=>{var g;const _=y.node;if(_!=null&&_.attributes){let S=null,E=null;for(const x of _.attributes)x.name==="binding"?S=x.value:x.name==="group"&&(E=x.value);if(p==S&&h==E){let x=!1;for(const T of d.resources)if(T.name===y.name&&T.group===parseInt(h)&&T.binding===parseInt(p)){x=!0;break}if(x)if(m.texture!==void 0&&m.descriptor!==void 0){const T=new Zr(m.texture,this.getTypeInfo(_.type),m.descriptor,(g=m.texture.view)!==null&&g!==void 0?g:null);y.value=T}else m.uniform!==void 0?y.value=new oi(m.uniform,this.getTypeInfo(_.type)):y.value=new oi(m,this.getTypeInfo(_.type))}}})}for(let h=0;h<c;++h)for(let p=0;p<l;++p)for(let m=0;m<a;++m)r.setVariable("@workgroup_id",new k([m,p,h],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[m,p,h],r)}execStatement(e,t){if(e instanceof aE)return this.evalExpression(e.value,t);if(e instanceof cE){if(e.condition){const n=this.evalExpression(e.condition,t);if(!(n instanceof M))throw new Error("Invalid break-if condition");if(!n.value)return null}return qi._breakObj}if(e instanceof uE)return qi._continueObj;if(e instanceof tu)this._let(e,t);else if(e instanceof Jr)this._var(e,t);else if(e instanceof ph)this._const(e,t);else if(e instanceof pu)this._function(e,t);else{if(e instanceof oE)return this._if(e,t);if(e instanceof rE)return this._switch(e,t);if(e instanceof tE)return this._for(e,t);if(e instanceof eE)return this._while(e,t);if(e instanceof sE)return this._loop(e,t);if(e instanceof Ng){const n=t.clone();return n.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof nE)this._assign(e,t);else if(e instanceof iE)this._increment(e,t);else{if(e instanceof Kr)return null;if(e instanceof wy){const n=e.name;t.getVariable(n)===null&&t.setVariable(n,new M(0,this.getTypeInfo("u32")))}else if(e instanceof Sy)this._call(e,t);else{if(e instanceof lE||e instanceof Ey)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof Ds?this._evalBinaryOp(e,t):e instanceof xi?this._evalLiteral(e,t):e instanceof Hn?this._evalVariable(e,t):e instanceof Cy?this._evalCall(e,t):e instanceof ur?this._evalCreate(e,t):e instanceof dE?this._evalConst(e,t):e instanceof hE?this._evalBitcast(e,t):e instanceof mi?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof Y){const s=this.reflection.getTypeInfo(e);if(s!==null)return s}let n=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return n!==null||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,t){for(const n in e){const s=e[n],r=this.reflection.getOverrideInfo(n);r!==null?(r.type===null&&(r.type=this.getTypeInfo("u32")),r.type.name==="u32"||r.type.name==="i32"||r.type.name==="f32"||r.type.name==="f16"?t.setVariable(n,new M(s,r.type)):r.type.name==="bool"?t.setVariable(n,new M(s?1:0,r.type)):r.type.name==="vec2"||r.type.name==="vec3"||r.type.name==="vec4"||r.type.name==="vec2f"||r.type.name==="vec3f"||r.type.name==="vec4f"||r.type.name==="vec2i"||r.type.name==="vec3i"||r.type.name==="vec4i"||r.type.name==="vec2u"||r.type.name==="vec3u"||r.type.name==="vec4u"||r.type.name==="vec2h"||r.type.name==="vec3h"||r.type.name==="vec4h"?t.setVariable(n,new k(s,r.type)):console.error(`Invalid constant type for ${n}`)):console.error(`Override ${n} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,n){const s=[1,1,1];for(const u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){const d=n.getVariableValue(u.value[0]);s[0]=d instanceof M?d.value:parseInt(u.value[0])}if(u.value.length>1){const d=n.getVariableValue(u.value[1]);s[1]=d instanceof M?d.value:parseInt(u.value[1])}if(u.value.length>2){const d=n.getVariableValue(u.value[2]);s[2]=d instanceof M?d.value:parseInt(u.value[2])}}const r=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new k(s,r));const a=s[0],l=s[1],c=s[2];for(let u=0,d=0;u<c;++u)for(let h=0;h<l;++h)for(let p=0;p<a;++p,++d){const m=[p,h,u],y=[p+t[0]*s[0],h+t[1]*s[1],u+t[2]*s[2]];n.setVariable("@local_invocation_id",new k(m,r)),n.setVariable("@global_invocation_id",new k(y,r)),n.setVariable("@local_invocation_index",new M(d,o)),this._dispatchExec(e,n)}}_dispatchExec(e,t){for(const n of e.node.args)for(const s of n.attributes)if(s.name==="builtin"){const r=`@${s.value}`,o=t.getVariable(r);o!==void 0&&t.variables.set(n.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof mi;)e=e.right;return e instanceof Hn?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(const n of e){if(n instanceof Array){const r=t.clone(),o=this._execStatements(n,r);if(o)return o;continue}const s=this.execStatement(n,t);if(s)return s}return null}_call(e,t){const n=t.clone();n.currentFunctionName=e.name;const s=t.getFunction(e.name);if(s){for(let r=0;r<s.node.args.length;++r){const o=s.node.args[r],a=this.evalExpression(e.args[r],n);n.setVariable(o.name,a,o)}this._execStatements(s.node.body,n)}else e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const n=this.getVariableName(e.variable,t),s=t.getVariable(n);s?e.operator==="++"?s.value instanceof M?s.value.value++:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):e.operator==="--"?s.value instanceof M?s.value.value--:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${n} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof Hn){const n=this.getVariableName(e,t),s=t.getVariable(n);return s===null?(console.error(`Variable ${n} not found. Line ${e.line}`),null):s.value.getSubData(this,e.postfix,t)}if(e instanceof mi){if(e.operator==="*"){const n=this._getVariableData(e.right,t);return n instanceof Ma?n.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const n=this._getVariableData(e.right,t);return new Ma(n)}}return null}_assign(e,t){let n=null,s="<var>",r=null;if(e.variable instanceof mi){const l=this._getVariableData(e.variable,t),c=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(l instanceof M||l instanceof k||l instanceof Ue){if(c instanceof M||c instanceof k||c instanceof Ue&&l.data.length===c.data.length)return void l.data.set(c.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(l instanceof oi&&c instanceof oi&&l.buffer.byteLength-l.offset>=c.buffer.byteLength-c.offset)return void(l.buffer.byteLength%4==0?new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4).set(new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4)):new Uint8Array(l.buffer,l.offset,l.typeInfo.size).set(new Uint8Array(c.buffer,c.offset,c.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return l instanceof M||l instanceof k||l instanceof Ue?c instanceof M||c instanceof k||c instanceof Ue?void l.data.set(c.data.map((d,h)=>l.data[h]+d)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(l instanceof M||l instanceof k||l instanceof Ue)&&(c instanceof M||c instanceof k||c instanceof Ue)?void l.data.set(c.data.map((d,h)=>l.data[h]-d)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof mi){if(e.variable.operator==="*"){s=this.getVariableName(e.variable.right,t);const l=t.getVariable(s);if(!(l&&l.value instanceof Ma))return void console.error(`Variable ${s} is not a pointer. Line ${e.line}`);n=l.value.reference;let c=e.variable.postfix;if(!c){let u=e.variable.right;for(;u instanceof mi;){if(u.postfix){c=u.postfix;break}u=u.right}}c&&(n=n.getSubData(this,c,t))}}else{r=e.variable.postfix,s=this.getVariableName(e.variable,t);const l=t.getVariable(s);if(l===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);n=l.value}if(n instanceof Ma&&(n=n.reference),n===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),a=e.operator;if(a!=="="){const l=n.getSubData(this,r,t);if(l instanceof k&&o instanceof M){const c=l.data,u=o.value;if(a==="+=")for(let d=0;d<c.length;++d)c[d]+=u;else if(a==="-=")for(let d=0;d<c.length;++d)c[d]-=u;else if(a==="*=")for(let d=0;d<c.length;++d)c[d]*=u;else if(a==="/=")for(let d=0;d<c.length;++d)c[d]/=u;else if(a==="%=")for(let d=0;d<c.length;++d)c[d]%=u;else if(a==="&=")for(let d=0;d<c.length;++d)c[d]&=u;else if(a==="|=")for(let d=0;d<c.length;++d)c[d]|=u;else if(a==="^=")for(let d=0;d<c.length;++d)c[d]^=u;else if(a==="<<=")for(let d=0;d<c.length;++d)c[d]<<=u;else if(a===">>=")for(let d=0;d<c.length;++d)c[d]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(l instanceof k&&o instanceof k){const c=l.data,u=o.data;if(c.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let d=0;d<c.length;++d)c[d]+=u[d];else if(a==="-=")for(let d=0;d<c.length;++d)c[d]-=u[d];else if(a==="*=")for(let d=0;d<c.length;++d)c[d]*=u[d];else if(a==="/=")for(let d=0;d<c.length;++d)c[d]/=u[d];else if(a==="%=")for(let d=0;d<c.length;++d)c[d]%=u[d];else if(a==="&=")for(let d=0;d<c.length;++d)c[d]&=u[d];else if(a==="|=")for(let d=0;d<c.length;++d)c[d]|=u[d];else if(a==="^=")for(let d=0;d<c.length;++d)c[d]^=u[d];else if(a==="<<=")for(let d=0;d<c.length;++d)c[d]<<=u[d];else if(a===">>=")for(let d=0;d<c.length;++d)c[d]>>=u[d];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(l instanceof M&&o instanceof M))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?l.value+=o.value:a==="-="?l.value-=o.value:a==="*="?l.value*=o.value:a==="/="?l.value/=o.value:a==="%="?l.value%=o.value:a==="&="?l.value&=o.value:a==="|="?l.value|=o.value:a==="^="?l.value^=o.value:a==="<<="?l.value<<=o.value:a===">>="?l.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}return void(n instanceof oi&&n.setDataValue(this,l,r,t))}if(n instanceof oi)n.setDataValue(this,o,r,t);else if(r){if(!(n instanceof k||n instanceof Ue))return void console.error(`Variable ${s} is not a vector or matrix. Line ${e.line}`);if(r instanceof kl){const l=this.evalExpression(r.index,t).value;if(n instanceof k){if(!(o instanceof M))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[l]=o.value}else{if(!(n instanceof Ue))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{const c=this.evalExpression(r.index,t).value;if(c<0)return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(o instanceof k))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{const u=n.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(c<2&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*c]=o.data[0],n.data[2*c+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(c<2&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*c]=o.data[0],n.data[3*c+1]=o.data[1],n.data[3*c+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(c<2&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*c]=o.data[0],n.data[4*c+1]=o.data[1],n.data[4*c+2]=o.data[2],n.data[4*c+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(c<3&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*c]=o.data[0],n.data[2*c+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(c<3&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*c]=o.data[0],n.data[3*c+1]=o.data[1],n.data[3*c+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(c<3&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*c]=o.data[0],n.data[4*c+1]=o.data[1],n.data[4*c+2]=o.data[2],n.data[4*c+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(c<4&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*c]=o.data[0],n.data[2*c+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(c<4&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*c]=o.data[0],n.data[3*c+1]=o.data[1],n.data[3*c+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(c<4&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*c]=o.data[0],n.data[4*c+1]=o.data[1],n.data[4*c+2]=o.data[2],n.data[4*c+3]=o.data[3]}}}}}else if(r instanceof ya){const l=r.value;if(!(n instanceof k))return void console.error(`Invalid assignment to ${l}. Variable ${s} is not a vector. Line ${e.line}`);if(o instanceof M){if(l.length>1)return void console.error(`Invalid assignment to ${l} for variable ${s}. Line ${e.line}`);if(l==="x")n.data[0]=o.value;else if(l==="y"){if(n.data.length<2)return void console.error(`Invalid assignment to ${l} for variable ${s}. Line ${e.line}`);n.data[1]=o.value}else if(l==="z"){if(n.data.length<3)return void console.error(`Invalid assignment to ${l} for variable ${s}. Line ${e.line}`);n.data[2]=o.value}else if(l==="w"){if(n.data.length<4)return void console.error(`Invalid assignment to ${l} for variable ${s}. Line ${e.line}`);n.data[3]=o.value}}else{if(!(o instanceof k))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(l.length!==o.data.length)return void console.error(`Invalid assignment to ${l} for variable ${s}. Line ${e.line}`);for(let c=0;c<l.length;++c){const u=l[c];if(u==="x"||u==="r")n.data[0]=o.data[c];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[1]=o.data[c]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[2]=o.data[c]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[3]=o.data[c]}}}}}else n instanceof M&&o instanceof M?n.value=o.value:n instanceof k&&o instanceof k||n instanceof Ue&&o instanceof Ue?n.data.set(o.data):console.error(`Invalid assignment to ${s}. Line ${e.line}`)}_function(e,t){const n=new Ay(e);t.functions.set(e.name,n)}_const(e,t){let n=null;e.value!==null&&(n=this.evalExpression(e.value,t)),t.createVariable(e.name,n,e)}_let(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof mi||(n=n.clone())}else{const s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||s==="array"){const r=new ur(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_var(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof mi||(n=n.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);const s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||e.type instanceof iu||e.type instanceof Kr||e.type instanceof B){const r=new ur(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_switch(e,t){t=t.clone();const n=this.evalExpression(e.condition,t);if(!(n instanceof M))return console.error(`Invalid if condition. Line ${e.line}`),null;let s=null;for(const r of e.cases)if(r instanceof mE)for(const o of r.selectors){if(o instanceof _h){s=r;continue}const a=this.evalExpression(o,t);if(!(a instanceof M))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===n.value)return this._execStatements(r.body,t)}else r instanceof gE&&(s=r);return s?this._execStatements(s.body,t):null}_if(e,t){t=t.clone();const n=this.evalExpression(e.condition,t);if(!(n instanceof M))return console.error(`Invalid if condition. Line ${e.line}`),null;if(n.value)return this._execStatements(e.body,t);for(const s of e.elseif){const r=this.evalExpression(s.condition,t);if(!(r instanceof M))return console.error(`Invalid if condition. Line ${e.line}`),null;if(r.value)return this._execStatements(s.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof M?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const n=this._execStatements(e.body,t);if(n===qi._breakObj)break;if(n!==null&&n!==qi._continueObj)return n;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const n=this._execStatements(e.body,t);if(n===qi._breakObj)break;if(n===qi._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===qi._breakObj)break}else if(n!==null)return n}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const n=this._execStatements(e.body,t);if(n===qi._breakObj)break;if(n!==qi._continueObj&&n!==null)return n}return null}_evalBitcast(e,t){const n=this.evalExpression(e.value,t),s=e.type;if(n instanceof M){const r=Tx(n.value,n.typeInfo.name,s.name);return new M(r,this.getTypeInfo(s))}if(n instanceof k){const r=n.typeInfo.getTypeName();let o="";if(r.endsWith("f"))o="f32";else if(r.endsWith("i"))o="i32";else if(r.endsWith("u"))o="u32";else if(r.endsWith("b"))o="bool";else{if(!r.endsWith("h"))return console.error(`Unknown vector type ${r}. Line ${e.line}`),null;o="f16"}const a=s.getTypeName();let l="";if(a.endsWith("f"))l="f32";else if(a.endsWith("i"))l="i32";else if(a.endsWith("u"))l="u32";else if(a.endsWith("b"))l="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${l}. Line ${e.line}`),null;l="f16"}const c=(function(u,d,h){if(d===h)return u;const p=new Array(u.length);for(let m=0;m<u.length;m++)p[m]=Tx(u[m],d,h);return p})(Array.from(n.data),o,l);return new k(c,this.getTypeInfo(s))}return console.error(`TODO: bitcast for ${n.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var n;if(e instanceof ur){if(e.type===null)return Dg.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}const s=e instanceof ur?e.type.name:e.name,r=e instanceof ur?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(r===null)return console.error(`Unknown type ${s}. Line ${e.line}`),null;if(r.size===0)return null;const o=new oi(new ArrayBuffer(r.size),r,0);if(r instanceof Fo){if(e.args)for(let a=0;a<e.args.length;++a){const l=r.members[a],c=e.args[a],u=this.evalExpression(c,t);o.setData(this,u,l.type,l.offset,t)}}else if(r instanceof Uo){let a=0;if(e.args)for(let l=0;l<e.args.length;++l){const c=e.args[l],u=this.evalExpression(c,t);r.format===null&&(((n=u.typeInfo)===null||n===void 0?void 0:n.name)==="x32"?r.format=this.getTypeInfo("i32"):r.format=u.typeInfo),o.setData(this,u,r.format,a,t),a+=r.stride}}else console.error(`Unknown type "${s}". Line ${e.line}`);return e instanceof ur?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){const n=this.getTypeInfo(e.type),s=n.name;return s==="x32"||s==="u32"||s==="f32"||s==="f16"||s==="i32"||s==="bool"?new M(e.scalarValue,n):s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"?this._callConstructorVec(e,t):s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const n=t.getVariableValue(e.name);return n===null?n:n.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){const s=qi._priority.get(t.name);qi._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const n=this.evalExpression(e.right,t);if(e.operator==="&")return new Ma(n);if(e.operator==="*")return n instanceof Ma?n.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);const s=n instanceof M?n.value:n instanceof k?Array.from(n.data):null;switch(e.operator){case"+":{if(ce(s)){const a=s.map((l,c)=>+l);return new k(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new M(+r,o)}case"-":{if(ce(s)){const a=s.map((l,c)=>-l);return new k(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new M(-r,o)}case"!":{if(ce(s)){const a=s.map((l,c)=>l?0:1);return new k(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new M(r?0:1,o)}case"~":{if(ce(s)){const a=s.map((l,c)=>~l);return new k(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new M(~r,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const n=this.evalExpression(e.left,t),s=this.evalExpression(e.right,t),r=n instanceof M?n.value:n instanceof k||n instanceof Ue?Array.from(n.data):null,o=s instanceof M?s.value:s instanceof k||s instanceof Ue?Array.from(s.data):null;switch(e.operator){case"+":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p+d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h+u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u+h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a+l,c)}case"-":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p-d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h-u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u-h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a-l,c)}case"*":{if(ce(r)&&ce(o)){const u=r,d=o;if(n instanceof Ue&&s instanceof Ue){const h=(function(g,_,S,E){if(on[_.name]===void 0||on[E.name]===void 0)return null;const x=on[_.name][0],T=on[_.name][1],I=on[E.name][0];if(x!==on[E.name][1])return null;const O=new Array(I*T);for(let H=0;H<T;H++)for(let Q=0;Q<I;Q++){let re=0;for(let D=0;D<x;D++)re+=g[D*T+H]*S[Q*x+D];O[H*I+Q]=re}return O})(u,n.typeInfo,d,s.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const p=on[s.typeInfo.name][0],m=on[n.typeInfo.name][1],y=this.getTypeInfo(`mat${p}x${m}f`);return new Ue(h,y)}if(n instanceof Ue&&s instanceof k){const h=(function(p,m,y,g){if(on[m.name]===void 0||dm[g.name]===void 0)return null;const _=on[m.name][0],S=on[m.name][1];if(_!==y.length)return null;const E=new Array(S);for(let x=0;x<S;x++){let T=0;for(let I=0;I<_;I++)T+=p[I*S+x]*y[I];E[x]=T}return E})(u,n.typeInfo,d,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new k(h,s.typeInfo)}if(n instanceof k&&s instanceof Ue){const h=(function(p,m,y,g){if(dm[m.name]===void 0||on[g.name]===void 0)return null;const _=on[g.name][0],S=on[g.name][1];if(S!==p.length)return null;const E=[];for(let x=0;x<_;x++){let T=0;for(let I=0;I<S;I++)T+=p[I]*y[I*_+x];E[x]=T}return E})(u,n.typeInfo,d,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new k(h,n.typeInfo)}{if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p*d[m]);return new k(h,n.typeInfo)}}if(ce(r)){const u=o,d=r.map((h,p)=>h*u);return n instanceof Ue?new Ue(d,n.typeInfo):new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u*h);return s instanceof Ue?new Ue(d,s.typeInfo):new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a*l,c)}case"%":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p%d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h%u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u%h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a%l,c)}case"/":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p/d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h/u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u/h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a/l,c)}case"&":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p&d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h&u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u&h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a&l,c)}case"|":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p|d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h|u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u|h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a|l,c)}case"^":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p^d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h^u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u^h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a^l,c)}case"<<":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p<<d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h<<u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u<<h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a<<l,c)}case">>":{if(ce(r)&&ce(o)){const u=r,d=o;if(u.length!==d.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((p,m)=>p>>d[m]);return new k(h,n.typeInfo)}if(ce(r)){const u=o,d=r.map((h,p)=>h>>u);return new k(d,n.typeInfo)}if(ce(o)){const u=r,d=o.map((h,p)=>u>>h);return new k(d,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new M(a>>l,c)}case">":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u>l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c>a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a>c?1:0);return new k(l,s.typeInfo)}return new M(r>o?1:0,this.getTypeInfo("bool"));case"<":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u<l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c<a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a<c?1:0);return new k(l,s.typeInfo)}return new M(r<o?1:0,this.getTypeInfo("bool"));case"==":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u===l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c==a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a==c?1:0);return new k(l,s.typeInfo)}return new M(r===o?1:0,this.getTypeInfo("bool"));case"!=":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u!==l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c!==a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a!==c?1:0);return new k(l,s.typeInfo)}return new M(r!==o?1:0,this.getTypeInfo("bool"));case">=":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u>=l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c>=a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a>=c?1:0);return new k(l,s.typeInfo)}return new M(r>=o?1:0,this.getTypeInfo("bool"));case"<=":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u<=l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c<=a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a<=c?1:0);return new k(l,s.typeInfo)}return new M(r<=o?1:0,this.getTypeInfo("bool"));case"&&":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u&&l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c&&a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a&&c?1:0);return new k(l,s.typeInfo)}return new M(r&&o?1:0,this.getTypeInfo("bool"));case"||":if(ce(r)&&ce(o)){const a=r,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,d)=>u||l[d]?1:0);return new k(c,n.typeInfo)}if(ce(r)){const a=o,l=r.map((c,u)=>c||a?1:0);return new k(l,n.typeInfo)}if(ce(o)){const a=r,l=o.map((c,u)=>a||c?1:0);return new k(l,s.typeInfo)}return new M(r||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const n=t.clone();n.currentFunctionName=e.name;const s=t.getFunction(e.name);if(!s)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let r=0;r<s.node.args.length;++r){const o=s.node.args[r],a=this.evalExpression(e.args[r],n);n.createVariable(o.name,a,o)}return this._execStatements(s.node.body,n)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const n=t.getFunction(e.name);if(n){const s=t.clone();for(let r=0;r<n.node.args.length;++r){const o=n.node.args[r],a=this.evalExpression(e.args[r],s);s.setVariable(o.name,a,o)}return this._execStatements(n.node.body,s)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new M(0,this.getTypeInfo(e.type));const n=this.evalExpression(e.args[0],t);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const n=this.getTypeInfo(e.type),s=e.type.getTypeName(),r=dm[s];if(r===void 0)return console.error(`Invalid vec constructor ${s}. Line ${e.line}`),null;const o=[];if(e instanceof xi)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);if(l instanceof k){const c=l.data;for(let u=0;u<c.length;++u){let d=c[u];o.push(d)}}else if(l instanceof M){let c=l.value;o.push(c)}}if(e.type instanceof B&&e.type.format===null&&(e.type.format=B.f32),o.length===0){const a=new Array(r).fill(0);return new k(a,n).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<r;)o.push(o[0]);return o.length<r?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new k(o.length>r?o.slice(0,r):o,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const n=this.getTypeInfo(e.type),s=e.type.getTypeName(),r=on[s];if(r===void 0)return console.error(`Invalid matrix constructor ${s}. Line ${e.line}`),null;const o=[];if(e instanceof xi)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);l instanceof k?o.push(...l.data):l instanceof M?o.push(l.value):l instanceof Ue&&o.push(...l.data)}if(n instanceof _a&&n.format===null&&(n.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(r[2]).fill(0);return new Ue(a,n).getSubData(this,e.postfix,t)}return o.length!==r[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new Ue(o,n).getSubData(this,e.postfix,t)}}qi._breakObj=new _s(new ms("BREAK",null),null),qi._continueObj=new _s(new ms("CONTINUE",null),null),qi._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class uB{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class dB{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new uB,this._exec=new qi,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const n=this._global_decl_or_directive();if(!n)break;t.push(n)}if(this._deferArrayCountEval.length>0){for(const n of this._deferArrayCountEval){const s=n.arrayType,r=n.countNode;if(r instanceof Hn){const o=r.name,a=this._context.constants.get(o);if(a)try{const l=a.constEvaluate(this._exec);s.count=l}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const n of t)n.search(s=>{s instanceof Ex||s instanceof gh?s.type=this._forwardType(s.type):s instanceof iu?s.format=this._forwardType(s.format):s instanceof Jr||s instanceof tu||s instanceof ph?s.type=this._forwardType(s.type):s instanceof pu?s.returnType=this._forwardType(s.returnType):s instanceof Sx&&(s.type=this._forwardType(s.type))});return t}_forwardType(e){if(e instanceof wx){const t=this._getType(e.name);if(t)return t}else e instanceof gh?e.type=this._forwardType(e.type):e instanceof iu&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const t=new eB(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==w.eof}_match(e){if(e instanceof N)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t<n;++t){const s=e[t];if(this._check(s))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const n=t.type;let s=!1;for(const r of e){if(n===r)return!0;r===w.tokens.name&&(s=!0)}if(s){const r=w.tokens.name.rule.exec(t.lexeme);if(r&&r.index==0&&r[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===w.tokens.name){const n=w.tokens.name.rule.exec(t.lexeme);return n&&n.index==0&&n[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(w.tokens.semicolon)&&!this._isAtEnd(););if(this._match(w.keywords.alias)){const t=this._type_alias();return this._consume(w.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(w.keywords.diagnostic)){const t=this._diagnostic();return this._consume(w.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(w.keywords.requires)){const t=this._requires_directive();return this._consume(w.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(w.keywords.enable)){const t=this._enable_directive();return this._consume(w.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}const e=this._attribute();if(this._check(w.keywords.var)){const t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(w.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(w.keywords.override)){const t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(w.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(w.keywords.let)){const t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(w.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(w.keywords.const)){const t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(w.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(w.keywords.struct)){const t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(w.keywords.fn)){const t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(w.keywords.fn))return null;const e=this._currentLine,t=this._consume(w.tokens.ident,"Expected function name.").toString();this._consume(w.tokens.paren_left,"Expected '(' for function arguments.");const n=[];if(!this._check(w.tokens.paren_right))do{if(this._check(w.tokens.paren_right))break;const a=this._attribute(),l=this._consume(w.tokens.name,"Expected argument name.").toString();this._consume(w.tokens.colon,"Expected ':' for argument type.");const c=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=c,n.push(this._updateNode(new Sx(l,u,a))))}while(this._match(w.tokens.comma));this._consume(w.tokens.paren_right,"Expected ')' after function arguments.");let s=null;if(this._match(w.tokens.arrow)){const a=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=a)}const r=this._compound_statement(),o=this._currentLine;return this._updateNode(new pu(t,n,s,r,e,o),e)}_compound_statement(){const e=[];for(this._consume(w.tokens.brace_left,"Expected '{' for block.");!this._check(w.tokens.brace_right);){const t=this._statement();t!==null&&e.push(t)}return this._consume(w.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(w.tokens.semicolon)&&!this._isAtEnd(););if(this._check(w.tokens.attr)&&this._attribute(),this._check(w.keywords.if))return this._if_statement();if(this._check(w.keywords.switch))return this._switch_statement();if(this._check(w.keywords.loop))return this._loop_statement();if(this._check(w.keywords.for))return this._for_statement();if(this._check(w.keywords.while))return this._while_statement();if(this._check(w.keywords.continuing))return this._continuing_statement();if(this._check(w.keywords.static_assert))return this._static_assert_statement();if(this._check(w.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(w.keywords.return))e=this._return_statement();else if(this._check([w.keywords.var,w.keywords.let,w.keywords.const]))e=this._variable_statement();else if(this._match(w.keywords.discard))e=this._updateNode(new ZM);else if(this._match(w.keywords.break)){const t=this._updateNode(new cE);if(this._currentLoop.length>0){const n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t,this._check(w.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(w.keywords.continue)){const t=this._updateNode(new uE);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(w.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(w.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new qM(t),e)}_while_statement(){if(!this._match(w.keywords.while))return null;const e=this._updateNode(new eE(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(w.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(w.keywords.continuing))return null;const t=this._currentLine,n=this._compound_statement();return this._updateNode(new Ng(n,e),t)}_for_statement(){if(!this._match(w.keywords.for))return null;this._consume(w.tokens.paren_left,"Expected '('.");const e=this._updateNode(new tE(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(w.tokens.semicolon)?null:this._for_init(),this._consume(w.tokens.semicolon,"Expected ';'."),e.condition=this._check(w.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(w.tokens.semicolon,"Expected ';'."),e.increment=this._check(w.tokens.paren_right)?null:this._for_increment(),this._consume(w.tokens.paren_right,"Expected ')'."),this._check(w.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(w.keywords.var)){const e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(w.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Jr(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(w.keywords.let)){const e=this._currentLine,t=this._consume(w.tokens.name,"Expected name for let.").toString();let n=null;if(this._match(w.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}this._consume(w.tokens.equal,"Expected '=' for let.");const s=this._short_circuit_or_expression();return this._updateNode(new tu(t,n,null,null,s),e)}if(this._match(w.keywords.const)){const e=this._currentLine,t=this._consume(w.tokens.name,"Expected name for const.").toString();let n=null;if(this._match(w.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}this._consume(w.tokens.equal,"Expected '=' for const.");const s=this._short_circuit_or_expression();return n===null&&s instanceof xi&&(n=s.type),this._updateNode(new ph(t,n,null,null,s),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(w.increment_operators))return this._current=e,null;const n=this._consume(w.increment_operators,"Expected increment operator");return this._updateNode(new iE(n.type===w.tokens.plus_plus?tl.increment:tl.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(w.tokens.brace_right))return null;let n=this._match(w.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e==null)return null;const s=this._consume(w.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new nE(Oc.parse(s.lexeme),e,r),t)}_func_call_statement(){if(!this._check(w.tokens.ident))return null;const e=this._currentLine,t=this._current,n=this._consume(w.tokens.ident,"Expected function name."),s=this._argument_expression_list();return s===null?(this._current=t,null):this._updateNode(new Sy(n.lexeme,s),e)}_loop_statement(){if(!this._match(w.keywords.loop))return null;this._check(w.tokens.attr)&&this._attribute(),this._consume(w.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new sE([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let n of t)e.body.push(n);else e.body.push(t);if(t instanceof Ng){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(w.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(w.keywords.switch))return null;const e=this._updateNode(new rE(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(w.tokens.attr)&&this._attribute(),this._consume(w.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),e.cases==null||e.cases.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(w.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([w.keywords.default,w.keywords.case]);){if(this._match(w.keywords.case)){const n=this._case_selectors();for(const r of n)if(r instanceof _h){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(w.tokens.colon),this._check(w.tokens.attr)&&this._attribute(),this._consume(w.tokens.brace_left,"Exected '{' for switch case.");const s=this._case_body();this._consume(w.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new mE(n,s)))}if(this._match(w.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(w.tokens.colon),this._check(w.tokens.attr)&&this._attribute(),this._consume(w.tokens.brace_left,"Exected '{' for switch default.");const n=this._case_body();this._consume(w.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new gE(n)))}}return e}_case_selectors(){const e=[];for(this._match(w.keywords.default)?e.push(this._updateNode(new _h)):e.push(this._shift_expression());this._match(w.tokens.comma);)this._match(w.keywords.default)?e.push(this._updateNode(new _h)):e.push(this._shift_expression());return e}_case_body(){if(this._match(w.keywords.fallthrough))return this._consume(w.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);const t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(w.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(w.tokens.attr)&&this._attribute();const n=this._compound_statement();let s=[];this._match_elseif()&&(this._check(w.tokens.attr)&&this._attribute(),s=this._elseif_statement(s));let r=null;return this._match(w.keywords.else)&&(this._check(w.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new oE(t,n,s,r),e)}_match_elseif(){return this._tokens[this._current].type===w.keywords.else&&this._tokens[this._current+1].type===w.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new QM(t,n))),this._match_elseif()&&(this._check(w.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(w.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new aE(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(w.tokens.or_or);)e=this._updateNode(new Ds(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(w.tokens.and_and);)e=this._updateNode(new Ds(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(w.tokens.or);)e=this._updateNode(new Ds(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(w.tokens.xor);)e=this._updateNode(new Ds(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(w.tokens.and);)e=this._updateNode(new Ds(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([w.tokens.equal_equal,w.tokens.not_equal])?this._updateNode(new Ds(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([w.tokens.less_than,w.tokens.greater_than,w.tokens.less_than_equal,w.tokens.greater_than_equal]);)e=this._updateNode(new Ds(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([w.tokens.shift_left,w.tokens.shift_right]);)e=this._updateNode(new Ds(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([w.tokens.plus,w.tokens.minus]);)e=this._updateNode(new Ds(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([w.tokens.star,w.tokens.forward_slash,w.tokens.modulo]);)e=this._updateNode(new Ds(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([w.tokens.minus,w.tokens.bang,w.tokens.tilde,w.tokens.star,w.tokens.and])?this._updateNode(new mi(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(w.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(w.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new kl(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(w.tokens.period)){const e=this._consume(w.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new ya(e.lexeme));return t&&(n.postfix=t),n}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return Y.void;case"bool":return Y.bool;case"i32":return Y.i32;case"u32":return Y.u32;case"f32":return Y.f32;case"f16":return Y.f16;case"vec2f":return B.vec2f;case"vec3f":return B.vec3f;case"vec4f":return B.vec4f;case"vec2i":return B.vec2i;case"vec3i":return B.vec3i;case"vec4i":return B.vec4i;case"vec2u":return B.vec2u;case"vec3u":return B.vec3u;case"vec4u":return B.vec4u;case"vec2h":return B.vec2h;case"vec3h":return B.vec3h;case"vec4h":return B.vec4h;case"mat2x2f":return B.mat2x2f;case"mat2x3f":return B.mat2x3f;case"mat2x4f":return B.mat2x4f;case"mat3x2f":return B.mat3x2f;case"mat3x3f":return B.mat3x3f;case"mat3x4f":return B.mat3x4f;case"mat4x2f":return B.mat4x2f;case"mat4x3f":return B.mat4x3f;case"mat4x4f":return B.mat4x4f;case"mat2x2h":return B.mat2x2h;case"mat2x3h":return B.mat2x3h;case"mat2x4h":return B.mat2x4h;case"mat3x2h":return B.mat3x2h;case"mat3x3h":return B.mat3x3h;case"mat3x4h":return B.mat3x4h;case"mat4x2h":return B.mat4x2h;case"mat4x3h":return B.mat4x3h;case"mat4x4h":return B.mat4x4h;case"mat2x2i":return B.mat2x2i;case"mat2x3i":return B.mat2x3i;case"mat2x4i":return B.mat2x4i;case"mat3x2i":return B.mat3x2i;case"mat3x3i":return B.mat3x3i;case"mat3x4i":return B.mat3x4i;case"mat4x2i":return B.mat4x2i;case"mat4x3i":return B.mat4x3i;case"mat4x4i":return B.mat4x4i;case"mat2x2u":return B.mat2x2u;case"mat2x3u":return B.mat2x3u;case"mat2x4u":return B.mat2x4u;case"mat3x2u":return B.mat3x2u;case"mat3x3u":return B.mat3x3u;case"mat3x4u":return B.mat3x4u;case"mat4x2u":return B.mat4x2u;case"mat4x3u":return B.mat4x3u;case"mat4x4u":return B.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(w.tokens.ident)){const n=this._previous().toString();if(this._check(w.tokens.paren_left)){const s=this._argument_expression_list(),r=this._getType(n);return r!==null?this._updateNode(new ur(r,s)):this._updateNode(new Cy(n,s))}if(this._context.constants.has(n)){const s=this._context.constants.get(n);return this._updateNode(new dE(n,s.value))}return this._updateNode(new Hn(n))}if(this._match(w.tokens.int_literal)){const n=this._previous().toString();let s=n.endsWith("i")||n.endsWith("i")?Y.i32:n.endsWith("u")||n.endsWith("U")?Y.u32:Y.x32;const r=parseInt(n);return this._validateTypeRange(r,s),this._updateNode(new xi(new M(r,this._exec.getTypeInfo(s)),s))}if(this._match(w.tokens.uint_literal)){const n=parseInt(this._previous().toString());return this._validateTypeRange(n,Y.u32),this._updateNode(new xi(new M(n,this._exec.getTypeInfo(Y.u32)),Y.u32))}if(this._match([w.tokens.decimal_float_literal,w.tokens.hex_float_literal])){let n=this._previous().toString(),s=n.endsWith("h");s&&(n=n.substring(0,n.length-1));const r=parseFloat(n);this._validateTypeRange(r,s?Y.f16:Y.f32);const o=s?Y.f16:Y.f32;return this._updateNode(new xi(new M(r,this._exec.getTypeInfo(o)),o))}if(this._match([w.keywords.true,w.keywords.false])){let n=this._previous().toString()===w.keywords.true.rule;return this._updateNode(new xi(new M(n?1:0,this._exec.getTypeInfo(Y.bool)),Y.bool))}if(this._check(w.tokens.paren_left))return this._paren_expression();if(this._match(w.keywords.bitcast)){this._consume(w.tokens.less_than,"Expected '<'.");const n=this._type_decl();this._consume(w.tokens.greater_than,"Expected '>'.");const s=this._paren_expression();return this._updateNode(new hE(n,s))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new ur(e,t))}_argument_expression_list(){if(!this._match(w.tokens.paren_left))return null;const e=[];do{if(this._check(w.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(w.tokens.comma));return this._consume(w.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(w.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(w.tokens.paren_right),e}_paren_expression(){this._consume(w.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(w.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(w.keywords.struct))return null;const e=this._currentLine,t=this._consume(w.tokens.ident,"Expected name for struct.").toString();this._consume(w.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(w.tokens.brace_right);){const o=this._attribute(),a=this._consume(w.tokens.name,"Expected variable name.").toString();this._consume(w.tokens.colon,"Expected ':' for struct member type.");const l=this._attribute(),c=this._type_decl();c!=null&&(c.attributes=l),this._check(w.tokens.brace_right)?this._match(w.tokens.comma):this._consume(w.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new Ex(a,c,o)))}this._consume(w.tokens.brace_right,"Expected '}' after struct body.");const s=this._currentLine,r=this._updateNode(new Kr(t,n,e,s),e);return this._context.structs.set(t,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(w.tokens.equal)){const t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof xi){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof xi&&(e.type=e.value.type.name==="x32"?Y.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(w.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(w.keywords.const))return null;const t=this._consume(w.tokens.name,"Expected variable name"),n=this._currentLine;let s=null;if(this._match(w.tokens.colon)){const l=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=l)}let r=null;this._consume(w.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let l=[Y.f32],c=o.constEvaluate(this._exec,l);c instanceof M&&this._validateTypeRange(c.value,l[0]),l[0]instanceof B&&l[0].format===null&&c.typeInfo instanceof _a&&c.typeInfo.format!==null&&(c.typeInfo.format.name==="f16"?l[0].format=Y.f16:c.typeInfo.format.name==="f32"?l[0].format=Y.f32:c.typeInfo.format.name==="i32"?l[0].format=Y.i32:c.typeInfo.format.name==="u32"?l[0].format=Y.u32:c.typeInfo.format.name==="bool"?l[0].format=Y.bool:console.error(`TODO: impelement template format type ${c.typeInfo.format.name}`)),r=this._updateNode(new xi(c,l[0])),this._exec.context.setVariable(t.toString(),c)}catch{r=o}if(s!==null&&r instanceof xi){if(r.type.name!=="x32"&&s.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${s.name}. Line:${this._currentLine}`);r.type=s,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else s===null&&r instanceof xi&&(s=(e=r==null?void 0:r.type)!==null&&e!==void 0?e:Y.f32,s===Y.x32&&(s=Y.i32));const a=this._updateNode(new ph(t.toString(),s,"","",r),n);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(w.keywords.let))return null;const e=this._currentLine,t=this._consume(w.tokens.name,"Expected variable name");let n=null;if(this._match(w.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}let s=null;if(this._match(w.tokens.equal)&&(s=this._const_expression()),n!==null&&s instanceof xi){if(s.type.name!=="x32"&&n.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${n.name}. Line:${this._currentLine}`);s.type=n}else n===null&&s instanceof xi&&(n=s.type.name==="x32"?Y.i32:s.type);return s instanceof xi&&s.isScalar&&this._validateTypeRange(s.scalarValue,n),this._updateNode(new tu(t.toString(),n,"","",s),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(w.keywords.var))return null;const e=this._currentLine;let t="",n="";this._match(w.tokens.less_than)&&(t=this._consume(w.storage_class,"Expected storage_class.").toString(),this._match(w.tokens.comma)&&(n=this._consume(w.access_mode,"Expected access_mode.").toString()),this._consume(w.tokens.greater_than,"Expected '>'."));const s=this._consume(w.tokens.name,"Expected variable name");let r=null;if(this._match(w.tokens.colon)){const o=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=o)}return this._updateNode(new Jr(s.toString(),r,t,n,null),e)}_override_decl(){if(!this._match(w.keywords.override))return null;const e=this._consume(w.tokens.name,"Expected variable name");let t=null;if(this._match(w.tokens.colon)){const n=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=n)}return this._updateNode(new wy(e.toString(),t,null))}_diagnostic(){this._consume(w.tokens.paren_left,"Expected '('");const e=this._consume(w.tokens.ident,"Expected severity control name.");this._consume(w.tokens.comma,"Expected ','");let t=this._consume(w.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(w.tokens.period)&&(t+=`.${this._consume(w.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(w.tokens.paren_right,"Expected ')'"),this._updateNode(new lE(e.toString(),t))}_enable_directive(){const e=this._consume(w.tokens.ident,"identity expected.");return this._updateNode(new XM(e.toString()))}_requires_directive(){const e=[this._consume(w.tokens.ident,"identity expected.").toString()];for(;this._match(w.tokens.comma);){const t=this._consume(w.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new KM(e))}_type_alias(){const e=this._consume(w.tokens.ident,"identity expected.");this._consume(w.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const n=this._updateNode(new Ey(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([w.tokens.ident,...w.texel_format,w.keywords.bool,w.keywords.f32,w.keywords.i32,w.keywords.u32])){const n=this._advance().toString();if(this._context.structs.has(n))return this._context.structs.get(n);if(this._context.aliases.has(n))return this._context.aliases.get(n).type;if(!this._getType(n)){const s=this._updateNode(new wx(n));return this._forwardTypeCount++,s}return this._updateNode(new Y(n))}let e=this._texture_sampler_types();if(e)return e;if(this._check(w.template_types)){let n=this._advance().toString(),s=null,r=null;return this._match(w.tokens.less_than)&&(s=this._type_decl(),r=null,this._match(w.tokens.comma)&&(r=this._consume(w.access_mode,"Expected access_mode for pointer").toString()),this._consume(w.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new B(n,s,r))}if(this._match(w.keywords.ptr)){let n=this._previous().toString();this._consume(w.tokens.less_than,"Expected '<' for pointer.");const s=this._consume(w.storage_class,"Expected storage_class for pointer");this._consume(w.tokens.comma,"Expected ',' for pointer.");const r=this._type_decl();let o=null;return this._match(w.tokens.comma)&&(o=this._consume(w.access_mode,"Expected access_mode for pointer").toString()),this._consume(w.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new gh(n,s.toString(),r,o))}const t=this._attribute();if(this._match(w.keywords.array)){let n=null,s=-1;const r=this._previous();let o=null;if(this._match(w.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let l="";if(this._match(w.tokens.comma)){o=this._shift_expression();try{l=o.constEvaluate(this._exec).toString(),o=null}catch{l="1"}}this._consume(w.tokens.greater_than,"Expected '>' for array."),s=l?parseInt(l):0}const a=this._updateNode(new iu(r.toString(),t,n,s));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(w.sampler_type))return this._updateNode(new Fc(this._previous().toString(),null,null));if(this._match(w.depth_texture_type))return this._updateNode(new Fc(this._previous().toString(),null,null));if(this._match(w.sampled_texture_type)||this._match(w.multisampled_texture_type)){const e=this._previous();this._consume(w.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(w.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Fc(e.toString(),t,null))}if(this._match(w.storage_texture_type)){const e=this._previous();this._consume(w.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(w.texel_format,"Invalid texel format.").toString();this._consume(w.tokens.comma,"Expected ',' after texel format.");const n=this._consume(w.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(w.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Fc(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(w.tokens.attr);){const t=this._consume(w.attribute_name,"Expected attribute name"),n=this._updateNode(new _E(t.toString(),null));if(this._match(w.tokens.paren_left)){if(n.value=this._consume(w.literal_or_ident,"Expected attribute value").toString(),this._check(w.tokens.comma)){this._advance();do{const s=this._consume(w.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(s)}while(this._match(w.tokens.comma))}this._consume(w.tokens.paren_right,"Expected ')'")}e.push(n)}return e.length==0?null:e}}class hB extends mr{constructor(e){super(),e&&this.update(e)}update(e){const t=new dB().parse(e);this.updateAST(t)}}function fB(i){var e;const t={attributes:[],bindings:[]};let n;try{n=pB(i)}catch(o){return le.error(o.message)(),t}for(const o of n.uniforms){const a=[];for(const l of((e=o.type)==null?void 0:e.members)||[])a.push({name:l.name,type:kx(l.type)});t.bindings.push({type:"uniform",name:o.name,group:o.group,location:o.binding,members:a})}for(const o of n.textures)t.bindings.push({type:"texture",name:o.name,group:o.group,location:o.binding});for(const o of n.samplers)t.bindings.push({type:"sampler",name:o.name,group:o.group,location:o.binding});const s=n.entry.vertex[0],r=(s==null?void 0:s.inputs.length)||0;for(let o=0;o<r;o++){const a=s.inputs[o];if(a.locationType==="location"){const l=kx(a.type);t.attributes.push({name:a.name,location:Number(a.location),type:l})}}return t}function kx(i){return i!=null&&i.format?`${i.name}<${i.format.name}>`:i.name}function pB(i){try{return new hB(i)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e!=null&&e.message&&(t+=`: ${e.message} `),typeof e=="object"&&e!=null&&e.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}const hm={};function up(i="id"){hm[i]=hm[i]||1;const e=hm[i]++;return`${i}-${e}`}class Ax{constructor(e){if($(this,"id"),$(this,"userData",{}),$(this,"topology"),$(this,"bufferLayout",[]),$(this,"vertexCount"),$(this,"indices"),$(this,"attributes"),this.id=e.id||up("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&me.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function mB(i,e){if(e instanceof Ax)return e;const t=gB(i,e),{attributes:n,bufferLayout:s}=_B(i,e);return new Ax({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:t,attributes:n})}function gB(i,e){if(!e.indices)return;const t=e.indices.value;return i.createBuffer({usage:me.INDEX,data:t})}function _B(i,e){const t=[],n={};for(const[r,o]of Object.entries(e.attributes)){let a=r;switch(r){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){n[a]=i.createBuffer({data:o.value,id:`${r}-buffer`});const{value:l,size:c,normalized:u}=o;t.push({name:a,format:_N(l,c,u)})}}const s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:t,vertexCount:s}}const yE=class bE{constructor(e){$(this,"device"),$(this,"cachingEnabled"),$(this,"destroyPolicy"),$(this,"debug"),$(this,"_hashCounter",0),$(this,"_hashes",{}),$(this,"_renderPipelineCache",{}),$(this,"_computePipelineCache",{}),this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new bE(e),e._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var t;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const n={...Zh.defaultProps,...e},s=this._renderPipelineCache,r=this._hashRenderPipeline(n);let o=(t=s[r])==null?void 0:t.pipeline;return o?(s[r].useCount++,this.debug&&le.log(3,`${this}: ${s[r].pipeline} reused, count=${s[r].useCount}, (id=${e.id})`)()):(o=this.device.createRenderPipeline({...n,id:n.id?`${n.id}-cached`:up("unnamed-cached")}),o.hash=r,s[r]={pipeline:o,useCount:1},this.debug&&le.log(3,`${this}: ${o} created, count=${s[r].useCount}`)()),o}createComputePipeline(e){var t;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const n={...tx.defaultProps,...e},s=this._computePipelineCache,r=this._hashComputePipeline(n);let o=(t=s[r])==null?void 0:t.pipeline;return o?(s[r].useCount++,this.debug&&le.log(3,`${this}: ${s[r].pipeline} reused, count=${s[r].useCount}, (id=${e.id})`)()):(o=this.device.createComputePipeline({...n,id:n.id?`${n.id}-cached`:void 0}),o.hash=r,s[r]={pipeline:o,useCount:1},this.debug&&le.log(3,`${this}: ${o} created, count=${s[r].useCount}`)()),o}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.debug&&le.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(le.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.debug&&le.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof tx&&(t=this._computePipelineCache),e instanceof Zh&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device,n=this._getHash(e.shader.source);return`${t}/C/${n}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s="-",r=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${n}V${s}BL${r}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${s}T${e.topology}P${a}BL${r}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};$(yE,"defaultProps",{...Zh.defaultProps});let yB=yE;const vE=class xE{constructor(e){$(this,"device"),$(this,"cachingEnabled"),$(this,"destroyPolicy"),$(this,"debug"),$(this,"_cache",{}),this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(e){var t;return(t=e._lumaData).defaultShaderFactory||(t.defaultShaderFactory=new xE(e)),e._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let n=this._cache[t];if(n)n.useCount++,this.debug&&le.log(3,`${this}: Reusing shader ${n.shader.id} count=${n.useCount}`)();else{const s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={shader:s,useCount:1},this.debug&&le.log(3,`${this}: Created new shader ${s.id}`)()}return n.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],n.shader.destroy(),this.debug&&le.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&le.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};$(vE,"defaultProps",{...VN.defaultProps});let bB=vE;function vB(i,e){var t;const n={},s="Values";if(i.attributes.length===0&&!((t=i.varyings)!=null&&t.length))return{"No attributes or varyings":{[s]:"N/A"}};for(const r of i.attributes)if(r){const o=`${r.location} ${r.name}: ${r.type}`;n[`in ${o}`]={[s]:r.stepMode||"vertex"}}for(const r of i.varyings||[]){const o=`${r.location} ${r.name}`;n[`out ${o}`]={[s]:JSON.stringify(r)}}return n}let ki=null,pc=null;function xB(i,{id:e,minimap:t,opaque:n,top:s="0",left:r="0",rgbaScale:o=1}){ki||(ki=document.createElement("canvas"),ki.id=e,ki.title=e,ki.style.zIndex="100",ki.style.position="absolute",ki.style.top=s,ki.style.left=r,ki.style.border="blue 5px solid",ki.style.transform="scaleY(-1)",document.body.appendChild(ki),pc=ki.getContext("2d")),(ki.width!==i.width||ki.height!==i.height)&&(ki.width=i.width/2,ki.height=i.height/2,ki.style.width="400px",ki.style.height="400px");const a=i.device.readPixelsToArrayWebGL(i),l=pc==null?void 0:pc.createImageData(i.width,i.height);if(l){for(let c=0;c<a.length;c+=4)l.data[0+c+0]=a[c+0]*o,l.data[0+c+1]=a[c+1]*o,l.data[0+c+2]=a[c+2]*o,l.data[0+c+3]=n?255:a[c+3]*o;pc==null||pc.putImageData(l,0,0)}}function Bg(i,e,t){if(i===e)return!0;if(!t||!i||!e)return!1;if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let n=0;n<i.length;n++)if(!Bg(i[n],e[n],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof i=="object"&&typeof e=="object"){const n=Object.keys(i),s=Object.keys(e);if(n.length!==s.length)return!1;for(const r of n)if(!e.hasOwnProperty(r)||!Bg(i[r],e[r],t-1))return!1;return!0}return!1}class fm{constructor(e){$(this,"bufferLayouts"),this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?(t=e.attributes)==null?void 0:t.map(n=>n.attribute):[e.name]}mergeBufferLayouts(e,t){const n=[...e];for(const s of t){const r=n.findIndex(o=>o.name===s.name);r<0?n.push(s):n[r]=s}return n}getBufferIndex(e){const t=this.bufferLayouts.findIndex(n=>n.name===e);return t===-1&&le.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function wB(i,e){const t=Object.fromEntries(i.attributes.map(s=>[s.name,s.location])),n=e.slice();return n.sort((s,r)=>{const o=s.attributes?s.attributes.map(u=>u.attribute):[s.name],a=r.attributes?r.attributes.map(u=>u.attribute):[r.name],l=Math.min(...o.map(u=>t[u])),c=Math.min(...a.map(u=>t[u]));return l-c}),n}function SB(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function EB(i){return Array.isArray(i)?i.length===0||typeof i[0]=="number":!1}function CB(i){return SB(i)||EB(i)}function TB(i){return CB(i)||typeof i=="number"||typeof i=="boolean"}function kB(i){const e={bindings:{},uniforms:{}};return Object.keys(i).forEach(t=>{const n=i[t];TB(n)?e.uniforms[t]=n:e.bindings[t]=n}),e}class AB{constructor(e,t){$(this,"options",{disableWarnings:!1}),$(this,"modules"),$(this,"moduleUniforms"),$(this,"moduleBindings"),Object.assign(this.options,t);const n=vy(Object.values(e).filter(s=>s.dependencies));for(const s of n)e[s.name]=s;le.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[s,r]of Object.entries(e))this._addModule(r),r.name&&s!==r.name&&!this.options.disableWarnings&&le.warn(`Module name: ${s} vs ${r.name}`)()}destroy(){}setProps(e){var t;for(const n of Object.keys(e)){const s=n,r=e[s]||{},o=this.modules[s];if(!o){this.options.disableWarnings||le.warn(`Module ${n} not found`)();continue}const a=this.moduleUniforms[s],l=this.moduleBindings[s],c=((t=o.getUniforms)==null?void 0:t.call(o,r,a))||r,{uniforms:u,bindings:d}=kB(c);this.moduleUniforms[s]={...a,...u},this.moduleBindings[s]={...l,...d}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var e;const t={};for(const[n,s]of Object.entries(this.moduleUniforms))for(const[r,o]of Object.entries(s))t[`${n}.${r}`]={type:(e=this.modules[n].uniformTypes)==null?void 0:e[r],value:String(o)};return t}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}let IB="";async function LB(i,e){const t=new Image;return t.crossOrigin="anonymous",t.src=i.startsWith("http")?i:IB+i,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}const RB=["+X","-X","+Y","-Y","+Z","-Z"],PB=["+X","-X","+Y","-Y","+Z","-Z"],wE=class SE{constructor(e,t){$(this,"device"),$(this,"id"),$(this,"props"),$(this,"texture"),$(this,"sampler"),$(this,"view"),$(this,"ready"),$(this,"isReady",!1),$(this,"destroyed",!1),$(this,"resolveReady",()=>{}),$(this,"rejectReady",()=>{}),this.device=e;const n=up("async-texture");this.props={...SE.defaultProps,id:n,...t},this.id=this.props.id,t={...t},typeof(t==null?void 0:t.data)=="string"&&t.dimension==="2d"&&(t.data=LB(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((s,r)=>{this.resolveReady=()=>{this.isReady=!0,s()},this.rejectReady=r}),this.initAsync(t)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,n=await EE(t).then(void 0,this.rejectReady);if(this.destroyed)return;const s=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(n);if(!s)throw new Error("Texture size could not be determined");const r={...s,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(r.width,r.height);if(r.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(r),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,n);break;case"2d":this._setTexture2DData(n);break;case"3d":this._setTexture3DData(this.texture,n);break;case"2d-array":this._setTextureArrayData(this.texture,n);break;case"cube":this._setTextureCubeData(this.texture,n);break;case"cube-array":this._setTextureCubeArrayData(this.texture,n);break}this.props.mipmaps&&this.generateMipmaps(),le.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof _y?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=e==null?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){const t=Object.values(e)[0];return{width:t.width,height:t.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const n=this._normalizeTextureData(e);n.length>1&&this.props.mipmaps!==!1&&le.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let s=0;s<n.length;s++){const r=n[s];this.device.isExternalImage(r)?this.texture.copyExternalImage({image:r,depth:t,mipLevel:s,flipY:!0}):this.texture.copyImageData({data:r.data,mipLevel:s})}}_setTexture3DData(e,t){var n;if(((n=this.texture)==null?void 0:n.props.dimension)!=="3d")throw new Error(this.id);for(let s=0;s<t.length;s++)this._setTexture2DData(t[s],s)}_setTextureCubeData(e,t){var n;if(((n=this.texture)==null?void 0:n.props.dimension)!=="cube")throw new Error(this.id);for(const[s,r]of Object.entries(t)){const o=PB.indexOf(s);this._setTexture2DData(r,o)}}_setTextureArrayData(e,t){var n;if(((n=this.texture)==null?void 0:n.props.dimension)!=="2d-array")throw new Error(this.id);for(let s=0;s<t.length;s++)this._setTexture2DData(t[s],s)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,n,s=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&le.warn(`${this.id} has mipmap and multiple LODs.`)();const r=RB.indexOf(n);this._setTexture2DData(t,r)}_normalizeTextureData(e){const t=this.texture;let n;return ArrayBuffer.isView(e)?n=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?n=e:n=[e],n}};$(wE,"defaultProps",{...lt.defaultProps,data:null,mipmaps:!1});let pm=wE;async function EE(i){if(i=await i,Array.isArray(i))return await Promise.all(i.map(EE));if(i&&typeof i=="object"&&i.constructor===Object){const e=i,t=await Promise.all(Object.values(e)),n=Object.keys(e),s={};for(let r=0;r<n.length;r++)s[n[r]]=t[r];return s}return i}const ea=2,NB=1e4,CE=class TE{constructor(e,t){$(this,"device"),$(this,"id"),$(this,"source"),$(this,"vs"),$(this,"fs"),$(this,"pipelineFactory"),$(this,"shaderFactory"),$(this,"userData",{}),$(this,"parameters"),$(this,"topology"),$(this,"bufferLayout"),$(this,"isInstanced"),$(this,"instanceCount",0),$(this,"vertexCount"),$(this,"indexBuffer",null),$(this,"bufferAttributes",{}),$(this,"constantAttributes",{}),$(this,"bindings",{}),$(this,"vertexArray"),$(this,"transformFeedback",null),$(this,"pipeline"),$(this,"shaderInputs"),$(this,"_uniformStore"),$(this,"_attributeInfos",{}),$(this,"_gpuGeometry",null),$(this,"props"),$(this,"_pipelineNeedsUpdate","newly created"),$(this,"_needsRedraw","initializing"),$(this,"_destroyed",!1),$(this,"_lastDrawTimestamp",-1),$(this,"_lastLogTime",0),$(this,"_logOpen",!1),$(this,"_drawCount",0);var n,s,r,o;this.props={...TE.defaultProps,...t},t=this.props,this.id=t.id||up("model"),this.device=e,Object.assign(this.userData,t.userData);const a=Object.fromEntries(((n=this.props.modules)==null?void 0:n.map(d=>[d.name,d]))||[]),l=t.shaderInputs||new AB(a,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(l);const c=MB(e),u=(((s=this.props.modules)==null?void 0:s.length)>0?this.props.modules:(r=this.shaderInputs)==null?void 0:r.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:d,getUniforms:h}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:c,...this.props,modules:u});this.source=d,this._getModuleUniforms=h,(o=this.props).shaderLayout||(o.shaderLayout=fB(this.source))}else{const{vs:d,fs:h,getUniforms:p}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:c,...this.props,modules:u});this.vs=d,this.fs=h,this._getModuleUniforms=p}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||yB.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||bB.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return le.info(ea,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const s=this._getBindings();this.pipeline.setBindings(s,{disableWarnings:this.props.disableWarnings});const{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){var t;(t=this._gpuGeometry)==null||t.destroy();const n=e&&mB(this.device,e);if(n){this.setTopology(n.topology||"triangle-list");const s=new fm(this.bufferLayout);this.bufferLayout=s.mergeBufferLayouts(n.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(n)}this._gpuGeometry=n}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new fm(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Bg(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new ai(this.shaderInputs.modules);for(const[t,n]of Object.entries(this.shaderInputs.modules))if(DB(n)){const s=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const n=(t==null?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&le.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=wB(this.pipeline.shaderLayout,this.bufferLayout);const s=new fm(this.bufferLayout);for(const[r,o]of Object.entries(e)){const a=s.getBufferLayout(r);if(!a){n||le.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const l=s.getAttributeNamesForBuffer(a);let c=!1;for(const u of l){const d=this._attributeInfos[u];if(d){const h=this.device.type==="webgpu"?s.getBufferIndex(d.bufferName):d.location;this.vertexArray.setBuffer(h,o),c=!0}}!c&&!n&&le.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[n,s]of Object.entries(e)){const r=this._attributeInfos[n];r?this.vertexArray.setConstantWebGL(r.location,s):((t==null?void 0:t.disableWarnings)??this.props.disableWarnings)||le.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof pm&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))n instanceof pm?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof zN?e=Math.max(e,t.texture.updateTimestamp):t instanceof me||t instanceof lt?e=Math.max(e,t.updateTimestamp):t instanceof pm?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof _y||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[n]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(s=>s.name===n)&&n!=="positions"&&delete t[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(le.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=n:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:s}),this._attributeInfos=R2(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=le.level>3?0:NB;le.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,le.group(ea,`>>> DRAWING MODEL ${this.id}`,{collapsed:le.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=vB(this.pipeline.shaderLayout,this.id);le.table(ea,e)();const t=this.shaderInputs.getDebugTable();le.table(ea,t)();const n=this._getAttributeDebugTable();le.table(ea,this._attributeInfos)(),le.table(ea,n)(),le.groupEnd(ea)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const n=e.props.framebuffer;n&&xB(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,n]of Object.entries(this._attributeInfos)){const s=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:s?this._getBufferOrConstantValues(s,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,n=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){const n=mN(t);return(e instanceof me?new n(e.debugData):e).toString()}};$(CE,"defaultProps",{...Zh.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:OM.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let ci=CE;function DB(i){return!!(i.uniformTypes&&!BB(i.uniformTypes))}function MB(i){return{type:i.type,shaderLanguage:i.info.shadingLanguage,shaderLanguageVersion:i.info.shadingLanguageVersion,gpu:i.info.gpu,features:i.features}}function BB(i){for(const e in i)return!1;return!0}class Zo{constructor(e,t,n,s,r){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=t,this.store=n,this.data=s,r&&(this.points=r)}}const OB=`#version 300 es
precision highp float;

in vec4 rgba;
out vec4 fragColor;

void main() {
  fragColor = rgba;
}`,FB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform calculateCentermassUniforms {
  float pointsTextureSize;
} calculateCentermass;

#define pointsTextureSize calculateCentermass.pointsTextureSize
#else
uniform float pointsTextureSize;
#endif

in vec2 pointIndices;

out vec4 rgba;

void main() {
  vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize);
  rgba = vec4(pointPosition.xy, 1.0, 0.0);

  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
  gl_PointSize = 1.0;
}
`,zB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;
uniform sampler2D centermassTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceCenterUniforms {
  float centerForce;
  float alpha;
} forceCenter;

#define centerForce forceCenter.centerForce
#define alpha forceCenter.alpha
#else
uniform float centerForce;
uniform float alpha;
#endif

in vec2 textureCoords;
out vec4 fragColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 velocity = vec4(0.0);
  vec4 centermassValues = texture(centermassTexture, vec2(0.0));
  vec2 centermassPosition = centermassValues.xy / centermassValues.b;
  vec2 distVector = centermassPosition - pointPosition.xy;
  float dist = sqrt(dot(distVector, distVector));
  if (dist > 0.0) {
    float angle = atan(distVector.y, distVector.x);
    float addV = alpha * centerForce * dist * 0.01;
    velocity.rg += addV * vec2(cos(angle), sin(angle));
  }

  fragColor = velocity;
}`;function dp(i){const e=new Float32Array(i*i*2);for(let t=0;t<i;t++)for(let n=0;n<i;n++){const s=t*i*2+n*2;e[s+0]=n,e[s+1]=t}return e}function at(i,e){const t=eu.getInfo(i);return e*(t.bytesPerPixel??0)}const fs=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 vertexCoord; // Vertex coordinates in normalized device coordinates
out vec2 textureCoords; // Texture coordinates to pass to the fragment shader

void main() {
    // Convert vertex coordinates from [-1, 1] range to [0, 1] range for texture sampling
    textureCoords = (vertexCoord + 1.0) / 2.0;
    gl_Position = vec4(vertexCoord, 0, 1);
}
`;class UB extends Zo{create(){var e;const{device:t,store:n}=this,{pointsTextureSize:s}=n;if(s){if(this.centermassTexture||(this.centermassTexture=t.createTexture({width:1,height:1,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST})),this.centermassTexture.copyImageData({data:new Float32Array(4).fill(0),bytesPerRow:at("rgba32float",1),mipLevel:0,x:0,y:0}),this.centermassFbo||(this.centermassFbo=t.createFramebuffer({width:1,height:1,colorAttachments:[this.centermassTexture]})),!this.pointIndices||this.previousPointsTextureSize!==n.pointsTextureSize){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const r=dp(n.pointsTextureSize);this.pointIndices=t.createBuffer({data:r,usage:me.VERTEX|me.COPY_DST}),(e=this.calculateCentermassCommand)==null||e.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=s}}initPrograms(){const{device:e,store:t,points:n}=this;!n||!t.pointsTextureSize||!this.centermassFbo||this.centermassFbo.destroyed||!this.centermassTexture||this.centermassTexture.destroyed||(this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.calculateUniformStore||(this.calculateUniformStore=new ai({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32"}}})),this.forceUniformStore||(this.forceUniformStore=new ai({forceCenterUniforms:{uniformTypes:{centerForce:"f32",alpha:"f32"}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new ci(e,{fs:OB,vs:FB,topology:"point-list",attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.runCommand||(this.runCommand=new ci(e,{fs:zB,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCenterUniforms:this.forceUniformStore.getManagedUniformBuffer(e,"forceCenterUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,store:t,points:n}=this;if(!n||!this.calculateCentermassCommand||!this.calculateUniformStore||!this.runCommand||!this.forceUniformStore||!this.centermassFbo||!this.centermassTexture||!n.previousPositionTexture||n.previousPositionTexture.destroyed||!n.velocityFbo||n.velocityFbo.destroyed||t.pointsTextureSize!==this.previousPointsTextureSize||!this.pointIndices)return;const s=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:t.pointsTextureSize??0}}),this.calculateCentermassCommand.setBindings({positionsTexture:n.previousPositionTexture}),this.calculateCentermassCommand.draw(s),s.end(),this.forceUniformStore.setUniforms({forceCenterUniforms:{centerForce:this.config.simulationCenter??0,alpha:t.alpha}}),this.runCommand.setBindings({positionsTexture:n.previousPositionTexture,centermassTexture:this.centermassTexture});const r=e.beginRenderPass({framebuffer:n.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(r),r.end()}destroy(){var e,t,n,s;(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(t=this.runCommand)==null||t.destroy(),this.runCommand=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=void 0,(n=this.calculateUniformStore)==null||n.destroy(),this.calculateUniformStore=void 0,(s=this.forceUniformStore)==null||s.destroy(),this.forceUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0,this.previousPointsTextureSize=void 0}}const $B=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceGravityUniforms {
  float gravity;
  float spaceSize;
  float alpha;
} forceGravity;

#define gravity forceGravity.gravity
#define spaceSize forceGravity.spaceSize
#define alpha forceGravity.alpha
#else
uniform float gravity;
uniform float spaceSize;
uniform float alpha;
#endif

in vec2 textureCoords;
out vec4 fragColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);

  vec4 velocity = vec4(0.0);

  vec2 centerPosition = vec2(spaceSize * 0.5);
  vec2 distVector = centerPosition - pointPosition.rg;
  float dist = sqrt(dot(distVector, distVector));
  if (dist > 0.0) {
    float angle = atan(distVector.y, distVector.x);
    float additionalVelocity = alpha * gravity * dist * 0.1;
    velocity.rg += additionalVelocity * vec2(cos(angle), sin(angle));
  }

  fragColor = velocity;
}`;class jB extends Zo{initPrograms(){const{device:e,points:t,store:n}=this;!t||!n.pointsTextureSize||(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ai({forceGravityUniforms:{uniformTypes:{gravity:"f32",spaceSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new ci(e,{fs:$B,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceGravityUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceGravityUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,points:t,store:n}=this;if(!t||!this.runCommand||!this.uniformStore||!t.previousPositionTexture||t.previousPositionTexture.destroyed||!t.velocityFbo||t.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceGravityUniforms:{gravity:this.config.simulationGravity??0,spaceSize:n.adjustedSpaceSize??0,alpha:n.alpha}}),this.runCommand.setBindings({positionsTexture:t.previousPositionTexture});const s=e.beginRenderPass({framebuffer:t.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}function HB(i){return`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;
uniform sampler2D linkInfoTexture; // Texture storing first link indices and amount
uniform sampler2D linkIndicesTexture;
uniform sampler2D linkPropertiesTexture; // Texture storing link bias and strength
uniform sampler2D linkRandomDistanceTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceLinkUniforms {
  float linkSpring;
  float linkDistance;
  vec2 linkDistRandomVariationRange;
  float pointsTextureSize;
  float linksTextureSize;
  float alpha;
} forceLink;

#define linkSpring forceLink.linkSpring
#define linkDistance forceLink.linkDistance
#define linkDistRandomVariationRange forceLink.linkDistRandomVariationRange
#define pointsTextureSize forceLink.pointsTextureSize
#define linksTextureSize forceLink.linksTextureSize
#define alpha forceLink.alpha
#else
uniform float linkSpring;
uniform float linkDistance;
uniform vec2 linkDistRandomVariationRange;
uniform float pointsTextureSize;
uniform float linksTextureSize;
uniform float alpha;
#endif

in vec2 textureCoords;
out vec4 fragColor;

const float MAX_LINKS = ${i}.0;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 velocity = vec4(0.0);

  vec4 linkInfo = texture(linkInfoTexture, textureCoords);
  float iCount = linkInfo.r;
  float jCount = linkInfo.g;
  float linkAmount = linkInfo.b;
  if (linkAmount > 0.0) {
    for (float i = 0.0; i < MAX_LINKS; i += 1.0) {
      if (i < linkAmount) {
        if (iCount >= linksTextureSize) {
          iCount = 0.0;
          jCount += 1.0;
        }
        vec2 linkTextureIndex = (vec2(iCount, jCount) + 0.5) / linksTextureSize;
        vec4 connectedPointIndex = texture(linkIndicesTexture, linkTextureIndex);
        vec4 biasAndStrength = texture(linkPropertiesTexture, linkTextureIndex);
        vec4 randomMinDistance = texture(linkRandomDistanceTexture, linkTextureIndex);
        float bias = biasAndStrength.r;
        float strength = biasAndStrength.g;
        float randomMinLinkDist = randomMinDistance.r * (linkDistRandomVariationRange.g - linkDistRandomVariationRange.r) + linkDistRandomVariationRange.r;
        randomMinLinkDist *= linkDistance;

        iCount += 1.0;

        vec4 connectedPointPosition = texture(positionsTexture, (connectedPointIndex.rg + 0.5) / pointsTextureSize);
        float x = connectedPointPosition.x - (pointPosition.x + velocity.x);
        float y = connectedPointPosition.y - (pointPosition.y + velocity.y);
        float l = sqrt(x * x + y * y);

        // Apply the link force
        l = max(l, randomMinLinkDist * 0.99);
        l = (l - randomMinLinkDist) / l;
        l *= linkSpring * alpha;
        l *= strength;
        l *= bias;
        x *= l;
        y *= l;
        velocity.x += x;
        velocity.y += y;
      }
    }
  }

  fragColor = vec4(velocity.rg, 0.0, 0.0);
}
  `}function _t(i,e){return!i||i.length!==2?e:[i[0],i[1]]}function Mi(i,e){return!i||i.length!==4?e:[i[0],i[1],i[2],i[3]]}var Og=(i=>(i.OUTGOING="outgoing",i.INCOMING="incoming",i))(Og||{});class Ix extends Zo{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){var t;const{device:n,store:{pointsTextureSize:s,linksTextureSize:r},data:o}=this;if(!s||!r)return;this.linkFirstIndicesAndAmount=new Float32Array(s*s*4),this.indices=new Float32Array(r*r*4);const a=new Float32Array(r*r*4),l=new Float32Array(r*r*4),c=e==="incoming"?o.sourceIndexToTargetIndices:o.targetIndexToSourceIndices;this.maxPointDegree=0;let u=0;c==null||c.forEach((p,m)=>{p&&(this.linkFirstIndicesAndAmount[m*4+0]=u%r,this.linkFirstIndicesAndAmount[m*4+1]=Math.floor(u/r),this.linkFirstIndicesAndAmount[m*4+2]=p.length??0,p.forEach(([y,g])=>{var _,S,E;this.indices[u*4+0]=y%s,this.indices[u*4+1]=Math.floor(y/s);const x=((_=o.degree)==null?void 0:_[y])??0,T=((S=o.degree)==null?void 0:S[m])??0,I=x+T,O=I!==0?x/I:.5,H=Math.min(x,T);let Q=((E=o.linkStrength)==null?void 0:E[g])??1/Math.max(H,1);Q=Math.sqrt(Q),a[u*4+0]=O,a[u*4+1]=Q,l[u*4]=this.store.getRandomFloat(0,1),u+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,p.length??0))});const d=!this.linkFirstIndicesAndAmountTexture||this.linkFirstIndicesAndAmountTexture.width!==s||this.linkFirstIndicesAndAmountTexture.height!==s,h=!this.indicesTexture||this.indicesTexture.width!==r||this.indicesTexture.height!==r;d&&(this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=n.createTexture({width:s,height:s,format:"rgba32float",usage:lt.SAMPLE|lt.COPY_DST})),this.linkFirstIndicesAndAmountTexture.copyImageData({data:this.linkFirstIndicesAndAmount,bytesPerRow:at("rgba32float",s),mipLevel:0,x:0,y:0}),h&&(this.indicesTexture&&!this.indicesTexture.destroyed&&this.indicesTexture.destroy(),this.biasAndStrengthTexture&&!this.biasAndStrengthTexture.destroyed&&this.biasAndStrengthTexture.destroy(),this.randomDistanceTexture&&!this.randomDistanceTexture.destroyed&&this.randomDistanceTexture.destroy(),this.indicesTexture=n.createTexture({width:r,height:r,format:"rgba32float",usage:lt.SAMPLE|lt.COPY_DST}),this.biasAndStrengthTexture=n.createTexture({width:r,height:r,format:"rgba32float",usage:lt.SAMPLE|lt.COPY_DST}),this.randomDistanceTexture=n.createTexture({width:r,height:r,format:"rgba32float",usage:lt.SAMPLE|lt.COPY_DST})),this.indicesTexture.copyImageData({data:this.indices,bytesPerRow:at("rgba32float",r),mipLevel:0,x:0,y:0}),this.biasAndStrengthTexture.copyImageData({data:a,bytesPerRow:at("rgba32float",r),mipLevel:0,x:0,y:0}),this.randomDistanceTexture.copyImageData({data:l,bytesPerRow:at("rgba32float",r),mipLevel:0,x:0,y:0}),this.previousMaxPointDegree!==void 0&&this.previousMaxPointDegree!==this.maxPointDegree&&((t=this.runCommand)==null||t.destroy(),this.runCommand=void 0),this.previousMaxPointDegree=this.maxPointDegree,this.previousPointsTextureSize=s,this.previousLinksTextureSize=r}initPrograms(){const{device:e,store:t,points:n}=this;!n||!t.pointsTextureSize||!t.linksTextureSize||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ai({forceLinkUniforms:{uniformTypes:{linkSpring:"f32",linkDistance:"f32",linkDistRandomVariationRange:"vec2<f32>",pointsTextureSize:"f32",linksTextureSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new ci(e,{fs:HB(this.maxPointDegree),vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceLinkUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceLinkUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,store:t,points:n}=this;if(!n||!this.runCommand||!this.uniformStore||!n.previousPositionTexture||n.previousPositionTexture.destroyed||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||!n.velocityFbo||n.velocityFbo.destroyed||t.pointsTextureSize!==this.previousPointsTextureSize||t.linksTextureSize!==this.previousLinksTextureSize)return;this.uniformStore.setUniforms({forceLinkUniforms:{linkSpring:this.config.simulationLinkSpring??0,linkDistance:this.config.simulationLinkDistance??0,linkDistRandomVariationRange:_t(this.config.simulationLinkDistRandomVariationRange,[0,0]),pointsTextureSize:t.pointsTextureSize,linksTextureSize:t.linksTextureSize,alpha:t.alpha}}),this.runCommand.setBindings({positionsTexture:n.previousPositionTexture,linkInfoTexture:this.linkFirstIndicesAndAmountTexture,linkIndicesTexture:this.indicesTexture,linkPropertiesTexture:this.biasAndStrengthTexture,linkRandomDistanceTexture:this.randomDistanceTexture});const s=e.beginRenderPass({framebuffer:n.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=void 0,this.indicesTexture&&!this.indicesTexture.destroyed&&this.indicesTexture.destroy(),this.indicesTexture=void 0,this.biasAndStrengthTexture&&!this.biasAndStrengthTexture.destroyed&&this.biasAndStrengthTexture.destroy(),this.biasAndStrengthTexture=void 0,this.randomDistanceTexture&&!this.randomDistanceTexture.destroyed&&this.randomDistanceTexture.destroy(),this.randomDistanceTexture=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const VB=`#version 300 es
precision highp float;

in vec4 vColor;
out vec4 fragColor;

void main() {
  fragColor = vColor;
}`,GB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform calculateLevelsUniforms {
  float pointsTextureSize;
  float levelTextureSize;
  float cellSize;
} calculateLevels;

#define pointsTextureSize calculateLevels.pointsTextureSize
#define levelTextureSize calculateLevels.levelTextureSize
#define cellSize calculateLevels.cellSize
#else
uniform float pointsTextureSize;
uniform float levelTextureSize;
uniform float cellSize;
#endif

in vec2 pointIndices;

out vec4 vColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize);
  vColor = vec4(pointPosition.rg, 1.0, 0.0);

  float n = floor(pointPosition.x / cellSize);
  float m = floor(pointPosition.y / cellSize);
  
  vec2 levelPosition = 2.0 * (vec2(n, m) + 0.5) / levelTextureSize - 1.0;

  gl_Position = vec4(levelPosition, 0.0, 1.0);
  gl_PointSize = 1.0;
}`,WB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;
uniform sampler2D levelFbo;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceUniforms {
  float level;
  float levels;
  float levelTextureSize;
  float repulsion;
  float alpha;
  float spaceSize;
  float theta;
} force;

#define level force.level
#define levels force.levels
#define levelTextureSize force.levelTextureSize
#define repulsion force.repulsion
#define alpha force.alpha
#define spaceSize force.spaceSize
#define theta force.theta
#else
uniform float level;
uniform float levels;
uniform float levelTextureSize;
uniform float repulsion;
uniform float alpha;
uniform float spaceSize;
uniform float theta;
#endif

in vec2 textureCoords;
out vec4 fragColor;

const float MAX_LEVELS_NUM = 14.0;

vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) {
  vec2 add = vec2(0.0);
  vec4 centermass = texture(levelFbo, ij);
  if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {
    vec2 centermassPosition = vec2(centermass.rg / centermass.b);
    vec2 distVector = pp - centermassPosition;
    float l = dot(distVector, distVector);
    float dist = sqrt(l);
    if (l > 0.0) {
      float c = alpha * repulsion * centermass.b;

      float distanceMin2 = 1.0;
      if (l < distanceMin2) l = sqrt(distanceMin2 * l);
      float addV = c / sqrt(l);
      add = addV * normalize(distVector);
    }
  }
  return add;
}

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  float x = pointPosition.x;
  float y = pointPosition.y;

  float left = 0.0;
  float top = 0.0;
  float right = spaceSize;
  float bottom = spaceSize;

  float n_left = 0.0;
  float n_top = 0.0;
  float n_right = 0.0;
  float n_bottom = 0.0;

  float cellSize = 0.0;

  // Iterate over levels to adjust the boundaries based on the current level
  for (float i = 0.0; i < MAX_LEVELS_NUM; i += 1.0) {
    if (i <= level) {
      left += cellSize * n_left;
      top += cellSize * n_top;
      right -= cellSize * n_right;
      bottom -= cellSize * n_bottom;

      cellSize = pow(2.0 , levels - i - 1.0);

      float dist_left = x - left;
      n_left = max(0.0, floor(dist_left / cellSize - theta));

      float dist_top = y - top;
      n_top = max(0.0, floor(dist_top / cellSize - theta));
      
      float dist_right = right - x;
      n_right = max(0.0, floor(dist_right / cellSize - theta));

      float dist_bottom = bottom - y;
      n_bottom = max(0.0, floor(dist_bottom / cellSize - theta));

    }
  }

  vec4 velocity = vec4(vec2(0.0), 1.0, 0.0);

  // Calculate the additional velocity based on neighboring cells
  for (float i = 0.0; i < 12.0; i += 1.0) {
    for (float j = 0.0; j < 4.0; j += 1.0) {
      float n = left + cellSize * j;
      float m = top + cellSize * n_top + cellSize * i;

      if (n < (left + n_left * cellSize) && m < bottom) {
        velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
      }

      n = left + cellSize * i;
      m = top + cellSize * j;

      if (n < (right - n_right * cellSize) && m < (top + n_top * cellSize)) {
        velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
      }

      n = right - n_right * cellSize + cellSize * j;
      m = top + cellSize * i;

      if (n < right && m < (bottom - n_bottom * cellSize)) {
        velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
      }

      n = left + n_left * cellSize + cellSize * i;
      m = bottom - n_bottom * cellSize + cellSize * j;

      if (n < right && m < bottom) {
        velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
      }
    }
  }

  fragColor = velocity;
}`,YB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;
uniform sampler2D levelFbo;
uniform sampler2D randomValues;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceCenterUniforms {
  float levelTextureSize;
  float repulsion;
  float alpha;
} forceCenter;

#define levelTextureSize forceCenter.levelTextureSize
#define repulsion forceCenter.repulsion
#define alpha forceCenter.alpha
#else
uniform float levelTextureSize;
uniform float repulsion;
uniform float alpha;
#endif

in vec2 textureCoords;
out vec4 fragColor;

// Calculate the additional velocity based on the center of mass
vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) {
  vec2 add = vec2(0.0);
  vec4 centermass = texture(levelFbo, ij);
  if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {
    vec2 centermassPosition = vec2(centermass.rg / centermass.b);
    vec2 distVector = pp - centermassPosition;
    float l = dot(distVector, distVector);
    float dist = sqrt(l);
    if (l > 0.0) {
      float angle = atan(distVector.y, distVector.x);
      float c = alpha * repulsion * centermass.b;

      float distanceMin2 = 1.0;
      if (l < distanceMin2) l = sqrt(distanceMin2 * l);
      float addV = c / sqrt(l);
      add = addV * vec2(cos(angle), sin(angle));
    }
  }
  return add;
}

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 random = texture(randomValues, textureCoords);

  vec4 velocity = vec4(0.0);

  // Calculate additional velocity based on the point position
  velocity.xy += calculateAdditionalVelocity(pointPosition.xy / levelTextureSize, pointPosition.xy);
  // Apply random factor to the velocity
  velocity.xy += velocity.xy * random.rg;

  fragColor = velocity;
}`;class qB extends Zo{constructor(){super(...arguments),this.levels=0,this.levelTargets=new Map}create(){var e;const{device:t,store:n}=this;if(!n.pointsTextureSize)return;this.levels=Math.log2(n.adjustedSpaceSize);for(let o=0;o<this.levels;o+=1){const a=Math.pow(2,o+1),l=this.levelTargets.get(o);if(l&&l.texture.width===a&&l.texture.height===a){l.texture.copyImageData({data:new Float32Array(a*a*4).fill(0),bytesPerRow:at("rgba32float",a),mipLevel:0,x:0,y:0});continue}l&&(l.fbo.destroyed||l.fbo.destroy(),l.texture.destroyed||l.texture.destroy());const c=t.createTexture({width:a,height:a,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST});c.copyImageData({data:new Float32Array(a*a*4).fill(0),bytesPerRow:at("rgba32float",a),mipLevel:0,x:0,y:0});const u=t.createFramebuffer({width:a,height:a,colorAttachments:[c]});this.levelTargets.set(o,{texture:c,fbo:u})}for(const[o,a]of Array.from(this.levelTargets.entries()))o>=this.levels&&(a.fbo.destroyed||a.fbo.destroy(),a.texture.destroyed||a.texture.destroy(),this.levelTargets.delete(o));const s=n.pointsTextureSize*n.pointsTextureSize,r=new Float32Array(s*4);for(let o=0;o<s;++o)r[o*4]=n.getRandomFloat(-1,1)*1e-5,r[o*4+1]=n.getRandomFloat(-1,1)*1e-5;if((!this.randomValuesTexture||this.randomValuesTexture.destroyed||this.randomValuesTexture.width!==n.pointsTextureSize||this.randomValuesTexture.height!==n.pointsTextureSize)&&(this.randomValuesTexture&&!this.randomValuesTexture.destroyed&&this.randomValuesTexture.destroy(),this.randomValuesTexture=t.createTexture({width:n.pointsTextureSize,height:n.pointsTextureSize,format:"rgba32float",usage:lt.SAMPLE|lt.COPY_DST})),this.randomValuesTexture.copyImageData({data:r,bytesPerRow:at("rgba32float",n.pointsTextureSize),mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==n.pointsTextureSize){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const o=dp(n.pointsTextureSize);this.pointIndices=t.createBuffer({data:o,usage:me.VERTEX|me.COPY_DST}),(e=this.calculateLevelsCommand)==null||e.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=n.pointsTextureSize,this.previousSpaceSize=n.adjustedSpaceSize}initPrograms(){const{device:e,store:t,data:n,points:s}=this;!n.pointsNumber||!s||!t.pointsTextureSize||(this.calculateLevelsUniformStore||(this.calculateLevelsUniformStore=new ai({calculateLevelsUniforms:{uniformTypes:{pointsTextureSize:"f32",levelTextureSize:"f32",cellSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,levelTextureSize:0,cellSize:0}}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=new ci(e,{fs:VB,vs:GB,topology:"point-list",vertexCount:n.pointsNumber,attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateLevelsUniforms:this.calculateLevelsUniformStore.getManagedUniformBuffer(e,"calculateLevelsUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceUniformStore||(this.forceUniformStore=new ai({forceUniforms:{uniformTypes:{level:"f32",levels:"f32",levelTextureSize:"f32",alpha:"f32",repulsion:"f32",spaceSize:"f32",theta:"f32"},defaultUniforms:{level:0,levels:this.levels,levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:t.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceCommand||(this.forceCommand=new ci(e,{fs:WB,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceUniforms:this.forceUniformStore.getManagedUniformBuffer(e,"forceUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceCenterUniformStore||(this.forceCenterUniformStore=new ai({forceCenterUniforms:{uniformTypes:{levelTextureSize:"f32",alpha:"f32",repulsion:"f32"},defaultUniforms:{levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0}}})),this.forceFromItsOwnCentermassCommand||(this.forceFromItsOwnCentermassCommand=new ci(e,{fs:YB,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCenterUniforms:this.forceCenterUniformStore.getManagedUniformBuffer(e,"forceCenterUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})))}run(){this.store.pointsTextureSize!==this.previousPointsTextureSize||this.store.adjustedSpaceSize!==this.previousSpaceSize||(this.drawLevels(),this.drawForces())}destroy(){var e,t,n,s,r,o;(e=this.calculateLevelsCommand)==null||e.destroy(),this.calculateLevelsCommand=void 0,(t=this.forceCommand)==null||t.destroy(),this.forceCommand=void 0,(n=this.forceFromItsOwnCentermassCommand)==null||n.destroy(),this.forceFromItsOwnCentermassCommand=void 0;for(const a of this.levelTargets.values())a.fbo&&!a.fbo.destroyed&&a.fbo.destroy();this.randomValuesTexture&&!this.randomValuesTexture.destroyed&&this.randomValuesTexture.destroy(),this.randomValuesTexture=void 0;for(const a of this.levelTargets.values())a.texture&&!a.texture.destroyed&&a.texture.destroy();this.levelTargets.clear(),(s=this.calculateLevelsUniformStore)==null||s.destroy(),this.calculateLevelsUniformStore=void 0,(r=this.forceUniformStore)==null||r.destroy(),this.forceUniformStore=void 0,(o=this.forceCenterUniformStore)==null||o.destroy(),this.forceCenterUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0}drawLevels(){const{device:e,store:t,data:n,points:s}=this;if(s&&!(!this.calculateLevelsCommand||!this.calculateLevelsUniformStore)&&!(!s.previousPositionTexture||s.previousPositionTexture.destroyed)&&n.pointsNumber&&this.pointIndices)for(let r=0;r<this.levels;r+=1){const o=this.levelTargets.get(r);if(!o||o.fbo.destroyed||o.texture.destroyed)continue;const a=Math.pow(2,r+1),l=(t.adjustedSpaceSize??0)/a;this.calculateLevelsUniformStore.setUniforms({calculateLevelsUniforms:{pointsTextureSize:t.pointsTextureSize??0,levelTextureSize:a,cellSize:l}}),this.calculateLevelsCommand.setVertexCount(n.pointsNumber),this.calculateLevelsCommand.setBindings({positionsTexture:s.previousPositionTexture});const c=e.beginRenderPass({framebuffer:o.fbo,clearColor:[0,0,0,0]});this.calculateLevelsCommand.draw(c),c.end()}}drawForces(){const{device:e,store:t,points:n}=this;if(!n||!this.forceCommand||!this.forceUniformStore||!this.forceFromItsOwnCentermassCommand||!this.forceCenterUniformStore||!n.previousPositionTexture||n.previousPositionTexture.destroyed||!this.randomValuesTexture||this.randomValuesTexture.destroyed||!n.velocityFbo||n.velocityFbo.destroyed)return;const s=e.beginRenderPass({framebuffer:n.velocityFbo,clearColor:[0,0,0,0]});for(let r=0;r<this.levels;r+=1){const o=this.levelTargets.get(r);if(!o||o.texture.destroyed)continue;const a=Math.pow(2,r+1);this.forceUniformStore.setUniforms({forceUniforms:{level:r,levels:this.levels,levelTextureSize:a,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:t.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}),this.forceCommand.setBindings({positionsTexture:n.previousPositionTexture,levelFbo:o.texture}),this.forceCommand.draw(s),r===this.levels-1&&(this.forceCenterUniformStore.setUniforms({forceCenterUniforms:{levelTextureSize:a,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0}}),this.forceFromItsOwnCentermassCommand.setBindings({positionsTexture:n.previousPositionTexture,randomValues:this.randomValuesTexture,levelFbo:o.texture}),this.forceFromItsOwnCentermassCommand.draw(s))}s.end()}}const XB=`#version 300 es
precision highp float;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform forceMouseUniforms {
  float repulsion;
  vec2 mousePos;
} forceMouse;

#define repulsion forceMouse.repulsion
#define mousePos forceMouse.mousePos
#else
uniform float repulsion;
uniform vec2 mousePos;
#endif

in vec2 textureCoords;
out vec4 fragColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 velocity = vec4(0.0);
  vec2 mouse = mousePos;
  // Move particles away from the mouse position using a repulsive force
  vec2 distVector = mouse - pointPosition.rg;
  float dist = sqrt(dot(distVector, distVector));
  dist = max(dist, 10.0);
  float angle = atan(distVector.y, distVector.x);
  float addV = 100.0 * repulsion / (dist * dist);
  velocity.rg -= addV * vec2(cos(angle), sin(angle));

  fragColor = velocity;
}`;class KB extends Zo{initPrograms(){const{device:e,points:t}=this;t&&(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ai({forceMouseUniforms:{uniformTypes:{repulsion:"f32",mousePos:"vec2<f32>"}}})),this.runCommand||(this.runCommand=new ci(e,{fs:XB,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceMouseUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceMouseUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,points:t,store:n}=this;if(!t||!this.runCommand||!this.uniformStore||!t.previousPositionTexture||t.previousPositionTexture.destroyed||!t.velocityFbo||t.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceMouseUniforms:{repulsion:this.config.simulationRepulsionFromMouse??0,mousePos:_t(n.mousePosition,[0,0])}}),this.runCommand.setBindings({positionsTexture:t.previousPositionTexture});const s=e.beginRenderPass({framebuffer:t.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const ZB=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec4 rgba;

out vec4 fragColor;

void main() {
  fragColor = rgba;
}`,QB=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D clusterTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform calculateCentermassUniforms {
  float pointsTextureSize;
  float clustersTextureSize;
} calculateCentermass;

#define pointsTextureSize calculateCentermass.pointsTextureSize
#define clustersTextureSize calculateCentermass.clustersTextureSize
#else
uniform float pointsTextureSize;
uniform float clustersTextureSize;
#endif

in vec2 pointIndices;

out vec4 rgba;

void main() {
  vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize);
  rgba = vec4(pointPosition.xy, 1.0, 0.0);

  vec4 pointClusterIndices = texture(clusterTexture, pointIndices / pointsTextureSize);
  vec2 xy = vec2(0.0);
  if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) {
    xy = 2.0 * (pointClusterIndices.xy + 0.5) / clustersTextureSize - 1.0;
  }
  
  gl_Position = vec4(xy, 0.0, 1.0);
  gl_PointSize = 1.0;
}
`,JB=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D centermassTexture;
uniform sampler2D clusterTexture;
uniform sampler2D clusterPositionsTexture;
uniform sampler2D clusterForceCoefficient;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform applyForcesUniforms {
  float alpha;
  float clustersTextureSize;
  float clusterCoefficient;
} applyForces;

#define alpha applyForces.alpha
#define clustersTextureSize applyForces.clustersTextureSize
#define clusterCoefficient applyForces.clusterCoefficient
#else
uniform float alpha;
uniform float clustersTextureSize;
uniform float clusterCoefficient;
#endif

in vec2 textureCoords;

out vec4 fragColor;


void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 velocity = vec4(0.0);
  vec4 pointClusterIndices = texture(clusterTexture, textureCoords);
  // no cluster, so no forces
  if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) {
    // positioning points to custom cluster position or either to the center of mass
    vec2 clusterPositions = texture(clusterPositionsTexture, pointClusterIndices.xy / clustersTextureSize).xy;
    if (clusterPositions.x < 0.0 || clusterPositions.y < 0.0) {
      vec4 centermassValues = texture(centermassTexture, pointClusterIndices.xy / clustersTextureSize);
      clusterPositions = centermassValues.xy / centermassValues.b;
    }
    vec4 clusterCustomCoeff = texture(clusterForceCoefficient, textureCoords);
    vec2 distVector = clusterPositions.xy - pointPosition.xy;
    float dist = length(distVector);
    if (dist > 0.0) {
      float addV = alpha * dist * clusterCoefficient * clusterCustomCoeff.r;
      velocity.rg += addV * normalize(distVector);
    }
  }

  fragColor = velocity;
}`;class eO extends Zo{create(){var e,t;const{device:n,store:s,data:r}=this,{pointsTextureSize:o}=s;if(r.pointsNumber===void 0||!r.pointClusters&&!r.clusterPositions)return;this.clusterCount=(r.pointClusters??[]).reduce((p,m)=>m===void 0||m<0?p:Math.max(p,m),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const a=this.previousPointsTextureSize!==o||this.previousClustersTextureSize!==this.clustersTextureSize||this.previousClusterCount!==this.clusterCount,l=o*o*4,c=this.clustersTextureSize*this.clustersTextureSize*4,u=new Float32Array(l),d=new Float32Array(c).fill(-1),h=new Float32Array(l).fill(1);if(r.clusterPositions)for(let p=0;p<this.clusterCount;++p)d[p*4+0]=r.clusterPositions[p*2+0]??-1,d[p*4+1]=r.clusterPositions[p*2+1]??-1;for(let p=0;p<r.pointsNumber;++p){const m=(e=r.pointClusters)==null?void 0:e[p];m===void 0?(u[p*4+0]=-1,u[p*4+1]=-1):(u[p*4+0]=m%this.clustersTextureSize,u[p*4+1]=Math.floor(m/this.clustersTextureSize)),r.clusterStrength&&(h[p*4+0]=r.clusterStrength[p]??1)}if(!this.clusterTexture||a?(this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=n.createTexture({width:o,height:o,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST}),this.clusterTexture.copyImageData({data:u,bytesPerRow:at("rgba32float",o),mipLevel:0,x:0,y:0})):this.clusterTexture.copyImageData({data:u,bytesPerRow:at("rgba32float",o),mipLevel:0,x:0,y:0}),!this.clusterPositionsTexture||a?(this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=n.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST}),this.clusterPositionsTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0})):this.clusterPositionsTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),!this.clusterForceCoefficientTexture||a?(this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=n.createTexture({width:o,height:o,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST}),this.clusterForceCoefficientTexture.copyImageData({data:h,bytesPerRow:at("rgba32float",o),mipLevel:0,x:0,y:0})):this.clusterForceCoefficientTexture.copyImageData({data:h,bytesPerRow:at("rgba32float",o),mipLevel:0,x:0,y:0}),!this.centermassTexture||this.previousClustersTextureSize!==this.clustersTextureSize?(this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=n.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST}),this.centermassTexture.copyImageData({data:new Float32Array(c).fill(0),bytesPerRow:at("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),this.centermassFbo=n.createFramebuffer({width:this.clustersTextureSize,height:this.clustersTextureSize,colorAttachments:[this.centermassTexture]})):this.centermassTexture.copyImageData({data:new Float32Array(c).fill(0),bytesPerRow:at("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==o){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const p=dp(s.pointsTextureSize);this.pointIndices=n.createBuffer({data:p,usage:me.VERTEX|me.COPY_DST}),(t=this.calculateCentermassCommand)==null||t.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=o,this.previousClustersTextureSize=this.clustersTextureSize,this.previousClusterCount=this.clusterCount}initPrograms(){const{device:e,store:t,data:n}=this;n.pointsNumber===void 0||!n.pointClusters&&!n.clusterPositions||(this.calculateCentermassUniformStore||(this.calculateCentermassUniformStore=new ai({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32",clustersTextureSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new ci(e,{fs:ZB,vs:QB,topology:"point-list",vertexCount:n.pointsNumber??0,attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.applyForcesUniformStore||(this.applyForcesUniformStore=new ai({applyForcesUniforms:{uniformTypes:{alpha:"f32",clustersTextureSize:"f32",clusterCoefficient:"f32"},defaultUniforms:{alpha:t.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}})),this.applyForcesVertexCoordBuffer||(this.applyForcesVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.applyForcesCommand||(this.applyForcesCommand=new ci(e,{fs:JB,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.applyForcesVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{applyForcesUniforms:this.applyForcesUniformStore.getManagedUniformBuffer(e,"applyForcesUniforms")}})))}calculateCentermass(){const{device:e,points:t}=this;if(!t||!this.calculateCentermassCommand||!this.calculateCentermassUniformStore||!this.pointIndices||!this.centermassFbo||this.centermassFbo.destroyed||!this.clusterTexture||this.clusterTexture.destroyed||!t.previousPositionTexture||t.previousPositionTexture.destroyed)return;this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.calculateCentermassUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:this.store.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}),this.calculateCentermassCommand.setBindings({clusterTexture:this.clusterTexture,positionsTexture:t.previousPositionTexture});const n=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateCentermassCommand.draw(n),n.end()}run(){var e;if(!this.data.pointClusters&&!this.data.clusterPositions||(this.calculateCentermass(),!this.applyForcesCommand||!this.applyForcesUniformStore)||!this.clusterTexture||this.clusterTexture.destroyed||!this.centermassTexture||this.centermassTexture.destroyed||!this.clusterPositionsTexture||this.clusterPositionsTexture.destroyed||!this.clusterForceCoefficientTexture||this.clusterForceCoefficientTexture.destroyed||!((e=this.points)!=null&&e.previousPositionTexture)||this.points.previousPositionTexture.destroyed||!this.points.velocityFbo||this.points.velocityFbo.destroyed)return;this.applyForcesUniformStore.setUniforms({applyForcesUniforms:{alpha:this.store.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}),this.applyForcesCommand.setBindings({clusterTexture:this.clusterTexture,centermassTexture:this.centermassTexture,clusterPositionsTexture:this.clusterPositionsTexture,clusterForceCoefficient:this.clusterForceCoefficientTexture,positionsTexture:this.points.previousPositionTexture});const t=this.device.beginRenderPass({framebuffer:this.points.velocityFbo,clearColor:[0,0,0,0]});this.applyForcesCommand.draw(t),t.end()}destroy(){var e,t,n,s;(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(t=this.applyForcesCommand)==null||t.destroy(),this.applyForcesCommand=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=void 0,this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=void 0,this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=void 0,this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=void 0,(n=this.calculateCentermassUniformStore)==null||n.destroy(),this.calculateCentermassUniformStore=void 0,(s=this.applyForcesUniformStore)==null||s.destroy(),this.applyForcesUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.applyForcesVertexCoordBuffer&&!this.applyForcesVertexCoordBuffer.destroyed&&this.applyForcesVertexCoordBuffer.destroy(),this.applyForcesVertexCoordBuffer=void 0}}function kE(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function tO(i){if(Object.prototype.hasOwnProperty.call(i,"__esModule"))return i;var e=i.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var s=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return i[n]}})}),t}var Fg={exports:{}},iO=Fg.exports,Lx;function nO(){return Lx||(Lx=1,(function(i,e){(function(t,n){i.exports=n()})(iO,function(){var t=`<div class="gl-box">
  <svg viewBox="0 0 55 60">
    <text x="27" y="56" class="gl-fps">00 FPS</text>
    <text x="28" y="8" class="gl-mem"></text>
    <rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect>
    <polyline class="gl-chart"></polyline>
  </svg>
  <svg viewBox="0 0 14 60" class="gl-cpu-svg">
    <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
    <line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/>
    <path d="M5.35 43c-.464 0-.812.377-.812.812v1.16c-.783.1972-1.421.812-1.595 1.624h-1.16c-.435 0-.812.348-.812.812s.348.812.812.812h1.102v1.653H1.812c-.464 0-.812.377-.812.812 0 .464.377.812.812.812h1.131c.1943.783.812 1.392 1.595 1.595v1.131c0 .464.377.812.812.812.464 0 .812-.377.812-.812V53.15h1.653v1.073c0 .464.377.812.812.812.464 0 .812-.377.812-.812v-1.131c.783-.1943 1.392-.812 1.595-1.595h1.131c.464 0 .812-.377.812-.812 0-.464-.377-.812-.812-.812h-1.073V48.22h1.102c.435 0 .812-.348.812-.812s-.348-.812-.812-.812h-1.16c-.1885-.783-.812-1.421-1.595-1.624v-1.131c0-.464-.377-.812-.812-.812-.464 0-.812.377-.812.812v1.073H6.162v-1.073c0-.464-.377-.812-.812-.812zm.58 3.48h2.088c.754 0 1.363.609 1.363 1.363v2.088c0 .754-.609 1.363-1.363 1.363H5.93c-.754 0-1.363-.609-1.363-1.363v-2.088c0-.754.609-1.363 1.363-1.363z"/>
  </svg>
  <svg viewBox="0 0 14 60" class="gl-gpu-svg">
    <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
    <line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>
    <path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z"/>
  </svg>
</div>`,n=`#gl-bench {
  position:absolute;
  left:0;
  top:0;
  z-index:1000;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

#gl-bench div {
  position: relative;
  display: block;
  margin: 4px;
  padding: 0 7px 0 10px;
  background: #6c6;
  border-radius: 15px;
  cursor: pointer;
  opacity: 0.9;
}

#gl-bench svg {
  height: 60px;
  margin: 0 -1px;
}

#gl-bench text {
  font-size: 12px;
  font-family: Helvetica,Arial,sans-serif;
  font-weight: 700;
  dominant-baseline: middle;
  text-anchor: middle;
}

#gl-bench .gl-mem {
  font-size: 9px;
}

#gl-bench line {
  stroke-width: 5;
  stroke: #112211;
  stroke-linecap: round;
}

#gl-bench polyline {
  fill: none;
  stroke: #112211;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.5;
}

#gl-bench rect {
  fill: #448844;
}

#gl-bench .opacity {
  stroke: #448844;
}
`;class s{constructor(o,a={}){this.css=n,this.svg=t,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],h=>{h.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,a),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let l,c=0,u,d=h=>{++c<20?l=requestAnimationFrame(d):(this.detected=Math.ceil(1e3*c/(h-u)/70),cancelAnimationFrame(l)),u||(u=h)};if(requestAnimationFrame(d),o){const h=async(m,y)=>Promise.resolve(setTimeout(()=>{o.getError();const g=this.now()-m;y.forEach((_,S)=>{_&&(this.gpuAccums[S]+=g)})},0)),p=(m,y,g)=>function(){const _=y.now();m.apply(g,arguments),y.trackGPU&&y.finished.push(h(_,y.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(m=>{o[m]&&(o[m]=p(o[m],this,o))}),o.getExtension=((m,y)=>function(){let g=m.apply(o,arguments);return g&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(_=>{g[_]&&(g[_]=p(g[_],y,g))}),g})(o.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let h=document.createElement("div");h.id="gl-bench",this.dom.appendChild(h),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=h,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((p,m,y)=>{const g=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],_=Object.assign({},g);return g.forEach(S=>_[S]=m.getElementsByClassName(S)),this.nodes=_,(S,E,x,T,I,O,H)=>{_["gl-cpu"][S].style.strokeDasharray=(E*.27).toFixed(0)+" 100",_["gl-gpu"][S].style.strokeDasharray=(x*.27).toFixed(0)+" 100",_["gl-mem"][S].innerHTML=y[S]?y[S]:T?"mem: "+T.toFixed(0)+"mb":"",_["gl-fps"][S].innerHTML=I.toFixed(0)+" FPS",p(y[S],E,x,T,I,O,H)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((p,m)=>{let y={"gl-chart":m.getElementsByClassName("gl-chart")};return(g,_,S)=>{let E="",x=_.length;for(let T=0;T<x;T++){let I=(S+T+1)%x;_[I]!=null&&(E=E+" "+(55*T/(x-1)).toFixed(1)+","+(45-_[I]*22/60/this.detected).toFixed(1))}y["gl-chart"][g].setAttribute("points",E),p(this.names[g],_,S)}})(this.chartLogger,this.dom)}}addUI(o){this.names.indexOf(o)==-1&&(this.names.push(o),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(o){this.frameId++;const a=o||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=a;else{let l=a-this.paramTime;if(l>=1e3){const c=this.frameId-this.paramFrame,u=c/l*1e3;for(let d=0;d<this.names.length;d++){const h=this.cpuAccums[d]/l*100,p=this.gpuAccums[d]/l*100,m=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(d,h,p,m,u,l,c),this.cpuAccums[d]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[d]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=a}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=a,this.circularId=0;else{let l=a-this.chartTime,c=this.chartHz*l/1e3;for(;--c>0&&this.detected;){const u=(this.frameId-this.chartFrame)/l*1e3;this.chart[this.circularId%this.chartLen]=u;for(let d=0;d<this.names.length;d++)this.chartLogger(d,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=a}}}begin(o){this.updateAccums(o)}end(o){this.updateAccums(o)}updateAccums(o){let a=this.names.indexOf(o);a==-1&&(a=this.names.length,this.addUI(o));const l=this.now(),c=l-this.t0;for(let u=0;u<a+1;u++)this.activeAccums[u]&&(this.cpuAccums[u]+=c);this.activeAccums[a]=!this.activeAccums[a],this.t0=l}}return s})})(Fg)),Fg.exports}var sO=nO();const rO=kE(sO),oO=`
  #gl-bench {
    position:absolute;
    right:0;
    top:0;
    z-index:1000;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
  }
  #gl-bench div {
    position: relative;
    display: block;
    margin: 4px;
    padding: 0 7px 0 10px;
    background: #5f69de;
    border-radius: 15px;
    cursor: pointer;
    opacity: 0.9;
  }
  #gl-bench svg {
    height: 60px;
    margin: 0 -1px;
  }
  #gl-bench text {
    font-size: 12px;
    font-family: Helvetica,Arial,sans-serif;
    font-weight: 700;
    dominant-baseline: middle;
    text-anchor: middle;
  }
  #gl-bench .gl-mem {
    font-size: 9px;
  }
  #gl-bench line {
    stroke-width: 5;
    stroke: #112211;
    stroke-linecap: round;
  }
  #gl-bench polyline {
    fill: none;
    stroke: #112211;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3.5;
  }
  #gl-bench rect {
    fill: #8288e4;
  }
  #gl-bench .opacity {
    stroke: #8288e4;
  }
`;class Rx{constructor(e){this.destroy();const t=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new rO(t,{css:oO})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var t,n;(t=this.bench)==null||t.end("frame"),(n=this.bench)==null||n.nextFrame(e)}destroy(){this.bench=void 0,wi("#gl-bench").remove()}}class aO{constructor(e){this._config=e}get pointsNumber(){return this.pointPositions&&this.pointPositions.length/2}get linksNumber(){return this.links&&this.links.length/2}updatePoints(){this.pointPositions=this.inputPointPositions}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=Oo(this._config.pointDefaultColor??this._config.pointColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let t=0;t<this.pointColors.length/4;t++)this.pointColors[t*4]=e[0],this.pointColors[t*4+1]=e[1],this.pointColors[t*4+2]=e[2],this.pointColors[t*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let t=0;t<this.pointColors.length/4;t++)ss(this.pointColors[t*4])||(this.pointColors[t*4]=e[0]),ss(this.pointColors[t*4+1])||(this.pointColors[t*4+1]=e[1]),ss(this.pointColors[t*4+2])||(this.pointColors[t*4+2]=e[2]),ss(this.pointColors[t*4+3])||(this.pointColors[t*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}const e=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(e);else{this.pointSizes=this.inputPointSizes;for(let t=0;t<this.pointSizes.length;t++)ss(this.pointSizes[t])||(this.pointSizes[t]=e)}}updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const e=0;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(e);else{this.pointShapes=new Float32Array(this.inputPointShapes);const t=this.pointShapes;for(let n=0;n<t.length;n++){const s=t[n];(s==null||!ss(s)||s<0||s>8)&&(t[n]=e)}}}updatePointImageIndices(){if(this.pointsNumber===void 0){this.pointImageIndices=void 0;return}if(this.inputPointImageIndices===void 0||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let t=0;t<e.length;t++){const n=e[t],s=n===void 0?NaN:n;!Number.isFinite(s)||s<0?e[t]=-1:e[t]=Math.trunc(s)}this.pointImageIndices=e}}updatePointImageSizes(){var e;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}const t=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(t);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let n=0;n<this.pointImageSizes.length;n++)ss(this.pointImageSizes[n])||(this.pointImageSizes[n]=((e=this.pointSizes)==null?void 0:e[n])??t)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Oo(this._config.linkDefaultColor??this._config.linkColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let t=0;t<this.linkColors.length/4;t++)this.linkColors[t*4]=e[0],this.linkColors[t*4+1]=e[1],this.linkColors[t*4+2]=e[2],this.linkColors[t*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let t=0;t<this.linkColors.length/4;t++)ss(this.linkColors[t*4])||(this.linkColors[t*4]=e[0]),ss(this.linkColors[t*4+1])||(this.linkColors[t*4+1]=e[1]),ss(this.linkColors[t*4+2])||(this.linkColors[t*4+2]=e[2]),ss(this.linkColors[t*4+3])||(this.linkColors[t*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}const e=this._config.linkDefaultWidth??this._config.linkWidth;if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(e);else{this.linkWidths=this.inputLinkWidths;for(let t=0;t<this.linkWidths.length;t++)ss(this.linkWidths[t])||(this.linkWidths[t]=e)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}const e=this._config.linkDefaultArrows??this._config.linkArrows;this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+e):this.linkArrows=this.linkArrowsBoolean.map(t=>+t)}updateLinkStrength(){this.linksNumber===void 0&&(this.linkStrength=void 0),this.inputLinkStrength===void 0||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(this.pointsNumber===void 0){this.pointClusters=void 0,this.clusterPositions=void 0;return}this.inputPointClusters===void 0||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,this.inputClusterPositions===void 0?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,this.inputClusterStrength===void 0||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var t,n,s,r;return[...((n=(t=this.sourceIndexToTargetIndices)==null?void 0:t[e])==null?void 0:n.map(o=>o[0]))||[],...((r=(s=this.targetIndexToSourceIndices)==null?void 0:s[e])==null?void 0:r.map(o=>o[0]))||[]]}_createAdjacencyLists(){var e,t;if(this.linksNumber===void 0||this.links===void 0){this.sourceIndexToTargetIndices=void 0,this.targetIndexToSourceIndices=void 0;return}this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let n=0;n<this.linksNumber;n++){const s=this.links[n*2],r=this.links[n*2+1];s!==void 0&&r!==void 0&&(this.sourceIndexToTargetIndices[s]===void 0&&(this.sourceIndexToTargetIndices[s]=[]),(e=this.sourceIndexToTargetIndices[s])==null||e.push([r,n]),this.targetIndexToSourceIndices[r]===void 0&&(this.targetIndexToSourceIndices[r]=[]),(t=this.targetIndexToSourceIndices[r])==null||t.push([s,n]))}}_calculateDegrees(){var e,t,n,s;if(this.pointsNumber===void 0){this.degree=void 0,this.inDegree=void 0,this.outDegree=void 0;return}this.degree=new Array(this.pointsNumber).fill(0),this.inDegree=new Array(this.pointsNumber).fill(0),this.outDegree=new Array(this.pointsNumber).fill(0);for(let r=0;r<this.pointsNumber;r++)this.inDegree[r]=((t=(e=this.targetIndexToSourceIndices)==null?void 0:e[r])==null?void 0:t.length)??0,this.outDegree[r]=((s=(n=this.sourceIndexToTargetIndices)==null?void 0:n[r])==null?void 0:s.length)??0,this.degree[r]=(this.inDegree[r]??0)+(this.outDegree[r]??0)}}const lO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec4 rgbaColor;
in vec2 pos;
in float arrowLength;
in float useArrow;
in float smoothing;
in float arrowWidthFactor;
in float linkIndex;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawLineFragmentUniforms {
  float renderMode;
} drawLineFrag;

#define renderMode drawLineFrag.renderMode
#else
// renderMode: 0.0 = normal rendering, 1.0 = index buffer rendering for picking
uniform float renderMode;
#endif

out vec4 fragColor;

float map(float value, float min1, float max1, float min2, float max2) {
  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}

void main() {
  float opacity = 1.0;
  vec3 color = rgbaColor.rgb;

  if (useArrow > 0.5) {
    float end_arrow = 0.5 + arrowLength / 2.0;
    float start_arrow = end_arrow - arrowLength;
    float arrowWidthDelta = arrowWidthFactor / 2.0;
    float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothing / 2.0, abs(pos.y));
    float arrowOpacity = 1.0;
    if (pos.x > start_arrow && pos.x < start_arrow + arrowLength) {
      float xmapped = map(pos.x, start_arrow, end_arrow, 0.0, 1.0);
      arrowOpacity = rgbaColor.a * smoothstep(xmapped - smoothing, xmapped, map(abs(pos.y), 0.5, 0.0, 0.0, 1.0));
      if (linkOpacity != arrowOpacity) {
        linkOpacity = max(linkOpacity, arrowOpacity);
      }
    }
    opacity = linkOpacity;
  } else opacity = rgbaColor.a * smoothstep(0.5, 0.5 - smoothing, abs(pos.y));
  
  if (renderMode > 0.0) {
    if (opacity > 0.0) {
      fragColor = vec4(linkIndex, 0.0, 0.0, 1.0);
    } else {
      fragColor = vec4(-1.0, 0.0, 0.0, 0.0);
    }
  } else fragColor = vec4(color, opacity);

}`,cO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 position, pointA, pointB;
in vec4 color;
in float width;
in float arrow;
in float linkIndices;

uniform sampler2D positionsTexture;
uniform sampler2D pointGreyoutStatus;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawLineUniforms {
  mat4 transformationMatrix;
  float pointsTextureSize;
  float widthScale;
  float linkArrowsSizeScale;
  float spaceSize;
  vec2 screenSize;
  vec2 linkVisibilityDistanceRange;
  float linkVisibilityMinTransparency;
  float linkOpacity;
  float greyoutOpacity;
  float curvedWeight;
  float curvedLinkControlPointDistance;
  float curvedLinkSegments;
  float scaleLinksOnZoom;
  float maxPointSize;
  float renderMode;
  float hoveredLinkIndex;
  vec4 hoveredLinkColor;
  float hoveredLinkWidthIncrease;
} drawLine;

#define transformationMatrix drawLine.transformationMatrix
#define pointsTextureSize drawLine.pointsTextureSize
#define widthScale drawLine.widthScale
#define linkArrowsSizeScale drawLine.linkArrowsSizeScale
#define spaceSize drawLine.spaceSize
#define screenSize drawLine.screenSize
#define linkVisibilityDistanceRange drawLine.linkVisibilityDistanceRange
#define linkVisibilityMinTransparency drawLine.linkVisibilityMinTransparency
#define linkOpacity drawLine.linkOpacity
#define greyoutOpacity drawLine.greyoutOpacity
#define curvedWeight drawLine.curvedWeight
#define curvedLinkControlPointDistance drawLine.curvedLinkControlPointDistance
#define curvedLinkSegments drawLine.curvedLinkSegments
#define scaleLinksOnZoom drawLine.scaleLinksOnZoom
#define maxPointSize drawLine.maxPointSize
#define renderMode drawLine.renderMode
#define hoveredLinkIndex drawLine.hoveredLinkIndex
#define hoveredLinkColor drawLine.hoveredLinkColor
#define hoveredLinkWidthIncrease drawLine.hoveredLinkWidthIncrease
#else
uniform mat3 transformationMatrix;
uniform float pointsTextureSize;
uniform float widthScale;
uniform float linkArrowsSizeScale;
uniform float spaceSize;
uniform vec2 screenSize;
uniform vec2 linkVisibilityDistanceRange;
uniform float linkVisibilityMinTransparency;
uniform float linkOpacity;
uniform float greyoutOpacity;
uniform float curvedWeight;
uniform float curvedLinkControlPointDistance;
uniform float curvedLinkSegments;
uniform bool scaleLinksOnZoom;
uniform float maxPointSize;
// renderMode: 0.0 = normal rendering, 1.0 = index buffer rendering for picking
uniform float renderMode;
uniform float hoveredLinkIndex;
uniform vec4 hoveredLinkColor;
uniform float hoveredLinkWidthIncrease;
#endif

out vec4 rgbaColor;
out vec2 pos;
out float arrowLength;
out float useArrow;
out float smoothing;
out float arrowWidthFactor;
out float linkIndex;

float map(float value, float min1, float max1, float min2, float max2) {
  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}

vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) {
  vec2 divident = (1.0 - t) * (1.0 - t) * A + 2.0 * (1.0 - t) * t * w * ControlPoint + t * t * B;
  float divisor = (1.0 - t) * (1.0 - t) + 2.0 * (1.0 - t) * t * w + t * t;
  return divident / divisor;
}

float calculateLinkWidth(float width) {
  float linkWidth;
  if (scaleLinksOnZoom > 0.0) {
    // Use original width if links should scale with zoom
    linkWidth = width;
  } else {
    // Adjust width based on zoom level to maintain visual size
    linkWidth = width / transformationMatrix[0][0];
    // Apply a non-linear scaling to avoid extreme widths
    linkWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
  }
  // Limit link width based on whether it has an arrow
  if (useArrow > 0.5) {
    return min(linkWidth, (maxPointSize * 2.0) / transformationMatrix[0][0]);
  } else {
    return min(linkWidth, maxPointSize / transformationMatrix[0][0]);
  }
}

float calculateArrowWidth(float arrowWidth) {
  if (scaleLinksOnZoom > 0.0) {
    return arrowWidth;
  } else {
    // Apply the same scaling logic as calculateLinkWidth to maintain proportionality
    arrowWidth = arrowWidth / transformationMatrix[0][0];
    // Apply the same non-linear scaling to avoid extreme widths
    arrowWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
    return arrowWidth;
  }
}

void main() {
  pos = position;
  linkIndex = linkIndices;

  vec2 pointTexturePosA = (pointA + 0.5) / pointsTextureSize;
  vec2 pointTexturePosB = (pointB + 0.5) / pointsTextureSize;
  
  vec4 greyoutStatusA = texture(pointGreyoutStatus, pointTexturePosA);
  vec4 greyoutStatusB = texture(pointGreyoutStatus, pointTexturePosB);
  
  vec4 pointPositionA = texture(positionsTexture, pointTexturePosA);
  vec4 pointPositionB = texture(positionsTexture, pointTexturePosB);
  vec2 a = pointPositionA.xy;
  vec2 b = pointPositionB.xy;
  
  // Calculate direction vector and its perpendicular
  vec2 xBasis = b - a;
  vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));

  // Calculate link distance and control point for curved link
  float linkDist = length(xBasis);
  float h = curvedLinkControlPointDistance;
  vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h;

  // Convert link distance to screen pixels
  float linkDistPx = linkDist * transformationMatrix[0][0];
  
  // Calculate line width using the width scale
  float linkWidth = width * widthScale;
  float k = 2.0;
  // Arrow width is proportionally larger than the line width
  float arrowWidth = linkWidth * k;
  arrowWidth *= linkArrowsSizeScale;

  // Ensure arrow width difference is non-negative to prevent unwanted changes to link width
  float arrowWidthDifference = max(0.0, arrowWidth - linkWidth);

  // Calculate arrow width in pixels
  float arrowWidthPx = calculateArrowWidth(arrowWidth);

  // Calculate arrow length proportional to its width
  // 0.866 is approximately sqrt(3)/2 - related to equilateral triangle geometry
  // Cap the length to avoid overly long arrows on short links
  arrowLength = min(0.3, (0.866 * arrowWidthPx * 2.0) / linkDist);

  useArrow = arrow;
  if (useArrow > 0.5) {
    linkWidth += arrowWidthDifference;
  }

  arrowWidthFactor = arrowWidthDifference / linkWidth;

  // Calculate final link width in pixels with smoothing
  float linkWidthPx = calculateLinkWidth(linkWidth);
    
  if (renderMode > 0.0) {
    // Add 5 pixels padding for better hover detection
    linkWidthPx += 5.0 / transformationMatrix[0][0];
  } else {
      // Add pixel increase if this is the hovered link
    if (hoveredLinkIndex == linkIndex) {
      linkWidthPx += hoveredLinkWidthIncrease / transformationMatrix[0][0];
    }
  }
  float smoothingPx = 0.5 / transformationMatrix[0][0];
  smoothing = smoothingPx / linkWidthPx;
  linkWidthPx += smoothingPx;



  // Calculate final color with opacity based on link distance
  vec3 rgbColor = color.rgb;
  // Adjust opacity based on link distance
  float opacity = color.a * linkOpacity * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0));

  // Apply greyed out opacity if either endpoint is greyed out
  if (greyoutStatusA.r > 0.0 || greyoutStatusB.r > 0.0) {
    opacity *= greyoutOpacity;
  }

  // Pass final color to fragment shader
  rgbaColor = vec4(rgbColor, opacity);

  // Apply hover color if this is the hovered link and hover color is defined
  if (hoveredLinkIndex == linkIndex && hoveredLinkColor.a > -0.5) {
    // Keep existing RGB values but multiply opacity with hover color opacity
    rgbaColor.rgb = hoveredLinkColor.rgb;
    rgbaColor.a *= hoveredLinkColor.a;
  }

  // Calculate position on the curved path
  float t = position.x;
  float w = curvedWeight;
  
  float tPrev = t - 1.0 / curvedLinkSegments;
  float tNext = t + 1.0 / curvedLinkSegments;
  
  vec2 pointCurr = conicParametricCurve(a, b, controlPoint, t, w);
  
  vec2 pointPrev = conicParametricCurve(a, b, controlPoint, max(0.0, tPrev), w);
  vec2 pointNext = conicParametricCurve(a, b, controlPoint, min(tNext, 1.0), w);
  
  vec2 xBasisCurved = pointNext - pointPrev;
  vec2 yBasisCurved = normalize(vec2(-xBasisCurved.y, xBasisCurved.x));
  
  pointCurr += yBasisCurved * linkWidthPx * position.y;
  
  // Transform to clip space coordinates
  vec2 p = 2.0 * pointCurr / spaceSize - 1.0;
  p *= spaceSize / screenSize;
  
  #ifdef USE_UNIFORM_BUFFERS
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 final = transformMat3 * vec3(p, 1);
  #else
  vec3 final = transformationMatrix * vec3(p, 1);
  #endif
  
  gl_Position = vec4(final.rg, 0, 1);
}`,uO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D linkIndexTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform hoveredLineIndexUniforms {
  vec2 mousePosition;
  vec2 screenSize;
} hoveredLine;

#define mousePosition hoveredLine.mousePosition
#define screenSize hoveredLine.screenSize
#else
uniform vec2 mousePosition;
uniform vec2 screenSize;
#endif

out vec4 fragColor;

void main() {
  // Convert mouse position to texture coordinates
  vec2 texCoord = mousePosition / screenSize;
  
  // Read the link index from the linkIndexFbo texture at mouse position
  vec4 linkIndexData = texture(linkIndexTexture, texCoord);
  
  // Extract the link index (stored in the red channel)
  float linkIndex = linkIndexData.r;
  
  // Check if there's a valid link at this position (alpha > 0)
  if (linkIndexData.a > 0.0 && linkIndex >= 0.0) {
    // Output the link index
    fragColor = vec4(linkIndex, 0.0, 0.0, 1.0);
  } else {
    // No link at this position, output -1 to indicate no hover
    fragColor = vec4(-1.0, 0.0, 0.0, 0.0);
  }
} `,dO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 vertexCoord;

void main() {
  gl_Position = vec4(vertexCoord, 0.0, 1.0);
} `;function yh(i,e){return i==null||e==null?NaN:i<e?-1:i>e?1:i>=e?0:NaN}function hO(i,e){return i==null||e==null?NaN:e<i?-1:e>i?1:e>=i?0:NaN}function AE(i){let e,t,n;i.length!==2?(e=yh,t=(a,l)=>yh(i(a),l),n=(a,l)=>i(a)-l):(e=i===yh||i===hO?i:fO,t=i,n=i);function s(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const d=c+u>>>1;t(a[d],l)<0?c=d+1:u=d}while(c<u)}return c}function r(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const d=c+u>>>1;t(a[d],l)<=0?c=d+1:u=d}while(c<u)}return c}function o(a,l,c=0,u=a.length){const d=s(a,l,c,u-1);return d>c&&n(a[d-1],l)>-n(a[d],l)?d-1:d}return{left:s,center:o,right:r}}function fO(){return 0}function pO(i){return i===null?NaN:+i}const mO=AE(yh),gO=mO.right;AE(pO).center;function Px(i,e){let t,n;for(const s of i)s!=null&&(t===void 0?s>=s&&(t=n=s):(t>s&&(t=s),n<s&&(n=s)));return[t,n]}var zg=Math.sqrt(50),Ug=Math.sqrt(10),$g=Math.sqrt(2);function _O(i,e,t){var n,s=-1,r,o,a;if(e=+e,i=+i,t=+t,i===e&&t>0)return[i];if((n=e<i)&&(r=i,i=e,e=r),(a=IE(i,e,t))===0||!isFinite(a))return[];if(a>0){let l=Math.round(i/a),c=Math.round(e/a);for(l*a<i&&++l,c*a>e&&--c,o=new Array(r=c-l+1);++s<r;)o[s]=(l+s)*a}else{a=-a;let l=Math.round(i*a),c=Math.round(e*a);for(l/a<i&&++l,c/a>e&&--c,o=new Array(r=c-l+1);++s<r;)o[s]=(l+s)/a}return n&&o.reverse(),o}function IE(i,e,t){var n=(e-i)/Math.max(0,t),s=Math.floor(Math.log(n)/Math.LN10),r=n/Math.pow(10,s);return s>=0?(r>=zg?10:r>=Ug?5:r>=$g?2:1)*Math.pow(10,s):-Math.pow(10,-s)/(r>=zg?10:r>=Ug?5:r>=$g?2:1)}function yO(i,e,t){var n=Math.abs(e-i)/Math.max(0,t),s=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),r=n/s;return r>=zg?s*=10:r>=Ug?s*=5:r>=$g&&(s*=2),e<i?-s:s}function bO(i,e,t){i=+i,e=+e,t=(s=arguments.length)<2?(e=i,i=0,1):s<3?1:+t;for(var n=-1,s=Math.max(0,Math.ceil((e-i)/t))|0,r=new Array(s);++n<s;)r[n]=i+n*t;return r}function LE(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function vO(i){return function(){return i}}function xO(i){return+i}var Nx=[0,1];function gr(i){return i}function jg(i,e){return(e-=i=+i)?function(t){return(t-i)/e}:vO(isNaN(e)?NaN:.5)}function wO(i,e){var t;return i>e&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function SO(i,e,t){var n=i[0],s=i[1],r=e[0],o=e[1];return s<n?(n=jg(s,n),r=t(o,r)):(n=jg(n,s),r=t(r,o)),function(a){return r(n(a))}}function EO(i,e,t){var n=Math.min(i.length,e.length)-1,s=new Array(n),r=new Array(n),o=-1;for(i[n]<i[0]&&(i=i.slice().reverse(),e=e.slice().reverse());++o<n;)s[o]=jg(i[o],i[o+1]),r[o]=t(e[o],e[o+1]);return function(a){var l=gO(i,a,1,n)-1;return r[l](s[l](a))}}function RE(i,e){return e.domain(i.domain()).range(i.range()).interpolate(i.interpolate()).clamp(i.clamp()).unknown(i.unknown())}function PE(){var i=Nx,e=Nx,t=dy,n,s,r,o=gr,a,l,c;function u(){var h=Math.min(i.length,e.length);return o!==gr&&(o=wO(i[0],i[h-1])),a=h>2?EO:SO,l=c=null,d}function d(h){return h==null||isNaN(h=+h)?r:(l||(l=a(i.map(n),e,t)))(n(o(h)))}return d.invert=function(h){return o(s((c||(c=a(e,i.map(n),Fs)))(h)))},d.domain=function(h){return arguments.length?(i=Array.from(h,xO),u()):i.slice()},d.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},d.rangeRound=function(h){return e=Array.from(h),t=O5,u()},d.clamp=function(h){return arguments.length?(o=h?!0:gr,u()):o!==gr},d.interpolate=function(h){return arguments.length?(t=h,u()):t},d.unknown=function(h){return arguments.length?(r=h,d):r},function(h,p){return n=h,s=p,u()}}function CO(){return PE()(gr,gr)}function TO(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function af(i,e){if((t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"))<0)return null;var t,n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function Al(i){return i=af(Math.abs(i)),i?i[1]:NaN}function kO(i,e){return function(t,n){for(var s=t.length,r=[],o=0,a=i[0],l=0;s>0&&a>0&&(l+a+1>n&&(a=Math.max(1,n-l)),r.push(t.substring(s-=a,s+a)),!((l+=a+1)>n));)a=i[o=(o+1)%i.length];return r.reverse().join(e)}}function AO(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var IO=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function lf(i){if(!(e=IO.exec(i)))throw new Error("invalid format: "+i);var e;return new Ly({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}lf.prototype=Ly.prototype;function Ly(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}Ly.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function LO(i){e:for(var e=i.length,t=1,n=-1,s;t<e;++t)switch(i[t]){case".":n=s=t;break;case"0":n===0&&(n=t),s=t;break;default:if(!+i[t])break e;n>0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(s+1):i}var NE;function RO(i,e){var t=af(i,e);if(!t)return i+"";var n=t[0],s=t[1],r=s-(NE=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,o=n.length;return r===o?n:r>o?n+new Array(r-o+1).join("0"):r>0?n.slice(0,r)+"."+n.slice(r):"0."+new Array(1-r).join("0")+af(i,Math.max(0,e+r-1))[0]}function Dx(i,e){var t=af(i,e);if(!t)return i+"";var n=t[0],s=t[1];return s<0?"0."+new Array(-s).join("0")+n:n.length>s+1?n.slice(0,s+1)+"."+n.slice(s+1):n+new Array(s-n.length+2).join("0")}const Mx={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:TO,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>Dx(i*100,e),r:Dx,s:RO,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function Bx(i){return i}var Ox=Array.prototype.map,Fx=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function PO(i){var e=i.grouping===void 0||i.thousands===void 0?Bx:kO(Ox.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",s=i.decimal===void 0?".":i.decimal+"",r=i.numerals===void 0?Bx:AO(Ox.call(i.numerals,String)),o=i.percent===void 0?"%":i.percent+"",a=i.minus===void 0?"−":i.minus+"",l=i.nan===void 0?"NaN":i.nan+"";function c(d){d=lf(d);var h=d.fill,p=d.align,m=d.sign,y=d.symbol,g=d.zero,_=d.width,S=d.comma,E=d.precision,x=d.trim,T=d.type;T==="n"?(S=!0,T="g"):Mx[T]||(E===void 0&&(E=12),x=!0,T="g"),(g||h==="0"&&p==="=")&&(g=!0,h="0",p="=");var I=y==="$"?t:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",O=y==="$"?n:/[%p]/.test(T)?o:"",H=Mx[T],Q=/[defgprs%]/.test(T);E=E===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function re(D){var de=I,se=O,R,ee,F;if(T==="c")se=H(D)+se,D="";else{D=+D;var q=D<0||1/D<0;if(D=isNaN(D)?l:H(Math.abs(D),E),x&&(D=LO(D)),q&&+D==0&&m!=="+"&&(q=!1),de=(q?m==="("?m:a:m==="-"||m==="("?"":m)+de,se=(T==="s"?Fx[8+NE/3]:"")+se+(q&&m==="("?")":""),Q){for(R=-1,ee=D.length;++R<ee;)if(F=D.charCodeAt(R),48>F||F>57){se=(F===46?s+D.slice(R+1):D.slice(R))+se,D=D.slice(0,R);break}}}S&&!g&&(D=e(D,1/0));var te=de.length+D.length+se.length,Z=te<_?new Array(_-te+1).join(h):"";switch(S&&g&&(D=e(Z+D,Z.length?_-se.length:1/0),Z=""),p){case"<":D=de+D+se+Z;break;case"=":D=de+Z+D+se;break;case"^":D=Z.slice(0,te=Z.length>>1)+de+D+se+Z.slice(te);break;default:D=Z+de+D+se;break}return r(D)}return re.toString=function(){return d+""},re}function u(d,h){var p=c((d=lf(d),d.type="f",d)),m=Math.max(-8,Math.min(8,Math.floor(Al(h)/3)))*3,y=Math.pow(10,-m),g=Fx[8+m/3];return function(_){return p(y*_)+g}}return{format:c,formatPrefix:u}}var Ad,DE,ME;NO({thousands:",",grouping:[3],currency:["$",""]});function NO(i){return Ad=PO(i),DE=Ad.format,ME=Ad.formatPrefix,Ad}function DO(i){return Math.max(0,-Al(Math.abs(i)))}function MO(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Al(e)/3)))*3-Al(Math.abs(i)))}function BO(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,Al(e)-Al(i))+1}function OO(i,e,t,n){var s=yO(i,e,t),r;switch(n=lf(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(r=MO(s,o))&&(n.precision=r),ME(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(r=BO(s,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=r-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(r=DO(s))&&(n.precision=r-(n.type==="%")*2);break}}return DE(n)}function BE(i){var e=i.domain;return i.ticks=function(t){var n=e();return _O(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var s=e();return OO(s[0],s[s.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),s=0,r=n.length-1,o=n[s],a=n[r],l,c,u=10;for(a<o&&(c=o,o=a,a=c,c=s,s=r,r=c);u-- >0;){if(c=IE(o,a,t),c===l)return n[s]=o,n[r]=a,e(n);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return i},i}function Hg(){var i=CO();return i.copy=function(){return RE(i,Hg())},LE.apply(i,arguments),BE(i)}function zx(i){return function(e){return e<0?-Math.pow(-e,i):Math.pow(e,i)}}function FO(i){return i<0?-Math.sqrt(-i):Math.sqrt(i)}function zO(i){return i<0?-i*i:i*i}function UO(i){var e=i(gr,gr),t=1;function n(){return t===1?i(gr,gr):t===.5?i(FO,zO):i(zx(t),zx(1/t))}return e.exponent=function(s){return arguments.length?(t=+s,n()):t},BE(e)}function OE(){var i=UO(PE());return i.copy=function(){return RE(i,OE()).exponent(i.exponent())},LE.apply(i,arguments),i}const $O=i=>{const e=OE().exponent(2).range([0,1]).domain([-1,1]),t=bO(0,i).map(s=>-.5+s/i);t.push(.5);const n=new Array(t.length*2);return t.forEach((s,r)=>{n[r*2]=[e(s*2),.5],n[r*2+1]=[e(s*2),-.5]}),n};class jO extends Zo{initPrograms(){var e;const{device:t,config:n,store:s}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=t.createTexture({width:1,height:1,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST,data:new Float32Array(4).fill(0)})),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=t.createFramebuffer({width:1,height:1,colorAttachments:[this.hoveredLineIndexTexture]})),this.curveLineGeometry||this.updateCurveLineGeometry();const r=this.data.linksNumber??0;this.pointABuffer||(this.pointABuffer=t.createBuffer({data:new Float32Array(r*2),usage:me.VERTEX|me.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=t.createBuffer({data:new Float32Array(r*2),usage:me.VERTEX|me.COPY_DST})),this.colorBuffer||(this.colorBuffer=t.createBuffer({data:new Float32Array(r*4),usage:me.VERTEX|me.COPY_DST})),this.widthBuffer||(this.widthBuffer=t.createBuffer({data:new Float32Array(r),usage:me.VERTEX|me.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=t.createBuffer({data:new Float32Array(r),usage:me.VERTEX|me.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=t.createBuffer({data:new Float32Array(r),usage:me.VERTEX|me.COPY_DST})),this.drawLineUniformStore||(this.drawLineUniformStore=new ai({drawLineUniforms:{uniformTypes:{transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",widthScale:"f32",linkArrowsSizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",linkVisibilityDistanceRange:"vec2<f32>",linkVisibilityMinTransparency:"f32",linkOpacity:"f32",greyoutOpacity:"f32",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32",scaleLinksOnZoom:"f32",maxPointSize:"f32",renderMode:"f32",hoveredLinkIndex:"f32",hoveredLinkColor:"vec4<f32>",hoveredLinkWidthIncrease:"f32"},defaultUniforms:{transformationMatrix:s.transformationMatrix4x4,pointsTextureSize:s.pointsTextureSize,widthScale:n.linkWidthScale??1,linkArrowsSizeScale:n.linkArrowsSizeScale??1,spaceSize:s.adjustedSpaceSize??0,screenSize:_t(s.screenSize,[0,0]),linkVisibilityDistanceRange:_t(n.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:n.linkVisibilityMinTransparency??0,linkOpacity:n.linkOpacity??1,greyoutOpacity:n.linkGreyoutOpacity??1,curvedWeight:n.curvedLinkWeight??0,curvedLinkControlPointDistance:n.curvedLinkControlPointDistance??0,curvedLinkSegments:n.curvedLinks?n.curvedLinkSegments??fe.curvedLinkSegments:1,scaleLinksOnZoom:n.scaleLinksOnZoom??!0?1:0,maxPointSize:s.maxPointSize??100,renderMode:0,hoveredLinkIndex:s.hoveredLinkIndex??-1,hoveredLinkColor:Mi(s.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:n.hoveredLinkWidthIncrease??0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}})),this.drawCurveCommand||(this.drawCurveCommand=new ci(t,{vs:cO,fs:lO,topology:"triangle-strip",vertexCount:((e=this.curveLineGeometry)==null?void 0:e.length)??0,attributes:{...this.curveLineBuffer&&{position:this.curveLineBuffer},...this.pointABuffer&&{pointA:this.pointABuffer},...this.pointBBuffer&&{pointB:this.pointBBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.widthBuffer&&{width:this.widthBuffer},...this.arrowBuffer&&{arrow:this.arrowBuffer},...this.linkIndexBuffer&&{linkIndices:this.linkIndexBuffer}},bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"color",format:"float32x4",stepMode:"instance"},{name:"width",format:"float32",stepMode:"instance"},{name:"arrow",format:"float32",stepMode:"instance"},{name:"linkIndices",format:"float32",stepMode:"instance"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(t,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(t,"drawLineFragmentUniforms")},parameters:{cullMode:"back",blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.quadBuffer||(this.quadBuffer=t.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:me.VERTEX|me.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new ai({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:_t(s.screenMousePosition,[0,0]),screenSize:_t(s.screenSize,[0,0])}}})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=new ci(t,{vs:dO,fs:uO,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.quadBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(t,"hoveredLineIndexUniforms")}}))}draw(e){const{config:t,points:n,store:s}=this;n&&(!n.currentPositionTexture||n.currentPositionTexture.destroyed||!n.greyoutStatusTexture||n.greyoutStatusTexture.destroyed||((!this.pointABuffer||!this.pointBBuffer)&&this.updatePointsBuffer(),this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!(!this.drawCurveCommand||!this.drawLineUniformStore)&&(this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:s.transformationMatrix4x4,pointsTextureSize:s.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:s.adjustedSpaceSize??0,screenSize:_t(s.screenSize,[0,0]),linkVisibilityDistanceRange:_t(t.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??fe.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:s.maxPointSize??100,renderMode:0,hoveredLinkIndex:s.hoveredLinkIndex??-1,hoveredLinkColor:Mi(s.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({positionsTexture:n.currentPositionTexture,pointGreyoutStatus:n.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e))))}updateLinkIndexFbo(){var e,t;const{device:n,store:s}=this;if(!this.store.isLinkHoveringEnabled)return;const r=s.screenSize??[0,0],o=r[0],a=r[1];if(!o||!a)return;const l=((e=this.previousScreenSize)==null?void 0:e[0])!==o||((t=this.previousScreenSize)==null?void 0:t[1])!==a;(!this.linkIndexTexture||l)&&(this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=n.createTexture({width:o,height:a,format:"rgba32float",usage:lt.SAMPLE|lt.RENDER|lt.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(o*a*4).fill(0),bytesPerRow:at("rgba32float",o),mipLevel:0,x:0,y:0}),this.linkIndexFbo=n.createFramebuffer({width:o,height:a,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[o,a])}updatePointsBuffer(){var e;const{device:t,data:n,store:s}=this;if(n.linksNumber===void 0||n.links===void 0||!s.pointsTextureSize)return;const r=new Float32Array(n.linksNumber*2),o=new Float32Array(n.linksNumber*2);for(let c=0;c<n.linksNumber;c++){const u=n.links[c*2],d=n.links[c*2+1],h=u%s.pointsTextureSize,p=Math.floor(u/s.pointsTextureSize),m=d%s.pointsTextureSize,y=Math.floor(d/s.pointsTextureSize);r[c*2]=h,r[c*2+1]=p,o[c*2]=m,o[c*2+1]=y}const a=(((e=this.pointABuffer)==null?void 0:e.byteLength)??0)/(Float32Array.BYTES_PER_ELEMENT*2);!this.pointABuffer||a!==n.linksNumber?(this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=t.createBuffer({data:r,usage:me.VERTEX|me.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||a!==n.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=t.createBuffer({data:o,usage:me.VERTEX|me.COPY_DST})):this.pointBBuffer.write(o);const l=new Float32Array(n.linksNumber);for(let c=0;c<n.linksNumber;c++)l[c]=c;!this.linkIndexBuffer||a!==n.linksNumber?(this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=t.createBuffer({data:l,usage:me.VERTEX|me.COPY_DST})):this.linkIndexBuffer.write(l),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer})}updateColor(){const{device:e,data:t}=this,n=t.linksNumber??0,s=t.linkColors??new Float32Array(n*4).fill(0);this.colorBuffer?(this.colorBuffer.byteLength??0)/(Float32Array.BYTES_PER_ELEMENT*4)!==n?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.colorBuffer.write(s):this.colorBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({color:this.colorBuffer})}updateWidth(){const{device:e,data:t}=this,n=t.linksNumber??0,s=t.linkWidths??new Float32Array(n).fill(0);this.widthBuffer?(this.widthBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==n?(this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.widthBuffer.write(s):this.widthBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({width:this.widthBuffer})}updateArrow(){const{device:e,data:t}=this,n=t.linksNumber??0,s=t.linkArrows?new Float32Array(t.linkArrows):new Float32Array(n).fill(0);this.arrowBuffer?(this.arrowBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==n?(this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.arrowBuffer.write(s):this.arrowBuffer=e.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({arrow:this.arrowBuffer})}updateCurveLineGeometry(){var e;const{device:t,config:{curvedLinks:n,curvedLinkSegments:s}}=this;this.curveLineGeometry=$O(n?s??fe.curvedLinkSegments:1);const r=new Float32Array(this.curveLineGeometry.length*2);for(let o=0;o<this.curveLineGeometry.length;o++)r[o*2]=this.curveLineGeometry[o][0],r[o*2+1]=this.curveLineGeometry[o][1];!this.curveLineBuffer||this.curveLineBuffer.byteLength!==r.byteLength?((e=this.curveLineBuffer)==null||e.destroy(),this.curveLineBuffer=t.createBuffer({data:r,usage:me.VERTEX|me.COPY_DST})):this.curveLineBuffer.write(r),this.drawCurveCommand&&(this.drawCurveCommand.setAttributes({position:this.curveLineBuffer}),this.drawCurveCommand.setVertexCount(this.curveLineGeometry.length))}findHoveredLine(){const{config:e,points:t,store:n}=this;if(!t||!t.currentPositionTexture||t.currentPositionTexture.destroyed||!t.greyoutStatusTexture||t.greyoutStatusTexture.destroyed||!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawCurveCommand||!this.drawLineUniformStore||!this.linkIndexTexture||this.linkIndexTexture.destroyed)return;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:n.transformationMatrix4x4,pointsTextureSize:n.pointsTextureSize,widthScale:e.linkWidthScale??1,linkArrowsSizeScale:e.linkArrowsSizeScale??1,spaceSize:n.adjustedSpaceSize??0,screenSize:_t(n.screenSize,[0,0]),linkVisibilityDistanceRange:_t(e.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:e.linkVisibilityMinTransparency??0,linkOpacity:e.linkOpacity??1,greyoutOpacity:e.linkGreyoutOpacity??1,curvedWeight:e.curvedLinkWeight??0,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance??0,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments??fe.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom??!0?1:0,maxPointSize:n.maxPointSize??100,renderMode:1,hoveredLinkIndex:n.hoveredLinkIndex??-1,hoveredLinkColor:Mi(n.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurveCommand.setBindings({positionsTexture:t.currentPositionTexture,pointGreyoutStatus:t.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0);const s=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurveCommand.draw(s),s.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:_t(n.screenMousePosition,[0,0]),screenSize:_t(n.screenSize,[0,0])}}),this.hoveredLineIndexCommand.setBindings({linkIndexTexture:this.linkIndexTexture});const r=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(r),r.end()}}destroy(){var e,t,n,s;(e=this.drawCurveCommand)==null||e.destroy(),this.drawCurveCommand=void 0,(t=this.hoveredLineIndexCommand)==null||t.destroy(),this.hoveredLineIndexCommand=void 0,this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexFbo=void 0,this.hoveredLineIndexFbo&&!this.hoveredLineIndexFbo.destroyed&&this.hoveredLineIndexFbo.destroy(),this.hoveredLineIndexFbo=void 0,this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=void 0,this.hoveredLineIndexTexture&&!this.hoveredLineIndexTexture.destroyed&&this.hoveredLineIndexTexture.destroy(),this.hoveredLineIndexTexture=void 0,(n=this.drawLineUniformStore)==null||n.destroy(),this.drawLineUniformStore=void 0,(s=this.hoveredLineIndexUniformStore)==null||s.destroy(),this.hoveredLineIndexUniformStore=void 0,this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=void 0,this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=void 0,this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=void 0,this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=void 0,this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=void 0,this.quadBuffer&&!this.quadBuffer.destroyed&&this.quadBuffer.destroy(),this.quadBuffer=void 0}}const HO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D imageAtlasTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawFragmentUniforms {
  float greyoutOpacity;
  float pointOpacity;
  float isDarkenGreyout;
  vec4 backgroundColor;
} drawFragment;

#define greyoutOpacity drawFragment.greyoutOpacity
#define pointOpacity drawFragment.pointOpacity
#define isDarkenGreyout drawFragment.isDarkenGreyout
#define backgroundColor drawFragment.backgroundColor
#else
uniform float greyoutOpacity;
uniform float pointOpacity;
uniform float isDarkenGreyout;
uniform vec4 backgroundColor;
#endif


in float pointShape;
in float isGreyedOut;
in vec4 shapeColor;
in vec4 imageAtlasUV;
in float shapeSize;
in float imageSizeVarying;
in float overallSize;

out vec4 fragColor;

// Smoothing controls the smoothness of the point's edge
const float smoothing = 0.9;

// Shape constants
const float CIRCLE = 0.0;
const float SQUARE = 1.0;
const float TRIANGLE = 2.0;
const float DIAMOND = 3.0;
const float PENTAGON = 4.0;
const float HEXAGON = 5.0;
const float STAR = 6.0;
const float CROSS = 7.0;
const float NONE = 8.0;

// Distance functions for different shapes
float circleDistance(vec2 p) {
    return dot(p, p);
}

// Function to apply greyout logic to image colors
vec4 applyGreyoutToImage(vec4 imageColor, float isGreyedOutValue) {
    vec3 finalColor = imageColor.rgb;
    float finalAlpha = imageColor.a;
    
    if (isGreyedOutValue > 0.0) {
        float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color)
        
        if (isDarkenGreyout > 0.0) {
            finalColor = mix(finalColor, vec3(0.2), blendFactor);
        } else {
            finalColor = mix(finalColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
        }
    }
    
    return vec4(finalColor, finalAlpha);
}

float squareDistance(vec2 p) {
    vec2 d = abs(p) - vec2(0.8);
    return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}

float triangleDistance(vec2 p) {
    const float k = sqrt(3.0);   // ≈1.732; slope of 60° lines for an equilateral triangle
    p.x = abs(p.x) - 0.9;        // fold the X axis and shift: brings left and right halves together
    p.y = p.y + 0.55;             // move the whole shape up slightly so it is centred vertically

    // reflect points that fall outside the main triangle back inside, to reuse the same maths
    if (p.x + k * p.y > 0.0)
        p = vec2(p.x - k * p.y,  -k * p.x - p.y) / 2.0;

    p.x -= clamp(p.x, -1.0, 0.0); // clip any remainder on the left side

    // Return signed distance: negative = inside; positive = outside
    return -length(p) * sign(p.y);
}

float diamondDistance(vec2 p) {
    // aspect > 1  →  taller diamond
    const float aspect = 1.2;
    return abs(p.x) + abs(p.y) / aspect - 0.8;
}

float pentagonDistance(vec2 p) {
    // Regular pentagon signed-distance (Inigo Quilez)
    const vec3 k = vec3(0.809016994, 0.587785252, 0.726542528);
    p.x = abs(p.x);

    // Reflect across the two tilted edges ─ only if point is outside
    p -= 2.0 * min(dot(vec2(-k.x, k.y), p), 0.0) * vec2(-k.x, k.y);
    p -= 2.0 * min(dot(vec2( k.x, k.y), p), 0.0) * vec2( k.x, k.y);

    // Clip against the top horizontal edge (keeps top point sharp)
    p -= vec2(clamp(p.x, -k.z * k.x, k.z * k.x), k.z);

    // Return signed distance (negative → inside, positive → outside)
    return length(p) * sign(p.y);
}

float hexagonDistance(vec2 p) {
    const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
    p = abs(p);
    p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy;
    p -= vec2(clamp(p.x, -k.z * 0.8, k.z * 0.8), 0.8);
    return length(p) * sign(p.y);
}

float starDistance(vec2 p) {
    // 5-point star signed-distance function (adapted from Inigo Quilez)
    // r  – outer radius, rf – inner/outer radius ratio
    const float r  = 0.9;
    const float rf = 0.45;

    // Pre-computed rotation vectors for the star arms (36° increments)
    const vec2 k1 = vec2(0.809016994, -0.587785252);
    const vec2 k2 = vec2(-k1.x, k1.y);

    // Fold the plane into a single arm sector
    p.x = abs(p.x);
    p -= 2.0 * max(dot(k1, p), 0.0) * k1;
    p -= 2.0 * max(dot(k2, p), 0.0) * k2;
    p.x = abs(p.x);

    // Translate so the top tip of the star lies on the X-axis
    p.y -= r;

    // Vector describing the edge between an outer tip and its adjacent inner point
    vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0);
    // Project the point onto that edge and clamp the projection to the segment
    float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);

    // Return signed distance (negative => inside, positive => outside)
    return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);
}

float crossDistance(vec2 p) {
    // Signed distance function for a cross (union of two rectangles)
    // Adapted from Inigo Quilez (https://iquilezles.org/)
    // Each arm has half-sizes 0.3 (thickness) and 0.8 (length)
    p = abs(p);
    if (p.y > p.x) p = p.yx;       // exploit symmetry

    vec2 q = p - vec2(0.8, 0.3);   // subtract half-sizes (length, thickness)

    // Standard rectangle SDF, then take union of the two arms
    return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
}

float getShapeDistance(vec2 p, float shape) {
    if (shape == SQUARE) return squareDistance(p);
    else if (shape == TRIANGLE) return triangleDistance(p);
    else if (shape == DIAMOND) return diamondDistance(p);
    else if (shape == PENTAGON) return pentagonDistance(p);
    else if (shape == HEXAGON) return hexagonDistance(p);
    else if (shape == STAR) return starDistance(p);
    else if (shape == CROSS) return crossDistance(p);
    else return circleDistance(p); // Default to circle
}

void main() {
    // Discard the fragment if the point is fully transparent and has no image
    if (shapeColor.a == 0.0 && imageAtlasUV.x == -1.0) {
        discard;
    }

    // Discard the fragment if the point has no shape and no image
    if (pointShape == NONE && imageAtlasUV.x == -1.0) {
        discard;
    }

    // Calculate coordinates within the point
    vec2 pointCoord = 2.0 * gl_PointCoord - 1.0;

    vec4 finalShapeColor = vec4(0.0);
    vec4 finalImageColor = vec4(0.0);
    
    // Handle shape rendering with centering logic
    if (pointShape != NONE) {
        // Calculate shape coordinates with centering
        vec2 shapeCoord = pointCoord;
        if (overallSize > shapeSize && shapeSize > 0.0) {
            // Shape is smaller than overall size, center it
            float scale = shapeSize / overallSize;
            shapeCoord = pointCoord / scale;
        }
        
        float opacity;
        if (pointShape == CIRCLE) {
            // For circles, use the original distance calculation
            float pointCenterDistance = dot(shapeCoord, shapeCoord);
            opacity = 1.0 - smoothstep(smoothing, 1.0, pointCenterDistance);
        } else {
            // For other shapes, use the shape distance function
            float shapeDistance = getShapeDistance(shapeCoord, pointShape);
            opacity = 1.0 - smoothstep(-0.01, 0.01, shapeDistance);
        }
        opacity *= shapeColor.a;

        finalShapeColor = vec4(shapeColor.rgb, opacity);
    }

    // Handle image rendering with centering logic
    if (imageAtlasUV.x != -1.0) {
        // Calculate image coordinates with centering
        vec2 imageCoord = pointCoord;
        if (overallSize > imageSizeVarying && imageSizeVarying > 0.0) {
            // Image is smaller than overall size, center it
            float scale = imageSizeVarying / overallSize;
            imageCoord = pointCoord / scale;
            
            // Check if we're outside the valid image area
            if (abs(imageCoord.x) > 1.0 || abs(imageCoord.y) > 1.0) {
                // We're outside the image bounds, don't render the image
                finalImageColor = vec4(0.0);
            } else {
                // Sample from texture atlas
                vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
                vec4 imageColor = texture(imageAtlasTexture, atlasUV);
                finalImageColor = applyGreyoutToImage(imageColor, isGreyedOut);
            }
        } else {
            // Image is same size or larger than overall size, no scaling needed
            // Sample from texture atlas
            vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
            vec4 imageColor = texture(imageAtlasTexture, atlasUV);
            finalImageColor = applyGreyoutToImage(imageColor, isGreyedOut);
        }
    }

    float finalPointAlpha = max(finalShapeColor.a, finalImageColor.a);
    if (isGreyedOut > 0.0 && greyoutOpacity != -1.0) {
        finalPointAlpha *= greyoutOpacity;
    } else {
        finalPointAlpha *= pointOpacity;
    }

    // Blend image color above point color
    fragColor = vec4(
        mix(finalShapeColor.rgb, finalImageColor.rgb, finalImageColor.a),
        finalPointAlpha
    );
}
`,VO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 pointIndices;
in float size;
in vec4 color;
in float shape;
in float imageIndex;
in float imageSize;

uniform sampler2D positionsTexture;
uniform sampler2D pointGreyoutStatus;
uniform sampler2D imageAtlasCoords;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawVertexUniforms {
  float ratio;
  mat4 transformationMatrix;
  float pointsTextureSize;
  float sizeScale;
  float spaceSize;
  vec2 screenSize;
  vec4 greyoutColor;
  vec4 backgroundColor;
  float scalePointsOnZoom;
  float maxPointSize;
  float isDarkenGreyout;
  float skipSelected;
  float skipUnselected;
  float hasImages;
  float imageCount;
  float imageAtlasCoordsTextureSize;
} drawVertex;

#define ratio drawVertex.ratio
#define transformationMatrix drawVertex.transformationMatrix
#define pointsTextureSize drawVertex.pointsTextureSize
#define sizeScale drawVertex.sizeScale
#define spaceSize drawVertex.spaceSize
#define screenSize drawVertex.screenSize
#define greyoutColor drawVertex.greyoutColor
#define backgroundColor drawVertex.backgroundColor
#define scalePointsOnZoom drawVertex.scalePointsOnZoom
#define maxPointSize drawVertex.maxPointSize
#define isDarkenGreyout drawVertex.isDarkenGreyout
#define skipSelected drawVertex.skipSelected
#define skipUnselected drawVertex.skipUnselected
#define hasImages drawVertex.hasImages
#define imageCount drawVertex.imageCount
#define imageAtlasCoordsTextureSize drawVertex.imageAtlasCoordsTextureSize
#else
uniform float ratio;
uniform mat3 transformationMatrix;
uniform float pointsTextureSize;
uniform float sizeScale;
uniform float spaceSize;
uniform vec2 screenSize;
uniform vec4 greyoutColor;
uniform vec4 backgroundColor;
uniform float scalePointsOnZoom;
uniform float maxPointSize;
uniform float isDarkenGreyout;
uniform float skipSelected;
uniform float skipUnselected;
uniform float hasImages;
uniform float imageCount;
uniform float imageAtlasCoordsTextureSize;
#endif

out float pointShape;
out float isGreyedOut;
out vec4 shapeColor;
out vec4 imageAtlasUV;
out float shapeSize;
out float imageSizeVarying;
out float overallSize;

float calculatePointSize(float size) {
  float pSize;

  if (scalePointsOnZoom > 0.0) { 
    pSize = size * ratio * transformationMatrix[0][0];
  } else {
    pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
  }

  return min(pSize, maxPointSize * ratio);
}

void main() {    
  // Check greyout status for selective rendering
  vec4 greyoutStatus = texture(pointGreyoutStatus, (pointIndices + 0.5) / pointsTextureSize);
  isGreyedOut = greyoutStatus.r;
  float isSelected = (greyoutStatus.r == 0.0) ? 1.0 : 0.0;
  
  // Discard point based on rendering mode
  if (skipSelected > 0.0 && isSelected > 0.0) {
    gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Move off-screen
    gl_PointSize = 0.0;
    return;
  }
  if (skipUnselected > 0.0 && isSelected <= 0.0) {
    gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Move off-screen
    gl_PointSize = 0.0;
    return;
  }
  
  // Position
  vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
  vec2 point = pointPosition.rg;

  // Transform point position to normalized device coordinates
  // Convert from space coordinates [0, spaceSize] to normalized [-1, 1]
  vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0;
  
  // Apply aspect ratio correction - this is needed to map the square space to the rectangular screen
  // The transformation matrix handles zoom/pan, but we need this to handle aspect ratio
  normalizedPosition *= spaceSize / screenSize;
  
  #ifdef USE_UNIFORM_BUFFERS
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 finalPosition = transformMat3 * vec3(normalizedPosition, 1);
  #else
  vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1);
  #endif
  gl_Position = vec4(finalPosition.rg, 0, 1);

  // Calculate sizes for shape and image
  float shapeSizeValue = calculatePointSize(size * sizeScale);
  float imageSizeValue = calculatePointSize(imageSize * sizeScale);
  
  // Use the larger of the two sizes for the overall point size
  float overallSizeValue = max(shapeSizeValue, imageSizeValue);
  gl_PointSize = overallSizeValue;

  // Pass size information to fragment shader
  shapeSize = shapeSizeValue;
  imageSizeVarying = imageSizeValue;
  overallSize = overallSizeValue;

  shapeColor = color;
  pointShape = shape;

  // Adjust alpha of selected points
  if (isGreyedOut > 0.0) {
    if (greyoutColor[0] != -1.0) {
      shapeColor = greyoutColor;
    } else {
      // If greyoutColor is not set, make color lighter or darker based on isDarkenGreyout
      float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color)
      
      #ifdef USE_UNIFORM_BUFFERS
      if (isDarkenGreyout > 0.0) {
        // Darken the color
        shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor);
      } else {
        // Lighten the color
        shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
      }
      #else
      if (isDarkenGreyout > 0.0) {
        // Darken the color
        shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor);
      } else {
        // Lighten the color
        shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
      }
      #endif
    }
  }

  #ifdef USE_UNIFORM_BUFFERS
  if (hasImages <= 0.0 || imageIndex < 0.0 || imageIndex >= imageCount) {
    imageAtlasUV = vec4(-1.0);
  } else {
    // Calculate image atlas UV coordinates based on imageIndex
    float atlasCoordIndex = imageIndex;
    // Calculate the position in the texture grid
    float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize);
    float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize);
    // Convert to texture coordinates (0.0 to 1.0)
    vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize;
    vec4 atlasCoords = texture(imageAtlasCoords, atlasCoordTexCoord);
    imageAtlasUV = atlasCoords;
  }
  #else
  if (hasImages <= 0.0 || imageIndex < 0.0 || imageIndex >= imageCount) {
    imageAtlasUV = vec4(-1.0);
  } else {
    // Calculate image atlas UV coordinates based on imageIndex
    float atlasCoordIndex = imageIndex;
    // Calculate the position in the texture grid
    float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize);
    float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize);
    // Convert to texture coordinates (0.0 to 1.0)
    vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize;
    vec4 atlasCoords = texture(imageAtlasCoords, atlasCoordTexCoord);
    imageAtlasUV = atlasCoords;
  }
  #endif
} `,GO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D pointSize;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform findPointsOnAreaSelectionUniforms {
  float sizeScale;
  float spaceSize;
  vec2 screenSize;
  float ratio;
  mat4 transformationMatrix;
  vec2 selection0;
  vec2 selection1;
  float scalePointsOnZoom;
  float maxPointSize;
} findPointsOnAreaSelection;

#define sizeScale findPointsOnAreaSelection.sizeScale
#define spaceSize findPointsOnAreaSelection.spaceSize
#define screenSize findPointsOnAreaSelection.screenSize
#define ratio findPointsOnAreaSelection.ratio
#define transformationMatrix findPointsOnAreaSelection.transformationMatrix
#define selection0 findPointsOnAreaSelection.selection0
#define selection1 findPointsOnAreaSelection.selection1
#define scalePointsOnZoom findPointsOnAreaSelection.scalePointsOnZoom
#define maxPointSize findPointsOnAreaSelection.maxPointSize
#else
uniform float sizeScale;
uniform float spaceSize;
uniform vec2 screenSize;
uniform float ratio;
uniform mat3 transformationMatrix;
uniform vec2 selection0;
uniform vec2 selection1;
uniform float scalePointsOnZoom;
uniform float maxPointSize;
#endif

in vec2 textureCoords;

out vec4 fragColor;

float pointSizeF(float size) {
  float pSize;
  // Extract top-left element from mat4 (or use mat3 conversion)
  #ifdef USE_UNIFORM_BUFFERS
  float scale = transformationMatrix[0][0]; // mat4 first element
  #else
  float scale = transformationMatrix[0][0]; // mat3 first element
  #endif
  if (scalePointsOnZoom > 0.0) { 
    pSize = size * ratio * scale;
  } else {
    pSize = size * ratio * min(5.0, max(1.0, scale * 0.01));
  }
  return min(pSize, maxPointSize * ratio);
}

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
  p *= spaceSize / screenSize;
  #ifdef USE_UNIFORM_BUFFERS
  // Convert mat4 to mat3 for vec3 multiplication
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 final = transformMat3 * vec3(p, 1);
  #else
  vec3 final = transformationMatrix * vec3(p, 1);
  #endif

  vec4 pSize = texture(pointSize, textureCoords);
  float size = pSize.r * sizeScale;

  float left = 2.0 * (selection0.x - 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
  float right = 2.0 * (selection1.x + 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
  float top =  2.0 * (selection0.y - 0.5 * pointSizeF(size)) / screenSize.y - 1.0;
  float bottom =  2.0 * (selection1.y + 0.5 * pointSizeF(size)) / screenSize.y - 1.0;

  fragColor = vec4(0.0, 0.0, pointPosition.r, pointPosition.g);
  if (final.x >= left && final.x <= right && final.y >= top && final.y <= bottom) {
    fragColor.r = 1.0;
  }
}

`,WO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D polygonPathTexture; // Texture containing polygon path points

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform findPointsOnPolygonSelectionUniforms {
  float spaceSize;
  vec2 screenSize;
  mat4 transformationMatrix;
  float polygonPathLength;
} findPointsOnPolygonSelection;

#define spaceSize findPointsOnPolygonSelection.spaceSize
#define screenSize findPointsOnPolygonSelection.screenSize
#define transformationMatrix findPointsOnPolygonSelection.transformationMatrix
#define polygonPathLength int(findPointsOnPolygonSelection.polygonPathLength)
#else
uniform int polygonPathLength;
uniform float spaceSize;
uniform vec2 screenSize;
uniform mat3 transformationMatrix;
#endif

in vec2 textureCoords;

out vec4 fragColor;

// Get a point from the polygon path texture at a specific index
vec2 getPolygonPoint(sampler2D pathTexture, int index, int pathLength) {
  if (index >= pathLength) return vec2(0.0);
  
  // Calculate texture coordinates for the index
  int textureSize = int(ceil(sqrt(float(pathLength))));
  int x = index - (index / textureSize) * textureSize;
  int y = index / textureSize;
  
  vec2 texCoord = (vec2(float(x), float(y)) + 0.5) / float(textureSize);
  vec4 pathData = texture(pathTexture, texCoord);
  
  return pathData.xy;
}

// Point-in-polygon algorithm using ray casting
bool pointInPolygon(vec2 point, sampler2D pathTexture, int pathLength) {
  bool inside = false;
  
  for (int i = 0; i < 2048; i++) {
    if (i >= pathLength) break;
    
    int j = int(mod(float(i + 1), float(pathLength)));
    
    vec2 pi = getPolygonPoint(pathTexture, i, pathLength);
    vec2 pj = getPolygonPoint(pathTexture, j, pathLength);
    
    if (((pi.y > point.y) != (pj.y > point.y)) &&
        (point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x)) {
      inside = !inside;
    }
  }
  
  return inside;
}

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
  p *= spaceSize / screenSize;
  #ifdef USE_UNIFORM_BUFFERS
  // Convert mat4 to mat3 for vec3 multiplication
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 final = transformMat3 * vec3(p, 1);
  #else
  vec3 final = transformationMatrix * vec3(p, 1);
  #endif

  // Convert to screen coordinates for polygon check
  vec2 screenPos = (final.xy + 1.0) * screenSize / 2.0;
  
  fragColor = vec4(0.0, 0.0, pointPosition.r, pointPosition.g);
  
  // Check if point center is inside the polygon
  if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) {
    fragColor.r = 1.0;
  }
} `,YO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawHighlightedUniforms {
  float size;
  mat4 transformationMatrix;
  float pointsTextureSize;
  float sizeScale;
  float spaceSize;
  vec2 screenSize;
  float scalePointsOnZoom;
  float pointIndex;
  float maxPointSize;
  vec4 color;
  float universalPointOpacity;
  float greyoutOpacity;
  float isDarkenGreyout;
  vec4 backgroundColor;
  vec4 greyoutColor;
  float width;
} drawHighlighted;

#define width drawHighlighted.width
#else
uniform float width;
#endif

in vec2 vertexPosition;
in float pointOpacity;
in vec3 rgbColor;

out vec4 fragColor;

const float smoothing = 1.05;

void main () {
  float r = dot(vertexPosition, vertexPosition);
  float opacity = smoothstep(r, r * smoothing, 1.0);
  float stroke = smoothstep(width, width * smoothing, r);
  fragColor = vec4(rgbColor, opacity * stroke * pointOpacity);
}`,qO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 vertexCoord;

uniform sampler2D positionsTexture;
uniform sampler2D pointGreyoutStatusTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform drawHighlightedUniforms {
  float size;
  mat4 transformationMatrix;
  float pointsTextureSize;
  float sizeScale;
  float spaceSize;
  vec2 screenSize;
  float scalePointsOnZoom;
  float pointIndex;
  float maxPointSize;
  vec4 color;
  float universalPointOpacity;
  float greyoutOpacity;
  float isDarkenGreyout;
  vec4 backgroundColor;
  vec4 greyoutColor;
  float width;
} drawHighlighted;

#define size drawHighlighted.size
#define transformationMatrix drawHighlighted.transformationMatrix
#define pointsTextureSize drawHighlighted.pointsTextureSize
#define sizeScale drawHighlighted.sizeScale
#define spaceSize drawHighlighted.spaceSize
#define screenSize drawHighlighted.screenSize
#define scalePointsOnZoom drawHighlighted.scalePointsOnZoom
#define pointIndex drawHighlighted.pointIndex
#define maxPointSize drawHighlighted.maxPointSize
#define color drawHighlighted.color
#define universalPointOpacity drawHighlighted.universalPointOpacity
#define greyoutOpacity drawHighlighted.greyoutOpacity
#define isDarkenGreyout drawHighlighted.isDarkenGreyout
#define backgroundColor drawHighlighted.backgroundColor
#define greyoutColor drawHighlighted.greyoutColor
#else
uniform float size;
uniform mat3 transformationMatrix;
uniform float pointsTextureSize;
uniform float sizeScale;
uniform float spaceSize;
uniform vec2 screenSize;
uniform float scalePointsOnZoom;
uniform float pointIndex;
uniform float maxPointSize;
uniform vec4 color;
uniform float universalPointOpacity;
uniform float greyoutOpacity;
uniform float isDarkenGreyout;
uniform vec4 backgroundColor;
uniform vec4 greyoutColor;
uniform float width;
#endif
out vec2 vertexPosition;
out float pointOpacity;
out vec3 rgbColor;

float calculatePointSize(float pointSize) {
  float pSize;

  if (scalePointsOnZoom > 0.0) { 
    pSize = pointSize * transformationMatrix[0][0];
  } else {
    pSize = pointSize * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
  }

  return min(pSize, maxPointSize);
}

const float relativeRingRadius = 1.3;

void main () {
  vertexPosition = vertexCoord;

  vec2 textureCoordinates = vec2(mod(pointIndex, pointsTextureSize), floor(pointIndex / pointsTextureSize)) + 0.5;
  vec4 pointPosition = texture(positionsTexture, textureCoordinates / pointsTextureSize);

  rgbColor = color.rgb;
  pointOpacity = color.a * universalPointOpacity;
  vec4 greyoutStatus = texture(pointGreyoutStatusTexture, textureCoordinates / pointsTextureSize);
  if (greyoutStatus.r > 0.0) {
    if (greyoutColor[0] != -1.0) {
      rgbColor = greyoutColor.rgb;
      pointOpacity = greyoutColor.a;
    } else {
      // If greyoutColor is not set, make color lighter or darker based on isDarkenGreyout
      float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color)
      
      #ifdef USE_UNIFORM_BUFFERS
      if (isDarkenGreyout > 0.0) {
        // Darken the color
        rgbColor = mix(rgbColor, vec3(0.2), blendFactor);
      } else {
        // Lighten the color
        rgbColor = mix(rgbColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
      }
      #else
      if (isDarkenGreyout > 0.0) {
        // Darken the color
        rgbColor = mix(rgbColor, vec3(0.2), blendFactor);
      } else {
        // Lighten the color
        rgbColor = mix(rgbColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
      }
      #endif
    }

    if (greyoutOpacity != -1.0) {
      pointOpacity *= greyoutOpacity;
    }
  }

  // Calculate point radius
  float pointSize = (calculatePointSize(size * sizeScale) * relativeRingRadius) / transformationMatrix[0][0];
  float radius = pointSize * 0.5;

  // Calculate point position in screen space
  vec2 a = pointPosition.xy;
  vec2 b = pointPosition.xy + vec2(0.0, radius);
  vec2 xBasis = b - a;
  vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
  vec2 pointPositionInScreenSpace = a + xBasis * vertexCoord.x + yBasis * radius * vertexCoord.y;

  // Transform point position to normalized device coordinates
  vec2 p = 2.0 * pointPositionInScreenSpace / spaceSize - 1.0;
  p *= spaceSize / screenSize;
  #ifdef USE_UNIFORM_BUFFERS
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 final = transformMat3 * vec3(p, 1);
  #else
  vec3 final = transformationMatrix * vec3(p, 1);
  #endif
  
  gl_Position = vec4(final.rg, 0, 1);
}`,XO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec4 rgba;

out vec4 fragColor;

void main() {
  if (rgba.g <= 0.0) {
    discard;
  }
  fragColor = rgba;
}`,KO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 pointIndices;
in float size;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform findHoveredPointUniforms {
  float pointsTextureSize;
  float sizeScale;
  float spaceSize;
  vec2 screenSize;
  float ratio;
  mat4 transformationMatrix;
  vec2 mousePosition;
  float scalePointsOnZoom;
  float maxPointSize;
} findHoveredPoint;

#define pointsTextureSize findHoveredPoint.pointsTextureSize
#define sizeScale findHoveredPoint.sizeScale
#define spaceSize findHoveredPoint.spaceSize
#define screenSize findHoveredPoint.screenSize
#define ratio findHoveredPoint.ratio
#define transformationMatrix findHoveredPoint.transformationMatrix
#define mousePosition findHoveredPoint.mousePosition
#define scalePointsOnZoom findHoveredPoint.scalePointsOnZoom
#define maxPointSize findHoveredPoint.maxPointSize
#else
uniform float pointsTextureSize;
uniform float sizeScale;
uniform float spaceSize;
uniform vec2 screenSize;
uniform float ratio;
uniform mat3 transformationMatrix;
uniform vec2 mousePosition;
uniform float scalePointsOnZoom;
uniform float maxPointSize;
#endif

out vec4 rgba;

float calculatePointSize(float size) {
  float pSize;

  if (scalePointsOnZoom > 0.0) { 
    pSize = size * ratio * transformationMatrix[0][0];
  } else {
    pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
  }

  return min(pSize, maxPointSize * ratio);
}

float euclideanDistance (float x1, float x2, float y1, float y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

void main() {
  vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
  vec2 point = pointPosition.rg;

  vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0;
  normalizedPosition *= spaceSize / screenSize;
  
  #ifdef USE_UNIFORM_BUFFERS
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 finalPosition = transformMat3 * vec3(normalizedPosition, 1);
  #else
  vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1);
  #endif

  float pointRadius = 0.5 * calculatePointSize(size * sizeScale);
  vec2 pointScreenPosition = (finalPosition.xy + 1.0) * screenSize / 2.0;
  
  rgba = vec4(0.0);
  gl_Position = vec4(0.5, 0.5, 0.0, 1.0);
  
  if (euclideanDistance(pointScreenPosition.x, mousePosition.x, pointScreenPosition.y, mousePosition.y) < pointRadius / ratio) {
    float index = pointIndices.g * pointsTextureSize + pointIndices.r;
    rgba = vec4(index, size, pointPosition.xy);
    gl_Position = vec4(-0.5, -0.5, 0.0, 1.0);
  }

  gl_PointSize = 1.0;
}`,ZO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec4 rgba;

out vec4 fragColor;

void main() {
  fragColor = rgba;
}`,QO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

in vec2 pointIndices;

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform fillSampledPointsUniforms {
  float pointsTextureSize;
  mat4 transformationMatrix;
  float spaceSize;
  vec2 screenSize;
} fillSampledPoints;

#define pointsTextureSize fillSampledPoints.pointsTextureSize
#define transformationMatrix fillSampledPoints.transformationMatrix
#define spaceSize fillSampledPoints.spaceSize
#define screenSize fillSampledPoints.screenSize
#else
uniform float pointsTextureSize;
uniform float spaceSize;
uniform vec2 screenSize;
uniform mat3 transformationMatrix;
#endif

out vec4 rgba;

void main() {
  vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
  vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
  p *= spaceSize / screenSize;
  #ifdef USE_UNIFORM_BUFFERS
  // Convert mat4 to mat3 for vec3 multiplication
  mat3 transformMat3 = mat3(transformationMatrix);
  vec3 final = transformMat3 * vec3(p, 1);
  #else
  vec3 final = transformationMatrix * vec3(p, 1);
  #endif

  vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0;
  float index = pointIndices.g * pointsTextureSize + pointIndices.r;
  rgba = vec4(index, 1.0, pointPosition.xy);
  float i = (pointScreenPosition.x + 0.5) / screenSize.x;
  float j = (pointScreenPosition.y + 0.5) / screenSize.y;
  gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0);

  gl_PointSize = 1.0;
}`,JO=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D velocity;
uniform sampler2D pinnedStatusTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform updatePositionUniforms {
  float friction;
  float spaceSize;
} updatePosition;

#define friction updatePosition.friction
#define spaceSize updatePosition.spaceSize
#else
uniform float friction;
uniform float spaceSize;
#endif

in vec2 textureCoords;

out vec4 fragColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);
  vec4 pointVelocity = texture(velocity, textureCoords);

  // Check if point is pinned
  // pinnedStatusTexture has the same size and layout as positionsTexture
  // Each pixel corresponds to a point: red channel > 0.5 means the point is pinned
  vec4 pinnedStatus = texture(pinnedStatusTexture, textureCoords);
  
  // If pinned, don't update position
  if (pinnedStatus.r > 0.5) {
    fragColor = pointPosition;
    return;
  }

  // Friction
  pointVelocity.rg *= friction;

  pointPosition.rg += pointVelocity.rg;

  pointPosition.r = clamp(pointPosition.r, 0.0, spaceSize);
  pointPosition.g = clamp(pointPosition.g, 0.0, spaceSize);
  
  fragColor = pointPosition;
}`,eF=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;
uniform sampler2D trackedIndices;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform trackPointsUniforms {
  float pointsTextureSize;
} trackPoints;

#define pointsTextureSize trackPoints.pointsTextureSize
#else
uniform float pointsTextureSize;
#endif

in vec2 textureCoords;

out vec4 fragColor;

void main() {
  vec4 trackedPointIndices = texture(trackedIndices, textureCoords);
  if (trackedPointIndices.r < 0.0) discard;
  vec4 pointPosition = texture(positionsTexture, (trackedPointIndices.rg + 0.5) / pointsTextureSize);

  fragColor = vec4(pointPosition.rg, 1.0, 1.0);
}

`,tF=`#version 300 es
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D positionsTexture;

#ifdef USE_UNIFORM_BUFFERS
layout(std140) uniform dragPointUniforms {
  vec2 mousePos;
  float index;
} dragPoint;

#define mousePos dragPoint.mousePos
#define index dragPoint.index
#else
uniform vec2 mousePos;
uniform float index;
#endif

in vec2 textureCoords;

out vec4 fragColor;

void main() {
  vec4 pointPosition = texture(positionsTexture, textureCoords);

  // Check if a point is being dragged
  if (index >= 0.0 && index == pointPosition.b) {
    pointPosition.rg = mousePos.rg;
  }

  fragColor = pointPosition;
}`;function iF(i,e=16384){if(!(i!=null&&i.length))return null;let t=0;for(const c of i){const u=Math.max(c.width,c.height);u>t&&(t=u)}if(t===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const n=t,s=Math.ceil(Math.sqrt(i.length));let r=s*t,o=1;r>e&&(o=e/r,t=Math.max(1,Math.floor(t*o)),r=Math.max(1,Math.floor(r*o)),console.warn(`🖼️  Atlas scaling required: Original size ${(n*s).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${r.toLocaleString()}px (${Math.round(o*100)}% of original quality)`));const a=new Uint8Array(r*r*4).fill(0),l=new Float32Array(s*s*4).fill(-1);for(const[c,u]of i.entries()){const d=u.width,h=u.height;if(d===0||h===0)continue;const p=Math.min(1,t/Math.max(d,h)),m=Math.floor(d*p),y=Math.floor(h*p),g=Math.floor(c/s),_=c%s*t,S=g*t;l[c*4]=_/r,l[c*4+1]=S/r,l[c*4+2]=(_+m)/r,l[c*4+3]=(S+y)/r;for(let E=0;E<y;E++)for(let x=0;x<m;x++){const T=Math.floor(x*(d/m)),I=(Math.floor(E*(h/y))*d+T)*4,O=((S+E)*r+(_+x))*4;a[O]=u.data[I]??0,a[O+1]=u.data[I+1]??0,a[O+2]=u.data[I+2]??0,a[O+3]=u.data[I+3]??255}}return{atlasData:a,atlasSize:r,atlasCoords:l,atlasCoordsSize:s}}class nF extends Zo{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){var e,t,n;const{device:s,store:r,data:o,config:{rescalePositions:a,enableSimulation:l}}=this,{pointsTextureSize:c}=r;if(!c||!o.pointPositions||o.pointsNumber===void 0)return;const u=c*c*4,d=new Float32Array(u),h=c*c*4*4,p=d.byteLength;p!==h&&console.error("Texture data size mismatch:",{pointsTextureSize:c,expectedBytes:h,actualBytes:p,textureDataSize:u,dataLength:d.length});let m=a;a===void 0&&!l&&(m=!0),this.shouldSkipRescale&&(m=!1),m?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let _=0;_<o.pointsNumber;++_)d[_*4+0]=o.pointPositions[_*2+0],d[_*4+1]=o.pointPositions[_*2+1],d[_*4+2]=_;if(!this.currentPositionTexture||this.currentPositionTexture.width!==c||this.currentPositionTexture.height!==c?(this.currentPositionTexture&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&this.currentPositionFbo.destroy(),this.currentPositionTexture=s.createTexture({width:c,height:c,format:"rgba32float"}),this.currentPositionTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.currentPositionFbo=s.createFramebuffer({width:c,height:c,colorAttachments:[this.currentPositionTexture]})):this.currentPositionTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),!this.previousPositionTexture||this.previousPositionTexture.width!==c||this.previousPositionTexture.height!==c?(this.previousPositionTexture&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&this.previousPositionFbo.destroy(),this.previousPositionTexture=s.createTexture({width:c,height:c,format:"rgba32float"}),this.previousPositionTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.previousPositionFbo=s.createFramebuffer({width:c,height:c,colorAttachments:[this.previousPositionTexture]})):this.previousPositionTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.config.enableSimulation){const _=new Float32Array(c*c*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==c||this.velocityTexture.height!==c?(this.velocityTexture&&this.velocityTexture.destroy(),this.velocityFbo&&this.velocityFbo.destroy(),this.velocityTexture=s.createTexture({width:c,height:c,format:"rgba32float"}),this.velocityTexture.copyImageData({data:_,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.velocityFbo=s.createFramebuffer({width:c,height:c,colorAttachments:[this.velocityTexture]})):this.velocityTexture.copyImageData({data:_,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0})}!this.selectedTexture||this.selectedTexture.width!==c||this.selectedTexture.height!==c?(this.selectedTexture&&this.selectedTexture.destroy(),this.selectedFbo&&this.selectedFbo.destroy(),this.selectedTexture=s.createTexture({width:c,height:c,format:"rgba32float"}),this.selectedTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.selectedFbo=s.createFramebuffer({width:c,height:c,colorAttachments:[this.selectedTexture]})):this.selectedTexture.copyImageData({data:d,bytesPerRow:at("rgba32float",c),mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=s.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const y=dp(r.pointsTextureSize),g=y.byteLength;!this.drawPointIndices||this.drawPointIndices.byteLength!==g?((e=this.drawPointIndices)==null||e.destroy(),this.drawPointIndices=s.createBuffer({data:y,usage:me.VERTEX|me.COPY_DST})):this.drawPointIndices.write(y),this.drawCommand&&this.drawCommand.setAttributes({pointIndices:this.drawPointIndices}),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==g?((t=this.hoveredPointIndices)==null||t.destroy(),this.hoveredPointIndices=s.createBuffer({data:y,usage:me.VERTEX|me.COPY_DST})):this.hoveredPointIndices.write(y),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==g?((n=this.sampledPointIndices)==null||n.destroy(),this.sampledPointIndices=s.createBuffer({data:y,usage:me.VERTEX|me.COPY_DST})):this.sampledPointIndices.write(y),this.fillSampledPointsFboCommand&&this.fillSampledPointsFboCommand.setAttributes({pointIndices:this.sampledPointIndices}),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){var e,t,n;const{device:s,config:r,store:o,data:a}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.greyoutStatusTexture||this.updateGreyoutStatus(),r.enableSimulation&&(this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new ai({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:r.simulationFriction??0,spaceSize:o.adjustedSpaceSize??0}}})),this.updatePositionCommand||(this.updatePositionCommand=new ci(s,{fs:JO,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.updatePositionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(s,"updatePositionUniforms")}}))),this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new ai({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:_t(o.mousePosition,[0,0]),index:((e=o.hoveredPoint)==null?void 0:e.index)??-1}}})),this.dragPointCommand||(this.dragPointCommand=new ci(s,{fs:tF,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(s,"dragPointUniforms")}})),this.drawUniformStore||(this.drawUniformStore=new ai({drawVertexUniforms:{uniformTypes:{ratio:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",greyoutColor:"vec4<f32>",backgroundColor:"vec4<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",isDarkenGreyout:"f32",skipSelected:"f32",skipUnselected:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32"},defaultUniforms:{ratio:r.pixelRatio??fe.pixelRatio,transformationMatrix:(()=>{const l=o.transform??[1,0,0,0,1,0,0,0,1];return[l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]})(),pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),greyoutColor:Mi(o.greyoutPointColor,[0,0,0,1]),backgroundColor:Mi(o.backgroundColor,[0,0,0,1]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,maxPointSize:o.maxPointSize??100,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,skipSelected:0,skipUnselected:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>"},defaultUniforms:{greyoutOpacity:r.pointGreyoutOpacity??-1,pointOpacity:r.pointOpacity??1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:Mi(o.backgroundColor,[0,0,0,1])}}})),this.drawCommand||(this.drawCommand=new ci(s,{fs:HO,vs:VO,topology:"point-list",vertexCount:a.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"color",format:"float32x4"},{name:"shape",format:"float32"},{name:"imageIndex",format:"float32"},{name:"imageSize",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(s,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(s,"drawFragmentUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.findPointsOnAreaSelectionVertexCoordBuffer||(this.findPointsOnAreaSelectionVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnAreaSelectionUniformStore||(this.findPointsOnAreaSelectionUniformStore=new ai({findPointsOnAreaSelectionUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",selection0:"vec2<f32>",selection1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),ratio:r.pixelRatio??fe.pixelRatio,transformationMatrix:o.transformationMatrix4x4,selection0:_t((t=o.selectedArea)==null?void 0:t[0],[0,0]),selection1:_t((n=o.selectedArea)==null?void 0:n[1],[0,0]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,maxPointSize:o.maxPointSize??100}}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=new ci(s,{fs:GO,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnAreaSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(s,"findPointsOnAreaSelectionUniforms")}})),this.findPointsOnPolygonSelectionVertexCoordBuffer||(this.findPointsOnPolygonSelectionVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnPolygonSelectionUniformStore||(this.findPointsOnPolygonSelectionUniformStore=new ai({findPointsOnPolygonSelectionUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),transformationMatrix:o.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionCommand=new ci(s,{fs:WO,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnPolygonSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(s,"findPointsOnPolygonSelectionUniforms")}})),this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new ai({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),ratio:r.pixelRatio??fe.pixelRatio,transformationMatrix:o.transformationMatrix4x4,mousePosition:_t(o.screenMousePosition,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,maxPointSize:o.maxPointSize??100}}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=new ci(s,{fs:XO,vs:KO,topology:"point-list",vertexCount:a.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(s,"findHoveredPointUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.fillSampledPointsUniformStore||(this.fillSampledPointsUniformStore=new ai({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0,transformationMatrix:o.transformationMatrix4x4,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0])}}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=new ci(s,{fs:ZO,vs:QO,topology:"point-list",vertexCount:a.pointsNumber??0,attributes:{...this.sampledPointIndices&&{pointIndices:this.sampledPointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(s,"fillSampledPointsUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.drawHighlightedVertexCoordBuffer||(this.drawHighlightedVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.drawHighlightedUniformStore||(this.drawHighlightedUniformStore=new ai({drawHighlightedUniforms:{uniformTypes:{size:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",scalePointsOnZoom:"f32",pointIndex:"f32",maxPointSize:"f32",color:"vec4<f32>",universalPointOpacity:"f32",greyoutOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>",greyoutColor:"vec4<f32>",width:"f32"},defaultUniforms:{size:1,transformationMatrix:o.transformationMatrix4x4,pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,pointIndex:-1,maxPointSize:o.maxPointSize??100,color:[0,0,0,1],universalPointOpacity:r.pointOpacity??1,greyoutOpacity:r.pointGreyoutOpacity??-1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:Mi(o.backgroundColor,[0,0,0,1]),greyoutColor:Mi(o.greyoutPointColor,[0,0,0,1]),width:.85}}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=new ci(s,{fs:YO,vs:qO,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(s,"drawHighlightedUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.trackPointsVertexCoordBuffer||(this.trackPointsVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.trackPointsUniformStore||(this.trackPointsUniformStore=new ai({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0}}})),this.trackPointsCommand||(this.trackPointsCommand=new ci(s,{fs:eF,vs:fs,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.trackPointsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(s,"trackPointsUniforms")}}))}updateColor(){var e;const{device:t,store:{pointsTextureSize:n},data:s}=this;if(!n)return;const r=s.pointColors,o=r.byteLength;!this.colorBuffer||this.colorBuffer.byteLength!==o?((e=this.colorBuffer)==null||e.destroy(),this.colorBuffer=t.createBuffer({data:r,usage:me.VERTEX|me.COPY_DST})):this.colorBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({color:this.colorBuffer})}updateGreyoutStatus(){const{device:e,store:{selectedIndices:t,pointsTextureSize:n}}=this;if(!n)return;const s=new Float32Array(n*n*4).fill(t?1:0);if(t)for(const r of t)s[r*4]=0;!this.greyoutStatusTexture||this.greyoutStatusTexture.width!==n||this.greyoutStatusTexture.height!==n?(this.greyoutStatusTexture&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=e.createTexture({width:n,height:n,format:"rgba32float"}),this.greyoutStatusTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})):this.greyoutStatusTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})}updatePinnedStatus(){const{device:e,store:{pointsTextureSize:t},data:n}=this;if(!t)return;const s=new Float32Array(t*t*4).fill(0);if(n.inputPinnedPoints&&n.pointsNumber!==void 0)for(const r of n.inputPinnedPoints)r>=0&&r<n.pointsNumber&&(s[r*4]=1);!this.pinnedStatusTexture||this.pinnedStatusTexture.width!==t||this.pinnedStatusTexture.height!==t?(this.pinnedStatusTexture&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.pinnedStatusTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",t),mipLevel:0,x:0,y:0})):this.pinnedStatusTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",t),mipLevel:0,x:0,y:0})}updateSize(){var e;const{device:t,store:{pointsTextureSize:n},data:s}=this;if(!n||s.pointsNumber===void 0||s.pointSizes===void 0)return;const r=s.pointSizes,o=r.byteLength;!this.sizeBuffer||this.sizeBuffer.byteLength!==o?((e=this.sizeBuffer)==null||e.destroy(),this.sizeBuffer=t.createBuffer({data:r,usage:me.VERTEX|me.COPY_DST})):this.sizeBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({size:this.sizeBuffer});const a=new Float32Array(n*n*4);for(let l=0;l<s.pointsNumber;l++)a[l*4]=s.pointSizes[l];!this.sizeTexture||this.sizeTexture.width!==n||this.sizeTexture.height!==n?(this.sizeTexture&&this.sizeTexture.destroy(),this.sizeTexture=t.createTexture({width:n,height:n,format:"rgba32float"}),this.sizeTexture.copyImageData({data:a,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})):this.sizeTexture.copyImageData({data:a,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})}updateShape(){var e;const{device:t,data:n}=this;if(n.pointsNumber===void 0||n.pointShapes===void 0)return;const s=n.pointShapes,r=s.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==r?((e=this.shapeBuffer)==null||e.destroy(),this.shapeBuffer=t.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.shapeBuffer.write(s),this.drawCommand&&this.drawCommand.setAttributes({shape:this.shapeBuffer})}updateImageIndices(){var e;const{device:t,data:n}=this;if(n.pointsNumber===void 0||n.pointImageIndices===void 0)return;const s=n.pointImageIndices,r=s.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==r?((e=this.imageIndicesBuffer)==null||e.destroy(),this.imageIndicesBuffer=t.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.imageIndicesBuffer.write(s),this.drawCommand&&this.drawCommand.setAttributes({imageIndex:this.imageIndicesBuffer})}updateImageSizes(){var e;const{device:t,data:n}=this;if(n.pointsNumber===void 0||n.pointImageSizes===void 0)return;const s=n.pointImageSizes,r=s.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==r?((e=this.imageSizesBuffer)==null||e.destroy(),this.imageSizesBuffer=t.createBuffer({data:s,usage:me.VERTEX|me.COPY_DST})):this.imageSizesBuffer.write(s),this.drawCommand&&this.drawCommand.setAttributes({imageSize:this.imageSizesBuffer})}createAtlas(){var e,t,n;const{device:s,data:r,store:o}=this;if(!((e=r.inputImageData)!=null&&e.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=s.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=s.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const a=iF(r.inputImageData,o.webglMaxTextureSize);if(!a){console.warn("Failed to create atlas from image data");return}this.imageCount=r.inputImageData.length;const{atlasData:l,atlasSize:c,atlasCoords:u,atlasCoordsSize:d}=a;this.imageAtlasCoordsTextureSize=d,(t=this.imageAtlasTexture)==null||t.destroy(),this.imageAtlasTexture=s.createTexture({width:c,height:c,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:l,bytesPerRow:at("rgba8unorm",c),rowsPerImage:c,mipLevel:0,x:0,y:0}),(n=this.imageAtlasCoordsTexture)==null||n.destroy(),this.imageAtlasCoordsTexture=s.createTexture({width:d,height:d,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:u,bytesPerRow:at("rgba32float",d),rowsPerImage:d,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},device:n}=this;let s=t??Math.min(...e)/2;s===0&&(s=fe.pointSamplingDistance);const r=Math.ceil(e[0]/s),o=Math.ceil(e[1]/s);(!this.sampledPointsFbo||this.sampledPointsFbo.width!==r||this.sampledPointsFbo.height!==o)&&(this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=n.createFramebuffer({width:r,height:o,colorAttachments:["rgba32float"]}))}trackPoints(){var e;if(!((e=this.trackedIndices)!=null&&e.length)||!this.trackPointsCommand||!this.trackPointsUniformStore||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.trackedIndicesTexture||this.trackedIndicesTexture.destroyed)return;this.trackPointsUniformStore.setUniforms({trackPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0}}),this.trackPointsCommand.setBindings({positionsTexture:this.currentPositionTexture,trackedIndices:this.trackedIndicesTexture});const t=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(t),t.end()}draw(e){var t,n;const{data:s,config:r,store:o}=this;if(this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!s.pointsNumber||s.pointsNumber===0||!o.screenSize||o.screenSize[0]===0||o.screenSize[1]===0)return;this.drawCommand.setVertexCount(s.pointsNumber);const a={ratio:r.pixelRatio??fe.pixelRatio,transformationMatrix:o.transformationMatrix4x4,pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),greyoutColor:Mi(o.greyoutPointColor,[-1,-1,-1,-1]),backgroundColor:Mi(o.backgroundColor,[0,0,0,1]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,maxPointSize:o.maxPointSize??100,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0},l={greyoutOpacity:r.pointGreyoutOpacity??-1,pointOpacity:r.pointOpacity??1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:Mi(o.backgroundColor,[0,0,0,1])};if(o.selectedIndices&&o.selectedIndices.length>0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...a,skipSelected:1,skipUnselected:0},drawFragmentUniforms:l}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...a,skipSelected:0,skipUnselected:1},drawFragmentUniforms:l}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...a,skipSelected:0,skipUnselected:0},drawFragmentUniforms:l}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),r.renderHoveredPointRing&&o.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((t=s.pointSizes)==null?void 0:t[o.hoveredPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:o.transformationMatrix4x4,pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,pointIndex:o.hoveredPoint.index,maxPointSize:o.maxPointSize??100,color:Mi(o.hoveredPointRingColor,[0,0,0,1]),universalPointOpacity:r.pointOpacity??1,greyoutOpacity:r.pointGreyoutOpacity??-1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:Mi(o.backgroundColor,[0,0,0,1]),greyoutColor:Mi(o.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}if(o.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((n=s.pointSizes)==null?void 0:n[o.focusedPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:o.transformationMatrix4x4,pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale??1,spaceSize:o.adjustedSpaceSize??0,screenSize:_t(o.screenSize,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom??!0?1:0,pointIndex:o.focusedPoint.index,maxPointSize:o.maxPointSize??100,color:Mi(o.focusedPointRingColor,[0,0,0,1]),universalPointOpacity:r.pointOpacity??1,greyoutOpacity:r.pointGreyoutOpacity??-1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:Mi(o.backgroundColor,[0,0,0,1]),greyoutColor:Mi(o.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}}updatePosition(){if(!this.updatePositionCommand||!this.updatePositionUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.velocityTexture||this.velocityTexture.destroyed||!this.pinnedStatusTexture||this.pinnedStatusTexture.destroyed)return;this.updatePositionUniformStore.setUniforms({updatePositionUniforms:{friction:this.config.simulationFriction??0,spaceSize:this.store.adjustedSpaceSize??0}}),this.updatePositionCommand.setBindings({positionsTexture:this.previousPositionTexture,velocity:this.velocityTexture,pinnedStatusTexture:this.pinnedStatusTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.updatePositionCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var e;if(!this.dragPointCommand||!this.dragPointUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed)return;this.dragPointUniformStore.setUniforms({dragPointUniforms:{mousePos:_t(this.store.mousePosition,[0,0]),index:((e=this.store.hoveredPoint)==null?void 0:e.index)??-1}}),this.dragPointCommand.setBindings({positionsTexture:this.previousPositionTexture});const t=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(t),t.end(),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var e,t;if(!this.findPointsOnAreaSelectionCommand||!this.findPointsOnAreaSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return;this.findPointsOnAreaSelectionUniformStore.setUniforms({findPointsOnAreaSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:_t(this.store.screenSize,[0,0]),sizeScale:this.config.pointSizeScale??1,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio??fe.pixelRatio,selection0:_t((e=this.store.selectedArea)==null?void 0:e[0],[0,0]),selection1:_t((t=this.store.selectedArea)==null?void 0:t[1],[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,maxPointSize:this.store.maxPointSize??100}}),this.findPointsOnAreaSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const n=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnAreaSelectionCommand.draw(n),n.end()}findPointsOnPolygonSelection(){if(!this.findPointsOnPolygonSelectionCommand||!this.findPointsOnPolygonSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return;this.findPointsOnPolygonSelectionUniformStore.setUniforms({findPointsOnPolygonSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:_t(this.store.screenSize,[0,0]),transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsOnPolygonSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnPolygonSelectionCommand.draw(e),e.end()}updatePolygonPath(e){const{device:t}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0;return}const n=Math.ceil(Math.sqrt(e.length)),s=new Float32Array(n*n*4);for(const[r,o]of e.entries()){const[a,l]=o;s[r*4]=a,s[r*4+1]=l,s[r*4+2]=0,s[r*4+3]=0}!this.polygonPathTexture||this.polygonPathTexture.width!==n||this.polygonPathTexture.height!==n?(this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=t.createTexture({width:n,height:n,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})):this.polygonPathTexture.copyImageData({data:s,bytesPerRow:at("rgba32float",n),mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed||!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed)return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}}),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{ratio:this.config.pixelRatio??fe.pixelRatio,sizeScale:this.config.pointSizeScale??1,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:_t(this.store.screenSize,[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,mousePosition:_t(this.store.screenMousePosition,[0,0]),maxPointSize:this.store.maxPointSize??100}}),this.findHoveredPointCommand.setBindings({positionsTexture:this.currentPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.hoveredFbo,clearColor:[0,0,0,0]});this.findHoveredPointCommand.draw(e),e.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:t},device:n}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!t)return;const s=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(s*s*4).fill(-1);for(const[o,a]of e.entries())a!==void 0&&(r[o*4]=a%t,r[o*4+1]=Math.floor(a/t),r[o*4+2]=0,r[o*4+3]=0);!this.trackedIndicesTexture||this.trackedIndicesTexture.width!==s||this.trackedIndicesTexture.height!==s?(this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=n.createTexture({width:s,height:s,format:"rgba32float"}),this.trackedIndicesTexture.copyImageData({data:r,bytesPerRow:at("rgba32float",s),mipLevel:0,x:0,y:0})):this.trackedIndicesTexture.copyImageData({data:r,bytesPerRow:at("rgba32float",s),mipLevel:0,x:0,y:0}),(!this.trackedPositionsFbo||this.trackedPositionsFbo.width!==s||this.trackedPositionsFbo.height!==s)&&(this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=n.createFramebuffer({width:s,height:s,colorAttachments:["rgba32float"]})),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:t}}=this;if((!e||!t)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const n=jn(this.device,this.trackedPositionsFbo),s=new Map;for(let r=0;r<n.length/4;r+=1){const o=n[r*4],a=n[r*4+1],l=this.trackedIndices[r];o!==void 0&&a!==void 0&&l!==void 0&&s.set(l,[o,a])}return(!e||!t)&&(this.trackedPositions=s,this.isPositionsUpToDate=!0),s}getSampledPointPositionsMap(){const e=new Map;if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return e;if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return e;this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:_t(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const n=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(n),n.end()}const t=jn(this.device,this.sampledPointsFbo);for(let n=0;n<t.length/4;n++){const s=t[n*4],r=!!t[n*4+1],o=t[n*4+2],a=t[n*4+3];r&&s!==void 0&&o!==void 0&&a!==void 0&&e.set(s,[o,a])}return e}getSampledPoints(){const e=[],t=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:t};if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:t};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:_t(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const s=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(s),s.end()}const n=jn(this.device,this.sampledPointsFbo);for(let s=0;s<n.length/4;s++){const r=n[s*4],o=!!n[s*4+1],a=n[s*4+2],l=n[s*4+3];o&&r!==void 0&&a!==void 0&&l!==void 0&&(e.push(r),t.push(a,l))}return{indices:e,positions:t}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const t=jn(this.device,this.trackedPositionsFbo);for(let n=0;n<t.length/4;n+=1){const s=t[n*4],r=t[n*4+1],o=this.trackedIndices[n];s!==void 0&&r!==void 0&&o!==void 0&&(e[n*2]=s,e[n*2+1]=r)}return e}destroy(){var e,t,n,s,r,o,a,l,c,u,d,h,p,m,y,g,_,S;(e=this.drawCommand)==null||e.destroy(),this.drawCommand=void 0,(t=this.drawHighlightedCommand)==null||t.destroy(),this.drawHighlightedCommand=void 0,(n=this.updatePositionCommand)==null||n.destroy(),this.updatePositionCommand=void 0,(s=this.dragPointCommand)==null||s.destroy(),this.dragPointCommand=void 0,(r=this.findPointsOnAreaSelectionCommand)==null||r.destroy(),this.findPointsOnAreaSelectionCommand=void 0,(o=this.findPointsOnPolygonSelectionCommand)==null||o.destroy(),this.findPointsOnPolygonSelectionCommand=void 0,(a=this.findHoveredPointCommand)==null||a.destroy(),this.findHoveredPointCommand=void 0,(l=this.fillSampledPointsFboCommand)==null||l.destroy(),this.fillSampledPointsFboCommand=void 0,(c=this.trackPointsCommand)==null||c.destroy(),this.trackPointsCommand=void 0,this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionFbo=void 0,this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedFbo=void 0,this.hoveredFbo&&!this.hoveredFbo.destroyed&&this.hoveredFbo.destroy(),this.hoveredFbo=void 0,this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=void 0,this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=void 0,this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionTexture=void 0,this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedTexture=void 0,this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=void 0,this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=void 0,this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=void 0,this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=void 0,this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=void 0,(u=this.updatePositionUniformStore)==null||u.destroy(),this.updatePositionUniformStore=void 0,(d=this.dragPointUniformStore)==null||d.destroy(),this.dragPointUniformStore=void 0,(h=this.drawUniformStore)==null||h.destroy(),this.drawUniformStore=void 0,(p=this.findPointsOnAreaSelectionUniformStore)==null||p.destroy(),this.findPointsOnAreaSelectionUniformStore=void 0,(m=this.findPointsOnPolygonSelectionUniformStore)==null||m.destroy(),this.findPointsOnPolygonSelectionUniformStore=void 0,(y=this.findHoveredPointUniformStore)==null||y.destroy(),this.findHoveredPointUniformStore=void 0,(g=this.fillSampledPointsUniformStore)==null||g.destroy(),this.fillSampledPointsUniformStore=void 0,(_=this.drawHighlightedUniformStore)==null||_.destroy(),this.drawHighlightedUniformStore=void 0,(S=this.trackPointsUniformStore)==null||S.destroy(),this.trackPointsUniformStore=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=void 0,this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=void 0,this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=void 0,this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=void 0,this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=void 0,this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=void 0,this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsOnAreaSelectionVertexCoordBuffer&&!this.findPointsOnAreaSelectionVertexCoordBuffer.destroyed&&this.findPointsOnAreaSelectionVertexCoordBuffer.destroy(),this.findPointsOnAreaSelectionVertexCoordBuffer=void 0,this.findPointsOnPolygonSelectionVertexCoordBuffer&&!this.findPointsOnPolygonSelectionVertexCoordBuffer.destroyed&&this.findPointsOnPolygonSelectionVertexCoordBuffer.destroy(),this.findPointsOnPolygonSelectionVertexCoordBuffer=void 0,this.drawHighlightedVertexCoordBuffer&&!this.drawHighlightedVertexCoordBuffer.destroyed&&this.drawHighlightedVertexCoordBuffer.destroy(),this.drawHighlightedVertexCoordBuffer=void 0,this.trackPointsVertexCoordBuffer&&!this.trackPointsVertexCoordBuffer.destroyed&&this.trackPointsVertexCoordBuffer.destroy(),this.trackPointsVertexCoordBuffer=void 0}swapFbo(){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionFbo||this.previousPositionFbo.destroyed)return;const e=this.previousPositionTexture,t=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=t}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,n=t.length/2;let s=1/0,r=-1/0,o=1/0,a=-1/0;for(let y=0;y<t.length;y+=2){const g=t[y],_=t[y+1];s=Math.min(s,g),r=Math.max(r,g),o=Math.min(o,_),a=Math.max(a,_)}const l=r-s,c=a-o,u=Math.max(l,c);if(u>e){this.scaleX=void 0,this.scaleY=void 0;return}const d=e*e*.001,h=(n>d?e*Math.max(1.2,Math.sqrt(n)/e):e*.1)/u,p=(u-l)/2*h,m=(u-c)/2*h;this.scaleX=y=>(y-s)*h+p,this.scaleY=y=>(y-o)*h+m;for(let y=0;y<n;y++)this.data.pointPositions[y*2]=this.scaleX(t[y*2]),this.data.pointPositions[y*2+1]=this.scaleY(t[y*2+1])}}var Ux=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});function sF(){var i=new Ux(9);return Ux!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[5]=0,i[6]=0,i[7]=0),i[0]=1,i[4]=1,i[8]=1,i}function $x(i,e,t){var n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=t[0],p=t[1];return i[0]=n,i[1]=s,i[2]=r,i[3]=o,i[4]=a,i[5]=l,i[6]=h*n+p*o+c,i[7]=h*s+p*a+u,i[8]=h*r+p*l+d,i}function mm(i,e,t){var n=t[0],s=t[1];return i[0]=n*e[0],i[1]=n*e[1],i[2]=n*e[2],i[3]=s*e[3],i[4]=s*e[4],i[5]=s*e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i}function rF(i,e,t){return i[0]=2/e,i[1]=0,i[2]=0,i[3]=0,i[4]=-2/t,i[5]=0,i[6]=-1,i[7]=1,i[8]=1,i}var Vg={exports:{}},oF=Vg.exports,jx;function aF(){return jx||(jx=1,(function(i){(function(e,t,n){function s(l){var c=this,u=a();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(l),c.s0<0&&(c.s0+=1),c.s1-=u(l),c.s1<0&&(c.s1+=1),c.s2-=u(l),c.s2<0&&(c.s2+=1),u=null}function r(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var u=new s(l),d=c&&c.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d=="object"&&r(d,u),h.state=function(){return r(u,{})}),h}function a(){var l=4022871197,c=function(u){u=String(u);for(var d=0;d<u.length;d++){l+=u.charCodeAt(d);var h=.02519603282416938*l;l=h>>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=o:this.alea=o})(oF,i)})(Vg)),Vg.exports}var Gg={exports:{}},lF=Gg.exports,Hx;function cF(){return Hx||(Hx=1,(function(i){(function(e,t,n){function s(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var d=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^d^d>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,l.next()}function r(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l}function o(a,l){var c=new s(a),u=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,p=(c.next()>>>0)/4294967296,m=(h+p)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&r(u,c),d.state=function(){return r(c,{})}),d}t&&t.exports?t.exports=o:this.xor128=o})(lF,i)})(Gg)),Gg.exports}var Wg={exports:{}},uF=Wg.exports,Vx;function dF(){return Vx||(Vx=1,(function(i){(function(e,t,n){function s(a){var l=this,c="";l.next=function(){var d=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(d^d<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,u==c.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function r(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function o(a,l){var c=new s(a),u=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,p=(c.next()>>>0)/4294967296,m=(h+p)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&r(u,c),d.state=function(){return r(c,{})}),d}t&&t.exports?t.exports=o:this.xorwow=o})(uF,i)})(Wg)),Wg.exports}var Yg={exports:{}},hF=Yg.exports,Gx;function fF(){return Gx||(Gx=1,(function(i){(function(e,t,n){function s(a){var l=this;l.next=function(){var u=l.x,d=l.i,h,p;return h=u[d],h^=h>>>7,p=h^h<<24,h=u[d+1&7],p^=h^h>>>10,h=u[d+3&7],p^=h^h>>>3,h=u[d+4&7],p^=h^h<<7,h=u[d+7&7],h=h^h<<13,p^=h^h<<9,u[d]=p,l.i=d+1&7,p};function c(u,d){var h,p=[];if(d===(d|0))p[0]=d;else for(d=""+d,h=0;h<d.length;++h)p[h&7]=p[h&7]<<15^d.charCodeAt(h)+p[h+1&7]<<13;for(;p.length<8;)p.push(0);for(h=0;h<8&&p[h]===0;++h);for(h==8?p[7]=-1:p[h],u.x=p,u.i=0,h=256;h>0;--h)u.next()}c(l,a)}function r(a,l){return l.x=a.x.slice(),l.i=a.i,l}function o(a,l){a==null&&(a=+new Date);var c=new s(a),u=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,p=(c.next()>>>0)/4294967296,m=(h+p)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,u&&(u.x&&r(u,c),d.state=function(){return r(c,{})}),d}t&&t.exports?t.exports=o:this.xorshift7=o})(hF,i)})(Yg)),Yg.exports}var qg={exports:{}},pF=qg.exports,Wx;function mF(){return Wx||(Wx=1,(function(i){(function(e,t,n){function s(a){var l=this;l.next=function(){var u=l.w,d=l.X,h=l.i,p,m;return l.w=u=u+1640531527|0,m=d[h+34&127],p=d[h=h+1&127],m^=m<<13,p^=p<<17,m^=m>>>15,p^=p>>>12,m=d[h]=m^p,l.i=h,m+(u^u>>>16)|0};function c(u,d){var h,p,m,y,g,_=[],S=128;for(d===(d|0)?(p=d,d=null):(d=d+"\0",p=0,S=Math.max(S,d.length)),m=0,y=-32;y<S;++y)d&&(p^=d.charCodeAt((y+32)%d.length)),y===0&&(g=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,y>=0&&(g=g+1640531527|0,h=_[y&127]^=p+g,m=h==0?m+1:0);for(m>=128&&(_[(d&&d.length||0)&127]=-1),m=127,y=512;y>0;--y)p=_[m+34&127],h=_[m=m+1&127],p^=p<<13,h^=h<<17,p^=p>>>15,h^=h>>>12,_[m]=p^h;u.w=g,u.X=_,u.i=m}c(l,a)}function r(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function o(a,l){a==null&&(a=+new Date);var c=new s(a),u=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,p=(c.next()>>>0)/4294967296,m=(h+p)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,u&&(u.X&&r(u,c),d.state=function(){return r(c,{})}),d}t&&t.exports?t.exports=o:this.xor4096=o})(pF,i)})(qg)),qg.exports}var Xg={exports:{}},gF=Xg.exports,Yx;function _F(){return Yx||(Yx=1,(function(i){(function(e,t,n){function s(a){var l=this,c="";l.next=function(){var d=l.b,h=l.c,p=l.d,m=l.a;return d=d<<25^d>>>7^h,h=h-p|0,p=p<<24^p>>>8^m,m=m-d|0,l.b=d=d<<20^d>>>12^h,l.c=h=h-p|0,l.d=p<<16^h>>>16^m,l.a=m-d|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u<c.length+20;u++)l.b^=c.charCodeAt(u)|0,l.next()}function r(a,l){return l.a=a.a,l.b=a.b,l.c=a.c,l.d=a.d,l}function o(a,l){var c=new s(a),u=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,p=(c.next()>>>0)/4294967296,m=(h+p)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&r(u,c),d.state=function(){return r(c,{})}),d}t&&t.exports?t.exports=o:this.tychei=o})(gF,i)})(Xg)),Xg.exports}var Kg={exports:{}};const yF={},bF=Object.freeze(Object.defineProperty({__proto__:null,default:yF},Symbol.toStringTag,{value:"Module"})),vF=tO(bF);var xF=Kg.exports,qx;function wF(){return qx||(qx=1,(function(i){(function(e,t,n){var s=256,r=6,o=52,a="random",l=n.pow(s,r),c=n.pow(2,o),u=c*2,d=s-1,h;function p(x,T,I){var O=[];T=T==!0?{entropy:!0}:T||{};var H=_(g(T.entropy?[x,E(t)]:x??S(),3),O),Q=new m(O),re=function(){for(var D=Q.g(r),de=l,se=0;D<c;)D=(D+se)*s,de*=s,se=Q.g(1);for(;D>=u;)D/=2,de/=2,se>>>=1;return(D+se)/de};return re.int32=function(){return Q.g(4)|0},re.quick=function(){return Q.g(4)/4294967296},re.double=re,_(E(Q.S),t),(T.pass||I||function(D,de,se,R){return R&&(R.S&&y(R,Q),D.state=function(){return y(Q,{})}),se?(n[a]=D,de):D})(re,H,"global"in T?T.global:this==n,T.state)}function m(x){var T,I=x.length,O=this,H=0,Q=O.i=O.j=0,re=O.S=[];for(I||(x=[I++]);H<s;)re[H]=H++;for(H=0;H<s;H++)re[H]=re[Q=d&Q+x[H%I]+(T=re[H])],re[Q]=T;(O.g=function(D){for(var de,se=0,R=O.i,ee=O.j,F=O.S;D--;)de=F[R=d&R+1],se=se*s+F[d&(F[R]=F[ee=d&ee+de])+(F[ee]=de)];return O.i=R,O.j=ee,se})(s)}function y(x,T){return T.i=x.i,T.j=x.j,T.S=x.S.slice(),T}function g(x,T){var I=[],O=typeof x,H;if(T&&O=="object")for(H in x)try{I.push(g(x[H],T-1))}catch{}return I.length?I:O=="string"?x:x+"\0"}function _(x,T){for(var I=x+"",O,H=0;H<I.length;)T[d&H]=d&(O^=T[d&H]*19)+I.charCodeAt(H++);return E(T)}function S(){try{var x;return h&&(x=h.randomBytes)?x=x(s):(x=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(x)),E(x)}catch{var T=e.navigator,I=T&&T.plugins;return[+new Date,e,I,e.screen,E(t)]}}function E(x){return String.fromCharCode.apply(0,x)}if(_(n.random(),t),i.exports){i.exports=p;try{h=vF}catch{}}else n["seed"+a]=p})(typeof self<"u"?self:xF,[],Math)})(Kg)),Kg.exports}var gm,Xx;function SF(){if(Xx)return gm;Xx=1;var i=aF(),e=cF(),t=dF(),n=fF(),s=mF(),r=_F(),o=wF();return o.alea=i,o.xor128=e,o.xorwow=t,o.xorshift7=n,o.xor4096=s,o.tychei=r,gm=o,gm}var EF=SF();const CF=kE(EF);function TF(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,AF(n.key),n)}}function Ry(i,e,t){return e&&TF(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function FE(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,Zg(i,e)}function Zg(i,e){return Zg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Zg(i,e)}function kF(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function AF(i){var e=kF(i,"string");return typeof e=="symbol"?e:String(e)}var hp=(function(){function i(){}var e=i.prototype;return e._seed=function(t,n){if(t===(t||0))return t;for(var s=""+t,r=0,o=0;o<s.length;++o)r^=s.charCodeAt(o)|0;return r},i})(),Kx=(function(i){FE(e,i);function e(n,s){var r;return r=i.call(this)||this,r._rng=void 0,r.seed(n,s),r}var t=e.prototype;return t.next=function(){return this._rng()},t.seed=function(n,s){this._rng=n},t.clone=function(n,s){return new e(this._rng,s)},Ry(e,[{key:"name",get:function(){return"function"}}]),e})(hp),Zx=function(){var i=[].slice.call(arguments),e=i,t=e[0],n=t===void 0?"default":t;switch(typeof n){case"object":if(n instanceof hp)return n;break;case"function":return new Kx(n);case"number":case"string":default:return new Kx(CF.apply(void 0,i))}throw new Error('invalid RNG "'+n+'"')},IF=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){return i.next()*(t-e)+e}};function Vs(i){return new LF(i)}var LF=function(i){var e=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(e.n))return e;throw new Error("Expected number to be an integer, got "+e.n)},this.isPositive=function(){if(e.n>0)return e;throw new Error("Expected number to be positive, got "+e.n)},this.lessThan=function(t){if(e.n<t)return e;throw new Error("Expected number to be less than "+t+", got "+e.n)},this.greaterThanOrEqual=function(t){if(e.n>=t)return e;throw new Error("Expected number to be greater than or equal to "+t+", got "+e.n)},this.greaterThan=function(t){if(e.n>t)return e;throw new Error("Expected number to be greater than "+t+", got "+e.n)},this.n=i},RF=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),t===void 0&&(t=e===void 0?1:e,e=0),Vs(e).isInt(),Vs(t).isInt(),function(){return Math.floor(i.next()*(t-e+1)+e)}},PF=function(i){return function(){return i.next()>=.5}},NF=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){var n,s,r;do n=i.next()*2-1,s=i.next()*2-1,r=n*n+s*s;while(!r||r>1);return e+t*s*Math.sqrt(-2*Math.log(r)/r)}},DF=function(i,e,t){e===void 0&&(e=0),t===void 0&&(t=1);var n=i.normal(e,t);return function(){return Math.exp(n())}},MF=function(i,e){return e===void 0&&(e=.5),Vs(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(i.next()+e)}},BF=function(i,e,t){return e===void 0&&(e=1),t===void 0&&(t=.5),Vs(e).isInt().isPositive(),Vs(t).greaterThanOrEqual(0).lessThan(1),function(){for(var n=0,s=0;n++<e;)i.next()<t&&s++;return s}},OF=function(i,e){e===void 0&&(e=.5),Vs(e).greaterThan(0).lessThan(1);var t=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(i.next())*t)}},FF=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],zF=function(i){return FF[i]},UF=.9189385332046727,$F=function(i,e){if(e===void 0&&(e=1),Vs(e).isPositive(),e<10){var t=Math.exp(-e);return function(){for(var l=t,c=0,u=i.next();u>l;)u=u-l,l=e*l/++c;return c}}else{var n=Math.sqrt(e),s=.931+2.53*n,r=-.059+.02483*s,o=1.1239+1.1328/(s-3.4),a=.9277-3.6224/(s-2);return function(){for(;;){var l=void 0,c=i.next();if(c<=.86*a)return l=c/a-.43,Math.floor((2*r/(.5-Math.abs(l))+s)*l+e+.445);c>=a?l=i.next()-.5:(l=c/a-.93,l=(l<0?-.5:.5)-l,c=i.next()*a);var u=.5-Math.abs(l);if(!(u<.013&&c>u)){var d=Math.floor((2*r/u+s)*l+e+.445);if(c=c*o/(r/(u*u)+s),d>=10){var h=(d+.5)*Math.log(e/d)-e-UF+d-(.08333333333333333-(.002777777777777778-1/(1260*d*d))/(d*d))/d;if(Math.log(c*n)<=h)return d}else if(d>=0){var p,m=(p=zF(d))!=null?p:0;if(Math.log(c)<=d*Math.log(e)-e-m)return d}}}}}},jF=function(i,e){return e===void 0&&(e=1),Vs(e).isPositive(),function(){return-Math.log(1-i.next())/e}},HF=function(i,e){return e===void 0&&(e=1),Vs(e).isInt().greaterThanOrEqual(0),function(){for(var t=0,n=0;n<e;++n)t+=i.next();return t}},VF=function(i,e){e===void 0&&(e=1),Vs(e).isInt().isPositive();var t=i.irwinHall(e);return function(){return t()/e}},GF=function(i,e){e===void 0&&(e=1),Vs(e).greaterThanOrEqual(0);var t=1/e;return function(){return 1/Math.pow(1-i.next(),t)}},WF=(function(i){FE(e,i);function e(){return i.apply(this,arguments)||this}var t=e.prototype;return t.next=function(){return Math.random()},t.seed=function(n,s){},t.clone=function(){return new e},Ry(e,[{key:"name",get:function(){return"default"}}]),e})(hp),zE=(function(){function i(t){var n=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return n._rng.next()},this.float=function(s,r){return n.uniform(s,r)()},this.int=function(s,r){return n.uniformInt(s,r)()},this.integer=function(s,r){return n.uniformInt(s,r)()},this.bool=function(){return n.uniformBoolean()()},this.boolean=function(){return n.uniformBoolean()()},this.uniform=function(s,r){return n._memoize("uniform",IF,s,r)},this.uniformInt=function(s,r){return n._memoize("uniformInt",RF,s,r)},this.uniformBoolean=function(){return n._memoize("uniformBoolean",PF)},this.normal=function(s,r){return NF(n,s,r)},this.logNormal=function(s,r){return DF(n,s,r)},this.bernoulli=function(s){return MF(n,s)},this.binomial=function(s,r){return BF(n,s,r)},this.geometric=function(s){return OF(n,s)},this.poisson=function(s){return $F(n,s)},this.exponential=function(s){return jF(n,s)},this.irwinHall=function(s){return HF(n,s)},this.bates=function(s){return VF(n,s)},this.pareto=function(s){return GF(n,s)},t&&t instanceof hp?this.use(t):this.use(new WF),this._cache={}}var e=i.prototype;return e.clone=function(){var t=[].slice.call(arguments);return t.length?new i(Zx.apply(void 0,t)):new i(this.rng.clone())},e.use=function(){this._rng=Zx.apply(void 0,[].slice.call(arguments))},e.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},e.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},e.choice=function(t){if(!Array.isArray(t))throw new Error("Random.choice expected input to be an array, got "+typeof t);var n=t==null?void 0:t.length;if(n>0){var s=this.uniformInt(0,n-1)();return t[s]}else return},e._memoize=function(t,n){var s=[].slice.call(arguments,2),r=""+s.join(";"),o=this._cache[t];return(o===void 0||o.key!==r)&&(o={key:r,distribution:n.apply(void 0,[this].concat(s))},this._cache[t]=o),o.distribution},Ry(i,[{key:"rng",get:function(){return this._rng}}]),i})();new zE;const Qg=.001,Jg=64,YF=4;class qF{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=sF(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=Jg,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=fe.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,MD],this.focusedPointRingColor=[1,1,1,BD],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=Hg(),this.scalePointY=Hg(),this.random=new zE,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Qg,1/e)}get backgroundColor(){return this._backgroundColor}get transformationMatrix4x4(){const e=this.transform;if(e.length!==9)throw new Error(`Transform must be a 9-element array (3x3 matrix), got ${e.length} elements`);return[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]}set backgroundColor(e){this._backgroundColor=e;const t=cM(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",t>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",t>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=t<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,t){return this.random.float(e,t)}adjustSpaceSize(e,t){(e<=0||!isFinite(e))&&(console.error(`Invalid spaceSize value: ${e}. Using default value of ${fe.spaceSize}`),e=fe.spaceSize);const n=2;e<n&&(console.warn(`spaceSize (${e}) is too small. Using minimum value of ${n}`),e=n),e>=t?(this.adjustedSpaceSize=Math.max(t/2,n),console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}setWebGLMaxTextureSize(e){this.webglMaxTextureSize=e}updateScreenSize(e,t){const{adjustedSpaceSize:n}=this;this.screenSize=[e,t],this.scalePointX.domain([0,n]).range([(e-n)/2,(e+n)/2]),this.scalePointY.domain([n,0]).range([(t-n)/2,(t+n)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=Oo(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=Oo(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const t=Oo(e);this.greyoutPointColor[0]=t[0],this.greyoutPointColor[1]=t[1],this.greyoutPointColor[2]=t[2],this.greyoutPointColor[3]=t[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const t=Oo(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const XF={passive:!1},mu={capture:!0,passive:!1};function _m(i){i.stopImmediatePropagation()}function ul(i){i.preventDefault(),i.stopImmediatePropagation()}function UE(i){var e=i.document.documentElement,t=wi(i).on("dragstart.drag",ul,mu);"onselectstart"in e?t.on("selectstart.drag",ul,mu):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function $E(i,e){var t=i.document.documentElement,n=wi(i).on("dragstart.drag",null);e&&(n.on("click.drag",ul,mu),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const Id=i=>()=>i;function e_(i,{sourceEvent:e,subject:t,target:n,identifier:s,active:r,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:i,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}e_.prototype.on=function(){var i=this._.on.apply(this._,arguments);return i===this._?this:i};function KF(i){return!i.ctrlKey&&!i.button}function ZF(){return this.parentNode}function QF(i,e){return e??{x:i.x,y:i.y}}function JF(){return navigator.maxTouchPoints||"ontouchstart"in this}function e6(){var i=KF,e=ZF,t=QF,n=JF,s={},r=ap("start","drag","end"),o=0,a,l,c,u,d=0;function h(x){x.on("mousedown.drag",p).filter(n).on("touchstart.drag",g).on("touchmove.drag",_,XF).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(x,T){if(!(u||!i.call(this,x,T))){var I=E(this,e.call(this,x,T),x,T,"mouse");I&&(wi(x.view).on("mousemove.drag",m,mu).on("mouseup.drag",y,mu),UE(x.view),_m(x),c=!1,a=x.clientX,l=x.clientY,I("start",x))}}function m(x){if(ul(x),!c){var T=x.clientX-a,I=x.clientY-l;c=T*T+I*I>d}s.mouse("drag",x)}function y(x){wi(x.view).on("mousemove.drag mouseup.drag",null),$E(x.view,c),ul(x),s.mouse("end",x)}function g(x,T){if(i.call(this,x,T)){var I=x.changedTouches,O=e.call(this,x,T),H=I.length,Q,re;for(Q=0;Q<H;++Q)(re=E(this,O,x,T,I[Q].identifier,I[Q]))&&(_m(x),re("start",x,I[Q]))}}function _(x){var T=x.changedTouches,I=T.length,O,H;for(O=0;O<I;++O)(H=s[T[O].identifier])&&(ul(x),H("drag",x,T[O]))}function S(x){var T=x.changedTouches,I=T.length,O,H;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),O=0;O<I;++O)(H=s[T[O].identifier])&&(_m(x),H("end",x,T[O]))}function E(x,T,I,O,H,Q){var re=r.copy(),D=Yr(Q||I,T),de,se,R;if((R=t.call(x,new e_("beforestart",{sourceEvent:I,target:h,identifier:H,active:o,x:D[0],y:D[1],dx:0,dy:0,dispatch:re}),O))!=null)return de=R.x-D[0]||0,se=R.y-D[1]||0,function ee(F,q,te){var Z=D,ae;switch(F){case"start":s[H]=ee,ae=o++;break;case"end":delete s[H],--o;case"drag":D=Yr(te||q,T),ae=o;break}re.call(F,x,new e_(F,{sourceEvent:q,subject:R,target:h,identifier:H,active:ae,x:D[0]+de,y:D[1]+se,dx:D[0]-Z[0],dy:D[1]-Z[1],dispatch:re}),O)}}return h.filter=function(x){return arguments.length?(i=typeof x=="function"?x:Id(!!x),h):i},h.container=function(x){return arguments.length?(e=typeof x=="function"?x:Id(x),h):e},h.subject=function(x){return arguments.length?(t=typeof x=="function"?x:Id(x),h):t},h.touchable=function(x){return arguments.length?(n=typeof x=="function"?x:Id(!!x),h):n},h.on=function(){var x=r.on.apply(r,arguments);return x===r?h:x},h.clickDistance=function(x){return arguments.length?(d=(x=+x)*x,h):Math.sqrt(d)},h}const Ld=i=>()=>i;function t6(i,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:i,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function so(i,e,t){this.k=i,this.x=e,this.y=t}so.prototype={constructor:so,scale:function(i){return i===1?this:new so(this.k*i,this.x,this.y)},translate:function(i,e){return i===0&e===0?this:new so(this.k,this.x+this.k*i,this.y+this.k*e)},apply:function(i){return[i[0]*this.k+this.x,i[1]*this.k+this.y]},applyX:function(i){return i*this.k+this.x},applyY:function(i){return i*this.k+this.y},invert:function(i){return[(i[0]-this.x)/this.k,(i[1]-this.y)/this.k]},invertX:function(i){return(i-this.x)/this.k},invertY:function(i){return(i-this.y)/this.k},rescaleX:function(i){return i.copy().domain(i.range().map(this.invertX,this).map(i.invert,i))},rescaleY:function(i){return i.copy().domain(i.range().map(this.invertY,this).map(i.invert,i))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var nu=new so(1,0,0);so.prototype;function ym(i){i.stopImmediatePropagation()}function mc(i){i.preventDefault(),i.stopImmediatePropagation()}function i6(i){return(!i.ctrlKey||i.type==="wheel")&&!i.button}function n6(){var i=this;return i instanceof SVGElement?(i=i.ownerSVGElement||i,i.hasAttribute("viewBox")?(i=i.viewBox.baseVal,[[i.x,i.y],[i.x+i.width,i.y+i.height]]):[[0,0],[i.width.baseVal.value,i.height.baseVal.value]]):[[0,0],[i.clientWidth,i.clientHeight]]}function Qx(){return this.__zoom||nu}function s6(i){return-i.deltaY*(i.deltaMode===1?.05:i.deltaMode?1:.002)*(i.ctrlKey?10:1)}function r6(){return navigator.maxTouchPoints||"ontouchstart"in this}function o6(i,e,t){var n=i.invertX(e[0][0])-t[0][0],s=i.invertX(e[1][0])-t[1][0],r=i.invertY(e[0][1])-t[0][1],o=i.invertY(e[1][1])-t[1][1];return i.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o))}function a6(){var i=i6,e=n6,t=o6,n=s6,s=r6,r=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=G5,c=ap("start","zoom","end"),u,d,h,p=500,m=150,y=0,g=10;function _(R){R.property("__zoom",Qx).on("wheel.zoom",H,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",re).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",de).on("touchend.zoom touchcancel.zoom",se).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(R,ee,F,q){var te=R.selection?R.selection():R;te.property("__zoom",Qx),R!==te?T(R,ee,F,q):te.interrupt().each(function(){I(this,arguments).event(q).start().zoom(null,typeof ee=="function"?ee.apply(this,arguments):ee).end()})},_.scaleBy=function(R,ee,F,q){_.scaleTo(R,function(){var te=this.__zoom.k,Z=typeof ee=="function"?ee.apply(this,arguments):ee;return te*Z},F,q)},_.scaleTo=function(R,ee,F,q){_.transform(R,function(){var te=e.apply(this,arguments),Z=this.__zoom,ae=F==null?x(te):typeof F=="function"?F.apply(this,arguments):F,J=Z.invert(ae),Se=typeof ee=="function"?ee.apply(this,arguments):ee;return t(E(S(Z,Se),ae,J),te,o)},F,q)},_.translateBy=function(R,ee,F,q){_.transform(R,function(){return t(this.__zoom.translate(typeof ee=="function"?ee.apply(this,arguments):ee,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,q)},_.translateTo=function(R,ee,F,q,te){_.transform(R,function(){var Z=e.apply(this,arguments),ae=this.__zoom,J=q==null?x(Z):typeof q=="function"?q.apply(this,arguments):q;return t(nu.translate(J[0],J[1]).scale(ae.k).translate(typeof ee=="function"?-ee.apply(this,arguments):-ee,typeof F=="function"?-F.apply(this,arguments):-F),Z,o)},q,te)};function S(R,ee){return ee=Math.max(r[0],Math.min(r[1],ee)),ee===R.k?R:new so(ee,R.x,R.y)}function E(R,ee,F){var q=ee[0]-F[0]*R.k,te=ee[1]-F[1]*R.k;return q===R.x&&te===R.y?R:new so(R.k,q,te)}function x(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function T(R,ee,F,q){R.on("start.zoom",function(){I(this,arguments).event(q).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(q).end()}).tween("zoom",function(){var te=this,Z=arguments,ae=I(te,Z).event(q),J=e.apply(te,Z),Se=F==null?x(J):typeof F=="function"?F.apply(te,Z):F,xe=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),et=te.__zoom,he=typeof ee=="function"?ee.apply(te,Z):ee,yt=l(et.invert(Se).concat(xe/et.k),he.invert(Se).concat(xe/he.k));return function(Xe){if(Xe===1)Xe=he;else{var dt=yt(Xe),ie=xe/dt[2];Xe=new so(ie,Se[0]-dt[0]*ie,Se[1]-dt[1]*ie)}ae.zoom(null,Xe)}})}function I(R,ee,F){return!F&&R.__zooming||new O(R,ee)}function O(R,ee){this.that=R,this.args=ee,this.active=0,this.sourceEvent=null,this.extent=e.apply(R,ee),this.taps=0}O.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,ee){return this.mouse&&R!=="mouse"&&(this.mouse[1]=ee.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=ee.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=ee.invert(this.touch1[0])),this.that.__zoom=ee,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var ee=wi(this.that).datum();c.call(R,this.that,new t6(R,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:c}),ee)}};function H(R,...ee){if(!i.apply(this,arguments))return;var F=I(this,ee).event(R),q=this.__zoom,te=Math.max(r[0],Math.min(r[1],q.k*Math.pow(2,n.apply(this,arguments)))),Z=Yr(R);if(F.wheel)(F.mouse[0][0]!==Z[0]||F.mouse[0][1]!==Z[1])&&(F.mouse[1]=q.invert(F.mouse[0]=Z)),clearTimeout(F.wheel);else{if(q.k===te)return;F.mouse=[Z,q.invert(Z)],uh(this),F.start()}mc(R),F.wheel=setTimeout(ae,m),F.zoom("mouse",t(E(S(q,te),F.mouse[0],F.mouse[1]),F.extent,o));function ae(){F.wheel=null,F.end()}}function Q(R,...ee){if(h||!i.apply(this,arguments))return;var F=R.currentTarget,q=I(this,ee,!0).event(R),te=wi(R.view).on("mousemove.zoom",Se,!0).on("mouseup.zoom",xe,!0),Z=Yr(R,F),ae=R.clientX,J=R.clientY;UE(R.view),ym(R),q.mouse=[Z,this.__zoom.invert(Z)],uh(this),q.start();function Se(et){if(mc(et),!q.moved){var he=et.clientX-ae,yt=et.clientY-J;q.moved=he*he+yt*yt>y}q.event(et).zoom("mouse",t(E(q.that.__zoom,q.mouse[0]=Yr(et,F),q.mouse[1]),q.extent,o))}function xe(et){te.on("mousemove.zoom mouseup.zoom",null),$E(et.view,q.moved),mc(et),q.event(et).end()}}function re(R,...ee){if(i.apply(this,arguments)){var F=this.__zoom,q=Yr(R.changedTouches?R.changedTouches[0]:R,this),te=F.invert(q),Z=F.k*(R.shiftKey?.5:2),ae=t(E(S(F,Z),q,te),e.apply(this,ee),o);mc(R),a>0?wi(this).transition().duration(a).call(T,ae,q,R):wi(this).call(_.transform,ae,q,R)}}function D(R,...ee){if(i.apply(this,arguments)){var F=R.touches,q=F.length,te=I(this,ee,R.changedTouches.length===q).event(R),Z,ae,J,Se;for(ym(R),ae=0;ae<q;++ae)J=F[ae],Se=Yr(J,this),Se=[Se,this.__zoom.invert(Se),J.identifier],te.touch0?!te.touch1&&te.touch0[2]!==Se[2]&&(te.touch1=Se,te.taps=0):(te.touch0=Se,Z=!0,te.taps=1+!!u);u&&(u=clearTimeout(u)),Z&&(te.taps<2&&(d=Se[0],u=setTimeout(function(){u=null},p)),uh(this),te.start())}}function de(R,...ee){if(this.__zooming){var F=I(this,ee).event(R),q=R.changedTouches,te=q.length,Z,ae,J,Se;for(mc(R),Z=0;Z<te;++Z)ae=q[Z],J=Yr(ae,this),F.touch0&&F.touch0[2]===ae.identifier?F.touch0[0]=J:F.touch1&&F.touch1[2]===ae.identifier&&(F.touch1[0]=J);if(ae=F.that.__zoom,F.touch1){var xe=F.touch0[0],et=F.touch0[1],he=F.touch1[0],yt=F.touch1[1],Xe=(Xe=he[0]-xe[0])*Xe+(Xe=he[1]-xe[1])*Xe,dt=(dt=yt[0]-et[0])*dt+(dt=yt[1]-et[1])*dt;ae=S(ae,Math.sqrt(Xe/dt)),J=[(xe[0]+he[0])/2,(xe[1]+he[1])/2],Se=[(et[0]+yt[0])/2,(et[1]+yt[1])/2]}else if(F.touch0)J=F.touch0[0],Se=F.touch0[1];else return;F.zoom("touch",t(E(ae,J,Se),F.extent,o))}}function se(R,...ee){if(this.__zooming){var F=I(this,ee).event(R),q=R.changedTouches,te=q.length,Z,ae;for(ym(R),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),Z=0;Z<te;++Z)ae=q[Z],F.touch0&&F.touch0[2]===ae.identifier?delete F.touch0:F.touch1&&F.touch1[2]===ae.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(ae=Yr(ae,this),Math.hypot(d[0]-ae[0],d[1]-ae[1])<g)){var J=wi(this).on("dblclick.zoom");J&&J.apply(this,arguments)}}}return _.wheelDelta=function(R){return arguments.length?(n=typeof R=="function"?R:Ld(+R),_):n},_.filter=function(R){return arguments.length?(i=typeof R=="function"?R:Ld(!!R),_):i},_.touchable=function(R){return arguments.length?(s=typeof R=="function"?R:Ld(!!R),_):s},_.extent=function(R){return arguments.length?(e=typeof R=="function"?R:Ld([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),_):e},_.scaleExtent=function(R){return arguments.length?(r[0]=+R[0],r[1]=+R[1],_):[r[0],r[1]]},_.translateExtent=function(R){return arguments.length?(o[0][0]=+R[0][0],o[1][0]=+R[1][0],o[0][1]=+R[0][1],o[1][1]=+R[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(R){return arguments.length?(t=R,_):t},_.duration=function(R){return arguments.length?(a=+R,_):a},_.interpolate=function(R){return arguments.length?(l=R,_):l},_.on=function(){var R=c.on.apply(c,arguments);return R===c?_:R},_.clickDistance=function(R){return arguments.length?(y=(R=+R)*R,_):Math.sqrt(y)},_.tapDistance=function(R){return arguments.length?(g=+R,_):g},_}class l6{constructor(e,t){this.eventTransform=nu,this.behavior=a6().scaleExtent([.001,1/0]).on("start",n=>{var s,r;this.isRunning=!0;const o=!!n.sourceEvent;(r=(s=this.config)==null?void 0:s.onZoomStart)==null||r.call(s,n,o)}).on("zoom",n=>{var s,r;this.eventTransform=n.transform;const{eventTransform:{x:o,y:a,k:l},store:{transform:c,screenSize:u}}=this,d=u[0],h=u[1];if(!d||!h)return;rF(c,d,h),$x(c,c,[o,a]),mm(c,c,[l,l]),$x(c,c,[d/2,h/2]),mm(c,c,[d/2,h/2]),mm(c,c,[1,-1]);const p=!!n.sourceEvent;(r=(s=this.config)==null?void 0:s.onZoom)==null||r.call(s,n,p)}).on("end",n=>{var s,r;this.isRunning=!1;const o=!!n.sourceEvent;(r=(s=this.config)==null?void 0:s.onZoomEnd)==null||r.call(s,n,o)}),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,n=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:s}}=this,r=s[0],o=s[1],a=Px(e.map(g=>g[0])),l=Px(e.map(g=>g[1]));a[0]=this.store.scaleX(a[0]),a[1]=this.store.scaleX(a[1]),l[0]=this.store.scaleY(l[0]),l[1]=this.store.scaleY(l[1]),a[0]===a[1]&&(a[0]-=.5,a[1]+=.5),l[0]===l[1]&&(l[0]+=.5,l[1]-=.5);const c=r*(1-n*2)/(a[1]-a[0]),u=o*(1-n*2)/(l[0]-l[1]),d=uM(t??Math.min(c,u),...this.behavior.scaleExtent()),h=(a[1]+a[0])/2,p=(l[1]+l[0])/2,m=r/2-h*d,y=o/2-p*d;return nu.translate(m,y).scale(d)}getDistanceToPoint(e){const{x:t,y:n,k:s}=this.eventTransform,r=this.getTransform([e],s),o=t-r.x,a=n-r.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:n,y:s,k:r}}=this,o=t[0],a=t[1],l=(o/2-n)/r,c=(a/2-s)/r,u=this.store.scaleX(e[0]),d=this.store.scaleY(e[1]),h=(l+u)/2,p=(c+d)/2,m=1,y=o/2-h*m,g=a/2-p*m;return nu.translate(y,g).scale(m)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:n,k:s},store:{screenSize:r}}=this,o=r[0],a=r[1],l=(e[0]-t)/s,c=(e[1]-n)/s,u=[l,a-c];return u[0]-=(o-this.store.adjustedSpaceSize)/2,u[1]-=(a-this.store.adjustedSpaceSize)/2,u}convertSpaceToScreenPosition(e){const t=this.eventTransform.applyX(this.store.scaleX(e[0])),n=this.eventTransform.applyY(this.store.scaleY(e[1]));return[t,n]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:n},eventTransform:{k:s}}=this;let r=e*2;return t?r*=s:r*=Math.min(5,Math.max(1,s*.01)),Math.min(r,n)/2}}class c6{constructor(e,t){this.isActive=!1,this.behavior=e6().subject(n=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:n.x,y:n.y}:void 0).on("start",n=>{var s,r;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(r=(s=this.config)==null?void 0:s.onDragStart)==null||r.call(s,n))}).on("drag",n=>{var s,r;(r=(s=this.config)==null?void 0:s.onDrag)==null||r.call(s,n)}).on("end",n=>{var s,r;this.isActive=!1,this.store.draggingPointIndex=void 0,(r=(s=this.config)==null?void 0:s.onDragEnd)==null||r.call(s,n)}),this.store=e,this.config=t}}class u6{constructor(e,t,n){if(this.config=new hM,this.graph=new aO(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new qF,this.zoomInstance=new l6(this.store,this.config),this.dragInstance=new c6(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,t&&this.config.init(t),n)this.deviceInitPromise=n;else{const s=document.createElement("canvas");this.deviceInitPromise=this.createDevice(s)}this.deviceInitPromise.then(s=>{if(this._isDestroyed)return s.destroy(),s;this.device=s;const r=this.validateDevice(s);n&&r.setProps({useDevicePixels:this.config.pixelRatio}),this.store.div=e;const o=r.canvas;o.parentNode!==this.store.div&&(o.parentNode&&o.parentNode.removeChild(o),this.store.div.appendChild(o)),this.addAttribution(),o.style.width="100%",o.style.height="100%",this.canvas=o;const a=this.canvas.clientWidth,l=this.canvas.clientHeight;this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(a,l),this.canvasD3Selection=wi(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",u=>{this._isMouseOnCanvas=!1,this.currentEvent=u,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(u),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(u),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),wi(document).on("keydown.cosmos",u=>{u.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",u=>{u.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",u=>{this.currentEvent=u}).on("zoom.detect",u=>{u.sourceEvent&&this.updateMousePosition(u.sourceEvent),this.currentEvent=u}).on("end.detect",u=>{this.currentEvent=u}),this.dragInstance.behavior.on("start.detect",u=>{this.currentEvent=u,this.updateCanvasCursor()}).on("drag.detect",u=>{this.dragInstance.isActive&&this.updateMousePosition(u),this.currentEvent=u}).on("end.detect",u=>{this.currentEvent=u,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1);const c=s.gl.getParameter(Bo.ALIASED_POINT_SIZE_RANGE);return this.store.maxPointSize=((c==null?void 0:c[1])??Jg)/this.config.pixelRatio,this.store.isSimulationRunning=this.config.enableSimulation,this.points=new nF(s,this.config,this.store,this.graph),this.lines=new jO(s,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new jB(s,this.config,this.store,this.graph,this.points),this.forceCenter=new UB(s,this.config,this.store,this.graph,this.points),this.forceManyBody=new qB(s,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Ix(s,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Ix(s,this.config,this.store,this.graph,this.points),this.forceMouse=new KB(s,this.config,this.store,this.graph,this.points)),this.clusters=new eO(s,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Oo(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??fe.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??fe.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ag),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??fe.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Rx(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),s}).catch(s=>{throw console.error("Device initialization failed:",s),s})}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var t,n,s,r,o,a,l,c,u;if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const d={...this.config};if(this.config.init(e),(d.pointDefaultColor!==this.config.pointDefaultColor||d.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),(t=this.points)==null||t.updateColor()),(d.pointDefaultSize!==this.config.pointDefaultSize||d.pointSize!==this.config.pointSize)&&(this.graph.updatePointSize(),(n=this.points)==null||n.updateSize()),(d.linkDefaultColor!==this.config.linkDefaultColor||d.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),(s=this.lines)==null||s.updateColor()),(d.linkDefaultWidth!==this.config.linkDefaultWidth||d.linkWidth!==this.config.linkWidth)&&(this.graph.updateLinkWidth(),(r=this.lines)==null||r.updateWidth()),(d.linkDefaultArrows!==this.config.linkDefaultArrows||d.linkArrows!==this.config.linkArrows)&&(this.graph.updateArrows(),(o=this.lines)==null||o.updateArrow()),(d.curvedLinkSegments!==this.config.curvedLinkSegments||d.curvedLinks!==this.config.curvedLinks)&&((a=this.lines)==null||a.updateCurveLineGeometry()),d.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Oo(this.config.backgroundColor??M2)),d.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??fe.hoveredPointRingColor),d.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??fe.focusedPointRingColor),d.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ag),d.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??fe.hoveredLinkColor),d.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),d.pixelRatio!==this.config.pixelRatio&&(l=this.device)!=null&&l.canvasContext){this.device.canvasContext.setProps({useDevicePixels:this.config.pixelRatio});const h=this.device.gl.getParameter(Bo.ALIASED_POINT_SIZE_RANGE);this.store.maxPointSize=((h==null?void 0:h[1])??Jg)/this.config.pixelRatio}d.spaceSize!==this.config.spaceSize&&(this.store.adjustSpaceSize(this.config.spaceSize,((c=this.device)==null?void 0:c.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),d.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Rx(this.canvas):((u=this.fpsMonitor)==null||u.destroy(),this.fpsMonitor=void 0)),(d.enableZoom!==this.config.enableZoom||d.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(d.onLinkClick!==this.config.onLinkClick||d.onLinkMouseOver!==this.config.onLinkMouseOver||d.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,t))||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=t,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||this.ensureDevice(()=>this.setPointColors(e))||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointSizes(e))||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(t=this.points)==null||t.createAtlas())}setPointImageIndices(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageIndices(e))||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageSizes(e))||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||this.ensureDevice(()=>this.setLinks(e))||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkColors(e))||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkWidths(e))||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkArrows(e))||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkStrength(e))||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusters(e))||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||this.ensureDevice(()=>this.setClusterPositions(e))||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusterStrength(e))||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setPinnedPoints(e))||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,(t=this.points)==null||t.updatePinnedStatus())}render(e){if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:n,fitViewPadding:s,fitViewDuration:r,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),wi(this.canvas).style("cursor",null),this.device&&this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end();return}this._isFirstRenderAfterInit&&t&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{a?this.fitViewByPointIndices(a,r,s):o?this.setZoomTransformByPointPositions(o,r,void 0,s):this.fitView(r,s)},n)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,t=700,n=OD,s=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,t,n,s))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:r}}=this,o=jn(this.device,this.points.currentPositionFbo);if(e===void 0)return;const a=o[e*4+0],l=o[e*4+1];if(a===void 0||l===void 0)return;const c=this.zoomInstance.getDistanceToPoint([a,l]),u=s?n:Math.max(this.getZoomLevel(),n);if(c<Math.min(r[0],r[1]))this.setZoomTransformByPointPositions([a,l],t,u);else{const d=this.zoomInstance.getTransform([[a,l]],u),h=this.zoomInstance.getMiddlePointTransform([a,l]);this.canvasD3Selection.transition().ease(GP).duration(t/2).call(this.zoomInstance.behavior.transform,h).transition().ease(WP).duration(t/2).call(this.zoomInstance.behavior.transform,d)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,t))||this.canvasD3Selection&&(t===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.device||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],t=jn(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let n=0;n<this.graph.pointsNumber;n+=1){const s=t[n*4+0],r=t[n*4+1];s!==void 0&&r!==void 0&&(e[n*2]=s,e[n*2+1]=r)}return e}getClusterPositions(){if(this._isDestroyed||!this.device||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],t=jn(this.device,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let n=0;n<e.length/2;n+=1){const s=t[n*4+0],r=t[n*4+1],o=t[n*4+2];s!==void 0&&r!==void 0&&o!==void 0&&(e[n*2]=s/o,e[n*2+1]=r/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,t))||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,t)}fitViewByPointIndices(e,t=250,n=.1){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,t,n)))return;const s=this.getPointPositions(),r=new Array(e.length*2);for(const[o,a]of e.entries())r[o*2]=s[a*2],r[o*2+1]=s[a*2+1];this.setZoomTransformByPointPositions(r,t,void 0,n)}fitViewByPointPositions(e,t=250,n=.1){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,t,n))||this.setZoomTransformByPointPositions(e,t,void 0,n)}getPointsInRect(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;const t=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection(),jn(this.device,this.points.selectedFbo).map((n,s)=>s%4===0&&n!==0?s/4:-1).filter(n=>n!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],n=e.map(([s,r])=>[s,t-r]);return this.points.updatePolygonPath(n),this.points.findPointsOnPolygonSelection(),jn(this.device,this.points.selectedFbo).map((s,r)=>r%4===0&&s!==0?r/4:-1).filter(s=>s!==-1)}selectPointsInRect(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInRect(e))&&!(!this.device||!this.points)){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const n=jn(this.device,this.points.selectedFbo);this.store.selectedIndices=n.map((s,r)=>r%4===0&&s!==0?r/4:-1).filter(s=>s!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInPolygon(e))&&!(!this.device||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const t=this.store.screenSize[1],n=e.map(([r,o])=>[r,t-o]);this.points.updatePolygonPath(n),this.points.findPointsOnPolygonSelection();const s=jn(this.device,this.points.selectedFbo);this.store.selectedIndices=s.map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointByIndex(e,t)))if(t){const n=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...n])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.selectPointsByIndices(e))||this.points&&(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(t=>t!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||this.ensureDevice(()=>this.unselectPoints())||this.points&&(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;if(!this._isDestroyed)return(t=this.graph.pointSizes)==null?void 0:t[e]}trackPointPositionsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.trackPointPositionsByIndices(e))||this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var t,n;this._isDestroyed||this.ensureDevice(()=>this.start(e))||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(n=(t=this.config).onSimulationStart)==null||n.call(t))}stop(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(t=(e=this.config).onSimulationEnd)==null||t.call(e))}pause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.pause())||(this.store.isSimulationRunning=!1,(t=(e=this.config).onSimulationPause)==null||t.call(e))}unpause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.unpause())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationUnpause)==null||t.call(e))}restart(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.restart())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationRestart)==null||t.call(e))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,t,n,s,r,o,a,l,c,u,d,h,p;this._isDestroyed||(this._isDestroyed=!0,window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),wi(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(t=this.dragInstance)!=null&&t.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(n=this.fpsMonitor)==null||n.destroy(),(s=this.points)==null||s.destroy(),(r=this.lines)==null||r.destroy(),(o=this.clusters)==null||o.destroy(),(a=this.forceGravity)==null||a.destroy(),(l=this.forceCenter)==null||l.destroy(),(c=this.forceManyBody)==null||c.destroy(),(u=this.forceLinkIncoming)==null||u.destroy(),(d=this.forceLinkOutgoing)==null||d.destroy(),(h=this.forceMouse)==null||h.destroy(),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.destroy()),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(p=document.getElementById("gl-bench-style"))==null||p.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0)}create(){var e,t,n,s,r;this._isDestroyed||this.ensureDevice(()=>this.create())||this.points&&this.lines&&(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((t=this.forceLinkIncoming)==null||t.create(Og.INCOMING),(n=this.forceLinkOutgoing)==null||n.create(Og.OUTGOING)),this.isForceCenterUpdateNeeded&&((s=this.forceCenter)==null||s.create()),this.isPointClusterUpdateNeeded&&((r=this.clusters)==null||r.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let n=0;n<e.length/2;n++)t[n]=[e[n*2],e[n*2+1]];return t}ensureDevice(e){return this.device?!1:(this.deviceInitPromise.then(()=>{this._isDestroyed||e()}).catch(t=>{console.error("Device initialization failed",t)}),!0)}validateDevice(e){const t=e.canvasContext;if(t===null||t.type==="offscreen-canvas")throw new Error("Device must have an HTMLCanvasElement canvas context. OffscreenCanvas and compute-only devices are not supported.");return t}async createDevice(e){return await NN.createDevice({type:"webgl",adapters:[TD],createCanvasContext:{canvas:e,useDevicePixels:this.config.pixelRatio,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:t}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((t.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var t,n,s,r,o,a,l,c,u,d,h,p,m,y,g,_,S,E,x;const{config:{simulationGravity:T,simulationCenter:I,enableSimulation:O},store:{isSimulationRunning:H}}=this;O&&(this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((t=this.forceMouse)==null||t.run(),(n=this.points)==null||n.updatePosition()),(e||H&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(T&&((s=this.forceGravity)==null||s.run(),(r=this.points)==null||r.updatePosition()),I&&((o=this.forceCenter)==null||o.run(),(a=this.points)==null||a.updatePosition()),(l=this.forceManyBody)==null||l.run(),(c=this.points)==null||c.updatePosition(),this.store.linksTextureSize&&((u=this.forceLinkIncoming)==null||u.run(),(d=this.points)==null||d.updatePosition(),(h=this.forceLinkOutgoing)==null||h.run(),(p=this.points)==null||p.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((m=this.clusters)==null||m.run(),(y=this.points)==null||y.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??fe.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Qg/this.store.alpha)),(E=(S=this.config).onSimulationTick)==null||E.call(S,this.store.alpha,(g=this.store.hoveredPoint)==null?void 0:g.index,(_=this.store.hoveredPoint)==null?void 0:_.position)),(x=this.points)==null||x.trackPoints())}initPrograms(){var e,t,n,s,r,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(t=this.forceManyBody)==null||t.initPrograms(),(n=this.forceCenter)==null||n.initPrograms(),(s=this.forceLinkIncoming)==null||s.initPrograms(),(r=this.forceLinkOutgoing)==null||r.initPrograms(),(o=this.forceMouse)==null||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:t}}=this;e<Qg&&t&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(n=>{this.renderFrame(n),this._isDestroyed||this.frame()})}renderFrame(e){var t,n,s,r,o,a,l;if(!this._isDestroyed&&this.store.pointsTextureSize){if((t=this.fpsMonitor)==null||t.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),this.device){const c=this.store.backgroundColor??[0,0,0,1],u=this.device.beginRenderPass({clearColor:c,clearDepth:1,clearStencil:0}),{config:{renderLinks:d}}=this;d!==!1&&this.store.linksTextureSize&&this.graph.linksNumber&&this.graph.linksNumber>0&&((n=this.lines)==null||n.draw(u)),(s=this.points)==null||s.draw(u),this.dragInstance.isActive&&((r=this.points)==null||r.drag(),(o=this.points)==null||o.drag(),(a=this.points)==null||a.trackPoints()),u.end(),this.device.submit()}(l=this.fpsMonitor)==null||l.end(e??performance.now()),this.currentEvent=void 0}}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(t=(e=this.config).onSimulationEnd)==null||t.call(e)}onClick(e){var t,n,s,r,o,a,l,c,u,d;(r=(s=this.config).onClick)==null||r.call(s,(t=this.store.hoveredPoint)==null?void 0:t.index,(n=this.store.hoveredPoint)==null?void 0:n.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointClick)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkClick)==null||c.call(l,this.store.hoveredLinkIndex,e):(d=(u=this.config).onBackgroundClick)==null||d.call(u,e)}updateMousePosition(e){if(!e)return;const t=e.offsetX??e.x,n=e.offsetY??e.y;t===void 0||n===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([t,n]),this.store.screenMousePosition=[t,this.store.screenSize[1]-n])}onMouseMove(e){var t,n,s,r;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(r=(s=this.config).onMouseMove)==null||r.call(s,(t=this.store.hoveredPoint)==null?void 0:t.index,(n=this.store.hoveredPoint)==null?void 0:n.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var t,n,s;if(this._isDestroyed)return;const r=this.canvas.clientWidth,o=this.canvas.clientHeight,[a,l]=this.store.screenSize;if(e||a!==r||l!==o){const{k:c}=this.zoomInstance.eventTransform,u=this.zoomInstance.convertScreenToSpacePosition([a/2,l/2]);this.store.updateScreenSize(r,o),(t=this.canvasD3Selection)==null||t.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([u],c)),(n=this.points)==null||n.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((s=this.lines)==null||s.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,t=250,n,s){var r;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),n,s);(r=this.canvasD3Selection)==null||r.transition().ease(YP).duration(t).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,t,n,s;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(t=this.canvasD3Selection)==null||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(n=this.canvasD3Selection)==null||n.call(this.zoomInstance.behavior):(s=this.canvasD3Selection)==null||s.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!(this._isDestroyed||!this._isMouseOnCanvas)){if(this._findHoveredItemExecutionCount<YF){this._findHoveredItemExecutionCount+=1;return}if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const e=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var e,t,n,s;if(this._isDestroyed||!this.device||!this.points)return;this.points.findHoveredPoint();let r=!1,o=!1;const a=jn(this.device,this.points.hoveredFbo,0,0,2,2),l=a[0],c=a[1],u=a[2],d=a[3];c>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==l)&&(r=!0),this.store.hoveredPoint={index:l,position:[u,d]}):(this.store.hoveredPoint&&(o=!0),this.store.hoveredPoint=void 0),r&&this.store.hoveredPoint&&((t=(e=this.config).onPointMouseOver)==null||t.call(e,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),o&&((s=(n=this.config).onPointMouseOut)==null||s.call(n,this.currentEvent))}findHoveredLine(){var e,t,n,s,r,o;if(this._isDestroyed||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(t=(e=this.config).onLinkMouseOut)==null||t.call(e,this.currentEvent));return}this.lines.findHoveredLine();let a=!1,l=!1;if(!this.device)return;const c=jn(this.device,this.lines.hoveredLineIndexFbo)[0];c>=0?(this.store.hoveredLinkIndex!==c&&(a=!0),this.store.hoveredLinkIndex=c):(this.store.hoveredLinkIndex!==void 0&&(l=!0),this.store.hoveredLinkIndex=void 0),a&&this.store.hoveredLinkIndex!==void 0&&((s=(n=this.config).onLinkMouseOver)==null||s.call(n,this.store.hoveredLinkIndex)),l&&((o=(r=this.config).onLinkMouseOut)==null||o.call(r,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?wi(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?wi(this.canvas).style("cursor",e):wi(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?wi(this.canvas).style("cursor",t):wi(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
      user-select: none;
      position: absolute;
      bottom: 0;
      right: 0;
      color: var(--cosmosgl-attribution-color);
      margin: 0 0.6rem 0.6rem 0;
      font-size: 0.7rem;
      font-family: inherit;
    `,this.attributionDivElement.innerHTML=dM(this.config.attribution,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br","img"],ALLOWED_ATTR:["href","target","class","id","style","src","alt","title"]}),(e=this.store.div)==null||e.appendChild(this.attributionDivElement))}}const Jx={};function d6(i,e=!1){let t,n,s=Jx;function r(c){var u;t=((u=i(c))==null?void 0:u.catch(()=>{}).finally(()=>{if(n){const{event:d}=n;n=null,r(d)}else t=null}))||null}function o(c){n={event:c}}function a(c){t?o(c):r(c)}function l(c){s!==c&&requestAnimationFrame(()=>{const u=s;s=Jx,a(u)}),s=c}return e?l:a}class h6{constructor(e){b(this,"_filterBy");b(this,"_requestUpdate");b(this,"_coordinator");b(this,"_pending");b(this,"_enabled");b(this,"_initialized");b(this,"_request");this._filterBy=e,this._requestUpdate=d6(()=>this.requestQuery(),!0),this._coordinator=null,this._pending=Promise.resolve(),this._enabled=!0,this._initialized=!1,this._request=null}get coordinator(){return this._coordinator}set coordinator(e){this._coordinator=e}get enabled(){return this._enabled}set enabled(e){e=!!e,this._enabled!==e&&(this._enabled=e,e&&(this._initialized?this._request&&this.requestQuery(this._request===!0?void 0:this._request):this.initialize(),this._request=null))}get pending(){return this._pending}get filterBy(){return this._filterBy}get filterStable(){return!0}async prepare(){}query(e){return null}queryPending(){return this}queryResult(e){return this}queryError(e){return this}requestQuery(e){var t;if(this._enabled){const n=e||this.query((t=this.filterBy)==null?void 0:t.predicate(this));return this._coordinator.requestQuery(this,n)}else return this._request=e??!0,null}requestUpdate(){this._enabled?this._requestUpdate():this.requestQuery()}initialize(){this._enabled?this._coordinator&&(this._initialized=!0,this._pending=this.prepare().then(()=>this.requestQuery())):this._initialized=!1}destroy(){var e;this._enabled=!1,(e=this.coordinator)==null||e.disconnect(this)}update(){return this}}const jE=Uint8Array.of(65,82,82,79,87,49),fp={V1:0,V4:3,V5:4},eo={NONE:0,Schema:1,DictionaryBatch:2,RecordBatch:3,Tensor:4,SparseTensor:5},K={Dictionary:-1,NONE:0,Null:1,Int:2,Float:3,Binary:4,Utf8:5,Bool:6,Decimal:7,Date:8,Time:9,Timestamp:10,Interval:11,List:12,Struct:13,Union:14,FixedSizeBinary:15,FixedSizeList:16,Map:17,Duration:18,LargeBinary:19,LargeUtf8:20,LargeList:21,RunEndEncoded:22,BinaryView:23,Utf8View:24,ListView:25,LargeListView:26},HE={HALF:0,SINGLE:1,DOUBLE:2},cf={DAY:0,MILLISECOND:1},Ln={SECOND:0,MILLISECOND:1,MICROSECOND:2,NANOSECOND:3},dl={YEAR_MONTH:0,DAY_TIME:1,MONTH_DAY_NANO:2},Py={Sparse:0,Dense:1},VE={LZ4_FRAME:0,ZSTD:1},GE={BUFFER:0},f6=Uint8Array,WE=Uint16Array,p6=Uint32Array,YE=BigUint64Array,qE=Int8Array,m6=Int16Array,Ys=Int32Array,Ar=BigInt64Array,g6=Float32Array,pp=Float64Array;function _6(i){return i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer}function y6(i,e){const t=Math.log2(i)-3;return(e?[qE,m6,Ys,Ar]:[f6,WE,p6,YE])[t]}function Ny(i,e){let t=0,n=i.length;if(n<=2147483648)do{const s=t+n>>>1;i[s]<=e?t=s+1:n=s}while(t<n);else do{const s=Math.trunc((t+n)/2);i[s]<=e?t=s+1:n=s}while(t<n);return t}function Dy(i,e,t){if(e(i))return i;throw new Error(t(i))}function Ir(i,e,t){return e=Array.isArray(e)?e:Object.values(e),Dy(i,n=>e.includes(n),t??(()=>`${i} must be one of ${e}`))}function My(i,e){for(const[t,n]of Object.entries(i))if(n===e)return t;return"<Unknown>"}const By=i=>`Unsupported data type: "${My(K,i)}" (id ${i})`,XE=(i,e,t=!0,n=null)=>({name:i,type:e,nullable:t,metadata:n});function KE(i){return Object.hasOwn(i,"name")&&ZE(i.type)}function ZE(i){return typeof(i==null?void 0:i.typeId)=="number"}function Ho(i,e="",t=!0){return KE(i)?i:XE(e,Dy(i,ZE,()=>"Data type expected."),t)}const b6=(i,e,t=!1,n=-1)=>({typeId:K.Dictionary,id:n,dictionary:i,indices:e||JE(),ordered:t}),QE=(i=32,e=!0)=>({typeId:K.Int,bitWidth:Ir(i,[8,16,32,64]),signed:e,values:y6(i,e)}),JE=()=>QE(32),v6=(i=2)=>({typeId:K.Float,precision:Ir(i,HE),values:[WE,g6,pp][i]}),x6=()=>({typeId:K.Binary,offsets:Ys}),w6=()=>({typeId:K.Utf8,offsets:Ys}),S6=(i,e,t=128)=>({typeId:K.Decimal,precision:i,scale:e,bitWidth:Ir(t,[32,64,128,256]),values:t===32?Ys:YE}),E6=i=>({typeId:K.Date,unit:Ir(i,cf),values:i===cf.DAY?Ys:Ar}),C6=(i=Ln.MILLISECOND)=>{i=Ir(i,Ln);const e=i===Ln.SECOND||i===Ln.MILLISECOND?32:64;return{typeId:K.Time,unit:i,bitWidth:e,values:e===32?Ys:Ar}},T6=(i=Ln.MILLISECOND,e=null)=>({typeId:K.Timestamp,unit:Ir(i,Ln),timezone:e,values:Ar}),k6=(i=dl.MONTH_DAY_NANO)=>({typeId:K.Interval,unit:Ir(i,dl),values:i===dl.MONTH_DAY_NANO?void 0:Ys}),A6=i=>({typeId:K.List,children:[Ho(i)],offsets:Ys}),I6=i=>({typeId:K.Struct,children:Array.isArray(i)&&i.length>0&&KE(i[0])?i:Object.entries(i).map(([e,t])=>XE(e,t))}),L6=(i,e,t,n)=>(t??(t=e.map((s,r)=>r)),{typeId:K.Union,mode:Ir(i,Py),typeIds:t,typeMap:t.reduce((s,r,o)=>(s[r]=o,s),{}),children:e.map((s,r)=>Ho(s,`_${r}`)),typeIdForValue:n,offsets:Ys}),R6=i=>({typeId:K.FixedSizeBinary,stride:i}),P6=(i,e)=>({typeId:K.FixedSizeList,stride:e,children:[Ho(i)]}),N6=(i,e)=>({typeId:K.Map,keysSorted:i,children:[e],offsets:Ys}),D6=(i=Ln.MILLISECOND)=>({typeId:K.Duration,unit:Ir(i,Ln),values:Ar}),M6=()=>({typeId:K.LargeBinary,offsets:Ar}),B6=()=>({typeId:K.LargeUtf8,offsets:Ar}),O6=i=>({typeId:K.LargeList,children:[Ho(i)],offsets:Ar}),F6=(i,e)=>({typeId:K.RunEndEncoded,children:[Dy(Ho(i,"run_ends"),t=>t.type.typeId===K.Int,()=>"Run-ends must have an integer type."),Ho(e,"values")]}),z6=i=>({typeId:K.ListView,children:[Ho(i,"value")],offsets:Ys}),U6=i=>({typeId:K.LargeListView,children:[Ho(i,"value")],offsets:Ar}),$6=new pp(2),j6=$6.buffer;new Ar(j6);function Vo(i){if(i>Number.MAX_SAFE_INTEGER||i<Number.MIN_SAFE_INTEGER)throw Error(`BigInt exceeds integer number representation: ${i}`);return Number(i)}function Oy(i,e){return Number(i/e)+Number(i%e)/Number(e)}const il=i=>BigInt.asUintN(64,i);function H6(i,e){return BigInt.asIntN(64,i[e])}function V6(i,e){const t=e<<1;let n;return BigInt.asIntN(64,i[t+1])<0?(n=il(~i[t])|il(~i[t+1])<<64n,n=-(n+1n)):n=i[t]|i[t+1]<<64n,n}function G6(i,e){const t=e<<2;let n;return BigInt.asIntN(64,i[t+3])<0?(n=il(~i[t])|il(~i[t+1])<<64n|il(~i[t+2])<<128n|il(~i[t+3])<<192n,n=-(n+1n)):n=i[t]|i[t+1]<<64n|i[t+2]<<128n|i[t+3]<<192n,n}const W6=new TextDecoder("utf-8");new TextEncoder;function mp(i){return W6.decode(i)}const gu=4;function e3(i,e){return(i[e>>3]&1<<e%8)!==0}function Lr(i,e){const t=e+ti(i,e),n=t-ti(i,t),s=ls(i,n);return(r,o,a=null)=>{if(r<s){const l=ls(i,n+r);if(l)return o(i,t+l)}return a}}function hl(i,e){return e}function _u(i,e){return!!t_(i,e)}function t_(i,e){return Fy(i,e)<<24>>24}function Fy(i,e){return i[e]}function ls(i,e){return Y6(i,e)<<16>>16}function Y6(i,e){return i[e]|i[e+1]<<8}function ti(i,e){return i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24}function e1(i,e){return ti(i,e)>>>0}function Vn(i,e){return Vo(BigInt.asIntN(64,BigInt(e1(i,e))+(BigInt(e1(i,e+gu))<<32n)))}function uf(i,e){let t=e+ti(i,e);const n=ti(i,t);return t+=gu,mp(i.subarray(t,t+n))}function $o(i,e,t,n){if(!e)return[];const s=e+ti(i,e);return Array.from({length:ti(i,s)},(r,o)=>n(i,s+gu+o*t))}const bm=Symbol("rowIndex");function i_(i,e){class t{constructor(r){this[bm]=r}toJSON(){return i3(i,e,this[bm])}}const n=t.prototype;for(let s=0;s<i.length;++s){if(Object.hasOwn(n,i[s]))continue;const r=e[s];Object.defineProperty(n,i[s],{get(){return r.at(this[bm])},enumerable:!0})}return s=>new t(s)}function t3(i,e){return t=>i3(i,e,t)}function i3(i,e,t){const n={};for(let s=0;s<i.length;++s)n[i[s]]=e[s].at(t);return n}function q6(i){return i instanceof $c}class Gu{constructor({length:e,nullCount:t,type:n,validity:s,values:r,offsets:o,sizes:a,children:l}){this.length=e,this.nullCount=t,this.type=n,this.validity=s,this.values=r,this.offsets=o,this.sizes=a,this.children=l,(!t||!this.validity)&&(this.at=c=>this.value(c))}get[Symbol.toStringTag](){return"Batch"}at(e){return this.isValid(e)?this.value(e):null}isValid(e){return e3(this.validity,e)}value(e){return this.values[e]}slice(e,t){const n=t-e,s=Array(n);for(let r=0;r<n;++r)s[r]=this.at(e+r);return s}*[Symbol.iterator](){for(let e=0;e<this.length;++e)yield this.at(e)}}b(Gu,"ArrayType",null);class $c extends Gu{constructor(e){super(e);const{length:t,values:n}=this;this.values=n.subarray(0,t)}slice(e,t){return this.nullCount?super.slice(e,t):this.values.subarray(e,t)}[Symbol.iterator](){return this.nullCount?super[Symbol.iterator]():this.values[Symbol.iterator]()}}class Wu extends Gu{}b(Wu,"ArrayType",pp);class li extends Gu{}b(li,"ArrayType",Array);class X6 extends li{value(e){return null}}class Gl extends Wu{value(e){return Vo(this.values[e])}}class K6 extends Wu{value(e){const t=this.values[e],n=(t&31744)>>10,s=(t&1023)/1024,r=(-1)**((t&32768)>>15);switch(n){case 31:return r*(s?Number.NaN:1/0);case 0:return r*(s?6103515625e-14*s:0)}return r*2**(n-15)*(1+s)}}class Z6 extends li{value(e){return e3(this.values,e)}}class Q6 extends Wu{constructor(e){super(e);const{scale:t}=this.type;this.scale=10**t}value(e){return this.values[e]/this.scale}}class n3 extends Gu{constructor(e){super(e);const{bitWidth:t,scale:n}=this.type;this.decimal=t===64?H6:t===128?V6:G6,this.scale=10n**BigInt(n)}}class s3 extends n3{value(e){return Oy(this.decimal(this.values,e),this.scale)}}b(s3,"ArrayType",pp);class r3 extends n3{value(e){return this.decimal(this.values,e)}}b(r3,"ArrayType",Array);class t1 extends li{constructor(e){super(e),this.source=e}value(e){return new Date(this.source.value(e))}}class J6 extends Wu{value(e){return 864e5*this.values[e]}}const ez=Gl;class tz extends Gl{value(e){return super.value(e)*1e3}}const iz=Gl;class nz extends Gl{value(e){return Oy(this.values[e],1000n)}}class sz extends Gl{value(e){return Oy(this.values[e],1000000n)}}class rz extends li{value(e){return this.values.subarray(e<<1,e+1<<1)}}class oz extends li{value(e){const t=this.values,n=e<<4;return Float64Array.of(ti(t,n),ti(t,n+4),Vn(t,n+8))}}const o3=({values:i,offsets:e},t)=>i.subarray(e[t],e[t+1]),a3=({values:i,offsets:e},t)=>i.subarray(Vo(e[t]),Vo(e[t+1]));class az extends li{value(e){return o3(this,e)}}class lz extends li{value(e){return a3(this,e)}}class cz extends li{value(e){return mp(o3(this,e))}}class uz extends li{value(e){return mp(a3(this,e))}}class dz extends li{value(e){const t=this.offsets;return this.children[0].slice(t[e],t[e+1])}}class hz extends li{value(e){const t=this.offsets;return this.children[0].slice(Vo(t[e]),Vo(t[e+1]))}}class fz extends li{value(e){const t=this.offsets[e],n=t+this.sizes[e];return this.children[0].slice(t,n)}}class pz extends li{value(e){const t=this.offsets[e],n=t+this.sizes[e];return this.children[0].slice(Vo(t),Vo(n))}}class l3 extends li{constructor(e){super(e),this.stride=this.type.stride}}class mz extends l3{value(e){const{stride:t,values:n}=this;return n.subarray(e*t,(e+1)*t)}}class gz extends l3{value(e){const{children:t,stride:n}=this;return t[0].slice(e*n,(e+1)*n)}}function c3({children:i,offsets:e},t){const[n,s]=i[0].children,r=e[t],o=e[t+1],a=[];for(let l=r;l<o;++l)a.push([n.at(l),s.at(l)]);return a}class _z extends li{value(e){return c3(this,e)}}class yz extends li{value(e){return new Map(c3(this,e))}}class u3 extends li{constructor({typeIds:e,...t}){super(t),this.typeIds=e,this.typeMap=this.type.typeMap}value(e,t=e){const{typeIds:n,children:s,typeMap:r}=this;return s[r[n[e]]].at(t)}}class bz extends u3{value(e){return super.value(e,this.offsets[e])}}class d3 extends li{constructor(e,t=t3){super(e),this.names=this.type.children.map(n=>n.name),this.factory=t(this.names,this.children)}value(e){return this.factory(e)}}class vz extends d3{constructor(e){super(e,i_)}}class xz extends li{value(e){const[{values:t},n]=this.children;return n.at(Ny(t,e))}}let wz=class extends li{setDictionary(e){return this.dictionary=e,this.cache=e.cache(),this}value(e){return this.cache[this.key(e)]}key(e){return this.values[e]}};class h3 extends li{constructor({data:e,...t}){super(t),this.data=e}view(e){const{values:t,data:n}=this,s=e<<4;let r=s+4,o=t;const a=ti(o,s);return a>12&&(r=ti(o,s+12),o=n[ti(o,s+8)]),o.subarray(r,r+a)}}class Sz extends h3{value(e){return this.view(e)}}class Ez extends h3{value(e){return mp(this.view(e))}}function i1(i){let e=[];return{add(t){return e.push(t),this},clear:()=>e=[],done:()=>new Cz(e,i)}}class Cz{constructor(e,t=(n=>(n=e[0])==null?void 0:n.type)()){this.type=t,this.length=e.reduce((o,a)=>o+a.length,0),this.nullCount=e.reduce((o,a)=>o+a.nullCount,0),this.data=e;const s=e.length,r=new Int32Array(s+1);if(s===1){const[o]=e;r[1]=o.length,this.at=a=>o.at(a)}else for(let o=0,a=0;o<s;++o)r[o+1]=a+=e[o].length;this.offsets=r}get[Symbol.toStringTag](){return"Column"}[Symbol.iterator](){const e=this.data;return e.length===1?e[0][Symbol.iterator]():Tz(e)}at(e){var r;const{data:t,offsets:n}=this,s=Ny(n,e)-1;return(r=t[s])==null?void 0:r.at(e-n[s])}get(e){return this.at(e)}toArray(){const{length:e,nullCount:t,data:n}=this,s=!t&&q6(n[0]),r=n.length;if(s&&r===1)return n[0].values;const o=!r||t>0?Array:n[0].constructor.ArrayType??n[0].values.constructor,a=new o(e);return s?kz(a,n):Az(a,n)}cache(){return this._cache??(this._cache=this.toArray())}}function*Tz(i){for(let e=0;e<i.length;++e){const t=i[e][Symbol.iterator]();for(let n=t.next();!n.done;n=t.next())yield n.value}}function kz(i,e){for(let t=0,n=0;t<e.length;++t){const{values:s}=e[t];i.set(s,n),n+=s.length}return i}function Az(i,e){let t=-1;for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.length;++r)i[++t]=s.at(r)}return i}let Iz=class f3{constructor(e,t,n=!1){const s=e.fields.map(o=>o.name);this.schema=e,this.names=s,this.children=t,this.factory=n?i_:t3;const r=[];this.getFactory=o=>r[o]??(r[o]=this.factory(s,t.map(a=>a.data[o])))}get[Symbol.toStringTag](){return"Table"}get numCols(){return this.names.length}get numRows(){var e;return((e=this.children[0])==null?void 0:e.length)??0}getChildAt(e){return this.children[e]}getChild(e){const t=this.names.findIndex(n=>n===e);return t>-1?this.children[t]:void 0}selectAt(e,t=[]){const{children:n,factory:s,schema:r}=this,{fields:o}=r;return new f3({...r,fields:e.map((a,l)=>Lz(o[a],t[l]))},e.map(a=>n[a]),s===i_)}select(e,t){const n=this.names,s=e.map(r=>n.indexOf(r));return this.selectAt(s,t)}toColumns(){const{children:e,names:t}=this,n={};return t.forEach((s,r)=>{var o;return n[s]=((o=e[r])==null?void 0:o.toArray())??[]}),n}toArray(){var o;const{children:e,getFactory:t,numRows:n}=this,s=((o=e[0])==null?void 0:o.data)??[],r=Array(n);for(let a=0,l=-1;a<s.length;++a){const c=t(a);for(let u=0;u<s[a].length;++u)r[++l]=c(u)}return r}*[Symbol.iterator](){var s;const{children:e,getFactory:t}=this,n=((s=e[0])==null?void 0:s.data)??[];for(let r=0;r<n.length;++r){const o=t(r);for(let a=0;a<n[r].length;++a)yield o(a)}}at(e){const{children:t,getFactory:n,numRows:s}=this;if(e<0||e>=s)return null;const[{offsets:r}]=t,o=Ny(r,e)-1;return n(o)(e-r[o])}get(e){return this.at(e)}};function Lz(i,e){return e!=null&&e!==i.name?{...i,name:e}:i}function Rz(i,e={}){const{typeId:t,bitWidth:n,mode:s,precision:r,unit:o}=i,{useBigInt:a,useDate:l,useDecimalInt:c,useMap:u,useProxy:d}=e;switch(t){case K.Null:return X6;case K.Bool:return Z6;case K.Int:case K.Time:case K.Duration:return a||n<64?$c:Gl;case K.Float:return r?$c:K6;case K.Date:return n1(o===cf.DAY?J6:ez,l&&t1);case K.Timestamp:return n1(o===Ln.SECOND?tz:o===Ln.MILLISECOND?iz:o===Ln.MICROSECOND?nz:sz,l&&t1);case K.Decimal:return n===32?c?$c:Q6:c?r3:s3;case K.Interval:return o===dl.DAY_TIME?rz:o===dl.YEAR_MONTH?$c:oz;case K.FixedSizeBinary:return mz;case K.Utf8:return cz;case K.LargeUtf8:return uz;case K.Binary:return az;case K.LargeBinary:return lz;case K.BinaryView:return Sz;case K.Utf8View:return Ez;case K.List:return dz;case K.LargeList:return hz;case K.Map:return u?yz:_z;case K.ListView:return fz;case K.LargeListView:return pz;case K.FixedSizeList:return gz;case K.Struct:return d?vz:d3;case K.RunEndEncoded:return xz;case K.Dictionary:return wz;case K.Union:return s?bz:u3}throw new Error(By(t))}function n1(i,e){return e?class extends e{constructor(n){super(new i(n))}}:i}const Pz=-1,Nz=8;function Dz(i){return`Missing compression codec "${My(VE,i)}" (id ${i})`}const Mz=new Map;function Bz(i){return i!=null&&Mz.get(i)||null}function Oz(i,{offset:e,length:t},n){if(t===0)return{bytes:new Uint8Array(0),offset:0,length:0};const s=Vn(i,e),r=i.subarray(e+Nz,e+t),o=s===Pz?r:n.decode(r);return{bytes:o,offset:0,length:o.length}}function Fz(i,e){return{offset:Vn(i,e),metadataLength:ti(i,e+8),bodyLength:Vn(i,e+16)}}function s1(i,e){return $o(i,e,24,Fz)}function zz(i,e){const t=Lr(i,e);return{codec:t(4,t_,VE.LZ4_FRAME),method:t(6,t_,GE.BUFFER)}}function p3(i,e,t){const n=Lr(i,e),s=t<fp.V4?8:0;return{length:n(4,Vn,0),nodes:$o(i,n(6,hl),16,(r,o)=>({length:Vn(r,o),nullCount:Vn(r,o+8)})),regions:$o(i,n(8,hl),16+s,(r,o)=>({offset:Vn(r,o+s),length:Vn(r,o+s+8)})),compression:n(10,zz),variadic:$o(i,n(12,hl),8,Vn)}}function Uz(i,e,t){const n=Lr(i,e);return{id:n(4,Vn,0),data:n(6,(s,r)=>p3(s,r,t)),isDelta:n(8,_u,!1)}}function m3(i,e,t,n){Ir(t,K,By);const s=Lr(i,e);switch(t){case K.Binary:return x6();case K.Utf8:return w6();case K.LargeBinary:return M6();case K.LargeUtf8:return B6();case K.List:return A6(n[0]);case K.ListView:return z6(n[0]);case K.LargeList:return O6(n[0]);case K.LargeListView:return U6(n[0]);case K.Struct:return I6(n);case K.RunEndEncoded:return F6(n[0],n[1]);case K.Int:return QE(s(4,ti,0),s(6,_u,!1));case K.Float:return v6(s(4,ls,HE.HALF));case K.Decimal:return S6(s(4,ti,0),s(6,ti,0),s(8,ti,128));case K.Date:return E6(s(4,ls,cf.MILLISECOND));case K.Time:return C6(s(4,ls,Ln.MILLISECOND));case K.Timestamp:return T6(s(4,ls,Ln.SECOND),s(6,uf));case K.Interval:return k6(s(4,ls,dl.YEAR_MONTH));case K.Duration:return D6(s(4,ls,Ln.MILLISECOND));case K.FixedSizeBinary:return R6(s(4,ti,0));case K.FixedSizeList:return P6(n[0],s(4,ti,0));case K.Map:return N6(s(4,_u,!1),n[0]);case K.Union:return L6(s(4,ls,Py.Sparse),n,$o(i,s(6,hl),4,ti))}return{typeId:t}}function zy(i,e){const t=$o(i,e,4,(n,s)=>{const r=Lr(n,s);return[r(4,uf),r(6,uf)]});return t.length?new Map(t):null}function g3(i,e,t){const n=Lr(i,e);return{version:t,endianness:n(4,ls,0),fields:n(6,$z,[]),metadata:n(8,zy)}}function $z(i,e){return $o(i,e,4,_3)}function _3(i,e){const t=Lr(i,e),n=t(8,Fy,K.NONE),s=t(10,hl,0),r=t(12,Hz),o=t(14,jz,[]);let a=m3(i,s,n,o);return r&&(r.dictionary=a,a=r),{name:t(4,uf),type:a,nullable:t(6,_u,!1),metadata:t(16,zy)}}function jz(i,e){return $o(i,e,4,_3)}function Hz(i,e){if(!e)return null;const t=Lr(i,e);return b6(null,t(6,Vz,JE()),t(8,_u,!1),t(4,Vn,0))}function Vz(i,e){return m3(i,e,K.Int)}const Gz=(i,e)=>`Expected to read ${i} metadata bytes, but only read ${e}.`,Wz=(i,e)=>`Expected to read ${i} bytes for message body, but only read ${e}.`,Yz=i=>`Unsupported message type: ${i} (${My(eo,i)})`;function n_(i,e){let t=ti(i,e)||0;if(e+=gu,t===-1&&(t=ti(i,e)||0,e+=gu),t===0)return null;const n=i.subarray(e,e+=t);if(n.byteLength<t)throw new Error(Gz(t,n.byteLength));const s=Lr(n,0),r=s(4,ls,fp.V1),o=s(6,Fy,eo.NONE),a=s(8,hl,0),l=s(10,Vn,0);let c;if(a){const u=o===eo.Schema?g3:o===eo.DictionaryBatch?Uz:o===eo.RecordBatch?p3:null;if(!u)throw new Error(Yz(o));if(c=u(n,a,r),l>0){const d=i.subarray(e,e+=l);if(d.byteLength<l)throw new Error(Wz(l,d.byteLength));c.body=d}else o!==eo.Schema&&(c.body=new Uint8Array(0))}return{version:r,type:o,index:e,content:c}}function qz(i){const e=_6(i)?new Uint8Array(i):i;return e instanceof Uint8Array&&Xz(e)?Zz(e):Kz(e)}function Xz(i){if(!i||i.length<4)return!1;for(let e=0;e<6;++e)if(jE[e]!==i[e])return!1;return!0}function Kz(i){const e=[i].flat();let t;const n=[],s=[];for(const r of e){if(!(r instanceof Uint8Array))throw new Error("IPC data batch was not a Uint8Array.");let o=0;for(;;){const a=n_(r,o);if(a===null)break;if(o=a.index,!!a.content)switch(a.type){case eo.Schema:t||(t=a.content);break;case eo.RecordBatch:n.push(a.content);break;case eo.DictionaryBatch:s.push(a.content);break}}}return{schema:t,dictionaries:s,records:n,metadata:null}}function Zz(i){const e=i.byteLength-(jE.length+4),t=ti(i,e),n=Lr(i,e-t),s=n(4,ls,fp.V1),r=n(8,s1,[]),o=n(10,s1,[]);return{schema:n(6,(a,l)=>g3(a,l,s)),dictionaries:r.map(({offset:a})=>n_(i,a).content),records:o.map(({offset:a})=>n_(i,a).content),metadata:n(12,zy)}}function Qz(i,e){return Jz(qz(i),e)}function Jz(i,e={}){const{schema:t={fields:[]},dictionaries:n,records:s}=i,{version:r,fields:o}=t,a=new Map,l=t7(e,r,a),c=new Map;e7(t,h=>{const p=h.type;p.typeId===K.Dictionary&&c.set(p.id,p.dictionary)});const u=new Map;for(const h of n){const{id:p,data:m,isDelta:y,body:g}=h,_=c.get(p),S=s_(_,l({...m,body:g}));if(u.has(p)){const E=u.get(p);y||E.clear(),E.add(S)}else{if(y)throw new Error("Delta update can not be first dictionary batch.");u.set(p,i1(_).add(S))}}u.forEach((h,p)=>a.set(p,h.done()));const d=o.map(h=>i1(h.type));for(const h of s){const p=l(h);o.forEach((m,y)=>d[y].add(s_(m.type,p)))}return new Iz(t,d.map(h=>h.done()),e.useProxy)}function e7(i,e){i.fields.forEach(function t(n){var s,r,o;e(n),(r=(s=n.type.dictionary)==null?void 0:s.children)==null||r.forEach(t),(o=n.type.children)==null||o.forEach(t)})}function t7(i,e,t){const n={version:e,options:i,dictionary:s=>t.get(s)};return s=>{const{length:r,nodes:o,regions:a,compression:l,variadic:c,body:u}=s;let d=-1,h=-1,p=-1;return{...n,length:r,node:()=>o[++d],buffer:m=>{const{bytes:y,length:g,offset:_}=i7(u,a[++h],l);return m?new m(y.buffer,y.byteOffset+_,g/m.BYTES_PER_ELEMENT):y.subarray(_,_+g)},variadic:()=>c[++p],visit(m){return m.map(y=>s_(y.type,this))}}}}function i7(i,e,t){if(t){if(t.method!==GE.BUFFER)throw new Error(`Unknown compression method (${t.method})`);{const n=t.codec,s=Bz(n);if(!s)throw new Error(Dz(n));return Oz(i,e,s)}}else return{bytes:i,...e}}function s_(i,e){const{typeId:t}=i,{options:n,node:s,buffer:r,variadic:o,version:a}=e,l=Rz(i,n),c={...s(),type:i};if(t===K.Null)return new l({...c,nullCount:c.length});switch(t){case K.Bool:case K.Int:case K.Time:case K.Duration:case K.Float:case K.Decimal:case K.Date:case K.Timestamp:case K.Interval:case K.FixedSizeBinary:return new l({...c,validity:r(),values:r(i.values)});case K.Utf8:case K.LargeUtf8:case K.Binary:case K.LargeBinary:return new l({...c,validity:r(),offsets:r(i.offsets),values:r()});case K.BinaryView:case K.Utf8View:return new l({...c,validity:r(),values:r(),data:Array.from({length:o()},()=>r())});case K.List:case K.LargeList:case K.Map:return new l({...c,validity:r(),offsets:r(i.offsets),children:e.visit(i.children)});case K.ListView:case K.LargeListView:return new l({...c,validity:r(),offsets:r(i.offsets),sizes:r(i.offsets),children:e.visit(i.children)});case K.FixedSizeList:case K.Struct:return new l({...c,validity:r(),children:e.visit(i.children)});case K.RunEndEncoded:return new l({...c,children:e.visit(i.children)});case K.Dictionary:{const{id:u,indices:d}=i;return new l({...c,validity:r(),values:r(d.values)}).setDictionary(e.dictionary(u))}case K.Union:return a<fp.V5&&r(),new l({...c,typeIds:r(qE),offsets:i.mode===Py.Sparse?null:r(i.offsets),children:e.visit(i.children)});default:throw new Error(By(t))}}new Uint16Array(new Uint8Array([1,0]).buffer)[0];function df(i,e={useDate:!0}){return Qz(i,e)}class n7{constructor({uri:e="ws://localhost:3000/",ipc:t=void 0}={}){b(this,"_uri");b(this,"_queue");b(this,"_connected");b(this,"_request");b(this,"_ws");b(this,"_events");this._uri=e,this._queue=[],this._connected=!1,this._request=null,this._ws=null;const n=this;this._events={open(){n._connected=!0,n.next()},close(){for(n._connected=!1,n._request=null,n._ws=null;n._queue.length;)n._queue.shift().reject("Socket closed")},error(s){if(n._request){const{reject:r}=n._request;n._request=null,n.next(),r(s)}else console.error("WebSocket error: ",s)},message(s){const{data:r}=s;if(n._request){const{query:o,resolve:a,reject:l}=n._request;if(n._request=null,n.next(),typeof r=="string"){const c=JSON.parse(r);c.error?l(c.error):a(c)}else if(o.type==="exec")a();else if(o.type==="arrow")a(df(r,t));else throw new Error(`Unexpected socket data: ${r}`)}else console.log("WebSocket message: ",r)}}}get connected(){return this._connected}init(){this._ws=new WebSocket(this._uri),this._ws.binaryType="arraybuffer";for(const e in this._events)this._ws.addEventListener(e,this._events[e])}enqueue(e,t,n){this._ws==null&&this.init(),this._queue.push({query:e,resolve:t,reject:n}),this._connected&&!this._request&&this.next()}next(){this._queue.length&&(this._request=this._queue.shift(),this._ws.send(JSON.stringify(this._request.query)))}query(e){return new Promise((t,n)=>this.enqueue(e,t,n))}}function Sr(i){return i instanceof go}let y3;function s7(i){y3=i}class go{constructor(e){b(this,"type");this.type=e}clone(){const e=new this.constructor(this.type);for(const t in this)t!=="type"&&(e[t]=this[t]);return e}toString(e=y3){if(!e)throw new Error("No visitor provided and no default visitor set.");return e.toString(this)}}class Ui extends go{}function b3(i){return i.split(".")}function ta(i){return`"${i.replaceAll('"','""')}"`}function vm(i){return i&&r7(i)?i.slice(1,-1):i}function r7(i){return i[0]==='"'&&i[i.length-1]==='"'}const gp="COLUMN_REF",_p="COLUMN_PARAM",v3="TABLE_REF",x3="LITERAL",o7="INTERVAL",a7="LIST",w3="UNNEST",S3="ORDER_BY",Uy="CAST",E3="CASE",C3="WHEN",T3="COLLATE",k3="UNARY",$y="UNARY_POSTFIX",jy="BINARY",Hy="BETWEEN",A3="NOT_BETWEEN",Vy="LOGICAL_OPERATOR",Gy="IN",Wy="FUNCTION",Yu="AGGREGATE",yp="WINDOW",I3="WINDOW_FUNCTION",Yy="WINDOW_DEF",L3="WINDOW_FRAME",qy="WINDOW_EXTENT_EXPR",R3="EXPRESSION",bp="FRAGMENT",Xy="VERBATIM",Ky="PARAM",Zy="WITH_CLAUSE",Qy="WINDOW_CLAUSE",Jy="SELECT_CLAUSE",eb="FROM_CLAUSE",P3="JOIN_CLAUSE",N3="SAMPLE_CLAUSE",tb="SELECT_QUERY",ib="DESCRIBE_QUERY",nb="SET_OPERATION",D3="SCALAR_SUBQUERY";class M3 extends Ui{constructor(t){super(x3);b(this,"value");this.value=t}}function r1(i){switch(typeof i){case"number":return Number.isFinite(i)?`${i}`:"NULL";case"string":return`'${i.replaceAll("'","''")}'`;case"boolean":return i?"TRUE":"FALSE";default:if(i==null)return"NULL";if(i instanceof Date){const e=+i;if(Number.isNaN(e))return"NULL";const t=i.getUTCFullYear(),n=i.getUTCMonth(),s=i.getUTCDate();return e===Date.UTC(t,n,s)?`DATE '${t}-${n+1}-${s}'`:`epoch_ms(${e})`}else return i instanceof RegExp?`'${i.source}'`:`${i}`}}class l7{toString(e){if(!e)throw new Error("Node is null or undefined");if(typeof e.type!="string")throw new Error(`Node type is not a string: ${typeof e.type}, value: ${e.type}`);if(e.type==="CUSTOM")return e.toString(this);const t=this.getVisitMethod(e.type);if(typeof t=="function")return t.call(this,e);throw new Error(`No visitor method for node type: '${e.type}'`)}getVisitMethod(e){switch(e){case Yu:return this.visitAggregate;case Hy:return this.visitBetween;case jy:return this.visitBinary;case E3:return this.visitCase;case Uy:return this.visitCast;case T3:return this.visitCollate;case _p:return this.visitColumnParam;case gp:return this.visitColumnRef;case ib:return this.visitDescribeQuery;case R3:return this.visitExpression;case bp:return this.visitFragment;case eb:return this.visitFromClause;case Wy:return this.visitFunction;case Gy:return this.visitIn;case o7:return this.visitInterval;case P3:return this.visitJoinClause;case a7:return this.visitList;case x3:return this.visitLiteral;case Vy:return this.visitLogicalOperator;case A3:return this.visitNotBetween;case S3:return this.visitOrderBy;case Ky:return this.visitParam;case N3:return this.visitSampleClause;case D3:return this.visitScalarSubquery;case Jy:return this.visitSelectClause;case tb:return this.visitSelectQuery;case nb:return this.visitSetOperation;case v3:return this.visitTableRef;case k3:return this.visitUnary;case $y:return this.visitUnaryPostfix;case w3:return this.visitUnnest;case Xy:return this.visitVerbatim;case C3:return this.visitWhen;case yp:return this.visitWindow;case Qy:return this.visitWindowClause;case Yy:return this.visitWindowDef;case qy:return this.visitWindowExtentExpr;case L3:return this.visitWindowFrame;case I3:return this.visitWindowFunction;case Zy:return this.visitWithClause;default:throw new Error(`Unknown node type: '${e}'`)}}mapToString(e){return e.map(t=>this.toString(t))}}function Go(i){return typeof i=="string"}function r_(i){return Array.isArray(i)}function sb(i){if(i){const e=i;return typeof(e==null?void 0:e.addEventListener)=="function"&&e.dynamic!==!1&&"value"in e}return!1}class rb extends Ui{constructor(t){super(Ky);b(this,"param");this.param=t}get value(){return this.param.value}}const c7="PRECEDING",u7="FOLLOWING",B3="CURRENT ROW",O3="UNBOUNDED";class d7 extends l7{visitAggregate(e){const{name:t,args:n,isDistinct:s,filter:r,order:o}=e,a=[s?"DISTINCT":"",n!=null&&n.length?this.mapToString(n).join(", "):t.toLowerCase()==="count"?"*":"",o.length?`ORDER BY ${this.mapToString(o).join(", ")}`:""].filter(c=>c).join(" "),l=r?` FILTER (WHERE ${this.toString(r)})`:"";return`${t}(${a})${l}`}visitBetween(e){return o1(this,e,"BETWEEN")}visitBinary(e){const{left:t,right:n,op:s}=e;return`(${this.toString(t)} ${s} ${this.toString(n)})`}visitCase(e){const{expr:t,_when:n,_else:s}=e;return"CASE "+(t?`${this.toString(t)} `:"")+this.mapToString(n).join(" ")+(s?` ELSE ${this.toString(s)}`:"")+" END"}visitCast(e){const{expr:t,cast:n}=e;return`(${this.toString(t)})::${n}`}visitCollate(e){const{expr:t,collation:n}=e;return`${this.toString(t)} COLLATE ${n}`}visitColumnParam(e){return this.visitColumnRef(e)}visitColumnRef(e){const{column:t,table:n}=e,s=n?`${this.toString(n)}.`:"",r=t==="*"?"*":ta(t);return`${s}${r}`}visitDescribeQuery(e){const{query:t}=e;return`DESC ${this.toString(t)}`}visitExpression(e){throw new Error(`Unexpected EXPRESSION node type. Node: ${JSON.stringify(e)}`)}visitFragment(e){const{spans:t}=e;return t.map(n=>typeof n=="string"?n:this.toString(n)).join("")}visitFromClause(e){var a;const{expr:t,alias:n,sample:s}=e,r=Y3(t)?`(${this.toString(t)})`:`${this.toString(t)}`;return`${n&&!(hf(t)&&((a=t.table)==null?void 0:a.join("."))===n)?`${r} AS ${ta(n)}`:`${r}`}${s?` TABLESAMPLE ${this.toString(s)}`:""}`}visitFunction(e){const{name:t,args:n}=e;return`${t}(${this.mapToString(n).join(", ")})`}visitIn(e){const{expr:t,values:n}=e;return`(${this.toString(t)} IN (${this.mapToString(n).join(", ")}))`}visitInterval(e){const{steps:t,name:n}=e;return`INTERVAL ${t} ${n}`}visitJoinClause(e){const{left:t,right:n,joinVariant:s,joinType:r,condition:o,using:a,sample:l}=e,c=s==="REGULAR"?"":`${s} `;let u="",d="";s!=="CROSS"&&(u=r!=="INNER"?`${r} `:"",d=o?` ON ${this.toString(o)}`:a?` USING (${this.mapToString(a).join(", ")})`:"");const h=l?` USING SAMPLE ${this.toString(l)}`:"";return`${this.toString(t)} ${c}${u}JOIN ${this.toString(n)}${d}${h}`}visitList(e){const{values:t}=e;return`[${this.mapToString(t).join(", ")}]`}visitLiteral(e){const{value:t}=e;return r1(t)}visitLogicalOperator(e){const{clauses:t,op:n}=e,s=this.mapToString(t);return s.length===0?"":s.length===1?`${s[0]}`:`(${s.join(` ${n} `)})`}visitNotBetween(e){return o1(this,e,"NOT BETWEEN")}visitOrderBy(e){const{expr:t,desc:n,nullsFirst:s}=e,r=n?" DESC":n===!1?" ASC":"",o=s?" NULLS FIRST":s===!1?" NULLS LAST":"";return`${this.toString(t)}${r}${o}`}visitParam(e){const{param:t}=e;return r1(t.value)}visitSampleClause(e){const{size:t,perc:n,method:s,seed:r}=e,o=s?`${s} `:"",a=r!=null?` REPEATABLE (${r})`:"";return`${o}(${t}${n?"%":" ROWS"})${a}`}visitScalarSubquery(e){return`(${this.toString(e.subquery)})`}visitSelectClause(e){const{expr:t,alias:n}=e;return!n||h7(t,n)?this.toString(t):`${this.toString(t)} AS ${ta(n)}`}visitSelectQuery(e){const{_with:t,_select:n,_distinct:s,_from:r,_sample:o,_where:a,_groupby:l,_having:c,_window:u,_qualify:d,_orderby:h,_limitPerc:p,_limit:m,_offset:y}=e,g=[];if(t.length&&g.push(`WITH ${this.mapToString(t).join(", ")}`),g.push(`SELECT${s?" DISTINCT":""} ${this.mapToString(n).join(", ")}`),r.length&&g.push(`FROM ${this.mapToString(r).join(", ")}`),o&&g.push(`USING SAMPLE ${this.toString(o)}`),a.length){const _=this.mapToString(a).filter(S=>S).join(" AND ");_&&g.push(`WHERE ${_}`)}if(l.length&&g.push(`GROUP BY ${this.mapToString(l).join(", ")}`),c.length){const _=this.mapToString(c).filter(S=>S).join(" AND ");_&&g.push(`HAVING ${_}`)}if(u.length&&g.push(`WINDOW ${this.mapToString(u).join(", ")}`),d.length){const _=this.mapToString(d).filter(S=>S).join(" AND ");_&&g.push(`QUALIFY ${_}`)}return h.length&&g.push(`ORDER BY ${this.mapToString(h).join(", ")}`),m&&g.push(`LIMIT ${this.toString(m)}${p?"%":""}`),y!=null&&g.push(`OFFSET ${this.toString(y)}`),g.join(" ")}visitSetOperation(e){const{op:t,queries:n,_with:s,_orderby:r,_limitPerc:o,_limit:a,_offset:l}=e,c=[];return s.length&&c.push(`WITH ${this.mapToString(s).join(", ")}`),c.push(n.join(` ${t} `)),r.length&&c.push(`ORDER BY ${this.mapToString(r).join(", ")}`),a&&c.push(`LIMIT ${this.toString(a)}${o?"%":""}`),l&&c.push(`OFFSET ${this.toString(l)}`),c.join(" ")}visitTableRef(e){const{table:t}=e;return t.map(n=>ta(n)).join(".")}visitUnary(e){const{expr:t,op:n}=e;return`(${n} ${this.toString(t)})`}visitUnaryPostfix(e){const{expr:t,op:n}=e;return`(${this.toString(t)} ${n})`}visitUnnest(e){const{expr:t,recursive:n,maxDepth:s}=e,r=[this.toString(t)];return n&&r.push("recursive := true"),s!=null&&s>0&&r.push(`max_depth := ${s}`),`UNNEST(${r.join(", ")})`}visitVerbatim(e){const{value:t}=e;return t}visitWhen(e){const{when:t,then:n}=e;return`WHEN ${this.toString(t)} THEN ${this.toString(n)}`}visitWindow(e){const{func:t,def:n}=e;return`${this.toString(t)} OVER ${this.toString(n)}`}visitWindowClause(e){const{name:t,def:n}=e;return`${ta(t)} AS ${this.toString(n)}`}visitWindowDef(e){const{name:t,partition:n,order:s,framedef:r}=e,o=t&&ta(t),a=[o,(n==null?void 0:n.length)&&`PARTITION BY ${this.mapToString(n).join(", ")}`,(s==null?void 0:s.length)&&`ORDER BY ${this.mapToString(s).join(", ")}`,r&&this.toString(r)].filter(l=>l);return o&&a.length<2?o:`(${a.join(" ")})`}visitWindowExtentExpr(e){const{scope:t,expr:n}=e;return t===B3?t:`${Sr(n)?this.toString(n):n??O3} ${t}`}visitWindowFrame(e){const{frameType:t,exclude:n,extent:s}=e,[r,o]=Sr(s)?s.value:s,a=a1(this,r,c7),l=a1(this,o,u7);return`${t} BETWEEN ${a} AND ${l}${n?` ${n}`:""}`}visitWindowFunction(e){const{name:t,args:n,ignoreNulls:s,order:r}=e,o=[this.mapToString(n).join(", "),r.length?`ORDER BY ${this.mapToString(r).join(", ")}`:"",s?"IGNORE NULLS":""].filter(a=>a).join(" ");return`${t}(${o})`}visitWithClause(e){const{name:t,query:n,materialized:s}=e,r=s===!0?"MATERIALIZED ":s===!1?"NOT MATERIALIZED ":"";return`${ta(t)} AS ${r}(${this.toString(n)})`}}function h7(i,e){return i instanceof vp&&i.table==null&&i.column===e}function o1(i,e,t){const{extent:n,expr:s}=e;if(!n)return"";const[r,o]=i.mapToString(n);return`(${i.toString(s)} ${t} ${r} AND ${o})`}function a1(i,e,t){const n=Sr(e)?i.toString(e):e;return Sr(e)&&e.type===qy?n:n!=null&&typeof n!="number"?`${n} ${t}`:n===0?B3:n&&Number.isFinite(n)?`${Math.abs(n)} ${t}`:`${O3} ${t}`}const f7=new d7;s7(f7);class p7 extends Ui{constructor(t,n=[]){super(Wy);b(this,"name");b(this,"args");this.name=t,this.args=n}}function qs(i,...e){return new p7(i,F3(e).map(_i))}function Rr(i,...e){return new ru(i,F3(e).map(_i))}function su(i,e){return i.flat().filter(t=>t!=null).map(t=>e(t))}function ba(i){return su(i,_i)}function F3(i){const e=i.length;let t=e;for(;t>0&&i[t-1]===void 0;--t);return t<e?i.slice(0,t):i}class m7 extends go{constructor(t,n){super(Qy);b(this,"name");b(this,"def");this.name=t,this.def=n}}class nl extends Ui{constructor(t,n=new z3){super(yp);b(this,"func");b(this,"def");this.func=t,this.def=n}over(t){return new nl(this.func,this.def.over(t))}partitionby(...t){return new nl(this.func,this.def.partitionby(...t))}orderby(...t){return new nl(this.func,this.def.orderby(...t))}frame(t){return new nl(this.func,this.def.frame(t))}}class z3 extends go{constructor(t,n,s,r){super(Yy);b(this,"name");b(this,"partition");b(this,"order");b(this,"framedef");this.name=t,this.partition=n,this.order=s,this.framedef=r}over(t){return Rd(this,{name:t})}partitionby(...t){return Rd(this,{partition:ba(t)})}orderby(...t){return Rd(this,{order:ba(t)})}frame(t){return Rd(this,{framedef:t})}}function Rd(i,e){return new z3(e.name??i.name,e.partition??i.partition,e.order??i.order,e.framedef??i.framedef)}function ob(i){return i instanceof vp}class vp extends Ui{constructor(t,n){super(t);b(this,"table");this.table=n}get column(){return""}}class U3 extends vp{constructor(t,n){super(gp,n);b(this,"name");this.name=t}get column(){return this.name}}class g7 extends vp{constructor(t,n){super(_p,n);b(this,"param");this.param=t}get column(){return`${this.param.value}`}}function cn(i,e){const t=y7(e);return sb(i)?new g7(new rb(i),t):new U3(i,t)}class $3 extends Ui{constructor(t,n){super(Xy);b(this,"value");b(this,"hint");this.value=t,this.hint=n}}function An(i){return new M3(i)}function _7(i,e){return new $3(i,e)}function hf(i){return i instanceof j3}class j3 extends Ui{constructor(t){super(v3);b(this,"table");this.table=[t].flat()}get name(){return this.table[this.table.length-1]}}function ab(...i){const e=su(i,String);return e!=null&&e.length?new j3(e):void 0}function _i(i){return Go(i)?v7(i):H3(i)}function bh(i){return Go(i)?_7(i):H3(i)}function H3(i){return i instanceof Ui?i:sb(i)?new rb(i):An(i)}function y7(i){return V3(i)}function b7(i){return V3(i)}function V3(i){return Go(i)?x7(i):r_(i)?ab(i):i}function v7(i){const e=b3(i);return cn(e.pop(),ab(e))}function x7(i){return ab(b3(i))}class ru extends Ui{constructor(t,n,s=!1,r=null,o=[]){super(Yu);b(this,"name");b(this,"args");b(this,"isDistinct");b(this,"filter");b(this,"order");this.name=t,this.args=n,this.isDistinct=s,this.filter=r,this.order=ba([o])}distinct(t=!0){return new ru(this.name,this.args,t,this.filter,this.order)}where(t){return Go(t)&&(t=bh(t)),new ru(this.name,this.args,this.isDistinct,t,this.order)}argOrder(t){return new ru(this.name,this.args,this.isDistinct,this.filter,t)}window(){return new nl(this)}partitionby(...t){return this.window().partitionby(...t)}orderby(...t){return this.window().orderby(...t)}frame(t){return this.window().frame(t)}}const w7=["any_value","approx_count_distinct","approx_quantile","arbitrary","arg_max","arg_max_null","arg_min","arg_min_null","array_agg","avg","bit_and","bit_or","bit_xor","bitstring_agg","bool_and","bool_or","corr","count","count_star","covar_pop","covar_samp","entropy","favg","first","fsum","geomean","kurtosis_pop","kurtosis","last","mad","max","max_by","median","min","min_by","mode","product","quantile","quantile_cont","quantile_disc","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_sxx","regr_sxy","regr_syy","regr_slope","reservoir_quantile","skewness","stddev","stddev_pop","stddev_samp","string_agg","sum","variance","var_pop","var_samp"];class S7 extends Ui{constructor(t,n,s){super(t);b(this,"expr");b(this,"extent");this.expr=n,this.extent=s}toSQL(t){const{extent:n,expr:s}=this;return n?`(${s} ${t} ${n[0]} AND ${n[1]})`:""}}class E7 extends S7{constructor(e,t){super(Hy,e,t)}}class C7 extends Ui{constructor(t,n,s){super(jy);b(this,"op");b(this,"left");b(this,"right");this.op=t,this.left=n,this.right=s}}class T7 extends Ui{constructor(t,n){super(Uy);b(this,"expr");b(this,"cast");this.expr=t,this.cast=n}}class k7 extends Ui{constructor(t){super(bp);b(this,"spans");this.spans=t}}class G3 extends go{}class yu extends G3{constructor(t,n,s){super(eb);b(this,"expr");b(this,"alias");b(this,"sample");this.expr=t,this.alias=n,this.sample=s}as(t){return new yu(this.expr,t,this.sample)}}class A7 extends Ui{constructor(t,n){super(Gy);b(this,"expr");b(this,"values");this.expr=t,this.values=n}}class W3 extends Ui{constructor(t,n){super(Vy);b(this,"op");b(this,"clauses");this.op=t,this.clauses=n}}class I7 extends W3{constructor(e){super("AND",e)}}class L7 extends W3{constructor(e){super("OR",e)}}class R7 extends go{constructor(t,n=!1,s,r){super(N3);b(this,"size");b(this,"perc");b(this,"method");b(this,"seed");this.size=t,this.perc=n,this.method=s,this.seed=r}}class P7 extends go{constructor(t,n){super(Jy);b(this,"expr");b(this,"alias");this.expr=t,this.alias=n}}class l1 extends go{constructor(t,n,s=null){super(Zy);b(this,"name");b(this,"query");b(this,"materialized");this.name=t,this.query=n,this.materialized=s}}function Y3(i){return i instanceof Ai}function xp(i){return i instanceof Il}function N7(i){return i instanceof wp}class Ai extends Ui{constructor(t){super(t);b(this,"_with",[]);b(this,"_orderby",[]);b(this,"_limitPerc",!1);b(this,"_limit");b(this,"_offset");b(this,"cteFor",null)}static with(...t){return new D7(...t)}static select(...t){return new Il().select(...t)}static from(...t){return new Il().from(...t)}static union(...t){return new ar("UNION",t.flat())}static unionByName(...t){return new ar("UNION BY NAME",t.flat())}static unionAll(...t){return new ar("UNION ALL",t.flat())}static unionAllByName(...t){return new ar("UNION ALL BY NAME",t.flat())}static intersect(...t){return new ar("INTERSECT",t.flat())}static intersectAll(...t){return new ar("INTERSECT ALL",t.flat())}static except(...t){return new ar("EXCEPT",t.flat())}static exceptAll(...t){return new ar("EXCEPT ALL",t.flat())}static describe(t){return new wp(t)}get subqueries(){return[]}clone(){return this}setCteFor(t){this.cteFor=t}with(...t){const n=[],s=(r,o)=>{const a=o.clone();a.setCteFor(this),n.push(new l1(r,a))};return t.flat().forEach(r=>{if(r instanceof l1)n.push(r);else if(r!=null)for(const o in r)s(o,r[o])}),this._with=this._with.concat(n),this}orderby(...t){return this._orderby=this._orderby.concat(ba(t)),this}limitPercent(t){return this._limitPerc=!0,this._limit=_i(t),this}limit(t){return this._limitPerc=!1,this._limit=_i(t),this}offset(t){return this._offset=_i(t),this}}class Il extends Ai{constructor(){super(tb);b(this,"_select",[]);b(this,"_from",[]);b(this,"_where",[]);b(this,"_sample");b(this,"_groupby",[]);b(this,"_having",[]);b(this,"_window",[]);b(this,"_qualify",[]);b(this,"_distinct",!1)}get subqueries(){const t=this.cteFor||this,s=(t instanceof Il?t._with:[]).reduce((o,a)=>(o[a.name]=a.query,o),{}),r=[];return this._from.forEach(o=>{if(o instanceof yu){const{expr:a}=o;if(Y3(a))r.push(a);else if(hf(a)){const l=s[a.name];l&&r.push(l)}}}),r}clone(){return Object.assign(new Il,this)}select(...t){const n=new Set,s=[],r=(o,a)=>{const l=vm(a);n.add(l),o&&s.push(new P7(_i(o),l))};return t.flat().forEach(o=>{if(o!=null)if(Go(o))r(o,o);else if(ob(o))r(o,o.column);else if(r_(o))r(o[1],o[0]);else if(Sr(o))r(o,`${o}`);else for(const a in o)r(o[a],a)}),this._select=this._select.filter(o=>!n.has(o.alias)).concat(s),this}setSelect(...t){return this._select=[],this.select(...t)}distinct(t=!0){return this._distinct=!!t,this}from(...t){const n=[],s=(r,o)=>{n.push(new yu(b7(r),vm(o)))};return t.flat().forEach(r=>{if(r!=null)if(r instanceof G3)n.push(r);else if(Go(r))s(r,r);else if(hf(r))s(r,r.name);else if(Sr(r))s(r);else if(r_(r))s(r[1],r[0]);else for(const o in r)s(r[o],o)}),this._from=this._from.concat(n),this}setFrom(...t){return this._from=[],this.from(...t)}sample(t,n,s){let r;if(typeof t=="number"){const o=t>0&&t<1,a=o?t*100:Math.floor(t);r=new R7(a,o,n,s)}else r=t;return this._sample=r??void 0,this}where(...t){return this._where=this._where.concat(su(t,bh)),this}setWhere(...t){return this._where=[],this.where(...t)}groupby(...t){return this._groupby=this._groupby.concat(ba(t)),this}setGroupby(...t){return this._groupby=[],this.groupby(...t)}having(...t){return this._having=this._having.concat(su(t,bh)),this}window(...t){const n=[];return t.flat().forEach(s=>{if(s!=null)for(const r in s)n.push(new m7(vm(r),s[r]))}),this._window=this._window.concat(n),this}qualify(...t){return this._qualify=this._qualify.concat(su(t,bh)),this}}class wp extends go{constructor(t){super(ib);b(this,"query");this.query=t}clone(){return new wp(this.query.clone())}}class ar extends Ai{constructor(t,n){super(nb);b(this,"op");b(this,"queries");this.op=t,this.queries=n}setCteFor(t){super.setCteFor(t);const{queries:n,cteFor:s}=this;s&&n.forEach(r=>r.setCteFor(s))}get subqueries(){return this.queries}clone(){const{op:t,queries:n,...s}=this;return Object.assign(new ar(t,n),s)}}class D7{constructor(...e){b(this,"_with");this._with=e}select(...e){return Ai.select(...e).with(...this._with)}from(...e){return Ai.from(...e).with(...this._with)}union(...e){return Ai.union(...e).with(...this._with)}unionByName(...e){return Ai.unionByName(...e).with(...this._with)}unionAll(...e){return Ai.unionAll(...e).with(...this._with)}unionAllByName(...e){return Ai.unionAllByName(...e).with(...this._with)}intersect(...e){return Ai.intersect(...e).with(...this._with)}intersectAll(...e){return Ai.intersectAll(...e).with(...this._with)}except(...e){return Ai.except(...e).with(...this._with)}exceptAll(...e){return Ai.exceptAll(...e).with(...this._with)}}class M7 extends Ui{constructor(t,n,s){super(t);b(this,"op");b(this,"expr");this.op=n,this.expr=s}}class B7 extends M7{constructor(e,t){super($y,e,t)}}function O7(i,e){return Rr("arg_max",i,e)}function F7(i,e){return Rr("arg_min",i,e)}function q3(i){return Rr("avg",i)}function lb(i){return Rr("count",i)}function z7(i){return Rr("max",i)}function U7(i){return Rr("min",i)}function $7(i,e){return Rr("regr_avgx",i,e)}function j7(i,e){return Rr("regr_avgy",i,e)}function H7(i,e){return Rr("regr_count",i,e)}function gi(i){return Rr("sum",i)}function X3(i,e){return new T7(_i(i),e)}function V7(i){return X3(i,"INTEGER")}function c1(i){return X3(i,"DOUBLE")}function G7(i){return qs("epoch_ms",i)}function cb(i){return qs("exp",i)}function W7(i){return qs("log",i)}function ou(i){return qs("ln",i)}function Ll(i){return qs("sign",i)}function bu(i){return qs("abs",i)}function ff(i){return qs("sqrt",i)}function Y7(i){return qs("ceil",i)}function q7(i){return qs("floor",i)}function X7(i,e){return qs("round",i,e)}function K3(i,e){return new B7(i,_i(e))}function Qo(i,e,t){return new C7(i,_i(e),_i(t))}function Z3(...i){return new I7(ba(i))}function K7(...i){return new L7(ba(i))}function Z7(i){return K3("IS NULL",i)}function Q3(i){return K3("IS NOT NULL",i)}function Q7(i,e){return Qo("+",i,e)}function Qi(i,e){return Qo("-",i,e)}function mn(i,e){return Qo("*",i,e)}function Fi(i,e){return Qo("/",i,e)}function ys(i,e){return Qo("**",i,e)}function J7(i,e){return Qo("=",i,e)}function ub(i,e){return Qo("<=",i,e)}function db(i,e){return Qo(">=",i,e)}function o_(i,e){return new E7(_i(i),e==null?void 0:e.map(_i))}function a_(i,e){return new A7(_i(i),e.map(_i))}function qu(i,...e){return new k7(e8(i,e))}function e8(i,e){const t=[i[0]],n=e.length;for(let s=0,r=0;s<n;){const o=e[s];Sr(o)?t[++r]=o:sb(o)?t[++r]=new rb(o):t[r]+=Go(o)?o:`${An(o)}`;const a=i[++s];Sr(t[r])?t[++r]=a:t[r]+=a}return t.filter(s=>s).map(s=>Go(s)?new $3(s):s)}function J3(...i){return qs("coalesce",...i)}const eC={[Yu]:["args","order","filter"],[Hy]:["expr","extent"],[jy]:["left","right"],[E3]:["expr","_when","_else"],[Uy]:["expr"],[T3]:["expr"],[_p]:["param","table"],[gp]:["table"],[ib]:["query"],[R3]:["node"],[bp]:["spans"],[eb]:["expr"],[Wy]:["args"],[Gy]:["expr","values"],[P3]:["left","right","on","using","sample"],[Vy]:["clauses"],[A3]:["expr","extent"],[S3]:["expr"],[Ky]:["value"],[D3]:["subquery"],[Jy]:["expr"],[tb]:["_with","_select","_from","_where","_sample","_groupby","_having","_window","_qualify","_orderby"],[nb]:["queries","_orderby"],[k3]:["expr"],[$y]:["expr"],[w3]:["expr"],[C3]:["when","then"],[yp]:["func","def"],[Qy]:["def"],[Yy]:["partition","order","framedef"],[qy]:["expr"],[L3]:["extent"],[I3]:["args"],[Zy]:["query"]};function l_(i,e){if(e.has(i))return e.get(i);if(Sr(i)){const t=eC[i.type],n=(t==null?void 0:t.length)??0;if(n>0){i=i.clone();for(let s=0;s<n;++s){const r=t[s],o=i[r];if(Array.isArray(o)){const a=i[r]=o.slice(),l=o.length;for(let c=0;c<l;++c)a[c]=l_(o[c],e)}else o&&(i[r]=l_(o,e))}}}return i}function vu(i,e){if(!Sr(i))return;const t=e(i);if(t)return t;const n=eC[i.type],s=(n==null?void 0:n.length)??0;for(let r=0;r<s;++r){const o=i[n[r]];if(Array.isArray(o)){const a=o.length;for(let l=0;l<a;++l)if(o[l]&&Number(vu(o[l],e))<0)return t}else if(o&&Number(vu(o,e))<0)return-1}}const t8=new RegExp(`^(${w7.join("|")})$`),i8=/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\w+\()/g;function n8(i){return i.split(i8).some(e=>e.endsWith("(")&&t8.test(e.slice(0,-1)))}function hb(i){let e=0;return vu(i,t=>{switch(t.type){case yp:return-1;case Yu:return e|=1,-1;case bp:case Xy:{let n=`${t}`.toLowerCase();const s=n.indexOf("(select ");return s>=0&&(n=n.slice(0,s)),n.includes(") over ")?-1:n8(n)?(e|=2,-1):1}}}),e}function s8(i){const e=new Set;return vu(i,t=>{t.type===Yu&&e.add(t)}),Array.from(e)}function tC(i){const e={};return vu(i,t=>{(t.type===gp||t.type===_p)&&(e[`${t}`]=t)}),Object.values(e)}function r8(i,e,{replace:t=!1,temp:n=!1,view:s=!1}={}){return"CREATE"+(t?" OR REPLACE ":" ")+(n?"TEMP ":"")+(s?"VIEW":"TABLE")+(t?" ":" IF NOT EXISTS ")+i+" AS "+e}function vh(i){return i}function u1(){return{apply:vh,invert:vh,sqlApply:_i,sqlInvert:vh}}function o8({base:i=null}={}){if(i==null||i===Math.E)return{apply:Math.log,invert:Math.exp,sqlApply:e=>ou(e),sqlInvert:e=>cb(e)};if(i===10)return{apply:Math.log10,invert:e=>Math.pow(10,e),sqlApply:e=>W7(e),sqlInvert:e=>ys(10,e)};{const e=+i;return{apply:t=>Math.log(t)/Math.log(e),invert:t=>Math.pow(e,t),sqlApply:t=>Fi(ou(t),ou(e)),sqlInvert:t=>ys(e,t)}}}function a8({constant:i=1}={}){const e=+i;return{apply:t=>Math.sign(t)*Math.log1p(Math.abs(t)),invert:t=>Math.sign(t)*Math.exp(Math.abs(t)-e),sqlApply:t=>(t=_i(t),mn(Ll(t),ou(Q7(e,bu(t))))),sqlInvert:t=>mn(Ll(t),Qi(cb(bu(t)),e))}}function l8(){return{apply:i=>Math.sign(i)*Math.sqrt(Math.abs(i)),invert:i=>Math.sign(i)*i*i,sqlApply:i=>(i=_i(i),mn(Ll(i),ff(bu(i)))),sqlInvert:i=>mn(Ll(i),ys(i,2))}}function c8({exponent:i=1}={}){const e=+i;return{apply:t=>Math.sign(t)*Math.pow(Math.abs(t),e),invert:t=>Math.sign(t)*Math.pow(Math.abs(t),1/e),sqlApply:t=>(t=_i(t),mn(Ll(t),ys(bu(t),e))),sqlInvert:t=>mn(Ll(t),ys(bu(t),Fi(1,e)))}}function d1(){return{apply:i=>Number(i),invert:i=>new Date(i),sqlApply:i=>i instanceof Date?An(+i):h8(i)?An(Number(i.value)):G7(i),sqlInvert:vh}}const u8={identity:u1,linear:u1,log:o8,symlog:a8,sqrt:l8,pow:c8,time:d1,utc:d1};function d8(i){const e=u8[i.type];if(!e)throw new Error(`Unrecognized scale type: ${i.type}`);return{...i,...e(i)}}function h8(i){return i instanceof M3&&i.value instanceof Date}function iC(i){let e=2166136261;for(let t=0,n=i.length;t<n;++t){const s=i.charCodeAt(t),r=s&65280;r&&(e=h1(e^r>>8)),e=h1(e^s&255)}return f8(e)>>>0}function h1(i){return i+(i<<1)+(i<<4)+(i<<7)+(i<<8)+(i<<24)}function f8(i){return i+=i<<13,i^=i>>>7,i+=i<<3,i^=i>>>17,i+=i<<5,i&4294967295}function p8(i,e,t){switch(i.name){case"count":case"count_star":return m8(e,i);case"sum":return sC(e,i);case"avg":return g8(e,i);case"geomean":return _8(e,i);case"arg_max":return y8(e,i);case"arg_min":return b8(e,i);case"variance":case"var_samp":return Pd(e,i,t);case"var_pop":return Pd(e,i,t,!1);case"stddev":case"stddev_samp":return ff(Pd(e,i,t));case"stddev_pop":return ff(Pd(e,i,t,!1));case"covar_samp":return xh(e,i,t);case"covar_pop":return xh(e,i,t,!1);case"corr":return f1(e,i,t);case"regr_count":return Wl(e,i).expr;case"regr_avgx":return oC(e,i);case"regr_avgy":return aC(e,i);case"regr_syy":return u_(e,0,i,t);case"regr_sxx":return u_(e,1,i,t);case"regr_sxy":return xh(e,i,t,null);case"regr_slope":return lC(e,i,t);case"regr_intercept":return v8(e,i,t);case"regr_r2":return ys(f1(e,i,t),2);case"max":case"min":case"bit_and":case"bit_or":case"bit_xor":case"bool_and":case"bool_or":case"product":{const n=nC(i);return e[n]=i,qu`${i.name}("${n}")`}default:return null}}function nC(i){return"pre_"+iC(`${i}`).toString(16)}function Ji(i,e,t){const n=t==null?void 0:t.filter;n&&(e=e.filter?e.where(Z3(n,e.filter)):e.where(n));const s=nC(e);return i[s]=e,s}function fb(i,e){const t=Ji(i,lb(e.args[0]),e);return{expr:J3(gi(t),0),name:t}}function m8(i,e){return J3(sC(i,e),0)}function sC(i,e){return gi(Ji(i,e))}function g8(i,e){const t=Ji(i,e),{expr:n,name:s}=fb(i,e);return Fi(gi(mn(t,s)),n)}function _8(i,e){const t=e.args[0],n=Ji(i,gi(ou(t)),e),{expr:s}=fb(i,e);return cb(Fi(gi(n),s))}function y8(i,e){const t=Ji(i,e),n=Ji(i,z7(e.args[1]),e);return O7(t,n)}function b8(i,e){const t=Ji(i,e),n=Ji(i,U7(e.args[1]),e);return F7(t,n)}function Pd(i,e,t,n=!0){const s=e.args[0],{expr:r}=fb(i,e),o=Qi(s,t(s)),a=Ji(i,gi(ys(o,2)),e),l=Ji(i,gi(o),e),c=n?Qi(r,1):r;return Fi(Qi(gi(a),Fi(ys(gi(l),2),r)),c)}function xh(i,e,t,n=!0){const{expr:s}=Wl(i,e),r=rC(i,e,t),o=xu(i,1,e,t),a=xu(i,0,e,t),l=Qi(r,Fi(mn(o,a),s));return n===null?l:n?Fi(l,Qi(s,1)):Fi(l,s)}function f1(i,e,t){const{expr:n}=Wl(i,e),s=rC(i,e,t),r=c_(i,1,e,t),o=c_(i,0,e,t),a=xu(i,1,e,t),l=xu(i,0,e,t),c=Qi(r,Fi(ys(a,2),n)),u=Qi(o,Fi(ys(l,2),n));return Fi(Qi(s,Fi(mn(a,l),n)),ff(mn(c,u)))}function Wl(i,e){const[t,n]=e.args,s=Ji(i,H7(t,n),e);return{expr:gi(s),name:s}}function xu(i,e,t,n){const s=t.args,r=s[e],o=s[1-e],a=gi(Qi(r,n(r))).where(Q3(o));return gi(Ji(i,a,t))}function c_(i,e,t,n){const s=t.args,r=s[e],o=s[1-e],a=gi(ys(Qi(r,n(r)),2)).where(Q3(o));return gi(Ji(i,a,t))}function rC(i,e,t){const[n,s]=e.args,r=gi(mn(Qi(s,t(s)),Qi(n,t(n))));return gi(Ji(i,r,e))}function oC(i,e){const[t,n]=e.args,{expr:s,name:r}=Wl(i,e),o=Ji(i,$7(t,n),e);return Fi(gi(mn(o,r)),s)}function aC(i,e){const[t,n]=e.args,{expr:s,name:r}=Wl(i,e),o=Ji(i,j7(t,n),e);return Fi(gi(mn(o,r)),s)}function u_(i,e,t,n){const{expr:s}=Wl(i,t),r=xu(i,e,t,n),o=c_(i,e,t,n);return Qi(o,Fi(ys(r,2),s))}function lC(i,e,t){const n=xh(i,e,t,null),s=u_(i,1,e,t);return Fi(n,s)}function v8(i,e,t){const n=oC(i,e),s=aC(i,e),r=lC(i,e,t);return Qi(s,mn(r,n))}function x8(i){if(!i.filterStable)return null;const e=i.query();if(!xp(e))return null;const t=pf(e,l=>{const c=l._from[0],u=c instanceof yu&&c.expr;return hf(u)?u.name:u});if(typeof t!="string")return null;const n=new Map,s={},r={},o=[],a=l=>{const c=l.column,u=pf(e,d=>{var h;return(h=d._select.find(p=>p.alias===c))==null?void 0:h.expr});return qu`(SELECT avg(${u??l}) FROM "${t}")`};for(const{alias:l,expr:c}of e._select){if(hb(c)>1)return null;const u=s8(c);if(u.length===0)o.push(l),s[l]=c;else{for(const d of u){if(d.isDistinct)return null;const h=p8(d,s,a);if(!h)return null;n.set(d,h)}r[l]=l_(c,n)}}return n.size?{group:o,preagg:s,output:r}:null}function pf(i,e){const t=i.subqueries;if(xp(i)&&t.length===0)return e(i);const n=pf(t[0],e);for(let s=1;s<t.length;++s){const r=pf(t[s],e);if(r!==void 0&&r!==n)return NaN}return n}const w8={skip:!0,result:null};class S8{constructor(e,{schema:t="mosaic",enabled:n=!0}={}){b(this,"entries");b(this,"active");b(this,"mc");b(this,"_schema");b(this,"_enabled");this.entries=new Map,this.active=null,this.mc=e,this._schema=t,this._enabled=n}set enabled(e){this._enabled!==e&&(e||this.clear(),this._enabled=e)}get enabled(){return this._enabled}set schema(e){this._schema!==e&&(this.clear(),this._schema=e)}get schema(){return this._schema}dropSchema(){return this.clear(),this.mc.exec(`DROP SCHEMA IF EXISTS "${this.schema}" CASCADE`)}clear(){this.entries.clear(),this.active=null}request(e,t,n){var d;if(!this.enabled||n==null)return null;const{entries:s,mc:r,schema:o}=this,{source:a}=n;if(!a||this.active&&(this.active.source!==a&&this.clear(),((d=this.active)==null?void 0:d.source)===null))return null;let{active:l}=this;if(!l&&(n.predicate==null||(this.active=l=E8(n),l.source===null)))return null;if(s.has(e))return s.get(e);const c=x8(e);let u;if(!c)u=null;else if(t.skip(e,n))u=w8;else{const h=t.remove(a).predicate(e);u=k8(e.query(h),l,c,o),u.result=r.exec([`CREATE SCHEMA IF NOT EXISTS ${o}`,r8(u.table,u.create,{temp:!1})]),u.result.catch(p=>r.logger().error(p))}return s.set(e,u),u}}function E8(i){const{source:e,meta:t}=i,n=i.predicate,s=tC(n).map(a=>a.column);let r,o;if(!t||!s)return{source:null,columns:o,predicate:r};switch(t.type){case"point":r=a=>a,o=Object.fromEntries(s.map(a=>[`${a}`,_i(a)]));break;case"interval":{const{scales:a,bin:l,pixelSize:c=1}=t;if(!a)break;const u=a.map(d=>T8(d,c,l));u.some(d=>!d)||(u.length===1?(r=d=>{var h;return d?o_("active0",(h=d.extent)==null?void 0:h.map(u[0])):[]},o={active0:u[0](n.expr)}):(r=d=>d?Z3(d.clauses.map((h,p)=>{var m;return o_(`active${p}`,(m=h.extent)==null?void 0:m.map(u[p]))})):[],o=Object.fromEntries(n.clauses.map((d,h)=>[`active${h}`,u[h](d.expr)]))))}}return{source:o?e:null,columns:o,predicate:r}}const C8={ceil:Y7,round:X7};function T8(i,e,t){const{type:n,domain:s,range:r,apply:o,sqlApply:a}=d8(i);if(!o)return;const l=C8[`${t}`.toLowerCase()]||q7,c=s.map(y=>Number(y)),u=o(Math.min(...c)),d=o(Math.max(...c)),h=(n==="identity"?1:Math.abs(r[1]-r[0])/(d-u))/e,p=h===1?y=>y:y=>mn(c1(h),y),m=u===0?y=>y:y=>Qi(y,c1(u));return y=>V7(l(p(m(a(y)))))}function k8(i,e,t,n){const{group:s,output:r,preagg:o}=t,{columns:a}=e,l=i.setSelect({...o,...a}).groupby(Object.keys(a)),[c]=l.subqueries;if(c){const g=Object.values(a).flatMap(_=>tC(_).map(S=>S.column));A8(c,g)}const u=l._having,d=l._orderby;l._having=[],l._orderby=[];const h=l.toString(),p=(iC(h)>>>0).toString(16),m=`${n}.preagg_${p}`,y=Ai.select(s,r).from(m).groupby(s).having(u).orderby(d);return new L8({table:m,create:h,active:e,select:y})}function A8(i,e){const t=new Set,n=s=>{if(!t.has(s)){if(t.add(s),xp(s)&&s._from.length&&(s.select(e),I8(s))){const r=new Set(s._groupby.flatMap(o=>o instanceof U3?[o.name]:[]));s.groupby(e.filter(o=>!r.has(o)))}s.subqueries.forEach(n)}};n(i)}function I8(i){return i._groupby.length>0||i._select.some(e=>hb(e))}class L8{constructor({table:e,create:t,active:n,select:s}){b(this,"table");b(this,"create");b(this,"result");b(this,"active");b(this,"select");b(this,"skip");this.table=e,this.create=t,this.result=null,this.active=n,this.select=s,this.skip=!1}query(e){return this.select.clone().where(this.active.predicate(e))}}function d_(){return{debug(){},info(){},log(){},warn(){},error(){},group(){},groupCollapsed(){},groupEnd(){}}}const oa=Object.freeze({pending:Symbol("pending"),ready:Symbol("ready"),error:Symbol("error"),done:Symbol("done")});class pb extends Promise{constructor(){let t,n;super((s,r)=>{t=s,n=r});b(this,"_resolve");b(this,"_reject");b(this,"_state");b(this,"_value");this._resolve=t,this._reject=n,this._state=oa.pending,this._value=void 0}fulfill(t){if(this._value!==void 0){if(t!==void 0)throw Error("Promise is ready and fulfill has a provided value");this._resolve(this._value)}else{if(t===void 0)throw Error("Promise is neither ready nor has provided value");this._resolve(t)}return this._state=oa.done,this}ready(t){return this._state=oa.ready,this._value=t,this}reject(t){return this._state=oa.error,this._reject(t),this}get state(){return this._state}}pb.prototype.constructor=Promise;function R8(i){return typeof requestAnimationFrame<"u"?requestAnimationFrame(i):typeof setImmediate<"u"?setImmediate(i):setTimeout(i)}function P8(i,e){let t=[],n=0;function s(){const r=N8(t,e);t=[],n=0;for(const o of r)M8(o,i),F8(o,e)}return{add(r,o){r.request.type==="arrow"?(n||(n=R8(()=>s())),t.push({entry:r,priority:o,index:t.length})):i(r,o)}}}function N8(i,e){const t=[],n=new Map;for(const s of i){const{entry:{request:r}}=s,o=D8(r.query,e);if(!n.has(o)){const a=[];t.push(a),n.set(o,a)}n.get(o).push(s)}return t}function D8(i,e){const t=`${i}`;if(xp(i)&&!e.get(t)){if(i._where.length||i._qualify.length||i._having.length||i._orderby.length||i._distinct)return t;const n=i.clone().setSelect("*"),s=i._groupby;if(s.length){const r={};i._select.forEach(({alias:o,expr:a})=>r[o]=a),n.setGroupby(s.map(o=>ob(o)&&r[o.column]||o))}else i._select.some(r=>hb(r.expr))&&n.setGroupby("ALL");return`${n}`}else return t}function M8(i,e){if(B8(i))e({request:{type:"arrow",cache:!1,query:i.query=O8(i)},result:i.result=new pb});else for(const{entry:t,priority:n}of i)e(t,n)}function B8(i){if(i.length>1){const e=`${i[0].entry.request.query}`;for(let t=1;t<i.length;++t)if(e!==`${i[t].entry.request.query}`)return!0}return!1}function O8(i){const e=i.maps=[],t=new Map;for(const r of i){const o=r.entry.request.query,a=[];e.push(a);for(const{alias:l,expr:c}of o._select){const u=`${c}`;t.has(u)||t.set(u,[`col${t.size}`,c]);const[d]=t.get(u);a.push([d,l])}}const n=i[0].entry.request.query.clone(),s=n._groupby;if(s.length){const r={};i.maps[0].forEach(([o,a])=>r[a]=o),n.setGroupby(s.map(o=>ob(o)&&r[o.column]||o))}return n.setSelect(Array.from(t.values()))}async function F8(i,e){const{maps:t,query:n,result:s}=i;if(!t)return;let r;try{r=await s}catch(a){for(const{entry:l}of i)l.result.reject(a);return}const o=N7(n);i.forEach(({entry:a},l)=>{const{request:c,result:u}=a,d=t[l],h=o&&d?U8(r,d):d?z8(r,d):r;c.cache&&e.set(String(c.query),h),u.fulfill(h)})}function z8(i,e){return i.select(e.map(t=>t[0]),e.map(t=>t[1]))}function U8(i,e){const t=new Map(e),n=[];for(const s of i)t.has(s.column_name)&&n.push({...s,column_name:t.get(s.column_name)});return n}const $8=typeof requestIdleCallback<"u"?requestIdleCallback:setTimeout;function j8(){return{get:()=>{},set:(i,e)=>e,clear:()=>{}}}function H8({max:i=1e3,ttl:e=10800*1e3}={}){let t=new Map;function n(){const s=performance.now()-e;let r=null,o=1/0;for(const[a,l]of t){const{last:c}=l;c<o&&(r=a,o=c),s>c&&t.delete(a)}r&&t.delete(r)}return{get(s){const r=t.get(s);if(r)return r.last=performance.now(),r.value},set(s,r){return t.set(s,{last:performance.now(),value:r}),t.size>i&&$8(n),r},clear(){t=new Map}}}class V8{constructor(e){b(this,"queue");this.queue=Array.from({length:e},()=>({head:null,tail:null}))}isEmpty(){return this.queue.every(e=>!e.head)}insert(e,t){const n=this.queue[t];if(!n)throw new Error(`Invalid queue priority rank: ${t}`);const s={item:e,next:null};n.head===null?n.head=n.tail=s:n.tail=n.tail.next=s}remove(e){for(const t of this.queue){let{head:n,tail:s}=t;for(let r=null,o=n;o;r=o,o=o.next)e(o.item)&&(o===n?n=o.next:r.next=o.next,o===s&&(s=r||n));t.head=n,t.tail=s}}next(){for(const e of this.queue){const{head:t}=e;if(t!==null)return e.head=t.next,e.tail===t&&(e.tail=null),t.item}}}const sl=Object.freeze({High:0,Normal:1,Low:2});class G8{constructor(e=32){b(this,"queue");b(this,"db");b(this,"clientCache");b(this,"_logger");b(this,"_logQueries");b(this,"_consolidate");b(this,"pendingResults");b(this,"maxConcurrentRequests");b(this,"pendingExec");this.queue=new V8(3),this.db=null,this.clientCache=null,this._logger=d_(),this._logQueries=!1,this._consolidate=null,this.pendingResults=[],this.maxConcurrentRequests=e,this.pendingExec=!1}next(){if(this.queue.isEmpty()||this.pendingResults.length>this.maxConcurrentRequests||this.pendingExec)return;const e=this.queue.next();if(!e)return;const{request:t,result:n}=e;this.pendingResults.push(n),t.type==="exec"&&(this.pendingExec=!0),this.submit(t,n).finally(()=>{for(;this.pendingResults.length&&this.pendingResults[0].state!==oa.pending;){const s=this.pendingResults.shift();s.state===oa.ready?s.fulfill():s.state===oa.done&&this._logger.warn("Found resolved query in pending results.")}t.type==="exec"&&(this.pendingExec=!1),this.next()})}enqueue(e,t=sl.Normal){this.queue.insert(e,t),this.next()}async submit(e,t){try{const{query:n,type:s,cache:r=!1,options:o}=e,a=n?`${n}`:null;if(r){const d=this.clientCache.get(a);if(d){const h=await d;this._logger.debug("Cache"),t.ready(h);return}}const l=performance.now();this._logQueries&&this._logger.debug("Query",{type:s,sql:a,...o});const c=this.db.query({type:s,sql:a,...o});r&&this.clientCache.set(a,c);const u=await c;r&&this.clientCache.set(a,u),this._logger.debug(`Request: ${(performance.now()-l).toFixed(1)}`),t.ready(s==="exec"?null:u)}catch(n){t.reject(n)}}cache(e){return e!==void 0?this.clientCache=e===!0?H8():e||j8():this.clientCache}logger(e){return e?this._logger=e:this._logger}logQueries(e){return e!==void 0?this._logQueries=!!e:this._logQueries}connector(e){return e?this.db=e:this.db}consolidate(e){e&&!this._consolidate?this._consolidate=P8(this.enqueue.bind(this),this.clientCache):!e&&this._consolidate&&(this._consolidate=null)}request(e,t=sl.Normal){const n=new pb,s={request:e,result:n};return this._consolidate?this._consolidate.add(s,t):this.enqueue(s,t),n}cancel(e){const t=new Set(e);if(t.size){this.queue.remove(({result:n})=>t.has(n)?(n.reject("Canceled"),!0):!1);for(const n of this.pendingResults)t.has(n)&&n.reject("Canceled")}}clear(){this.queue.remove(({result:e})=>(e.reject("Cleared"),!0));for(const e of this.pendingResults)e.reject("Cleared");this.pendingResults=[]}}let Nd;function h_(i){return i?Nd=i:Nd==null&&(Nd=new cC),Nd}class cC{constructor(e=new n7,t={}){b(this,"manager");b(this,"preaggregator");b(this,"clients",new Set);b(this,"filterGroups",new Map);b(this,"_logger",d_());const{logger:n=console,manager:s=new G8,cache:r=!0,consolidate:o=!0,preagg:a={}}=t;this.manager=s,this.manager.cache(r),this.manager.consolidate(o),this.databaseConnector(e),this.logger(n),this.clear(),this.preaggregator=new S8(this,a)}clear(e={}){var s,r;const{clients:t=!0,cache:n=!0}=e;this.manager.clear(),t&&((s=this.filterGroups)==null||s.forEach(o=>o.disconnect()),this.filterGroups=new Map,(r=this.clients)==null||r.forEach(o=>this.disconnect(o)),this.clients=new Set),n&&this.manager.cache().clear()}databaseConnector(e){return e?this.manager.connector(e):this.manager.connector()}logger(e){return arguments.length&&(this._logger=e||d_(),this.manager.logger(this._logger)),this._logger}cancel(e){this.manager.cancel(e)}exec(e,t={}){const{priority:n=sl.Normal}=t;return e=Array.isArray(e)?e.filter(s=>s).join(`;
`):e,this.manager.request({type:"exec",query:e},n)}query(e,t={}){const{type:n="arrow",cache:s=!0,priority:r=sl.Normal,...o}=t;return this.manager.request({type:n,query:e,cache:s,options:o},r)}prefetch(e,t={}){return this.query(e,{...t,cache:!0,priority:sl.Low})}updateClient(e,t,n=sl.Normal){return e.queryPending(),e._pending=this.query(t,{priority:n}).then(s=>e.queryResult(s).update(),s=>{var r;(r=this._logger)==null||r.error(s),e.queryError(s)}).catch(s=>{var r;return(r=this._logger)==null?void 0:r.error(s)})}requestQuery(e,t){return this.preaggregator.clear(),t?this.updateClient(e,t):Promise.resolve(e.update())}connect(e){const{clients:t}=this;if(t!=null&&t.has(e))throw new Error("Client already connected.");t==null||t.add(e),e.coordinator=this,e.initialize(),W8(this,e.filterBy,e)}disconnect(e){const{clients:t,filterGroups:n}=this;if(!(t!=null&&t.has(e)))return;t.delete(e),e.coordinator=null;const s=n==null?void 0:n.get(e.filterBy);s&&s.clients.delete(e)}}function W8(i,e,t){var s,r;if(!e)return;let n=(s=i.filterGroups)==null?void 0:s.get(e);if(!n){const o=l=>Y8(i,e,l),a=()=>q8(i,e);e.addEventListener("activate",o),e.addEventListener("value",a),n={selection:e,clients:new Set,disconnect(){e.removeEventListener("activate",o),e.removeEventListener("value",a)}},(r=i.filterGroups)==null||r.set(e,n)}n.clients.add(t)}function Y8(i,e,t){const{preaggregator:n,filterGroups:s}=i,{clients:r}=s.get(e);for(const o of r)o.enabled&&n.request(o,e,t)}function q8(i,e){const{preaggregator:t,filterGroups:n}=i,{clients:s}=n.get(e),{active:r}=e;return Promise.allSettled(Array.from(s,o=>{if(!o.enabled)return o.requestQuery();const a=t.request(o,e,r),l=a?null:e.predicate(o);if(a!=null&&a.skip||!a&&!l)return;const c=(a==null?void 0:a.query(r.predicate))??o.query(l);return i.updateClient(o,c)}))}function X8(i){const{coordinator:e=h_(),...t}=i,n=new K8(t);return e.connect(n),n}class K8 extends h6{constructor({selection:t=void 0,enabled:n=!0,filterStable:s=!0,...r}){super(t);b(this,"_methods");b(this,"_filterStable");this.enabled=n,this._methods=r,this._filterStable=s}get filterStable(){return this._filterStable}async prepare(){var t,n;await((n=(t=this._methods).prepare)==null?void 0:n.call(t))}query(t){var n,s;return((s=(n=this._methods).query)==null?void 0:s.call(n,t))??null}queryResult(t){var n,s;return(s=(n=this._methods).queryResult)==null||s.call(n,t),this}queryPending(){var t,n;return(n=(t=this._methods).queryPending)==null||n.call(t),this}queryError(t){var n,s;return(s=(n=this._methods).queryError)==null||s.call(n,t),this}}class Z8{constructor(){b(this,"_callbacks");this._callbacks=new Map}addEventListener(e,t){this._callbacks.has(e)||this._callbacks.set(e,{callbacks:new Set,pending:null,queue:new Q8}),this._callbacks.get(e).callbacks.add(t)}removeEventListener(e,t){const n=this._callbacks.get(e);n&&n.callbacks.delete(t)}willEmit(e,t){return t}emitQueueFilter(e,t){return null}cancel(e){const t=this._callbacks.get(e);t==null||t.queue.clear()}async pending(e){var t;await((t=this._callbacks.get(e))==null?void 0:t.pending)}emit(e,t){const n=this._callbacks.get(e)||{};if(n.pending)n.queue.enqueue(t,this.emitQueueFilter(e,t));else{const s=this.willEmit(e,t),{callbacks:r,queue:o}=n;if(r!=null&&r.size){const a=Array.from(r,l=>l(s));n.pending=Promise.allSettled(a).then(()=>{n.pending=null,o.isEmpty()||this.emit(e,o.dequeue())})}}}}class Q8{constructor(){b(this,"next",null);this.clear()}clear(){this.next=null}isEmpty(){return!this.next}enqueue(e,t){const n={value:e};if(t&&this.next){let s=this;for(;s.next;)t(s.next.value)?s=s.next:s.next=s.next.next;s.next=n}else this.next=n}dequeue(){const{next:e}=this;return this.next=(e==null?void 0:e.next)||null,e==null?void 0:e.value}}function J8(i,e){return i===e?!1:i instanceof Date&&e instanceof Date?+i!=+e:Array.isArray(i)&&Array.isArray(e)?eU(i,e):!0}function eU(i,e){if(i.length!==e.length)return!0;for(let t=0;t<i.length;++t)if(i[t]!==e[t])return!0;return!1}function xm(i){return i instanceof fl}class fl extends Z8{constructor(t){super();b(this,"_value");this._value=t}static value(t){return new fl(t)}static array(t){if(t.some(n=>xm(n))){const n=new fl,s=()=>{n.update(t.map(r=>xm(r)?r.value:r))};return s(),t.forEach(r=>xm(r)?r.addEventListener("value",s):0),n}return new fl(t)}get value(){return this._value}update(t,{force:n}={}){return J8(this._value,t)||n?this.emit("value",t):this.cancel("value"),this}willEmit(t,n){return t==="value"&&(this._value=n),n}}function Dd(i,e){return new f_(new dC(i),e?[e].flat():void 0)}let f_=class uC extends fl{constructor(t=new dC,n=[]){super([]);b(this,"_resolved");b(this,"_resolver");b(this,"_relay");if(this._resolved=this._value,this._resolver=t,this._relay=new Set,Array.isArray(n))for(const s of n)s._relay.add(this)}static intersect({cross:t=!1,empty:n=!1,include:s=[]}={}){return Dd({cross:t,empty:n},s)}static union({cross:t=!1,empty:n=!1,include:s=[]}={}){return Dd({cross:t,empty:n,union:!0},s)}static single({cross:t=!1,empty:n=!1,include:s=[]}={}){return Dd({cross:t,empty:n,single:!0},s)}static crossfilter({empty:t=!1,include:n=[]}={}){return Dd({cross:!0,empty:t},n)}clone(){const t=new uC(this._resolver);return t._value=t._resolved=this._value,t}remove(t){const n=this.clone();return n._value=n._resolved=n._resolver.resolve(this._resolved,{source:t}),n._value.active={source:t},n}get resolver(){return this._resolver}get single(){return this._resolver.single}get clauses(){return super.value}get active(){return this.clauses.active}get value(){var t;return(t=this.active)==null?void 0:t.value}valueFor(t){var n;return(n=this.clauses.find(s=>s.source===t))==null?void 0:n.value}activate(t){this.emit("activate",t),this._relay.forEach(n=>n.activate(t))}update(t){return this._resolved=this._resolver.resolve(this._resolved,t,!0),this._resolved.active=t,this._relay.forEach(n=>n.update(t)),super.update(this._resolved)}reset(t){return t??(t=this._resolved),t.forEach(n=>{var s,r;return(r=(s=n.source)==null?void 0:s.reset)==null?void 0:r.call(s)}),this._resolved=this._resolved.filter(n=>!t.includes(n)),this._relay.forEach(n=>n.reset(t)),super.update(this._resolved)}willEmit(t,n){return t==="value"?(this._value=n,this.value):n}emitQueueFilter(t,n){return t==="value"?this._resolver.queueFilter(n):null}skip(t,n){return this._resolver.skip(t,n)}predicate(t=void 0,n=!1){const{clauses:s}=this,r=n?null:s.active;return this._resolver.predicate(s,r,t)}};class dC{constructor({union:e,cross:t,single:n,empty:s}={}){b(this,"union");b(this,"cross");b(this,"single");b(this,"empty");this.union=!!e,this.cross=!!t,this.single=!!n,this.empty=!!s}resolve(e,t,n=!1){const{source:s,predicate:r}=t,o=e.filter(l=>s!==l.source),a=this.single?[]:o;return this.single&&n&&o.forEach(l=>{var c,u;return(u=(c=l.source)==null?void 0:c.reset)==null?void 0:u.call(c)}),r&&a.push(t),a}skip(e,t){var n;return e==null?!1:!!(this.cross&&((n=t==null?void 0:t.clients)!=null&&n.has(e)))}predicate(e,t,n){const{empty:s,union:r}=this;if(s&&!e.length)return[An(!1)];if(this.skip(n,t))return;const o=e.filter(a=>!this.skip(n,a)).map(a=>a.predicate);return r&&o.length>1?K7(o):o}queueFilter(e){var t;if(this.cross){const n=(t=e.active)==null?void 0:t.source;return s=>{var r;return((r=s.active)==null?void 0:r.source)!==n}}return null}}class tU{constructor({uri:e="http://localhost:3000/",ipc:t=void 0}={}){b(this,"_uri");b(this,"_ipc");this._uri=e,this._ipc=t}async query(e){const t=fetch(this._uri,{method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t;if(!n.ok)throw new Error(`Query failed with HTTP status ${n.status}: ${await n.text()}`);return e.type==="exec"?t:e.type==="arrow"?df(await n.arrayBuffer(),this._ipc):n.json()}}function je(i,e,t,n){function s(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(u){try{c(n.next(u))}catch(d){o(d)}}function l(u){try{c(n.throw(u))}catch(d){o(d)}}function c(u){u.done?r(u.value):s(u.value).then(a,l)}c((n=n.apply(i,e||[])).next())})}function p1(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ze(i){return this instanceof Ze?(this.v=i,this):new Ze(i)}function _r(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(i,e||[]),s,r=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(m){return Promise.resolve(m).then(p,d)}}function a(p,m){n[p]&&(s[p]=function(y){return new Promise(function(g,_){r.push([p,y,g,_])>1||l(p,y)})},m&&(s[p]=m(s[p])))}function l(p,m){try{c(n[p](m))}catch(y){h(r[0][3],y)}}function c(p){p.value instanceof Ze?Promise.resolve(p.value.v).then(u,d):h(r[0][2],p)}function u(p){l("next",p)}function d(p){l("throw",p)}function h(p,m){p(m),r.shift(),r.length&&l(r[0][0],r[0][1])}}function wh(i){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,r){e[s]=i[s]?function(o){return(t=!t)?{value:Ze(i[s](o)),done:!1}:r?r(o):o}:r}}function ua(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof p1=="function"?p1(i):i[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=i[r]&&function(o){return new Promise(function(a,l){o=i[r](o),s(a,l,o.done,o.value)})}}function s(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}const iU=new TextDecoder("utf-8"),p_=i=>iU.decode(i),nU=new TextEncoder,Xu=i=>nU.encode(i),sU=i=>typeof i=="number",hC=i=>typeof i=="boolean",Si=i=>typeof i=="function",Pn=i=>i!=null&&Object(i)===i,Wo=i=>Pn(i)&&Si(i.then),Ku=i=>Pn(i)&&Si(i[Symbol.iterator]),Yl=i=>Pn(i)&&Si(i[Symbol.asyncIterator]),m_=i=>Pn(i)&&Pn(i.schema),fC=i=>Pn(i)&&"done"in i&&"value"in i,pC=i=>Pn(i)&&Si(i.stat)&&sU(i.fd),mC=i=>Pn(i)&&mb(i.body),Sp=i=>"_getDOMStream"in i&&"_getNodeStream"in i,rU=i=>Pn(i)&&Si(i.abort)&&Si(i.getWriter)&&!Sp(i),mb=i=>Pn(i)&&Si(i.cancel)&&Si(i.getReader)&&!Sp(i),oU=i=>Pn(i)&&Si(i.end)&&Si(i.write)&&hC(i.writable)&&!Sp(i),gC=i=>Pn(i)&&Si(i.read)&&Si(i.pipe)&&hC(i.readable)&&!Sp(i),aU=i=>Pn(i)&&Si(i.clear)&&Si(i.bytes)&&Si(i.position)&&Si(i.setPosition)&&Si(i.capacity)&&Si(i.getBufferIdentifier)&&Si(i.createLong),gb=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function lU(i){const e=i[0]?[i[0]]:[];let t,n,s,r;for(let o,a,l=0,c=0,u=i.length;++l<u;){if(o=e[c],a=i[l],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(e[++c]=a);continue}if({byteOffset:t,byteLength:s}=o,{byteOffset:n,byteLength:r}=a,t+s<n||n+r<t){a&&(e[++c]=a);continue}e[c]=new Uint8Array(o.buffer,t,n-t+r)}return e}function g_(i,e,t=0,n=e.byteLength){const s=i.byteLength,r=new Uint8Array(i.buffer,i.byteOffset,s),o=new Uint8Array(e.buffer,e.byteOffset,Math.min(n,s));return r.set(o,t),i}function Er(i,e){const t=lU(i),n=t.reduce((u,d)=>u+d.byteLength,0);let s,r,o,a=0,l=-1;const c=Math.min(e||Number.POSITIVE_INFINITY,n);for(const u=t.length;++l<u;){if(s=t[l],r=s.subarray(0,Math.min(s.length,c-a)),c<=a+r.length){r.length<s.length?t[l]=s.subarray(r.length):r.length===s.length&&l++,o?g_(o,r,a):o=r;break}g_(o||(o=new Uint8Array(c)),r,a),a+=r.length}return[o||new Uint8Array(0),t.slice(l),n-(o?o.byteLength:0)]}function Bt(i,e){let t=fC(e)?e.value:e;return t instanceof i?i===Uint8Array?new i(t.buffer,t.byteOffset,t.byteLength):t:t?(typeof t=="string"&&(t=Xu(t)),t instanceof ArrayBuffer?new i(t):t instanceof gb?new i(t):aU(t)?Bt(i,t.bytes()):ArrayBuffer.isView(t)?t.byteLength<=0?new i(0):new i(t.buffer,t.byteOffset,t.byteLength/i.BYTES_PER_ELEMENT):i.from(t)):new i(0)}const gc=i=>Bt(Int32Array,i),m1=i=>Bt(BigInt64Array,i),ot=i=>Bt(Uint8Array,i),__=i=>(i.next(),i);function*cU(i,e){const t=function*(s){yield s},n=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof gb?t(e):Ku(e)?e:t(e);return yield*__((function*(s){let r=null;do r=s.next(yield Bt(i,r));while(!r.done)})(n[Symbol.iterator]())),new i}const uU=i=>cU(Uint8Array,i);function _C(i,e){return _r(this,arguments,function*(){if(Wo(e))return yield Ze(yield Ze(yield*wh(ua(_C(i,yield Ze(e))))));const n=function(o){return _r(this,arguments,function*(){yield yield Ze(yield Ze(o))})},s=function(o){return _r(this,arguments,function*(){yield Ze(yield*wh(ua(__((function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)})(o[Symbol.iterator]())))))})},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof gb?n(e):Ku(e)?s(e):Yl(e)?e:n(e);return yield Ze(yield*wh(ua(__((function(o){return _r(this,arguments,function*(){let a=null;do a=yield Ze(o.next(yield yield Ze(Bt(i,a))));while(!a.done)})})(r[Symbol.asyncIterator]()))))),yield Ze(new i)})}const dU=i=>_C(Uint8Array,i);function yC(i,e,t){if(i!==0){t=t.slice(0,e);for(let n=-1,s=t.length;++n<s;)t[n]+=i}return t.subarray(0,e)}function hU(i,e){let t=0;const n=i.length;if(n!==e.length)return!1;if(n>0)do if(i[t]!==e[t])return!1;while(++t<n);return!0}const cs={fromIterable(i){return Md(fU(i))},fromAsyncIterable(i){return Md(pU(i))},fromDOMStream(i){return Md(mU(i))},fromNodeStream(i){return Md(_U(i))},toDOMStream(i,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(i,e){throw new Error('"toNodeStream" not available in this environment')}},Md=i=>(i.next(),i);function*fU(i){let e,t=!1,n=[],s,r,o,a=0;function l(){return r==="peek"?Er(n,o)[0]:([s,n,a]=Er(n,o),s)}({cmd:r,size:o}=(yield null)||{cmd:"read",size:0});const c=uU(i)[Symbol.iterator]();try{do if({done:e,value:s}=Number.isNaN(o-a)?c.next():c.next(o-a),!e&&s.byteLength>0&&(n.push(s),a+=s.byteLength),e||o<=a)do({cmd:r,size:o}=yield l());while(o<a);while(!e)}catch(u){(t=!0)&&typeof c.throw=="function"&&c.throw(u)}finally{t===!1&&typeof c.return=="function"&&c.return(null)}return null}function pU(i){return _r(this,arguments,function*(){let t,n=!1,s=[],r,o,a,l=0;function c(){return o==="peek"?Er(s,a)[0]:([r,s,l]=Er(s,a),r)}({cmd:o,size:a}=(yield yield Ze(null))||{cmd:"read",size:0});const u=dU(i)[Symbol.asyncIterator]();try{do if({done:t,value:r}=Number.isNaN(a-l)?yield Ze(u.next()):yield Ze(u.next(a-l)),!t&&r.byteLength>0&&(s.push(r),l+=r.byteLength),t||a<=l)do({cmd:o,size:a}=yield yield Ze(c()));while(a<l);while(!t)}catch(d){(n=!0)&&typeof u.throw=="function"&&(yield Ze(u.throw(d)))}finally{n===!1&&typeof u.return=="function"&&(yield Ze(u.return(new Uint8Array(0))))}return yield Ze(null)})}function mU(i){return _r(this,arguments,function*(){let t=!1,n=!1,s=[],r,o,a,l=0;function c(){return o==="peek"?Er(s,a)[0]:([r,s,l]=Er(s,a),r)}({cmd:o,size:a}=(yield yield Ze(null))||{cmd:"read",size:0});const u=new gU(i);try{do if({done:t,value:r}=Number.isNaN(a-l)?yield Ze(u.read()):yield Ze(u.read(a-l)),!t&&r.byteLength>0&&(s.push(ot(r)),l+=r.byteLength),t||a<=l)do({cmd:o,size:a}=yield yield Ze(c()));while(a<l);while(!t)}catch(d){(n=!0)&&(yield Ze(u.cancel(d)))}finally{n===!1?yield Ze(u.cancel()):i.locked&&u.releaseLock()}return yield Ze(null)})}class gU{constructor(e){this.source=e,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return je(this,void 0,void 0,function*(){const{reader:t,source:n}=this;t&&(yield t.cancel(e).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(e){return je(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=ot(t)),t})}}const wm=(i,e)=>{const t=s=>n([e,s]);let n;return[e,t,new Promise(s=>(n=s)&&i.once(e,t))]};function _U(i){return _r(this,arguments,function*(){const t=[];let n="error",s=!1,r=null,o,a,l=0,c=[],u;function d(){return o==="peek"?Er(c,a)[0]:([u,c,l]=Er(c,a),u)}if({cmd:o,size:a}=(yield yield Ze(null))||{cmd:"read",size:0},i.isTTY)return yield yield Ze(new Uint8Array(0)),yield Ze(null);try{t[0]=wm(i,"end"),t[1]=wm(i,"error");do{if(t[2]=wm(i,"readable"),[n,r]=yield Ze(Promise.race(t.map(p=>p[2]))),n==="error")break;if((s=n==="end")||(Number.isFinite(a-l)?(u=ot(i.read(a-l)),u.byteLength<a-l&&(u=ot(i.read()))):u=ot(i.read()),u.byteLength>0&&(c.push(u),l+=u.byteLength)),s||a<=l)do({cmd:o,size:a}=yield yield Ze(d()));while(a<l)}while(!s)}finally{yield Ze(h(t,n==="error"?r:null))}return yield Ze(null);function h(p,m){return u=c=null,new Promise((y,g)=>{for(const[_,S]of p)i.off(_,S);try{const _=i.destroy;_&&_.call(i,m),m=void 0}catch(_){m=_||m}finally{m!=null?g(m):y()}})}})}var ui;(function(i){i[i.V1=0]="V1",i[i.V2=1]="V2",i[i.V3=2]="V3",i[i.V4=3]="V4",i[i.V5=4]="V5"})(ui||(ui={}));var en;(function(i){i[i.Sparse=0]="Sparse",i[i.Dense=1]="Dense"})(en||(en={}));var Ii;(function(i){i[i.HALF=0]="HALF",i[i.SINGLE=1]="SINGLE",i[i.DOUBLE=2]="DOUBLE"})(Ii||(Ii={}));var bs;(function(i){i[i.DAY=0]="DAY",i[i.MILLISECOND=1]="MILLISECOND"})(bs||(bs={}));var ke;(function(i){i[i.SECOND=0]="SECOND",i[i.MILLISECOND=1]="MILLISECOND",i[i.MICROSECOND=2]="MICROSECOND",i[i.NANOSECOND=3]="NANOSECOND"})(ke||(ke={}));var Cr;(function(i){i[i.YEAR_MONTH=0]="YEAR_MONTH",i[i.DAY_TIME=1]="DAY_TIME",i[i.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Cr||(Cr={}));const Sm=2,hr=4,to=4,Pt=4,Do=new Int32Array(2),g1=new Float32Array(Do.buffer),_1=new Float64Array(Do.buffer),Bd=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var y_;(function(i){i[i.UTF8_BYTES=1]="UTF8_BYTES",i[i.UTF16_STRING=2]="UTF16_STRING"})(y_||(y_={}));let Rl=class bC{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new bC(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readUint64(e){return BigInt.asUintN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readFloat32(e){return Do[0]=this.readInt32(e),g1[0]}readFloat64(e){return Do[Bd?0:1]=this.readInt32(e),Do[Bd?1:0]=this.readInt32(e+4),_1[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){g1[0]=t,this.writeInt32(e,Do[0])}writeFloat64(e,t){_1[0]=t,this.writeInt32(e,Do[Bd?0:1]),this.writeInt32(e+4,Do[Bd?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+hr+to)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<to;t++)e+=String.fromCharCode(this.readInt8(this.position_+hr+t));return e}__offset(e,t){const n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const n=this.readInt32(e);e+=hr;const s=this.bytes_.subarray(e,e+n);return t===y_.UTF8_BYTES?s:this.text_decoder_.decode(s)}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+hr}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=to)throw new Error("FlatBuffers: file identifier must be length "+to);for(let t=0;t<to;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+hr+t))return!1;return!0}createScalarList(e,t){const n=[];for(let s=0;s<t;++s){const r=e(s);r!==null&&n.push(r)}return n}createObjList(e,t){const n=[];for(let s=0;s<t;++s){const r=e(s);r!==null&&n.push(r.unpack())}return n}},vC=class xC{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let t;e?t=e:t=1024,this.bb=Rl.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const n=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<n+e+t;){const s=this.bb.capacity();this.bb=xC.growByteBuffer(this.bb),this.space+=this.bb.capacity()-s}this.pad(n)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||t!==n)&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=t<<1,s=Rl.allocate(n);return s.setPosition(n-t),s.bytes().set(e.bytes(),n-t),s}addOffset(e){this.prep(hr,0),this.writeInt32(this.offset()-e+hr)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const s=2;this.addInt16(e-this.object_start);const r=(n+s)*Sm;this.addInt16(r);let o=0;const a=this.space;e:for(t=0;t<this.vtables.length;t++){const l=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(l)){for(let c=Sm;c<r;c+=Sm)if(this.bb.readInt16(a+c)!=this.bb.readInt16(l+c))continue e;o=this.vtables[t];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){const s=n?Pt:0;if(t){const r=t;if(this.prep(this.minalign,hr+to+s),r.length!=to)throw new TypeError("FlatBuffers: file identifier must be length "+to);for(let o=to-1;o>=0;o--)this.writeInt8(r.charCodeAt(o))}this.prep(this.minalign,hr+s),this.addOffset(e),s&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const n=this.bb.capacity()-e,s=n-this.bb.readInt32(n);if(!(t<this.bb.readInt16(s)&&this.bb.readInt16(s+t)!=0))throw new TypeError("FlatBuffers: field "+t+" must be set")}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(hr,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(e==null)return 0;let t;return e instanceof Uint8Array?t=e:t=this.text_encoder.encode(e),this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector()}createByteVector(e){return e==null?0:(this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector())}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let n=0;n<e.length;++n){const s=e[n];if(s!==null)t.push(this.createObjectOffset(s));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e.slice().reverse()),this.endVector()}};var mf;(function(i){i[i.BUFFER=0]="BUFFER"})(mf||(mf={}));var gf;(function(i){i[i.LZ4_FRAME=0]="LZ4_FRAME",i[i.ZSTD=1]="ZSTD"})(gf||(gf={}));class Mo{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBodyCompression(e,t){return(t||new Mo).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBodyCompression(e,t){return e.setPosition(e.position()+Pt),(t||new Mo).__init(e.readInt32(e.position())+e.position(),e)}codec(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):gf.LZ4_FRAME}method(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):mf.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,t){e.addFieldInt8(0,t,gf.LZ4_FRAME)}static addMethod(e,t){e.addFieldInt8(1,t,mf.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(e,t,n){return Mo.startBodyCompression(e),Mo.addCodec(e,t),Mo.addMethod(e,n),Mo.endBodyCompression(e)}}class wC{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}}let SC=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},qr=class b_{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsRecordBatch(e,t){return(t||new b_).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,t){return e.setPosition(e.position()+Pt),(t||new b_).__init(e.readInt32(e.position())+e.position(),e)}length(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}nodes(e,t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new SC).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}nodesLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,t){const n=this.bb.__offset(this.bb_pos,8);return n?(t||new wC).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}buffersLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new Mo).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,t){e.addFieldInt64(0,t,BigInt("0"))}static addNodes(e,t){e.addFieldOffset(1,t,0)}static startNodesVector(e,t){e.startVector(16,t,8)}static addBuffers(e,t){e.addFieldOffset(2,t,0)}static startBuffersVector(e,t){e.startVector(16,t,8)}static addCompression(e,t){e.addFieldOffset(3,t,0)}static endRecordBatch(e){return e.endObject()}},Ga=class v_{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryBatch(e,t){return(t||new v_).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,t){return e.setPosition(e.position()+Pt),(t||new v_).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}data(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new qr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isDelta(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startDictionaryBatch(e){e.startObject(3)}static addId(e,t){e.addFieldInt64(0,t,BigInt("0"))}static addData(e,t){e.addFieldOffset(1,t,0)}static addIsDelta(e,t){e.addFieldInt8(2,+t,0)}static endDictionaryBatch(e){return e.endObject()}};var Pl;(function(i){i[i.Little=0]="Little",i[i.Big=1]="Big"})(Pl||(Pl={}));var _f;(function(i){i[i.DenseArray=0]="DenseArray"})(_f||(_f={}));class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInt(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInt(e,t){return e.setPosition(e.position()+Pt),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}bitWidth(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}isSigned(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startInt(e){e.startObject(2)}static addBitWidth(e,t){e.addFieldInt32(0,t,0)}static addIsSigned(e,t){e.addFieldInt8(1,+t,0)}static endInt(e){return e.endObject()}static createInt(e,t,n){return Gn.startInt(e),Gn.addBitWidth(e,t),Gn.addIsSigned(e,n),Gn.endInt(e)}}class io{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryEncoding(e,t){return(t||new io).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryEncoding(e,t){return e.setPosition(e.position()+Pt),(t||new io).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}indexType(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Gn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isOrdered(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}dictionaryKind(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt16(this.bb_pos+e):_f.DenseArray}static startDictionaryEncoding(e){e.startObject(4)}static addId(e,t){e.addFieldInt64(0,t,BigInt("0"))}static addIndexType(e,t){e.addFieldOffset(1,t,0)}static addIsOrdered(e,t){e.addFieldInt8(2,+t,0)}static addDictionaryKind(e,t){e.addFieldInt16(3,t,_f.DenseArray)}static endDictionaryEncoding(e){return e.endObject()}}class Ei{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsKeyValue(e,t){return(t||new Ei).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsKeyValue(e,t){return e.setPosition(e.position()+Pt),(t||new Ei).__init(e.readInt32(e.position())+e.position(),e)}key(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}value(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startKeyValue(e){e.startObject(2)}static addKey(e,t){e.addFieldOffset(0,t,0)}static addValue(e,t){e.addFieldOffset(1,t,0)}static endKeyValue(e){return e.endObject()}static createKeyValue(e,t,n){return Ei.startKeyValue(e),Ei.addKey(e,t),Ei.addValue(e,n),Ei.endKeyValue(e)}}let y1=class jc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBinary(e,t){return(t||new jc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBinary(e,t){return e.setPosition(e.position()+Pt),(t||new jc).__init(e.readInt32(e.position())+e.position(),e)}static startBinary(e){e.startObject(0)}static endBinary(e){return e.endObject()}static createBinary(e){return jc.startBinary(e),jc.endBinary(e)}},b1=class Hc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBool(e,t){return(t||new Hc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBool(e,t){return e.setPosition(e.position()+Pt),(t||new Hc).__init(e.readInt32(e.position())+e.position(),e)}static startBool(e){e.startObject(0)}static endBool(e){return e.endObject()}static createBool(e){return Hc.startBool(e),Hc.endBool(e)}},Sh=class Wa{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDate(e,t){return(t||new Wa).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDate(e,t){return e.setPosition(e.position()+Pt),(t||new Wa).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):bs.MILLISECOND}static startDate(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,bs.MILLISECOND)}static endDate(e){return e.endObject()}static createDate(e,t){return Wa.startDate(e),Wa.addUnit(e,t),Wa.endDate(e)}},Ya=class Po{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDecimal(e,t){return(t||new Po).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDecimal(e,t){return e.setPosition(e.position()+Pt),(t||new Po).__init(e.readInt32(e.position())+e.position(),e)}precision(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}scale(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):0}bitWidth(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt32(this.bb_pos+e):128}static startDecimal(e){e.startObject(3)}static addPrecision(e,t){e.addFieldInt32(0,t,0)}static addScale(e,t){e.addFieldInt32(1,t,0)}static addBitWidth(e,t){e.addFieldInt32(2,t,128)}static endDecimal(e){return e.endObject()}static createDecimal(e,t,n,s){return Po.startDecimal(e),Po.addPrecision(e,t),Po.addScale(e,n),Po.addBitWidth(e,s),Po.endDecimal(e)}},Eh=class qa{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDuration(e,t){return(t||new qa).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDuration(e,t){return e.setPosition(e.position()+Pt),(t||new qa).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ke.MILLISECOND}static startDuration(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,ke.MILLISECOND)}static endDuration(e){return e.endObject()}static createDuration(e,t){return qa.startDuration(e),qa.addUnit(e,t),qa.endDuration(e)}},Ch=class Xa{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeBinary(e,t){return(t||new Xa).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFixedSizeBinary(e,t){return e.setPosition(e.position()+Pt),(t||new Xa).__init(e.readInt32(e.position())+e.position(),e)}byteWidth(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeBinary(e){e.startObject(1)}static addByteWidth(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeBinary(e){return e.endObject()}static createFixedSizeBinary(e,t){return Xa.startFixedSizeBinary(e),Xa.addByteWidth(e,t),Xa.endFixedSizeBinary(e)}},Th=class Ka{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeList(e,t){return(t||new Ka).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFixedSizeList(e,t){return e.setPosition(e.position()+Pt),(t||new Ka).__init(e.readInt32(e.position())+e.position(),e)}listSize(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeList(e){e.startObject(1)}static addListSize(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeList(e){return e.endObject()}static createFixedSizeList(e,t){return Ka.startFixedSizeList(e),Ka.addListSize(e,t),Ka.endFixedSizeList(e)}};class fr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFloatingPoint(e,t){return(t||new fr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFloatingPoint(e,t){return e.setPosition(e.position()+Pt),(t||new fr).__init(e.readInt32(e.position())+e.position(),e)}precision(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ii.HALF}static startFloatingPoint(e){e.startObject(1)}static addPrecision(e,t){e.addFieldInt16(0,t,Ii.HALF)}static endFloatingPoint(e){return e.endObject()}static createFloatingPoint(e,t){return fr.startFloatingPoint(e),fr.addPrecision(e,t),fr.endFloatingPoint(e)}}class pr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInterval(e,t){return(t||new pr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInterval(e,t){return e.setPosition(e.position()+Pt),(t||new pr).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Cr.YEAR_MONTH}static startInterval(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,Cr.YEAR_MONTH)}static endInterval(e){return e.endObject()}static createInterval(e,t){return pr.startInterval(e),pr.addUnit(e,t),pr.endInterval(e)}}let v1=class Vc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeBinary(e,t){return(t||new Vc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsLargeBinary(e,t){return e.setPosition(e.position()+Pt),(t||new Vc).__init(e.readInt32(e.position())+e.position(),e)}static startLargeBinary(e){e.startObject(0)}static endLargeBinary(e){return e.endObject()}static createLargeBinary(e){return Vc.startLargeBinary(e),Vc.endLargeBinary(e)}},x1=class Gc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeUtf8(e,t){return(t||new Gc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsLargeUtf8(e,t){return e.setPosition(e.position()+Pt),(t||new Gc).__init(e.readInt32(e.position())+e.position(),e)}static startLargeUtf8(e){e.startObject(0)}static endLargeUtf8(e){return e.endObject()}static createLargeUtf8(e){return Gc.startLargeUtf8(e),Gc.endLargeUtf8(e)}},w1=class Wc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsList(e,t){return(t||new Wc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsList(e,t){return e.setPosition(e.position()+Pt),(t||new Wc).__init(e.readInt32(e.position())+e.position(),e)}static startList(e){e.startObject(0)}static endList(e){return e.endObject()}static createList(e){return Wc.startList(e),Wc.endList(e)}},kh=class Za{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMap(e,t){return(t||new Za).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMap(e,t){return e.setPosition(e.position()+Pt),(t||new Za).__init(e.readInt32(e.position())+e.position(),e)}keysSorted(){const e=this.bb.__offset(this.bb_pos,4);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startMap(e){e.startObject(1)}static addKeysSorted(e,t){e.addFieldInt8(0,+t,0)}static endMap(e){return e.endObject()}static createMap(e,t){return Za.startMap(e),Za.addKeysSorted(e,t),Za.endMap(e)}},S1=class Yc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNull(e,t){return(t||new Yc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNull(e,t){return e.setPosition(e.position()+Pt),(t||new Yc).__init(e.readInt32(e.position())+e.position(),e)}static startNull(e){e.startObject(0)}static endNull(e){return e.endObject()}static createNull(e){return Yc.startNull(e),Yc.endNull(e)}};class aa{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsStruct_(e,t){return(t||new aa).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsStruct_(e,t){return e.setPosition(e.position()+Pt),(t||new aa).__init(e.readInt32(e.position())+e.position(),e)}static startStruct_(e){e.startObject(0)}static endStruct_(e){return e.endObject()}static createStruct_(e){return aa.startStruct_(e),aa.endStruct_(e)}}class us{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTime(e,t){return(t||new us).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTime(e,t){return e.setPosition(e.position()+Pt),(t||new us).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ke.MILLISECOND}bitWidth(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):32}static startTime(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,ke.MILLISECOND)}static addBitWidth(e,t){e.addFieldInt32(1,t,32)}static endTime(e){return e.endObject()}static createTime(e,t,n){return us.startTime(e),us.addUnit(e,t),us.addBitWidth(e,n),us.endTime(e)}}class ds{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTimestamp(e,t){return(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTimestamp(e,t){return e.setPosition(e.position()+Pt),(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ke.SECOND}timezone(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startTimestamp(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,ke.SECOND)}static addTimezone(e,t){e.addFieldOffset(1,t,0)}static endTimestamp(e){return e.endObject()}static createTimestamp(e,t,n){return ds.startTimestamp(e),ds.addUnit(e,t),ds.addTimezone(e,n),ds.endTimestamp(e)}}class kn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUnion(e,t){return(t||new kn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUnion(e,t){return e.setPosition(e.position()+Pt),(t||new kn).__init(e.readInt32(e.position())+e.position(),e)}mode(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):en.Sparse}typeIds(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+e*4):0}typeIdsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}typeIdsArray(){const e=this.bb.__offset(this.bb_pos,6);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}static startUnion(e){e.startObject(2)}static addMode(e,t){e.addFieldInt16(0,t,en.Sparse)}static addTypeIds(e,t){e.addFieldOffset(1,t,0)}static createTypeIdsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,n){return kn.startUnion(e),kn.addMode(e,t),kn.addTypeIds(e,n),kn.endUnion(e)}}let E1=class qc{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new qc).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+Pt),(t||new qc).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return qc.startUtf8(e),qc.endUtf8(e)}};var Gt;(function(i){i[i.NONE=0]="NONE",i[i.Null=1]="Null",i[i.Int=2]="Int",i[i.FloatingPoint=3]="FloatingPoint",i[i.Binary=4]="Binary",i[i.Utf8=5]="Utf8",i[i.Bool=6]="Bool",i[i.Decimal=7]="Decimal",i[i.Date=8]="Date",i[i.Time=9]="Time",i[i.Timestamp=10]="Timestamp",i[i.Interval=11]="Interval",i[i.List=12]="List",i[i.Struct_=13]="Struct_",i[i.Union=14]="Union",i[i.FixedSizeBinary=15]="FixedSizeBinary",i[i.FixedSizeList=16]="FixedSizeList",i[i.Map=17]="Map",i[i.Duration=18]="Duration",i[i.LargeBinary=19]="LargeBinary",i[i.LargeUtf8=20]="LargeUtf8",i[i.LargeList=21]="LargeList",i[i.RunEndEncoded=22]="RunEndEncoded"})(Gt||(Gt={}));let as=class Ah{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Ah).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+Pt),(t||new Ah).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Gt.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new io).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const n=this.bb.__offset(this.bb_pos,14);return n?(t||new Ah).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const n=this.bb.__offset(this.bb_pos,16);return n?(t||new Ei).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Gt.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},lr=class Wr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new Wr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+Pt),(t||new Wr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Pl.Little}fields(e,t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new as).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const n=this.bb.__offset(this.bb_pos,8);return n?(t||new Ei).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Pl.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,n,s,r){return Wr.startSchema(e),Wr.addEndianness(e,t),Wr.addFields(e,n),Wr.addCustomMetadata(e,s),Wr.addFeatures(e,r),Wr.endSchema(e)}};var xt;(function(i){i[i.NONE=0]="NONE",i[i.Schema=1]="Schema",i[i.DictionaryBatch=2]="DictionaryBatch",i[i.RecordBatch=3]="RecordBatch",i[i.Tensor=4]="Tensor",i[i.SparseTensor=5]="SparseTensor"})(xt||(xt={}));var A;(function(i){i[i.NONE=0]="NONE",i[i.Null=1]="Null",i[i.Int=2]="Int",i[i.Float=3]="Float",i[i.Binary=4]="Binary",i[i.Utf8=5]="Utf8",i[i.Bool=6]="Bool",i[i.Decimal=7]="Decimal",i[i.Date=8]="Date",i[i.Time=9]="Time",i[i.Timestamp=10]="Timestamp",i[i.Interval=11]="Interval",i[i.List=12]="List",i[i.Struct=13]="Struct",i[i.Union=14]="Union",i[i.FixedSizeBinary=15]="FixedSizeBinary",i[i.FixedSizeList=16]="FixedSizeList",i[i.Map=17]="Map",i[i.Duration=18]="Duration",i[i.LargeBinary=19]="LargeBinary",i[i.LargeUtf8=20]="LargeUtf8",i[i.Dictionary=-1]="Dictionary",i[i.Int8=-2]="Int8",i[i.Int16=-3]="Int16",i[i.Int32=-4]="Int32",i[i.Int64=-5]="Int64",i[i.Uint8=-6]="Uint8",i[i.Uint16=-7]="Uint16",i[i.Uint32=-8]="Uint32",i[i.Uint64=-9]="Uint64",i[i.Float16=-10]="Float16",i[i.Float32=-11]="Float32",i[i.Float64=-12]="Float64",i[i.DateDay=-13]="DateDay",i[i.DateMillisecond=-14]="DateMillisecond",i[i.TimestampSecond=-15]="TimestampSecond",i[i.TimestampMillisecond=-16]="TimestampMillisecond",i[i.TimestampMicrosecond=-17]="TimestampMicrosecond",i[i.TimestampNanosecond=-18]="TimestampNanosecond",i[i.TimeSecond=-19]="TimeSecond",i[i.TimeMillisecond=-20]="TimeMillisecond",i[i.TimeMicrosecond=-21]="TimeMicrosecond",i[i.TimeNanosecond=-22]="TimeNanosecond",i[i.DenseUnion=-23]="DenseUnion",i[i.SparseUnion=-24]="SparseUnion",i[i.IntervalDayTime=-25]="IntervalDayTime",i[i.IntervalYearMonth=-26]="IntervalYearMonth",i[i.DurationSecond=-27]="DurationSecond",i[i.DurationMillisecond=-28]="DurationMillisecond",i[i.DurationMicrosecond=-29]="DurationMicrosecond",i[i.DurationNanosecond=-30]="DurationNanosecond"})(A||(A={}));var Xr;(function(i){i[i.OFFSET=0]="OFFSET",i[i.DATA=1]="DATA",i[i.VALIDITY=2]="VALIDITY",i[i.TYPE=3]="TYPE"})(Xr||(Xr={}));const yU=void 0;function va(i){if(i===null)return"null";if(i===yU)return"undefined";switch(typeof i){case"number":return`${i}`;case"bigint":return`${i}`;case"string":return`"${i}"`}return typeof i[Symbol.toPrimitive]=="function"?i[Symbol.toPrimitive]("string"):ArrayBuffer.isView(i)?i instanceof BigInt64Array||i instanceof BigUint64Array?`[${[...i].map(e=>va(e))}]`:`[${i}]`:ArrayBuffer.isView(i)?`[${i}]`:JSON.stringify(i,(e,t)=>typeof t=="bigint"?`${t}`:t)}function Ht(i){if(typeof i=="bigint"&&(i<Number.MIN_SAFE_INTEGER||i>Number.MAX_SAFE_INTEGER))throw new TypeError(`${i} is not safe to convert to a number.`);return Number(i)}function EC(i,e){return Ht(i/e)+Ht(i%e)/Ht(e)}const bU=Symbol.for("isArrowBigNum");function Xs(i,...e){return e.length===0?Object.setPrototypeOf(Bt(this.TypedArray,i),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(i,...e),this.constructor.prototype)}Xs.prototype[bU]=!0;Xs.prototype.toJSON=function(){return`"${Su(this)}"`};Xs.prototype.valueOf=function(i){return CC(this,i)};Xs.prototype.toString=function(){return Su(this)};Xs.prototype[Symbol.toPrimitive]=function(i="default"){switch(i){case"number":return CC(this);case"string":return Su(this);case"default":return wU(this)}return Su(this)};function pl(...i){return Xs.apply(this,i)}function ml(...i){return Xs.apply(this,i)}function wu(...i){return Xs.apply(this,i)}Object.setPrototypeOf(pl.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ml.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(wu.prototype,Object.create(Uint32Array.prototype));Object.assign(pl.prototype,Xs.prototype,{constructor:pl,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ml.prototype,Xs.prototype,{constructor:ml,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(wu.prototype,Xs.prototype,{constructor:wu,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const vU=BigInt(4294967296)*BigInt(4294967296),xU=vU-BigInt(1);function CC(i,e){const{buffer:t,byteOffset:n,byteLength:s,signed:r}=i,o=new BigUint64Array(t,n,s/8),a=r&&o.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),c=0;if(a){for(const u of o)l|=(u^xU)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const u of o)l|=u*(BigInt(1)<<BigInt(64*c++));if(typeof e=="number"){const u=BigInt(Math.pow(10,e)),d=l/u,h=l%u;return Ht(d)+Ht(h)/Ht(u)}return Ht(l)}function Su(i){if(i.byteLength===8)return`${new i.BigIntArray(i.buffer,i.byteOffset,1)[0]}`;if(!i.signed)return Em(i);let e=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2);if(new Int16Array([e.at(-1)])[0]>=0)return Em(i);e=e.slice();let n=1;for(let r=0;r<e.length;r++){const o=e[r],a=~o+n;e[r]=a,n&=o===0?1:0}return`-${Em(e)}`}function wU(i){return i.byteLength===8?new i.BigIntArray(i.buffer,i.byteOffset,1)[0]:Su(i)}function Em(i){let e="";const t=new Uint32Array(2);let n=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2);const s=new Uint32Array((n=new Uint16Array(n).reverse()).buffer);let r=-1;const o=n.length-1;do{for(t[0]=n[r=0];r<o;)n[r++]=t[1]=t[0]/10,t[0]=(t[0]-t[1]*10<<16)+n[r];n[r]=t[1]=t[0]/10,t[0]=t[0]-t[1]*10,e=`${t[0]}${e}`}while(s[0]||s[1]||s[2]||s[3]);return e??"0"}class _b{static new(e,t){switch(t){case!0:return new pl(e);case!1:return new ml(e)}switch(e.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new pl(e)}return e.byteLength===16?new wu(e):new ml(e)}static signed(e){return new pl(e)}static unsigned(e){return new ml(e)}static decimal(e){return new wu(e)}constructor(e,t){return _b.new(e,t)}}var TC,kC,AC,IC,LC,RC,PC,NC,DC,MC,BC,OC,FC,zC,UC,$C,jC,HC,VC,GC,WC,YC;class ve{static isNull(e){return(e==null?void 0:e.typeId)===A.Null}static isInt(e){return(e==null?void 0:e.typeId)===A.Int}static isFloat(e){return(e==null?void 0:e.typeId)===A.Float}static isBinary(e){return(e==null?void 0:e.typeId)===A.Binary}static isLargeBinary(e){return(e==null?void 0:e.typeId)===A.LargeBinary}static isUtf8(e){return(e==null?void 0:e.typeId)===A.Utf8}static isLargeUtf8(e){return(e==null?void 0:e.typeId)===A.LargeUtf8}static isBool(e){return(e==null?void 0:e.typeId)===A.Bool}static isDecimal(e){return(e==null?void 0:e.typeId)===A.Decimal}static isDate(e){return(e==null?void 0:e.typeId)===A.Date}static isTime(e){return(e==null?void 0:e.typeId)===A.Time}static isTimestamp(e){return(e==null?void 0:e.typeId)===A.Timestamp}static isInterval(e){return(e==null?void 0:e.typeId)===A.Interval}static isDuration(e){return(e==null?void 0:e.typeId)===A.Duration}static isList(e){return(e==null?void 0:e.typeId)===A.List}static isStruct(e){return(e==null?void 0:e.typeId)===A.Struct}static isUnion(e){return(e==null?void 0:e.typeId)===A.Union}static isFixedSizeBinary(e){return(e==null?void 0:e.typeId)===A.FixedSizeBinary}static isFixedSizeList(e){return(e==null?void 0:e.typeId)===A.FixedSizeList}static isMap(e){return(e==null?void 0:e.typeId)===A.Map}static isDictionary(e){return(e==null?void 0:e.typeId)===A.Dictionary}static isDenseUnion(e){return ve.isUnion(e)&&e.mode===en.Dense}static isSparseUnion(e){return ve.isUnion(e)&&e.mode===en.Sparse}constructor(e){this.typeId=e}}TC=Symbol.toStringTag;ve[TC]=(i=>(i.children=null,i.ArrayType=Array,i.OffsetArrayType=Int32Array,i[Symbol.toStringTag]="DataType"))(ve.prototype);class co extends ve{constructor(){super(A.Null)}toString(){return"Null"}}kC=Symbol.toStringTag;co[kC]=(i=>i[Symbol.toStringTag]="Null")(co.prototype);class Nn extends ve{constructor(e,t){super(A.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}AC=Symbol.toStringTag;Nn[AC]=(i=>(i.isSigned=null,i.bitWidth=null,i[Symbol.toStringTag]="Int"))(Nn.prototype);class qC extends Nn{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class XC extends Nn{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class xa extends Nn{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}let yb=class extends Nn{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}};class KC extends Nn{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}class ZC extends Nn{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class QC extends Nn{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}let JC=class extends Nn{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(qC.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(XC.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(xa.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(yb.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(KC.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(ZC.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(QC.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(JC.prototype,"ArrayType",{value:BigUint64Array});class Nl extends ve{constructor(e){super(A.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ii.HALF:return Uint16Array;case Ii.SINGLE:return Float32Array;case Ii.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}IC=Symbol.toStringTag;Nl[IC]=(i=>(i.precision=null,i[Symbol.toStringTag]="Float"))(Nl.prototype);class eT extends Nl{constructor(){super(Ii.SINGLE)}}class bb extends Nl{constructor(){super(Ii.DOUBLE)}}Object.defineProperty(eT.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(bb.prototype,"ArrayType",{value:Float64Array});class yf extends ve{constructor(){super(A.Binary)}toString(){return"Binary"}}LC=Symbol.toStringTag;yf[LC]=(i=>(i.ArrayType=Uint8Array,i[Symbol.toStringTag]="Binary"))(yf.prototype);class bf extends ve{constructor(){super(A.LargeBinary)}toString(){return"LargeBinary"}}RC=Symbol.toStringTag;bf[RC]=(i=>(i.ArrayType=Uint8Array,i.OffsetArrayType=BigInt64Array,i[Symbol.toStringTag]="LargeBinary"))(bf.prototype);class Eu extends ve{constructor(){super(A.Utf8)}toString(){return"Utf8"}}PC=Symbol.toStringTag;Eu[PC]=(i=>(i.ArrayType=Uint8Array,i[Symbol.toStringTag]="Utf8"))(Eu.prototype);class vf extends ve{constructor(){super(A.LargeUtf8)}toString(){return"LargeUtf8"}}NC=Symbol.toStringTag;vf[NC]=(i=>(i.ArrayType=Uint8Array,i.OffsetArrayType=BigInt64Array,i[Symbol.toStringTag]="LargeUtf8"))(vf.prototype);class Cu extends ve{constructor(){super(A.Bool)}toString(){return"Bool"}}DC=Symbol.toStringTag;Cu[DC]=(i=>(i.ArrayType=Uint8Array,i[Symbol.toStringTag]="Bool"))(Cu.prototype);class xf extends ve{constructor(e,t,n=128){super(A.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}MC=Symbol.toStringTag;xf[MC]=(i=>(i.scale=null,i.precision=null,i.ArrayType=Uint32Array,i[Symbol.toStringTag]="Decimal"))(xf.prototype);class wf extends ve{constructor(e){super(A.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bs[this.unit]}>`}get ArrayType(){return this.unit===bs.DAY?Int32Array:BigInt64Array}}BC=Symbol.toStringTag;wf[BC]=(i=>(i.unit=null,i[Symbol.toStringTag]="Date"))(wf.prototype);class Sf extends ve{constructor(e,t){super(A.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${ke[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}OC=Symbol.toStringTag;Sf[OC]=(i=>(i.unit=null,i.bitWidth=null,i[Symbol.toStringTag]="Time"))(Sf.prototype);class Tu extends ve{constructor(e,t){super(A.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${ke[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}FC=Symbol.toStringTag;Tu[FC]=(i=>(i.unit=null,i.timezone=null,i.ArrayType=BigInt64Array,i[Symbol.toStringTag]="Timestamp"))(Tu.prototype);class SU extends Tu{constructor(e){super(ke.MILLISECOND,e)}}class Ef extends ve{constructor(e){super(A.Interval),this.unit=e}toString(){return`Interval<${Cr[this.unit]}>`}}zC=Symbol.toStringTag;Ef[zC]=(i=>(i.unit=null,i.ArrayType=Int32Array,i[Symbol.toStringTag]="Interval"))(Ef.prototype);class Cf extends ve{constructor(e){super(A.Duration),this.unit=e}toString(){return`Duration<${ke[this.unit]}>`}}UC=Symbol.toStringTag;Cf[UC]=(i=>(i.unit=null,i.ArrayType=BigInt64Array,i[Symbol.toStringTag]="Duration"))(Cf.prototype);class Dl extends ve{constructor(e){super(A.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}$C=Symbol.toStringTag;Dl[$C]=(i=>(i.children=null,i[Symbol.toStringTag]="List"))(Dl.prototype);class Oi extends ve{constructor(e){super(A.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}jC=Symbol.toStringTag;Oi[jC]=(i=>(i.children=null,i[Symbol.toStringTag]="Struct"))(Oi.prototype);class ku extends ve{constructor(e,t,n){super(A.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((s,r,o)=>(s[r]=o)&&s||s,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}HC=Symbol.toStringTag;ku[HC]=(i=>(i.mode=null,i.typeIds=null,i.children=null,i.typeIdToChildIndex=null,i.ArrayType=Int8Array,i[Symbol.toStringTag]="Union"))(ku.prototype);class Tf extends ve{constructor(e){super(A.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}VC=Symbol.toStringTag;Tf[VC]=(i=>(i.byteWidth=null,i.ArrayType=Uint8Array,i[Symbol.toStringTag]="FixedSizeBinary"))(Tf.prototype);class Au extends ve{constructor(e,t){super(A.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}GC=Symbol.toStringTag;Au[GC]=(i=>(i.children=null,i.listSize=null,i[Symbol.toStringTag]="FixedSizeList"))(Au.prototype);class Iu extends ve{constructor(e,t=!1){var n,s,r;if(super(A.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((n=e==null?void 0:e.type)===null||n===void 0)&&n.children)){const o=(s=e==null?void 0:e.type)===null||s===void 0?void 0:s.children[0];o&&(o.name="key");const a=(r=e==null?void 0:e.type)===null||r===void 0?void 0:r.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}WC=Symbol.toStringTag;Iu[WC]=(i=>(i.children=null,i.keysSorted=null,i[Symbol.toStringTag]="Map_"))(Iu.prototype);const EU=(i=>()=>++i)(-1);class Yo extends ve{constructor(e,t,n,s){super(A.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=s||!1,this.id=n==null?EU():Ht(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}YC=Symbol.toStringTag;Yo[YC]=(i=>(i.id=null,i.indices=null,i.isOrdered=null,i.dictionary=null,i[Symbol.toStringTag]="Dictionary"))(Yo.prototype);function dr(i){const e=i;switch(i.typeId){case A.Decimal:return i.bitWidth/32;case A.Interval:return 1+e.unit;case A.FixedSizeList:return e.listSize;case A.FixedSizeBinary:return e.byteWidth;default:return 1}}class Qe{visitMany(e,...t){return e.map((n,s)=>this.visit(n,...t.map(r=>r[s])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return CU(this,e,t)}getVisitFnByTypeId(e,t=!0){return Qa(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function CU(i,e,t=!0){return typeof e=="number"?Qa(i,e,t):typeof e=="string"&&e in A?Qa(i,A[e],t):e&&e instanceof ve?Qa(i,C1(e),t):e!=null&&e.type&&e.type instanceof ve?Qa(i,C1(e.type),t):Qa(i,A.NONE,t)}function Qa(i,e,t=!0){let n=null;switch(e){case A.Null:n=i.visitNull;break;case A.Bool:n=i.visitBool;break;case A.Int:n=i.visitInt;break;case A.Int8:n=i.visitInt8||i.visitInt;break;case A.Int16:n=i.visitInt16||i.visitInt;break;case A.Int32:n=i.visitInt32||i.visitInt;break;case A.Int64:n=i.visitInt64||i.visitInt;break;case A.Uint8:n=i.visitUint8||i.visitInt;break;case A.Uint16:n=i.visitUint16||i.visitInt;break;case A.Uint32:n=i.visitUint32||i.visitInt;break;case A.Uint64:n=i.visitUint64||i.visitInt;break;case A.Float:n=i.visitFloat;break;case A.Float16:n=i.visitFloat16||i.visitFloat;break;case A.Float32:n=i.visitFloat32||i.visitFloat;break;case A.Float64:n=i.visitFloat64||i.visitFloat;break;case A.Utf8:n=i.visitUtf8;break;case A.LargeUtf8:n=i.visitLargeUtf8;break;case A.Binary:n=i.visitBinary;break;case A.LargeBinary:n=i.visitLargeBinary;break;case A.FixedSizeBinary:n=i.visitFixedSizeBinary;break;case A.Date:n=i.visitDate;break;case A.DateDay:n=i.visitDateDay||i.visitDate;break;case A.DateMillisecond:n=i.visitDateMillisecond||i.visitDate;break;case A.Timestamp:n=i.visitTimestamp;break;case A.TimestampSecond:n=i.visitTimestampSecond||i.visitTimestamp;break;case A.TimestampMillisecond:n=i.visitTimestampMillisecond||i.visitTimestamp;break;case A.TimestampMicrosecond:n=i.visitTimestampMicrosecond||i.visitTimestamp;break;case A.TimestampNanosecond:n=i.visitTimestampNanosecond||i.visitTimestamp;break;case A.Time:n=i.visitTime;break;case A.TimeSecond:n=i.visitTimeSecond||i.visitTime;break;case A.TimeMillisecond:n=i.visitTimeMillisecond||i.visitTime;break;case A.TimeMicrosecond:n=i.visitTimeMicrosecond||i.visitTime;break;case A.TimeNanosecond:n=i.visitTimeNanosecond||i.visitTime;break;case A.Decimal:n=i.visitDecimal;break;case A.List:n=i.visitList;break;case A.Struct:n=i.visitStruct;break;case A.Union:n=i.visitUnion;break;case A.DenseUnion:n=i.visitDenseUnion||i.visitUnion;break;case A.SparseUnion:n=i.visitSparseUnion||i.visitUnion;break;case A.Dictionary:n=i.visitDictionary;break;case A.Interval:n=i.visitInterval;break;case A.IntervalDayTime:n=i.visitIntervalDayTime||i.visitInterval;break;case A.IntervalYearMonth:n=i.visitIntervalYearMonth||i.visitInterval;break;case A.Duration:n=i.visitDuration;break;case A.DurationSecond:n=i.visitDurationSecond||i.visitDuration;break;case A.DurationMillisecond:n=i.visitDurationMillisecond||i.visitDuration;break;case A.DurationMicrosecond:n=i.visitDurationMicrosecond||i.visitDuration;break;case A.DurationNanosecond:n=i.visitDurationNanosecond||i.visitDuration;break;case A.FixedSizeList:n=i.visitFixedSizeList;break;case A.Map:n=i.visitMap;break}if(typeof n=="function")return n;if(!t)return()=>null;throw new Error(`Unrecognized type '${A[e]}'`)}function C1(i){switch(i.typeId){case A.Null:return A.Null;case A.Int:{const{bitWidth:e,isSigned:t}=i;switch(e){case 8:return t?A.Int8:A.Uint8;case 16:return t?A.Int16:A.Uint16;case 32:return t?A.Int32:A.Uint32;case 64:return t?A.Int64:A.Uint64}return A.Int}case A.Float:switch(i.precision){case Ii.HALF:return A.Float16;case Ii.SINGLE:return A.Float32;case Ii.DOUBLE:return A.Float64}return A.Float;case A.Binary:return A.Binary;case A.LargeBinary:return A.LargeBinary;case A.Utf8:return A.Utf8;case A.LargeUtf8:return A.LargeUtf8;case A.Bool:return A.Bool;case A.Decimal:return A.Decimal;case A.Time:switch(i.unit){case ke.SECOND:return A.TimeSecond;case ke.MILLISECOND:return A.TimeMillisecond;case ke.MICROSECOND:return A.TimeMicrosecond;case ke.NANOSECOND:return A.TimeNanosecond}return A.Time;case A.Timestamp:switch(i.unit){case ke.SECOND:return A.TimestampSecond;case ke.MILLISECOND:return A.TimestampMillisecond;case ke.MICROSECOND:return A.TimestampMicrosecond;case ke.NANOSECOND:return A.TimestampNanosecond}return A.Timestamp;case A.Date:switch(i.unit){case bs.DAY:return A.DateDay;case bs.MILLISECOND:return A.DateMillisecond}return A.Date;case A.Interval:switch(i.unit){case Cr.DAY_TIME:return A.IntervalDayTime;case Cr.YEAR_MONTH:return A.IntervalYearMonth}return A.Interval;case A.Duration:switch(i.unit){case ke.SECOND:return A.DurationSecond;case ke.MILLISECOND:return A.DurationMillisecond;case ke.MICROSECOND:return A.DurationMicrosecond;case ke.NANOSECOND:return A.DurationNanosecond}return A.Duration;case A.Map:return A.Map;case A.List:return A.List;case A.Struct:return A.Struct;case A.Union:switch(i.mode){case en.Dense:return A.DenseUnion;case en.Sparse:return A.SparseUnion}return A.Union;case A.FixedSizeBinary:return A.FixedSizeBinary;case A.FixedSizeList:return A.FixedSizeList;case A.Dictionary:return A.Dictionary}throw new Error(`Unrecognized type '${A[i.typeId]}'`)}Qe.prototype.visitInt8=null;Qe.prototype.visitInt16=null;Qe.prototype.visitInt32=null;Qe.prototype.visitInt64=null;Qe.prototype.visitUint8=null;Qe.prototype.visitUint16=null;Qe.prototype.visitUint32=null;Qe.prototype.visitUint64=null;Qe.prototype.visitFloat16=null;Qe.prototype.visitFloat32=null;Qe.prototype.visitFloat64=null;Qe.prototype.visitDateDay=null;Qe.prototype.visitDateMillisecond=null;Qe.prototype.visitTimestampSecond=null;Qe.prototype.visitTimestampMillisecond=null;Qe.prototype.visitTimestampMicrosecond=null;Qe.prototype.visitTimestampNanosecond=null;Qe.prototype.visitTimeSecond=null;Qe.prototype.visitTimeMillisecond=null;Qe.prototype.visitTimeMicrosecond=null;Qe.prototype.visitTimeNanosecond=null;Qe.prototype.visitDenseUnion=null;Qe.prototype.visitSparseUnion=null;Qe.prototype.visitIntervalDayTime=null;Qe.prototype.visitIntervalYearMonth=null;Qe.prototype.visitDuration=null;Qe.prototype.visitDurationSecond=null;Qe.prototype.visitDurationMillisecond=null;Qe.prototype.visitDurationMicrosecond=null;Qe.prototype.visitDurationNanosecond=null;const tT=new Float64Array(1),Ba=new Uint32Array(tT.buffer);function iT(i){const e=(i&31744)>>10,t=(i&1023)/1024,n=Math.pow(-1,(i&32768)>>15);switch(e){case 31:return n*(t?Number.NaN:1/0);case 0:return n*(t?6103515625e-14*t:0)}return n*Math.pow(2,e-15)*(1+t)}function nT(i){if(i!==i)return 32256;tT[0]=i;const e=(Ba[1]&2147483648)>>16&65535;let t=Ba[1]&2146435072,n=0;return t>=1089470464?Ba[0]>0?t=31744:(t=(t&2080374784)>>16,n=(Ba[1]&1048575)>>10):t<=1056964608?(n=1048576+(Ba[1]&1048575),n=1048576+(n<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,n=(Ba[1]&1048575)+512>>10),e|t|n&65535}class Me extends Qe{}function Fe(i){return(e,t,n)=>{if(e.setValid(t,n!=null))return i(e,t,n)}}const TU=(i,e,t)=>{i[e]=Math.floor(t/864e5)},sT=(i,e,t,n)=>{if(t+1<e.length){const s=Ht(e[t]),r=Ht(e[t+1]);i.set(n.subarray(0,r-s),s)}},kU=({offset:i,values:e},t,n)=>{const s=i+t;n?e[s>>3]|=1<<s%8:e[s>>3]&=~(1<<s%8)},_o=({values:i},e,t)=>{i[e]=t},vb=({values:i},e,t)=>{i[e]=t},rT=({values:i},e,t)=>{i[e]=nT(t)},AU=(i,e,t)=>{switch(i.type.precision){case Ii.HALF:return rT(i,e,t);case Ii.SINGLE:case Ii.DOUBLE:return vb(i,e,t)}},xb=({values:i},e,t)=>{TU(i,e,t.valueOf())},wb=({values:i},e,t)=>{i[e]=BigInt(t)},oT=({stride:i,values:e},t,n)=>{e.set(n.subarray(0,i),i*t)},aT=({values:i,valueOffsets:e},t,n)=>sT(i,e,t,n),lT=({values:i,valueOffsets:e},t,n)=>sT(i,e,t,Xu(n)),cT=(i,e,t)=>{i.type.unit===bs.DAY?xb(i,e,t):wb(i,e,t)},Sb=({values:i},e,t)=>{i[e]=BigInt(t/1e3)},Eb=({values:i},e,t)=>{i[e]=BigInt(t)},Cb=({values:i},e,t)=>{i[e]=BigInt(t*1e3)},Tb=({values:i},e,t)=>{i[e]=BigInt(t*1e6)},uT=(i,e,t)=>{switch(i.type.unit){case ke.SECOND:return Sb(i,e,t);case ke.MILLISECOND:return Eb(i,e,t);case ke.MICROSECOND:return Cb(i,e,t);case ke.NANOSECOND:return Tb(i,e,t)}},kb=({values:i},e,t)=>{i[e]=t},Ab=({values:i},e,t)=>{i[e]=t},Ib=({values:i},e,t)=>{i[e]=t},Lb=({values:i},e,t)=>{i[e]=t},dT=(i,e,t)=>{switch(i.type.unit){case ke.SECOND:return kb(i,e,t);case ke.MILLISECOND:return Ab(i,e,t);case ke.MICROSECOND:return Ib(i,e,t);case ke.NANOSECOND:return Lb(i,e,t)}},hT=({values:i,stride:e},t,n)=>{i.set(n.subarray(0,e),e*t)},IU=(i,e,t)=>{const n=i.children[0],s=i.valueOffsets,r=vs.getVisitFn(n);if(Array.isArray(t))for(let o=-1,a=s[e],l=s[e+1];a<l;)r(n,a++,t[++o]);else for(let o=-1,a=s[e],l=s[e+1];a<l;)r(n,a++,t.get(++o))},LU=(i,e,t)=>{const n=i.children[0],{valueOffsets:s}=i,r=vs.getVisitFn(n);let{[e]:o,[e+1]:a}=s;const l=t instanceof Map?t.entries():Object.entries(t);for(const c of l)if(r(n,o,c),++o>=a)break},RU=(i,e)=>(t,n,s,r)=>n&&t(n,i,e[r]),PU=(i,e)=>(t,n,s,r)=>n&&t(n,i,e.get(r)),NU=(i,e)=>(t,n,s,r)=>n&&t(n,i,e.get(s.name)),DU=(i,e)=>(t,n,s,r)=>n&&t(n,i,e[s.name]),MU=(i,e,t)=>{const n=i.type.children.map(r=>vs.getVisitFn(r.type)),s=t instanceof Map?NU(e,t):t instanceof ze?PU(e,t):Array.isArray(t)?RU(e,t):DU(e,t);i.type.children.forEach((r,o)=>s(n[o],i.children[o],r,o))},BU=(i,e,t)=>{i.type.mode===en.Dense?fT(i,e,t):pT(i,e,t)},fT=(i,e,t)=>{const n=i.type.typeIdToChildIndex[i.typeIds[e]],s=i.children[n];vs.visit(s,i.valueOffsets[e],t)},pT=(i,e,t)=>{const n=i.type.typeIdToChildIndex[i.typeIds[e]],s=i.children[n];vs.visit(s,e,t)},OU=(i,e,t)=>{var n;(n=i.dictionary)===null||n===void 0||n.set(i.values[e],t)},mT=(i,e,t)=>{i.type.unit===Cr.DAY_TIME?Rb(i,e,t):Pb(i,e,t)},Rb=({values:i},e,t)=>{i.set(t.subarray(0,2),2*e)},Pb=({values:i},e,t)=>{i[e]=t[0]*12+t[1]%12},Nb=({values:i},e,t)=>{i[e]=t},Db=({values:i},e,t)=>{i[e]=t},Mb=({values:i},e,t)=>{i[e]=t},Bb=({values:i},e,t)=>{i[e]=t},gT=(i,e,t)=>{switch(i.type.unit){case ke.SECOND:return Nb(i,e,t);case ke.MILLISECOND:return Db(i,e,t);case ke.MICROSECOND:return Mb(i,e,t);case ke.NANOSECOND:return Bb(i,e,t)}},FU=(i,e,t)=>{const{stride:n}=i,s=i.children[0],r=vs.getVisitFn(s);if(Array.isArray(t))for(let o=-1,a=e*n;++o<n;)r(s,a+o,t[o]);else for(let o=-1,a=e*n;++o<n;)r(s,a+o,t.get(o))};Me.prototype.visitBool=Fe(kU);Me.prototype.visitInt=Fe(_o);Me.prototype.visitInt8=Fe(_o);Me.prototype.visitInt16=Fe(_o);Me.prototype.visitInt32=Fe(_o);Me.prototype.visitInt64=Fe(_o);Me.prototype.visitUint8=Fe(_o);Me.prototype.visitUint16=Fe(_o);Me.prototype.visitUint32=Fe(_o);Me.prototype.visitUint64=Fe(_o);Me.prototype.visitFloat=Fe(AU);Me.prototype.visitFloat16=Fe(rT);Me.prototype.visitFloat32=Fe(vb);Me.prototype.visitFloat64=Fe(vb);Me.prototype.visitUtf8=Fe(lT);Me.prototype.visitLargeUtf8=Fe(lT);Me.prototype.visitBinary=Fe(aT);Me.prototype.visitLargeBinary=Fe(aT);Me.prototype.visitFixedSizeBinary=Fe(oT);Me.prototype.visitDate=Fe(cT);Me.prototype.visitDateDay=Fe(xb);Me.prototype.visitDateMillisecond=Fe(wb);Me.prototype.visitTimestamp=Fe(uT);Me.prototype.visitTimestampSecond=Fe(Sb);Me.prototype.visitTimestampMillisecond=Fe(Eb);Me.prototype.visitTimestampMicrosecond=Fe(Cb);Me.prototype.visitTimestampNanosecond=Fe(Tb);Me.prototype.visitTime=Fe(dT);Me.prototype.visitTimeSecond=Fe(kb);Me.prototype.visitTimeMillisecond=Fe(Ab);Me.prototype.visitTimeMicrosecond=Fe(Ib);Me.prototype.visitTimeNanosecond=Fe(Lb);Me.prototype.visitDecimal=Fe(hT);Me.prototype.visitList=Fe(IU);Me.prototype.visitStruct=Fe(MU);Me.prototype.visitUnion=Fe(BU);Me.prototype.visitDenseUnion=Fe(fT);Me.prototype.visitSparseUnion=Fe(pT);Me.prototype.visitDictionary=Fe(OU);Me.prototype.visitInterval=Fe(mT);Me.prototype.visitIntervalDayTime=Fe(Rb);Me.prototype.visitIntervalYearMonth=Fe(Pb);Me.prototype.visitDuration=Fe(gT);Me.prototype.visitDurationSecond=Fe(Nb);Me.prototype.visitDurationMillisecond=Fe(Db);Me.prototype.visitDurationMicrosecond=Fe(Mb);Me.prototype.visitDurationNanosecond=Fe(Bb);Me.prototype.visitFixedSizeList=Fe(FU);Me.prototype.visitMap=Fe(LU);const vs=new Me,Os=Symbol.for("parent"),gl=Symbol.for("rowIndex");class Ob{constructor(e,t){return this[Os]=e,this[gl]=t,new Proxy(this,new UU)}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gl],t=this[Os],n=t.type.children,s={};for(let r=-1,o=n.length;++r<o;)s[n[r].name]=Dn.visit(t.children[r],e);return s}toString(){return`{${[...this].map(([e,t])=>`${va(e)}: ${va(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new zU(this[Os],this[gl])}}class zU{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return e<this.numChildren?(this.childIndex=e+1,{done:!1,value:[this.childFields[e].name,Dn.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Ob.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Os]:{writable:!0,enumerable:!1,configurable:!1,value:null},[gl]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class UU{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Os].type.children.map(t=>t.name)}has(e,t){return e[Os].type.children.findIndex(n=>n.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[Os].type.children.findIndex(n=>n.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const n=e[Os].type.children.findIndex(s=>s.name===t);if(n!==-1){const s=Dn.visit(e[Os].children[n],e[gl]);return Reflect.set(e,t,s),s}}set(e,t,n){const s=e[Os].type.children.findIndex(r=>r.name===t);return s!==-1?(vs.visit(e[Os].children[s],e[gl],n),Reflect.set(e,t,n)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,n):!1}}class Ae extends Qe{}function Be(i){return(e,t)=>e.getValid(t)?i(e,t):null}const $U=(i,e)=>864e5*i[e],jU=(i,e)=>null,_T=(i,e,t)=>{if(t+1>=e.length)return null;const n=Ht(e[t]),s=Ht(e[t+1]);return i.subarray(n,s)},HU=({offset:i,values:e},t)=>{const n=i+t;return(e[n>>3]&1<<n%8)!==0},yT=({values:i},e)=>$U(i,e),bT=({values:i},e)=>Ht(i[e]),Jo=({stride:i,values:e},t)=>e[i*t],VU=({stride:i,values:e},t)=>iT(e[i*t]),vT=({values:i},e)=>i[e],GU=({stride:i,values:e},t)=>e.subarray(i*t,i*(t+1)),xT=({values:i,valueOffsets:e},t)=>_T(i,e,t),wT=({values:i,valueOffsets:e},t)=>{const n=_T(i,e,t);return n!==null?p_(n):null},WU=({values:i},e)=>i[e],YU=({type:i,values:e},t)=>i.precision!==Ii.HALF?e[t]:iT(e[t]),qU=(i,e)=>i.type.unit===bs.DAY?yT(i,e):bT(i,e),ST=({values:i},e)=>1e3*Ht(i[e]),ET=({values:i},e)=>Ht(i[e]),CT=({values:i},e)=>EC(i[e],BigInt(1e3)),TT=({values:i},e)=>EC(i[e],BigInt(1e6)),XU=(i,e)=>{switch(i.type.unit){case ke.SECOND:return ST(i,e);case ke.MILLISECOND:return ET(i,e);case ke.MICROSECOND:return CT(i,e);case ke.NANOSECOND:return TT(i,e)}},kT=({values:i},e)=>i[e],AT=({values:i},e)=>i[e],IT=({values:i},e)=>i[e],LT=({values:i},e)=>i[e],KU=(i,e)=>{switch(i.type.unit){case ke.SECOND:return kT(i,e);case ke.MILLISECOND:return AT(i,e);case ke.MICROSECOND:return IT(i,e);case ke.NANOSECOND:return LT(i,e)}},ZU=({values:i,stride:e},t)=>_b.decimal(i.subarray(e*t,e*(t+1))),QU=(i,e)=>{const{valueOffsets:t,stride:n,children:s}=i,{[e*n]:r,[e*n+1]:o}=t,l=s[0].slice(r,o-r);return new ze([l])},JU=(i,e)=>{const{valueOffsets:t,children:n}=i,{[e]:s,[e+1]:r}=t,o=n[0];return new Ep(o.slice(s,r-s))},e9=(i,e)=>new Ob(i,e),t9=(i,e)=>i.type.mode===en.Dense?RT(i,e):PT(i,e),RT=(i,e)=>{const t=i.type.typeIdToChildIndex[i.typeIds[e]],n=i.children[t];return Dn.visit(n,i.valueOffsets[e])},PT=(i,e)=>{const t=i.type.typeIdToChildIndex[i.typeIds[e]],n=i.children[t];return Dn.visit(n,e)},i9=(i,e)=>{var t;return(t=i.dictionary)===null||t===void 0?void 0:t.get(i.values[e])},n9=(i,e)=>i.type.unit===Cr.DAY_TIME?NT(i,e):DT(i,e),NT=({values:i},e)=>i.subarray(2*e,2*(e+1)),DT=({values:i},e)=>{const t=i[e],n=new Int32Array(2);return n[0]=Math.trunc(t/12),n[1]=Math.trunc(t%12),n},MT=({values:i},e)=>i[e],BT=({values:i},e)=>i[e],OT=({values:i},e)=>i[e],FT=({values:i},e)=>i[e],s9=(i,e)=>{switch(i.type.unit){case ke.SECOND:return MT(i,e);case ke.MILLISECOND:return BT(i,e);case ke.MICROSECOND:return OT(i,e);case ke.NANOSECOND:return FT(i,e)}},r9=(i,e)=>{const{stride:t,children:n}=i,r=n[0].slice(e*t,t);return new ze([r])};Ae.prototype.visitNull=Be(jU);Ae.prototype.visitBool=Be(HU);Ae.prototype.visitInt=Be(WU);Ae.prototype.visitInt8=Be(Jo);Ae.prototype.visitInt16=Be(Jo);Ae.prototype.visitInt32=Be(Jo);Ae.prototype.visitInt64=Be(vT);Ae.prototype.visitUint8=Be(Jo);Ae.prototype.visitUint16=Be(Jo);Ae.prototype.visitUint32=Be(Jo);Ae.prototype.visitUint64=Be(vT);Ae.prototype.visitFloat=Be(YU);Ae.prototype.visitFloat16=Be(VU);Ae.prototype.visitFloat32=Be(Jo);Ae.prototype.visitFloat64=Be(Jo);Ae.prototype.visitUtf8=Be(wT);Ae.prototype.visitLargeUtf8=Be(wT);Ae.prototype.visitBinary=Be(xT);Ae.prototype.visitLargeBinary=Be(xT);Ae.prototype.visitFixedSizeBinary=Be(GU);Ae.prototype.visitDate=Be(qU);Ae.prototype.visitDateDay=Be(yT);Ae.prototype.visitDateMillisecond=Be(bT);Ae.prototype.visitTimestamp=Be(XU);Ae.prototype.visitTimestampSecond=Be(ST);Ae.prototype.visitTimestampMillisecond=Be(ET);Ae.prototype.visitTimestampMicrosecond=Be(CT);Ae.prototype.visitTimestampNanosecond=Be(TT);Ae.prototype.visitTime=Be(KU);Ae.prototype.visitTimeSecond=Be(kT);Ae.prototype.visitTimeMillisecond=Be(AT);Ae.prototype.visitTimeMicrosecond=Be(IT);Ae.prototype.visitTimeNanosecond=Be(LT);Ae.prototype.visitDecimal=Be(ZU);Ae.prototype.visitList=Be(QU);Ae.prototype.visitStruct=Be(e9);Ae.prototype.visitUnion=Be(t9);Ae.prototype.visitDenseUnion=Be(RT);Ae.prototype.visitSparseUnion=Be(PT);Ae.prototype.visitDictionary=Be(i9);Ae.prototype.visitInterval=Be(n9);Ae.prototype.visitIntervalDayTime=Be(NT);Ae.prototype.visitIntervalYearMonth=Be(DT);Ae.prototype.visitDuration=Be(s9);Ae.prototype.visitDurationSecond=Be(MT);Ae.prototype.visitDurationMillisecond=Be(BT);Ae.prototype.visitDurationMicrosecond=Be(OT);Ae.prototype.visitDurationNanosecond=Be(FT);Ae.prototype.visitFixedSizeList=Be(r9);Ae.prototype.visitMap=Be(JU);const Dn=new Ae,sa=Symbol.for("keys"),_l=Symbol.for("vals"),Ja=Symbol.for("kKeysAsStrings"),x_=Symbol.for("_kKeysAsStrings");class Ep{constructor(e){return this[sa]=new ze([e.children[0]]).memoize(),this[_l]=e.children[1],new Proxy(this,new a9)}get[Ja](){return this[x_]||(this[x_]=Array.from(this[sa].toArray(),String))}[Symbol.iterator](){return new o9(this[sa],this[_l])}get size(){return this[sa].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[sa],t=this[_l],n={};for(let s=-1,r=e.length;++s<r;)n[e.get(s)]=Dn.visit(t,s);return n}toString(){return`{${[...this].map(([e,t])=>`${va(e)}: ${va(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class o9{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Dn.visit(this.vals,e)]})}}class a9{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Ja]}has(e,t){return e[Ja].includes(t)}getOwnPropertyDescriptor(e,t){if(e[Ja].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const n=e[Ja].indexOf(t);if(n!==-1){const s=Dn.visit(Reflect.get(e,_l),n);return Reflect.set(e,t,s),s}}set(e,t,n){const s=e[Ja].indexOf(t);return s!==-1?(vs.visit(Reflect.get(e,_l),s,n),Reflect.set(e,t,n)):Reflect.has(e,t)?Reflect.set(e,t,n):!1}}Object.defineProperties(Ep.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[sa]:{writable:!0,enumerable:!1,configurable:!1,value:null},[_l]:{writable:!0,enumerable:!1,configurable:!1,value:null},[x_]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let T1;function zT(i,e,t,n){const{length:s=0}=i;let r=typeof e!="number"?0:e,o=typeof t!="number"?s:t;return r<0&&(r=(r%s+s)%s),o<0&&(o=(o%s+s)%s),o<r&&(T1=r,r=o,o=T1),o>s&&(o=s),n?n(i,r,o):[r,o]}const Fb=(i,e)=>i<0?e+i:i,k1=i=>i!==i;function ql(i){if(typeof i!=="object"||i===null)return k1(i)?k1:t=>t===i;if(i instanceof Date){const t=i.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(i)?t=>t?hU(i,t):!1:i instanceof Map?c9(i):Array.isArray(i)?l9(i):i instanceof ze?u9(i):d9(i,!0)}function l9(i){const e=[];for(let t=-1,n=i.length;++t<n;)e[t]=ql(i[t]);return Cp(e)}function c9(i){let e=-1;const t=[];for(const n of i.values())t[++e]=ql(n);return Cp(t)}function u9(i){const e=[];for(let t=-1,n=i.length;++t<n;)e[t]=ql(i.get(t));return Cp(e)}function d9(i,e=!1){const t=Object.keys(i);if(!e&&t.length===0)return()=>!1;const n=[];for(let s=-1,r=t.length;++s<r;)n[s]=ql(i[t[s]]);return Cp(n,t)}function Cp(i,e){return t=>{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return h9(i,t);case Map:return A1(i,t,t.keys());case Ep:case Ob:case Object:case void 0:return A1(i,t,e||Object.keys(t))}return t instanceof ze?f9(i,t):!1}}function h9(i,e){const t=i.length;if(e.length!==t)return!1;for(let n=-1;++n<t;)if(!i[n](e[n]))return!1;return!0}function f9(i,e){const t=i.length;if(e.length!==t)return!1;for(let n=-1;++n<t;)if(!i[n](e.get(n)))return!1;return!0}function A1(i,e,t){const n=t[Symbol.iterator](),s=e instanceof Map?e.keys():Object.keys(e)[Symbol.iterator](),r=e instanceof Map?e.values():Object.values(e)[Symbol.iterator]();let o=0;const a=i.length;let l=r.next(),c=n.next(),u=s.next();for(;o<a&&!c.done&&!u.done&&!l.done&&!(c.value!==u.value||!i[o](l.value));++o,c=n.next(),u=s.next(),l=r.next());return o===a&&c.done&&u.done&&l.done?!0:(n.return&&n.return(),s.return&&s.return(),r.return&&r.return(),!1)}function UT(i,e,t,n){return(t&1<<n)!==0}function p9(i,e,t,n){return(t&1<<n)>>n}function kf(i,e,t){const n=t.byteLength+7&-8;if(i>0||t.byteLength<n){const s=new Uint8Array(n);return s.set(i%8===0?t.subarray(i>>3):Af(new zb(t,i,e,null,UT)).subarray(0,n)),s}return t}function Af(i){const e=[];let t=0,n=0,s=0;for(const o of i)o&&(s|=1<<n),++n===8&&(e[t++]=s,s=n=0);(t===0||n>0)&&(e[t++]=s);const r=new Uint8Array(e.length+7&-8);return r.set(e),r}class zb{constructor(e,t,n,s,r){this.bytes=e,this.length=n,this.context=s,this.get=r,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function w_(i,e,t){if(t-e<=0)return 0;if(t-e<8){let r=0;for(const o of new zb(i,e,t-e,i,p9))r+=o;return r}const n=t>>3<<3,s=e+(e%8===0?0:8-e%8);return w_(i,e,s)+w_(i,n,t)+m9(i,s>>3,n-s>>3)}function m9(i,e,t){let n=0,s=Math.trunc(e);const r=new DataView(i.buffer,i.byteOffset,i.byteLength),o=t===void 0?i.byteLength:s+t;for(;o-s>=4;)n+=Cm(r.getUint32(s)),s+=4;for(;o-s>=2;)n+=Cm(r.getUint16(s)),s+=2;for(;o-s>=1;)n+=Cm(r.getUint8(s)),s+=1;return n}function Cm(i){let e=Math.trunc(i);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const g9=-1;class vt{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return ve.isSparseUnion(e)?this.children.some(t=>t.nullable):ve.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:n,nullBitmap:s,typeIds:r}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),s&&(e+=s.byteLength),r&&(e+=r.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(ve.isUnion(this.type))return this.children.reduce((n,s)=>n+s.nullCount,0);let e=this._nullCount,t;return e<=g9&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-w_(t,this.offset,this.offset+this.length)),e}constructor(e,t,n,s,r,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(s||0,-1));let l;r instanceof vt?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=dr(e),r&&((l=r[0])&&(this.valueOffsets=l),(l=r[1])&&(this.values=l),(l=r[2])&&(this.nullBitmap=l),(l=r[3])&&(this.typeIds=l)))}getValid(e){const{type:t}=this;if(ve.isUnion(t)){const n=t,s=this.children[n.typeIdToChildIndex[this.typeIds[e]]],r=n.mode===en.Dense?this.valueOffsets[e]:e;return s.getValid(r)}if(this.nullable&&this.nullCount>0){const n=this.offset+e;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(e,t){let n;const{type:s}=this;if(ve.isUnion(s)){const r=s,o=this.children[r.typeIdToChildIndex[this.typeIds[e]]],a=r.mode===en.Dense?this.valueOffsets[e]:e;n=o.getValid(a),o.setValid(a,t)}else{let{nullBitmap:r}=this;const{offset:o,length:a}=this,l=o+e,c=1<<l%8,u=l>>3;(!r||r.byteLength<=u)&&(r=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(kf(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));const d=r[u];n=(d&c)!==0,r[u]=t?d|c:d&~c}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,n=this.length,s=this._nullCount,r=this,o=this.children){return new vt(e,t,n,s,r,o,this.dictionary)}slice(e,t){const{stride:n,typeId:s,children:r}=this,o=+(this._nullCount===0)-1,a=s===16?n:1,l=this._sliceBuffers(e,t,n,s);return this.clone(this.type,this.offset+e,t,o,l,r.length===0||this.valueOffsets?r:this._sliceChildren(r,a*e,a*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===A.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:n}=this,s=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);s[t>>3]=(1<<t-(t&-8))-1,n>0&&s.set(kf(this.offset,t,this.nullBitmap),0);const r=this.buffers;return r[Xr.VALIDITY]=s,this.clone(this.type,0,e,n+(e-t),r)}_sliceBuffers(e,t,n,s){let r;const{buffers:o}=this;return(r=o[Xr.TYPE])&&(o[Xr.TYPE]=r.subarray(e,e+t)),(r=o[Xr.OFFSET])&&(o[Xr.OFFSET]=r.subarray(e,e+t+1))||(r=o[Xr.DATA])&&(o[Xr.DATA]=s===6?r:r.subarray(n*e,n*(e+t))),o}_sliceChildren(e,t,n){return e.map(s=>s.slice(t,n))}}vt.prototype.children=Object.freeze([]);class au extends Qe{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:n=0,["length"]:s=0}=e;return new vt(t,n,s,s)}visitBool(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitInt(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitFloat(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitUtf8(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.data),r=ot(e.nullBitmap),o=gc(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,s,r])}visitLargeUtf8(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.data),r=ot(e.nullBitmap),o=m1(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,s,r])}visitBinary(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.data),r=ot(e.nullBitmap),o=gc(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,s,r])}visitLargeBinary(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.data),r=ot(e.nullBitmap),o=m1(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,s,r])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitDate(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitTimestamp(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitTime(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitDecimal(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitList(e){const{["type"]:t,["offset"]:n=0,["child"]:s}=e,r=ot(e.nullBitmap),o=gc(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,void 0,r],[s])}visitStruct(e){const{["type"]:t,["offset"]:n=0,["children"]:s=[]}=e,r=ot(e.nullBitmap),{length:o=s.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,void 0,r],s)}visitUnion(e){const{["type"]:t,["offset"]:n=0,["children"]:s=[]}=e,r=Bt(t.ArrayType,e.typeIds),{["length"]:o=r.length,["nullCount"]:a=-1}=e;if(ve.isSparseUnion(t))return new vt(t,n,o,a,[void 0,void 0,void 0,r],s);const l=gc(e.valueOffsets);return new vt(t,n,o,a,[l,void 0,void 0,r],s)}visitDictionary(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.indices.ArrayType,e.data),{["dictionary"]:o=new ze([new au().visit({type:t.dictionary})])}=e,{["length"]:a=r.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[void 0,r,s],[],o)}visitInterval(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitDuration(e){const{["type"]:t,["offset"]:n=0}=e,s=ot(e.nullBitmap),r=Bt(t.ArrayType,e.data),{["length"]:o=r.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,r,s])}visitFixedSizeList(e){const{["type"]:t,["offset"]:n=0,["child"]:s=new au().visit({type:t.valueType})}=e,r=ot(e.nullBitmap),{["length"]:o=s.length/dr(t),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new vt(t,n,o,a,[void 0,void 0,r],[s])}visitMap(e){const{["type"]:t,["offset"]:n=0,["child"]:s=new au().visit({type:t.childType})}=e,r=ot(e.nullBitmap),o=gc(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new vt(t,n,a,l,[o,void 0,r],[s])}}const _9=new au;function De(i){return _9.visit(i)}class I1{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const e=this.chunkIterator.next();if(!e.done)return e;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function y9(i){return i.some(e=>e.nullable)}function $T(i){return i.reduce((e,t)=>e+t.nullCount,0)}function jT(i){return i.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(i.length+1))}function HT(i,e,t,n){const s=[];for(let r=-1,o=i.length;++r<o;){const a=i[r],l=e[r],{length:c}=a;if(l>=n)break;if(t>=l+c)continue;if(l>=t&&l+c<=n){s.push(a);continue}const u=Math.max(0,t-l),d=Math.min(n-l,c);s.push(a.slice(u,d-u))}return s.length===0&&s.push(i[0].slice(0,0)),s}function Ub(i,e,t,n){let s=0,r=0,o=e.length-1;do{if(s>=o-1)return t<e[o]?n(i,s,t-e[s]):null;r=s+Math.trunc((o-s)*.5),t<e[r]?o=r:s=r}while(s<o)}function $b(i,e){return i.getValid(e)}function If(i){function e(t,n,s){return i(t[n],s)}return function(t){const n=this.data;return Ub(n,this._offsets,t,e)}}function VT(i){let e;function t(n,s,r){return i(n[s],r,e)}return function(n,s){const r=this.data;e=s;const o=Ub(r,this._offsets,n,t);return e=void 0,o}}function GT(i){let e;function t(n,s,r){let o=r,a=0,l=0;for(let c=s-1,u=n.length;++c<u;){const d=n[c];if(~(a=i(d,e,o)))return l+a;o=0,l+=d.length}return-1}return function(n,s){e=n;const r=this.data,o=typeof s!="number"?t(r,0,0):Ub(r,this._offsets,s,t);return e=void 0,o}}class Ie extends Qe{}function b9(i,e){return e===null&&i.length>0?0:-1}function v9(i,e){const{nullBitmap:t}=i;if(!t||i.nullCount<=0)return-1;let n=0;for(const s of new zb(t,i.offset+(e||0),i.length,t,UT)){if(!s)return n;++n}return-1}function $e(i,e,t){if(e===void 0)return-1;if(e===null)switch(i.typeId){case A.Union:break;case A.Dictionary:break;default:return v9(i,t)}const n=Dn.getVisitFn(i),s=ql(e);for(let r=(t||0)-1,o=i.length;++r<o;)if(s(n(i,r)))return r;return-1}function WT(i,e,t){const n=Dn.getVisitFn(i),s=ql(e);for(let r=(t||0)-1,o=i.length;++r<o;)if(s(n(i,r)))return r;return-1}Ie.prototype.visitNull=b9;Ie.prototype.visitBool=$e;Ie.prototype.visitInt=$e;Ie.prototype.visitInt8=$e;Ie.prototype.visitInt16=$e;Ie.prototype.visitInt32=$e;Ie.prototype.visitInt64=$e;Ie.prototype.visitUint8=$e;Ie.prototype.visitUint16=$e;Ie.prototype.visitUint32=$e;Ie.prototype.visitUint64=$e;Ie.prototype.visitFloat=$e;Ie.prototype.visitFloat16=$e;Ie.prototype.visitFloat32=$e;Ie.prototype.visitFloat64=$e;Ie.prototype.visitUtf8=$e;Ie.prototype.visitLargeUtf8=$e;Ie.prototype.visitBinary=$e;Ie.prototype.visitLargeBinary=$e;Ie.prototype.visitFixedSizeBinary=$e;Ie.prototype.visitDate=$e;Ie.prototype.visitDateDay=$e;Ie.prototype.visitDateMillisecond=$e;Ie.prototype.visitTimestamp=$e;Ie.prototype.visitTimestampSecond=$e;Ie.prototype.visitTimestampMillisecond=$e;Ie.prototype.visitTimestampMicrosecond=$e;Ie.prototype.visitTimestampNanosecond=$e;Ie.prototype.visitTime=$e;Ie.prototype.visitTimeSecond=$e;Ie.prototype.visitTimeMillisecond=$e;Ie.prototype.visitTimeMicrosecond=$e;Ie.prototype.visitTimeNanosecond=$e;Ie.prototype.visitDecimal=$e;Ie.prototype.visitList=$e;Ie.prototype.visitStruct=$e;Ie.prototype.visitUnion=$e;Ie.prototype.visitDenseUnion=WT;Ie.prototype.visitSparseUnion=WT;Ie.prototype.visitDictionary=$e;Ie.prototype.visitInterval=$e;Ie.prototype.visitIntervalDayTime=$e;Ie.prototype.visitIntervalYearMonth=$e;Ie.prototype.visitDuration=$e;Ie.prototype.visitDurationSecond=$e;Ie.prototype.visitDurationMillisecond=$e;Ie.prototype.visitDurationMicrosecond=$e;Ie.prototype.visitDurationNanosecond=$e;Ie.prototype.visitFixedSizeList=$e;Ie.prototype.visitMap=$e;const Lf=new Ie;class Le extends Qe{}function Oe(i){const{type:e}=i;if(i.nullCount===0&&i.stride===1&&(ve.isInt(e)&&e.bitWidth!==64||ve.isTime(e)&&e.bitWidth!==64||ve.isFloat(e)&&e.precision!==Ii.HALF))return new I1(i.data.length,n=>{const s=i.data[n];return s.values.subarray(0,s.length)[Symbol.iterator]()});let t=0;return new I1(i.data.length,n=>{const r=i.data[n].length,o=i.slice(t,t+r);return t+=r,new x9(o)})}class x9{constructor(e){this.vector=e,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}Le.prototype.visitNull=Oe;Le.prototype.visitBool=Oe;Le.prototype.visitInt=Oe;Le.prototype.visitInt8=Oe;Le.prototype.visitInt16=Oe;Le.prototype.visitInt32=Oe;Le.prototype.visitInt64=Oe;Le.prototype.visitUint8=Oe;Le.prototype.visitUint16=Oe;Le.prototype.visitUint32=Oe;Le.prototype.visitUint64=Oe;Le.prototype.visitFloat=Oe;Le.prototype.visitFloat16=Oe;Le.prototype.visitFloat32=Oe;Le.prototype.visitFloat64=Oe;Le.prototype.visitUtf8=Oe;Le.prototype.visitLargeUtf8=Oe;Le.prototype.visitBinary=Oe;Le.prototype.visitLargeBinary=Oe;Le.prototype.visitFixedSizeBinary=Oe;Le.prototype.visitDate=Oe;Le.prototype.visitDateDay=Oe;Le.prototype.visitDateMillisecond=Oe;Le.prototype.visitTimestamp=Oe;Le.prototype.visitTimestampSecond=Oe;Le.prototype.visitTimestampMillisecond=Oe;Le.prototype.visitTimestampMicrosecond=Oe;Le.prototype.visitTimestampNanosecond=Oe;Le.prototype.visitTime=Oe;Le.prototype.visitTimeSecond=Oe;Le.prototype.visitTimeMillisecond=Oe;Le.prototype.visitTimeMicrosecond=Oe;Le.prototype.visitTimeNanosecond=Oe;Le.prototype.visitDecimal=Oe;Le.prototype.visitList=Oe;Le.prototype.visitStruct=Oe;Le.prototype.visitUnion=Oe;Le.prototype.visitDenseUnion=Oe;Le.prototype.visitSparseUnion=Oe;Le.prototype.visitDictionary=Oe;Le.prototype.visitInterval=Oe;Le.prototype.visitIntervalDayTime=Oe;Le.prototype.visitIntervalYearMonth=Oe;Le.prototype.visitDuration=Oe;Le.prototype.visitDurationSecond=Oe;Le.prototype.visitDurationMillisecond=Oe;Le.prototype.visitDurationMicrosecond=Oe;Le.prototype.visitDurationNanosecond=Oe;Le.prototype.visitFixedSizeList=Oe;Le.prototype.visitMap=Oe;const jb=new Le;var YT;const qT={},XT={};class ze{constructor(e){var t,n,s;const r=e[0]instanceof ze?e.flatMap(a=>a.data):e;if(r.length===0||r.some(a=>!(a instanceof vt)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(t=r[0])===null||t===void 0?void 0:t.type;switch(r.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:c}=qT[o.typeId],u=r[0];this.isValid=d=>$b(u,d),this.get=d=>a(u,d),this.set=(d,h)=>l(u,d,h),this.indexOf=d=>c(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,XT[o.typeId]),this._offsets=jT(r);break}this.data=r,this.type=o,this.stride=dr(o),this.numChildren=(s=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&s!==void 0?s:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return y9(this.data)}get nullCount(){return $T(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${A[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Fb(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return jb.visit(this)}concat(...e){return new ze(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new ze(zT(this,e,t,({data:n,_offsets:s},r,o)=>HT(n,s,r,o)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:n,stride:s,ArrayType:r}=this;switch(e.typeId){case A.Int:case A.Float:case A.Decimal:case A.Time:case A.Timestamp:switch(t.length){case 0:return new r;case 1:return t[0].values.subarray(0,n*s);default:return t.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*s),o.offset),o.offset+=l*s,o),{array:new r(n*s),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(n=>n.name===e))}getChildAt(e){return e>-1&&e<this.numChildren?new ze(this.data.map(({children:t})=>t[e])):null}get isMemoized(){return ve.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(ve.isDictionary(this.type)){const e=new Rf(this.data[0].dictionary),t=this.data.map(n=>{const s=n.clone();return s.dictionary=e,s});return new ze(t)}return new Rf(this)}unmemoize(){if(ve.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(n=>{const s=n.clone();return s.dictionary=e,s});return new ze(t)}return this}}YT=Symbol.toStringTag;ze[YT]=(i=>{i.type=ve.prototype,i.data=[],i.length=0,i.stride=1,i.numChildren=0,i._offsets=new Uint32Array([0]),i[Symbol.isConcatSpreadable]=!0;const e=Object.keys(A).map(t=>A[t]).filter(t=>typeof t=="number"&&t!==A.NONE);for(const t of e){const n=Dn.getVisitFnByTypeId(t),s=vs.getVisitFnByTypeId(t),r=Lf.getVisitFnByTypeId(t);qT[t]={get:n,set:s,indexOf:r},XT[t]=Object.create(i,{isValid:{value:If($b)},get:{value:If(Dn.getVisitFnByTypeId(t))},set:{value:VT(vs.getVisitFnByTypeId(t))},indexOf:{value:GT(Lf.getVisitFnByTypeId(t))}})}return"Vector"})(ze.prototype);class Rf extends ze{constructor(e){super(e.data);const t=this.get,n=this.set,s=this.slice,r=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=r[o];if(a!==void 0)return a;const l=t.call(this,o);return r[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),r[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new Rf(s.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new ze(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}function KT(i){if(i){if(i instanceof vt)return new ze([i]);if(i instanceof ze)return new ze(i.data);if(i.type instanceof ve)return new ze([De(i)]);if(Array.isArray(i))return new ze(i.flatMap(e=>w9(e)));if(ArrayBuffer.isView(i)){i instanceof DataView&&(i=new Uint8Array(i.buffer));const e={offset:0,length:i.length,nullCount:-1,data:i};if(i instanceof Int8Array)return new ze([De(Object.assign(Object.assign({},e),{type:new qC}))]);if(i instanceof Int16Array)return new ze([De(Object.assign(Object.assign({},e),{type:new XC}))]);if(i instanceof Int32Array)return new ze([De(Object.assign(Object.assign({},e),{type:new xa}))]);if(i instanceof BigInt64Array)return new ze([De(Object.assign(Object.assign({},e),{type:new yb}))]);if(i instanceof Uint8Array||i instanceof Uint8ClampedArray)return new ze([De(Object.assign(Object.assign({},e),{type:new KC}))]);if(i instanceof Uint16Array)return new ze([De(Object.assign(Object.assign({},e),{type:new ZC}))]);if(i instanceof Uint32Array)return new ze([De(Object.assign(Object.assign({},e),{type:new QC}))]);if(i instanceof BigUint64Array)return new ze([De(Object.assign(Object.assign({},e),{type:new JC}))]);if(i instanceof Float32Array)return new ze([De(Object.assign(Object.assign({},e),{type:new eT}))]);if(i instanceof Float64Array)return new ze([De(Object.assign(Object.assign({},e),{type:new bb}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function w9(i){return i instanceof vt?[i]:i instanceof ze?i.data:KT(i).data}function S9(i){if(!i||i.length<=0)return function(s){return!0};let e="";const t=i.filter(n=>n===n);return t.length>0&&(e=`
    switch (x) {${t.map(n=>`
        case ${E9(n)}:`).join("")}
            return false;
    }`),i.length!==t.length&&(e=`if (x !== x) return false;
${e}`),new Function("x",`${e}
return true;`)}function E9(i){return typeof i!="bigint"?va(i):`${va(i)}n`}function Tm(i,e){const t=Math.ceil(i)*e-1;return(t-t%64+64||64)/e}function L1(i,e=0){return i.length>=e?i.subarray(0,e):g_(new i.constructor(e),i,0)}class Zu{constructor(e,t=0,n=1){this.length=Math.ceil(t/n),this.buffer=new e(this.length),this.stride=n,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,t){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;const t=this.stride,n=this.length*t,s=this.buffer.length;n>=s&&this._resize(s===0?Tm(n*1,this.BYTES_PER_ELEMENT):Tm(n*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Tm(e*this.stride,this.BYTES_PER_ELEMENT);const t=L1(this.buffer,e);return this.clear(),t}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=L1(this.buffer,e)}}class Qu extends Zu{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,t){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=t,this}}class ZT extends Qu{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,t){const{buffer:n}=this.reserve(e-this.length+1),s=e>>3,r=e%8,o=n[s]>>r&1;return t?o===0&&(n[s]|=1<<r,++this.numValid):o===1&&(n[s]&=~(1<<r),--this.numValid),this}clear(){return this.numValid=0,super.clear()}}class QT extends Qu{constructor(e){super(e.OffsetArrayType,1,1)}append(e){return this.set(this.length-1,e)}set(e,t){const n=this.length-1,s=this.reserve(e-n+1).buffer;return n<e++&&n>=0&&s.fill(s[n],n,e),s[e]=s[e-1]+t,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}}let Mn=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:t}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=t,this.stride=dr(e),this._nulls=new ZT,t&&t.length>0&&(this._isValid=S9(t))}toVector(){return new ze([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0;const{_offsets:t,_values:n,_nulls:s,_typeIds:r,children:o}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),s&&(e+=s.byteLength),r&&(e+=r.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((t,n)=>t+n.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,t){return this.setValid(e,this.isValid(t))&&this.setValue(e,t),this}setValue(e,t){this._setValue(this,e,t)}setValid(e,t){return this.length=this._nulls.set(e,+t).length,t}addChild(e,t=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,t,n,s;const{type:r,length:o,nullCount:a,_typeIds:l,_offsets:c,_values:u,_nulls:d}=this;(t=l==null?void 0:l.flush(o))?s=c==null?void 0:c.flush(o):(s=c==null?void 0:c.flush(o))?e=u==null?void 0:u.flush(c.last()):e=u==null?void 0:u.flush(o),a>0&&(n=d==null?void 0:d.flush(o));const h=this.children.map(p=>p.flush());return this.clear(),De({type:r,length:o,nullCount:a,children:h,child:h[0],data:e,typeIds:t,nullBitmap:n,valueOffsets:s})}finish(){this.finished=!0;for(const e of this.children)e.finish();return this}clear(){var e,t,n,s;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(t=this._values)===null||t===void 0||t.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(s=this._typeIds)===null||s===void 0||s.clear();for(const r of this.children)r.clear();return this}};Mn.prototype.length=1;Mn.prototype.stride=1;Mn.prototype.children=null;Mn.prototype.finished=!1;Mn.prototype.nullValues=null;Mn.prototype._isValid=()=>!0;class yo extends Mn{constructor(e){super(e),this._values=new Qu(this.ArrayType,0,this.stride)}setValue(e,t){const n=this._values;return n.reserve(e-n.length+1),super.setValue(e,t)}}class Xl extends Mn{constructor(e){super(e),this._pendingLength=0,this._offsets=new QT(e.type)}setValue(e,t){const n=this._pending||(this._pending=new Map),s=n.get(e);s&&(this._pendingLength-=s.length),this._pendingLength+=t instanceof Ep?t[sa].length:t.length,n.set(e,t)}setValid(e,t){return super.setValid(e,t)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){const e=this._pending,t=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,t),this}}class S_{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,n,s){return e.prep(8,24),e.writeInt64(BigInt(s??0)),e.pad(4),e.writeInt32(n),e.writeInt64(BigInt(t??0)),e.offset()}}class $n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new $n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+Pt),(t||new $n).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ui.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new lr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const n=this.bb.__offset(this.bb_pos,8);return n?(t||new S_).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new S_).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new Ei).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ui.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class kt{constructor(e=[],t,n,s=ui.V5){this.fields=e||[],this.metadata=t||new Map,n||(n=E_(this.fields)),this.dictionaries=n,this.metadataVersion=s}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),n=this.fields.filter(s=>t.has(s.name));return new kt(n,this.metadata)}selectAt(e){const t=e.map(n=>this.fields[n]).filter(Boolean);return new kt(t,this.metadata)}assign(...e){const t=e[0]instanceof kt?e[0]:Array.isArray(e[0])?new kt(e[0]):new kt(e),n=[...this.fields],s=Od(Od(new Map,this.metadata),t.metadata),r=t.fields.filter(a=>{const l=n.findIndex(c=>c.name===a.name);return~l?(n[l]=a.clone({metadata:Od(Od(new Map,n[l].metadata),a.metadata)}))&&!1:!0}),o=E_(r,new Map);return new kt([...n,...r],s,new Map([...this.dictionaries,...o]))}}kt.prototype.fields=null;kt.prototype.metadata=null;kt.prototype.dictionaries=null;class wt{static new(...e){let[t,n,s,r]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],n===void 0&&(n=e[0].type),s===void 0&&(s=e[0].nullable),r===void 0&&(r=e[0].metadata)),new wt(`${t}`,n,s,r)}constructor(e,t,n=!1,s){this.name=e,this.type=t,this.nullable=n,this.metadata=s||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,n,s,r]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,n=this.type,s=this.nullable,r=this.metadata]=e:{name:t=this.name,type:n=this.type,nullable:s=this.nullable,metadata:r=this.metadata}=e[0],wt.new(t,n,s,r)}}wt.prototype.type=null;wt.prototype.name=null;wt.prototype.nullable=null;wt.prototype.metadata=null;function Od(i,e){return new Map([...i||new Map,...e||new Map])}function E_(i,e=new Map){for(let t=-1,n=i.length;++t<n;){const r=i[t].type;if(ve.isDictionary(r)){if(!e.has(r.id))e.set(r.id,r.dictionary);else if(e.get(r.id)!==r.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}r.children&&r.children.length>0&&E_(r.children,e)}return e}var C9=vC,T9=Rl;class Lu{static decode(e){e=new T9(ot(e));const t=$n.getRootAsFooter(e),n=kt.decode(t.schema(),new Map,t.version());return new k9(n,t)}static encode(e){const t=new C9,n=kt.encode(t,e.schema);$n.startRecordBatchesVector(t,e.numRecordBatches);for(const o of[...e.recordBatches()].slice().reverse())qo.encode(t,o);const s=t.endVector();$n.startDictionariesVector(t,e.numDictionaries);for(const o of[...e.dictionaryBatches()].slice().reverse())qo.encode(t,o);const r=t.endVector();return $n.startFooter(t),$n.addSchema(t,n),$n.addVersion(t,ui.V5),$n.addRecordBatches(t,s),$n.addDictionaries(t,r),$n.finishFooterBuffer(t,$n.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ui.V5,n,s){this.schema=e,this.version=t,n&&(this._recordBatches=n),s&&(this._dictionaryBatches=s)}*recordBatches(){for(let e,t=-1,n=this.numRecordBatches;++t<n;)(e=this.getRecordBatch(t))&&(yield e)}*dictionaryBatches(){for(let e,t=-1,n=this.numDictionaries;++t<n;)(e=this.getDictionaryBatch(t))&&(yield e)}getRecordBatch(e){return e>=0&&e<this.numRecordBatches&&this._recordBatches[e]||null}getDictionaryBatch(e){return e>=0&&e<this.numDictionaries&&this._dictionaryBatches[e]||null}}class k9 extends Lu{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(e,t){super(e,t.version()),this._footer=t}getRecordBatch(e){if(e>=0&&e<this.numRecordBatches){const t=this._footer.recordBatches(e);if(t)return qo.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){const t=this._footer.dictionaries(e);if(t)return qo.decode(t)}return null}}class qo{static decode(e){return new qo(e.metaDataLength(),e.bodyLength(),e.offset())}static encode(e,t){const{metaDataLength:n}=t,s=BigInt(t.offset),r=BigInt(t.bodyLength);return S_.createBlock(e,s,n,r)}constructor(e,t,n){this.metaDataLength=e,this.offset=Ht(n),this.bodyLength=Ht(t)}}const ii=Object.freeze({done:!0,value:void 0});class R1{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Hb{tee(){return this._getDOMStream().tee()}pipe(e,t){return this._getNodeStream().pipe(e,t)}pipeTo(e,t){return this._getDOMStream().pipeTo(e,t)}pipeThrough(e,t){return this._getDOMStream().pipeThrough(e,t)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class A9 extends Hb{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return je(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(ii);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return cs.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return cs.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return je(this,void 0,void 0,function*(){return yield this.abort(e),ii})}return(e){return je(this,void 0,void 0,function*(){return yield this.close(),ii})}read(e){return je(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return je(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,n)=>{this.resolvers.push({resolve:t,reject:n})}):Promise.resolve(ii)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Ih extends A9{write(e){if((e=ot(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?p_(this.toUint8Array(!0)):this.toUint8Array(!1).then(p_)}toUint8Array(e=!1){return e?Er(this._values)[0]:je(this,void 0,void 0,function*(){var t,n,s,r;const o=[];let a=0;try{for(var l=!0,c=ua(this),u;u=yield c.next(),t=u.done,!t;l=!0){r=u.value,l=!1;const d=r;o.push(d),a+=d.byteLength}}catch(d){n={error:d}}finally{try{!l&&!t&&(s=c.return)&&(yield s.call(c))}finally{if(n)throw n.error}}return Er(o,a)[0]})}}class Pf{constructor(e){e&&(this.source=new I9(cs.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Ml{constructor(e){e instanceof Ml?this.source=e.source:e instanceof Ih?this.source=new ia(cs.fromAsyncIterable(e)):gC(e)?this.source=new ia(cs.fromNodeStream(e)):mb(e)?this.source=new ia(cs.fromDOMStream(e)):mC(e)?this.source=new ia(cs.fromDOMStream(e.body)):Ku(e)?this.source=new ia(cs.fromIterable(e)):Wo(e)?this.source=new ia(cs.fromAsyncIterable(e)):Yl(e)&&(this.source=new ia(cs.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class I9{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||ii)}return(e){return Object.create(this.source.return&&this.source.return(e)||ii)}}class ia{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return je(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return je(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return je(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return je(this,arguments,void 0,function*(t,n="read"){return yield this.source.next({cmd:n,size:t})})}throw(e){return je(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||ii;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return je(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||ii;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class P1 extends Pf{constructor(e,t){super(),this.position=0,this.buffer=ot(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:n}=this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e<this.size}read(e){const{buffer:t,size:n,position:s}=this;return t&&s<n?(typeof e!="number"&&(e=Number.POSITIVE_INFINITY),this.position=Math.min(n,s+Math.min(n-s,e)),t.subarray(s,this.position)):null}readAt(e,t){const n=this.buffer,s=Math.min(this.size,e+t);return n?n.subarray(e,s):new Uint8Array(t)}close(){this.buffer&&(this.buffer=null)}throw(e){return this.close(),{done:!0,value:e}}return(e){return this.close(),{done:!0,value:e}}}class Nf extends Ml{constructor(e,t){super(),this.position=0,this._handle=e,typeof t=="number"?this.size=t:this._pending=je(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending})}readInt32(e){return je(this,void 0,void 0,function*(){const{buffer:t,byteOffset:n}=yield this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)})}seek(e){return je(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e<this.size})}read(e){return je(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:t,size:n,position:s}=this;if(t&&s<n){typeof e!="number"&&(e=Number.POSITIVE_INFINITY);let r=s,o=0,a=0;const l=Math.min(n,r+Math.min(n-r,e)),c=new Uint8Array(Math.max(0,(this.position=l)-r));for(;(r+=a)<l&&(o+=a)<c.byteLength;)({bytesRead:a}=yield t.read(c,o,c.byteLength-o,r));return c}return null})}readAt(e,t){return je(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:s}=this;if(n&&e+t<s){const r=Math.min(s,e+t),o=new Uint8Array(r-e);return(yield n.read(o,0,t,e)).buffer}return new Uint8Array(t)})}close(){return je(this,void 0,void 0,function*(){const e=this._handle;this._handle=null,e&&(yield e.close())})}throw(e){return je(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}return(e){return je(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}}const L9=65536;function rl(i){return i<0&&(i=4294967295+i+1),`0x${i.toString(16)}`}const Bl=8,Vb=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class JT{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){const t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let s=t[3]*n[3];this.buffer[0]=s&65535;let r=s>>>16;return s=t[2]*n[3],r+=s,s=t[3]*n[2]>>>0,r+=s,this.buffer[0]+=r<<16,this.buffer[1]=r>>>0<s?L9:0,this.buffer[1]+=r>>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]<e.buffer[1]||this.buffer[1]===e.buffer[1]&&this.buffer[0]<e.buffer[0]}equals(e){return this.buffer[1]===e.buffer[1]&&this.buffer[0]==e.buffer[0]}greaterThan(e){return e.lessThan(this)}hex(){return`${rl(this.buffer[1])} ${rl(this.buffer[0])}`}}class Mt extends JT{times(e){return this._times(e),this}plus(e){return this._plus(e),this}static from(e,t=new Uint32Array(2)){return Mt.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(2)){return Mt.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(2)){const n=e.length,s=new Mt(t);for(let r=0;r<n;){const o=Bl<n-r?Bl:n-r,a=new Mt(new Uint32Array([Number.parseInt(e.slice(r,r+o),10),0])),l=new Mt(new Uint32Array([Vb[o],0]));s.times(l),s.plus(a),r+=o}return s}static convertArray(e){const t=new Uint32Array(e.length*2);for(let n=-1,s=e.length;++n<s;)Mt.from(e[n],new Uint32Array(t.buffer,t.byteOffset+2*n*4,2));return t}static multiply(e,t){return new Mt(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Mt(new Uint32Array(e.buffer)).plus(t)}}class Cn extends JT{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(e){return this._times(e),this}plus(e){return this._plus(e),this}lessThan(e){const t=this.buffer[1]<<0,n=e.buffer[1]<<0;return t<n||t===n&&this.buffer[0]<e.buffer[0]}static from(e,t=new Uint32Array(2)){return Cn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(2)){return Cn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(2)){const n=e.startsWith("-"),s=e.length,r=new Cn(t);for(let o=n?1:0;o<s;){const a=Bl<s-o?Bl:s-o,l=new Cn(new Uint32Array([Number.parseInt(e.slice(o,o+a),10),0])),c=new Cn(new Uint32Array([Vb[a],0]));r.times(c),r.plus(l),o+=a}return n?r.negate():r}static convertArray(e){const t=new Uint32Array(e.length*2);for(let n=-1,s=e.length;++n<s;)Cn.from(e[n],new Uint32Array(t.buffer,t.byteOffset+2*n*4,2));return t}static multiply(e,t){return new Cn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Cn(new Uint32Array(e.buffer)).plus(t)}}class cr{constructor(e){this.buffer=e}high(){return new Cn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Cn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(e){const t=new Mt(new Uint32Array([this.buffer[3],0])),n=new Mt(new Uint32Array([this.buffer[2],0])),s=new Mt(new Uint32Array([this.buffer[1],0])),r=new Mt(new Uint32Array([this.buffer[0],0])),o=new Mt(new Uint32Array([e.buffer[3],0])),a=new Mt(new Uint32Array([e.buffer[2],0])),l=new Mt(new Uint32Array([e.buffer[1],0])),c=new Mt(new Uint32Array([e.buffer[0],0]));let u=Mt.multiply(r,c);this.buffer[0]=u.low();const d=new Mt(new Uint32Array([u.high(),0]));return u=Mt.multiply(s,c),d.plus(u),u=Mt.multiply(r,l),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new Mt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Mt.multiply(n,c)).plus(Mt.multiply(s,l)).plus(Mt.multiply(r,a)),this.buffer[3]+=Mt.multiply(t,c).plus(Mt.multiply(n,l)).plus(Mt.multiply(s,a)).plus(Mt.multiply(r,o)).low(),this}plus(e){const t=new Uint32Array(4);return t[3]=this.buffer[3]+e.buffer[3]>>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]<this.buffer[0]>>>0&&++t[1],t[1]<this.buffer[1]>>>0&&++t[2],t[2]<this.buffer[2]>>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${rl(this.buffer[3])} ${rl(this.buffer[2])} ${rl(this.buffer[1])} ${rl(this.buffer[0])}`}static multiply(e,t){return new cr(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new cr(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return cr.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return cr.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const n=e.startsWith("-"),s=e.length,r=new cr(t);for(let o=n?1:0;o<s;){const a=Bl<s-o?Bl:s-o,l=new cr(new Uint32Array([Number.parseInt(e.slice(o,o+a),10),0,0,0])),c=new cr(new Uint32Array([Vb[a],0,0,0]));r.times(c),r.plus(l),o+=a}return n?r.negate():r}static convertArray(e){const t=new Uint32Array(e.length*4);for(let n=-1,s=e.length;++n<s;)cr.from(e[n],new Uint32Array(t.buffer,t.byteOffset+16*n,4));return t}}class ek extends Qe{constructor(e,t,n,s,r=ui.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=e,this.nodes=t,this.buffers=n,this.dictionaries=s,this.metadataVersion=r}visit(e){return super.visit(e instanceof wt?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return De({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitFixedSizeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}visitStruct(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),children:this.visitMany(e.children)})}visitUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<ui.V5&&this.readNullBitmap(e,n),e.mode===en.Sparse?this.visitSparseUnion(e,{length:t,nullCount:n}):this.visitDenseUnion(e,{length:t,nullCount:n})}visitDenseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),valueOffsets:this.readOffsets(e),children:this.visitMany(e.children)})}visitSparseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e.indices),dictionary:this.readDictionary(e)})}visitInterval(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),child:this.visit(e.children[0])})}visitMap(e,{length:t,nullCount:n}=this.nextFieldNode()){return De({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(e,t,n=this.nextBufferRange()){return t>0&&this.readData(e,n)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class R9 extends ek{constructor(e,t,n,s,r){super(new Uint8Array(0),t,n,s,r),this.sources=e}readNullBitmap(e,t,{offset:n}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Af(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Bt(Uint8Array,Bt(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Bt(Uint8Array,Bt(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:n}=this;return ve.isTimestamp(e)||(ve.isInt(e)||ve.isTime(e))&&e.bitWidth===64||ve.isDuration(e)||ve.isDate(e)&&e.unit===bs.MILLISECOND?Bt(Uint8Array,Cn.convertArray(n[t])):ve.isDecimal(e)?Bt(Uint8Array,cr.convertArray(n[t])):ve.isBinary(e)||ve.isLargeBinary(e)||ve.isFixedSizeBinary(e)?P9(n[t]):ve.isBool(e)?Af(n[t]):ve.isUtf8(e)||ve.isLargeUtf8(e)?Xu(n[t].join("")):Bt(Uint8Array,Bt(e.ArrayType,n[t].map(s=>+s)))}}function P9(i){const e=i.join(""),t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n>>1]=Number.parseInt(e.slice(n,n+2),16);return t}class tk extends Xl{constructor(e){super(e),this._values=new Zu(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,ot(t))}_flushPending(e,t){const n=this._offsets,s=this._values.reserve(t).buffer;let r=0;for(const[o,a]of e)if(a===void 0)n.set(o,0);else{const l=a.length;s.set(a,r),n.set(o,l),r+=l}}}class ik extends Xl{constructor(e){super(e),this._values=new Zu(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,ot(t))}_flushPending(e,t){const n=this._offsets,s=this._values.reserve(t).buffer;let r=0;for(const[o,a]of e)if(a===void 0)n.set(o,BigInt(0));else{const l=a.length;s.set(a,r),n.set(o,BigInt(l)),r+=l}}}class N9 extends Mn{constructor(e){super(e),this._values=new ZT}setValue(e,t){this._values.set(e,+t)}}class Tp extends yo{}Tp.prototype._setValue=cT;class nk extends Tp{}nk.prototype._setValue=xb;class sk extends Tp{}sk.prototype._setValue=wb;class rk extends yo{}rk.prototype._setValue=hT;class D9 extends Mn{constructor({type:e,nullValues:t,dictionaryHashFunction:n}){super({type:new Yo(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Df({type:this.type.indices,nullValues:t}),this.dictionary=Df({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,t){const n=this.indices;return t=n.setValid(e,t),this.length=n.length,t}setValue(e,t){const n=this._keysToIndices,s=this.valueToKey(t);let r=n[s];return r===void 0&&(n[s]=r=this._dictionaryOffset+this.dictionary.append(t).length-1),this.indices.setValue(e,r)}flush(){const e=this.type,t=this._dictionary,n=this.dictionary.toVector(),s=this.indices.flush().clone(e);return s.dictionary=t?t.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=s.dictionary,this.clear(),s}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}}class ok extends yo{}ok.prototype._setValue=oT;class M9 extends Mn{setValue(e,t){const[n]=this.children,s=e*this.stride;for(let r=-1,o=t.length;++r<o;)n.set(s+r,t[r])}addChild(e,t="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");const n=this.children.push(e);return this.type=new Au(this.type.listSize,new wt(t,e.type,!0)),n}}class kp extends yo{setValue(e,t){this._values.set(e,t)}}class B9 extends kp{setValue(e,t){super.setValue(e,nT(t))}}class O9 extends kp{}class F9 extends kp{}class Ap extends yo{}Ap.prototype._setValue=mT;class ak extends Ap{}ak.prototype._setValue=Rb;class lk extends Ap{}lk.prototype._setValue=Pb;class Kl extends yo{}Kl.prototype._setValue=gT;class ck extends Kl{}ck.prototype._setValue=Nb;class uk extends Kl{}uk.prototype._setValue=Db;class dk extends Kl{}dk.prototype._setValue=Mb;class hk extends Kl{}hk.prototype._setValue=Bb;class bo extends yo{setValue(e,t){this._values.set(e,t)}}class z9 extends bo{}class U9 extends bo{}class $9 extends bo{}class j9 extends bo{}class H9 extends bo{}class V9 extends bo{}class G9 extends bo{}class W9 extends bo{}class Y9 extends Xl{constructor(e){super(e),this._offsets=new QT(e.type)}addChild(e,t="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new Dl(new wt(t,e.type,!0)),this.numChildren-1}_flushPending(e){const t=this._offsets,[n]=this.children;for(const[s,r]of e)if(typeof r>"u")t.set(s,0);else{const o=r,a=o.length,l=t.set(s,a).buffer[s];for(let c=-1;++c<a;)n.set(l+c,o[c])}}}class q9 extends Xl{set(e,t){return super.set(e,t)}setValue(e,t){const n=t instanceof Map?t:new Map(Object.entries(t)),s=this._pending||(this._pending=new Map),r=s.get(e);r&&(this._pendingLength-=r.size),this._pendingLength+=n.size,s.set(e,n)}addChild(e,t=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new Iu(new wt(t,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){const t=this._offsets,[n]=this.children;for(const[s,r]of e)if(r===void 0)t.set(s,0);else{let{[s]:o,[s+1]:a}=t.set(s,r.size).buffer;for(const l of r.entries())if(n.set(o,l),++o>=a)break}}}class X9 extends Mn{setValue(e,t){}setValid(e,t){return this.length=Math.max(e+1,this.length),t}}class K9 extends Mn{setValue(e,t){const{children:n,type:s}=this;switch(Array.isArray(t)||t.constructor){case!0:return s.children.forEach((r,o)=>n[o].set(e,t[o]));case Map:return s.children.forEach((r,o)=>n[o].set(e,t.get(r.name)));default:return s.children.forEach((r,o)=>n[o].set(e,t[r.name]))}}setValid(e,t){return super.setValid(e,t)||this.children.forEach(n=>n.setValid(e,t)),t}addChild(e,t=`${this.numChildren}`){const n=this.children.push(e);return this.type=new Oi([...this.type.children,new wt(t,e.type,!0)]),n}}class Zl extends yo{}Zl.prototype._setValue=uT;class fk extends Zl{}fk.prototype._setValue=Sb;class pk extends Zl{}pk.prototype._setValue=Eb;class mk extends Zl{}mk.prototype._setValue=Cb;class gk extends Zl{}gk.prototype._setValue=Tb;class Ql extends yo{}Ql.prototype._setValue=dT;class _k extends Ql{}_k.prototype._setValue=kb;class yk extends Ql{}yk.prototype._setValue=Ab;class bk extends Ql{}bk.prototype._setValue=Ib;class vk extends Ql{}vk.prototype._setValue=Lb;class Gb extends Mn{constructor(e){super(e),this._typeIds=new Qu(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,t){return this.set(this.length,e,t)}set(e,t,n){return n===void 0&&(n=this._valueToChildTypeId(this,t,e)),this.setValue(e,t,n),this}setValue(e,t,n){this._typeIds.set(e,n);const s=this.type.typeIdToChildIndex[n],r=this.children[s];r==null||r.set(e,t)}addChild(e,t=`${this.children.length}`){const n=this.children.push(e),{type:{children:s,mode:r,typeIds:o}}=this,a=[...s,new wt(t,e.type)];return this.type=new ku(r,[...o,n],a),n}_valueToChildTypeId(e,t,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}}class Z9 extends Gb{}class Q9 extends Gb{constructor(e){super(e),this._offsets=new Qu(Int32Array)}setValue(e,t,n){const s=this._typeIds.set(e,n).buffer[e],r=this.getChildAt(this.type.typeIdToChildIndex[s]),o=this._offsets.set(e,r.length).buffer[e];r==null||r.set(o,t)}}class xk extends Xl{constructor(e){super(e),this._values=new Zu(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,Xu(t))}_flushPending(e,t){}}xk.prototype._flushPending=tk.prototype._flushPending;class wk extends Xl{constructor(e){super(e),this._values=new Zu(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,Xu(t))}_flushPending(e,t){}}wk.prototype._flushPending=ik.prototype._flushPending;class J9 extends Qe{visitNull(){return X9}visitBool(){return N9}visitInt(){return bo}visitInt8(){return z9}visitInt16(){return U9}visitInt32(){return $9}visitInt64(){return j9}visitUint8(){return H9}visitUint16(){return V9}visitUint32(){return G9}visitUint64(){return W9}visitFloat(){return kp}visitFloat16(){return B9}visitFloat32(){return O9}visitFloat64(){return F9}visitUtf8(){return xk}visitLargeUtf8(){return wk}visitBinary(){return tk}visitLargeBinary(){return ik}visitFixedSizeBinary(){return ok}visitDate(){return Tp}visitDateDay(){return nk}visitDateMillisecond(){return sk}visitTimestamp(){return Zl}visitTimestampSecond(){return fk}visitTimestampMillisecond(){return pk}visitTimestampMicrosecond(){return mk}visitTimestampNanosecond(){return gk}visitTime(){return Ql}visitTimeSecond(){return _k}visitTimeMillisecond(){return yk}visitTimeMicrosecond(){return bk}visitTimeNanosecond(){return vk}visitDecimal(){return rk}visitList(){return Y9}visitStruct(){return K9}visitUnion(){return Gb}visitDenseUnion(){return Q9}visitSparseUnion(){return Z9}visitDictionary(){return D9}visitInterval(){return Ap}visitIntervalDayTime(){return ak}visitIntervalYearMonth(){return lk}visitDuration(){return Kl}visitDurationSecond(){return ck}visitDurationMillisecond(){return uk}visitDurationMicrosecond(){return dk}visitDurationNanosecond(){return hk}visitFixedSizeList(){return M9}visitMap(){return q9}}const e$=new J9;class Re extends Qe{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((n,s)=>this.compareFields(n,t[s]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function bn(i,e){return e instanceof i.constructor}function ka(i,e){return i===e||bn(i,e)}function vo(i,e){return i===e||bn(i,e)&&i.bitWidth===e.bitWidth&&i.isSigned===e.isSigned}function Ip(i,e){return i===e||bn(i,e)&&i.precision===e.precision}function t$(i,e){return i===e||bn(i,e)&&i.byteWidth===e.byteWidth}function Wb(i,e){return i===e||bn(i,e)&&i.unit===e.unit}function Ju(i,e){return i===e||bn(i,e)&&i.unit===e.unit&&i.timezone===e.timezone}function ed(i,e){return i===e||bn(i,e)&&i.unit===e.unit&&i.bitWidth===e.bitWidth}function i$(i,e){return i===e||bn(i,e)&&i.children.length===e.children.length&&uo.compareManyFields(i.children,e.children)}function n$(i,e){return i===e||bn(i,e)&&i.children.length===e.children.length&&uo.compareManyFields(i.children,e.children)}function Yb(i,e){return i===e||bn(i,e)&&i.mode===e.mode&&i.typeIds.every((t,n)=>t===e.typeIds[n])&&uo.compareManyFields(i.children,e.children)}function s$(i,e){return i===e||bn(i,e)&&i.id===e.id&&i.isOrdered===e.isOrdered&&uo.visit(i.indices,e.indices)&&uo.visit(i.dictionary,e.dictionary)}function qb(i,e){return i===e||bn(i,e)&&i.unit===e.unit}function td(i,e){return i===e||bn(i,e)&&i.unit===e.unit}function r$(i,e){return i===e||bn(i,e)&&i.listSize===e.listSize&&i.children.length===e.children.length&&uo.compareManyFields(i.children,e.children)}function o$(i,e){return i===e||bn(i,e)&&i.keysSorted===e.keysSorted&&i.children.length===e.children.length&&uo.compareManyFields(i.children,e.children)}Re.prototype.visitNull=ka;Re.prototype.visitBool=ka;Re.prototype.visitInt=vo;Re.prototype.visitInt8=vo;Re.prototype.visitInt16=vo;Re.prototype.visitInt32=vo;Re.prototype.visitInt64=vo;Re.prototype.visitUint8=vo;Re.prototype.visitUint16=vo;Re.prototype.visitUint32=vo;Re.prototype.visitUint64=vo;Re.prototype.visitFloat=Ip;Re.prototype.visitFloat16=Ip;Re.prototype.visitFloat32=Ip;Re.prototype.visitFloat64=Ip;Re.prototype.visitUtf8=ka;Re.prototype.visitLargeUtf8=ka;Re.prototype.visitBinary=ka;Re.prototype.visitLargeBinary=ka;Re.prototype.visitFixedSizeBinary=t$;Re.prototype.visitDate=Wb;Re.prototype.visitDateDay=Wb;Re.prototype.visitDateMillisecond=Wb;Re.prototype.visitTimestamp=Ju;Re.prototype.visitTimestampSecond=Ju;Re.prototype.visitTimestampMillisecond=Ju;Re.prototype.visitTimestampMicrosecond=Ju;Re.prototype.visitTimestampNanosecond=Ju;Re.prototype.visitTime=ed;Re.prototype.visitTimeSecond=ed;Re.prototype.visitTimeMillisecond=ed;Re.prototype.visitTimeMicrosecond=ed;Re.prototype.visitTimeNanosecond=ed;Re.prototype.visitDecimal=ka;Re.prototype.visitList=i$;Re.prototype.visitStruct=n$;Re.prototype.visitUnion=Yb;Re.prototype.visitDenseUnion=Yb;Re.prototype.visitSparseUnion=Yb;Re.prototype.visitDictionary=s$;Re.prototype.visitInterval=qb;Re.prototype.visitIntervalDayTime=qb;Re.prototype.visitIntervalYearMonth=qb;Re.prototype.visitDuration=td;Re.prototype.visitDurationSecond=td;Re.prototype.visitDurationMillisecond=td;Re.prototype.visitDurationMicrosecond=td;Re.prototype.visitDurationNanosecond=td;Re.prototype.visitFixedSizeList=r$;Re.prototype.visitMap=o$;const uo=new Re;function C_(i,e){return uo.compareSchemas(i,e)}function a$(i,e){return uo.visit(i,e)}function Df(i){const e=i.type,t=new(e$.getVisitFn(e)())(i);if(e.children&&e.children.length>0){const n=i.children||[],s={nullValues:i.nullValues},r=Array.isArray(n)?((o,a)=>n[a]||s):(({name:o})=>n[o]||s);for(const[o,a]of e.children.entries()){const{type:l}=a,c=r(a,o);t.children.push(Df(Object.assign(Object.assign({},c),{type:l})))}}return t}function no(i,e){if(i instanceof vt||i instanceof ze||i.type instanceof ve||ArrayBuffer.isView(i))return KT(i);const t={type:Lh(i),nullValues:[null]},n=[...c$(t)(i)],s=n.length===1?n[0]:n.reduce((r,o)=>r.concat(o));return ve.isDictionary(s.type)?s.memoize():s}function l$(i){const e=no(i),t=new dn(new kt(e.type.children),e.data[0]);return new zt(t)}function Lh(i){if(i.length===0)return new co;let e=0,t=0,n=0,s=0,r=0,o=0,a=0,l=0;for(const c of i){if(c==null){++e;continue}switch(typeof c){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++s;continue;case"string":++r;continue;case"object":Array.isArray(c)?++t:Object.prototype.toString.call(c)==="[object Date]"?++l:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(s+e===i.length)return new bb;if(r+e===i.length)return new Yo(new Eu,new xa);if(o+e===i.length)return new yb;if(a+e===i.length)return new Cu;if(l+e===i.length)return new SU;if(t+e===i.length){const c=i,u=Lh(c[c.findIndex(d=>d!=null)]);if(c.every(d=>d==null||a$(u,Lh(d))))return new Dl(new wt("",u,!0))}else if(n+e===i.length){const c=new Map;for(const u of i)for(const d of Object.keys(u))!c.has(d)&&u[d]!=null&&c.set(d,new wt(d,Lh([u[d]]),!0));return new Oi([...c.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function c$(i){const{["queueingStrategy"]:e="count"}=i,{["highWaterMark"]:t=e!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=i,n=e!=="bytes"?"length":"byteLength";return function*(s){let r=0;const o=Df(i);for(const a of s)o.append(a)[n]>=t&&++r&&(yield o.toVector());(o.finish().length>0||r===0)&&(yield o.toVector())}}function km(i,e){return u$(i,e.map(t=>t.data.concat()))}function u$(i,e){const t=[...i.fields],n=[],s={numBatches:e.reduce((d,h)=>Math.max(d,h.length),0)};let r=0,o=0,a=-1;const l=e.length;let c,u=[];for(;s.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<l;)u[a]=c=e[a].shift(),o=Math.min(o,c?c.length:o);Number.isFinite(o)&&(u=d$(t,o,u,e,s),o>0&&(n[r++]=De({type:new Oi(t),length:o,nullCount:0,children:u.slice()})))}return[i=i.assign(t),n.map(d=>new dn(i,d))]}function d$(i,e,t,n,s){var r;const o=(e+63&-64)>>3;for(let a=-1,l=n.length;++a<l;){const c=t[a],u=c==null?void 0:c.length;if(u>=e)u===e?t[a]=c:(t[a]=c.slice(0,e),s.numBatches=Math.max(s.numBatches,n[a].unshift(c.slice(e,u-e))));else{const d=i[a];i[a]=d.clone({nullable:!0}),t[a]=(r=c==null?void 0:c._changeLengthAndBackfillNullBitmap(e))!==null&&r!==void 0?r:De({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return t}var Sk;class zt{constructor(...e){var t,n;if(e.length===0)return this.batches=[],this.schema=new kt([]),this._offsets=[0],this;let s,r;e[0]instanceof kt&&(s=e.shift()),e.at(-1)instanceof Uint32Array&&(r=e.pop());const o=l=>{if(l){if(l instanceof dn)return[l];if(l instanceof zt)return l.batches;if(l instanceof vt){if(l.type instanceof Oi)return[new dn(new kt(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>o(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>o(c));if(typeof l=="object"){const c=Object.keys(l),u=c.map(p=>new ze([l[p]])),d=s??new kt(c.map((p,m)=>new wt(String(p),u[m].type,u[m].nullable))),[,h]=km(d,u);return h.length===0?[new dn(l)]:h}}}return[]},a=e.flatMap(l=>o(l));if(s=(n=s??((t=a[0])===null||t===void 0?void 0:t.schema))!==null&&n!==void 0?n:new kt([]),!(s instanceof kt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of a){if(!(l instanceof dn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!C_(s,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=s,this.batches=a,this._offsets=r??jT(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=$T(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Fb(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?jb.visit(new ze(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
  ${this.toArray().join(`,
  `)}
]`}concat(...e){const t=this.schema,n=this.data.concat(e.flatMap(({data:s})=>s));return new zt(t,n.map(s=>new dn(t,s)))}slice(e,t){const n=this.schema;[e,t]=zT({length:this.numRows},e,t);const s=HT(this.data,this._offsets,e,t);return new zt(n,s.map(r=>new dn(n,r)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&e<this.schema.fields.length){const t=this.data.map(n=>n.children[e]);if(t.length===0){const{type:n}=this.schema.fields[e],s=De({type:n,length:0,nullCount:0});t.push(s._changeLengthAndBackfillNullBitmap(this.numRows))}return new ze(t)}return null}setChild(e,t){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(s=>s.name===e),t)}setChildAt(e,t){let n=this.schema,s=[...this.batches];if(e>-1&&e<this.numCols){t||(t=new ze([De({type:new co,length:this.numRows})]));const r=n.fields.slice(),o=r[e].clone({type:t.type}),a=this.schema.fields.map((l,c)=>this.getChildAt(c));[r[e],a[e]]=[o,t],[n,s]=km(n,a)}return new zt(n,s)}select(e){const t=this.schema.fields.reduce((n,s,r)=>n.set(s.name,r),new Map);return this.selectAt(e.map(n=>t.get(n)).filter(n=>n>-1))}selectAt(e){const t=this.schema.selectAt(e),n=this.batches.map(s=>s.selectAt(e));return new zt(t,n)}assign(e){const t=this.schema.fields,[n,s]=e.schema.fields.reduce((a,l,c)=>{const[u,d]=a,h=t.findIndex(p=>p.name===l.name);return~h?d[h]=c:u.push(c),a},[[],[]]),r=this.schema.assign(e.schema),o=[...t.map((a,l)=>[l,s[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...n.map(a=>e.getChildAt(a))].filter(Boolean);return new zt(...km(r,o))}}Sk=Symbol.toStringTag;zt[Sk]=(i=>(i.schema=null,i.batches=[],i._offsets=new Uint32Array([0]),i._nullCount=-1,i[Symbol.isConcatSpreadable]=!0,i.isValid=If($b),i.get=If(Dn.getVisitFn(A.Struct)),i.set=VT(vs.getVisitFn(A.Struct)),i.indexOf=GT(Lf.getVisitFn(A.Struct)),"Table"))(zt.prototype);function Ek(i){const e={},t=Object.entries(i);for(const[n,s]of t)e[n]=no(s);return new zt(e)}var Ck;let dn=class Xc{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof kt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=De({nullCount:0,type:new Oi(this.schema.fields),children:this.schema.fields.map(t=>De({type:t.type,nullCount:0}))})]=e,!(this.data instanceof vt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=N1(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:n,children:s,length:r}=Object.keys(t).reduce((l,c,u)=>(l.children[u]=t[c],l.length=Math.max(l.length,t[c].length),l.fields[u]=wt.new({name:c,type:t[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new kt(n),a=De({type:new Oi(n),length:r,children:s,nullCount:0});[this.schema,this.data]=N1(o,a.children,r);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Tk(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Dn.visit(this.data,e)}at(e){return this.get(Fb(e,this.numRows))}set(e,t){return vs.visit(this.data,e,t)}indexOf(e,t){return Lf.visit(this.data,e,t)}[Symbol.iterator](){return jb.visit(new ze([this.data]))}toArray(){return[...this]}concat(...e){return new zt(this.schema,[this,...e])}slice(e,t){const[n]=new ze([this.data]).slice(e,t).data;return new Xc(this.schema,n)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(n=>n.name===e))}getChildAt(e){return e>-1&&e<this.schema.fields.length?new ze([this.data.children[e]]):null}setChild(e,t){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(s=>s.name===e),t)}setChildAt(e,t){let n=this.schema,s=this.data;if(e>-1&&e<this.numCols){t||(t=new ze([De({type:new co,length:this.numRows})]));const r=n.fields.slice(),o=s.children.slice(),a=r[e].clone({type:t.type});[r[e],o[e]]=[a,t.data[0]],n=new kt(r,new Map(this.schema.metadata)),s=De({type:new Oi(r),children:o})}return new Xc(n,s)}select(e){const t=this.schema.select(e),n=new Oi(t.fields),s=[];for(const r of e){const o=this.schema.fields.findIndex(a=>a.name===r);~o&&(s[o]=this.data.children[o])}return new Xc(t,De({type:n,length:this.numRows,children:s}))}selectAt(e){const t=this.schema.selectAt(e),n=e.map(r=>this.data.children[r]).filter(Boolean),s=De({type:new Oi(t.fields),length:this.numRows,children:n});return new Xc(t,s)}};Ck=Symbol.toStringTag;dn[Ck]=(i=>(i._nullCount=-1,i[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(dn.prototype);function N1(i,e,t=e.reduce((n,s)=>Math.max(n,s.length),0)){var n;const s=[...i.fields],r=[...e],o=(t+63&-64)>>3;for(const[a,l]of i.fields.entries()){const c=e[a];(!c||c.length!==t)&&(s[a]=l.clone({nullable:!0}),r[a]=(n=c==null?void 0:c._changeLengthAndBackfillNullBitmap(t))!==null&&n!==void 0?n:De({type:l.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)}))}return[i.assign(s),De({type:new Oi(s),length:t,children:r})]}function Tk(i,e,t=new Map){var n,s;if(((n=i==null?void 0:i.length)!==null&&n!==void 0?n:0)>0&&(i==null?void 0:i.length)===(e==null?void 0:e.length))for(let r=-1,o=i.length;++r<o;){const{type:a}=i[r],l=e[r];for(const c of[l,...((s=l==null?void 0:l.dictionary)===null||s===void 0?void 0:s.data)||[]])Tk(a.children,c==null?void 0:c.children,t);if(ve.isDictionary(a)){const{id:c}=a;if(!t.has(c))l!=null&&l.dictionary&&t.set(c,l.dictionary);else if(t.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return t}class Xb extends dn{constructor(e){const t=e.fields.map(s=>De({type:s.type})),n=De({type:new Oi(e.fields),nullCount:0,children:t});super(e,n)}}let To=class rr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new rr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+Pt),(t||new rr).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ui.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):xt.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new Ei).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ui.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,xt.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,n,s,r,o){return rr.startMessage(e),rr.addVersion(e,t),rr.addHeaderType(e,n),rr.addHeader(e,s),rr.addBodyLength(e,r),rr.addCustomMetadata(e,o),rr.endMessage(e)}};class h$ extends Qe{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return S1.startNull(t),S1.endNull(t)}visitInt(e,t){return Gn.startInt(t),Gn.addBitWidth(t,e.bitWidth),Gn.addIsSigned(t,e.isSigned),Gn.endInt(t)}visitFloat(e,t){return fr.startFloatingPoint(t),fr.addPrecision(t,e.precision),fr.endFloatingPoint(t)}visitBinary(e,t){return y1.startBinary(t),y1.endBinary(t)}visitLargeBinary(e,t){return v1.startLargeBinary(t),v1.endLargeBinary(t)}visitBool(e,t){return b1.startBool(t),b1.endBool(t)}visitUtf8(e,t){return E1.startUtf8(t),E1.endUtf8(t)}visitLargeUtf8(e,t){return x1.startLargeUtf8(t),x1.endLargeUtf8(t)}visitDecimal(e,t){return Ya.startDecimal(t),Ya.addScale(t,e.scale),Ya.addPrecision(t,e.precision),Ya.addBitWidth(t,e.bitWidth),Ya.endDecimal(t)}visitDate(e,t){return Sh.startDate(t),Sh.addUnit(t,e.unit),Sh.endDate(t)}visitTime(e,t){return us.startTime(t),us.addUnit(t,e.unit),us.addBitWidth(t,e.bitWidth),us.endTime(t)}visitTimestamp(e,t){const n=e.timezone&&t.createString(e.timezone)||void 0;return ds.startTimestamp(t),ds.addUnit(t,e.unit),n!==void 0&&ds.addTimezone(t,n),ds.endTimestamp(t)}visitInterval(e,t){return pr.startInterval(t),pr.addUnit(t,e.unit),pr.endInterval(t)}visitDuration(e,t){return Eh.startDuration(t),Eh.addUnit(t,e.unit),Eh.endDuration(t)}visitList(e,t){return w1.startList(t),w1.endList(t)}visitStruct(e,t){return aa.startStruct_(t),aa.endStruct_(t)}visitUnion(e,t){kn.startTypeIdsVector(t,e.typeIds.length);const n=kn.createTypeIdsVector(t,e.typeIds);return kn.startUnion(t),kn.addMode(t,e.mode),kn.addTypeIds(t,n),kn.endUnion(t)}visitDictionary(e,t){const n=this.visit(e.indices,t);return io.startDictionaryEncoding(t),io.addId(t,BigInt(e.id)),io.addIsOrdered(t,e.isOrdered),n!==void 0&&io.addIndexType(t,n),io.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ch.startFixedSizeBinary(t),Ch.addByteWidth(t,e.byteWidth),Ch.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Th.startFixedSizeList(t),Th.addListSize(t,e.listSize),Th.endFixedSizeList(t)}visitMap(e,t){return kh.startMap(t),kh.addKeysSorted(t,e.keysSorted),kh.endMap(t)}}const Am=new h$;function f$(i,e=new Map){return new kt(m$(i,e),Rh(i.metadata),e)}function kk(i){return new qn(i.count,Ak(i.columns),Ik(i.columns))}function p$(i){return new Tr(kk(i.data),i.id,i.isDelta)}function m$(i,e){return(i.fields||[]).filter(Boolean).map(t=>wt.fromJSON(t,e))}function D1(i,e){return(i.children||[]).filter(Boolean).map(t=>wt.fromJSON(t,e))}function Ak(i){return(i||[]).reduce((e,t)=>[...e,new Xo(t.count,g$(t.VALIDITY)),...Ak(t.children)],[])}function Ik(i,e=[]){for(let t=-1,n=(i||[]).length;++t<n;){const s=i[t];s.VALIDITY&&e.push(new yr(e.length,s.VALIDITY.length)),s.TYPE_ID&&e.push(new yr(e.length,s.TYPE_ID.length)),s.OFFSET&&e.push(new yr(e.length,s.OFFSET.length)),s.DATA&&e.push(new yr(e.length,s.DATA.length)),e=Ik(s.children,e)}return e}function g$(i){return(i||[]).reduce((e,t)=>e+ +(t===0),0)}function _$(i,e){let t,n,s,r,o,a;return!e||!(r=i.dictionary)?(o=B1(i,D1(i,e)),s=new wt(i.name,o,i.nullable,Rh(i.metadata))):e.has(t=r.id)?(n=(n=r.indexType)?M1(n):new xa,a=new Yo(e.get(t),n,t,r.isOrdered),s=new wt(i.name,a,i.nullable,Rh(i.metadata))):(n=(n=r.indexType)?M1(n):new xa,e.set(t,o=B1(i,D1(i,e))),a=new Yo(o,n,t,r.isOrdered),s=new wt(i.name,a,i.nullable,Rh(i.metadata))),s||null}function Rh(i=[]){return new Map(i.map(({key:e,value:t})=>[e,t]))}function M1(i){return new Nn(i.isSigned,i.bitWidth)}function B1(i,e){const t=i.type.name;switch(t){case"NONE":return new co;case"null":return new co;case"binary":return new yf;case"largebinary":return new bf;case"utf8":return new Eu;case"largeutf8":return new vf;case"bool":return new Cu;case"list":return new Dl((e||[])[0]);case"struct":return new Oi(e||[]);case"struct_":return new Oi(e||[])}switch(t){case"int":{const n=i.type;return new Nn(n.isSigned,n.bitWidth)}case"floatingpoint":{const n=i.type;return new Nl(Ii[n.precision])}case"decimal":{const n=i.type;return new xf(n.scale,n.precision,n.bitWidth)}case"date":{const n=i.type;return new wf(bs[n.unit])}case"time":{const n=i.type;return new Sf(ke[n.unit],n.bitWidth)}case"timestamp":{const n=i.type;return new Tu(ke[n.unit],n.timezone)}case"interval":{const n=i.type;return new Ef(Cr[n.unit])}case"duration":{const n=i.type;return new Cf(ke[n.unit])}case"union":{const n=i.type,[s,...r]=(n.mode+"").toLowerCase(),o=s.toUpperCase()+r.join("");return new ku(en[o],n.typeIds||[],e||[])}case"fixedsizebinary":{const n=i.type;return new Tf(n.byteWidth)}case"fixedsizelist":{const n=i.type;return new Au(n.listSize,(e||[])[0])}case"map":{const n=i.type;return new Iu((e||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var y$=vC,b$=Rl;class hn{static fromJSON(e,t){const n=new hn(0,ui.V5,t);return n._createHeader=v$(e,t),n}static decode(e){e=new b$(ot(e));const t=To.getRootAsMessage(e),n=t.bodyLength(),s=t.version(),r=t.headerType(),o=new hn(n,s,r);return o._createHeader=x$(t,r),o}static encode(e){const t=new y$;let n=-1;return e.isSchema()?n=kt.encode(t,e.header()):e.isRecordBatch()?n=qn.encode(t,e.header()):e.isDictionaryBatch()&&(n=Tr.encode(t,e.header())),To.startMessage(t),To.addVersion(t,ui.V5),To.addHeader(t,n),To.addHeaderType(t,e.headerType),To.addBodyLength(t,BigInt(e.bodyLength)),To.finishMessageBuffer(t,To.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof kt)return new hn(0,ui.V5,xt.Schema,e);if(e instanceof qn)return new hn(t,ui.V5,xt.RecordBatch,e);if(e instanceof Tr)return new hn(t,ui.V5,xt.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===xt.Schema}isRecordBatch(){return this.headerType===xt.RecordBatch}isDictionaryBatch(){return this.headerType===xt.DictionaryBatch}constructor(e,t,n,s){this._version=t,this._headerType=n,this.body=new Uint8Array(0),s&&(this._createHeader=()=>s),this._bodyLength=Ht(e)}}class qn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,n){this._nodes=t,this._buffers=n,this._length=Ht(e)}}class Tr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,n=!1){this._data=e,this._isDelta=n,this._id=Ht(t)}}class yr{constructor(e,t){this.offset=Ht(e),this.length=Ht(t)}}class Xo{constructor(e,t){this.length=Ht(e),this.nullCount=Ht(t)}}function v$(i,e){return(()=>{switch(e){case xt.Schema:return kt.fromJSON(i);case xt.RecordBatch:return qn.fromJSON(i);case xt.DictionaryBatch:return Tr.fromJSON(i)}throw new Error(`Unrecognized Message type: { name: ${xt[e]}, type: ${e} }`)})}function x$(i,e){return(()=>{switch(e){case xt.Schema:return kt.decode(i.header(new lr),new Map,i.version());case xt.RecordBatch:return qn.decode(i.header(new qr),i.version());case xt.DictionaryBatch:return Tr.decode(i.header(new Ga),i.version())}throw new Error(`Unrecognized Message type: { name: ${xt[e]}, type: ${e} }`)})}wt.encode=P$;wt.decode=L$;wt.fromJSON=_$;kt.encode=R$;kt.decode=w$;kt.fromJSON=f$;qn.encode=N$;qn.decode=S$;qn.fromJSON=kk;Tr.encode=D$;Tr.decode=E$;Tr.fromJSON=p$;Xo.encode=M$;Xo.decode=T$;yr.encode=B$;yr.decode=C$;function w$(i,e=new Map,t=ui.V5){const n=I$(i,e);return new kt(n,Ph(i),e,t)}function S$(i,e=ui.V5){if(i.compression()!==null)throw new Error("Record batch compression not implemented");return new qn(i.length(),k$(i),A$(i,e))}function E$(i,e=ui.V5){return new Tr(qn.decode(i.data(),e),i.id(),i.isDelta())}function C$(i){return new yr(i.offset(),i.length())}function T$(i){return new Xo(i.length(),i.nullCount())}function k$(i){const e=[];for(let t,n=-1,s=-1,r=i.nodesLength();++n<r;)(t=i.nodes(n))&&(e[++s]=Xo.decode(t));return e}function A$(i,e){const t=[];for(let n,s=-1,r=-1,o=i.buffersLength();++s<o;)(n=i.buffers(s))&&(e<ui.V4&&(n.bb_pos+=8*(s+1)),t[++r]=yr.decode(n));return t}function I$(i,e){const t=[];for(let n,s=-1,r=-1,o=i.fieldsLength();++s<o;)(n=i.fields(s))&&(t[++r]=wt.decode(n,e));return t}function O1(i,e){const t=[];for(let n,s=-1,r=-1,o=i.childrenLength();++s<o;)(n=i.children(s))&&(t[++r]=wt.decode(n,e));return t}function L$(i,e){let t,n,s,r,o,a;return!e||!(a=i.dictionary())?(s=z1(i,O1(i,e)),n=new wt(i.name(),s,i.nullable(),Ph(i))):e.has(t=Ht(a.id()))?(r=(r=a.indexType())?F1(r):new xa,o=new Yo(e.get(t),r,t,a.isOrdered()),n=new wt(i.name(),o,i.nullable(),Ph(i))):(r=(r=a.indexType())?F1(r):new xa,e.set(t,s=z1(i,O1(i,e))),o=new Yo(s,r,t,a.isOrdered()),n=new wt(i.name(),o,i.nullable(),Ph(i))),n||null}function Ph(i){const e=new Map;if(i)for(let t,n,s=-1,r=Math.trunc(i.customMetadataLength());++s<r;)(t=i.customMetadata(s))&&(n=t.key())!=null&&e.set(n,t.value());return e}function F1(i){return new Nn(i.isSigned(),i.bitWidth())}function z1(i,e){const t=i.typeType();switch(t){case Gt.NONE:return new co;case Gt.Null:return new co;case Gt.Binary:return new yf;case Gt.LargeBinary:return new bf;case Gt.Utf8:return new Eu;case Gt.LargeUtf8:return new vf;case Gt.Bool:return new Cu;case Gt.List:return new Dl((e||[])[0]);case Gt.Struct_:return new Oi(e||[])}switch(t){case Gt.Int:{const n=i.type(new Gn);return new Nn(n.isSigned(),n.bitWidth())}case Gt.FloatingPoint:{const n=i.type(new fr);return new Nl(n.precision())}case Gt.Decimal:{const n=i.type(new Ya);return new xf(n.scale(),n.precision(),n.bitWidth())}case Gt.Date:{const n=i.type(new Sh);return new wf(n.unit())}case Gt.Time:{const n=i.type(new us);return new Sf(n.unit(),n.bitWidth())}case Gt.Timestamp:{const n=i.type(new ds);return new Tu(n.unit(),n.timezone())}case Gt.Interval:{const n=i.type(new pr);return new Ef(n.unit())}case Gt.Duration:{const n=i.type(new Eh);return new Cf(n.unit())}case Gt.Union:{const n=i.type(new kn);return new ku(n.mode(),n.typeIdsArray()||[],e||[])}case Gt.FixedSizeBinary:{const n=i.type(new Ch);return new Tf(n.byteWidth())}case Gt.FixedSizeList:{const n=i.type(new Th);return new Au(n.listSize(),(e||[])[0])}case Gt.Map:{const n=i.type(new kh);return new Iu((e||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Gt[t]}" (${t})`)}function R$(i,e){const t=e.fields.map(r=>wt.encode(i,r));lr.startFieldsVector(i,t.length);const n=lr.createFieldsVector(i,t),s=e.metadata&&e.metadata.size>0?lr.createCustomMetadataVector(i,[...e.metadata].map(([r,o])=>{const a=i.createString(`${r}`),l=i.createString(`${o}`);return Ei.startKeyValue(i),Ei.addKey(i,a),Ei.addValue(i,l),Ei.endKeyValue(i)})):-1;return lr.startSchema(i),lr.addFields(i,n),lr.addEndianness(i,O$?Pl.Little:Pl.Big),s!==-1&&lr.addCustomMetadata(i,s),lr.endSchema(i)}function P$(i,e){let t=-1,n=-1,s=-1;const r=e.type;let o=e.typeId;ve.isDictionary(r)?(o=r.dictionary.typeId,s=Am.visit(r,i),n=Am.visit(r.dictionary,i)):n=Am.visit(r,i);const a=(r.children||[]).map(u=>wt.encode(i,u)),l=as.createChildrenVector(i,a),c=e.metadata&&e.metadata.size>0?as.createCustomMetadataVector(i,[...e.metadata].map(([u,d])=>{const h=i.createString(`${u}`),p=i.createString(`${d}`);return Ei.startKeyValue(i),Ei.addKey(i,h),Ei.addValue(i,p),Ei.endKeyValue(i)})):-1;return e.name&&(t=i.createString(e.name)),as.startField(i),as.addType(i,n),as.addTypeType(i,o),as.addChildren(i,l),as.addNullable(i,!!e.nullable),t!==-1&&as.addName(i,t),s!==-1&&as.addDictionary(i,s),c!==-1&&as.addCustomMetadata(i,c),as.endField(i)}function N$(i,e){const t=e.nodes||[],n=e.buffers||[];qr.startNodesVector(i,t.length);for(const o of t.slice().reverse())Xo.encode(i,o);const s=i.endVector();qr.startBuffersVector(i,n.length);for(const o of n.slice().reverse())yr.encode(i,o);const r=i.endVector();return qr.startRecordBatch(i),qr.addLength(i,BigInt(e.length)),qr.addNodes(i,s),qr.addBuffers(i,r),qr.endRecordBatch(i)}function D$(i,e){const t=qn.encode(i,e.data);return Ga.startDictionaryBatch(i),Ga.addId(i,BigInt(e.id)),Ga.addIsDelta(i,e.isDelta),Ga.addData(i,t),Ga.endDictionaryBatch(i)}function M$(i,e){return SC.createFieldNode(i,BigInt(e.length),BigInt(e.nullCount))}function B$(i,e){return wC.createBuffer(i,BigInt(e.offset),BigInt(e.length))}const O$=(()=>{const i=new ArrayBuffer(2);return new DataView(i).setInt16(0,256,!0),new Int16Array(i)[0]===256})(),Kb=i=>`Expected ${xt[i]} Message in stream, but was null or length 0.`,Zb=i=>`Header pointer of flatbuffer-encoded ${xt[i]} Message is null or length 0.`,Lk=(i,e)=>`Expected to read ${i} metadata bytes, but only read ${e}.`,Rk=(i,e)=>`Expected to read ${i} bytes for message body, but only read ${e}.`;class Pk{constructor(e){this.source=e instanceof Pf?e:new Pf(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?ii:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(Kb(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=ot(this.source.read(e));if(t.byteLength<e)throw new Error(Rk(e,t.byteLength));return t.byteOffset%8===0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()}readSchema(e=!1){const t=xt.Schema,n=this.readMessage(t),s=n==null?void 0:n.header();if(e&&!s)throw new Error(Zb(t));return s}readMetadataLength(){const e=this.source.read(Lp),t=e&&new Rl(e),n=(t==null?void 0:t.readInt32(0))||0;return{done:n===0,value:n}}readMetadata(e){const t=this.source.read(e);if(!t)return ii;if(t.byteLength<e)throw new Error(Lk(e,t.byteLength));return{done:!1,value:hn.decode(t)}}}class F${constructor(e,t){this.source=e instanceof Ml?e:pC(e)?new Nf(e,t):new Ml(e)}[Symbol.asyncIterator](){return this}next(){return je(this,void 0,void 0,function*(){let e;return(e=yield this.readMetadataLength()).done||e.value===-1&&(e=yield this.readMetadataLength()).done||(e=yield this.readMetadata(e.value)).done?ii:e})}throw(e){return je(this,void 0,void 0,function*(){return yield this.source.throw(e)})}return(e){return je(this,void 0,void 0,function*(){return yield this.source.return(e)})}readMessage(e){return je(this,void 0,void 0,function*(){let t;if((t=yield this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(Kb(e));return t.value})}readMessageBody(e){return je(this,void 0,void 0,function*(){if(e<=0)return new Uint8Array(0);const t=ot(yield this.source.read(e));if(t.byteLength<e)throw new Error(Rk(e,t.byteLength));return t.byteOffset%8===0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()})}readSchema(){return je(this,arguments,void 0,function*(e=!1){const t=xt.Schema,n=yield this.readMessage(t),s=n==null?void 0:n.header();if(e&&!s)throw new Error(Zb(t));return s})}readMetadataLength(){return je(this,void 0,void 0,function*(){const e=yield this.source.read(Lp),t=e&&new Rl(e),n=(t==null?void 0:t.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(e){return je(this,void 0,void 0,function*(){const t=yield this.source.read(e);if(!t)return ii;if(t.byteLength<e)throw new Error(Lk(e,t.byteLength));return{done:!1,value:hn.decode(t)}})}}class z$ extends Pk{constructor(e){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof R1?e:new R1(e)}next(){const{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:hn.fromJSON(e.schema,xt.Schema)};if(this._dictionaryIndex<e.dictionaries.length){const t=e.dictionaries[this._dictionaryIndex++];return this._body=t.data.columns,{done:!1,value:hn.fromJSON(t,xt.DictionaryBatch)}}if(this._batchIndex<e.batches.length){const t=e.batches[this._batchIndex++];return this._body=t.columns,{done:!1,value:hn.fromJSON(t,xt.RecordBatch)}}return this._body=[],ii}readMessageBody(e){return t(this._body);function t(n){return(n||[]).reduce((s,r)=>[...s,...r.VALIDITY&&[r.VALIDITY]||[],...r.TYPE_ID&&[r.TYPE_ID]||[],...r.OFFSET&&[r.OFFSET]||[],...r.DATA&&[r.DATA]||[],...t(r.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(Kb(e));return t.value}readSchema(){const e=xt.Schema,t=this.readMessage(e),n=t==null?void 0:t.header();if(!t||!n)throw new Error(Zb(e));return n}}const Lp=4,T_="ARROW1",Ru=new Uint8Array(T_.length);for(let i=0;i<T_.length;i+=1)Ru[i]=T_.codePointAt(i);function Qb(i,e=0){for(let t=-1,n=Ru.length;++t<n;)if(Ru[t]!==i[e+t])return!1;return!0}const id=Ru.length,Nk=id+Lp,U$=id*2+Lp;class zi extends Hb{constructor(e){super(),this._impl=e}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(e){return this._impl.throw(e)}return(e){return this._impl.return(e)}cancel(){return this._impl.cancel()}reset(e){return this._impl.reset(e),this._DOMStream=void 0,this._nodeStream=void 0,this}open(e){const t=this._impl.open(e);return Wo(t)?t.then(()=>this):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return cs.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return cs.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof zi?e:m_(e)?V$(e):pC(e)?Y$(e):Wo(e)?je(this,void 0,void 0,function*(){return yield zi.from(yield e)}):mC(e)||mb(e)||gC(e)||Yl(e)?W$(new Ml(e)):G$(new Pf(e))}static readAll(e){return e instanceof zi?e.isSync()?U1(e):$1(e):m_(e)||ArrayBuffer.isView(e)||Ku(e)||fC(e)?U1(e):$1(e)}}class Mf extends zi{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return _r(this,arguments,function*(){yield Ze(yield*wh(ua(this[Symbol.iterator]())))})}}class Bf extends zi{constructor(e){super(e),this._impl=e}readAll(){return je(this,void 0,void 0,function*(){var e,t,n,s;const r=new Array;try{for(var o=!0,a=ua(this),l;l=yield a.next(),e=l.done,!e;o=!0){s=l.value,o=!1;const c=s;r.push(c)}}catch(c){t={error:c}}finally{try{!o&&!e&&(n=a.return)&&(yield n.call(a))}finally{if(t)throw t.error}}return r})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Dk extends Mf{constructor(e){super(e),this._impl=e}}class $$ extends Bf{constructor(e){super(e),this._impl=e}}class Mk{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const n=this._loadVectors(e,t,this.schema.fields),s=De({type:new Oi(this.schema.fields),length:e.length,children:n});return new dn(this.schema,s)}_loadDictionaryBatch(e,t){const{id:n,isDelta:s}=e,{dictionaries:r,schema:o}=this,a=r.get(n),l=o.dictionaries.get(n),c=this._loadVectors(e.data,t,[l]);return(a&&s?a.concat(new ze(c)):new ze(c)).memoize()}_loadVectors(e,t,n){return new ek(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}class Of extends Mk{constructor(e,t){super(t),this._reader=m_(e)?new z$(this._handle=e):new Pk(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Ok(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):ii}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):ii}next(){if(this.closed)return ii;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const n=e.header(),s=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const n=e.header(),s=t.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(n,s);this.dictionaries.set(n.id,r)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Xb(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class Ff extends Mk{constructor(e,t){super(t),this._reader=new F$(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return je(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return je(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ok(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return je(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):ii})}return(e){return je(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):ii})}next(){return je(this,void 0,void 0,function*(){if(this.closed)return ii;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const n=e.header(),s=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,s)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const n=e.header(),s=yield t.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(n,s);this.dictionaries.set(n.id,r)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Xb(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return je(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Bk extends Of{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof P1?e:new P1(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const n=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(n&&this._handle.seek(n.offset)){const s=this._reader.readMessage(xt.RecordBatch);if(s!=null&&s.isRecordBatch()){const r=s.header(),o=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(r,o)}}return null}_readDictionaryBatch(e){var t;const n=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(n&&this._handle.seek(n.offset)){const s=this._reader.readMessage(xt.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const r=s.header(),o=this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(r,o);this.dictionaries.set(r.id,a)}}}_readFooter(){const{_handle:e}=this,t=e.size-Nk,n=e.readInt32(t),s=e.readAt(t-n,n);return Lu.decode(s)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(e)}return null}}class j$ extends Ff{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,...t){const n=typeof t[0]!="number"?t.shift():void 0,s=t[0]instanceof Map?t.shift():void 0;super(e instanceof Nf?e:new Nf(e,n),s)}isFile(){return!0}isAsync(){return!0}open(e){const t=Object.create(null,{open:{get:()=>super.open}});return je(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return je(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const n=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(n&&(yield this._handle.seek(n.offset))){const s=yield this._reader.readMessage(xt.RecordBatch);if(s!=null&&s.isRecordBatch()){const r=s.header(),o=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(r,o)}}return null})}_readDictionaryBatch(e){return je(this,void 0,void 0,function*(){var t;const n=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(n&&(yield this._handle.seek(n.offset))){const s=yield this._reader.readMessage(xt.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const r=s.header(),o=yield this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(r,o);this.dictionaries.set(r.id,a)}}})}_readFooter(){return je(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-Nk,n=yield e.readInt32(t),s=yield e.readAt(t-n,n);return Lu.decode(s)})}_readNextMessageAndValidate(e){return je(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const t=this._footer.getRecordBatch(this._recordBatchIndex);if(t&&(yield this._handle.seek(t.offset)))return yield this._reader.readMessage(e)}return null})}}class H$ extends Of{constructor(e,t){super(e,t)}_loadVectors(e,t,n){return new R9(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}}function Ok(i,e){return e&&typeof e.autoDestroy=="boolean"?e.autoDestroy:i.autoDestroy}function*U1(i){const e=zi.from(i);try{if(!e.open({autoDestroy:!1}).closed)do yield e;while(!e.reset().open().closed)}finally{e.cancel()}}function $1(i){return _r(this,arguments,function*(){const t=yield Ze(zi.from(i));try{if(!(yield Ze(t.open({autoDestroy:!1}))).closed)do yield yield Ze(t);while(!(yield Ze(t.reset().open())).closed)}finally{yield Ze(t.cancel())}})}function V$(i){return new Mf(new H$(i))}function G$(i){const e=i.peek(id+7&-8);return e&&e.byteLength>=4?Qb(e)?new Dk(new Bk(i.read())):new Mf(new Of(i)):new Mf(new Of((function*(){})()))}function W$(i){return je(this,void 0,void 0,function*(){const e=yield i.peek(id+7&-8);return e&&e.byteLength>=4?Qb(e)?new Dk(new Bk(yield i.read())):new Bf(new Ff(i)):new Bf(new Ff((function(){return _r(this,arguments,function*(){})})()))})}function Y$(i){return je(this,void 0,void 0,function*(){const{size:e}=yield i.stat(),t=new Nf(i,e);return e>=U$&&Qb(yield t.readAt(0,id+7&-8))?new $$(new j$(t)):new Bf(new Ff(t))})}class ni extends Qe{static assemble(...e){const t=s=>s.flatMap(r=>Array.isArray(r)?t(r):r instanceof dn?r.data.children:r.data),n=new ni;return n.visitMany(t(e)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof ze)return this.visitMany(e.data),this;const{type:t}=e;if(!ve.isDictionary(t)){const{length:n}=e;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(ve.isUnion(t))this.nodes.push(new Xo(n,0));else{const{nullCount:s}=e;ve.isNull(t)||js.call(this,s<=0?new Uint8Array(0):kf(e.offset,n,e.nullBitmap)),this.nodes.push(new Xo(n,s))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function js(i){const e=i.byteLength+7&-8;return this.buffers.push(i),this.bufferRegions.push(new yr(this._byteLength,e)),this._byteLength+=e,this}function q$(i){var e;const{type:t,length:n,typeIds:s,valueOffsets:r}=i;if(js.call(this,s),t.mode===en.Sparse)return k_.call(this,i);if(t.mode===en.Dense){if(i.offset<=0)return js.call(this,r),k_.call(this,i);{const o=new Int32Array(n),a=Object.create(null),l=Object.create(null);for(let c,u,d=-1;++d<n;)(c=s[d])!==void 0&&((u=a[c])===void 0&&(u=a[c]=r[d]),o[d]=r[d]-u,l[c]=((e=l[c])!==null&&e!==void 0?e:0)+1);js.call(this,o),this.visitMany(i.children.map((c,u)=>{const d=t.typeIds[u],h=a[d],p=l[d];return c.slice(h,Math.min(n,p))}))}}return this}function X$(i){let e;return i.nullCount>=i.length?js.call(this,new Uint8Array(0)):(e=i.values)instanceof Uint8Array?js.call(this,kf(i.offset,i.length,e)):js.call(this,Af(i.values))}function xo(i){return js.call(this,i.values.subarray(0,i.length*i.stride))}function Rp(i){const{length:e,values:t,valueOffsets:n}=i,s=Ht(n[0]),r=Ht(n[e]),o=Math.min(r-s,t.byteLength-s);return js.call(this,yC(-s,e+1,n)),js.call(this,t.subarray(s,s+o)),this}function Jb(i){const{length:e,valueOffsets:t}=i;if(t){const{[0]:n,[e]:s}=t;return js.call(this,yC(-n,e+1,t)),this.visit(i.children[0].slice(n,s-n))}return this.visit(i.children[0])}function k_(i){return this.visitMany(i.type.children.map((e,t)=>i.children[t]).filter(Boolean))[0]}ni.prototype.visitBool=X$;ni.prototype.visitInt=xo;ni.prototype.visitFloat=xo;ni.prototype.visitUtf8=Rp;ni.prototype.visitLargeUtf8=Rp;ni.prototype.visitBinary=Rp;ni.prototype.visitLargeBinary=Rp;ni.prototype.visitFixedSizeBinary=xo;ni.prototype.visitDate=xo;ni.prototype.visitTimestamp=xo;ni.prototype.visitTime=xo;ni.prototype.visitDecimal=xo;ni.prototype.visitList=Jb;ni.prototype.visitStruct=k_;ni.prototype.visitUnion=q$;ni.prototype.visitInterval=xo;ni.prototype.visitDuration=xo;ni.prototype.visitFixedSizeList=Jb;ni.prototype.visitMap=Jb;class Fk extends Hb{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Ih,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Pn(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Wo(e)?e.then(t=>this.writeAll(t)):Yl(e)?nv(this,e):iv(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof Ih?this._sink=e:(this._sink=new Ih,e&&rU(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&oU(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!t||!C_(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof zt&&!(t=e.schema))return this.finish()&&void 0;if(e instanceof dn&&!(t=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(t&&!C_(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof dn?e instanceof Xb||this._writeRecordBatch(e):e instanceof zt?this.writeAll(e.batches):Ku(e)&&this.writeAll(e)}_writeMessage(e,t=8){const n=t-1,s=hn.encode(e),r=s.byteLength,o=this._writeLegacyIpcFormat?4:8,a=r+o+n&~n,l=a-r-o;return e.headerType===xt.RecordBatch?this._recordBatchBlocks.push(new qo(a,e.bodyLength,this._position)):e.headerType===xt.DictionaryBatch&&this._dictionaryBlocks.push(new qo(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),r>0&&this._write(s),this._writePadding(l)}_write(e){if(this._started){const t=ot(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(hn.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Ru)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){const{byteLength:t,nodes:n,bufferRegions:s,buffers:r}=ni.assemble(e),o=new qn(e.numRows,n,s),a=hn.from(o,t);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(r)}_writeDictionaryBatch(e,t,n=!1){const{byteLength:s,nodes:r,bufferRegions:o,buffers:a}=ni.assemble(new ze([e])),l=new qn(e.length,r,o),c=new Tr(l,t,n),u=hn.from(c,s);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(e){let t,n,s;for(let r=-1,o=e.length;++r<o;)(t=e[r])&&(n=t.byteLength)>0&&(this._write(t),(s=(n+7&-8)-n)>0&&this._writePadding(s));return this}_writeDictionaries(e){var t,n;for(const[s,r]of e.dictionaries){const o=(t=r==null?void 0:r.data)!==null&&t!==void 0?t:[],a=this._seenDictionaries.get(s),l=(n=this._dictionaryDeltaOffsets.get(s))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(const[c,u]of o.entries())this._writeDictionaryBatch(u,s,c>0);else if(l<o.length)for(const c of o.slice(l))this._writeDictionaryBatch(c,s,!0);this._seenDictionaries.set(s,r),this._dictionaryDeltaOffsets.set(s,o.length)}return this}}class ev extends Fk{static writeAll(e,t){const n=new ev(t);return Wo(e)?e.then(s=>n.writeAll(s)):Yl(e)?nv(n,e):iv(n,e)}}class tv extends Fk{static writeAll(e){const t=new tv;return Wo(e)?e.then(n=>t.writeAll(n)):Yl(e)?nv(t,e):iv(t,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,t,n=!1){if(!n&&this._seenDictionaries.has(t))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,t,n)}_writeFooter(e){const t=Lu.encode(new Lu(e,ui.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}}function iv(i,e){let t=e;e instanceof zt&&(t=e.batches,i.reset(void 0,e.schema));for(const n of t)i.write(n);return i.finish()}function nv(i,e){return je(this,void 0,void 0,function*(){var t,n,s,r,o,a,l;try{for(t=!0,n=ua(e);s=yield n.next(),r=s.done,!r;t=!0){l=s.value,t=!1;const c=l;i.write(c)}}catch(c){o={error:c}}finally{try{!t&&!r&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return i.finish()})}function zk(i){const e=zi.from(i);return Wo(e)?e.then(t=>zk(t)):e.isAsync()?e.readAll().then(t=>new zt(t)):new zt(e.readAll())}function sv(i,e="stream"){return(e==="stream"?ev:tv).writeAll(i).toUint8Array(!0)}var K$=Object.create,Uk=Object.defineProperty,Z$=Object.getOwnPropertyDescriptor,Q$=Object.getOwnPropertyNames,J$=Object.getPrototypeOf,ej=Object.prototype.hasOwnProperty,tj=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),ij=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Q$(e))!ej.call(i,s)&&s!==t&&Uk(i,s,{get:()=>e[s],enumerable:!(n=Z$(e,s))||n.enumerable});return i},nj=(i,e,t)=>(t=i!=null?K$(J$(i)):{},ij(!i||!i.__esModule?Uk(t,"default",{value:i,enumerable:!0}):t,i)),sj=tj((i,e)=>{e.exports=Worker}),rj=(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.AUTOMATIC=1]="AUTOMATIC",i[i.READ_ONLY=2]="READ_ONLY",i[i.READ_WRITE=3]="READ_WRITE",i))(rj||{}),oj=(i=>(i[i.IDENTIFIER=0]="IDENTIFIER",i[i.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",i[i.STRING_CONSTANT=2]="STRING_CONSTANT",i[i.OPERATOR=3]="OPERATOR",i[i.KEYWORD=4]="KEYWORD",i[i.COMMENT=5]="COMMENT",i))(oj||{}),aj=(i=>(i[i.NONE=0]="NONE",i[i.DEBUG=1]="DEBUG",i[i.INFO=2]="INFO",i[i.WARNING=3]="WARNING",i[i.ERROR=4]="ERROR",i))(aj||{}),lj=(i=>(i[i.NONE=0]="NONE",i[i.CONNECT=1]="CONNECT",i[i.DISCONNECT=2]="DISCONNECT",i[i.OPEN=3]="OPEN",i[i.QUERY=4]="QUERY",i[i.INSTANTIATE=5]="INSTANTIATE",i))(lj||{}),cj=(i=>(i[i.NONE=0]="NONE",i[i.OK=1]="OK",i[i.ERROR=2]="ERROR",i[i.START=3]="START",i[i.RUN=4]="RUN",i[i.CAPTURE=5]="CAPTURE",i))(cj||{}),uj=(i=>(i[i.NONE=0]="NONE",i[i.WEB_WORKER=1]="WEB_WORKER",i[i.NODE_WORKER=2]="NODE_WORKER",i[i.BINDINGS=3]="BINDINGS",i[i.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",i))(uj||{}),dj=class{log(e){}},hj=class{constructor(i=2){this.level=i}log(i){i.level>=this.level&&console.log(i)}},fj=(i=>(i[i.SUCCESS=0]="SUCCESS",i[i.MAX_ARROW_ERROR=255]="MAX_ARROW_ERROR",i[i.DUCKDB_WASM_RETRY=256]="DUCKDB_WASM_RETRY",i))(fj||{}),pj=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=zi.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new zt(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let s=new $k(this._bindings,this._conn,n),r=await zi.from(s);return console.assert(r.isAsync()),console.assert(r.isStream()),r}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new mj(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=sv(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},$k=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;for(this._inFlight!=null&&(e=await this._inFlight,this._inFlight=null);e==null;)e=await this.db.fetchQueryResults(this.conn);return this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},mj=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=zi.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new zt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new $k(this.bindings,this.connectionId,t),s=await zi.from(n);return console.assert(s.isAsync()),console.assert(s.isStream()),s}},gj=(i=>(i.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",i.CLOSE_PREPARED="CLOSE_PREPARED",i.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",i.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",i.CONNECT="CONNECT",i.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",i.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",i.CREATE_PREPARED="CREATE_PREPARED",i.DISCONNECT="DISCONNECT",i.DROP_FILE="DROP_FILE",i.DROP_FILES="DROP_FILES",i.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",i.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",i.FLUSH_FILES="FLUSH_FILES",i.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",i.GET_TABLE_NAMES="GET_TABLE_NAMES",i.GET_VERSION="GET_VERSION",i.GLOB_FILE_INFOS="GLOB_FILE_INFOS",i.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",i.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",i.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",i.INSTANTIATE="INSTANTIATE",i.OPEN="OPEN",i.PING="PING",i.POLL_PENDING_QUERY="POLL_PENDING_QUERY",i.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",i.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",i.REGISTER_FILE_URL="REGISTER_FILE_URL",i.RESET="RESET",i.RUN_PREPARED="RUN_PREPARED",i.RUN_QUERY="RUN_QUERY",i.SEND_PREPARED="SEND_PREPARED",i.START_PENDING_QUERY="START_PENDING_QUERY",i.TOKENIZE="TOKENIZE",i))(gj||{}),_j=(i=>(i.CONNECTION_INFO="CONNECTION_INFO",i.ERROR="ERROR",i.FEATURE_FLAGS="FEATURE_FLAGS",i.FILE_BUFFER="FILE_BUFFER",i.FILE_INFOS="FILE_INFOS",i.FILE_SIZE="FILE_SIZE",i.FILE_STATISTICS="FILE_STATISTICS",i.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",i.LOG="LOG",i.PROGRESS_UPDATE="PROGRESS_UPDATE",i.OK="OK",i.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",i.QUERY_PLAN="QUERY_PLAN",i.QUERY_RESULT="QUERY_RESULT",i.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",i.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",i.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",i.REGISTERED_FILE="REGISTERED_FILE",i.SCRIPT_TOKENS="SCRIPT_TOKENS",i.SUCCESS="SUCCESS",i.TABLE_NAMES="TABLE_NAMES",i.VERSION_STRING="VERSION_STRING",i))(_j||{}),ft=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,s)=>{this.promiseResolver=n,this.promiseRejecter=s})}};function Nh(i){switch(i.typeId){case A.Binary:return{sqlType:"binary"};case A.Bool:return{sqlType:"bool"};case A.Date:return{sqlType:"date"};case A.DateDay:return{sqlType:"date32[d]"};case A.DateMillisecond:return{sqlType:"date64[ms]"};case A.Decimal:{let e=i;return{sqlType:"decimal",precision:e.precision,scale:e.scale}}case A.Float:return{sqlType:"float"};case A.Float16:return{sqlType:"float16"};case A.Float32:return{sqlType:"float32"};case A.Float64:return{sqlType:"float64"};case A.Int:return{sqlType:"int32"};case A.Int16:return{sqlType:"int16"};case A.Int32:return{sqlType:"int32"};case A.Int64:return{sqlType:"int64"};case A.Uint16:return{sqlType:"uint16"};case A.Uint32:return{sqlType:"uint32"};case A.Uint64:return{sqlType:"uint64"};case A.Uint8:return{sqlType:"uint8"};case A.IntervalDayTime:return{sqlType:"interval[dt]"};case A.IntervalYearMonth:return{sqlType:"interval[m]"};case A.List:return{sqlType:"list",valueType:Nh(i.valueType)};case A.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:i.byteWidth};case A.Null:return{sqlType:"null"};case A.Utf8:return{sqlType:"utf8"};case A.Struct:return{sqlType:"struct",fields:i.children.map(e=>A_(e.name,e.type))};case A.Map:{let e=i;return{sqlType:"map",keyType:Nh(e.keyType),valueType:Nh(e.valueType)}}case A.Time:return{sqlType:"time[s]"};case A.TimeMicrosecond:return{sqlType:"time[us]"};case A.TimeMillisecond:return{sqlType:"time[ms]"};case A.TimeNanosecond:return{sqlType:"time[ns]"};case A.TimeSecond:return{sqlType:"time[s]"};case A.Timestamp:return{sqlType:"timestamp",timezone:i.timezone||void 0};case A.TimestampSecond:return{sqlType:"timestamp[s]",timezone:i.timezone||void 0};case A.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:i.timezone||void 0};case A.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:i.timezone||void 0};case A.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:i.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(i.toString()))}function A_(i,e){let t=Nh(e);return t.name=i,t}var yj=new TextEncoder,bj=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let r of this._onExecutionProgress)r(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let r of this._onInstantiationProgress)r(n.data);return}}let s=this._pendingRequests.get(n.requestId);if(!s){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let r=new Error(n.data.message);r.name=n.data.name,(t=Object.getOwnPropertyDescriptor(r,"stack"))!=null&&t.writable&&(r.stack=n.data.stack),s.promiseRejecter(r);return}switch(s.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){s.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){s.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){s.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){s.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){s.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){s.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){s.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){s.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){s.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){s.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){s.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){s.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){s.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){s.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){s.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){s.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){s.promiseResolver(n.data);return}break}s.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new ft("RESET",null);return await this.postTask(e)}async ping(){let e=new ft("PING",null);await this.postTask(e)}async dropFile(e){let t=new ft("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new ft("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new ft("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=s=>{}){this._onInstantiationProgress.push(n);let s=new ft("INSTANTIATE",[e,t]);return await this.postTask(s)}async getVersion(){let e=new ft("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new ft("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new ft("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new ft("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new ft("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new pj(this,e)}async disconnect(e){let t=new ft("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new ft("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let s=new ft("START_PENDING_QUERY",[e,t,n]);return await this.postTask(s)}async pollPendingQuery(e){let t=new ft("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new ft("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new ft("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new ft("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new ft("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new ft("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let s=new ft("RUN_PREPARED",[e,t,n]);return await this.postTask(s)}async sendPrepared(e,t,n){let s=new ft("SEND_PREPARED",[e,t,n]);return await this.postTask(s)}async globFiles(e){let t=new ft("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=yj.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,s){t===void 0&&(t=e);let r=new ft("REGISTER_FILE_URL",[e,t,n,s]);await this.postTask(r)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new ft("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,s){let r=new ft("REGISTER_FILE_HANDLE",[e,t,n,s]);await this.postTask(r,[])}async registerOPFSFileName(e){let t=new ft("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new ft("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new ft("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new ft("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new ft("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let s=new ft("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(s,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let r=[];for(let o in n.columns){let a=n.columns[o];r.push(A_(o,a))}n.columnsFlat=r,delete n.columns}let s=new ft("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(s)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let r=[];for(let o in n.columns){let a=n.columns[o];r.push(A_(o,a))}n.columnsFlat=r,delete n.columns}let s=new ft("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(s)}};function vj(){let i=new TextDecoder;return e=>(typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),i.decode(e))}vj();var xj=(i=>(i[i.BUFFER=0]="BUFFER",i[i.NODE_FS=1]="NODE_FS",i[i.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",i[i.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",i[i.HTTP=4]="HTTP",i[i.S3=5]="S3",i))(xj||{}),wj=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),Sj=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),Ej=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),Cj=()=>(async i=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(i)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),rv={name:"@duckdb/duckdb-wasm",version:"1.30.0"},Tj=rv.name,kj=rv.version,ov=rv.version.split(".");ov[0];ov[1];ov[2];var Aj=()=>typeof navigator>"u";function Ij(){let i="https://cdn.jsdelivr.net/npm/".concat(Tj,"@").concat(kj,"/dist/");return{mvp:{mainModule:"".concat(i,"duckdb-mvp.wasm"),mainWorker:"".concat(i,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(i,"duckdb-eh.wasm"),mainWorker:"".concat(i,"duckdb-browser-eh.worker.js")}}}var Im=null,Lm=null,Rm=null,Pm=null,Nm=null;async function Lj(){return Im==null&&(Im=typeof BigInt64Array<"u"),Lm==null&&(Lm=await Sj()),Rm==null&&(Rm=await Cj()),Pm==null&&(Pm=await Ej()),Nm==null&&(Nm=await wj()),{bigInt64Array:Im,crossOriginIsolated:Aj()||globalThis.crossOriginIsolated||!1,wasmExceptions:Lm,wasmSIMD:Pm,wasmThreads:Rm,wasmBulkMemory:Nm}}async function Rj(i){let e=await Lj();if(e.wasmExceptions){if(e.wasmSIMD&&e.wasmThreads&&e.crossOriginIsolated&&i.coi)return{mainModule:i.coi.mainModule,mainWorker:i.coi.mainWorker,pthreadWorker:i.coi.pthreadWorker};if(i.eh)return{mainModule:i.eh.mainModule,mainWorker:i.eh.mainWorker,pthreadWorker:null}}return{mainModule:i.mvp.mainModule,mainWorker:i.mvp.mainWorker,pthreadWorker:null}}nj(sj());class j1{constructor(e={}){b(this,"_ipc");b(this,"_options");b(this,"_db");b(this,"_con");b(this,"_config");b(this,"_loadPromise");const{ipc:t,duckdb:n,connection:s,config:r,...o}=e;this._ipc=t,this._options=o,this._db=n,this._con=s,this._config=r}async getDuckDB(){return this._db||await H1(this),this._db}async getConnection(){return this._con||await H1(this),this._con}async query(e){const{type:t,sql:n}=e,s=await this.getConnection(),r=await Pj(s,n);return t==="exec"?void 0:t==="arrow"?df(r,this._ipc):df(r).toArray()}}function Pj(i,e){return new Promise((t,n)=>{i.useUnsafe(async(s,r)=>{try{const o=await s.runQuery(r,e);t(o)}catch(o){n(o)}})})}function H1(i){return i._loadPromise||(i._loadPromise=(i._db?Promise.resolve(i._db):Nj(i._options).then(e=>i._db=e)).then(e=>i._config!=null?e.open(i._config).then(()=>e):e).then(e=>e.connect()).then(e=>i._con=e)),i._loadPromise}async function Nj({log:i=!1}={}){const e=Ij(),t=await Rj(e),n=URL.createObjectURL(new Blob([`importScripts("${t.mainWorker}");`],{type:"text/javascript"})),s=new Worker(n),r=i?new hj:new dj,o=new bj(r,s);return await o.instantiate(t.mainModule,t.pthreadWorker),URL.revokeObjectURL(n),o}const we=(i,e,t="info")=>{if(window.cosmographDisableLogging)return;let n,s;switch(t){case"ok":n="#54AE47",s="✅ ";break;case"info":n="#4196f8",s="ℹ️ ";break;case"warn":n="#FFA500",s="⚠️ ";break;case"util":n="#666666",s="⚙️ ";break;case"error":n="#FF0000",s="🚫 "}console.log(`%c${s}[${e==="data-kit"?"CosmographDataKit":"Cosmograph"}${e?e==="data-kit"?"":` > ${e}`:""}]: ${i}`,`color: ${n}; font-weight: bold;`)};var Dj={};const Pu=(i,e,t=new Set)=>{if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;if(t.has(i))return!0;t.add(i);for(let n=0;n<i.length;n++)if(!Pu(i[n],e[n],t))return!1;return!0}if(i instanceof Date&&e instanceof Date)return i.getTime()===e.getTime();if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object")return!1;if(i===e)return!0;if(Object.keys(i).length!==Object.keys(e).length)return!1;if(t.has(i))return!0;t.add(i);for(const n in i)if(!Pu(i[n],e[n],t))return!1;return!0}return i===e},jk=i=>{if(!i)return[];const e=i.numRows,t=i.schema.fields,n=new Array(e);for(let s=0;s<e;s++){const r={};for(let o=0;o<t.length;o++){const a=i.getChildAt(o);a&&(r[t[o].name]=a.get(s))}n[s]=r}return n},av=()=>{let i;try{i=!!Dj.DEBUG}catch{i=!1}return i},yl=(i,e)=>[Math.round(i),Math.round(e)],Pp=i=>`'${String(i).replace(/'/g,"''")}'`,Ko=i=>(i==null?void 0:i.typeId)===2||(i==null?void 0:i.typeId)===3||(i==null?void 0:i.typeId)===7,Nu=i=>(i==null?void 0:i.typeId)===5,Du=i=>(i==null?void 0:i.typeId)===6||(i==null?void 0:i.typeId)===20,Hk=i=>(i==null?void 0:i.typeId)===12||(i==null?void 0:i.typeId)===13,Mj=i=>typeof i=="string"?/(\[\]|list)/i.test(i):Hk(i??void 0),lv=()=>Math.random().toString(36).substring(2,9),Bj=(i,e)=>{const{signal:t}=e;return i.reduce((n,s)=>n.then(async()=>{var r;if(!t.aborted)try{await s()}catch(o){(r=o)&&(r.message||String(r)),t.aborted}}),Promise.resolve()).then(()=>{})};var Oj=Object.create,Vk=Object.defineProperty,Fj=Object.getOwnPropertyDescriptor,zj=Object.getOwnPropertyNames,Uj=Object.getPrototypeOf,$j=Object.prototype.hasOwnProperty,jj=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Hj=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of zj(e))!$j.call(i,s)&&s!==t&&Vk(i,s,{get:()=>e[s],enumerable:!(n=Fj(e,s))||n.enumerable});return i},Vj=(i,e,t)=>(t=i!=null?Oj(Uj(i)):{},Hj(!i||!i.__esModule?Vk(t,"default",{value:i,enumerable:!0}):t,i)),Gj=jj((i,e)=>{e.exports=Worker}),Wj=(i=>(i[i.UNDEFINED=0]="UNDEFINED",i[i.AUTOMATIC=1]="AUTOMATIC",i[i.READ_ONLY=2]="READ_ONLY",i[i.READ_WRITE=3]="READ_WRITE",i))(Wj||{}),Yj=(i=>(i[i.IDENTIFIER=0]="IDENTIFIER",i[i.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",i[i.STRING_CONSTANT=2]="STRING_CONSTANT",i[i.OPERATOR=3]="OPERATOR",i[i.KEYWORD=4]="KEYWORD",i[i.COMMENT=5]="COMMENT",i))(Yj||{}),qj=(i=>(i[i.NONE=0]="NONE",i[i.DEBUG=1]="DEBUG",i[i.INFO=2]="INFO",i[i.WARNING=3]="WARNING",i[i.ERROR=4]="ERROR",i))(qj||{}),Xj=(i=>(i[i.NONE=0]="NONE",i[i.CONNECT=1]="CONNECT",i[i.DISCONNECT=2]="DISCONNECT",i[i.OPEN=3]="OPEN",i[i.QUERY=4]="QUERY",i[i.INSTANTIATE=5]="INSTANTIATE",i))(Xj||{}),Kj=(i=>(i[i.NONE=0]="NONE",i[i.OK=1]="OK",i[i.ERROR=2]="ERROR",i[i.START=3]="START",i[i.RUN=4]="RUN",i[i.CAPTURE=5]="CAPTURE",i))(Kj||{}),Zj=(i=>(i[i.NONE=0]="NONE",i[i.WEB_WORKER=1]="WEB_WORKER",i[i.NODE_WORKER=2]="NODE_WORKER",i[i.BINDINGS=3]="BINDINGS",i[i.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",i))(Zj||{}),Qj=class{log(e){}},Jj=(i=>(i[i.SUCCESS=0]="SUCCESS",i[i.MAX_ARROW_ERROR=255]="MAX_ARROW_ERROR",i[i.DUCKDB_WASM_RETRY=256]="DUCKDB_WASM_RETRY",i))(Jj||{}),eH=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=zi.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new zt(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let s=new Gk(this._bindings,this._conn,n),r=await zi.from(s);return console.assert(r.isAsync()),console.assert(r.isStream()),r}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new tH(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=sv(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},Gk=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;for(this._inFlight!=null&&(e=await this._inFlight,this._inFlight=null);e==null;)e=await this.db.fetchQueryResults(this.conn);return this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},tH=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=zi.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new zt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Gk(this.bindings,this.connectionId,t),s=await zi.from(n);return console.assert(s.isAsync()),console.assert(s.isStream()),s}},iH=(i=>(i.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",i.CLOSE_PREPARED="CLOSE_PREPARED",i.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",i.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",i.CONNECT="CONNECT",i.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",i.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",i.CREATE_PREPARED="CREATE_PREPARED",i.DISCONNECT="DISCONNECT",i.DROP_FILE="DROP_FILE",i.DROP_FILES="DROP_FILES",i.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",i.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",i.FLUSH_FILES="FLUSH_FILES",i.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",i.GET_TABLE_NAMES="GET_TABLE_NAMES",i.GET_VERSION="GET_VERSION",i.GLOB_FILE_INFOS="GLOB_FILE_INFOS",i.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",i.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",i.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",i.INSTANTIATE="INSTANTIATE",i.OPEN="OPEN",i.PING="PING",i.POLL_PENDING_QUERY="POLL_PENDING_QUERY",i.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",i.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",i.REGISTER_FILE_URL="REGISTER_FILE_URL",i.RESET="RESET",i.RUN_PREPARED="RUN_PREPARED",i.RUN_QUERY="RUN_QUERY",i.SEND_PREPARED="SEND_PREPARED",i.START_PENDING_QUERY="START_PENDING_QUERY",i.TOKENIZE="TOKENIZE",i))(iH||{}),nH=(i=>(i.CONNECTION_INFO="CONNECTION_INFO",i.ERROR="ERROR",i.FEATURE_FLAGS="FEATURE_FLAGS",i.FILE_BUFFER="FILE_BUFFER",i.FILE_INFOS="FILE_INFOS",i.FILE_SIZE="FILE_SIZE",i.FILE_STATISTICS="FILE_STATISTICS",i.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",i.LOG="LOG",i.PROGRESS_UPDATE="PROGRESS_UPDATE",i.OK="OK",i.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",i.QUERY_PLAN="QUERY_PLAN",i.QUERY_RESULT="QUERY_RESULT",i.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",i.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",i.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",i.REGISTERED_FILE="REGISTERED_FILE",i.SCRIPT_TOKENS="SCRIPT_TOKENS",i.SUCCESS="SUCCESS",i.TABLE_NAMES="TABLE_NAMES",i.VERSION_STRING="VERSION_STRING",i))(nH||{}),pt=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,s)=>{this.promiseResolver=n,this.promiseRejecter=s})}};function Dh(i){switch(i.typeId){case A.Binary:return{sqlType:"binary"};case A.Bool:return{sqlType:"bool"};case A.Date:return{sqlType:"date"};case A.DateDay:return{sqlType:"date32[d]"};case A.DateMillisecond:return{sqlType:"date64[ms]"};case A.Decimal:{let e=i;return{sqlType:"decimal",precision:e.precision,scale:e.scale}}case A.Float:return{sqlType:"float"};case A.Float16:return{sqlType:"float16"};case A.Float32:return{sqlType:"float32"};case A.Float64:return{sqlType:"float64"};case A.Int:return{sqlType:"int32"};case A.Int16:return{sqlType:"int16"};case A.Int32:return{sqlType:"int32"};case A.Int64:return{sqlType:"int64"};case A.Uint16:return{sqlType:"uint16"};case A.Uint32:return{sqlType:"uint32"};case A.Uint64:return{sqlType:"uint64"};case A.Uint8:return{sqlType:"uint8"};case A.IntervalDayTime:return{sqlType:"interval[dt]"};case A.IntervalYearMonth:return{sqlType:"interval[m]"};case A.List:return{sqlType:"list",valueType:Dh(i.valueType)};case A.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:i.byteWidth};case A.Null:return{sqlType:"null"};case A.Utf8:return{sqlType:"utf8"};case A.Struct:return{sqlType:"struct",fields:i.children.map(e=>I_(e.name,e.type))};case A.Map:{let e=i;return{sqlType:"map",keyType:Dh(e.keyType),valueType:Dh(e.valueType)}}case A.Time:return{sqlType:"time[s]"};case A.TimeMicrosecond:return{sqlType:"time[us]"};case A.TimeMillisecond:return{sqlType:"time[ms]"};case A.TimeNanosecond:return{sqlType:"time[ns]"};case A.TimeSecond:return{sqlType:"time[s]"};case A.Timestamp:return{sqlType:"timestamp",timezone:i.timezone||void 0};case A.TimestampSecond:return{sqlType:"timestamp[s]",timezone:i.timezone||void 0};case A.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:i.timezone||void 0};case A.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:i.timezone||void 0};case A.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:i.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(i.toString()))}function I_(i,e){let t=Dh(e);return t.name=i,t}var sH=new TextEncoder,rH=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let r of this._onExecutionProgress)r(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let r of this._onInstantiationProgress)r(n.data);return}}let s=this._pendingRequests.get(n.requestId);if(!s){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let r=new Error(n.data.message);r.name=n.data.name,(t=Object.getOwnPropertyDescriptor(r,"stack"))!=null&&t.writable&&(r.stack=n.data.stack),s.promiseRejecter(r);return}switch(s.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){s.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){s.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){s.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){s.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){s.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){s.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){s.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){s.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){s.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){s.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){s.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){s.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){s.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){s.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){s.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){s.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){s.promiseResolver(n.data);return}break}s.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new pt("RESET",null);return await this.postTask(e)}async ping(){let e=new pt("PING",null);await this.postTask(e)}async dropFile(e){let t=new pt("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new pt("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new pt("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=s=>{}){this._onInstantiationProgress.push(n);let s=new pt("INSTANTIATE",[e,t]);return await this.postTask(s)}async getVersion(){let e=new pt("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new pt("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new pt("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new pt("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new pt("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new eH(this,e)}async disconnect(e){let t=new pt("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new pt("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let s=new pt("START_PENDING_QUERY",[e,t,n]);return await this.postTask(s)}async pollPendingQuery(e){let t=new pt("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new pt("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new pt("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new pt("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new pt("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new pt("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let s=new pt("RUN_PREPARED",[e,t,n]);return await this.postTask(s)}async sendPrepared(e,t,n){let s=new pt("SEND_PREPARED",[e,t,n]);return await this.postTask(s)}async globFiles(e){let t=new pt("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=sH.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,s){t===void 0&&(t=e);let r=new pt("REGISTER_FILE_URL",[e,t,n,s]);await this.postTask(r)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new pt("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,s){let r=new pt("REGISTER_FILE_HANDLE",[e,t,n,s]);await this.postTask(r,[])}async registerOPFSFileName(e){let t=new pt("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new pt("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new pt("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new pt("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new pt("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let s=new pt("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(s,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let r=[];for(let o in n.columns){let a=n.columns[o];r.push(I_(o,a))}n.columnsFlat=r,delete n.columns}let s=new pt("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(s)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let r=[];for(let o in n.columns){let a=n.columns[o];r.push(I_(o,a))}n.columnsFlat=r,delete n.columns}let s=new pt("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(s)}};function oH(){let i=new TextDecoder;return e=>(typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),i.decode(e))}oH();var Wk=(i=>(i[i.BUFFER=0]="BUFFER",i[i.NODE_FS=1]="NODE_FS",i[i.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",i[i.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",i[i.HTTP=4]="HTTP",i[i.S3=5]="S3",i))(Wk||{}),aH=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),lH=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),cH=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),uH=()=>(async i=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(i)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),cv={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev260.0"},dH=cv.name,hH=cv.version,uv=cv.version.split(".");uv[0];uv[1];uv[2];var fH=()=>typeof navigator>"u";function pH(){let i="https://cdn.jsdelivr.net/npm/".concat(dH,"@").concat(hH,"/dist/");return{mvp:{mainModule:"".concat(i,"duckdb-mvp.wasm"),mainWorker:"".concat(i,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(i,"duckdb-eh.wasm"),mainWorker:"".concat(i,"duckdb-browser-eh.worker.js")}}}var Dm=null,Mm=null,Bm=null,Om=null,Fm=null;async function mH(){return Dm==null&&(Dm=typeof BigInt64Array<"u"),Mm==null&&(Mm=await lH()),Bm==null&&(Bm=await uH()),Om==null&&(Om=await cH()),Fm==null&&(Fm=await aH()),{bigInt64Array:Dm,crossOriginIsolated:fH()||globalThis.crossOriginIsolated||!1,wasmExceptions:Mm,wasmSIMD:Om,wasmThreads:Bm,wasmBulkMemory:Fm}}async function gH(i){let e=await mH();if(e.wasmExceptions){if(e.wasmSIMD&&e.wasmThreads&&e.crossOriginIsolated&&i.coi)return{mainModule:i.coi.mainModule,mainWorker:i.coi.mainWorker,pthreadWorker:i.coi.pthreadWorker};if(i.eh)return{mainModule:i.eh.mainModule,mainWorker:i.eh.mainWorker,pthreadWorker:null}}return{mainModule:i.mvp.mainModule,mainWorker:i.mvp.mainWorker,pthreadWorker:null}}Vj(Gj());var qe,_e,Xi;(function(i){i.RawPoints="temp_cosmograph_raw_points",i.RawLinks="temp_cosmograph_raw_links",i.PreparedPoints="temp_cosmograph_prepared_points",i.PreparedLinks="temp_cosmograph_prepared_links",i.Points="cosmograph_points",i.Links="cosmograph_links"})(qe||(qe={})),(function(i){i.Id="id",i.Idx="idx",i.Sequence="points_idx_seq",i.Source="source",i.SourceIdx="sourceidx",i.Target="target",i.TargetIdx="targetidx"})(_e||(_e={})),(function(i){i.Parquet="parquet",i.Arrow="arrow",i.CSV="csv",i.JSON="json"})(Xi||(Xi={}));const Oa=av(),_H=pH();var Tn;let Yk=(Tn=class{constructor(){b(this,"_db");b(this,"_connection");b(this,"logTable",async(e,t=!1)=>{var c;if(!Oa)return;const n=`SELECT COUNT(*) as count FROM ${e}`,s=await this.query(n);if(!s)return;const r=(c=s.getChild("count"))==null?void 0:c.get(0),o=`SELECT * FROM ${e} ${t?"":"LIMIT 10"}`,a=await this.query(o);if(!a)return;const l=jk(a);console.groupCollapsed(`Table: ${e} | ${r} rows ${t?"":"(showing first 10)"}`),console.table(l),console.groupEnd()})}static async getInstance(){return Tn._initPromise=(async()=>{const e=new Tn;return await e._init(),e})(),Tn._instance=await Tn._initPromise,Tn._instance}async _init(){const e=await gH(_H),t=URL.createObjectURL(new Blob([`importScripts("${e.mainWorker}");`],{type:"text/javascript"})),n=new Worker(t),s=new Qj;this._db=new rH(s,n),await this._db.instantiate(e.mainModule,e.pthreadWorker),this._connection=await this._db.connect(),await this._connection.query(`
      SET max_expression_depth TO 20000000;
      SET memory_limit = '10GB';
    `.trim()),URL.revokeObjectURL(t)}get connection(){if(!this._connection)throw new Error("Cosmograph: DuckDB-Wasm connection is not initialized");return this._connection}get db(){if(!this._db)throw new Error("Cosmograph: DuckDB-Wasm is not initialized");return this._db}async destroy(){await this.connection.close(),await this.db.terminate(),Tn._instance=void 0,Tn._initPromise=void 0}async dropTable(e){await this.query(`DROP TABLE IF EXISTS "${e}"`)}async query(e){let t;Oa&&(console.log("%cExecuted query:","color: #a6a6a6;",{sql:e}),t=performance.now());try{return await this.connection.query(e)}catch(n){globalThis.__lastDuckdbError=String(n),console.warn(`Couldn't query internal DuckDB instance: ${n}`)}finally{if(Oa&&t!==void 0){const n=performance.now()-t;console.log("%cFinished query:","color: #a6a6a6;",{sql:e,duration:+n.toFixed(1)})}}}async exec(e){await this.query(e)}async send(e,t){Oa&&console.log(e),Oa&&console.time("query");try{const n=await this.connection.send(e);let s;for(;!(s=await n.next()).done;){const r=s.value;for(let o=0;o<r.numRows;o++){const a=r.getChildAt(o);t&&t(a)}}}catch(n){console.warn(`Couldn't query internal DuckDB instance: ${n}`)}Oa&&console.timeEnd("query")}async uploadData(e,t,n=!1,s,r){if(Array.isArray(e)&&e.length>0&&e[0]&&typeof e[0]=="object")return await this.uploadObject(e,t,n);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof zt)return await this._uploadArrow(e,t,n);if(typeof e=="string"||e instanceof File){const o=c=>c.endsWith(".arrow")?Xi.Arrow:c.endsWith(".parquet")||c.endsWith(".pq")?Xi.Parquet:c.endsWith(".csv")||c.endsWith(".tsv")?Xi.CSV:c.endsWith(".json")?Xi.JSON:"unknown",a=e instanceof File?e.name:e,l=o(a);l==="unknown"&&console.warn(`Unknown file type: ${a}`);try{switch(l){case Xi.Arrow:return await this._uploadArrow(e,t,n);case Xi.Parquet:return await this._uploadParquet(e,t,n);case Xi.CSV:return await this._uploadCSV(e,t,n,s,r);case Xi.JSON:return await this._uploadJSON(e,t,n);default:throw new Error("Unsupported file type")}}catch(c){return console.warn(`uploadData: ${c}`),{error:c}}}return{error:"Could not upload data"}}async uploadArrow(e,t){return await this._uploadArrow(e,t)}async exportTableToArrow(e){try{const t=[],n=await this.connection.send(`SELECT * FROM ${e}`);let s;for(;!(s=await n.next()).done;){const r=s.value;r&&r.numRows&&t.push(r)}return t.length?new zt(t):void 0}catch(t){throw console.warn(`exportTableToArrow: Failed to export table "${e}":`,t),t}}async exportTableToArrowBuffer(e){const t=await this.exportTableToArrow(e);return t?sv(t):void 0}async exportTableToPq(e){var n,s;const t=`${e}.${Xi.Parquet}`;try{return await this.connection.query(`COPY ${e} TO '${t}' (FORMAT PARQUET)`),await((n=this._db)==null?void 0:n.copyFileToBuffer(t))}catch(r){console.error(`Failed to export table "${e}" to file "${t}":`,r)}finally{await((s=this._db)==null?void 0:s.registerEmptyFileBuffer(t))}}async exportTableToCSV(e){var n,s;const t=`${e}.${Xi.CSV}`;try{return await this.connection.query(`COPY ${e} TO '${t}' (HEADER, DELIMITER ',')`),await((n=this._db)==null?void 0:n.copyFileToBuffer(t))}catch(r){console.error(`Failed to export table "${e}" to file "${t}":`,r)}finally{await((s=this._db)==null?void 0:s.registerEmptyFileBuffer(t))}}async uploadObject(e,t,n=!1){if(e.length===0)return{};try{const s=`t_${t}`;await this.query(`DROP TABLE IF EXISTS "${s}"`);const r=l$(e);return await this.connection.insertArrowTable(r,{name:s}),await this._handleTableInsertion(s,t,n),await this.logTable(t),{}}catch(s){throw new Error(`Failed to upload Object: ${s}`)}}async _uploadCSV(e,t,n=!1,s,r){const o=`t_${t}`;let a=null;try{let l;if(e instanceof File){const u=await e.text();a=e.name,await this.db.registerFileText(a,u),l=a}else l=e;const c=`
        CREATE TABLE ${o} AS SELECT * FROM read_csv_auto(
          '${l}',
          SAMPLE_SIZE=-1,
          allow_quoted_nulls=true,
          ignore_errors=true
          ${s?`, timestampformat='${s}'`:""}
          ${r?`, types=${JSON.stringify(r)}`:""}
        )`.trim();return await this.query(c),await this._handleTableInsertion(o,t,n),await this.logTable(t),{}}catch(l){throw new Error(`Failed to upload CSV: ${l}`)}finally{a&&await this.db.dropFile(a)}}async _uploadParquet(e,t,n=!1){const s=`t_${t}`;let r=null;try{let o;e instanceof File?(r=e.name,await this.db.registerFileHandle(r,e,Wk.BROWSER_FILEREADER,!0),o=r):o=e;const a=`CREATE TABLE ${s} AS SELECT * FROM read_parquet('${o}')`;return await this.query(a),await this._handleTableInsertion(s,t,n),await this.logTable(t),{}}catch(o){const a=o instanceof Error?o.message:String(o);throw new Error(`Failed to upload Parquet: ${a}`)}finally{r&&await this.db.dropFile(r)}}async _uploadArrow(e,t,n=!1){try{let s;const r=`t_${t}`;if(await this.query(`DROP TABLE IF EXISTS "${r}"`),e instanceof File)s=await e.arrayBuffer(),s=new Uint8Array(s);else if(typeof e=="string"){const a=await fetch(e);a.ok||console.warn(`Failed to fetch file: ${a.statusText}`),s=await a.arrayBuffer(),s=new Uint8Array(s)}else s=e;const o=e instanceof zt?e:zk(s);return await this.connection.insertArrowTable(o,{name:r}),await this._handleTableInsertion(r,t,n),await this.logTable(t),{}}catch(s){const r=s instanceof Error?s.message:String(s);throw new Error(`Failed to upload Arrow: ${r}`)}}async _uploadJSON(e,t,n=!1){const s=`t_${t}`;await this.query(`DROP TABLE IF EXISTS "${s}"`);try{if(e instanceof File){const r=await e.text();await this.db.registerFileText("json",r)}else{const r=await fetch(e);r.ok||console.warn(`Failed to fetch file: ${r.statusText}`);const o=await r.text();await this.db.registerFileText("json",o)}return await this.connection.insertJSONFromPath("json",{name:s}),await this._handleTableInsertion(s,t,n),await this.logTable(t),{}}catch(r){const o=r instanceof Error?r.message:String(r);throw new Error(`Failed to upload JSON: ${o}`)}finally{await this.db.dropFile("json")}}async _handleTableInsertion(e,t,n){n?(await this.query(`INSERT INTO "${t}" SELECT * FROM "${e}"`),await this.query(`DROP TABLE IF EXISTS "${e}"`)):(await this.query(`DROP TABLE IF EXISTS "${t}"`),await this.query(`ALTER TABLE "${e}" RENAME TO "${t}"`))}},b(Tn,"_instance"),b(Tn,"_initPromise"),Tn);const yH=av();let bH=class qk{constructor(e,t){b(this,"_coordinator");b(this,"_internalDB");if(!e)return;const n=new cC;n.databaseConnector(e),yH?n.manager.logQueries(!0):n.logger(null),this._coordinator=n,this._internalDB=t}static async create(e){let t,n;try{if(e)typeof e=="string"?(t=new tU({uri:e}),we("Connected to remote DuckDB instance","","ok")):(t=new j1(e),we("Connected to configured duckdb-wasm instance","","ok"));else{const s=Date.now();n=await Yk.getInstance(),t=new j1({duckdb:n.db,connection:n.connection});const r=Date.now();we(`Initialized local duckdb-wasm instance in ${(r-s).toFixed()}ms`,"","ok")}}catch(s){return void we(`Couldn't create MosaicDBCoordinator: ${s}`,"","error")}return new qk(t,n)}get internalDB(){return this._internalDB}connect(e){var t,n;(t=this._coordinator)!=null&&t.clients.has(e)||((n=this._coordinator)==null||n.connect(e))}disconnect(e){var t,n;(t=this._coordinator)!=null&&t.clients.has(e)&&((n=this._coordinator)==null||n.disconnect(e))}clearCache(){var e;(e=this._coordinator)==null||e.clear({cache:!0,clients:!1})}async destroy(){var e;(e=this._coordinator)==null||e.clear(),this._coordinator=void 0}query(e,t={}){const{cache:n=!1,...s}=t;return this._coordinator.query(e,{cache:n,...s})}};var L_="http://www.w3.org/1999/xhtml";const V1={svg:"http://www.w3.org/2000/svg",xhtml:L_,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Np(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),V1.hasOwnProperty(e)?{space:V1[e],local:i}:i}function vH(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===L_&&e.documentElement.namespaceURI===L_?e.createElement(i):e.createElementNS(t,i)}}function xH(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function Xk(i){var e=Np(i);return(e.local?xH:vH)(e)}function wH(){}function dv(i){return i==null?wH:function(){return this.querySelector(i)}}function SH(i){typeof i!="function"&&(i=dv(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=new Array(o),l,c,u=0;u<o;++u)(l=r[u])&&(c=i.call(l,l.__data__,u,r))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new Xn(n,this._parents)}function EH(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function CH(){return[]}function Kk(i){return i==null?CH:function(){return this.querySelectorAll(i)}}function TH(i){return function(){return EH(i.apply(this,arguments))}}function kH(i){typeof i=="function"?i=TH(i):i=Kk(i);for(var e=this._groups,t=e.length,n=[],s=[],r=0;r<t;++r)for(var o=e[r],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(n.push(i.call(l,l.__data__,c,o)),s.push(l));return new Xn(n,s)}function Zk(i){return function(){return this.matches(i)}}function Qk(i){return function(e){return e.matches(i)}}var AH=Array.prototype.find;function IH(i){return function(){return AH.call(this.children,i)}}function LH(){return this.firstElementChild}function RH(i){return this.select(i==null?LH:IH(typeof i=="function"?i:Qk(i)))}var PH=Array.prototype.filter;function NH(){return Array.from(this.children)}function DH(i){return function(){return PH.call(this.children,i)}}function MH(i){return this.selectAll(i==null?NH:DH(typeof i=="function"?i:Qk(i)))}function BH(i){typeof i!="function"&&(i=Zk(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&i.call(l,l.__data__,c,r)&&a.push(l);return new Xn(n,this._parents)}function Jk(i){return new Array(i.length)}function OH(){return new Xn(this._enter||this._groups.map(Jk),this._parents)}function zf(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}zf.prototype={constructor:zf,appendChild:function(i){return this._parent.insertBefore(i,this._next)},insertBefore:function(i,e){return this._parent.insertBefore(i,e)},querySelector:function(i){return this._parent.querySelector(i)},querySelectorAll:function(i){return this._parent.querySelectorAll(i)}};function FH(i){return function(){return i}}function zH(i,e,t,n,s,r){for(var o=0,a,l=e.length,c=r.length;o<c;++o)(a=e[o])?(a.__data__=r[o],n[o]=a):t[o]=new zf(i,r[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function UH(i,e,t,n,s,r,o){var a,l,c=new Map,u=e.length,d=r.length,h=new Array(u),p;for(a=0;a<u;++a)(l=e[a])&&(h[a]=p=o.call(l,l.__data__,a,e)+"",c.has(p)?s[a]=l:c.set(p,l));for(a=0;a<d;++a)p=o.call(i,r[a],a,r)+"",(l=c.get(p))?(n[a]=l,l.__data__=r[a],c.delete(p)):t[a]=new zf(i,r[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(h[a])===l&&(s[a]=l)}function $H(i){return i.__data__}function jH(i,e){if(!arguments.length)return Array.from(this,$H);var t=e?UH:zH,n=this._parents,s=this._groups;typeof i!="function"&&(i=FH(i));for(var r=s.length,o=new Array(r),a=new Array(r),l=new Array(r),c=0;c<r;++c){var u=n[c],d=s[c],h=d.length,p=HH(i.call(u,u&&u.__data__,c,n)),m=p.length,y=a[c]=new Array(m),g=o[c]=new Array(m),_=l[c]=new Array(h);t(u,d,y,g,_,p,e);for(var S=0,E=0,x,T;S<m;++S)if(x=y[S]){for(S>=E&&(E=S+1);!(T=g[E])&&++E<m;);x._next=T||null}}return o=new Xn(o,n),o._enter=a,o._exit=l,o}function HH(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function VH(){return new Xn(this._exit||this._groups.map(Jk),this._parents)}function GH(i,e,t){var n=this.enter(),s=this,r=this.exit();return typeof i=="function"?(n=i(n),n&&(n=n.selection())):n=n.append(i+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?r.remove():t(r),n&&s?n.merge(s).order():s}function WH(i){for(var e=i.selection?i.selection():i,t=this._groups,n=e._groups,s=t.length,r=n.length,o=Math.min(s,r),a=new Array(s),l=0;l<o;++l)for(var c=t[l],u=n[l],d=c.length,h=a[l]=new Array(d),p,m=0;m<d;++m)(p=c[m]||u[m])&&(h[m]=p);for(;l<s;++l)a[l]=t[l];return new Xn(a,this._parents)}function YH(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var n=i[e],s=n.length-1,r=n[s],o;--s>=0;)(o=n[s])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function qH(i){i||(i=XH);function e(d,h){return d&&h?i(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r){for(var o=t[r],a=o.length,l=s[r]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new Xn(s,this._parents).order()}function XH(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function KH(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function ZH(){return Array.from(this)}function QH(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,r=n.length;s<r;++s){var o=n[s];if(o)return o}return null}function JH(){let i=0;for(const e of this)++i;return i}function eV(){return!this.node()}function tV(i){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,o=s.length,a;r<o;++r)(a=s[r])&&i.call(a,a.__data__,r,s);return this}function iV(i){return function(){this.removeAttribute(i)}}function nV(i){return function(){this.removeAttributeNS(i.space,i.local)}}function sV(i,e){return function(){this.setAttribute(i,e)}}function rV(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function oV(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function aV(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(i.space,i.local):this.setAttributeNS(i.space,i.local,t)}}function lV(i,e){var t=Np(i);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?nV:iV:typeof e=="function"?t.local?aV:oV:t.local?rV:sV)(t,e))}function eA(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function cV(i){return function(){this.style.removeProperty(i)}}function uV(i,e,t){return function(){this.style.setProperty(i,e,t)}}function dV(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function hV(i,e,t){return arguments.length>1?this.each((e==null?cV:typeof e=="function"?dV:uV)(i,e,t??"")):Ol(this.node(),i)}function Ol(i,e){return i.style.getPropertyValue(e)||eA(i).getComputedStyle(i,null).getPropertyValue(e)}function fV(i){return function(){delete this[i]}}function pV(i,e){return function(){this[i]=e}}function mV(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function gV(i,e){return arguments.length>1?this.each((e==null?fV:typeof e=="function"?mV:pV)(i,e)):this.node()[i]}function tA(i){return i.trim().split(/^|\s+/)}function hv(i){return i.classList||new iA(i)}function iA(i){this._node=i,this._names=tA(i.getAttribute("class")||"")}iA.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function nA(i,e){for(var t=hv(i),n=-1,s=e.length;++n<s;)t.add(e[n])}function sA(i,e){for(var t=hv(i),n=-1,s=e.length;++n<s;)t.remove(e[n])}function _V(i){return function(){nA(this,i)}}function yV(i){return function(){sA(this,i)}}function bV(i,e){return function(){(e.apply(this,arguments)?nA:sA)(this,i)}}function vV(i,e){var t=tA(i+"");if(arguments.length<2){for(var n=hv(this.node()),s=-1,r=t.length;++s<r;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?bV:e?_V:yV)(t,e))}function xV(){this.textContent=""}function wV(i){return function(){this.textContent=i}}function SV(i){return function(){var e=i.apply(this,arguments);this.textContent=e??""}}function EV(i){return arguments.length?this.each(i==null?xV:(typeof i=="function"?SV:wV)(i)):this.node().textContent}function CV(){this.innerHTML=""}function TV(i){return function(){this.innerHTML=i}}function kV(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e??""}}function AV(i){return arguments.length?this.each(i==null?CV:(typeof i=="function"?kV:TV)(i)):this.node().innerHTML}function IV(){this.nextSibling&&this.parentNode.appendChild(this)}function LV(){return this.each(IV)}function RV(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function PV(){return this.each(RV)}function NV(i){var e=typeof i=="function"?i:Xk(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function DV(){return null}function MV(i,e){var t=typeof i=="function"?i:Xk(i),n=e==null?DV:typeof e=="function"?e:dv(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function BV(){var i=this.parentNode;i&&i.removeChild(this)}function OV(){return this.each(BV)}function FV(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function zV(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function UV(i){return this.select(i?zV:FV)}function $V(i){return arguments.length?this.property("__data__",i):this.node().__data__}function jV(i){return function(e){i.call(this,e,this.__data__)}}function HV(i){return i.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function VV(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,r;t<s;++t)r=e[t],(!i.type||r.type===i.type)&&r.name===i.name?this.removeEventListener(r.type,r.listener,r.options):e[++n]=r;++n?e.length=n:delete this.__on}}}function GV(i,e,t){return function(){var n=this.__on,s,r=jV(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===i.type&&s.name===i.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=t),s.value=e;return}}this.addEventListener(i.type,r,t),s={type:i.type,name:i.name,value:e,listener:r,options:t},n?n.push(s):this.__on=[s]}}function WV(i,e,t){var n=HV(i+""),s,r=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(s=0,u=a[l];s<r;++s)if((o=n[s]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?GV:VV,s=0;s<r;++s)this.each(a(n[s],e,t));return this}function rA(i,e,t){var n=eA(i),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),i.dispatchEvent(s)}function YV(i,e){return function(){return rA(this,i,e)}}function qV(i,e){return function(){return rA(this,i,e.apply(this,arguments))}}function XV(i,e){return this.each((typeof e=="function"?qV:YV)(i,e))}function*KV(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,r=n.length,o;s<r;++s)(o=n[s])&&(yield o)}var oA=[null];function Xn(i,e){this._groups=i,this._parents=e}function nd(){return new Xn([[document.documentElement]],oA)}function ZV(){return this}Xn.prototype=nd.prototype={constructor:Xn,select:SH,selectAll:kH,selectChild:RH,selectChildren:MH,filter:BH,data:jH,enter:OH,exit:VH,join:GH,merge:WH,selection:ZV,order:YH,sort:qH,call:KH,nodes:ZH,node:QH,size:JH,empty:eV,each:tV,attr:lV,style:hV,property:gV,classed:vV,text:EV,html:AV,raise:LV,lower:PV,append:NV,insert:MV,remove:OV,clone:UV,datum:$V,on:WV,dispatch:XV,[Symbol.iterator]:KV};function Wt(i){return typeof i=="string"?new Xn([[document.querySelector(i)]],[document.documentElement]):new Xn([[i]],oA)}function QV(i){let e;for(;e=i.sourceEvent;)i=e;return i}function G1(i,e){if(i=QV(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=i.clientX,n.y=i.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[i.clientX-s.left-e.clientLeft,i.clientY-s.top-e.clientTop]}}return[i.pageX,i.pageY]}var JV={value:()=>{}};function fv(){for(var i=0,e=arguments.length,t={},n;i<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Mh(t)}function Mh(i){this._=i}function eG(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Mh.prototype=fv.prototype={constructor:Mh,on:function(i,e){var t=this._,n=eG(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(i=n[r]).type)&&(s=tG(t[s],i.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<o;)if(s=(i=n[r]).type)t[s]=W1(t[s],i.name,e);else if(e==null)for(s in t)t[s]=W1(t[s],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new Mh(i)},call:function(i,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,r;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(r=this._[i],n=0,s=r.length;n<s;++n)r[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],s=0,r=n.length;s<r;++s)n[s].value.apply(e,t)}};function tG(i,e){for(var t=0,n=i.length,s;t<n;++t)if((s=i[t]).name===e)return s.value}function W1(i,e,t){for(var n=0,s=i.length;n<s;++n)if(i[n].name===e){i[n]=JV,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var Fl=0,Kc=0,_c=0,aA=1e3,Uf,Zc,$f=0,wa=0,Dp=0,Mu=typeof performance=="object"&&performance.now?performance:Date,lA=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function pv(){return wa||(lA(iG),wa=Mu.now()+Dp)}function iG(){wa=0}function jf(){this._call=this._time=this._next=null}jf.prototype=cA.prototype={constructor:jf,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?pv():+t)+(e==null?0:+e),!this._next&&Zc!==this&&(Zc?Zc._next=this:Uf=this,Zc=this),this._call=i,this._time=t,R_()},stop:function(){this._call&&(this._call=null,this._time=1/0,R_())}};function cA(i,e,t){var n=new jf;return n.restart(i,e,t),n}function nG(){pv(),++Fl;for(var i=Uf,e;i;)(e=wa-i._time)>=0&&i._call.call(void 0,e),i=i._next;--Fl}function Y1(){wa=($f=Mu.now())+Dp,Fl=Kc=0;try{nG()}finally{Fl=0,rG(),wa=0}}function sG(){var i=Mu.now(),e=i-$f;e>aA&&(Dp-=e,$f=i)}function rG(){for(var i,e=Uf,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:Uf=t);Zc=i,R_(n)}function R_(i){if(!Fl){Kc&&(Kc=clearTimeout(Kc));var e=i-wa;e>24?(i<1/0&&(Kc=setTimeout(Y1,i-Mu.now()-Dp)),_c&&(_c=clearInterval(_c))):(_c||($f=Mu.now(),_c=setInterval(sG,aA)),Fl=1,lA(Y1))}}function q1(i,e,t){var n=new jf;return e=e==null?0:+e,n.restart(s=>{n.stop(),i(s+e)},e,t),n}var oG=fv("start","end","cancel","interrupt"),aG=[],uA=0,X1=1,P_=2,Bh=3,K1=4,N_=5,Oh=6;function Mp(i,e,t,n,s,r){var o=i.__transition;if(!o)i.__transition={};else if(t in o)return;lG(i,t,{name:e,index:n,group:s,on:oG,tween:aG,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:uA})}function mv(i,e){var t=Ks(i,e);if(t.state>uA)throw new Error("too late; already scheduled");return t}function Pr(i,e){var t=Ks(i,e);if(t.state>Bh)throw new Error("too late; already running");return t}function Ks(i,e){var t=i.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function lG(i,e,t){var n=i.__transition,s;n[e]=t,t.timer=cA(r,0,t.time);function r(c){t.state=X1,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,d,h,p;if(t.state!==X1)return l();for(u in n)if(p=n[u],p.name===t.name){if(p.state===Bh)return q1(o);p.state===K1?(p.state=Oh,p.timer.stop(),p.on.call("interrupt",i,i.__data__,p.index,p.group),delete n[u]):+u<e&&(p.state=Oh,p.timer.stop(),p.on.call("cancel",i,i.__data__,p.index,p.group),delete n[u])}if(q1(function(){t.state===Bh&&(t.state=K1,t.timer.restart(a,t.delay,t.time),a(c))}),t.state=P_,t.on.call("start",i,i.__data__,t.index,t.group),t.state===P_){for(t.state=Bh,s=new Array(h=t.tween.length),u=0,d=-1;u<h;++u)(p=t.tween[u].value.call(i,i.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function a(c){for(var u=c<t.duration?t.ease.call(null,c/t.duration):(t.timer.restart(l),t.state=N_,1),d=-1,h=s.length;++d<h;)s[d].call(i,u);t.state===N_&&(t.on.call("end",i,i.__data__,t.index,t.group),l())}function l(){t.state=Oh,t.timer.stop(),delete n[e];for(var c in n)return;delete i.__transition}}function D_(i,e){var t=i.__transition,n,s,r=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){r=!1;continue}s=n.state>P_&&n.state<N_,n.state=Oh,n.timer.stop(),n.on.call(s?"interrupt":"cancel",i,i.__data__,n.index,n.group),delete t[o]}r&&delete i.__transition}}function cG(i){return this.each(function(){D_(this,i)})}function Bp(i,e,t){i.prototype=e.prototype=t,t.constructor=i}function gv(i,e){var t=Object.create(i.prototype);for(var n in e)t[n]=e[n];return t}function Jl(){}var Sa=.7,zl=1/Sa,bl="\\s*([+-]?\\d+)\\s*",Bu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uG=/^#([0-9a-f]{3,8})$/,dG=new RegExp(`^rgb\\(${bl},${bl},${bl}\\)$`),hG=new RegExp(`^rgb\\(${wr},${wr},${wr}\\)$`),fG=new RegExp(`^rgba\\(${bl},${bl},${bl},${Bu}\\)$`),pG=new RegExp(`^rgba\\(${wr},${wr},${wr},${Bu}\\)$`),mG=new RegExp(`^hsl\\(${Bu},${wr},${wr}\\)$`),gG=new RegExp(`^hsla\\(${Bu},${wr},${wr},${Bu}\\)$`),Z1={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Bp(Jl,ho,{copy(i){return Object.assign(new this.constructor,this,i)},displayable(){return this.rgb().displayable()},hex:Q1,formatHex:Q1,formatHex8:_G,formatHsl:yG,formatRgb:J1,toString:J1});function Q1(){return this.rgb().formatHex()}function _G(){return this.rgb().formatHex8()}function yG(){return hA(this).formatHsl()}function J1(){return this.rgb().formatRgb()}function ho(i){var e,t;return i=(i+"").trim().toLowerCase(),(e=uG.exec(i))?(t=e[1].length,e=parseInt(e[1],16),t===6?ew(e):t===3?new Zi(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?Fd(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?Fd(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=dG.exec(i))?new Zi(e[1],e[2],e[3],1):(e=hG.exec(i))?new Zi(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=fG.exec(i))?Fd(e[1],e[2],e[3],e[4]):(e=pG.exec(i))?Fd(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=mG.exec(i))?nw(e[1],e[2]/100,e[3]/100,1):(e=gG.exec(i))?nw(e[1],e[2]/100,e[3]/100,e[4]):Z1.hasOwnProperty(i)?ew(Z1[i]):i==="transparent"?new Zi(NaN,NaN,NaN,0):null}function ew(i){return new Zi(i>>16&255,i>>8&255,i&255,1)}function Fd(i,e,t,n){return n<=0&&(i=e=t=NaN),new Zi(i,e,t,n)}function dA(i){return i instanceof Jl||(i=ho(i)),i?(i=i.rgb(),new Zi(i.r,i.g,i.b,i.opacity)):new Zi}function Hf(i,e,t,n){return arguments.length===1?dA(i):new Zi(i,e,t,n??1)}function Zi(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}Bp(Zi,Hf,gv(Jl,{brighter(i){return i=i==null?zl:Math.pow(zl,i),new Zi(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?Sa:Math.pow(Sa,i),new Zi(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Zi(da(this.r),da(this.g),da(this.b),Vf(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:tw,formatHex:tw,formatHex8:bG,formatRgb:iw,toString:iw}));function tw(){return`#${la(this.r)}${la(this.g)}${la(this.b)}`}function bG(){return`#${la(this.r)}${la(this.g)}${la(this.b)}${la((isNaN(this.opacity)?1:this.opacity)*255)}`}function iw(){const i=Vf(this.opacity);return`${i===1?"rgb(":"rgba("}${da(this.r)}, ${da(this.g)}, ${da(this.b)}${i===1?")":`, ${i})`}`}function Vf(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function da(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function la(i){return i=da(i),(i<16?"0":"")+i.toString(16)}function nw(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new $s(i,e,t,n)}function hA(i){if(i instanceof $s)return new $s(i.h,i.s,i.l,i.opacity);if(i instanceof Jl||(i=ho(i)),!i)return new $s;if(i instanceof $s)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=NaN,a=r-s,l=(r+s)/2;return a?(e===r?o=(t-n)/a+(t<n)*6:t===r?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?r+s:2-r-s,o*=60):a=l>0&&l<1?0:o,new $s(o,a,l,i.opacity)}function vG(i,e,t,n){return arguments.length===1?hA(i):new $s(i,e,t,n??1)}function $s(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}Bp($s,vG,gv(Jl,{brighter(i){return i=i==null?zl:Math.pow(zl,i),new $s(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?Sa:Math.pow(Sa,i),new $s(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new Zi(zm(i>=240?i-240:i+120,s,n),zm(i,s,n),zm(i<120?i+240:i-120,s,n),this.opacity)},clamp(){return new $s(sw(this.h),zd(this.s),zd(this.l),Vf(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=Vf(this.opacity);return`${i===1?"hsl(":"hsla("}${sw(this.h)}, ${zd(this.s)*100}%, ${zd(this.l)*100}%${i===1?")":`, ${i})`}`}}));function sw(i){return i=(i||0)%360,i<0?i+360:i}function zd(i){return Math.max(0,Math.min(1,i||0))}function zm(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const xG=Math.PI/180,wG=180/Math.PI;var fA=-.14861,_v=1.78277,yv=-.29227,Op=-.90649,Ou=1.97294,rw=Ou*Op,ow=Ou*_v,aw=_v*yv-Op*fA;function SG(i){if(i instanceof ha)return new ha(i.h,i.s,i.l,i.opacity);i instanceof Zi||(i=dA(i));var e=i.r/255,t=i.g/255,n=i.b/255,s=(aw*n+rw*e-ow*t)/(aw+rw-ow),r=n-s,o=(Ou*(t-s)-yv*r)/Op,a=Math.sqrt(o*o+r*r)/(Ou*s*(1-s)),l=a?Math.atan2(o,r)*wG-120:NaN;return new ha(l<0?l+360:l,a,s,i.opacity)}function M_(i,e,t,n){return arguments.length===1?SG(i):new ha(i,e,t,n??1)}function ha(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}Bp(ha,M_,gv(Jl,{brighter(i){return i=i==null?zl:Math.pow(zl,i),new ha(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?Sa:Math.pow(Sa,i),new ha(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=isNaN(this.h)?0:(this.h+120)*xG,e=+this.l,t=isNaN(this.s)?0:this.s*e*(1-e),n=Math.cos(i),s=Math.sin(i);return new Zi(255*(e+t*(fA*n+_v*s)),255*(e+t*(yv*n+Op*s)),255*(e+t*(Ou*n)),this.opacity)}}));const Fp=i=>()=>i;function pA(i,e){return function(t){return i+t*e}}function EG(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function CG(i,e){var t=e-i;return t?pA(i,t>180||t<-180?t-360*Math.round(t/360):t):Fp(isNaN(i)?e:i)}function TG(i){return(i=+i)==1?vl:function(e,t){return t-e?EG(e,t,i):Fp(isNaN(e)?t:e)}}function vl(i,e){var t=e-i;return t?pA(i,t):Fp(isNaN(i)?e:i)}const Gf=(function i(e){var t=TG(e);function n(s,r){var o=t((s=Hf(s)).r,(r=Hf(r)).r),a=t(s.g,r.g),l=t(s.b,r.b),c=vl(s.opacity,r.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return n.gamma=i,n})(1);function kG(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),s;return function(r){for(s=0;s<t;++s)n[s]=i[s]*(1-r)+e[s]*r;return n}}function AG(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function IG(i,e){var t=e?e.length:0,n=i?Math.min(t,i.length):0,s=new Array(n),r=new Array(t),o;for(o=0;o<n;++o)s[o]=ec(i[o],e[o]);for(;o<t;++o)r[o]=e[o];return function(a){for(o=0;o<n;++o)r[o]=s[o](a);return r}}function LG(i,e){var t=new Date;return i=+i,e=+e,function(n){return t.setTime(i*(1-n)+e*n),t}}function zs(i,e){return i=+i,e=+e,function(t){return i*(1-t)+e*t}}function RG(i,e){var t={},n={},s;(i===null||typeof i!="object")&&(i={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in i?t[s]=ec(i[s],e[s]):n[s]=e[s];return function(r){for(s in t)n[s]=t[s](r);return n}}var B_=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Um=new RegExp(B_.source,"g");function PG(i){return function(){return i}}function NG(i){return function(e){return i(e)+""}}function mA(i,e){var t=B_.lastIndex=Um.lastIndex=0,n,s,r,o=-1,a=[],l=[];for(i=i+"",e=e+"";(n=B_.exec(i))&&(s=Um.exec(e));)(r=s.index)>t&&(r=e.slice(t,r),a[o]?a[o]+=r:a[++o]=r),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:zs(n,s)})),t=Um.lastIndex;return t<e.length&&(r=e.slice(t),a[o]?a[o]+=r:a[++o]=r),a.length<2?l[0]?NG(l[0].x):PG(e):(e=l.length,function(c){for(var u=0,d;u<e;++u)a[(d=l[u]).i]=d.x(c);return a.join("")})}function ec(i,e){var t=typeof e,n;return e==null||t==="boolean"?Fp(e):(t==="number"?zs:t==="string"?(n=ho(e))?(e=n,Gf):mA:e instanceof ho?Gf:e instanceof Date?LG:AG(e)?kG:Array.isArray(e)?IG:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?RG:zs)(i,e)}function gA(i,e){return i=+i,e=+e,function(t){return Math.round(i*(1-t)+e*t)}}var lw=180/Math.PI,O_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _A(i,e,t,n,s,r){var o,a,l;return(o=Math.sqrt(i*i+e*e))&&(i/=o,e/=o),(l=i*t+e*n)&&(t-=i*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),i*n<e*t&&(i=-i,e=-e,l=-l,o=-o),{translateX:s,translateY:r,rotate:Math.atan2(e,i)*lw,skewX:Math.atan(l)*lw,scaleX:o,scaleY:a}}var Ud;function DG(i){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(i+"");return e.isIdentity?O_:_A(e.a,e.b,e.c,e.d,e.e,e.f)}function MG(i){return i==null||(Ud||(Ud=document.createElementNS("http://www.w3.org/2000/svg","g")),Ud.setAttribute("transform",i),!(i=Ud.transform.baseVal.consolidate()))?O_:(i=i.matrix,_A(i.a,i.b,i.c,i.d,i.e,i.f))}function yA(i,e,t,n){function s(c){return c.length?c.pop()+" ":""}function r(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push("translate(",null,e,null,t);m.push({i:y-4,x:zs(c,d)},{i:y-2,x:zs(u,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(c,u,d,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:zs(c,u)})):u&&d.push(s(d)+"rotate("+u+n)}function a(c,u,d,h){c!==u?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:zs(c,u)}):u&&d.push(s(d)+"skewX("+u+n)}function l(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push(s(p)+"scale(",null,",",null,")");m.push({i:y-4,x:zs(c,d)},{i:y-2,x:zs(u,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=i(c),u=i(u),r(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var m=-1,y=h.length,g;++m<y;)d[(g=h[m]).i]=g.x(p);return d.join("")}}}var BG=yA(DG,"px, ","px)","deg)"),OG=yA(MG,", ",")",")");function bA(i){return(function e(t){t=+t;function n(s,r){var o=i((s=M_(s)).h,(r=M_(r)).h),a=vl(s.s,r.s),l=vl(s.l,r.l),c=vl(s.opacity,r.opacity);return function(u){return s.h=o(u),s.s=a(u),s.l=l(Math.pow(u,t)),s.opacity=c(u),s+""}}return n.gamma=e,n})(1)}const vA=bA(CG);bA(vl);function xA(i,e){e===void 0&&(e=i,i=ec);for(var t=0,n=e.length-1,s=e[0],r=new Array(n<0?0:n);t<n;)r[t]=i(s,s=e[++t]);return function(o){var a=Math.max(0,Math.min(n-1,Math.floor(o*=n)));return r[a](o-a)}}function FG(i,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=i(n/(e-1));return t}function zG(i,e){var t,n;return function(){var s=Pr(this,i),r=s.tween;if(r!==t){n=t=r;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function UG(i,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var r=Pr(this,i),o=r.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,c=s.length;l<c;++l)if(s[l].name===e){s[l]=a;break}l===c&&s.push(a)}r.tween=s}}function $G(i,e){var t=this._id;if(i+="",arguments.length<2){for(var n=Ks(this.node(),t).tween,s=0,r=n.length,o;s<r;++s)if((o=n[s]).name===i)return o.value;return null}return this.each((e==null?zG:UG)(t,i,e))}function bv(i,e,t){var n=i._id;return i.each(function(){var s=Pr(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Ks(s,n).value[e]}}function wA(i,e){var t;return(typeof e=="number"?zs:e instanceof ho?Gf:(t=ho(e))?(e=t,Gf):mA)(i,e)}function jG(i){return function(){this.removeAttribute(i)}}function HG(i){return function(){this.removeAttributeNS(i.space,i.local)}}function VG(i,e,t){var n,s=t+"",r;return function(){var o=this.getAttribute(i);return o===s?null:o===n?r:r=e(n=o,t)}}function GG(i,e,t){var n,s=t+"",r;return function(){var o=this.getAttributeNS(i.space,i.local);return o===s?null:o===n?r:r=e(n=o,t)}}function WG(i,e,t){var n,s,r;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(i):(o=this.getAttribute(i),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function YG(i,e,t){var n,s,r;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(i.space,i.local):(o=this.getAttributeNS(i.space,i.local),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function qG(i,e){var t=Np(i),n=t==="transform"?OG:wA;return this.attrTween(i,typeof e=="function"?(t.local?YG:WG)(t,n,bv(this,"attr."+i,e)):e==null?(t.local?HG:jG)(t):(t.local?GG:VG)(t,n,e))}function XG(i,e){return function(t){this.setAttribute(i,e.call(this,t))}}function KG(i,e){return function(t){this.setAttributeNS(i.space,i.local,e.call(this,t))}}function ZG(i,e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&KG(i,r)),t}return s._value=e,s}function QG(i,e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&XG(i,r)),t}return s._value=e,s}function JG(i,e){var t="attr."+i;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=Np(i);return this.tween(t,(n.local?ZG:QG)(n,e))}function eW(i,e){return function(){mv(this,i).delay=+e.apply(this,arguments)}}function tW(i,e){return e=+e,function(){mv(this,i).delay=e}}function iW(i){var e=this._id;return arguments.length?this.each((typeof i=="function"?eW:tW)(e,i)):Ks(this.node(),e).delay}function nW(i,e){return function(){Pr(this,i).duration=+e.apply(this,arguments)}}function sW(i,e){return e=+e,function(){Pr(this,i).duration=e}}function rW(i){var e=this._id;return arguments.length?this.each((typeof i=="function"?nW:sW)(e,i)):Ks(this.node(),e).duration}function oW(i,e){if(typeof e!="function")throw new Error;return function(){Pr(this,i).ease=e}}function aW(i){var e=this._id;return arguments.length?this.each(oW(e,i)):Ks(this.node(),e).ease}function lW(i,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Pr(this,i).ease=t}}function cW(i){if(typeof i!="function")throw new Error;return this.each(lW(this._id,i))}function uW(i){typeof i!="function"&&(i=Zk(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&i.call(l,l.__data__,c,r)&&a.push(l);return new fo(n,this._parents,this._name,this._id)}function dW(i){if(i._id!==this._id)throw new Error;for(var e=this._groups,t=i._groups,n=e.length,s=t.length,r=Math.min(n,s),o=new Array(n),a=0;a<r;++a)for(var l=e[a],c=t[a],u=l.length,d=o[a]=new Array(u),h,p=0;p<u;++p)(h=l[p]||c[p])&&(d[p]=h);for(;a<n;++a)o[a]=e[a];return new fo(o,this._parents,this._name,this._id)}function hW(i){return(i+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function fW(i,e,t){var n,s,r=hW(e)?mv:Pr;return function(){var o=r(this,i),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function pW(i,e){var t=this._id;return arguments.length<2?Ks(this.node(),t).on.on(i):this.each(fW(t,i,e))}function mW(i){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==i)return;e&&e.removeChild(this)}}function gW(){return this.on("end.remove",mW(this._id))}function _W(i){var e=this._name,t=this._id;typeof i!="function"&&(i=dv(i));for(var n=this._groups,s=n.length,r=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,c=r[o]=new Array(l),u,d,h=0;h<l;++h)(u=a[h])&&(d=i.call(u,u.__data__,h,a))&&("__data__"in u&&(d.__data__=u.__data__),c[h]=d,Mp(c[h],e,t,h,c,Ks(u,t)));return new fo(r,this._parents,e,t)}function yW(i){var e=this._name,t=this._id;typeof i!="function"&&(i=Kk(i));for(var n=this._groups,s=n.length,r=[],o=[],a=0;a<s;++a)for(var l=n[a],c=l.length,u,d=0;d<c;++d)if(u=l[d]){for(var h=i.call(u,u.__data__,d,l),p,m=Ks(u,t),y=0,g=h.length;y<g;++y)(p=h[y])&&Mp(p,e,t,y,h,m);r.push(h),o.push(u)}return new fo(r,o,e,t)}var bW=nd.prototype.constructor;function vW(){return new bW(this._groups,this._parents)}function xW(i,e){var t,n,s;return function(){var r=Ol(this,i),o=(this.style.removeProperty(i),Ol(this,i));return r===o?null:r===t&&o===n?s:s=e(t=r,n=o)}}function SA(i){return function(){this.style.removeProperty(i)}}function wW(i,e,t){var n,s=t+"",r;return function(){var o=Ol(this,i);return o===s?null:o===n?r:r=e(n=o,t)}}function SW(i,e,t){var n,s,r;return function(){var o=Ol(this,i),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(i),Ol(this,i))),o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a))}}function EW(i,e){var t,n,s,r="style."+e,o="end."+r,a;return function(){var l=Pr(this,i),c=l.on,u=l.value[r]==null?a||(a=SA(e)):void 0;(c!==t||s!==u)&&(n=(t=c).copy()).on(o,s=u),l.on=n}}function CW(i,e,t){var n=(i+="")=="transform"?BG:wA;return e==null?this.styleTween(i,xW(i,n)).on("end.style."+i,SA(i)):typeof e=="function"?this.styleTween(i,SW(i,n,bv(this,"style."+i,e))).each(EW(this._id,i)):this.styleTween(i,wW(i,n,e),t).on("end.style."+i,null)}function TW(i,e,t){return function(n){this.style.setProperty(i,e.call(this,n),t)}}function kW(i,e,t){var n,s;function r(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&TW(i,o,t)),n}return r._value=e,r}function AW(i,e,t){var n="style."+(i+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,kW(i,e,t??""))}function IW(i){return function(){this.textContent=i}}function LW(i){return function(){var e=i(this);this.textContent=e??""}}function RW(i){return this.tween("text",typeof i=="function"?LW(bv(this,"text",i)):IW(i==null?"":i+""))}function PW(i){return function(e){this.textContent=i.call(this,e)}}function NW(i){var e,t;function n(){var s=i.apply(this,arguments);return s!==t&&(e=(t=s)&&PW(s)),e}return n._value=i,n}function DW(i){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(i==null)return this.tween(e,null);if(typeof i!="function")throw new Error;return this.tween(e,NW(i))}function MW(){for(var i=this._name,e=this._id,t=EA(),n=this._groups,s=n.length,r=0;r<s;++r)for(var o=n[r],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=Ks(l,e);Mp(l,i,t,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new fo(n,this._parents,i,t)}function BW(){var i,e,t=this,n=t._id,s=t.size();return new Promise(function(r,o){var a={value:o},l={value:function(){--s===0&&r()}};t.each(function(){var c=Pr(this,n),u=c.on;u!==i&&(e=(i=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),s===0&&r()})}var OW=0;function fo(i,e,t,n){this._groups=i,this._parents=e,this._name=t,this._id=n}function EA(){return++OW}var jr=nd.prototype;fo.prototype={constructor:fo,select:_W,selectAll:yW,selectChild:jr.selectChild,selectChildren:jr.selectChildren,filter:uW,merge:dW,selection:vW,transition:MW,call:jr.call,nodes:jr.nodes,node:jr.node,size:jr.size,empty:jr.empty,each:jr.each,on:pW,attr:qG,attrTween:JG,style:CW,styleTween:AW,text:RW,textTween:DW,remove:gW,tween:$G,delay:iW,duration:rW,ease:aW,easeVarying:cW,end:BW,[Symbol.iterator]:jr[Symbol.iterator]};function FW(i){return((i*=2)<=1?i*i*i:(i-=2)*i*i+2)/2}var zW={time:null,delay:0,duration:250,ease:FW};function UW(i,e){for(var t;!(t=i.__transition)||!(t=t[e]);)if(!(i=i.parentNode))throw new Error(`transition ${e} not found`);return t}function $W(i){var e,t;i instanceof fo?(e=i._id,i=i._name):(e=EA(),(t=zW).time=pv(),i=i==null?null:i+"");for(var n=this._groups,s=n.length,r=0;r<s;++r)for(var o=n[r],a=o.length,l,c=0;c<a;++c)(l=o[c])&&Mp(l,i,e,c,o,t||UW(l,e));return new fo(n,this._parents,i,e)}nd.prototype.interrupt=cG;nd.prototype.transition=$W;var fa=[],jW=function(){return fa.some(function(i){return i.activeTargets.length>0})},HW=function(){return fa.some(function(i){return i.skippedTargets.length>0})},cw="ResizeObserver loop completed with undelivered notifications.",VW=function(){var i;typeof ErrorEvent=="function"?i=new ErrorEvent("error",{message:cw}):(i=document.createEvent("Event"),i.initEvent("error",!1,!1),i.message=cw),window.dispatchEvent(i)},Fu;(function(i){i.BORDER_BOX="border-box",i.CONTENT_BOX="content-box",i.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(Fu||(Fu={}));var pa=function(i){return Object.freeze(i)},GW=(function(){function i(e,t){this.inlineSize=e,this.blockSize=t,pa(this)}return i})(),CA=(function(){function i(e,t,n,s){return this.x=e,this.y=t,this.width=n,this.height=s,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,pa(this)}return i.prototype.toJSON=function(){var e=this,t=e.x,n=e.y,s=e.top,r=e.right,o=e.bottom,a=e.left,l=e.width,c=e.height;return{x:t,y:n,top:s,right:r,bottom:o,left:a,width:l,height:c}},i.fromRect=function(e){return new i(e.x,e.y,e.width,e.height)},i})(),vv=function(i){return i instanceof SVGElement&&"getBBox"in i},TA=function(i){if(vv(i)){var e=i.getBBox(),t=e.width,n=e.height;return!t&&!n}var s=i,r=s.offsetWidth,o=s.offsetHeight;return!(r||o||i.getClientRects().length)},uw=function(i){var e;if(i instanceof Element)return!0;var t=(e=i==null?void 0:i.ownerDocument)===null||e===void 0?void 0:e.defaultView;return!!(t&&i instanceof t.Element)},WW=function(i){switch(i.tagName){case"INPUT":if(i.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},lu=typeof window<"u"?window:{},$d=new WeakMap,dw=/auto|scroll/,YW=/^tb|vertical/,qW=/msie|trident/i.test(lu.navigator&&lu.navigator.userAgent),sr=function(i){return parseFloat(i||"0")},xl=function(i,e,t){return i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=!1),new GW((t?e:i)||0,(t?i:e)||0)},hw=pa({devicePixelContentBoxSize:xl(),borderBoxSize:xl(),contentBoxSize:xl(),contentRect:new CA(0,0,0,0)}),kA=function(i,e){if(e===void 0&&(e=!1),$d.has(i)&&!e)return $d.get(i);if(TA(i))return $d.set(i,hw),hw;var t=getComputedStyle(i),n=vv(i)&&i.ownerSVGElement&&i.getBBox(),s=!qW&&t.boxSizing==="border-box",r=YW.test(t.writingMode||""),o=!n&&dw.test(t.overflowY||""),a=!n&&dw.test(t.overflowX||""),l=n?0:sr(t.paddingTop),c=n?0:sr(t.paddingRight),u=n?0:sr(t.paddingBottom),d=n?0:sr(t.paddingLeft),h=n?0:sr(t.borderTopWidth),p=n?0:sr(t.borderRightWidth),m=n?0:sr(t.borderBottomWidth),y=n?0:sr(t.borderLeftWidth),g=d+c,_=l+u,S=y+p,E=h+m,x=a?i.offsetHeight-E-i.clientHeight:0,T=o?i.offsetWidth-S-i.clientWidth:0,I=s?g+S:0,O=s?_+E:0,H=n?n.width:sr(t.width)-I-T,Q=n?n.height:sr(t.height)-O-x,re=H+g+T+S,D=Q+_+x+E,de=pa({devicePixelContentBoxSize:xl(Math.round(H*devicePixelRatio),Math.round(Q*devicePixelRatio),r),borderBoxSize:xl(re,D,r),contentBoxSize:xl(H,Q,r),contentRect:new CA(d,l,H,Q)});return $d.set(i,de),de},AA=function(i,e,t){var n=kA(i,t),s=n.borderBoxSize,r=n.contentBoxSize,o=n.devicePixelContentBoxSize;switch(e){case Fu.DEVICE_PIXEL_CONTENT_BOX:return o;case Fu.BORDER_BOX:return s;default:return r}},XW=(function(){function i(e){var t=kA(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=pa([t.borderBoxSize]),this.contentBoxSize=pa([t.contentBoxSize]),this.devicePixelContentBoxSize=pa([t.devicePixelContentBoxSize])}return i})(),IA=function(i){if(TA(i))return 1/0;for(var e=0,t=i.parentNode;t;)e+=1,t=t.parentNode;return e},KW=function(){var i=1/0,e=[];fa.forEach(function(o){if(o.activeTargets.length!==0){var a=[];o.activeTargets.forEach(function(c){var u=new XW(c.target),d=IA(c.target);a.push(u),c.lastReportedSize=AA(c.target,c.observedBox),d<i&&(i=d)}),e.push(function(){o.callback.call(o.observer,a,o.observer)}),o.activeTargets.splice(0,o.activeTargets.length)}});for(var t=0,n=e;t<n.length;t++){var s=n[t];s()}return i},fw=function(i){fa.forEach(function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach(function(s){s.isActive()&&(IA(s.target)>i?t.activeTargets.push(s):t.skippedTargets.push(s))})})},ZW=function(){var i=0;for(fw(i);jW();)i=KW(),fw(i);return HW()&&VW(),i>0},$m,LA=[],QW=function(){return LA.splice(0).forEach(function(i){return i()})},JW=function(i){if(!$m){var e=0,t=document.createTextNode(""),n={characterData:!0};new MutationObserver(function(){return QW()}).observe(t,n),$m=function(){t.textContent="".concat(e?e--:e++)}}LA.push(i),$m()},eY=function(i){JW(function(){requestAnimationFrame(i)})},Fh=0,tY=function(){return!!Fh},iY=250,nY={attributes:!0,characterData:!0,childList:!0,subtree:!0},pw=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],mw=function(i){return i===void 0&&(i=0),Date.now()+i},jm=!1,sY=(function(){function i(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return i.prototype.run=function(e){var t=this;if(e===void 0&&(e=iY),!jm){jm=!0;var n=mw(e);eY(function(){var s=!1;try{s=ZW()}finally{if(jm=!1,e=n-mw(),!tY())return;s?t.run(1e3):e>0?t.run(e):t.start()}})}},i.prototype.schedule=function(){this.stop(),this.run()},i.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,nY)};document.body?t():lu.addEventListener("DOMContentLoaded",t)},i.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),pw.forEach(function(t){return lu.addEventListener(t,e.listener,!0)}))},i.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),pw.forEach(function(t){return lu.removeEventListener(t,e.listener,!0)}),this.stopped=!0)},i})(),F_=new sY,gw=function(i){!Fh&&i>0&&F_.start(),Fh+=i,!Fh&&F_.stop()},rY=function(i){return!vv(i)&&!WW(i)&&getComputedStyle(i).display==="inline"},oY=(function(){function i(e,t){this.target=e,this.observedBox=t||Fu.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return i.prototype.isActive=function(){var e=AA(this.target,this.observedBox,!0);return rY(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},i})(),aY=(function(){function i(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t}return i})(),jd=new WeakMap,_w=function(i,e){for(var t=0;t<i.length;t+=1)if(i[t].target===e)return t;return-1},Hd=(function(){function i(){}return i.connect=function(e,t){var n=new aY(e,t);jd.set(e,n)},i.observe=function(e,t,n){var s=jd.get(e),r=s.observationTargets.length===0;_w(s.observationTargets,t)<0&&(r&&fa.push(s),s.observationTargets.push(new oY(t,n&&n.box)),gw(1),F_.schedule())},i.unobserve=function(e,t){var n=jd.get(e),s=_w(n.observationTargets,t),r=n.observationTargets.length===1;s>=0&&(r&&fa.splice(fa.indexOf(n),1),n.observationTargets.splice(s,1),gw(-1))},i.disconnect=function(e){var t=this,n=jd.get(e);n.observationTargets.slice().forEach(function(s){return t.unobserve(e,s.target)}),n.activeTargets.splice(0,n.activeTargets.length)},i})(),RA=(function(){function i(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Hd.connect(this,e)}return i.prototype.observe=function(e,t){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!uw(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Hd.observe(this,e,t)},i.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!uw(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Hd.unobserve(this,e)},i.prototype.disconnect=function(){Hd.disconnect(this)},i.toString=function(){return"function ResizeObserver () { [polyfill code] }"},i})();function lY(i){return i}var cY=3,yw=1e-6;function uY(i){return"translate("+i+",0)"}function dY(i){return e=>+i(e)}function hY(i,e){return e=Math.max(0,i.bandwidth()-e*2)/2,i.round()&&(e=Math.round(e)),t=>+i(t)+e}function fY(){return!this.__axis}function pY(i,e){var t=[],n=null,s=null,r=6,o=6,a=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,c=1,u="y",d=uY;function h(p){var m=n??(e.ticks?e.ticks.apply(e,t):e.domain()),y=s??(e.tickFormat?e.tickFormat.apply(e,t):lY),g=Math.max(r,0)+a,_=e.range(),S=+_[0]+l,E=+_[_.length-1]+l,x=(e.bandwidth?hY:dY)(e.copy(),l),T=p.selection?p.selection():p,I=T.selectAll(".domain").data([null]),O=T.selectAll(".tick").data(m,e).order(),H=O.exit(),Q=O.enter().append("g").attr("class","tick"),re=O.select("line"),D=O.select("text");I=I.merge(I.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),O=O.merge(Q),re=re.merge(Q.append("line").attr("stroke","currentColor").attr(u+"2",c*r)),D=D.merge(Q.append("text").attr("fill","currentColor").attr(u,c*g).attr("dy","0.71em")),p!==T&&(I=I.transition(p),O=O.transition(p),re=re.transition(p),D=D.transition(p),H=H.transition(p).attr("opacity",yw).attr("transform",function(de){return isFinite(de=x(de))?d(de+l):this.getAttribute("transform")}),Q.attr("opacity",yw).attr("transform",function(de){var se=this.parentNode.__axis;return d((se&&isFinite(se=se(de))?se:x(de))+l)})),H.remove(),I.attr("d",o?"M"+S+","+c*o+"V"+l+"H"+E+"V"+c*o:"M"+S+","+l+"H"+E),O.attr("opacity",1).attr("transform",function(de){return d(x(de)+l)}),re.attr(u+"2",c*r),D.attr(u,c*g).text(y),T.filter(fY).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor","middle"),T.each(function(){this.__axis=x})}return h.scale=function(p){return arguments.length?(e=p,h):e},h.ticks=function(){return t=Array.from(arguments),h},h.tickArguments=function(p){return arguments.length?(t=p==null?[]:Array.from(p),h):t.slice()},h.tickValues=function(p){return arguments.length?(n=p==null?null:Array.from(p),h):n&&n.slice()},h.tickFormat=function(p){return arguments.length?(s=p,h):s},h.tickSize=function(p){return arguments.length?(r=o=+p,h):r},h.tickSizeInner=function(p){return arguments.length?(r=+p,h):r},h.tickSizeOuter=function(p){return arguments.length?(o=+p,h):o},h.tickPadding=function(p){return arguments.length?(a=+p,h):a},h.offset=function(p){return arguments.length?(l=+p,h):l},h}function z_(i){return pY(cY,i)}const U_={capture:!0,passive:!1};function $_(i){i.preventDefault(),i.stopImmediatePropagation()}function mY(i){var e=i.document.documentElement,t=Wt(i).on("dragstart.drag",$_,U_);"onselectstart"in e?t.on("selectstart.drag",$_,U_):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function gY(i,e){var t=i.document.documentElement,n=Wt(i).on("dragstart.drag",null);e&&(n.on("click.drag",$_,U_),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const Hm=i=>()=>i;function _Y(i,{sourceEvent:e,target:t,selection:n,mode:s,dispatch:r}){Object.defineProperties(this,{type:{value:i,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},selection:{value:n,enumerable:!0,configurable:!0},mode:{value:s,enumerable:!0,configurable:!0},_:{value:r}})}function yY(i){i.stopImmediatePropagation()}function Vm(i){i.preventDefault(),i.stopImmediatePropagation()}var bw={name:"drag"},Gm={name:"space"},Fa={name:"handle"},za={name:"center"};const{abs:vw,max:Wi,min:Yi}=Math;function xw(i){return[+i[0],+i[1]]}function j_(i){return[xw(i[0]),xw(i[1])]}var zh={name:"x",handles:["w","e"].map(Wf),input:function(i,e){return i==null?null:[[+i[0],e[0][1]],[+i[1],e[1][1]]]},output:function(i){return i&&[i[0][0],i[1][0]]}},Wm={},bY={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(Wf),input:function(i){return i==null?null:j_(i)},output:function(i){return i}},Hr={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},ww={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Sw={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},vY={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},xY={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function Wf(i){return{type:i}}function wY(i){return!i.ctrlKey&&!i.button}function SY(){var i=this.ownerSVGElement||this;return i.hasAttribute("viewBox")?(i=i.viewBox.baseVal,[[i.x,i.y],[i.x+i.width,i.y+i.height]]):[[0,0],[i.width.baseVal.value,i.height.baseVal.value]]}function EY(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ym(i){for(;!i.__brush;)if(!(i=i.parentNode))return;return i.__brush}function CY(i){return i[0][0]===i[1][0]||i[0][1]===i[1][1]}function PA(){return NA(zh)}function TY(){return NA(bY)}function NA(i){var e=SY,t=wY,n=EY,s=!0,r=fv("start","brush","end"),o=6,a;function l(g){var _=g.property("__brush",y).selectAll(".overlay").data([Wf("overlay")]);_.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Hr.overlay).merge(_).each(function(){var E=Ym(this).extent;Wt(this).attr("x",E[0][0]).attr("y",E[0][1]).attr("width",E[1][0]-E[0][0]).attr("height",E[1][1]-E[0][1])}),g.selectAll(".selection").data([Wf("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Hr.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var S=g.selectAll(".handle").data(i.handles,function(E){return E.type});S.exit().remove(),S.enter().append("rect").attr("class",function(E){return"handle handle--"+E.type}).attr("cursor",function(E){return Hr[E.type]}),g.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(n).on("touchstart.brush",h).on("touchmove.brush",p).on("touchend.brush touchcancel.brush",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}l.move=function(g,_,S){g.tween?g.on("start.brush",function(E){u(this,arguments).beforestart().start(E)}).on("interrupt.brush end.brush",function(E){u(this,arguments).end(E)}).tween("brush",function(){var E=this,x=E.__brush,T=u(E,arguments),I=x.selection,O=i.input(typeof _=="function"?_.apply(this,arguments):_,x.extent),H=ec(I,O);function Q(re){x.selection=re===1&&O===null?null:H(re),c.call(E),T.brush()}return I!==null&&O!==null?Q:Q(1)}):g.each(function(){var E=this,x=arguments,T=E.__brush,I=i.input(typeof _=="function"?_.apply(E,x):_,T.extent),O=u(E,x).beforestart();D_(E),T.selection=I===null?null:I,c.call(E),O.start(S).brush(S).end(S)})},l.clear=function(g,_){l.move(g,null,_)};function c(){var g=Wt(this),_=Ym(this).selection;_?(g.selectAll(".selection").style("display",null).attr("x",_[0][0]).attr("y",_[0][1]).attr("width",_[1][0]-_[0][0]).attr("height",_[1][1]-_[0][1]),g.selectAll(".handle").style("display",null).attr("x",function(S){return S.type[S.type.length-1]==="e"?_[1][0]-o/2:_[0][0]-o/2}).attr("y",function(S){return S.type[0]==="s"?_[1][1]-o/2:_[0][1]-o/2}).attr("width",function(S){return S.type==="n"||S.type==="s"?_[1][0]-_[0][0]+o:o}).attr("height",function(S){return S.type==="e"||S.type==="w"?_[1][1]-_[0][1]+o:o})):g.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(g,_,S){var E=g.__brush.emitter;return E&&(!S||!E.clean)?E:new d(g,_,S)}function d(g,_,S){this.that=g,this.args=_,this.state=g.__brush,this.active=0,this.clean=S}d.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(g,_){return this.starting?(this.starting=!1,this.emit("start",g,_)):this.emit("brush",g),this},brush:function(g,_){return this.emit("brush",g,_),this},end:function(g,_){return--this.active===0&&(delete this.state.emitter,this.emit("end",g,_)),this},emit:function(g,_,S){var E=Wt(this.that).datum();r.call(g,this.that,new _Y(g,{sourceEvent:_,target:l,selection:i.output(this.state.selection),mode:S,dispatch:r}),E)}};function h(g){if(a&&!g.touches||!t.apply(this,arguments))return;var _=this,S=g.target.__data__.type,E=(s&&g.metaKey?S="overlay":S)==="selection"?bw:s&&g.altKey?za:Fa,x=i===Wm?null:vY[S],T=i===zh?null:xY[S],I=Ym(_),O=I.extent,H=I.selection,Q=O[0][0],re,D,de=O[0][1],se,R,ee=O[1][0],F,q,te=O[1][1],Z,ae,J=0,Se=0,xe,et=x&&T&&s&&g.shiftKey,he,yt,Xe=Array.from(g.touches||[g],pe=>{const it=pe.identifier;return pe=G1(pe,_),pe.point0=pe.slice(),pe.identifier=it,pe});D_(_);var dt=u(_,arguments,!0).beforestart();if(S==="overlay"){H&&(xe=!0);const pe=[Xe[0],Xe[1]||Xe[0]];I.selection=H=[[re=i===Wm?Q:Yi(pe[0][0],pe[1][0]),se=i===zh?de:Yi(pe[0][1],pe[1][1])],[F=i===Wm?ee:Wi(pe[0][0],pe[1][0]),Z=i===zh?te:Wi(pe[0][1],pe[1][1])]],Xe.length>1&&We(g)}else re=H[0][0],se=H[0][1],F=H[1][0],Z=H[1][1];D=re,R=se,q=F,ae=Z;var ie=Wt(_).attr("pointer-events","none"),Ce=ie.selectAll(".overlay").attr("cursor",Hr[S]);if(g.touches)dt.moved=X,dt.ended=He;else{var Pe=Wt(g.view).on("mousemove.brush",X,!0).on("mouseup.brush",He,!0);s&&Pe.on("keydown.brush",bt,!0).on("keyup.brush",Vt,!0),mY(g.view)}c.call(_),dt.start(g,E.name);function X(pe){for(const it of pe.changedTouches||[pe])for(const si of Xe)si.identifier===it.identifier&&(si.cur=G1(it,_));if(et&&!he&&!yt&&Xe.length===1){const it=Xe[0];vw(it.cur[0]-it[0])>vw(it.cur[1]-it[1])?yt=!0:he=!0}for(const it of Xe)it.cur&&(it[0]=it.cur[0],it[1]=it.cur[1]);xe=!0,Vm(pe),We(pe)}function We(pe){const it=Xe[0],si=it.point0;var yi;switch(J=it[0]-si[0],Se=it[1]-si[1],E){case Gm:case bw:{x&&(J=Wi(Q-re,Yi(ee-F,J)),D=re+J,q=F+J),T&&(Se=Wi(de-se,Yi(te-Z,Se)),R=se+Se,ae=Z+Se);break}case Fa:{Xe[1]?(x&&(D=Wi(Q,Yi(ee,Xe[0][0])),q=Wi(Q,Yi(ee,Xe[1][0])),x=1),T&&(R=Wi(de,Yi(te,Xe[0][1])),ae=Wi(de,Yi(te,Xe[1][1])),T=1)):(x<0?(J=Wi(Q-re,Yi(ee-re,J)),D=re+J,q=F):x>0&&(J=Wi(Q-F,Yi(ee-F,J)),D=re,q=F+J),T<0?(Se=Wi(de-se,Yi(te-se,Se)),R=se+Se,ae=Z):T>0&&(Se=Wi(de-Z,Yi(te-Z,Se)),R=se,ae=Z+Se));break}case za:{x&&(D=Wi(Q,Yi(ee,re-J*x)),q=Wi(Q,Yi(ee,F+J*x))),T&&(R=Wi(de,Yi(te,se-Se*T)),ae=Wi(de,Yi(te,Z+Se*T)));break}}q<D&&(x*=-1,yi=re,re=F,F=yi,yi=D,D=q,q=yi,S in ww&&Ce.attr("cursor",Hr[S=ww[S]])),ae<R&&(T*=-1,yi=se,se=Z,Z=yi,yi=R,R=ae,ae=yi,S in Sw&&Ce.attr("cursor",Hr[S=Sw[S]])),I.selection&&(H=I.selection),he&&(D=H[0][0],q=H[1][0]),yt&&(R=H[0][1],ae=H[1][1]),(H[0][0]!==D||H[0][1]!==R||H[1][0]!==q||H[1][1]!==ae)&&(I.selection=[[D,R],[q,ae]],c.call(_),dt.brush(pe,E.name))}function He(pe){if(yY(pe),pe.touches){if(pe.touches.length)return;a&&clearTimeout(a),a=setTimeout(function(){a=null},500)}else gY(pe.view,xe),Pe.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);ie.attr("pointer-events","all"),Ce.attr("cursor",Hr.overlay),I.selection&&(H=I.selection),CY(H)&&(I.selection=null,c.call(_)),dt.end(pe,E.name)}function bt(pe){switch(pe.keyCode){case 16:{et=x&&T;break}case 18:{E===Fa&&(x&&(F=q-J*x,re=D+J*x),T&&(Z=ae-Se*T,se=R+Se*T),E=za,We(pe));break}case 32:{(E===Fa||E===za)&&(x<0?F=q-J:x>0&&(re=D-J),T<0?Z=ae-Se:T>0&&(se=R-Se),E=Gm,Ce.attr("cursor",Hr.selection),We(pe));break}default:return}Vm(pe)}function Vt(pe){switch(pe.keyCode){case 16:{et&&(he=yt=et=!1,We(pe));break}case 18:{E===za&&(x<0?F=q:x>0&&(re=D),T<0?Z=ae:T>0&&(se=R),E=Fa,We(pe));break}case 32:{E===Gm&&(pe.altKey?(x&&(F=q-J*x,re=D+J*x),T&&(Z=ae-Se*T,se=R+Se*T),E=za):(x<0?F=q:x>0&&(re=D),T<0?Z=ae:T>0&&(se=R),E=Fa),Ce.attr("cursor",Hr[S]),We(pe));break}default:return}Vm(pe)}}function p(g){u(this,arguments).moved(g)}function m(g){u(this,arguments).ended(g)}function y(){var g=this.__brush||{selection:null};return g.extent=j_(e.apply(this,arguments)),g.dim=i,g}return l.extent=function(g){return arguments.length?(e=typeof g=="function"?g:Hm(j_(g)),l):e},l.filter=function(g){return arguments.length?(t=typeof g=="function"?g:Hm(!!g),l):t},l.touchable=function(g){return arguments.length?(n=typeof g=="function"?g:Hm(!!g),l):n},l.handleSize=function(g){return arguments.length?(o=+g,l):o},l.keyModifiers=function(g){return arguments.length?(s=!!g,l):s},l.on=function(){var g=r.on.apply(r,arguments);return g===r?l:g},l}function sd(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function kY(i,e){switch(arguments.length){case 0:break;case 1:{typeof i=="function"?this.interpolator(i):this.range(i);break}default:{this.domain(i),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const Ew=Symbol("implicit");function DA(){var i=new k0,e=[],t=[],n=Ew;function s(r){let o=i.get(r);if(o===void 0){if(n!==Ew)return n;i.set(r,o=e.push(r)-1)}return t[o%t.length]}return s.domain=function(r){if(!arguments.length)return e.slice();e=[],i=new k0;for(const o of r)i.has(o)||i.set(o,e.push(o)-1);return s},s.range=function(r){return arguments.length?(t=Array.from(r),s):t.slice()},s.unknown=function(r){return arguments.length?(n=r,s):n},s.copy=function(){return DA(e,t).unknown(n)},sd.apply(s,arguments),s}function AY(i){return function(){return i}}function IY(i){return+i}var Cw=[0,1];function zo(i){return i}function H_(i,e){return(e-=i=+i)?function(t){return(t-i)/e}:AY(isNaN(e)?NaN:.5)}function LY(i,e){var t;return i>e&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function RY(i,e,t){var n=i[0],s=i[1],r=e[0],o=e[1];return s<n?(n=H_(s,n),r=t(o,r)):(n=H_(n,s),r=t(r,o)),function(a){return r(n(a))}}function PY(i,e,t){var n=Math.min(i.length,e.length)-1,s=new Array(n),r=new Array(n),o=-1;for(i[n]<i[0]&&(i=i.slice().reverse(),e=e.slice().reverse());++o<n;)s[o]=H_(i[o],i[o+1]),r[o]=t(e[o],e[o+1]);return function(a){var l=OS(i,a,1,n)-1;return r[l](s[l](a))}}function xv(i,e){return e.domain(i.domain()).range(i.range()).interpolate(i.interpolate()).clamp(i.clamp()).unknown(i.unknown())}function MA(){var i=Cw,e=Cw,t=ec,n,s,r,o=zo,a,l,c;function u(){var h=Math.min(i.length,e.length);return o!==zo&&(o=LY(i[0],i[h-1])),a=h>2?PY:RY,l=c=null,d}function d(h){return h==null||isNaN(h=+h)?r:(l||(l=a(i.map(n),e,t)))(n(o(h)))}return d.invert=function(h){return o(s((c||(c=a(e,i.map(n),zs)))(h)))},d.domain=function(h){return arguments.length?(i=Array.from(h,IY),u()):i.slice()},d.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},d.rangeRound=function(h){return e=Array.from(h),t=gA,u()},d.clamp=function(h){return arguments.length?(o=h?!0:zo,u()):o!==zo},d.interpolate=function(h){return arguments.length?(t=h,u()):t},d.unknown=function(h){return arguments.length?(r=h,d):r},function(h,p){return n=h,s=p,u()}}function BA(){return MA()(zo,zo)}function NY(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function Yf(i,e){if((t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"))<0)return null;var t,n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function Ul(i){return i=Yf(Math.abs(i)),i?i[1]:NaN}function DY(i,e){return function(t,n){for(var s=t.length,r=[],o=0,a=i[0],l=0;s>0&&a>0&&(l+a+1>n&&(a=Math.max(1,n-l)),r.push(t.substring(s-=a,s+a)),!((l+=a+1)>n));)a=i[o=(o+1)%i.length];return r.reverse().join(e)}}function MY(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var BY=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function qf(i){if(!(e=BY.exec(i)))throw new Error("invalid format: "+i);var e;return new wv({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}qf.prototype=wv.prototype;function wv(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}wv.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function OY(i){e:for(var e=i.length,t=1,n=-1,s;t<e;++t)switch(i[t]){case".":n=s=t;break;case"0":n===0&&(n=t),s=t;break;default:if(!+i[t])break e;n>0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(s+1):i}var OA;function FY(i,e){var t=Yf(i,e);if(!t)return i+"";var n=t[0],s=t[1],r=s-(OA=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,o=n.length;return r===o?n:r>o?n+new Array(r-o+1).join("0"):r>0?n.slice(0,r)+"."+n.slice(r):"0."+new Array(1-r).join("0")+Yf(i,Math.max(0,e+r-1))[0]}function Tw(i,e){var t=Yf(i,e);if(!t)return i+"";var n=t[0],s=t[1];return s<0?"0."+new Array(-s).join("0")+n:n.length>s+1?n.slice(0,s+1)+"."+n.slice(s+1):n+new Array(s-n.length+2).join("0")}const kw={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:NY,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>Tw(i*100,e),r:Tw,s:FY,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function Aw(i){return i}var Iw=Array.prototype.map,Lw=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function zY(i){var e=i.grouping===void 0||i.thousands===void 0?Aw:DY(Iw.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",s=i.decimal===void 0?".":i.decimal+"",r=i.numerals===void 0?Aw:MY(Iw.call(i.numerals,String)),o=i.percent===void 0?"%":i.percent+"",a=i.minus===void 0?"−":i.minus+"",l=i.nan===void 0?"NaN":i.nan+"";function c(d){d=qf(d);var h=d.fill,p=d.align,m=d.sign,y=d.symbol,g=d.zero,_=d.width,S=d.comma,E=d.precision,x=d.trim,T=d.type;T==="n"?(S=!0,T="g"):kw[T]||(E===void 0&&(E=12),x=!0,T="g"),(g||h==="0"&&p==="=")&&(g=!0,h="0",p="=");var I=y==="$"?t:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",O=y==="$"?n:/[%p]/.test(T)?o:"",H=kw[T],Q=/[defgprs%]/.test(T);E=E===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function re(D){var de=I,se=O,R,ee,F;if(T==="c")se=H(D)+se,D="";else{D=+D;var q=D<0||1/D<0;if(D=isNaN(D)?l:H(Math.abs(D),E),x&&(D=OY(D)),q&&+D==0&&m!=="+"&&(q=!1),de=(q?m==="("?m:a:m==="-"||m==="("?"":m)+de,se=(T==="s"?Lw[8+OA/3]:"")+se+(q&&m==="("?")":""),Q){for(R=-1,ee=D.length;++R<ee;)if(F=D.charCodeAt(R),48>F||F>57){se=(F===46?s+D.slice(R+1):D.slice(R))+se,D=D.slice(0,R);break}}}S&&!g&&(D=e(D,1/0));var te=de.length+D.length+se.length,Z=te<_?new Array(_-te+1).join(h):"";switch(S&&g&&(D=e(Z+D,Z.length?_-se.length:1/0),Z=""),p){case"<":D=de+D+se+Z;break;case"=":D=de+Z+D+se;break;case"^":D=Z.slice(0,te=Z.length>>1)+de+D+se+Z.slice(te);break;default:D=Z+de+D+se;break}return r(D)}return re.toString=function(){return d+""},re}function u(d,h){var p=c((d=qf(d),d.type="f",d)),m=Math.max(-8,Math.min(8,Math.floor(Ul(h)/3)))*3,y=Math.pow(10,-m),g=Lw[8+m/3];return function(_){return p(y*_)+g}}return{format:c,formatPrefix:u}}var Vd,Sv,FA;UY({thousands:",",grouping:[3],currency:["$",""]});function UY(i){return Vd=zY(i),Sv=Vd.format,FA=Vd.formatPrefix,Vd}function $Y(i){return Math.max(0,-Ul(Math.abs(i)))}function jY(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ul(e)/3)))*3-Ul(Math.abs(i)))}function HY(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,Ul(e)-Ul(i))+1}function VY(i,e,t,n){var s=yg(i,e,t),r;switch(n=qf(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(r=jY(s,o))&&(n.precision=r),FA(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(r=HY(s,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=r-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(r=$Y(s))&&(n.precision=r-(n.type==="%")*2);break}}return Sv(n)}function zp(i){var e=i.domain;return i.ticks=function(t){var n=e();return HL(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var s=e();return VY(s[0],s[s.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),s=0,r=n.length-1,o=n[s],a=n[r],l,c,u=10;for(a<o&&(c=o,o=a,a=c,c=s,s=r,r=c);u-- >0;){if(c=VL(o,a,t),c===l)return n[s]=o,n[r]=a,e(n);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return i},i}function zu(){var i=BA();return i.copy=function(){return xv(i,zu())},sd.apply(i,arguments),zp(i)}function GY(i,e){i=i.slice();var t=0,n=i.length-1,s=i[t],r=i[n],o;return r<s&&(o=t,t=n,n=o,o=s,s=r,r=o),i[t]=e.floor(s),i[n]=e.ceil(r),i}function Rw(i){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/i))}}function Pw(i){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*i}}function WY(i){var e=1,t=i(Rw(e),Pw(e));return t.constant=function(n){return arguments.length?i(Rw(e=+n),Pw(e)):e},zp(t)}function Up(){var i=WY(MA());return i.copy=function(){return xv(i,Up()).constant(i.constant())},sd.apply(i,arguments)}function zA(){var i=0,e=1,t=1,n=[.5],s=[0,1],r;function o(l){return l!=null&&l<=l?s[OS(n,l,0,t)]:r}function a(){var l=-1;for(n=new Array(t);++l<t;)n[l]=((l+1)*e-(l-t)*i)/(t+1);return o}return o.domain=function(l){return arguments.length?([i,e]=l,i=+i,e=+e,a()):[i,e]},o.range=function(l){return arguments.length?(t=(s=Array.from(l)).length-1,a()):s.slice()},o.invertExtent=function(l){var c=s.indexOf(l);return c<0?[NaN,NaN]:c<1?[i,n[0]]:c>=t?[n[t-1],e]:[n[c-1],n[c]]},o.unknown=function(l){return arguments.length&&(r=l),o},o.thresholds=function(){return n.slice()},o.copy=function(){return zA().domain([i,e]).range(s).unknown(r)},sd.apply(zp(o),arguments)}const qm=new Date,Xm=new Date;function Ci(i,e,t,n){function s(r){return i(r=arguments.length===0?new Date:new Date(+r)),r}return s.floor=r=>(i(r=new Date(+r)),r),s.ceil=r=>(i(r=new Date(r-1)),e(r,1),i(r),r),s.round=r=>{const o=s(r),a=s.ceil(r);return r-o<a-r?o:a},s.offset=(r,o)=>(e(r=new Date(+r),o==null?1:Math.floor(o)),r),s.range=(r,o,a)=>{const l=[];if(r=s.ceil(r),a=a==null?1:Math.floor(a),!(r<o)||!(a>0))return l;let c;do l.push(c=new Date(+r)),e(r,a),i(r);while(c<r&&r<o);return l},s.filter=r=>Ci(o=>{if(o>=o)for(;i(o),!r(o);)o.setTime(o-1)},(o,a)=>{if(o>=o)if(a<0)for(;++a<=0;)for(;e(o,-1),!r(o););else for(;--a>=0;)for(;e(o,1),!r(o););}),t&&(s.count=(r,o)=>(qm.setTime(+r),Xm.setTime(+o),i(qm),i(Xm),Math.floor(t(qm,Xm))),s.every=r=>(r=Math.floor(r),!isFinite(r)||!(r>0)?null:r>1?s.filter(n?o=>n(o)%r===0:o=>s.count(0,o)%r===0):s)),s}const Xf=Ci(()=>{},(i,e)=>{i.setTime(+i+e)},(i,e)=>e-i);Xf.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?Ci(e=>{e.setTime(Math.floor(e/i)*i)},(e,t)=>{e.setTime(+e+t*i)},(e,t)=>(t-e)/i):Xf);Xf.range;const ro=1e3,ps=ro*60,oo=ps*60,po=oo*24,Ev=po*7,Nw=po*30,Km=po*365,ol=Ci(i=>{i.setTime(i-i.getMilliseconds())},(i,e)=>{i.setTime(+i+e*ro)},(i,e)=>(e-i)/ro,i=>i.getUTCSeconds());ol.range;const Cv=Ci(i=>{i.setTime(i-i.getMilliseconds()-i.getSeconds()*ro)},(i,e)=>{i.setTime(+i+e*ps)},(i,e)=>(e-i)/ps,i=>i.getMinutes());Cv.range;const YY=Ci(i=>{i.setUTCSeconds(0,0)},(i,e)=>{i.setTime(+i+e*ps)},(i,e)=>(e-i)/ps,i=>i.getUTCMinutes());YY.range;const Tv=Ci(i=>{i.setTime(i-i.getMilliseconds()-i.getSeconds()*ro-i.getMinutes()*ps)},(i,e)=>{i.setTime(+i+e*oo)},(i,e)=>(e-i)/oo,i=>i.getHours());Tv.range;const qY=Ci(i=>{i.setUTCMinutes(0,0,0)},(i,e)=>{i.setTime(+i+e*oo)},(i,e)=>(e-i)/oo,i=>i.getUTCHours());qY.range;const rd=Ci(i=>i.setHours(0,0,0,0),(i,e)=>i.setDate(i.getDate()+e),(i,e)=>(e-i-(e.getTimezoneOffset()-i.getTimezoneOffset())*ps)/po,i=>i.getDate()-1);rd.range;const kv=Ci(i=>{i.setUTCHours(0,0,0,0)},(i,e)=>{i.setUTCDate(i.getUTCDate()+e)},(i,e)=>(e-i)/po,i=>i.getUTCDate()-1);kv.range;const XY=Ci(i=>{i.setUTCHours(0,0,0,0)},(i,e)=>{i.setUTCDate(i.getUTCDate()+e)},(i,e)=>(e-i)/po,i=>Math.floor(i/po));XY.range;function Aa(i){return Ci(e=>{e.setDate(e.getDate()-(e.getDay()+7-i)%7),e.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*ps)/Ev)}const $p=Aa(0),Kf=Aa(1),KY=Aa(2),ZY=Aa(3),$l=Aa(4),QY=Aa(5),JY=Aa(6);$p.range;Kf.range;KY.range;ZY.range;$l.range;QY.range;JY.range;function Ia(i){return Ci(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-i)%7),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/Ev)}const UA=Ia(0),Zf=Ia(1),eq=Ia(2),tq=Ia(3),jl=Ia(4),iq=Ia(5),nq=Ia(6);UA.range;Zf.range;eq.range;tq.range;jl.range;iq.range;nq.range;const Av=Ci(i=>{i.setDate(1),i.setHours(0,0,0,0)},(i,e)=>{i.setMonth(i.getMonth()+e)},(i,e)=>e.getMonth()-i.getMonth()+(e.getFullYear()-i.getFullYear())*12,i=>i.getMonth());Av.range;const sq=Ci(i=>{i.setUTCDate(1),i.setUTCHours(0,0,0,0)},(i,e)=>{i.setUTCMonth(i.getUTCMonth()+e)},(i,e)=>e.getUTCMonth()-i.getUTCMonth()+(e.getUTCFullYear()-i.getUTCFullYear())*12,i=>i.getUTCMonth());sq.range;const mo=Ci(i=>{i.setMonth(0,1),i.setHours(0,0,0,0)},(i,e)=>{i.setFullYear(i.getFullYear()+e)},(i,e)=>e.getFullYear()-i.getFullYear(),i=>i.getFullYear());mo.every=i=>!isFinite(i=Math.floor(i))||!(i>0)?null:Ci(e=>{e.setFullYear(Math.floor(e.getFullYear()/i)*i),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t*i)});mo.range;const Ea=Ci(i=>{i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0)},(i,e)=>{i.setUTCFullYear(i.getUTCFullYear()+e)},(i,e)=>e.getUTCFullYear()-i.getUTCFullYear(),i=>i.getUTCFullYear());Ea.every=i=>!isFinite(i=Math.floor(i))||!(i>0)?null:Ci(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/i)*i),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t*i)});Ea.range;function rq(i,e,t,n,s,r){const o=[[ol,1,ro],[ol,5,5*ro],[ol,15,15*ro],[ol,30,30*ro],[r,1,ps],[r,5,5*ps],[r,15,15*ps],[r,30,30*ps],[s,1,oo],[s,3,3*oo],[s,6,6*oo],[s,12,12*oo],[n,1,po],[n,2,2*po],[t,1,Ev],[e,1,Nw],[e,3,3*Nw],[i,1,Km]];function a(c,u,d){const h=u<c;h&&([c,u]=[u,c]);const p=d&&typeof d.range=="function"?d:l(c,u,d),m=p?p.range(c,+u+1):[];return h?m.reverse():m}function l(c,u,d){const h=Math.abs(u-c)/d,p=ny(([,,g])=>g).right(o,h);if(p===o.length)return i.every(yg(c/Km,u/Km,d));if(p===0)return Xf.every(Math.max(yg(c,u,d),1));const[m,y]=o[h/o[p-1][2]<o[p][2]/h?p-1:p];return m.every(y)}return[a,l]}const[oq,aq]=rq(mo,Av,$p,rd,Tv,Cv);function Zm(i){if(0<=i.y&&i.y<100){var e=new Date(-1,i.m,i.d,i.H,i.M,i.S,i.L);return e.setFullYear(i.y),e}return new Date(i.y,i.m,i.d,i.H,i.M,i.S,i.L)}function Qm(i){if(0<=i.y&&i.y<100){var e=new Date(Date.UTC(-1,i.m,i.d,i.H,i.M,i.S,i.L));return e.setUTCFullYear(i.y),e}return new Date(Date.UTC(i.y,i.m,i.d,i.H,i.M,i.S,i.L))}function yc(i,e,t){return{y:i,m:e,d:t,H:0,M:0,S:0,L:0}}function lq(i){var e=i.dateTime,t=i.date,n=i.time,s=i.periods,r=i.days,o=i.shortDays,a=i.months,l=i.shortMonths,c=bc(s),u=vc(s),d=bc(r),h=vc(r),p=bc(o),m=vc(o),y=bc(a),g=vc(a),_=bc(l),S=vc(l),E={a:q,A:te,b:Z,B:ae,c:null,d:zw,e:zw,f:Rq,g:$q,G:Hq,H:Aq,I:Iq,j:Lq,L:$A,m:Pq,M:Nq,p:J,q:Se,Q:jw,s:Hw,S:Dq,u:Mq,U:Bq,V:Oq,w:Fq,W:zq,x:null,X:null,y:Uq,Y:jq,Z:Vq,"%":$w},x={a:xe,A:et,b:he,B:yt,c:null,d:Uw,e:Uw,f:qq,g:sX,G:oX,H:Gq,I:Wq,j:Yq,L:HA,m:Xq,M:Kq,p:Xe,q:dt,Q:jw,s:Hw,S:Zq,u:Qq,U:Jq,V:eX,w:tX,W:iX,x:null,X:null,y:nX,Y:rX,Z:aX,"%":$w},T={a:re,A:D,b:de,B:se,c:R,d:Ow,e:Ow,f:Eq,g:Bw,G:Mw,H:Fw,I:Fw,j:vq,L:Sq,m:bq,M:xq,p:Q,q:yq,Q:Tq,s:kq,S:wq,u:fq,U:pq,V:mq,w:hq,W:gq,x:ee,X:F,y:Bw,Y:Mw,Z:_q,"%":Cq};E.x=I(t,E),E.X=I(n,E),E.c=I(e,E),x.x=I(t,x),x.X=I(n,x),x.c=I(e,x);function I(ie,Ce){return function(Pe){var X=[],We=-1,He=0,bt=ie.length,Vt,pe,it;for(Pe instanceof Date||(Pe=new Date(+Pe));++We<bt;)ie.charCodeAt(We)===37&&(X.push(ie.slice(He,We)),(pe=Dw[Vt=ie.charAt(++We)])!=null?Vt=ie.charAt(++We):pe=Vt==="e"?" ":"0",(it=Ce[Vt])&&(Vt=it(Pe,pe)),X.push(Vt),He=We+1);return X.push(ie.slice(He,We)),X.join("")}}function O(ie,Ce){return function(Pe){var X=yc(1900,void 0,1),We=H(X,ie,Pe+="",0),He,bt;if(We!=Pe.length)return null;if("Q"in X)return new Date(X.Q);if("s"in X)return new Date(X.s*1e3+("L"in X?X.L:0));if(Ce&&!("Z"in X)&&(X.Z=0),"p"in X&&(X.H=X.H%12+X.p*12),X.m===void 0&&(X.m="q"in X?X.q:0),"V"in X){if(X.V<1||X.V>53)return null;"w"in X||(X.w=1),"Z"in X?(He=Qm(yc(X.y,0,1)),bt=He.getUTCDay(),He=bt>4||bt===0?Zf.ceil(He):Zf(He),He=kv.offset(He,(X.V-1)*7),X.y=He.getUTCFullYear(),X.m=He.getUTCMonth(),X.d=He.getUTCDate()+(X.w+6)%7):(He=Zm(yc(X.y,0,1)),bt=He.getDay(),He=bt>4||bt===0?Kf.ceil(He):Kf(He),He=rd.offset(He,(X.V-1)*7),X.y=He.getFullYear(),X.m=He.getMonth(),X.d=He.getDate()+(X.w+6)%7)}else("W"in X||"U"in X)&&("w"in X||(X.w="u"in X?X.u%7:"W"in X?1:0),bt="Z"in X?Qm(yc(X.y,0,1)).getUTCDay():Zm(yc(X.y,0,1)).getDay(),X.m=0,X.d="W"in X?(X.w+6)%7+X.W*7-(bt+5)%7:X.w+X.U*7-(bt+6)%7);return"Z"in X?(X.H+=X.Z/100|0,X.M+=X.Z%100,Qm(X)):Zm(X)}}function H(ie,Ce,Pe,X){for(var We=0,He=Ce.length,bt=Pe.length,Vt,pe;We<He;){if(X>=bt)return-1;if(Vt=Ce.charCodeAt(We++),Vt===37){if(Vt=Ce.charAt(We++),pe=T[Vt in Dw?Ce.charAt(We++):Vt],!pe||(X=pe(ie,Pe,X))<0)return-1}else if(Vt!=Pe.charCodeAt(X++))return-1}return X}function Q(ie,Ce,Pe){var X=c.exec(Ce.slice(Pe));return X?(ie.p=u.get(X[0].toLowerCase()),Pe+X[0].length):-1}function re(ie,Ce,Pe){var X=p.exec(Ce.slice(Pe));return X?(ie.w=m.get(X[0].toLowerCase()),Pe+X[0].length):-1}function D(ie,Ce,Pe){var X=d.exec(Ce.slice(Pe));return X?(ie.w=h.get(X[0].toLowerCase()),Pe+X[0].length):-1}function de(ie,Ce,Pe){var X=_.exec(Ce.slice(Pe));return X?(ie.m=S.get(X[0].toLowerCase()),Pe+X[0].length):-1}function se(ie,Ce,Pe){var X=y.exec(Ce.slice(Pe));return X?(ie.m=g.get(X[0].toLowerCase()),Pe+X[0].length):-1}function R(ie,Ce,Pe){return H(ie,e,Ce,Pe)}function ee(ie,Ce,Pe){return H(ie,t,Ce,Pe)}function F(ie,Ce,Pe){return H(ie,n,Ce,Pe)}function q(ie){return o[ie.getDay()]}function te(ie){return r[ie.getDay()]}function Z(ie){return l[ie.getMonth()]}function ae(ie){return a[ie.getMonth()]}function J(ie){return s[+(ie.getHours()>=12)]}function Se(ie){return 1+~~(ie.getMonth()/3)}function xe(ie){return o[ie.getUTCDay()]}function et(ie){return r[ie.getUTCDay()]}function he(ie){return l[ie.getUTCMonth()]}function yt(ie){return a[ie.getUTCMonth()]}function Xe(ie){return s[+(ie.getUTCHours()>=12)]}function dt(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var Ce=I(ie+="",E);return Ce.toString=function(){return ie},Ce},parse:function(ie){var Ce=O(ie+="",!1);return Ce.toString=function(){return ie},Ce},utcFormat:function(ie){var Ce=I(ie+="",x);return Ce.toString=function(){return ie},Ce},utcParse:function(ie){var Ce=O(ie+="",!0);return Ce.toString=function(){return ie},Ce}}}var Dw={"-":"",_:" ",0:"0"},Ri=/^\s*\d+/,cq=/^%/,uq=/[\\^$*+?|[\]().{}]/g;function St(i,e,t){var n=i<0?"-":"",s=(n?-i:i)+"",r=s.length;return n+(r<t?new Array(t-r+1).join(e)+s:s)}function dq(i){return i.replace(uq,"\\$&")}function bc(i){return new RegExp("^(?:"+i.map(dq).join("|")+")","i")}function vc(i){return new Map(i.map((e,t)=>[e.toLowerCase(),t]))}function hq(i,e,t){var n=Ri.exec(e.slice(t,t+1));return n?(i.w=+n[0],t+n[0].length):-1}function fq(i,e,t){var n=Ri.exec(e.slice(t,t+1));return n?(i.u=+n[0],t+n[0].length):-1}function pq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.U=+n[0],t+n[0].length):-1}function mq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.V=+n[0],t+n[0].length):-1}function gq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.W=+n[0],t+n[0].length):-1}function Mw(i,e,t){var n=Ri.exec(e.slice(t,t+4));return n?(i.y=+n[0],t+n[0].length):-1}function Bw(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.y=+n[0]+(+n[0]>68?1900:2e3),t+n[0].length):-1}function _q(i,e,t){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(t,t+6));return n?(i.Z=n[1]?0:-(n[2]+(n[3]||"00")),t+n[0].length):-1}function yq(i,e,t){var n=Ri.exec(e.slice(t,t+1));return n?(i.q=n[0]*3-3,t+n[0].length):-1}function bq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.m=n[0]-1,t+n[0].length):-1}function Ow(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.d=+n[0],t+n[0].length):-1}function vq(i,e,t){var n=Ri.exec(e.slice(t,t+3));return n?(i.m=0,i.d=+n[0],t+n[0].length):-1}function Fw(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.H=+n[0],t+n[0].length):-1}function xq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.M=+n[0],t+n[0].length):-1}function wq(i,e,t){var n=Ri.exec(e.slice(t,t+2));return n?(i.S=+n[0],t+n[0].length):-1}function Sq(i,e,t){var n=Ri.exec(e.slice(t,t+3));return n?(i.L=+n[0],t+n[0].length):-1}function Eq(i,e,t){var n=Ri.exec(e.slice(t,t+6));return n?(i.L=Math.floor(n[0]/1e3),t+n[0].length):-1}function Cq(i,e,t){var n=cq.exec(e.slice(t,t+1));return n?t+n[0].length:-1}function Tq(i,e,t){var n=Ri.exec(e.slice(t));return n?(i.Q=+n[0],t+n[0].length):-1}function kq(i,e,t){var n=Ri.exec(e.slice(t));return n?(i.s=+n[0],t+n[0].length):-1}function zw(i,e){return St(i.getDate(),e,2)}function Aq(i,e){return St(i.getHours(),e,2)}function Iq(i,e){return St(i.getHours()%12||12,e,2)}function Lq(i,e){return St(1+rd.count(mo(i),i),e,3)}function $A(i,e){return St(i.getMilliseconds(),e,3)}function Rq(i,e){return $A(i,e)+"000"}function Pq(i,e){return St(i.getMonth()+1,e,2)}function Nq(i,e){return St(i.getMinutes(),e,2)}function Dq(i,e){return St(i.getSeconds(),e,2)}function Mq(i){var e=i.getDay();return e===0?7:e}function Bq(i,e){return St($p.count(mo(i)-1,i),e,2)}function jA(i){var e=i.getDay();return e>=4||e===0?$l(i):$l.ceil(i)}function Oq(i,e){return i=jA(i),St($l.count(mo(i),i)+(mo(i).getDay()===4),e,2)}function Fq(i){return i.getDay()}function zq(i,e){return St(Kf.count(mo(i)-1,i),e,2)}function Uq(i,e){return St(i.getFullYear()%100,e,2)}function $q(i,e){return i=jA(i),St(i.getFullYear()%100,e,2)}function jq(i,e){return St(i.getFullYear()%1e4,e,4)}function Hq(i,e){var t=i.getDay();return i=t>=4||t===0?$l(i):$l.ceil(i),St(i.getFullYear()%1e4,e,4)}function Vq(i){var e=i.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+St(e/60|0,"0",2)+St(e%60,"0",2)}function Uw(i,e){return St(i.getUTCDate(),e,2)}function Gq(i,e){return St(i.getUTCHours(),e,2)}function Wq(i,e){return St(i.getUTCHours()%12||12,e,2)}function Yq(i,e){return St(1+kv.count(Ea(i),i),e,3)}function HA(i,e){return St(i.getUTCMilliseconds(),e,3)}function qq(i,e){return HA(i,e)+"000"}function Xq(i,e){return St(i.getUTCMonth()+1,e,2)}function Kq(i,e){return St(i.getUTCMinutes(),e,2)}function Zq(i,e){return St(i.getUTCSeconds(),e,2)}function Qq(i){var e=i.getUTCDay();return e===0?7:e}function Jq(i,e){return St(UA.count(Ea(i)-1,i),e,2)}function VA(i){var e=i.getUTCDay();return e>=4||e===0?jl(i):jl.ceil(i)}function eX(i,e){return i=VA(i),St(jl.count(Ea(i),i)+(Ea(i).getUTCDay()===4),e,2)}function tX(i){return i.getUTCDay()}function iX(i,e){return St(Zf.count(Ea(i)-1,i),e,2)}function nX(i,e){return St(i.getUTCFullYear()%100,e,2)}function sX(i,e){return i=VA(i),St(i.getUTCFullYear()%100,e,2)}function rX(i,e){return St(i.getUTCFullYear()%1e4,e,4)}function oX(i,e){var t=i.getUTCDay();return i=t>=4||t===0?jl(i):jl.ceil(i),St(i.getUTCFullYear()%1e4,e,4)}function aX(){return"+0000"}function $w(){return"%"}function jw(i){return+i}function Hw(i){return Math.floor(+i/1e3)}var Ua,Nr;lX({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lX(i){return Ua=lq(i),Nr=Ua.format,Ua.parse,Ua.utcFormat,Ua.utcParse,Ua}function cX(i){return new Date(i)}function uX(i){return i instanceof Date?+i:+new Date(+i)}function GA(i,e,t,n,s,r,o,a,l,c){var u=BA(),d=u.invert,h=u.domain,p=c(".%L"),m=c(":%S"),y=c("%I:%M"),g=c("%I %p"),_=c("%a %d"),S=c("%b %d"),E=c("%B"),x=c("%Y");function T(I){return(l(I)<I?p:a(I)<I?m:o(I)<I?y:r(I)<I?g:n(I)<I?s(I)<I?_:S:t(I)<I?E:x)(I)}return u.invert=function(I){return new Date(d(I))},u.domain=function(I){return arguments.length?h(Array.from(I,uX)):h().map(cX)},u.ticks=function(I){var O=h();return i(O[0],O[O.length-1],I??10)},u.tickFormat=function(I,O){return O==null?T:c(O)},u.nice=function(I){var O=h();return(!I||typeof I.range!="function")&&(I=e(O[0],O[O.length-1],I??10)),I?h(GY(O,I)):u},u.copy=function(){return xv(u,GA(i,e,t,n,s,r,o,a,l,c))},u}function dX(){return sd.apply(GA(oq,aq,mo,Av,$p,rd,Tv,Cv,ol,Nr).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function hX(){var i=0,e=1,t,n,s,r,o=zo,a=!1,l;function c(d){return d==null||isNaN(d=+d)?l:o(s===0?.5:(d=(r(d)-t)*s,a?Math.max(0,Math.min(1,d)):d))}c.domain=function(d){return arguments.length?([i,e]=d,t=r(i=+i),n=r(e=+e),s=t===n?0:1/(n-t),c):[i,e]},c.clamp=function(d){return arguments.length?(a=!!d,c):a},c.interpolator=function(d){return arguments.length?(o=d,c):o};function u(d){return function(h){var p,m;return arguments.length?([p,m]=h,o=d(p,m),c):[o(0),o(1)]}}return c.range=u(ec),c.rangeRound=u(gA),c.unknown=function(d){return arguments.length?(l=d,c):l},function(d){return r=d,t=d(i),n=d(e),s=t===n?0:1/(n-t),c}}function fX(i,e){return e.domain(i.domain()).interpolator(i.interpolator()).clamp(i.clamp()).unknown(i.unknown())}function WA(){var i=zp(hX()(zo));return i.copy=function(){return fX(i,WA())},kY.apply(i,arguments)}const pX='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="currentColor" d="M48 64C21.5 64 0 85.5 0 112V400c0 26.5 21.5 48 48 48H80c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48H48zm192 0c-26.5 0-48 21.5-48 48V400c0 26.5 21.5 48 48 48h32c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48H240z"/></svg>',mX='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"/></svg>',gX={top:1,left:5,bottom:1,right:5},Gd={allowSelection:!0,showAnimationControls:!1,animationSpeed:50,padding:gX,axisTickHeight:16,selectionRadius:3,selectionPadding:8,barCount:250,barRadius:1,barPadding:.1,barTopMargin:20,minBarHeight:1,dataStep:void 0,tickStep:void 0,stickySelection:!0,formatter:void 0,onBrush:void 0,onBarHover:void 0,onAnimationPlay:void 0,onAnimationPause:void 0,onAnimationTick:void 0,noDataMessage:"No timeline data",loadingMessage:"Data loading..."},_X=i=>typeof i=="function",yX=i=>Array.isArray(i),bX=i=>i instanceof Object,Qf=i=>i.constructor.name!=="Function"&&i.constructor.name!=="Object",Vw=i=>bX(i)&&!yX(i)&&!_X(i)&&!Qf(i),Jf=(i,e=new Map)=>{if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof Array){const t=[];e.set(i,t);for(const n of i)t.push(e.has(n)?e.get(n):Jf(n,e));return i}if(Qf(i))return i;if(i instanceof Object){const t={};e.set(i,t);const n=i;return Object.keys(i).reduce((s,r)=>(s[r]=e.has(n[r])?e.get(n[r]):Jf(n[r],e),s),t),t}return i},Yt=(i,e,t=new Map)=>{const n=Qf(i)?i:Jf(i);return i===e?i:t.has(e)?t.get(e):(t.set(e,n),Object.keys(e).forEach(s=>{Vw(i[s])&&Vw(e[s])?n[s]=Yt(i[s],e[s],t):Qf(e)?n[s]=e:n[s]=Jf(e[s])}),n)},vX=i=>{const e=getComputedStyle(i);let t=i.clientWidth,n=i.clientHeight;return n-=parseFloat(e.paddingTop)+parseFloat(e.paddingBottom),t-=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),{height:n,width:t}},Hs=(i,e="",t,n)=>{if(!i)return"0";let s,r;t?(s=i,r=t):Math.abs(i)>=7e11?(s=i/1e12,r="T"):Math.abs(i)>=2e8?(s=i/1e9,r="B"):Math.abs(i)>=1e6?(s=i/1e6,r="M"):Math.abs(i)>=1e3?(s=i/1e3,r="K"):(s=i,r="");const o=Math.abs(s);n===void 0&&(Number.isInteger(o)?n=0:o<.1?n=3:o<1?n=2:o<10?n=1:n=0);let a=o>0&&o<.5/Math.pow(10,n);if(a){let c=n;for(;a&&c<8;)c++,a=o<.5/Math.pow(10,c);if(!a)n=c;else return`~${e??""}0`}let l=i<0?"-":"";return e&&(l+=e),`${l}${Sv(`.${n}~f`)(o)}${r}`};function xX(i,e,t=e,n=[]){if(!i.length||!e.length||!t.length)return new Array(e.length).fill(0);const s=new Array(e.length).fill(0),r=new Map;for(const[l,c]of t){r.has(l)||r.set(l,new Map);for(let u=0;u<e.length;u++){const[d,h]=e[u];if(l===d&&c===h){r.get(l).set(c,u);break}}}const o=n.length>0?n[n.length-1]:e[e.length-1][1],a=[...t].sort((l,c)=>l[0]-c[0]);for(const l of i){let c=0,u=a.length-1;for(;c<=u;){const d=Math.floor((c+u)/2),[h,p]=a[d],m=p===o;if(l>=h&&(m?l<=p:l<p)){const y=r.get(h);if(y){const g=y.get(p);g!==void 0&&s[g]++}break}else l<h?u=d-1:c=d+1}}return s}function YA(i,e,t){if(!i)return[];const[n,s]=i,r=Math.abs(+s-+n),o=Number.isFinite(r)&&e>1?r/(e-1):1,a=t??o;if(a===0)return[];const l=Array.from({length:e},(c,u)=>+n+u*a);return l[e-1]=+s,l}function ep(i,e,t,n=!1,s=!0){const r=Array.from({length:e.length-1},(l,c)=>[e[c],e[c+1]]),o=t&&n?r.filter(([l,c])=>{const[u,d]=t;return l<+u?!1:c>=+d?c>+u&&l<+d:!0}):r,a=xX(i,r,o,e);return r.map(([l,c],u)=>({rangeStart:s?l:new Date(l),rangeEnd:s?c:new Date(c),count:a[u]??0}))}const wX=Nr(".%L"),SX=Nr(":%S"),EX=Nr("%I:%M"),CX=Nr("%I %p"),TX=Nr("%a %d"),kX=Nr("%d %b"),AX=Nr("%b %Y"),IX=Nr("%Y"),LX=1,qA=1e3*LX,XA=60*qA,KA=60*XA,jp=24*KA,RX=7*jp,PX=30*jp,NX=365*jp,Gw=(i,e=null,t=!1)=>{if(t)return Hs(i);const n=new Date(i),s=e!==null?e:Date.now()-n.getTime();return(s<qA?wX:s<XA?SX:s<KA?EX:s<jp?CX:s<PX?s<RX?TX:kX:s>NX*20?IX:AX)(n)},DX="style_module_displayState__6ae19b84",MX={displayState:DX};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var BX=Object.defineProperty,OX=(i,e,t)=>e in i?BX(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Wd=(i,e,t)=>OX(i,typeof e!="symbol"?e+"":e,t);const Yd={noDataMessage:"No data",loadingMessage:"Data loading...",disableStateMessages:!1,allowPointerEvents:!1};let Li=class{constructor(e,t){Wd(this,"_displayStateDiv"),Wd(this,"_displayStateTimeout",null),Wd(this,"_displayStateConfig"),Wd(this,"_displayStateContainerNode"),this._displayStateContainerNode=e,this._displayStateConfig={...Yd,...t},getComputedStyle(e).position==="static"&&(e.style.position="relative"),this._displayStateDiv=this._createDisplayStateElement(),this._displayStateContainerNode.appendChild(this._displayStateDiv)}static extractConfig(e,t){return{noDataMessage:e.noDataMessage??t.noDataMessage,loadingMessage:e.loadingMessage??t.loadingMessage,disableStateMessages:e.disableStateMessages??t.disableStateMessages,allowPointerEvents:e.allowPointerEvents??t.allowPointerEvents}}_createDisplayStateElement(){const e=document.createElement("div");return e.classList.add(MX.displayState),this._displayStateConfig.allowPointerEvents===!1&&(this._displayStateConfig.noDataMessage===!1?this._displayStateContainerNode.style.pointerEvents="none":this._displayStateContainerNode.style.pointerEvents=""),!this._displayStateConfig.disableStateMessages&&this._displayStateConfig.noDataMessage!==!1&&(e.textContent=typeof this._displayStateConfig.noDataMessage=="string"?this._displayStateConfig.noDataMessage:Yd.noDataMessage),e}setLoadingState(){!this._displayStateConfig.disableStateMessages&&this._displayStateConfig.loadingMessage!==!1?this._displayStateDiv.textContent=typeof this._displayStateConfig.loadingMessage=="string"?this._displayStateConfig.loadingMessage:Yd.loadingMessage:this._displayStateDiv.textContent=""}showState(e){this._resetDisplayStateTimeout(),this._displayStateConfig.disableStateMessages?this._displayStateDiv.textContent="":e?this._displayStateDiv.textContent=e:this._displayStateConfig.noDataMessage!==!1?this._displayStateDiv.textContent=typeof this._displayStateConfig.noDataMessage=="string"?this._displayStateConfig.noDataMessage:Yd.noDataMessage:this._displayStateDiv.textContent="",this._displayStateConfig.allowPointerEvents===!1&&(this._displayStateContainerNode.style.pointerEvents="none"),this._displayStateDiv.style.display!=="flex"&&(this._displayStateTimeout=setTimeout(()=>{this._displayStateDiv.style.display="flex"},150))}hideState(){this._resetDisplayStateTimeout(),this._displayStateDiv.style.display="none",this._displayStateContainerNode.style.pointerEvents=""}setDisplayStateConfig(e){this._displayStateConfig={...this._displayStateConfig,...e}}_resetDisplayStateTimeout(){this._displayStateTimeout&&(clearTimeout(this._displayStateTimeout),this._displayStateTimeout=null)}destroy(){var e,t;this._resetDisplayStateTimeout(),(t=(e=this._displayStateDiv)==null?void 0:e.parentNode)==null||t.removeChild(this._displayStateDiv)}};const FX="style_module_timeline__736434f7",zX="style_module_timelineSvg__b916ad04",UX="style_module_selection__ebee57f8",$X="style_module_axisTick__5865631d",jX="style_module_axisLine__992b502d",HX="style_module_bar__114fa79f",VX="style_module_axis__5ff3086c",GX="style_module_bars__097b45e0",WX="style_module_brush__39277182",YX="style_module_animationControl__ee52cd66",qX="style_module_hidden__a73fe81a",XX="style_module_disabled__eb988570",KX="style_module_highlightedBar__c2fc9bdc",ZX="style_module_playAnimation__c1180703",QX="style_module_pauseAnimation__d6cfd97b",mt={timeline:FX,timelineSvg:zX,selection:UX,axisTick:$X,axisLine:jX,bar:HX,axis:VX,bars:GX,brush:WX,animationControl:YX,hidden:qX,disabled:XX,highlightedBar:KX,playAnimation:ZX,pauseAnimation:QX};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var JX=Object.defineProperty,eK=(i,e,t)=>e in i?JX(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ve=(i,e,t)=>eK(i,typeof e!="symbol"?e+"":e,t);class tK extends Li{constructor(e,t){const n=Yt(Gd,t??{});super(e,Li.extractConfig(n,Gd)),Ve(this,"_config"),Ve(this,"_animationInterval"),Ve(this,"_isAnimationRunning",!1),Ve(this,"_svgParser",new DOMParser),Ve(this,"_svg"),Ve(this,"_animationControlDiv"),Ve(this,"_playButtonSvg"),Ve(this,"_pauseButtonSvg"),Ve(this,"_containerNode"),Ve(this,"_axisGroup"),Ve(this,"_barsGroup"),Ve(this,"_brushGroup"),Ve(this,"_highlightedBarsGroup"),Ve(this,"_resizeObserver"),Ve(this,"_height",0),Ve(this,"_width",0),Ve(this,"_timelineWidth",0),Ve(this,"_timelineHeight",0),Ve(this,"_barWidth",0),Ve(this,"_maxCount",0),Ve(this,"_barsData",[]),Ve(this,"_highlightedBarsData",[]),Ve(this,"_highlightedData"),Ve(this,"_timeData"),Ve(this,"_extent"),Ve(this,"_bandIntervals",[]),Ve(this,"_currentSelection"),Ve(this,"_currentSelectionInPixels"),Ve(this,"_isNumericTimeline",!1),Ve(this,"_firstRender",!0),Ve(this,"_yScale",Up()),Ve(this,"_timeScale",dX()),Ve(this,"_numScale",zu()),Ve(this,"_activeAxisScale",this._timeScale),Ve(this,"_timeAxis",z_(this._timeScale)),Ve(this,"_numAxis",z_(this._numScale)),Ve(this,"_brushInstance"),Ve(this,"_toggleAnimation",s=>{s.preventDefault(),this._isAnimationRunning?this.pauseAnimation():this.playAnimation()}),Ve(this,"_disableAnimation",()=>{var s,r;this.pauseAnimation(),(s=this._animationControlDiv)==null||s.removeEventListener("click",this._toggleAnimation),(r=this._animationControlDiv)==null||r.remove()}),Ve(this,"playAnimation",()=>{var s,r,o,a;clearInterval(this._animationInterval),this._currentSelectionInPixels&&(this._animationInterval=setInterval(this._animateSelection,this._config.animationSpeed??0),this._isAnimationRunning=!0,(r=(s=this._config).onAnimationPlay)==null||r.call(s,this._isAnimationRunning,this._currentSelection),(o=this._pauseButtonSvg)==null||o.classList.remove(mt.hidden),(a=this._playButtonSvg)==null||a.classList.add(mt.hidden))}),Ve(this,"pauseAnimation",()=>{var s,r,o,a;clearInterval(this._animationInterval),this._isAnimationRunning=!1,(r=(s=this._config).onAnimationPause)==null||r.call(s,this._isAnimationRunning,this._currentSelection),(o=this._pauseButtonSvg)==null||o.classList.add(mt.hidden),(a=this._playButtonSvg)==null||a.classList.remove(mt.hidden)}),Ve(this,"stopAnimation",()=>{var s,r;this.pauseAnimation(),this.setSelection(void 0),(r=(s=this._config).onBrush)==null||r.call(s,void 0)}),Ve(this,"_animateSelection",()=>{var s,r,o,a;const l=this._currentSelectionInPixels;l&&l[0]!==void 0&&l[1]!==void 0&&(this._setSelectionInPixels([l[0]+this._barWidth,l[1]+this._barWidth]),(r=(s=this._config).onAnimationTick)==null||r.call(s,this._currentSelection),(l[1]===((o=this._currentSelectionInPixels)==null?void 0:o[1])||((a=this._currentSelectionInPixels)==null?void 0:a[1])===void 0)&&this.stopAnimation())}),Ve(this,"destroy",()=>{super.destroy(),this._resizeObserver.disconnect(),this._containerNode.innerHTML="",clearInterval(this._animationInterval)}),this._config=n,this._containerNode=e,this._containerNode.classList.add(mt.timeline),this._animationControlDiv=document.createElement("div"),this._animationControlDiv.classList.add(mt.animationControl),this._containerNode.appendChild(this._animationControlDiv),this._initializeSVG(),this._initializeGroups(),this._initAnimationControls(),this._resizeObserver=new RA(()=>{this.resize()}),this._resizeObserver.observe(this._containerNode)}_initializeSVG(){this._svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._svg.classList.add(mt.timelineSvg),this._containerNode.appendChild(this._svg)}async _initAnimationControls(){await(async()=>{var e,t;if(!this._animationControlDiv.firstChild){const n=this._svgParser.parseFromString(mX,"image/svg+xml").firstChild,s=this._svgParser.parseFromString(pX,"image/svg+xml").firstChild;this._pauseButtonSvg=(e=this._animationControlDiv)==null?void 0:e.appendChild(s),this._playButtonSvg=(t=this._animationControlDiv)==null?void 0:t.appendChild(n)}})().then(()=>{var e,t,n,s,r;this._isAnimationRunning?((n=this._playButtonSvg)==null||n.classList.add(mt.playAnimation,mt.hidden),(s=this._pauseButtonSvg)==null||s.classList.add(mt.pauseAnimation)):((e=this._playButtonSvg)==null||e.classList.add(mt.playAnimation),(t=this._pauseButtonSvg)==null||t.classList.add(mt.pauseAnimation,mt.hidden)),this._currentSelection||(r=this._animationControlDiv)==null||r.classList.add(mt.disabled),this._animationControlDiv.addEventListener("click",this._toggleAnimation)})}setLoadingState(){super.setLoadingState()}_initializeGroups(){this._axisGroup=Wt(this._svg).append("g").attr("class",mt.axis),this._barsGroup=Wt(this._svg).append("g").attr("class",mt.bars),this._highlightedBarsGroup=Wt(this._svg).append("g").attr("class",mt.bars),this._brushGroup=Wt(this._svg).append("g").attr("class",mt.brush)}get _barPadding(){return this._barWidth*(this._config.barPadding??0)}getCurrentSelection(){return this._currentSelection}getCurrentSelectionInPixels(){return this._currentSelectionInPixels}getBarWidth(){return this._barWidth-this._barPadding}getConfig(){return this._config}getIsAnimationRunning(){return this._isAnimationRunning}setConfig(e){var t,n,s,r;const o=JSON.parse(JSON.stringify(this._config));this._config=Yt(Gd,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,Gd)),o.formatter!==this._config.formatter&&this._checkFormatter(),(t=this._config)!=null&&t.showAnimationControls?(n=this._animationControlDiv)!=null&&n.isConnected||this._initAnimationControls():this._animationControlDiv&&this._disableAnimation(),this._config.allowSelection||this._disableBrush(),(((s=this._config)==null?void 0:s.dataStep)!==o.dataStep||((r=this._config)==null?void 0:r.barCount)!==o.barCount)&&(this._updateTimelineData(this._timeData),this._updateTimelineData(this._highlightedData,!0)),this.resize()}_checkFormatter(){this._config.formatter?(this._timeAxis.tickFormat(e=>this._config.formatter(e)),this._numAxis.tickFormat(e=>this._config.formatter(e))):this._extent&&(this._timeAxis.tickFormat(e=>Gw(e,+this._extent[1]-+this._extent[0],this._isNumericTimeline)),this._numAxis.tickFormat(e=>Gw(e,+this._extent[1]-+this._extent[0],this._isNumericTimeline)))}_parseData(e){if(!(e!=null&&e.length))return[];const t=new Float64Array(e.length);let n=0;for(let s=0;s<e.length;s++){const r=e[s];let o;r instanceof Date?o=r.getTime():o=r,o&&!isNaN(o)&&(t[n++]=this._normalizeTimeToMilliseconds(o))}return Array.from(t.subarray(0,n))}setTimeData(e,t){if(this._highlightedBarsData=[],this._timeData=[],this._currentSelection=void 0,t&&t[1]<=t[0])return;if(this._brushCurrentSelection(),e&&e.length>1){const o=e[0],a=o instanceof Date&&!isNaN(o.getTime()),l=typeof o=="number"&&new Date(o).getFullYear()>1970;this._isNumericTimeline=!a&&!l}const n=this._parseData(e),s=t||Rn(n),r=s[0]<s[1]&&n.length>1;Wt(this._animationControlDiv).style("display",r?"flex":"none"),r?(this.hideState(),this._timeData=n,this._extent=s,this._firstRender=!0):(this.showState("Empty or invalid timeline data"),this.render()),this._updateTimelineData(this._timeData),this._updateScales(),this.render()}setHighlightedData(e){this._highlightedBarsData=[],this._timeData&&(this._highlightedData=this._parseData(e),this._updateTimelineData(this._highlightedData,!0),this._updateBars(!0))}_updateTimelineData(e=[],t=!1){const n=t?"_highlightedBarsData":"_barsData";if(!this._extent){this[n]=[];return}if(!e.length){this[n]=ep([],this._bandIntervals,this._currentSelection,t);return}t||this._generateBandIntervals();const s=ep(e,this._bandIntervals,this._currentSelection,t);this[n]=s,t||(this._maxCount=Math.max(...s.map(r=>r.count)))}_generateBandIntervals(){if(!this._extent)return;const{barCount:e=30,dataStep:t}=this._config;this._bandIntervals=YA(this._extent,e,t)}setSelection(e,t=!1){var n,s,r,o,a,l,c;const u=this._currentSelection;if(e&&this._extent){const d=[Math.max(+this._extent[0],Math.min(+e[0],+this._extent[1])),Math.min(+this._extent[1],Math.max(+e[1],+this._extent[0]))];if(d[0]<d[1]){if(this._config.stickySelection){const h=d.map(this._activeAxisScale);this._mapSelection(h)}else this._currentSelection=d;(n=this._animationControlDiv)==null||n.classList.remove(mt.disabled)}else this._currentSelection=void 0,(s=this._animationControlDiv)==null||s.classList.add(mt.disabled)}else this._currentSelection=void 0,(r=this._animationControlDiv)==null||r.classList.add(mt.disabled);!t&&((u==null?void 0:u[0])!==((o=this._currentSelection)==null?void 0:o[0])||(u==null?void 0:u[1])!==((a=this._currentSelection)==null?void 0:a[1]))&&((c=(l=this._config).onBrush)==null||c.call(l,this._currentSelection,!0)),this._brushCurrentSelection()}_setSelectionInPixels(e){var t,n,s,r,o;if(e){const a=[Math.max(0,Math.min(e[0],this._timelineWidth)),Math.min(this._timelineWidth,Math.max(e[1],0))];a[0]<a[1]?(this._currentSelection=a.map(l=>this._activeAxisScale.invert(l)),(t=this._animationControlDiv)==null||t.classList.remove(mt.disabled)):(this._currentSelection=void 0,(n=this._animationControlDiv)==null||n.classList.add(mt.disabled))}else this._currentSelection=void 0,(s=this._animationControlDiv)==null||s.classList.add(mt.disabled);(o=(r=this._config).onBrush)==null||o.call(r,this._currentSelection),this._brushCurrentSelection()}updateDimensions(){var e,t,n,s;const{height:r,width:o}=vX(this._containerNode),{offsetWidth:a}=this._animationControlDiv;this._width=o,this._height=r,this._timelineWidth=this._width-(((e=this._config.padding)==null?void 0:e.left)??0)-(((t=this._config.padding)==null?void 0:t.right)??0)-a,this._timelineHeight=this._height-(((n=this._config.padding)==null?void 0:n.top)??0)-(((s=this._config.padding)==null?void 0:s.bottom)??0)}resize(){var e,t;this.updateDimensions();const n=((e=this._config.padding)==null?void 0:e.top)??0,s=((t=this._config.padding)==null?void 0:t.bottom)??0;this._timelineHeight>n+s&&(this._updateScales(),this._checkLastTickPosition(),this._currentSelection&&this.setSelection(this._currentSelection,!0),this.render())}render(){if(this._timelineHeight<=0||this._timelineWidth<=0){this._axisGroup.style("display","none");return}this._firstRender&&(this.updateDimensions(),this._updateScales(),this._checkLastTickPosition()),this._updateBrush(),this._updateBars(),this._updateBars(!0),this._updateAxis(),this._firstRender&&(this._firstRender=!1)}_updateAxis(){if(!this._timeData||!this._timeData.length){this._axisGroup.style("display","none");return}const{padding:e,axisTickHeight:t,selectionPadding:n}=this._config;this._axisGroup.style("transform",`translate(${((e==null?void 0:e.left)??0)+1}px, ${((e==null?void 0:e.top)??0)+(t??0)+1+(n??0)/2}px)`).call(this._isNumericTimeline?this._numAxis:this._timeAxis).call(s=>s.select(".domain").remove()),this._axisGroup.selectAll(".tick").select("text").attr("class",mt.axisTick).attr("y",0).attr("dy",-(t??0)).attr("dx","5px"),this._axisGroup.selectAll("line").attr("class",mt.axisLine).attr("y2",-(t??0))}_updateBrush(){if(!this._config.allowSelection||this._timelineHeight<0||this._timelineWidth<0){this._brushGroup.selectAll("*").remove();return}const{selectionPadding:e,padding:t,selectionRadius:n}=this._config,s=this._timelineHeight-(e??0),r=[[0,(e??0)/2],[this._timelineWidth,s+(e??0)/2]];this._brushInstance=PA().extent(r),this._brushInstance.on("end",({selection:o,sourceEvent:a})=>{var l,c,u,d,h,p;a&&(o?(this._config.stickySelection?this._mapSelection(o):this._currentSelection=o.map(m=>this._activeAxisScale.invert(m)),(l=this._animationControlDiv)==null||l.classList.remove(mt.disabled),(u=(c=this._config).onBrush)==null||u.call(c,this._currentSelection)):(this._currentSelection=void 0,(h=(d=this._config).onBrush)==null||h.call(d,void 0),(p=this._animationControlDiv)==null||p.classList.add(mt.disabled)),this._brushCurrentSelection())}),this._brushGroup.style("transform",`translate(${(t==null?void 0:t.left)??0}px, ${(t==null?void 0:t.top)??0}px)`).call(this._brushInstance).call(this._brushInstance.move,this._currentSelectionInPixels||null),this._brushGroup.select("rect.selection").classed(mt.selection,!0).attr("rx",n??0).attr("ry",n??0)}_updateBars(e=!1){const{padding:t,selectionPadding:n}=this._config,s=e?this._highlightedBarsGroup:this._barsGroup;if(!this._timeData||!this._timeData.length){s.selectAll("rect").remove();return}s.style("transform",`translate(${(t==null?void 0:t.left)??0}px, ${((t==null?void 0:t.top)??0)-(n??0)/2}px)`);const r=e?.5:1,o=this._createBars(s,e);!e&&this._config.onBarHover&&o.on("mouseover",a=>{var l,c;return(c=(l=this._config).onBarHover)==null?void 0:c.call(l,a)}),this._animateBars(o,e,r)}_createBars(e,t){return!this._activeAxisScale||!this._yScale||!this._barsData.length?(e.selectAll("rect").remove(),e.selectAll("rect")):e.selectAll(`.${t?mt.highlightedBar:mt.bar}`).data(t?this._highlightedBarsData:this._barsData).join("rect").attr("class",t?mt.highlightedBar:mt.bar).attr("x",n=>this._activeAxisScale(n.rangeStart)+this._barPadding/2).attr("width",this.getBarWidth()).attr("rx",this._config.barRadius??0).attr("ry",this._config.barRadius??0).attr("y",-this._timelineHeight)}_animateBars(e,t,n){e.transition().duration(this._isAnimationRunning?0:300).attr("height",s=>t?s.count===0?0:this._yScale(s.count):this._yScale(s.count)).style("opacity",s=>this._yScale(s.count)===(this._config.minBarHeight??0)?.4:n)}_updateScales(){if(!this._extent||!this._barsData.length||this._timelineHeight<0||this._timelineWidth<0){this._axisGroup.style("display","none");return}this._checkFormatter(),this._axisGroup.style("display","inherit");const e=this._barsData[this._barsData.length-1],t=Math.floor(this._timelineWidth/100),n=this._barsData.map(p=>p.rangeStart);let s;if(n.length>t){const p=Math.ceil(n.length/t);s=n.filter((m,y)=>y%p===0)}else s=n;(this._isNumericTimeline?this._numAxis:this._timeAxis).tickValues(s);const r=Math.max(0,this._maxCount),o=Math.max(0,this._config.minBarHeight??0),a=Math.max(0,this._timelineHeight-(this._config.barTopMargin??0)-(this._config.selectionPadding??0));this._yScale.range([o,a]).domain([0,r]).clamp(!0);const l=[this._extent[0],e.rangeEnd],c=[0,this._timelineWidth],u=this._isNumericTimeline?this._numScale:this._timeScale;u.domain(l),u.range(c),u.clamp(!0),this._activeAxisScale=u;const d=this._barsData[0],h=this._activeAxisScale(d.rangeEnd)-this._activeAxisScale(d.rangeStart);this._barWidth=h}_disableBrush(){var e,t;(e=this._brushInstance)==null||e.clear(this._brushGroup),this._currentSelectionInPixels=void 0,this._currentSelection=void 0,this.pauseAnimation(),this._brushGroup.selectAll("*").remove(),this._config.showAnimationControls&&((t=this._animationControlDiv)==null||t.classList.add(mt.disabled))}_mapSelection(e){if(!this._barsData.length)return;const t=this._activeAxisScale.invert(e[0]),n=this._activeAxisScale.invert(e[1]),s=this._getClosestRange(+t),r=this._getClosestRange(+n,!0);s&&r&&s.rangeStart<=r.rangeEnd&&e[1]-e[0]>this.getBarWidth()/2?this._currentSelection=[s.rangeStart,r.rangeEnd]:this._currentSelection=void 0}_getClosestRange(e,t){return this._barsData.reduce((n,s)=>{const r=t?n.rangeEnd:n.rangeStart,o=t?s.rangeEnd:s.rangeStart;return Math.abs(+o-+e)<Math.abs(+r-+e)?s:n})}_checkLastTickPosition(){var e;const t=this._axisGroup.selectAll(".tick:last-of-type").nodes();if(t!=null&&t.length){const n=t[0],s=n==null?void 0:n.getBoundingClientRect().right,r=(e=this._svg)==null?void 0:e.getBoundingClientRect().right;n.style.display=s>=r?"none":"inherit"}}_brushCurrentSelection(){var e;this._currentSelection?(this._currentSelectionInPixels=this._currentSelection.map(this._activeAxisScale),this._brushInstance&&!this._firstRender&&this._brushGroup.call(this._brushInstance.move,this._currentSelectionInPixels)):(this._currentSelectionInPixels=void 0,(e=this._brushInstance)==null||e.clear(this._brushGroup))}_normalizeTimeToMilliseconds(e){if(e<1e13)return e;const t=10**(Math.floor(Math.log10(e))-12);return Math.round(e/t*1e3)/1e3}}const Ww={debounceTime:300,suggestionsLimit:50,maxVisibleItems:10,minSearchLength:2,highlightMatch:!0,disabled:!1,openListUpwards:!1,placeholderRenderer:"Search...",suggestionRenderer:i=>String(i),selectedSuggestionRenderer:i=>String(i),inputClassName:void 0,suggestionListClassName:void 0,searchFn:async()=>[],onEnter:()=>{},onInput:()=>{},onSelect:()=>{},onClear:()=>{},noResultsText:"No results found",footerComponent:void 0},iK="style_module_searchInput__d7830601",nK="style_module_searchSuggestions__b0d3f71e",sK="style_module_clearButton__5ebb41de",rK="style_module_visible__5be7493d",oK="style_module_placeholderWrapper__72d5eb0e",aK="style_module_hidden__acfb8431",lK="style_module_disabled__62c35dc5",cK="style_module_searchInputWrapper__1edbcb22",uK="style_module_noResults__363397c3",dK="style_module_loading__296e0212",hK="style_module_dropdownContainer__d98287da",fK="style_module_upwards__e0b4831b",pK="style_module_footerContainer__73e7a066",Nt={searchInput:iK,searchSuggestions:nK,clearButton:sK,visible:rK,placeholderWrapper:oK,hidden:aK,disabled:lK,searchInputWrapper:cK,noResults:uK,loading:dK,dropdownContainer:hK,upwards:fK,footerContainer:pK};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();const mK="style_module_scrollbar__f1516254",Iv={scrollbar:mK};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var gK=Object.defineProperty,_K=(i,e,t)=>e in i?gK(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,zn=(i,e,t)=>_K(i,typeof e!="symbol"?e+"":e,t);let yK=class{constructor(e,t){zn(this,"_container"),zn(this,"_inputElement"),zn(this,"_suggestionList"),zn(this,"_dropdownContainer"),zn(this,"_footerContainer",null),zn(this,"_clearButton"),zn(this,"_config"),zn(this,"_debounceTimeout"),zn(this,"_placeholderElement",null),zn(this,"_handleFocus"),zn(this,"_handleBlur"),zn(this,"_handleClearClick"),zn(this,"_handleMouseDown"),this._container=e,this._container.classList.add(Iv.scrollbar),this._config=Yt(Ww,t??{});const n=document.createElement("div");n.className=Nt.searchInputWrapper,this._container.appendChild(n),this._inputElement=document.createElement("input"),this._inputElement.className=this._config.inputClassName??Nt.searchInput,n.appendChild(this._inputElement),this._createPlaceholderElement(),this._handleFocus=()=>this._updatePlaceholderVisibility(),this._handleBlur=()=>this._updatePlaceholderVisibility(),this._handleClearClick=()=>this.clearInput(),this._inputElement.addEventListener("focus",this._handleFocus),this._inputElement.addEventListener("blur",this._handleBlur),this._clearButton=document.createElement("button"),this._clearButton.className=Nt.clearButton,this._clearButton.innerHTML="×",this._clearButton.addEventListener("click",this._handleClearClick),n.appendChild(this._clearButton),this._dropdownContainer=document.createElement("div"),this._dropdownContainer.className=Nt.dropdownContainer,this._config.openListUpwards&&this._dropdownContainer.classList.add(Nt.upwards),n.appendChild(this._dropdownContainer),this._suggestionList=document.createElement("ul"),this._suggestionList.classList.add(this._config.suggestionListClassName??Nt.searchSuggestions),this._dropdownContainer.appendChild(this._suggestionList),this._footerContainer=document.createElement("div"),this._footerContainer.className=Nt.footerContainer,this._dropdownContainer.appendChild(this._footerContainer),this._handleKeyDown=this._handleKeyDown.bind(this),this._handleInput=this._handleInput.bind(this),this._inputElement.addEventListener("input",this._handleInput),this._inputElement.addEventListener("keydown",this._handleKeyDown),this._config.disabled&&this.setDisabled(!0)}get suggestionList(){return this._suggestionList}get dropdownContainer(){return this._dropdownContainer}_handleInput(e){if(this._config.disabled)return;const t=this._inputElement.value;t?this._clearButton.classList.add(Nt.visible):this._clearButton.classList.remove(Nt.visible),this._updatePlaceholderVisibility(),this._debounceTimeout&&window.clearTimeout(this._debounceTimeout),t.length>=(this._config.minSearchLength??0)&&this._renderLoading(),this._debounceTimeout=window.setTimeout(async()=>{const n=await this._performSearch(t);this._config.onInput&&this._config.onInput(t,n,e),this._renderSuggestions(n)},this._config.debounceTime??300)}async _handleKeyDown(e){if(!this._config.disabled&&e.key==="Enter"){const t=this._inputElement.value;this._renderLoading();const n=await this._performSearch(t);this._config.onEnter&&this._config.onEnter(t,n),this._renderSuggestions(n)}}_createPlaceholderElement(){var e;if(this._config.placeholderRenderer){const t=this._config.placeholderRenderer;t instanceof HTMLElement?(this._placeholderElement=document.createElement("div"),this._placeholderElement.className=Nt.placeholderWrapper,this._handleMouseDown=n=>{if(this._config.disabled){n.preventDefault();return}let s=n.target;for(;s&&s!==this._placeholderElement;){if(s.dataset.ignoreFocus==="true"){n.preventDefault();return}s=s.parentElement}},this._placeholderElement.addEventListener("mousedown",this._handleMouseDown),this._placeholderElement.appendChild(t),(e=this._inputElement.parentNode)==null||e.insertBefore(this._placeholderElement,this._inputElement)):this._inputElement.placeholder=t}this._updatePlaceholderVisibility()}_updatePlaceholderVisibility(){this._placeholderElement&&(this._inputElement.value||document.activeElement===this._inputElement?this._placeholderElement.classList.add(Nt.hidden):this._placeholderElement.classList.remove(Nt.hidden))}_createSuggestionElement(e){var t,n;const s=document.createElement("li"),r=document.createElement("div"),o=((n=(t=this._config).suggestionRenderer)==null?void 0:n.call(t,e,this._inputElement.value))??String(e);return typeof o=="string"?(r.title=o,r.innerHTML=this._config.highlightMatch?this.getHighlightedMatch(o):o):r.appendChild(o),s.appendChild(r),s}_renderSuggestions(e){this._suggestionList.innerHTML="";const t=this._config.maxVisibleItems&&e.length>this._config.maxVisibleItems;if(this._suggestionList.style.overflowY=t?"auto":"",e.length>0){const s=this._createSuggestionElement(e[0]);this._suggestionList.appendChild(s);const r=s.offsetHeight;if(this._suggestionList.removeChild(s),this._config.maxVisibleItems&&r>0){const o=r*this._config.maxVisibleItems,a=window.innerHeight*.6;this._suggestionList.style.maxHeight=`${Math.min(o,a)}px`}}const n=this._inputElement.value.length>=(this._config.minSearchLength??0);if(e.forEach(s=>{const r=this._createSuggestionElement(s);r.addEventListener("click",()=>this._handleSuggestionClick(s)),this._suggestionList.appendChild(r)}),e.length===0&&this._config.noResultsText&&n){const s=document.createElement("li");s.className=Nt.noResults,s.textContent=this._config.noResultsText,this._suggestionList.appendChild(s)}this._footerContainer&&(this._footerContainer.innerHTML="",this._config.footerComponent&&n&&e.length>0&&this._footerContainer.appendChild(this._config.footerComponent)),e.length>0||this._config.noResultsText&&n?this._dropdownContainer.classList.add(Nt.visible):this._dropdownContainer.classList.remove(Nt.visible)}_renderLoading(){if(!(this._inputElement.value.length>=(this._config.minSearchLength??0)))return;this._suggestionList.innerHTML="";const e=document.createElement("li");e.className=Nt.loading,e.textContent="Searching…",this._suggestionList.appendChild(e),this._footerContainer&&(this._footerContainer.innerHTML=""),this._dropdownContainer.classList.add(Nt.visible)}_handleSuggestionClick(e){var t,n;this._config.disabled||(this._config.onSelect&&this._config.onSelect(e),this._inputElement.value=((n=(t=this._config).selectedSuggestionRenderer)==null?void 0:n.call(t,e,this._inputElement.value))??String(e),this._updatePlaceholderVisibility(),this._clearButton.classList.add(Nt.visible),this._suggestionList.innerHTML="",this._footerContainer&&(this._footerContainer.innerHTML=""),this._dropdownContainer.classList.remove(Nt.visible))}async _performSearch(e){let t=[];return this._config.searchFn&&e.length>=(this._config.minSearchLength??0)&&(t=await this._config.searchFn(e,this._config.suggestionsLimit)),t}getHighlightedMatch(e){if(!this._config.highlightMatch||!this._inputElement.value)return e;const t=this._inputElement.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`(${t})`,"gi");return e.replace(n,"<mark>$1</mark>")}setDisabled(e){var t;e?(this._inputElement.disabled=!0,this._inputElement.value="",(t=this._placeholderElement)==null||t.classList.remove(Nt.hidden),this._clearButton.classList.remove(Nt.visible),this._container.classList.add(Nt.disabled),this._dropdownContainer.classList.remove(Nt.visible)):(this._inputElement.disabled=!1,this._container.classList.remove(Nt.disabled)),this._config.disabled=e}isDisabled(){return!!this._config.disabled}setConfig(e){const t=this._config.openListUpwards;this._config=Yt(Ww,e??{}),this.setDisabled(!!this._config.disabled),t!==this._config.openListUpwards&&(this._config.openListUpwards?this._dropdownContainer.classList.add(Nt.upwards):this._dropdownContainer.classList.remove(Nt.upwards))}destroy(){var e;this._inputElement.removeEventListener("input",this._handleInput),this._inputElement.removeEventListener("keydown",this._handleKeyDown),this._inputElement.removeEventListener("focus",this._handleFocus),this._inputElement.removeEventListener("blur",this._handleBlur),this._clearButton.removeEventListener("click",this._handleClearClick),this._placeholderElement&&this._handleMouseDown&&((e=this._placeholderElement)==null||e.removeEventListener("mousedown",this._handleMouseDown)),this._container.innerHTML=""}clearInput(){if(this._config.disabled)return;const e=!!this._inputElement.value;this._inputElement.value="",this._suggestionList.innerHTML="",this._footerContainer&&(this._footerContainer.innerHTML=""),this._dropdownContainer.classList.remove(Nt.visible),this._clearButton.classList.remove(Nt.visible),this._updatePlaceholderVisibility(),e&&this._config.onClear&&this._config.onClear()}hideSuggestions(){this._suggestionList.innerHTML="",this._footerContainer&&(this._footerContainer.innerHTML=""),this._dropdownContainer.classList.remove(Nt.visible)}focus(){this._inputElement.focus()}blur(){this._inputElement.blur()}};const bK={top:5,left:5,bottom:1,right:5},ZA=30,qd={padding:bK,barPadding:.1,minBarHeight:2,selectionRadius:3,selectionPadding:8,barCount:ZA,dataStep:void 0,barRadius:1,barTopMargin:7,labelSideMargin:3,formatter:Hs,allowSelection:!0,stickySelection:!0,onBrush:void 0,onBarHover:void 0,noDataMessage:"No histogram data",loadingMessage:"Data loading..."},vK="style_module_histogram__9d8a77ea",xK="style_module_histogramSvg__ccccb628",wK="style_module_selection__7db96137",SK="style_module_axisTick__898e1f39",EK="style_module_bar__3c9ab488",CK="style_module_highlightedBar__b193a8de",TK="style_module_axis__e37d2f53",kK="style_module_bars__cf3a511f",AK="style_module_brush__5a0c1368",rs={histogram:vK,histogramSvg:xK,selection:wK,axisTick:SK,bar:EK,highlightedBar:CK,axis:TK,bars:kK,brush:AK};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var IK=Object.defineProperty,LK=(i,e,t)=>e in i?IK(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,jt=(i,e,t)=>LK(i,typeof e!="symbol"?e+"":e,t);let RK=class extends Li{constructor(e,t){const n=Yt(qd,t??{}),s=Li.extractConfig(n,qd);super(e,s),jt(this,"_config"),jt(this,"_containerNode"),jt(this,"_resizeObserver"),jt(this,"_svg"),jt(this,"_axisGroup"),jt(this,"_barsGroup"),jt(this,"_highlightedBarsGroup"),jt(this,"_brushGroup"),jt(this,"_firstRender",!0),jt(this,"_height"),jt(this,"_width"),jt(this,"_histogramWidth"),jt(this,"_histogramHeight"),jt(this,"_barWidth",0),jt(this,"_maxCount",0),jt(this,"_extent"),jt(this,"_barsData",[]),jt(this,"_highlightedBarsData",[]),jt(this,"_histogramData"),jt(this,"_highlightedData"),jt(this,"_bandIntervals",[]),jt(this,"_currentSelection"),jt(this,"_currentSelectionInPixels"),jt(this,"_yScale",Up()),jt(this,"_xScale",zu()),jt(this,"_axis",z_(this._xScale)),jt(this,"_brushInstance"),this._config=n,this._containerNode=e,this._containerNode.classList.add(rs.histogram),this._width=e.offsetWidth,this._height=e.offsetHeight,this._histogramWidth=this._width-this._config.padding.left-this._config.padding.right,this._histogramHeight=this._height-this._config.padding.top-this._config.padding.bottom,this._initializeSVG(),this._initializeGroups(),this._resizeObserver=new RA(()=>this.resize()),this._resizeObserver.observe(this._containerNode)}_initializeSVG(){this._svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._svg.classList.add(rs.histogramSvg),this._containerNode.appendChild(this._svg)}setLoadingState(){super.setLoadingState()}_initializeGroups(){this._axisGroup=Wt(this._svg).append("g").attr("class",rs.axis),this._barsGroup=Wt(this._svg).append("g").attr("class",rs.bars),this._highlightedBarsGroup=Wt(this._svg).append("g").attr("class",rs.bars),this._brushGroup=Wt(this._svg).append("g").attr("class",rs.brush)}get _barPadding(){return this._barWidth*(this._config.barPadding??0)}get _formatter(){return this._config.formatter??Hs}getCurrentSelection(){return this._currentSelection}getCurrentSelectionInPixels(){return this._currentSelectionInPixels??[]}getBarWidth(){return this._barWidth-this._barPadding}getConfig(){return this._config}setConfig(e){const t=JSON.parse(JSON.stringify(this._config));this._config=Yt(qd,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,qd)),this._config.allowSelection||this._disableBrush(),(this._config.dataStep!==t.dataStep||this._config.barCount!==t.barCount)&&(this._updateHistogramData(this._histogramData),this._updateHistogramData(this._highlightedData,!0)),this._axis.tickFormat(n=>this._formatter(n)),this.resize()}setSelection(e,t=!1){var n,s,r,o;const a=this._currentSelection;if(e&&this._extent){const l=[Math.max(this._extent[0],Math.min(e[0],this._extent[1])),Math.min(this._extent[1],Math.max(e[1],this._extent[0]))];if(l[0]<l[1])if(this._config.stickySelection){const c=l.map(this._xScale);this._mapSelection(c)}else this._currentSelection=l;else this._currentSelection=void 0}else this._currentSelection=void 0;!t&&((a==null?void 0:a[0])!==((n=this._currentSelection)==null?void 0:n[0])||(a==null?void 0:a[1])!==((s=this._currentSelection)==null?void 0:s[1]))&&((o=(r=this._config).onBrush)==null||o.call(r,this._currentSelection,!0)),this._brushCurrentSelection()}resize(){const{offsetWidth:e,offsetHeight:t}=this._containerNode;this._width=e,this._height=t,this._histogramWidth=this._width-this._config.padding.left-this._config.padding.right,this._histogramHeight=this._height-this._config.padding.top-this._config.padding.bottom,this._histogramHeight>this._config.padding.top+this._config.padding.bottom&&(this._updateScales(),this._currentSelection&&this.setSelection(this._currentSelection,!0),this._firstRender||this.render())}render(){this._updateBrush(),this._updateBars(),this._updateBars(!0),this._updateAxis(),this._firstRender&&(this._firstRender=!1)}destroy(){super.destroy(),this._resizeObserver.disconnect(),this._containerNode.innerHTML=""}_parseData(e){if(!(e!=null&&e.length))return[];const t=new Float64Array(e.length);let n=0;for(let s=0;s<e.length;s++){const r=e[s];typeof r=="number"&&!isNaN(r)&&(t[n++]=r)}return Array.from(t.subarray(0,n))}setHistogramData(e,t){if(t&&t[1]<=t[0])return;this._histogramData=[],this._highlightedBarsData=[],this._currentSelection=void 0,this._brushCurrentSelection();const n=this._parseData(e),s=t||Rn(n),r=s[0]<s[1];r&&n.length>1?(this.hideState(),this._histogramData=n,this._extent=s,this._firstRender=!0):this.showState(r?void 0:"Empty or invalid histogram data"),this._updateHistogramData(this._histogramData),this._updateScales(),this.render()}setHighlightedData(e){this._histogramData&&(this._highlightedData=this._parseData(e),this._highlightedBarsData=[],this._updateHistogramData(this._highlightedData,!0),this._updateBars(!0))}_updateAxis(){if(!this._histogramData||!this._histogramData.length){this._axisGroup.style("display","none");return}this._axisGroup.style("transform",`translate(${this._config.padding.left}px, ${this._config.padding.top-(this._config.selectionPadding??0)/2+1}px)`).call(this._axis).call(e=>e.select(".domain").remove()),this._axisGroup.selectAll(".tick").select("text").attr("class",rs.axisTick).attr("y",0).attr("dy",-2).attr("dx",this._config.labelSideMargin??0),this._axisGroup.selectAll(".tick:last-of-type text").attr("dx",-(this._config.labelSideMargin??0)).style("text-anchor","end"),this._axisGroup.selectAll("line").attr("y2",this._histogramHeight).attr("y1",0).attr("opacity",.1)}_updateBrush(){if(!this._config.allowSelection||this._histogramHeight<0||this._histogramWidth<0){this._brushGroup.selectAll("*").remove();return}const e=this._config.selectionPadding??0,t=this._histogramHeight-e,n=[[0,e/2],[this._histogramWidth,t+e/2]];this._brushInstance=PA().extent(n),this._brushInstance.on("end",({selection:s,sourceEvent:r})=>{var o,a,l,c;r&&(s?(this._config.stickySelection?this._mapSelection(s):this._currentSelection=s.map(u=>this._xScale.invert(u)),(a=(o=this._config).onBrush)==null||a.call(o,this._currentSelection)):(this._currentSelection=void 0,(c=(l=this._config).onBrush)==null||c.call(l,void 0)),this._brushCurrentSelection())}),this._brushGroup.style("transform",`translate(${this._config.padding.left}px, ${this._config.padding.top}px)`).call(this._brushInstance).call(this._brushInstance.move,this._currentSelectionInPixels||null),this._brushGroup.select("rect.selection").classed(rs.selection,!0).attr("rx",this._config.selectionRadius??0).attr("ry",this._config.selectionRadius??0)}_updateBars(e=!1){const t=e?this._highlightedBarsGroup:this._barsGroup;if(!this._histogramData||!this._histogramData.length){t.selectAll("rect").remove();return}t.style("transform",`translate(${this._config.padding.left}px, ${this._config.padding.top-(this._config.selectionPadding??0)/2}px)`);const n=e?.5:1,s=this._createBars(t,e);!e&&this._config.onBarHover&&s.on("mouseover",this._config.onBarHover),this._animateBars(s,e,n)}_createBars(e,t){return e.selectAll(`.${t?rs.highlightedBar:rs.bar}`).data(t?this._highlightedBarsData:this._barsData).join("rect").attr("class",t?rs.highlightedBar:rs.bar).attr("x",n=>this._xScale(n.rangeStart)+this._barPadding/2).attr("width",this.getBarWidth()).attr("rx",this._config.barRadius??0).attr("ry",this._config.barRadius??0).attr("y",-this._histogramHeight)}_animateBars(e,t,n){e.transition().duration(300).attr("height",s=>t?s.count===0?0:this._yScale(s.count):this._yScale(s.count)).style("opacity",s=>this._yScale(s.count)===this._config.minBarHeight?.4:n)}_updateScales(){if(!this._extent||!this._barsData.length||this._histogramHeight<0||this._histogramWidth<0)this._axisGroup.style("display","none");else{this._axisGroup.style("display","inherit");const e=this._barsData[this._barsData.length-1],t=this._config.dataStep?[this._extent[0],e.rangeEnd]:this._extent;this._xScale.domain(t).range([0,this._histogramWidth]).clamp(!0),this._yScale.range([this._config.minBarHeight??0,this._histogramHeight-(this._config.barTopMargin??0)-(this._config.selectionPadding??0)]).domain([0,this._maxCount]).clamp(!0),this._axis.tickValues(t),this._barWidth=this._xScale(e.rangeEnd)-this._xScale(e.rangeStart)}}_updateHistogramData(e,t=!1){const n=t?"_highlightedBarsData":"_barsData";if(!this._extent){this[n]=[];return}if(!(e!=null&&e.length)){this[n]=ep([],this._bandIntervals,this._currentSelection,t);return}t||this._generateBandIntervals();const s=ep(e,this._bandIntervals,this._currentSelection,t);this[n]=s,t||(this._maxCount=Math.max(...s.map(r=>r.count)))}_generateBandIntervals(){if(!this._extent)return;const{barCount:e=ZA,dataStep:t}=this._config;this._bandIntervals=YA(this._extent,e,t)}_disableBrush(){this._currentSelection=void 0,this._brushCurrentSelection(),this._brushGroup.selectAll("*").remove()}_mapSelection(e){if(!this._barsData.length)return;const t=this._xScale.invert(e[0]),n=this._xScale.invert(e[1]),s=this._getClosestRange(t),r=this._getClosestRange(n,!0);s&&r&&s.rangeStart<=r.rangeEnd&&e[1]-e[0]>this.getBarWidth()/2?this._currentSelection=[s.rangeStart,r.rangeEnd]:this._currentSelection=void 0}_getClosestRange(e,t){return this._barsData.reduce((n,s)=>{const r=t?n.rangeEnd:n.rangeStart,o=t?s.rangeEnd:s.rangeStart;return Math.abs(o-e)<Math.abs(r-e)?s:n})}_brushCurrentSelection(){var e;this._currentSelection?(this._currentSelectionInPixels=this._currentSelection.map(this._xScale),this._brushInstance&&!this._firstRender&&this._brushGroup.call(this._brushInstance.move,this._currentSelectionInPixels)):(this._currentSelectionInPixels=void 0,(e=this._brushInstance)==null||e.clear(this._brushGroup))}};const QA=10,$a={maxDisplayedItems:QA,showSortingBlock:!0,showSearch:!0,sort:"count",sortAscending:!1,showTotalWhenFiltered:!1,countFormatter:Hs,expanded:!1,onClick:void 0,onBarHover:void 0,noDataMessage:"No bars data",loadingMessage:"Data loading...",allowPointerEvents:!0},PK="style_module_bars__25497ded",NK={bars:PK};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var DK=Object.defineProperty,MK=(i,e,t)=>e in i?DK(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,gt=(i,e,t)=>MK(i,typeof e!="symbol"?e+"":e,t);let BK=class extends Li{constructor(e,t){const n=Yt($a,t??{}),s=Li.extractConfig(n,$a);super(e,s),gt(this,"_data",[]),gt(this,"_originalData",[]),gt(this,"_config"),gt(this,"_container"),gt(this,"_searchContainer"),gt(this,"_searchInput"),gt(this,"_clearButton"),gt(this,"_scrollContainer"),gt(this,"_barsContainer"),gt(this,"_highlightedBarsContainer"),gt(this,"_showMoreButton"),gt(this,"_showMoreCount"),gt(this,"_sortingBlock"),gt(this,"_uniqueValues",new Set),gt(this,"_countMap",new Int32Array(0)),gt(this,"_visibleItemsCount",0),gt(this,"_hiddenItemsSum",0),gt(this,"_itemHeight",0),gt(this,"_itemMargin",0),gt(this,"_startIndex",0),gt(this,"_endIndex",0),gt(this,"_maxCount",0),gt(this,"_selectedItem"),gt(this,"_isExpanded",!1),gt(this,"_sortingHandlers"),gt(this,"_highlightedCounts"),gt(this,"_isFilteringActive",!1),gt(this,"_updateVisibleItems",()=>{const r=this._itemHeight+this._itemMargin;this._startIndex=Math.floor(this._scrollContainer.scrollTop/r),this._endIndex=Math.min(this._startIndex+this._visibleItemsCount+1,this._data.length),this._renderItems()}),gt(this,"_handleShowMoreCount",()=>{var r,o,a,l,c,u;const d=this._data.length-this._maxDisplayedItems,h=((o=(r=this._config).countFormatter)==null?void 0:o.call(r,this._hiddenItemsSum))??this._hiddenItemsSum.toString();if(this._isFilteringActive&&this._config.showTotalWhenFiltered){const p=this._data.slice(this._maxDisplayedItems).reduce((y,g)=>y+g.count,0),m=((l=(a=this._config).countFormatter)==null?void 0:l.call(a,p))??p.toString();this._showMoreCount.textContent=`${h} / ${m}`}else this._showMoreCount.textContent=h;this._showMoreButton.firstChild.textContent=`${((u=(c=this._config).countFormatter)==null?void 0:u.call(c,d))??d.toString()} more`}),gt(this,"_handleScroll",()=>{this._updateVisibleItems()}),gt(this,"_handleSort",()=>{this._config.sort==="alphabetical"?this.sortAlphabetically(this._config.sortAscending):this.sortByCount(this._config.sortAscending)}),gt(this,"_handleSearch",()=>{const r=this._searchInput.value.toLowerCase();this._clearButton.classList[r?"add":"remove"]("visible"),this._data=this._originalData.filter(o=>String(o.label).toLowerCase().includes(r)),this._handleSort()}),gt(this,"_clearSearch",()=>{this._searchInput.value="",this._handleSearch()}),gt(this,"_handleShowMore",()=>{this._isExpanded=!this._isExpanded,this._isExpanded?(this._scrollContainer.style.overflowY="auto",this._showMoreButton.firstChild.textContent="show less",this._showMoreCount.textContent=""):(this._scrollContainer.style.overflowY="hidden",this._scrollContainer.scrollTop=0,this._handleShowMoreCount())}),this._config=n,this._container=e,this._container.classList.add(NK.bars),this._container.classList.add(Iv.scrollbar),this._scrollContainer=document.createElement("div"),this._scrollContainer.classList.add("scroll-container"),this._barsContainer=document.createElement("div"),this._barsContainer.classList.add("bars-container"),this._highlightedBarsContainer=document.createElement("div"),this._highlightedBarsContainer.classList.add("bars-container","highlighted-bars-container"),this._scrollContainer.appendChild(this._barsContainer),this._scrollContainer.appendChild(this._highlightedBarsContainer),this._showMoreButton=this._createShowMoreButton(),this._sortingBlock=this._createSortingBlock(),this._searchContainer=this._createSearch(),this._container.appendChild(this._searchContainer),this._container.appendChild(this._scrollContainer),this._container.appendChild(this._showMoreButton),this._container.appendChild(this._sortingBlock),this._scrollContainer.addEventListener("scroll",this._handleScroll,{passive:!0})}get _maxDisplayedItems(){return this._config.maxDisplayedItems??QA}_createSearch(){const e=document.createElement("div");return e.classList.add("search-container"),this._clearButton=document.createElement("button"),this._clearButton.classList.add("clear-button"),this._clearButton.innerHTML="×",this._clearButton.addEventListener("click",this._clearSearch),this._searchInput=document.createElement("input"),this._searchInput.classList.add("search-input"),this._searchInput.placeholder="Search...",this._searchInput.addEventListener("input",this._handleSearch),e.appendChild(this._searchInput),e.appendChild(this._clearButton),e}_updateButtonState(e,t){e.classList.add("selected"),e.classList.remove("unselected"),t.classList.add("unselected"),t.classList.remove("selected")}_updateArrowText(e,t,n){e.textContent=`${t?"↑":"↓"}${n}`}_createSortingHandlers(e,t,n,s){return{alpha:()=>{this._config.sort==="alphabetical"&&(n=!n,this._updateArrowText(e,n,"ABC")),this._config.sort="alphabetical",this._config.sortAscending=n,this._updateButtonState(e,t),this._handleSort()},numeric:()=>{this._config.sort==="count"&&(s=!s,this._updateArrowText(t,s,"123")),this._config.sort="count",this._config.sortAscending=s,this._updateButtonState(t,e),this._handleSort()},reset:()=>{var r,o;(o=(r=this._config).onClick)==null||o.call(r,void 0),this.setSelectedItem(void 0)}}}_createSortingBlock(){const e=document.createElement("div"),t=document.createElement("div"),[n,s]=[document.createElement("div"),document.createElement("div")],r=document.createElement("div");e.classList.add("sorting-block"),t.classList.add("buttons-container"),r.classList.add("reset-text","unselected");const o=this._config.sort==="alphabetical"?this._config.sortAscending:!0,a=this._config.sort==="count"?this._config.sortAscending:!0;return this._updateArrowText(n,o??!1,"ABC"),this._updateArrowText(s,a??!1,"123"),r.textContent="reset selection",this._config.sort&&this._updateButtonState(this._config.sort==="alphabetical"?n:s,this._config.sort==="alphabetical"?s:n),this._sortingHandlers=this._createSortingHandlers(n,s,o??!1,a??!1),n.addEventListener("click",this._sortingHandlers.alpha),s.addEventListener("click",this._sortingHandlers.numeric),r.addEventListener("click",this._sortingHandlers.reset),t.append(n,s),e.append(t,r),e}_createShowMoreButton(){const e=document.createElement("div");e.classList.add("show-more"),e.addEventListener("click",this._handleShowMore);const t=document.createElement("span");return this._showMoreCount=document.createElement("span"),this._showMoreCount.classList.add("show-more-count"),e.appendChild(t),e.appendChild(this._showMoreCount),e}_calculateVisibleItems(){const e=this._itemHeight+this._itemMargin;this._visibleItemsCount=Math.ceil(this._scrollContainer.clientHeight/e)}_createBarElement(e,t=!1,n){var s,r,o,a,l,c,u;if(t){const _=document.createElement("div");_.classList.add("bar-highlighted"),_.dataset.label=e.label,_.style.position="absolute";const S=n/e.count*(e.count/this._maxCount)*100;return _.style.width=`${S}%`,_}const d=document.createElement("div");if(d.classList.add("row"),d.style.position="absolute",(s=this._config)!=null&&s.onClick&&(d.style.cursor="pointer",d.addEventListener("click",()=>{var _,S;return(S=(_=this._config).onClick)==null?void 0:S.call(_,e)})),this._selectedItem){const _=this._container.querySelector(".reset-text");_==null||_.classList.remove("unselected"),_==null||_.classList.add("selected"),d.classList.add(this._selectedItem.label===e.label?"selected":"unselected")}const h=e.count/this._maxCount*100,p=document.createElement("div");p.classList.add("bar"),p.style.width=`${h}%`;const m=document.createElement("div");m.classList.add("info");const y=document.createElement("div");y.classList.add("label"),y.textContent=e.label,y.title=e.label;const g=document.createElement("div");if(g.classList.add("count"),this._isFilteringActive&&n!==void 0){const _=((o=(r=this._config).countFormatter)==null?void 0:o.call(r,n))??n.toString();if(this._config.showTotalWhenFiltered){const S=((l=(a=this._config).countFormatter)==null?void 0:l.call(a,e.count))??e.count.toString();g.textContent=`${_} / ${S}`}else g.textContent=_}else g.textContent=((u=(c=this._config).countFormatter)==null?void 0:u.call(c,e.count))??e.count.toString();return m.append(y,g),d.append(p,m),d}_renderItems(){this._renderItemsToContainer(this._barsContainer,!1),this._renderItemsToContainer(this._highlightedBarsContainer,!0)}_renderItemsToContainer(e,t){var n;const s=this._itemHeight+this._itemMargin;if(t){if(!this._highlightedCounts){e.replaceChildren();return}const r=new Map;for(const a of Array.from(e.children)){const l=a;l.classList.contains("bar-highlighted")&&l.dataset.label&&r.set(l.dataset.label,l)}const o=new Set;for(let a=this._startIndex;a<this._endIndex;a++){const l=this._data[a];if(!l)continue;const c=this._highlightedCounts.get(l.label)||0;if(c>0){o.add(l.label);const u=r.get(l.label);if(u){const d=c/l.count*(l.count/this._maxCount)*100;u.style.width=`${d}%`,u.style.top=`${a*s}px`}else{const d=this._createBarElement(l,!0,c);d.style.top=`${a*s}px`,d.style.height=`${this._itemHeight}px`,e.appendChild(d)}}}for(const[a,l]of r)o.has(a)||l.remove()}else{const r=document.createDocumentFragment();for(let o=this._startIndex;o<this._endIndex;o++){const a=this._data[o];if(!a)continue;const l=((n=this._highlightedCounts)==null?void 0:n.get(a.label))||0,c=this._createBarElement(a,!1,l);c.style.top=`${o*s}px`,c.style.height=`${this._itemHeight}px`,r.appendChild(c)}e.replaceChildren(r)}}_updateContainerHeights(e){const t=Math.min(this._originalData.length,this._maxDisplayedItems)*e;this._scrollContainer.style.height=`${t}px`;const n=`${this._data.length*e}px`;this._barsContainer.style.height=n,this._highlightedBarsContainer.style.height=n}_updateShowMoreButton(){if(this._originalData.length>this._maxDisplayedItems){const e=this._data.length>this._maxDisplayedItems;this._showMoreButton.style.visibility=e?"visible":"hidden",this._showMoreButton.style.display="flex"}else this._showMoreButton.style.display="none"}_updateUIElements(e=$a.showSortingBlock,t=$a.showSearch){this._originalData.length?this._data.length?(this._sortingBlock.style.visibility=e?"visible":"hidden",this._searchContainer.style.display=t?"block":"none",this.hideState(),this._scrollContainer.style.visibility="visible"):(this._sortingBlock.style.visibility=e?"visible":"hidden",this._searchContainer.style.display=t?"block":"none",this._scrollContainer.style.visibility="visible",this.showState(this._searchInput.value.length?"No results found":void 0)):(this._sortingBlock.style.visibility="hidden",this._searchContainer.style.display="none",this._scrollContainer.style.visibility="hidden",this._showMoreButton.style.display="none",this.showState())}_render(){this._maxCount=Math.max(...this._data.map(s=>s.count),1),this._calculateItemDimensions();const{showSortingBlock:e,showSearch:t}=this._config,n=this._itemHeight+this._itemMargin;this._updateContainerHeights(n),this._updateShowMoreButton(),this._updateUIElements(e,t),this._calculateVisibleItems(),this._updateVisibleItems()}_calculateItemDimensions(){if(!this._data.length)return;const e=this._createBarElement(this._data[0]);this._barsContainer.appendChild(e);const t=window.getComputedStyle(e);this._itemHeight=e.offsetHeight,this._itemMargin=parseFloat(t.marginTop)+parseFloat(t.marginBottom),this._barsContainer.removeChild(e)}_calcHiddenSum(){if(this._data.length>this._maxDisplayedItems){const e=this._data.slice(this._maxDisplayedItems);this._isFilteringActive?this._hiddenItemsSum=e.reduce((t,n)=>{var s;const r=((s=this._highlightedCounts)==null?void 0:s.get(n.label))||0;return t+r},0):this._hiddenItemsSum=e.reduce((t,n)=>t+n.count,0)}else this._hiddenItemsSum=0;this._handleShowMoreCount()}getConfig(){return this._config}setConfig(e){this._config=Yt($a,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,$a)),this._isExpanded=(e==null?void 0:e.expanded)??!1,this._calcHiddenSum(),this._render()}setData(e=[]){var t,n;this._clearSearch(),this._uniqueValues=new Set(e),this._countMap=new Int32Array(this._uniqueValues.size);const s=new Map([...this._uniqueValues].map((r,o)=>[r,o]));e.forEach(r=>{const o=s.get(r);o!==void 0&&this._countMap[o]++}),this._data=[...this._uniqueValues].map((r,o)=>({label:r,count:this._countMap[o]||0})),this._originalData=[...this._data],!this._originalData.length&&this._selectedItem&&(this.setSelectedItem(void 0),(n=(t=this._config).onClick)==null||n.call(t,void 0)),this._searchContainer.style.display=this._originalData.length?"block":"none",this._handleSort()}sortByCount(e=!1){this._data.sort((t,n)=>e?t.count-n.count:n.count-t.count),this._calcHiddenSum(),this._render()}sortAlphabetically(e=!0){this._data.sort((t,n)=>e?t.label.toString().localeCompare(n.label):n.label.toString().localeCompare(t.label)),this._calcHiddenSum(),this._render()}destroy(){this._scrollContainer.removeEventListener("scroll",this._handleScroll),this._searchInput.removeEventListener("input",this._handleSearch),this._clearButton.removeEventListener("click",this._clearSearch),this._showMoreButton.removeEventListener("click",this._handleShowMore);const e=this._sortingBlock.querySelector("div:first-child"),t=this._sortingBlock.querySelector("div:nth-child(2)"),n=this._sortingBlock.querySelector(".reset-text");e==null||e.removeEventListener("click",this._sortingHandlers.alpha),t==null||t.removeEventListener("click",this._sortingHandlers.numeric),n==null||n.removeEventListener("click",this._sortingHandlers.reset),this._container.innerHTML="",this._data=[],this._originalData=[],this._uniqueValues.clear(),this._countMap=new Int32Array(0),this._hiddenItemsSum=0,this._highlightedCounts=void 0,this._isFilteringActive=!1,super.destroy()}resetList(){this._scrollContainer.scrollTop=0,this._searchInput.value="",this._selectedItem=void 0,this._highlightedCounts=void 0,this._isFilteringActive=!1,this._data=[...this._originalData],this._updateVisibleItems()}getSelectedItem(){return this._selectedItem}setSelectedItem(e){if(!e){const t=this._container.querySelector(".reset-text");t==null||t.classList.remove("selected"),t==null||t.classList.add("unselected")}this._selectedItem=e,this._updateVisibleItems()}setHighlightedData(e){if(e==null)this._highlightedCounts=void 0,this._isFilteringActive=!1;else{this._highlightedCounts=new Map;for(const n of e)this._highlightedCounts.set(n,(this._highlightedCounts.get(n)||0)+1);const t=this._originalData.reduce((n,s)=>n+s.count,0);this._isFilteringActive=e.length<t}this._calcHiddenSum(),this._renderItems()}setLoadingState(){super.setLoadingState()}};const Xd={hidden:!1,label:void 0,labelFormatter:Hs,extent:void 0,extentLabels:void 0,enableEvents:!0,form:"point",showSublabels:!1,minSubLabel:"min",maxSubLabel:"max",sizeMultiplier:void 0,onClick:void 0,onMinClick:void 0,onMaxClick:void 0,onHover:void 0,noDataMessage:"No legend data",loadingMessage:"Data loading..."},OK="style_module_container__d2889234",FK="style_module_legend__75c167f2",zK="style_module_enabled__91eae57a",UK="style_module_disabled__d51f7a10",$K="style_module_hovered__1206707f",Is={container:OK,legend:FK,enabled:zK,disabled:UK,hovered:$K};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var jK=Object.defineProperty,HK=(i,e,t)=>e in i?jK(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Vr=(i,e,t)=>HK(i,typeof e!="symbol"?e+"":e,t);let VK=class extends Li{constructor(e,t){const n=Yt(Xd,t??{});super(e,Li.extractConfig(n,Xd)),Vr(this,"_config"),Vr(this,"_containerNode"),Vr(this,"_legend"),Vr(this,"_sizeElements",null),Vr(this,"_isHidden",!1),Vr(this,"_handleClick",s=>{var r,o;this._config.enableEvents&&((o=(r=this._config).onClick)==null||o.call(r,s))}),Vr(this,"_handleHover",s=>{var r,o;this._config.enableEvents&&((o=(r=this._config).onHover)==null||o.call(r,s))}),Vr(this,"_handleSizeElementHover",s=>{var r,o,a,l;if(!this._config.enableEvents||!this._config.extent||!this._sizeElements)return;const c=s.currentTarget;if(!c)return;const u=c.classList.contains("min")?"min":"max",d=s.type==="mouseenter",h=u==="min"?0:this._config.extent.length-1,p=(r=this._config.extent)==null?void 0:r[h],m=(o=this._config.extentLabels)==null?void 0:o[h];c.classList.toggle(Is.hovered,d),(l=(a=this._config).onHover)==null||l.call(a,{target:c,type:u,size:p,value:m})}),Vr(this,"_handleSizeElementClick",s=>{var r,o;if(!this._config.enableEvents)return;const a=s.currentTarget.className.includes("min")?"min":"max",l=a==="min"?this._config.onMinClick:this._config.onMaxClick;if(l){const c=((r=this._config.extent)==null?void 0:r[a==="min"?0:1])??void 0,u=((o=this._config.extentLabels)==null?void 0:o[a==="min"?0:1])??c;l(c,u,s)}}),this._config=n,this._containerNode=e,this._containerNode.classList.add(Is.container),this._createElements()}hide(){this._isHidden||(this._isHidden=!0,this._containerNode.classList.remove(Is.enabled),this._containerNode.classList.add(Is.disabled))}show(){this._isHidden&&(this._isHidden=!1,this._containerNode.classList.remove(Is.disabled),this._containerNode.classList.add(Is.enabled))}setConfig(e){this._config=Yt(Xd,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,Xd)),this._updateLegend()}setLoadingState(){super.setLoadingState()}destroy(){this._legend&&(this._legend.removeEventListener("click",this._handleClick),this._legend.removeEventListener("mouseover",this._handleHover),this._sizeElements&&["min","max"].forEach(e=>{const t=this._sizeElements[e];t.removeEventListener("click",this._handleSizeElementClick),t.removeEventListener("mouseenter",this._handleSizeElementHover),t.removeEventListener("mouseleave",this._handleSizeElementHover)}),this._containerNode.removeChild(this._legend),super.destroy())}get sizeElements(){return this._sizeElements}get config(){return this._config}get isHidden(){return this._isHidden}_createElements(){this._legend=this._createLegendElement(),this._containerNode.appendChild(this._legend),this._isHidden||this.show()}_createLegendElement(){const e=document.createElement("div");e.classList.add(Is.legend);const t=document.createElement("div");t.className="legend-content",this._sizeElements={min:this._createSizeElement("min"),max:this._createSizeElement("max")},t.appendChild(this._sizeElements.min),t.appendChild(this._sizeElements.max),e.appendChild(t);const n=document.createElement("div");return n.className="name",e.appendChild(n),e}_createSizeElement(e){const t=document.createElement("div");t.classList.add(e);const n=document.createElement("div");t.appendChild(n);const s=document.createElement("div");return s.className="label",t.appendChild(s),t.addEventListener("click",this._handleSizeElementClick),t.addEventListener("mouseenter",this._handleSizeElementHover),t.addEventListener("mouseleave",this._handleSizeElementHover),t}_updateLegend(){const{extent:e,extentLabels:t}=this._config,{noDataMessage:n,loadingMessage:s}=this._displayStateConfig,r=!e&&n===!1&&s===!1;if(this._config.hidden||r?this.hide():this.show(),e!=null&&e.every(Number.isFinite)&&t!=null&&t.every(Number.isFinite)){this.hideState();const o=this._legend.querySelector(".name");o&&(o.textContent=this._config.label??""),this._sizeElements&&(t[0]===t[1]?(this._updateSizeElement("min"),this._sizeElements.min.style.display="block",this._sizeElements.max.style.display="none"):(this._updateSizeElement("min"),this._updateSizeElement("max"),this._sizeElements.min.style.display="block",this._sizeElements.max.style.display="block")),this._legend.classList.remove(Is.disabled),this._legend.classList.add(Is.enabled)}else this.showState(),this._legend.classList.remove(Is.enabled),this._legend.classList.add(Is.disabled)}_updateSizeElement(e){var t,n;if(!this._sizeElements)return;const s=this._sizeElements[e];s.style.pointerEvents=this._config.enableEvents?"auto":"none";const r=((t=this._config.extent)==null?void 0:t[e==="min"?0:1])??1,o=((n=this._config.extentLabels)==null?void 0:n[e==="min"?0:1])??r,a=s.querySelector("div");this._config.form==="point"?(a.classList.remove("line"),a.classList.add("circle"),a.style.height=a.style.width=`${r*(this._config.sizeMultiplier??1)}px`):(a.style.width="",a.classList.remove("circle"),a.classList.add("line"),a.style.height=`${r*(this._config.sizeMultiplier??1)}px`);const l=s.querySelector(".label");l.textContent=this._formatLabel(o),this._updateSublabel(s,e)}_updateSublabel(e,t){let n=e.querySelector(".sublabel");this._config.showSublabels?(n||(n=document.createElement("div"),n.className="sublabel",e.appendChild(n)),n.textContent=t==="min"?this._config.minSubLabel??"min":this._config.maxSubLabel??"max"):n&&n.remove()}_formatLabel(e){return this._config.labelFormatter?this._config.labelFormatter(e):e.toString()}};const Kd={hidden:!1,label:void 0,labelFormatter:Hs,extent:void 0,extentLabels:void 0,enableEvents:!0,showSublabels:!1,minSubLabel:"min",maxSubLabel:"max",discreteColors:!1,onClick:void 0,onHover:void 0,onMaxClick:void 0,onMinClick:void 0,noDataMessage:"No legend data",loadingMessage:"Data loading..."},GK="style_module_container__05cc807d",WK="style_module_legend__a3e235e4",YK="style_module_enabled__b3120e27",qK="style_module_disabled__c2dc158c",XK="style_module_hovered__dfd7bb2c",Ls={container:GK,legend:WK,enabled:YK,disabled:qK,hovered:XK};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var KK=Object.defineProperty,ZK=(i,e,t)=>e in i?KK(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Rs=(i,e,t)=>ZK(i,typeof e!="symbol"?e+"":e,t);let QK=class extends Li{constructor(e,t){const n=Yt(Kd,t??{}),s=Li.extractConfig(n,Kd);super(e,s),Rs(this,"_config"),Rs(this,"_containerNode"),Rs(this,"_legend"),Rs(this,"_legendElements"),Rs(this,"_gradientElement"),Rs(this,"_extentElements",null),Rs(this,"_isHidden",!1),Rs(this,"_handleClick",r=>{var o,a;this._config.enableEvents&&((a=(o=this._config).onClick)==null||a.call(o,r))}),Rs(this,"_handleHover",r=>{var o,a;this._config.enableEvents&&((a=(o=this._config).onHover)==null||a.call(o,r))}),Rs(this,"_handleColorElementClick",r=>{var o,a;if(!this._config.enableEvents)return;const l=r.currentTarget.className.includes("min")?"min":"max",c=l==="min"?this._config.onMinClick:this._config.onMaxClick;if(c){const u=l==="min"?0:1,d=(o=this._config.extent)==null?void 0:o[l==="min"?0:this._config.extent.length-1],h=(a=this._config.extentLabels)==null?void 0:a[u];c(d,h,r)}}),Rs(this,"_handleColorElementHover",r=>{var o,a,l,c;if(!this._config.enableEvents||!this._config.extent)return;const u=r.currentTarget;if(!u)return;const d=u.classList.contains("min")?"min":"max",h=r.type==="mouseenter",p=d==="min"?0:this._config.extent.length-1,m=(o=this._config.extent)==null?void 0:o[p],y=(a=this._config.extentLabels)==null?void 0:a[p];u.classList.toggle(Ls.hovered,h),(c=(l=this._config).onHover)==null||c.call(l,{target:u,type:d,color:m,value:y})}),this._config=n,this._containerNode=e,this._containerNode.classList.add(Ls.container),this._createElements()}get extentElements(){return this._extentElements}get config(){return this._config}hide(){this._isHidden||(this._isHidden=!0,this._containerNode.classList.remove(Ls.enabled),this._containerNode.classList.add(Ls.disabled))}show(){this._isHidden&&(this._isHidden=!1,this._containerNode.classList.remove(Ls.disabled),this._containerNode.classList.add(Ls.enabled))}setConfig(e){this._config=Yt(Kd,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,Kd)),this._updateLegend()}destroy(){this._legend&&(this._legend.removeEventListener("click",this._handleClick),this._legend.removeEventListener("mouseover",this._handleHover),this._extentElements&&["min","max"].forEach(e=>{const t=this._extentElements[e];t.removeEventListener("click",this._handleColorElementClick),t.removeEventListener("mouseenter",this._handleColorElementHover),t.removeEventListener("mouseleave",this._handleColorElementHover)}),this._containerNode.removeChild(this._legend),super.destroy())}setLoadingState(){super.setLoadingState()}_createElements(){this._legend=document.createElement("div"),this._legend.classList.add(Ls.legend),this._legendElements=this._createLegend(),this._gradientElement=this._createGradientElement(),this._legend.appendChild(this._legendElements),this._legend.appendChild(this._gradientElement),this._containerNode.appendChild(this._legend),this._isHidden||this.show()}_createLegend(){const e=document.createElement("div");e.classList.add("legend-content");const t=document.createElement("div");return t.classList.add("name"),this._extentElements={min:this._createLabelExtent("min"),max:this._createLabelExtent("max")},e.appendChild(this._extentElements.min),e.appendChild(t),e.appendChild(this._extentElements.max),e}_createLabelExtent(e){const t=document.createElement("div");t.classList.add("extent"),t.classList.add(e);const n=document.createElement("div");return n.classList.add("label"),t.appendChild(n),t.addEventListener("click",this._handleColorElementClick),t.addEventListener("mouseenter",this._handleColorElementHover),t.addEventListener("mouseleave",this._handleColorElementHover),t}_createGradientElement(){const e=document.createElement("div");return e.classList.add("gradient"),e}_updateLegend(){var e,t,n;const{noDataMessage:s,loadingMessage:r}=this._displayStateConfig,o=!this._config.extent&&s===!1&&r===!1;if(this._config.hidden||o?this.hide():this.show(),this._config.extent){this.hideState();const a=this._legendElements.querySelector(".name");a&&(a.textContent=this._config.label??"");const l=((e=this._config.extentLabels)==null?void 0:e[0])===((t=this._config.extentLabels)==null?void 0:t[1]);if(this._extentElements)if(l){if(this._extentElements.min.style.display="none",this._extentElements.max.style.display="none",a&&((n=this._config.extentLabels)==null?void 0:n[0])!==void 0){const c=this._formatLabel(this._config.extentLabels[0]),u=a.textContent?`${c}
${a.textContent}`:c;a.textContent=u}}else this._updateLabelWrapper("min"),this._updateLabelWrapper("max"),this._extentElements.min.style.display="block",this._extentElements.max.style.display="block";this._updateGradient(),this._legend.classList.remove(Ls.disabled),this._legend.classList.add(Ls.enabled)}else this.showState(),this._legend.classList.remove(Ls.enabled),this._legend.classList.add(Ls.disabled)}_updateGradient(){if(!this._config.extent)return;const e=this._config.extent.map(t=>this._getColor(t)).filter((t,n,s)=>n===0||t!==s[n-1]);if(e.length===1){this._gradientElement.style.backgroundImage="none",this._gradientElement.style.backgroundColor=e[0];return}if(this._config.discreteColors){const t=100/e.length,n=e.map((s,r)=>`${s} ${r*t}% ${(r+1)*t}%`);this._gradientElement.style.backgroundImage=`linear-gradient(to right, ${n.join(", ")})`}else{const t=this._config.extent.map((n,s)=>`${this._getColor(n)} ${s/(this._config.extent.length-1)*100}%`).join(", ");this._gradientElement.style.backgroundImage=`linear-gradient(to right, ${t})`}}_updateLabelWrapper(e){var t;const n=this._legendElements.querySelector(`.extent:${e==="min"?"first-child":"last-child"}`);if(!n)return;const s=e==="min"?0:1,r=(t=this._config.extentLabels)==null?void 0:t[s],o=n.querySelector(".label");o&&r!==void 0&&(o.textContent=this._formatLabel(r)),this._updateSublabel(n,e)}_updateSublabel(e,t){let n=e.querySelector(".sublabel");this._config.showSublabels?(n||(n=document.createElement("div"),n.classList.add("sublabel"),e.appendChild(n)),n.textContent=t==="min"?this._config.minSubLabel??"min":this._config.maxSubLabel??"max"):n&&n.remove()}_formatLabel(e){return typeof e=="string"?e:this._config.labelFormatter?this._config.labelFormatter(e):e.toString()}_getColor(e){return Array.isArray(e)?`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`:e}};const ja=15,Zd={hidden:!1,label:void 0,items:[],labelFormatter:void 0,enableEvents:!0,expanded:!1,maxDisplayedItems:15,alignRight:!1,onClick:void 0,onHover:void 0,noDataMessage:"No legend data",loadingMessage:"Data loading..."},JK="style_module_enabled__277b2403",eZ="style_module_disabled__7a587f96",tZ="style_module_wrapper__ea8ca7f4",iZ="style_module_typeLegend__15bf4b2f",nZ="style_module_hovered__c0993502",sZ="style_module_selected__36e1dd81",rZ="style_module_unselected__4826cfb7",Sn={enabled:JK,disabled:eZ,wrapper:tZ,typeLegend:iZ,hovered:nZ,selected:sZ,unselected:rZ};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var oZ=Object.defineProperty,aZ=(i,e,t)=>e in i?oZ(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ri=(i,e,t)=>aZ(i,typeof e!="symbol"?e+"":e,t);class lZ extends Li{constructor(e,t){const n=Yt(Zd,t??{});super(e,Li.extractConfig(n,Zd)),ri(this,"_containerNode"),ri(this,"_config"),ri(this,"_scrollContainer"),ri(this,"_legendItems"),ri(this,"_showMoreButton"),ri(this,"_wrapper"),ri(this,"_itemHeight",0),ri(this,"_itemMargin",0),ri(this,"_visibleItemsCount",0),ri(this,"_startIndex",0),ri(this,"_endIndex",0),ri(this,"_listItems",[]),ri(this,"_selectedItem"),ri(this,"_isExpanded",!1),ri(this,"_isHidden",!1),ri(this,"_calculatedWidth",0),ri(this,"_maxMeasuredWidth",0),ri(this,"_maxMeasuredCharLength",0),ri(this,"_label"),ri(this,"_handleShowMore",()=>{var s,r;this._isExpanded=!this._isExpanded,this._isExpanded?(this._containerNode.style.pointerEvents="all",this._scrollContainer.style.overflowY="auto",this._showMoreButton.firstChild.textContent="show less"):(this._containerNode.style.pointerEvents="none",this._scrollContainer.style.overflowY="hidden",this._scrollContainer.scrollTop=0,this._handleShowMoreCount()),(r=(s=this._config).onShowMoreClick)==null||r.call(s,this._isExpanded),this._calculateOptimalWidth(),this._updateVisibleItems()}),ri(this,"_handleShowMoreCount",()=>{const{maxDisplayedItems:s=ja}=this._config,r=this._listItems.length-s;this._showMoreButton.firstChild.textContent=`${r} more...`}),ri(this,"_handleScroll",()=>{requestAnimationFrame(()=>{this._updateVisibleItems()})}),this._config=n,this._containerNode=e,this._containerNode.classList.add(Sn.typeLegend),this._containerNode.classList.add(Iv.scrollbar),this._createElements()}get config(){return this._config}get legendItems(){return this._legendItems}get isExpanded(){return this._isExpanded}setConfig(e){const t=this._isExpanded;this._config=Yt(Zd,e??{}),this.setDisplayStateConfig(Li.extractConfig(this._config,Zd)),this._isExpanded=(e==null?void 0:e.expanded)??t,this._updateLegend()}setSelectedItem(e){this._selectedItem=e,this._updateVisibleItems()}resetList(){this._scrollContainer.scrollTop=0,this._selectedItem=void 0,this._updateVisibleItems()}getConfig(){return this._config}show(){this._isHidden&&(this._isHidden=!1,this._containerNode.classList.remove(Sn.disabled),this._containerNode.classList.add(Sn.enabled))}hide(){this._isHidden||(this._isHidden=!0,this._containerNode.classList.remove(Sn.enabled),this._containerNode.classList.add(Sn.disabled))}destroy(){this._scrollContainer.removeEventListener("scroll",this._handleScroll),this._containerNode.innerHTML="",super.destroy()}setLoadingState(){super.setLoadingState()}_updateLegend(){const{maxDisplayedItems:e=ja,items:t}=this._config,{noDataMessage:n,loadingMessage:s}=this._displayStateConfig,r=!(t!=null&&t.length)&&n===!1&&s===!1;if(this._config.hidden||r?this.hide():this.show(),t!=null&&t.length){this.hideState(),this._wrapper.classList.remove(Sn.disabled),this._wrapper.classList.add(Sn.enabled);const o=this._config.label;this._label.textContent=o??"",this._label.title=o??"",o?this._label.classList.remove("hidden"):this._label.classList.add("hidden"),this._listItems=t;const a=this._listItems.length;this._calculateItemDimensions(),this._calculateOptimalWidth(),this._visibleItemsCount=e>a?a:e;const l=this._itemHeight+this._itemMargin,c=Math.ceil(this._visibleItemsCount*l-this._itemMargin);this._scrollContainer.style.height=`${c}px`,this._legendItems.style.height=`${Math.ceil(this._listItems.length*l)}px`,this._scrollContainer.style.overflowY=this._isExpanded?"auto":"hidden",this._containerNode.style.pointerEvents=this._isExpanded?"all":"none",this._updateVisibleItems(),this._showMoreButton.style.display=this._listItems.length>e?"block":"none"}else this.showState(),this._wrapper.classList.remove(Sn.enabled),this._wrapper.classList.add(Sn.disabled)}_updateVisibleItems(){const e=this._itemHeight+this._itemMargin,t=3,n=this._scrollContainer.scrollTop;this._startIndex=Math.max(0,Math.floor(n/e)-t);const s=this._isExpanded?Math.ceil(this._scrollContainer.clientHeight/e+t*2):this._visibleItemsCount;this._endIndex=Math.min(this._startIndex+s,this._listItems.length);const r=document.createDocumentFragment();for(let o=this._startIndex;o<this._endIndex;o++){const a=this._listItems[o];if(a){const l=this._createLegendItem(a);l.style.position="absolute",l.style.top=`${o*e}px`,r.appendChild(l)}}this._legendItems.innerHTML="",this._legendItems.appendChild(r),this._updateShowMoreButton()}_createElements(){this._wrapper=document.createElement("div"),this._wrapper.classList.add(Sn.wrapper),this._label=document.createElement("div"),this._label.classList.add("name"),this._wrapper.appendChild(this._label),this._scrollContainer=document.createElement("div"),this._scrollContainer.classList.add("scroll-container"),this._scrollContainer.addEventListener("scroll",this._handleScroll,{passive:!0}),this._legendItems=document.createElement("div"),this._legendItems.className="legend-items",this._scrollContainer.appendChild(this._legendItems),this._showMoreButton=this._createShowMoreButton(),this._wrapper.appendChild(this._scrollContainer),this._wrapper.appendChild(this._showMoreButton),this._containerNode.appendChild(this._wrapper),this._isHidden||this.show()}_createShowMoreButton(){const e=document.createElement("div");e.classList.add("show-more"),e.addEventListener("click",this._handleShowMore);const t=document.createElement("span");return e.appendChild(t),e}_updateShowMoreButton(){this._isExpanded?this._showMoreButton.firstChild.textContent="show less":this._handleShowMoreCount()}_calculateItemDimensions(){const e=this._createLegendItem({label:"Sample",color:"#000000"});e.style.visibility="hidden",e.style.position="absolute",this._legendItems.appendChild(e);const t=window.getComputedStyle(e);this._itemHeight=e.offsetHeight,this._itemMargin=parseFloat(t.marginTop)+parseFloat(t.marginBottom),this._legendItems.removeChild(e)}_createLegendItem(e){const t=document.createElement("div");t.classList.add("legend-item"),t.title=e.label,this._config.alignRight&&t.classList.add("reverted"),this._selectedItem&&t.classList.add(this._selectedItem.label===e.label?Sn.selected:Sn.unselected),this._config.enableEvents&&(this._config.onClick&&(t.style.cursor="pointer",t.addEventListener("click",r=>this._config.onClick(r,e))),this._config.onHover&&(t.addEventListener("mouseenter",r=>{t.classList.add(Sn.hovered),this._config.onHover(r,e)}),t.addEventListener("mouseleave",r=>{t.classList.remove(Sn.hovered),this._config.onHover(r,e)})));const n=document.createElement("div");n.className="bullet",n.style.backgroundColor=e.color;const s=document.createElement("div");return s.className="label",s.style.whiteSpace="nowrap",s.textContent=e.label,t.appendChild(n),t.appendChild(s),t}_calculateOptimalWidth(){var e;if(!this._listItems.length)return;let t=0;for(const d of this._listItems)d.label&&d.label.length>t&&(t=d.label.length);if(this._listItems.length>(this._config.maxDisplayedItems||ja)){const d=this._listItems.length-(this._config.maxDisplayedItems||ja);t=Math.max(t,`${d} more...`.length,9)}if(t<=this._maxMeasuredCharLength){this._maxMeasuredWidth&&this._applyCalculatedWidth(this._maxMeasuredWidth);return}this._maxMeasuredCharLength=t;const n=getComputedStyle(this._containerNode).getPropertyValue("--cosmograph-color-legend-type-font-size")||"11px",s=getComputedStyle(this._containerNode).getPropertyValue("--cosmograph-color-legend-type-font-family")||"inherit",r="300",o=document.createElement("canvas").getContext("2d");o.font=`${r} ${n} ${s}`;let a=0;if(this._listItems.forEach(d=>{const h=o.measureText(d.label).width;h>a&&(a=h)}),this._listItems.length>(this._config.maxDisplayedItems||ja)){const d=this._listItems.length-(this._config.maxDisplayedItems||ja);a=Math.max(a,o.measureText(`${d} more...`).width,o.measureText("show less").width)}const l=13+a+10,c=((e=this._containerNode.parentElement)==null?void 0:e.offsetWidth)||0,u=c>0?Math.min(c-20,l):l;this._calculatedWidth=Math.max(100,u),this._maxMeasuredWidth=this._calculatedWidth,this._applyCalculatedWidth(this._calculatedWidth)}_applyCalculatedWidth(e){this._containerNode.style.minWidth=`${e}px`,this._wrapper.style.minWidth=`${e}px`}}const cZ={onClick:void 0,iconSvg:void 0,description:void 0},uZ="style_module_button__e95a1138",dZ={button:uZ};(function(){try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes style_module_fadeIn__ffac87fd{0%{opacity:0}to{opacity:.2}}.style_module_displayState__6ae19b84{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--cosmograph-ui-text);display:flex;justify-content:center;align-items:center;min-width:100px;opacity:.2;font-size:calc(var(--cosmograph-ui-font-size) + 1px);letter-spacing:-.02em;font-weight:200;user-select:none;-webkit-user-select:none;animation:style_module_fadeIn__ffac87fd .3s ease-in-out}:root{--cosmograph-timeline-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-timeline-selection-opacity: .5;--cosmograph-timeline-bar-color: var(--cosmograph-ui-element-color);--cosmograph-timeline-highlighted-bar-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-timeline-font-family: var(--cosmograph-ui-font-family);--cosmograph-timeline-font-size: var(--cosmograph-ui-tick-font-size);--cosmograph-timeline-background: var(--cosmograph-ui-background);--cosmograph-timeline-text-color: var(--cosmograph-ui-text);--cosmograph-timeline-axis-color: var(--cosmograph-ui-text)}.style_module_timeline__736434f7{position:relative;display:flex;background:var(--cosmograph-timeline-background);width:100%;min-height:25px;overflow:hidden}.style_module_timelineSvg__b916ad04{position:relative;width:100%;height:100%}.style_module_selection__ebee57f8{fill:var(--cosmograph-timeline-selection-color);fill-opacity:var(--cosmograph-timeline-selection-opacity);stroke:none}.style_module_axisTick__5865631d{color:var(--cosmograph-timeline-axis-color);font:var(--cosmograph-timeline-font-family);font-size:var(--cosmograph-timeline-font-size);user-select:none;-webkit-user-select:none;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum";alignment-baseline:text-before-edge}.style_module_axisLine__992b502d{opacity:.2;color:var(--cosmograph-timeline-axis-color)}.style_module_bar__114fa79f{fill:var(--cosmograph-timeline-bar-color);transform:scaleY(-1);opacity:0}.style_module_animationControl__ee52cd66{color:var(--cosmograph-timeline-axis-color);width:6%;max-width:30px;min-width:20px;cursor:pointer;display:none;align-items:center;user-select:none;-webkit-user-select:none;opacity:.5;position:relative;justify-content:center}.style_module_animationControl__ee52cd66>svg{width:50%;max-height:20px;padding-right:2px}.style_module_hidden__a73fe81a{display:none}.style_module_disabled__eb988570{opacity:.2;pointer-events:none}.style_module_highlightedBar__c2fc9bdc{fill:var(--cosmograph-timeline-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-search-font-family: var(--cosmograph-ui-font-family);--cosmograph-search-font-size: 14px;--cosmograph-search-list-font-size: 13.5px;--cosmograph-search-text-color: var(--cosmograph-ui-text);--cosmograph-search-background: transparent;--cosmograph-search-list-background: rgba(0, 0, 0, .2);--cosmograph-search-list-match-background: rgba(255, 255, 255, .2);--cosmograph-search-list-match-color: var(--cosmograph-ui-text)}.style_module_searchInput__d7830601:hover{filter:brightness(1.2) contrast(1)}.style_module_searchInput__d7830601{width:100%;background:transparent;color:var(--cosmograph-search-text-color);border:none;border-bottom:.5px solid var(--cosmograph-search-text-color);padding:4px 20px 5px 2px;font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .2s ease-out}.style_module_searchInput__d7830601::selection{background:var(--cosmograph-search-list-match-background)}.style_module_searchInput__d7830601:focus{outline:none}.style_module_searchSuggestions__b0d3f71e{color:#fff;width:100%;padding:0;margin:0;background:transparent;overflow-y:auto;flex:1;min-height:0}.style_module_searchSuggestions__b0d3f71e li{padding:5px 10px;cursor:pointer;-webkit-user-select:none;user-select:none;display:block;font-weight:500;font-size:var(--cosmograph-search-list-font-size);max-width:100%;overflow:hidden}.style_module_searchSuggestions__b0d3f71e li>div{white-space:nowrap;font-weight:200;overflow:hidden;text-overflow:ellipsis;width:100%}.style_module_searchSuggestions__b0d3f71e li:hover{background:#ffffff1a}.style_module_searchSuggestions__b0d3f71e mark{background:var(--cosmograph-search-list-match-background);color:var(--cosmograph-search-list-match-color);border-radius:2px}.style_module_clearButton__5ebb41de{position:absolute;right:0;top:0;height:100%;background:none;border:none;color:var(--cosmograph-search-text-color);font-weight:300;cursor:pointer;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_clearButton__5ebb41de.style_module_visible__5be7493d{opacity:.7}.style_module_placeholderWrapper__72d5eb0e{z-index:1;color:var(--cosmograph-search-text-color);font-family:var(--cosmograph-search-font-family);font-size:var(--cosmograph-search-font-size);position:absolute;top:0;left:0;width:100%;bottom:0;display:flex;line-height:1.25;align-items:center;transition:transform .3s ease-out,opacity .3s ease-out}.style_module_placeholderWrapper__72d5eb0e.style_module_hidden__acfb8431{transform:translate(-30px);pointer-events:none;opacity:0}.style_module_searchInput__d7830601:disabled,.style_module_searchInput__d7830601.style_module_disabled__62c35dc5{opacity:.2;cursor:not-allowed;pointer-events:none}.style_module_disabled__62c35dc5 .style_module_clearButton__5ebb41de{display:none}.style_module_disabled__62c35dc5 .style_module_placeholderWrapper__72d5eb0e{opacity:.3;cursor:not-allowed}.style_module_searchInputWrapper__1edbcb22{position:relative;display:flex;width:100%}.style_module_noResults__363397c3{opacity:.3!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none}.style_module_noResults__363397c3:hover{background:none}.style_module_loading__296e0212{opacity:.7!important;cursor:default;font-weight:300!important;padding:6px!important;text-align:center;pointer-events:none;-webkit-user-select:none;user-select:none}.style_module_dropdownContainer__d98287da{position:absolute;top:100%;left:0;width:100%;background:var(--cosmograph-search-list-background);border-radius:4px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;pointer-events:none;overflow:hidden;z-index:10;display:flex;flex-direction:column;padding-bottom:2px}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b{top:auto;bottom:100%;transform:translateY(10px)}.style_module_dropdownContainer__d98287da.style_module_visible__5be7493d{opacity:1;transform:translateY(0);pointer-events:auto}.style_module_dropdownContainer__d98287da.style_module_upwards__e0b4831b.style_module_visible__5be7493d{opacity:1;transform:translateY(-2px);pointer-events:auto}.style_module_footerContainer__73e7a066{flex-shrink:0}:root{--cosmograph-scrollbar-background: rgba(255, 255, 255, .1);--cosmograph-ui-background: rgb(45, 49, 58);--cosmograph-ui-text: #ffffffc7;--cosmograph-ui-tick-font-size: 11px;--cosmograph-ui-font-size: 12px;--cosmograph-ui-font-family: inherit;--cosmograph-ui-element-color: #5C616A;--cosmograph-ui-highlighted-element-color: white;--cosmograph-ui-selection-control-color: #8d949ea8;-webkit-font-smoothing:antialiased!important;text-rendering:optimizeLegibility!important}.style_module_cosmograph-ui__5acb97f1{background:var(--cosmograph-ui-background);color:var(--cosmograph-ui-text)}.style_module_scrollbar__f1516254 *::-webkit-scrollbar{width:5px;height:5px;border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-track{border-radius:.3rem}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-corner{background:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-button{display:none!important}.style_module_scrollbar__f1516254 *::-webkit-scrollbar-thumb{background-color:var(--cosmograph-scrollbar-background);transition:background-color .5s;border-radius:20px;border:3px solid var(--cosmograph-scrollbar-background)}@-moz-document url-prefix(){.style_module_scrollbar__f1516254 *{scrollbar-width:thin;scrollbar-color:var(--cosmograph-scrollbar-background) transparent;scrollbar-track-color:transparent;scrollbar-face-color:var(--cosmograph-scrollbar-background)}}:root{--cosmograph-histogram-background: var(--cosmograph-ui-background);--cosmograph-histogram-text-color: var(--cosmograph-ui-text);--cosmograph-histogram-axis-color: var(--cosmograph-ui-text);--cosmograph-histogram-selection-color: var(--cosmograph-ui-selection-control-color);--cosmograph-histogram-selection-opacity: .5;--cosmograph-histogram-bar-color: var(--cosmograph-ui-element-color);--cosmograph-histogram-highlighted-bar-color: var( --cosmograph-ui-highlighted-element-color);--cosmograph-histogram-font-family: var(--cosmograph-ui-font-family);--cosmograph-histogram-font-size: var(--cosmograph-ui-tick-font-size)}.style_module_histogram__9d8a77ea{position:relative;display:flex;min-height:25px;background:var(--cosmograph-histogram-background);width:100%}.style_module_histogramSvg__ccccb628{position:relative;width:100%;height:100%}.style_module_selection__7db96137{fill:var(--cosmograph-histogram-selection-color);fill-opacity:var(--cosmograph-histogram-selection-opacity);stroke:none}.style_module_axisTick__898e1f39{color:var(--cosmograph-histogram-axis-color);font-family:var(--cosmograph-histogram-font-family);font-size:var(--cosmograph-histogram-font-size);user-select:none;-webkit-user-select:none;alignment-baseline:text-before-edge;opacity:1;font-weight:300;text-anchor:initial;font-feature-settings:"tnum"}.style_module_bar__3c9ab488{fill:var(--cosmograph-histogram-bar-color);transform:scaleY(-1)}.style_module_highlightedBar__b193a8de{fill:var(--cosmograph-histogram-highlighted-bar-color);transform:scaleY(-1);pointer-events:none}:root{--cosmograph-bars-font-color: var(--cosmograph-ui-text);--cosmograph-bars-font-family: var(--cosmograph-ui-font-family);--cosmograph-bars-font-size: var(--cosmograph-ui-font-size);--cosmograph-bars-ui-font-size: 11.5px;--cosmograph-bars-background: var(--cosmograph-ui-element-color);--cosmograph-bars-bar-height: 20px;--cosmograph-bars-bar-bottom-margin: 2px;--cosmograph-bars-highlighted-color: var( --cosmograph-ui-highlighted-element-color)}.style_module_bars__25497ded{position:relative;width:100%;min-height:100px;user-select:none;flex-direction:column;-webkit-user-select:none}.style_module_bars__25497ded .scroll-container{position:relative;width:100%;overflow-y:hidden;overflow-x:hidden}.style_module_bars__25497ded .bars-container{position:relative;width:calc(100% - 1px);font-family:var(--cosmograph-bars-font-family)}.style_module_bars__25497ded .highlighted-bars-container{position:absolute;top:0;left:0;pointer-events:none}.style_module_bars__25497ded .row{height:var(--cosmograph-bars-bar-height);display:flex;align-items:center;margin-bottom:var(--cosmograph-bars-bar-bottom-margin);width:100%;transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row:hover{filter:brightness(1.15) contrast(1.05);transition:opacity .1s linear,filter .1s linear}.style_module_bars__25497ded .row.unselected:hover{filter:brightness(.95) contrast(1.15);transition:filter .05s linear}.style_module_bars__25497ded .unselected{opacity:.85;filter:brightness(.8) contrast(1.1)}.style_module_bars__25497ded .selected{filter:brightness(1.05) contrast(1.05)}.style_module_bars__25497ded .selected>.info>.label{font-weight:600;filter:brightness(1.1) contrast(1.05)}.style_module_bars__25497ded .unselected>.info>.label{font-weight:300}.style_module_bars__25497ded .bar{height:100%;background-color:var(--cosmograph-bars-background);opacity:.8;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .bar-highlighted{height:100%;background-color:var(--cosmograph-bars-highlighted-color);opacity:.2;transition:opacity .3s ease,width .3s ease}.style_module_bars__25497ded .info{display:flex;justify-content:space-between;width:100%;padding:0 4px;position:absolute;font-size:var(--cosmograph-bars-font-size);font-feature-settings:"tnum";color:var(--cosmograph-bars-font-color);gap:2px}.style_module_bars__25497ded .label{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:opacity .05s linear}.style_module_bars__25497ded .count{flex-shrink:0;font-weight:300;opacity:.8;transition:opacity .05s linear}.style_module_bars__25497ded .show-more{cursor:pointer;padding-top:2px;display:flex;font-weight:300;color:var(--cosmograph-bars-font-color);font-size:11px;justify-content:space-between;opacity:.6;font-size:var(--cosmograph-bars-ui-font-size);pointer-events:none;transition:opacity .1s linear}.style_module_bars__25497ded .show-more:hover{opacity:1;text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .show-more>span{pointer-events:all}.style_module_bars__25497ded .show-more-count{padding-right:5px;pointer-events:all;font-feature-settings:"tnum"}.style_module_bars__25497ded .unselected>.info>.label,.style_module_bars__25497ded .unselected>.info>.count{opacity:.5}.style_module_bars__25497ded .unselected:hover>.info>.label,.style_module_bars__25497ded .unselected:hover>.info>.count{opacity:1}.style_module_bars__25497ded .search-input{background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,.3);font-size:13px!important;color:var(--cosmograph-bars-font-color);line-height:1.5;padding:2px;width:100%;position:relative;transition:border-bottom-color .2s}.style_module_bars__25497ded .search-input::placeholder{color:var(--cosmograph-bars-font-color)!important;opacity:.4;font-weight:300;font-family:inherit}.style_module_bars__25497ded .search-container{position:relative;width:100%;margin-bottom:4px;display:none;z-index:1}.style_module_bars__25497ded .clear-button{position:absolute;right:0;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--cosmograph-bars-font-color);font-weight:300;font-size:16px;padding:0 4px;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-out}.style_module_bars__25497ded .clear-button.visible:hover{transition:opacity .1s ease-in-out;opacity:1}.style_module_bars__25497ded .clear-button.visible{opacity:.7}.style_module_bars__25497ded .clear-button svg{width:10px;height:10px;fill:currentColor}.style_module_bars__25497ded .sorting-block{visibility:hidden;margin-top:1px;display:flex;justify-content:space-between}.style_module_bars__25497ded .buttons-container{margin-top:4px;font-size:var(--cosmograph-bars-ui-font-size);display:flex;gap:4px;line-height:1.25}.style_module_bars__25497ded .buttons-container>div{transition:opacity .05s linear,filter .05s linear;padding:1px 5px;background:var(--cosmograph-bars-background);border-radius:4px;opacity:.9;display:flex;cursor:pointer;align-items:center}.style_module_bars__25497ded .buttons-container>div:hover{filter:brightness(1.2)}.style_module_bars__25497ded .reset-text{transition:opacity .05s linear,filter .05s linear;display:flex;font-size:var(--cosmograph-bars-ui-font-size);align-items:end;padding-right:4px;cursor:pointer;font-weight:300}.style_module_bars__25497ded .reset-text:hover{text-decoration:underline;text-underline-offset:1.5px;text-decoration-thickness:.25px}.style_module_bars__25497ded .reset-text.unselected{pointer-events:none;cursor:default;opacity:.7}.style_module_bars__25497ded :scope.reset-text:hover:not(.unselected){filter:brightness(1.5);opacity:1}:root{--cosmograph-size-legend-form-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-color: var(--cosmograph-ui-text);--cosmograph-size-legend-font-family: inherit;--cosmograph-size-legend-font-size: var(--cosmograph-ui-font-size);--cosmograph-size-legend-sublabel-font-size: 10px;--cosmograph-size-legend-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-size-legend-line-radius: 2px;--cosmograph-size-legend-line-width: 30px;--cosmograph-size-legend-hide-transform: translateY(100%);--cosmograph-size-legend-show-transform: translateX(0)}.style_module_container__d2889234{display:flex;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;overflow:hidden;min-height:25px}.style_module_legend__75c167f2{width:auto;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-size-legend-font-size);font-family:var(--cosmograph-size-legend-font-family);user-select:none;-webkit-user-select:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.04em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__91eae57a{opacity:1;transform:var(--cosmograph-size-legend-show-transform)}.style_module_disabled__d51f7a10{opacity:0;transform:var(--cosmograph-size-legend-hide-transform);pointer-events:none;display:none!important;min-height:0}@starting-style{.style_module_container__d2889234.style_module_enabled__91eae57a,.style_module_legend__75c167f2.style_module_enabled__91eae57a{opacity:0;transform:var(--cosmograph-size-legend-hide-transform)}}.style_module_legend__75c167f2 .circle{background-color:var(--cosmograph-size-legend-form-color);border-radius:50%;transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2 .line{background-color:var(--cosmograph-size-legend-form-color);border-radius:var(--cosmograph-size-legend-line-radius);width:var(--cosmograph-size-legend-line-width);transition:background-color .15s ease-in-out;display:inline-block}.style_module_legend__75c167f2.style_module_events__894316a8{pointer-events:auto;cursor:pointer}.style_module_legend__75c167f2 .legend-content{display:flex;align-items:end;justify-content:center;gap:.75rem}.style_module_legend__75c167f2 .legend-content>div{transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__75c167f2 .labels-wrapper{white-space:nowrap}.style_module_legend__75c167f2 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-size-legend-items-margin)}.style_module_legend__75c167f2 .name{align-items:center;text-align:center;justify-content:center;display:flex;color:var(--cosmograph-size-legend-font-color);overflow:hidden;width:100%;margin-top:3px;word-break:break-all;white-space:pre-line;transition:color .15s ease-in-out;letter-spacing:-.02em}.style_module_legend__75c167f2 .label{color:var(--cosmograph-size-legend-font-color);overflow:hidden;transition:color .15s ease-in-out;text-overflow:ellipsis;font-feature-settings:"tnum"}.style_module_legend__75c167f2 .sublabel{padding-top:1px;font-size:var(--cosmograph-size-legend-sublabel-font-size);opacity:.5;line-height:1;min-width:10px;transition:color .15s ease-in-out}.style_module_hovered__1206707f .label,.style_module_hovered__1206707f .sublabel{color:var(--cosmograph-size-legend-hover-color);cursor:pointer}.style_module_hovered__1206707f .circle,.style_module_hovered__1206707f .line{background-color:var(--cosmograph-size-legend-hover-color);cursor:pointer}:root{--cosmograph-color-legend-range-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-range-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-range-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-label-font-size: var(--cosmograph-ui-font-size);--cosmograph-color-legend-range-sublabel-font-size: 10px;--cosmograph-color-legend-range-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-range-gradient-height: 6px;--cosmograph-color-legend-range-gradient-radius: 8px;--cosmograph-color-legend-range-gradient-top-margin: 6px;--cosmograph-color-legend-hide-transform: translateY(100%);--cosmograph-color-legend-show-transform: translateX(0)}.style_module_container__05cc807d{display:flex;min-width:150px;min-height:25px;width:100%;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_legend__a3e235e4{width:100%;font-weight:300;letter-spacing:-.04em;display:flex;flex-direction:column;font-size:var(--cosmograph-color-legend-range-font-size);font-family:var(--cosmograph-color-legend-range-font-family);user-select:none;-webkit-user-select:none;pointer-events:none;cursor:default;text-align:center;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_enabled__b3120e27{opacity:1;transform:var(--cosmograph-color-legend-show-transform);pointer-events:auto}.style_module_disabled__c2dc158c{opacity:0;transform:var(--cosmograph-color-legend-hide-transform);pointer-events:none;display:none;min-height:0}@starting-style{.style_module_container__05cc807d.style_module_enabled__b3120e27,.style_module_legend__a3e235e4.style_module_enabled__b3120e27{opacity:0;transform:var(--cosmograph-color-legend-hide-transform)}}.style_module_legend__a3e235e4 .legend-content{display:flex;align-items:end;justify-content:space-between}.style_module_hovered__dfd7bb2c .label,.style_module_hovered__dfd7bb2c .sublabel{color:var(--cosmograph-size-legend-hover-color)!important;cursor:pointer}.style_module_legend__a3e235e4 .extent{white-space:nowrap;transition:filter .1s ease-in-out,opacity .1s ease-in-out}.style_module_legend__a3e235e4 .gradient{width:100%;margin-top:var(--cosmograph-color-legend-range-gradient-top-margin);height:var(--cosmograph-color-legend-range-gradient-height);border-radius:var(--cosmograph-color-legend-range-gradient-radius)}.style_module_legend__a3e235e4 .legend-item{display:flex;align-items:center;margin-top:var(--cosmograph-color-legend-range-items-margin)}.style_module_legend__a3e235e4 .name{align-items:center;text-align:center;justify-content:space-around;display:flex;color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;width:100%;word-break:break-word;text-wrap:balance;white-space:pre-line;transition:color .15s ease-in-out;margin:0 4px;letter-spacing:-.02em;line-height:1.25}.style_module_legend__a3e235e4 .label{color:var(--cosmograph-color-legend-range-font-color);overflow:hidden;max-width:150px;text-overflow:ellipsis;font-size:var(--cosmograph-color-legend-range-label-font-size);transition:color .15s ease-in-out;line-height:1;font-feature-settings:"tnum"}.style_module_legend__a3e235e4 .sublabel{padding-top:1px;color:var(--cosmograph-color-legend-range-font-color);opacity:.55;font-size:var(--cosmograph-color-legend-range-sublabel-font-size);line-height:1;transition:color .15s ease-in-out}:root{--cosmograph-color-legend-type-font-color: var(--cosmograph-ui-text);--cosmograph-color-legend-type-font-family: var(--cosmograph-ui-font-family);--cosmograph-color-legend-type-font-size: 11px;--cosmograph-color-legend-type-hover-color: var(--cosmograph-ui-highlighted-element-color);--cosmograph-color-legend-type-others-color: #bab0ab;--cosmograph-color-legend-type-bullet-size: 8px;--cosmograph-color-legend-type-bullet-radius: 1rem;--cosmograph-color-legend-type-items-margin: 4px;--cosmograph-color-legend-type-hide-transform: translateY(125%);--cosmograph-color-legend-type-show-transform: translateX(0)}.style_module_enabled__277b2403{opacity:1;transform:var(--cosmograph-color-legend-type-show-transform)}.style_module_disabled__7a587f96{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform);display:none!important;min-height:0}.style_module_wrapper__ea8ca7f4{position:relative;max-width:100%;width:fit-content;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out}.style_module_typeLegend__15bf4b2f{position:relative;width:fit-content;max-width:100%;min-height:25px;transition:opacity .3s ease-in-out,transform .3s ease-in-out,display .3s allow-discrete,min-height .3s ease-in-out;font-weight:300;letter-spacing:-.015em;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased}.style_module_typeLegend__15bf4b2f .reverted{flex-direction:row-reverse}.style_module_typeLegend__15bf4b2f .scroll-container{width:100%;display:flex;flex-direction:column;position:relative;font-size:var(--cosmograph-color-legend-type-font-size);font-family:var(--cosmograph-color-legend-type-font-family);user-select:none;-webkit-user-select:none;line-height:normal;overflow-x:hidden;overflow-y:auto;will-change:transform}@starting-style{.style_module_typeLegend__15bf4b2f.style_module_enabled__277b2403,.style_module_wrapper__ea8ca7f4.style_module_enabled__277b2403{opacity:0;transform:var(--cosmograph-color-legend-type-hide-transform)}}.style_module_typeLegend__15bf4b2f .legend-item{display:flex;align-items:center;position:absolute;margin-bottom:var(--cosmograph-color-legend-type-items-margin);pointer-events:none;width:100%;padding-left:1px;font-weight:300;transition:filter .1s ease-in-out,opacity .1s ease-in-out;min-height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px + var(--cosmograph-color-legend-type-items-margin));height:calc(var(--cosmograph-color-legend-type-bullet-size) + 2px);box-sizing:border-box}.style_module_typeLegend__15bf4b2f .unknown{background-color:var(--cosmograph-color-legend-type-unknown-color)}.style_module_typeLegend__15bf4b2f .others{background-color:var(--cosmograph-color-legend-type-others-color)}.style_module_typeLegend__15bf4b2f .bullet{height:var(--cosmograph-color-legend-type-bullet-size);width:var(--cosmograph-color-legend-type-bullet-size);min-height:var(--cosmograph-color-legend-type-bullet-size);min-width:var(--cosmograph-color-legend-type-bullet-size);border-radius:var(--cosmograph-color-legend-type-bullet-radius);pointer-events:all;margin-right:5px}.style_module_typeLegend__15bf4b2f .label{color:var(--cosmograph-color-legend-type-font-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - var(--cosmograph-color-legend-type-bullet-size) - 5px);pointer-events:all;transition:.05s linear color}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.bullet{margin-right:0}.style_module_typeLegend__15bf4b2f .legend-item.reverted>.label{margin-right:5px}.style_module_typeLegend__15bf4b2f .show-more{cursor:pointer;padding-top:4px;display:none;font-weight:300;color:var(--cosmograph-color-legend-type-font-color);font-size:11px;opacity:.6;pointer-events:all;justify-content:space-between;transition:opacity .1s linear;font-feature-settings:"tnum"}.style_module_typeLegend__15bf4b2f .show-more:hover{opacity:1}.style_module_hovered__c0993502 .label,.style_module_hovered__c0993502 .sublabel{color:var(--cosmograph-color-legend-type-hover-color)!important;cursor:pointer}.style_module_selected__36e1dd81{filter:brightness(1)}.style_module_selected__36e1dd81>.style_module_label__afecc7a3{filter:brightness(1.2)}.style_module_unselected__4826cfb7{filter:brightness(.5)}.style_module_typeLegend__15bf4b2f .name{font-size:calc(var(--cosmograph-color-legend-type-font-size) + 1px);font-family:var(--cosmograph-color-legend-type-font-family);color:var(--cosmograph-color-legend-type-font-color);transition:color .15s ease-in-out,opacity .3s ease-in-out,max-height .3s ease-in-out,transform .3s ease-in-out;margin-bottom:4px;margin-top:2px;margin-left:1px;letter-spacing:-.02em;line-height:1.25;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis;pointer-events:all;-webkit-user-select:none!important;user-select:none!important;max-height:100px;opacity:1;transform:translateY(0)}.style_module_typeLegend__15bf4b2f .name.hidden{opacity:0;max-height:0;margin-bottom:0;margin-top:0;transform:translateY(-10px)}:root{--cosmograph-button-color: var(--cosmograph-ui-text);--cosmograph-button-background: var(--cosmograph-ui-element-color);--cosmograph-button-border-radius: 2px}.style_module_button__e95a1138{background:var(--cosmograph-button-background);color:var(--cosmograph-button-color);border-radius:var(--cosmograph-button-border-radius);display:none;align-items:center;justify-content:center;width:25px;height:25px;margin:3px;padding:5px;cursor:pointer;filter:brightness(.95) contrast(.9);transition:filter .1s}.style_module_button__e95a1138:hover{filter:brightness(1.2) contrast(1)}')),document.head.appendChild(i)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var hZ=Object.defineProperty,fZ=(i,e,t)=>e in i?hZ(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Jm=(i,e,t)=>fZ(i,typeof e!="symbol"?e+"":e,t);let Ca=class{constructor(e,t){Jm(this,"_container"),Jm(this,"config"),Jm(this,"_handleClick",()=>{var n,s;(s=(n=this.config).onClick)==null||s.call(n)}),this._container=e,this._container.classList.add(dZ.button),this.setConfig(t??{}),this._container.addEventListener("click",this._handleClick)}get element(){return this._container}setConfig(e){this.config=Yt(cZ,e),this._container.title=this.config.description??"",this._container.innerHTML=this.config.iconSvg??""}show(){this._container.style.display="block"}hide(){this._container.style.display="none"}destroy(){this._container.removeEventListener("click",this._handleClick),this._container.innerHTML=""}};const pZ={Points:"points",PointId:"pointIdBy",PointIndex:"pointIndexBy"},Ct={PointColor:"pointColorBy",PointColorMap:"pointColorByMap",PointColorFn:"pointColorByFn",PointColorPalette:"pointColorPalette",PointColorStrategy:"pointColorStrategy",PointSize:"pointSizeBy",PointSizeStrategy:"pointSizeStrategy",PointSizeRange:"pointSizeRange",PointSizeFn:"pointSizeByFn",PointLabel:"pointLabelBy",PointLabelWeight:"pointLabelWeightBy",PointX:"pointXBy",PointY:"pointYBy",PointCluster:"pointClusterBy",PointClusterFn:"pointClusterByFn",PointClusterStrength:"pointClusterStrengthBy",PointIncludeColumns:"pointIncludeColumns"},mZ={Links:"links",LinkSource:"linkSourceBy",LinkSourceIndex:"linkSourceIndexBy",LinkTarget:"linkTargetBy",LinkTargetIndex:"linkTargetIndexBy"},ei={LinkColor:"linkColorBy",LinkColorFn:"linkColorByFn",LinkColorPalette:"linkColorPalette",LinkColorStrategy:"linkColorStrategy",LinkWidth:"linkWidthBy",LinkWidthRange:"linkWidthRange",LinkWidthFn:"linkWidthByFn",LinkWidthStrategy:"linkWidthStrategy",LinkArrow:"linkArrowBy",LinkArrowFn:"linkArrowByFn",LinkStrength:"linkStrengthBy",LinkStrengthFn:"linkStrengthByFn",LinkStrengthRange:"linkStrengthRange",LinkIncludeColumns:"linkIncludeColumns"},gZ={ClusterPositionsMap:"clusterPositionsMap"},_Z=Object.values(Ct),yZ=Object.values(ei),bZ=Object.values(gZ),JA=Object.values(pZ),eI=Object.values(mZ),vZ=[...yZ].filter(i=>i!==ei.LinkIncludeColumns).concat("linkDefaultColor","linkDefaultWidth"),xZ=[..._Z].filter(i=>i!==Ct.PointLabel&&i!==Ct.PointLabelWeight&&i!==Ct.PointIncludeColumns).concat("pointDefaultColor","pointDefaultSize"),V_={ShowLabels:"showLabels",ShowDynamicLabels:"showDynamicLabels",ShowTopLabels:"showTopLabels",ShowTopLabelsLimit:"showTopLabelsLimit",ShowLabelsFor:"showLabelsFor",ShowClusterLabels:"showClusterLabels",PointLabelClassName:"pointLabelClassName",PointLabelFn:"pointLabelFn",PointLabelWeightFn:"pointLabelWeightFn",PointLabelColor:"pointLabelColor",PointLabelFontSize:"pointLabelFontSize",ClusterLabelFontSize:"clusterLabelFontSize",ClusterLabelClassName:"clusterLabelClassName",ScaleClusterLabels:"scaleClusterLabels",UsePointColorStrategyForClusterLabels:"usePointColorStrategyForClusterLabels",StaticLabelWeight:"staticLabelWeight",DynamicLabelWeight:"dynamicLabelWeight",LabelMargin:"labelMargin",LabelPadding:"labelPadding",CustomLabels:"customLabels"},wZ=[...Object.values(V_),Ct.PointLabel,Ct.PointLabelWeight],od=.95,ad=.05,cu=[2,9],tI=[1,9],SZ=[.2,1],EZ=8192,iI=["rgba(43, 85, 168, 0.85)","rgba(153, 82, 213, 0.85)","rgba(240, 105, 180, 0.85)","rgba(255, 149, 131, 0.85)","rgba(254, 224, 139, 0.85)"],nI=["#206176","#38657e","#506987","#686d90","#807098","#9874a1","#af78a9","#c77cb2","#df7fba","#f783c3","#FFB4D3","#f6c0d8"],Lv="rgb(45, 49, 58)",tc="rgba(205, 207, 213, 0.9)",G_=tc,CZ=tc,xc=16,TZ=!1,kZ="color: white; background: #333841;",AZ="background: none; font-weight: 300; opacity: 0.9;",eg={showLabels:!0,showTopLabels:!0,showDynamicLabels:!0,showHoveredPointLabel:!1,scaleClusterLabels:!0,usePointColorStrategyForClusterLabels:!1,showTopLabelsLimit:30,staticLabelWeight:.8,dynamicLabelWeight:.7,pointGreyoutOpacity:.3,labelMargin:5,pointSamplingDistance:170,labelPadding:[6.5,4.5,6.5,4.5],preservePointPositionsOnDataUpdate:!1,backgroundColor:Lv,hoveredPointLabelClassName:kZ,pointLabelFontSize:13,clusterLabelFontSize:16,clusterLabelClassName:AZ,pointSizeRange:cu,linkWidthRange:tI,linkStrengthRange:SZ,pointColorPalette:iI,linkColorPalette:nI,pointDefaultColor:G_,linkDefaultColor:CZ,unknownColor:tc,hoveredLinkWidthIncrease:0,simulationRepulsion:.5,simulationFriction:.5,simulationLinkSpring:.4,simulationLinkDistance:20,resetSelectionOnEmptyCanvasClick:!0},tp=i=>i===Ct.PointLabel?"":i===Ct.PointLabelWeight||i===Ct.PointX||i===Ct.PointY||i===Ct.PointCluster?0:i===Ct.PointClusterStrength?1:i===ei.LinkStrength?0:i===ei.LinkArrow?TZ:0,Ta=async(i,e)=>{const t=await i.query("SHOW ALL TABLES"),n=t==null?void 0:t.toArray();if(!(n!=null&&n.length))return!1;const[s,r]=e.includes(".")?e.split("."):["main",e];return n.find(o=>o.name===r&&o.schema===s)!==void 0},sI=async(i,e)=>{const t=await i.query(`PRAGMA table_info(${e})`);return t?t.toArray().map(({name:n,type:s})=>({name:n,type:s})):[]},Yw=async(i,e)=>await Ta(i,e)?(await i.query(`SUMMARIZE ${e}`)).toArray():[],Hl=async(i,e)=>{const t=await sI(i,e);return t?t.map(n=>n.name):[]},Hp=async(i,e,t,n)=>{const s=await Hl(i,e);if(!s.length)return n==null||n.push(...t),!1;const r=new Set(s),o=t.filter(a=>!r.has(a));return n==null||n.push(...o),o.length===0},Qd=(i,e,t=4)=>{if(i.size>=e.length/t)return new Float32Array(0);const n=new Float32Array(e.length-i.size*t);let s=0;for(let r=0;r<e.length;r+=t)i.has(r/t)||(n.set(e.subarray(r,r+t),s),s+=t);return n},W_=i=>{const e=new Map;for(const t of i)e.set(t,(e.get(t)||0)+1);return Array.from(e.entries()).sort((t,n)=>n[1]-t[1]).map(t=>t[0])},Rv=(i,e,t)=>i.length?i.reduce((n,s,r)=>(t(s,e)&&n.push(r),n),[]):[],Uu=(i,e)=>{const t=El(i,ad),n=El(i,od);if(t===n){const[s,r]=Rn(i);return e?e(s,r):[s,r]}return e?e(t,n):[t,n]},rI=(i,e,t)=>{if(!i.length)return t;const n=e?Uu(i):Rn(i);if(n[0]===void 0||n[1]===void 0)return t;if(!t)return n;if(!e)return t;const[s,r]=t,[o,a]=n,l=Math.max(s,o),c=Math.min(r,a);return!Number.isFinite(l)||!Number.isFinite(c)||l>=c?t:[l,c]},IZ=(i,e)=>{if(!(i!=null&&i.length))return[];const t=[],n=e;for(let s=0;s<i.length;s++){const r=i[s];if(Array.isArray(r))for(let o=0;o<r.length;o++){const a=r[o];a!=null&&t.push(n?n(a):a)}else r!=null&&t.push(n?n(r):r)}return t},oI=async(i,e,t)=>await i.query(`SELECT ${(t==null?void 0:t.map(n=>`"${n}"`).join(", "))??"*"} FROM ${e}`),LZ=async(i,e,t,n)=>{const s=n.join(", ");return await i.query(`SELECT * FROM ${e} WHERE "${t}" IN (${s})`)},ip=async(i,e,t,n)=>{var a;const s=n.map(l=>typeof l=="string"?`${Pp(l)}`:l),r=`SELECT "${t.pointIndexBy}" FROM ${e} WHERE "${t.pointIdBy}" IN (${s})`,o=await i.query(r);return o?((a=o.getChildAt(0))==null?void 0:a.toArray())??[]:void 0},aI=async(i,e,t,n)=>{var a;const s=n.join(", "),r=`SELECT "${t.pointIdBy}" FROM ${e} WHERE "${t.pointIndexBy}" IN (${s})`,o=await i.query(r);return o?((a=o.getChildAt(0))==null?void 0:a.toArray())??[]:void 0},RZ=async(i,e,t,n,s)=>{var l;const r=s.map(c=>typeof c=="string"?`${Pp(c)}`:c),o=`SELECT "${t.pointIndexBy}" FROM ${e} WHERE "${n}" IN (${r.join(", ")})`,a=await i.query(o);return a?((l=a.getChildAt(0))==null?void 0:l.toArray())??[]:void 0},PZ=async(i,e,t,n,s,r)=>{var c;const o=r?">=":"<=",a=`SELECT "${t.pointIndexBy}" FROM ${e} WHERE "${n}" ${o} ${s}`,l=await i.query(a);if(l)return((c=l.getChildAt(0))==null?void 0:c.toArray())??[]},NZ=async(i,e,t)=>{if(!(t!=null&&t.pointXBy)||!(t!=null&&t.pointYBy))return!1;const n=await Hl(i,e);return n.includes(t.pointXBy)&&n.includes(t.pointYBy)},DZ=(i,e)=>{if(!(e!=null&&e.pointXBy)||!(e!=null&&e.pointYBy))return[];const t=i.getChild(e.pointXBy),n=i.getChild(e.pointYBy),s=i.numRows,r=new Array(2*s);for(let o=0;o<s;o++)r[2*o]=t==null?void 0:t.get(o),r[2*o+1]=n==null?void 0:n.get(o);return r},Y_=(i,e=EZ,t=e/2,n=e/8)=>Array.from({length:2*i},()=>{const s=t+n*Math.sqrt(-2*Math.log(Math.random()))*Math.cos(2*Math.PI*Math.random());return Math.max(1,Math.min(e-1,s))}),MZ=(i,e)=>{const t=i==null?void 0:i.getPointPositions(),n=i.getScaleX(),s=i.getScaleY();if(t!=null&&t.length){const r=e-t.length/2;let o=Y_(r,i.config.spaceSize);return n&&s&&(o=o.map((a,l)=>l%2==0?n(a):s(a))),t.concat(o)}return Y_(e,i.config.spaceSize)},BZ=(i,e)=>new Map(Array.from({length:e},(t,n)=>[n,[i[2*n],i[2*n+1]]])),OZ=(i,e)=>{const t=i.length/2;for(let n=0;n<t;n++){const s=e.get(n);s&&(i[2*n]=s[0],i[2*n+1]=s[1])}e.clear()},FZ=(i,e)=>{if(!e.linkSourceIndexBy||!e.linkTargetIndexBy)return new Float32Array(0);const t=i.getChild(e.linkSourceIndexBy),n=i.getChild(e.linkTargetIndexBy),s=i.numRows,r=new Float32Array(2*s);for(let o=0,a=0;o<s;o++,a+=2)r[a]=(t==null?void 0:t.get(o))??0,r[a+1]=(n==null?void 0:n.get(o))??0;return r},zZ=(i,e)=>{if(!e.linkSourceIndexBy||!e.linkTargetIndexBy)return new Set;const t=i.getChild(e.linkSourceIndexBy),n=i.getChild(e.linkTargetIndexBy);if(!t||!n)return new Set;const s=new Set;for(let r=0;r<t.length;r++)s.add(t.get(r)),s.add(n.get(r));return s},lI=async(i,e)=>{var r,o;const t=await i.query(e);if(!t)return;const n=((r=t.getChildAt(0))==null?void 0:r.toArray())??[],s=((o=t.getChildAt(1))==null?void 0:o.toArray())??[];return[...new Set([...n,...s])]},UZ=async(i,e,t,n,s)=>{const r=s.map(a=>typeof a=="string"?`${Pp(a)}`:a),o=`SELECT "${t.linkSourceIndexBy}", "${t.linkTargetIndexBy}" FROM ${e} WHERE "${n}" IN (${r.join(", ")})`;return lI(i,o)},$Z=async(i,e,t,n,s,r)=>{const o=r?">=":"<=",a=`SELECT "${t.linkSourceIndexBy}", "${t.linkTargetIndexBy}" FROM ${e} WHERE "${n}" ${o} ${s}`;return lI(i,a)},jZ=async(i,e,t,n)=>{const s=n.map(r=>typeof r=="string"?`${Pp(r)}`:r);return await i.query(`SELECT * FROM ${e} WHERE "${t.linkSourceBy}" IN (${s}) OR "${t.linkTargetBy}" IN (${s})`)},HZ=async(i,e,t,n)=>{const s=n.join(", ");return await i.query(`SELECT * FROM ${e} WHERE "${t.linkSourceIndexBy}" IN (${s}) OR "${t.linkTargetIndexBy}" IN (${s})`)},cI=async(i,e,t)=>await i.query(`SELECT ${(t==null?void 0:t.map(n=>`"${n}"`).join(", "))??"*"} FROM ${e}`),VZ=[null,void 0,"null","","undefined","nan"],qw=i=>VZ.includes(typeof i=="string"?i.toLowerCase():i),uI=i=>{const e=El(i,ad),t=El(i,od),[n,s]=Rn(i),r=e===t?n:e,o=e===t?s:t;return r===o?[r,o+1e-6]:[r,o]},Pv=(i,e,t)=>{const n=new Set(i);for(const r of n)qw(r)&&n.delete(r);const s=DA().domain(Array.from(n)).range(e);return r=>qw(r)?t:s(r)},wl=(i,e,t,n=!0)=>{const s=n?uI(i):Rn(i);return WA(xA(vA.gamma(1.5),e)).domain(s).unknown(t).clamp(!0)},GZ=(i,e,t)=>{const n=Array.from(new Set(i)),s=FG(xA(vA.gamma(2.2),e),n.length);return Pv(n,s.reverse(),t)},q_=(i,e,t,n=!0)=>{const s=n?uI(i):Rn(i);return zA().domain(s).range(e).unknown(t)},WZ=(i,e)=>i?[i[4*e]??0,i[4*e+1]??0,i[4*e+2]??0,i[4*e+3]??0]:void 0,YZ=i=>{const e=(t=>{const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return n?{r:parseInt((n[1]||0).toString(),16),g:parseInt((n[2]||0).toString(),16),b:parseInt((n[3]||0).toString(),16)}:{r:0,g:0,b:0}})(i);return(.2126*e.r+.7152*e.g+.0722*e.b)/255},ao=(i,e)=>{if(!i)return e;if(typeof i=="string")return i;const[t,n,s]=i.map(r=>Math.round(255*r));return`rgb(${t}, ${n}, ${s})`},qZ=i=>{var r,o;if(!i)return;if(typeof i=="string")return(r=ho(i))==null?void 0:r.formatHex();const[e,t,n,s]=i;return(o=ho(`rgba(${e}, ${t}, ${n}, ${s})`))==null?void 0:o.formatHex()},uu=(i,e,t=!1)=>{let n;if(t){const s=El(i,ad),r=El(i,od);n=s===r?Rn(i):[s,r]}else n=Rn(i);return n[0]===n[1]&&(n[1]=n[1]+1e-6),Up().range(e).domain(n).clamp(!0)},XZ=(i,e)=>{const t=[];return e.forEach((n,s)=>{if(i&&n in i){const r=i[n];if(r){const[o,a]=r;t[2*s]=o,t[2*s+1]=a}else t[2*s]=void 0,t[2*s+1]=void 0}else t[2*s]=void 0,t[2*s+1]=void 0}),t};let KZ=class{constructor(){b(this,"_colorStore");this._colorStore=new Map}getColor(e){if(this._colorStore.has(e))return this._colorStore.get(e);{const t=Hf(e),n=[t.r/255,t.g/255,t.b/255,t.opacity];return this._colorStore.set(e,n),n}}clearCache(){this._colorStore.clear()}};const Ha=(i,e,t)=>{const n=new Float32Array(i.length);for(let s=0;s<i.length;s++){const r=i.get(s);n[s]=t?t(r,s):r??e}return n},wc=(i,e,t)=>{const n=new Float32Array(4*i.length),s=new KZ;for(let r=0;r<i.length;r++){const o=i.get(r),a=t?t(o,r):o??e;let[l,c,u,d]=Array.isArray(a)?a:s.getColor(a);(isNaN(l)||isNaN(c)||isNaN(u)||isNaN(d))&&([l,c,u,d]=Array.isArray(e)?e:s.getColor(e));const h=4*r;n[h]=l,n[h+1]=c,n[h+2]=u,n[h+3]=d}return s.clearCache(),n},ZZ=(i,e,t)=>{const n=new Array(i.length);for(let s=0;s<i.length;s++){const r=i.get(s);n[s]=t?t(r,s):r??e}return n};var Ye;function QZ(i={},e){const{pointColorStrategy:t,pointColorBy:n,pointColorByFn:s,pointColorByMap:r,linkSourceBy:o,linkTargetBy:a}=i;if(t&&Object.values(Ye).includes(t))return t;if(s)return Ye.Direct;if(n){if(r)return Ye.Map;if(Ko(e))return Ye.Continuous;if(Nu(e)||Du(e))return Ye.Categorical}return!n&&o&&a?Ye.Degree:Ye.Single}(function(i){i.Categorical="categorical",i.Continuous="continuous",i.Map="map",i.Degree="degree",i.PreciseDegree="preciseDegree",i.LinkDirection="linkDirection",i.Direct="direct",i.Single="single"})(Ye||(Ye={}));const tg=(i,e,t,n)=>{const s=ao(e.unknownColor,tc),r=e.pointColorPalette??iI;return{[Ye.Degree]:()=>wl(t,r,s),[Ye.PreciseDegree]:()=>wl(t,r,s,!1),[Ye.LinkDirection]:()=>q_(t,r,s,!1),[Ye.Map]:()=>o=>e.pointColorByMap?e.pointColorByMap[o]??s:s,[Ye.Categorical]:()=>{let o;if(Ko(n)&&(o=q_(t,r,s)),Nu(n)||Du(n)){const a=W_(t);o=Pv(a,r,s)}return o},[Ye.Continuous]:()=>{let o;if(Ko(n)&&(o=wl(t,r,s)),Nu(n)||Du(n)){const a=W_(t);o=GZ(a,r,s)}return o},[Ye.Direct]:()=>e.pointColorByFn,[Ye.Single]:()=>()=>e.pointDefaultColor}[i]()};var ut;function JZ(i={},e){const{linkColorStrategy:t,linkColorBy:n,linkColorByFn:s,linkSourceBy:r,linkTargetBy:o}=i;if(t&&Object.values(ut).includes(t))return t;if(s)return ut.Direct;if(n){if(Ko(e))return ut.Sum;if(Nu(e)||Du(e))return ut.Categorical}return!n&&r&&o?ut.Count:ut.Single}(function(i){i.Sum="sum",i.Average="average",i.Count="count",i.Categorical="categorical",i.Direct="direct",i.Single="single"})(ut||(ut={}));const Xw=(i,e,t,n)=>{const s=ao(e.unknownColor,tc),r=e.linkColorPalette??nI;return{[ut.Sum]:()=>wl(t,r,s),[ut.Average]:()=>wl(t,r,s),[ut.Count]:()=>wl(t,r,s),[ut.Categorical]:()=>{let o;if(Ko(n)&&(o=q_(t,r,s)),Nu(n)||Du(n)){const a=W_(t);o=Pv(a,r,s)}return o},[ut.Direct]:()=>e.linkColorByFn,[ut.Single]:()=>()=>e.linkDefaultColor}[i]()};var Kt;(function(i){i.Degree="degree",i.PreciseDegree="preciseDegree",i.Auto="auto",i.Direct="direct",i.Single="single"})(Kt||(Kt={}));const Kw=(i,e,t)=>({[Kt.Degree]:()=>uu(t,e.pointSizeRange??cu,!0),[Kt.PreciseDegree]:()=>uu(t,e.pointSizeRange??cu),[Kt.Auto]:()=>uu(t,e.pointSizeRange??cu,!0),[Kt.Direct]:()=>e.pointSizeByFn,[Kt.Single]:()=>()=>e.pointDefaultSize})[i]();function eQ(i,e){const{pointSizeStrategy:t,pointSizeBy:n,pointDefaultSize:s,pointSizeByFn:r,linkSourceBy:o,linkTargetBy:a}=i;return t&&Object.values(Kt).includes(t)?t:r?Kt.Direct:n&&Ko(e)?Kt.Auto:!s&&!n&&o&&a?Kt.Degree:Kt.Single}var Tt;(function(i){i.Sum="sum",i.Average="average",i.Count="count",i.Direct="direct",i.Single="single"})(Tt||(Tt={}));const Zw=(i,e,t)=>{const n=()=>uu(t,e.linkWidthRange??tI,!0);return{[Tt.Sum]:n,[Tt.Average]:n,[Tt.Count]:n,[Tt.Direct]:()=>e.linkWidthByFn??n(),[Tt.Single]:()=>()=>e.linkDefaultWidth}[i]()};function tQ(i,e){const{linkWidthStrategy:t,linkWidthBy:n,linkWidthByFn:s,linkSourceBy:r,linkTargetBy:o}=i;return t&&Object.values(Tt).includes(t)?t:s?Tt.Direct:n&&Ko(e)?Tt.Sum:!n&&r&&o?Tt.Count:Tt.Single}class iQ{constructor(e){b(this,"_");b(this,"config",eg);b(this,"_rawConfig",{});b(this,"_cosmosConfig",{});b(this,"_configUpdatePromise",null);b(this,"_cosmosInitPromise",null);b(this,"_cosmosInitResolved",null);b(this,"_currentPointColorStrategy",Ye.Direct);b(this,"_currentLinkColorStrategy",ut.Direct);b(this,"_currentPointSizeStrategy",Kt.Direct);b(this,"_currentLinkWidthStrategy",Tt.Direct);b(this,"_currentPointColorFn");b(this,"_currentPointSizeFn");b(this,"_currentLinkColorFn");b(this,"_currentLinkWidthFn");b(this,"_clusterMapping",new Map);b(this,"_clusterIndexToNameMapping",new Map);b(this,"_preservedPointPositions",new Map);b(this,"resetCosmographConfig",()=>{this.config=eg});b(this,"_checkPointEvents",()=>!(this.config.onClick===void 0&&!this.config.selectPointOnClick&&!this.config.focusPointOnClick));this._=e,this._cosmosInitPromise=new Promise(t=>{this._cosmosInitResolved=t})}get activePointColorStrategy(){return this._currentPointColorStrategy}get activeLinkColorStrategy(){return this._currentLinkColorStrategy}get activePointSizeStrategy(){return this._currentPointSizeStrategy}get activeLinkWidthStrategy(){return this._currentLinkWidthStrategy}get activePointColorFn(){return this._currentPointColorFn}get activePointSizeFn(){return this._currentPointSizeFn}get activeLinkColorFn(){return this._currentLinkColorFn}get activeLinkWidthFn(){return this._currentLinkWidthFn}get clusterMapping(){return this._clusterMapping}get clusterIndexToNameMapping(){return this._clusterIndexToNameMapping}get cosmosConfig(){return this._cosmosConfig}async configUpdated(){await this._configUpdatePromise}async cosmosInitialized(){await this._cosmosInitPromise}setConfig(e){this._configUpdatePromise=(async()=>{var t,n,s;try{await this._.dbReady();const r=this.config;if(r.points&&!(e!=null&&e.points)&&!this._.public.stats.pointsCount)return void this._.public.reset();this.config=Yt(eg,e??{}),this._rawConfig=e??{},this._controlBackgroundColor(r,this.config),this._.rectangularSelection.updateSelectionClassName(),window.cosmographDisableLogging=this.config.disableLogging??!1,this._cosmosConfig=this._createCosmosConfig(),(t=this._.cosmos)==null||t.setConfig(this._cosmosConfig),await this._processConfigUpdate(r),this._handleScaleChangeEvents(r,this.config)}finally{this._configUpdatePromise=null,(s=(n=this.config).onConfigUpdated)==null||s.call(n)}})()}async _processConfigUpdate(e){var l,c;const t=this._detectPointsChanged(e),n=this._detectLinksChanged(e),s=this._detectVisualLinkChanges(e),r=this._detectVisualPointChanges(e),o=this._detectClusterChanges(e),a=this._detectLabelChanges(e);if((t||n)&&await this._.dataManager.updateGraphData(t,n))return await this._rebuildGraph(!t&&n,n),void(this._cosmosInitResolved&&(this._cosmosInitResolved(),this._cosmosInitResolved=null));(s||r||o)&&this._.cosmos&&(await this._updateGraphProperties(e,r,this._.public.stats.linksCount>0&&s),this._.cosmos.render((l=this._.cosmos)!=null&&l.isSimulationRunning?void 0:0)),a&&((c=this._.labels)==null||c.update()),!this.config.preservePointPositionsOnDataUpdate&&this._preservedPointPositions.size&&this._preservedPointPositions.clear()}async _rebuildGraph(e,t){var n,s,r;try{e?await this._updateGraphProperties(void 0,!1):(this._.dispatchEvent(new CustomEvent("reset")),await this._.initializeCosmos(),this._.initializeLabels(),await this._updateGraphProperties(void 0,!0,t)),this._.updateMessage(null);const o=!this._.public.isSimulationAvailable||!this._.pointsHaveLayout;(n=this._.cosmos)==null||n.render(o?void 0:0),this._.updateStats(),this._.dispatchEvent(new CustomEvent("graphRebuilt")),(r=(s=this.config).onGraphRebuilt)==null||r.call(s,this._.public.stats),this.config.points&&we(`Rendered graph with ${this._.public.stats.pointsCount} points and ${this._.public.stats.linksCount} links.`)}catch(o){we(o,"_rebuildGraph","error"),this._.updateMessage(`🚨 ${o}`)}}async _updateGraphProperties(e,t=!0,n=!0){n&&await this.updateLinkProperties(e),t&&await this.updatePointProperties(e),this._updateClusterProperties(e)}async updatePointProperties(e,t=!1){var h,p,m;const{_:{dbCoordinator:n,config:s,public:{pointsTableName:r}}}=this,o=[s.pointXBy,s.pointYBy,s.pointColorBy,s.pointSizeBy,s.pointClusterBy,s.pointIndexBy,s.pointClusterStrengthBy].filter(Boolean),a=await Hl(n,r),l=new Set(a),c=o.filter(y=>l.has(y)),u=await oI(n,r,c);let d=!1;u!=null&&u.numRows?(d=await this._handlePointPositions(e,u,t),d&&((h=this._.cosmos)==null||h.graph.update()),this._handlePointColors(e,u),this._handlePointSizes(e,u),await this._handlePointClusterProps(e,u),d?(p=this._.labels)==null||p.update():(m=this._.labels)==null||m.render()):await this._.public.reset(!1)}async updateLinkProperties(e){const{dbCoordinator:t,cosmos:n,config:s,public:{linksTableName:r,stats:o}}=this._;if(!o.linksCount&&!await Ta(t,r))return;const a=[s.linkColorBy,s.linkWidthBy,s.linkStrengthBy,s.linkArrowBy,s.linkSourceIndexBy,s.linkTargetIndexBy].filter(Boolean),l=await Hl(t,r),c=new Set(l),u=a.filter(h=>c.has(h)),d=await cI(t,r,u);if(d){if(d.numRows!==(n==null?void 0:n.graph.linksNumber)){const h=FZ(d,this.config);n==null||n.setLinks(h),this._.linkAggregationManager.buildCountCache(d),this._.linkAggregationManager.clearColorSumCache(),this._.linkAggregationManager.clearWidthSumCache()}this._handleLinkColors(e,d),this._handleLinkWidths(e,d),this._handleLinkStrengths(e,d),this._handleLinkArrows(e,d)}}_updateClusterProperties(e){const{config:t,_:{cosmos:n}}=this;if(!e||(e==null?void 0:e.clusterPositionsMap)!==t.clusterPositionsMap)if(t.clusterPositionsMap&&this._clusterMapping.size>0){const s=XZ(t.clusterPositionsMap,Array.from(this._clusterMapping.keys()));n==null||n.setClusterPositions(s)}else n==null||n.setClusterPositions([])}async _handlePointPositions(e,t,n=!1){const{config:s,_:{cosmos:r}}=this;if(r!=null&&r.graph.pointsNumber&&e&&e.pointXBy===s.pointXBy&&e.pointYBy===s.pointYBy)return!1;let o=[];if(s.pointXBy||s.pointYBy){if(!await this._.dataValidator.validatePointPositions())return!1;o=DZ(t,s)}else o=n?MZ(r,t.numRows):Y_(t.numRows,s.spaceSize);return s.preservePointPositionsOnDataUpdate&&this._preservedPointPositions.size>0&&OZ(o,this._preservedPointPositions),r==null||r.setPointPositions(new Float32Array(o),!n&&void 0),!0}_handlePointColors(e,t){const{config:n,_:{cosmos:s}}=this,r=[Ct.PointColor,Ct.PointColorStrategy,Ct.PointColorPalette,Ct.PointColorFn,Ct.PointColorMap,"pointDefaultColor"];if(e&&!this._hasConfigChanged(e,n,r))return;let o=new Float32Array;const a=n.pointColorBy?t.getChild(n.pointColorBy):void 0;if(this._currentPointColorStrategy=QZ(this._rawConfig,a==null?void 0:a.type),this._currentPointColorFn=void 0,this._currentPointColorStrategy===Ye.Degree||this._currentPointColorStrategy===Ye.PreciseDegree){const l=this._.public.pointDegrees;l&&(this._currentPointColorFn=tg(this._currentPointColorStrategy,n,l),o=wc(no(l),n.unknownColor,this._currentPointColorFn))}else if(this._currentPointColorStrategy===Ye.LinkDirection){const l=this._.public.pointDirections;l&&(this._currentPointColorFn=tg(this._currentPointColorStrategy,n,l),o=wc(no(l),n.unknownColor,this._currentPointColorFn))}else a?(this._currentPointColorFn=tg(this._currentPointColorStrategy,n,a.toArray(),a==null?void 0:a.type),o=wc(a,n.unknownColor,this._currentPointColorFn)):n.pointColorBy&&we(`Column "${n.pointColorBy}" for \`${Ct.PointColor}\` not found`,"_handlePointColors","warn");s==null||s.setPointColors(o),this._.dispatchEvent(new CustomEvent("pointColorUpdated"))}_handlePointSizes(e,t){const{config:n,_:{cosmos:s}}=this,r=[Ct.PointSize,Ct.PointSizeStrategy,Ct.PointSizeRange,Ct.PointSizeFn,"pointDefaultSize"];if(e&&!this._hasConfigChanged(e,n,r))return;let o=new Float32Array;const a=n.pointSizeBy?t.getChild(n.pointSizeBy):void 0;if(this._currentPointSizeStrategy=eQ(this._rawConfig,a==null?void 0:a.type),this._currentPointSizeFn=void 0,this._currentPointSizeStrategy===Kt.Degree||this._currentPointSizeStrategy===Kt.PreciseDegree){const l=s==null?void 0:s.graph.degree;l&&(this._currentPointSizeFn=Kw(this._currentPointSizeStrategy,n,l),o=Ha(no(l),n.pointDefaultSize,this._currentPointSizeFn))}else a?(this._currentPointSizeFn=Kw(this._currentPointSizeStrategy,n,a.toArray()),o=Ha(a,n.pointDefaultSize,this._currentPointSizeFn)):n.pointSizeBy&&we(`Column "${n.pointSizeBy}" for \`${Ct.PointSize}\` not found`,"_handlePointSizes","warn");s==null||s.setPointSizes(o),this._.dispatchEvent(new CustomEvent("pointSizeUpdated"))}async _handlePointClusterProps(e,t){const{config:n,_:{cosmos:s}}=this;if(!e||e.pointClusterStrengthBy!==n.pointClusterStrengthBy){const a=n.pointClusterStrengthBy?t.getChild(n.pointClusterStrengthBy):void 0;let l=new Float32Array;a&&(l=Ha(a,tp(Ct.PointClusterStrength))),s==null||s.setPointClusterStrength(l)}const r=[Ct.PointCluster,Ct.PointClusterFn];if(e&&!this._hasConfigChanged(e,n,r))return;const o=n.pointClusterBy?t.getChild(n.pointClusterBy):void 0;if(o){let a=Array.from(o.toArray());n.pointClusterByFn&&(a=a.map(n.pointClusterByFn));const l=new Map;for(const d of a){const h=String(d);l.set(h,(l.get(h)??0)+1)}this._clusterMapping.clear(),this._clusterIndexToNameMapping.clear();let c=0;for(const d of l.keys()){const h=l.get(d);this._clusterMapping.set(d,{index:c,count:h}),this._clusterIndexToNameMapping.set(c,{name:d,count:h}),c++}const u=a.map(d=>{var h;return d===void 0||(h=this._clusterMapping.get(String(d)))==null?void 0:h.index});s==null||s.setPointClusters(u)}else this._clusterMapping.clear(),this._clusterIndexToNameMapping.clear(),s==null||s.setPointClusters([]);this._.dispatchEvent(new CustomEvent("clustersUpdated"))}_handleLinkColors(e,t){const{config:n,_:{cosmos:s}}=this,r=[ei.LinkColor,ei.LinkColorStrategy,ei.LinkColorPalette,ei.LinkColorFn,"linkDefaultColor"];if(e&&e.linkColorBy!==n.linkColorBy&&this._.linkAggregationManager.clearColorSumCache(),e&&!this._hasConfigChanged(e,n,r))return;let o=new Float32Array;const a=n.linkColorBy?t.getChild(n.linkColorBy)??void 0:void 0;if(this._currentLinkColorStrategy=JZ(this._rawConfig,a==null?void 0:a.type),this._currentLinkColorFn=void 0,this._currentLinkColorStrategy!==ut.Sum&&this._currentLinkColorStrategy!==ut.Average||!a||this._.linkAggregationManager.colorSumCache||this._.linkAggregationManager.buildColorSumCache(t,a),[ut.Count,ut.Sum,ut.Average].includes(this._currentLinkColorStrategy)){const l=this._.linkAggregationManager.aggregateFromCache(t,this._currentLinkColorStrategy,!0);l&&(this._currentLinkColorFn=Xw(this._currentLinkColorStrategy,n,l),o=wc(no(l),n.unknownColor,this._currentLinkColorFn))}else a?(this._currentLinkColorFn=Xw(this._currentLinkColorStrategy,n,a.toArray(),a==null?void 0:a.type),o=wc(a,n.unknownColor,this._currentLinkColorFn)):n.linkColorBy&&we(`Column "${n.linkColorBy}" for \`${ei.LinkColor}\` not found`,"_handleLinkColors","warn");s==null||s.setLinkColors(o),this._.dispatchEvent(new CustomEvent("linkColorUpdated"))}_handleLinkWidths(e,t){const{config:n,_:{cosmos:s}}=this,r=[ei.LinkWidth,ei.LinkWidthRange,ei.LinkWidthStrategy,ei.LinkWidthFn,"linkDefaultWidth"];if(e&&e.linkWidthBy!==n.linkWidthBy&&this._.linkAggregationManager.clearWidthSumCache(),e&&!this._hasConfigChanged(e,n,r))return;let o=new Float32Array;const a=n.linkWidthBy?t.getChild(n.linkWidthBy):void 0;if(this._currentLinkWidthStrategy=tQ(this._rawConfig,a==null?void 0:a.type),this._currentLinkWidthFn=void 0,this._currentLinkWidthStrategy!==Tt.Sum&&this._currentLinkWidthStrategy!==Tt.Average||!a||this._.linkAggregationManager.widthSumCache||this._.linkAggregationManager.buildWidthSumCache(t,a),[Tt.Count,Tt.Sum,Tt.Average].includes(this._currentLinkWidthStrategy)){const l=this._.linkAggregationManager.aggregateFromCache(t,this._currentLinkWidthStrategy,!1);l&&(this._currentLinkWidthFn=Zw(this._currentLinkWidthStrategy,this.config,l),o=Ha(no(l),this.config.linkDefaultWidth,this._currentLinkWidthFn))}else a?(this._currentLinkWidthFn=Zw(this._currentLinkWidthStrategy,this.config,a.toArray()),o=Ha(a,n.linkDefaultWidth,this._currentLinkWidthFn)):n.linkWidthBy&&we(`Column "${n.linkWidthBy}" for \`${ei.LinkWidth}\` not found`,"_handleLinkWidths","warn");s==null||s.setLinkWidths(o),this._.dispatchEvent(new CustomEvent("linkWidthUpdated"))}_handleLinkStrengths(e,t){const{config:n,_:{cosmos:s}}=this,r=[ei.LinkStrength,ei.LinkStrengthRange,ei.LinkStrengthFn];if(e&&!this._hasConfigChanged(e,n,r))return;let o=new Float32Array;const a=n.linkStrengthBy?t.getChild(n.linkStrengthBy):void 0;if(a){const l=n.linkStrengthByFn??uu(a.toArray(),n.linkStrengthRange);o=Ha(a,tp(ei.LinkStrength),l)}else n.linkStrengthBy&&we(`Column "${n.linkStrengthBy}" for \`${ei.LinkStrength}\` not found`,"_handleLinkStrengths","warn");s==null||s.setLinkStrength(o)}_handleLinkArrows(e,t){const{config:n,_:{cosmos:s}}=this,r=[ei.LinkArrow,ei.LinkArrowFn,"linkDefaultArrows"];if(e&&!this._hasConfigChanged(e,n,r))return;let o=[];const a=n.linkArrowBy?t.getChild(n.linkArrowBy):void 0;a?o=ZZ(a,n.linkDefaultArrows,n.linkArrowByFn):n.linkArrowBy&&we(`Column "${n.linkArrowBy}" for \`${ei.LinkArrow}\` not found`,"_handleLinkArrows","warn"),s==null||s.setLinkArrows(o)}_handleScaleChangeEvents(e,t){(e==null?void 0:e.pointSizeScale)===t.pointSizeScale&&(e==null?void 0:e.scalePointsOnZoom)===t.scalePointsOnZoom||this._.dispatchEvent(new CustomEvent("pointSizeScaleUpdated")),(e==null?void 0:e.linkWidthScale)===t.linkWidthScale&&(e==null?void 0:e.scaleLinksOnZoom)===t.scaleLinksOnZoom||this._.dispatchEvent(new CustomEvent("linkWidthScaleUpdated"))}_hasConfigChanged(e,t,n){return n.some(s=>!Pu(e[s],t[s]))}_detectPointsChanged(e){return this._hasConfigChanged(e,this.config,JA)}_detectLinksChanged(e){return this._hasConfigChanged(e,this.config,eI)}_detectLabelChanges(e){return this._hasConfigChanged(e,this.config,wZ)}_detectVisualLinkChanges(e){return this._hasConfigChanged(e,this.config,vZ)}_detectVisualPointChanges(e){return this._hasConfigChanged(e,this.config,xZ)}_detectClusterChanges(e){return this._hasConfigChanged(e,this.config,bZ)}_controlBackgroundColor(e,t){var r,o;if((e==null?void 0:e.backgroundColor)===t.backgroundColor)return;const n=qZ(t.backgroundColor),s=n&&YZ(n)>.65?"#000000":"#ffffff";(r=this._.containerElement)==null||r.style.setProperty("--cosmograph-text-color",s),(o=this._.cosmosElement)==null||o.style.setProperty("backgroundColor",n??Lv)}_createCosmosConfig(){var t;const e={...this.config,hoveredPointCursor:this._checkPointEvents()?((t=this.config)==null?void 0:t.hoveredPointCursor)??"pointer":"auto"};return delete e.enableSimulation,delete e.attribution,this._.eventManager.attachCosmosEvents(e),e}updatePreservedPointPositions(e){this._preservedPointPositions=e}clearCosmosBuffers(e){const{_:{cosmos:t}}=this;e||(t==null||t.setPointPositions(new Float32Array),t==null||t.setPointColors(new Float32Array),t==null||t.setPointSizes(new Float32Array),t==null||t.setPointClusters([]),t==null||t.setPointClusterStrength(new Float32Array),t==null||t.setClusterPositions([])),t==null||t.setLinks(new Float32Array),t==null||t.setLinkColors(new Float32Array),t==null||t.setLinkWidths(new Float32Array),t==null||t.setLinkStrength(new Float32Array),t==null||t.setLinkArrows([])}}let nQ=class{constructor(e){b(this,"_");b(this,"_linksSelection",f_.crossfilter());b(this,"_pointsSelection",f_.crossfilter());b(this,"_onLinksFiltered");b(this,"_onPointsFiltered");b(this,"_crossfilter",{links:new Set,points:new Set,intersection:new Set});this._=e,this._onLinksFiltered=t=>this._handleCrossfiltering(t,"links"),this._onPointsFiltered=t=>this._handleCrossfiltering(t,"points")}get filtered(){return this._crossfilter}get pointsSelection(){return this._pointsSelection}get linksSelection(){return this._linksSelection}get onLinksFiltered(){return this._onLinksFiltered}get onPointsFiltered(){return this._onPointsFiltered}get isFilteringActive(){return this._linksSelection.clauses.length>0||this._pointsSelection.clauses.length>0}_handleCrossfiltering(e,t){var l,c;const{config:n,cosmos:s,labels:r}=this._;this._getSetForCrossfilter(e,t),this._getIntersection(),this.isFilteringActive?s==null||s.selectPointsByIndices(Array.from(this._crossfilter.intersection)):s==null||s.unselectPoints();const o=this._.public.getSelectedLinkIndices(),a=s==null?void 0:s.getSelectedIndices();t==="points"&&((l=n.onPointsFiltered)==null||l.call(n,e,a,o)),t==="links"&&((c=n.onLinksFiltered)==null||c.call(n,e,a,o)),r==null||r.update(),this._.dispatchEvent(new CustomEvent("dataFiltered"))}_getSetForCrossfilter(e,t){var r;const{config:n}=this._;let s;if(t==="links")s=zZ(e,n);else{const o=(r=e.getChild(n.pointIndexBy))==null?void 0:r.toArray();s=new Set(o)}this._crossfilter[t]=s}_getIntersection(){const{links:e,points:t}=this._crossfilter,n=t.values();let s=new Set;if(this._linksSelection.clauses.length&&this._pointsSelection.clauses.length)for(const r of n)e.has(r)&&s.add(r);else s=this._linksSelection.clauses.length?e:t;this._crossfilter.intersection=s}},sQ=class{constructor(e){b(this,"_");b(this,"_dataUploadPromise",null);this._=e}get dataUploadPromise(){return this._dataUploadPromise}async dataReady(){var e;await this._.dbReady(),(e=this._.dbCoordinator)!=null&&e.internalDB&&this._dataUploadPromise&&await this._dataUploadPromise}async updateGraphData(e,t){let n=!1;return this._dataUploadPromise&&(we("Data upload is already in progress, waiting for it to complete.","updateGraphData","info"),await this._dataUploadPromise),!!this._.dbCoordinator&&(this._dataUploadPromise=(async()=>{var s,r,o,a,l;(s=this._.cosmos)!=null&&s.isSimulationRunning&&((r=this._.cosmos)==null||r.stop()),(o=this._.dbCoordinator)==null||o.clearCache();try{if(e){const{pointsOk:c}=await this._uploadAndValidateGraphData(t);n=c}else if(t){const{linksOk:c}=await this._uploadAndValidateLinksData();n=e?n&&c:c}}finally{this._dataUploadPromise=null,this._.dispatchEvent(new CustomEvent("dataUploaded")),(l=(a=this._.config)==null?void 0:a.onGraphDataUpdated)==null||l.call(a)}})(),await this._dataUploadPromise,n)}async _addPreparedData(e,t){var l;const{_:{dbCoordinator:n,public:{linksTableName:s,isSimulationRunning:r,activePointColorStrategy:o,activePointSizeStrategy:a}}}=this;if(n&&(n!=null&&n.internalDB)){if(e&&(await this._uploadPoints(e,!0),await this._.configManager.updatePointProperties(void 0,!0)),t){const c=await Ta(n,s);await this._uploadLinks(t,c),await this._.configManager.updateLinkProperties(void 0),o!==Ye.Degree&&o!==Ye.LinkDirection&&a!==Kt.Degree||await this._.configManager.updatePointProperties(void 0,!0)}(l=this._.cosmos)==null||l.render(r?this._.config.simulationImpulse:0),this._triggerGraphUpdated()}}async addPoints(e){const{_:{dbCoordinator:t,public:{stats:n}}}=this,{pointIndexBy:s,pointIdBy:r}=this._.config;if(t&&(t!=null&&t.internalDB)){const o=n.pointsCount,a=await Hl(t,qe.Points),l=[];for(const c of e){if(c.id===void 0)continue;const u={};for(const d of a)if(d===s)u[d]=BigInt(o+l.length);else if(d===r)u[d]=c.id;else if(c[d]!==void 0)u[d]=c[d];else{const h=Object.values(Ct).find(p=>this._.config[p]===d);u[d]=h?tp(h):null}l.push(u)}this._preservePointPositionsIfEnabled(),l.length&&await this._addPreparedData(l,void 0)}}async addLinks(e){const{_:{dbCoordinator:t,config:n}}=this;if(!(t!=null&&t.internalDB))return;const{linkSourceBy:s,linkTargetBy:r,linkSourceIndexBy:o,linkTargetIndexBy:a}=n;if(!(s&&r&&o&&a))return;const l=e.filter(m=>m.source!=null&&m.target!=null),c=[...new Set(l.flatMap(m=>[m.source,m.target]).map(String))];if(!c.length)return;const u=await ip(t,qe.Points,n,c);if(!u)return;const d=new Map(c.map((m,y)=>[m,u[y]]));let h=await Ta(t,qe.Links)?await Hl(t,qe.Links):[];h.length||(h=[s,r,o,a,...n.linkColorBy?[n.linkColorBy]:[],...n.linkWidthBy?[n.linkWidthBy]:[],...n.linkArrowBy?[n.linkArrowBy]:[],...n.linkStrengthBy?[n.linkStrengthBy]:[],...Array.isArray(n.linkIncludeColumns)?n.linkIncludeColumns:[]]);const p=[];for(const m of l){const y=String(m.source),g=String(m.target),_=d.get(y),S=d.get(g);if(_===void 0||S===void 0)continue;const E={};for(const x of h)if(x===s)E[x]=m.source;else if(x===r)E[x]=m.target;else if(x===o)E[x]=BigInt(_);else if(x===a)E[x]=BigInt(S);else if(x in m&&m[x]!==void 0)E[x]=m[x];else{const T=Object.values(ei).find(I=>n[I]===x);E[x]=T?tp(T):null}p.push(E)}p.length&&await this._addPreparedData(void 0,p)}async removePointsByIndices(e,t=!0){var c;const{_:{dbCoordinator:n,public:{pointsTableName:s,linksTableName:r,stats:o,isSimulationRunning:a}}}=this;if(!n||o.pointsCount<=1)return;const l=[...new Set(e)];if(!(l.length>=o.pointsCount)&&(n!=null&&n.internalDB)){const u=`${l.join(", ")}`;await n.internalDB.query(`DELETE FROM ${s} WHERE "${this._.config.pointIndexBy}" IN (${u})`),this._removePointsInCosmos(l),t&&o.linksCount&&(await n.internalDB.query(`DELETE FROM ${r} WHERE "${this._.config.linkSourceIndexBy}" IN (${u})
          OR "${this._.config.linkTargetIndexBy}" IN (${u})`),await this._.configManager.updateLinkProperties(void 0)),(c=this._.cosmos)==null||c.render(a?this._.config.simulationImpulse:0),this._triggerGraphUpdated()}}async removePointsByIds(e){const t=await ip(this._.dbCoordinator,this._.public.pointsTableName,this._.config,e);t&&await this.removePointsByIndices(t)}async removeLinksByPointIdPairs(e){await this._removeLinks(e,!1)}async removeLinksByPointIndicesPairs(e){await this._removeLinks(e,!0)}async _uploadData(e,t){let n={pointsError:!1,linksError:!1};if(!this._.dbCoordinator||!this._.dbCoordinator.internalDB)return n;try{n=await this._executeUpload(e,t)}catch(s){we(`Error during data upload: ${s}`,"_uploadData","error")}return n}async _uploadPoints(e,t=!1){var s,r;const n=await((r=(s=this._.dbCoordinator)==null?void 0:s.internalDB)==null?void 0:r.uploadData(e,qe.Points,t));return!!(n!=null&&n.error)}async _uploadLinks(e,t=!1){var s,r;const n=await((r=(s=this._.dbCoordinator)==null?void 0:s.internalDB)==null?void 0:r.uploadData(e,qe.Links,t));return!!(n!=null&&n.error)}async _executeUpload(e,t){we("Data uploading...","uploadData");const n={pointsError:!1,linksError:!1};return await this._.dbReady(),this._.updateMessage("🌀 Loading data..."),e&&(n.pointsError=await this._uploadPoints(e)),t&&(n.linksError=await this._uploadLinks(t)),this._.updateMessage(n.pointsError?"🚨 Points data is empty or invalid.":null),n}_preservePointPositionsIfEnabled(){var n;const{config:e,public:{stats:t}}=this._;if(e.pointIdBy&&t.pointsCount&&e.preservePointPositionsOnDataUpdate){const s=(n=this._.cosmos)==null?void 0:n.getPointPositions();if(s&&s.length){const r=BZ(s,t.pointsCount);this._.configManager.updatePreservedPointPositions(r)}}}async _uploadAndValidateGraphData(e){const{_:{config:t}}=this;if(!t.points){await this._.public.reset(!1);const r="Points source data is not provided in `points`.";return we(r,"_uploadAndValidateGraphData","error"),this._.updateMessage(`🚨 ${r}`),{pointsOk:!1,linksOk:!1}}this._preservePointPositionsIfEnabled();const{pointsError:n,linksError:s}=await this._uploadData(t.points,t.links);if(await this._.updateSummary(),n){const r="Failed to upload points data: The data is invalid or empty.";return we(r,"_uploadAndValidateGraphData","error"),this._.updateMessage(`🚨 ${r}`),{pointsOk:!1,linksOk:!1}}try{const r=!n&&await this._.dataValidator.validatePoints();if(!r)return{pointsOk:r,linksOk:!1};const o=e&&!s&&await this._.dataValidator.validateLinks();return t.links&&!o&&we("Provided links data is empty or invalid. Only points will be rendered.","_uploadAndValidateGraphData","warn"),{pointsOk:r,linksOk:o}}catch(r){return we(`Error during data validation: ${r}`,"_uploadAndValidateGraphData","error"),{pointsOk:!1,linksOk:!1}}}async _uploadAndValidateLinksData(){let e=!1;if(this._.public.stats.pointsCount===0)return{linksOk:e};if(this._.configManager.clearCosmosBuffers(!0),!this._.config.links)return await this._.dropLocalTables(!0),{linksOk:e};const{linksError:t}=await this._uploadData(void 0,this._.config.links);return await this._.updateSummary(),e=!t&&await this._.dataValidator.validateLinks(),e||await this._.dropLocalTables(!0),{linksOk:e}}_removePointsInCosmos(e){var n,s,r,o,a,l,c,u,d,h,p,m,y,g,_,S,E,x,T,I;if(!e.length)return;const t=new Set(e);if((s=(n=this._.cosmos)==null?void 0:n.graph.pointPositions)!=null&&s.length){const O=Qd(t,(r=this._.cosmos)==null?void 0:r.graph.pointPositions,2);(o=this._.cosmos)==null||o.setPointPositions(O,!1)}if((l=(a=this._.cosmos)==null?void 0:a.graph.pointColors)!=null&&l.length){const O=Qd(t,(c=this._.cosmos)==null?void 0:c.graph.pointColors,4);(u=this._.cosmos)==null||u.setPointColors(O)}if((h=(d=this._.cosmos)==null?void 0:d.graph.pointSizes)!=null&&h.length){const O=Qd(t,(p=this._.cosmos)==null?void 0:p.graph.pointSizes,1);(m=this._.cosmos)==null||m.setPointSizes(O)}if((g=(y=this._.cosmos)==null?void 0:y.graph.pointClusters)!=null&&g.length){const O=(_=this._.cosmos)==null?void 0:_.graph.pointClusters.filter((H,Q)=>!t.has(Q));(S=this._.cosmos)==null||S.setPointClusters(O)}if((x=(E=this._.cosmos)==null?void 0:E.graph.clusterStrength)!=null&&x.length){const O=Qd(t,(T=this._.cosmos)==null?void 0:T.graph.clusterStrength,1);(I=this._.cosmos)==null||I.setPointClusterStrength(O)}}async _removeLinks(e,t){var p;const{_:{dbCoordinator:n,public:{linksTableName:s,stats:r,isSimulationRunning:o,activePointColorStrategy:a,activePointSizeStrategy:l}}}=this;if(!(n!=null&&n.internalDB)||!r.linksCount)return;const c=t?this._.config.linkSourceIndexBy:this._.config.linkSourceBy,u=t?this._.config.linkTargetIndexBy:this._.config.linkTargetBy,d=m=>t?m.toString():`'${m}'`,h=`
      DELETE FROM ${s}
      WHERE ${e.map(([m,y])=>`((${c} = ${d(m)} AND ${u} = ${d(y)}) OR
        (${c} = ${d(y)} AND ${u} = ${d(m)}))`).join(" OR ")}
    `;await n.internalDB.query(h),await this._.configManager.updateLinkProperties(void 0),a!==Ye.Degree&&a!==Ye.LinkDirection&&l!==Kt.Degree||await this._.configManager.updatePointProperties(void 0,!0),(p=this._.cosmos)==null||p.render(o?this._.config.simulationImpulse:0),this._triggerGraphUpdated()}_triggerGraphUpdated(){var e,t;this._.dbCoordinator.clearCache(),this._.updateStats(),(t=(e=this._.config).onGraphRebuilt)==null||t.call(e,this._.public.stats),this._.dispatchEvent(new CustomEvent("dataUploaded")),this._.dispatchEvent(new CustomEvent("graphRebuilt"))}};const Qw=()=>globalThis.__lastDuckdbError;let rQ=class{constructor(e){b(this,"_");this._=e}async validatePoints(){const{config:e,dbCoordinator:t,public:{pointsTableName:n}}=this._,s=JA.slice(1),r=u=>{throw we(u,"validatePoints","error"),this._.updateMessage(`🚨 ${u}`),new Error(u)};if(!await Ta(t,n)){const u=Qw();return r(u?`Failed to get points data: ${u}`:`Failed to get points data. Table "${n}" does not exist`)}const o=this._getMissingProperties(e,s);if(o.length)return r(`Failed to get points data.

Missing required properties: ${this._formatMissingProps(o)}.`);const{exists:a,missingColumns:l}=await this._validateColumns(e,n,s);if(!a)return r(`Failed to get points data.

Missing provided columns for required properties: ${this._formatMissingColumns(l,s)}.`);const c=(await sI(t,n)).find(u=>u.name===e.pointIndexBy);return(c==null?void 0:c.type)!=="VARCHAR"||r(`The column specified for \`pointIndexBy\` (${e.pointIndexBy}) cannot be of type VARCHAR. Please use an integer-based column.`)}async validateLinks(){const{config:e,dbCoordinator:t,public:{linksTableName:n}}=this._,s=eI.slice(1),r=c=>{throw we(c,"validateLinks","error"),this._.updateMessage(`🚨 ${c}`),new Error(c)};if(!e.links){const c="Found links-related properties but links data is not provided. Rendering points only.";return we(c,"validateLinks","warn"),this._.updateMessage(`⚠️ ${c}`),!1}if(!await Ta(t,n)){const c=Qw();if(c)return r(`Failed to get links data: ${c}`);const u=`Failed to get links data. Table "${n}" does not exist`;return we(u,"validateLinks","error"),this._.updateMessage(`🚨 ${u}`),!1}const o=this._getMissingProperties(e,s);if(o.length)return r(`Failed to get links data. 

Missing required properties: ${this._formatMissingProps(o)}.`);const{exists:a,missingColumns:l}=await this._validateColumns(e,n,s);return!!a||r(`Failed to get links data. 

Missing provided columns for required properties: ${this._formatMissingColumns(l,s)}.`)}async validatePointPositions(){const{config:e,config:{pointXBy:t,pointYBy:n},public:{pointsTableName:s}}=this._;if(!!t!=!!n){const r=`Couldn't render points: Only one of \`${Ct.PointX}\` or \`${Ct.PointY}\` provided.`;throw we(r,"validatePointPositions","error"),this._.updateMessage(`🚨 ${r}`),new Error(r)}if(t&&n){const{exists:r,missingColumns:o}=await this._validateColumns(e,s,[Ct.PointX,Ct.PointY]);if(!r){const a=`Couldn't render points: Failed to get provided point positions, missing columns for positions: ${this._formatMissingProps(o)}.`;throw we(a,"validatePointPositions","error"),this._.updateMessage(`🚨 ${a}`),new Error(a)}}return!0}async _validateColumns(e,t,n){const s=n.map(o=>e[o]),r=[];return{exists:await Hp(this._.dbCoordinator,t,s,r),missingColumns:r}}_getMissingProperties(e,t){return t.filter(n=>e[n]===void 0)}_formatMissingProps(e){return e.map(t=>`"${t}"`).join(", ")}_formatMissingColumns(e,t){return e.map(n=>`"${n}" (${t[e.indexOf(n)]})`).join(", ")}},oQ=class{constructor(e){b(this,"_");b(this,"_hoveredPointIndex");this._=e}attachCosmosEvents(e={}){e.onSimulationStart=this.onSimulationStart.bind(this),e.onSimulationTick=this.onSimulationTick.bind(this),e.onSimulationEnd=this.onSimulationEnd.bind(this),e.onSimulationPause=this.onSimulationPause.bind(this),e.onSimulationUnpause=this.onSimulationUnpause.bind(this),e.onClick=this.onClick.bind(this),e.onPointMouseOver=this.onPointMouseOver.bind(this),e.onPointMouseOut=this.onPointMouseOut.bind(this),e.onMouseMove=this.onMouseMove.bind(this),e.onZoomStart=this.onZoomStart.bind(this),e.onZoom=this.onZoom.bind(this),e.onZoomEnd=this.onZoomEnd.bind(this),e.onDrag=this.onDrag.bind(this),e.onDragEnd=this.onDragEnd.bind(this),e.onLinkClick=this.onLinkClick.bind(this),e.onLinkMouseOver=this.onLinkMouseOver.bind(this),e.onLinkMouseOut=this.onLinkMouseOut.bind(this)}getLabelEvents(){return{onLabelClick:this.onLabelClick.bind(this),onHoveredLabelClick:this.onHoveredLabelClick.bind(this)}}onClick(...e){var n;const{config:t}=this._;t.selectPointOnClick?this._handlePointClick(e[0],e[2]):e[0]||this._.public.selectPoint(void 0),(n=t.onClick)==null||n.call(t,...e)}async onLabelClick(e,t){var l,c,u;const{public:{pointsTableName:n},config:s,dbCoordinator:r,configManager:o}=this._;if(typeof t.id=="string"&&t.id.startsWith("cluster-")){const d=t.id.slice(8),h=Number(d);if(!Number.isNaN(h)){const p=((l=o.clusterIndexToNameMapping.get(h))==null?void 0:l.name)??t.id;s.selectClusterOnLabelClick&&await this._handleClusterClick(p,e),(c=s.onClusterLabelClick)==null||c.call(s,h,p,e)}return}if(!r)return;const a=await ip(r,n,s,[t.id]);a&&a[0]!==void 0&&(s.selectPointOnLabelClick&&this._handlePointClick(a[0],e,s.selectPointOnLabelClick,!0),(u=s.onLabelClick)==null||u.call(s,a[0],t.id,e))}async onHoveredLabelClick(e){var o;const{public:{pointsTableName:t},config:n,dbCoordinator:s}=this._;if(this._hoveredPointIndex===void 0||!s)return;const r=await aI(s,t,n,[this._hoveredPointIndex]);r&&r[0]&&(n.selectPointOnLabelClick&&this._handlePointClick(this._hoveredPointIndex,e,n.selectPointOnLabelClick,!0),(o=n.onLabelClick)==null||o.call(n,this._hoveredPointIndex,r[0],e))}onRectSelect(e,t=!1,n=!0){var s,r;n?this._.public.unselectPointsInRect(e):this._.public.selectPointsInRect(e,t),(r=(s=this._.config).onRectSelected)==null||r.call(s,e),this._.dispatchEvent(new CustomEvent("rectSelected"))}onPolygonSelect(e,t=!1,n=!0){var s,r;n?this._.public.unselectPointsInPolygon(e):this._.public.selectPointsInPolygon(e,t),(r=(s=this._.config).onPolygonSelected)==null||r.call(s,e),this._.dispatchEvent(new CustomEvent("polygonSelected"))}onPointMouseOver(...e){var n,s;const[t]=e;(s=(n=this._.config).onPointMouseOver)==null||s.call(n,...e),this._hoveredPointIndex=t,this._renderCurrentHoveredLabel()}onPointMouseOut(...e){var t,n;(n=(t=this._.config).onPointMouseOut)==null||n.call(t,...e),this._hoveredPointIndex=void 0,this._renderCurrentHoveredLabel()}onLinkMouseOver(...e){var t,n;(n=(t=this._.config).onLinkMouseOver)==null||n.call(t,...e)}onLinkMouseOut(...e){var t,n;(n=(t=this._.config).onLinkMouseOut)==null||n.call(t,...e)}onLinkClick(...e){var t,n;(n=(t=this._.config).onLinkClick)==null||n.call(t,...e)}onMouseMove(...e){var t,n;(n=(t=this._.config).onMouseMove)==null||n.call(t,...e)}onZoomStart(...e){var t,n,s;(n=(t=this._.config).onZoomStart)==null||n.call(t,...e),(s=this._.labels)==null||s.render()}onDrag(...e){var t,n,s;(n=(t=this._.config).onDrag)==null||n.call(t,...e),(s=this._.labels)==null||s.updatePositions(),this._renderCurrentHoveredLabel(),this._.dispatchEvent(new CustomEvent("onDrag"))}onDragEnd(...e){var t,n,s;(n=(t=this._.config).onDragEnd)==null||n.call(t,...e),(s=this._.labels)==null||s.update(),this._renderCurrentHoveredLabel()}async onZoom(...e){var t,n,s,r;(n=(t=this._.config).onZoom)==null||n.call(t,...e),(s=this._.labels)==null||s.setZooming(!0,!!e[0].sourceEvent),await((r=this._.labels)==null?void 0:r.render()),this._renderCurrentHoveredLabel(),this._.dispatchEvent(new CustomEvent("onZoom")),this._.dispatchEvent(new CustomEvent("pointSizeScaleUpdated")),this._.dispatchEvent(new CustomEvent("linkWidthScaleUpdated"))}onZoomEnd(...e){var t,n,s;(n=(t=this._.config).onZoomEnd)==null||n.call(t,...e),(s=this._.labels)==null||s.setZooming(!1,!!e[0].sourceEvent),this._.dispatchEvent(new CustomEvent("zoomEnded"))}onSimulationStart(...e){var t,n;(n=(t=this._.config).onSimulationStart)==null||n.call(t,...e)}onSimulationTick(...e){var t,n,s;(n=(t=this._.config).onSimulationTick)==null||n.call(t,...e),(s=this._.labels)==null||s.updatePositions(),this._.dispatchEvent(new CustomEvent("onSimulationTick"))}onSimulationEnd(...e){var t,n;(n=(t=this._.config).onSimulationEnd)==null||n.call(t,...e),this._.dispatchEvent(new CustomEvent("onSimulationEnd"))}onSimulationPause(...e){var t,n,s;(n=(t=this._.config).onSimulationPause)==null||n.call(t,...e),(s=this._.labels)==null||s.render()}onSimulationUnpause(...e){var t,n,s,r;(n=(t=this._.config).onSimulationUnpause)==null||n.call(t,...e),(r=(s=this._.config).onSimulationRestart)==null||r.call(s,...e)}_handlePointClick(e,t,n,s=!1){const{config:r}=this._,{shiftKey:o,altKey:a}=t;if(a)this._.public.unselectPoint(e);else{const l=n===!0||n!=="single"&&void 0;this._.public.selectPoint(e,o,l)}(s?r.focusPointOnLabelClick??r.selectPointOnLabelClick:r.focusPointOnClick??r.selectPointOnClick)&&!a&&this._.public.setFocusedPoint(e)}async _handleClusterClick(e,t){const{config:n}=this._,{pointClusterBy:s}=n;if(!s)return;const r=await this._.public.getPointIndicesByExactValues(s,[e]);if(!r||!r.length)return;const{shiftKey:o,altKey:a}=t;a?this._.public.unselectPointsByIndices(r):this._.public.selectPoints(r,o)}_renderCurrentHoveredLabel(){var t,n,s;if(this._hoveredPointIndex===void 0)return void((t=this._.labels)==null?void 0:t.renderHoveredLabel());const e=this._.public.getPointPositionByIndex(this._hoveredPointIndex);e?(n=this._.labels)==null||n.renderHoveredLabel(this._hoveredPointIndex,e):(s=this._.labels)==null||s.renderHoveredLabel()}};const ig=(i,e)=>0x100000000n*BigInt(i)+BigInt(e),aQ=i=>{const e=Number(i%0x100000000n);return{sourceIdx:Number(i/0x100000000n),targetIdx:e}};let lQ=class{constructor(e){b(this,"_");b(this,"_countCache",null);b(this,"_colorSumCache",null);b(this,"_widthSumCache",null);b(this,"_colorSumCacheColumn",null);b(this,"_widthSumCacheColumn",null);this._=e}get countCache(){return this._countCache}get colorSumCache(){return this._colorSumCache}get widthSumCache(){return this._widthSumCache}buildCountCache(e){const t=this._getIndexColumns(e);if(!t)return void(this._countCache=null);const{sourceIdxColumn:n,targetIdxColumn:s,numRows:r}=t,o=new Map;for(let a=0;a<r;a++){const l=n.get(a),c=s.get(a),u=ig(l,c);o.set(u,(o.get(u)??0)+1)}this._countCache=o}buildColorSumCache(e,t){const{config:n}=this._;this._buildSumCacheForType(e,t,n.linkColorBy,!0)}buildWidthSumCache(e,t){const{config:n}=this._;this._buildSumCacheForType(e,t,n.linkWidthBy,!1)}_buildSumCacheForType(e,t,n,s){const r=n??null;if(!r)return void(s?(this._colorSumCache=null,this._colorSumCacheColumn=null):(this._widthSumCache=null,this._widthSumCacheColumn=null));const o=s?this._widthSumCache:this._colorSumCache;if(r===(s?this._widthSumCacheColumn:this._colorSumCacheColumn)&&o)return void(s?(this._colorSumCache=o,this._colorSumCacheColumn=r):(this._widthSumCache=o,this._widthSumCacheColumn=r));const a=s?this._colorSumCache:this._widthSumCache;if(r===(s?this._colorSumCacheColumn:this._widthSumCacheColumn)&&a)return;const l=this._buildSumCache(e,t);s?(this._colorSumCache=l,this._colorSumCacheColumn=l?r:null):(this._widthSumCache=l,this._widthSumCacheColumn=l?r:null)}_buildSumCache(e,t){if(!t)return null;const n=this._getIndexColumns(e);if(!n)return null;const{sourceIdxColumn:s,targetIdxColumn:r,numRows:o}=n,a=new Map;for(let l=0;l<o;l++){const c=s.get(l),u=r.get(l),d=ig(c,u),h=t.get(l);a.set(d,(a.get(d)??0)+h)}return a}_getIndexColumns(e){const{config:t}=this._;if(!t.linkSourceIndexBy||!t.linkTargetIndexBy)return null;const n=e.getChild(t.linkSourceIndexBy),s=e.getChild(t.linkTargetIndexBy);return n&&s?{sourceIdxColumn:n,targetIdxColumn:s,numRows:e.numRows}:null}aggregateFromCache(e,t,n=!0){const{config:s}=this._;if(!s.linkSourceIndexBy||!s.linkTargetIndexBy)return;const r=e.getChild(s.linkSourceIndexBy),o=e.getChild(s.linkTargetIndexBy);if(!r||!o||!this._countCache)return;const a=n?this._colorSumCache:this._widthSumCache,l=e.numRows,c=new Array(l);for(let u=0;u<l;u++){const d=r.get(u),h=o.get(u),p=ig(d,h),m=this._countCache.get(p)??0;if(t==="count")c[u]=m;else if(t==="sum")c[u]=(a==null?void 0:a.get(p))??0;else{const y=(a==null?void 0:a.get(p))??0;c[u]=m>0?y/m:0}}return c}getKeysByValueCondition(e,t){if(!e)return[];const n=[];for(const[s,r]of e)t(r)&&n.push(s);return n}getIndicesSetFromKeys(e){if(!e)return[];const t=new Set;for(const n of e){const{sourceIdx:s,targetIdx:r}=aQ(n);t.add(s),t.add(r)}return Array.from(t)}getIndicesByValueCondition(e,t){const n=this.getKeysByValueCondition(e,t);return this.getIndicesSetFromKeys(n)}getIndicesByAverageCondition(e,t,n){if(!e||!t)return[];const s=[];for(const[r,o]of e){const a=t.get(r)??0;n(o>0?a/o:0)&&s.push(r)}return this.getIndicesSetFromKeys(s)}clear(){this._countCache=null,this._colorSumCache=null,this._widthSumCache=null,this._colorSumCacheColumn=null,this._widthSumCacheColumn=null}clearColorSumCache(){this._colorSumCache=null,this._colorSumCacheColumn=null}clearWidthSumCache(){this._widthSumCache=null,this._widthSumCacheColumn=null}};function cQ(i,e){const[t,n,s,r]=[i.x,i.y+i.height,i.x+i.width,i.y],[o,a,l,c]=[e.x,e.y+e.height,e.x+e.width,e.y];return!(n<c||a<r||s<o||l<t)}const ko=6,Ao=9,Sc=14,Uh="css-label--labels-container",dI="css-label--labels-container-hidden",X_="css-label--label",hI="css-label--hidden",uQ=`
  :root {
    --css-label-background-color: #1e2428;
    --css-label-brightness: brightness(150%);
  }

  .${Uh} {
    transition: opacity 100ms;
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    top: 0%;
    pointer-events: none;
    opacity: 1;
  }

  .${dI} {
    opacity: 0;

    div {
      pointer-events: none;
    }
  }
`,dQ=`
  .${X_} {
    position: absolute;
    top: 0;
    left: 0;

    cursor: pointer;
    
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    filter: var(--css-label-brightness);
    pointer-events: none;
    background-color: var(--css-label-background-color);
    font-weight: 700;
    border-radius: 6px;
    
    transition: opacity 600ms;
    opacity: 1;
  }

  /* We use "important" here because the users may pass their own label class, overriding the opacity */
  .${hI} {
    opacity: 0 !important;
  }
`,fI=i=>{const e=document.createElement("style");e.innerHTML=i;const t=document.head.getElementsByTagName("style")[0];return t?document.head.insertBefore(e,t):document.head.appendChild(e),e};let Jw;class pI{constructor(e,t,n){this.element=document.createElement("div"),this.fontWidthHeightRatio=.6,this._x=0,this._y=0,this._estimatedWidth=0,this._estimatedHeight=0,this._visible=!1,this._prevVisible=!1,this._weight=0,this._needsMeasureUpdate=!0,this._customFontSize=Sc,this._customColor=void 0,this._customOpacity=void 0,this._shouldBeShown=!1,this._text="",this._customPadding={left:Ao,top:ko,right:Ao,bottom:ko},!n&&!Jw&&(Jw=fI(dQ)),this._container=e,this._updateClasses(),t&&this.setText(t),this.resetFontSize(),this.resetPadding()}setText(e){this._text!==e&&(this._text=e,this.element.innerHTML=e,this._needsMeasureUpdate=!0)}setPosition(e,t){this._x=e,this._y=t}setStyle(e){if(this._customStyle!==e&&(this._customStyle=e,this.element.style.cssText=this._customStyle,this._customColor&&(this.element.style.color=this._customColor),this._customOpacity&&(this.element.style.opacity=String(this._customOpacity)),this._customPointerEvents&&(this.element.style.pointerEvents=this._customPointerEvents),this._customFontSize&&(this.element.style.fontSize=`${this._customFontSize}px`),this._customPadding)){const{top:t,right:n,bottom:s,left:r}=this._customPadding;this.element.style.padding=`${t}px ${n}px ${s}px ${r}px`}}setClassName(e){this._customClassName!==e&&(this._customClassName=e,this._updateClasses())}setFontSize(e=Sc){this._customFontSize!==e&&(this.element.style.fontSize=`${e}px`,this._customFontSize=e,this._needsMeasureUpdate=!0)}resetFontSize(){this._customFontSize!==Sc&&(this.element.style.fontSize=`${Sc}px`,this._customFontSize=Sc,this._needsMeasureUpdate=!0)}setColor(e){this._customColor!==e&&(this.element.style.color=e,this._customColor=e)}resetColor(){this.element.style.removeProperty("color"),this._customColor=void 0}setOpacity(e){this._customOpacity!==e&&(this.element.style.opacity=String(e),this._customOpacity=e)}resetOpacity(){this.element.style.removeProperty("opacity"),this._customOpacity=void 0}setPointerEvents(e){this._customPointerEvents!==e&&(this.element.style.pointerEvents=`${e}`,this._customPointerEvents=e)}resetPointerEvents(){this.element.style.removeProperty("pointer-events"),this._customPointerEvents=void 0}setPadding(e={left:Ao,top:ko,right:Ao,bottom:ko}){(this._customPadding.left!==e.left||this._customPadding.top!==e.top||this._customPadding.right!==e.right||this._customPadding.bottom!==e.bottom)&&(this._customPadding=e,this.element.style.padding=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`,this._needsMeasureUpdate=!0)}resetPadding(){if(this._customPadding.left===Ao&&this._customPadding.top===ko&&this._customPadding.right===Ao&&this._customPadding.bottom===ko)return;const e={left:Ao,top:ko,right:Ao,bottom:ko};this.element.style.padding=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`,this._customPadding=e,this._needsMeasureUpdate=!0}setForceShow(e){this._shouldBeShown=e}getForceShow(){return this._shouldBeShown}draw(){const e=this.getVisibility();e!==this._prevVisible&&(this._prevVisible===!1?this._container.appendChild(this.element):this._container.removeChild(this.element),this._updateClasses(),this._prevVisible=e),e&&(this.element.style.transform=`
        translate(-50%, -100%)
        translate3d(${this._x}px, ${this._y}px, 0)
      `)}overlaps(e){return this._measureText(),e._measureText(),cQ({height:this._estimatedHeight,width:this._estimatedWidth,x:this._x,y:this._y},{height:e._estimatedHeight,width:e._estimatedWidth,x:e._x,y:e._y})}setVisibility(e=!0){this._visible=e}getVisibility(){return this._visible}isOnScreen(){return this._x>0&&this._y>0&&this._x<this._container.offsetWidth&&this._y<this._container.offsetHeight}setWeight(e){this._weight=e}getWeight(){return this._weight}raise(){this._container.appendChild(this.element)}destroy(){this.element.remove()}_updateClasses(){this.getVisibility()?window.requestAnimationFrame(()=>{this.element.className=`${X_} ${this._customClassName||""}`}):this.element.className=`${X_} ${this._customClassName||""} ${hI}`}_measureText(){if(this._needsMeasureUpdate){const{left:e,top:t,right:n,bottom:s}=this._customPadding;this._estimatedWidth=this._customFontSize*this.fontWidthHeightRatio*this.element.innerHTML.length+e+n,this._estimatedHeight=this._customFontSize+t+s,this._needsMeasureUpdate=!1}}}let eS;class hQ{constructor(e,t){this._cssLabels=new Map,this._elementToData=new Map,!(t!=null&&t.dontInjectStyles)&&!eS&&(eS=fI(uQ)),this._container=e,e.addEventListener("click",this._onClick.bind(this)),this._container.className=Uh,t!=null&&t.onLabelClick&&(this._onClickCallback=t.onLabelClick),t!=null&&t.pointerEvents&&(this._pointerEvents=t.pointerEvents),t!=null&&t.dontInjectStyles&&(this._dontInjectStyles=t.dontInjectStyles),t!=null&&t.padding&&(this._padding=t.padding),t!=null&&t.fontSize&&(this._fontSize=t.fontSize),t!=null&&t.dispatchWheelEventElement&&(this._dispatchWheelEventElement=t.dispatchWheelEventElement,this._container.addEventListener("wheel",this._onWheel.bind(this)))}setLabels(e){const t=new Map(this._cssLabels);e.forEach(n=>{const{x:s,y:r,fontSize:o,color:a,text:l,weight:c,opacity:u,shouldBeShown:d,style:h,className:p,padding:m}=n;if(this._cssLabels.get(n.id))t.delete(n.id);else{const _=new pI(this._container,n.text,this._dontInjectStyles);this._cssLabels.set(n.id,_),this._elementToData.set(_.element,n)}const g=this._cssLabels.get(n.id);g&&(g.setText(l),g.setPosition(s,r),h!==void 0&&g.setStyle(h),c!==void 0&&g.setWeight(c),a!==void 0&&g.setColor(a),o!==void 0?g.setFontSize(o):this._fontSize!==void 0?g.setFontSize(this._fontSize):g.resetFontSize(),m!==void 0?g.setPadding(m):this._padding!==void 0?g.setPadding(this._padding):g.resetPadding(),this._pointerEvents!==void 0&&g.setPointerEvents(this._pointerEvents),u!==void 0&&g.setOpacity(u),d!==void 0&&g.setForceShow(d),p!==void 0&&g.setClassName(p))});for(const[n]of t){const s=this._cssLabels.get(n);s&&(this._elementToData.delete(s.element),s.destroy()),this._cssLabels.delete(n)}}draw(e=!0){e&&this._intersectLabels(),this._cssLabels.forEach(t=>t.draw())}show(){this._container.className=Uh}hide(){this._container.className=`${Uh} ${dI}`}destroy(){this._container.removeEventListener("click",this._onClick.bind(this)),this._container.removeEventListener("wheel",this._onWheel.bind(this)),this._cssLabels.forEach(e=>e.destroy())}_onClick(e){var t;const n=this._elementToData.get(e.target);n&&((t=this._onClickCallback)===null||t===void 0||t.call(this,e,n))}_onWheel(e){var t;e.preventDefault();const n=new WheelEvent("wheel",e);(t=this._dispatchWheelEventElement)===null||t===void 0||t.dispatchEvent(n)}_intersectLabels(){const e=Array.from(this._cssLabels.values());e.forEach(t=>t.setVisibility(t.isOnScreen()));for(let t=0;t<e.length;t+=1){const n=e[t];if(n.getVisibility())for(let s=t+1;s<e.length;s+=1){const r=e[s];if(!r.getVisibility())continue;if(n.overlaps(r)){r.getWeight()>n.getWeight()?n.setVisibility(r.getForceShow()?!1:n.getForceShow()):r.setVisibility(n.getForceShow()?!1:r.getForceShow());continue}}}}}const Nv=async(i,e,t,n,s)=>{if(!t.pointIdBy||!t.pointIndexBy||!t.pointLabelBy)return{indices:null,ids:null,labels:null,weights:null};let r=`SELECT ${[...new Set([t.pointLabelBy,t.pointIndexBy,t.pointIdBy,...s?[s]:[]])].map(y=>`"${y}"`).join(", ")} FROM ${e}`;n&&(r+=` ${n}`),s&&(r+=` ORDER BY "${s}" DESC`),r+=` LIMIT ${t.showTopLabelsLimit}`;const o=await i.query(r,{cache:!0});if(!o)return{indices:null,ids:null,labels:null,weights:null};const a=o.getChild(t.pointIdBy),l=o.getChild(t.pointIndexBy);let c=o.getChild(t.pointLabelBy),u=null;s&&(u=o.getChild(s));const d=t.pointLabelFn,h=t.pointLabelWeightFn,p=!!c&&typeof d=="function",m=!!u&&typeof h=="function";if(t.pointLabelFn&&!p&&we(`Provided \`${[V_.PointLabelFn]}\` is not a function`,"executeLabelsQuery","warn"),t.pointLabelWeightFn&&!m&&we(`Provided \`${[V_.PointLabelWeightFn]}\` is not a function`,"executeLabelsQuery","warn"),p||m){const y=p?c.toArray():null,g=m?u.toArray():null,_=Math.max((y==null?void 0:y.length)??0,(g==null?void 0:g.length)??0);for(let S=0;S<_;S++){const E=l==null?void 0:l.get(S);p&&y&&d&&(y[S]=d(y[S],E)),m&&g&&h&&(g[S]=h(g[S],E))}y&&(c=no(y)),g&&(u=no(g))}return{indices:l,ids:a,labels:c,weights:u}},Ec=async(i,e,t,n,s)=>Nv(i,e,t,`WHERE ${t.pointIndexBy} IN (${n.join(", ")})`,s),fQ=async(i,e,t)=>Nv(i,e,t),pQ=async(i,e,t,n)=>{const s=(t.showLabelsFor??[]).map(r=>`'${r}'`).join(", ");return Nv(i,e,t,`WHERE ${t.pointIdBy} IN (${s})`,n)};var tS=[],Cc=[];function Dr(i,e){if(i&&typeof document<"u"){var t,n=e.prepend===!0?"prepend":"append",s=e.singleTag===!0,r=typeof e.container=="string"?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(s){var o=tS.indexOf(r);o===-1&&(o=tS.push(r)-1,Cc[o]={}),t=Cc[o]&&Cc[o][n]?Cc[o][n]:Cc[o][n]=a()}else t=a();i.charCodeAt(0)===65279&&(i=i.substring(1)),t.styleSheet?t.styleSheet.cssText+=i:t.appendChild(document.createTextNode(i))}function a(){var l=document.createElement("style");if(l.setAttribute("type","text/css"),e.attributes)for(var c=Object.keys(e.attributes),u=0;u<c.length;u++)l.setAttribute(c[u],e.attributes[c[u]]);var d=n==="prepend"?"afterbegin":"beforeend";return r.insertAdjacentElement(d,l),l}}var mQ=".style_module_cosmographDynamicLabel__2e27a4a3,.style_module_cosmographStaticLabel__2e27a4a3{opacity:1}.style_module_cosmographLabelBase__2e27a4a3{-webkit-font-smoothing:antialiased!important;background-color:#24272fe0;cursor:default;font-weight:400!important;line-height:1!important;max-width:350px;overflow:hidden;text-overflow:ellipsis;text-rendering:optimizeLegibility!important;transition:opacity .25s;white-space:nowrap}.style_module_cosmographLabelHovered__2e27a4a3{z-index:1}.style_module_cosmographLabelInteractive__2e27a4a3{cursor:pointer;pointer-events:all}.style_module_cosmographLabelHidden__2e27a4a3{opacity:.1}.style_module_cosmographClusterLabel__2e27a4a3{background:#3f4562a1;font-weight:500!important;opacity:.9;text-shadow:-1px -1px 0 #3f4562a1,-1px -1px 5px #00000026,1px -1px 0 #3f4562a1,1px -1px 5px #00000026,-1px 1px 0 #3f4562a1,-1px 1px 5px #00000026,1px 1px 0 #3f4562a1,1px 1px 5px #00000026}",os={cosmographStaticLabel:"style_module_cosmographStaticLabel__2e27a4a3",cosmographDynamicLabel:"style_module_cosmographDynamicLabel__2e27a4a3",cosmographLabel:"style_module_cosmographLabel__2e27a4a3 style_module_cosmographLabelBase__2e27a4a3",cosmographLabelHovered:"style_module_cosmographLabelHovered__2e27a4a3 style_module_cosmographLabelBase__2e27a4a3",cosmographLabelInteractive:"style_module_cosmographLabelInteractive__2e27a4a3",cosmographLabelHidden:"style_module_cosmographLabelHidden__2e27a4a3 style_module_cosmographLabelBase__2e27a4a3",cosmographCustomLabel:"style_module_cosmographCustomLabel__2e27a4a3 style_module_cosmographLabelBase__2e27a4a3",cosmographClusterLabel:"style_module_cosmographClusterLabel__2e27a4a3 style_module_cosmographLabelBase__2e27a4a3"};Dr(mQ,{});let gQ=class{constructor(e,t){b(this,"_");b(this,"_onHoveredLabelClick");b(this,"_hoveredCssLabel");b(this,"_cssLabelsRenderer");b(this,"_focusedLabel");b(this,"_staticLabelsMap",new Map);b(this,"_dynamicLabelsMap",new Map);b(this,"_validLabelAccessor",!1);b(this,"_validLabelWeightAccessor",!1);b(this,"_labelDataMap",new Map);b(this,"_customLabelsMap",new Map);b(this,"_columnNames","");b(this,"_cachedTrackedPointsPositions");b(this,"_lastTrackedPointsQueryTime",0);b(this,"_isZooming",!1);b(this,"_isManualZooming",!1);b(this,"_clustersFontScale");b(this,"_clustersWeightScale");b(this,"_updateClustersFontScaleHandler");b(this,"_minDegree");b(this,"_maxDegree");b(this,"_degreeRange");b(this,"_degreeSummaryCalculated",!1);b(this,"labelsContainer",document.createElement("div"));b(this,"_checkLabelEvents",()=>this._hasPointLabelEvents()?"all":"none");var s;this._=e;const n=this._.eventManager.getLabelEvents();(s=e.containerElement)==null||s.appendChild(this.labelsContainer),this._cssLabelsRenderer=new hQ(this.labelsContainer,{dispatchWheelEventElement:t,onLabelClick:n.onLabelClick}),this._onHoveredLabelClick=n.onHoveredLabelClick,this._hoveredCssLabel=new pI(this.labelsContainer),this._hoveredCssLabel.setPointerEvents(this._checkLabelEvents()),this._hoveredCssLabel.element.addEventListener("click",this._onHoveredLabelClick,{passive:!0}),this._updateClustersFontScaleHandler=()=>this._updateClustersFontScale(),this._.addEventListener("clustersUpdated",this._updateClustersFontScaleHandler)}get _labelWeightAccessor(){const{pointLabelWeightBy:e,pointSizeBy:t}=this._.config;return e||t}async render(){const{customLabels:e,showClusterLabels:t}=this._.config;this._.cosmos&&this._.config&&((this._validLabelAccessor||e||t)&&!this._isZooming?await this._updateLabels():this._isZooming&&this._populateLabelDataMap(this._isManualZooming),this._renderLabels())}async update(){if(this._degreeSummaryCalculated=!1,!this._.cosmos||!this._.dbCoordinator)return;const{config:e,public:{pointsTableName:t}}=this._,{pointLabelBy:n,customLabels:s,showClusterLabels:r}=e;await this._.configManager.configUpdated();const o=this._columnNames;this._columnNames=`${n||""}-${this._labelWeightAccessor||""}`,this.setCustomLabels(s);let a=!1;if(n){if(o!==this._columnNames){const l=[];await Hp(this._.dbCoordinator,t,[n,this._labelWeightAccessor].filter(Boolean),l),this._validLabelAccessor=!l.includes(n),this._validLabelWeightAccessor=!!this._labelWeightAccessor&&!l.includes(this._labelWeightAccessor),this._validLabelAccessor&&!this._validLabelWeightAccessor&&(a=!0)}this._validLabelAccessor?(a&&this._calculateDegreeSummary(),await this._updateStaticLabels(),await this.render()):(we(`Column "${n}" for \`pointLabelBy\` not found`,"Labels > update","warn"),this.clear())}else this._customLabelsMap.size>0||r?await this.render():this.clear()}updatePositions(){var n,s;const e=(n=this._.cosmos)==null?void 0:n.getPointPositions(),t=(s=this._.cosmos)==null?void 0:s.getClusterPositions();e&&this._labelDataMap.forEach(r=>{const o=r.index,a=e[2*o],l=e[2*o+1];a!==void 0&&l!==void 0&&(r.position=[a,l])}),t&&this._labelDataMap.forEach((r,o)=>{var a;if((a=o.startsWith)!=null&&a.call(o,"cluster-")){const l=r.index,c=t[2*l],u=t[2*l+1];c!==void 0&&u!==void 0&&(r.position=[c,u])}}),this._renderLabels()}async _updateLabels(){var c,u,d,h;const{config:e,cosmosInitialized:t,dbCoordinator:n,public:{pointsTableName:s,focusedPointIndex:r}}=this._,{showDynamicLabels:o,pointLabelBy:a,showLabels:l}=e;if(this._dynamicLabelsMap.clear(),this._validLabelAccessor&&a&&l&&n)if(o&&await this._updateDynamicLabels(),r){if(!this._focusedLabel||this._focusedLabel&&this._focusedLabel[0]!==r){const p=await Ec(n,s,e,[r]);if(this._focusedLabel=[(c=p.indices)==null?void 0:c.get(0),(u=p.ids)==null?void 0:u.get(0),(d=p.labels)==null?void 0:d.get(0)],t){const m=Array.from(this._staticLabelsMap.keys()).concat(r);(h=this._.cosmos)==null||h.trackPointPositionsByIndices(m)}}}else this._focusedLabel=void 0;this._populateLabelDataMap()}async _updateDynamicLabels(){const{config:e,dbCoordinator:t,public:{pointsTableName:n}}=this._,s=this._.public.getSampledPointPositionsMap();if(!(s!=null&&s.size))return;const r=Array.from(s.keys()),o=await Ec(t,n,e,r);this._setLabels(this._dynamicLabelsMap,o)}async _updateStaticLabels(){var d;const{config:e,dbCoordinator:t,public:{pointsTableName:n,focusedPointIndex:s}}=this._,{pointLabelBy:r,showTopLabels:o,showLabelsFor:a,showLabels:l}=e;if(this._staticLabelsMap.clear(),!l||!t||!r)return;const c=[];a!=null&&a.length&&c.push(pQ(t,n,e,this._validLabelWeightAccessor?this._labelWeightAccessor:void 0).then(h=>this._setLabels(this._staticLabelsMap,h))),o&&c.push(this._getTopLabels().then(h=>this._setLabels(this._staticLabelsMap,h))),c.length&&await Promise.all(c);const u=Array.from(this._staticLabelsMap.keys());s&&u.push(s),u.length&&((d=this._.cosmos)==null||d.trackPointPositionsByIndices(u))}async _getTopLabels(){const{config:e,dbCoordinator:t,public:{pointsTableName:n}}=this._;if(!t)return;const s=this._.public.getSelectedPointIndices();if(s!=null&&s.length)return await Ec(t,n,e,s,this._validLabelWeightAccessor?this._labelWeightAccessor:void 0);if(this._labelWeightAccessor&&this._validLabelWeightAccessor)return await fQ(t,n,e);this._labelWeightAccessor&&!this._validLabelWeightAccessor&&we(`Column "${this._labelWeightAccessor}" for weights not found, getting top labels by degree`,"Labels > _getTopLabels","warn");const r=this._findTopIndicesByDegree();return r.length?await Ec(t,n,e,r,this._validLabelWeightAccessor?this._labelWeightAccessor:void 0):void 0}_setLabels(e,t){var s;if(!(t!=null&&t.indices)||!t.labels||!t.ids)return;const n=t.indices.length;for(let r=0;r<n;r++)e.set(t.indices.get(r),[t.ids.get(r),t.labels.get(r),(s=t.weights)==null?void 0:s.get(r)])}_findTopIndicesByDegree(){const{showTopLabelsLimit:e=100}=this._.config,{pointDegrees:t}=this._.public;if(!t)return[];const n=new Set(this._.public.getSelectedPointIndices()),s=[];if(n.size>0){const r=Array.from(n).sort((o,a)=>(t[a]||0)-(t[o]||0)).slice(0,e);s.push(...r)}if(s.length<e){const r=e-s.length,o=[];for(let a=0;a<t.length;a++)!n.has(a)&&t[a]&&(o.length<r?(o.push({index:a,degree:t[a]??0}),o.length===r&&o.sort((l,c)=>c.degree-l.degree)):t[a]>o[r-1].degree&&(o[r-1]={index:a,degree:t[a]},o.sort((l,c)=>c.degree-l.degree)));s.push(...o.map(a=>a.index))}return s}_populateLabelDataMap(e=!1){const{showLabels:t,staticLabelWeight:n,dynamicLabelWeight:s,showDynamicLabels:r,showTopLabels:o,showLabelsFor:a,pointLabelBy:l}=this._.config;if(e&&t||this._labelDataMap.clear(),!t)return;const c=this._.crossfilter.isFilteringActive;if(!(this._.config.showClusterLabels&&!c)&&this._validLabelAccessor&&l&&t){const u=this._getTrackedPositions(e);if(u&&((o||a!=null&&a.length)&&this._addLabelsToDataMap(this._staticLabelsMap,u,os.cosmographStaticLabel,n),this._addFocusedLabelToDataMap(u)),!e&&r){const d=this._.public.getSampledPointPositionsMap();d&&this._addLabelsToDataMap(this._dynamicLabelsMap,d,os.cosmographDynamicLabel,s)}}this._addClusterLabelsToDataMap(),this._addCustomLabelsToDataMap()}_getTrackedPositions(e){var s;const t=Date.now();if(e&&this._cachedTrackedPointsPositions&&t-this._lastTrackedPointsQueryTime<1e3)return this._cachedTrackedPointsPositions;const n=(s=this._.cosmos)==null?void 0:s.getTrackedPointPositionsMap();return this._cachedTrackedPointsPositions=n,this._lastTrackedPointsQueryTime=t,n}_addLabelsToDataMap(e,t,n,s){e.size&&t.forEach((r,o)=>{const a=e.get(o);if(a){const[l,c,u]=a;this._labelDataMap.set(l,{index:o,text:c,position:r,className:n,weight:u??s})}})}_updateClustersFontScale(){const{config:e}=this._;if(!e.pointClusterBy)return;const t=Array.from(this._.configManager.clusterIndexToNameMapping.values()).map(({count:a})=>a),n=Rn(t),s=e.clusterLabelFontSize??xc,r=Math.max(10,Math.floor(.7*s)),o=Math.ceil(1.5*s);this._clustersFontScale=zu().domain(n).range([r,o]),this._clustersWeightScale=zu().domain(n).range([1100,1e4])}_addClusterLabelsToDataMap(){var a,l,c,u,d;const{config:{showClusterLabels:e,clusterLabelFontSize:t=xc,scaleClusterLabels:n,usePointColorStrategyForClusterLabels:s,pointDefaultColor:r}}=this._;if(!e||this._.crossfilter.isFilteringActive)return;const o=(a=this._.cosmos)==null?void 0:a.getClusterPositions();if(o)for(let h=0;h<o.length;h+=2){const p=Number(o[h]),m=Number(o[h+1]),y=h/2,g=this._.configManager.clusterIndexToNameMapping.get(y);if(!g)continue;const _=n?(l=this._clustersFontScale)==null?void 0:l.call(this,(g==null?void 0:g.count)??0):t,S=ao(r,G_),E=s?(u=(c=this._.configManager).activePointColorFn)==null?void 0:u.call(c,g==null?void 0:g.name):void 0,x=E?typeof E=="string"?E:ao(E,S):void 0,{text:T,maxWidth:I}=this._getClusterLabelText((g==null?void 0:g.name)??`Cluster ${y}`,_);this._labelDataMap.set(`cluster-${y}`,{text:T,position:[p,m],className:os.cosmographClusterLabel,index:y,fontSize:_,color:s?x:"white",weight:((d=this._clustersWeightScale)==null?void 0:d.call(this,(g==null?void 0:g.count)??0))??5e3,padding:this._getClusterPadding(_),maxWidth:I})}}_addCustomLabelsToDataMap(){const{staticLabelWeight:e,pointLabelColor:t}=this._.config;this._customLabelsMap.forEach((n,s)=>{this._labelDataMap.set(s,{index:0,text:n.text,position:n.position,className:n.className??os.cosmographCustomLabel,color:t??(n.className?void 0:"white"),weight:e})})}_addFocusedLabelToDataMap(e){if(!this._focusedLabel)return;const[t,n,s]=this._focusedLabel,r=e.get(t);r&&this._labelDataMap.set(n,{index:t,text:s,position:r,className:os.cosmographStaticLabel,weight:1e4})}_normalizeWeight(e,t,n){var r,o;if(n)return 1e3;if(this._validLabelWeightAccessor&&e!==void 0){const a=(o=(r=this._.summary)==null?void 0:r.pointsSummary)==null?void 0:o.find(l=>l.column_name===this._labelWeightAccessor);if(a){const{min:l,max:c}=a,u=c-l;return u>0?(e-l)/u*100:50}}const s=this._.public.pointDegrees;if(this._degreeSummaryCalculated&&s&&s[t]!==void 0){const a=s[t]??this._minDegree??0;return(this._degreeRange??0)>0?(a-(this._minDegree??0))/this._degreeRange*100:50}return 1}_calculateDegreeSummary(){const e=this._.public.pointDegrees;if(e&&!this._degreeSummaryCalculated){this._minDegree=1/0,this._maxDegree=-1/0;for(let t=0;t<e.length;t++){const n=e[t];n!==void 0&&(this._maxDegree=Math.max(this._maxDegree,n),this._minDegree=Math.min(this._minDegree,n))}this._minDegree===1/0&&(this._minDegree=0),this._maxDegree===-1/0&&(this._maxDegree=this._minDegree),this._degreeRange=this._maxDegree-this._minDegree,this._degreeSummaryCalculated=!0}}_renderLabels(){var p,m;const{public:{crossfilter:e}}=this._,{pointLabelClassName:t,clusterLabelClassName:n,labelMargin:s,pointLabelColor:r,pointLabelFontSize:o,clusterLabelFontSize:a=xc,labelPadding:l}=this._.config,c=e.intersection,u=this._.crossfilter.isFilteringActive,d=os.cosmographLabelHidden,h=Array.from(this._labelDataMap.entries()).map(([y,g])=>{var et;const{index:_,text:S,position:E,className:x,weight:T,color:I,fontSize:O,padding:H,maxWidth:Q}=g,re=y.startsWith("custom-"),D=y.startsWith("cluster-"),de=D?os.cosmographClusterLabel:os.cosmographLabel,[se,R]=this._.public.spaceToScreenPosition(E),ee=this._.public.getPointScreenRadiusByIndex(_),F=((et=this._focusedLabel)==null?void 0:et[0])===_,q=!!u&&c.has(_),te=!u||q,Z=D?n:t;let ae;if(ae=typeof Z=="function"?Z(S,_,y)??"":Z??"",D&&Q){const he=`max-width: ${Q}px;`;ae=ae.includes(":")?`${ae} ${he}`:he}const J=ae.includes(":");let Se=J?`${te?de:d} ${x}`:`${te?de:d} ${ae} ${x}`,xe;return(D?this._hasClusterLabelEvents():this._hasPointLabelEvents())&&(Se+=` ${os.cosmographLabelInteractive}`),xe=re?R:D?R+a/2+s:R-ee/2-s,{id:y,text:S,x:se,y:xe,padding:D?H:this._getPaddingObject(l),weight:D?T:this._normalizeWeight(T,_,q),shouldBeShown:F,fontSize:O??o,color:re?I:I??(t!==void 0?void 0:r??this._getLabelColorByIndex(_)),style:J?ae:"",className:Se}});(p=this._cssLabelsRenderer)==null||p.setLabels(h),(m=this._cssLabelsRenderer)==null||m.draw(!0)}async renderHoveredLabel(e,t){var T,I;if(!this._.cosmos)return;const{config:n,dbCoordinator:s,public:{pointsTableName:r}}=this._,{pointLabelBy:o,showHoveredPointLabel:a,hoveredPointLabelClassName:l,labelMargin:c,pointLabelFontSize:u,labelPadding:d}=n;if(this._hoveredCssLabel.setPointerEvents(this._checkLabelEvents()),!(s&&a&&o&&e!==void 0&&t&&this._validLabelAccessor))return this._hoveredCssLabel.setVisibility(!1),void this._hoveredCssLabel.draw();const h=await Ec(s,r,n,[e]);if(!h)return;const p=(T=h.ids)==null?void 0:T.get(0),m=((I=h.labels)==null?void 0:I.get(0))??"",[y,g]=this._.public.spaceToScreenPosition(t),_=this._.public.getPointScreenRadiusByIndex(e);let S,E;S=typeof l=="function"?l(m,e,p)??"":l??"";const x=S.includes(":");E=x?os.cosmographLabelHovered:[os.cosmographLabelHovered,S].join(" "),this._checkLabelEvents()==="all"&&(E+=` ${os.cosmographLabelInteractive}`),this._hoveredCssLabel.setText(m),this._hoveredCssLabel.setVisibility(!0),this._hoveredCssLabel.setPosition(y,g-_/2-c),this._hoveredCssLabel.setClassName(E),this._hoveredCssLabel.setStyle(x?S:""),this._hoveredCssLabel.setFontSize(u),this._hoveredCssLabel.setPadding(this._getPaddingObject(d)),l||this._hoveredCssLabel.setColor(this._getLabelColorByIndex(e)),this._hoveredCssLabel.draw()}setCustomLabels(e){const{rescaleXFn:t,rescaleYFn:n}=this._.public;this._customLabelsMap.clear(),e&&e.forEach((s,r)=>{const o={...s};t&&n&&o.position[0]!==void 0&&o.position[1]!==void 0&&(o.position=[t(o.position[0]),n(o.position[1])]),this._customLabelsMap.set(`custom-${r}`,o)})}setZooming(e,t=!0){const n=this._isZooming;this._isZooming=e,this._isManualZooming=t,n&&!e&&this.render().catch(console.error)}destroy(){var e,t,n,s;this.clear(),(e=this._hoveredCssLabel)==null||e.element.removeEventListener("click",this._onHoveredLabelClick,{passive:!0}),(t=this._hoveredCssLabel)==null||t.destroy(),(n=this._cssLabelsRenderer)==null||n.destroy(),(s=this._.containerElement)==null||s.removeChild(this.labelsContainer)}clear(){var e,t,n;this._cachedTrackedPointsPositions=void 0,this._lastTrackedPointsQueryTime=0,this._isZooming=!1,this._degreeSummaryCalculated=!1,this._minDegree=void 0,this._maxDegree=void 0,this._degreeRange=void 0,this._labelDataMap.size&&(this._customLabelsMap.clear(),this._staticLabelsMap.clear(),this._dynamicLabelsMap.clear(),this._labelDataMap.clear(),(e=this._cssLabelsRenderer)==null||e.setLabels([]),(t=this._cssLabelsRenderer)==null||t.draw(),(n=this._hoveredCssLabel)==null||n.destroy())}_getLabelColorByIndex(e){var r;const t=(r=this._.cosmos)==null?void 0:r.graph.pointColors,n=WZ(t,e)??this._.config.pointDefaultColor,s=ao(this._.config.pointDefaultColor,G_);return ao(n,s)}_hasPointLabelEvents(){const{onLabelClick:e,selectPointOnLabelClick:t,focusPointOnLabelClick:n}=this._.config;return e!==void 0||!!t||!!n}_hasClusterLabelEvents(){const{onClusterLabelClick:e,selectClusterOnLabelClick:t}=this._.config;return e!==void 0||!!t}_getPaddingObject(e){if(e&&!(e.length<4))return{left:e[0]??0,top:e[1]??0,right:e[2]??0,bottom:e[3]??0}}_getClusterPadding(e){const{scaleClusterLabels:t,clusterLabelFontSize:n=xc}=this._.config,s=this._getPaddingObject(this._.config.labelPadding);if(!t||!e)return s;const r=e/n;return{left:s.left*r,top:s.top*r,right:s.right*r,bottom:s.bottom*r}}_getClusterLabelText(e,t){const{scaleClusterLabels:n,clusterLabelFontSize:s=xc}=this._.config;if(!n||!t)return{text:e,maxWidth:350};const r=t/s,o=Math.max(350,Math.min(900,500*r)),a=.6*t,l=Math.floor(o/a);return e.length*a>o?{text:`${e.substring(0,Math.max(3,l-3))}...`,maxWidth:o}:{text:e,maxWidth:o}}};const _Q='<svg fill="currentColor" height="11" viewBox="0 0 163 11" width="163" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor"><path d="m2.45674 8-1.925002-5.379h.924002l1.617 4.73h.154l1.617-4.73h.924l-1.925 5.379z"/><path d="m7.02243 8v-5.379h.869v5.379zm.44-6.215c-.19067 0-.352-.06233-.484-.187-.12467-.12467-.187-.28233-.187-.473 0-.198.06233-.359333.187-.484.132-.124667.29333-.187.484-.187.19066 0 .34833.062333.473.187.12466.124667.187.286.187.484 0 .19067-.06234.34833-.187.473-.12467.12467-.28234.187-.473.187z"/><path d="m11.8857 8.154c-.6673 0-1.232-.154-1.694-.462-.45465-.308-.72965-.79567-.82499-1.463l.82499-.187c.0587.352.1687.63067.33.836.1613.198.3593.341.594.429.242.08067.4987.121.77.121.4033 0 .7223-.08067.957-.242s.352-.37767.352-.649c0-.27867-.1137-.473-.341-.583-.22-.11733-.5243-.21267-.913-.286l-.451-.077c-.3447-.05867-.66-.15033-.946-.275s-.5133-.29333-.68199-.506c-.16866-.21267-.25299-.48033-.25299-.803 0-.484.18699-.86167.56098-1.133.374-.27133.869-.407 1.485-.407.6087 0 1.1.13933 1.474.418.3813.27133.627.65633.737 1.155l-.814.209c-.066-.38867-.2237-.66-.473-.814-.2493-.16133-.5573-.242-.924-.242s-.6563.06967-.869.209c-.2127.132-.319.33-.319.594 0 .25667.099.44733.297.572.2053.11733.4767.20533.814.264l.451.077c.3813.066.7223.15767 1.023.275.308.11.55.27133.726.484.1833.21267.275.49133.275.836 0 .528-.198.935-.594 1.221-.3887.286-.913.429-1.573.429z"/><path d="m17.5765 8.099c-.3887 0-.748-.08433-1.078-.253-.3227-.16867-.5793-.418-.77-.748-.1833-.33733-.275-.74433-.275-1.221v-3.256h.869v3.19c0 .53533.132.924.396 1.166.2713.242.6343.363 1.089.363.5133 0 .935-.16867 1.265-.506s.495-.83967.495-1.507v-2.706h.869v5.379h-.847v-.913h-.154c-.1173.25667-.319.49133-.605.704-.286.20533-.704.308-1.254.308z"/><path d="m23.9048 8.154c-.374 0-.715-.066-1.023-.198s-.55-.32267-.726-.572-.264-.55367-.264-.913c0-.36667.088-.66733.264-.902.176-.242.418-.42167.726-.539.308-.12467.6527-.187 1.034-.187h1.815v-.396c0-.38133-.1136-.682-.341-.902-.22-.22-.55-.33-.99-.33-.4326 0-.77.10633-1.012.319-.242.20533-.407.484-.495.836l-.814-.264c.088-.30067.2274-.572.418-.814.1907-.24933.4437-.44733.759-.594.3227-.154.7077-.231 1.155-.231.6894 0 1.2247.17967 1.606.539.3814.352.572.85067.572 1.496v2.431c0 .22.1027.33.308.33h.495v.737h-.759c-.242 0-.4363-.066-.583-.198-.1466-.13933-.22-.32267-.22-.55v-.055h-.132c-.0806.13933-.1906.286-.33.44-.132.14667-.3153.26767-.55.363-.2346.10267-.539.154-.913.154zm.099-.748c.5134 0 .9277-.15033 1.243-.451.3227-.308.484-.737.484-1.287v-.121h-1.782c-.3446 0-.6306.077-.858.231-.22.14667-.33.37033-.33.671s.1137.53533.341.704c.2347.16867.5354.253.902.253z"/><path d="m28.582 8v-7.7h.869v7.7z"/><path d="m31.2783 8v-5.379h.869v5.379zm.44-6.215c-.1907 0-.352-.06233-.484-.187-.1247-.12467-.187-.28233-.187-.473 0-.198.0623-.359333.187-.484.132-.124667.2933-.187.484-.187s.3483.062333.473.187.187.286.187.484c0 .19067-.0623.34833-.187.473s-.2823.187-.473.187z"/><path d="m33.7326 8v-1.122l3.421-3.377v-.121h-3.311v-.759h4.224v1.122l-3.432 3.377v.132h3.52v.748z"/><path d="m41.9601 8.154c-.5427 0-1.0194-.11367-1.43-.341-.4107-.23467-.7297-.561-.957-.979-.2274-.418-.341-.902-.341-1.452v-.132c0-.55733.1136-1.045.341-1.463.2273-.418.5426-.74067.946-.968.4033-.23467.8653-.352 1.386-.352.506 0 .9533.11 1.342.33.3886.21267.693.52067.913.924s.33.87633.33 1.419v.396h-4.389c.022.57933.209 1.034.561 1.364.352.32267.792.484 1.32.484.462 0 .8176-.10633 1.067-.319.2493-.21267.44-.46567.572-.759l.748.363c-.11.22733-.264.45467-.462.682-.1907.22733-.4437.418-.759.572-.308.154-.704.231-1.188.231zm-1.848-3.333h3.498c-.0294-.49867-.2017-.88733-.517-1.166-.308-.27867-.704-.418-1.188-.418-.4914 0-.8947.13933-1.21.418-.3154.27867-.5097.66733-.583 1.166z"/><path d="m48.2828 8.154c-.462 0-.8873-.11-1.276-.33-.3886-.22-.6966-.539-.924-.957-.2273-.418-.341-.913-.341-1.485v-.143c0-.572.1137-1.06333.341-1.474.2274-.418.5317-.737.913-.957.3887-.22733.8177-.341 1.287-.341.374 0 .6894.05133.946.154.264.09533.4767.22.638.374.1614.14667.286.30433.374.473h.154v-3.168h.869v7.7h-.847v-.891h-.154c-.1466.27133-.374.51333-.682.726s-.7406.319-1.298.319zm.231-.77c.5574 0 1.0084-.176 1.353-.528.352-.35933.528-.858.528-1.496v-.099c0-.638-.176-1.133-.528-1.485-.3446-.35933-.7956-.539-1.353-.539-.55 0-1.0046.17967-1.364.539-.352.352-.528.847-.528 1.485v.099c0 .638.176 1.13667.528 1.496.3594.352.814.528 1.364.528z"/><path d="m58.8911 8.154c-.5573 0-.9936-.10633-1.309-.319-.308-.21267-.5316-.45467-.671-.726h-.154v.891h-.847v-7.7h.869v3.168h.154c.088-.16867.2127-.32633.374-.473.1614-.154.3704-.27867.627-.374.264-.10267.583-.154.957-.154.4694 0 .8947.11367 1.276.341.3887.22.6967.539.924.957.2274.41067.341.902.341 1.474v.143c0 .572-.1173 1.067-.352 1.485-.2273.418-.5353.737-.924.957-.3813.22-.803.33-1.265.33zm-.231-.77c.5574 0 1.0084-.176 1.353-.528.352-.35933.528-.858.528-1.496v-.099c0-.638-.176-1.133-.528-1.485-.3446-.35933-.7956-.539-1.353-.539-.55 0-1.0046.17967-1.364.539-.352.352-.528.847-.528 1.485v.099c0 .638.176 1.13667.528 1.496.3594.352.814.528 1.364.528z"/><path d="m63.6382 10.2v-.77h3.08c.2127 0 .319-.11.319-.33v-1.958h-.154c-.0733.154-.187.308-.341.462-.1466.14667-.341.26767-.583.363-.242.088-.5463.132-.913.132-.3886 0-.748-.08433-1.078-.253-.3226-.16867-.5793-.418-.77-.748-.1833-.33-.275-.73333-.275-1.21v-3.267h.869v3.201c0 .528.132.913.396 1.155.2714.242.6344.363 1.089.363.5134 0 .935-.16867 1.265-.506s.495-.83967.495-1.507v-2.706h.869v6.633c0 .29333-.0843.52433-.253.693-.1613.1687-.3996.253-.715.253z"/><path d="m75.2998 8.154c-.9167 0-1.6464-.264-2.189-.792-.5427-.53533-.814-1.31267-.814-2.332v-1.76c0-1.01933.2713-1.793.814-2.321.5426-.535333 1.2723-.803 2.189-.803.9093 0 1.606.253 2.09.759.4913.506.737 1.199.737 2.079v.055h-.913v-.088c0-.57933-.1577-1.05233-.473-1.419-.308-.374-.7884-.561-1.441-.561-.6527 0-1.1624.20167-1.529.605-.3667.396-.55.95333-.55 1.672v1.804c0 .71867.1833 1.27967.55 1.683.3666.396.8763.594 1.529.594.6526 0 1.133-.18333 1.441-.55.3153-.374.473-.85067.473-1.43v-.176h.913v.143c0 .88-.2457 1.573-.737 2.079-.484.506-1.1807.759-2.09.759z"/><path d="m82.0934 8.154c-.5427 0-1.023-.11367-1.441-.341-.4107-.22733-.7333-.54633-.968-.957-.2273-.418-.341-.90933-.341-1.474v-.143c0-.55733.1137-1.045.341-1.463.2347-.418.5573-.74067.968-.968.418-.22733.8983-.341 1.441-.341s1.0193.11367 1.43.341c.418.22733.7407.55.968.968.2347.418.352.90567.352 1.463v.143c0 .56467-.1173 1.056-.352 1.474-.2273.41067-.55.72967-.968.957-.4107.22733-.8873.341-1.43.341zm0-.781c.572 0 1.0267-.17967 1.364-.539.3447-.36667.517-.858.517-1.474v-.099c0-.616-.1723-1.10367-.517-1.463-.3373-.36667-.792-.55-1.364-.55-.5647 0-1.0193.18333-1.364.55-.3447.35933-.517.847-.517 1.463v.099c0 .616.1723 1.10733.517 1.474.3447.35933.7993.539 1.364.539z"/><path d="m88.5742 8.154c-.6673 0-1.232-.154-1.694-.462-.4547-.308-.7297-.79567-.825-1.463l.825-.187c.0587.352.1687.63067.33.836.1613.198.3593.341.594.429.242.08067.4987.121.77.121.4033 0 .7223-.08067.957-.242s.352-.37767.352-.649c0-.27867-.1137-.473-.341-.583-.22-.11733-.5243-.21267-.913-.286l-.451-.077c-.3447-.05867-.66-.15033-.946-.275s-.5133-.29333-.682-.506-.253-.48033-.253-.803c0-.484.187-.86167.561-1.133s.869-.407 1.485-.407c.6087 0 1.1.13933 1.474.418.3813.27133.627.65633.737 1.155l-.814.209c-.066-.38867-.2237-.66-.473-.814-.2493-.16133-.5573-.242-.924-.242s-.6563.06967-.869.209c-.2127.132-.319.33-.319.594 0 .25667.099.44733.297.572.2053.11733.4767.20533.814.264l.451.077c.3813.066.7223.15767 1.023.275.308.11.55.27133.726.484.1833.21267.275.49133.275.836 0 .528-.198.935-.594 1.221-.3887.286-.913.429-1.573.429z"/><path d="m92.208 8v-5.379h.847v.671h.154c.1026-.19067.2713-.36667.506-.528.2346-.16133.5646-.242.99-.242.418 0 .7553.09167 1.012.275.264.18333.4546.407.572.671h.154c.1246-.264.3116-.48767.561-.671.2566-.18333.6123-.275 1.067-.275.3593 0 .6746.07333.946.22.2713.14667.484.35933.638.638.1613.27133.242.59767.242.979v3.641h-.869v-3.564c0-.35933-.1064-.64167-.319-.847-.2054-.21267-.495-.319-.869-.319-.396 0-.7224.12833-.979.385-.2494.25667-.374.627-.374 1.111v3.234h-.869v-3.564c0-.35933-.1064-.64167-.319-.847-.2054-.21267-.495-.319-.869-.319-.396 0-.7224.12833-.979.385-.2494.25667-.374.627-.374 1.111v3.234z"/><path d="m104.158 8.154c-.543 0-1.023-.11367-1.441-.341-.411-.22733-.733-.54633-.968-.957-.227-.418-.341-.90933-.341-1.474v-.143c0-.55733.114-1.045.341-1.463.235-.418.557-.74067.968-.968.418-.22733.898-.341 1.441-.341s1.019.11367 1.43.341c.418.22733.741.55.968.968.235.418.352.90567.352 1.463v.143c0 .56467-.117 1.056-.352 1.474-.227.41067-.55.72967-.968.957-.411.22733-.887.341-1.43.341zm0-.781c.572 0 1.027-.17967 1.364-.539.345-.36667.517-.858.517-1.474v-.099c0-.616-.172-1.10367-.517-1.463-.337-.36667-.792-.55-1.364-.55-.565 0-1.019.18333-1.364.55-.345.35933-.517.847-.517 1.463v.099c0 .616.172 1.10733.517 1.474.345.35933.799.539 1.364.539z"/><path d="m108.208 5.338v-.154c0-.56467.113-1.04867.341-1.452.227-.40333.535-.715.924-.935.388-.22.814-.33 1.276-.33.564 0 .997.11 1.298.33.308.21267.535.451.682.715h.154v-.891h.825v6.633c0 .29333-.081.52433-.242.693-.162.1687-.396.253-.704.253h-3.652v-.77h3.421c.22 0 .33-.11.33-.33v-2.046h-.154c-.088.16133-.213.319-.374.473-.162.154-.371.28233-.627.385-.257.09533-.576.143-.957.143-.462 0-.888-.11-1.276-.33-.389-.22-.697-.53167-.924-.935-.228-.41067-.341-.89467-.341-1.452zm2.772 1.947c.557 0 1.008-.176 1.353-.528.352-.352.528-.836.528-1.452v-.088c0-.62333-.176-1.10733-.528-1.452-.345-.352-.796-.528-1.353-.528-.55 0-1.005.176-1.364.528-.352.34467-.528.82867-.528 1.452v.088c0 .616.176 1.1.528 1.452.359.352.814.528 1.364.528z"/><path d="m115.529 8v-5.379h.847v.66h.154c.096-.23467.242-.407.44-.517s.459-.165.781-.165h.638v.792h-.693c-.388 0-.704.11-.946.33-.234.21267-.352.54633-.352 1.001v3.278z"/><path d="m121.143 8.154c-.374 0-.715-.066-1.023-.198s-.55-.32267-.726-.572-.264-.55367-.264-.913c0-.36667.088-.66733.264-.902.176-.242.418-.42167.726-.539.308-.12467.653-.187 1.034-.187h1.815v-.396c0-.38133-.114-.682-.341-.902-.22-.22-.55-.33-.99-.33-.433 0-.77.10633-1.012.319-.242.20533-.407.484-.495.836l-.814-.264c.088-.30067.227-.572.418-.814.191-.24933.444-.44733.759-.594.323-.154.708-.231 1.155-.231.689 0 1.225.17967 1.606.539.381.352.572.85067.572 1.496v2.431c0 .22.103.33.308.33h.495v.737h-.759c-.242 0-.436-.066-.583-.198-.147-.13933-.22-.32267-.22-.55v-.055h-.132c-.081.13933-.191.286-.33.44-.132.14667-.315.26767-.55.363-.235.10267-.539.154-.913.154zm.099-.748c.513 0 .928-.15033 1.243-.451.323-.308.484-.737.484-1.287v-.121h-1.782c-.345 0-.631.077-.858.231-.22.14667-.33.37033-.33.671s.114.53533.341.704c.235.16867.535.253.902.253z"/><path d="m125.82 10.2v-7.579h.847v.891h.154c.14-.27133.363-.51333.671-.726.316-.21267.752-.319 1.309-.319.462 0 .884.11367 1.265.341.389.22.697.53533.924.946.235.41067.352.90567.352 1.485v.143c0 .572-.113 1.067-.341 1.485-.227.418-.535.737-.924.957-.381.22-.806.33-1.276.33-.374 0-.693-.05133-.957-.154-.256-.09533-.465-.22-.627-.374-.161-.154-.286-.31167-.374-.473h-.154v3.047zm2.75-2.816c.558 0 1.009-.176 1.353-.528.352-.35933.528-.858.528-1.496v-.099c0-.638-.176-1.133-.528-1.485-.344-.35933-.795-.539-1.353-.539-.55 0-1.004.17967-1.364.539-.352.352-.528.847-.528 1.485v.099c0 .638.176 1.13667.528 1.496.36.352.814.528 1.364.528z"/><path d="m132.899 8v-7.7h.869v3.179h.154c.074-.16133.184-.31167.33-.451.154-.14667.349-.26767.583-.363.242-.09533.547-.143.913-.143.404 0 .763.088 1.078.264.323.16867.58.418.77.748.191.32267.286.726.286 1.21v3.256h-.869v-3.19c0-.53533-.135-.924-.407-1.166-.264-.242-.623-.363-1.078-.363-.52 0-.946.16867-1.276.506-.322.33733-.484.83967-.484 1.507v2.706z"/><path d="m140.118 8.154c-.212 0-.392-.06967-.539-.209-.139-.13933-.209-.319-.209-.539s.07-.39967.209-.539c.147-.13933.327-.209.539-.209.22 0 .4.06967.539.209.14.13933.209.319.209.539s-.069.39967-.209.539c-.139.13933-.319.209-.539.209z"/><path d="m144.078 8.154c-.374 0-.715-.066-1.023-.198s-.55-.32267-.726-.572-.264-.55367-.264-.913c0-.36667.088-.66733.264-.902.176-.242.418-.42167.726-.539.308-.12467.652-.187 1.034-.187h1.815v-.396c0-.38133-.114-.682-.341-.902-.22-.22-.55-.33-.99-.33-.433 0-.77.10633-1.012.319-.242.20533-.407.484-.495.836l-.814-.264c.088-.30067.227-.572.418-.814.19-.24933.443-.44733.759-.594.322-.154.707-.231 1.155-.231.689 0 1.224.17967 1.606.539.381.352.572.85067.572 1.496v2.431c0 .22.102.33.308.33h.495v.737h-.759c-.242 0-.437-.066-.583-.198-.147-.13933-.22-.32267-.22-.55v-.055h-.132c-.081.13933-.191.286-.33.44-.132.14667-.316.26767-.55.363-.235.10267-.539.154-.913.154zm.099-.748c.513 0 .927-.15033 1.243-.451.322-.308.484-.737.484-1.287v-.121h-1.782c-.345 0-.631.077-.858.231-.22.14667-.33.37033-.33.671s.113.53533.341.704c.234.16867.535.253.902.253z"/><path d="m148.755 10.2v-7.579h.847v.891h.154c.139-.27133.363-.51333.671-.726.315-.21267.752-.319 1.309-.319.462 0 .884.11367 1.265.341.389.22.697.53533.924.946.235.41067.352.90567.352 1.485v.143c0 .572-.114 1.067-.341 1.485s-.535.737-.924.957c-.381.22-.807.33-1.276.33-.374 0-.693-.05133-.957-.154-.257-.09533-.466-.22-.627-.374s-.286-.31167-.374-.473h-.154v3.047zm2.75-2.816c.557 0 1.008-.176 1.353-.528.352-.35933.528-.858.528-1.496v-.099c0-.638-.176-1.133-.528-1.485-.345-.35933-.796-.539-1.353-.539-.55 0-1.005.17967-1.364.539-.352.352-.528.847-.528 1.485v.099c0 .638.176 1.13667.528 1.496.359.352.814.528 1.364.528z"/><path d="m155.834 10.2v-7.579h.847v.891h.154c.139-.27133.363-.51333.671-.726.315-.21267.752-.319 1.309-.319.462 0 .884.11367 1.265.341.389.22.697.53533.924.946.235.41067.352.90567.352 1.485v.143c0 .572-.114 1.067-.341 1.485s-.535.737-.924.957c-.381.22-.807.33-1.276.33-.374 0-.693-.05133-.957-.154-.257-.09533-.466-.22-.627-.374s-.286-.31167-.374-.473h-.154v3.047zm2.75-2.816c.557 0 1.008-.176 1.353-.528.352-.35933.528-.858.528-1.496v-.099c0-.638-.176-1.133-.528-1.485-.345-.35933-.796-.539-1.353-.539-.55 0-1.005.17967-1.364.539-.352.352-.528.847-.528 1.485v.099c0 .638.176 1.13667.528 1.496.359.352.814.528 1.364.528z"/><path d="m71.6368 9.375h90.3682v.55h-90.3682z"/></g></svg>';var yQ=".style_module_rectSelect__6c3b1fe5{height:100%;left:0;position:absolute;top:0;width:100%}",bQ={rectSelect:"style_module_rectSelect__6c3b1fe5"};Dr(yQ,{});let vQ=class{constructor(e){b(this,"_");b(this,"_svg");b(this,"_onSelectCallback");b(this,"_brush",TY().keyModifiers(!1).on("end",e=>{var r;if(!e.sourceEvent)return;const{shiftKey:t,altKey:n}=e.sourceEvent,s=e.selection;(r=this._onSelectCallback)==null||r.call(this,s,t,n)}));var t;this._=e,this._svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._svg.classList.add(bQ.rectSelect),(t=this._.containerElement)==null||t.appendChild(this._svg),this._onSelectCallback=this._.eventManager.onRectSelect,Wt(this._svg).select(".brush-group").remove(),this._brush.extent([[0,0],[this._svg.clientWidth,this._svg.clientHeight]]),Wt(this._svg).append("g").attr("class","brush-group").call(this._brush),this.updateSelectionClassName(),Wt(this._svg).style("display","none")}updateSelectionClassName(){const e=`selection ${this._.config.rectangularSelectorClassName??""}`;Wt(this._svg).select(".brush-group").selectAll(".selection").attr("class",e)}enable(){Wt(this._svg).style("display",null),this._brush.extent([[0,0],[this._svg.clientWidth,this._svg.clientHeight]]),Wt(this._svg).select(".brush-group").call(this._brush)}disable(){Wt(this._svg).style("display","none"),Wt(this._svg).select(".brush-group").call(this._brush.clear)}destroy(){Wt(this._svg).select(".brush-group").remove(),this._svg.remove()}};var xQ=".style_module_polygonalSelect__f21ae84d{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}",wQ={polygonalSelect:"style_module_polygonalSelect__f21ae84d"};Dr(xQ,{});let SQ=class{constructor(e){b(this,"_");b(this,"_canvas");b(this,"_ctx");b(this,"_isDrawing",!1);b(this,"_points",[]);b(this,"_onSelectCallback");b(this,"_resizeObserver");b(this,"_startDrawing",e=>{this._isDrawing=!0,this._points=[];const t=this._canvas.getBoundingClientRect();this._points.push({x:e.clientX-t.left,y:e.clientY-t.top});const n=window.devicePixelRatio||1;this._ctx.clearRect(0,0,this._canvas.width/n,this._canvas.height/n)});b(this,"_draw",e=>{if(!this._isDrawing)return;const t=this._canvas.getBoundingClientRect();this._points.push({x:e.clientX-t.left,y:e.clientY-t.top});const n=window.devicePixelRatio||1;this._ctx.clearRect(0,0,this._canvas.width/n,this._canvas.height/n),this._ctx.beginPath(),this._points.length>0&&this._points[0]&&this._ctx.moveTo(this._points[0].x,this._points[0].y);for(let s=1;s<this._points.length;s++){const r=this._points[s];r&&this._ctx.lineTo(r.x,r.y)}this._ctx.strokeStyle=this._.config.polygonalSelectorStrokeColor||"#ffffff",this._ctx.lineWidth=this._.config.polygonalSelectorLineWidth||2,this._ctx.stroke()});b(this,"_stopDrawing",e=>{var n;if(!this._isDrawing)return;if(this._isDrawing=!1,this._points.length>2){this._ctx.closePath(),this._ctx.stroke();const s=this._points.map(a=>[a.x,a.y]),r=s[0],o=s[s.length-1];r&&o&&(r[0]!==o[0]||r[1]!==o[1])&&s.push(r),(n=this._onSelectCallback)==null||n.call(this,s,e.shiftKey,e.altKey)}const t=window.devicePixelRatio||1;this._ctx.clearRect(0,0,this._canvas.width/t,this._canvas.height/t)});this._=e,this._onSelectCallback=this._.eventManager.onPolygonSelect,this._initializeCanvas(),this._resizeObserver=new ResizeObserver(()=>this._resizeCanvas()),this._resizeObserver.observe(this._.containerElement)}_initializeCanvas(){const e=this._.containerElement;if(!e)return void console.error("Container element is undefined");this._canvas=document.createElement("canvas"),this._canvas.classList.add(wQ.polygonalSelect),e.appendChild(this._canvas);const t=this._canvas.getContext("2d");if(!t)return void console.error("Failed to get canvas context");this._ctx=t;const n=window.devicePixelRatio||1;this._canvas.width=e.clientWidth*n,this._canvas.height=e.clientHeight*n,this._canvas.style.width=`${e.clientWidth}px`,this._canvas.style.height=`${e.clientHeight}px`,this._ctx.scale(n,n)}enable(){this._canvas.style.display="block",this._canvas.style.pointerEvents="auto",this._canvas.style.cursor="crosshair",this._canvas.addEventListener("mousedown",this._startDrawing),this._canvas.addEventListener("mousemove",this._draw),this._canvas.addEventListener("mouseup",this._stopDrawing)}disable(){if(this._canvas.style.display="none",this._canvas.style.pointerEvents="none",this._canvas.style.cursor="default",this._canvas.removeEventListener("mousedown",this._startDrawing),this._canvas.removeEventListener("mousemove",this._draw),this._canvas.removeEventListener("mouseup",this._stopDrawing),this._ctx){const e=window.devicePixelRatio||1;this._ctx.clearRect(0,0,this._canvas.width/e,this._canvas.height/e)}}destroy(){var e;(e=this._resizeObserver)==null||e.disconnect(),this.disable(),this._canvas.parentNode&&this._canvas.parentNode.removeChild(this._canvas)}_resizeCanvas(){const{width:e,height:t}=this._.containerElement.getBoundingClientRect(),n=window.devicePixelRatio||1;this._canvas.width=e*n,this._canvas.height=t*n,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._ctx.scale(n,n)}};const mI=new WeakMap;function La(i){return mI.get(i)}function EQ(i,e){mI.set(i,e)}var br;let gI=(br=class{constructor(e){b(this,"_id");b(this,"_isActive",!0);b(this,"_client");b(this,"_selection");b(this,"_config");b(this,"_currentData");b(this,"_isArrayColumn",!1);this._config=e,this._client=this._createClient();const t=`${this.fieldsToQuery.join(",")}-${lv()}`;this._id=e.id?`${e.id}-${t}`:t}static getOrCreateClient(e){if(e.id){const n=br._clientRegistry.get(e.id);if(n)return n._config=e,n._isArrayColumn=!1,n._currentData&&n._detectArrayColumn(),n}const t=new br(e);return e.id&&br._clientRegistry.set(e.id,t),t}get selection(){return this._selection}get tableName(){return this._config.getTableName()}get accessor(){return this._config.getAccessor()}get id(){return this._id}get active(){return this._client.enabled}get currentData(){return this._currentData}get fieldsToQuery(){const e=this._config.includeFields?this._config.includeFields():[];return this._isActive?[...new Set([...this.accessor?[cn(this.accessor)]:[],...e].filter(Boolean))]:["*"]}setActive(e){this._isActive=e}async getCurrentData(){const e=await this._config.coordinator.query(Ai.from(this.tableName).select(this.fieldsToQuery));return this._currentData=e,this._detectArrayColumn(),e}_detectArrayColumn(){var e;try{const t=this.accessor,n=t?(e=this._currentData)==null?void 0:e.getChild(t):void 0;this._isArrayColumn=!(!n||!(Hk(n.type)||n.length>0&&Array.isArray(n.get(0))))}catch{this._isArrayColumn=!1}}applyFilter(e){var t;(t=this.selection)==null||t.update({source:this,predicate:e??null,value:e??null})}applyRangeFilter(e){this.accessor&&this.applyFilter(e?o_(cn(this.accessor),e):void 0)}applyExactFilter(e){if(e===void 0)return void this.applyFilter(void 0);if(e==="null")return void this.applyFilter(Z7(cn(this.accessor)));const t=this._isArrayColumn?qu`list_contains(${cn(this.accessor)}, ${An(e)})`:J7(cn(this.accessor),An(e));this.applyFilter(t)}applyInFilter(e){if(this.accessor)if(e&&e.length>0){const t=(Array.isArray(e)?e:Array.from(e)).map(n=>An(n));this.applyFilter(a_(cn(this.accessor),t))}else this.applyFilter(void 0)}applyLessOrEqFilter(e){this.accessor&&this.applyFilter(e!==void 0?ub(cn(this.accessor),An(e)):void 0)}applyGreaterOrEqFilter(e){this.accessor&&this.applyFilter(e!==void 0?db(cn(this.accessor),An(e)):void 0)}resetFilter(){var e,t;this.selection&&((t=(e=this.selection)==null?void 0:e.clauses)==null?void 0:t.filter(n=>n.source.id===this.id).length)>0&&this.selection.update({source:this,predicate:null,value:null})}update(){this._client.update()}destroy(){this.resetFilter(),this._client.destroy(),this._config.id&&br._clientRegistry.delete(this._config.id)}regenerateClient(){this.destroy(),this._client=this._createClient()}_createClient(){return this._selection=this._config.getSelection(),X8({coordinator:this._config.coordinator,selection:this.selection,query:e=>{var t;return this._isActive&&((t=this.selection)!=null&&t.clauses.active)?Ai.from(this.tableName).select(this.fieldsToQuery).where(e??[]):null},queryResult:e=>{var n,s;const t=e;this._currentData=t,(s=(n=this._config).onFiltered)==null||s.call(n,t)}})}reset(){this.resetFilter()}},b(br,"_clientRegistry",new Map),br),_I=class{constructor(e,t,n){b(this,"_dataUpdatedHandler");b(this,"_dataFilteredHandler");b(this,"_resetSelectionsHandler");b(this,"_internalApi");b(this,"_isValidAccessor",!1);b(this,"_currentData");b(this,"_client");b(this,"_uiComponent");b(this,"_config");b(this,"_targetElement");b(this,"_abortController",new AbortController);b(this,"_readyPromise");b(this,"_isInitialLoad",!0);this._internalApi=La(e),this._targetElement=t,this._config=this._mergeWithDefaultConfig(n),this._dataUpdatedHandler=async()=>await this.fetchData(),this._dataFilteredHandler=()=>this.onDataFiltered(),this._resetSelectionsHandler=()=>this._onResetSelections(),this._internalApi.addEventListener("dataUploaded",this._dataUpdatedHandler),this._internalApi.addEventListener("dataFiltered",this._dataFilteredHandler),this._internalApi.addEventListener("resetSelections",this._resetSelectionsHandler),this._readyPromise=this._initialize()}onInitialize(){}onResetClientSelections(){}getCurrentData(){return null}async shouldUpdateComponentData(){return!1}get useLinksData(){return this._config.useLinksData??!1}get pointAccessors(){const{pointIdBy:e,pointIndexBy:t}=this._internalApi.config;return e&&t?[e,t]:[]}get linkAccessors(){const{linkSourceIndexBy:e,linkTargetIndexBy:t}=this._internalApi.config;return e&&t?[e,t]:[]}get selection(){return this.useLinksData?this._internalApi.crossfilter.linksSelection:this._internalApi.crossfilter.pointsSelection}get tableName(){return this.useLinksData?this._internalApi.public.linksTableName:this._internalApi.public.pointsTableName}async _initialize(){await Bj([async()=>{await this._internalApi.dbReady();const e=await this._getGlobalDisplayStateSettings(this._config);this._config={...this._config,...e}},async()=>{this._uiComponent=this.createUIComponent(this._targetElement),await this._internalApi.configManager.cosmosInitialized()},()=>this._createClient(),()=>this.fetchData(),()=>this.setConfig(this._config),()=>this.onConfigUpdate(),()=>Promise.resolve(this.onInitialize())],this._abortController)}async _getGlobalDisplayStateSettings(e){await this._internalApi.dbReady();const{componentsDisplayStateMode:t}=this._internalApi.config;let{disableStateMessages:n,noDataMessage:s}=e;return t===!1?n=!0:t==="loading"&&(s=!1),{disableStateMessages:n,noDataMessage:s,loadingMessage:e.loadingMessage}}async setConfig(e){var r;const t=this._config,n=this.accessor;this._config=this._mergeWithDefaultConfig(e),this._config={...this._config,...await this._getGlobalDisplayStateSettings(this._config)};const s=await this.shouldUpdateComponentData();this._config.useLinksData!==t.useLinksData&&((r=this._client)==null||r.regenerateClient()),(s||this._config.useLinksData!==t.useLinksData||this._config.useQuantiles!==t.useQuantiles||this.accessor!==n)&&(await this.fetchData(),this.onResetClientSelections()),await this.onConfigUpdate(t)}async fetchData(){var s,r,o,a,l;const{dbCoordinator:e,dataManager:t}=this._internalApi;if(!e||!this.accessor)return;await t.dataReady(),(r=(s=this._uiComponent)==null?void 0:s.setLoadingState)==null||r.call(s);const n=!this.accessor||await Ta(e,this.tableName);if(this._isValidAccessor=!this.accessor||n&&await Hp(e,this.tableName,[this.accessor]),this._isInitialLoad||((o=this._client)==null||o.resetFilter()),(a=this._client)==null||a.setActive(this._isValidAccessor),this._isValidAccessor){const c=await this.getCurrentData();this._currentData=c!==null?c:await((l=this._client)==null?void 0:l.getCurrentData())}else this._currentData=void 0;this._isInitialLoad&&(this._isInitialLoad=!1)}ready(){return this._readyPromise}checkReady(e){return!!this._uiComponent||(this.ready().then(e),!1)}async _createClient(){if(await this._internalApi.dbReady(),!this._internalApi.dbCoordinator)return;const e={coordinator:this._internalApi.dbCoordinator,getTableName:()=>this.tableName,getSelection:()=>this.selection,getAccessor:()=>this.accessor,includeFields:()=>this.useLinksData?this.linkAccessors:this.pointAccessors,onFiltered:this._handleSelectionUpdate.bind(this),id:this._config.id||this.constructor.name+this.accessor+lv()};this._client=gI.getOrCreateClient(e)}_handleSelectionUpdate(e){var n,s,r,o;if(!this.accessor)return;const t=this._internalApi.crossfilter;if(this.useLinksData){const a=t.linksSelection.active;((n=a==null?void 0:a.source)==null?void 0:n.id)===((s=this._client)==null?void 0:s.id)&&t.onLinksFiltered(e)}else{const a=t.pointsSelection.active;((r=a==null?void 0:a.source)==null?void 0:r.id)===((o=this._client)==null?void 0:o.id)&&t.onPointsFiltered(e)}}_onResetSelections(){var e;(e=this._client)==null||e.resetFilter(),this.onResetClientSelections()}_mergeWithDefaultConfig(e){return Yt(this.defaultConfig,e??{})}remove(){var e,t;this._abortController.abort(),(e=this._uiComponent)==null||e.destroy(),this._config.preserveSelectionOnUnmount||((t=this._client)==null||t.resetFilter()),this._internalApi.removeEventListener("dataUploaded",this._dataUpdatedHandler),this._internalApi.removeEventListener("dataFiltered",this._dataFilteredHandler),this._internalApi.removeEventListener("resetSelections",this._resetSelectionsHandler),this._isInitialLoad=!0}};var hs;let $u=(hs=class extends _I{static isInclusiveComponent(e){return hs._inclusiveComponentIds.has(e)}static register(e){hs._inclusiveComponentIds.add(e)}static unregister(e){hs._inclusiveComponentIds.delete(e)}onInitialize(){var e;(e=this._client)!=null&&e.id&&hs.register(this._client.id)}onDataFiltered(){var a;const{pointsSelection:e,linksSelection:t}=this._internalApi.crossfilter,n=e.active,s=t.active,r=!(n!=null&&n.predicate||e.clauses.length||s!=null&&s.predicate||t.clauses.length),o=l=>{var c,u,d;return(l==null?void 0:l.predicate)!==void 0&&((c=l==null?void 0:l.source)==null?void 0:c.id)===((u=this._client)==null?void 0:u.id)&&!hs.isInclusiveComponent((d=l==null?void 0:l.source)==null?void 0:d.id)};(o(n)||o(s)||r)&&((a=this._client)==null||a.resetFilter(),this.onResetClientSelections()),this.updateCrossfilteredData()}updateCrossfilteredData(){var n,s;const{crossfilter:e}=this._internalApi;if(!this._currentData||!this._isValidAccessor||!this.accessor)return;const t=e.filtered.intersection;if(e.isFilteringActive){const r=this._filterByIdx(this._currentData,t);this.updateHighlightedData(r)}else{const r=(s=(n=this._currentData)==null?void 0:n.getChild(this.accessor))==null?void 0:s.toArray();this.updateHighlightedData(r)}}_filterByIdx(e,t){var d,h;const{config:n}=this._internalApi;if(!this.accessor||!t.size)return[];const s=e.getChild(this.accessor);if(!s)return[];const r=this.useLinksData?n.linkSourceIndexBy:n.pointIndexBy,o=(d=e.getChild(r))==null?void 0:d.toArray();if(!o)return[];const a=this.useLinksData?(h=e.getChild(n.linkTargetIndexBy))==null?void 0:h.toArray():void 0,l=s.toArray(),c=t,u=[];for(let p=0,m=l.length;p<m;++p){const y=o[p];if(c.has(y)||a!==void 0&&c.has(a[p])){const g=l[p];Array.isArray(g)?u.push(...g):u.push(g)}}return u}remove(){var e;(e=this._client)!=null&&e.id&&hs.unregister(this._client.id),super.remove()}},b(hs,"_inclusiveComponentIds",new Set),hs),CQ=class{constructor(e){b(this,"_internalApi");b(this,"_pointSelectionClient");this._internalApi=e;const t={coordinator:this._internalApi.dbCoordinator,getSelection:()=>this._internalApi.crossfilter.pointsSelection,getTableName:()=>this._internalApi.public.pointsTableName,getAccessor:()=>this._internalApi.config.pointIndexBy,onFiltered:n=>this._onPointsFiltered(n),id:"pointsSelectionClient"};this._pointSelectionClient=new gI(t),this._pointSelectionClient.setActive(!0),$u.register(this._pointSelectionClient.id)}_onPointsFiltered(e){this._internalApi.crossfilter.onPointsFiltered(e)}selectPoints(e){e===void 0?this._pointSelectionClient.resetFilter():this._pointSelectionClient.applyInFilter(e)}get id(){return this._pointSelectionClient.id}destroy(){$u.unregister(this._pointSelectionClient.id)}};function Qc(i,e,t){this.k=i,this.x=e,this.y=t}Qc.prototype={constructor:Qc,scale:function(i){return i===1?this:new Qc(this.k*i,this.x,this.y)},translate:function(i,e){return i===0&e===0?this:new Qc(this.k,this.x+this.k*i,this.y+this.k*e)},apply:function(i){return[i[0]*this.k+this.x,i[1]*this.k+this.y]},applyX:function(i){return i*this.k+this.x},applyY:function(i){return i*this.k+this.y},invert:function(i){return[(i[0]-this.x)/this.k,(i[1]-this.y)/this.k]},invertX:function(i){return(i-this.x)/this.k},invertY:function(i){return(i-this.y)/this.k},rescaleX:function(i){return i.copy().domain(i.range().map(this.invertX,this).map(i.invert,i))},rescaleY:function(i){return i.copy().domain(i.range().map(this.invertY,this).map(i.invert,i))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};Qc.prototype;const TQ=bI(i=>{const e=yI(i);return t=>t==null?"":typeof t=="number"?e(t):t instanceof Date?kQ(t):`${t}`}),yI=bI(i=>e=>e===0?"0":e.toLocaleString(i));TQ();yI();function kQ(i){return AQ(i,"Invalid Date")}function bI(i){let e=null,t;return(n="en")=>n===e?t:t=i(e=n)}function AQ(i,e){if(i instanceof Date||(i=new Date(+i)),isNaN(+i))return typeof e=="function"?e(i):e;const t=i.getUTCHours(),n=i.getUTCMinutes(),s=i.getUTCSeconds(),r=i.getUTCMilliseconds();return`${IQ(i.getUTCFullYear())}-${Qr(i.getUTCMonth()+1,2)}-${Qr(i.getUTCDate(),2)}${t||n||s||r?`T${Qr(t,2)}:${Qr(n,2)}${s||r?`:${Qr(s,2)}${r?`.${Qr(r,3)}`:""}`:""}Z`:""}`}function IQ(i){return i<0?`-${Qr(-i,6)}`:i>9999?`+${Qr(i,6)}`:Qr(i,4)}function Qr(i,e){return`${i}`.padStart(e,"0")}let LQ=class{constructor(e){b(this,"_id");b(this,"_component");b(this,"_container");b(this,"_isDestroyed",!1);b(this,"_errorMessage");b(this,"_internalApi");b(this,"_marks",[]);this._id=e.id||`mosaic-component-${lv()}`,this._internalApi=e.internalApi}get id(){return this._id}get errorMessage(){return this._errorMessage}async mount(e,t){if(this._isDestroyed)return this._errorMessage=`Cannot mount component: component ${this._id} has been destroyed`,void we(`Cannot mount component: component ${this._id} has been destroyed`,"","warn");this._component&&(we(`Component ${this._id} is already mounted, unmounting first`,"","warn"),await this._unmount()),this._errorMessage=void 0;try{const n=await this._resolveElement(e);if(!n)return this._errorMessage="Component did not resolve to an HTMLElement",void we(`Skipped mounting ${this._id}: ${this._errorMessage}`,"","warn");const s=n==null?void 0:n.value;if(s&&!await this._validatePlot(s))return this._abortMount(t,this._errorMessage||"Chart references columns not available in dataset");s&&(this._attachErrorInterceptors(s,t),this._connectPlot(s),this._marks=s.marks?[...s.marks]:[]),this._component=e,this._container=t,t.innerHTML="",t.appendChild(n)}catch(n){this._abortMount(t,n instanceof Error?n.message:String(n))}}_abortMount(e,t){this._errorMessage=t,this._marks=[],this._showError(e),we(`Skipped mounting ${this._id}: ${t}`,"","warn")}async _resolveElement(e){if(e instanceof HTMLElement)return e}async _validatePlot(e){var t,n;if(!this._internalApi.dbCoordinator||!((t=e==null?void 0:e.marks)!=null&&t.length))return!0;for(const s of e.marks){const r=s.sourceTable(),o=(n=s.channels)==null?void 0:n.map(l=>{var c;return(c=l==null?void 0:l.field)==null?void 0:c.column}).filter(l=>typeof l=="string");if(!r||!(o!=null&&o.length))continue;const a=[];if(!await Hp(this._internalApi.dbCoordinator,r,o,a))return this._errorMessage=`Missing columns for table "${r}"${a.length?`: ${[...new Set(a)].join(", ")}`:""}`,!1}return!0}_attachErrorInterceptors(e,t){var n,s;if((n=e==null?void 0:e.marks)!=null&&n.length)for(const r of e.marks){if(!r)continue;const o=(s=r.queryError)==null?void 0:s.bind(r);r.queryError=a=>this._handleQueryError(a,e,t)?r:(o==null?void 0:o(a))??r}}_connectPlot(e){var t,n;if((t=e==null?void 0:e.marks)!=null&&t.length&&this._internalApi.dbCoordinator){for(const s of e.marks)if(s&&s.coordinator!==this._internalApi.dbCoordinator)try{(n=s.coordinator)==null||n.disconnect(s),this._internalApi.dbCoordinator.connect(s),s.queryPending()}catch(r){we(`Failed to connect mark for ${this._id}: ${r}`,"","warn")}}}_handleQueryError(e,t,n){var r;const s=e instanceof Error?e.message:String(e);return!!/no such column|cannot find column/i.test(s)&&(this._errorMessage="Mosaic query failed because required columns are missing.",this._cleanupSelections(),(r=t==null?void 0:t.marks)==null||r.forEach(o=>{var a,l;o&&(o.enabled=!1,(l=(a=o.coordinator)==null?void 0:a.disconnect)==null||l.call(a,o))}),this._component=void 0,this._marks=[],this._showError(n),we(`Disabled ${this._id} after query error: ${s}`,"","warn"),!0)}_cleanupSelections(){if(!this._marks.length)return;const e=new Set(this._marks.flatMap(t=>{var n;return((n=t==null?void 0:t.plot)==null?void 0:n.interactors)||[]}).filter(t=>(t==null?void 0:t.mark)&&this._marks.includes(t.mark)));e.size&&[this._internalApi.crossfilter.pointsSelection,this._internalApi.crossfilter.linksSelection].filter(Boolean).forEach(t=>{t.clauses.filter(n=>e.has(n==null?void 0:n.source)).forEach(n=>{t.update({source:n.source,predicate:null,value:null})})})}async _unmount(){this._container&&(this._cleanupSelections(),this._container.innerHTML="",this._component=void 0,this._container=void 0,this._errorMessage=void 0,this._marks=[],we(`Unmounted ${this._id}`,"","ok"))}async destroy(){this._isDestroyed||(await this._unmount(),this._isDestroyed=!0,we(`Destroyed ${this._id}`,"","ok"))}_showError(e){e&&(e.innerHTML=`
      <div style="padding: 15px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; color: #856404; font-size: 13px;">
        <strong>Chart Error: ${this._id}</strong>
        <p style="margin: 5px 0 0 0;">This chart cannot be displayed. Check configuration, it may reference columns that don't exist in your data.</p>
      </div>
    `)}};typeof h_=="function"&&h_({connect:()=>{},disconnect:()=>{}});let RQ=class{constructor(e){b(this,"_internalApi");b(this,"_components",new Map);this._internalApi=e}get components(){return this._components}async addComponent(e,t,n){const s=new LQ({...n,internalApi:this._internalApi});if(this._components.has(s.id)){const r=this._components.get(s.id);we(`Component with id ${s.id} already exists, replacing it`,"","warn"),await r.destroy()}return await s.mount(e,t),this._components.set(s.id,s),s.errorMessage?we(`Error adding vgplot component: ${s.id} - ${s.errorMessage}`,"","warn"):we(`Added vgplot component: ${s.id}`,"","ok"),s}async removeComponent(e){const t=this._components.get(e);return!!t&&(await t.destroy(),this._components.delete(e),!0)}async destroyAll(){const e=Array.from(this._components.values()).map(t=>t.destroy());await Promise.all(e),this._components.clear()}};var PQ=".style_module_cosmograph__8ee622df{--cosmograph-text-color:#fff;-webkit-font-smoothing:antialiased!important;display:flex;height:100%;overflow:hidden;position:relative;text-rendering:optimizeLegibility!important;width:100%}.style_module_popupContainer__8ee622df{height:100%;pointer-events:none;position:absolute;width:100%;z-index:1}.style_module_attribution__8ee622df{bottom:0;color:var(--cosmograph-text-color);cursor:pointer;line-height:0;margin:0 .6rem .6rem 0;opacity:.7;position:absolute;right:0;user-select:none;-webkit-user-select:none;z-index:1}.style_module_message__8ee622df{color:var(--cosmograph-text-color);font-size:14px;font-weight:300;left:50%;max-width:300px;opacity:.6;position:absolute;text-align:center;top:50%;transform:translate(-50%,-50%);z-index:1000}.style_module_messageError__8ee622df{max-width:min(800px,90vw);text-align:left}.style_module_messagePre__8ee622df{white-space:pre-wrap}.style_module_message__8ee622df>br{display:none}@keyframes style_module_spin__8ee622df{to{transform:rotate(1turn)}}@keyframes style_module_fadeIn__8ee622df{0%{opacity:0}to{opacity:1}}.style_module_spinner__8ee622df{animation:style_module_fadeIn__8ee622df .3s ease forwards,style_module_spin__8ee622df 1s linear infinite;border:4px solid hsla(0,0%,100%,.3);border-radius:50%;border-top:4px solid var(--cosmograph-text-color);display:block;height:30px;margin:0 auto;opacity:0;width:30px}",Ps={cosmograph:"style_module_cosmograph__8ee622df",popupContainer:"style_module_popupContainer__8ee622df",attribution:"style_module_attribution__8ee622df",message:"style_module_message__8ee622df",messageError:"style_module_messageError__8ee622df",messagePre:"style_module_messagePre__8ee622df",spinner:"style_module_spinner__8ee622df"};Dr(PQ,{});class NQ{constructor(e,t,n){b(this,"_internalApi");b(this,"_eventTarget",new EventTarget);b(this,"_dbReadinessPromise",null);b(this,"_labels");b(this,"_cosmos");b(this,"_cosmosInitialized",!1);b(this,"_dbCoordinator");b(this,"_dataValidator");b(this,"_configManager");b(this,"_dataManager");b(this,"_eventManager");b(this,"_crossfilter");b(this,"_linkAggregationManager");b(this,"_rectangularSelection");b(this,"_polygonalSelection");b(this,"_pointSelectionClient");b(this,"_mosaicComponentManager");b(this,"_containerElement");b(this,"_popupElement");b(this,"_attributionDivElement");b(this,"_cosmosElement");b(this,"_messageDivElement");b(this,"_focusedPointIndex");b(this,"_enableSimulation",!0);b(this,"_pointsHaveLayout",!1);b(this,"_isDestroyed",!1);b(this,"_summary",{});b(this,"_stats",{pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0});b(this,"_initializeLabels",()=>{this._labels&&this._labels.destroy();const e=this._cosmosElement.querySelector("canvas");e&&(this._labels=new gQ(this._internalApi,e))});b(this,"_initializeClients",async()=>{this._pointSelectionClient=new CQ(this._internalApi),this._mosaicComponentManager=new RQ(this._internalApi)});b(this,"_dropLocalTables",async e=>{var t,n;this._dbCoordinator&&(e||await((t=this._dbCoordinator.internalDB)==null?void 0:t.dropTable(qe.Points)),await((n=this._dbCoordinator.internalDB)==null?void 0:n.dropTable(qe.Links)))});window.cosmographDisableLogging=t.disableLogging??!1,this._containerElement=e,this._internalApi=this._initializeInternalApi(this),EQ(this,this._internalApi),we("Initialization..."),this._initializeDB(n),this._dataValidator=new rQ(this._internalApi),this._eventManager=new oQ(this._internalApi),this._linkAggregationManager=new lQ(this._internalApi),this._configManager=new iQ(this._internalApi),this._dataManager=new sQ(this._internalApi),this._crossfilter=new nQ(this._internalApi),this._rectangularSelection=new vQ(this._internalApi),this._polygonalSelection=new SQ(this._internalApi),t.statusIndicatorMode!==void 0&&(this._configManager.config.statusIndicatorMode=t.statusIndicatorMode),this._initializeHTMLElements(),this.setConfig(t)}_initializeInternalApi(e){return{get public(){return e},get labels(){return e._labels},get cosmos(){return e._cosmos},get summary(){return e._summary},get eventManager(){return e._eventManager},get configManager(){return e._configManager},get dataManager(){return e._dataManager},get dataValidator(){return e._dataValidator},get linkAggregationManager(){return e._linkAggregationManager},get rectangularSelection(){return e._rectangularSelection},get polygonalSelection(){return e._polygonalSelection},get crossfilter(){return e._crossfilter},get selectionClient(){return e._pointSelectionClient},get dbCoordinator(){return e._dbCoordinator},get containerElement(){return e._containerElement},get cosmosElement(){return e._cosmosElement},get popupElement(){return e._popupElement},get config(){return e._configManager.config},get cosmosInitialized(){return e._cosmosInitialized},get pointsHaveLayout(){return e._pointsHaveLayout},dropLocalTables:async t=>await e._dropLocalTables(t),updateMessage:t=>e._updateMessage(t),initializeLabels:()=>e._initializeLabels(),initializeCosmos:()=>e._initializeCosmos(),updateStats:()=>e._updateStats(),updateSummary:async()=>e._updateSummary(),dbReady:async()=>e._dbReady(),addEventListener:(t,n)=>{e._eventTarget.addEventListener(t,n,{passive:!0})},removeEventListener:(t,n)=>{e._eventTarget.removeEventListener(t,n,{passive:!0})},dispatchEvent:t=>e._eventTarget.dispatchEvent(t)}}_initializeDB(e){this._dbReadinessPromise=bH.create(e).then(async t=>{if(this._ensureAlive())if(this._dbCoordinator=t,t)this._updateMessage("👩🏻‍🚀 Cosmograph is ready, load your data!",!0),await this._initializeClients();else{const n=e?"🚨 Couldn't create coordinator for specified DuckDB connection. Please check your external DuckDB instance configuration and try to initialize Cosmograph again.":"🚨 Failed to fetch DuckDB-Wasm bundles. Please try to initialize Cosmograph again.";this._updateMessage(n)}else this.destroy()}).catch(t=>{throw this._isDestroyed||we("Database initialization error",t,"error"),t})}_initializeHTMLElements(){var e,t;this._containerElement.classList.add(Ps.cosmograph),(e=this._containerElement)==null||e.style.setProperty("--cosmograph-text-color","#ffffff"),this._popupElement=document.createElement("div"),this._popupElement.classList.add(Ps.popupContainer),this._cosmosElement=document.createElement("div"),this._cosmosElement.style.width="100%",this._cosmosElement.style.height="100%",(t=this._cosmosElement)==null||t.style.setProperty("backgroundColor",Lv),this._containerElement.appendChild(this._cosmosElement),this._containerElement.appendChild(this._popupElement),this._addAttribution(),this._addMessageElement()}_addAttribution(){var t;this._attributionDivElement=document.createElement("div"),this._attributionDivElement.classList.add(Ps.attribution),this._attributionDivElement.onclick=()=>{var n;return(n=window.open("https://cosmograph.app/","_blank"))==null?void 0:n.focus()};const e=new DOMParser().parseFromString(_Q,"image/svg+xml").firstChild;(t=this._attributionDivElement)==null||t.appendChild(e),this._containerElement.appendChild(this._attributionDivElement)}_addMessageElement(){this._messageDivElement=document.createElement("div"),this._messageDivElement.classList.add(Ps.message),this._containerElement.appendChild(this._messageDivElement),this._updateMessage("🚀 Initializing Cosmograph...")}async _initializeCosmos(){const{_config:e}=this;this._cosmos&&(this._cosmos.destroy(),this._cosmosInitialized=!1),this._pointsHaveLayout=await NZ(this._dbCoordinator,this.pointsTableName,e),this._enableSimulation=e.enableSimulation??(!!e.links||!this._pointsHaveLayout),this._configManager.cosmosConfig.enableSimulation=this._enableSimulation,this._cosmos=new u6(this._cosmosElement,this._configManager.cosmosConfig),this._cosmosInitialized=!0}_ensureAlive(){return!this._isDestroyed&&!!this._containerElement.isConnected}_updateMessage(e,t){if(!this._messageDivElement)return;const n=this._configManager.config.statusIndicatorMode??"spinner";if(n===!1||n==="spinner"&&t||e===null)this._messageDivElement.style.display="none";else if(this._messageDivElement.style.display="block",n==="spinner"){const s=e.startsWith("🚨");if(this._messageDivElement.classList.toggle(Ps.messageError,s),s){if(this._messageDivElement.innerText!==e||this._messageDivElement.querySelector(`.${Ps.spinner}`)){this._messageDivElement.innerHTML="";const r=document.createElement("div");r.classList.add(Ps.messagePre),r.innerText=e,this._messageDivElement.appendChild(r)}}else if(!this._messageDivElement.querySelector(`.${Ps.spinner}`)){this._messageDivElement.innerHTML="";const r=document.createElement("div");r.classList.add(Ps.spinner),this._messageDivElement.appendChild(r)}}else this._messageDivElement.classList.remove(Ps.messageError),(this._messageDivElement.textContent!==e||this._messageDivElement.querySelector(`.${Ps.spinner}`))&&(this._messageDivElement.innerHTML="",this._messageDivElement.innerText=e)}async _updateSummary(){this._dbCoordinator&&(this._summary={pointsSummary:await Yw(this._dbCoordinator,this.pointsTableName),linksSummary:this._config.links?await Yw(this._dbCoordinator,this.linksTableName):void 0})}_updateStats(){var n,s;const{pointsSummary:e,linksSummary:t}=this._summary;this._stats={pointsCount:((n=this._cosmos)==null?void 0:n.graph.pointsNumber)??0,linksCount:((s=this._cosmos)==null?void 0:s.graph.linksNumber)??0,pointsSummary:e,linksSummary:t}}async _dbReady(){return this._dbReadinessPromise?await this._dbReadinessPromise:new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("Cosmograph: Database initialization timeout"))},3e4),s=()=>{this._dbReadinessPromise?(clearTimeout(n),this._dbReadinessPromise.then(e).catch(t)):setTimeout(s,10)};s()})}async dataUploaded(){return await this._dataManager.dataReady()}get _config(){return this._configManager.config}get stats(){return this._stats}get crossfilter(){return this._crossfilter.filtered}get maxPointSize(){var e;return((e=this._cosmos)==null?void 0:e.maxPointSize)??0}get progress(){var e;return(e=this._cosmos)==null?void 0:e.progress}get isSimulationRunning(){var e;return(e=this._cosmos)==null?void 0:e.isSimulationRunning}get isSimulationAvailable(){return this._enableSimulation}get pointDegrees(){var e;return(e=this._cosmos)==null?void 0:e.graph.degree}get pointDirections(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.graph.inDegree)==null?void 0:t.map((n,s)=>{var l,c;const r=(c=(l=this._cosmos)==null?void 0:l.graph.outDegree)==null?void 0:c[s],o=n!==null&&n!==0,a=r!==null&&r!==0;return o&&a?1:a?0:o?2:3})}get rescaleXFn(){var e;return(e=this._cosmos)==null?void 0:e.getScaleX()}get rescaleYFn(){var e;return(e=this._cosmos)==null?void 0:e.getScaleY()}get focusedPointIndex(){return this._config.focusedPointIndex??this._focusedPointIndex}get clusterMapping(){return this._configManager.clusterMapping}get activePointColorStrategy(){return this._configManager.activePointColorStrategy}get activePointSizeStrategy(){return this._configManager.activePointSizeStrategy}get activeLinkColorStrategy(){return this._configManager.activeLinkColorStrategy}get activeLinkWidthStrategy(){return this._configManager.activeLinkWidthStrategy}get linksTableName(){var e;return(e=this._dbCoordinator)!=null&&e.internalDB||typeof this._config.links!="string"?qe.Links:this._config.links}get pointsTableName(){var e;return(e=this._dbCoordinator)!=null&&e.internalDB||typeof this._config.points!="string"?qe.Points:this._config.points}async getConfig(){return await this._configManager.configUpdated(),this._configManager.config}async getActivePointColorFn(){return await this._configManager.configUpdated(),this._configManager.activePointColorFn}async getActivePointSizeFn(){return await this._configManager.configUpdated(),this._configManager.activePointSizeFn}async getActiveLinkColorFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkColorFn}async getActiveLinkWidthFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkWidthFn}setConfig(e){return this._configManager.setConfig(e),this._configManager.configUpdated()}captureScreenshot(e="cosmograph-screenshot.png"){var s;const t=(s=this._cosmosElement)==null?void 0:s.querySelector("canvas");if(!t)return;const n=document.createElement("a");n.download=e,n.href=t.toDataURL("image/png"),n.click()}getPointPositions(){var e;return(e=this._cosmos)==null?void 0:e.getPointPositions()}getClusterPositions(){var e;return(e=this._cosmos)==null?void 0:e.getClusterPositions()}getPointColors(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getPointColors)==null?void 0:t.call(e)}getPointSizes(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getPointSizes)==null?void 0:t.call(e)}getLinkColors(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getLinkColors)==null?void 0:t.call(e)}getLinkWidths(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getLinkWidths)==null?void 0:t.call(e)}setPointShapes(e){var t;(t=this._cosmos)==null||t.setPointShapes(new Float32Array(e))}setPointImageIndices(e){var t;(t=this._cosmos)==null||t.setPointImageIndices(new Float32Array(e))}setPointImageSizes(e){var t;(t=this._cosmos)==null||t.setPointImageSizes(new Float32Array(e))}setImageData(e){var t;(t=this._cosmos)==null||t.setImageData([e])}getPointPositionByIndex(e){var r;const t=(r=this._cosmos)==null?void 0:r.getPointPositions();if(!t||!t.length)return;const n=t[2*e],s=t[2*e+1];return n==null||s==null?void 0:[n,s]}activateRectSelection(){this._rectangularSelection.enable(),this._polygonalSelection.disable()}deactivateRectSelection(){this._rectangularSelection.disable()}activatePolygonalSelection(){this._polygonalSelection.enable(),this._rectangularSelection.disable()}deactivatePolygonalSelection(){this._polygonalSelection.disable()}getSelectedPointIndices(){var e;return((e=this._cosmos)==null?void 0:e.getSelectedIndices())??void 0}getSelectedLinkIndices(){var r,o;const e=(r=this._cosmos)==null?void 0:r.getSelectedIndices();if(!e||e.length===0)return;const t=(o=this._cosmos)==null?void 0:o.graph.sourceIndexToTargetIndices;if(!t)return;const n=new Set(e),s=new Set;for(let a=0;a<e.length;a++){const l=t[e[a]];if(l)for(let c=0;c<l.length;c++){const[u,d]=l[c];n.has(u)&&s.add(d)}}return s.size?Array.from(s):void 0}selectPointsInRect(e,t=!1){if(!this._cosmos||!e)return;const n=this._cosmos.getPointsInRect(e);this.selectPoints(Array.from(n),t)}selectPointsInPolygon(e,t=!1){if(!this._cosmos||!e.length)return;const n=this._cosmos.getPointsInPolygon(e);this.selectPoints(Array.from(n),t)}unselectPointsInRect(e){if(!this._cosmos||!e)return;const t=this._cosmos.getPointsInRect(e);this.unselectPointsByIndices(Array.from(t))}unselectPointsInPolygon(e){if(!this._cosmos||!e.length)return;const t=this._cosmos.getPointsInPolygon(e);this.unselectPointsByIndices(Array.from(t))}selectPoints(e,t=!1){var n,s;this._cosmos&&(e!=null&&e.length?(t&&(e=[...this._cosmos.getSelectedIndices()||[],...e]),(n=this._pointSelectionClient)==null||n.selectPoints(e)):(s=this._pointSelectionClient)==null||s.selectPoints(void 0))}selectPoint(e,t=!1,n=this._config.selectPointOnClick===!0){var s,r;if(this._cosmos&&(e!==void 0||!t))if(e!==void 0){let o=[e];if(t&&(o=[...this._cosmos.getSelectedIndices()||[],e]),n){const a=this._cosmos.getAdjacentIndices(e);o=[...o,...a]}(s=this._pointSelectionClient)==null||s.selectPoints(o)}else this._config.resetSelectionOnEmptyCanvasClick&&((r=this._pointSelectionClient)==null||r.selectPoints(void 0))}unselectPoint(e,t=this._config.selectPointOnClick===!0){var r;if(!this._cosmos||e===void 0)return;const n=this._cosmos.getSelectedIndices()||[];if(n.length===0||!n.includes(e))return;let s=n.filter(o=>o!==e);if(t){const o=this._cosmos.getAdjacentIndices(e);s=s.filter(a=>!o.includes(a))}this._focusedPointIndex&&!s.includes(this._focusedPointIndex)&&this.setFocusedPoint(void 0),(r=this._pointSelectionClient)==null||r.selectPoints(s.length?s:void 0)}unselectPointsByIndices(e){var s;if(!this._cosmos)return;const t=this._cosmos.getSelectedIndices()||[];if(t.length===0)return;const n=t.filter(r=>!e.includes(r));this._focusedPointIndex&&!n.includes(this._focusedPointIndex)&&this.setFocusedPoint(void 0),(s=this._pointSelectionClient)==null||s.selectPoints(n.length?n:void 0)}unselectAllPoints(){var e;this._cosmos&&(this.focusedPointIndex&&this.setFocusedPoint(void 0),(e=this._pointSelectionClient)==null||e.selectPoints(void 0),this._internalApi.dispatchEvent(new CustomEvent("resetSelections")))}setFocusedPoint(e){var t,n;this._focusedPointIndex=this._config.focusedPointIndex??e,this._cosmos&&!this._config.focusedPointIndex&&((t=this._cosmos)==null||t.setConfig({focusedPointIndex:this._focusedPointIndex}),(n=this._labels)==null||n.render())}setPinnedPoints(e){var t;(t=this._cosmos)==null||t.setPinnedPoints(e)}start(e){var t;this._enableSimulation!==!1&&this._cosmos&&((t=this._cosmos)==null||t.start(e),this._internalApi.dispatchEvent(new CustomEvent("onSimulationStart")))}pause(){var e;this._enableSimulation!==!1&&this._cosmos&&((e=this._cosmos)==null||e.pause(),this._internalApi.dispatchEvent(new CustomEvent("onSimulationPause")))}unpause(){var e;this._enableSimulation!==!1&&this._cosmos&&((e=this._cosmos)==null||e.unpause(),this._internalApi.dispatchEvent(new CustomEvent("onSimulationStart")))}restart(){this.unpause()}stop(){var e;this._enableSimulation!==!1&&this._cosmos&&((e=this._cosmos)==null||e.stop(),this._internalApi.dispatchEvent(new CustomEvent("onSimulationPause")))}step(){var e;(e=this._cosmos)==null||e.step()}setZoomLevel(e,t=0){var n;(n=this._cosmos)==null||n.setZoomLevel(e,t)}getZoomLevel(){var e;return(e=this._cosmos)==null?void 0:e.getZoomLevel()}zoomToPoint(e,t=this._config.fitViewDuration,n,s){var r;(r=this._cosmos)==null||r.zoomToPointByIndex(e,t,n,s)}fitView(e=this._config.fitViewDuration,t=this._config.fitViewPadding){var n;(n=this._cosmos)==null||n.fitView(e,t)}fitViewByIndices(e,t=this._config.fitViewDuration,n=this._config.fitViewPadding){var s;(s=this._cosmos)==null||s.fitViewByPointIndices(e,t,n)}fitViewByCoordinates(e,t=this._config.fitViewDuration,n=this._config.fitViewPadding){var s;(s=this._cosmos)==null||s.fitViewByPointPositions(e,t,n)}getConnectedPointIndices(e){var t;return(t=this._cosmos)==null?void 0:t.getAdjacentIndices(e)}getPointDegrees(e){var t,n;if(this._cosmos)return{inDegree:((t=this._cosmos.graph.inDegree)==null?void 0:t[e])??0,outDegree:((n=this._cosmos.graph.outDegree)==null?void 0:n[e])??0}}spaceToScreenPosition(e){var t;return(t=this._cosmos)==null?void 0:t.spaceToScreenPosition(e)}screenToSpacePosition(e){var t;return(t=this._cosmos)==null?void 0:t.spaceToScreenPosition(e)}spaceToScreenRadius(e){var t;return(t=this._cosmos)==null?void 0:t.spaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;return(t=this._cosmos)==null?void 0:t.getPointRadiusByIndex(e)}getPointScreenRadiusByIndex(e){var l,c;const t=((l=this._cosmos)==null?void 0:l.config.pointSizeScale)??1,n=(c=this._cosmos)==null?void 0:c.getPointRadiusByIndex(e);if(!n)return 0;const s=n*t,{scalePointsOnZoom:r}=this._config,o=this.getZoomLevel(),a=this.maxPointSize;return r?Math.min(s*o,a):s}trackPointPositionsByIndices(e){var t;(t=this._cosmos)==null||t.trackPointPositionsByIndices(e)}getTrackedPointPositionsArray(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getTrackedPointPositionsArray)==null?void 0:t.call(e)}getTrackedPointPositionsMap(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getTrackedPointPositionsMap)==null?void 0:t.call(e)}getSampledPoints(){var e,t;return(t=(e=this._cosmos)==null?void 0:e.getSampledPoints)==null?void 0:t.call(e)}getSampledPointPositionsMap(){var e;if(this._cosmosInitialized)return(e=this._cosmos)==null?void 0:e.getSampledPointPositionsMap()}getActiveSelectionSourceId(){const e=this._crossfilter.pointsSelection.active,t=e==null?void 0:e.source;return t==null?void 0:t.id}get pointsSelection(){return this._crossfilter.pointsSelection}get linksSelection(){return this._crossfilter.linksSelection}async getPointIndicesByIds(e){if(this._dbCoordinator&&this.stats.pointsCount&&e.length)return await ip(this._dbCoordinator,this.pointsTableName,this._config,e)}async getPointIdsByIndices(e){if(this._dbCoordinator&&this.stats.pointsCount&&e.length)return await aI(this._dbCoordinator,this.pointsTableName,this._config,e)}async getPointsByIndices(e){if(this._dbCoordinator&&this.stats.pointsCount&&e.length)return await LZ(this._dbCoordinator,this.pointsTableName,this._config.pointIndexBy,e)}async getPointIndicesByExactValues(e,t){if(this._dbCoordinator&&this.stats.pointsCount)return t.length?await RZ(this._dbCoordinator,this.pointsTableName,this._config,e,t):[]}async getPointIndicesByNumericValue(e,t,n){if(this._dbCoordinator&&this.stats.pointsCount)return t?await PZ(this._dbCoordinator,this.pointsTableName,this._config,e,t,n):[]}async getPointIndicesByLinksExactValues(e,t){if(this._dbCoordinator&&this.stats.linksCount)return t.length?await UZ(this._dbCoordinator,this.linksTableName,this._config,e,t):[]}async getPointIndicesByLinksNumericValue(e,t,n){if(this._dbCoordinator&&this.stats.linksCount)return t?await $Z(this._dbCoordinator,this.linksTableName,this._config,e,t,n):[]}async getLinksByPointIds(e){if(this._dbCoordinator&&this.stats.linksCount&&e.length)return await jZ(this._dbCoordinator,this.pointsTableName,this._config,e)}async getLinksByPointIndices(e){if(this._dbCoordinator&&this.stats.linksCount&&e.length)return await HZ(this._dbCoordinator,this.pointsTableName,this._config,e)}async getLinksData(){if(this._dbCoordinator&&this.stats.linksCount)return await cI(this._dbCoordinator,this.linksTableName)}async getPointsData(){if(this._dbCoordinator&&this.stats.pointsCount)return await oI(this._dbCoordinator,this.pointsTableName)}convertCosmographDataToObject(e){return jk(e)}flattenPositions(e){var t;return(t=this._cosmos)==null?void 0:t.flatten(e)}pair(e){var t;return(t=this._cosmos)==null?void 0:t.pair(e)}async addPoints(e){await this._dataManager.addPoints(e)}async addLinks(e){await this._dataManager.addLinks(e)}async removePointsByIndices(e,t=!0){await this._dataManager.removePointsByIndices(e,t)}async removePointsByIds(e){await this._dataManager.removePointsByIds(e)}async removeLinksByPointIdPairs(e){await this._dataManager.removeLinksByPointIdPairs(e)}async removeLinksByPointIndicesPairs(e){await this._dataManager.removeLinksByPointIndicesPairs(e)}async addMosaicComponent(e,t,n){if(await this._dataManager.dataReady(),this._ensureAlive()){if(this._mosaicComponentManager)return await this._mosaicComponentManager.addComponent(e,t,n);we("Mosaic component manager not initialized","","error")}}async removeMosaicComponent(e){return this._mosaicComponentManager?await this._mosaicComponentManager.removeComponent(e):(we("Mosaic component manager not initialized","","error"),!1)}getMosaicComponents(){var e;return(e=this._mosaicComponentManager)==null?void 0:e.components}async reset(e=!0){var t,n,s,r,o;e&&(this._configManager.resetCosmographConfig(),this._messageDivElement.innerText="👩🏻‍🚀 Cosmograph is ready, load your data!",this._messageDivElement.style.display="block"),(t=this._labels)==null||t.clear(),this._configManager.clearCosmosBuffers(),(n=this._cosmos)==null||n.render(),await this._dropLocalTables(),(s=this._dbCoordinator)==null||s.clearCache(),this._linkAggregationManager.clear(),this._stats={pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0},await((r=this._mosaicComponentManager)==null?void 0:r.destroyAll()),(o=this._pointSelectionClient)==null||o.destroy(),this._pointSelectionClient=void 0,this._internalApi.dispatchEvent(new CustomEvent("reset")),this._internalApi.dispatchEvent(new CustomEvent("dataUploaded"))}async destroy(){var e,t,n,s,r;we("Destroying Cosmograph instance","","warn"),this._isDestroyed?we("Instance already destroyed","","warn"):(this._isDestroyed=!0,this._internalApi.dispatchEvent(new CustomEvent("reset")),(e=this._labels)==null||e.destroy(),(t=this._cosmos)==null||t.destroy(),this._cosmos=void 0,await this._dropLocalTables(),await((n=this._dbCoordinator)==null?void 0:n.destroy()),this._dbCoordinator=void 0,this._linkAggregationManager.clear(),this._containerElement.innerHTML="",this._rectangularSelection.destroy(),this._polygonalSelection.destroy(),await((s=this._mosaicComponentManager)==null?void 0:s.destroyAll()),this._mosaicComponentManager=void 0,(r=this._pointSelectionClient)==null||r.destroy(),this._pointSelectionClient=void 0,delete window.cosmographDisableLogging)}}const vI=av(),xI=async(i,e)=>{const t=await i.query(`DESCRIBE ${e}`);return new Map((t==null?void 0:t.toArray().map(n=>[n.column_name,n.column_type]))??[])},np=(i,e)=>({existing:[...new Set(i.filter(t=>e.has(t.name)).map(t=>t.name))],missing:i.filter(t=>!e.has(t.name))}),DQ=async(i,e)=>{var p,m,y,g;const t=await xI(i,qe.RawPoints),{missing:n}=np((_=>{const{pointIdBy:S,linkSourceBy:E,linkTargetsBy:x}=_;return S?[{prop:"pointIdBy",name:S}]:E&&x?[{prop:"linkSourceBy",name:E},...x.map(T=>({prop:"linkTargetBy",name:T}))]:[{prop:"pointIdBy",name:S??"undefined"}]})(e),t);if(n.length>0)return{missingRequiredColumns:n,missingOptionalColumns:[],processedFully:!0,pointsAdded:!1};const{existing:s,missing:r}=np((_=>{const{pointSizeBy:S,pointColorBy:E,pointClusterBy:x,pointClusterStrengthBy:T,pointLabelBy:I,pointLabelWeightBy:O,pointXBy:H,pointYBy:Q,pointIncludeColumns:re=[]}=_;return[...S?[{prop:"pointSizeBy",name:S}]:[],...E?[{prop:"pointColorBy",name:E}]:[],...x?[{prop:"pointClusterBy",name:x}]:[],...T?[{prop:"pointClusterStrengthBy",name:T}]:[],...I?[{prop:"pointLabelBy",name:I}]:[],...O?[{prop:"pointLabelWeightBy",name:O}]:[],...[...new Set(re)].map(D=>({prop:"pointIncludeColumns",name:D})),...H&&Q?[{prop:"pointXBy",name:H},{prop:"pointYBy",name:Q}]:[]]})(e),t),o=s.filter(_=>_!==_e.Id);if(await i.exec(`
    BEGIN;
    DROP SEQUENCE IF EXISTS ${_e.Sequence} CASCADE;
    CREATE SEQUENCE ${_e.Sequence} MINVALUE 0;
    CREATE TABLE ${qe.PreparedPoints} (
      ${_e.Id} VARCHAR,
      ${_e.Idx} INT DEFAULT nextval('${_e.Sequence}')
    );
    COMMIT;
  `),o.length>0){const _=o.map(S=>`ALTER TABLE ${qe.PreparedPoints} ADD COLUMN IF NOT EXISTS "${S}" ${t.get(S)};`).join(`
`);await i.exec(_)}const{pointIdBy:a,linkSourceBy:l,linkTargetsBy:c}=e,u=l&&c?[l,...c]:[a],d=(m=(p=await i.query(`SELECT COUNT(*) as cnt FROM ${qe.RawPoints}`))==null?void 0:p.getChild("cnt"))==null?void 0:m.get(0);let h=!0;if(u.length===1&&d>25e4)try{await(async(S,E,x,T)=>{let O=0;for(;O<T;)await S.exec(`
      CREATE TEMP TABLE chunk_temp AS 
      SELECT "${E}" AS ${_e.Id}, ${x.map(H=>`"${H}"`).join(", ")}
      FROM ${qe.RawPoints}
      WHERE "${E}" IS NOT NULL
      LIMIT 250000
    `),await S.exec(`INSERT INTO ${qe.PreparedPoints} (${[`"${_e.Id}"`,...x.map(H=>`"${H}"`)].join(", ")}) SELECT * FROM chunk_temp`),await S.exec(`DELETE FROM ${qe.RawPoints} WHERE "${E}" IN (SELECT ${_e.Id} FROM chunk_temp)`),await S.exec("DROP TABLE chunk_temp"),O+=25e4})(i,u[0],o,d),((g=(y=await i.query(`SELECT COUNT(*) as cnt FROM ${qe.RawPoints}`))==null?void 0:y.getChild("cnt"))==null?void 0:g.get(0))>0&&(h=!1)}catch(_){console.warn("processLargeDatasetInChunks failed:",_),h=!1}else{const _=`
      INSERT INTO ${qe.PreparedPoints} (${[_e.Id,...o].map(S=>`"${S}"`).join(", ")})
      SELECT DISTINCT ON (${_e.Id}) combined_points.*
      FROM (
        ${u.map(S=>`
          SELECT "${S}" AS ${_e.Id}${o.length>0?`, ${o.map(E=>`"${E}"`).join(", ")}`:""}
          FROM ${qe.RawPoints}
          WHERE "${S}" IS NOT NULL
        `).join(" UNION ALL ")}
      ) AS combined_points
    `;await i.exec(_)}return vI&&await i.logTable(qe.PreparedPoints),{missingRequiredColumns:[],missingOptionalColumns:r,processedFully:h,pointsAdded:!1}},MQ=async(i,e)=>{var E;const{linkSourceBy:t=_e.Source,linkTargetsBy:n=[_e.Target],linkIncludeColumns:s=[],linkColorBy:r,linkWidthBy:o,linkArrowBy:a,linkStrengthBy:l}=e;if(!(n!=null&&n.length))return{missingRequiredColumns:[],missingOptionalColumns:[],processedFully:!0,pointsAdded:!1};const c=await xI(i,qe.RawLinks),u=[{prop:"linkSourceBy",name:t},...n.map(x=>({prop:"linkTargetsBy",name:x}))],{missing:d}=np(u,c);if(d.length>0)return{missingRequiredColumns:d,missingOptionalColumns:[],processedFully:!0,pointsAdded:!1};const h=[...r?[{prop:"linkColorBy",name:r}]:[],...o?[{prop:"linkWidthBy",name:o}]:[],...a?[{prop:"linkArrowBy",name:a}]:[],...l?[{prop:"linkStrengthBy",name:l}]:[],...s.map(x=>({prop:"linkIncludeColumns",name:x}))],{existing:p,missing:m}=np(h,c),y=[_e.SourceIdx,_e.TargetIdx,_e.Source,_e.Target],g=p.filter(x=>!y.includes(x));if(await i.exec(`
    CREATE TABLE IF NOT EXISTS ${qe.PreparedLinks} (
      ${_e.SourceIdx} INTEGER,
      ${_e.TargetIdx} INTEGER,
      ${_e.Source} VARCHAR,
      ${_e.Target} VARCHAR
    );
  `.trim()),g.length>0){const x=g.map(T=>`ALTER TABLE ${qe.PreparedLinks} ADD COLUMN IF NOT EXISTS "${T}" ${c.get(T)||"VARCHAR"};`).join(`
`);await i.exec(x)}await i.exec(`
    CREATE TEMP TABLE temp_points AS
    SELECT ${_e.Id}, ${_e.Idx}
    FROM ${qe.PreparedPoints}
  `.trim());let _=!1;if(e.createMissingPoints){const x=[t,...n].map(O=>`
    SELECT DISTINCT "${O}"::text as ${_e.Id}
    FROM ${qe.RawLinks}
    WHERE "${O}" IS NOT NULL
  `).join(" UNION "),T=await i.query(`
    SELECT COUNT(*) as cnt
    FROM (${x}) all_ids
    WHERE ${_e.Id} NOT IN (SELECT ${_e.Id} FROM temp_points)
  `.trim()),I=((E=T==null?void 0:T.getChild("cnt"))==null?void 0:E.get(0))||0;_=I>0,I>0&&(await i.exec(`
      CREATE TEMP TABLE missing_ids AS
      SELECT DISTINCT ${_e.Id}
      FROM (${x}) all_ids
      WHERE ${_e.Id} NOT IN (SELECT ${_e.Id} FROM temp_points)
    `.trim()),await i.exec(`
      CREATE TEMP TABLE missing_ids_with_idx AS
      SELECT ${_e.Id},
             ROW_NUMBER() OVER (ORDER BY ${_e.Id}) + (SELECT COALESCE(MAX(${_e.Idx}), 0) FROM ${qe.PreparedPoints}) as ${_e.Idx}
      FROM missing_ids
    `.trim()),await i.exec(`
      INSERT INTO ${qe.PreparedPoints} (${_e.Id}, ${_e.Idx})
      SELECT ${_e.Id}, ${_e.Idx} FROM missing_ids_with_idx
    `.trim()),await i.exec("DROP TABLE temp_points"),await i.exec(`
      CREATE TEMP TABLE temp_points AS
      SELECT ${_e.Id}, ${_e.Idx}
      FROM ${qe.PreparedPoints}
    `.trim()),await i.exec("DROP TABLE missing_ids"),await i.exec("DROP TABLE missing_ids_with_idx"))}const S=[_e.SourceIdx,_e.TargetIdx,_e.Source,_e.Target,...g];for(const x of n){const T=`
      INSERT INTO ${qe.PreparedLinks} (${S.map(I=>`"${I}"`).join(", ")})
      SELECT DISTINCT
        sp.${_e.Idx} AS ${_e.SourceIdx},
        tp.${_e.Idx} AS ${_e.TargetIdx},
        d."${t}" AS ${_e.Source},
        d."${x}" AS ${_e.Target}
        ${g.length>0?`, ${g.map(I=>`d."${I}"`).join(", ")}`:""}
      FROM ${qe.RawLinks} d
      INNER JOIN temp_points sp ON sp.${_e.Id} = d."${t}"::text
      INNER JOIN temp_points tp ON tp.${_e.Id} = d."${x}"::text
    `;await i.exec(T.trim())}return await i.exec("DROP TABLE temp_points"),vI&&await(i==null?void 0:i.logTable(qe.PreparedLinks)),{missingRequiredColumns:[],missingOptionalColumns:m,processedFully:!0,pointsAdded:_}};let Ki,Jd=null;const wI=async(i,e,t=!1)=>{switch(i){case Xi.Parquet:return await Ki.exportTableToPq(e)??new Uint8Array;case Xi.Arrow:return t?await Ki.exportTableToArrow(e)??new zt:await Ki.exportTableToArrowBuffer(e)??new Uint8Array;case Xi.CSV:return await Ki.exportTableToCSV(e)??new Uint8Array;default:throw new Error(`Unsupported format: ${i}`)}},iS=async(i,e,t,n,s,r,o,a=!1)=>{const{ok:l,processedFully:c,pointsAdded:u}=await(async(p,m,y,g)=>{try{let _;if(_=Array.isArray(p)?await Ki.uploadObject(p,m):await Ki.uploadData(p,m,!1,g.csvParseTimeFormat,g.csvColumnTypesMap),_==null?void 0:_.error)return we(`Failed to upload data to ${m}: ${_.error}`,"data-kit","error"),{ok:!1,processedFully:!0,pointsAdded:!1};"pointIdBy"in g&&(g.pointIdBy!==void 0||g.linkSourceBy||g.linkTargetsBy||(we("No `pointIdBy` column or `linkSourceBy` and `linkTargetsBy` columns specified. Automatically generating an indexed `pointIdBy` column","data-kit","warn"),await Ki.query(`ALTER TABLE ${m} ADD COLUMN ${_e.Id} INTEGER; UPDATE ${m} SET ${_e.Id} = rowid;`),await Ki.logTable(m),g.pointIdBy=_e.Id));const{missingRequiredColumns:S,missingOptionalColumns:E,processedFully:x,pointsAdded:T}=await y(Ki,g);return S.length>0?(we(`Data preparing stopped: Required columns are missing from the data source. Please check your data source and configuration.
Missing columns: ${S.map(I=>`'${I.name}' (\`${I.prop}\`)`).join(", ")}.`,"data-kit","error"),{ok:!1,processedFully:x,pointsAdded:T??!1}):E.length>0?(we(`Optional columns are missing from the data source. These columns will not be included in the final dataset.
Missing columns: ${E.map(I=>`'${I.name}' (\`${I.prop}\`)`).join(", ")}.`,"data-kit","warn"),{ok:!0,processedFully:x,pointsAdded:T??!1}):{ok:!0,processedFully:x,pointsAdded:T??!1}}catch(_){return console.warn(`loadTable: ${_}`),{ok:!1,processedFully:!0,pointsAdded:!1}}})(i,e,n,s);if(!l)return void we(`loadTable failed for ${e}`,"data-kit","error");await Ki.dropTable(e);const d=await wI(r,t,a),h=await Ki.query(`SUMMARIZE ${t}`);return d instanceof Uint8Array&&d.length||d instanceof zt&&d.numRows?{data:o(d),summary:h==null?void 0:h.toArray(),processedFully:c,pointsAdded:u}:void we(`processData: No ${t} to export found (buffer length: ${d instanceof Uint8Array?d.length:d instanceof zt?d.numRows:"unknown"})`,"data-kit","warn")},BQ=async(i,e,t,n,s,r=!1)=>{let o,a;await(async()=>{Ki=await Yk.getInstance()})(),await Ki.query(`DROP TABLE IF EXISTS ${qe.PreparedPoints}`),await Ki.query(`DROP TABLE IF EXISTS ${qe.PreparedLinks}`);let l=!0,c=!0;try{if(!i.points||i.points.pointIdBy!==void 0&&(i.points.linkSourceBy!==void 0||i.points.linkTargetsBy!==void 0))return void we("Stopped: points configuration is invalid","data-kit","error");const u=await iS(e,qe.RawPoints,qe.PreparedPoints,DQ,i.points,n,s,r);if(!u)return void we("Failed to process points data source","data-kit","error");let d=u.data;o=u.summary,l=u.processedFully;const h={...i};let p;if(t&&i.links)if(i.links.linkSourceBy&&i.links.linkTargetsBy)try{const y=await iS(t,qe.RawLinks,qe.PreparedLinks,MQ,i.links,n,s,r);if(y){if(p=y.data,a=y.summary,c=y.processedFully,y.pointsAdded){const g=await wI(n,qe.PreparedPoints,r),_=await Ki.query(`SUMMARIZE ${qe.PreparedPoints}`);(g instanceof Uint8Array&&g.length||g instanceof zt&&g.numRows)&&(d=s(g),o=_==null?void 0:_.toArray())}}else we("Failed to process links data - processData returned undefined","data-kit","error")}catch(y){we(`Failed to process links data: ${y}`,"data-kit","error")}else we("Links configuration is invalid, only points will be exported.","data-kit","error");!p&&i.links&&(h.links=void 0,we("Links configuration is invalid, only points will be exported.","data-kit","warn"));const m=(y=>{const g={...Object.fromEntries(Object.entries(y.points).filter(([_,S])=>_!=="outputFilename"&&_!=="linkTargetsBy"&&_!=="linkSourceBy"&&S!==void 0)),pointIdBy:_e.Id,pointIndexBy:_e.Idx};return y.links?{...g,...Object.fromEntries(Object.entries(y.links).filter(([_,S])=>_!=="linkTargetsBy"&&_!=="outputFilename"&&S!==void 0)),linkSourceBy:_e.Source,linkSourceIndexBy:_e.SourceIdx,linkTargetBy:_e.Target,linkTargetIndexBy:_e.TargetIdx}:g})(h);return{points:d,links:p,pointsSummary:o,linksSummary:a,cosmographConfig:m,pointsProcessedFully:l,linksProcessedFully:c}}catch(u){return void console.warn("_prepareCosmographData:",u)}finally{await Ki.destroy()}},OQ=async i=>Jd||(we("Started data preparing...","data-kit","util"),Jd=(async()=>{try{const e=await i();return e&&we("Finished data preparing","data-kit","util"),e}catch(e){return void we(e,"data-kit","error")}finally{Jd=null}})(),Jd),FQ=async(i,e,t)=>OQ(()=>BQ(i,e,t,Xi.Arrow,n=>n,!0)),nS={highlightSelectedData:!0,showAnimationControls:!0,useLinksData:!1,useQuantiles:!1};let zQ=class extends $u{constructor(){super(...arguments);b(this,"_dataExtent");b(this,"_visualExtent")}getCurrentSelection(){if(this.checkReady(()=>this.getCurrentSelection()))return this._uiComponent.getCurrentSelection()}getCurrentSelectionInPixels(){if(this.checkReady(()=>this.getCurrentSelectionInPixels()))return this._uiComponent.getCurrentSelectionInPixels()}getBarWidth(){if(this.checkReady(()=>this.getBarWidth()))return this._uiComponent.getBarWidth()}setSelection(t){var n,s,r;this.checkReady(()=>this.setSelection(t))&&(this._uiComponent.setSelection(t,!0),(n=this._client)==null||n.applyRangeFilter(t),(r=(s=this._config).onSelection)==null||r.call(s,t,!0))}getIsAnimationRunning(){return!!this.checkReady(()=>this.getIsAnimationRunning())&&this._uiComponent.getIsAnimationRunning()}playAnimation(){this.checkReady(()=>this.playAnimation())&&this._uiComponent.playAnimation()}pauseAnimation(){this.checkReady(()=>this.pauseAnimation())&&this._uiComponent.pauseAnimation()}stopAnimation(){this.checkReady(()=>this.stopAnimation())&&this._uiComponent.stopAnimation()}get defaultConfig(){return nS}get accessor(){return this._config.accessor??nS.accessor}async fetchData(){var t,n;if(await super.fetchData(),this._currentData){const s=(n=(t=this._currentData)==null?void 0:t.getChild(this.accessor))==null?void 0:n.toArray(),r=s==null?void 0:s.map(a=>a instanceof Date?a.getTime():a);this._dataExtent=r!=null&&r.length?Rn(r):void 0;const o=rI(r??[],this._config.useQuantiles,this._config.customExtent);this._visualExtent=o,this._uiComponent.setTimeData(s,o),this.updateCrossfilteredData()}else this._uiComponent.setTimeData(void 0),this.updateHighlightedData(void 0);this._uiComponent.pauseAnimation()}createUIComponent(t){return new tK(t,this.createComponentConfig(this._config))}createComponentConfig(t){return{...t,formatter:n=>{const s=typeof n=="number"?n:n.getTime(),r=((t==null?void 0:t.formatter)??Hs)(s);if(!this._config.useQuantiles||!this._dataExtent||!this._visualExtent)return r;const[o,a]=this._visualExtent,[l,c]=this._dataExtent;return s===o&&o>l?`< ${r}`:s===a&&a<c?`> ${r}`:r},onBrush:(n,s)=>{var l,c,u,d;let r=n;if(n&&this._config.useQuantiles&&this._visualExtent&&this._dataExtent){const h=n.map(T=>T instanceof Date?T.getTime():T),[p,m]=h,[y,g]=this._visualExtent,[_,S]=this._dataExtent,E=p===y?_:p,x=m===g?S:m;r=n[0]instanceof Date?[new Date(E),new Date(x)]:[E,x]}const o=(l=this._currentData)==null?void 0:l.getChild(this.accessor),a=r?Ko(o==null?void 0:o.type)?r==null?void 0:r.map(h=>+h):r.map(h=>new Date(h)):void 0;(c=this._client)==null||c.applyRangeFilter(a),(d=(u=this._config).onSelection)==null||d.call(u,r,s)},onBarHover:n=>{var s,r;(r=(s=this._config).onBarHover)==null||r.call(s,n)},onAnimationPlay:(n,s)=>{var r,o;(o=(r=this._config).onAnimationPlay)==null||o.call(r,n,s)},onAnimationPause:(n,s)=>{var r,o;(o=(r=this._config).onAnimationPause)==null||o.call(r,n,s)},onAnimationTick:n=>{var s,r;(r=(s=this._config).onAnimationTick)==null||r.call(s,n)}}}onResetClientSelections(){this.setSelection()}updateHighlightedData(t){const{highlightSelectedData:n}=this._config;n&&this._uiComponent.setHighlightedData(t)}async onConfigUpdate(){this._uiComponent.setConfig(this.createComponentConfig(this._config))}};const sS={highlightSelectedData:!0,useLinksData:!1,useQuantiles:!1};let UQ=class extends $u{constructor(){super(...arguments);b(this,"_dataExtent");b(this,"_visualExtent")}getCurrentSelection(){if(this.checkReady(()=>this.getCurrentSelection()))return this._uiComponent.getCurrentSelection()}getCurrentSelectionInPixels(){if(this.checkReady(()=>this.getCurrentSelectionInPixels()))return this._uiComponent.getCurrentSelectionInPixels()}getBarWidth(){if(this.checkReady(()=>this.getBarWidth()))return this._uiComponent.getBarWidth()}setSelection(t){var n,s,r;this.checkReady(()=>this.setSelection(t))&&(this._uiComponent.setSelection(t,!0),(n=this._client)==null||n.applyRangeFilter(t),(r=(s=this._config).onSelection)==null||r.call(s,t,!0))}get defaultConfig(){return sS}get accessor(){return this._config.accessor??sS.accessor}async fetchData(){var t,n;if(await super.fetchData(),this._currentData){const s=(n=(t=this._currentData)==null?void 0:t.getChild(this.accessor))==null?void 0:n.toArray();this._dataExtent=s!=null&&s.length?Rn(s):void 0;const r=rI(s??[],this._config.useQuantiles,this._config.customExtent);this._visualExtent=r,this._uiComponent.setHistogramData(s,r),this.updateCrossfilteredData()}else this._uiComponent.setHistogramData(void 0),this.updateHighlightedData(void 0)}createUIComponent(t){return new RK(t,this.createComponentConfig(this._config))}createComponentConfig(t){return{...t,formatter:n=>{const s=((t==null?void 0:t.formatter)??Hs)(n);if(!this._config.useQuantiles||!this._dataExtent||!this._visualExtent)return s;const[r,o]=this._visualExtent,[a,l]=this._dataExtent;return n===r&&r>a?`< ${s}`:n===o&&o<l?`> ${s}`:s},onBrush:(n,s)=>{var o,a,l;let r=n;if(n&&this._config.useQuantiles&&this._visualExtent&&this._dataExtent){const[c,u]=n,[d,h]=this._visualExtent,[p,m]=this._dataExtent;r=[c===d?p:c,u===h?m:u]}(o=this._client)==null||o.applyRangeFilter(r),(l=(a=this._config).onSelection)==null||l.call(a,r,s)},onBarHover:n=>{var s,r;(r=(s=this._config).onBarHover)==null||r.call(s,n)}}}updateHighlightedData(t){const{highlightSelectedData:n}=this._config;n&&this._uiComponent.setHighlightedData(t)}onResetClientSelections(){this.setSelection()}async onConfigUpdate(){this._uiComponent.setConfig(this.createComponentConfig(this._config))}};var vr;let Vp=(vr=class extends _I{constructor(){super(...arguments);b(this,"selected")}checkCurrentSelection(){this.selected&&this.setSelectedItem(this.selected)}onSelect(t){var n,s,r;this.compareSelectedItem(t)?((n=this._client)==null||n.resetFilter(),this.onResetClientSelections(),vr._activeComponentId=null):(vr._activeComponentId!==((s=this._client)==null?void 0:s.id)&&(this._internalApi.public.unselectAllPoints(),this._internalApi.dispatchEvent(new CustomEvent("resetSelections"))),vr._activeComponentId=((r=this._client)==null?void 0:r.id)||null,this.selected=t,this.setSelectedItem(t),this.accessor&&this.applyFilter(t))}onResetClientSelections(){this.selected=void 0,this.setSelectedItem(void 0)}onDataFiltered(){var t,n;((t=this._client)==null?void 0:t.id)!==vr._activeComponentId&&(this.selected=void 0,this.setSelectedItem(void 0),(n=this._client)==null||n.resetFilter())}},b(vr,"_activeComponentId",null),vr);const Io={suggestionsLimit:50,placeholderText:"Search...",showAccessorsMenu:!0,suggestionTruncationLength:50,accessor:"id",suggestionFieldsPalette:["#fbb4aebf","#b3cde3bf","#ccebc5bf","#decbe4bf","#fed9a6bf","#ffffccbf","#e5d8bdbf","#fddaecbf"],showFooter:!1};var $Q=".style_module_searchContainer__1bed75df{align-items:center;display:flex;gap:6px;position:relative;width:100%}.style_module_accessorButton__1bed75df{align-items:center;backdrop-filter:blur(8px);background:var(--cosmograph-search-accessors-background);border-radius:4px;cursor:pointer;display:flex;flex-shrink:0;font-size:13px;font-weight:300;line-height:1;max-width:100px;overflow:hidden;padding:2.5px 5px;text-overflow:ellipsis;white-space:nowrap}.style_module_accessorsMenuPlaceholder__1bed75df{font-size:11.5px;font-weight:600;letter-spacing:.07em;line-height:2;opacity:.9;padding-bottom:0;padding-left:10px;padding-top:4px;pointer-events:none;text-transform:uppercase;user-select:none}.style_module_accessorsMenu__1bed75df{backdrop-filter:blur(8px);background:var(--cosmograph-search-list-background);border-radius:4px;color:#fff;left:0;margin:2px 0 0;min-width:100%;opacity:0;overflow:hidden;padding:0 0 2px;pointer-events:none;position:absolute;right:0;top:100%;transform:translateY(-10px);transition:opacity .2s ease-out,transform .2s ease-out;width:100%}.style_module_accessorsMenu__1bed75df.style_module_upwards__1bed75df{bottom:100%;top:auto;transform:translateY(10px)}.style_module_accessorsMenu__1bed75df.style_module_visible__1bed75df{opacity:1;pointer-events:auto;transform:translateY(0)}.style_module_accessorsMenu__1bed75df.style_module_upwards__1bed75df.style_module_visible__1bed75df{opacity:1;pointer-events:auto;transform:translateY(-7px)}.style_module_accessorsMenu__1bed75df li{cursor:pointer;display:block;font-size:var(--cosmograph-search-list-font-size,13.5px);font-weight:500;line-height:normal;max-width:100%;opacity:0;padding:5px 10px;transform:translateY(5px);transition:opacity .2s ease-out,transform .2s ease-out;user-select:none}.style_module_accessorsMenu__1bed75df.style_module_visible__1bed75df li{opacity:1;transform:translateY(0)}.style_module_accessorsMenu__1bed75df li:hover{background:hsla(0,0%,100%,.1)}.style_module_accessorsMenu__1bed75df li>div{font-weight:200;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}.style_module_placeholderInput__1bed75df{align-items:center;cursor:text;display:flex;font-weight:300;min-width:0;opacity:.7;width:100%}.style_module_placeholderInput__1bed75df.style_module_disabled__1bed75df{cursor:not-allowed;opacity:.5;pointer-events:none}.style_module_searchResult__1bed75df{align-items:center;display:flex;flex-wrap:wrap}.style_module_searchResultMultiField__1bed75df{text-wrap:initial;align-items:center;color:hsla(0,0%,100%,.8);display:inline-block;font-size:var(--cosmograph-search-list-font-size,13.5px);font-weight:300;line-height:normal;margin-right:8px;max-width:100%;overflow-wrap:anywhere;word-break:normal}.style_module_searchResultMultiField__1bed75df span{text-wrap:balance;display:inline;font-size:calc(var(--cosmograph-search-list-font-size)*.95);hyphens:auto;line-height:1.25;overflow-wrap:anywhere;white-space:normal;word-break:break-all}.style_module_searchResultMultiField__1bed75df .style_module_separator__1bed75df{display:inline;opacity:.5}.style_module_searchResultMultiField__1bed75df b{font-size:calc(var(--cosmograph-search-list-font-size)*.9);font-weight:600;letter-spacing:.015em;opacity:.7;text-transform:uppercase;white-space:pre}.style_module_selectAllContainer__1bed75df{align-items:center;display:flex;gap:4px;justify-content:start;line-height:1;margin:.25rem .5rem .15rem;padding:.2rem 0;width:100%}.style_module_selectAllButton__1bed75df{align-items:center;backdrop-filter:blur(4px);background:var(--cosmograph-search-select-all-background,hsla(0,0%,100%,.1));border:none;border-radius:4px;color:var(--cosmograph-search-select-all-color,hsla(0,0%,100%,.75));cursor:pointer;font-size:var(--cosmograph-search-list-font-size,13.5px);font-weight:300;margin:0!important;padding:2px 8px;text-align:center;transition:background-color .2s ease,border-color .2s ease}.style_module_selectAllButton__1bed75df:hover{background:var(--cosmograph-search-select-all-hover-background,hsla(0,0%,100%,.15))}.style_module_resultsCounter__1bed75df{color:hsla(0,0%,100%,.4);font-size:12px;font-weight:400;user-select:none;white-space:nowrap}.style_module_selectAllContainer__1bed75df .style_module_separator__1bed75df{color:hsla(0,0%,100%,.4);opacity:.7;user-select:none}",Dt={searchContainer:"style_module_searchContainer__1bed75df",accessorButton:"style_module_accessorButton__1bed75df",accessorsMenuPlaceholder:"style_module_accessorsMenuPlaceholder__1bed75df",accessorsMenu:"style_module_accessorsMenu__1bed75df",upwards:"style_module_upwards__1bed75df",visible:"style_module_visible__1bed75df",placeholderInput:"style_module_placeholderInput__1bed75df",disabled:"style_module_disabled__1bed75df",searchResult:"style_module_searchResult__1bed75df",searchResultMultiField:"style_module_searchResultMultiField__1bed75df",separator:"style_module_separator__1bed75df",selectAllContainer:"style_module_selectAllContainer__1bed75df",selectAllButton:"style_module_selectAllButton__1bed75df",resultsCounter:"style_module_resultsCounter__1bed75df"};Dr($Q,{});var jQ=":root{--cosmograph-search-accessors-background:#8791a159}";Dr(jQ,{});var Wn;let HQ=(Wn=class extends Vp{constructor(){super(...arguments);b(this,"_isDataFetched",!1);b(this,"_accessorsMenu",null);b(this,"_placeholderElement",null);b(this,"_accessorButton",null);b(this,"_clickOutsideHandler",t=>this._handleClickOutside(t));b(this,"_enterFilterActive",!1);b(this,"_currentSearchInput","");b(this,"_currentSearchResults",[]);b(this,"_totalResultsCount",0);b(this,"_resultsCounter",null);b(this,"_arrayColumnsCache",new Set);b(this,"_selectedSearchField",Io.accessor)}get defaultConfig(){return Io}get accessor(){return this._config.accessor??Io.accessor}_isAllFieldsSelected(){return this._selectedSearchField===Wn.ALL_FIELDS_TOKEN}_getSelectedFieldLabel(){return this._isAllFieldsSelected()?Wn.ALL_FIELDS_LABEL:this.accessor}_syncSelectedSearchFieldWithConfig(){this._isAllFieldsSelected()||(this._selectedSearchField=this.accessor)}_getAutoSuggestionFields(){const{config:t}=this._internalApi,n=this._internalApi.summary.pointsSummary;if(!n||n.length===0)return;const s={};for(const r of n){const o=String(r.column_name);o!==t.pointIndexBy&&(s[o]=o)}if(this._config.suggestionFields)for(const[r,o]of Object.entries(this._config.suggestionFields))s[r]!==void 0&&(s[r]=o);return s}_getEffectiveSuggestionFields(){return this._isAllFieldsSelected()?this._getAutoSuggestionFields():this._config.suggestionFields}_getAllFields(){return Object.keys(this._getAutoSuggestionFields()??{})}_valueAccessor(t,n=this.accessor){const s=t[n];return s==null?"null":String(s)}_indexAccessor(t){const{config:n}=this._internalApi;return Number(t[n.pointIndexBy])}_calculateDisabledState(){return!this._isDataFetched||(typeof this._config.disabled=="boolean"?this._config.disabled:!this._isDataFetched)}async fetchData(){if(!this._internalApi.dbCoordinator)return;await this._internalApi.dataManager.dataReady(),this._isDataFetched=!0,this._syncSelectedSearchFieldWithConfig();const t=this._calculateDisabledState();this._uiComponent.setDisabled(t),this._findPlaceholderElement(),this._updatePlaceholderDisabledState(),this._config.showAccessorsMenu&&(await this._updateAccessorsMenu(),this._updateAccessorButton()),this._detectArrayColumns(),this._client&&this.accessor&&await this._client.getCurrentData()}_detectArrayColumns(){this._arrayColumnsCache.clear();for(const t of this._internalApi.summary.pointsSummary??[])Mj(String(t.column_type??""))&&this._arrayColumnsCache.add(String(t.column_name))}_isArrayColumn(t){return this._arrayColumnsCache.has(t)}applyFilter(t){var s,r,o;const{config:n}=this._internalApi;if(t)if(this._getEffectiveSuggestionFields()){const a=this._indexAccessor(t);(s=this._client)==null||s.applyFilter(a_(cn(n.pointIndexBy),[a])),this._internalApi.public.zoomToPoint(a),(n.focusPointOnClick??n.selectPointOnClick)&&this._internalApi.public.setFocusedPoint(a)}else(r=this._client)==null||r.applyExactFilter(this._valueAccessor(t));else(o=this._client)==null||o.resetFilter()}setSelectedItem(t){t||this._uiComponent.clearInput()}compareSelectedItem(t){var n;return!(t||!this.selected)||((n=this.selected)==null?void 0:n.id)===(t==null?void 0:t.id)}createUIComponent(t){return new yK(t,this.createComponentConfig({...this._config}))}onResetClientSelections(){this._uiComponent.clearInput()}async onConfigUpdate(){const t=this._config.openListUpwards;this._uiComponent.setConfig(this.createComponentConfig({...this._config})),this._updatePlaceholderDisabledState(),this._syncSelectedSearchFieldWithConfig(),this._config.showAccessorsMenu&&this._accessorsMenu&&t!==this._config.openListUpwards&&(this._config.openListUpwards?this._accessorsMenu.classList.add(Dt.upwards):this._accessorsMenu.classList.remove(Dt.upwards)),this._config.showAccessorsMenu&&this._updateAccessorButton(),this._uiComponent.clearInput(),this.onResetClientSelections()}async _getSuggestions(t){if(this._internalApi.dbCoordinator)return await this._internalApi.dataManager.dataReady(),this._syncSelectedSearchFieldWithConfig(),this._isAllFieldsSelected()?this._getAllFieldsSuggestions(t):this._getSingleFieldSuggestions(t)}async _executeQuery(t){var n;return await((n=this._internalApi.dbCoordinator)==null?void 0:n.query(t))}_buildOrderByClause(t,n){return this._isNullSearch(n)?`"${this.accessor}"`:`
      CASE WHEN ${t} = LOWER('${n}') THEN 0 ELSE 1 END,
      CASE WHEN ${t} LIKE LOWER('${n}%') THEN 0 ELSE 1 END,
      STRPOS(${t}, LOWER('${n}'))
    `}_isNullSearch(t){return t.toLowerCase().trim()==="null"}_buildFieldUtilities(t){const n=s=>this._isArrayColumn(s)?`LOWER(array_to_string("${s}", ', '))`:`LOWER(CAST("${s}" AS VARCHAR))`;return{fieldCast:n,fieldMatchCondition:s=>this._isNullSearch(t)?`"${s}" IS NULL`:this._isArrayColumn(s)?`EXISTS(
          SELECT 1 FROM UNNEST("${s}") AS element
          WHERE LOWER(CAST(element AS VARCHAR)) LIKE LOWER('%${t}%')
        )`:`${n(s)} LIKE LOWER('%${t}%')`}}_buildSingleFieldWhereCondition(t){const{fieldMatchCondition:n}=this._buildFieldUtilities(t);return n(this.accessor)}_buildAllFieldsWhereCondition(t){const n=this._getAllFields();if(n.length===0)return this._buildSingleFieldWhereCondition(t);const{fieldMatchCondition:s}=this._buildFieldUtilities(t);return n.map(s).join(" OR ")}_truncateAroundMatch(t,n,s){if(s===0||t.length<=s)return t;const r=t.toLowerCase(),o=n.toLowerCase(),a=r.indexOf(o);if(a===-1)return t.length>s?`${t.substring(0,s)}...`:t;const l=a+n.length,c=Math.floor(s/2);let u=Math.max(0,a-c),d=Math.min(t.length,l+c);u===0?d=Math.min(t.length,u+s):d===t.length&&(u=Math.max(0,d-s));let h=t.substring(u,d);return u>0&&(h=`...${h}`),d<t.length&&(h=`${h}...`),h}async _getSingleFieldSuggestions(t){const{fieldCast:n}=this._buildFieldUtilities(t),s=this._config.suggestionsLimit??Io.suggestionsLimit,r=this._buildSingleFieldWhereCondition(t);if(!this._getEffectiveSuggestionFields()){if(this._isNullSearch(t)){const l=`
          SELECT 'null' AS "${this.accessor}",
                 'null' AS id,
                 1 AS total_count
          FROM (SELECT 1) AS dummy
          WHERE EXISTS (
            SELECT 1 FROM ${this.tableName}
            WHERE "${this.accessor}" IS NULL
            LIMIT 1
          )
          LIMIT 1
        `;return this._executeQuery(l)}if(this._isArrayColumn(this.accessor)){const l=`
          WITH values AS (
            SELECT DISTINCT CAST(u.value AS VARCHAR) AS value
            FROM ${this.tableName} t,
                 UNNEST(t."${this.accessor}") AS u(value)
            WHERE LOWER(CAST(u.value AS VARCHAR)) LIKE LOWER('%${t}%')
          ),
          ranked AS (
            SELECT value,
                   LOWER(value) AS lower_value,
                   COUNT(*) OVER() AS total_count
            FROM values
          )
          SELECT value AS "${this.accessor}",
                 value AS id,
                 total_count
          FROM ranked
          ORDER BY ${this._buildOrderByClause("lower_value",t)},
                   value
          LIMIT ${s}
        `;return this._executeQuery(l)}const a=`
        WITH values AS (
          SELECT DISTINCT CAST("${this.accessor}" AS VARCHAR) AS value
          FROM ${this.tableName}
          WHERE ${r}
        ),
        ranked AS (
          SELECT value,
                 LOWER(value) AS lower_value,
                 COUNT(*) OVER() AS total_count
          FROM values
        )
        SELECT value AS "${this.accessor}",
               value AS id,
               total_count
        FROM ranked
        ORDER BY ${this._buildOrderByClause("lower_value",t)},
                 value
        LIMIT ${s}
      `;return this._executeQuery(a)}if(this._isNullSearch(t)){const a=`
        SELECT *,
               COUNT(*) OVER() AS total_count
        FROM ${this.tableName}
        WHERE ${r}
        ORDER BY ${this._buildOrderByClause("",t)}
        LIMIT ${s}
      `;return this._executeQuery(a)}const o=`
      SELECT *,
             COUNT(*) OVER() AS total_count
      FROM (
        SELECT *,
               ${n(this.accessor)} AS lower_value
        FROM ${this.tableName}
        WHERE ${r}
      ) t
      ORDER BY ${this._buildOrderByClause("lower_value",t)}
      LIMIT ${s}
    `;return this._executeQuery(o)}async _getAllFieldsSuggestions(t){const n=this._getAllFields(),s=this._config.suggestionsLimit??Io.suggestionsLimit,r=this._buildAllFieldsWhereCondition(t),{fieldCast:o,fieldMatchCondition:a}=this._buildFieldUtilities(t);if(n.length===0)return this._getSingleFieldSuggestions(t);const l=n.map(u=>`WHEN ${a(u)} THEN '${u}'`).join(" ");if(this._isNullSearch(t)){const u=`
        SELECT *,
               COUNT(*) OVER() AS total_count,
               'null' AS matched_value,
               CASE ${l} END AS matched_field
        FROM ${this.tableName}
        WHERE ${r}
        ORDER BY "${this.accessor}"
        LIMIT ${s}
      `;return this._executeQuery(u)}const c=`
      SELECT *,
             COUNT(*) OVER() AS total_count
      FROM (
        SELECT *,
               CASE ${l} END AS matched_field,
               CASE ${n.map(u=>`WHEN ${a(u)} THEN ${o(u)}`).join(" ")} END AS matched_value
        FROM ${this.tableName}
        WHERE ${r}
      ) t
      ORDER BY ${this._buildOrderByClause("matched_value",t)}
      LIMIT ${s}
    `;return this._executeQuery(c)}async _getSearchItems(t){var o,a;if(!this._isDataFetched||((o=this._internalApi.summary.pointsSummary)==null?void 0:o.length)===0)return this._currentSearchResults=[],this._totalResultsCount=0,this._updateResultsCounter(),[];const n=await this._getSuggestions(t),s=(n==null?void 0:n.toArray())??[];this._currentSearchResults=s;const r=(a=s[0])==null?void 0:a.total_count;return this._totalResultsCount=typeof r=="number"?r:s.length,this._updateResultsCounter(),this._currentSearchResults}_createAccessorButton(){const t=document.createElement("div");return t.classList.add(Dt.accessorButton),t.dataset.ignoreFocus="true",t.textContent=this._getSelectedFieldLabel(),t.onclick=()=>{this._accessorsMenu&&(this._accessorsMenu.classList.contains(Dt.visible)?this._accessorsMenu.classList.remove(Dt.visible):this._accessorsMenu.classList.add(Dt.visible))},t}_createFooter(){const t=document.createElement("div");t.classList.add(Dt.selectAllContainer);const n=document.createElement("button");n.classList.add(Dt.selectAllButton),n.textContent="select found results",n.onclick=async r=>{r.stopPropagation(),await this._handleSelectAllClick()},this._resultsCounter=document.createElement("span"),this._resultsCounter.classList.add(Dt.resultsCounter),this._resultsCounter.textContent=this._getResultsCountText(),t.appendChild(n);const s=document.createElement("span");return s.classList.add(Dt.separator),s.textContent=" · ",t.appendChild(s),t.appendChild(this._resultsCounter),t}_getResultsCountText(){const t=this._totalResultsCount,n=this._currentSearchResults.length,s=(r,o,a=`${o}s`)=>r===1?o:a;return t===n?`${Hs(t)} ${s(t,"result")} found`:`${Hs(n)} of ${Hs(t)} ${s(t,"result")} shown`}_updateResultsCounter(){this._resultsCounter&&(this._resultsCounter.textContent=this._getResultsCountText())}async _handleSelectAllClick(){var t,n,s;if(this._currentSearchResults.length!==0&&this._currentSearchInput)try{const{config:r}=this._internalApi,o=r.pointIndexBy,a=this._isAllFieldsSelected()?this._buildAllFieldsWhereCondition(this._currentSearchInput):this._buildSingleFieldWhereCondition(this._currentSearchInput),l=`
        SELECT DISTINCT "${o}" as point_index
        FROM ${this.tableName}
        WHERE ${a}
      `,c=await this._executeQuery(l),u=((c==null?void 0:c.toArray())??[]).map(d=>d.point_index);(t=this._client)==null||t.applyFilter(a_(cn(this._internalApi.config.pointIndexBy),u)),this._enterFilterActive=!0,(s=(n=this._config).onSelectAll)==null||s.call(n,u),this._uiComponent.hideSuggestions()}catch{this._uiComponent.hideSuggestions()}}_createAccessorsMenu(){const t=document.createElement("ul");return t.dataset.ignoreFocus="true",t.classList.add(Dt.accessorsMenu),this._config.openListUpwards&&t.classList.add(Dt.upwards),t}_handleClickOutside(t){var n;this._accessorsMenu&&this._accessorsMenu.classList.contains(Dt.visible)&&!((n=this._accessorButton)!=null&&n.contains(t.target))&&!this._accessorsMenu.contains(t.target)&&this._accessorsMenu.classList.remove(Dt.visible)}_createPlaceholderElement(){if(!this._placeholderElement){this._placeholderElement=document.createElement("div"),this._placeholderElement.classList.add(Dt.searchContainer),this._config.showAccessorsMenu&&(this._accessorsMenu=this._createAccessorsMenu(),this._accessorButton=this._createAccessorButton(),this._placeholderElement.appendChild(this._accessorButton),this._placeholderElement.appendChild(this._accessorsMenu),document.addEventListener("click",this._clickOutsideHandler));const t=document.createElement("div");t.classList.add(Dt.placeholderInput),t.innerHTML=this._config.placeholderText??"Search...",this._calculateDisabledState()&&t.classList.add(Dt.disabled),t.onclick=()=>{this._calculateDisabledState()||this._uiComponent.focus()},this._placeholderElement.appendChild(t)}return this._placeholderElement}_updateAccessorButton(){if(this._accessorButton){const t=this._getSelectedFieldLabel();this._accessorButton.textContent=t,this._accessorButton.title=t}}_findPlaceholderElement(){if(!this._placeholderElement){const t=`.${Dt.searchContainer}`,n=document.querySelector(t);if(!n)return;this._placeholderElement=n,this._accessorButton=n.querySelector(`.${Dt.accessorButton}`),this._config.showAccessorsMenu&&!this._accessorsMenu&&(this._accessorsMenu=this._createAccessorsMenu(),this._placeholderElement.appendChild(this._accessorsMenu))}}_updatePlaceholderDisabledState(){if(!this._placeholderElement)return;const t=this._placeholderElement.querySelector(`.${Dt.placeholderInput}`);t&&(this._calculateDisabledState()?t.classList.add(Dt.disabled):t.classList.remove(Dt.disabled))}async _updateAccessorsMenu(){var r;if(!this._config.showAccessorsMenu||!this._accessorsMenu)return;const{config:t}=this._internalApi;if(!this._internalApi.summary.pointsSummary)return;this._config.openListUpwards?this._accessorsMenu.classList.add(Dt.upwards):this._accessorsMenu.classList.remove(Dt.upwards);const n=(r=this._internalApi.summary.pointsSummary)==null?void 0:r.map(o=>String(o.column_name)).filter(o=>o!==t.pointIndexBy);this._accessorsMenu.innerHTML="";const s=document.createElement("div");s.classList.add(Dt.accessorsMenuPlaceholder),s.textContent="Select field to search",this._accessorsMenu.appendChild(s),this._accessorsMenu.appendChild(this._createAccessorItem(Wn.ALL_FIELDS_TOKEN,Wn.ALL_FIELDS_LABEL)),n.forEach(o=>{const a=this._createAccessorItem(o);this._accessorsMenu.appendChild(a)})}_createAccessorItem(t,n){const s=document.createElement("li"),r=document.createElement("div"),o=n??t;return r.textContent=o,r.title=o,r.onclick=a=>this._handleAccessorClick(t,a),s.onclick=a=>this._handleAccessorClick(t,a),s.appendChild(r),s}async _handleAccessorClick(t,n){n.stopPropagation(),t===Wn.ALL_FIELDS_TOKEN?this._isAllFieldsSelected()||(this._selectedSearchField=Wn.ALL_FIELDS_TOKEN,this._updateAccessorButton(),this._uiComponent.clearInput(),await this.onConfigUpdate()):(this._config.accessor!==t||this._isAllFieldsSelected())&&(this._selectedSearchField=t,this._config.accessor=t,this._updateAccessorButton(),this._uiComponent.clearInput(),await this.onConfigUpdate(),this._client&&await this._client.getCurrentData()),this._accessorsMenu&&this._accessorsMenu.classList.remove(Dt.visible)}_renderSuggestionField(t,n,s,r,o){const a=n[s]!==void 0&&n[s]!==null,l=(n[s]===null||n[s]===void 0)&&this._isNullSearch(this._currentSearchInput);if(a||l){const c=o[s];let u=this._valueAccessor(n,s);const d=this._config.suggestionTruncationLength??Io.suggestionTruncationLength;if(d>0&&this._currentSearchInput&&u.length>d&&(u=this._truncateAroundMatch(u,this._currentSearchInput,d)),r>0){const g=document.createElement("div");g.classList.add(Dt.separator),g.innerHTML=" · ",t.appendChild(g)}const h=document.createElement("span"),p=document.createElement("b");p.textContent=`${c}: `,h.appendChild(p);const m=document.createElement("span");let y;if(r>0&&this._config.suggestionFieldsPalette&&this._config.suggestionFieldsPalette.length>0){const g=(r-1)%this._config.suggestionFieldsPalette.length;y=this._config.suggestionFieldsPalette[g],h.style.color=y??"inherit"}if(this._isAllFieldsSelected()?this._currentSearchInput&&(this._isNullSearch(this._currentSearchInput)?u.toLowerCase()==="null":u.toLowerCase().includes(this._currentSearchInput.toLowerCase())):s===this.accessor){const g=this._uiComponent.getHighlightedMatch(u);m.innerHTML=y?g.replace(/<mark[^>]*>/g,`<mark style="color: ${y}">`):g}else m.textContent=u;h.appendChild(m),t.appendChild(h)}}_renderSuggestion(t){const n=this._getEffectiveSuggestionFields();if(!n){let l=this._valueAccessor(t);const c=this._config.suggestionTruncationLength??Io.suggestionTruncationLength;return c>0&&this._currentSearchInput&&l.length>c&&(l=this._truncateAroundMatch(l,this._currentSearchInput,c)),l}const s=document.createElement("div");s.classList.add(Dt.searchResult);const r={...n};let o=Object.keys(r);r[this.accessor]?o[0]!==this.accessor&&(o=o.filter(l=>l!==this.accessor),o.unshift(this.accessor)):(r[this.accessor]=this.accessor,o.unshift(this.accessor));const a=document.createElement("span");return a.classList.add(Dt.searchResultMultiField),o.forEach((l,c)=>{this._renderSuggestionField(a,t,l,c,r)}),s.appendChild(a),s}createComponentConfig(t){return{...t,onEnter:async(...n)=>{var r,o,a;const[,s]=n;Array.isArray(s)&&s.length>0?await this._handleSelectAllClick():((r=this._client)==null||r.resetFilter(),this._enterFilterActive=!1),this._uiComponent.hideSuggestions(),Array.isArray(s)&&s.splice(0,s.length),(a=(o=this._config).onEnter)==null||a.call(o,...n)},onInput:(...n)=>{var r,o;const[s]=n;this._currentSearchInput=s,(o=(r=this._config).onInput)==null||o.call(r,...n)},onSelect:(...n)=>{var s,r;this._enterFilterActive=!1,this.onSelect(n[0]),(r=(s=this._config).onSelect)==null||r.call(s,n[0])},onClear:()=>{var n,s;this._enterFilterActive=!1,this.onSelect(void 0),(s=(n=this._config).onClear)==null||s.call(n)},disabled:this._calculateDisabledState(),searchFn:async(...n)=>await this._getSearchItems(n[0]),suggestionRenderer:n=>this._renderSuggestion(n),selectedSuggestionRenderer:n=>{let s=this._valueAccessor(n);const r=this._config.suggestionTruncationLength??Io.suggestionTruncationLength;return r>0&&this._currentSearchInput&&s.length>r&&(s=this._truncateAroundMatch(s,this._currentSearchInput,r)),s},placeholderRenderer:this._createPlaceholderElement(),footerComponent:this._config.showFooter?this._createFooter():void 0}}remove(){document.removeEventListener("click",this._clickOutsideHandler),this._accessorButton&&(this._accessorButton.onclick=null),this._uiComponent.destroy(),this._accessorsMenu=null,this._placeholderElement=null,this._accessorButton=null,this._resultsCounter=null,this._currentSearchResults=[],this._totalResultsCount=0,super.remove()}onDataFiltered(){this._enterFilterActive||super.onDataFiltered()}hideSuggestions(){this.checkReady(()=>this.hideSuggestions())&&this._uiComponent.hideSuggestions()}clearInput(){this.checkReady(()=>this.clearInput())&&this._uiComponent.clearInput()}focus(){this.checkReady(()=>this.focus())&&this._uiComponent.focus()}blur(){this.checkReady(()=>this.blur())&&this._uiComponent.blur()}},b(Wn,"ALL_FIELDS_TOKEN","__all_fields__"),b(Wn,"ALL_FIELDS_LABEL","all fields"),Wn);const VQ={useLinksData:!1,selectOnClick:!0,highlightSelectedData:!0};let GQ=class extends $u{setSelectedItem(e){var t;this.checkReady(()=>this.setSelectedItem(e))&&(this._uiComponent.setSelectedItem(e),e||((t=this._client)==null||t.resetFilter()))}get defaultConfig(){return VQ}get accessor(){return this._config.accessor}onResetClientSelections(){this.setSelectedItem(void 0)}async fetchData(){var e,t;if(await super.fetchData(),this._currentData){this._uiComponent.resetList();const n=this.accessor?IZ((t=(e=this._currentData)==null?void 0:e.getChild(this.accessor))==null?void 0:t.toArray(),String):[];this._uiComponent.setData(n),this.updateCrossfilteredData()}else this._uiComponent.setData(void 0),this.updateHighlightedData(void 0)}createUIComponent(e){return new BK(e,this.createComponentConfig(this._config))}createComponentConfig(e){return{...e,onClick:t=>{var s,r,o,a,l,c,u,d,h;const n=this._uiComponent.getSelectedItem();t&&(n==null?void 0:n.label)===t.label?((s=this._client)==null||s.resetFilter(),this.setSelectedItem(void 0),(o=(r=this._config).onClick)==null||o.call(r,void 0)):t?((a=this._client)==null||a.applyExactFilter(t.label),this.setSelectedItem(t),(c=(l=this._config).onClick)==null||c.call(l,t)):((u=this._client)==null||u.resetFilter(),this.setSelectedItem(void 0),(h=(d=this._config).onClick)==null||h.call(d,void 0))},onBarHover:t=>{var n,s;(s=(n=this._config).onBarHover)==null||s.call(n,t)}}}async onConfigUpdate(){this._uiComponent.setConfig(this.createComponentConfig(this._config))}updateHighlightedData(e){const{highlightSelectedData:t}=this._config;if(t)if(this._internalApi.crossfilter.isFilteringActive)if(e&&e.length>0){const n=e.map(s=>String(s));this._uiComponent.setHighlightedData(n)}else this._uiComponent.setHighlightedData([]);else this._uiComponent.setHighlightedData(void 0)}};/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */const{entries:SI,setPrototypeOf:rS,isFrozen:WQ,getPrototypeOf:YQ,getOwnPropertyDescriptor:qQ}=Object;let{freeze:gn,seal:xs,create:K_}=Object,{apply:Z_,construct:Q_}=typeof Reflect<"u"&&Reflect;gn||(gn=function(e){return e});xs||(xs=function(e){return e});Z_||(Z_=function(e,t){for(var n=arguments.length,s=new Array(n>2?n-2:0),r=2;r<n;r++)s[r-2]=arguments[r];return e.apply(t,s)});Q_||(Q_=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return new e(...n)});const eh=_n(Array.prototype.forEach),XQ=_n(Array.prototype.lastIndexOf),oS=_n(Array.prototype.pop),Tc=_n(Array.prototype.push),KQ=_n(Array.prototype.splice),$h=_n(String.prototype.toLowerCase),ng=_n(String.prototype.toString),sg=_n(String.prototype.match),kc=_n(String.prototype.replace),ZQ=_n(String.prototype.indexOf),QQ=_n(String.prototype.trim),Bs=_n(Object.prototype.hasOwnProperty),an=_n(RegExp.prototype.test),Ac=JQ(TypeError);function _n(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return Z_(i,e,n)}}function JQ(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Q_(i,t)}}function tt(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$h;rS&&rS(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(WQ(e)||(e[n]=r),s=r)}i[s]=!0}return i}function eJ(i){for(let e=0;e<i.length;e++)Bs(i,e)||(i[e]=null);return i}function or(i){const e=K_(null);for(const[t,n]of SI(i))Bs(i,t)&&(Array.isArray(n)?e[t]=eJ(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=or(n):e[t]=n);return e}function Ic(i,e){for(;i!==null;){const n=qQ(i,e);if(n){if(n.get)return _n(n.get);if(typeof n.value=="function")return _n(n.value)}i=YQ(i)}function t(){return null}return t}const aS=gn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),rg=gn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),og=gn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),tJ=gn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ag=gn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),iJ=gn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lS=gn(["#text"]),cS=gn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),lg=gn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),uS=gn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),th=gn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nJ=xs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),sJ=xs(/<%[\w\W]*|[\w\W]*%>/gm),rJ=xs(/\$\{[\w\W]*/gm),oJ=xs(/^data-[\-\w.\u00B7-\uFFFF]+$/),aJ=xs(/^aria-[\-\w]+$/),EI=xs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lJ=xs(/^(?:\w+script|data):/i),cJ=xs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),CI=xs(/^html$/i),uJ=xs(/^[a-z][.\w]*(-[.\w]+)+$/i);var dS=Object.freeze({__proto__:null,ARIA_ATTR:aJ,ATTR_WHITESPACE:cJ,CUSTOM_ELEMENT:uJ,DATA_ATTR:oJ,DOCTYPE_NAME:CI,ERB_EXPR:sJ,IS_ALLOWED_URI:EI,IS_SCRIPT_OR_DATA:lJ,MUSTACHE_EXPR:nJ,TMPLIT_EXPR:rJ});const Lc={element:1,text:3,progressingInstruction:7,comment:8,document:9},dJ=function(){return typeof window>"u"?null:window},hJ=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(n=t.getAttribute(s));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},hS=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function TI(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dJ();const e=V=>TI(V);if(e.version="3.3.1",e.removed=[],!i||!i.document||i.document.nodeType!==Lc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=Ic(m,"cloneNode"),g=Ic(m,"remove"),_=Ic(m,"nextSibling"),S=Ic(m,"childNodes"),E=Ic(m,"parentNode");if(typeof o=="function"){const V=t.createElement("template");V.content&&V.content.ownerDocument&&(t=V.content.ownerDocument)}let x,T="";const{implementation:I,createNodeIterator:O,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:re}=n;let D=hS();e.isSupported=typeof SI=="function"&&typeof E=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:de,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:ee,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:te,CUSTOM_ELEMENT:Z}=dS;let{IS_ALLOWED_URI:ae}=dS,J=null;const Se=tt({},[...aS,...rg,...og,...ag,...lS]);let xe=null;const et=tt({},[...cS,...lg,...uS,...th]);let he=Object.seal(K_(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),yt=null,Xe=null;const dt=Object.seal(K_(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ie=!0,Ce=!0,Pe=!1,X=!0,We=!1,He=!0,bt=!1,Vt=!1,pe=!1,it=!1,si=!1,yi=!1,Zs=!0,Zn=!1;const wo="user-content-";let Bn=!0,di=!1,tn={},bi=null;const Qn=tt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ss=null;const Qs=tt({},["audio","video","img","source","image","track"]);let On=null;const Es=tt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nn="http://www.w3.org/1998/Math/MathML",Ti="http://www.w3.org/2000/svg",Qt="http://www.w3.org/1999/xhtml";let $i=Qt,vn=!1,So=null;const Mr=tt({},[nn,Ti,Qt],ng);let ji=tt({},["mi","mo","mn","ms","mtext"]),Br=tt({},["annotation-xml"]);const Cs=tt({},["title","style","font","a","script"]);let Js=null;const ic=["application/xhtml+xml","text/html"],Jt="text/html";let At=null,Jn=null;const Ut=t.createElement("form"),Ts=function(C){return C instanceof RegExp||C instanceof Function},er=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Jn&&Jn===C)){if((!C||typeof C!="object")&&(C={}),C=or(C),Js=ic.indexOf(C.PARSER_MEDIA_TYPE)===-1?Jt:C.PARSER_MEDIA_TYPE,At=Js==="application/xhtml+xml"?ng:$h,J=Bs(C,"ALLOWED_TAGS")?tt({},C.ALLOWED_TAGS,At):Se,xe=Bs(C,"ALLOWED_ATTR")?tt({},C.ALLOWED_ATTR,At):et,So=Bs(C,"ALLOWED_NAMESPACES")?tt({},C.ALLOWED_NAMESPACES,ng):Mr,On=Bs(C,"ADD_URI_SAFE_ATTR")?tt(or(Es),C.ADD_URI_SAFE_ATTR,At):Es,Ss=Bs(C,"ADD_DATA_URI_TAGS")?tt(or(Qs),C.ADD_DATA_URI_TAGS,At):Qs,bi=Bs(C,"FORBID_CONTENTS")?tt({},C.FORBID_CONTENTS,At):Qn,yt=Bs(C,"FORBID_TAGS")?tt({},C.FORBID_TAGS,At):or({}),Xe=Bs(C,"FORBID_ATTR")?tt({},C.FORBID_ATTR,At):or({}),tn=Bs(C,"USE_PROFILES")?C.USE_PROFILES:!1,ie=C.ALLOW_ARIA_ATTR!==!1,Ce=C.ALLOW_DATA_ATTR!==!1,Pe=C.ALLOW_UNKNOWN_PROTOCOLS||!1,X=C.ALLOW_SELF_CLOSE_IN_ATTR!==!1,We=C.SAFE_FOR_TEMPLATES||!1,He=C.SAFE_FOR_XML!==!1,bt=C.WHOLE_DOCUMENT||!1,it=C.RETURN_DOM||!1,si=C.RETURN_DOM_FRAGMENT||!1,yi=C.RETURN_TRUSTED_TYPE||!1,pe=C.FORCE_BODY||!1,Zs=C.SANITIZE_DOM!==!1,Zn=C.SANITIZE_NAMED_PROPS||!1,Bn=C.KEEP_CONTENT!==!1,di=C.IN_PLACE||!1,ae=C.ALLOWED_URI_REGEXP||EI,$i=C.NAMESPACE||Qt,ji=C.MATHML_TEXT_INTEGRATION_POINTS||ji,Br=C.HTML_INTEGRATION_POINTS||Br,he=C.CUSTOM_ELEMENT_HANDLING||{},C.CUSTOM_ELEMENT_HANDLING&&Ts(C.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(he.tagNameCheck=C.CUSTOM_ELEMENT_HANDLING.tagNameCheck),C.CUSTOM_ELEMENT_HANDLING&&Ts(C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(he.attributeNameCheck=C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),C.CUSTOM_ELEMENT_HANDLING&&typeof C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),We&&(Ce=!1),si&&(it=!0),tn&&(J=tt({},lS),xe=[],tn.html===!0&&(tt(J,aS),tt(xe,cS)),tn.svg===!0&&(tt(J,rg),tt(xe,lg),tt(xe,th)),tn.svgFilters===!0&&(tt(J,og),tt(xe,lg),tt(xe,th)),tn.mathMl===!0&&(tt(J,ag),tt(xe,uS),tt(xe,th))),C.ADD_TAGS&&(typeof C.ADD_TAGS=="function"?dt.tagCheck=C.ADD_TAGS:(J===Se&&(J=or(J)),tt(J,C.ADD_TAGS,At))),C.ADD_ATTR&&(typeof C.ADD_ATTR=="function"?dt.attributeCheck=C.ADD_ATTR:(xe===et&&(xe=or(xe)),tt(xe,C.ADD_ATTR,At))),C.ADD_URI_SAFE_ATTR&&tt(On,C.ADD_URI_SAFE_ATTR,At),C.FORBID_CONTENTS&&(bi===Qn&&(bi=or(bi)),tt(bi,C.FORBID_CONTENTS,At)),C.ADD_FORBID_CONTENTS&&(bi===Qn&&(bi=or(bi)),tt(bi,C.ADD_FORBID_CONTENTS,At)),Bn&&(J["#text"]=!0),bt&&tt(J,["html","head","body"]),J.table&&(tt(J,["tbody"]),delete yt.tbody),C.TRUSTED_TYPES_POLICY){if(typeof C.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ac('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof C.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ac('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=C.TRUSTED_TYPES_POLICY,T=x.createHTML("")}else x===void 0&&(x=hJ(p,s)),x!==null&&typeof T=="string"&&(T=x.createHTML(""));gn&&gn(C),Jn=C}},Or=tt({},[...rg,...og,...tJ]),Eo=tt({},[...ag,...iJ]),es=function(C){let G=E(C);(!G||!G.tagName)&&(G={namespaceURI:$i,tagName:"template"});const ne=$h(C.tagName),Te=$h(G.tagName);return So[C.namespaceURI]?C.namespaceURI===Ti?G.namespaceURI===Qt?ne==="svg":G.namespaceURI===nn?ne==="svg"&&(Te==="annotation-xml"||ji[Te]):!!Or[ne]:C.namespaceURI===nn?G.namespaceURI===Qt?ne==="math":G.namespaceURI===Ti?ne==="math"&&Br[Te]:!!Eo[ne]:C.namespaceURI===Qt?G.namespaceURI===Ti&&!Br[Te]||G.namespaceURI===nn&&!ji[Te]?!1:!Eo[ne]&&(Cs[ne]||!Or[ne]):!!(Js==="application/xhtml+xml"&&So[C.namespaceURI]):!1},hi=function(C){Tc(e.removed,{element:C});try{E(C).removeChild(C)}catch{g(C)}},xn=function(C,G){try{Tc(e.removed,{attribute:G.getAttributeNode(C),from:G})}catch{Tc(e.removed,{attribute:null,from:G})}if(G.removeAttribute(C),C==="is")if(it||si)try{hi(G)}catch{}else try{G.setAttribute(C,"")}catch{}},ks=function(C){let G=null,ne=null;if(pe)C="<remove></remove>"+C;else{const st=sg(C,/^[\r\n\t ]+/);ne=st&&st[0]}Js==="application/xhtml+xml"&&$i===Qt&&(C='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+C+"</body></html>");const Te=x?x.createHTML(C):C;if($i===Qt)try{G=new h().parseFromString(Te,Js)}catch{}if(!G||!G.documentElement){G=I.createDocument($i,"template",null);try{G.documentElement.innerHTML=vn?T:Te}catch{}}const It=G.body||G.documentElement;return C&&ne&&It.insertBefore(t.createTextNode(ne),It.childNodes[0]||null),$i===Qt?Q.call(G,bt?"html":"body")[0]:bt?G.documentElement:It},ct=function(C){return O.call(C.ownerDocument||C,C,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fr=function(C){return C instanceof d&&(typeof C.nodeName!="string"||typeof C.textContent!="string"||typeof C.removeChild!="function"||!(C.attributes instanceof u)||typeof C.removeAttribute!="function"||typeof C.setAttribute!="function"||typeof C.namespaceURI!="string"||typeof C.insertBefore!="function"||typeof C.hasChildNodes!="function")},nt=function(C){return typeof a=="function"&&C instanceof a};function wn(V,C,G){eh(V,ne=>{ne.call(e,C,G,Jn)})}const zr=function(C){let G=null;if(wn(D.beforeSanitizeElements,C,null),Fr(C))return hi(C),!0;const ne=At(C.nodeName);if(wn(D.uponSanitizeElement,C,{tagName:ne,allowedTags:J}),He&&C.hasChildNodes()&&!nt(C.firstElementChild)&&an(/<[/\w!]/g,C.innerHTML)&&an(/<[/\w!]/g,C.textContent)||C.nodeType===Lc.progressingInstruction||He&&C.nodeType===Lc.comment&&an(/<[/\w]/g,C.data))return hi(C),!0;if(!(dt.tagCheck instanceof Function&&dt.tagCheck(ne))&&(!J[ne]||yt[ne])){if(!yt[ne]&&Fn(ne)&&(he.tagNameCheck instanceof RegExp&&an(he.tagNameCheck,ne)||he.tagNameCheck instanceof Function&&he.tagNameCheck(ne)))return!1;if(Bn&&!bi[ne]){const Te=E(C)||C.parentNode,It=S(C)||C.childNodes;if(It&&Te){const st=It.length;for(let Je=st-1;Je>=0;--Je){const vi=y(It[Je],!0);vi.__removalCount=(C.__removalCount||0)+1,Te.insertBefore(vi,_(C))}}}return hi(C),!0}return C instanceof l&&!es(C)||(ne==="noscript"||ne==="noembed"||ne==="noframes")&&an(/<\/no(script|embed|frames)/i,C.innerHTML)?(hi(C),!0):(We&&C.nodeType===Lc.text&&(G=C.textContent,eh([de,se,R],Te=>{G=kc(G,Te," ")}),C.textContent!==G&&(Tc(e.removed,{element:C.cloneNode()}),C.textContent=G)),wn(D.afterSanitizeElements,C,null),!1)},tr=function(C,G,ne){if(Zs&&(G==="id"||G==="name")&&(ne in t||ne in Ut))return!1;if(!(Ce&&!Xe[G]&&an(ee,G))){if(!(ie&&an(F,G))){if(!(dt.attributeCheck instanceof Function&&dt.attributeCheck(G,C))){if(!xe[G]||Xe[G]){if(!(Fn(C)&&(he.tagNameCheck instanceof RegExp&&an(he.tagNameCheck,C)||he.tagNameCheck instanceof Function&&he.tagNameCheck(C))&&(he.attributeNameCheck instanceof RegExp&&an(he.attributeNameCheck,G)||he.attributeNameCheck instanceof Function&&he.attributeNameCheck(G,C))||G==="is"&&he.allowCustomizedBuiltInElements&&(he.tagNameCheck instanceof RegExp&&an(he.tagNameCheck,ne)||he.tagNameCheck instanceof Function&&he.tagNameCheck(ne))))return!1}else if(!On[G]){if(!an(ae,kc(ne,te,""))){if(!((G==="src"||G==="xlink:href"||G==="href")&&C!=="script"&&ZQ(ne,"data:")===0&&Ss[C])){if(!(Pe&&!an(q,kc(ne,te,"")))){if(ne)return!1}}}}}}}return!0},Fn=function(C){return C!=="annotation-xml"&&sg(C,Z)},sn=function(C){wn(D.beforeSanitizeAttributes,C,null);const{attributes:G}=C;if(!G||Fr(C))return;const ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let Te=G.length;for(;Te--;){const It=G[Te],{name:st,namespaceURI:Je,value:vi}=It,ht=At(st),ir=vi;let Lt=st==="value"?ir:QQ(ir);if(ne.attrName=ht,ne.attrValue=Lt,ne.keepAttr=!0,ne.forceKeepAttr=void 0,wn(D.uponSanitizeAttribute,C,ne),Lt=ne.attrValue,Zn&&(ht==="id"||ht==="name")&&(xn(st,C),Lt=wo+Lt),He&&an(/((--!?|])>)|<\/(style|title|textarea)/i,Lt)){xn(st,C);continue}if(ht==="attributename"&&sg(Lt,"href")){xn(st,C);continue}if(ne.forceKeepAttr)continue;if(!ne.keepAttr){xn(st,C);continue}if(!X&&an(/\/>/i,Lt)){xn(st,C);continue}We&&eh([de,se,R],Ra=>{Lt=kc(Lt,Ra," ")});const Pi=At(C.nodeName);if(!tr(Pi,ht,Lt)){xn(st,C);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!Je)switch(p.getAttributeType(Pi,ht)){case"TrustedHTML":{Lt=x.createHTML(Lt);break}case"TrustedScriptURL":{Lt=x.createScriptURL(Lt);break}}if(Lt!==ir)try{Je?C.setAttributeNS(Je,st,Lt):C.setAttribute(st,Lt),Fr(C)?hi(C):oS(e.removed)}catch{xn(st,C)}}wn(D.afterSanitizeAttributes,C,null)},L=function V(C){let G=null;const ne=ct(C);for(wn(D.beforeSanitizeShadowDOM,C,null);G=ne.nextNode();)wn(D.uponSanitizeShadowNode,G,null),zr(G),sn(G),G.content instanceof r&&V(G.content);wn(D.afterSanitizeShadowDOM,C,null)};return e.sanitize=function(V){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},G=null,ne=null,Te=null,It=null;if(vn=!V,vn&&(V="<!-->"),typeof V!="string"&&!nt(V))if(typeof V.toString=="function"){if(V=V.toString(),typeof V!="string")throw Ac("dirty is not a string, aborting")}else throw Ac("toString is not a function");if(!e.isSupported)return V;if(Vt||er(C),e.removed=[],typeof V=="string"&&(di=!1),di){if(V.nodeName){const vi=At(V.nodeName);if(!J[vi]||yt[vi])throw Ac("root node is forbidden and cannot be sanitized in-place")}}else if(V instanceof a)G=ks("<!---->"),ne=G.ownerDocument.importNode(V,!0),ne.nodeType===Lc.element&&ne.nodeName==="BODY"||ne.nodeName==="HTML"?G=ne:G.appendChild(ne);else{if(!it&&!We&&!bt&&V.indexOf("<")===-1)return x&&yi?x.createHTML(V):V;if(G=ks(V),!G)return it?null:yi?T:""}G&&pe&&hi(G.firstChild);const st=ct(di?V:G);for(;Te=st.nextNode();)zr(Te),sn(Te),Te.content instanceof r&&L(Te.content);if(di)return V;if(it){if(si)for(It=H.call(G.ownerDocument);G.firstChild;)It.appendChild(G.firstChild);else It=G;return(xe.shadowroot||xe.shadowrootmode)&&(It=re.call(n,It,!0)),It}let Je=bt?G.outerHTML:G.innerHTML;return bt&&J["!doctype"]&&G.ownerDocument&&G.ownerDocument.doctype&&G.ownerDocument.doctype.name&&an(CI,G.ownerDocument.doctype.name)&&(Je="<!DOCTYPE "+G.ownerDocument.doctype.name+`>
`+Je),We&&eh([de,se,R],vi=>{Je=kc(Je,vi," ")}),x&&yi?x.createHTML(Je):Je},e.setConfig=function(){let V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};er(V),Vt=!0},e.clearConfig=function(){Jn=null,Vt=!1},e.isValidAttribute=function(V,C,G){Jn||er({});const ne=At(V),Te=At(C);return tr(ne,Te,G)},e.addHook=function(V,C){typeof C=="function"&&Tc(D[V],C)},e.removeHook=function(V,C){if(C!==void 0){const G=XQ(D[V],C);return G===-1?void 0:KQ(D[V],G,1)[0]}return oS(D[V])},e.removeHooks=function(V){D[V]=[]},e.removeAllHooks=function(){D=hS()},e}var fJ=TI();const pJ={content:"",bindTo:void 0,placement:"top",offset:[0,8],hidden:!0};var mJ=".style_module_popup__d19738e9{box-shadow:0 2px 8px rgba(0,0,0,.15);opacity:0;pointer-events:auto;position:absolute;transition:opacity .15s ease,visibility .15s ease;visibility:hidden;z-index:1}.style_module_visible__d19738e9{opacity:1;transition:opacity .4s ease,visibility .4s ease;visibility:visible}",cg={popup:"style_module_popup__d19738e9",visible:"style_module_visible__d19738e9"};Dr(mJ,{});let gJ=class{constructor(e,t){b(this,"_internalApi");b(this,"_config");b(this,"_popupContent");b(this,"_popupElement");b(this,"_isVisible",!1);b(this,"_lastBindId");b(this,"_lastBindIndex");b(this,"_initialize",()=>{this._popupElement=this._internalApi.popupElement,this._initializePopupContent(),requestAnimationFrame(()=>this.setConfig(this._config)),this._internalApi.addEventListener("onSimulationTick",this._render),this._internalApi.addEventListener("onZoom",this._render),this._internalApi.addEventListener("onDrag",this._render),this._internalApi.addEventListener("reset",this._reset),this._internalApi.addEventListener("graphRebuilt",this._reset)});b(this,"_initializePopupContent",()=>{this._popupContent||(this._popupContent=document.createElement("div"),this._popupContent.classList.add(cg.popup),this._popupElement.appendChild(this._popupContent))});b(this,"_updatePosition",()=>{const{bindTo:e}=this._config;this._internalApi.cosmosInitialized&&e!==void 0&&(typeof e=="number"?this._showOnPointIndex(e):typeof e=="string"?this._showOnPointId(e):Array.isArray(e)&&this._showAt(e))});b(this,"_render",()=>{this._isVisible&&this._updatePosition()});b(this,"_removePopupContent",()=>{var e;this._isVisible=!1,(e=this._popupContent)==null||e.remove(),this._popupContent=void 0});b(this,"_reset",()=>{this._lastBindId=void 0,this._lastBindIndex=void 0,this._render()});b(this,"remove",()=>{this._lastBindId=void 0,this._lastBindIndex=void 0,this._internalApi.removeEventListener("onSimulationTick",this._render),this._internalApi.removeEventListener("onZoom",this._render),this._internalApi.removeEventListener("onDrag",this._render),this._internalApi.removeEventListener("reset",this._reset),this._internalApi.removeEventListener("graphRebuilt",this._reset),this.hide(),this._popupContent&&this._popupContent.addEventListener("transitionend",()=>this._removePopupContent(),{once:!0})});this._internalApi=La(e),this._config={...pJ,...t},this._initialize()}_showAt(e){var h,p;const t=fJ.sanitize(this._config.content??"",{USE_PROFILES:{html:!0}});if(!this._popupContent)return;this._popupContent.innerHTML=t,this._popupContent.style.display="block";const{placement:n="bottom",offset:s=[0,8]}=this._config,r=(h=this._popupContent)==null?void 0:h.offsetWidth,o=(p=this._popupContent)==null?void 0:p.offsetHeight,a=this._internalApi.public.spaceToScreenPosition(e);if(!a)return this._removePopupContent();const[l,c]=a,u=l-r/2+s[0],d=n==="bottom"?c+s[1]:c-o-s[1];this._popupContent.style.left=`${u}px`,this._popupContent.style.top=`${d}px`,this._popupContent.style.display="block"}_showOnPointIndex(e){const{placement:t}=this._config;this._internalApi.configManager.configUpdated().then(async()=>{const n=this._internalApi.public.getPointPositionByIndex(e);if(!n)return this._removePopupContent();const[s,r]=n;if(s==null||r==null)return this._removePopupContent();const o=this._internalApi.public.getPointScreenRadiusByIndex(e)/2/this._internalApi.public.getZoomLevel(),a=r+(t==="bottom"?-o:o);this._showAt([s,a])})}_showOnPointId(e){this._lastBindId!==e||this._lastBindIndex===void 0?this._internalApi.configManager.cosmosInitialized().then(async()=>{const t=await this._internalApi.public.getPointIndicesByIds([e]);if(!t||t[0]===void 0)return this._removePopupContent();const n=t[0];this._lastBindId=e,this._lastBindIndex=n,this._showOnPointIndex(n)}):this._showOnPointIndex(this._lastBindIndex)}setConfig(e){this._config={...this._config,...e},this._config.hidden||this._updatePosition(),(e==null?void 0:e.hidden)!==void 0&&(this._config.hidden?this.hide():this._config.hidden||this.show())}hide(){var e;this._isVisible&&(this._isVisible=!1,(e=this._popupContent)==null||e.classList.remove(cg.visible))}show(){var e;this._isVisible||(this._isVisible=!0,(e=this._popupContent)==null||e.classList.add(cg.visible))}};const _J={useLinksData:!1,hideWhenSizeMoreThan:120,selectOnClick:!0,useQuantiles:!0,minSubLabel:"and less",maxSubLabel:"and more"};var yJ=".style_module_selected__91af67ac{filter:brightness(1.2)}.style_module_unselected__91af67ac{filter:brightness(.5);opacity:.7}",Lo={selected:"style_module_selected__91af67ac",unselected:"style_module_unselected__91af67ac"};Dr(yJ,{});class bJ extends Vp{constructor(){super(...arguments);b(this,"_uiComponentConfig",{});b(this,"_extent");b(this,"_manuallyHidden",!1);b(this,"_originalMaxValue",0);b(this,"_pointSizeScaleUpdateHandler");b(this,"_linkWidthScaleUpdateHandler");b(this,"_pointSizeUpdateHandler");b(this,"_linkWidthUpdateHandler");b(this,"_currentSizeAccessor");b(this,"_currentExtent");b(this,"_remapValues",async t=>{const n=await this._getMappingFunction();return n?t.map(s=>+n(s)):t});b(this,"_getExtentAndRange",async()=>{const t=await this._calculateExtent();return!t||isNaN(t==null?void 0:t[0])||isNaN(t==null?void 0:t[1])?{extent:void 0,range:void 0}:{extent:t,range:await this._calculateRange(t)}});b(this,"_onSizeScaleUpdated",async()=>{await this._updateLegend()});b(this,"_onSizeUpdated",async()=>{var t;await this._internalApi.configManager.configUpdated(),this._currentExtent=this._uiComponentConfig.extentLabels,this._currentSizeAccessor!==this.accessor?await this.fetchData():await this._updateExtents(),await this._updateLegend(),Pu(this._currentExtent,this._uiComponentConfig.extentLabels)||((t=this._client)==null||t.resetFilter(),this.onResetClientSelections())})}get _isLinkAggregateStrategy(){const t=this._internalApi.public.activeLinkWidthStrategy;return!!this._config.useLinksData&&[Tt.Count,Tt.Sum,Tt.Average].includes(t)}get _isPointDegreeStrategy(){const t=this._internalApi.public.activePointSizeStrategy;return!this._config.useLinksData&&[Kt.Degree,Kt.PreciseDegree].includes(t)}get domain(){var n;const t=(n=this._currentData)==null?void 0:n.toArray()[0];return this._currentData?[t.min,t.max]:void 0}get defaultConfig(){return _J}get accessor(){const{linkWidthBy:t,pointSizeBy:n,pointIndexBy:s}=this._internalApi.config,r=this._isPointDegreeStrategy?s:n,o=t;return this._config.useLinksData?o:r}get _hasClickableEvents(){const{onClick:t,onMaxClick:n,onMinClick:s,overrideExtent:r}=this._config;return!r||t!==void 0||n!==void 0||s!==void 0}onInitialize(){this._pointSizeScaleUpdateHandler=async()=>{this._config.useLinksData||await this._onSizeScaleUpdated()},this._linkWidthScaleUpdateHandler=async()=>{this._config.useLinksData&&await this._onSizeScaleUpdated()},this._pointSizeUpdateHandler=async()=>{this._config.useLinksData||await this._onSizeUpdated()},this._linkWidthUpdateHandler=async()=>{this._config.useLinksData&&await this._onSizeUpdated()},this._internalApi.addEventListener("pointSizeScaleUpdated",this._pointSizeScaleUpdateHandler),this._internalApi.addEventListener("linkWidthScaleUpdated",this._linkWidthScaleUpdateHandler),this._internalApi.addEventListener("pointSizeUpdated",this._pointSizeUpdateHandler),this._internalApi.addEventListener("linkWidthUpdated",this._linkWidthUpdateHandler)}createUIComponent(t){return new VK(t,this.createComponentConfig(this._config))}createComponentConfig(t){return{...t,onClick:n=>{var s,r;(r=(s=this._config).onClick)==null||r.call(s,n)},onHover:n=>{var s,r;(r=(s=this._config).onHover)==null||r.call(s,n)},onMaxClick:(n,s,r)=>{var o,a;(a=(o=this._config).onMaxClick)==null||a.call(o,n,s,r),this._hasClickableEvents&&this.onSelect("max")},onMinClick:(n,s,r)=>{var o,a;(a=(o=this._config).onMinClick)==null||a.call(o,n,s,r),this._hasClickableEvents&&this.onSelect("min")}}}compareSelectedItem(t){return this.selected===t}setSelectedItem(t){var n;if((n=this._uiComponent)!=null&&n.sizeElements)if(t){const s=t,r=t==="min"?"max":"min";this._uiComponent.sizeElements[s].classList.remove(Lo.unselected),this._uiComponent.sizeElements[s].classList.add(Lo.selected),this._uiComponent.sizeElements[r].classList.remove(Lo.selected),this._uiComponent.sizeElements[r].classList.add(Lo.unselected)}else this._uiComponent.sizeElements.min.classList.remove(Lo.selected,Lo.unselected),this._uiComponent.sizeElements.max.classList.remove(Lo.selected,Lo.unselected)}_filterPointsByDegree(t,n){if(!this._isPointDegreeStrategy)return;const{public:{pointDegrees:s}}=this._internalApi;return t!==void 0&&(s!=null&&s.length)?Rv(s,t,n):void 0}applyFilter(t){var n,s,r,o,a,l,c,u,d,h,p,m;if(t==="min")if(this._isPointDegreeStrategy){const y=this._filterPointsByDegree((n=this._extent)==null?void 0:n[0],(g,_)=>g<=_);(s=this._client)==null||s.applyInFilter(y)}else if(this._isLinkAggregateStrategy){const y=this._createLinkAggregatePredicate((r=this._extent)==null?void 0:r[0],"min");(o=this._client)==null||o.applyFilter(y)}else(l=this._client)==null||l.applyLessOrEqFilter((a=this._extent)==null?void 0:a[0]);else if(this._isPointDegreeStrategy){const y=this._filterPointsByDegree((c=this._extent)==null?void 0:c[1],(g,_)=>g>=_);(u=this._client)==null||u.applyInFilter(y)}else if(this._isLinkAggregateStrategy){const y=this._createLinkAggregatePredicate((d=this._extent)==null?void 0:d[1],"max");(h=this._client)==null||h.applyFilter(y)}else(m=this._client)==null||m.applyGreaterOrEqFilter((p=this._extent)==null?void 0:p[1])}async getCurrentData(){await this._internalApi.configManager.configUpdated();const{summary:{linksSummary:t,pointsSummary:n}}=this._internalApi,s=this._config.useLinksData?t:n,r=s==null?void 0:s.find(o=>o.column_name===this.accessor);if(r)return this._config.useQuantiles?await this._getQuantiledExtentDataForColumn():Ek({min:[Number(r.min)],max:[Number(r.max)]})}async fetchData(){var n;this._currentSizeAccessor=this.accessor,this.onResetClientSelections();const{public:{activeLinkWidthStrategy:t}}=this._internalApi;this._config.useLinksData&&t===Tt.Count?(this._isValidAccessor=!0,this._currentData=void 0,(n=this._client)==null||n.setActive(!0)):await super.fetchData(),await this._updateExtents(),this._uiComponentConfig.extent===void 0&&this._uiComponent.showState()}async onConfigUpdate(){this._manuallyHidden=!!this._config.hidden,await this._updateLegend()}async shouldUpdateComponentData(){return!this._currentSizeAccessor||(await this._internalApi.configManager.configUpdated(),this._currentSizeAccessor!==this.accessor)}_getPointsDegreeExtent(){const{public:{activePointSizeStrategy:t,pointDegrees:n}}=this._internalApi;if(!(n!=null&&n.length))return[0,0];if(t===Kt.Degree)return Uu(n,yl);const[s,r]=Rn(n);return yl(s,r)}async _getQuantiledExtentDataForColumn(){const t=`
        SELECT 
          quantile("${this.accessor}", ${ad}) as min,
          quantile("${this.accessor}", ${od}) as max
        FROM ${this.tableName}
      `;return await this._internalApi.dbCoordinator.query(t)}_calculateExtent(){const{public:{activeLinkWidthStrategy:t}}=this._internalApi,n=t===Tt.Count;if(!this._config.useLinksData)return this._isPointDegreeStrategy?this._getPointsDegreeExtent():this.domain;if(this._isLinkAggregateStrategy){if(!n&&!this.accessor)return;const{linkAggregationManager:{countCache:s,widthSumCache:r}}=this._internalApi;if(!s||s.size===0)return this.domain;const o=Array.from(s.entries(),([a,l])=>{if(n)return l;if(t===Tt.Sum)return(r==null?void 0:r.get(a))??0;{const c=(r==null?void 0:r.get(a))??0;return l>0?c/l:0}});return Uu(o,n?yl:void 0)}return this.domain}async _calculateRange(t){const{config:n,public:{activePointSizeStrategy:s}}=this._internalApi;return this._config.useLinksData||n.pointSizeByFn&&s!==Kt.Auto&&!this._isPointDegreeStrategy?await this._remapValues(t):s===Kt.Direct?t:n.pointSizeRange||cu}async _updateExtents(){const{public:{activePointSizeStrategy:t,activeLinkWidthStrategy:n}}=this._internalApi;if(!this._isValidAccessor||!this.useLinksData&&t===Kt.Single||this.useLinksData&&n===Tt.Single)this._uiComponentConfig.extent=void 0;else if(this._config.overrideExtent)this._uiComponentConfig.extent=this._config.overrideExtent,this._uiComponentConfig.extentLabels=this._config.overrideExtent;else{const{extent:s,range:r}=await this._getExtentAndRange();(s||s&&this._isPointDegreeStrategy&&(s[0]!==0||s[1]!==0))&&r?(this._originalMaxValue=s[1],this._extent=s,this._uiComponentConfig.extent=r[0]<0?[0,r[1]]:r,this._uiComponentConfig.extentLabels=this._config.extentLabels??[s[0],s[1]]):this._uiComponentConfig.extent=void 0}}async _updateLegend(){await this._updateSizeMultiplier(),this._updateLegendVisibility(),this._checkEvents(),this._updateLabels(),this._uiComponentConfig.form=this._config.useLinksData?"line":"point",this._uiComponent.setConfig(this.createComponentConfig({...this._config,...this._uiComponentConfig}))}_updateLabels(){const{showSublabels:t,useQuantiles:n}=this._config,{public:{activePointSizeStrategy:s}}=this._internalApi,r=this._getLabelValue();this._uiComponentConfig.label=r,this._uiComponentConfig.showSublabels=t??(this._isPointDegreeStrategy?s===Kt.Degree:n)}_checkEvents(){const{enableEvents:t,overrideExtent:n,onHover:s}=this._config;let r=t??!0;n&&(r=t??(this._hasClickableEvents||s!==void 0)),this._uiComponentConfig.enableEvents=r}_updateLegendVisibility(){const{extent:t,sizeMultiplier:n}=this._uiComponentConfig,{hideWhenSizeMoreThan:s}=this._config;let r=this._manuallyHidden;if(!r&&t){const o=n?n*t[1]:t[1];s&&s<o&&(r=!0)}this._uiComponentConfig.hidden=r}async _updateSizeMultiplier(){const{config:t}=this._internalApi,n=this._internalApi.public.getZoomLevel()??1,s=this._config.useLinksData?t.scaleLinksOnZoom:t.scalePointsOnZoom,r=this._config.useLinksData?t.linkWidthScale??1:t.pointSizeScale??1;this._uiComponentConfig.sizeMultiplier=s?r*n:r,s&&await this._updateMaxLabel()}async _updateMaxLabel(){const{config:t,public:{maxPointSize:n}}=this._internalApi,{extentLabels:s,sizeMultiplier:r}=this._uiComponentConfig;if(t.pointSizeByFn&&s&&!this._uiComponent.isHidden&&r){const o=await this._calcVisibleMaxLabel(n/r,s[0],this._originalMaxValue);this._uiComponentConfig.extentLabels=[s[0],o]}}async _calcVisibleMaxLabel(t,n,s){const r=await this._getMappingFunction();if(r){const o=t/r(1),a=Math.min(Math.abs(s),Math.max(Math.abs(n),Math.abs(o))),l=Math.sign(s)*a;let c=0;const u=Math.abs(l);return u>0&&(c=u<.001?6:u<.01?4:u<.1?3:u<1?2:u<10?1:0),Number(l.toFixed(c))}return 0}_getLabelValue(){const{useLinksData:t,overrideExtent:n}=this._config,{public:{activeLinkWidthStrategy:s}}=this._internalApi;if(this._isLinkAggregateStrategy)return s===Tt.Count?"count":s===Tt.Sum?`sum by ${this.accessor}`:s===Tt.Average?`average by ${this.accessor}`:this.accessor;if(!n&&!t&&this._isPointDegreeStrategy)return"connections count";const r=this._config.labelResolver;return r&&typeof r=="function"?r(this.accessor):r??this.accessor}async _getMappingFunction(){return this._config.useLinksData?await this._internalApi.public.getActiveLinkWidthFn():await this._internalApi.public.getActivePointSizeFn()}_createLinkAggregatePredicate(t,n){if(t===void 0)return;const{public:{activeLinkWidthStrategy:s}}=this._internalApi,{linkSourceIndexBy:r,linkTargetIndexBy:o,linkWidthBy:a}=this._internalApi.config;if(!r||!o)return;let l,c;switch(s){case Tt.Count:l=lb();break;case Tt.Sum:if(!a)return;l=gi(a);break;case Tt.Average:if(!a)return;l=q3(a);break;default:return}c=n==="min"?ub(l,An(t)):db(l,An(t));const u=Ai.from(this.tableName).select(r,o).groupby(r,o).having(c);return qu`(${cn(r)}, ${cn(o)}) IN (${u})`}hide(){this._manuallyHidden=!0,this.checkReady(()=>this.hide())&&this._uiComponent.hide()}show(){this._manuallyHidden=!1,this.checkReady(()=>this.show())&&this._uiComponent.show()}remove(){this._internalApi.removeEventListener("pointSizeScaleUpdated",this._pointSizeScaleUpdateHandler),this._internalApi.removeEventListener("linkWidthScaleUpdated",this._linkWidthScaleUpdateHandler),this._internalApi.removeEventListener("pointSizeUpdated",this._pointSizeUpdateHandler),this._internalApi.removeEventListener("linkWidthUpdated",this._linkWidthUpdateHandler),super.remove()}}const vJ={useLinksData:!1,selectOnClick:!0,steps:10,overrideColors:void 0,useQuantiles:!0,useDiscreteColors:!1,minSubLabel:"and less",maxSubLabel:"and more"};var xJ=".style_module_selected__12a865d0{filter:brightness(1.2)}.style_module_unselected__12a865d0{filter:brightness(.5);opacity:.7}",Ro={selected:"style_module_selected__12a865d0",unselected:"style_module_unselected__12a865d0"};Dr(xJ,{});class wJ extends Vp{constructor(){super(...arguments);b(this,"_uiComponentConfig",{});b(this,"_linkColorUpdateHandler");b(this,"_pointColorUpdateHandler");b(this,"_extent");b(this,"_currentColorAccessor");b(this,"_currentExtent");b(this,"_remapValues",async t=>{if(!t)return;const[n,s]=t,r=await this._getMappingFunction();return r?Array.from({length:this._config.steps},(o,a)=>{const l=n+a/(this._config.steps-1)*(s-n);return r(l)}):void 0});b(this,"_getExtentAndRange",async()=>{const t=await this._calculateExtent();return!t||isNaN(t==null?void 0:t[0])||isNaN(t==null?void 0:t[1])?{extent:void 0,range:void 0}:{extent:t,range:await this._calculateRange(t)}})}get _isLinkAggregateStrategy(){const t=this._internalApi.public.activeLinkColorStrategy;return!!this._config.useLinksData&&[ut.Count,ut.Sum,ut.Average].includes(t)}get _isPointDegreeStrategy(){const t=this._internalApi.public.activePointColorStrategy;return!this._config.useLinksData&&[Ye.Degree,Ye.PreciseDegree].includes(t)}get domain(){var n;const t=(n=this._currentData)==null?void 0:n.toArray()[0];return this._currentData?[t.min,t.max]:void 0}get defaultConfig(){return vJ}get accessor(){const{linkColorBy:t,pointColorBy:n,pointIndexBy:s}=this._internalApi.config,r=this._isPointDegreeStrategy?s:n,o=t;return this._config.useLinksData?o:r}get _hasClickableEvents(){const{onClick:t,onMaxClick:n,onMinClick:s,overrideColors:r}=this._config;return!r||t!==void 0||n!==void 0||s!==void 0}onInitialize(){this._linkColorUpdateHandler=async()=>{this._config.useLinksData&&await this._onColorUpdated()},this._pointColorUpdateHandler=async()=>{this._config.useLinksData||await this._onColorUpdated()},this._internalApi.addEventListener("pointColorUpdated",this._pointColorUpdateHandler),this._internalApi.addEventListener("linkColorUpdated",this._linkColorUpdateHandler)}createUIComponent(t){return new QK(t,this.createComponentConfig(this._config))}createComponentConfig(t){return{...t,onClick:n=>{var s,r;(r=(s=this._config).onClick)==null||r.call(s,n)},onHover:n=>{var s,r;(r=(s=this._config).onHover)==null||r.call(s,n)},onMaxClick:(n,s,r)=>{var o,a;(a=(o=this._config).onMaxClick)==null||a.call(o,n,s,r),this._hasClickableEvents&&this.onSelect("max")},onMinClick:(n,s,r)=>{var o,a;(a=(o=this._config).onMinClick)==null||a.call(o,n,s,r),this._hasClickableEvents&&this.onSelect("min")}}}compareSelectedItem(t){return this.selected===t}setSelectedItem(t){var n,s,r,o,a,l;if(t){const c=t,u=t==="min"?"max":"min";(n=this._uiComponent.extentElements)==null||n[c].classList.remove(Ro.unselected),(s=this._uiComponent.extentElements)==null||s[c].classList.add(Ro.selected),(r=this._uiComponent.extentElements)==null||r[u].classList.remove(Ro.selected),(o=this._uiComponent.extentElements)==null||o[u].classList.add(Ro.unselected)}else(a=this._uiComponent.extentElements)==null||a.min.classList.remove(Ro.selected,Ro.unselected),(l=this._uiComponent.extentElements)==null||l.max.classList.remove(Ro.selected,Ro.unselected)}_filterPointsByDegree(t,n){if(!this._isPointDegreeStrategy)return;const{public:{pointDegrees:s}}=this._internalApi;return t!==void 0&&(s!=null&&s.length)?Rv(s,t,n):void 0}applyFilter(t){var n,s,r,o,a,l,c,u,d,h,p,m;if(t==="min")if(this._isPointDegreeStrategy){const y=this._filterPointsByDegree((n=this._extent)==null?void 0:n[0],(g,_)=>g<=_);(s=this._client)==null||s.applyInFilter(y)}else if(this._isLinkAggregateStrategy){const y=this._createLinkAggregatePredicate((r=this._extent)==null?void 0:r[0],"min");(o=this._client)==null||o.applyFilter(y)}else(l=this._client)==null||l.applyLessOrEqFilter((a=this._extent)==null?void 0:a[0]);else if(this._isPointDegreeStrategy){const y=this._filterPointsByDegree((c=this._extent)==null?void 0:c[1],(g,_)=>g>=_);(u=this._client)==null||u.applyInFilter(y)}else if(this._isLinkAggregateStrategy){const y=this._createLinkAggregatePredicate((d=this._extent)==null?void 0:d[1],"max");(h=this._client)==null||h.applyFilter(y)}else(m=this._client)==null||m.applyGreaterOrEqFilter((p=this._extent)==null?void 0:p[1])}async getCurrentData(){await this._internalApi.configManager.configUpdated();const{summary:{linksSummary:t,pointsSummary:n}}=this._internalApi,s=this._config.useLinksData?t:n,r=s==null?void 0:s.find(o=>o.column_name===this.accessor);if(r)return this._config.useQuantiles?await this._getQuantiledExtentDataForColumn():Ek({min:[Number(r.min)],max:[Number(r.max)]})}async fetchData(){var t;this._currentColorAccessor=(t=this.accessor)==null?void 0:t.toString(),this.onResetClientSelections(),await super.fetchData(),await this._updateExtents(),this._uiComponentConfig.extent===void 0&&this._uiComponent.showState()}async onConfigUpdate(){await this._updateLegend()}async shouldUpdateComponentData(){return!this._currentColorAccessor||(await this._internalApi.configManager.configUpdated(),this._currentColorAccessor!==this.accessor)}_createLinkAggregatePredicate(t,n){if(t===void 0)return;const{public:{activeLinkColorStrategy:s}}=this._internalApi,{linkSourceIndexBy:r,linkTargetIndexBy:o,linkColorBy:a}=this._internalApi.config;if(!r||!o)return;let l,c;switch(s){case ut.Count:l=lb();break;case ut.Sum:if(!a)return;l=gi(a);break;case ut.Average:if(!a)return;l=q3(a);break;default:return}c=n==="min"?ub(l,An(t)):db(l,An(t));const u=Ai.from(this.tableName).select(r,o).groupby(r,o).having(c);return qu`(${cn(r)}, ${cn(o)}) IN (${u})`}async _onColorUpdated(){var t;await this._internalApi.configManager.configUpdated(),this._currentExtent=this._uiComponentConfig.extentLabels,this._currentColorAccessor!==this.accessor?await this.fetchData():await this._updateExtents(),await this._updateLegend(),Pu(this._currentExtent,this._uiComponentConfig.extentLabels)||((t=this._client)==null||t.resetFilter(),this.onResetClientSelections())}_getPointsDegreeExtent(){const{public:{activePointColorStrategy:t,pointDegrees:n}}=this._internalApi;if(!(n!=null&&n.length))return[0,0];if(t===Ye.Degree)return Uu(n,yl);const[s,r]=Rn(n);return yl(s,r)}async _getQuantiledExtentDataForColumn(){const t=`
        SELECT 
          quantile("${this.accessor}", ${ad}) as min,
          quantile("${this.accessor}", ${od}) as max
        FROM ${this.tableName}
      `;return await this._internalApi.dbCoordinator.query(t)}_calculateExtent(){const{public:{activeLinkColorStrategy:t}}=this._internalApi,n=t===ut.Count;if(!this._config.useLinksData)return this._isPointDegreeStrategy?this._getPointsDegreeExtent():this.domain;if(this._isLinkAggregateStrategy){if(!this.accessor)return;const{linkAggregationManager:{countCache:s,colorSumCache:r}}=this._internalApi;if(!s||s.size===0)return this.domain;const o=Array.from(s.entries(),([a,l])=>{if(n)return l;if(t===ut.Sum)return(r==null?void 0:r.get(a))??0;{const c=(r==null?void 0:r.get(a))??0;return l>0?c/l:0}});return Uu(o,n?yl:void 0)}return this.domain}async _calculateRange(t){const{public:{activePointColorStrategy:n}}=this._internalApi;if(this._config.useLinksData||n!==Ye.Map&&n!==Ye.LinkDirection)return await this._remapValues(t);this._uiComponent.showState()}async _getMappingFunction(){return this._config.useLinksData?await this._internalApi.public.getActiveLinkColorFn():await this._internalApi.public.getActivePointColorFn()}async _updateExtents(){const{public:{activePointColorStrategy:t,activeLinkColorStrategy:n}}=this._internalApi;if(!this._isValidAccessor||!this.useLinksData&&t===Ye.Single||this.useLinksData&&n===ut.Single)this._uiComponentConfig.extent=void 0;else if(this._config.overrideColors)this._uiComponentConfig.extent=this._config.overrideColors,this._uiComponentConfig.extentLabels=this._config.extentLabels;else{const{extent:s,range:r}=await this._getExtentAndRange();s||s&&this._isPointDegreeStrategy&&(s[0]!==0||s[1]!==0)?(this._extent=s,this._uiComponentConfig.extent=r,this._uiComponentConfig.extentLabels=this._config.extentLabels??[s[0],s[1]]):this._uiComponentConfig.extent=void 0}}_checkEvents(){const{enableEvents:t,overrideColors:n,onHover:s}=this._config;let r=t??!0;n&&(r=t??(this._hasClickableEvents||s!==void 0)),this._uiComponentConfig.enableEvents=r}_updateLabels(){const{showSublabels:t,useQuantiles:n}=this._config,{public:{activePointColorStrategy:s}}=this._internalApi;this._uiComponentConfig.label=this._getLabelValue(),this._uiComponentConfig.showSublabels=t??(this._isPointDegreeStrategy?s===Ye.Degree:n)}async _updateLegend(){const{public:{activePointColorStrategy:t,activeLinkColorStrategy:n}}=this._internalApi,{overrideColors:s,useDiscreteColors:r}=this._config,o=this._config.useLinksData?n===ut.Categorical:t===Ye.Categorical;this._uiComponentConfig.discreteColors=s?r:o,this._checkEvents(),this._updateLabels(),this._uiComponent.setConfig(this.createComponentConfig({...this._config,...this._uiComponentConfig}))}_getLabelValue(){const{useLinksData:t,overrideColors:n}=this._config,{public:{activeLinkColorStrategy:s}}=this._internalApi;if(this._isLinkAggregateStrategy)return s===ut.Count?"count":s===ut.Sum?`sum by ${this.accessor}`:s===ut.Average?`average by ${this.accessor}`:this.accessor;if(!n&&!t&&this._isPointDegreeStrategy)return"connections count";const r=this._config.labelResolver;return r&&typeof r=="function"?r(this.accessor):r??this.accessor}hide(){this.checkReady(()=>this.hide())&&this._uiComponent.hide()}show(){this.checkReady(()=>this.show())&&this._uiComponent.show()}remove(){this._internalApi.removeEventListener("pointColorUpdated",this._pointColorUpdateHandler),this._internalApi.removeEventListener("linkColorUpdated",this._linkColorUpdateHandler),super.remove()}}const kI={0:"source",1:"source+target",2:"target",3:"not linked"},SJ=Object.fromEntries(Object.entries(kI).map(([i,e])=>[e,i])),EJ={useLinksData:!1,selectOnClick:!0,hideUnknown:!0,resetSelectionOnCollapse:!0,showLabel:!1};class CJ extends Vp{constructor(){super(...arguments);b(this,"_uiComponentConfig",{});b(this,"_linkColorUpdateHandler");b(this,"_pointColorUpdateHandler");b(this,"_currentColorAccessor");b(this,"_fetchDataPromise",null);b(this,"_onColorUpdated",async()=>{this._fetchDataPromise&&await this._fetchDataPromise,await this._internalApi.configManager.configUpdated(),this._currentColorAccessor!==this.accessor?await this.fetchData():await this._updateItems(),await this._updateLegend()})}get _summary(){const{summary:{linksSummary:t,pointsSummary:n}}=this._internalApi;return this._config.useLinksData?t:n}get _isLinkDirectionStrategy(){return!this.useLinksData&&this._internalApi.public.activePointColorStrategy===Ye.LinkDirection}get defaultConfig(){return EJ}get accessor(){const{linkColorBy:t,pointColorBy:n,pointIndexBy:s}=this._internalApi.config;return this._config.useLinksData?t:this._isLinkDirectionStrategy?s:n}get _hasClickableEvents(){const{onClick:t,overrideItems:n}=this._config;return!n||t!==void 0}onInitialize(){this._linkColorUpdateHandler=async()=>{this._config.useLinksData&&await this._onColorUpdated()},this._pointColorUpdateHandler=async()=>{this._config.useLinksData||await this._onColorUpdated()},this._internalApi.addEventListener("pointColorUpdated",this._pointColorUpdateHandler),this._internalApi.addEventListener("linkColorUpdated",this._linkColorUpdateHandler)}createUIComponent(t){return new lZ(t,this.createComponentConfig(this._config))}createComponentConfig(t){return{...t,onClick:(n,s)=>{var r,o;(o=(r=this._config).onClick)==null||o.call(r,n,s),this._hasClickableEvents&&this.onSelect(s)},onHover:(n,s)=>{var r,o;(o=(r=this._config).onHover)==null||o.call(r,n,s)},onShowMoreClick:n=>{var s,r;(r=(s=this._config).onShowMoreClick)==null||r.call(s,n),this._config.resetSelectionOnCollapse&&this.selected&&!n&&this.onSelect(void 0)}}}compareSelectedItem(t){var n;return((n=this.selected)==null?void 0:n.label)===(t==null?void 0:t.label)}setSelectedItem(t){this._uiComponent.setSelectedItem(t)}applyFilter(t){var n,s;if(this._isLinkDirectionStrategy){if(!t)return;const r=Number(SJ[t.label]),o=this._internalApi.public.pointDirections;if(!o)return;const a=Rv(o,r,(l,c)=>l===c);(n=this._client)==null||n.applyInFilter(a)}else(s=this._client)==null||s.applyExactFilter(t==null?void 0:t.label)}async fetchData(){return this._fetchDataPromise&&await this._fetchDataPromise,this._fetchDataPromise=(async()=>{var t;try{this._currentColorAccessor=(t=this.accessor)==null?void 0:t.toString(),await super.fetchData(),await this._updateItems(),this.onResetClientSelections()}finally{this._fetchDataPromise=null}})(),this._fetchDataPromise}async onConfigUpdate(){await this._updateLegend()}async getCurrentData(){var n;if(await this._internalApi.configManager.configUpdated(),((n=this._summary)==null?void 0:n.find(s=>s.column_name===this.accessor))&&this._summary)return await this._getDistinctValues(this._summary)}async shouldUpdateComponentData(){return!this._currentColorAccessor||(await this._internalApi.configManager.configUpdated(),this._currentColorAccessor!==this.accessor)}async _getDistinctValues(t){var a;const{public:{activePointColorStrategy:n}}=this._internalApi;let s="DESC";!this.useLinksData&&[Ye.Continuous,Ye.Categorical].includes(n)&&(s=this._config.sortOrder??"DESC");const r=`ORDER BY "${this._config.sortBy??"count"}" ${s}`,o=(a=t.find(l=>l.column_name===this.accessor))==null?void 0:a.column_type;return await this._internalApi.dbCoordinator.query((l=>l==="VARCHAR"?`SELECT "${this.accessor}", COUNT(*) as count 
                FROM ${this.tableName}
                GROUP BY "${this.accessor}"
                ${r}`:`SELECT DISTINCT "${this.accessor}"
                FROM ${this.tableName}
                ORDER BY "${this.accessor}" ${this._config.sortOrder||s}`)(o))}_checkEvents(){const{enableEvents:t,overrideItems:n,onHover:s}=this._config;let r=t??!0;n&&(r=t??(this._hasClickableEvents||s!==void 0)),this._uiComponentConfig.enableEvents=r}async _updateLegend(){this._checkEvents();const t=this.accessor;if(this._config.showLabel){const n=this._config.labelResolver,s=typeof n=="function"?n(t):n;this._uiComponentConfig.label=s??t}else this._uiComponentConfig.label=void 0;this._uiComponent.setConfig(this.createComponentConfig({...this._config,...this._uiComponentConfig}))}async _updateItems(){var r,o;const{activePointColorStrategy:t,activeLinkColorStrategy:n}=this._internalApi.public,{overrideItems:s}=this._config;if(s)this._uiComponentConfig.items=s;else{if(!this.useLinksData&&t===Ye.LinkDirection){const c=this._internalApi.public.pointDirections;if(c){const u=Array.from(new Set(c)).map(String);this._uiComponentConfig.items=await this._createLegendItems(u)}return}const a=[Ye.Degree,Ye.PreciseDegree,Ye.Single,Ye.Direct].includes(t),l=[ut.Direct,ut.Single].includes(n);if(!this.accessor||!this.useLinksData&&a||this.useLinksData&&l)return this._uiComponentConfig.items=void 0,void this._uiComponent.showState();if((r=this._currentData)!=null&&r.numRows){const c=(o=this._currentData.getChildAt(0))==null?void 0:o.toArray();if(c)return void(this._uiComponentConfig.items=await this._createLegendItems(c))}this._uiComponentConfig.items=void 0}}async _createLegendItems(t){const{public:{activePointColorStrategy:n},config:s}=this._internalApi,r=await this._getMappingFunction();if(r){const o=ao(s==null?void 0:s.unknownColor,tc),a=l=>({color:ao(r(l),o),label:String(l)});if(!this.useLinksData&&n===Ye.LinkDirection)return Array.from(t,l=>({color:ao(r(l),o),label:kI[l]}));if(this.useLinksData||n!==Ye.Map)return Array.from(t,a);{const l=new Set(Object.keys(s.pointColorByMap??{}));return[...Array.from(t.filter(c=>l.has(c)),a),...this._config.hideUnknown?[]:Array.from(t.filter(c=>!l.has(c)),a)]}}return[]}async _getMappingFunction(){return this._config.useLinksData?await this._internalApi.public.getActiveLinkColorFn():await this._internalApi.public.getActivePointColorFn()}show(){this.checkReady(()=>this.show())&&this._uiComponent.show()}hide(){this.checkReady(()=>this.hide())&&this._uiComponent.hide()}remove(){this._internalApi.removeEventListener("pointColorUpdated",this._pointColorUpdateHandler),this._internalApi.removeEventListener("linkColorUpdated",this._linkColorUpdateHandler),super.remove()}}const TJ=`
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="m21 21-6-6m6 6v-4.8m0 4.8h-4.8"/>
  <path d="M3 16.2V21m0 0h4.8M3 21l6-6"/>
  <path d="M21 7.8V3m0 0h-4.8M21 3l-6 6"/>
  <path d="M3 7.8V3m0 0h4.8M3 3l6 6"/>
</svg>
`,kJ={onClick:void 0,iconSvg:TJ,duration:250,padding:.1,description:"Fit view"};let AJ=class{constructor(e,t,n={}){b(this,"_internalApi");b(this,"_config");b(this,"_uiButtonConfig");b(this,"_fitViewButton");b(this,"_handleClick",()=>{var e,t;(t=(e=this._config).onClick)==null||t.call(e),this._internalApi.public.fitView(this._config.duration,this._config.padding)});b(this,"_show",()=>{this._fitViewButton.show()});this._internalApi=La(e),this._fitViewButton=new Ca(t),this._internalApi.addEventListener("graphRebuilt",this._show),this.setConfig(n)}setConfig(e={}){this._config=Yt(kJ,e),this._uiButtonConfig={...this._config,onClick:this._handleClick},this._fitViewButton.setConfig(this._uiButtonConfig)}remove(){this._fitViewButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show)}};const J_=`
<svg width="100%" height="100%" viewBox="0 0 15 18" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
  <path d="M15 9L-8.15666e-07 17.6603L-5.85621e-08 0.339745L15 9Z"/>
</svg>`,IJ=`
<svg width="100%" height="100%" viewBox="0 0 14 18" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
  <path fill-rule="evenodd" clip-rule="evenodd" d="M4.91659 0.666656H0.333252V17.3333H4.91659V0.666656ZM13.6666 0.666656H9.08325V17.3333H13.6666V0.666656Z"/>
</svg>
`,fS={onClick:void 0,iconSvg:J_,description:"Play/Pause"};let LJ=class{constructor(e,t,n={}){b(this,"_internalApi");b(this,"_config",fS);b(this,"_playPauseButton");b(this,"_update",()=>{this._internalApi.cosmos&&(this._internalApi.cosmos.config.enableSimulation===!1?this._playPauseButton.hide():this._playPauseButton.show(),this._config.iconSvg=this._internalApi.public.isSimulationRunning?IJ:J_,this._playPauseButton.setConfig(this._config))});this._internalApi=La(e),this._playPauseButton=new Ca(t,{iconSvg:J_}),this._internalApi.addEventListener("onSimulationEnd",this._update),this._internalApi.addEventListener("onSimulationStart",this._update),this._internalApi.addEventListener("onSimulationPause",this._update),this._internalApi.addEventListener("graphRebuilt",this._update),this.setConfig(n)}setConfig(e={}){this._config=Yt(fS,e),this._config.onClick=()=>{var t;if((t=e==null?void 0:e.onClick)==null||t.call(e),this._internalApi.public.progress!==0||this._internalApi.public.isSimulationRunning)if(this._internalApi.public.isSimulationRunning)this._internalApi.public.pause();else{if(this._internalApi.public.progress===1)return void this._internalApi.public.start();this._internalApi.public.unpause()}else this._internalApi.public.start()},this._update()}remove(){this._playPauseButton.destroy(),this._internalApi.removeEventListener("onSimulationEnd",this._update),this._internalApi.removeEventListener("onSimulationStart",this._update),this._internalApi.removeEventListener("onSimulationPause",this._update),this._internalApi.removeEventListener("graphRebuilt",this._update)}};const RJ=`
<svg width="100%" height="100%" viewBox="0 0 96 96" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-miterlimit:2;">
    <style type="text/css">
        .st0{fill:none;fill-rule:nonzero;stroke:currentColor;stroke-width:8px;}
    </style>
    <g>
        <path d="M92.8,71.003L92.8,83.2L75.058,83.2" class="st0"/>
        <path d="M65.014,83.2L34.968,83.2" class="st0"/>
        <path d="M24.994,83.2L4,83.2L4,71.003" class="st0"/>
        <path d="M4,60.954L4,35.036" class="st0"/>
        <path d="M4,25.06L4,11.8L24.994,11.8" class="st0"/>
        <path d="M34.968,11.8L65.014,11.8" class="st0"/>
        <path d="M75.058,11.8L92.8,11.8L92.8,25.06" class="st0"/>
        <path d="M92.8,35.036L92.8,60.954" class="st0"/>
    </g>
</svg>
`,pS={onClick:void 0,iconSvg:RJ,description:"Rectangle selection"};class PJ{constructor(e,t,n={}){b(this,"_internalApi");b(this,"_config");b(this,"_selectRectButton");b(this,"_rectSelectedHandler");b(this,"_show",()=>{this._selectRectButton.show()});this._internalApi=La(e),this._config=Yt(pS,n),this._config.onClick=()=>{var s;(s=n==null?void 0:n.onClick)==null||s.call(n),this._internalApi.public.activateRectSelection()},this._selectRectButton=new Ca(t,this._config),this._rectSelectedHandler=()=>{this._internalApi.public.deactivateRectSelection()},this._internalApi.addEventListener("graphRebuilt",this._show),this._internalApi.addEventListener("rectSelected",this._rectSelectedHandler)}setConfig(e={}){this._config=Yt(pS,e)}remove(){this._selectRectButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show),this._internalApi.removeEventListener("rectSelected",this._rectSelectedHandler)}}const NJ=`
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" transform="scale(1.15)"><path fill="currentColor" fill-rule="evenodd" d="M21.72.226a1 1 0 0 1 .587.936l-.336 13.583a1 1 0 0 1-.685.924l-8.893 2.948a2.6 2.6 0 0 1-.028.692a2.93 2.93 0 0 1 1.429 1.495c.342.792.33 1.645.198 2.267a1 1 0 0 1-1.956-.417c.07-.328.06-.739-.078-1.056c-.098-.226-.27-.444-.655-.565l-.064.05c-.667.512-1.545.8-2.475.8s-1.808-.288-2.476-.8c-.668-.511-1.165-1.289-1.165-2.224s.497-1.712 1.165-2.224q.232-.178.495-.318L1.782 5.237a1 1 0 0 1 1.092-1.394l11.694 2.146L20.63.402a1 1 0 0 1 1.09-.176m-1.73 13.766l-8.53 2.828a3 3 0 0 0-.22-.185c-.668-.511-1.546-.799-2.476-.799H8.76L4.39 6.154l10.308 1.892a1 1 0 0 0 .859-.248l4.692-4.326zm-12.485 4.23c-.288.22-.382.455-.382.637s.094.416.382.637c.288.22.73.386 1.259.386s.97-.165 1.259-.386c.288-.22.382-.455.382-.637s-.094-.416-.382-.637c-.289-.22-.73-.386-1.26-.386s-.97.165-1.258.386" clip-rule="evenodd"/></svg>
`,mS={onClick:void 0,iconSvg:NJ,description:"Polygonal selection"};class DJ{constructor(e,t,n={}){b(this,"_internalApi");b(this,"_config");b(this,"_selectPolygonButton");b(this,"_polygonSelectedHandler");b(this,"_show",()=>{this._selectPolygonButton.show()});this._internalApi=La(e),this._config=Yt(mS,n),this._config.onClick=()=>{var s;(s=n==null?void 0:n.onClick)==null||s.call(n),this._internalApi.public.activatePolygonalSelection()},this._selectPolygonButton=new Ca(t,this._config),this._polygonSelectedHandler=()=>{this._internalApi.public.deactivatePolygonalSelection()},this._internalApi.addEventListener("graphRebuilt",this._show),this._internalApi.addEventListener("polygonSelected",this._polygonSelectedHandler)}setConfig(e={}){this._config=Yt(mS,e)}remove(){this._selectPolygonButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show),this._internalApi.removeEventListener("polygonSelected",this._polygonSelectedHandler)}}const MJ=`
<svg width="100%" height="100%" viewBox="0 0 24 24" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
  <path d="M4 12H20M12 4V20" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`,BJ=`
<svg width="100%" height="100%" viewBox="0 0 24 24" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
  <path d="M4 12H20" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`,ug={onZoomInClick:void 0,onZoomOutClick:void 0,zoomInIconSvg:MJ,zoomOutIconSvg:BJ,duration:250,zoomIncrement:1.4};var OJ=".style_module_zoomButtons__738b35dc{height:50px;margin:3px;width:25px}.style_module_zoomButton__738b35dc{height:50%;margin:0;width:100%}.style_module_zoomInButton__738b35dc{border-radius:2px 2px 0 0}.style_module_zoomOutButton__738b35dc{border-radius:0 0 2px 2px}",Rc={zoomButtons:"style_module_zoomButtons__738b35dc",zoomButton:"style_module_zoomButton__738b35dc",zoomInButton:"style_module_zoomInButton__738b35dc",zoomOutButton:"style_module_zoomOutButton__738b35dc"};Dr(OJ,{});let FJ=class{constructor(e,t,n){b(this,"_internalApi");b(this,"_config");b(this,"_zoomInButtonConfig");b(this,"_zoomOutButtonConfig");b(this,"_zoomInButton");b(this,"_zoomOutButton");b(this,"_zoomInButtonDiv");b(this,"_zoomOutButtonDiv");b(this,"_show",()=>{this._zoomInButton.show(),this._zoomOutButton.show()});this._internalApi=La(e),t.classList.add(Rc.zoomButtons),this._zoomInButtonDiv=document.createElement("div"),this._zoomInButtonDiv.classList.add(Rc.zoomButton,Rc.zoomInButton),this._zoomOutButtonDiv=document.createElement("div"),this._zoomOutButtonDiv.classList.add(Rc.zoomButton,Rc.zoomOutButton),t.appendChild(this._zoomInButtonDiv),t.appendChild(this._zoomOutButtonDiv),this._zoomInButton=new Ca(this._zoomInButtonDiv),this._zoomOutButton=new Ca(this._zoomOutButtonDiv),this._internalApi.addEventListener("graphRebuilt",this._show),this.setConfig(n??{})}setConfig(e){this._config=Yt(ug,e??{}),this._zoomInButtonConfig={onClick:()=>{var n,s;const t=this._internalApi.public.getZoomLevel();if(t){const r=this._config.zoomIncrement??ug.zoomIncrement;this._internalApi.public.setZoomLevel(t*r,this._config.duration)}(s=(n=this._config).onZoomInClick)==null||s.call(n)},iconSvg:this._config.zoomInIconSvg},this._zoomOutButtonConfig={onClick:()=>{var n,s;const t=this._internalApi.public.getZoomLevel();if(t){const r=this._config.zoomIncrement??ug.zoomIncrement;this._internalApi.public.setZoomLevel(t/r,this._config.duration)}(s=(n=this._config).onZoomOutClick)==null||s.call(n)},iconSvg:this._config.zoomOutIconSvg},this._zoomInButton.setConfig(this._zoomInButtonConfig),this._zoomOutButton.setConfig(this._zoomOutButtonConfig)}remove(){this._zoomInButton.destroy(),this._zoomOutButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show)}};class zJ{constructor(e,t,n={}){b(this,"_button");this._button=new Ca(t,n)}setConfig(e={}){this._button.setConfig(e)}remove(){this._button.destroy()}show(){this._button.show()}hide(){this._button.hide()}}function UJ({style:i,className:e,onMount:t,duckDBConnection:n,...s},r){const o=sy(),a=U.useRef(null),l=U.useRef(),c=U.useRef(!1),u=U.useRef(!1),[d,h]=U.useState(!1);return c.current&&(u.current=!0),U.useEffect(()=>{if(!c.current&&a.current){const p=new NQ(a.current,s,n);l.current=p,c.current=!0,o==null||o.initCosmograph(l.current),h(!0),t&&t(l.current)}return()=>{var p;u.current&&((p=l.current)==null||p.destroy(),h(!1))}},[]),U.useEffect(()=>{(async()=>l.current&&d&&await l.current.setConfig(s))()},[s,d]),U.useImperativeHandle(r,()=>l.current,[d]),un.createElement("div",{style:i,className:e,ref:a})}const gS=un.memo(un.forwardRef(UJ)),AI={display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",opacity:.25,fontSize:12,fontWeight:300,whiteSpace:"pre-wrap"},sp=(i,e,t=new Set)=>{if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;if(t.has(i))return!0;t.add(i);for(let n=0;n<i.length;n++)if(!sp(i[n],e[n],t))return!1;return!0}if(i instanceof Date&&e instanceof Date)return i.getTime()===e.getTime();if(typeof i=="function"&&typeof e=="function")return i.toString()===e.toString();if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object")return!1;if(i===e)return!0;if(Object.keys(i).length!==Object.keys(e).length)return!1;if(t.has(i))return!0;t.add(i);for(const n in i)if(!sp(i[n],e[n],t))return!1;return!0}return i===e};function Kn(i){const e=i.name,t=un.forwardRef((n,s)=>{const r=sy(),o=U.useRef(null),a=U.useRef(),l=U.useRef({}),[c,u]=U.useState(!1);return U.useEffect(()=>{if(o.current&&(r!=null&&r.cosmograph)){const{style:d,className:h,...p}=n;a.current=new i(r.cosmograph,o.current,p),l.current=n,u(!0)}return()=>{var d,h;(h=(d=a.current)==null?void 0:d.remove)==null||h.call(d)}},[r==null?void 0:r.cosmograph]),U.useEffect(()=>{var d,h;if(!sp(n,l.current)){const{style:p,className:m,...y}=n;(h=(d=a.current)==null?void 0:d.setConfig)==null||h.call(d,y),l.current=n}},[n]),U.useImperativeHandle(s,()=>a.current,[c]),r?un.createElement("div",{id:e,style:n.style,className:n.className,ref:o}):un.createElement("div",{style:n.style,className:n.className},un.createElement("div",{style:AI},"⚠️ ",un.createElement("b",null,e)," should be used under ",un.createElement("b",null,"CosmographProvider")))});return t.displayName=e,un.memo(t)}Kn(HQ);Kn(zQ);Kn(UQ);Kn(GQ);const II=un.forwardRef((i,e)=>{const t=sy(),n=U.useRef(),s=U.useRef(i),[r,o]=U.useState(!1);return U.useEffect(()=>(t!=null&&t.cosmograph&&(n.current=new gJ(t.cosmograph,i),s.current=i,o(!0)),()=>{var a;(a=n.current)==null||a.remove()}),[t==null?void 0:t.cosmograph]),U.useEffect(()=>{var a;sp(i,s.current)||((a=n.current)==null||a.setConfig(i),s.current=i)},[i]),U.useImperativeHandle(e,()=>n.current,[r]),t?null:un.createElement("div",{style:AI},"⚠️ ",un.createElement("b",null,"CosmographPopup")," should be used under ",un.createElement("b",null,"CosmographProvider"))});II.displayName="CosmographPopup";un.memo(II);Kn(bJ);Kn(wJ);Kn(CJ);Kn(zJ);Kn(AJ);Kn(LJ);Kn(PJ);Kn(DJ);Kn(FJ);const $J=[{tier:"14d",label:"14 days",description:"Default — good balance of coverage and speed",loadTime:"~5–15 sec"},{tier:"21d",label:"21 days",description:"Extended window — reveals weekly traffic patterns",loadTime:"~10–30 sec"},{tier:"30d",label:"30 days",description:"Full month — robust topology for established meshes",loadTime:"~15–45 sec"},{tier:"90d",label:"90 days",description:"Maximum — pulls all available data, up to 90 days",loadTime:"~30–120 sec"}],al={fetching:0,topology:1,complete:2};function jJ(i,e,t,n,s){let r="fetching";return!e&&!t&&n>s?r="complete":e||(r="topology"),al[r]>al[i]?r:i}const HJ=12e4;function _S({label:i,icon:e,status:t,detail:n}){return f.jsxs("div",{className:oh("flex items-center gap-3 py-3 px-4 radius-inset transition-base",t==="active"&&"bg-sys-blue/15",t==="complete"&&"bg-sys-blue/15 ring-2 ring-inset ring-sys-blue",t==="pending"&&"opacity-40"),children:[f.jsx("div",{className:oh("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",t==="active"&&"bg-sys-blue/20",t==="complete"&&"bg-sys-blue/20",t==="pending"&&"bg-subtle-fill"),children:t==="complete"?f.jsx(ey,{className:"w-4 h-4 text-sys-blue"}):t==="active"?f.jsx(gg,{className:"w-4 h-4 animate-spin text-sys-blue"}):f.jsx("span",{className:"text-fg-muted",children:e})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:oh("text-sm font-medium transition-colors",t==="active"&&"text-sys-blue",t==="complete"&&"text-sys-blue",t==="pending"&&"text-fg-muted"),children:i}),n&&t!=="pending"&&f.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:n})]})]})}function VJ({isOpen:i,onClose:e}){const{packetCacheState:t,requestTierData:n}=mg(),s=dL(),r=hL(),o=t.packetCount,[a,l]=U.useState("pick"),[c,u]=U.useState(null),[d,h]=U.useState("fetching"),p=U.useRef(0),m=U.useRef("fetching"),y=U.useRef(null),g=U.useRef(null);U.useEffect(()=>{i&&(l("pick"),u(null),h("fetching"),m.current="fetching",p.current=0,y.current&&clearTimeout(y.current),g.current&&clearTimeout(g.current),y.current=null,g.current=null)},[i]);const _=U.useCallback(O=>{u(O),l("loading"),h("fetching"),m.current="fetching",p.current=r,y.current=setTimeout(()=>{h("complete"),m.current="complete"},HJ),n(O)},[n,r]);U.useEffect(()=>{if(a!=="loading")return;const O=jJ(m.current,t.isBackgroundLoading,s,r,p.current);al[O]>al[m.current]&&(m.current=O,h(O),O==="complete"&&(y.current&&(clearTimeout(y.current),y.current=null),g.current=setTimeout(()=>e(),1200)))},[a,t.isBackgroundLoading,s,r,e]),U.useEffect(()=>()=>{y.current&&clearTimeout(y.current),g.current&&clearTimeout(g.current)},[]);const S=d==="complete",E=t.loadProgress,x=U.useMemo(()=>{if(E&&E.target>0){const O=(E.loaded/1e3).toFixed(1),H=(E.target/1e3).toFixed(1);return`${O}k / ${H}k packets (${E.percent}%)`}return o>0?`${o.toLocaleString()} packets loaded`:"Connecting to database..."},[E,o]),T=O=>al[O]<al[d]?"complete":O===d?S?"complete":"active":"pending",I=a==="pick"||S?e:()=>{};return f.jsx(fL,{open:i,onClose:I,size:"sm",bottomSheet:!1,children:a==="pick"?f.jsxs(g0,{className:"p-6 radius-card overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(Wp,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"MeshGraph Data Range"}),f.jsx("p",{className:"text-xs text-fg-muted",children:"More data = richer topology"})]})]}),f.jsx("button",{onClick:e,className:"hidden sm:flex p-1.5 radius-inner hover-bg transition-base text-fg-muted hover:text-fg-primary shrink-0",title:"Close",children:f.jsx(Vl,{className:"size-4"})})]}),f.jsx("p",{className:"text-xs text-fg-secondary mb-4 leading-relaxed",children:"MeshGraph works better with more historical data. Larger time windows reveal more nodes, edges, and traffic patterns — but take longer to load."}),f.jsx("div",{className:"space-y-2 mb-4",children:$J.map(O=>f.jsxs("button",{onClick:()=>_(O.tier),className:oh("w-full flex items-center gap-3 px-4 py-3 radius-inset text-left","transition-all duration-150 active:scale-[0.98]","hover:bg-sys-blue/10 hover:ring-2 hover:ring-inset hover:ring-sys-blue/40","bg-subtle-fill-strong"),children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm font-medium text-fg-primary",children:O.label}),f.jsx("div",{className:"text-xs text-fg-muted mt-0.5",children:O.description})]}),f.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-fg-muted shrink-0 tabular-nums",children:[f.jsx(eR,{className:"w-3 h-3"}),O.loadTime]})]},O.tier))}),f.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 radius-inset bg-status-warning/15 text-[11px] text-fg-secondary leading-relaxed",children:[f.jsx(pL,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-status-warning"}),f.jsx("span",{children:"Load times depend on your network's packet volume and connection speed. Selecting 90 days will pull the maximum data available on the backend."})]}),f.jsx("button",{onClick:e,className:"mt-4 sm:hidden w-full min-h-[44px] flex items-center justify-center text-[15px] font-medium text-fg-muted active:text-fg-primary transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsx(mL,{isLoading:!S,borderRadius:16,children:f.jsx(g0,{className:"p-6 radius-card overflow-hidden",children:S?f.jsxs("div",{className:"flex flex-col items-center py-6",children:[f.jsx(ma.div,{variants:JL,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:f.jsx(ey,{className:"w-8 h-8 text-sys-blue"})}),f.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),f.jsx("button",{onClick:e,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(Wp,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),f.jsxs("p",{className:"text-xs text-fg-muted",children:["Loading ",c," of mesh data"]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(_S,{label:"Loading Packets",icon:f.jsx(gL,{className:"w-4 h-4"}),status:T("fetching"),detail:x}),f.jsx(_S,{label:"Computing Topology",icon:f.jsx(Wp,{className:"w-4 h-4"}),status:T("topology"),detail:"Building mesh edges & node discovery"})]}),f.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const GJ=U.memo(VJ);function WJ(i,e=1e3){const[t,n]=U.useState(i),s=U.useRef(Date.now()),r=U.useRef(null);return U.useEffect(()=>{const o=Date.now(),a=e-(o-s.current);return a<=0?(n(i),s.current=o):(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(i),s.current=Date.now()},a)),()=>{r.current&&clearTimeout(r.current)}},[i,e]),t}function YJ(i){if(i==null)return"";const e=String(i);return e.includes(",")||e.includes('"')||e.includes(`
`)?`"${e.replace(/"/g,'""')}"`:e}function Gp(i,e){const t=[i.join(",")];for(const n of e)t.push(n.map(YJ).join(","));return t.join(`
`)}function na(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function LI(i){return!i||i<=0?"":new Date(i*1e3).toISOString()}function dg(i,e){const n=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return`${i}-${n}.${e}`}const qJ=["hash","prefix","name","nodeClass","communityId","degree","inDegree","outDegree","betweenness","pathDiversity","packetCount","lastSeen","activityLevel","recencyScore","avgRssi","avgSnr","isZeroHop","prefixConfidence","hasCollision","collisionCandidates","isLocal","isHub","isGateway","isBackbone","isMobile","isGhost","isInLoop","latitude","longitude","contactType"];function XJ(i){var e,t;return[i.hash,i.prefix,i.name??"",i.nodeClass,i.communityId,i.degree,i.inDegree,i.outDegree,i.betweenness.toFixed(6),i.pathDiversity,i.packetCount,LI(i.lastSeen),i.activityLevel,i.recencyScore.toFixed(4),((e=i.avgRssi)==null?void 0:e.toFixed(1))??"",((t=i.avgSnr)==null?void 0:t.toFixed(1))??"",i.isZeroHop,i.prefixConfidence.toFixed(4),i.hasCollision,i.collisionCandidates,i.isLocal,i.isHub,i.isGateway,i.isBackbone,i.isMobile,i.isGhost,i.isInLoop,i.latitude??"",i.longitude??"",i.contactType??""]}function yS(i,e){const t=[];for(const n of i.nodeMetrics.values())!e&&n.isGhost||t.push(XJ(n));return Gp(qJ,t)}function KJ(i,e){const t=[];for(const n of i.nodeMetrics.values())!e&&n.isGhost||t.push({hash:n.hash,prefix:n.prefix,name:n.name,nodeClass:n.nodeClass,communityId:n.communityId,degree:n.degree,inDegree:n.inDegree,outDegree:n.outDegree,betweenness:n.betweenness,pathDiversity:n.pathDiversity,packetCount:n.packetCount,lastSeen:n.lastSeen,activityLevel:n.activityLevel,recencyScore:n.recencyScore,avgRssi:n.avgRssi,avgSnr:n.avgSnr,isZeroHop:n.isZeroHop,prefixConfidence:n.prefixConfidence,hasCollision:n.hasCollision,isLocal:n.isLocal,isHub:n.isHub,isGateway:n.isGateway,isBackbone:n.isBackbone,isMobile:n.isMobile,isGhost:n.isGhost,isInLoop:n.isInLoop,latitude:n.latitude,longitude:n.longitude,contactType:n.contactType});return t}const ZJ=["fromHash","toHash","key","packetCount","certainCount","avgConfidence","strength","forwardCount","reverseCount","symmetryRatio","dominantDirection","floodCount","directCount","isDirectPathEdge","isZeroHop","isLoopEdge","isCertain","avgRssi","avgSnr","avgRecency","hopDistanceFromLocal","edgeBetweenness","isBackbone"];function QJ(i,e,t){var n,s;return[i.fromHash,i.toHash,i.key,i.packetCount,i.certainCount,i.avgConfidence.toFixed(4),i.strength.toFixed(4),i.forwardCount,i.reverseCount,i.symmetryRatio.toFixed(4),i.dominantDirection,i.floodCount,i.directCount,i.isDirectPathEdge,i.isZeroHop??!1,i.isLoopEdge??!1,i.isCertain,((n=i.avgRssi)==null?void 0:n.toFixed(1))??"",((s=i.avgSnr)==null?void 0:s.toFixed(1))??"",i.avgRecency.toFixed(4),i.hopDistanceFromLocal,(e.get(i.key)??0).toFixed(6),t.has(i.key)]}function JJ(i,e){const t=e?i.edges:i.validatedEdges,n=new Set(i.backboneEdges),s=t.map(r=>QJ(r,i.edgeBetweenness,n));return Gp(ZJ,s)}function eee(i,e){const t=e?i.edges:i.validatedEdges,n=new Set(i.backboneEdges);return t.map(s=>({fromHash:s.fromHash,toHash:s.toHash,key:s.key,packetCount:s.packetCount,certainCount:s.certainCount,avgConfidence:s.avgConfidence,strength:s.strength,forwardCount:s.forwardCount,reverseCount:s.reverseCount,symmetryRatio:s.symmetryRatio,dominantDirection:s.dominantDirection,floodCount:s.floodCount,directCount:s.directCount,isDirectPathEdge:s.isDirectPathEdge,isZeroHop:s.isZeroHop??!1,isLoopEdge:s.isLoopEdge??!1,isCertain:s.isCertain,avgRssi:s.avgRssi??null,avgSnr:s.avgSnr??null,avgRecency:s.avgRecency,hopDistanceFromLocal:s.hopDistanceFromLocal,edgeBetweenness:i.edgeBetweenness.get(s.key)??0,isBackbone:n.has(s.key)}))}const tee=["pathKey","hops","hopCount","healthScore","weakestLinkKey","weakestLinkConfidence","avgEdgeCertainty","observationTrend","alternatePathsCount","estimatedLatencyMs","observationCount","routeType","lastSeen","involvesHub"];function iee(i){return[i.pathKey,i.hops.join(">"),i.hops.length,i.healthScore.toFixed(4),i.weakestLinkKey??"",i.weakestLinkConfidence.toFixed(4),i.avgEdgeCertainty.toFixed(4),i.observationTrend.toFixed(4),i.alternatePathsCount,i.estimatedLatencyMs.toFixed(0),i.observationCount,i.routeType,LI(i.lastSeen),i.involvesHub]}function nee(i){const e=i.pathHealth.map(iee);return Gp(tee,e)}const see=["nodeHash","nodePrefix","nodeName","networkRole","floodFactor","directFactor","floodSlots","directSlots","trafficIntensity","directNeighborCount","collisionRisk","confidence","adjustment","dataConfidence","observationSymmetry","rationale"];function ree(i,e,t){const n=t.get(i);return[i,(n==null?void 0:n.prefix)??"",(n==null?void 0:n.name)??"",e.networkRole,e.floodFactor.toFixed(2),e.directFactor.toFixed(2),e.floodSlots,e.directSlots,e.trafficIntensity.toFixed(4),e.directNeighborCount,e.collisionRisk.toFixed(4),e.confidence.toFixed(4),e.adjustment,e.dataConfidence,e.observationSymmetry.toFixed(4),e.rationale]}function oee(i){const e=[];for(const[t,n]of i.txDelayRecommendations)e.push(ree(t,n,i.nodeMetrics));return Gp(see,e)}function aee(i,e){var r,o;const t=new Set(i.backboneEdges),s=['<?xml version="1.0" encoding="UTF-8"?>','<gexf xmlns="http://gexf.net/1.3" version="1.3">',`  <meta lastmodifieddate="${new Date().toISOString()}">`,`    <creator>pymc_console v${PS}</creator>`,"    <description>MeshCore LoRa Mesh Network Topology</description>","  </meta>",'  <graph defaultedgetype="directed" mode="static">',"","    <!-- Node Attributes -->",'    <attributes class="node">','      <attribute id="n0" title="prefix" type="string"/>','      <attribute id="n1" title="name" type="string"/>','      <attribute id="n2" title="nodeClass" type="string"/>','      <attribute id="n3" title="communityId" type="integer"/>','      <attribute id="n4" title="degree" type="integer"/>','      <attribute id="n5" title="betweenness" type="float"/>','      <attribute id="n6" title="packetCount" type="integer"/>','      <attribute id="n7" title="activityLevel" type="string"/>','      <attribute id="n8" title="isHub" type="boolean"/>','      <attribute id="n9" title="isGateway" type="boolean"/>','      <attribute id="n10" title="isBackbone" type="boolean"/>','      <attribute id="n11" title="isMobile" type="boolean"/>','      <attribute id="n12" title="isGhost" type="boolean"/>','      <attribute id="n13" title="isZeroHop" type="boolean"/>','      <attribute id="n14" title="prefixConfidence" type="float"/>','      <attribute id="n15" title="avgRssi" type="float"/>','      <attribute id="n16" title="avgSnr" type="float"/>',"    </attributes>","","    <!-- Edge Attributes -->",'    <attributes class="edge">','      <attribute id="e0" title="packetCount" type="integer"/>','      <attribute id="e1" title="certainCount" type="integer"/>','      <attribute id="e2" title="confidence" type="float"/>','      <attribute id="e3" title="symmetryRatio" type="float"/>','      <attribute id="e4" title="dominantDirection" type="string"/>','      <attribute id="e5" title="isBackbone" type="boolean"/>','      <attribute id="e6" title="isLoopEdge" type="boolean"/>','      <attribute id="e7" title="isDirectPath" type="boolean"/>','      <attribute id="e8" title="isZeroHop" type="boolean"/>','      <attribute id="e9" title="edgeBetweenness" type="float"/>','      <attribute id="e10" title="floodCount" type="integer"/>','      <attribute id="e11" title="directCount" type="integer"/>',"    </attributes>","","    <nodes>"];for(const a of i.nodeMetrics.values()){if(!e&&a.isGhost)continue;const l=na(a.name??a.prefix);s.push(`      <node id="${na(a.hash)}" label="${l}">`),s.push("        <attvalues>"),s.push(`          <attvalue for="n0" value="${na(a.prefix)}"/>`),s.push(`          <attvalue for="n1" value="${na(a.name??"")}"/>`),s.push(`          <attvalue for="n2" value="${a.nodeClass}"/>`),s.push(`          <attvalue for="n3" value="${a.communityId}"/>`),s.push(`          <attvalue for="n4" value="${a.degree}"/>`),s.push(`          <attvalue for="n5" value="${a.betweenness}"/>`),s.push(`          <attvalue for="n6" value="${a.packetCount}"/>`),s.push(`          <attvalue for="n7" value="${a.activityLevel}"/>`),s.push(`          <attvalue for="n8" value="${a.isHub}"/>`),s.push(`          <attvalue for="n9" value="${a.isGateway}"/>`),s.push(`          <attvalue for="n10" value="${a.isBackbone}"/>`),s.push(`          <attvalue for="n11" value="${a.isMobile}"/>`),s.push(`          <attvalue for="n12" value="${a.isGhost}"/>`),s.push(`          <attvalue for="n13" value="${a.isZeroHop}"/>`),s.push(`          <attvalue for="n14" value="${a.prefixConfidence}"/>`),a.avgRssi!=null&&s.push(`          <attvalue for="n15" value="${a.avgRssi}"/>`),a.avgSnr!=null&&s.push(`          <attvalue for="n16" value="${a.avgSnr}"/>`),s.push("        </attvalues>"),a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)&&s.push(`        <viz:position x="${a.longitude}" y="${a.latitude}" z="0.0"/>`),s.push("      </node>")}s.push("    </nodes>"),s.push(""),s.push("    <edges>");for(const a of i.validatedEdges){const l=i.nodeMetrics;if(!e&&((r=l.get(a.fromHash))!=null&&r.isGhost||(o=l.get(a.toHash))!=null&&o.isGhost))continue;const c=i.edgeBetweenness.get(a.key)??0;s.push(`      <edge id="${na(a.key)}" source="${na(a.fromHash)}" target="${na(a.toHash)}" weight="${a.strength}">`),s.push("        <attvalues>"),s.push(`          <attvalue for="e0" value="${a.packetCount}"/>`),s.push(`          <attvalue for="e1" value="${a.certainCount}"/>`),s.push(`          <attvalue for="e2" value="${a.avgConfidence}"/>`),s.push(`          <attvalue for="e3" value="${a.symmetryRatio}"/>`),s.push(`          <attvalue for="e4" value="${a.dominantDirection}"/>`),s.push(`          <attvalue for="e5" value="${t.has(a.key)}"/>`),s.push(`          <attvalue for="e6" value="${a.isLoopEdge??!1}"/>`),s.push(`          <attvalue for="e7" value="${a.isDirectPathEdge}"/>`),s.push(`          <attvalue for="e8" value="${a.isZeroHop??!1}"/>`),s.push(`          <attvalue for="e9" value="${c}"/>`),s.push(`          <attvalue for="e10" value="${a.floodCount}"/>`),s.push(`          <attvalue for="e11" value="${a.directCount}"/>`),s.push("        </attvalues>"),s.push("      </edge>")}return s.push("    </edges>"),s.push("  </graph>"),s.push("</gexf>"),s.join(`
`)}function lee(i,e,t){const n={meta:{exportedAt:new Date().toISOString(),pymcConsoleVersion:PS,nodeCount:i.nodeMetrics.size,edgeCount:i.validatedEdges.length,communityCount:i.communityCount,loopCount:i.loops.length,backboneEdgeCount:i.backboneEdges.length,hubNodes:i.hubNodes.length,gatewayNodes:i.gatewayNodes.length,mobileNodes:i.mobileNodes.length,ghostNodes:i.discoveredNodes.filter(s=>s.isLikelyReal).length},nodes:KJ(i,e),edges:eee(i,t),pathHealth:i.pathHealth.map(s=>({pathKey:s.pathKey,hops:s.hops,healthScore:s.healthScore,weakestLinkKey:s.weakestLinkKey,weakestLinkConfidence:s.weakestLinkConfidence,avgEdgeCertainty:s.avgEdgeCertainty,observationTrend:s.observationTrend,alternatePathsCount:s.alternatePathsCount,estimatedLatencyMs:s.estimatedLatencyMs,observationCount:s.observationCount,routeType:s.routeType,lastSeen:s.lastSeen,involvesHub:s.involvesHub})),txDelayRecommendations:Array.from(i.txDelayRecommendations.entries()).map(([s,r])=>{var o,a;return{nodeHash:s,nodePrefix:((o=i.nodeMetrics.get(s))==null?void 0:o.prefix)??"",nodeName:((a=i.nodeMetrics.get(s))==null?void 0:a.name)??null,networkRole:r.networkRole,floodFactor:r.floodFactor,directFactor:r.directFactor,floodSlots:r.floodSlots,directSlots:r.directSlots,trafficIntensity:r.trafficIntensity,collisionRisk:r.collisionRisk,confidence:r.confidence,adjustment:r.adjustment,dataConfidence:r.dataConfidence,rationale:r.rationale}}),loops:i.loops.map(s=>({id:s.id,nodes:s.nodes,edgeKeys:s.edgeKeys,size:s.size,avgCertainCount:s.avgCertainCount,minCertainCount:s.minCertainCount,includesLocal:s.includesLocal,strength:s.strength})),disambiguationStats:{totalPrefixes:i.disambiguationStats.totalPrefixes,unambiguousPrefixes:i.disambiguationStats.unambiguousPrefixes,collisionPrefixes:i.disambiguationStats.collisionPrefixes,collisionRate:i.disambiguationStats.collisionRate,avgConfidence:i.disambiguationStats.avgConfidence},viterbiStats:{totalPaths:i.viterbiStats.totalPaths,pathsWithGhosts:i.viterbiStats.pathsWithGhosts,avgPathConfidence:i.viterbiStats.avgPathConfidence,tracePacketsProcessed:i.viterbiStats.tracePacketsProcessed,pathPacketsProcessed:i.viterbiStats.pathPacketsProcessed,distantEdgesDiscovered:i.viterbiStats.distantEdgesDiscovered,duplicateGroupsFound:i.viterbiStats.duplicateGroupsFound,echolocationEdgesInferred:i.viterbiStats.echolocationEdgesInferred}};return JSON.stringify(n,null,2)}function cee(i,e){const t=e.includeGhosts??!0,n=e.includeWeakEdges??!1;switch(e.format){case"csv":{let s,r;switch(e.dataset){case"nodes":s=yS(i,t),r="mesh-nodes";break;case"edges":s=JJ(i,n),r="mesh-edges";break;case"pathHealth":s=nee(i),r="mesh-path-health";break;case"txDelay":s=oee(i),r="mesh-tx-delay";break;case"full":default:s=yS(i,t),r="mesh-nodes";break}return{content:s,filename:dg(r,"csv"),mimeType:"text/csv"}}case"gexf":return{content:aee(i,t),filename:dg("mesh-topology","gexf"),mimeType:"application/xml"};case"json":default:return{content:lee(i,t,n),filename:dg("mesh-topology","json"),mimeType:"application/json"}}}function uee(i){const e=new Blob([i.content],{type:i.mimeType}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=i.filename,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function dee(i,e){const t=cee(i,e);uee(t)}const hee=1e-7,fee=10;function pee(i,e,t=1){const n=e.length,s=new Map;for(let l=0;l<n;l++)s.set(e[l],l);const r=Array.from({length:n},()=>[]),o=new Array(n).fill(0);let a=0;for(const l of i){const c=s.get(l.fromHash),u=s.get(l.toHash);if(c===void 0||u===void 0||c===u)continue;const d=Math.max(.01,(l.certainCount+1)*l.avgConfidence*l.strength),h=t===1?d:Math.pow(d,t);r[c].push({j:u,w:h}),r[u].push({j:c,w:h}),o[c]+=h,o[u]+=h,a+=h}return{graph:{n,adjList:r,totalWeight:a,degree:o},hashToIdx:s}}function mee(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return!1;const a=2*r,l=new Float64Array(n);for(let d=0;d<n;d++)l[e[d]]+=o[d];let c=!1,u=!0;for(;u;){u=!1;for(let d=0;d<n;d++){const h=e[d],p=o[d];if(p===0)continue;const m=new Map;for(const{j:x,w:T}of s[d]){const I=e[x];m.set(I,(m.get(I)??0)+T)}const y=m.get(h)??0,g=l[h]-p,_=-y/r+t*(p*g)/(a*r);let S=h,E=0;for(const[x,T]of m){if(x===h)continue;const I=T/r-t*(p*l[x])/(a*r),O=_+I;O>E+hee&&(E=O,S=x)}S!==h&&(l[h]-=p,l[S]+=p,e[d]=S,u=!0,c=!0)}}return c}function gee(i,e){const{n:t,adjList:n}=i,s=new Set;for(let p=0;p<t;p++)s.add(e[p]);const r=Array.from(s).sort((p,m)=>p-m),o=new Map;for(let p=0;p<r.length;p++)o.set(r[p],p);const a=r.length,l=new Int32Array(t);for(let p=0;p<t;p++)l[p]=o.get(e[p]);const c=new Map,u=new Float64Array(a);let d=0;for(let p=0;p<t;p++){const m=l[p];for(const{j:y,w:g}of n[p]){const _=l[y];if(m===_)continue;const S=m<=_?`${m}-${_}`:`${_}-${m}`;c.set(S,(c.get(S)??0)+g)}}const h=Array.from({length:a},()=>[]);for(const[p,m]of c){const[y,g]=p.split("-").map(Number),_=m/2;h[y].push({j:g,w:_}),h[g].push({j:y,w:_}),u[y]+=_,u[g]+=_,d+=_}return{newGraph:{n:a,adjList:h,totalWeight:d,degree:Array.from(u)},mapping:l}}function _ee(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return 0;const a=2*r;let l=0;for(let c=0;c<n;c++)for(const{j:u,w:d}of s[c])e[c]===e[u]&&(l+=d-t*(o[c]*o[u])/a);return l/a}function bS(i,e,t){const n=(t==null?void 0:t.resolution)??1,s=(t==null?void 0:t.kWeight)??1,r=e.length;if(r===0)return{communities:new Map,numCommunities:0,modularity:0,passes:0};if(r===1)return{communities:new Map([[e[0],0]]),numCommunities:1,modularity:0,passes:0};const{graph:o}=pee(i,e,s);let a=o,l=new Int32Array(r);for(let S=0;S<r;S++)l[S]=S;const c=[];let u=0;for(;u<fee&&mee(a,l,n);){u++;const{newGraph:E,mapping:x}=gee(a,l);if(c.push(x),E.n>=a.n)break;a=E,l=new Int32Array(E.n);for(let T=0;T<E.n;T++)l[T]=T}const d=new Int32Array(r);for(let S=0;S<r;S++)d[S]=S;for(const S of c)for(let E=0;E<r;E++)d[E]=S[d[E]];for(let S=0;S<r;S++)d[S]=l[d[S]];const h=new Set;for(let S=0;S<r;S++)h.add(d[S]);const p=Array.from(h).sort((S,E)=>S-E),m=new Map;for(let S=0;S<p.length;S++)m.set(p[S],S);const y=new Map;for(let S=0;S<r;S++)y.set(e[S],m.get(d[S]));const g=new Int32Array(r);for(let S=0;S<r;S++)g[S]=m.get(d[S]);const _=_ee(o,g,n);return{communities:y,numCommunities:p.length,modularity:_,passes:u}}const yee=299792458,RI=915,bee=6,vee=-174,PI=2.15,NI=2.15,vS={7:-124,8:-127,9:-130,10:-133,11:-135.5,12:-137},xee={62.5:3,125:0,250:-3,500:-6},wee={5:0,6:-.6,7:-1.1,8:-1.5},ih={EXCELLENT:20,GOOD:10,FAIR:3,MARGINAL:0},nh={ANOMALOUS_GOOD:15,BETTER:5,EXPECTED_LOWER:-5,WORSE:-20};function DI(i,e){if(i<=0)return 0;const t=e*1e6;return 20*Math.log10(i)+20*Math.log10(t)+20*Math.log10(4*Math.PI/yee)}function Dv(i,e,t=5){const n=vS[i]??vS[12],s=xee[e]??0,r=wee[t]??0;return n+s+r}function MI(i,e=bee){return vee+10*Math.log10(i)+e}function BI(i){return i>=ih.EXCELLENT?"excellent":i>=ih.GOOD?"good":i>=ih.FAIR?"fair":i>=ih.MARGINAL?"marginal":"critical"}function OI(i){return i>=nh.ANOMALOUS_GOOD?"anomalous-good":i>=nh.BETTER?"better":i>=nh.EXPECTED_LOWER?"expected":i>=nh.WORSE?"worse":"anomalous-bad"}function See(i,e,t,n,s){const r=n.tx_power??22,o=n.spreading_factor??12,a=n.coding_rate??5,l=n.frequency??0,c=l>1e5?l/1e6:l||RI,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=(s==null?void 0:s.sensitivityOverrideDbm)??Dv(o,d,a);let p=null,m=null;e&&t&&jh(e.latitude??void 0,e.longitude??void 0)&&jh(t.latitude??void 0,t.longitude??void 0)&&(p=NS(e.latitude,e.longitude,t.latitude,t.longitude),m=p/1e3);let y=null,g=null;p!=null&&p>0&&(y=DI(p,c),g=r+PI+NI-y);const _=i.avgRssi??null,S=i.avgSnr??null;let E=null,x=null;_!=null&&g!=null&&(E=_-g,x=OI(E));let T=null,I=null;_!=null&&(T=_-h,I=BI(T));const O=_!=null,H=x==="anomalous-good"||x==="anomalous-bad";return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:p,distanceKm:m,fsplDb:y,theoreticalRxPowerDbm:g,observedRssiDbm:_,observedSnrDb:S,deviationDb:E,deviationClass:x,marginDb:T,marginClass:I,sensitivityDbm:h,txPowerDbm:r,frequencyMhz:c,spreadingFactor:o,bandwidthKhz:d,noiseFloorDbm:null,isZeroHop:i.isZeroHop??!1,isTraceEstimated:!1,hasData:O,isAnomalous:H}}function Eee(i,e,t,n,s=22,r){var re,D;const o=i.traceQuality;if(!o)return null;let a=null;if(o.forward!=null&&o.reverse!=null?a=Math.min(o.forward.mean,o.reverse.mean):a=((re=o.forward)==null?void 0:re.mean)??((D=o.reverse)==null?void 0:D.mean)??null,a==null)return null;const l=n.spreading_factor??12,c=n.coding_rate??5,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=d*1e3,p=n.frequency??0,m=p>1e5?p/1e6:p||RI,y=(r==null?void 0:r.sensitivityOverrideDbm)??Dv(l,d,c),g=(r==null?void 0:r.observedNoiseFloorDbm)??MI(h),_=g+a;let S=null,E=null;e&&t&&jh(e.latitude??void 0,e.longitude??void 0)&&jh(t.latitude??void 0,t.longitude??void 0)&&(S=NS(e.latitude,e.longitude,t.latitude,t.longitude),E=S/1e3);let x=null,T=null;S!=null&&S>0&&(x=DI(S,m),T=s+PI+NI-x);let I=null,O=null;T!=null&&(I=_-T,O=OI(I));const H=_-y,Q=BI(H);return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:S,distanceKm:E,fsplDb:x,theoreticalRxPowerDbm:T,observedRssiDbm:_,observedSnrDb:a,deviationDb:I,deviationClass:O,marginDb:H,marginClass:Q,sensitivityDbm:y,noiseFloorDbm:g,txPowerDbm:s,frequencyMhz:m,spreadingFactor:l,bandwidthKhz:d,isZeroHop:!1,isTraceEstimated:!0,hasData:!0,isAnomalous:O==="anomalous-good"||O==="anomalous-bad"}}function Cee(i,e,t){const n=[],s=i.nodeMetrics,r=new Set,o=e.tx_power??22;for(const a of i.edges){if(!a.isZeroHop)continue;const l=s.get(a.fromHash),c=s.get(a.toHash);n.push(See(a,l,c,e,t)),r.add(a.key)}for(const a of i.edges){if(r.has(a.key)||!a.traceQuality)continue;const l=s.get(a.fromHash),c=s.get(a.toHash),u=Eee(a,l,c,e,o,t);u&&(n.push(u),r.add(a.key))}return n}function Tee(i){const e={"anomalous-good":0,better:0,expected:0,worse:0,"anomalous-bad":0},t={excellent:0,good:0,fair:0,marginal:0,critical:0};let n=0,s=0,r=null,o=null,a=0,l=0;for(const c of i)c.hasData&&(c.marginDb!=null&&(n+=c.marginDb,s++,(!r||c.marginDb<(r.marginDb??1/0))&&(r=c),(!o||c.marginDb>(o.marginDb??-1/0))&&(o=c)),c.marginClass&&t[c.marginClass]++,c.deviationDb!=null&&c.deviationClass?(e[c.deviationClass]++,l++):a++);return{totalEdges:i.length,analyzedEdges:l,rssiOnlyEdges:a,avgMarginDb:s>0?n/s:null,worstMargin:r,bestMargin:o,deviationCounts:e,marginCounts:t,anomalousCount:e["anomalous-good"]+e["anomalous-bad"]}}const kee={"anomalous-good":"#2DD4BF",better:"#34D399",expected:"#9CA3AF",worse:"#FB923C","anomalous-bad":"#EF4444"},Mv={excellent:"#34D399",good:"#A3E635",fair:"#FBBF24",marginal:"#FB923C",critical:"#EF4444"};function Aee(i,e="margin"){return i.hasData?e==="deviation"?i.deviationClass?kee[i.deviationClass]:"#505058":i.marginClass?Mv[i.marginClass]:"#505058":"#505058"}function Iee(i,e=.5,t=4){if(i.marginDb==null)return e;const n=Math.max(0,Math.min(1,i.marginDb/40));return e+n*(t-e)}const Lee=.15,Ree=200;let Pee=0;function Ns(){return`ta-${++Pee}-${Date.now()}`}function Nee(i){var c,u;const e=new Set;for(const d of i.edges)e.add(d.key);const t=new Map,n=new Map,s=new Map,r=new Set;for(const[d,h]of i.nodeMetrics)t.set(d,h.betweenness),n.set(d,h.communityId),s.set(d,h.nodeClass),r.add(d);const o=new Set;for(const d of i.discoveredNodes)d.isLikelyReal&&o.add(d.prefix);const a=new Map,l=new Map;for(const d of i.edges)(c=d.traceQuality)!=null&&c.composite&&a.set(d.key,d.traceQuality.composite.mean),((u=d.traceQuality)==null?void 0:u.asymmetryDb)!=null&&l.set(d.key,d.traceQuality.asymmetryDb);return{timestamp:Date.now(),edgeKeys:e,betweenness:t,communities:n,nodeClasses:s,ghostPrefixes:o,nodeHashes:r,traceSnr:a,traceAsymmetry:l}}function Dee(i,e,t){const n=Date.now(),s=[],r=h=>(t==null?void 0:t.get(h))??null;for(const h of e.edgeKeys)if(!i.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-appeared",severity:"info",description:`New edge: ${y} ↔ ${g}`,edgeKey:h})}for(const h of i.edgeKeys)if(!e.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-disappeared",severity:"warning",description:`Edge lost: ${y} ↔ ${g}`,edgeKey:h})}for(const h of e.nodeHashes)if(!i.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-appeared",severity:"info",description:`Node appeared: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of i.nodeHashes)if(!e.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-disappeared",severity:"warning",description:`Node dropped: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of e.ghostPrefixes)i.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-appeared",severity:"info",description:`Ghost node discovered: ${h.toUpperCase()}`});for(const h of i.ghostPrefixes)e.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-disappeared",severity:"info",description:`Ghost node resolved: ${h.toUpperCase()}`});const o=3;for(const[h,p]of e.traceSnr){const m=i.traceSnr.get(h);if(m===void 0)continue;const y=m-p;y>=o&&s.push({id:Ns(),detectedAt:n,category:"snr-degradation",severity:y>=6?"critical":"warning",description:`SNR dropped ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}const a=4;for(const[h,p]of e.traceAsymmetry){const m=i.traceAsymmetry.get(h);if(m===void 0)continue;const y=p-m;y>=a&&s.push({id:Ns(),detectedAt:n,category:"asymmetry-shift",severity:y>=8?"critical":"warning",description:`Asymmetry grew ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}for(const[h,p]of e.betweenness){const m=i.betweenness.get(h);if(m===void 0)continue;const y=Math.abs(p-m);if(y>=Lee){const g=r(h),_=p>m?"increased":"decreased";s.push({id:Ns(),detectedAt:n,category:"betweenness-shift",severity:y>=.3?"critical":"warning",description:`${g??h.slice(0,8)} betweenness ${_}: ${m.toFixed(3)} → ${p.toFixed(3)}`,nodeHash:h,nodeName:g??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.communities){const m=i.communities.get(h);if(m!==void 0&&p!==m){const y=r(h);s.push({id:Ns(),detectedAt:n,category:"community-change",severity:"info",description:`${y??h.slice(0,8)} moved: community #${m} → #${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.nodeClasses){const m=i.nodeClasses.get(h);if(m!==void 0&&p!==m){const y=r(h),g=xS(p)>xS(m);s.push({id:Ns(),detectedAt:n,category:"class-change",severity:g?"warning":"info",description:`${y??h.slice(0,8)} ${g?"promoted":"changed"}: ${m} → ${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}const l={},c={},u=["edge-appeared","edge-disappeared","ghost-appeared","ghost-disappeared","betweenness-shift","community-change","class-change","node-appeared","node-disappeared","snr-degradation","asymmetry-shift"],d=["info","warning","critical"];for(const h of u)l[h]=0;for(const h of d)c[h]=0;for(const h of s)l[h.category]++,c[h.severity]++;return s.sort((h,p)=>p.detectedAt-h.detectedAt),{anomalies:s,categoryCounts:l,severityCounts:c,totalCount:s.length,timestamp:n}}function xS(i){return{standard:0,ghost:1,mobile:2,neighbor:3,backbone:4,gateway:5,hub:6,local:7}[i]??0}class Mee{constructor(e=Ree){b(this,"prevSnapshot",null);b(this,"log",[]);b(this,"maxLog");this.maxLog=e}update(e,t){const n=Nee(e);if(!this.prevSnapshot)return this.prevSnapshot=n,{anomalies:[],categoryCounts:Fee(),severityCounts:zee(),totalCount:0,timestamp:Date.now()};const s=Dee(this.prevSnapshot,n,t);this.prevSnapshot=n;try{Oee(s.anomalies,e)}catch(r){console.warn("[TopologyAnomalyTracker] Enrichment failed, anomalies logged without detail:",r)}return this.log.unshift(...s.anomalies),this.log.length>this.maxLog&&(this.log.length=this.maxLog),s}getLog(){return this.log}getFiltered(e){const t=Date.now();return this.log.filter(n=>!(e.category&&n.category!==e.category||e.severity&&n.severity!==e.severity||e.nodeHash&&n.nodeHash!==e.nodeHash||e.maxAge&&t-n.detectedAt>e.maxAge))}clear(){this.log=[],this.prevSnapshot=null}}function Bee(i){return{nodeClass:i.nodeClass,degree:i.degree,betweenness:i.betweenness,activityLevel:i.activityLevel,isZeroHop:i.isZeroHop,avgRssi:i.avgRssi,avgSnr:i.avgSnr,communityId:i.communityId,packetCount:i.packetCount,connectionCount:i.degree}}function Oee(i,e){var r,o,a;const t=e.edgeMap,n=e.nodeMetrics,s=new Set(e.backboneEdges??[]);for(const l of i){if(l.edgeKey&&(l.category==="edge-appeared"||l.category==="edge-disappeared")){const c=t==null?void 0:t.get(l.edgeKey),u=l.edgeKey.split("-"),d=u[0],h=u[1],p=d?n==null?void 0:n.get(d):void 0,m=h?n==null?void 0:n.get(h):void 0;c?l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:c.packetCount,confidence:c.avgConfidence,symmetryRatio:c.symmetryRatio,isBackbone:s.has(l.edgeKey),isLoop:c.isLoopEdge??!1,isZeroHop:c.isZeroHop??!1,isDirectPath:c.isDirectPathEdge,avgRssi:c.avgRssi??null,avgSnr:c.avgSnr??null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:((o=(r=c.traceQuality)==null?void 0:r.composite)==null?void 0:o.mean)??null,traceAsymmetryDb:((a=c.traceQuality)==null?void 0:a.asymmetryDb)??null}:l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:0,confidence:0,symmetryRatio:0,isBackbone:!1,isLoop:!1,isZeroHop:!1,isDirectPath:!1,avgRssi:null,avgSnr:null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:null,traceAsymmetryDb:null}}if(l.nodeHash){const c=n==null?void 0:n.get(l.nodeHash);c&&(l.nodeDetail=Bee(c))}}}function Fee(){return{"edge-appeared":0,"edge-disappeared":0,"ghost-appeared":0,"ghost-disappeared":0,"betweenness-shift":0,"community-change":0,"class-change":0,"node-appeared":0,"node-disappeared":0,"snr-degradation":0,"asymmetry-shift":0}}function zee(){return{info:0,warning:0,critical:0}}const FI=24,Uee=3;function $ee(i,e,t,n){const s=[],r=hd(e).toLowerCase();for(const o of i){if(o.transmitted||o.rssi==null||o.snr==null||o.rssi===0&&o.snr===0)continue;const a=o.src_hash??"";if(hd(a).toLowerCase()!==r&&hd(a)!==hd(e))continue;const c=o.original_path??o.forwarded_path??[],u=_L(c,n),d=(u==null?void 0:u.effectiveLength)??0,h=o.route??o.route_type;let p=!1;h!=null&&yL(h)?p=d<=1:p=d===0,p&&s.push({timestamp:o.timestamp*1e3,rssi:o.rssi,snr:o.snr})}if(s.sort((o,a)=>o.timestamp-a.timestamp),s.length>0&&s[0].timestamp<4102444800)for(const o of s)o.timestamp*=1e3;return s}function jee(i,e=FI){if(i.length===0)return[];const t=i[0].timestamp,s=i[i.length-1].timestamp-t;if(s<=0){const l=i.reduce((u,d)=>u+d.rssi,0)/i.length,c=i.reduce((u,d)=>u+d.snr,0)/i.length;return[{timestamp:t,avgRssi:l,avgSnr:c,minRssi:Math.min(...i.map(u=>u.rssi)),maxRssi:Math.max(...i.map(u=>u.rssi)),minSnr:Math.min(...i.map(u=>u.snr)),maxSnr:Math.max(...i.map(u=>u.snr)),count:i.length}]}const r=s/e,o=[];for(let l=0;l<e;l++)o.push({timestamp:t+(l+.5)*r,avgRssi:0,avgSnr:0,minRssi:1/0,maxRssi:-1/0,minSnr:1/0,maxSnr:-1/0,count:0});for(const l of i){const c=Math.min(e-1,Math.floor((l.timestamp-t)/r)),u=o[c];u.avgRssi+=l.rssi,u.avgSnr+=l.snr,u.minRssi=Math.min(u.minRssi,l.rssi),u.maxRssi=Math.max(u.maxRssi,l.rssi),u.minSnr=Math.min(u.minSnr,l.snr),u.maxSnr=Math.max(u.maxSnr,l.snr),u.count++}const a=[];for(const l of o)l.count>0&&(l.avgRssi/=l.count,l.avgSnr/=l.count,a.push(l));return a}function wS(i){if(i.length<2)return 0;const e=i.length;let t=0,n=0,s=0,r=0;for(let a=0;a<e;a++)t+=a,n+=i[a],s+=a*i[a],r+=a*a;const o=e*r-t*t;return o===0?0:(e*s-t*n)/o}function Hee(i,e,t,n,s=FI){const r=$ee(i,e,t,n);if(r.length<Uee)return null;const o=jee(r,s);if(o.length<2)return null;let a=0,l=0,c=1/0,u=-1/0,d=1/0,h=-1/0;for(const _ of r)a+=_.rssi,l+=_.snr,c=Math.min(c,_.rssi),u=Math.max(u,_.rssi),d=Math.min(d,_.snr),h=Math.max(h,_.snr);const p=wS(o.map(_=>_.avgRssi)),m=wS(o.map(_=>_.avgSnr)),y=r[0].timestamp,g=r[r.length-1].timestamp;return{buckets:o,totalSamples:r.length,rssiRange:[c,u],snrRange:[d,h],avgRssi:a/r.length,avgSnr:l/r.length,rssiTrend:p,snrTrend:m,timeSpanMs:g-y}}const ln={observationTrend:.3,edgeCertainty:.25,redundancy:.15,signalMargin:.15,traceSnrTrend:.15},hg={critical:.75,high:.55,moderate:.35},Vee=-137,Gee=5;function Wee(i,e,t){if(i.observationCount<Gee)return null;const n=[];let s=0;i.observationTrend<0&&(s=Math.abs(i.observationTrend),n.push({name:"Declining usage",description:i.observationTrend<-.3?"Traffic rapidly declining":"Traffic gradually declining",score:s,weight:ln.observationTrend}));const r=1-Math.min(1,i.avgEdgeCertainty);r>.3&&n.push({name:"Weak link certainty",description:i.weakestLinkKey?`Weakest: ${i.weakestLinkConfidence<.3?"very low":"low"} confidence`:`Average certainty: ${(i.avgEdgeCertainty*100).toFixed(0)}%`,score:r,weight:ln.edgeCertainty});let o=0;i.alternatePathsCount===0?(o=1,n.push({name:"No alternate paths",description:"Single route to destination — no failover available",score:o,weight:ln.redundancy})):i.alternatePathsCount===1&&(o=.5,n.push({name:"Limited redundancy",description:"Only 1 alternate path available",score:o,weight:ln.redundancy}));let a=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=(h==null?void 0:h.avgRssi)??null,m=i.weakestLinkTraceSnr;if(p!=null){const y=p-t;y<3?(a=1,n.push({name:"Signal near sensitivity",description:`Weakest link: ${y.toFixed(1)} dB margin (< 3 dB)`,score:a,weight:ln.signalMargin})):y<10&&(a=1-(y-3)/7,n.push({name:"Low signal margin",description:`Weakest link: ${y.toFixed(1)} dB margin`,score:a,weight:ln.signalMargin}))}else m!=null&&m<5&&(a=m<-5?1:m<0?.7:.4,n.push({name:"Low trace SNR",description:`Weakest link trace SNR: ${m.toFixed(1)} dB`,score:a,weight:ln.signalMargin}))}let l=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=h==null?void 0:h.traceQuality;p!=null&&p.composite&&(p.composite.mean<0?(l=.8,n.push({name:"Trace SNR negative",description:`Composite trace SNR: ${p.composite.mean.toFixed(1)} dB (negative)`,score:l,weight:ln.traceSnrTrend})):p.composite.stdDev>4?(l=.6,n.push({name:"Unstable trace SNR",description:`High variance: σ=${p.composite.stdDev.toFixed(1)} dB`,score:l,weight:ln.traceSnrTrend})):p.asymmetryDb!=null&&p.asymmetryDb>8&&(l=.5,n.push({name:"High SNR asymmetry",description:`Bidirectional asymmetry: ${p.asymmetryDb.toFixed(1)} dB`,score:l,weight:ln.traceSnrTrend})))}const c=s*ln.observationTrend+r*ln.edgeCertainty+o*ln.redundancy+a*ln.signalMargin+l*ln.traceSnrTrend;if(c<hg.moderate)return null;let u,d;return c>=hg.critical?(u="critical",d="imminent"):c>=hg.high?(u="high",d="near-term"):(u="moderate",d="watch"),{pathKey:i.pathKey,hops:i.hops,riskScore:Math.round(c*100)/100,riskLevel:u,factors:n,weakestEdgeKey:i.weakestLinkKey,healthScore:i.healthScore,observationTrend:i.observationTrend,alternatePathsCount:i.alternatePathsCount,urgency:d}}function Yee(i,e,t=Vee){const n=new Map;for(const o of e)n.set(o.key,o);const s=e.filter(o=>o.avgRssi!=null).length,r=[];for(const o of i){const a=Wee(o,n,t);a&&r.push(a)}return r.sort((o,a)=>a.riskScore-o.riskScore),{atRiskPaths:r,criticalCount:r.filter(o=>o.riskLevel==="critical").length,highCount:r.filter(o=>o.riskLevel==="high").length,moderateCount:r.filter(o=>o.riskLevel==="moderate").length,edgesAnalyzed:e.length,edgesWithSignal:s}}let qee=100;function SS(){return++qee}const zI="meshgraph-panel-";function ES(i){try{const e=localStorage.getItem(zI+i);return e?JSON.parse(e):null}catch{return null}}function Xee(i,e){try{localStorage.setItem(zI+i,JSON.stringify(e))}catch{}}function Kee(i,e,t,n,s){return{x:Math.max(8,Math.min(i,Math.max(8,n-t-8))),y:Math.max(8,Math.min(e,Math.max(8,s-36)))}}function sh({id:i,title:e,icon:t,open:n,onClose:s,defaultPosition:r,defaultSize:o,minSize:a={width:180,height:120},maxSize:l,autoHeight:c=!1,headerActions:u,children:d}){const h=GL(),p=U.useRef(null),m=U.useRef(null),y=U.useMemo(()=>{const F=ES(i);return F?{x:F.x,y:F.y,w:F.w,h:c?o.height:F.h,minimized:F.minimized}:{x:r.x,y:r.y,w:o.width,h:o.height,minimized:!1}},[i]),[g,_]=U.useState({w:y.w,h:y.h}),[S,E]=U.useState(y.minimized),[x,T]=U.useState(()=>SS()),[I,O]=U.useState({x:y.x,y:y.y});U.useLayoutEffect(()=>{const F=p.current;if(!n||!F)return;const q=F.getBoundingClientRect();if(q.width<1||q.height<1)return;const te=ES(i),Z=(te==null?void 0:te.x)??y.x,ae=(te==null?void 0:te.y)??y.y,J=(te==null?void 0:te.w)??g.w,Se=Kee(Z,ae,J,q.width,q.height);O(Se)},[n,i]);const[H,Q]=U.useState(!1),re=U.useRef({startX:0,startY:0,startW:0,startH:0,edge:""}),D=U.useRef(),de=U.useCallback(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{const F=m.current;if(!F)return;const q=window.getComputedStyle(F),te=new DOMMatrix(q.transform);Xee(i,{x:te.m41,y:te.m42,w:g.w,h:g.h,minimized:S})},300)},[i,g.w,g.h,S]);U.useEffect(()=>{de()},[g,S,de]);const se=U.useCallback(()=>{T(SS())},[]),R=U.useCallback(()=>{E(F=>!F)},[]),ee=U.useCallback((F,q)=>{F.preventDefault(),F.stopPropagation(),Q(!0),re.current={startX:F.clientX,startY:F.clientY,startW:g.w,startH:g.h,edge:q},se();const te=ae=>{const{startX:J,startY:Se,startW:xe,startH:et,edge:he}=re.current,yt=ae.clientX-J,Xe=ae.clientY-Se;let dt=xe,ie=et;(he==="e"||he==="se")&&(dt=Math.max(a.width,xe+yt),l&&(dt=Math.min(l.width,dt))),(he==="s"||he==="se")&&(ie=Math.max(a.height,et+Xe),l&&(ie=Math.min(l.height,ie))),_({w:dt,h:ie})},Z=()=>{Q(!1),window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",Z)};window.addEventListener("pointermove",te),window.addEventListener("pointerup",Z)},[g,a,l,se]);return f.jsx("div",{ref:p,className:"absolute inset-0 pointer-events-none",style:{zIndex:x},children:f.jsx(Jc,{children:n&&f.jsxs(ma.div,{ref:m,drag:!H,dragControls:h,dragConstraints:p,dragElastic:.05,dragMomentum:!1,dragListener:!1,initial:{opacity:0,scale:.96,x:I.x,y:I.y},animate:{opacity:1,scale:1,x:I.x,y:I.y},exit:{opacity:0,scale:.96},transition:{duration:.15},onPointerDown:se,className:"absolute top-0 left-0 pointer-events-auto",style:{width:g.w,touchAction:"none"},children:[f.jsxs("div",{className:"surface-elevated radius-inset shadow-xl overflow-hidden flex flex-col",style:{maxHeight:S?void 0:c?"80vh":g.h},children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-edge-subtle cursor-grab active:cursor-grabbing select-none shrink-0",onPointerDown:F=>{se(),h.start(F)},children:[f.jsx(WL,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),t&&f.jsx("span",{className:"text-fg-muted shrink-0 [&>svg]:w-3 [&>svg]:h-3",children:t}),f.jsx("span",{className:"text-[11px] font-medium text-fg-primary flex-1 truncate",children:e}),u,f.jsx("button",{onClick:R,className:"p-0.5 radius-badge hover-bg transition-base",title:S?"Expand":"Minimize",children:S?f.jsx(DS,{className:"w-2.5 h-2.5 text-fg-muted"}):f.jsx(bL,{className:"w-2.5 h-2.5 text-fg-muted"})}),f.jsx("button",{onClick:s,className:"p-0.5 radius-badge hover-bg transition-base",title:"Close",children:f.jsx(Vl,{className:"w-2.5 h-2.5 text-fg-muted"})})]}),f.jsx(Jc,{initial:!1,children:!S&&f.jsx(ma.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:f.jsx("div",{className:"overflow-y-auto",style:{maxHeight:c?"70vh":void 0},children:d})})})]}),!S&&!c&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"absolute top-0 -right-1 w-2 h-full cursor-ew-resize",onPointerDown:F=>ee(F,"e")}),f.jsx("div",{className:"absolute -bottom-1 left-0 w-full h-2 cursor-ns-resize",onPointerDown:F=>ee(F,"s")}),f.jsx("div",{className:"absolute -bottom-1 -right-1 w-3 h-3 cursor-nwse-resize",onPointerDown:F=>ee(F,"se"),children:f.jsxs("svg",{className:"w-full h-full text-fg-muted/30",viewBox:"0 0 12 12",children:[f.jsx("path",{d:"M10 2 L10 10 L2 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M7 5 L7 7 L5 7",fill:"none",stroke:"currentColor",strokeWidth:"1"})]})})]})]})})})}const UI=[{target:"Graph",fn:"topology.edges",minStage:2,when:v0},{target:"Graph",fn:"topology.edges",minStage:2,when:ZL},{target:"Graph",fn:"nodeMetrics",minStage:2},{target:"Graph",fn:"ghostNodes",minStage:2,when:v0},{target:"Graph",fn:"_advertNodeType",minStage:1,when:QL},{target:"Graph",fn:"pathHealth",minStage:2}];KL(UI);const Zee=400,rh=800,el={critical:[Ge.red,Ge.red],poor:[Ge.orange,Ge.orange],fair:[Ge.amber,Ge.amber],good:[Ge.green,Ge.green],excellent:[Ge.blue,Ge.blue]};function Qee(i,e){if(i==null)return null;const t=Math.max(0,i),n=t>0?(Math.log10(t)+4)/4.5:0,s=Math.round(Math.max(0,Math.min(100,n*100)));let r,o;s<10?(r="critical",o="Partition risk"):s<30?(r="poor",o="Weak connectivity"):s<55?(r="fair",o="Moderate resilience"):s<80?(r="good",o="Well connected"):(r="excellent",o="Highly resilient");const[a,l]=el[r];return{score:s,grade:r,label:o,color:e?a:l}}const CS=5,fg=28,TS=6,Jee=6,ete={active:1,recent:.85,stale:.45,inactive:.25},tte=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange],ite=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange];function Sl(i,e,t){const n=(r,o)=>parseInt(r.slice(1+o*2,3+o*2),16),s=r=>Math.round(n(i,r)*t+n(e,r)*(1-t));return`#${[0,1,2].map(r=>s(r).toString(16).padStart(2,"0")).join("")}`}const $I={zeroHop:Sl(Ge.amber,Xt[500],.55),directPath:Sl(Ge.teal,Xt[500],.55),loop:Sl(Ge.purple,Xt[500],.55),backbone:Xt[300],standard:Xt[500],standardDim:Xt[600],ghost:Xt[600]},jI={zeroHop:Sl(Ge.amber,Xt[700],.5),directPath:Sl(Ge.teal,Xt[700],.5),loop:Sl(Ge.purple,Xt[700],.5),backbone:Xt[700],standard:Xt[400],standardDim:Xt[300],ghost:Xt[400]},Ne={simulationDecay:2e4,simulationGravity:.05,simulationCenter:.05,simulationRepulsion:5,simulationRepulsionTheta:.4,simulationLinkSpring:.05,simulationLinkDistance:78,simulationFriction:.72,simulationRepulsionFromMouse:0,pointSizeScale:.4,pointOpacity:1,pointGreyoutOpacity:.1,linkWidthScale:.06,linkOpacity:.95,linkGreyoutOpacity:.1,curvedLinks:!1,curvedLinkWeight:.8,linkDefaultArrows:!0,linkArrowsSizeScale:1.7,scalePointsOnZoom:!0,scaleLinksOnZoom:!0,renderLinks:!0,renderHoveredPointRing:!0,fitViewPadding:.15,spaceSize:4096};function nte(i){if(typeof document>"u")return i?Xt[950]:"#EFF0F1";const e=getComputedStyle(document.documentElement).getPropertyValue("--bg-body").trim();return e.startsWith("#")?e:i?Xt[950]:"#EFF0F1"}function ste(i){if(typeof document>"u")return i?Xt[400]:Xt[500];const e=getComputedStyle(document.documentElement).getPropertyValue("--text-secondary").trim();return e.startsWith("#")?e:i?Xt[400]:Xt[500]}const HI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:Xt[400],standard:Xt[300]},VI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:Xt[500],standard:Xt[600]},rte={local:"Your repeater — the home node running this dashboard",hub:"≥10% of last-hop traffic — dominant forwarder for your local node",gateway:"7-10% of last-hop traffic — significant relay node",backbone:"High betweenness centrality — critical path node connecting clusters",neighbor:"Zero-hop direct RF contact — no intermediate forwarders",mobile:"High path volatility — node appears and disappears frequently",ghost:"Unresolved prefix inferred by Viterbi HMM from path patterns",standard:"<7% of traffic — normal mesh participant"};function kS(i){const e=i.replace("#","");return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}function pg(i,e,t){const[n,s,r]=kS(i),[o,a,l]=kS(e),c=Math.max(0,Math.min(1,t)),u=Math.round(n*c+o*(1-c)),d=Math.round(s*c+a*(1-c)),h=Math.round(r*c+l*(1-c));return`#${u.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`}function ote(i,e){return i.isZeroHop?"zero-hop":i.isDirectPathEdge?"direct-path":i.isLoopEdge?"loop":e.has(i.key)?"backbone":"standard"}function AS(i,e,t){const n=t?$I:jI;switch(i){case"zero-hop":return n.zeroHop;case"direct-path":return n.directPath;case"loop":return n.loop;case"backbone":return n.backbone;case"ghost":return n.ghost;case"standard":default:return e>=.7?n.standard:n.standardDim}}const ate={"zero-hop":"Zero-Hop (Direct RF)","direct-path":"Direct Path (Unicast)",loop:"Redundant Loop",backbone:"Backbone",standard:"Standard",ghost:"Ghost (Inferred)"},lte={"zero-hop":"Direct radio contact — no intermediate forwarders in path","direct-path":"Unicast-routed edge — verified via DIRECT route type packets",loop:"Redundant path — alternate route between the same endpoints exists",backbone:"High betweenness centrality — critical traffic flow edge",standard:"Normal mesh edge with moderate-to-high confidence",ghost:"Inferred connection from Viterbi HMM ghost node analysis"};function cte(i){const e=i.rssiTrend<-.1,t=i.snrTrend<-.1,n=i.rssiTrend>.1,s=i.snrTrend>.1,r=i.rssiRange[1]-i.rssiRange[0],o=i.snrRange[1]-i.snrRange[0];return e&&t?{text:"Both RSSI and SNR declining — possible antenna degradation or increasing distance",color:"#EF4444"}:t&&!e?{text:"SNR declining while RSSI stable — likely RF interference or noise floor increase",color:"#F97316"}:e&&!t?{text:"RSSI declining while SNR stable — possible path obstruction or power change",color:"#F97316"}:n&&s?{text:"Signal improving — conditions favorable or antenna adjustment working",color:"#34D399"}:r>15||o>10?{text:"High signal variance — intermittent obstruction or multipath fading",color:"#FBBF24"}:{text:"Signal stable — no significant degradation detected",color:"#9CA3AF"}}const ute=U.memo(function({timeline:e}){const t=e.buckets;if(t.length<2)return null;const n=200,s=36,r=1,[o,a]=e.rssiRange,l=Math.max(1,a-o),[c,u]=e.snrRange,d=Math.max(1,u-c),h=(n-r*2)/(t.length-1),p=t.map((T,I)=>{const O=r+I*h,H=r+(1-(T.avgRssi-o)/l)*(s-r*2);return`${O.toFixed(1)},${H.toFixed(1)}`}).join(" "),m=t.map((T,I)=>{const O=r+I*h,H=r+(1-(T.avgSnr-c)/d)*(s-r*2);return`${O.toFixed(1)},${H.toFixed(1)}`}).join(" "),y=e.rssiTrend>.1?"↑":e.rssiTrend<-.1?"↓":"→",g=e.snrTrend>.1?"↑":e.snrTrend<-.1?"↓":"→",_=e.rssiTrend>.1?"#34D399":e.rssiTrend<-.1?"#EF4444":"#9CA3AF",S=e.snrTrend>.1?"#34D399":e.snrTrend<-.1?"#EF4444":"#9CA3AF",E=(e.timeSpanMs/36e5).toFixed(1),x=cte(e);return f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Signal Quality Over Time"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Tracks RSSI (signal power) and SNR (signal-to-noise ratio) for zero-hop packets received directly from this neighbor. Reveals weather effects, interference, and antenna degradation."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Samples"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:e.totalSamples})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Time span"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[E,"h"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg RSSI"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg SNR"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"RSSI trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:_},children:[e.rssiTrend>0?"+":"",e.rssiTrend.toFixed(3)," dBm/bucket"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"SNR trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:S},children:[e.snrTrend>0?"+":"",e.snrTrend.toFixed(3)," dB/bucket"]})]})]}),f.jsxs("div",{className:"text-[10px] text-fg-muted italic",children:["Trend is linear regression slope across ",t.length," time buckets. ↑ = improving, ↓ = degrading, → = stable."]})]}),children:f.jsx("span",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Signal Timeline"})}),f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums",children:[e.totalSamples," samples · ",E,"h"]})]}),f.jsxs("svg",{viewBox:`0 0 ${n} ${s}`,className:"w-full h-9",preserveAspectRatio:"none",children:[f.jsx("polyline",{points:p,fill:"none",stroke:"#60A5FA",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.8"}),f.jsx("polyline",{points:m,fill:"none",stroke:"#34D399",strokeWidth:"1",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.5",strokeDasharray:"3 2"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[9px] mt-0.5",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1.5px] bg-[#60A5FA] rounded-full inline-block"}),f.jsx("span",{className:"text-fg-muted",children:"RSSI"}),f.jsx("span",{className:"tabular-nums",style:{color:_},children:y})]}),f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1px] bg-[#34D399] rounded-full inline-block opacity-50",style:{borderTop:"1px dashed #34D399"}}),f.jsx("span",{className:"text-fg-muted",children:"SNR"}),f.jsx("span",{className:"tabular-nums",style:{color:S},children:g})]})]}),f.jsxs("div",{className:"flex items-center gap-2 text-fg-muted tabular-nums",children:[f.jsxs("span",{children:[o.toFixed(0),"…",a.toFixed(0)," dBm"]}),f.jsxs("span",{children:[c.toFixed(0),"…",u.toFixed(0)," dB"]})]})]}),f.jsx("div",{className:"mt-1 text-[9px] leading-tight",style:{color:x.color},children:x.text})]})}),IS=U.memo(function({edge:e,onClose:t}){const n=U.useMemo(()=>{if(!e.isZeroHop&&e.edgeType!=="zero-hop")return null;const s=mg.getState().packets,r=mg.getState().cachedLocalHash??void 0;return Hee(s,e.source,e.target,r)},[e.source,e.target,e.isZeroHop,e.edgeType]);return f.jsxs(ma.div,{variants:iy,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(aR,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsxs("span",{className:"text-sm font-semibold text-fg-primary truncate",children:[e.fromName??e.source.slice(0,6)," → ",e.toName??e.target.slice(0,6)]}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[f.jsx(Bi,{color:"zinc",compact:!0,children:ate[e.edgeType]}),e.isBackbone&&f.jsx(Bi,{color:"emerald",compact:!0,children:"BONE"}),e.isLoopEdge&&f.jsx(Bi,{color:"indigo",compact:!0,children:"LOOP"}),e.isGhost&&f.jsx(Bi,{color:"zinc",compact:!0,children:"GHOST"})]})]}),f.jsx(ty,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx(Vl,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all observations of this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.confidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Observations where both endpoints had high-confidence disambiguation",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Certain"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.certainCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed traversing this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Combined certainCount × confidence metric for edge ranking",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Strength"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.strength.toFixed(2)})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Bidirectional balance (min/max) — 0 = one-way traffic, 1 = perfectly balanced",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Symmetry"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.symmetryRatio.toFixed(2)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Dominant traffic flow direction between these nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direction"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.dominantDirection})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Forward (A→B) vs reverse (B→A) observation counts",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Fwd / Rev"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.forwardCount," / ",e.reverseCount]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Routing method — broadcast flood vs unicast direct routing",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood / Direct"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.floodCount," / ",e.directCount]})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),e.linkBudget&&f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.linkBudget.distanceKm!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Haversine distance between endpoint locations",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Distance"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.distanceKm.toFixed(2)," km"]})]}),e.linkBudget.fsplDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Free Space Path Loss — theoretical signal attenuation over this distance at configured frequency",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"FSPL"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.fsplDb.toFixed(1)," dB"]})]}),e.linkBudget.marginDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Link margin — observed RSSI minus receiver sensitivity. Positive = signal headroom above minimum.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Margin"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",style:{color:e.linkBudget.marginClass?Mv[e.linkBudget.marginClass]:void 0},children:[e.linkBudget.marginDb>0?"+":"",e.linkBudget.marginDb.toFixed(1)," dB"]})]}),e.linkBudget.deviationDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Deviation from theoretical FSPL — positive means better signal than free-space prediction",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"vs Theory"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.deviationDb>0?"+":"",e.linkBudget.deviationDb.toFixed(1)," dB"]})]})]}),n&&f.jsx(ute,{timeline:n})]})]})}),LS=U.memo(function({node:e,onClose:t,egoMetrics:n,onExpandEgo:s,neighbors:r,onSelectNeighbor:o,txDelayRec:a}){const[l,c]=U.useState(!1),[u,d]=U.useState(!1);return f.jsxs(ma.div,{variants:iy,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl max-h-[60vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(FL()?HI:VI)[e.nodeClass]}}),f.jsx("code",{className:"text-sm font-semibold text-fg-primary shrink-0",children:e.prefix}),e.name&&f.jsx("span",{className:"text-sm text-fg-secondary truncate",children:e.name}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.isLocal&&f.jsx(Bi,{color:"yellow",compact:!0,children:"LOCAL"}),e.isHub&&f.jsx(Bi,{color:"violet",compact:!0,children:"HUB"}),e.isGateway&&f.jsx(Bi,{color:"sky",compact:!0,children:"GW"}),e.isBackbone&&f.jsx(Bi,{color:"emerald",compact:!0,children:"BONE"}),e.isMobile&&f.jsx(Bi,{color:"orange",compact:!0,children:"MOB"}),e.isZeroHop&&f.jsx(Bi,{color:"amber",compact:!0,children:"RF"}),e.isGhost&&f.jsx(Bi,{color:"zinc",compact:!0,children:"GHOST"}),e.isInLoop&&f.jsx(Bi,{color:"indigo",compact:!0,children:"LOOP"})]})]}),f.jsx(ty,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx(Vl,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsx(zL,{copy:!0,size:"compact",truncate:[10,6],className:"w-full mb-3",children:e.hash}),f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Total connections (edges) to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Degree"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.degree})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Inbound vs outbound edge count — indicates traffic directionality",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"In / Out"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.inDegree," / ",e.outDegree]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Betweenness centrality (0–1) — how often this node lies on shortest paths. High value = critical relay.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.betweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed involving this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of topology edges connected to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Community cluster assignment from graph partitioning algorithm",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Community"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:["#",e.communityId]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Prefix disambiguation confidence — how certain the 2-char prefix→node mapping is (multi-factor scoring)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.prefixConfidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Recency level — active (<1h), recent (<6h), stale (<24h), inactive (>24h)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Activity"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.activityLevel})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of direct 1-hop neighbors in the topology",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Ego Size"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.neighborCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Local clustering coefficient — how interconnected this node's neighbors are (0 = none, 1 = fully connected)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Clustering"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.clusteringCoeff.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Average betweenness centrality of this node's direct neighbors",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Nbr Btw."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.avgNeighborBetweenness.toFixed(3)})]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all connected edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edge Conf."})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(n.avgEdgeConfidence*100).toFixed(0),"%"]})]}),n.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgRssi.toFixed(1)," dBm"]})]}),n.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgSnr.toFixed(1)," dB"]})]})]})]}),a&&!a.insufficientData&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[f.jsx(be,{content:"RF-grounded TX delay recommendation from centralized topology engine. Anchored to MeshCore firmware defaults with observer bias correction.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase tracking-wide cursor-help",children:"TX Delay Recommendation"})}),f.jsxs("div",{className:"flex items-center gap-1",children:[a.networkRole&&f.jsx(Bi,{color:tR[a.networkRole],compact:!0,children:a.networkRole}),a.dataConfidence&&f.jsx(Bi,{color:iR[a.dataConfidence],compact:!0,children:a.dataConfidence})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:`Flood TX delay factor (firmware default: ×${nR})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:w0(a.floodFactor)})]}),f.jsxs("div",{children:[f.jsx(be,{content:`Direct TX delay factor (firmware default: ×${sR})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direct"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:w0(a.directFactor)})]})]}),a.rationale&&f.jsx("div",{className:"mt-1 text-[9px] text-fg-muted leading-snug",children:a.rationale}),a.observationSymmetry!=null&&a.observationSymmetry<.6&&f.jsxs("div",{className:"mt-1 text-[9px] text-sys-amber/70 leading-snug",children:["⚠ Low observation symmetry (",(a.observationSymmetry*100).toFixed(0),"%) — recommendation damped toward firmware defaults"]}),f.jsxs("button",{onClick:async()=>{const h=`set txdelay ${a.floodFactor.toFixed(1)}
set direct.txdelay ${a.directFactor.toFixed(1)}`;await $L(h),d(!0),setTimeout(()=>d(!1),1500)},className:"mt-1.5 flex items-center gap-1 text-[9px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[u?f.jsx(ey,{className:"w-3 h-3 text-sys-green"}):f.jsx(UL,{className:"w-3 h-3"}),u?"Copied!":"Copy CLI commands"]})]}),s&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 text-[10px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[f.jsx(jL,{className:"w-3 h-3"}),"Expand 2-hop neighborhood"]})}),r&&r.length>0&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("button",{onClick:()=>c(h=>!h),className:"flex items-center justify-between w-full text-[9px] text-fg-muted uppercase tracking-wide cursor-pointer hover:text-fg-secondary transition-base",children:[f.jsxs("span",{children:["Neighbors (",r.length,")"]}),f.jsx(Pc,{className:`w-3 h-3 transition-transform ${l?"rotate-180":""}`})]}),l&&f.jsx("div",{className:"mt-1.5 max-h-32 overflow-y-auto space-y-0.5",children:r.map(h=>f.jsxs("button",{onClick:()=>o==null?void 0:o(h.hash),className:"w-full flex items-center gap-2 px-1.5 py-1 radius-badge hover-bg transition-base text-left group",children:[f.jsx("code",{className:"text-[10px] text-sys-blue shrink-0 tabular-nums",children:h.prefix}),f.jsx("span",{className:"text-[10px] text-fg-secondary truncate flex-1",children:h.name||"—"}),h.avgSnr!=null&&f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:[h.avgSnr.toFixed(0)," dB"]}),h.avgRssi!=null&&f.jsx("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:h.avgRssi.toFixed(0)}),f.jsxs("span",{className:"text-[9px] text-fg-muted/60 tabular-nums shrink-0",children:[(h.edgeConfidence*100).toFixed(0),"%"]})]},h.hash))})]})]})]})}),RS=U.memo(function({metrics:e,onClose:t}){const n=Object.entries(e.communities).sort(([,r],[,o])=>o-r),s=Object.entries(e.nodeClasses).sort(([,r],[,o])=>o-r);return f.jsxs(ma.div,{variants:iy,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(BS,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:"Subgraph Analysis"}),f.jsxs(Bi,{color:"violet",compact:!0,children:[e.nodeCount," nodes"]})]}),f.jsx(ty,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx(Vl,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Nodes"}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.nodeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Edges where both endpoints are within the lasso selection",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Internal Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean betweenness centrality of selected nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.avgBetweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean edge disambiguation confidence for internal edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.avgConfidence*100).toFixed(0),"%"]})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Communities"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary",children:["#",r,"×",o]},r))})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Node Types"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary capitalize",children:[r,"×",o]},r))})]})]}),e.nodeCount>1&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("div",{className:"text-[9px] text-fg-muted flex items-center gap-1 flex-wrap",children:[f.jsx(be,{content:"Fraction of possible edges that exist — 2E / N(N-1)",children:f.jsxs("span",{className:"cursor-help",children:["Density: ",(2*e.edgeCount/(e.nodeCount*(e.nodeCount-1))*100).toFixed(1),"%"]})}),f.jsx("span",{children:"·"}),f.jsx(be,{content:"Mean connections per node — 2E / N",children:f.jsxs("span",{className:"cursor-help",children:["Avg Degree: ",(2*e.edgeCount/e.nodeCount).toFixed(1)]})}),e.avgPathHealth!=null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"·"}),f.jsx(be,{content:"Average health score of paths within the selection",children:f.jsxs("span",{className:"cursor-help",children:["Path Health: ",(e.avgPathHealth*100).toFixed(0),"%"]})})]})]})})]})]})});function dte(){return f.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 text-center px-8",children:[f.jsx("div",{className:"p-4 radius-pill bg-subtle-fill",children:f.jsx(MS,{className:"w-8 h-8 text-fg-muted"})}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("h2",{className:"type-subheading text-fg-primary",children:"No Topology Data"}),f.jsx("p",{className:"type-body text-fg-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed."})]}),f.jsxs("div",{className:"flex items-center gap-2 type-data-xs text-fg-muted",children:[f.jsx(_g,{className:"w-4 h-4 animate-pulse"}),f.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}const pi=U.memo(function({label:e,value:t,onChange:n,min:s,max:r,step:o}){const[a,l]=U.useState(!1),[c,u]=U.useState(""),d=U.useRef(null),h=U.useCallback(()=>{const m=parseFloat(c);isNaN(m)||n(Math.min(r,Math.max(s,Math.round(m/o)*o))),l(!1)},[c,n,s,r,o]),p=U.useCallback(()=>{u(t.toFixed(2)),l(!0),setTimeout(()=>{var m;return(m=d.current)==null?void 0:m.select()},0)},[t]);return f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[10px] text-fg-muted",children:e}),a?f.jsx("input",{ref:d,type:"number",value:c,onChange:m=>u(m.target.value),onBlur:h,onKeyDown:m=>{m.key==="Enter"&&h(),m.key==="Escape"&&l(!1)},min:s,max:r,step:o,className:"w-14 text-right text-[10px] text-fg-secondary tabular-nums bg-subtle-fill radius-badge px-1 py-0.5 border border-edge-subtle focus:outline-none focus:border-sys-blue"}):f.jsx("button",{onClick:p,className:"text-[10px] text-fg-secondary tabular-nums hover:text-sys-blue cursor-text transition-colors",title:"Click to type a value",children:t.toFixed(2)})]}),f.jsx("input",{type:"range",min:s,max:r,step:o,value:t,onChange:m=>n(parseFloat(m.target.value)),className:"w-full h-1 bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"})]})}),Va=U.memo(function({label:e,checked:t,onChange:n}){return f.jsxs(ML,{className:"flex items-center justify-between",children:[f.jsx(BL,{className:"text-[10px] text-fg-muted cursor-pointer select-none",children:e}),f.jsx(OL,{enabled:t,onChange:n,size:"sm"})]})});function hte(){var e0,t0,i0,n0,s0,r0,o0,a0,l0,c0,u0,d0,h0,f0,p0;XL(UI);const i=vL(),[e,t]=U.useState(!1),n=i&&!e,s=U.useCallback(()=>{t(!0)},[]),r=xL(),o=wL(),a=WJ(o,2e3),l=SL(),c=EL(),u=CL(),d=TL(),h=kL(),p=AL(),m=IL(),y=m?HI:VI,g=m?tte:ite,_=U.useMemo(()=>nte(m),[m]),S=U.useMemo(()=>ste(m),[m]),[E,x]=U.useState(!0),[T,I]=U.useState(null),[O,H]=U.useState(null),[Q,re]=U.useState(!1),[D,de]=U.useState(""),[se,R]=U.useState(!1),[ee,F]=U.useState(!1),[q,te]=U.useState("simulation"),[Z,ae]=U.useState(!0),[J,Se]=U.useState(!1),[xe,et]=U.useState(!0),[he,yt]=U.useState(!1),[Xe,dt]=U.useState(!1),[ie,Ce]=U.useState(new Set),[Pe,X]=U.useState(!1),[We,He]=U.useState("spectral"),[bt,Vt]=U.useState(1),[pe,it]=U.useState(1),[si,yi]=U.useState(!1),[Zs,Zn]=U.useState(null),[wo,Bn]=U.useState(!1),[di,tn]=U.useState(!1),[bi,Qn]=U.useState(null),[Ss,Qs]=U.useState(null),[On,Es]=U.useState(null),[nn,Ti]=U.useState(null),[Qt,$i]=U.useState(null),vn=LL(),[So,Mr]=U.useState(!1),[ji,Br]=U.useState([]),[Cs,Js]=U.useState(0),[ic,Jt]=U.useState(null),At=U.useRef(new Mee),Jn=U.useRef(null),Ut=U.useRef(null),[Ts,er]=U.useState(null),[Or,Eo]=U.useState(null),[es,hi]=U.useState({}),[xn,ks]=U.useState(null),[ct,Fr]=U.useState({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize}),nt=U.useCallback((v,j)=>{Fr(W=>({...W,[v]:j}))},[]),wn=U.useCallback(()=>{Fr({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize})},[]);U.useEffect(()=>()=>{var v;try{(v=Ut.current)==null||v.destroy()}catch{}Ut.current=null},[]),U.useEffect(()=>{const v=j=>{var W,ue;if(!(j.target instanceof HTMLInputElement||j.target instanceof HTMLSelectElement))switch(j.key.toLowerCase()){case"f":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),(W=Ut.current)==null||W.fitView(rh));break;case"escape":se?(R(!1),de("")):T&&(I(null),(ue=Ut.current)==null||ue.unselectAllPoints());break;case"/":se||(j.preventDefault(),R(!0),setTimeout(()=>{var oe;return(oe=Jn.current)==null?void 0:oe.focus()},50));break;case" ":j.preventDefault(),Ut.current&&(E?Ut.current.pause():Ut.current.start(),x(oe=>!oe));break;case"l":ae(oe=>!oe);break}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[se,T,E]);const zr=U.useMemo(()=>new Set((r==null?void 0:r.backboneEdges)??[]),[r==null?void 0:r.backboneEdges]),tr=U.useMemo(()=>({resolution:bt,kWeight:pe}),[bt,pe]),Fn=U.useMemo(()=>{if(We!=="louvain")return null;const v=r==null?void 0:r.edges;if(!v||v.length===0||!a||a.size<3)return null;const j=Array.from(a.keys());return bS(v,j,tr).communities},[We,r==null?void 0:r.edges,a,tr]),sn=U.useMemo(()=>{var oe;if(!a||a.size===0||!e)return[];const v=[],j=(p==null?void 0:p.node_name)??((oe=p==null?void 0:p.config)==null?void 0:oe.node_name)??null,W=m?"#171717":"#EFF0F1";let ue=1;for(const Ke of a.values())Ke.degree>ue&&(ue=Ke.degree);for(const Ke of a.values()){const ge=Ke,Ee=ge.degree>0?Math.log10(ge.degree+1)/Math.log10(ue+1):0,Ot=CS+Math.min(1,Ee)*(fg-CS),Di=ge.betweenness*TS,is=ge.isLocal?fg:Math.min(fg+TS,Ot+Di),ns=(Fn==null?void 0:Fn.get(ge.hash))??ge.communityId,$t=Pe&&ns>=0?g[ns%g.length]:y[ge.nodeClass],ye=ete[ge.activityLevel]??1,qt=ge.isLocal?y.local:ye<1?pg($t,W,ye):$t,rc=ge.isLocal?j??ge.name:ge.name;v.push({id:ge.hash,label:rc?`${ge.prefix} ${rc}`:ge.prefix,color:qt,size:is,nodeClass:ge.nodeClass,name:rc,prefix:ge.prefix,packetCount:ge.packetCount,isLocal:ge.isLocal,isHub:ge.isHub,isGateway:ge.isGateway,isBackbone:ge.isBackbone,isMobile:ge.isMobile,isZeroHop:ge.isZeroHop,isGhost:ge.isGhost,degree:ge.degree,betweenness:ge.betweenness,communityId:(Fn==null?void 0:Fn.get(ge.hash))??ge.communityId,activityLevel:ge.activityLevel,prefixConfidence:ge.prefixConfidence,hasCollision:ge.hasCollision,inDegree:ge.inDegree,outDegree:ge.outDegree,isInLoop:ge.isInLoop,avgRssi:ge.avgRssi,avgSnr:ge.avgSnr})}for(const Ke of l){const ge=`ghost-${Ke.prefix}`;if(v.some(Ot=>Ot.id===ge))continue;const Ee=pg(y.ghost,W,.6);v.push({id:ge,label:`? ${Ke.prefix.toUpperCase()}`,color:Ee,size:Jee,nodeClass:"ghost",name:null,prefix:Ke.prefix,packetCount:Ke.observationCount,isLocal:!1,isHub:!1,isGateway:!1,isBackbone:!1,isMobile:!1,isZeroHop:!1,isGhost:!0,degree:Ke.commonNeighbors.size,betweenness:0,communityId:-1,activityLevel:"active",prefixConfidence:Ke.confidence,hasCollision:!1,inDegree:0,outDegree:0,isInLoop:!1,avgRssi:null,avgSnr:null})}return v},[a,e,p==null?void 0:p.node_name,(e0=p==null?void 0:p.config)==null?void 0:e0.node_name,y,m,l,g,Pe,Fn]),L=U.useMemo(()=>new Set(sn.map(v=>v.id)),[sn]),V=U.useMemo(()=>{const v=new Map;if(!a)return v;for(const j of a.values())v.set(j.hash,j.name);return v},[a]),C=U.useMemo(()=>{const v=(r==null?void 0:r.edges)??[];if(!v.length||!e)return[];const j=[],W=(r==null?void 0:r.edgeBetweenness)??new Map;for(const oe of v){if(!L.has(oe.fromHash)||!L.has(oe.toHash))continue;const Ke=ote(oe,zr),ge=AS(Ke,oe.avgConfidence,m),Ee=W.get(oe.key)??0,Ot=Ee>0?.5+Ee*4:.5+Math.min(1,oe.certainCount/50)*2;j.push({source:oe.fromHash,target:oe.toHash,color:ge,width:Ot,key:oe.key,packetCount:oe.packetCount,certainCount:oe.certainCount,confidence:oe.avgConfidence,symmetryRatio:oe.symmetryRatio,dominantDirection:oe.dominantDirection,isBackbone:zr.has(oe.key),isLoopEdge:oe.isLoopEdge??!1,isDirectPath:oe.isDirectPathEdge,isZeroHop:oe.isZeroHop??!1,isGhost:!1,forwardCount:oe.forwardCount,reverseCount:oe.reverseCount,floodCount:oe.floodCount,directCount:oe.directCount,avgRssi:oe.avgRssi??null,avgSnr:oe.avgSnr??null,strength:oe.strength,fromName:V.get(oe.fromHash)??null,toName:V.get(oe.toHash)??null,edgeType:Ke})}const ue=m?$I:jI;for(const oe of l){const Ke=`ghost-${oe.prefix}`;if(L.has(Ke))for(const ge of oe.commonNeighbors)L.has(ge)&&j.push({source:Ke,target:ge,color:ue.ghost,width:.4,key:`ghost-${oe.prefix}-${ge}`,packetCount:oe.observationCount,certainCount:0,confidence:oe.confidence,symmetryRatio:0,dominantDirection:"balanced",isBackbone:!1,isLoopEdge:!1,isDirectPath:!1,isZeroHop:!1,isGhost:!0,forwardCount:0,reverseCount:0,floodCount:0,directCount:0,avgRssi:null,avgSnr:null,strength:oe.confidence,fromName:null,toName:V.get(ge)??null,edgeType:"ghost"})}return j},[r==null?void 0:r.edges,r==null?void 0:r.edgeBetweenness,e,L,m,zr,V,l]),G=(i0=(t0=p==null?void 0:p.config)==null?void 0:t0.radio)==null?void 0:i0.frequency,ne=(s0=(n0=p==null?void 0:p.config)==null?void 0:n0.radio)==null?void 0:s0.bandwidth,Te=(o0=(r0=p==null?void 0:p.config)==null?void 0:r0.radio)==null?void 0:o0.spreading_factor,It=(l0=(a0=p==null?void 0:p.config)==null?void 0:a0.radio)==null?void 0:l0.tx_power,st=(u0=(c0=p==null?void 0:p.config)==null?void 0:c0.radio)==null?void 0:u0.coding_rate,Je=U.useMemo(()=>{if(!r||!di)return null;const v={frequency:G,bandwidth:On!=null?On*1e3:ne,spreading_factor:Ss??Te,tx_power:bi??It,coding_rate:nn??st},j={};return Qt!=null&&(j.sensitivityOverrideDbm=Qt),vn!=null&&(j.observedNoiseFloorDbm=vn),Cee(r,v,j)},[r,di,G,ne,Te,It,st,bi,Ss,On,nn,Qt,vn]),vi=U.useMemo(()=>{if(!Je)return null;const v=new Map;for(const j of Je)v.set(j.edgeKey,j);return v},[Je]),ht=U.useMemo(()=>!Je||Je.length===0?null:Tee(Je),[Je]),ir=U.useMemo(()=>{if(!di||!vi)return C;const v=m?"#303038":"#D0D0D8";return C.map(j=>{const W=vi.get(j.key);return!W||!W.hasData?{...j,color:v,width:.3}:{...j,color:Aee(W,"margin"),width:Iee(W),linkBudget:W}})},[C,di,vi,m]),Lt=U.useMemo(()=>ie.size===0?sn:sn.filter(v=>!ie.has(v.nodeClass)),[sn,ie]),Pi=U.useMemo(()=>{if(ie.size===0)return ir;const v=new Set(Lt.map(j=>j.id));return ir.filter(j=>v.has(j.source)&&v.has(j.target))},[ir,Lt,ie]),Ra=U.useRef([]);U.useEffect(()=>{Ra.current=Pi},[Pi]);const ld=U.useMemo(()=>{const v=new Map;for(const j of C)v.set(j.source,(v.get(j.source)??0)+1),v.set(j.target,(v.get(j.target)??0)+1);return v},[C]),As=U.useMemo(()=>{const v=new Map;for(const j of sn)v.set(j.id,j);return v},[sn]);Lt.length===0&&(Ts!==null||Or!==null||xn!==null)&&(er(null),Eo(null),hi({}),ks(null)),U.useEffect(()=>{if(Lt.length===0)return;let v=!1,j=null;const ue=setTimeout(async()=>{try{ks(null),console.log("[MeshGraph] Preparing %d points, %d links",Lt.length,Pi.length);const oe=Lt.map(Ot=>({id:Ot.id,label:Ot.label,color:Ot.color,size:Ot.size,communityId:String(Ot.communityId)})),Ke=Pi.map(Ot=>({source:Ot.source,target:Ot.target,color:Ot.color,width:Ot.width})),ge={points:{pointIdBy:"id",pointColorBy:"color",pointColorStrategy:"direct",pointDefaultColor:m?"#9CA3AF":"#374151",pointLabelBy:"label",pointSizeBy:"size",pointSizeStrategy:"direct",pointDefaultSize:8,pointSizeScale:1,pointGreyoutOpacity:.3,pointIncludeColumns:["communityId"]},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",linkColorStrategy:"direct",linkDefaultColor:m?"#6B7280":"#9CA3AF",linkWidthBy:"width",linkWidthStrategy:"direct",linkDefaultWidth:1,linkWidthScale:1,linkGreyoutOpacity:.1}},Ee=await Promise.race([FQ(ge,oe,Ke),new Promise((Ot,Di)=>{j=setTimeout(()=>Di(new Error("Data preparation timed out after 10s")),1e4)})]);if(j&&clearTimeout(j),v)return;if(console.log("[MeshGraph] prepareCosmographData returned:",{hasResult:!!Ee,hasPoints:!!(Ee!=null&&Ee.points),hasLinks:!!(Ee!=null&&Ee.links),configKeys:Ee?Object.keys(Ee.cosmographConfig??{}).length:0}),!Ee||!Ee.points){console.warn("[MeshGraph] prepareCosmographData returned no points data:",Ee),ks("Graph data preparation returned empty — try refreshing the page");return}er(Ee.points),Eo(Ee.links??null),hi(Ee.cosmographConfig??{})}catch(oe){if(j&&clearTimeout(j),v)return;console.error("[MeshGraph] Data preparation failed:",oe),ks(oe instanceof Error?oe.message:"Unknown preparation error")}},100);return()=>{v=!0,clearTimeout(ue),j&&clearTimeout(j)}},[Lt,Pi,m]);const Bv=U.useCallback(v=>{v&&(Ut.current=v,v.start(),setTimeout(()=>{v.fitView(rh)},1500))},[]),GI=U.useCallback(()=>{var v;(v=Ut.current)==null||v.fitView(rh)},[]),WI=U.useCallback(()=>{const v=Ut.current;v&&(E?v.pause():v.start(),x(!E))},[E]),cd=U.useCallback(async v=>{const j=Ut.current,W=As.get(v);if(W){if(j)try{const ue=await j.getPointIndicesByIds([v]);ue&&ue.length>0&&ue[0]!==void 0&&(j.zoomToPoint(ue[0],Zee,2.5),j.selectPoint(ue[0],!1,!0))}catch{}H(null),I({hash:v,name:W.name,prefix:W.prefix,nodeClass:W.nodeClass,packetCount:W.packetCount,edgeCount:ld.get(v)??0,degree:W.degree,betweenness:W.betweenness,communityId:W.communityId,isLocal:W.isLocal,isHub:W.isHub,isGateway:W.isGateway,isBackbone:W.isBackbone,isMobile:W.isMobile,isZeroHop:W.isZeroHop,isGhost:W.isGhost,isInLoop:W.isInLoop,activityLevel:W.activityLevel,prefixConfidence:W.prefixConfidence,hasCollision:W.hasCollision,inDegree:W.inDegree,outDegree:W.outDegree,avgRssi:W.avgRssi,avgSnr:W.avgSnr})}},[As,ld]),Ov=U.useRef(null);U.useEffect(()=>{Ov.current=vi},[vi]);const Fv=U.useCallback(v=>{var ue;if(v===void 0){H(null);return}const j=Ra.current[v];if(!j)return;const W=(ue=Ov.current)==null?void 0:ue.get(j.key);H(W&&!j.linkBudget?{...j,linkBudget:W}:j),I(null)},[]),zv=U.useCallback(async(v,j,W)=>{var oe;if(v===void 0){I(null),Zn(null),(oe=Ut.current)==null||oe.unselectAllPoints();return}H(null);const ue=Ut.current;if(ue)try{const Ke=await ue.getPointIdsByIndices([v]);if(!Ke||Ke.length===0)return;const ge=Ke[0],Ee=As.get(ge);if(!Ee)return;ue.selectPoint(v,!1,!0),I({hash:ge,name:Ee.name,prefix:Ee.prefix,nodeClass:Ee.nodeClass,packetCount:Ee.packetCount,edgeCount:ld.get(ge)??0,degree:Ee.degree,betweenness:Ee.betweenness,communityId:Ee.communityId,isLocal:Ee.isLocal,isHub:Ee.isHub,isGateway:Ee.isGateway,isBackbone:Ee.isBackbone,isMobile:Ee.isMobile,isZeroHop:Ee.isZeroHop,isGhost:Ee.isGhost,isInLoop:Ee.isInLoop,activityLevel:Ee.activityLevel,prefixConfidence:Ee.prefixConfidence,hasCollision:Ee.hasCollision,inDegree:Ee.inDegree,outDegree:Ee.outDegree,avgRssi:Ee.avgRssi,avgSnr:Ee.avgSnr})}catch{}},[As,ld]),nc=U.useMemo(()=>{if(!se||!D.trim())return[];const v=D.toLowerCase();return sn.filter(j=>{var W;return j.prefix.toLowerCase().includes(v)||((W=j.name)==null?void 0:W.toLowerCase().includes(v))||j.id.toLowerCase().includes(v)}).slice(0,8)},[sn,D,se]),Uv=U.useCallback(v=>{R(!1),de(""),cd(v.id)},[cd]),$v=U.useCallback(()=>{re(v=>!v)},[]),YI=U.useCallback(v=>{Ce(j=>{const W=new Set(j);return W.has(v)?W.delete(v):W.add(v),W})},[]),qI=U.useCallback(()=>{X(v=>{const j=!v,W=Ut.current;return W&&W.start(.5),j})},[]),XI=U.useCallback(()=>{yi(v=>{const j=!v,W=Ut.current;return W&&(j?W.activatePolygonalSelection():(W.deactivatePolygonalSelection(),Zn(null),W.unselectAllPoints())),j})},[]),jv=U.useCallback(async()=>{const v=Ut.current;if(!v)return;await new Promise($t=>setTimeout($t,80));const j=v.getSelectedPointIndices();if(!j||j.length===0){Zn(null);return}const W=await v.getPointIdsByIndices(j);if(!W||W.length===0){Zn(null);return}const ue=new Set(W);let oe=0,Ke=0;for(const $t of Ra.current)ue.has($t.source)&&ue.has($t.target)&&(oe++,Ke+=$t.confidence);let ge=0;const Ee={},Ot={};for(const $t of W){const ye=As.get($t);ye&&(ge+=ye.betweenness,Ee[ye.communityId]=(Ee[ye.communityId]??0)+1,Ot[ye.nodeClass]=(Ot[ye.nodeClass]??0)+1)}const Di=new Set;for(const $t of W){const ye=As.get($t);ye&&Di.add(ye.prefix.toLowerCase())}let is=0,ns=0;for(const $t of d)if($t.hops.length>=2){const ye=$t.hops[0].toLowerCase(),qt=$t.hops[$t.hops.length-1].toLowerCase();Di.has(ye)&&Di.has(qt)&&(is+=$t.healthScore,ns++)}Zn({nodeCount:W.length,edgeCount:oe,avgBetweenness:W.length>0?ge/W.length:0,avgConfidence:oe>0?Ke/oe:0,avgPathHealth:ns>0?is/ns:null,communities:Ee,nodeClasses:Ot}),I(null),H(null)},[As,d]),Hv=U.useCallback(()=>{var v;Zn(null),(v=Ut.current)==null||v.unselectAllPoints()},[]),Vv=U.useMemo(()=>{var $t;if(!T)return null;const v=T.hash,j=new Set;for(const ye of Pi)ye.source===v?j.add(ye.target):ye.target===v&&j.add(ye.source);if(j.size===0)return{clusteringCoeff:0,avgNeighborBetweenness:0,neighborCount:0,avgEdgeConfidence:0,avgRssi:null,avgSnr:null};let W=0;for(const ye of Pi)j.has(ye.source)&&j.has(ye.target)&&W++;const ue=j.size,oe=ue>1?2*W/(ue*(ue-1)):0;let Ke=0;for(const ye of j)Ke+=(($t=As.get(ye))==null?void 0:$t.betweenness)??0;let ge=0,Ee=0,Ot=0,Di=0,is=0,ns=0;for(const ye of Pi)(ye.source===v||ye.target===v)&&(ge+=ye.confidence,Ee++,ye.avgRssi!=null&&(Ot+=ye.avgRssi,Di++),ye.avgSnr!=null&&(is+=ye.avgSnr,ns++));return{clusteringCoeff:Math.min(1,oe),avgNeighborBetweenness:Ke/ue,neighborCount:ue,avgEdgeConfidence:Ee>0?ge/Ee:0,avgRssi:Di>0?Ot/Di:null,avgSnr:ns>0?is/ns:null}},[T,Pi,As]),Gv=U.useMemo(()=>!T||!h?null:h.get(T.hash)??null,[T,h]),Wv=U.useMemo(()=>{if(!T)return[];const v=T.hash,j=[],W=new Set;for(const ue of Pi){let oe=null;if(ue.source===v?oe=ue.target:ue.target===v&&(oe=ue.source),!oe||W.has(oe))continue;W.add(oe);const Ke=As.get(oe);j.push({hash:oe,prefix:(Ke==null?void 0:Ke.prefix)??oe.slice(2,4).toUpperCase(),name:(Ke==null?void 0:Ke.name)??null,edgeConfidence:ue.confidence,edgeType:ue.edgeType,avgRssi:ue.avgRssi,avgSnr:ue.avgSnr})}return j.sort((ue,oe)=>oe.edgeConfidence-ue.edgeConfidence),j},[T,Pi,As]),Yv=U.useCallback(async()=>{const v=Ut.current;if(!v||!T)return;const j=await v.getPointIndicesByIds([T.hash]);if(!j||j[0]===void 0)return;const W=j[0],ue=v.getConnectedPointIndices(W)??[],oe=new Set([W,...ue]);for(const ge of ue){const Ee=v.getConnectedPointIndices(ge)??[];for(const Ot of Ee)oe.add(Ot)}const Ke=Array.from(oe);v.selectPoints(Ke),v.fitViewByIndices(Ke,rh,.15)},[T]);U.useEffect(()=>{if(!si)return;const v=j=>{var W,ue;j.key==="Escape"&&(yi(!1),(W=Ut.current)==null||W.deactivatePolygonalSelection(),Zn(null),(ue=Ut.current)==null||ue.unselectAllPoints())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[si]);const KI=U.useCallback((v,j)=>{r&&(dee(r,{format:v,dataset:j}),Bn(!1))},[r]),Hi=U.useMemo(()=>{if(!r||!d.length)return null;const v=r.edges??[];return v.length===0?null:Yee(d,v)},[r,d]),Co=U.useMemo(()=>{const v=r==null?void 0:r.edges;if(!v||v.length===0||!a||a.size<3)return null;const j=Array.from(a.keys());return YL(v,j)},[r==null?void 0:r.edges,a]),ud=U.useMemo(()=>{if(We!=="louvain")return null;const v=r==null?void 0:r.edges;if(!v||v.length===0||!a||a.size<3)return null;const j=Array.from(a.keys());return bS(v,j,tr)},[We,r==null?void 0:r.edges,a,tr]);U.useEffect(()=>{if(!r)return;const v=new Map;for(const[W,ue]of r.nodeMetrics)v.set(W,ue.name);const j=At.current.update(r,v);j.totalCount>0&&(Br(At.current.getLog()),Js(W=>W+j.totalCount))},[r]);const ZI=U.useCallback(()=>{Js(0),Mr(v=>!v)},[]),Ur=U.useMemo(()=>Qee(Co,m),[Co,m]),dd=f.jsxs("div",{className:"absolute top-0 left-0 right-0 z-20 px-4 py-3 pointer-events-none flex items-start justify-between",children:[f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2 sm:gap-3 pointer-events-auto",children:[f.jsx(_0,{className:"w-5 h-5 sm:w-6 sm:h-6 text-icon-page-title"}),f.jsx("span",{children:"MeshGraph"}),f.jsx(Bi,{color:"violet",compact:!0,children:"Analytics"})]}),Ur&&f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-2",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Mesh Resilience Score"}),f.jsx("div",{className:"text-fg-secondary",children:"Derived from the Fiedler eigenvalue (λ₂) — the second-smallest eigenvalue of the graph Laplacian. Measures how well-connected the mesh is and how resistant it is to partitioning."}),f.jsxs("div",{className:"space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Raw λ₂"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:(Co==null?void 0:Co.toFixed(6))??"—"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Score"}),f.jsxs("span",{className:"tabular-nums",style:{color:Ur.color},children:[Ur.score,"/100"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Grade"}),f.jsx("span",{className:"capitalize",style:{color:Ur.color},children:Ur.grade})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Grade thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.excellent[0]},children:"Excellent"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"80-100 (λ₂ > 0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.good[0]},children:"Good"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-79 (λ₂ 0.03-0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.fair[0]},children:"Fair"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30-54 (λ₂ 0.003-0.03)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.poor[0]},children:"Poor"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"10-29 (λ₂ 0.0001-0.003)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.critical[0]},children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"<10 (λ₂ ≈ 0)"})]})]}),f.jsx("div",{className:"text-[10px] text-fg-muted italic",children:"Near-zero λ₂ = one bridge away from network partition. Log-scale mapping: small λ₂ changes at low values have outsized impact."})]}),children:f.jsxs("div",{className:"pointer-events-auto surface-control radius-inner px-3 py-1.5 flex items-center gap-2 cursor-help",children:[f.jsxs("div",{className:"flex items-baseline gap-1.5",children:[f.jsx("span",{className:"text-[10px] text-fg-muted uppercase tracking-wider",children:"Resilience"}),f.jsx("span",{className:"text-lg font-semibold tabular-nums leading-none",style:{color:Ur.color},children:Ur.score})]}),f.jsx("div",{className:"w-12 h-1.5 rounded-full bg-subtle-fill overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Ur.score}%`,backgroundColor:Ur.color}})})]})})]}),ts=(v,j=!1)=>{const W="flex flex-col items-center gap-0.5 px-1.5 py-1 radius-inner transition-all duration-100 active:scale-95";return v&&j?`${W} bg-status-warning/15 text-status-warning shadow-inner`:v?`${W} bg-sys-blue/20 text-sys-blue shadow-inner`:`${W} hover:bg-white/5 hover:scale-105 text-fg-secondary`},sc=f.jsx("div",{className:"w-px h-6 bg-border-subtle/40 mx-0.5 shrink-0"}),qv=f.jsxs("div",{className:"absolute top-12 right-3 z-10 flex items-center gap-0.5 surface-control radius-inner px-1.5 py-1",children:[f.jsx(be,{content:"Visible nodes / edges in the graph",children:f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums mr-1.5 leading-none cursor-help",children:[Lt.length,f.jsx("br",{}),Pi.length]})}),sc,f.jsx(be,{content:Z?"Hide labels (L)":"Show labels (L)",children:f.jsxs("button",{onClick:()=>ae(v=>!v),className:ts(!Z,!0),children:[Z?f.jsx(RL,{className:"w-3.5 h-3.5"}):f.jsx(qL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Lbl"})]})}),f.jsx(be,{content:Pe?"Disable clustering":"Community clustering",children:f.jsxs("button",{onClick:qI,className:ts(Pe),children:[f.jsx(dR,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Grp"})]})}),f.jsx(be,{content:si?"Exit lasso (Esc)":"Lasso selection",children:f.jsxs("button",{onClick:XI,className:ts(si,!0),children:[f.jsx(BS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Sel"})]})}),sc,f.jsx(be,{content:"Legend",children:f.jsxs("button",{onClick:()=>Se(v=>!v),className:ts(J),children:[f.jsx(S0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Map"})]})}),f.jsx(be,{content:"Search (/)",children:f.jsxs("button",{onClick:()=>{R(!0),setTimeout(()=>{var v;return(v=Jn.current)==null?void 0:v.focus()},50)},className:ts(se),children:[f.jsx(E0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fnd"})]})}),sc,f.jsx(be,{content:E?"Pause (Space)":"Play (Space)",children:f.jsxs("button",{onClick:WI,className:ts(!E),children:[E?f.jsx(PL,{className:"w-3.5 h-3.5 text-sys-green"}):f.jsx(NL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:E?"Run":"Stop"})]})}),f.jsx(be,{content:"Fit view (F)",children:f.jsxs("button",{onClick:GI,className:ts(!1),children:[f.jsx(cR,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fit"})]})}),sc,f.jsx(be,{content:di?"Disable link budget":"Link budget overlay",children:f.jsxs("button",{onClick:()=>tn(v=>!v),className:ts(di),children:[f.jsx(_g,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"RF"})]})}),f.jsx(be,{content:"Anomaly log",children:f.jsxs("button",{onClick:ZI,className:`relative ${ts(So,!0)}`,children:[f.jsx(fd,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Alert"}),Cs>0&&f.jsx("span",{className:"absolute -top-1 -right-0.5 w-3 h-3 rounded-full bg-status-danger text-[7px] font-bold text-white flex items-center justify-center",children:Cs>9?"9+":Cs})]})}),f.jsx(be,{content:"Export topology",children:f.jsxs("button",{onClick:()=>Bn(v=>!v),className:ts(wo),children:[f.jsx(y0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Exp"})]})}),f.jsx(be,{content:"Settings",children:f.jsxs("button",{onClick:()=>F(v=>!v),className:ts(ee),children:[f.jsx(C0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Cfg"})]})}),sc,f.jsx(be,{content:Q?"Exit fullscreen":"Fullscreen",children:f.jsxs("button",{onClick:$v,className:ts(Q),children:[Q?f.jsx(x0,{className:"w-3.5 h-3.5"}):f.jsx(DS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Max"})]})})]}),Xv=f.jsxs(sh,{id:"settings",title:"Graph Settings",icon:f.jsx(C0,{}),open:ee,onClose:()=>F(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-308:600,y:60},defaultSize:{width:288,height:420},minSize:{width:260,height:200},maxSize:{width:400,height:600},headerActions:f.jsx(be,{content:"Reset to defaults",children:f.jsx("button",{onClick:wn,className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx(T0,{className:"w-2.5 h-2.5 text-fg-muted"})})}),children:[f.jsx("div",{className:"flex border-b border-edge-subtle",children:["simulation","points","links","rendering"].map(v=>f.jsx("button",{onClick:()=>te(v),className:`flex-1 px-2 py-1.5 text-[10px] font-medium capitalize transition-colors ${q===v?"text-sys-blue border-b-2 border-sys-blue":"text-fg-muted hover:text-fg-secondary"}`,children:v},v))}),f.jsxs("div",{className:"p-3 space-y-3",children:[q==="simulation"&&f.jsxs(f.Fragment,{children:[f.jsx(pi,{label:"Gravity",value:ct.simulationGravity,onChange:v=>nt("simulationGravity",v),min:0,max:1,step:.01}),f.jsx(pi,{label:"Repulsion",value:ct.simulationRepulsion,onChange:v=>nt("simulationRepulsion",v),min:0,max:5,step:.1}),f.jsx(pi,{label:"Link Spring",value:ct.simulationLinkSpring,onChange:v=>nt("simulationLinkSpring",v),min:0,max:2,step:.05}),f.jsx(pi,{label:"Link Distance",value:ct.simulationLinkDistance,onChange:v=>nt("simulationLinkDistance",v),min:1,max:100,step:1}),f.jsx(pi,{label:"Friction",value:ct.simulationFriction,onChange:v=>nt("simulationFriction",v),min:0,max:1,step:.01}),f.jsx(pi,{label:"Center Force",value:ct.simulationCenter,onChange:v=>nt("simulationCenter",v),min:0,max:1,step:.01}),f.jsx(pi,{label:"Decay",value:ct.simulationDecay,onChange:v=>nt("simulationDecay",v),min:100,max:2e4,step:100}),f.jsx(pi,{label:"Repulsion Theta",value:ct.simulationRepulsionTheta,onChange:v=>nt("simulationRepulsionTheta",v),min:.1,max:3,step:.05}),f.jsx(pi,{label:"Mouse Repulsion",value:ct.simulationRepulsionFromMouse,onChange:v=>nt("simulationRepulsionFromMouse",v),min:0,max:10,step:.5})]}),q==="points"&&f.jsxs(f.Fragment,{children:[f.jsx(pi,{label:"Size Scale",value:ct.pointSizeScale,onChange:v=>nt("pointSizeScale",v),min:.1,max:5,step:.1}),f.jsx(pi,{label:"Opacity",value:ct.pointOpacity,onChange:v=>nt("pointOpacity",v),min:0,max:1,step:.05}),f.jsx(pi,{label:"Greyout Opacity",value:ct.pointGreyoutOpacity,onChange:v=>nt("pointGreyoutOpacity",v),min:0,max:1,step:.05}),f.jsx(Va,{label:"Scale on Zoom",checked:ct.scalePointsOnZoom,onChange:v=>nt("scalePointsOnZoom",v)}),f.jsx(Va,{label:"Hover Ring",checked:ct.renderHoveredPointRing,onChange:v=>nt("renderHoveredPointRing",v)})]}),q==="links"&&f.jsxs(f.Fragment,{children:[f.jsx(Va,{label:"Show Links",checked:ct.renderLinks,onChange:v=>nt("renderLinks",v)}),f.jsx(Va,{label:"Curved Links",checked:ct.curvedLinks,onChange:v=>nt("curvedLinks",v)}),f.jsx(Va,{label:"Show Arrows",checked:ct.linkDefaultArrows,onChange:v=>nt("linkDefaultArrows",v)}),f.jsx(pi,{label:"Width Scale",value:ct.linkWidthScale,onChange:v=>nt("linkWidthScale",v),min:.1,max:5,step:.1}),f.jsx(pi,{label:"Opacity",value:ct.linkOpacity,onChange:v=>nt("linkOpacity",v),min:0,max:1,step:.05}),f.jsx(pi,{label:"Greyout Opacity",value:ct.linkGreyoutOpacity,onChange:v=>nt("linkGreyoutOpacity",v),min:0,max:1,step:.05}),ct.curvedLinks&&f.jsx(pi,{label:"Curve Weight",value:ct.curvedLinkWeight,onChange:v=>nt("curvedLinkWeight",v),min:0,max:1,step:.05}),ct.linkDefaultArrows&&f.jsx(pi,{label:"Arrow Size",value:ct.linkArrowsSizeScale,onChange:v=>nt("linkArrowsSizeScale",v),min:.1,max:3,step:.1}),f.jsx(Va,{label:"Scale on Zoom",checked:ct.scaleLinksOnZoom,onChange:v=>nt("scaleLinksOnZoom",v)})]}),q==="rendering"&&f.jsxs(f.Fragment,{children:[f.jsx(pi,{label:"Space Size",value:ct.spaceSize,onChange:v=>nt("spaceSize",v),min:1024,max:16384,step:512}),f.jsx("div",{className:"pt-2 border-t border-edge-subtle/50",children:f.jsx("p",{className:"text-[9px] text-fg-muted",children:"Space size defines the simulation boundary. Larger values allow more spread."})})]})]})]}),QI=[{label:"Full Topology (JSON)",format:"json",dataset:"full",desc:"All data: nodes, edges, paths, TX delay"},{label:"Gephi Graph (GEXF)",format:"gexf",dataset:"full",desc:"Import into Gephi for advanced analysis"},{label:"Nodes (CSV)",format:"csv",dataset:"nodes",desc:"Node metrics: centrality, class, signal"},{label:"Edges (CSV)",format:"csv",dataset:"edges",desc:"Edge metrics: confidence, symmetry, type"},{label:"Path Health (CSV)",format:"csv",dataset:"pathHealth",desc:"Route health scores and trends"},{label:"TX Delay (CSV)",format:"csv",dataset:"txDelay",desc:"TX delay recommendations per node"}],Kv=f.jsxs(sh,{id:"export",title:"Export Topology",icon:f.jsx(y0,{}),open:wo,onClose:()=>Bn(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-280:600,y:100},defaultSize:{width:256,height:320},minSize:{width:220,height:150},autoHeight:!0,children:[f.jsx("div",{className:"py-1",children:QI.map(({label:v,format:j,dataset:W,desc:ue})=>f.jsxs("button",{onClick:()=>KI(j,W),className:"w-full flex flex-col px-3 py-2 text-left hover-bg transition-base",children:[f.jsx("span",{className:"text-[11px] font-medium text-fg-primary",children:v}),f.jsx("span",{className:"text-[9px] text-fg-muted",children:ue})]},`${j}-${W}`))}),f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[((d0=r==null?void 0:r.nodeMetrics)==null?void 0:d0.size)??0," nodes · ",((h0=r==null?void 0:r.validatedEdges)==null?void 0:h0.length)??0," edges"]})})]}),JI={info:{dot:"bg-sys-blue",text:"text-fg-secondary"},warning:{dot:"bg-status-warning",text:"text-status-warning"},critical:{dot:"bg-status-danger",text:"text-status-danger"}},eL={"edge-appeared":"Link Discovered","edge-disappeared":"Link Lost","ghost-appeared":"Ghost Discovered","ghost-disappeared":"Ghost Resolved","betweenness-shift":"Traffic Rerouting","community-change":"Community Change","class-change":"Role Change","node-appeared":"Node Appeared","node-disappeared":"Node Dropped","snr-degradation":"SNR Degradation","asymmetry-shift":"Asymmetry Shift"},Ni=(v,j,W)=>j==null||j===""?null:f.jsxs("div",{className:"flex justify-between gap-2",children:[f.jsx("span",{className:"text-fg-muted",children:v}),f.jsx("span",{className:`tabular-nums text-right ${W??"text-fg-secondary"}`,children:j})]}),tL=v=>{const j=[];return v.isZeroHop&&j.push({label:"Zero-Hop",color:"text-status-warning"}),v.isDirectPath&&j.push({label:"Direct",color:"text-sys-blue"}),v.isBackbone&&j.push({label:"Backbone",color:"text-fg-primary"}),v.isLoop&&j.push({label:"Loop",color:"text-sys-indigo"}),j.length===0?null:f.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:j.map(W=>f.jsx("span",{className:`text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill ${W.color}`,children:W.label},W.label))})},iL=(v,j)=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[(v.fromClass||v.toClass)&&f.jsxs("div",{className:"flex items-center gap-1 text-fg-muted",children:[f.jsx("span",{className:"capitalize",children:v.fromClass??"?"}),f.jsx("span",{className:"text-fg-muted/40",children:"↔"}),f.jsx("span",{className:"capitalize",children:v.toClass??"?"})]}),j==="edge-appeared"&&v.packetCount>0&&f.jsxs(f.Fragment,{children:[Ni("Packets",v.packetCount),Ni("Confidence",`${(v.confidence*100).toFixed(0)}%`,v.confidence>=.8?"text-sys-green":v.confidence>=.5?"text-sys-indigo":"text-signal-poor"),Ni("Symmetry",`${(v.symmetryRatio*100).toFixed(0)}%`)]}),v.isZeroHop&&v.avgRssi!=null&&Ni("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.isZeroHop&&v.avgSnr!=null&&Ni("SNR",`${v.avgSnr.toFixed(1)} dB`),v.fromBetweenness!=null&&v.fromBetweenness>.01&&Ni(`${v.fromName??"A"} centrality`,v.fromBetweenness.toFixed(3)),v.toBetweenness!=null&&v.toBetweenness>.01&&Ni(`${v.toName??"B"} centrality`,v.toBetweenness.toFixed(3)),tL(v)]}),nL=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"capitalize font-medium text-fg-secondary",children:v.nodeClass}),v.isZeroHop&&f.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill text-status-warning",children:"Neighbor"})]}),Ni("Degree",v.degree),v.betweenness>.01&&Ni("Betweenness",v.betweenness.toFixed(3)),Ni("Packets",v.packetCount),Ni("Community",`#${v.communityId}`),Ni("Activity",v.activityLevel),v.avgRssi!=null&&Ni("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.avgSnr!=null&&Ni("SNR",`${v.avgSnr.toFixed(1)} dB`)]}),sL=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[v.previousValue!=null&&v.currentValue!=null&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-fg-muted font-mono",children:typeof v.previousValue=="number"?v.previousValue.toFixed(3):v.previousValue}),f.jsx("span",{className:"text-fg-muted/40",children:"→"}),f.jsx("span",{className:"text-fg-secondary font-mono",children:typeof v.currentValue=="number"?v.currentValue.toFixed(3):v.currentValue}),typeof v.previousValue=="number"&&typeof v.currentValue=="number"&&f.jsxs("span",{className:v.currentValue>v.previousValue?"text-sys-green":"text-signal-poor",children:["(",v.currentValue>v.previousValue?"+":"",(v.currentValue-v.previousValue).toFixed(3),")"]})]}),v.nodeDetail&&f.jsxs(f.Fragment,{children:[Ni("Class",v.nodeDetail.nodeClass),Ni("Degree",v.nodeDetail.degree),v.nodeDetail.betweenness>.01&&Ni("Betweenness",v.nodeDetail.betweenness.toFixed(3))]})]}),rL=U.useCallback(v=>{Jt(j=>j===v?null:v)},[]),Zv=f.jsxs(sh,{id:"anomaly",title:"Anomaly Log",icon:f.jsx(fd,{}),open:So,onClose:()=>Mr(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-328:600,y:100},defaultSize:{width:308,height:400},minSize:{width:260,height:180},maxSize:{width:440,height:700},headerActions:ji.length>0?f.jsx("button",{onClick:()=>{At.current.clear(),Br([]),Jt(null)},className:"p-0.5 radius-badge hover-bg transition-base",title:"Clear all",children:f.jsx(T0,{className:"w-2.5 h-2.5 text-fg-muted"})}):void 0,children:[ji.length===0?f.jsxs("div",{className:"px-3 py-6 text-center",children:[f.jsx(fd,{className:"w-5 h-5 text-fg-muted mx-auto mb-1.5"}),f.jsx("p",{className:"text-[11px] text-fg-muted",children:"No anomalies detected yet"}),f.jsx("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:"Changes appear after topology recomputes"})]}):f.jsx("div",{className:"overflow-y-auto",children:ji.slice(0,50).map(v=>{const j=JI[v.severity],W=DL(v.detectedAt/1e3),ue=ic===v.id,oe=!!(v.edgeDetail||v.nodeDetail||v.previousValue!=null);return f.jsxs("div",{className:`border-b border-edge-subtle/50 last:border-0 transition-colors ${oe?"cursor-pointer hover-bg":""} ${ue?"bg-subtle-fill/50":""}`,onClick:oe?()=>rL(v.id):void 0,children:[f.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5",children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-1.5 ${j.dot}`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:`text-[10px] leading-tight ${j.text}`,children:v.description}),f.jsxs("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:[eL[v.category]??v.category," · ",W]})]}),oe&&f.jsx(Pc,{className:`w-3 h-3 text-fg-muted/40 shrink-0 mt-0.5 transition-transform duration-150 ${ue?"rotate-180":""}`})]}),ue&&f.jsx("div",{className:"px-3 pb-2 pl-6",children:f.jsxs("div",{className:"border-l-2 border-edge-subtle/60 pl-2 py-0.5",children:[v.edgeDetail&&iL(v.edgeDetail,v.category),v.nodeDetail&&!v.edgeDetail&&(v.category==="node-appeared"||v.category==="node-disappeared")&&nL(v.nodeDetail),(v.category==="betweenness-shift"||v.category==="community-change"||v.category==="class-change")&&sL(v)]})})]},v.id)})}),ji.length>0&&f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[ji.length," total · showing ",Math.min(ji.length,50)]})})]}),oL=[["local","Local"],["hub","Hub"],["gateway","Gateway"],["backbone","Backbone"],["neighbor","Neighbor"],["mobile","Mobile"],["ghost","Ghost"],["standard","Standard"]],aL=[{type:"zero-hop",label:"Zero-Hop RF"},{type:"direct-path",label:"Direct Path"},{type:"loop",label:"Loop"},{type:"backbone",label:"Backbone"},{type:"standard",label:"Standard"},{type:"ghost",label:"Ghost"}],lL=U.useMemo(()=>{const v={};for(const j of C)v[j.edgeType]=(v[j.edgeType]??0)+1;return v},[C]),Qv=f.jsxs(sh,{id:"legend",title:"Legend",icon:f.jsx(S0,{}),open:J,onClose:()=>Se(!1),defaultPosition:{x:12,y:60},defaultSize:{width:224,height:400},minSize:{width:200,height:150},maxSize:{width:360,height:700},autoHeight:!0,children:[f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>et(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[xe?f.jsx(Pc,{className:"w-3 h-3"}):f.jsx(Yp,{className:"w-3 h-3"}),"Nodes",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Lt.length})]}),xe&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:oL.map(([v,j])=>{const W=c[v]??0;if(W===0&&v!=="local")return null;const ue=ie.has(v);return f.jsx(be,{content:rte[v],children:f.jsxs("button",{onClick:()=>YI(v),className:`w-full flex items-center gap-2 px-2 py-1 radius-badge transition-base text-left ${ue?"opacity-40":"hover-bg"}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:y[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>yt(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[he?f.jsx(Pc,{className:"w-3 h-3"}):f.jsx(Yp,{className:"w-3 h-3"}),"Edges",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Pi.length})]}),he&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:aL.map(({type:v,label:j})=>{const W=lL[v]??0;if(W===0)return null;const ue=AS(v,.8,m);return f.jsx(be,{content:lte[v],children:f.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-help",children:[f.jsx("span",{className:"w-4 h-0.5 shrink-0 rounded-full",style:{backgroundColor:ue}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),di&&ht&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-medium text-sys-green flex items-center gap-1.5",children:[f.jsx(_g,{className:"w-3 h-3"}),"Link Budget",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[ht.analyzedEdges+ht.rssiOnlyEdges,"/",ht.totalEdges]})]}),f.jsxs("div",{className:"px-3 pb-2 space-y-0.5",children:[(()=>{const v=G&&G>1e5?G/1e6:G||915,j=Ss??Te??12,W=On??(ne&&ne>1e3?ne/1e3:ne||125),ue=nn??st??5,oe=bi??It??22,Ke=Dv(j,W,ue),ge=Qt??Ke,Ee=MI(W*1e3),Ot=vn??Ee,Di=(Je==null?void 0:Je.filter(ye=>ye.isTraceEstimated).length)??0,is=(Je==null?void 0:Je.filter(ye=>ye.isZeroHop).length)??0,ns=bi!=null||Ss!=null||On!=null||nn!=null||Qt!=null,$t="w-10 px-1 py-0 text-[10px] text-right tabular-nums bg-subtle-fill border border-edge-subtle rounded text-fg-secondary focus:outline-none focus:border-sys-blue";return f.jsxs("div",{className:"pb-1 mb-1 border-b border-edge-subtle space-y-0.5",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Frequency"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[v.toFixed(3)," MHz"]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"SF"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:j,onChange:ye=>{const qt=parseInt(ye.target.value,10);Qs(qt===(Te??12)?null:qt)},className:$t+" w-12 appearance-none",children:[7,8,9,10,11,12].map(ye=>f.jsxs("option",{value:ye,children:["SF",ye]},ye))}),Ss!=null&&f.jsx("button",{onClick:()=>Qs(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"BW"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:W,onChange:ye=>{const qt=parseFloat(ye.target.value),rc=ne&&ne>1e3?ne/1e3:ne||125;Es(qt===rc?null:qt)},className:$t+" w-14 appearance-none",children:[62.5,125,250,500].map(ye=>f.jsxs("option",{value:ye,children:[ye," kHz"]},ye))}),On!=null&&f.jsx("button",{onClick:()=>Es(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"CR"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:ue,onChange:ye=>{const qt=parseInt(ye.target.value,10);Ti(qt===(st??5)?null:qt)},className:$t+" w-12 appearance-none",children:[5,6,7,8].map(ye=>f.jsxs("option",{value:ye,children:["4/",ye]},ye))}),nn!=null&&f.jsx("button",{onClick:()=>Ti(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"TX Power"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:1,max:36,step:1,value:oe,onChange:ye=>{const qt=parseInt(ye.target.value,10);isNaN(qt)||Qn(qt)},onBlur:ye=>{const qt=parseInt(ye.target.value,10);if(isNaN(qt)){Qn(null);return}Qn(Math.max(1,Math.min(36,qt)))},className:$t}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),bi!=null&&f.jsx("button",{onClick:()=>Qn(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"Sensitivity"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:-150,max:-80,step:.5,value:Math.round(ge*10)/10,onChange:ye=>{const qt=parseFloat(ye.target.value);isNaN(qt)||$i(qt)},onBlur:ye=>{const qt=parseFloat(ye.target.value);if(isNaN(qt)){$i(null);return}$i(Math.max(-150,Math.min(-80,qt)))},className:$t+" w-12"}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),Qt!=null&&f.jsx("button",{onClick:()=>$i(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),Di>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Noise Floor"}),f.jsxs("span",{className:`text-fg-secondary tabular-nums ${vn!=null?"":"italic text-fg-muted"}`,children:[Ot.toFixed(1)," dBm",vn!=null?"":" (est.)"]})]}),ns&&f.jsx("button",{onClick:()=>{Qn(null),Qs(null),Es(null),Ti(null),$i(null)},className:"w-full text-[9px] text-sys-blue hover:underline text-center pt-0.5",children:"Reset all to radio config"}),(is>0||Di>0)&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-fg-muted",children:"Sources"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[is>0&&f.jsxs("span",{children:[is," direct"]}),is>0&&Di>0&&f.jsx("span",{className:"text-fg-muted",children:" · "}),Di>0&&f.jsxs("span",{className:"text-sys-indigo",children:[Di," trace"]})]})]})]})})(),ht.avgMarginDb!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg Margin"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[ht.avgMarginDb>0?"+":"",ht.avgMarginDb.toFixed(1)," dB"]})]}),["excellent","good","fair","marginal","critical"].map(v=>{const j=ht.marginCounts[v];return j===0?null:f.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[f.jsx("span",{className:"w-3 h-0.5 shrink-0 rounded-full",style:{backgroundColor:Mv[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1 capitalize",children:v}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:j})]},v)}),ht.anomalousCount>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-status-warning",children:"Anomalous"}),f.jsx("span",{className:"text-status-warning tabular-nums",children:ht.anomalousCount})]})]})]}),Hi&&Hi.atRiskPaths.length>0&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsxs("button",{onClick:()=>dt(v=>!v),className:"flex-1 flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-status-warning hover-bg transition-base",children:[Xe?f.jsx(Pc,{className:"w-3 h-3"}):f.jsx(Yp,{className:"w-3 h-3"}),"At-Risk Paths",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[Hi.criticalCount>0&&f.jsxs("span",{className:"text-status-danger",children:[Hi.criticalCount,"c"]}),Hi.criticalCount>0&&Hi.highCount>0&&" ",Hi.highCount>0&&f.jsxs("span",{className:"text-status-warning",children:[Hi.highCount,"h"]}),(Hi.criticalCount>0||Hi.highCount>0)&&Hi.moderateCount>0&&" ",Hi.moderateCount>0&&f.jsxs("span",{className:"text-fg-muted",children:[Hi.moderateCount,"m"]})]})]}),f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Predictive Path Failure"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Identifies paths at risk of failure by combining four weighted factors. Paths below the moderate threshold (35%) are not shown."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Factor weights"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Declining usage"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Weak link certainty"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"No alternate paths"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"20%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Low signal margin"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"15%"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Risk thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-danger",children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"≥75% — failure likely imminent"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-warning",children:"High"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-74% — significant risk"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Moderate"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35-54% — worth monitoring"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 text-[10px] text-fg-muted font-mono space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"Edges analyzed"}),f.jsx("span",{className:"tabular-nums",children:Hi.edgesAnalyzed})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"With signal data"}),f.jsx("span",{className:"tabular-nums",children:Hi.edgesWithSignal})]})]})]}),children:f.jsx("span",{className:"px-2 py-1.5 text-fg-muted cursor-help",children:f.jsx(fd,{className:"w-3 h-3"})})})]}),Xe&&f.jsx("div",{className:"px-2 pb-2 space-y-1",children:Hi.atRiskPaths.slice(0,8).map(v=>{const j=v.riskLevel==="critical"?"#EF4444":v.riskLevel==="high"?"#F97316":"#FBBF24",W=v.urgency==="imminent"?"IMM":v.urgency==="near-term"?"NEAR":"WATCH";return f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary font-mono text-[11px]",children:v.hops.join(" → ")}),f.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Risk score"}),f.jsxs("span",{className:"font-semibold tabular-nums",style:{color:j},children:[(v.riskScore*100).toFixed(1),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Health score"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[(v.healthScore*100).toFixed(0),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Obs. trend"}),f.jsxs("span",{className:`tabular-nums ${v.observationTrend<0?"text-status-danger":"text-fg-secondary"}`,children:[v.observationTrend>0?"+":"",v.observationTrend.toFixed(3)]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Alt. paths"}),f.jsx("span",{className:`tabular-nums ${v.alternatePathsCount===0?"text-status-danger":"text-fg-secondary"}`,children:v.alternatePathsCount})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Urgency"}),f.jsx("span",{className:"capitalize",style:{color:j},children:v.urgency})]})]}),v.factors.length>0&&f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Contributing factors"}),v.factors.map((ue,oe)=>f.jsxs("div",{className:"space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:ue.name}),f.jsxs("span",{className:"text-fg-muted tabular-nums",children:[(ue.score*ue.weight*100).toFixed(1),"% (",(ue.weight*100).toFixed(0),"w × ",(ue.score*100).toFixed(0),"s)"]})]}),f.jsx("div",{className:"text-fg-muted pl-1",children:ue.description})]},oe))]})]}),children:f.jsxs("div",{className:"px-2 py-1 radius-badge bg-subtle-fill/30 cursor-help",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:j}}),f.jsx("span",{className:"text-[10px] text-fg-secondary font-mono truncate flex-1",children:v.hops.join(" → ")}),f.jsx("span",{className:"text-[8px] uppercase tracking-wide px-1 py-px radius-badge",style:{backgroundColor:`${j}20`,color:j},children:W}),f.jsxs("span",{className:"text-[10px] tabular-nums font-semibold",style:{color:j},children:[(v.riskScore*100).toFixed(0),"%"]})]}),f.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5 pl-3",children:v.factors.map((ue,oe)=>f.jsxs("span",{className:"text-[8px] text-fg-muted",children:[ue.name," (",(ue.score*ue.weight*100).toFixed(0),"%)",oe<v.factors.length-1?" ·":""]},oe))})]})},v.pathKey)})})]}),f.jsxs("div",{className:"px-3 py-2 space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Number of detected community clusters via graph partitioning",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Communities"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:We==="louvain"&&ud?ud.numCommunities:u})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Spectral uses eigenvector decomposition; Louvain maximizes modularity iteratively. Click to switch.",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Algorithm"})}),f.jsx("button",{onClick:()=>He(v=>v==="spectral"?"louvain":"spectral"),className:"text-sys-blue hover:underline cursor-pointer",children:We==="spectral"?"Spectral":"Louvain"})]}),We==="louvain"&&ud&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Louvain modularity score — quality of community partition (higher = better defined communities)",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Modularity Q"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:ud.modularity.toFixed(4)})]}),We==="louvain"&&f.jsxs("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle space-y-1.5",children:[f.jsx(pi,{label:"Resolution γ",value:bt,onChange:Vt,min:.01,max:5,step:.01}),f.jsx(pi,{label:"K-weight",value:pe,onChange:it,min:.01,max:5,step:.01}),(bt!==1||pe!==1)&&f.jsx("button",{onClick:()=>{Vt(1),it(1)},className:"w-full text-[10px] text-sys-blue hover:underline text-center",children:"Reset defaults"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Redundant path cycles in the topology — indicates alternate routing options",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Loops"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((f0=r==null?void 0:r.loops)==null?void 0:f0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"High-betweenness edges that carry disproportionate traffic flow",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Backbone"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((p0=r==null?void 0:r.backboneEdges)==null?void 0:p0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Unresolved prefix nodes inferred by Viterbi HMM from repeated path patterns",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Ghosts"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:l.length})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Community-aware node coloring — groups nodes by cluster assignment",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Clustering"})}),f.jsx("span",{className:`tabular-nums ${Pe?"text-sys-blue":"text-fg-muted"}`,children:Pe?"On":"Off"})]}),Co!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Algebraic connectivity — 2nd-smallest eigenvalue of the graph Laplacian. Near-zero = one bridge from network partition.",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Fiedler λ₂"})}),f.jsx("span",{className:`tabular-nums ${Co<.01?"text-status-warning":"text-fg-secondary"}`,children:Co.toFixed(4)})]}),ie.size>0&&f.jsxs("button",{onClick:()=>Ce(new Set),className:"w-full mt-1 text-[10px] text-sys-blue hover:underline text-center",children:["Clear filters (",ie.size,")"]})]})]}),Jv=f.jsx(Jc,{children:se&&f.jsx(ma.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:f.jsxs("div",{className:"surface-elevated radius-inset shadow-2xl overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-edge-subtle",children:[f.jsx(E0,{className:"w-4 h-4 text-fg-muted shrink-0"}),f.jsx("input",{ref:Jn,type:"text",value:D,onChange:v=>de(v.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-fg-primary placeholder:text-fg-muted focus:outline-none",onKeyDown:v=>{v.key==="Escape"?(R(!1),de("")):v.key==="Enter"&&nc.length>0&&Uv(nc[0])}}),D&&f.jsx("button",{onClick:()=>de(""),className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx(Vl,{className:"w-3 h-3 text-fg-muted"})})]}),nc.length>0&&f.jsx("div",{className:"max-h-64 overflow-y-auto",children:nc.map((v,j)=>f.jsxs("button",{onClick:()=>Uv(v),className:`w-full flex items-center gap-3 px-3 py-2 text-left hover-bg transition-base ${j===0?"bg-subtle-fill/50":""}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:y[v.nodeClass]}}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm text-fg-primary truncate",children:v.name||v.prefix}),v.name&&f.jsx("div",{className:"text-[10px] text-fg-muted",children:v.prefix})]}),f.jsx(rR,{className:"w-3 h-3 text-fg-muted shrink-0"})]},v.id))}),D&&nc.length===0&&f.jsx("div",{className:"px-3 py-4 text-center text-sm text-fg-muted",children:"No nodes found"}),!D&&f.jsx("div",{className:"px-3 py-2 type-data-xs text-fg-muted",children:"Type to search • Enter to select • Esc to close"})]})})});return e?sn.length===0?f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsx("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:f.jsx(dte,{})})]}):Ts?Q?f.jsxs("div",{className:"fixed inset-0 z-50 bg-body flex flex-col overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 surface-header z-10",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(_0,{className:"w-5 h-5 text-icon-page-title"}),f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2",children:["MeshGraph",f.jsx(Bi,{color:"violet",compact:!0,children:"Analytics"})]}),f.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[Lt.length," nodes • ",Pi.length," edges"]})]}),f.jsx(be,{content:"Exit fullscreen",children:f.jsx("button",{onClick:$v,className:"p-1.5 radius-inner hover-bg transition-base",children:f.jsx(x0,{className:"w-4 h-4 text-fg-muted"})})})]}),f.jsxs("div",{className:"flex-1 relative min-h-0 m-2 surface-base radius-inset overflow-hidden border border-edge-subtle",children:[f.jsx(gS,{className:"absolute inset-0",points:Ts,links:Or,...es,...ct,backgroundColor:_,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:S,pointClusterBy:Pe?"communityId":void 0,onPolygonSelected:si?jv:void 0,polygonalSelectorStrokeColor:m?"#FBBF24":"#D97706",onClick:zv,onLinkClick:Fv,onMount:Bv,hoveredPointRingColor:m?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Jv,Qv,qv,Xv,Kv,Zv,f.jsxs(Jc,{children:[T&&f.jsx(LS,{node:T,egoMetrics:Vv,onExpandEgo:Yv,neighbors:Wv,onSelectNeighbor:cd,txDelayRec:Gv,onClose:()=>{var v;I(null),(v=Ut.current)==null||v.unselectAllPoints()}}),O&&!T&&f.jsx(IS,{edge:O,onClose:()=>H(null)}),Zs&&!T&&!O&&f.jsx(RS,{metrics:Zs,onClose:Hv})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0",children:[f.jsx(gS,{className:"absolute inset-0",points:Ts,links:Or,...es,...ct,backgroundColor:_,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:S,pointClusterBy:Pe?"communityId":void 0,onPolygonSelected:si?jv:void 0,polygonalSelectorStrokeColor:m?"#FBBF24":"#D97706",onClick:zv,onLinkClick:Fv,onMount:Bv,hoveredPointRingColor:m?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Jv,Qv,qv,Xv,Kv,Zv,f.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 type-data-xs text-fg-muted/60",children:[f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"L"})," Labels"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),f.jsxs(Jc,{children:[T&&f.jsx(LS,{node:T,egoMetrics:Vv,onExpandEgo:Yv,neighbors:Wv,onSelectNeighbor:cd,txDelayRec:Gv,onClose:()=>{var v;I(null),(v=Ut.current)==null||v.unselectAllPoints()}}),O&&!T&&f.jsx(IS,{edge:O,onClose:()=>H(null)}),Zs&&!T&&!O&&f.jsx(RS,{metrics:Zs,onClose:Hv})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsx("div",{className:"absolute inset-0 bg-body flex flex-col items-center justify-center gap-3",children:xn?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"p-4 radius-pill bg-status-danger/15",children:f.jsx(MS,{className:"w-8 h-8 text-status-danger"})}),f.jsx("span",{className:"type-body text-fg-primary",children:"Preparation Failed"}),f.jsx("span",{className:"type-data-xs text-fg-muted max-w-sm text-center",children:xn}),f.jsx("button",{onClick:()=>{ks(null),er(null),Eo(null)},className:"mt-2 px-4 py-2 radius-inner bg-sys-blue/15 text-sys-blue text-sm font-medium hover:bg-sys-blue/25 transition-base",children:"Retry"})]}):f.jsxs(f.Fragment,{children:[f.jsx(gg,{className:"w-8 h-8 text-sys-blue animate-spin"}),f.jsx("span",{className:"type-body text-fg-muted",children:"Preparing graph..."})]})})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:[f.jsx(GJ,{isOpen:n,onClose:s}),!n&&f.jsx(gg,{className:"w-8 h-8 text-sys-blue animate-spin"})]})]})}const Rie=Object.freeze(Object.defineProperty({__proto__:null,default:hte},Symbol.toStringTag,{value:"Module"}));export{me as $,le as B,_y as D,YN as H,py as I,eN as J,VN as K,Rie as M,Cg as N,eu as T,Vu as U,Zh as a,yn as b,Mte as c,mN as d,lt as e,Pte as f,pN as h,zN as j,Nte as l,Rte as o,Ite as r,Lte as s,Bte as u};
