1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-VYSuD6Fo.js","assets/react-core-D4Uq2L8f.js","assets/layout-CAFBOxgd.js","assets/index-F_oLv1_S.js","assets/style-CO8OwCQY.js","assets/style-cTJ1pkTZ.css","assets/layout-KOCOopJ_.css","assets/ChevronRightIcon-ClOyqLyn.js"])))=>i.map(i=>d[i]); 2import{r as J,d as Mc,j as D,p as Bt,g as kc}from"./react-core-D4Uq2L8f.js";import{eg as Wt,eh as ro,ei as Fc,ej as Ks,ek as oo,el as Dc,em as Oc,c as Oa,dy as Bc,dz as Uc,cJ as Lc}from"./layout-CAFBOxgd.js";import{_ as ao}from"./style-CO8OwCQY.js";import{F as zc,a as Hc}from"./ChevronRightIcon-ClOyqLyn.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="3b955923-74e1-4f2a-ae45-d66bac4c1cc8",t._sentryDebugIdIdentifier="sentry-dbid-3b955923-74e1-4f2a-ae45-d66bac4c1cc8")}catch{}})();(function(){var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t._sentryModuleMetadata=t._sentryModuleMetadata||{},(function(){var e,i=new t.Error().stack,n=t._sentryModuleMetadata[i]||{},s={"_sentryBundlerPluginAppKey:ncapx-platform":!0},r={};for(e in n)n.hasOwnProperty(e)&&(r[e]=n[e]);for(e in s)s.hasOwnProperty(e)&&(r[e]=s[e]);t._sentryModuleMetadata[i]=r})()})();function Vc({title:t,titleId:e,...i},n){return J.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":e},i),t?J.createElement("title",{id:e},t):null,J.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 5.25v13.5m-7.5-13.5v13.5"}))}const Xc=J.forwardRef(Vc);function Wc({title:t,titleId:e,...i},n){return J.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":e},i),t?J.createElement("title",{id:e},t):null,J.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"}))}const $c=J.forwardRef(Wc);var lo=180/Math.PI,Gs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ba(t,e,i,n,s,r){var o,a,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*i+e*n)&&(i-=t*l,n-=e*l),(a=Math.sqrt(i*i+n*n))&&(i/=a,n/=a,l/=a),t*n<e*i&&(t=-t,e=-e,l=-l,o=-o),{translateX:s,translateY:r,rotate:Math.atan2(e,t)*lo,skewX:Math.atan(l)*lo,scaleX:o,scaleY:a}}var nn;function Yc(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Gs:Ba(e.a,e.b,e.c,e.d,e.e,e.f)}function Kc(t){return t==null||(nn||(nn=document.createElementNS("http://www.w3.org/2000/svg","g")),nn.setAttribute("transform",t),!(t=nn.transform.baseVal.consolidate()))?Gs:(t=t.matrix,Ba(t.a,t.b,t.c,t.d,t.e,t.f))}function Ua(t,e,i,n){function s(c){return c.length?c.pop()+" ":""}function r(c,u,h,f,d,T){if(c!==h||u!==f){var C=d.push("translate(",null,e,null,i);T.push({i:C-4,x:Wt(c,h)},{i:C-2,x:Wt(u,f)})}else(h||f)&&d.push("translate("+h+e+f+i)}function o(c,u,h,f){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),f.push({i:h.push(s(h)+"rotate(",null,n)-2,x:Wt(c,u)})):u&&h.push(s(h)+"rotate("+u+n)}function a(c,u,h,f){c!==u?f.push({i:h.push(s(h)+"skewX(",null,n)-2,x:Wt(c,u)}):u&&h.push(s(h)+"skewX("+u+n)}function l(c,u,h,f,d,T){if(c!==h||u!==f){var C=d.push(s(d)+"scale(",null,",",null,")");T.push({i:C-4,x:Wt(c,h)},{i:C-2,x:Wt(u,f)})}else(h!==1||f!==1)&&d.push(s(d)+"scale("+h+","+f+")")}return function(c,u){var h=[],f=[];return c=t(c),u=t(u),r(c.translateX,c.translateY,u.translateX,u.translateY,h,f),o(c.rotate,u.rotate,h,f),a(c.skewX,u.skewX,h,f),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,h,f),c=u=null,function(d){for(var T=-1,C=f.length,w;++T<C;)h[(w=f[T]).i]=w.x(d);return h.join("")}}}var Gc=Ua(Yc,"px, ","px)","deg)"),jc=Ua(Kc,", ",")",")"),qc=1e-12;function co(t){return((t=Math.exp(t))+1/t)/2}function Zc(t){return((t=Math.exp(t))-1/t)/2}function Qc(t){return((t=Math.exp(2*t))-1)/(t+1)}const Jc=(function t(e,i,n){function s(r,o){var a=r[0],l=r[1],c=r[2],u=o[0],h=o[1],f=
2o[2],d=u-a,T=h-l,C=d*d+T*T,w,A;if(C<qc)A=Math.log(f/c)/e,w=function(B){return[a+B*d,l+B*T,c*Math.exp(e*B*A)]};else{var F=Math.sqrt(C),b=(f*f-c*c+n*C)/(2*c*i*F),g=(f*f-c*c-n*C)/(2*f*i*F),v=Math.log(Math.sqrt(b*b+1)-b),N=Math.log(Math.sqrt(g*g+1)-g);A=(N-v)/e,w=function(B){var W=B*A,Y=co(v),q=c/(i*F)*(Y*Qc(e*W+v)-Zc(v));return[a+q*d,l+q*T,c*Y/co(e*W+v)]}}return w.duration=A*1e3*e/Math.SQRT2,w}return s.rho=function(r){var o=Math.max(.001,+r),a=o*o,l=a*a;return t(o,a,l)},s})(Math.SQRT2,2,4),eu={},tu=Object.freeze(Object.defineProperty({__proto__:null,default:eu},Symbol.toStringTag,{value:"Module"})),iu=Mc(tu);function nu(t,e){const i=t.toLowerCase(),n=[];for(const a of e){const l=a.trim().toLowerCase();if(l.length<4)continue;let c=0;for(;c<i.length;){const u=i.indexOf(l,c);if(u===-1)break;n.push([u,u+l.length]),c=u+l.length}}if(n.length===0)return[{text:t,hit:!1}];n.sort((a,l)=>a[0]-l[0]);const s=[];for(const[a,l]of n){const c=s[s.length-1];c&&a<=c[1]?c[1]=Math.max(c[1],l):s.push([a,l])}const r=[];let o=0;for(const[a,l]of s)a>o&&r.push({text:t.slice(o,a),hit:!1}),r.push({text:t.slice(a,l),hit:!0}),o=l;return o<t.length&&r.push({text:t.slice(o),hit:!1}),r}function su({content:t,quotes:e}){if(!t||!t.type)return null;if(t.type==="text"){const i=nu(t.text??"",e);return D.jsxs("div",{children:[D.jsxs("p",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap rounded-md bg-neutral-50 p-2 text-[11px] leading-relaxed text-charcoal-500",children:[i.map((n,s)=>n.hit?D.jsx("mark",{className:"rounded-sm bg-leaf/20 px-0.5 text-charcoal-500",children:n.text},s):D.jsx("span",{children:n.text},s)),t.truncated?D.jsx("span",{className:"text-dusk-400",children:" â¦[truncated]"}):null]}),(t.figure_descriptions??[]).map((n,s)=>D.jsxs("p",{className:"mt-1 text-[10px] italic text-dusk-400",children:["Figure: ",n]},s)),(t.sharing??[]).length>0&&D.jsxs("p",{className:"mt-1 text-[10px] text-dusk-400",children:["Appears in:"," ",(t.sharing??[]).map(n=>`${n.doc_id}${n.state?` (${n.state})`:""}`).join(", ")]})]})}return t.type==="claim"?D.jsxs("div",{children:[D.jsx("p",{className:"text-xs text-charcoal-500",children:t.statement??""}),(t.evidence??[]).map((i,n)=>D.jsxs("blockquote",{className:"mt-1.5 border-l-2 border-leaf/40 pl-2",children:[D.jsxs("p",{className:"text-[11px] italic text-charcoal-400",children:["â",i.quote,"â"]}),D.jsxs("p",{className:"mt-0.5 font-mono text-[9px] uppercase tracking-widest text-dusk-400",children:[i.doc_id??"unknown doc",i.state?` · ${i.state}`:""]})]},n))]}):t.type==="headings"?D.jsxs("ul",{className:"max-h-56 space-y-0.5 overflow-y-auto",children:[(t.headings??[]).map((i,n)=>D.jsx("li",{className:"text-[11px] text-charcoal-400",style:{paddingLeft:`${Math.max(0,(i.level??1)-1)*10}px`},children:i.heading},n)),t.truncated?D.jsx("li",{className:"text-[10px] italic text-dusk-400",children:"â¦more sections"}):null]}):t.text?D.jsx("p",{className:"text-[11px] italic text-dusk-400",children:t.text}):null}function ru({nodeId:t,fetchNodeDetail:e,quotesForCanonical:i,onClose:n}){const[s,r]=J.useState(null),[o,a]=J.useState([]),[l,c]=J.useState("loading");return J.useEffect(()=>{let u=!1;return c("loading"),r(null),a([]),e(t).then(async h=>{if(!u){if(h===null){c("missing");return}if(r(h),c("ready"),h.kind==="canonical"){const f=await i(t);u||a(f)}}}).catch(()=>{u||c("missing")}),()=>{u=!0}},[t,e,i]),D.jsxs("div",{className:"rounded-lg border border-dusk-100 bg-white p-3",children:[D.jsxs("div",{className:"flex items-start justify-between gap-2",children:[D.jsxs("div",{className:"min-w-0",children:[D.jsx("p",{className:"font-mono text-[9px] uppercase tracking-widest text-dusk-400",children:s?.kind??t}),D.jsx("p",{className:"truncate text-sm font-medium text-charcoal-500",children:s?.title??""})]}),D.jsx("button",{type:"button",onClick:n,className:"flex-shrink-0 text-dusk-400 transition-colors hover:text-charcoal-500","aria-label":"Close inspector",children:D.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l==="loading"&&D.jsx("p",{className:"mt-2 text-xs text-dusk-400",children:"Loadingâ¦"}),l==="missing"&&D.jsx("p",{className:"mt-2 text-xs italic text-dusk-400",children:"No details available for this node."}),l==="ready"&&s&&D.jsxs(D.Fragment,{children:[s.props.filter(u=>u.value!==null&&u.value!=="").length>0&&D.jsx("dl",{className:"mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:s.props.filter(u=>u.value!==null&&u.value!=="").map(u=>D.jsxs("div",{className:"contents",children:[D.jsx("dt",{className:"font-mono text-[9px] uppercase tracking-widest leading-4 text-dusk-400",children:u.label}),D.jsx("dd",{className:"text-[11px] leading-4 text-charcoal-500",children:String(u.value)})]},u.label))}),D.jsx("div",{className:"mt-2",children:D.jsx(su,{content:s.content,quotes:o})})]})]})}var js="http://www.w3.org/1999/xhtml";
vendor: 6,135 bytes, line 2
2const uo={svg:"http://www.w3.org/2000/svg",xhtml:js,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Zn(t){var e=t+="",i=e.indexOf(":");return i>=0&&(e=t.slice(0,i))!=="xmlns"&&(t=t.slice(i+1)),uo.hasOwnProperty(e)?{space:uo[e],local:t}:t}function ou(t){return function(){var e=this.ownerDocument,i=this.namespaceURI;return i===js&&e.documentElement.namespaceURI===js?e.createElement(t):e.createElementNS(i,t)}}function au(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function La(t){var e=Zn(t);return(e.local?au:ou)(e)}function lu(){}function fr(t){return t==null?lu:function(){return this.querySelector(t)}}function cu(t){typeof t!="function"&&(t=fr(t));for(var e=this._groups,i=e.length,n=new Array(i),s=0;s<i;++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=t.call(l,l.__data__,u,r))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new Ze(n,this._parents)}function uu(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function hu(){return[]}function za(t){return t==null?hu:function(){return this.querySelectorAll(t)}}function fu(t){return function(){return uu(t.apply(this,arguments))}}function du(t){typeof t=="function"?t=fu(t):t=za(t);for(var e=this._groups,i=e.length,n=[],s=[],r=0;r<i;++r)for(var o=e[r],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(n.push(t.call(l,l.__data__,c,o)),s.push(l));return new Ze(n,s)}function Ha(t){return function(){return this.matches(t)}}function Va(t){return function(e){return e.matches(t)}}var pu=Array.prototype.find;function _u(t){return function(){return pu.call(this.children,t)}}function mu(){return this.firstElementChild}function gu(t){return this.select(t==null?mu:_u(typeof t=="function"?t:Va(t)))}var Tu=Array.prototype.filter;function Su(){return Array.from(this.children)}function xu(t){return function(){return Tu.call(this.children,t)}}function yu(t){return this.selectAll(t==null?Su:xu(typeof t=="function"?t:Va(t)))}function vu(t){typeof t!="function"&&(t=Ha(t));for(var e=this._groups,i=e.length,n=new Array(i),s=0;s<i;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&t.call(l,l.__data__,c,r)&&a.push(l);return new Ze(n,this._parents)}function Xa(t){return new Array(t.length)}function Eu(){return new Ze(this._enter||this._groups.map(Xa),this._parents)}function Fn(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Fn.prototype={constructor:Fn,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Au(t){return function(){return t}}function Ru(t,e,i,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):i[o]=new Fn(t,r[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function Cu(t,e,i,n,s,r,o){var a,l,c=new Map,u=e.length,h=r.length,f=new Array(u),d;for(a=0;a<u;++a)(l=e[a])&&(f[a]=d=o.call(l,l.__data__,a,e)+"",c.has(d)?s[a]=l:c.set(d,l));for(a=0;a<h;++a)d=o.call(t,r[a],a,r)+"",(l=c.get(d))?(n[a]=l,l.__data__=r[a],c.delete(d)):i[a]=new Fn(t,r[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(f[a])===l&&(s[a]=l)}function bu(t){return t.__data__}function Iu(t,e){if(!arguments.length)return Array.from(this,bu);var i=e?Cu:Ru,n=this._parents,s=this._groups;typeof t!="function"&&(t=Au(t));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],h=s[c],f=h.length,d=Pu(t.call(u,u&&u.__data__,c,n)),T=d.length,C=a[c]=new Array(T),w=o[c]=new Array(T),A=l[c]=new Array(f);i(u,h,C,w,A,d,e);for(var F=0,b=0,g,v;F<T;++F)if(g=C[F]){for(F>=b&&(b=F+1);!(v=w[b])&&++b<T;);g._next=v||null}}return o=new Ze(o,n),o._enter=a,o._exit=l,o}function Pu(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function wu(){return new Ze(this._exit||this._groups.map(Xa),this._parents)}function Nu(t,e,i){var n=this.enter(),s=this,r=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(s=e(s),s&&(s=s.selection())),i==null?r.remove():i(r),n&&s?n.merge(s).order():s}function Mu(t){for(var e=t.selection?t.selection():t,i=this._groups,n=e._groups,s=i.length,r=n.length,o=Math.min(s,r),a=new Array(s),l=0;l<o;++l)for(var c=i[l],u=n[l],h=c.length,f=a[l]=new Array(h),d,T=0;T<h;++T)(d=c[T]||u[T])&&(f[T]=d);for(;l<s;++l)a[l]=i[l];return new Ze(a,this._parents)}function ku(){for(var t=this._groups,e=-1,i=t.length;++e<i;)for(var n=t[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 Fu(t){t||(t=Du);function e(h,f){return h&&f?t(h.__data__,f.__data__):!h-!f}for(var i=this._groups,n=i.length,s=new Array(n),r=0;r<n;++r){for(var o=i[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 Ze(s,this._parents).order()}function Du(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Ou(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Bu(){return Array.from(this)}function Uu(){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var n=t[e],s=0,r=n.length;s<r;++s){var o=n[s];if(o)return o}return null}function Lu(){let t=0;for(const e of this)++t;return t}function zu(){return!this.node()}function Hu(t){for(var e=this._groups,i=0,n=e.length;i<n;++i)for(var s=e[i],r=0,o=s.length,a;r<o;++r)(a=s[r])&&t.call(a,a.__data__,r,s);return this}function Vu(t){return function(){this.removeAttribute(t)}}function Xu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Wu(t,e){return function(){this.setAttribute(t,e)}}function $u(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Yu(t,e){return function(){var i=e.apply(this,arguments);i==null?this.removeAttribute(t):this.setAttribute(t,i)}}function Ku(t,e){return function(){var i=e.apply(this,arguments);i==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,i)}}function Gu(t,e){var i=Zn(t);
vendor: 5,039 bytes, line 2
2if(arguments.length<2){var n=this.node();return i.local?n.getAttributeNS(i.space,i.local):n.getAttribute(i)}return this.each((e==null?i.local?Xu:Vu:typeof e=="function"?i.local?Ku:Yu:i.local?$u:Wu)(i,e))}function Wa(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ju(t){return function(){this.style.removeProperty(t)}}function qu(t,e,i){return function(){this.style.setProperty(t,e,i)}}function Zu(t,e,i){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,i)}}function Qu(t,e,i){return arguments.length>1?this.each((e==null?ju:typeof e=="function"?Zu:qu)(t,e,i??"")):hi(this.node(),t)}function hi(t,e){return t.style.getPropertyValue(e)||Wa(t).getComputedStyle(t,null).getPropertyValue(e)}function Ju(t){return function(){delete this[t]}}function eh(t,e){return function(){this[t]=e}}function th(t,e){return function(){var i=e.apply(this,arguments);i==null?delete this[t]:this[t]=i}}function ih(t,e){return arguments.length>1?this.each((e==null?Ju:typeof e=="function"?th:eh)(t,e)):this.node()[t]}function $a(t){return t.trim().split(/^|\s+/)}function dr(t){return t.classList||new Ya(t)}function Ya(t){this._node=t,this._names=$a(t.getAttribute("class")||"")}Ya.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ka(t,e){for(var i=dr(t),n=-1,s=e.length;++n<s;)i.add(e[n])}function Ga(t,e){for(var i=dr(t),n=-1,s=e.length;++n<s;)i.remove(e[n])}function nh(t){return function(){Ka(this,t)}}function sh(t){return function(){Ga(this,t)}}function rh(t,e){return function(){(e.apply(this,arguments)?Ka:Ga)(this,t)}}function oh(t,e){var i=$a(t+"");if(arguments.length<2){for(var n=dr(this.node()),s=-1,r=i.length;++s<r;)if(!n.contains(i[s]))return!1;return!0}return this.each((typeof e=="function"?rh:e?nh:sh)(i,e))}function ah(){this.textContent=""}function lh(t){return function(){this.textContent=t}}function ch(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function uh(t){return arguments.length?this.each(t==null?ah:(typeof t=="function"?ch:lh)(t)):this.node().textContent}function hh(){this.innerHTML=""}function fh(t){return function(){this.innerHTML=t}}function dh(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function ph(t){return arguments.length?this.each(t==null?hh:(typeof t=="function"?dh:fh)(t)):this.node().innerHTML}function _h(){this.nextSibling&&this.parentNode.appendChild(this)}function mh(){return this.each(_h)}function gh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Th(){return this.each(gh)}function Sh(t){var e=typeof t=="function"?t:La(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function xh(){return null}function yh(t,e){var i=typeof t=="function"?t:La(t),n=e==null?xh:typeof e=="function"?e:fr(e);return this.select(function(){return this.insertBefore(i.apply(this,arguments),n.apply(this,arguments)||null)})}function vh(){var t=this.parentNode;t&&t.removeChild(this)}function Eh(){return this.each(vh)}function Ah(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Rh(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ch(t){return this.select(t?Rh:Ah)}function bh(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Ih(t){return function(e){t.call(this,e,this.__data__)}}function Ph(t){return t.trim().split(/^|\s+/).map(function(e){var i="",n=e.indexOf(".");return n>=0&&(i=e.slice(n+1),e=e.slice(0,n)),{type:e,name:i}})}function wh(t){return function(){var e=this.__on;if(e){for(var i=0,n=-1,s=e.length,r;i<s;++i)r=e[i],(!t.type||r.type===t.type)&&r.name===t.name?this.removeEventListener(r.type,r.listener,r.options):e[++n]=r;++n?e.length=n:delete this.__on}}}function Nh(t,e,i){return function(){var n=this.__on,s,r=Ih(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===t.type&&s.name===t.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=i),s.value=e;return}}this.addEventListener(t.type,r,i),s={type:t.type,name:t.name,value:e,listener:r,options:i},n?n.push(s):this.__on=[s]}}function Mh(t,e,i){var n=Ph(t+""),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?Nh:wh,s=0;s<r;++s)this.each(a(n[s],e,i));return this}function ja(t,e,i){var n=Wa(t),s=n.CustomEvent;typeof s=="function"?s=new s(e,i):(s=n.document.createEvent("Event"),i?(s.initEvent(e,i.bubbles,i.cancelable),s.detail=i.detail):s.initEvent(e,!1,!1)),t.dis
vendor: 4,563 bytes, line 2
2patchEvent(s)}function kh(t,e){return function(){return ja(this,t,e)}}function Fh(t,e){return function(){return ja(this,t,e.apply(this,arguments))}}function Dh(t,e){return this.each((typeof e=="function"?Fh:kh)(t,e))}function*Oh(){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var n=t[e],s=0,r=n.length,o;s<r;++s)(o=n[s])&&(yield o)}var qa=[null];function Ze(t,e){this._groups=t,this._parents=e}function Yi(){return new Ze([[document.documentElement]],qa)}function Bh(){return this}Ze.prototype=Yi.prototype={constructor:Ze,select:cu,selectAll:du,selectChild:gu,selectChildren:yu,filter:vu,data:Iu,enter:Eu,exit:wu,join:Nu,merge:Mu,selection:Bh,order:ku,sort:Fu,call:Ou,nodes:Bu,node:Uu,size:Lu,empty:zu,each:Hu,attr:Gu,style:Qu,property:ih,classed:oh,text:uh,html:ph,raise:mh,lower:Th,append:Sh,insert:yh,remove:Eh,clone:Ch,datum:bh,on:Mh,dispatch:Dh,[Symbol.iterator]:Oh};function Me(t){return typeof t=="string"?new Ze([[document.querySelector(t)]],[document.documentElement]):new Ze([[t]],qa)}function Uh(t){let e;for(;e=t.sourceEvent;)t=e;return t}function vt(t,e){if(t=Uh(t),e===void 0&&(e=t.currentTarget),e){var i=e.ownerSVGElement||e;if(i.createSVGPoint){var n=i.createSVGPoint();return n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}}return[t.pageX,t.pageY]}var Lh={value:()=>{}};function Qn(){for(var t=0,e=arguments.length,i={},n;t<e;++t){if(!(n=arguments[t]+"")||n in i||/[\s.]/.test(n))throw new Error("illegal type: "+n);i[n]=[]}return new mn(i)}function mn(t){this._=t}function zh(t,e){return t.trim().split(/^|\s+/).map(function(i){var n="",s=i.indexOf(".");if(s>=0&&(n=i.slice(s+1),i=i.slice(0,s)),i&&!e.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:n}})}mn.prototype=Qn.prototype={constructor:mn,on:function(t,e){var i=this._,n=zh(t+"",i),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(t=n[r]).type)&&(s=Hh(i[s],t.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<o;)if(s=(t=n[r]).type)i[s]=ho(i[s],t.name,e);else if(e==null)for(s in i)i[s]=ho(i[s],t.name,null);return this},copy:function(){var t={},e=this._;for(var i in e)t[i]=e[i].slice();return new mn(t)},call:function(t,e){if((s=arguments.length-2)>0)for(var i=new Array(s),n=0,s,r;n<s;++n)i[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(r=this._[t],n=0,s=r.length;n<s;++n)r[n].value.apply(e,i)},apply:function(t,e,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],s=0,r=n.length;s<r;++s)n[s].value.apply(e,i)}};function Hh(t,e){for(var i=0,n=t.length,s;i<n;++i)if((s=t[i]).name===e)return s.value}function ho(t,e,i){for(var n=0,s=t.length;n<s;++n)if(t[n].name===e){t[n]=Lh,t=t.slice(0,n).concat(t.slice(n+1));break}return i!=null&&t.push({name:e,value:i}),t}var fi=0,Pi=0,xi=0,Za=1e3,Dn,wi,On=0,$t=0,Jn=0,Vi=typeof performance=="object"&&performance.now?performance:Date,Qa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function pr(){return $t||(Qa(Vh),$t=Vi.now()+Jn)}function Vh(){$t=0}function Bn(){this._call=this._time=this._next=null}Bn.prototype=Ja.prototype={constructor:Bn,restart:function(t,e,i){if(typeof t!="function")throw new TypeError("callback is not a function");i=(i==null?pr():+i)+(e==null?0:+e),!this._next&&wi!==this&&(wi?wi._next=this:Dn=this,wi=this),this._call=t,this._time=i,qs()},stop:function(){this._call&&(this._call=null,this._time=1/0,qs())}};function Ja(t,e,i){var n=new Bn;return n.restart(t,e,i),n}function Xh(){pr(),++fi;for(var t=Dn,e;t;)(e=$t-t._time)>=0&&t._call.call(void 0,e),t=t._next;--fi}function fo(){$t=(On=Vi.now())+Jn,fi=Pi=0;try{Xh()}finally{fi=0,$h(),$t=0}}function Wh(){var t=Vi.now(),e=t-On;e>Za&&(Jn-=e,On=t)}function $h(){for(var t,e=Dn,i,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(i=e._next,e._next=null,e=t?t._next=i:Dn=i);wi=t,qs(n)}function qs(t){if(!fi){Pi&&(Pi=clearTimeout(Pi));var e=t-$t;e>24?(t<1/0&&(Pi=setTimeout(fo,t-Vi.now()-Jn)),xi&&(xi=clearInterval(xi))):(xi||(On=Vi.now(),xi=setInterval(Wh,Za)),fi=1,Qa(fo))}}function po(t,e,i){var n=new Bn;return e=e==null?0:+e,n.restart(s=>{n.stop(),t(s+e)},e,i),n}var Yh=Qn("start","end","cancel","interrupt"),Kh=[],el=0,_o=1,Zs=2,gn=3,mo=4,Qs=5,Tn=6;function es(t,e,i,n,s,r){var o=t.__transition;if(!o)t.__transition={};else if(i in o)return;
vendor: 10,754 bytes, line 2
2Gh(t,i,{name:e,index:n,group:s,on:Yh,tween:Kh,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:el})}function _r(t,e){var i=lt(t,e);if(i.state>el)throw new Error("too late; already scheduled");return i}function Tt(t,e){var i=lt(t,e);if(i.state>gn)throw new Error("too late; already running");return i}function lt(t,e){var i=t.__transition;if(!i||!(i=i[e]))throw new Error("transition not found");return i}function Gh(t,e,i){var n=t.__transition,s;n[e]=i,i.timer=Ja(r,0,i.time);function r(c){i.state=_o,i.timer.restart(o,i.delay,i.time),i.delay<=c&&o(c-i.delay)}function o(c){var u,h,f,d;if(i.state!==_o)return l();for(u in n)if(d=n[u],d.name===i.name){if(d.state===gn)return po(o);d.state===mo?(d.state=Tn,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete n[u]):+u<e&&(d.state=Tn,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete n[u])}if(po(function(){i.state===gn&&(i.state=mo,i.timer.restart(a,i.delay,i.time),a(c))}),i.state=Zs,i.on.call("start",t,t.__data__,i.index,i.group),i.state===Zs){for(i.state=gn,s=new Array(f=i.tween.length),u=0,h=-1;u<f;++u)(d=i.tween[u].value.call(t,t.__data__,i.index,i.group))&&(s[++h]=d);s.length=h+1}}function a(c){for(var u=c<i.duration?i.ease.call(null,c/i.duration):(i.timer.restart(l),i.state=Qs,1),h=-1,f=s.length;++h<f;)s[h].call(t,u);i.state===Qs&&(i.on.call("end",t,t.__data__,i.index,i.group),l())}function l(){i.state=Tn,i.timer.stop(),delete n[e];for(var c in n)return;delete t.__transition}}function Sn(t,e){var i=t.__transition,n,s,r=!0,o;if(i){e=e==null?null:e+"";for(o in i){if((n=i[o]).name!==e){r=!1;continue}s=n.state>Zs&&n.state<Qs,n.state=Tn,n.timer.stop(),n.on.call(s?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete i[o]}r&&delete t.__transition}}function jh(t){return this.each(function(){Sn(this,t)})}function qh(t,e){var i,n;return function(){var s=Tt(this,t),r=s.tween;if(r!==i){n=i=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 Zh(t,e,i){var n,s;if(typeof i!="function")throw new Error;return function(){var r=Tt(this,t),o=r.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:i},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 Qh(t,e){var i=this._id;if(t+="",arguments.length<2){for(var n=lt(this.node(),i).tween,s=0,r=n.length,o;s<r;++s)if((o=n[s]).name===t)return o.value;return null}return this.each((e==null?qh:Zh)(i,t,e))}function mr(t,e,i){var n=t._id;return t.each(function(){var s=Tt(this,n);(s.value||(s.value={}))[e]=i.apply(this,arguments)}),function(s){return lt(s,n).value[e]}}function tl(t,e){var i;return(typeof e=="number"?Wt:e instanceof Ks?ro:(i=Ks(e))?(e=i,ro):Fc)(t,e)}function Jh(t){return function(){this.removeAttribute(t)}}function ef(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tf(t,e,i){var n,s=i+"",r;return function(){var o=this.getAttribute(t);return o===s?null:o===n?r:r=e(n=o,i)}}function nf(t,e,i){var n,s=i+"",r;return function(){var o=this.getAttributeNS(t.space,t.local);return o===s?null:o===n?r:r=e(n=o,i)}}function sf(t,e,i){var n,s,r;return function(){var o,a=i(this),l;return a==null?void this.removeAttribute(t):(o=this.getAttribute(t),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function rf(t,e,i){var n,s,r;return function(){var o,a=i(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),l=a+"",o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a)))}}function of(t,e){var i=Zn(t),n=i==="transform"?jc:tl;return this.attrTween(t,typeof e=="function"?(i.local?rf:sf)(i,n,mr(this,"attr."+t,e)):e==null?(i.local?ef:Jh)(i):(i.local?nf:tf)(i,n,e))}function af(t,e){return function(i){this.setAttribute(t,e.call(this,i))}}function lf(t,e){return function(i){this.setAttributeNS(t.space,t.local,e.call(this,i))}}function cf(t,e){var i,n;function s(){var r=e.apply(this,arguments);return r!==n&&(i=(n=r)&&lf(t,r)),i}return s._value=e,s}function uf(t,e){var i,n;function s(){var r=e.apply(this,arguments);return r!==n&&(i=(n=r)&&af(t,r)),i}return s._value=e,s}function hf(t,e){var i="attr."+t;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;var n=Zn(t);return this.tween(i,(n.local?cf:uf)(n,e))}function ff(t,e){return function(){_r(this,t).delay=+e.apply(this,arguments)}}function df(t,e){return e=+e,function(){_r(this,t).delay=e}}function pf(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?ff:df)(e,t)):lt(this.node(),e).delay}function _f(t,e){return function(){Tt(this,t).duration=+e.apply(this,arguments)}}function mf(t,e){return e=+e,function(){Tt(this,t).duration=e}}function gf(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?_f:mf)(e,t)):lt(this.node(),e).duration}function Tf(t,e){if(typeof e!="function")throw new Error;return function(){Tt(this,t).ease=e}}function Sf(t){var e=this._id;return arguments.length?this.each(Tf(e,t)):lt(this.node(),e).ease}function xf(t,e){return function(){var i=e.apply(this,arguments);if(typeof i!="function")throw new Error;Tt(this,t).ease=i}}function yf(t){if(typeof t!="function")throw new Error;return this.each(xf(this._id,t))}function vf(t){typeof t!="function"&&(t=Ha(t));for(var e=this._groups,i=e.length,n=new Array(i),s=0;s<i;++s)for(var r=e[s],o=r.length,a=n[s]=[],l,c=0;c<o;++c)(l=r[c])&&t.call(l,l.__data__,c,r)&&a.push(l);return new It(n,this._parents,this._name,this._id)}function Ef(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,i=t._groups,n=e.length,s=i.length,r=Math.min(n,s),o=new Array(n),a=0;a<r;++a)for(var l=e[a],c=i[a],u=l.length,h=o[a]=new Array(u),f,d=0;d<u;++d)(f=l[d]||c[d])&&(h[d]=f);for(;a<n;++a)o[a]=e[a];return new It(o,this._parents,this._name,this._id)}function Af(t){return(t+"").trim().split(/^|\s+/).every(function(e){var i=e.indexOf(".");return i>=0&&(e=e.slice(0,i)),!e||e==="start"})}function Rf(t,e,i){var n,s,r=Af(e)?_r:Tt;return function(){var o=r(this,t),a=o.on;a!==n&&(s=(n=a).copy()).on(e,i),o.on=s}}function Cf(t,e){var i=this._id;return arguments.length<2?lt(this.node(),i).on.on(t):this.each(Rf(i,t,e))}function bf(t){return function(){var e=this.parentNode;for(var i in this.__transition)if(+i!==t)return;e&&e.removeChild(this)}}function If(){return this.on("end.remove",bf(this._id))}function Pf(t){var e=this._name,i=this._id;typeof t!="function"&&(t=fr(t));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,h,f=0;f<l;++f)(u=a[f])&&(h=t.call(u,u.__data__,f,a))&&("__data__"in u&&(h.__data__=u.__data__),c[f]=h,es(c[f],e,i,f,c,lt(u,i)));return new It(r,this._parents,e,i)}function wf(t){var e=this._name,i=this._id;typeof t!="function"&&(t=za(t));for(var n=this._groups,s=n.length,r=[],o=[],a=0;a<s;++a)for(var l=n[a],c=l.length,u,h=0;h<c;++h)if(u=l[h]){for(var f=t.call(u,u.__data__,h,l),d,T=lt(u,i),C=0,w=f.length;C<w;++C)(d=f[C])&&es(d,e,i,C,f,T);r.push(f),o.push(u)}return new It(r,o,e,i)}var Nf=Yi.prototype.constructor;function Mf(){return new Nf(this._groups,this._parents)}function kf(t,e){var i,n,s;return function(){var r=hi(this,t),o=(this.style.removeProperty(t),hi(this,t));return r===o?null:r===i&&o===n?s:s=e(i=r,n=o)}}function il(t){return function(){this.style.removeProperty(t)}}function Ff(t,e,i){var n,s=i+"",r;return function(){var o=hi(this,t);return o===s?null:o===n?r:r=e(n=o,i)}}function Df(t,e,i){var n,s,r;return function(){var o=hi(this,t),a=i(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),hi(this,t))),o===l?null:o===n&&l===s?r:(s=l,r=e(n=o,a))}}function Of(t,e){var i,n,s,r="style."+e,o="end."+r,a;return function(){var l=Tt(this,t),c=l.on,u=l.value[r]==null?a||(a=il(e)):void 0;(c!==i||s!==u)&&(n=(i=c).copy()).on(o,s=u),l.on=n}}function Bf(t,e,i){var n=(t+="")=="transform"?Gc:tl;return e==null?this.styleTween(t,kf(t,n)).on("end.style."+t,il(t)):typeof e=="function"?this.styleTween(t,Df(t,n,mr(this,"style."+t,e))).each(Of(this._id,t)):this.styleTween(t,Ff(t,n,e),i).on("end.style."+t,null)}function Uf(t,e,i){return function(n){this.style.setProperty(t,e.call(this,n),i)}}function Lf(t,e,i){var n,s;function r(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&Uf(t,o,i)),n}return r._value=e,r}function zf(t,e,i){var n="style."+(t+="");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,Lf(t,e,i??""))}function Hf(t){return function(){this.textContent=t}}function Vf(t){return function(){var e=t(this);this.textContent=e??""}}function Xf(t){return this.tween("text",typeof t=="function"?Vf(mr(this,"text",t)):Hf(t==null?"":t+""))}function Wf(t){return function(e){this.textContent=t.call(this,e)}}function $f(t){var e,i;function n(){var s=t.apply(this,arguments);return s!==i&&(e=(i=s)&&Wf(s)),e}return n._value=t,n}function Yf(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,$f(t))}function Kf(){for(var t=this._name,e=this._id,i=nl(),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=lt(l,e);es(l,t,i,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new It(n,this._parents,t,i)}function Gf(){var t,e,i=this,n=i._id,s=i.size();return new Promise(function(r,o){var a={value:o},l={value:function(){--s===0&&r()}};i.each(function(){var c=Tt(this,n),u=c.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),s===0&&r()})}var jf=0;function It(t,e,i,n){this._groups=t,this._parents=e,this._name=i,this._id=n}function nl(){return++jf}var yt=Yi.prototype;It.prototype={constructor:It,select:Pf,selectAll:wf,selectChild:yt.selectChild,selectChildren:yt.selectChildren,filter:vf,merge:Ef,selection:Mf,transition:Kf,call:yt.call,nodes:yt.nodes,node:yt.node,size:yt.size,empty:yt.empty,each:yt.each,on:Cf,attr:of,attrTween:hf,style:Bf,styleTween:zf,text:Xf,textTween:Yf,remove:If,tween:Qh,delay:pf,duration:gf,ease:Sf,easeVarying:yf,end:Gf,[Symbol.iterator]:yt[Symbol.iterator]};const sl=t=>+t;function rl(t){return t*t}function ol(t){return t*(2-t)}function al(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function qf(t){return t*t*t}function Zf(t){return--t*t*t+1}function ll(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var cl=Math.PI,ul=cl/2;function Qf(t){return+t==1?1:1-Math.cos(t*ul)}function Jf(t){return Math.sin(t*ul)}function ed(t){return(1-Math.cos(cl*t))/2}function Un(t){return(Math.pow(2,-10*t)-.0009765625)*1.0009775171065494}function td(t){return Un(1-+t)}function id(t){return 1-Un(t)}
2function nd(t){return((t*=2)<=1?Un(1-t):2-Un(t-1))/2}function sd(t){return 1-Math.sqrt(1-t*t)}function rd(t){return Math.sqrt(1- --t*t)}function od(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var ad={time:null,delay:0,duration:250,ease:ll};function ld(t,e){for(var i;!(i=t.__transition)||!(i=i[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return i}function cd(t){var e,i;t instanceof It?(e=t._id,t=t._name):(e=nl(),(i=ad).time=pr(),t=t==null?null:t+"");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])&&es(l,t,e,c,o,i||ld(l,e));return new It(n,this._parents,t,e)}Yi.prototype.interrupt=jh;Yi.prototype.transition=cd;function go(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof Bt<"u"&&Bt.hrtime){const e=Bt.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}class To{constructor(e,i){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=i,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=go(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(go()-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 ud{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,i="count"){return this._getOrCreate({name:e,type:i})}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 i of Object.values(this.stats))e(i)}getTable(){const e={};return this.forEach(i=>{e[i.name]={time:i.time||0,count:i.count||0,average:i.getAverageTime()||0,hz:i.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(i=>this._getOrCreate(i))}_getOrCreate(e){const{name:i,type:n}=e;let s=this.stats[i];return s||(e instanceof To?s=e:s=new To(i,n),this.stats[i]=s),s}}class hd{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new ud({id:e})),this.stats.get(e)}}const hl=new hd,So=globalThis,xo=globalThis.process||{},yS=globalThis.navigator||{};function fd(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof Bt<"u"&&Bt.versions?.electron)return!0;const i=typeof navigator<"u"&&navigator.userAgent;return!!(i&&i.indexOf("Electron")>=0)}function Ki(){return!(typeof Bt=="object"&&String(Bt)==="[object process]"&&!Bt?.browser)||fd()}const fl="4.1.1";function gr(t,e){if(!t)throw new Error("Assertion failed")}function dl(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return gr(Number.isFinite(e)&&e>=0),e}function dd(t){const{logLevel:e,message:i}=t;t.logLevel=dl(e);const n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==i;);switch(typeof e){case"string":case"function":i!==void 0&&n.unshift(i),t.message=e;break;case"object":Object.assign(t,e);break}typeof t.message=="function"&&(t.message=t.message());const s=typeof t.message;return gr(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}const ni=()=>{};class pd{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...i){return this._log("warn",0,e,i,{once:!0})}error(e,...i){return this._log("error",0,e,i)}log(e,i,...n){return this._log("log",e,i,n)}info(e,i,...n){return this._log("info",e,i,n)}once(e,i,...n){return this._log("once",e,i,n,{once:!0})}_log(e,i,n,s,r={}){const o=dd({logLevel:i,message:n,args:this._buildArgs(i,n,s),opts:r});return this._createLogFunction(e,o,r)}_buildArgs(e,i,n){return[e,i,...n]}_createLogFunction(e,i,n){if(!this._shouldLog(i.logLevel))return ni;const s=this._getOnceTag(n.tag??i.tag??i.message);if((n.once||i.once)&&s!==void 0){if(this._onceCache.has(s))return ni;this._onceCache.add(s)}return this._emit(e,i)}_shouldLog(e){return this.getLevel()>=dl(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}function _d(t){try{const e=window[t],i="__storage_test__";return e.setItem(i,i),e.removeItem(i),e}catch{return null}}class md{constructor(e,i,n="sessionStorage"){this.storage=_d(n),this.id=e,this.config=i,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const i=JSON.stringify(this.config);this.storage.setItem(this.id,i)}}_loadConfiguration(){let e={};
2if(this.storage){const i=this.storage.getItem(this.id);e=i?JSON.parse(i):{}}return Object.assign(this.config,e),this}}function gd(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Td(t,e=8){const i=Math.max(e-t.length,0);return`${" ".repeat(i)}${t}`}var Ln;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ln||(Ln={}));const Sd=10;function yo(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ln[t]||Ln.WHITE)}function xd(t,e,i){return!Ki&&typeof t=="string"&&(e&&(t=`\x1B[${yo(e)}m${t}\x1B[39m`),i&&(t=`\x1B[${yo(i)+Sd}m${t}\x1B[49m`)),t}function yd(t,e=["constructor"]){const i=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(i),s=t;for(const r of n){const o=s[r];typeof o=="function"&&(e.find(a=>r===a)||(s[r]=o.bind(t)))}}function yi(){let t;if(Ki()&&So.performance)t=So?.performance?.now?.();else if("hrtime"in xo){const e=xo?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}const Qt={debug:Ki()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},xs={enabled:!0,level:0};class pl extends pd{constructor({id:e}={id:""}){super({level:0}),this.VERSION=fl,this._startTs=yi(),this._deltaTs=yi(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new md(`__probe-${this.id}__`,{[this.id]:xs}),this.timeStamp(`${this.id} started`),yd(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((yi()-this._startTs).toPrecision(10))}getDelta(){return Number((yi()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,i){this._updateConfiguration({[e]:i})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,i){if(!e)throw new Error(i||"Assertion failed")}warn(e,...i){return this._log("warn",0,e,i,{method:Qt.warn,once:!0})}error(e,...i){return this._log("error",0,e,i,{method:Qt.error})}deprecated(e,i){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${i}\` instead`)}removed(e,i){return this.error(`\`${e}\` has been removed. Use \`${i}\` instead`)}probe(e,i,...n){return this._log("log",e,i,n,{method:Qt.log,time:!0,once:!0})}log(e,i,...n){return this._log("log",e,i,n,{method:Qt.debug})}info(e,i,...n){return this._log("info",e,i,n,{method:console.info})}once(e,i,...n){return this._log("once",e,i,n,{method:Qt.debug||Qt.info,once:!0})}table(e,i,n){return i?this._log("table",e,i,n&&[n]||[],{method:console.table||ni,tag:Ed(i)}):ni}time(e,i){return this._log("time",e,i,[],{method:console.time?console.time:console.info})}timeEnd(e,i){return this._log("time",e,i,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,i){return this._log("time",e,i,[],{method:console.timeStamp||ni})}group(e,i,n={collapsed:!1}){const s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,i,[],{method:s})}groupCollapsed(e,i,n={}){return this.group(e,i,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||ni})}withGroup(e,i,n){this.group(e,i)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,i){const n=i.method;gr(n),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=yi();const s=vd(this.id,i.message,i);return n.bind(console,s,...i.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(xs),this._storage.config[this.id]}_updateConfiguration(e){const i=this._storage.config[this.id]||{...xs};this._storage.setConfiguration({[this.id]:{...i,...e}})}}pl.VERSION=fl;
2function vd(t,e,i){if(typeof e=="string"){const n=i.time?Td(gd(i.total)):"";e=i.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=xd(e,i.color,i.background)}return e}function Ed(t){for(const e in t)for(const i in t[e])return i||"untitled";return"empty"}const V=new pl({id:"luma.gl"}),ys={};function Tr(t="id"){ys[t]=ys[t]||1;const e=ys[t]++;return`${t}-${e}`}class je{static defaultProps={id:"undefined",handle:void 0,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,i,n){if(!e)throw new Error("no device");this._device=e,this.props=Ad(i,n);const s=this.props.id!=="undefined"?this.props.id:Tr(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}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"),i=this[Symbol.toStringTag];e.get(`${i}s Active`).decrementCount()}trackAllocatedMemory(e,i=this[Symbol.toStringTag]){const n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${i} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),i=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${i}s Created`).incrementCount(),e.get(`${i}s Active`).incrementCount()}}function Ad(t,e){const i={...e};for(const n in t)t[n]!==void 0&&(i[n]=t[n]);return i}class G extends je{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,i){const n={...i};(i.usage||0)&G.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?n.indexType="uint32":i.data instanceof Uint16Array?n.indexType="uint16":i.data instanceof Uint8Array&&(n.indexType="uint8")),delete n.data,super(e,n,G.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,i,n){const s=ArrayBuffer.isView(e)?e.buffer:e,r=Math.min(e?e.byteLength:n,G.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(r):i===0&&n===s.byteLength?this.debugData=s.slice(0,r):this.debugData=s.slice(i,i+r)}static defaultProps={...je.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}function _l(t){const[e,i,n]=Sr[t],s=t.includes("norm"),r=!s&&!t.startsWith("float"),o=t.startsWith("s");return{signedType:e,primitiveType:i,byteLength:n,normalized:s,integer:r,signed:o}}function Rd(t){const e=t;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Cd(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function bd(t){const e=ArrayBuffer.isView(t)?t.constructor:t;if(e===Uint8ClampedArray)return"uint8";const i=Object.values(Sr).find(n=>e===n[4]);if(!i)throw new Error(e.name);return i[0]}function Id(t){const[,,,,e]=Sr[t];return e}const Sr={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 xr(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);const[i,n]=t.split("x"),s=i,r=n?parseInt(n):1,o=_l(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 Pd(t,e,i){const n=i?Rd(t):t;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 wd(t,e,i){if(!e||e>4)throw new Error(`size ${e}`);const n=e,s=bd(t);return Pd(s,n,i)}function Nd(t){let e;switch(t.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return t.components<=2?"float16x2":"float16x4"}return t.components===1?e:`${e}x${t.components}`}const Le="texture-compression-bc",me="texture-compression-astc",ft="texture-compression-etc2",Md="texture-compression-etc1-webgl",sn="texture-compression-pvrtc-webgl",vs="texture-compression-atc-webgl",rn="float32-renderable-webgl",Es="float16-renderable-webgl",kd="rgb9e5ufloat-renderable-webgl",As="snorm8-renderable-webgl",vi="norm16-renderable-webgl",Rs="snorm16-renderable-webgl",on="float32-filterable",vo="float16-filterable-webgl";function ml(t){const e=Od[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}const Fd={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:As},rg8snorm:{render:As},"rgb8snorm-webgl":{},rgba8snorm:{render:As},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:vi},rg16unorm:{render:vi},"rgb16unorm-webgl":{f:vi},rgba16unorm:{render:vi},r16snorm:{f:Rs},rg16snorm:{render:Rs}
2,"rgb16snorm-webgl":{f:vi},rgba16snorm:{render:Rs},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Es,filter:"float16-filterable-webgl"},rg16float:{render:Es,filter:vo},rgba16float:{render:Es,filter:vo},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:rn,filter:on},rg32float:{render:!1,filter:on},"rgb32float-webgl":{render:rn,filter:on},rgba32float:{render:rn,filter:on},"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:kd},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:rn},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}},Dd={"bc1-rgb-unorm-webgl":{f:Le},"bc1-rgb-unorm-srgb-webgl":{f:Le},"bc1-rgba-unorm":{f:Le},"bc1-rgba-unorm-srgb":{f:Le},"bc2-rgba-unorm":{f:Le},"bc2-rgba-unorm-srgb":{f:Le},"bc3-rgba-unorm":{f:Le},"bc3-rgba-unorm-srgb":{f:Le},"bc4-r-unorm":{f:Le},"bc4-r-snorm":{f:Le},"bc5-rg-unorm":{f:Le},"bc5-rg-snorm":{f:Le},"bc6h-rgb-ufloat":{f:Le},"bc6h-rgb-float":{f:Le},"bc7-rgba-unorm":{f:Le},"bc7-rgba-unorm-srgb":{f:Le},"etc2-rgb8unorm":{f:ft},"etc2-rgb8unorm-srgb":{f:ft},"etc2-rgb8a1unorm":{f:ft},"etc2-rgb8a1unorm-srgb":{f:ft},"etc2-rgba8unorm":{f:ft},"etc2-rgba8unorm-srgb":{f:ft},"eac-r11unorm":{f:ft},"eac-r11snorm":{f:ft},"eac-rg11unorm":{f:ft},"eac-rg11snorm":{f:ft},"astc-4x4-unorm":{f:me},"astc-4x4-unorm-srgb":{f:me},"astc-5x4-unorm":{f:me},"astc-5x4-unorm-srgb":{f:me},"astc-5x5-unorm":{f:me},"astc-5x5-unorm-srgb":{f:me},"astc-6x5-unorm":{f:me},"astc-6x5-unorm-srgb":{f:me},"astc-6x6-unorm":{f:me},"astc-6x6-unorm-srgb":{f:me},"astc-8x5-unorm":{f:me},"astc-8x5-unorm-srgb":{f:me},"astc-8x6-unorm":{f:me},"astc-8x6-unorm-srgb":{f:me},"astc-8x8-unorm":{f:me},"astc-8x8-unorm-srgb":{f:me},"astc-10x5-unorm":{f:me},"astc-10x5-unorm-srgb":{f:me},"astc-10x6-unorm":{f:me},"astc-10x6-unorm-srgb":{f:me},"astc-10x8-unorm":{f:me},"astc-10x8-unorm-srgb":{f:me},"astc-10x10-unorm":{f:me},"astc-10x10-unorm-srgb":{f:me},"astc-12x10-unorm":{f:me},"astc-12x10-unorm-srgb":{f:me},"astc-12x12-unorm":{f:me},"astc-12x12-unorm-srgb":{f:me},"pvrtc-rgb4unorm-webgl":{f:sn},"pvrtc-rgba4unorm-webgl":{f:sn},"pvrtc-rbg2unorm-webgl":{f:sn},"pvrtc-rgba2unorm-webgl":{f:sn},"etc1-rbg-unorm-webgl":{f:Md},"atc-rgb-unorm-webgl":{f:vs},"atc-rgba-unorm-webgl":{f:vs},"atc-rgbai-unorm-webgl":{f:vs}},Od={...Fd,...Dd},Bd=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Ud=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class Ld{getInfo(e){return Eo(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 Bd.some(i=>e.startsWith(i))}getCapabilities(e){const i=ml(e),n={format:e,create:i.f??!0,render:i.render??!0,filter:i.filter??!0,blend:i.blend??!0,store:i.store??!0},s=Eo(e),r=e.startsWith("depth")||e.startsWith("stencil"),o=s?.signed,a=s?.integer,l=s?.webgl;return n.render&&=!o,n.filter&&=!r&&!o&&!a&&!l,n}}const Oi=new Ld;function Eo(t){let e=zd(t);if(Oi.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const n=Hd(t);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}const i=Ud.exec(t);if(i){const[,n,s,r,o,a]=i,l=`${r}${s}`,c=_l(l),u=c.byteLength*8,h=n.length,f=[u,h>=2?u:0,h>=3?u:0,h>=4?u:0];e={format:t,attachment:e.attachment,dataType:c.signedType,components:h,channels:n,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:f,bytesPerPixel:c.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function zd(t){const e=ml(t),i=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:i,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function Hd(t){const i=/.*-(\d+)x(\d+)-.*/.exec(t);if(i){const[,n,s]=i;return{blockWidth:Number(n),blockHeight:Number(s)}}return null}function Vd(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function Xd(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWi
2dth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}class vS{}class ES{features;disabledFeatures;constructor(e=[],i){this.features=new Set(e),this.disabledFeatures=i||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}}class Xi{static defaultProps={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,i)=>{},onResize:(e,i)=>{const[n,s]=e.getDevicePixelSize();V.log(1,`${e} resized => ${n}x${s}px`)()},onPositionChange:(e,i)=>{const[n,s]=e.getPosition();V.log(1,`${e} repositioned => ${n},${s}`)()},onVisibilityChange:e=>V.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,i)=>V.log(1,`${e} DPR changed ${i.oldRatio} => ${e.devicePixelRatio}`)(),debug:V.get("debug")||void 0,debugShaders:V.get("debug-shaders")||void 0,debugFramebuffers:!!V.get("debug-framebuffers"),debugFactories:!!V.get("debug-factories"),debugWebGL:!!V.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};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=hl;timestamp=0;_reused=!1;_lumaData={};_textureCaps={};constructor(e){this.props={...Xi.defaultProps,...e},this.id=this.props.id||Tr(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return xr(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Oi.getInfo(e)}getTextureFormatCapabilities(e){let i=this._textureCaps[e];if(!i){const n=this._getDeviceTextureFormatCapabilities(e);i=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=i}return i}getMipLevelCount(e,i,n=1){const s=Math.max(e,i,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return Vd(e)}getExternalImageSize(e){return Xd(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 Oi.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,i,...n){return this.props.onError(e,i)?()=>{}:V.error(e.message,i,...n)}debug(){if(this.props.debug)debugger;else V.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', 3or 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,i){throw new Error("not implemented")}readPixelsToBufferWebGL(e,i){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,i){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 i=Oi.getCapabilities(e),n=r=>(typeof r=="string"?this.features.has(r):r)??!0,s=n(i.create);return{format:e,create:s,render:s&&n(i.render),filter:s&&n(i.filter),blend:s&&n(i.blend),store:s&&n(i.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const i={...e};if((e.usage||0)&G.INDEX&&(e.indexType||(e.data instanceof Uint32Array?i.indexType="uint32":e.data instanceof Uint16Array?i.indexType="uint16":e.data instanceof Uint8Array&&(i.data=new Uint16Array(e.data),i.indexType="uint16")),!i.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return i}}const Wd="set luma.log.level=1 (or higher) to trace rendering",Ao="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.";class zn{static defaultProps={...Xi.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=hl;log=V;VERSION="9.2.6";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw V.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),V.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");V.error("This version of luma.gl has already been initialized")()}V.log(1,`${this.VERSION} - ${Wd}`)(),globalThis.luma=this}async createDevice(e={}){const i={...zn.defaultProps,...e},n=this.selectAdapter(i.type,i.adapters);if(!n)throw new Error(Ao);return i.waitForPageLoad&&await n.pageLoaded,await n.create(i)}async attachDevice(e,i){const n=this._getTypeFromHandle(e,i.adapters),s=n&&this.selectAdapter(n,i.adapters);if(!s)throw new Error(Ao);return await s?.attach?.(e,i)}registerAdapters(e){for(const i of e)this.preregisteredAdapters.set(i.type,i)}
3getSupportedAdapters(e=[]){const i=this._getAdapterMap(e);return Array.from(i).map(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapterType(e=[]){const i=["webgpu","webgl","null"],n=this._getAdapterMap(e);for(const s of i)if(n.get(s)?.isSupported?.())return s;return null}selectAdapter(e,i=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(i));const s=this._getAdapterMap(i);return n&&s.get(n)||null}enforceWebGL2(e=!0,i=[]){const s=this._getAdapterMap(i).get("webgl");s||V.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(zn.defaultProps,e)}_getAdapterMap(e=[]){const i=new Map(this.preregisteredAdapters);for(const n of e)i.set(n.type,n);return i}_getTypeFromHandle(e,i=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?V.warn("WebGL1 is not supported",e)():V.warn("Unknown handle type",e)(),null)}}const $d=new zn;class Yd{get pageLoaded(){return jd()}}const Kd=Ki()&&typeof document<"u",Gd=()=>Kd&&document.readyState==="complete";let an=null;function jd(){return an||(Gd()||typeof window>"u"?an=Promise.resolve():an=new Promise(t=>window.addEventListener("load",()=>t()))),an}class di extends je{static defaultProps={...je.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};get[Symbol.toStringTag](){return"Sampler"}constructor(e,i){i=di.normalizeProps(e,i),super(e,i,di.defaultProps)}static normalizeProps(e,i){return i}}const qd={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"};class j extends je{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,i){if(i=j.normalizeProps(e,i),super(e,i,j.defaultProps),this.dimension=this.props.dimension,this.baseDimension=qd[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(i.data)){const n=e.getExternalImageSize(i.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&V.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}setSampler(e){this.sampler=e instanceof di?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,i){const n={...i},{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:i,height:n,depth:s}=this,r={...j.defaultCopyDataOptions,width:i,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||i*(o.bytesPerPixel||4),r.rowsPerImage=e.rowsPerImage||n,r}_normalizeCopyExternalImageOptions(e){const i=this.device.getExternalImageSize(e.image),n={...j.defaultCopyExternalImageOptions,...i,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}static defaultProps={...je.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:j.TEXTURE|j.RENDER_ATTACHMENT|j.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static 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}}class yr extends je{get[Symbol.toStringTag](){return"TextureView"}constructor(e,i){super(e,i,yr.defaultProps)}static defaultProps={...je.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}function Zd(t,e,i){let n="";const s=e.split(/\r?\n/),r=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(i?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(n+=gl(s[a-1],a,i);r.length>
3o&&r[o].lineNum===a;){const l=r[o++];n+=Cs(l,s,l.lineNum,{...i,inlineSource:!1})}for(;r.length>o;){const a=r[o++];n+=Cs(a,[],0,{...i,inlineSource:!1})}return n;case"issues":case"no":for(const a of t)n+=Cs(a,s,a.lineNum,{inlineSource:i?.showSourceCode!=="no"});return n}}function Cs(t,e,i,n){if(n?.inlineSource){const r=Qd(e,i),o=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ 4`:"";return` 5${r}${o}${t.type.toUpperCase()}: ${t.message} 6 7`}const s=t.type==="error"?"red":"#8B4000";return n?.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function Qd(t,e,i){let n="";for(let s=e-2;s<=e;s++){const r=t[s-1];r!==void 0&&(n+=gl(r,e,i))}return n}function gl(t,e,i){const n=i?.html?ep(t):t;return`${Jd(String(e),4)}: ${n}${i?.html?"<br/>":` 8`}`}function Jd(t,e){let i="";for(let n=t.length;n<e;++n)i+=" ";return i+t}function ep(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}class vr extends je{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,i){i={...i,debugShaders:i.debugShaders||e.props.debugShaders||"errors"},super(e,{id:tp(i),...i},vr.defaultProps),this.stage=this.props.stage,this.source=this.props.source}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 i=await this.getCompilationInfo();e==="warnings"&&i?.length===0||this._displayShaderLog(i,this.id)}_displayShaderLog(e,i){if(typeof document>"u"||!document?.createElement)return;const n=i,s=`${this.stage} shader "${n}"`;let r=Zd(e,this.source,{showSourceCode:"all",html:!0});const o=this.getTranslatedSource();o&&(r+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);const a=document.createElement("Button");a.innerHTML=` 9<h1>Compilation error in ${s}</h1><br /><br /> 10<code style="user-select:text;"><pre> 11${r} 12</pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),a.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}static defaultProps={...je.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}function tp(t){return ip(t.source)||t.id||Tr(`unnamed ${t.stage}-shader`)}function ip(t,e="unnamed"){const n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return n?n[1]:e}class ai extends je{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,i){super(e,i,ai.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}static defaultProps={...je.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:{}}}class Hn extends je{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,i){super(e,i,Hn.defaultProps),this.shaderLayout=i.shaderLayout}static defaultProps={...je.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}function np(t){return ap[t]}function sp(t){const[e,i]=op[t],n=e==="i32"||e==="u32",s=e!=="u32",r=rp[e]*i;return{primitiveType:e,components:i,byteLength:r,integer:n,signed:s}}const rp={f32:4,f16:2,i32:4,u32:4},op={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]},ap={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>
12":{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 Tl(t,e){const i={};for(const n of t.attributes){const s=lp(t,e,n.name);s&&(i[n.name]=s)}return i}function AS(t,e,i=16){const n=Tl(t,e),s=new Array(i).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function lp(t,e,i){const n=cp(t,i),s=up(e,i);if(!n)return null;const r=sp(n.type),o=Nd(r),a=s?.vertexFormat||o,l=xr(a);return{attributeName:s?.attributeName||n.name,bufferName: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?.stepMode||n.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function cp(t,e){const i=t.attributes.find(n=>n.name===e);return i||V.warn(`shader layout attribute "${e}" not present in shader`),i||null}function up(t,e){hp(t);let i=fp(t,e);return i||(i=dp(t,e),i)?i:(V.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function hp(t){for(const e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&V.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function fp(t,e){for(const i of t)if(i.format&&i.name===e)return{attributeName:i.name,bufferName:e,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}function dp(t,e){for(const i of t){let n=i.byteStride;if(typeof i.byteStride!="number")for(const r of i.attributes||[]){const o=xr(r.format);n+=o.byteLength}const s=i.attributes?.find(r=>r.attribute===e);if(s)return{attributeName:s.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:n}}return null}let ln;function Sl(t){return(!ln||ln.byteLength<t)&&(ln=new ArrayBuffer(t)),ln}function RS(t,e){const i=Sl(t.BYTES_PER_ELEMENT*e);return new t(i,0,e)}function pp(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Vn(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":pp(t)}const _p=1024;class mp{layout={};byteLength;constructor(e,i={}){let n=0;for(const[r,o]of Object.entries(e)){const a=np(o),{type:l,components:c}=a,u=c*(i?.[r]??1);n=Cd(n,u);const h=n;n+=u,this.layout[r]={type:l,size:u,offset:h}}n+=(4-n%4)%4;const s=n*4;this.byteLength=Math.max(s,_p)}getData(e){const i=Sl(this.byteLength),n={i32:new Int32Array(i),u32:new Uint32Array(i),f32:new Float32Array(i),f16:new Uint16Array(i)};for(const[s,r]of Object.entries(e)){const o=this.layout[s];if(!o){V.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"){V.warn(`Supplied value for single component uniform ${s} is not a number: ${r}`)();continue}u[c]=Number(r)}else{if(!Vn(r)){V.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${r}`)();continue}u.set(r,c)}}return new Uint8Array(i,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}
12function gp(t,e,i=16){if(t!==e)return!1;const n=t,s=e;if(!Vn(n))return!1;if(Vn(s)&&n.length===s.length){for(let r=0;r<n.length;++r)if(s[r]!==n[r])return!1}return!0}function Tp(t){return Vn(t)?t.slice():t}class Sp{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){const i=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!i)throw new Error(e?.name);const n=i;for(const s of n.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(const[i,n]of Object.entries(e))this._setUniform(i,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${i}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,i){gp(this.uniforms[e],i)||(this.uniforms[e]=Tp(i),this.modifiedUniforms[e]=!0,this.modified=!0)}}class Se{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(const[i,n]of Object.entries(e)){const s=i,r=new mp(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new Sp({name:i});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(const[i,n]of Object.entries(e))this.uniformBlocks.get(i)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){const i=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(i)}createUniformBuffer(e,i,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(i),r=e.createBuffer({usage:G.UNIFORM|G.COPY_DST,byteLength:s}),o=this.getUniformBufferData(i);return r.write(o),r}getManagedUniformBuffer(e,i){if(!this.uniformBuffers.get(i)){const n=this.getUniformBufferByteLength(i),s=e.createBuffer({usage:G.UNIFORM|G.COPY_DST,byteLength:n});this.uniformBuffers.set(i,s)}return this.uniformBuffers.get(i)}updateUniformBuffers(){let e=!1;for(const i of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(i);e||=n}return e&&V.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){const i=this.uniformBlocks.get(e);let n=this.uniformBuffers.get(e),s=!1;if(n&&i?.needsRedraw){s||=i.needsRedraw;const r=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(r);const o=this.uniformBlocks.get(e)?.getAllUniforms();V.log(4,`Writing to uniform buffer ${String(e)}`,r,o)()}return s}}var si;(
vendor: 32,708 bytes, line 12
12function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}
12)(si||(si={}));const xp={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:{}},yp=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),vp=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),Ep=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}});function Ap(t=!0){const e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(i,n){if(i==="webgl"||i==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&Rp(s),s}return this.originalGetContext(i,n)}}function Rp(t){t.getExtension("EXT_color_buffer_float");const e={...xp,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:yp(t),OES_vertex_array_object:vp(t),ANGLE_instanced_arrays:Ep(t)},i=t.getExtension;t.getExtension=function(s){const r=i.call(t,s);return r||(s in e?e[s]:null)};const n=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(n.apply(t)||[])?.concat(Object.keys(e))}}async function xl(t,e){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${t}': ${o}`)),i.appendChild(n)})}const Cp=1;let qe=null,Ro=!1;const Er={debugSpectorJS:V.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/[email protected]/dist/spector.bundle.js",gl:void 0};async function bp(t){if(!globalThis.SPECTOR)try{await xl(t.debugSpectorJSUrl||Er.debugSpectorJSUrl)}catch(e){V.warn(String(e))}}function CS(t){if(t={...Er,...t},!t.debugSpectorJS)return null;if(!qe&&globalThis.SPECTOR&&!globalThis.luma?.spector){V.probe(Cp,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:e}=globalThis.SPECTOR;qe=new e,globalThis.luma&&(globalThis.luma.spector=qe)}if(!qe)return null;if(Ro||(Ro=!0,qe.spyCanvases(),qe?.onCaptureStarted.add(e=>V.info("Spector capture started:",e)()),qe?.onCapture.add(e=>{V.info("Spector capture complete:",e)(),qe?.getResultUI(),qe?.resultView.display(),qe?.resultView.addCapture(e)})),t.gl){const e=t.gl,i=e.device;qe?.startCapture(t.gl,500),e.device=i,new Promise(n=>setTimeout(n,2e3)).then(n=>{V.info("Spector capture stopped after 2 seconds")(),qe?.stopCapture()})}return qe}const Ip="https://unpkg.com/[email protected]/index.js";function yl(t){return t.luma=t.luma||{},t.luma}async function Pp(){Ki()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await xl(Ip))}function bS(t,e={}){return e.debugWebGL||e.traceWebGL?Np(t,e):wp(t)}function wp(t){const e=yl(t);return e.realContext?e.realContext:t}function Np(t,e){if(!globalThis.WebGLDebugUtils)return V.warn("webgl-debug not loaded")(),t;const i=yl(t);if(i.debugContext)return i.debugContext;globalThis.WebGLDebugUtils.init({...si,...t});const n=globalThis.WebGLDebugUtils.makeDebugContext(t,Mp.bind(null,e),kp.bind(null,e));for(const o in si)!(o in n)&&typeof si[o]=="number"&&(n[o]=si[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,n);const r=Object.create(s);return i.realContext=t,i.debugContext=r,r.debug=!0,r}function Co(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${t}(${i})`}function Mp(t,e,i,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,n),o=`${s} in gl.${i}(${r})`;V.error(o)();debugger}function kp(t,e,i){let n="";V.level>=1&&(n=Co(e,i),t.traceWebGL&&V.log(1,n)());for(const s of i)if(s===void 0){n=n||Co(e,i);debugger}}const cn=1;class Fp extends Yd{type="webgl";constructor(){super(),Xi.defaultProps={...Xi.defaultProps,...Er}}enforceWebGL2(e){Ap(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&V.warn("WebGL1 is not supported",e)(),!1)}async attach(e,i={}){const{WebGLDevice:n}=await ao(async()=>{const{WebGLDevice:r}=await import("./webgl-device-VYSuD6Fo.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]));if(e instanceof n)return e;if(e?.device instanceof n)return e.device;if(!Dp(e))throw new Error("Invalid WebGL2RenderingContext");
12const s=i.createCanvasContext===!0?{}:i.createCanvasContext;return new n({...i,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:i}=await ao(async()=>{const{WebGLDevice:n}=await import("./webgl-device-VYSuD6Fo.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7]));V.groupCollapsed(cn,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(Pp()),e.debugSpectorJS&&n.push(bp(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&V.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new i(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 V.probe(cn,o)(),V.table(cn,r.info)(),r}finally{V.groupEnd(cn)()}}}function Dp(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&Number.isFinite(t._version))}const Op=new Fp;/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */function bo(t,e){(e==null||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function Bp(t){if(Array.isArray(t))return t}function Up(t,e){var i=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(i!=null){var n,s,r,o,a=[],l=!0,c=!1;try{if(r=(i=i.call(t)).next,e!==0)for(;!(l=(n=r.call(i)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(u){c=!0,s=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}function Lp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 13In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zp(t,e){return Bp(t)||Up(t,e)||Hp(t,e)||Lp()}function Hp(t,e){if(t){if(typeof t=="string")return bo(t,e);var i={}.toString.call(t).slice(8,-1);return i==="Object"&&t.constructor&&(i=t.constructor.name),i==="Map"||i==="Set"?Array.from(t):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?bo(t,e):void 0}}const vl=Object.entries,Io=Object.setPrototypeOf,Vp=Object.isFrozen,Xp=Object.getPrototypeOf,Wp=Object.getOwnPropertyDescriptor;let Be=Object.freeze,Ue=Object.seal,ii=Object.create,El=typeof Reflect<"u"&&Reflect,Js=El.apply,er=El.construct;Be||(Be=function(e){return e});Ue||(Ue=function(e){return e});Js||(Js=function(e,i){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(i,s)});er||(er=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return new e(...n)});const Ei=Pe(Array.prototype.forEach),$p=Pe(Array.prototype.lastIndexOf),Po=Pe(Array.prototype.pop),Jt=Pe(Array.prototype.push),Yp=Pe(Array.prototype.splice),Dt=Array.isArray,Ni=Pe(String.prototype.toLowerCase),bs=Pe(String.prototype.toString),wo=Pe(String.prototype.match),Ai=Pe(String.prototype.replace),No=Pe(String.prototype.indexOf),Kp=Pe(String.prototype.trim),Gp=Pe(Number.prototype.toString),jp=Pe(Boolean.prototype.toString),Mo=typeof BigInt>"u"?null:Pe(BigInt.prototype.toString),ko=typeof Symbol>"u"?null:Pe(Symbol.prototype.toString),De=Pe(Object.prototype.hasOwnProperty),Ri=Pe(Object.prototype.toString),Oe=Pe(RegExp.prototype.test),Vt=qp(TypeError);function Pe(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return Js(t,e,n)}}function qp(t){return function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];
vendor: 4,574 bytes, line 13
13return er(t,i)}}function fe(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ni;if(Io&&Io(t,null),!Dt(e))return t;let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=i(s);r!==s&&(Vp(e)||(e[n]=r),s=r)}t[s]=!0}return t}function Zp(t){for(let e=0;e<t.length;e++)De(t,e)||(t[e]=null);return t}function $e(t){const e=ii(null);for(const n of vl(t)){var i=zp(n,2);const s=i[0],r=i[1];De(t,s)&&(Dt(r)?e[s]=Zp(r):r&&typeof r=="object"&&r.constructor===Object?e[s]=$e(r):e[s]=r)}return e}function Qp(t){switch(typeof t){case"string":return t;case"number":return Gp(t);case"boolean":return jp(t);case"bigint":return Mo?Mo(t):"0";case"symbol":return ko?ko(t):"Symbol()";case"undefined":return Ri(t);case"function":case"object":{if(t===null)return Ri(t);const e=t,i=_t(e,"toString");if(typeof i=="function"){const n=i(e);return typeof n=="string"?n:Ri(n)}return Ri(t)}default:return Ri(t)}}function _t(t,e){for(;t!==null;){const n=Wp(t,e);if(n){if(n.get)return Pe(n.get);if(typeof n.value=="function")return Pe(n.value)}t=Xp(t)}function i(){return null}return i}function Jp(t){try{return Oe(t,""),!0}catch{return!1}}const Fo=Be(["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"]),Is=Be(["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"]),Ps=Be(["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"]),e_=Be(["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"]),ws=Be(["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"]),t_=Be(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Do=Be(["#text"]),Oo=Be(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","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","
13spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ns=Be(["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"]),Bo=Be(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","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"]),un=Be(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),i_=Ue(/{{[\w\W]*|^[\w\W]*}}/g),n_=Ue(/<%[\w\W]*|^[\w\W]*%>/g),s_=Ue(/\${[\w\W]*/g),r_=Ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),o_=Ue(/^aria-[\-\w]+$/),Uo=Ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),a_=Ue(/^(?:\w+script|data):/i),l_=Ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),c_=Ue(/^html$/i),u_=Ue(/^[a-z][.\w]*(-[.\w]+)+$/i),Lo=Ue(/<[/\w!]/g),h_=Ue(/<[/\w]/g),f_=Ue(/<\/no(script|embed|frames)/i),d_=Ue(/\/>/i),dt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},p_=function(){return typeof window>"u"?null:window},__=function(e,i){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;
vendor: 4,100 bytes, line 13
13const s="data-tt-policy-suffix";i&&i.hasAttribute(s)&&(n=i.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}},zo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ft=function(e,i,n,s){return De(e,i)&&Dt(e[i])?fe(s.base?$e(s.base):{},e[i],s.transform):n};function Al(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p_();const e=z=>Al(z);if(e.version="3.4.11",e.removed=[],!t||!t.document||t.document.nodeType!==dt.document||!t.Element)return e.isSupported=!1,e;let i=t.document;const n=i,s=n.currentScript;t.DocumentFragment;const r=t.HTMLTemplateElement,o=t.Node,a=t.Element,l=t.NodeFilter,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const u=t.DOMParser,h=t.trustedTypes,f=a.prototype,d=_t(f,"cloneNode"),T=_t(f,"remove"),C=_t(f,"nextSibling"),w=_t(f,"childNodes"),A=_t(f,"parentNode"),F=_t(f,"shadowRoot"),b=_t(f,"attributes"),g=o&&o.prototype?_t(o.prototype,"nodeType"):null,v=o&&o.prototype?_t(o.prototype,"nodeName"):null;if(typeof r=="function"){const z=i.createElement("template");z.content&&z.content.ownerDocument&&(i=z.content.ownerDocument)}let N,B="",W,Y=!1,q=0;const ee=function(){if(q>0)throw Vt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ne=function(m){ee(),q++;try{return N.createHTML(m)}finally{q--}},re=function(m){ee(),q++;try{return N.createScriptURL(m)}finally{q--}},I=function(){return Y||(W=__(h,s),Y=!0),W},U=i,k=U.implementation,$=U.createNodeIterator,Z=U.createDocumentFragment,ie=U.getElementsByTagName,te=n.importNode;let O=zo();e.isSupported=typeof vl=="function"&&typeof A=="function"&&k&&k.createHTMLDocument!==void 0;const H=i_,ae=n_,Q=s_,oe=r_,Ce=o_,Ve=a_,Qe=l_,_i=u_;let Fr=Uo,ye=null;const Dr=fe({},[...Fo,...Is,...Ps,...ws,...Do]);let ve=null;const Or=fe({},[...Oo,...Ns,...Bo,...un]);let Ee=Object.seal(ii(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}})),mi=null,Br=null;const Nt=Object.seal(ii(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ur=!0,ns=!0,Lr=!1,zr=!0,Mt=!1,gi=!0,zt=!1,ss=!1,rs=null,os=null,as=!1,Kt=!1,ji=!1,qi=!1,Hr=!0,Vr=!1;const Xr="user-content-";let ls=!0,cs=!1,Gt={},ut=null;const us=fe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Wr=null;const $r=fe({},["audio","video","img","source","image","track"]);let hs=null;const Yr=fe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Zi="http://www.w3.org/1998/Math/MathML",Qi="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml";let jt=ht,fs=!1,ds=null;const mc=fe({},[Zi,Qi,ht],bs),Kr=Be(["mi","mo","mn","ms","mtext"]);let ps=fe({},Kr);const Gr=Be(["annotation-xml"]);let _s=fe({},Gr);const gc=fe({},["title","style","font","a","script"]);let Ti=null;const Tc=["application/xhtml+xml","text/html"],Sc="text/html";let Ae=null,qt=null;const xc=i.createElement("form"),jr=function(m){return m instanceof RegExp||m instanceof Function},ms=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(qt&&qt===m)return;(!m||typeof m!="object")&&(m={}
vendor: 8,090 bytes, line 13
13),m=$e(m),Ti=Tc.indexOf(m.PARSER_MEDIA_TYPE)===-1?Sc:m.PARSER_MEDIA_TYPE,Ae=Ti==="application/xhtml+xml"?bs:Ni,ye=Ft(m,"ALLOWED_TAGS",Dr,{transform:Ae}),ve=Ft(m,"ALLOWED_ATTR",Or,{transform:Ae}),ds=Ft(m,"ALLOWED_NAMESPACES",mc,{transform:bs}),hs=Ft(m,"ADD_URI_SAFE_ATTR",Yr,{transform:Ae,base:Yr}),Wr=Ft(m,"ADD_DATA_URI_TAGS",$r,{transform:Ae,base:$r}),ut=Ft(m,"FORBID_CONTENTS",us,{transform:Ae}),mi=Ft(m,"FORBID_TAGS",$e({}),{transform:Ae}),Br=Ft(m,"FORBID_ATTR",$e({}),{transform:Ae}),Gt=De(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?$e(m.USE_PROFILES):m.USE_PROFILES:!1,Ur=m.ALLOW_ARIA_ATTR!==!1,ns=m.ALLOW_DATA_ATTR!==!1,Lr=m.ALLOW_UNKNOWN_PROTOCOLS||!1,zr=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Mt=m.SAFE_FOR_TEMPLATES||!1,gi=m.SAFE_FOR_XML!==!1,zt=m.WHOLE_DOCUMENT||!1,Kt=m.RETURN_DOM||!1,ji=m.RETURN_DOM_FRAGMENT||!1,qi=m.RETURN_TRUSTED_TYPE||!1,as=m.FORCE_BODY||!1,Hr=m.SANITIZE_DOM!==!1,Vr=m.SANITIZE_NAMED_PROPS||!1,ls=m.KEEP_CONTENT!==!1,cs=m.IN_PLACE||!1,Fr=Jp(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:Uo,jt=typeof m.NAMESPACE=="string"?m.NAMESPACE:ht,ps=De(m,"MATHML_TEXT_INTEGRATION_POINTS")&&m.MATHML_TEXT_INTEGRATION_POINTS&&typeof m.MATHML_TEXT_INTEGRATION_POINTS=="object"?$e(m.MATHML_TEXT_INTEGRATION_POINTS):fe({},Kr),_s=De(m,"HTML_INTEGRATION_POINTS")&&m.HTML_INTEGRATION_POINTS&&typeof m.HTML_INTEGRATION_POINTS=="object"?$e(m.HTML_INTEGRATION_POINTS):fe({},Gr);const P=De(m,"CUSTOM_ELEMENT_HANDLING")&&m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING=="object"?$e(m.CUSTOM_ELEMENT_HANDLING):ii(null);if(Ee=ii(null),De(P,"tagNameCheck")&&jr(P.tagNameCheck)&&(Ee.tagNameCheck=P.tagNameCheck),De(P,"attributeNameCheck")&&jr(P.attributeNameCheck)&&(Ee.attributeNameCheck=P.attributeNameCheck),De(P,"allowCustomizedBuiltInElements")&&typeof P.allowCustomizedBuiltInElements=="boolean"&&(Ee.allowCustomizedBuiltInElements=P.allowCustomizedBuiltInElements),Ue(Ee),Mt&&(ns=!1),ji&&(Kt=!0),Gt&&(ye=fe({},Do),ve=ii(null),Gt.html===!0&&(fe(ye,Fo),fe(ve,Oo)),Gt.svg===!0&&(fe(ye,Is),fe(ve,Ns),fe(ve,un)),Gt.svgFilters===!0&&(fe(ye,Ps),fe(ve,Ns),fe(ve,un)),Gt.mathMl===!0&&(fe(ye,ws),fe(ve,Bo),fe(ve,un))),Nt.tagCheck=null,Nt.attributeCheck=null,De(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Nt.tagCheck=m.ADD_TAGS:Dt(m.ADD_TAGS)&&(ye===Dr&&(ye=$e(ye)),fe(ye,m.ADD_TAGS,Ae))),De(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Nt.attributeCheck=m.ADD_ATTR:Dt(m.ADD_ATTR)&&(ve===Or&&(ve=$e(ve)),fe(ve,m.ADD_ATTR,Ae))),De(m,"ADD_URI_SAFE_ATTR")&&Dt(m.ADD_URI_SAFE_ATTR)&&fe(hs,m.ADD_URI_SAFE_ATTR,Ae),De(m,"FORBID_CONTENTS")&&Dt(m.FORBID_CONTENTS)&&(ut===us&&(ut=$e(ut)),fe(ut,m.FORBID_CONTENTS,Ae)),De(m,"ADD_FORBID_CONTENTS")&&Dt(m.ADD_FORBID_CONTENTS)&&(ut===us&&(ut=$e(ut)),fe(ut,m.ADD_FORBID_CONTENTS,Ae)),ls&&(ye["#text"]=!0),zt&&fe(ye,["html","head","body"]),ye.table&&(fe(ye,["tbody"]),delete mi.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Vt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Vt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const L=N;N=m.TRUSTED_TYPES_POLICY;try{B=ne("")}catch(K){throw N=L,K}}else m.TRUSTED_TYPES_POLICY===null?(N=void 0,B=""):(N===void 0&&(N=I()),N&&typeof B=="string"&&(B=ne("")));Be&&Be(m),qt=m},qr=fe({},[...Is,...Ps,...e_]),Zr=fe({},[...ws,...t_]),yc=function(m,P,L){return P.namespaceURI===ht?m==="svg":P.namespaceURI===Zi?m==="svg"&&(L==="annotation-xml"||ps[L]):!!qr[m]},vc=function(m,P,L){return P.namespaceURI===ht?m==="math":P.namespaceURI===Qi?m==="math"&&_s[L]:!!Zr[m]},Ec=function(m,P,L){return P.namespaceURI===Qi&&!_s[L]||P.namespaceURI===Zi&&!ps[L]?!1:!Zr[m]&&(gc[m]||!qr[m])},Ac=function(m){let P=A(m);(!P||!P.tagName)&&(P={namespaceURI:jt,tagName:"template"});const L=Ni(m.tagName),K=Ni(P.tagName);return ds[m.namespaceURI]?m.namespaceURI===Qi?yc(L,P,K):m.namespaceURI===Zi?vc(L,P,K):m.namespaceURI===ht?Ec(L,P,K):!!(Ti==="application/xhtml+xml"&&ds[m.namespaceURI]):!1},kt=function(m){Jt(e.removed,{element:m});try{A(m).removeChild(m)}catch{if(T(m),!A(m))throw Vt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Qr=function(m){const P=w(m);if(P){const K=[];Ei(P,le=>{Jt(K,le)}),Ei(K,le=>{try{T(le)}catch{}})}const L=b(m);if(L)for(let K=L.length-1;K>=0;--K){const le=L[K],de=le&&le.name;if(typeof de=="string")try{m.removeAttribute(de)}catch{}}},Ht=function(m,P){try{Jt(e.removed,{attribute:P.getAttributeNode(m),from:P})}catch{Jt(e.removed,{attribute:null,from:P})}if(P.removeAttribute(m),m==="is")if(Kt||ji)try{kt(P)}catch{}else try{P.setAttribute(m,"")}catch{}},Rc=function(m){const P=b(m);if(P)for(let L=P.length-1;L>=0;--L){const K=P[L],le=K&&K.name;if(!(typeof le!="string"||ve[Ae(le)]))try{m.removeAttribute(le)}catch{}}},Cc=function(m){const P=[m];for(;P.length>0;){const L=P.pop();(g?g(L):L.nodeType)===dt.element&&Rc(L);const le=w(L);if(le)for(let de=le.length-1;de>=0;--de)P.push(le[de])}},Jr=function(m){let P=null,L=null;if(as)m="<remove></remove>"+m;else{const de=wo(m,/^[\r\n\t ]+/);L=de&&de[0]}Ti==="application/xhtml+xml"&&jt===ht&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const K=N?ne(m):m;if(jt===ht)try{P=new u().parseFromString(K,Ti)}catch{}if(!P||!P.documentElement){P=k.createDocument(jt,"template",null);try{P.documentElement.innerHTML=fs?B:K}catch{}}const le=P.body||P.documentElement;return m&&L&&le.insertBefore(i.createTextNode(L),le.childNodes[0]||null),jt===ht?ie.call(P,zt?"html":"body")[0]:zt?P.documentElement:le},eo=function(m){return $.call(m.ownerDocument||m,m,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ji=function(m){return m=Ai(m,H," "),m=Ai(m,ae," "),m=Ai(m,Q," "),m},gs=function(m){var P;m.normalize();const L=$.call(m.ownerDocument||m,m,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let K=L.nextNode();for(;K;)K.data=Ji(K.data),K=L.nextNode();const le=(P=m.querySelectorAll)===null||P===void 0?void 0:P.call(m,"template");le&&Ei(le,de=>{Zt(de.content)&&gs(de.content)})},en=function(m){const P=v?v(m):null;return typeof P!="string"||Ae(P)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==b(m)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==g(m)||m.childNodes!==w(m)},Zt=function(m){if(!g||typeof m!="object"||m===null)return!1;try{return g(m)===dt.documentFragment}catch{return!1}},Si=function(m){if(!g||typeof m!="object"||m===null)return!1;try{return typeof g(m)=="number"}catch{return!1}};function xt(z,m,P){z.length!==0&&Ei(z,L=>{L.call(e,m,P,qt)})}const bc=function(m,P){return!!(gi&&m.hasChildNodes()&&!Si(m.firstElementChild)&&Oe(Lo,m.textContent)&&Oe(Lo,m.innerHTML)||gi&&m.namespaceURI===ht&&P==="style"&&Si(m.firstElementChild)||m.nodeType===dt.processingInstruction||gi&&m.nodeType===dt.comment&&Oe(h_,m.data))},Ic=function(m,P){if(!mi[P]&&no(P)&&(Ee.tagNameCheck instanceof RegExp&&Oe(Ee.tagNameCheck,P)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(P)))return!1;if(ls&&!ut[P]){const L=A(m),K=w(m);if(K&&L){const le=K.length;for(let de=le-1;de>=0;--de){const ke=cs?K[de]:d(K[de],!0);L.insertBefore(ke,C(m))}}}return kt(m),!0},to=function(m){if(xt(O.beforeSanitizeElements,m,null),en(m))return kt(m),!0;const P=Ae(v?v(m):m.nodeName);if(xt(O.uponSanitizeElement,m,{tagName:P,allowedTags:ye}),bc(m,P))return kt(m),!0;if(mi[P]||!(Nt.tagCheck instanceof Function&&Nt.tagCheck(P))&&!ye[P])return Ic(m,P);if((g?g(m):m.nodeType)===dt.element&&!Ac(m)||(P==="noscript"||P==="noembed"||P==="noframes")&&Oe(f_,m.innerHTML))return kt(m),!0;if(Mt&&m.nodeType===dt.text){const K=Ji(m.textContent);m.textContent!==K&&(Jt(e.removed,{element:m.cloneNode()}),m.textContent=K)}return xt(O.afterSanitizeElements,m,null),!1}
13,io=function(m,P,L){if(Br[P]||Hr&&(P==="id"||P==="name")&&(L in i||L in xc))return!1;const K=ve[P]||Nt.attributeCheck instanceof Function&&Nt.attributeCheck(P,m);if(!(ns&&Oe(oe,P))){if(!(Ur&&Oe(Ce,P))){if(K){if(!hs[P]){if(!Oe(Fr,Ai(L,Qe,""))){if(!((P==="src"||P==="xlink:href"||P==="href")&&m!=="script"&&No(L,"data:")===0&&Wr[m])){if(!(Lr&&!Oe(Ve,Ai(L,Qe,"")))){if(L)return!1}}}}}else if(!(no(m)&&(Ee.tagNameCheck instanceof RegExp&&Oe(Ee.tagNameCheck,m)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(m))&&(Ee.attributeNameCheck instanceof RegExp&&Oe(Ee.attributeNameCheck,P)||Ee.attributeNameCheck instanceof Function&&Ee.attributeNameCheck(P,m))||P==="is"&&Ee.allowCustomizedBuiltInElements&&(Ee.tagNameCheck instanceof RegExp&&Oe(Ee.tagNameCheck,L)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(L))))return!1}}return!0},Pc=fe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),no=function(m){return!Pc[Ni(m)]&&Oe(_i,m)},wc=function(m,P,L,K){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!L)switch(h.getAttributeType(m,P)){case"TrustedHTML":return ne(K);case"TrustedScriptURL":return re(K)}return K},Nc=function(m,P,L,K){try{L?m.setAttributeNS(L,P,K):m.setAttribute(P,K),en(m)?kt(m):Po(e.removed)}catch{Ht(P,m)}},so=function(m){xt(O.beforeSanitizeAttributes,m,null);const P=m.attributes;if(!P||en(m))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ve,forceKeepAttr:void 0};let K=P.length;const le=Ae(m.nodeName);for(;K--;){const de=P[K],ke=de.name,be=de.namespaceURI,Je=de.value,it=Ae(ke),Ss=Je;let Xe=ke==="value"?Ss:Kp(Ss);if(L.attrName=it,L.attrValue=Xe,L.keepAttr=!0,L.forceKeepAttr=void 0,xt(O.uponSanitizeAttribute,m,L),Xe=L.attrValue,Vr&&(it==="id"||it==="name")&&No(Xe,Xr)!==0&&(Ht(ke,m),Xe=Xr+Xe),gi&&Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Xe)){Ht(ke,m);continue}if(it==="attributename"&&wo(Xe,"href")){Ht(ke,m);continue}if(!L.forceKeepAttr){if(!L.keepAttr){Ht(ke,m);continue}if(!zr&&Oe(d_,Xe)){Ht(ke,m);continue}if(Mt&&(Xe=Ji(Xe)),!io(le,it,Xe)){Ht(ke,m);continue}Xe=wc(le,it,be,Xe),Xe!==Ss&&Nc(m,ke,be,Xe)}}xt(O.afterSanitizeAttributes,m,null)},tn=function(m){let P=null;const L=eo(m);for(xt(O.beforeSanitizeShadowDOM,m,null);P=L.nextNode();)if(xt(O.uponSanitizeShadowNode,P,null),to(P),so(P),Zt(P.content)&&tn(P.content),(g?g(P):P.nodeType)===dt.element){const le=F(P);Zt(le)&&(Ts(le),tn(le))}xt(O.afterSanitizeShadowDOM,m,null)},Ts=function(m){const P=[{node:m,shadow:null}];for(;P.length>0;){const L=P.pop();if(L.shadow){tn(L.shadow);continue}const K=L.node,de=(g?g(K):K.nodeType)===dt.element,ke=w(K);if(ke)for(let be=ke.length-1;be>=0;--be)P.push({node:ke[be],shadow:null});if(de){const be=v?v(K):null;if(typeof be=="string"&&Ae(be)==="template"){const Je=K.content;Zt(Je)&&P.push({node:Je,shadow:null})}}if(de){const be=F(K);Zt(be)&&P.push({node:null,shadow:be},{node:be,shadow:null})}}};return e.sanitize=function(z){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},P=null,L=null,K=null,le=null;if(fs=!z,fs&&(z="<!-->"),typeof z!="string"&&!Si(z)&&(z=Qp(z),typeof z!="string"))throw Vt("dirty is not a string, aborting");if(!e.isSupported)return z;ss?(ye=rs,ve=os):ms(m),(O.uponSanitizeElement.length>0||O.uponSanitizeAttribute.length>0)&&(ye=$e(ye)),O.uponSanitizeAttribute.length>0&&(ve=$e(ve)),e.removed=[];const de=cs&&typeof z!="string"&&Si(z);if(de){const Je=v?v(z):z.nodeName;if(typeof Je=="string"){const it=Ae(Je);if(!ye[it]||mi[it])throw Vt("root node is forbidden and cannot be sanitized in-place")}if(en(z))throw Vt("root node is clobbered and cannot be sanitized in-place");try{Ts(z)}catch(it){throw Qr(z),it}}else if(Si(z))P=Jr("<!---->"),L=P.ownerDocument.importNode(z,!0),L.nodeType===dt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?P=L:P.appendChild(L),Ts(L);else{if(!Kt&&!Mt&&!zt&&z.indexOf("<")===-1)return N&&qi?ne(z):z;if(P=Jr(z),!P)return Kt?null:qi?B:""}P&&as&&kt(P.firstChild);const ke=eo(de?z:P);try{for(;K=ke.nextNode();)to(K),so(K),Zt(K.content)&&tn(K.content)}catch(Je){throw de&&Qr(z),Je}if(de)return Ei(e.removed,Je=>{Je.element&&Cc(Je.element)}),Mt&&gs(z),z;if(Kt){if(Mt&&gs(P),ji)for(le=Z.call(P.ownerDocument);
13P.firstChild;)le.appendChild(P.firstChild);else le=P;return(ve.shadowroot||ve.shadowrootmode)&&(le=te.call(n,le,!0)),le}let be=zt?P.outerHTML:P.innerHTML;return zt&&ye["!doctype"]&&P.ownerDocument&&P.ownerDocument.doctype&&P.ownerDocument.doctype.name&&Oe(c_,P.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+P.ownerDocument.doctype.name+`> 14`+be),Mt&&(be=Ji(be)),N&&qi?ne(be):be},e.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ms(z),ss=!0,rs=ye,os=ve},e.clearConfig=function(){qt=null,ss=!1,rs=null,os=null,N=W,B=""},e.isValidAttribute=function(z,m,P){qt||ms({});const L=Ae(z),K=Ae(m);return io(L,K,P)},e.addHook=function(z,m){typeof m=="function"&&De(O,z)&&Jt(O[z],m)},e.removeHook=function(z,m){if(De(O,z)){if(m!==void 0){const P=$p(O[z],m);return P===-1?void 0:Yp(O[z],P,1)[0]}return Po(O[z])}},e.removeHooks=function(z){De(O,z)&&(O[z]=[])},e.removeAllHooks=function(){O=zo()},e}var m_=Al(),Ho=typeof Float32Array<"u"?Float32Array:Array;function g_(){var t=new Ho(9);return Ho!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function Vo(t,e,i){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],h=e[8],f=i[0],d=i[1];return t[0]=n,t[1]=s,t[2]=r,t[3]=o,t[4]=a,t[5]=l,t[6]=f*n+d*o+c,t[7]=f*s+d*a+u,t[8]=f*r+d*l+h,t}function Ms(t,e,i){var n=i[0],s=i[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function T_(t,e,i){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/i,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}var xn={exports:{}},S_=xn.exports,Xo;function x_(){return Xo||(Xo=1,(function(t){(function(e,i,n){function s(l){var c=this,u=a();c.next=function(){var h=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=h-(c.c=h|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),h=c&&c.state,f=u.next;return f.int32=function(){return u.next()*4294967296|0},f.double=function(){return f()+(f()*2097152|0)*11102230246251565e-32},f.quick=f,h&&(typeof h=="object"&&r(h,u),f.state=function(){return r(u,{})}),f}function a(){var l=4022871197,c=function(u){u=String(u);for(var h=0;h<u.length;h++){l+=u.charCodeAt(h);var f=.02519603282416938*l;l=f>>>0,f-=l,f*=l,l=f>>>0,f-=l,l+=f*4294967296}return(l>>>0)*23283064365386963e-26};return c}i&&i.exports?i.exports=o:this.alea=o})(S_,t)})(xn)),xn.exports}var yn={exports:{}},y_=yn.exports,Wo;function v_(){return Wo||(Wo=1,(function(t){(function(e,i,n){function s(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>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,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var f=c.next()>>>11,d=(c.next()>>>0)/4294967296,T=(f+d)/(1<<21);while(T===0);return T},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}i&&i.exports?i.exports=o:this.xor128=o})(y_,t)})(yn)),yn.exports}var vn={exports:{}},E_=vn.exports,$o;function A_(){return $o||($o=1,(function(t){(function(e,i,n){function s(a){var l=this,c="";l.next=function(){var h=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^(h^h<<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,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var f=c.next()>>>11,d=(c.next()>>>0)/4294967296,T=(f+d)/(1<<21);while(T===0);return T},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}i&&i.exports?i.exports=o:this.xorwow=o})(E_,t)})(vn)),vn.exports}var En={exports:{}},R_=En.exports,Yo;function C_(){return Yo||(Yo=1,(function(t){(function(e,i,n){function s(a){var l=this;l.next=function(){var u=l.x,h=l.i,f,d;return f=u[h],f^=f>>>7,d=f^f<<24,f=u[h+1&7],d^=f^f>>>10,f=u[h+3&7],d^=f^f>>>3,f=u[h+4&7],d^=f^f<<7,f=u[h+7&7],f=f^f<<13,d^=f^f<<9,u[h]=d,l.i=h+1&7,d};function c(u,h){var f,d=[];if(h===(h|0))d[0]=h;else for(h=""+h,f=0;f<h.length;++f)d[f&7]=d[f&7]<<15^h.charCodeAt(f)+d[f+1&7]<<13;for(;d.length<8;)d.push(0);for(f=0;f<8&&d[f]===0;++f);for(f==8?d[7]=-1:d[f],u.x=d,u.i=0,f=256;f>0;--f)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,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var f=c.next()>>>11,d=(c.next()>>>0)/4294967296,T=(f+d)/(1<<21);while(T===0);return T},h.int32=c.next,h.quick=h,u&&(u.x&&r(u,c),h.state=function(){return r(c,{})}),h}i&&i.exports?i.exports=o:this.xorshift7=o})(R_,t)})(En)),En.exports}
14var An={exports:{}},b_=An.exports,Ko;function I_(){return Ko||(Ko=1,(function(t){(function(e,i,n){function s(a){var l=this;l.next=function(){var u=l.w,h=l.X,f=l.i,d,T;return l.w=u=u+1640531527|0,T=h[f+34&127],d=h[f=f+1&127],T^=T<<13,d^=d<<17,T^=T>>>15,d^=d>>>12,T=h[f]=T^d,l.i=f,T+(u^u>>>16)|0};function c(u,h){var f,d,T,C,w,A=[],F=128;for(h===(h|0)?(d=h,h=null):(h=h+"\0",d=0,F=Math.max(F,h.length)),T=0,C=-32;C<F;++C)h&&(d^=h.charCodeAt((C+32)%h.length)),C===0&&(w=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,C>=0&&(w=w+1640531527|0,f=A[C&127]^=d+w,T=f==0?T+1:0);for(T>=128&&(A[(h&&h.length||0)&127]=-1),T=127,C=512;C>0;--C)d=A[T+34&127],f=A[T=T+1&127],d^=d<<13,f^=f<<17,d^=d>>>15,f^=f>>>12,A[T]=d^f;u.w=w,u.X=A,u.i=T}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,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var f=c.next()>>>11,d=(c.next()>>>0)/4294967296,T=(f+d)/(1<<21);while(T===0);return T},h.int32=c.next,h.quick=h,u&&(u.X&&r(u,c),h.state=function(){return r(c,{})}),h}i&&i.exports?i.exports=o:this.xor4096=o})(b_,t)})(An)),An.exports}var Rn={exports:{}},P_=Rn.exports,Go;function w_(){return Go||(Go=1,(function(t){(function(e,i,n){function s(a){var l=this,c="";l.next=function(){var h=l.b,f=l.c,d=l.d,T=l.a;return h=h<<25^h>>>7^f,f=f-d|0,d=d<<24^d>>>8^T,T=T-h|0,l.b=h=h<<20^h>>>12^f,l.c=f=f-d|0,l.d=d<<16^f>>>16^T,l.a=T-h|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,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var f=c.next()>>>11,d=(c.next()>>>0)/4294967296,T=(f+d)/(1<<21);while(T===0);return T},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&r(u,c),h.state=function(){return r(c,{})}),h}i&&i.exports?i.exports=o:this.tychei=o})(P_,t)})(Rn)),Rn.exports}var Cn={exports:{}},N_=Cn.exports,jo;function M_(){return jo||(jo=1,(function(t){(function(e,i,n){var s=256,r=6,o=52,a="random",l=n.pow(s,r),c=n.pow(2,o),u=c*2,h=s-1,f;function d(g,v,N){var B=[];v=v==!0?{entropy:!0}:v||{};var W=A(w(v.entropy?[g,b(i)]:g??F(),3),B),Y=new T(B),q=function(){for(var ee=Y.g(r),ne=l,re=0;ee<c;)ee=(ee+re)*s,ne*=s,re=Y.g(1);for(;ee>=u;)ee/=2,ne/=2,re>>>=1;return(ee+re)/ne};return q.int32=function(){return Y.g(4)|0},q.quick=function(){return Y.g(4)/4294967296},q.double=q,A(b(Y.S),i),(v.pass||N||function(ee,ne,re,I){return I&&(I.S&&C(I,Y),ee.state=function(){return C(Y,{})}),re?(n[a]=ee,ne):ee})(q,W,"global"in v?v.global:this==n,v.state)}function T(g){var v,N=g.length,B=this,W=0,Y=B.i=B.j=0,q=B.S=[];for(N||(g=[N++]);W<s;)q[W]=W++;for(W=0;W<s;W++)q[W]=q[Y=h&Y+g[W%N]+(v=q[W])],q[Y]=v;(B.g=function(ee){for(var ne,re=0,I=B.i,U=B.j,k=B.S;ee--;)ne=k[I=h&I+1],re=re*s+k[h&(k[I]=k[U=h&U+ne])+(k[U]=ne)];return B.i=I,B.j=U,re})(s)}function C(g,v){return v.i=g.i,v.j=g.j,v.S=g.S.slice(),v}function w(g,v){var N=[],B=typeof g,W;if(v&&B=="object")for(W in g)try{N.push(w(g[W],v-1))}catch{}return N.length?N:B=="string"?g:g+"\0"}function A(g,v){for(var N=g+"",B,W=0;W<N.length;)v[h&W]=h&(B^=v[h&W]*19)+N.charCodeAt(W++);return b(v)}function F(){try{var g;return f&&(g=f.randomBytes)?g=g(s):(g=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(g)),b(g)}catch{var v=e.navigator,N=v&&v.plugins;return[+new Date,e,N,e.screen,b(i)]}}function b(g){return String.fromCharCode.apply(0,g)}if(A(n.random(),i),t.exports){t.exports=d;try{f=iu}catch{}}else n["seed"+a]=d})(typeof self<"u"?self:N_,[],Math)})(Cn)),Cn.exports}var ks,qo;function k_(){if(qo)return ks;qo=1;var t=x_(),e=v_(),i=A_(),n=C_(),s=I_(),r=w_(),o=M_();return o.alea=t,o.xor128=e,o.xorwow=i,o.xorshift7=n,o.xor4096=s,o.tychei=r,ks=o,ks}var F_=k_();const D_=kc(F_);function O_(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,U_(n.key),n)}}function Ar(t,e,i){return e&&O_(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Rl(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,tr(t,e)}function tr(t,e){return tr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},tr(t,e)}function B_(t,e){if(typeof t!="object"||t===null)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var n=i.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function U_(t){var e=B_(t,"string");return typeof e=="symbol"?e:String(e)}var ts=(function(){function t(){}var e=t.prototype;return e._seed=function(n,s){if(n===(n||0))return n;for(var r=""+n,o=0,a=0;a<r.length;++a)o^=r.charCodeAt(a)|0;return o},t})(),Zo=(function(t){Rl(e,t);function e(n,s){var r;return r=t.call(this)||this,r._rng=void 0,r.seed(n,s),r}var i=e.prototype;return i.next=function(){return this._rng()},i.seed=function(s,r){this._rng=s},i.clone=function(s,r){return new e(this._rng,r)},Ar(e,[{key:"name",get:function(){return"function"}}]),e})(ts),Qo=(function(){var t=[].slice.call(arguments),e=t,i=e[0],n=i===void 0?"default":i;switch(typeof n){case"object":if(n instanceof ts)return n;break;case"function":return new Zo(n);case"number":case"string":default:return new Zo(D_.apply(void 0,t))}throw new Error('invalid RNG "'+n+'"')}
14),L_=(function(t,e,i){return e===void 0&&(e=0),i===void 0&&(i=1),function(){return t.next()*(i-e)+e}});function at(t){return new z_(t)}var z_=function(e){var i=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(i.n))return i;throw new Error("Expected number to be an integer, got "+i.n)},this.isPositive=function(){if(i.n>0)return i;throw new Error("Expected number to be positive, got "+i.n)},this.lessThan=function(n){if(i.n<n)return i;throw new Error("Expected number to be less than "+n+", got "+i.n)},this.greaterThanOrEqual=function(n){if(i.n>=n)return i;throw new Error("Expected number to be greater than or equal to "+n+", got "+i.n)},this.greaterThan=function(n){if(i.n>n)return i;throw new Error("Expected number to be greater than "+n+", got "+i.n)},this.n=e},H_=(function(t,e,i){return e===void 0&&(e=0),i===void 0&&(i=1),i===void 0&&(i=e===void 0?1:e,e=0),at(e).isInt(),at(i).isInt(),function(){return Math.floor(t.next()*(i-e+1)+e)}}),V_=(function(t){return function(){return t.next()>=.5}}),X_=(function(t,e,i){return e===void 0&&(e=0),i===void 0&&(i=1),function(){var n,s,r;do n=t.next()*2-1,s=t.next()*2-1,r=n*n+s*s;while(!r||r>1);return e+i*s*Math.sqrt(-2*Math.log(r)/r)}}),W_=(function(t,e,i){e===void 0&&(e=0),i===void 0&&(i=1);var n=t.normal(e,i);return function(){return Math.exp(n())}}),$_=(function(t,e){return e===void 0&&(e=.5),at(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(t.next()+e)}}),Y_=(function(t,e,i){return e===void 0&&(e=1),i===void 0&&(i=.5),at(e).isInt().isPositive(),at(i).greaterThanOrEqual(0).lessThan(1),function(){for(var n=0,s=0;n++<e;)t.next()<i&&s++;return s}}),K_=(function(t,e){e===void 0&&(e=.5),at(e).greaterThan(0).lessThan(1);var i=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(t.next())*i)}}),G_=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],j_=function(e){return G_[e]},q_=.9189385332046727,Z_=(function(t,e){if(e===void 0&&(e=1),at(e).isPositive(),e<10){var i=Math.exp(-e);return function(){for(var l=i,c=0,u=t.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=t.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=t.next()-.5:(l=c/a-.93,l=(l<0?-.5:.5)-l,c=t.next()*a);var u=.5-Math.abs(l);if(!(u<.013&&c>u)){var h=Math.floor((2*r/u+s)*l+e+.445);if(c=c*o/(r/(u*u)+s),h>=10){var f=(h+.5)*Math.log(e/h)-e-q_+h-(.08333333333333333-(.002777777777777778-1/(1260*h*h))/(h*h))/h;if(Math.log(c*n)<=f)return h}else if(h>=0){var d,T=(d=j_(h))!=null?d:0;if(Math.log(c)<=h*Math.log(e)-e-T)return h}}}}}}),Q_=(function(t,e){return e===void 0&&(e=1),at(e).isPositive(),function(){return-Math.log(1-t.next())/e}}),J_=(function(t,e){return e===void 0&&(e=1),at(e).isInt().greaterThanOrEqual(0),function(){for(var i=0,n=0;n<e;++n)i+=t.next();return i}}),em=(function(t,e){e===void 0&&(e=1),at(e).isInt().isPositive();var i=t.irwinHall(e);return function(){return i()/e}}),tm=(function(t,e){e===void 0&&(e=1),at(e).greaterThanOrEqual(0);var i=1/e;return function(){return 1/Math.pow(1-t.next(),i)}}),im=(function(t){Rl(e,t);function e(){return t.apply(this,arguments)||this}var i=e.prototype;return i.next=function(){return Math.random()},i.seed=function(s,r){},i.clone=function(){return new e},Ar(e,[{key:"name",get:function(){return"default"}}]),e})(ts),Cl=(function(){function t(i){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",L_,s,r)},this.uniformInt=function(s,r){return n._memoize("uniformInt",H_,s,r)},this.uniformBoolean=function(){return n._memoize("uniformBoolean",V_)},this.normal=function(s,r){return X_(n,s,r)},this.logNormal=function(s,r){return W_(n,s,r)},this.bernoulli=function(s){return $_(n,s)},this.binomial=function(s,r){return Y_(n,s,r)},this.geometric=function(s){return K_(n,s)},this.poisson=function(s){return Z_(n,s)},this.exponential=function(s){return Q_(n,s)},this.irwinHall=function(s){return J_(n,s)},this.bates=function(s){return em(n,s)},this.pareto=function(s){return tm(n,s)},i&&i instanceof ts?this.use(i):this.use(new im),this._cache={}}var e=t.prototype;return e.clone=function(){var n=[].slice.call(arguments);return n.length?new t(Qo.apply(void 0,n)):new t(this.rng.clone())},e.use=function(){this._rng=Qo.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(n){if(!Array.isArray(n))throw new Error("Random.choice expected input to be an array, got "+typeof n);var s=n?.length;if(s>0){var r=this.uniformInt(0,s-1)();return n[r]}else return},e._memoize=function(n,s){var r=[].slice.call(arguments,2),o=""+r.join(";"),a=this._cache[n];return(a===void 0||a.key!==o)&&(a={key:o,distribution:s.apply(void 0,[this].concat(r))},this._cache[n]=a),a.distribution},Ar(t,[{key:"rng",get:function(){return this._rng}}]),t})();new Cl;function Rr(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}const Fs={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function nm(t){const e={};for(const[i,n]of Object.entries(t))e[i]=sm(n);return e}function sm(t){let e=Jo(t);if(e!=="object")return{value:t,...Fs[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Fs[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=Jo(t.value),{...t,...Fs[e],type:e}):{type:"object",value:null};throw new Error("props")}function Jo(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}const rm=`#ifdef MODULE_LOGDEPTH 15 logdepth_adjustPosition(gl_Position); 16#endif 17`,om=`#ifdef MODULE_MATERIAL 18 fragColor = material_filterColor(fragColor); 19#endif 20 21#ifdef MODULE_LIGHTING 22 fragColor = lighting_filterColor(fragColor); 23#endif 24 25#ifdef MODULE_FOG 26 fragColor = fog_filterColor(fragColor); 27#endif 28 29#ifdef MODULE_PICKING 30 fragColor = picking_filterHighlightColor(fragColor); 31 fragColor = picking_filterPickingColor(fragColor); 32#endif 33 34#ifdef MODULE_LOGDEPTH 35 logdepth_setFragDepth(); 36#endif 37`,am={vertex:rm,fragment:om},ea=/void\s+main\s*\([^)]*\)\s*\{\n?/,ta=/}\n?[^{}]*$/,Ds=[],bn="__LUMA_INJECT_DECLARATIONS__";function lm(t){const e={vertex:{},fragment:{}};for(const i in t){let n=t[i];const s=cm(i);typeof n=="string"&&(n={order:0,injection:n}),e[s][i]=n}return e}function cm(t){const e=t.slice(0,2);switch(e){case"vs":return"vertex";
37case"fs":return"fragment";default:throw new Error(e)}}function Xn(t,e,i,n=!1){const s=e==="vertex";for(const r in i){const o=i[r];o.sort((l,c)=>l.order-c.order),Ds.length=o.length;for(let l=0,c=o.length;l<c;++l)Ds[l]=o[l].injection;const a=`${Ds.join(` 38`)} 39`;switch(r){case"vs:#decl":s&&(t=t.replace(bn,a));break;case"vs:#main-start":s&&(t=t.replace(ea,l=>l+a));break;case"vs:#main-end":s&&(t=t.replace(ta,l=>a+l));break;case"fs:#decl":s||(t=t.replace(bn,a));break;case"fs:#main-start":s||(t=t.replace(ea,l=>l+a));break;case"fs:#main-end":s||(t=t.replace(ta,l=>a+l));break;default:t=t.replace(r,l=>l+a)}}return t=t.replace(bn,""),n&&(t=t.replace(/\}\s*$/,r=>r+am[e])),t}function Wn(t){t.map(e=>um(e))}function um(t){if(t.instance)return;Wn(t.dependencies||[]);const{propTypes:e={},deprecations:i=[],inject:n={}}=t,s={normalizedInjections:lm(n),parsedDeprecations:hm(i)};e&&(s.propValidators=nm(e)),t.instance=s;let r={};e&&(r=Object.entries(e).reduce((o,[a,l])=>{const c=l?.value;return c&&(o[a]=c),o},{})),t.defaultUniforms={...t.defaultUniforms,...r}}function bl(t,e,i){t.deprecations?.forEach(n=>{n.regex?.test(e)&&(n.deprecated?i.deprecated(n.old,n.new)():i.removed(n.old,n.new)())})}function hm(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function Cr(t){Wn(t);const e={},i={};Il({modules:t,level:0,moduleMap:e,moduleDepth:i});const n=Object.keys(i).sort((s,r)=>i[r]-i[s]).map(s=>e[s]);return Wn(n),n}function Il(t){const{modules:e,level:i,moduleMap:n,moduleDepth:s}=t;if(i>=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]<i)&&(s[r.name]=i);for(const r of e)r.dependencies&&Il({modules:r.dependencies,level:i+1,moduleMap:n,moduleDepth:s})}function fm(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU 40// Apple optimizes away the calculation necessary for emulated fp64 41#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 42#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 43// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow 44#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 45`;case"nvidia":return`#define NVIDIA_GPU 46// Nvidia optimizes away the calculation necessary for emulated fp64 47#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 48`;case"intel":return`#define INTEL_GPU 49// Intel optimizes away the calculation necessary for emulated fp64 50#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 51// Intel's built-in 'tan' function doesn't have acceptable precision 52#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 53// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow 54#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 55`;case"amd":return`#define AMD_GPU 56`;default:return`#define DEFAULT_GPU 57// Prevent driver from optimizing away the calculation necessary for emulated fp64 58#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 59// Headless Chrome's software shader 'tan' function doesn't have acceptable precision 60#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 61// If the GPU doesn't have full 32 bits precision, will causes overflow 62#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 63`}}function dm(t,e){if(Number(t.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=ia(t,pm),t;case"fragment":return t=ia(t,_m),t;default:throw new Error(e)}}const Pl=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es 64`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],pm=[...Pl,[ir("attribute"),"in $1"],[ir("varying"),"out $1"]],_m=[...Pl,[ir("varying"),"in $1"]];function ia(t,e){for(const[i,n]of e)t=t.replace(i,n);return t}function ir(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function wl(t,e){let i="";for(const n in t){const s=t[n];if(i+=`void ${s.signature} { 65`,s.header&&(i+=` ${s.header}`),e[n]){const r=e[n];r.sort((o,a)=>o.order-a.order);for(const o of r)i+=` ${o.injection} 66`}s.footer&&(i+=` ${s.footer}`),i+=`} 67`}return i}function Nl(t){const e={vertex:{},fragment:{}};for(const i of t){let n,s;
67typeof i!="string"?(n=i,s=n.hook):(n={},s=i),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 mm(t,e){return{name:gm(t,e),language:"glsl",version:Tm(t)}}function gm(t,e="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return n?n[1]:e}function Tm(t){let e=100;const i=t.match(/[^\s]+/g);if(i&&i.length>=2&&i[0]==="#version"){const n=parseInt(i[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}const Ml=` 68 69${bn} 70`,Sm=`precision highp float; 71`;function xm(t){const e=Cr(t.modules||[]);return{source:vm(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:kl(e)}}function ym(t){const{vs:e,fs:i}=t,n=Cr(t.modules||[]);return{vs:na(t.platformInfo,{...t,source:e,stage:"vertex",modules:n}),fs:na(t.platformInfo,{...t,source:i,stage:"fragment",modules:n}),getUniforms:kl(n)}}function vm(t,e){const{source:i,stage:n,modules:s,hookFunctions:r=[],inject:o={},log:a}=e;Rr(typeof i=="string","shader source must be a string");const l=i;let c="";const u=Nl(r),h={},f={},d={};for(const C in o){const w=typeof o[C]=="string"?{injection:o[C],order:0}:o[C],A=/^(v|f)s:(#)?([\w-]+)$/.exec(C);if(A){const F=A[2],b=A[3];F?b==="decl"?f[C]=[w]:d[C]=[w]:h[C]=[w]}else d[C]=[w]}const T=s;for(const C of T){a&&bl(C,l,a);const w=Fl(C,"wgsl");c+=w;const A=C.injections?.[n]||{};for(const F in A){const b=/^(v|f)s:#([\w-]+)$/.exec(F);if(b){const v=b[2]==="decl"?f:d;v[F]=v[F]||[],v[F].push(A[F])}else h[F]=h[F]||[],h[F].push(A[F])}}return c+=Ml,c=Xn(c,n,f),c+=wl(u[n],h),c+=l,c=Xn(c,n,d),c}function na(t,e){const{source:i,stage:n,language:s="glsl",modules:r,defines:o={},hookFunctions:a=[],inject:l={},prologue:c=!0,log:u}=e;Rr(typeof i=="string","shader source must be a string");const h=s==="glsl"?mm(i).version:-1,f=t.shaderLanguageVersion,d=h===100?"#version 100":"#version 300 es",C=i.split(` 72`).slice(1).join(` 73`),w={};r.forEach(N=>{Object.assign(w,N.defines)}),Object.assign(w,o);let A="";switch(s){case"wgsl":break;case"glsl":A=c?`${d} 74 75// ----- PROLOGUE ------------------------- 76${`#define SHADER_TYPE_${n.toUpperCase()}`} 77 78${fm(t)} 79${n==="fragment"?Sm:""} 80 81// ----- APPLICATION DEFINES ------------------------- 82 83${Em(w)} 84 85`:`${d} 86`;break}const F=Nl(a),b={},g={},v={};for(const N in l){const B=typeof l[N]=="string"?{injection:l[N],order:0}:l[N],W=/^(v|f)s:(#)?([\w-]+)$/.exec(N);if(W){const Y=W[2],q=W[3];Y?q==="decl"?g[N]=[B]:v[N]=[B]:b[N]=[B]}else v[N]=[B]}for(const N of r){u&&bl(N,C,u);const B=Fl(N,n);A+=B;const W=N.instance?.normalizedInjections[n]||{};for(const Y in W){const q=/^(v|f)s:#([\w-]+)$/.exec(Y);if(q){const ne=q[2]==="decl"?g:v;ne[Y]=ne[Y]||[],ne[Y].push(W[Y])}else b[Y]=b[Y]||[],b[Y].push(W[Y])}}return A+="// ----- MAIN SHADER SOURCE -------------------------",A+=Ml,A=Xn(A,n,g),A+=wl(F[n],b),A+=C,A=Xn(A,n,v),s==="glsl"&&h!==f&&(A=dm(A,n)),A.trim()}function kl(t){return function(i){const n={};for(const s of t){const r=s.getUniforms?.(i,n);Object.assign(n,r)}return n}}function Em(t={}){let e="";for(const i in t){const n=t[i];(n||Number.isFinite(n))&&(e+=`#define ${i.toUpperCase()} ${t[i]} 87`)}return e}function Fl(t,e){let i;switch(e){case"vertex":i=t.vs||"";break;case"fragment":i=t.fs||"";break;case"wgsl":i=t.source||"";break;default:Rr(!1)}if(!t.name)throw new Error("Shader module must have a name");const n=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let s=`// ----- MODULE ${t.name} --------------- 88 89`;return e!=="wgsl"&&(s+=`#define MODULE_${n} 90`),s+=`${i} 91`,s}const Am=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Rm=/^\s*\#\s*endif\s*$/;function Cm(t,e){const i=t.split(` 92`),n=[];let s=!0,r=null;for(const o of i){const a=o.match(Am),l=o.match(Rm);a?(r=a[1],s=!!e?.defines?.[r]):l?s=!0:s&&n.push(o)}return n.join(` 93`)}class ri{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return ri.defaultShaderAssembler=ri.defaultShaderAssembler||new ri,ri.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(i=>i.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const i=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==i)}addShaderHook(e,i){i&&(e=Object.assign(i,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const i=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:r}=xm({...e,source:e.source,modules:i,hookFunctions:n});return{source:e.platformInfo.shaderLanguage==="wgsl"?Cm(s):s,getUniforms:r,modules:i}}assembleGLSLShaderPair(e){const i=this._getModuleList(e.modules),n=this._hookFunctions;return{...ym({...e,vs:e.vs,fs:e.fs,modules:i,hookFunctions:n}),modules:i}}_getModuleList(e=[]){const i=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;i[s++]=a,n[l]=!0}for(let r=0,o=e.length;r<o;++r){const a=e[r],l=a.name;n[l]||(i[s++]=a,n[l]=!0)}return i.length=s,Wn(i),i}}class tt{constructor(e,i){this.name=e,this.attributes=i,this.size=0}get isArray(){return!1}
93get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class sa{constructor(e,i,n){this.name=e,this.type=i,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 Ot extends tt{constructor(e,i){super(e,i),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Ut extends tt{constructor(e,i){super(e,i),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class nr extends tt{constructor(e,i,n){super(e,n),this.format=i}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class Lt extends tt{constructor(e,i,n,s){super(e,n),this.format=i,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 ot;(t=>{t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Immediate=2]="Immediate",t[t.Texture=3]="Texture",t[t.Sampler=4]="Sampler",t[t.StorageTexture=5]="StorageTexture"})(ot||(ot={}));class Ci{constructor(e,i,n,s,r,o,a){this.relations=null,this.name=e,this.type=i,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 bm{constructor(e,i){this.name=e,this.type=i}}class Im{constructor(e,i,n,s){this.name=e,this.type=i,this.locationType=n,this.location=s,this.interpolation=null}}class ra{constructor(e,i,n,s){this.name=e,this.type=i,this.locationType=n,this.location=s}}class Pm{constructor(e,i,n,s){this.name=e,this.type=i,this.attributes=n,this.id=s}}class wm{constructor(e,i,n){this.name=e,this.type=i,this.attributes=n}}class Nm{constructor(e,i=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=i,this.attributes=n}}class Mm{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function km(t){var e=(32768&t)>>15,i=(31744&t)>>10,n=1023&t;return i==0?(e?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):i==31?n?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))}const Dl=new Float32Array(1),Fm=new Int32Array(Dl.buffer),ze=new Uint16Array(1);function Dm(t){Dl[0]=t;const e=Fm[0],i=e>>31&1;let n=e>>23&255,s=8388607&e;if(n===255)return ze[0]=i<<15|31744|(s!==0?512:0),ze[0];if(n===0){if(s===0)return ze[0]=i<<15,ze[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),ze[0]=i<<15|n<<10|s>>13,ze[0]):(ze[0]=i<<15,ze[0])}return n=n-127+15,n>=31?(ze[0]=i<<15|31744,ze[0]):n<=0?n<-10?(ze[0]=i<<15,ze[0]):(s=(8388608|s)>>1-n,ze[0]=i<<15|s>>13,ze[0]):(s>>=13,ze[0]=i<<15|n<<10|s,ze[0])}const br=new Uint32Array(1),Ol=new Float32Array(br.buffer,0,1);function oa(t){const e=112+(t>>6&31)<<23|(63&t)<<17;return br[0]=e,Ol[0]}
93function Om(t,e,i,n,s,r,o,a,l){const c=n*(o>>=s)*(r>>=s)+i*o+e*a;switch(l){case"r8unorm":return[pe(t,c,"8unorm",1)[0]];case"r8snorm":return[pe(t,c,"8snorm",1)[0]];case"r8uint":return[pe(t,c,"8uint",1)[0]];case"r8sint":return[pe(t,c,"8sint",1)[0]];case"rg8unorm":{const u=pe(t,c,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=pe(t,c,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=pe(t,c,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=pe(t,c,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=pe(t,c,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=pe(t,c,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=pe(t,c,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=pe(t,c,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=pe(t,c,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[pe(t,c,"16uint",1)[0]];case"r16sint":return[pe(t,c,"16sint",1)[0]];case"r16float":return[pe(t,c,"16float",1)[0]];case"rg16uint":{const u=pe(t,c,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=pe(t,c,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=pe(t,c,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=pe(t,c,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=pe(t,c,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=pe(t,c,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[pe(t,c,"32uint",1)[0]];case"r32sint":return[pe(t,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[pe(t,c,"32float",1)[0]];case"rg32uint":{const u=pe(t,c,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=pe(t,c,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=pe(t,c,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=pe(t,c,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=pe(t,c,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=pe(t,c,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(t.buffer,c,1)[0],h=(4192256&u)>>11,f=(4290772992&u)>>22;return[oa(2047&u),oa(h),(function(d){const T=112+(d>>5&31)<<23|(31&d)<<18;return br[0]=T,Ol[0]})(f),1]}}return null}function pe(t,e,i,n){const s=[0,0,0,0];for(let r=0;r<n;++r)switch(i){case"8unorm":s[r]=t[e]/255,e++;break;case"8snorm":s[r]=t[e]/255*2-1,e++;break;case"8uint":s[r]=t[e],e++;break;case"8sint":s[r]=t[e]-127,e++;break;case"16uint":s[r]=t[e]|t[e+1]<<8,e+=2;break;case"16sint":s[r]=(t[e]|t[e+1]<<8)-32768,e+=2;break;case"16float":s[r]=km(t[e]|t[e+1]<<8),e+=2;break;case"32uint":case"32sint":s[r]=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,e+=4;break;case"32float":s[r]=new Float32Array(t.buffer,e,1)[0],e+=4}return s}function _e(t,e,i,n,s){for(let r=0;r<n;++r)switch(i){case"8unorm":t[e]=255*s[r],e++;break;case"8snorm":t[e]=.5*(s[r]+1)*255,e++;break;case"8uint":t[e]=s[r],e++;break;case"8sint":t[e]=s[r]+127,e++;break;case"16uint":new Uint16Array(t.buffer,e,1)[0]=s[r],e+=2;break;case"16sint":new Int16Array(t.buffer,e,1)[0]=s[r],e+=2;break;case"16float":{const o=Dm(s[r]);new Uint16Array(t.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(t.buffer,e,1)[0]=s[r],e+=4;break;case"32sint":new Int32Array(t.buffer,e,1)[0]=s[r],e+=4;break;case"32float":new Float32Array(t.buffer,e,1)[0]=s[r],e+=4}return s}const Os={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}};let St=class Bl{constructor(){this.id=Bl._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,i){if(e){i($n.instance);for(const n of e)n instanceof Array?this.searchBlock(n,i):n.search(i);i(Yn.instance)}}constEvaluate(e,i){throw new Error("Cannot evaluate node")}constEvaluateString(e){var i,n;return(n=(i=this.constEvaluate(e))===null||i===void 0?void 0:i.toString())!==null&&n!==void 0?n:""}};St._id=0;class $n extends St{}$n.instance=new $n;let Yn=class extends St{};Yn.instance=new Yn;const Ul=new Set(["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","d
93pdxCoarse","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"]);let xe=class extends St{};class Wi extends xe{constructor(e,i,n,s,r,o){super(),this.calls=new Set,this.name=e,this.args=i,this.returnType=n,this.body=s,this.startLine=r,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const i of this.attributes)e(i);e(this);for(const i of this.args)e(i);this.searchBlock(this.body,e)}}class aa extends xe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}let Ll=class extends xe{constructor(e,i){super(),this.condition=e,this.body=i}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}};class sr extends xe{constructor(e,i){super(),this.body=e,this.loopId=i}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}let zl=class extends xe{constructor(e,i,n,s){super(),this.init=e,this.condition=i,this.increment=n,this.body=s}get astNodeType(){return"for"}search(e){var i,n,s;(i=this.init)===null||i===void 0||i.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)}},gt=class extends xe{constructor(e,i,n,s,r){super(),this.attributes=null,this.name=e,this.type=i,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"var"}search(e){var i;e(this),(i=this.value)===null||i===void 0||i.search(e)}},Ir=class extends xe{constructor(e,i,n){super(),this.attributes=null,this.name=e,this.type=i,this.value=n}get astNodeType(){return"override"}search(e){var i;(i=this.value)===null||i===void 0||i.search(e)}},Bi=class extends xe{constructor(e,i,n,s,r){super(),this.attributes=null,this.name=e,this.type=i,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"let"}search(e){var i;e(this),(i=this.value)===null||i===void 0||i.search(e)}},In=class extends xe{constructor(e,i,n,s,r){super(),this.attributes=null,this.name=e,this.type=i,this.storage=n,this.access=s,this.value=r}get astNodeType(){return"const"}constEvaluate(e,i){return this.value.constEvaluate(e,i)}search(e){var i;e(this),(i=this.value)===null||i===void 0||i.search(e)}};var oi,Mi,R,x;(t=>{t.increment="++",t.decrement="--"})(oi||(oi={})),(t=>{t.parse=function(e){const i=e;if(i==="parse")throw new Error("Invalid value for IncrementOperator");return t[i]}})(oi||(oi={}));class Hl extends xe{constructor(e,i){super(),this.operator=e,this.variable=i}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(t=>{t.assign="=",t.addAssign="+=",t.subtractAssign="-=",t.multiplyAssign="*=",t.divideAssign="/=",t.moduloAssign="%=",t.andAssign="&=",t.orAssign="|=",t.xorAssign="^=",t.shiftLeftAssign="<<=",t.shiftRightAssign=">>="})(Mi||(Mi={})),(t=>{t.parse=function(e){const i=e;if(i==="parse")throw new Error("Invalid value for AssignOperator");return i}})(Mi||(Mi={}));class Vl extends xe{constructor(e,i,n){super(),this.operator=e,this.variable=i,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}let Pr=class extends xe{constructor(e,i){super(),this.name=e,this.args=i}get astNodeType(){return"call"}isBuiltin(){return Ul.has(this.name)}search(e){for(const i of this.args)i.search(e);e(this)}};class Xl extends xe{constructor(e,i){super(),this.body=e,this.continuing=i}get astNodeType(){return"loop"}search(e){var i;this.searchBlock(this.body,e),(i=this.continuing)===null||i===void 0||i.search(e)}}let Wl=class extends xe{constructor(e,i){super(),this.condition=e,this.cases=i}get astNodeType(){return"switch"}search(e){e(this);for(const i of this.cases)i.search(e)}},$l=class extends xe{constructor(e,i,n,s){super(),this.condition=e,this.body=i,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)}},Yl=class extends xe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var i;(i=this.value)===null||i===void 0||i.search(e)}},Bm=class extends xe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}};class Um extends xe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class Kl extends xe{constructor(e,i){super(),this.severity=e,this.rule=i}get astNodeType(){return"diagnostic"}}class wr extends xe{constructor(e,i){super(),this.name=e,this.type=i}get astNodeType(){return"alias"}}class Lm extends xe{get astNodeType(){return"discard"}}class Gl extends xe{constructor(){super(...arguments),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class jl extends xe{constructor(){super(...arguments),this.loopId=-1}get astNodeType(){return"continue"}}class M extends xe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}
93get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let i=e[0];if(i.name==="f32")return i;for(let n=1;n<e.length;++n){const s=M._priority.get(i.name);M._priority.get(e[n].name)<s&&(i=e[n])}return i.name==="x32"?M.i32:i}getTypeName(){return this.name}}M.x32=new M("x32"),M.f32=new M("f32"),M.i32=new M("i32"),M.u32=new M("u32"),M.f16=new M("f16"),M.bool=new M("bool"),M.void=new M("void"),M._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class la extends M{constructor(e){super(e)}}class Et extends M{constructor(e,i,n,s){super(e),this.members=i,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let i=0;i<this.members.length;i++)if(this.members[i].name===e)return i;return-1}search(e){for(const i of this.members)e(i)}}class E extends M{constructor(e,i,n){super(e),this.format=i,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}}E.vec2f=new E("vec2",M.f32,null),E.vec3f=new E("vec3",M.f32,null),E.vec4f=new E("vec4",M.f32,null),E.vec2i=new E("vec2",M.i32,null),E.vec3i=new E("vec3",M.i32,null),E.vec4i=new E("vec4",M.i32,null),E.vec2u=new E("vec2",M.u32,null),E.vec3u=new E("vec3",M.u32,null),E.vec4u=new E("vec4",M.u32,null),E.vec2h=new E("vec2",M.f16,null),E.vec3h=new E("vec3",M.f16,null),E.vec4h=new E("vec4",M.f16,null),E.vec2b=new E("vec2",M.bool,null),E.vec3b=new E("vec3",M.bool,null),E.vec4b=new E("vec4",M.bool,null),E.mat2x2f=new E("mat2x2",M.f32,null),E.mat2x3f=new E("mat2x3",M.f32,null),E.mat2x4f=new E("mat2x4",M.f32,null),E.mat3x2f=new E("mat3x2",M.f32,null),E.mat3x3f=new E("mat3x3",M.f32,null),E.mat3x4f=new E("mat3x4",M.f32,null),E.mat4x2f=new E("mat4x2",M.f32,null),E.mat4x3f=new E("mat4x3",M.f32,null),E.mat4x4f=new E("mat4x4",M.f32,null),E.mat2x2h=new E("mat2x2",M.f16,null),E.mat2x3h=new E("mat2x3",M.f16,null),E.mat2x4h=new E("mat2x4",M.f16,null),E.mat3x2h=new E("mat3x2",M.f16,null),E.mat3x3h=new E("mat3x3",M.f16,null),E.mat3x4h=new E("mat3x4",M.f16,null),E.mat4x2h=new E("mat4x2",M.f16,null),E.mat4x3h=new E("mat4x3",M.f16,null),E.mat4x4h=new E("mat4x4",M.f16,null),E.mat2x2i=new E("mat2x2",M.i32,null),E.mat2x3i=new E("mat2x3",M.i32,null),E.mat2x4i=new E("mat2x4",M.i32,null),E.mat3x2i=new E("mat3x2",M.i32,null),E.mat3x3i=new E("mat3x3",M.i32,null),E.mat3x4i=new E("mat3x4",M.i32,null),E.mat4x2i=new E("mat4x2",M.i32,null),E.mat4x3i=new E("mat4x3",M.i32,null),E.mat4x4i=new E("mat4x4",M.i32,null),E.mat2x2u=new E("mat2x2",M.u32,null),E.mat2x3u=new E("mat2x3",M.u32,null),E.mat2x4u=new E("mat2x4",M.u32,null),E.mat3x2u=new E("mat3x2",M.u32,null),E.mat3x3u=new E("mat3x3",M.u32,null),E.mat3x4u=new E("mat3x4",M.u32,null),E.mat4x2u=new E("mat4x2",M.u32,null),E.mat4x3u=new E("mat4x3",M.u32,null),E.mat4x4u=new E("mat4x4",M.u32,null);class Pn extends M{constructor(e,i,n,s){super(e),this.storage=i,this.type=n,this.access=s}get astNodeType(){return"pointer"}}let Ui=class extends M{constructor(e,i,n,s){super(e),this.attributes=i,this.format=n,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}};class ki extends M{constructor(e,i,n){super(e),this.format=i,this.access=n}get astNodeType(){return"sampler"}}class ct extends St{constructor(){super(),this.postfix=null,this.hasParen=!1}}let Yt=class extends ct{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}};class mt extends ct{constructor(e,i){super(),this.type=e,this.args=i}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const i of this.args)i.search(e)}constEvaluate(e,i){return i&&(i[0]=this.type),e.evalExpression(this,e.context)}}let li=class wn extends ct{constructor(e,i){super(),this.cachedReturnValue=null,this.name=e,this.args=i}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Ul.has(this.name)}constEvaluate(e,i){const n=e.evalExpression(this,e.context);return i!==void 0&&this._resolveReturnType(e,i),n}_resolveReturnType(e,i){const n=e.context.getFunction(this.name);if(n!==null)return void(n.node.returnType!==null&&(i[0]=n.node.returnType));const s=wn._builtinFixedReturnType.get(this.name);if(s!==void 0)return void(i[0]=s);const r=wn._builtinSameAsArg.get(this.name);if(r!==void 0&&this.args&&this.args[r])return void this.args[r].constEvaluate(e,i);const o=wn._builtinComponentOfArg.get(this.name);if(o!==void 0&&this.args&&this.args[o]){const a=[M.f32];return this.args[o].constEvaluate(e,a),void(a[0]instanceof E&&a[0].format!==null?i[0]=a[0].format:i[0]=a[0])}}search(e){for(const i of this.args)i.search(e);e(this)}};li._builtinFixedReturnType=new Map([["all",M.bool],["any",M.bool],["arrayLength",M.u32],["dot4U8Packed",M.u32],["dot4I8Packed",M.i32],["pack4x8snorm",M.u32],["pack4x8unorm",M.u32],["pack4xI8",M.u32],["pack4xU8",M.u32],["pack4x8Clamp",M.u32],["pack4xU8Clamp",M.u32],["pack2x16snorm",M.u32],["pack2x16unorm",M.u32],["pack2x16float",M.u32],["unpack4x8snorm",E.vec4f],["unpack4x8unorm",E.vec4f],["unpack4xI8",E.vec4i],["unpack4xU8",E.vec4u],["unpack2x16snorm",E.vec2f],["unpack2x16unorm",E.vec2f],["unpack2x16float",E.vec2f],["storageBarrier",M.void],["textureBarrier",M.void],["workgroupBarrier",M.void],["atomicStore",M.void]]),li._builtinSameAsArg=new Map([["abs",0],["acos",0],["acosh",0],["asin",0],["asinh",0],["atan",0],["atanh",0],["atan2",0],["ceil",0],["clamp",0],["cos",0],["cosh",0],["countLeadingZeros",0],["countOneBits",0],["countTrailingZeros",0],["cross",0],["degrees",0],["exp",0],["exp2",0],["extractBits",0],["faceForward",0],["firstLeadingBit",0],["firstTrailingBit",0],["floor",0],["fma",0],["fract",0],["insertBits",0],["inverseSqrt",0],["ldexp",0],["log",0],["log2",0],["max",0],["min",0],["mix",0],["normalize",0],["pow",0],["quantizeToF16",0],["radians",0],["reflect",0],["refract",0],["reverseBits",0],["round",0],["saturate",0],["sign",0],["sin",0],["sinh",0],["smoothstep",2],["sqrt",0],["step",1],["tan",0],["tanh",0],["trunc",0],["dpdx",0],["dpdxCoarse",0],["dpdxFine",0],["dpdy",0],["dpdyCoarse",0],["dpdyFine",0],["fwidth",0],["fwidthCoarse",0],["fwidthFine",0],["select",0],["workgroupUniformLoad",0],["atomicLoad",0],["atomicAdd",1],["atomicSub",1],["atomicMax",1],["atomicMin",1],["atomicAnd",1],["atomicOr",1],["atomicXor",1],["atomicExchange",1],["subgroupAdd",0],["subgroupExclusiveAdd",0],["subgroupInclusiveAdd",0],["subgroupAnd",0],["subgroupBroadcast",0],["subgroupBroadcastFirst",0],["subgroupMax",0],["subgroupMin",0],["subgroupMul",0],["subgroupExclusiveMul",0],["subgroupInclusiveMul",0],["subgroupOr",0],["subgroupShuffle",0],["subgroupShuffleDown",0],["subgroupShuffleUp",0],["subgroupShuffleXor",0],["subgroupXor",0],["quadBroadcast",0],["quadSwapDiagonal",0],["quadSwapX",0],["quadSwapY",0]]),li._builtinComponentOfArg=new Map([["length",0],["distance",0],["dot",0],["determinant",0]]);let Ye=class extends ct{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,i){const n=e.evalExpression(this,e.context);if(i!==void 0&&this.postfix===null){const s=e.context.getVariable(this.name);s!==null&&s.node!==null&&s.node.type!==null&&(i[0]=s.node.type)}return n}},ql=class extends ct{constructor(e,i){super(),this.name=e,this.initializer=i}get astNodeType(){return"constExpr"}constEvaluate(e,i){const n=e.evalExpression(this.initializer,e.context);return i!==void 0&&this.initializer.constEvaluate(e,i),n!==null&&this.postfix?n.getSubData(e,this.postfix,e.context):n}search(e){this.initializer.search(e)}},Ne=class extends ct{constructor(e,i){super(),this.value=e,this.type=i}get astNodeType(){return"literalExpr"}constEvaluate(e,i){return i!==void 0&&(i[0]=this.type),this.value}get isScalar(){return this.value instanceof S}get isVector(){return this.value instanceof _||this.value instanceof se}get scalarValue(){return this.value instanceof S?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof _||this.value instanceof se?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}};class Zl extends ct{constructor(e,i){super(),this.type=e,this.value=i}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class pi extends ct{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Ql extends ct{constructor(){super()}}class Re extends Ql{constructor(e,i){super(),this.operator=e,this.right=i}get astNodeType(){return"unaryOp"}constEvaluate(e,i){const n=e.evalExpression(this,e.context);return i!==void 0&&(this.operator==="!"?i[0]=M.bool:this.right.constEvaluate(e,i)),n}search(e){this.right.search(e)}}class nt extends Ql{constructor(e,i,n){super(),this.operator=e,this.left=i,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,i){return e.name===i.name?e:e.name==="f32"||i.name==="f32"?M.f32:e.name==="u32"||i.name==="u32"?M.u32:M.i32}constEvaluate(e,i){const n=e.evalExpression(this,e.context);if(i!==void 0)switch(this.operator){case"==":case"!=":case"<":case">":case"<=":case">=":case"&&":case"||":i[0]=M.bool;break;default:{const s=[M.f32],r=[M.f32];this.left.constEvaluate(e,s),this.right.constEvaluate(e,r),i[0]=this._getPromotedType(s[0],r[0]);break}}return n}search(e){this.left.search(e),this.right.search(e)}}let Jl=class extends St{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}},Nn=class extends ct{get astNodeType(){return"default"}};class ec extends Jl{constructor(e,i){super(i),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}let tc=class extends Jl{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}};class ca extends St{constructor(e,i,n){super(),this.name=e,this.type=i,this.attributes=n}get astNodeType(){return"argument"}}class zm extends St{constructor(e,i){super(),this.condition=e,this.body=i}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}let ua=class extends St{constructor(e,i,n){super(),this.name=e,this.type=i,this.attributes=n}get astNodeType(){return"member"}};class ic extends St{constructor(e,i){super(),this.name=e,this.value=i}get astNodeType(){return"attribute"}}let Pt=class nc{constructor(e,i){this.parent=null,this.typeInfo=e,this.parent=i,this.id=nc._id++}setDataValue(e,i,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,i,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}};Pt._id=0;class ha extends Pt{constructor(e,i){super(e,i)}clone(){return this}toString(){return this.typeInfo.name}}let rr=class extends Pt{constructor(){super(new tt("void",null),null)}clone(){return this}toString(){return"void"}};rr.void=new rr;let ei=class extends Pt{constructor(e){super(new nr("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,i,n,s){this.reference.setDataValue(e,i,n,s)}getSubData(e,i,n){return i?this.reference.getSubData(e,i,n):this}toString(){return`&${this.reference.toString()}`}};class S extends Pt{constructor(e,i,n=null){super(i,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.t
93ypeInfo.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",i)}clone(){if(this.data instanceof Float32Array)return new S(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new S(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new S(new Uint32Array(this.data),this.typeInfo,null);throw new Error("ScalarData: Invalid data type")}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,i,n,s){if(n)return void console.error("SetDataValue: Scalar data does not support postfix",n);if(!(i instanceof S))return void console.error("SetDataValue: Invalid value",i);let r=i.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,i,n){return i?(console.error("getSubData: Scalar data does not support postfix",i),null):this}toString(){return`${this.value}`}}function Hm(t,e,i){const n=e.length;return n===2?i==="f32"?new _(new Float32Array(e),t.getTypeInfo("vec2f")):i==="i32"||i==="bool"?new _(new Int32Array(e),t.getTypeInfo("vec2i")):i==="u32"?new _(new Uint32Array(e),t.getTypeInfo("vec2u")):i==="f16"?new _(new Float32Array(e),t.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${i}`),null):n===3?i==="f32"?new _(new Float32Array(e),t.getTypeInfo("vec3f")):i==="i32"||i==="bool"?new _(new Int32Array(e),t.getTypeInfo("vec3i")):i==="u32"?new _(new Uint32Array(e),t.getTypeInfo("vec3u")):i==="f16"?new _(new Float32Array(e),t.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${i}`),null):n===4?i==="f32"?new _(new Float32Array(e),t.getTypeInfo("vec4f")):i==="i32"||i==="bool"?new _(new Int32Array(e),t.getTypeInfo("vec4i")):i==="u32"?new _(new Uint32Array(e),t.getTypeInfo("vec4u")):i==="f16"?new _(new Float32Array(e),t.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${i}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}let _=class Fi extends Pt{constructor(e,i,n=null){if(super(i,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 Fi(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Fi(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Fi(new Uint32Array(this.data),this.typeInfo,null);throw new Error("VectorData: Invalid data type")}setDataValue(e,i,n,s){n instanceof Yt?console.error("TODO: Set vector postfix"):i instanceof Fi?this.data=i.data:console.error("SetDataValue: Invalid value",i)}getSubData(e,i,n){if(i===null)return this;let s=e.getTypeInfo("f32");if(this.typeInfo instanceof Lt)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(;i!==null&&r!==null;){if(i instanceof pi){const o=i.index;let a=-1;if(o instanceof Ne){if(!(o.value instanceof S))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const l=e.evalExpression(o,n);if(!(l instanceof S))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 S(l,s)}if(r.data instanceof Int32Array){const l=new Int32Array(r.data.buffer,r.data.byteOffset+4*a,1);return new S(l,s)}if(r.data instanceof Uint32Array){const l=new Uint32Array(r.data.buffer,r.data.byteOffset+4*a,1);return new S(l,s)}throw new Error("GetSubData: Invalid data type")}if(!(i instanceof Yt))return console.error("GetSubData: Unknown postfix",i),null;{const o=i.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 S(c,s,this)}if(this.data instanceof Int32Array){let c=new Int32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new S(c,s,this)}if(this.data instanceof Uint32Array){let c=new Uint32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new S(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=Hm(e,a,s.name)}i=i.postfix}return r}toString(){let e=`${this.data[0]}`;for(let i=1;i<this.data.length;++i)e+=`, ${this.data[i]}`;return e}};class se extends Pt{constructor(e,i,n=null){super(i,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new se(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,i,n,s){n instanceof Yt?console.error("TODO: Set matrix postfix"):i instanceof se?this.data=i.data:console.error("SetDataValue: Invalid value",i)}getSubData(e,i,n){if(i===null)return this;const s=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof Lt)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(i instanceof pi){const r=i.index;let o=-1;if(r instanceof Ne){if(!(r.value instanceof S))return console.error(`GetDataValue: Invalid array index ${r.value}`),null;o=r.value.value}else{const c=e.evalExpression(r,n);if(!(c instanceof S))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 _(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 _(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 _(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return i.postfix?l.getSubData(e,i.postfix,n):l}return console.error("GetDataValue: Invalid postfix",i),null}toString(){let e=`${this.data[0]}`;for(let i=1;i<this.data.length;++i)e+=`, ${this.data[i]}`;return e}}class Te extends Pt{constructor(e,i,n=0,s=null){super(i,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 Te(e.buffer,this.typeInfo,0,null)}setDataValue(e,i,n,s){if(i===null)return void console.log("setDataValue: NULL data.");let r=this.offset,o=this.typeInfo;for(;n;){if(n instanceof pi)if(o instanceof Ut){const a=n.index;if(a instanceof Ne){if(!(a.value instanceof S))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 S))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 Yt))return void console.error("SetDataValue: Unknown postfix type",n);{const a=n.value;if(o instanceof Ot){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 tt){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(!(i instanceof S))return void console.error("SetDataValue: Invalid value",i);const u=i.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,i,o,r,s)}setData(e,i,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(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1]):(a[0]=i[0],a[1]=i[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,s,3);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2]):(a[0]=i[0],a[1]=i[1],a[2]=i[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,s,4);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,s,2);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1]):(a[0]=i[0],a[1]=i[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,s,3);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2]):(a[0]=i[0],a[1]=i[1],a[2]=i[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,s,4);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,s,2);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1]):(a[0]=i[0],a[1]=i[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,s,3);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2]):(a[0]=i[0],a[1]=i[1],a[2]=i[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,s,4);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,s,2);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1]):(a[0]=i[0],a[1]=i[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,s,3);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2]):(a[0]=i[0],a[1]=i[1],a[2]=i[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,s,4);return void(i instanceof _?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,s,4);
93return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,s,6);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,s,8);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,s,6);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,s,9);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7],a[8]=i.data[8]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7],a[8]=i[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,s,12);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7],a[8]=i.data[8],a[9]=i.data[9],a[10]=i.data[10],a[11]=i.data[11]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7],a[8]=i[8],a[9]=i[9],a[10]=i[10],a[11]=i[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,s,8);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,s,12);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7],a[8]=i.data[8],a[9]=i.data[9],a[10]=i.data[10],a[11]=i.data[11]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7],a[8]=i[8],a[9]=i[9],a[10]=i[10],a[11]=i[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,s,16);return void(i instanceof se?(a[0]=i.data[0],a[1]=i.data[1],a[2]=i.data[2],a[3]=i.data[3],a[4]=i.data[4],a[5]=i.data[5],a[6]=i.data[6],a[7]=i.data[7],a[8]=i.data[8],a[9]=i.data[9],a[10]=i.data[10],a[11]=i.data[11],a[12]=i.data[12],a[13]=i.data[13],a[14]=i.data[14],a[15]=i.data[15]):(a[0]=i[0],a[1]=i[1],a[2]=i[2],a[3]=i[3],a[4]=i[4],a[5]=i[5],a[6]=i[6],a[7]=i[7],a[8]=i[8],a[9]=i[9],a[10]=i[10],a[11]=i[11],a[12]=i[12],a[13]=i[13],a[14]=i[14],a[15]=i[15]))}if(i instanceof Te){if(n===i.typeInfo)return void new Uint8Array(this.buffer,s,i.buffer.byteLength).set(new Uint8Array(i.buffer));console.error("SetDataValue: Type mismatch",o,i.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else i instanceof S&&(new Int32Array(this.buffer,s,1)[0]=i.value);else i instanceof S&&(new Uint32Array(this.buffer,s,1)[0]=i.value);else i instanceof S&&(new Int32Array(this.buffer,s,1)[0]=i.value);else i instanceof S&&(new Float32Array(this.buffer,s,1)[0]=i.value)}getSubData(e,i,n){var s,r,o;if(i===null)return this;let a=this.offset,l=this.typeInfo;for(;i;){if(i instanceof pi){const u=i.index,h=u instanceof ct?e.evalExpression(u,n):u;let f=0;if(h instanceof S?f=h.value:typeof h=="number"?f=h:console.error("GetDataValue: Invalid index type",u),l instanceof Ut)a+=f*l.stride,l=l.format;else{const d=l.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*f,l=e.getTypeInfo("vec4f")):d==="mat4x3"||d==="mat4x3f"||d==="mat4x3h"?(a+=12*f,l=e.getTypeInfo("vec3f")):d==="mat4x2"||d==="mat4x2f"||d==="mat4x2h"?(a+=8*f,l=e.getTypeInfo("vec2f")):d==="mat3x4"||d==="mat3x4f"||d==="mat3x4h"?(a+=12*f,l=e.getTypeInfo("vec4f")):d==="mat3x3"||d==="mat3x3f"||d==="mat3x3h"?(a+=9*f,l=e.getTypeInfo("vec3f")):d==="mat3x2"||d==="mat3x2f"||d==="mat3x2h"?(a+=6*f,l=e.getTypeInfo("vec2f")):d==="mat2x4"||d==="mat2x4f"||d==="mat2x4h"?(a+=8*f,l=e.getTypeInfo("vec4f")):d==="mat2x3"||d==="mat2x3f"||d==="mat2x3h"?(a+=6*f,l=e.getTypeInfo("vec3f")):d==="mat2x2"||d==="mat2x2f"||d==="mat2x2h"?(a+=4*f,l=e.getTypeInfo("vec2f")):d==="vec2f"||d==="vec3f"||d==="vec4f"?(a+=4*f,l=e.getTypeInfo("f32")):d==="vec2h"||d==="vec3h"||d==="vec4h"?(a+=2*f,l=e.getTypeInfo("f16")):d==="vec2b"||d==="vec3b"||d==="vec4b"?(a+=1*f,l=e.getTypeInfo("bool")):d==="vec2i"||d==="vec3i"||d==="vec4i"?(a+=4*f,l=e.getTypeInfo("i32")):d==="vec2u"||d==="vec3u"||d==="vec4u"?(a+=4*f,l=e.getTypeInfo("u32")):console.error(`getDataValue: Type ${l.getTypeName()} is not an array`)}}else{if(!(i instanceof Yt))return console.error("GetDataValue: Unknown postfix type",i),null;{const u=i.value;if(l instanceof Ot){let h=!1;for(const f of l.members)if(f.name===u){a+=f.offset,l=f.type,h=!0;break}if(!h)return console.error(`GetDataValue: Member ${u} not found`),null}else if(l instanceof tt){const h=l.getTypeName();if(h==="vec2f"||h==="vec3f"||h==="vec4f"||h==="vec2i"||h==="vec3i"||h==="vec4i"||h==="vec2u"||h==="vec3u"||h==="vec4u"||h==="vec2b"||h==="vec3b"||h==="vec4b"||h==="vec2h"||h==="vec3h"||h==="vec4h"||h==="vec2"||h==="vec3"||h==="vec4"){if(u.length>0&&u.length<5){let f="f";const d=[];for(let T=0;T<u.length;++T){const C=u[T].toLowerCase();let w=0;if(C==="x"||C==="r")w=0;else if(C==="y"||C==="g")w=1;else if(C==="z"||C==="b")w=2;else{if(C!=="w"&&C!=="a")return console.error(`Unknown member ${u}`),null;w=3}if(u.length===1){if(h.endsWith("f"))return this.buffer.byteLength<a+4*w+4?(console.log("Insufficient buffer data"),null):new S(new Float32Array(this.buffer,a+4*w,1),e.getTypeInfo("f32"),this);if(h.endsWith("h"))return new S(new Float32Array(this.buffer,a+4*w,1),e.getTypeInfo("f16"),this);if(h.endsWith("i"))return new S(new Int32Array(this.buffer,a+4*w,1),e.getTypeInfo("i32"),this);if(h.endsWith("b"))return new S(new Int32Array(this.buffer,a+4*w,1),e.getTypeInfo("bool"),this);if(h.endsWith("u"))return new S(new Uint32Array(this.buffer,a+4*w,1),e.getTypeInfo("i32"),this)}if(h==="vec2f")d.push(new Float32Array(this.buffer,a,2)[w]);else if(h==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const A=new Float32Array(this.buffer,a,3);d.push(A[w])}else if(h==="vec4f")d.push(new Float32Array(this.buffer,a,4)[w]);else if(h==="vec2i")f="i",d.push(new Int32Array(this.buffer,a,2)[w]);else if(h==="vec3i")f="i",d.push(new Int32Array(this.buffer,a,3)[w]);else if(h==="vec4i")f="i",d.push(new Int32Array(this.buffer,a,4)[w]);else if(h==="vec2u"){f="u";const A=new Uint32Array(this.buffer,a,2);d.push(A[w])}else h==="vec3u"?(f="u",d.push(new Uint32Array(this.buffer,a,3)[w])):h==="vec4u"&&(f="u",d.push(new Uint32Array(this.buffer,a,4)[w]))}return d.length===2?l=e.getTypeInfo(`vec2${f}`):d.length===3?l=e.getTypeInfo(`vec3${f}`):d.length===4?l=e.getTypeInfo(`vec4${f}`):console.error(`GetDataValue: Invalid vector length ${d.length}
93`),new _(d,l,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${h} is not a struct`),null}}}i=i.postfix}const c=l.getTypeName();return c==="f32"?new S(new Float32Array(this.buffer,a,1),l,this):c==="i32"?new S(new Int32Array(this.buffer,a,1),l,this):c==="u32"?new S(new Uint32Array(this.buffer,a,1),l,this):c==="vec2f"?new _(new Float32Array(this.buffer,a,2),l,this):c==="vec3f"?new _(new Float32Array(this.buffer,a,3),l,this):c==="vec4f"?new _(new Float32Array(this.buffer,a,4),l,this):c==="vec2i"?new _(new Int32Array(this.buffer,a,2),l,this):c==="vec3i"?new _(new Int32Array(this.buffer,a,3),l,this):c==="vec4i"?new _(new Int32Array(this.buffer,a,4),l,this):c==="vec2u"?new _(new Uint32Array(this.buffer,a,2),l,this):c==="vec3u"?new _(new Uint32Array(this.buffer,a,3),l,this):c==="vec4u"?new _(new Uint32Array(this.buffer,a,4),l,this):l instanceof Lt&&l.name==="atomic"?((s=l.format)===null||s===void 0?void 0:s.name)==="u32"?new S(new Uint32Array(this.buffer,a,1)[0],l.format,this):((r=l.format)===null||r===void 0?void 0:r.name)==="i32"?new S(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 Te(this.buffer,l,a,this)}toArray(){const e=this.typeInfo.getTypeName();return e==="f32"||e==="f16"?new Float32Array(this.buffer,this.offset,1):e==="i32"||e==="atomic<i32>"||e==="x32"?new Int32Array(this.buffer,this.offset,1):e==="u32"||e==="atomic<u32>"?new Uint32Array(this.buffer,this.offset,1):e==="bool"?new Int32Array(this.buffer,this.offset,1):e==="vec2f"||e==="vec2h"?new Float32Array(this.buffer,this.offset,2):e==="vec3f"||e==="vec3h"?new Float32Array(this.buffer,this.offset,3):e==="vec4f"||e==="vec4h"?new Float32Array(this.buffer,this.offset,4):e==="vec2i"?new Int32Array(this.buffer,this.offset,2):e==="vec3i"?new Int32Array(this.buffer,this.offset,3):e==="vec4i"?new Int32Array(this.buffer,this.offset,4):e==="vec2u"?new Uint32Array(this.buffer,this.offset,2):e==="vec3u"?new Uint32Array(this.buffer,this.offset,3):e==="vec4u"?new Uint32Array(this.buffer,this.offset,4):e==="vec2b"?new Uint32Array(this.buffer,this.offset,2):e==="vec3b"?new Uint32Array(this.buffer,this.offset,3):e==="vec4b"?new Uint32Array(this.buffer,this.offset,4):e==="mat2x2f"||e==="mat2x2h"?new Float32Array(this.buffer,this.offset,4):e==="mat2x3f"||e==="mat2x3h"?new Float32Array(this.buffer,this.offset,6):e==="mat2x4f"||e==="mat2x4h"?new Float32Array(this.buffer,this.offset,8):e==="mat3x2f"||e==="mat3x2h"?new Float32Array(this.buffer,this.offset,6):e==="mat3x3f"||e==="mat3x3h"?new Float32Array(this.buffer,this.offset,9):e==="mat3x4f"||e==="mat3x4h"?new Float32Array(this.buffer,this.offset,12):e==="mat4x2f"||e==="mat4x2h"?new Float32Array(this.buffer,this.offset,8):e==="mat4x3f"||e==="mat4x3h"?new Float32Array(this.buffer,this.offset,12):e==="mat4x4f"||e==="mat4x4h"?new Float32Array(this.buffer,this.offset,16):null}toString(){let e="";
93if(this.typeInfo instanceof Ut)if(this.typeInfo.format.name==="f32"){const i=new Float32Array(this.buffer,this.offset);e=`[${i[0]}`;for(let n=1;n<i.length;++n)e+=`, ${i[n]}`}else if(this.typeInfo.format.name==="i32"){const i=new Int32Array(this.buffer,this.offset);e=`[${i[0]}`;for(let n=1;n<i.length;++n)e+=`, ${i[n]}`}else if(this.typeInfo.format.name==="u32"){const i=new Uint32Array(this.buffer,this.offset);e=`[${i[0]}`;for(let n=1;n<i.length;++n)e+=`, ${i[n]}`}else if(this.typeInfo.format.name==="vec2f"){const i=new Float32Array(this.buffer,this.offset);e=`[${i[0]}, ${i[1]}]`;for(let n=1;n<i.length/2;++n)e+=`, [${i[2*n]}, ${i[2*n+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const i=new Float32Array(this.buffer,this.offset);e=`[${i[0]}, ${i[1]}, ${i[2]}]`;for(let n=4;n<i.length;n+=4)e+=`, [${i[n]}, ${i[n+1]}, ${i[n+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const i=new Float32Array(this.buffer,this.offset);e=`[${i[0]}, ${i[1]}, ${i[2]}, ${i[3]}]`;for(let n=4;n<i.length;n+=4)e+=`, [${i[n]}, ${i[n+1]}, ${i[n+2]}, ${i[n+3]}]`}else e="[...]";else this.typeInfo instanceof Ot?e+="{...}":e="[...]";return e}}class At extends Pt{constructor(e,i,n,s){super(i,null),this.data=e,this.descriptor=n,this.view=s}clone(){return new At(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,i;const n=this.descriptor.size;return n instanceof Array&&n.length>0?(e=n[0])!==null&&e!==void 0?e:0:n instanceof Object&&(i=n.width)!==null&&i!==void 0?i:0}get height(){var e,i;const n=this.descriptor.size;return n instanceof Array&&n.length>1?(e=n[1])!==null&&e!==void 0?e:0:n instanceof Object&&(i=n.height)!==null&&i!==void 0?i:0}get depthOrArrayLayers(){var e,i;const n=this.descriptor.size;return n instanceof Array&&n.length>2?(e=n[2])!==null&&e!==void 0?e:0:n instanceof Object&&(i=n.depthOrArrayLayers)!==null&&i!==void 0?i: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 i=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n<i.length;++n)i[n]=Math.max(1,i[n]>>e);return i}get texelByteSize(){const e=this.format,i=Os[e];return i?i.isDepthStencil?4:i.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,i=Os[e];return!!i&&i.isDepthStencil}getGpuSize(){const e=this.format,i=Os[e],n=this.width;if(!e||n<=0||!i)return-1;const s=this.height,r=this.depthOrArrayLayers,o=this.dimension;return n/i.blockWidth*(o==="1d"?1:s/i.blockHeight)*i.bytesPerBlock*r}getPixel(e,i,n=0,s=0){const r=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[s];return Om(new Uint8Array(l),e,i,n,s,a,o,r,this.format)}setPixel(e,i,n,s,r){const o=this.texelByteSize,a=this.bytesPerRow,l=this.height,c=this.data[s];(function(u,h,f,d,T,C,w,A,F,b){const g=d*(w>>=T)*(C>>=T)+f*w+h*A;switch(F){case"r8unorm":return void _e(u,g,"8unorm",1,b);case"r8snorm":return void _e(u,g,"8snorm",1,b);case"r8uint":return void _e(u,g,"8uint",1,b);case"r8sint":return void _e(u,g,"8sint",1,b);case"rg8unorm":return void _e(u,g,"8unorm",2,b);case"rg8snorm":return void _e(u,g,"8snorm",2,b);case"rg8uint":return void _e(u,g,"8uint",2,b);case"rg8sint":return void _e(u,g,"8sint",2,b);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void _e(u,g,"8unorm",4,b);case"rgba8snorm":return void _e(u,g,"8snorm",4,b);case"rgba8uint":return void _e(u,g,"8uint",4,b);case"rgba8sint":return void _e(u,g,"8sint",4,b);case"r16uint":return void _e(u,g,"16uint",1,b);case"r16sint":return void _e(u,g,"16sint",1,b);case"r16float":return void _e(u,g,"16float",1,b);case"rg16uint":return void _e(u,g,"16uint",2,b);case"rg16sint":return void _e(u,g,"16sint",2,b);case"rg16float":return void _e(u,g,"16float",2,b);case"rgba16uint":return void _e(u,g,"16uint",4,b);case"rgba16sint":return void _e(u,g,"16sint",4,b);case"rgba16float":return void _e(u,g,"16float",4,b);case"r32uint":return void _e(u,g,"32uint",1,b);case"r32sint":return void _e(u,g,"32sint",1,b);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void _e(u,g,"32float",1,b);case"rg32uint":return void _e(u,g,"32uint",2,b);case"rg32sint":return void _e(u,g,"32sint",2,b);case"rg32float":return void _e(u,g,"32float",2,b);case"rgba32uint":return void _e(u,g,"32uint",4,b);case"rgba32sint":return void _e(u,g,"32sint",4,b);case"rgba32float":return void _e(u,g,"32float",4,b);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(c),e,i,n,s,l,a,o,this.format,r)}}(t=>{t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(x||(x={}));class y{constructor(e,i,n){this.name=e,this.type=i,this.rule=n}toString(){return this.name}}class p{}R=p,p.none=new y("",x.reserved,""),p.eof=new y("EOF",x.token,""),p.reserved={asm:new y("asm",x.reserved,"asm"),bf16:new y("bf16",x.reserved,"bf16"),do:new y("do",x.reserved,"do"),enum:new y("enum",x.reserved,"enum"),f16:new y("f16",x.reserved,"f16"),f64:new y("f64",x.reserved,"f64"),handle:new y("handle",x.reserved,"handle"),i8:new y("i8",x.reserved,"i8"),i16:new y("i16",x.reserved,"i16"),i64:new y("i64",x.reserved,"i64"),mat:new y("mat",x.reserved,"mat"),premerge:new y("premerge",x.reserved,"premerge"),regardless:new y("regardless",x.reserved,"regardless"),typedef:new y("typedef",x.reserved,"typedef"),u8:new y("u8",x.reserved,"u8"),u16:new y("u16",x.reserved,"u16"),u64:new y("u64",x.reserved,"u64"),unless:new y("unless",x.reserved,"unless"),using:new y("using",x.reserved,"using"),vec:new y("vec",x.reserved,"vec"),void:new y("void",x.reserved,"void")},p.keywords={array:new y("array",x.keyword,"array"),atomic:new y("atomic",x.keyword,"atomic"),bool:new y("bool",x.keyword,"bool"),f32:new y("f32",x.keyword,"f32"),i32:new y("i32",x.keyword,"i32"),mat2x2:new y("mat2x2",x.keyword,"mat2x2"),mat2x3:new y("mat2x3",x.keyword,"mat2x3"),mat2x4:new y("mat2x4",x.keyword,"mat2x4"),mat3x2:new y("mat3x2",x.keyword,"mat3x2"),mat3x3:new y("mat3x3",x.keyword,"mat3x3"),mat3x4:ne
vendor: 11,283 bytes, line 93
93w y("mat3x4",x.keyword,"mat3x4"),mat4x2:new y("mat4x2",x.keyword,"mat4x2"),mat4x3:new y("mat4x3",x.keyword,"mat4x3"),mat4x4:new y("mat4x4",x.keyword,"mat4x4"),ptr:new y("ptr",x.keyword,"ptr"),sampler:new y("sampler",x.keyword,"sampler"),sampler_comparison:new y("sampler_comparison",x.keyword,"sampler_comparison"),struct:new y("struct",x.keyword,"struct"),texture_1d:new y("texture_1d",x.keyword,"texture_1d"),texture_2d:new y("texture_2d",x.keyword,"texture_2d"),texture_2d_array:new y("texture_2d_array",x.keyword,"texture_2d_array"),texture_3d:new y("texture_3d",x.keyword,"texture_3d"),texture_cube:new y("texture_cube",x.keyword,"texture_cube"),texture_cube_array:new y("texture_cube_array",x.keyword,"texture_cube_array"),texture_multisampled_2d:new y("texture_multisampled_2d",x.keyword,"texture_multisampled_2d"),texture_storage_1d:new y("texture_storage_1d",x.keyword,"texture_storage_1d"),texture_storage_2d:new y("texture_storage_2d",x.keyword,"texture_storage_2d"),texture_storage_2d_array:new y("texture_storage_2d_array",x.keyword,"texture_storage_2d_array"),texture_storage_3d:new y("texture_storage_3d",x.keyword,"texture_storage_3d"),texture_depth_2d:new y("texture_depth_2d",x.keyword,"texture_depth_2d"),texture_depth_2d_array:new y("texture_depth_2d_array",x.keyword,"texture_depth_2d_array"),texture_depth_cube:new y("texture_depth_cube",x.keyword,"texture_depth_cube"),texture_depth_cube_array:new y("texture_depth_cube_array",x.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new y("texture_depth_multisampled_2d",x.keyword,"texture_depth_multisampled_2d"),texture_external:new y("texture_external",x.keyword,"texture_external"),u32:new y("u32",x.keyword,"u32"),vec2:new y("vec2",x.keyword,"vec2"),vec3:new y("vec3",x.keyword,"vec3"),vec4:new y("vec4",x.keyword,"vec4"),bitcast:new y("bitcast",x.keyword,"bitcast"),block:new y("block",x.keyword,"block"),break:new y("break",x.keyword,"break"),case:new y("case",x.keyword,"case"),continue:new y("continue",x.keyword,"continue"),continuing:new y("continuing",x.keyword,"continuing"),default:new y("default",x.keyword,"default"),diagnostic:new y("diagnostic",x.keyword,"diagnostic"),discard:new y("discard",x.keyword,"discard"),else:new y("else",x.keyword,"else"),enable:new y("enable",x.keyword,"enable"),fallthrough:new y("fallthrough",x.keyword,"fallthrough"),false:new y("false",x.keyword,"false"),fn:new y("fn",x.keyword,"fn"),for:new y("for",x.keyword,"for"),function:new y("function",x.keyword,"function"),if:new y("if",x.keyword,"if"),let:new y("let",x.keyword,"let"),const:new y("const",x.keyword,"const"),loop:new y("loop",x.keyword,"loop"),while:new y("while",x.keyword,"while"),private:new y("private",x.keyword,"private"),read:new y("read",x.keyword,"read"),read_write:new y("read_write",x.keyword,"read_write"),return:new y("return",x.keyword,"return"),requires:new y("requires",x.keyword,"requires"),storage:new y("storage",x.keyword,"storage"),immediate:new y("immediate",x.keyword,"immediate"),switch:new y("switch",x.keyword,"switch"),true:new y("true",x.keyword,"true"),alias:new y("alias",x.keyword,"alias"),type:new y("type",x.keyword,"type"),uniform:new y("uniform",x.keyword,"uniform"),var:new y("var",x.keyword,"var"),override:new y("override",x.keyword,"override"),workgroup:new y("workgroup",x.keyword,"workgroup"),write:new y("write",x.keyword,"write"),r8unorm:new y("r8unorm",x.keyword,"r8unorm"),r8snorm:new y("r8snorm",x.keyword,"r8snorm"),r8uint:new y("r8uint",x.keyword,"r8uint"),r8sint:new y("r8sint",x.keyword,"r8sint"),r16uint:new y("r16uint",x.keyword,"r16uint"),r16sint:new y("r16sint",x.keyword,"r16sint"),r16float:new y("r16float",x.keyword,"r16float"),rg8unorm:new y("rg8unorm",x.keyword,"rg8unorm"),rg8snorm:new y("rg8snorm",x.keyword,"rg8snorm"),rg8uint:new y("rg8uint",x.keyword,"rg8uint"),rg8sint:new y("rg8sint",x.keyword,"rg8sint"),r32uint:new y("r32uint",x.keyword,"r32uint"),r32sint:new y("r32sint",x.keyword,"r32sint"),r32float:new y("r32float",x.keyword,"r32float"),rg16uint:new y("rg16uint",x.keyword,"rg16uint"),rg16sint:new y("rg16sint",x.keyword,"rg16sint"),rg16float:new y("rg16float",x.keyword,"rg16float"),rgba8unorm:new y("rgba8unorm",x.keyword,"rgba8unorm"),rgba8unorm_srgb:new y("rgba8unorm_srgb",x.keyword,"rgba8unorm_srgb"),rgba8snorm:new y("rgba8snorm",x.keyword,"rgba8snorm"),rgba8uint:new y("rgba8uint",x.keyword,"rgba8uint"),rgba8sint:new y("rgba8sint",x.keyword,"rgba8sint"),bgra8unorm:new y("bgra8unorm",x.keyword,"bgra8unorm"),bgra8unorm_srgb:new y("bgra8unorm_srgb",x.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new y("rgb10a2unorm",x.keyword,"rgb10a2unorm"),rg11b10float:new y("rg11b10float",x.keyword,"rg11b10float"),rg32uint:new y("rg32uint",x.keyword,"rg32uint"),rg32sint:new y("rg32sint",x.keyword,"rg32sint"),rg32float:new y("rg32float",x.keyword,"rg32float"),rgba16uint:new y("rgba16uint",x.keyword,"rgba16uint"),rgba16sint:new y("rgba16sint",x.keyword,"rgba16sint"),rgba16float:new y("rgba16float",x.keyword,"rgba16float"),rgba32uint:new y("rgba32uint",x.keyword,"rgba32uint"),rgba32sint:new y("rgba32sint",x.keyword,"rgba32sint"),rgba32float:new y("rgba32float",x.keyword,"rgba32float"),static_assert:new y("static_assert",x.keyword,"static_assert"),const_assert:new y("const_assert",x.keyword,"const_assert")},p.tokens={decimal_float_literal:new y("decimal_float_literal",x.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 y("hex_float_literal",x.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 y("int_literal",x.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new y("uint_literal",x.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new y("name",x.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new y("ident",x.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new y("and",x.token,"&"),and_and:new y("and_and",x.token,"&&"),arrow:new y("arrow ",x.token,"->"),attr:new y("attr",x.token,"@"),forward_slash:new y("forward_slash",x.token,"/"),bang:new y("bang",x.token,"!"),bracket_left:new y("bracket_left",x.token,"["),bracket_right:new y("bracket_right",x.token,"]"),brace_left:new y("brace_left",x.token,"{"),brace_right:new y("brace_right",x.token,"}"),colon:new y("colon",x.token,":"),comma:new y("comma",x.token,","),equal:new y("equal",x.token,"="),equal_equal:new y("equal_equal",x.token,"=="),not_equal:new y("not_equal",x.token,"!="),greater_than:new y("greater_than",x.token,">"),greater_than_equal:new y("greater_than_equal",x.token,">="),shift_right:new y("shift_right",x.token,">>"),less_than:new y("less_than",x.token,"<"),less_than_equal:new y("less_than_equal",x.token,"<="),shift_left:new y("shift_left",x.token,"<<"),modulo:new y("modulo",x.token,"%"),minus:new y("minus",x.token,"-"),minus_minus:new y("minus_minus",x.token,"--"),period:new y("period",x.token,"."),plus:new y("plus",x.token,"+"),plus_plus:new y("plus_plus",x.token,"++"),or:new y("or",x.token,"|"),or_or:new y("or_or",x.token,"||"),paren_left:new y("paren_left",x.token,"("),paren_right:new y("paren_right",x.token,")"),semicolon:new y("semicolon",x.token,";"),star:new y("star",x.token,"*"),tilde:new y("tilde",x.token,"~"),underscore:new y("underscore",x.token,"_"),xor:new y("xor",x.token,"^"),plus_equal:new y("plus_equal",x.token,"+="),minus_equal:new y("minus_equal",x.token,"-="),times_equal:new y("times_equal",x.token,"*="),division_equal:new y("division_equal",x.token,"/="),modulo_equal:new y("modulo_equal",x.token,"%="),and_equal:new y("and_equal",x.token,"&="),or_equal:new y("or_equal",x.token,"|="),xor_equal:new y("xor_equal",x.token,"^="),shift_right_equal:new y("shift_right_equal",x.token,">>="),shift_left_equal:new y("shift_left_equal",x.token,"<<=")},p.simpleTokens={"@":R.tokens.attr,"{":R.tokens.brace_left,"}":R.tokens.brace_right,":":R.tokens.colon,",":R.tokens.comma,"(":R.tokens.paren_left,")":R.tokens.paren_right,";":R.tokens.semicolon},p.literalTokens={"&":R.tokens.and,"&&":R.tokens.and_and,"->":R.tokens.arrow,"/":R.tokens.forward_slash,"!":R.tokens.bang,"[":R.tokens.bracket_left,"]":R.tokens.bracket_right,"=":R.tokens.equal,"==":R.tokens.equal_equal,"!=":R.tokens.not_equal,">":R.tokens.greater_than,">=":R.tokens.greater_than_equal,">>":R.tokens.shift_right,"<":R.tokens.less_than,"<=":R.tokens.less_than_equal,"<<":R.tokens.shift_left,"%":R.tokens.modulo,"-":R.tokens.minus,"--":R.tokens.minus_minus,".":R.tokens.period,"+":R.tokens.plus,"++":R.tokens.plus_plus,"|":R.tokens.or,"||":R.tokens.or_or,"*":R.tokens.star,"~":R.tokens.tilde,_:R.tokens.underscore,"^":R.tokens.xor,"+=":R.tokens.plus_equal,"-=":R.tokens.minus_equal,"*=":R.tokens.times_equal,"/=":R.tokens.division_equal,"%=":R.tokens.modulo_equal,"&=":R.tokens.and_equal,"|=":R.tokens.or_equal,"^=":R.tokens.xor_equal,">>=":R.tokens.shift_right_equal,"<<=":R.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:R.tokens.decimal_float_literal,hex_float_literal:R.tokens.hex_float_literal,int_literal:R.tokens.int_literal,uint_literal:R.tokens.uint_literal,ident:R.tokens.ident},p.storage_class=[R.keywords.function,R.keywords.private,R.keywords.workgroup,R.keywords.uniform,R.keywords.storage,R.keywords.immediate],p.access_mode=[R.keywords.read,R.keywords.write,R.keywords.read_write],p.sampler_type=[R.keywords.sampler,R.keywords.sampler_comparison],p.sampled_texture_type=[R.keywords.texture_1d,R.keywords.texture_2d,R.keywords.texture_2d_array,R.keywords.texture_3d,R.keywords.texture_cube,R.keywords.texture_cube_array],p.multisampled_texture_type=[R.keywords.texture_multisampled_2d],p.storage_texture_type=[R.keywords.texture_storage_1d,R.keywords.texture_storage_2d,R.keywords.texture_storage_2d_array,R.keywords.texture_storage_3d],p.depth_texture_type=[R.keywords.texture_depth_2d,R.keywords.texture_depth_2d_array,R.keywords.texture_depth_cube,R.keywords.texture_depth_cube_array,R.keywords.texture_depth_multisampled_2d],p.texture_external_type=[R.keywords.texture_external],p.any_texture_type=[...R.sampled_texture_type,...R.multisampled_texture_type,...R.storage_texture_type,...R.depth_texture_type,...R.texture_external_type],p.texel_format=[R.keywords.r8unorm,R.keywords.r8snorm,R.keywords.r8uint,R.keywords.r8sint,R.keywords.r16uint,R.keywords.r16sint,R.keywords.r16float,R.keywords.rg8unorm,R.keywords.rg8snorm,R.keywords.rg8uint,R.keywords.rg8sint,R.keywords.r32uint,R.keywords.r32sint,R.keywords.r32float,R.keywords.rg16uint,R.keywords.rg16sint,R.keywords.rg16float,R.keywords.rgba8unorm,R.keywords.rgba8unorm_srgb,R.keywords.rgba8snorm,R.keywords.rgba8uint,R.keywords.rgba8sint,R.keywords.bgra8unorm,R.keywords.bgra8unorm_srgb,R.keywords.rgb10a2unorm,R.keywords.rg11b10float,R.keywords.rg32uint,R.keywords.rg32sint,R.keywords.rg32float,R.keywords.rgba16uint,R.keywords.rgba16sint,R.keywords.rgba16float,R.keywords.rgba32uint,R.keywords.rgba32sint,R.keywords.rgba32float],p.const_literal=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.keywords.true,R.keywords.false],p.literal_or_ident=[R.tokens.ident,R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.tokens.name],p.element_c
93ount_expression=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.ident],p.template_types=[R.keywords.vec2,R.keywords.vec3,R.keywords.vec4,R.keywords.mat2x2,R.keywords.mat2x3,R.keywords.mat2x4,R.keywords.mat3x2,R.keywords.mat3x3,R.keywords.mat3x4,R.keywords.mat4x2,R.keywords.mat4x3,R.keywords.mat4x4,R.keywords.atomic,R.keywords.bitcast,...R.any_texture_type],p.attribute_name=[R.tokens.ident,R.keywords.block,R.keywords.diagnostic],p.assignment_operators=[R.tokens.equal,R.tokens.plus_equal,R.tokens.minus_equal,R.tokens.times_equal,R.tokens.division_equal,R.tokens.modulo_equal,R.tokens.and_equal,R.tokens.or_equal,R.tokens.xor_equal,R.tokens.shift_right_equal,R.tokens.shift_left_equal],p.increment_operators=[R.tokens.plus_plus,R.tokens.minus_minus];class fa{constructor(e,i,n,s,r){this.type=e,this.lexeme=i,this.line=n,this.start=s,this.end=r}toString(){return this.lexeme}isTemplateType(){return p.template_types.includes(this.type)}isArrayType(){return this.type===p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}let sc=class rc{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 fa(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==` 94`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=` 95`;){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==` 96`)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 i=p.simpleTokens[e];if(i)return this._addToken(i),!0;let n=p.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=p.keywords[e];if(o)return this._addToken(o),!0}if(s||r)return this._addToken(p.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(p.tokens.minus_equal),!0;if(a=="-")return this._current++,e+=a,this._addToken(p.tokens.minus_minus),!0;const l=this._tokens.length-1;if((p.literal_or_ident.includes(this._tokens[l].type)||this._tokens[l].type==p.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&&!p.assignment_operators.includes(this._tokens[c].type);++u,--c)if(this._tokens[c].type===p.tokens.less_than){c>0&&this._tokens[c-1].isArrayOrTemplateType()&&(l=!0);break}if(l)return this._addToken(o),!0}if(o===p.none){let l=e,c=0;const u=2;for(let h=0;h<u;++h)if(l+=this._peekAhead(h),o=this._findType(l),o!==p.none){c=h;break}if(o===p.none)return n!==p.none&&(this._current--,this._addToken(n),!0);e=l,this._current+=c+1}if(n=o,this._isAtEnd())break;e+=this._advance()}return n!==p.none&&(this._addToken(n),!0)}_findType(e){for(const n in p.regexTokens){const s=p.regexTokens[n];if(this._match(e,s.rule))return s}return p.literalTokens[e]||p.none}_match(e,i){const n=i.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!=="_"&&!rc._operators.has(e)}_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){const i=this._source[this._current];return this._current+=e+1,i??"\0"}_peekAhead(e=0){return this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const i=this._source.substring(this._start,this._current);this._tokens.push(new fa(e,i,this._line,this._start,this._current))}};function X(t){return Array.isArray(t)||t?.buffer instanceof ArrayBuffer}sc._operators=new Set([".","(",")","[","]","{","}",",",";",":","=","!","<",">","+","-","*","/","%","&","|","^","~","@","#","?","'","`",'"',"\\",` 97`,"\r"," ","\0"]);const Kn=new Float32Array(1),Vm=new Uint32Array(Kn.buffer),Xm=new Uint32Array(Kn.buffer),Gn=new Int32Array(1),Wm=new Float32Array(Gn.buffer),$m=ne
97w Uint32Array(Gn.buffer),jn=new Uint32Array(1),Ym=new Float32Array(jn.buffer),Km=new Int32Array(jn.buffer);function da(t,e,i){if(e===i)return t;if(e==="f32"){if(i==="i32"||i==="x32")return Kn[0]=t,Vm[0];if(i==="u32")return Kn[0]=t,Xm[0]}else if(e==="i32"||e==="x32"){if(i==="f32")return Gn[0]=t,Wm[0];if(i==="u32")return Gn[0]=t,$m[0]}else if(e==="u32"){if(i==="f32")return jn[0]=t,Ym[0];if(i==="i32"||i==="x32")return jn[0]=t,Km[0]}return console.error(`Unsupported cast from ${e} to ${i}`),t}let Gm=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},hn=class{constructor(e,i){this.align=e,this.size=i}},Li=class Di{constructor(){this.uniforms=[],this.storage=[],this.immediates=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Mm,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 i of e)i instanceof Wi&&this._functions.set(i.name,new Gm(i));for(const i of e)if(i instanceof Et){const n=this.getTypeInfo(i,null);n instanceof Ot&&this.structs.push(n)}for(const i of e)if(i instanceof wr)this.aliases.push(this._getAliasInfo(i));else{if(i instanceof Ir){const n=i,s=this._getAttributeNum(n.attributes,"id",0),r=n.type!=null?this.getTypeInfo(n.type,n.attributes):null;this.overrides.push(new Pm(n.name,r,n.attributes,s));continue}if(this._isUniformVar(i)){const n=i,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Ci(n.name,o,s,r,n.attributes,ot.Uniform,n.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isImmediateVar(i)){const n=i,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Ci(n.name,o,s,r,n.attributes,ot.Immediate,n.access);a.access||(a.access="read"),this.immediates.push(a);continue}if(this._isStorageVar(i)){const n=i,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 Ci(n.name,o,s,r,n.attributes,a?ot.StorageTexture:ot.Storage,n.access);l.access||(l.access="read"),this.storage.push(l);continue}if(this._isTextureVar(i)){const n=i,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=a?o.access:n.access,c=new Ci(n.name,o,s,r,n.attributes,a?ot.StorageTexture:ot.Texture,l||n.access);c.access||(c.access="read"),a?this.storage.push(c):this.textures.push(c);continue}if(this._isSamplerVar(i)){const n=i,s=this._getAttributeNum(n.attributes,"group",0),r=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Ci(n.name,o,s,r,n.attributes,ot.Sampler,n.access);this.samplers.push(a);continue}}for(const i of e)if(i instanceof Wi){const n=this._getAttribute(i,"vertex"),s=this._getAttribute(i,"fragment"),r=this._getAttribute(i,"compute"),o=n||s||r,a=new Nm(i.name,o?.name,i.attributes);a.attributes=i.attributes,a.startLine=i.startLine,a.endLine=i.endLine,this.functions.push(a),this._functions.get(i.name).info=a,o&&(this._functions.get(i.name).inUse=!0,a.inUse=!0,a.inputs=this._getInputs(i.args),a.outputs=this._getOutputs(i.returnType),this.entry[o.name].push(a)),a.resources=this._findResources(i,!!o),a.arguments=i.args.map(l=>new wm(l.name,this.getTypeInfo(l.type,l.attributes),l.attributes)),a.returnType=i.returnType?this.getTypeInfo(i.returnType,i.attributes):null;continue}for(const i of this._functions.values())i.info&&(i.info.inUse=i.inUse,this._addCalls(i.node,i.info.calls));for(const i of this._functions.values())i.node.search(n=>{var s,r,o;if(n instanceof ic){if(n.value)if(X(n.value))for(const a of n.value)for(const l of this.overrides)a===l.name&&((s=i.info)===null||s===void 0||s.overrides.push(l));else for(const a of this.overrides)n.value===a.name&&((r=i.info)===null||r===void 0||r.overrides.push(a))}else if(n instanceof Ye)for(const a of this.overrides)n.name===a.name&&((o=i.info)===null||o===void 0||o.overrides.push(a))});for(const i of this.uniforms)this._markStructsInUse(i.type);for(const i of this.storage)this._markStructsInUse(i.type)}getFunctionInfo(e){for(const i of this.functions)if(i.name==e)return i;return null}getStructInfo(e){for(const i of this.structs)if(i.name==e)return i;return null}getOverrideInfo(e){for(const i of this.overrides)if(i.name==e)return i;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const i of e.members)this._markStructsInUse(i.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const i=this._getAlias(e.name);i&&this._markStructsInUse(i)}}_addCalls(e,i){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&&i.add(r)}}findResource(e,i,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==i)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==i)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==i)return r}}for(const s of this.uniforms)if(s.group==e&&s.binding==i)return s;for(const s of this.storage)if(s.group==e&&s.binding==i)return s;for(const s of this.textures)if(s.group==e&&s.binding==i)return s;for(const s of this.samplers)if(s.group==e&&s.binding==i)return s;return null}_findResource(e){for(const i of this.uniforms)if(i.name==e)return i;for(const i of this.storage)if(i.name==e)return i;for(const i of this.textures)if(i.name==e)return i;for(const i of this.samplers)if(i.name==e)return i;return null}_markStructsFromAST(e){const i=this.getTypeInfo(e,null);this._markStructsInUse(i)}_findResources(e,i){const n=[],s=this,r=[];return e.search(o=>{if(o instanceof $n)r.push({});else if(o instanceof Yn)r.pop();else if(o instanceof gt){const a=o;i&&a.type!==null&&this._markStructsFromAST(a.type),r.length>0&&(r[r.length-1][a.name]=a)}else if(o instanceof mt){const a=o;i&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Bi){const a=o;i&&a.type!==null&&this._markStructsFromAST(a.type),r.length>0&&(r[r.length-1][a.name]=a)}else if(o instanceof Ye){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 li){const a=o,l=s._functions.get(a.name);if(l&&(i&&(l.inUse=!0),e.calls.add(l.node),l.resources=s._findResources(l.node,i),n.push(...l.resources)),a.name==="textureSample"&&a.args.length>=2){const c=a.args[0];let u=null;if(c instanceof Ye){const d=s._findResource(c.name);d&&d.resourceType===ot.Texture&&(u=d)}const h=a.args[1];let f=null;if(h instanceof Ye){const d=s._findResource(h.name);d&&d.resourceType===ot.Sampler&&(f=d)}u&&f&&(u.relations===null&&(u.relations=[]),u.relations.push(f),f.relations===null&&(f.relations=[]),f.relations.push(u))}}else if(o instanceof Pr){const a=o,l=s._functions.get(a.name);l&&(i&&(l.inUse=!0),e.calls.add(l.node),l.resources=s._findResources(l.node,i),n.push(...l.resources))}}),[...new Map(n.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function i(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)i(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.storage)i(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.textures)i(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.samplers)i(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,i=void 0){if(i===void 0&&(i=[]),e instanceof Et)this._getStructOutputs(e,i);else{const n=this._getOutputInfo(e);n!==null&&i.push(n)}return i}_getStructOutputs(e,i){for(const n of e.members)if(n.type instanceof Et)this._getStructOutputs(n.t
vendor: 4,142 bytes, line 97
97ype,i);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 ra(n.name,r,s.name,o);i.push(a)}}}_getOutputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const n=this.getTypeInfo(e,e.attributes),s=this._parseInt(i.value);return new ra("",n,i.name,s)}return null}_getInputs(e,i=void 0){i===void 0&&(i=[]);for(const n of e)if(n.type instanceof Et)this._getStructInputs(n.type,i);else{const s=this._getInputInfo(n);s!==null&&i.push(s)}return i}_getStructInputs(e,i){for(const n of e.members)if(n.type instanceof Et)this._getStructInputs(n.type,i);else{const s=this._getInputInfo(n);s!==null&&i.push(s)}}_getInputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const n=this._getAttribute(e,"interpolate"),s=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(i.value),o=new Im(e.name,s,i.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 i=parseInt(e);return isNaN(i)?e:i}_getAlias(e){for(const i of this.aliases)if(i.name==e)return i.type;return null}_getAliasInfo(e){return new bm(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const i of this.structs)if(i.name==e)return i;for(const i of this.aliases)if(i.name==e)return i.type;return null}getTypeInfo(e,i=null){if(this._types.has(e))return this._types.get(e);if(e instanceof Pn){const s=e.type?this.getTypeInfo(e.type,e.attributes):null,r=new nr(e.name,s,i);return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof Ui){const s=e,r=s.format?this.getTypeInfo(s.format,s.attributes):null,o=new Ut(s.name,i);return o.format=r,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof Et){const s=e,r=new Ot(s.name,i);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 sa(o.name,a,o.attributes))}return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof ki){const s=e,r=s.format instanceof M,o=s.format?r?this.getTypeInfo(s.format,null):new tt(s.format,null):null,a=new Lt(s.name,o,i,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof E){const s=e,r=s.format?this.getTypeInfo(s.format,null):null,o=new Lt(s.name,r,i,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const n=new tt(e.name,i);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var i,n,s;const r=this._getTypeSize(e);if(e.size=(i=r?.size)!==null&&i!==void 0?i:0,e instanceof Ut&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((n=o?.size)!==null&&n!==void 0?n:0,(s=o?.align)!==null&&s!==void 0?s:0),this._updateTypeInfo(e.format)}e instanceof nr&&this._updateTypeInfo(e.format),e instanceof Ot&&this._updateStructInfo(e)}_updateStructInfo(e){var i;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;(i=this._getAlias(c.type.name))!==null&&i!==void 0||c.type;const h=u.align,f=u.size;n=this._roundUp(h,n+s),s=f,r=n,o=Math.max(o,h),c.offset=n,c.size=f,this._updateTypeInfo(c.type)}e.size=this._roundUp(o,r+s),e.align=o}_getTypeSize(e){var i,n;if(e==null)return null;const s=this._getAttributeNum(e.attributes,"size",0),r=this._getAttributeNum(e.attributes,"align",0);if(e instanceof sa&&(e=e.type),e instanceof tt){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=Di._typeInfo[e.name];if(o!==void 0){const a=((i=e.format)===null||i===void 0?void 0:i.name)==="f16"?2:1;return new hn(Math.max(r,o.align/a),Math.max(s,o.size/a))}}{const o=Di._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new hn(Math.max(r,o.align/a),Math.max(s,o.size/a))}}if(e instanceof Ut){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?.attributes)!==null&&n!==void 0?n:null,"
97stride",this._roundUp(a,l)),s&&(l=s),new hn(Math.max(r,a),Math.max(s,l))}if(e instanceof Ot){let o=0,a=0,l=0,c=0,u=0;for(const h of e.members){const f=this._getTypeSize(h.type);f!==null&&(o=Math.max(f.align,o),l=this._roundUp(f.align,l+c),c=f.size,u=l)}return a=this._roundUp(o,u+c),new hn(Math.max(r,o),Math.max(s,a))}return null}_isUniformVar(e){return e instanceof gt&&e.storage=="uniform"}_isImmediateVar(e){return e instanceof gt&&e.storage=="immediate"}_isStorageVar(e){return e instanceof gt&&e.storage=="storage"}_isTextureVar(e){return e instanceof gt&&e.type!==null&&Di._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof gt&&e.type!==null&&Di._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,i){const n=e;if(!n||!n.attributes)return null;const s=n.attributes;for(let r of s)if(r.name==i)return r;return null}_getAttributeNum(e,i,n){if(e===null)return n;for(let s of e)if(s.name==i){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,i){return Math.ceil(i/e)*e}};Li._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}},Li._textureTypes=p.any_texture_type.map(t=>t.name),Li._samplerTypes=p.sampler_type.map(t=>t.name);let Nr=0,jm=class oc{constructor(e,i,n){this.id=Nr++,this.name=e,this.value=i,this.node=n}clone(){return new oc(this.name,this.value,this.node)}},qm=class ac{constructor(e){this.id=Nr++,this.name=e.name,this.node=e}clone(){return new ac(this.node)}},Zm=class lc{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=Nr++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var i;return this.variables.has(e)?(i=this.variables.get(e))!==null&&i!==void 0?i:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var i;return this.functions.has(e)?(i=this.functions.get(e))!==null&&i!==void 0?i:null:this.parent?this.parent.getFunction(e):null}createVariable(e,i,n){this.variables.set(e,new jm(e,i,n??null))}setVariable(e,i,n){const s=this.getVariable(e);s!==null?s.value=i:this.createVariable(e,i,n)}getVariableValue(e){var i;const n=this.getVariable(e);return(i=n?.value)!==null&&i!==void 0?i:null}clone(){return new lc(this)}},Qm=class{evalExpression(e,i){return null}getTypeInfo(e){return null}getVariableName(e,i){return""}},Mn=class st{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,i){const n=this.exec.evalExpression(e.args[0],i);let s=!0;if(n instanceof _)return n.data.forEach(r=>{r||(s=!1)}),new S(s?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _){const s=n.data.some(r=>r);return new S(s?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,i){const n=this.exec.evalExpression(e.args[2],i);if(!(n instanceof S))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],i):this.exec.evalExpression(e.args[0],i)}ArrayLength(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.evalExpression(n,i);if(s instanceof Te&&s.typeInfo.size===0){const r=s.typeInfo,o=s.buffer.byteLength/r.stride;return new S(o,this.getTypeInfo("u32"))}return new S(s.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.abs(r)),n.typeInfo);const s=n;return new S(Math.abs(s.value),s.typeInfo)}Acos(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.acos(r)),n.typeInfo);const s=n;return new S(Math.acos(s.value),n.typeInfo)}Acosh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.acosh(r)),n.typeInfo);const s=n;return new S(Math.acosh(s.value),n.typeInfo)}Asin(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.asin(r)),n.typeInfo);const s=n;return new S(Math.asin(s.value),n.typeInfo)}Asinh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.asinh(r)),n.typeInfo);const s=n;return new S(Math.asinh(s.value),n.typeInfo)}Atan(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.atan(r)),n.typeInfo);const s=n;return new S(Math.atan(s.value),n.typeInfo)}Atanh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.atanh(r)),n.typeInfo);const s=n;return new S(Math.atanh(s.value),n.typeInfo)}Atan2(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((a,l)=>Math.atan2(a,s.data[l])),n.typeInfo);const r=n,o=s;return new S(Math.atan2(r.value,o.value),n.typeInfo)}Ceil(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.ceil(r)),n.typeInfo);const s=n;return new S(Math.ceil(s.value),n.typeInfo)}_clamp(e,i,n){return Math.min(Math.max(e,i),n)}Clamp(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(n instanceof _&&s instanceof _&&r instanceof _)return new _(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 S(this._clamp(o.value,a.value,l.value),n.typeInfo)}Cos(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.cos(r)),n.typeInfo);const s=n;return new S(Math.cos(s.value),n.typeInfo)}Cosh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.cosh(r)),n.typeInfo);const s=n;return new S(Math.cos(s.value),n.typeInfo)}CountLeadingZeros(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.clz32(r)),n.typeInfo);const s=n;return new S(Math.clz32(s.value),n.typeInfo)}_countOneBits(e){let i=0;for(;e!==0;)1&e&&i++,e>>=1;return i}CountOneBits(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>this._countOneBits(r)),n.typeInfo);const s=n;return new S(this._countOneBits(s.value),n.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let i=0;for(;!(1&e);)e>>=1,i++;return i}CountTrailingZeros(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>this._countTrailingZeros(r)),n.typeInfo);const s=n;return new S(this._countTrailingZeros(s.value),n.typeInfo)}Cross(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _){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 _([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,i){const n=this.exec.evalExpression(e.args[0],i),s=180/Math.PI;return n instanceof _?new _(n.data.map(r=>r*s),n.typeInfo):new S(n.value*s,this.getTypeInfo("f32"))}Determinant(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof se){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 S(s[0]*s[3]-s[1]*s[2],o);if(r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h")return new S(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==="mat4x4"||r==="mat4x4f"||r==="mat4x4h"){const a=s[0],l=s[1],c=s[2],u=s[3],h=s[4],f=s[5],d=s[6],T=s[7],C=s[8],w=s[9],A=s[10],F=s[11],b=s[12],g=s[13],v=s[14],N=s[15];return new S((a*f-h*l)*(A*N-v*F)-(a*d-h*c)*(w*N-g*F)+(a*T-h*u)*(w*v-g*A)+(l*d-f*c)*(C*N-b*F)-(l*T-f*u)*(C*v-b*A)+(c*T-d*u)*(C*g-b*w),o)}return console.error(`Determinant: unsupported matrix type ${r}. Line ${e.line}`),null}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _){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 S(Math.sqrt(a),this.getTypeInfo("f32"))}const r=n,o=s;return new S(Math.abs(r.value-o.value),n.typeInfo)}_dot(e,i){let n=0;for(let s=0;s<e.length;++s)n+=i[s]*e[s];return n}Dot(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);return n instanceof _&&s instanceof _?new S(this._dot(n.data,s.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=n.value>>>0,o=s.value>>>0;let a=0;for(let l=0;l<4;++l)a+=(r>>>8*l&255)*(o>>>8*l&255);return new S(a>>>0,this.getTypeInfo("u32"))}Dot4I8Packed(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=n.value>>>0,o=s.value>>>0,a=c=>128&c?c-256:c;let l=0;for(let c=0;c<4;++c)l+=a(r>>>8*c&255)*a(o>>>8*c&255);return new S(0|l,this.getTypeInfo("i32"))}Exp(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.exp(r)),n.typeInfo);const s=n;return new S(Math.exp(s.value),n.typeInfo)}Exp2(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.pow(2,r)),n.typeInfo);const s=n;return new S(Math.pow(2,s.value),n.typeInfo)}ExtractBits(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);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 _)return new _(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 S(l>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(n instanceof _&&s instanceof _&&r instanceof _){const o=this._dot(s.data,r.data);return new _(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,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>this._firstLeadingBit(r)),n.typeInfo);const s=n;return new S(this._firstLeadingBit(s.value),n.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>this._firstTrailingBit(r)),n.typeInfo);const s=n;return new S(this._firstTrailingBit(s.value),n.typeInfo)}Floor(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.floor(r)),n.typeInfo);const s=n;return new S(Math.floor(s.value),n.typeInfo)}Fma(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(n instanceof _&&s instanceof _&&r instanceof _)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 _(n.data.map((c,u)=>c*s.data[u]+r.data[u]),n.typeInfo);const o=n,a=s,l=r;return new S(o.value*a.value+l.value,o.typeInfo)}Fract(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>r-Math.floor(r)),n.typeInfo);const s=n;return new S(s.value-Math.floor(s.value),n.typeInfo)}Frexp(e,i){const n=this.exec.evalExpression(e.args[0],i),s=r=>{if(r===0||!isFinite(r)||isNaN(r))return r;const o=Math.floor(Math.log2(Math.abs(r)))+1;return r/Math.pow(2,o)};return n instanceof _?new _(n.data.map(r=>s(r)),n.typeInfo):new S(s(n.value),n.typeInfo)}InsertBits(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i),o=this.exec.evalExpression(e.args[3],i);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 _&&s instanceof _)return new _(n.data.map((f,d)=>f&c|s.data[d]<<a&l),n.typeInfo);const u=n.value,h=s.value;return new S(u&c|h<<a&l,n.typeInfo)}InverseSqrt(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>1/Math.sqrt(r)),n.typeInfo);const s=n;return new S(1/Math.sqrt(s.value),n.typeInfo)}Ldexp(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((o,a)=>o*Math.pow(2,s.data[a])),n.typeInfo);const r=s;return new S(n.value*Math.pow(2,r.value),n.typeInfo)}Length(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _){let r=0;return n.data.forEach(o=>{r+=o*o}),new S(Math.sqrt(r),this.getTypeInfo("f32"))}const s=n;return new S(Math.abs(s.value),n.typeInfo)}Log(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.log(r)),n.typeInfo);const s=n;return new S(Math.log(s.value),n.typeInfo)}Log2(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.log2(r)),n.typeInfo);const s=n;return new S(Math.log2(s.value),n.typeInfo)}Max(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((a,l)=>Math.max(a,s.data[l])),n.typeInfo);const r=n,o=s;return new S(Math.max(r.value,o.value),n.typeInfo)}Min(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((a,l)=>Math.min(a,s.data[l])),n.typeInfo);const r=n,o=s;return new S(Math.min(r.value,o.value),n.typeInfo)}Mix(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(n instanceof _&&s instanceof _&&r instanceof _)return new _(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 S(n.value*(1-a.value)+o.value*a.value,n.typeInfo)}Modf(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((o,a)=>o%s.data[a]),n.typeInfo);const r=s;return new S(n.value%r.value,n.typeInfo)}Normalize(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _){const s=this.Length(e,i).value;return new _(n.data.map(r=>r/s),n.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _)return new _(n.data.map((a,l)=>Math.pow(a,s.data[l])),n.typeInfo);const r=n,o=s;return new S(Math.pow(r.value,o.value),n.typeInfo)}QuantizeToF16(e,i){const n=this.exec.evalExpression(e.args[0],i),s=r=>st._f16BitsToF32(st._f32ToF16Bits(r));return n instanceof _?new _(n.data.map(r=>s(r)),n.typeInfo):new S(s(n.value),n.typeInfo)}Radians(e,i){const n=this.exec.evalExpression(e.args[0],i);return n instanceof _?new _(n.data.map(s=>s*Math.PI/180),n.typeInfo):new S(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,i){const n=this.exec.evalExpression(e.args[
970],i),s=this.exec.evalExpression(e.args[1],i);if(n instanceof _&&s instanceof _){const r=this._dot(n.data,s.data);return new _(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,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(n instanceof _&&s instanceof _&&r instanceof S){const o=this._dot(s.data,n.data);return new _(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,i){const n=this.exec.evalExpression(e.args[0],i),s=r=>{let o=r>>>0;return o=(1431655765&o)<<1|o>>>1&1431655765,o=(858993459&o)<<2|o>>>2&858993459,o=(252645135&o)<<4|o>>>4&252645135,o=(16711935&o)<<8|o>>>8&16711935,(o<<16|o>>>16)>>>0};return n instanceof _?new _(n.data.map(r=>s(r)),n.typeInfo):new S(s(n.value),n.typeInfo)}Round(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.round(r)),n.typeInfo);const s=n;return new S(Math.round(s.value),n.typeInfo)}Saturate(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.min(Math.max(r,0),1)),n.typeInfo);const s=n;return new S(Math.min(Math.max(s.value,0),1),n.typeInfo)}Sign(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.sign(r)),n.typeInfo);const s=n;return new S(Math.sign(s.value),n.typeInfo)}Sin(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.sin(r)),n.typeInfo);const s=n;return new S(Math.sin(s.value),n.typeInfo)}Sinh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.sinh(r)),n.typeInfo);const s=n;return new S(Math.sinh(s.value),n.typeInfo)}_smoothstep(e,i,n){const s=Math.min(Math.max((n-e)/(i-e),0),1);return s*s*(3-2*s)}SmoothStep(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i),r=this.exec.evalExpression(e.args[2],i);if(r instanceof _&&n instanceof _&&s instanceof _)return new _(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 S(this._smoothstep(o.value,a.value,l.value),r.typeInfo)}Sqrt(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.sqrt(r)),n.typeInfo);const s=n;return new S(Math.sqrt(s.value),n.typeInfo)}Step(e,i){const n=this.exec.evalExpression(e.args[0],i),s=this.exec.evalExpression(e.args[1],i);if(s instanceof _&&n instanceof _)return new _(s.data.map((o,a)=>o<n.data[a]?0:1),s.typeInfo);const r=n;return new S(s.value<r.value?0:1,r.typeInfo)}Tan(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.tan(r)),n.typeInfo);const s=n;return new S(Math.tan(s.value),n.typeInfo)}Tanh(e,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.tanh(r)),n.typeInfo);const s=n;return new S(Math.tanh(s.value),n.typeInfo)}_getTransposeType(e){const i=e.getTypeName();return i==="mat2x2f"||i==="mat2x2h"?e:i==="mat2x3f"?this.getTypeInfo("mat3x2f"):i==="mat2x3h"?this.getTypeInfo("mat3x2h"):i==="mat2x4f"?this.getTypeInfo("mat4x2f"):i==="mat2x4h"?this.getTypeInfo("mat4x2h"):i==="mat3x2f"?this.getTypeInfo("mat2x3f"):i==="mat3x2h"?this.getTypeInfo("mat2x3h"):i==="mat3x3f"||i==="mat3x3h"?e:i==="mat3x4f"?this.getTypeInfo("mat4x3f"):i==="mat3x4h"?this.getTypeInfo("mat4x3h"):i==="mat4x2f"?this.getTypeInfo("mat2x4f"):i==="mat4x2h"?this.getTypeInfo("mat2x4h"):i==="mat4x3f"?this.getTypeInfo("mat3x4f"):i==="mat4x3h"?this.getTypeInfo("mat3x4h"):(i==="mat4x4f"||i==="mat4x4h"||console.error(`Invalid matrix type ${i}`),e)}Transpose(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof se))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 se([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 se([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 se([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 se([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 se([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 se([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 se([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 se([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 se([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,i){const n=this.exec.evalExpression(e.args[0],i);if(n instanceof _)return new _(n.data.map(r=>Math.trunc(r)),n.typeInfo);const s=n;return new S(Math.trunc(s.value),n.typeInfo)}Dpdx(e,i){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,i){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,i){return console.error("TODO: dpdxFine"),null}Dpdy(e,i){return console.error("TODO: dpdy"),null}DpdyCoarse(e,i){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,i){return console.error("TODO: dpdyFine"),null}Fwidth(e,i){return console.error("TODO: fwidth"),null}FwidthCoarse(e,i){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,i){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,i){const n=e.args[0],s=e.args.length>1?this.exec.evalExpression(e.args[1],i).value:0;if(n instanceof Ye){const r=n.name,o=i.getVariableValue(r);if(o instanceof At){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 S(a[0],this.getTypeInfo("u32")):l==="3d"?new _(a,this.getTypeInfo("vec3u")):l==="2d"?new _(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,i){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,i){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,i){const n=e.args[0],s=this.exec.evalExpression(e.args[1],i);if(!(s instanceof _)||s.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(n instanceof Ye){const r=n.name,o=i.getVariableValue(r);if(o instanceof At){let a=0,l=0;["texture_storage_2d_array","texture_2d_array","texture_depth_2d_array"].indexOf(o.typeInfo.name)>-1&&(a=this.exec.evalExpression(e.args[2],i).value),["texture_1d","texture_2d","texture_depth_2d","texture_3d"].indexOf(o.typeInfo.name)>-1&&(l=this.exec.evalExpression(e.args[2],i).value),["texture_2d_array","texture_depth_2d_array"].indexOf(o.typeInfo.name)>-1&&(l=this.exec.evalExpression(e.args[3],i).value);const c=Math.floor(s.data[0]),u=Math.floor(s.data[1]),h=Math.floor(a),f=Math.floor(l);if(c<0||c>=o.width||u<0||u>=o.height)return console.error(`Texture ${r} out of bounds. Line ${e.line}`),null;const d=o.getPixel(c,u,h,f);return d===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new _(d,this.getTypeInfo("vec4f"))}return console.error(`Texture ${r} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,i){const n=e.args[0];if(n instanceof Ye){const s=n.name,r=i.getVariableValue(s);return r instanceof At?new S(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,i){const n=e.args[0];if(n instanceof Ye){const s=n.name,r=i.getVariableValue(s);return r instanceof At?new S(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,i){const n=e.args[0];if(n instanceof Ye){const s=n.name,r=i.getVariableValue(s);
97return r instanceof At?new S(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,i){return console.error("TODO: textureSample"),null}TextureSampleBias(e,i){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,i){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,i){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,i){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,i){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,i){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,i){const n=e.args[0],s=this.exec.evalExpression(e.args[1],i),r=e.args.length===4?this.exec.evalExpression(e.args[2],i).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],i).data:this.exec.evalExpression(e.args[2],i).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(s instanceof _)||s.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(n instanceof Ye){const a=n.name,l=i.getVariableValue(a);if(l instanceof At){const c=l.getMipLevelSize(0),u=Math.floor(s.data[0]),h=Math.floor(s.data[1]);return u<0||u>=c[0]||h<0||h>=c[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(l.setPixel(u,h,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,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i);return i.getVariable(s).value.getSubData(this.exec,n.postfix,i)}AtomicStore(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i);return l instanceof S&&a instanceof S&&(l.value=a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),null}AtomicAdd(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value+=a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicSub(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value-=a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicMax(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=Math.max(l.value,a.value)),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicMin(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=Math.min(l.value,a.value)),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicAnd(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=l.value&a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicOr(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=l.value|a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicXor(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=l.value^a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicExchange(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s);let o=e.args[1];const a=this.exec.evalExpression(o,i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&a instanceof S&&(l.value=a.value),r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i),c}AtomicCompareExchangeWeak(e,i){let n=e.args[0];n instanceof Re&&(n=n.right);const s=this.exec.getVariableName(n,i),r=i.getVariable(s),o=this.exec.evalExpression(e.args[1],i),a=this.exec.evalExpression(e.args[2],i),l=r.value.getSubData(this.exec,n.postfix,i),c=new S(l.value,l.typeInfo);return l instanceof S&&o instanceof S&&a instanceof S&&l.value===o.value&&(l.value=a.value,r.value instanceof Te&&r.value.setDataValue(this.exec,l,n.postfix,i)
97),c}_packSnormByte(e){const i=Math.round(127*e);return 255&(i<-128?-128:i>127?127:i)}_packUnormByte(e){const i=Math.round(255*e);return 255&(i<0?0:i>255?255:i)}Pack4x8snorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4x8snorm() expects a vec4<f32> argument. Line ${e.line}`),null;const s=n.data,r=(this._packSnormByte(s[0])|this._packSnormByte(s[1])<<8|this._packSnormByte(s[2])<<16|this._packSnormByte(s[3])<<24)>>>0;return new S(r,this.getTypeInfo("u32"))}Pack4x8unorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4x8unorm() expects a vec4<f32> argument. Line ${e.line}`),null;const s=n.data,r=(this._packUnormByte(s[0])|this._packUnormByte(s[1])<<8|this._packUnormByte(s[2])<<16|this._packUnormByte(s[3])<<24)>>>0;return new S(r,this.getTypeInfo("u32"))}Pack4xI8(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4xI8() expects a vec4<i32> argument. Line ${e.line}`),null;const s=n.data,r=(255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24)>>>0;return new S(r,this.getTypeInfo("u32"))}Pack4xU8(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4xU8() expects a vec4<u32> argument. Line ${e.line}`),null;const s=n.data,r=(255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24)>>>0;return new S(r,this.getTypeInfo("u32"))}Pack4x8Clamp(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4x8Clamp() expects a vec4<i32> argument. Line ${e.line}`),null;const s=n.data,r=a=>255&(a<-128?-128:a>127?127:a),o=(r(s[0])|r(s[1])<<8|r(s[2])<<16|r(s[3])<<24)>>>0;return new S(o,this.getTypeInfo("u32"))}Pack4xU8Clamp(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack4xU8Clamp() expects a vec4<u32> argument. Line ${e.line}`),null;const s=n.data,r=a=>255&(a<0?0:a>255?255:a),o=(r(s[0])|r(s[1])<<8|r(s[2])<<16|r(s[3])<<24)>>>0;return new S(o,this.getTypeInfo("u32"))}Pack2x16snorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack2x16snorm() expects a vec2<f32> argument. Line ${e.line}`),null;const s=n.data,r=a=>{const l=Math.round(32767*a);return 65535&(l<-32768?-32768:l>32767?32767:l)},o=(r(s[0])|r(s[1])<<16)>>>0;return new S(o,this.getTypeInfo("u32"))}Pack2x16unorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack2x16unorm() expects a vec2<f32> argument. Line ${e.line}`),null;const s=n.data,r=a=>{const l=Math.round(65535*a);return 65535&(l<0?0:l>65535?65535:l)},o=(r(s[0])|r(s[1])<<16)>>>0;return new S(o,this.getTypeInfo("u32"))}Pack2x16float(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof _))return console.error(`Pack2x16float() expects a vec2<f32> argument. Line ${e.line}`),null;const s=n.data,r=(st._f32ToF16Bits(s[0])|st._f32ToF16Bits(s[1])<<16)>>>0;return new S(r,this.getTypeInfo("u32"))}Unpack4x8snorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack4x8snorm() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0,r=o=>{const a=(128&o?o-256:o)/127;return a<-1?-1:a>1?1:a};return new _([r(255&s),r(s>>>8&255),r(s>>>16&255),r(s>>>24&255)],this.getTypeInfo("vec4f"))}Unpack4x8unorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack4x8unorm() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0;return new _([(255&s)/255,(s>>>8&255)/255,(s>>>16&255)/255,(s>>>24&255)/255],this.getTypeInfo("vec4f"))}Unpack4xI8(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack4xI8() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0,r=o=>128&o?o-256:o;return new _([r(255&s),r(s>>>8&255),r(s>>>16&255),r(s>>>24&255)],this.getTypeInfo("vec4i"))}Unpack4xU8(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack4xU8() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0;return new _([255&s,s>>>8&255,s>>>16&255,s>>>24&255],this.getTypeInfo("vec4u"))}Unpack2x16snorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack2x16snorm() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0,r=o=>{const a=(32768&o?o-65536:o)/32767;return a<-1?-1:a>1?1:a};return new _([r(65535&s),r(s>>>16&65535)],this.getTypeInfo("vec2f"))}Unpack2x16unorm(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack2x16unorm() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0;return new _([(65535&s)/65535,(s>>>16&65535)/65535],this.getTypeInfo("vec2f"))}Unpack2x16float(e,i){const n=this.exec.evalExpression(e.args[0],i);if(!(n instanceof S))return console.error(`Unpack2x16float() expects a u32 argument. Line ${e.line}`),null;const s=n.value>>>0;return new _([st._f16BitsToF32(65535&s),st._f16BitsToF32(s>>>16&65535)],this.getTypeInfo("vec2f"))}static _f32ToF16Bits(e){st._f32Convert[0]=e;const i=st._u32View[0],n=i>>>16&32768;let s=(i>>>23&255)-127+15;const r=8388607&i;return 255&~(i>>>23)?s>=31?31744|n:s<=0?s<-10?n:n|(8388608|r)>>>14-s:n|s<<10|r>>>13:31744|n|(r?512:0)}static _f16BitsToF32(e){const i=(32768&e)<<16,n=e>>>10&31,s=1023&e;let r=0;if(n===0)if(s===0)r=i;else{let o=s,a=-14;for(;!(1024&o);)o<<=1,a--;o&=1023,r=i|a+127<<23|o<<13}else r=n===31?2139095040|i|s<<13:i|n-15+127<<23|s<<13;return st._u32View[0]=r,st._f32Convert[0]}StorageBarrier(e,i){return null}TextureBarrier(e,i){return null}WorkgroupBarrier(e,i){return null}WorkgroupUniformLoad(e,i){return null}SubgroupAdd(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupExclusiveAdd(e,i){const n=this.exec.evalExpression(e.args[0],i);return n instanceof _?new _(n.data.map(()=>0),n.typeInfo):new S(0,n.typeInfo)}SubgroupInclusiveAdd(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupAll(e,i){const n=this.exec.evalExpression(e.args[0],i);return new S(n.value?1:0,this.getTypeInfo("bool"))}SubgroupAnd(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupAny(e,i){const n=this.exec.evalExpression(e.args[0],i);return new S(n.value?1:0,this.getTypeInfo("bool"))}SubgroupBallot(e,i){const n=this.exec.evalExpression(e.args[0],i).value?1:0;return new _([n,0,0,0],this.getTypeInfo("vec4u"))}SubgroupBroadcast(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupBroadcastFirst(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupElect(e,i){return new S(1,this.getTypeInfo("bool"))}SubgroupMax(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupMin(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupMul(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupExclusiveMul(e,i){const n=this.exec.evalExpression(e.args[0],i);return n instanceof _?new _(n.data.map(()=>1),n.typeInfo):new S(1,n.typeInfo)}SubgroupInclusiveMul(e,i){return this.exec.evalExpression(e.args[0],i)}
97SubgroupOr(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupShuffle(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupShuffleDown(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupShuffleUp(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupShuffleXor(e,i){return this.exec.evalExpression(e.args[0],i)}SubgroupXor(e,i){return this.exec.evalExpression(e.args[0],i)}QuadBroadcast(e,i){return this.exec.evalExpression(e.args[0],i)}QuadSwapDiagonal(e,i){return this.exec.evalExpression(e.args[0],i)}QuadSwapX(e,i){return this.exec.evalExpression(e.args[0],i)}QuadSwapY(e,i){return this.exec.evalExpression(e.args[0],i)}};Mn._f32Convert=new Float32Array(1),Mn._u32View=new Uint32Array(Mn._f32Convert.buffer);const Bs={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},We={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]};let rt=class He extends Qm{constructor(e,i){var n;super(),this.ast=e??[],this.reflection=new Li,this.reflection.updateAST(this.ast),this.context=(n=i?.clone())!==null&&n!==void 0?n:new Zm,this.builtins=new Mn(this),this.typeInfo={bool:this.getTypeInfo(M.bool),i32:this.getTypeInfo(M.i32),u32:this.getTypeInfo(M.u32),f32:this.getTypeInfo(M.f32),f16:this.getTypeInfo(M.f16),vec2f:this.getTypeInfo(E.vec2f),vec2u:this.getTypeInfo(E.vec2u),vec2i:this.getTypeInfo(E.vec2i),vec2h:this.getTypeInfo(E.vec2h),vec3f:this.getTypeInfo(E.vec3f),vec3u:this.getTypeInfo(E.vec3u),vec3i:this.getTypeInfo(E.vec3i),vec3h:this.getTypeInfo(E.vec3h),vec4f:this.getTypeInfo(E.vec4f),vec4u:this.getTypeInfo(E.vec4u),vec4i:this.getTypeInfo(E.vec4i),vec4h:this.getTypeInfo(E.vec4h),mat2x2f:this.getTypeInfo(E.mat2x2f),mat2x3f:this.getTypeInfo(E.mat2x3f),mat2x4f:this.getTypeInfo(E.mat2x4f),mat3x2f:this.getTypeInfo(E.mat3x2f),mat3x3f:this.getTypeInfo(E.mat3x3f),mat3x4f:this.getTypeInfo(E.mat3x4f),mat4x2f:this.getTypeInfo(E.mat4x2f),mat4x3f:this.getTypeInfo(E.mat4x3f),mat4x4f:this.getTypeInfo(E.mat4x4f)}}getVariableValue(e){var i,n;const s=(n=(i=this.context.getVariable(e))===null||i===void 0?void 0:i.value)!==null&&n!==void 0?n:null;if(s===null)return null;if(s instanceof S)return s.value;if(s instanceof _||s instanceof se)return Array.from(s.data);if(s instanceof Te&&s.typeInfo instanceof Ut){const r=this._resolveAtomicType(s.typeInfo.format).name;if(r==="u32")return Array.from(new Uint32Array(s.buffer,s.offset,s.typeInfo.count));if(r==="i32")return Array.from(new Int32Array(s.buffer,s.offset,s.typeInfo.count));if(r==="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,i,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 i=="number")i=[i,1,1];else{if(i.length===0)return void console.error("Invalid dispatch count");i.length===1?i=[i[0],1,1]:i.length===2?i=[i[0],i[1],1]:i.length>3&&(i=[i[0],i[1],i[2]])}const a=i[0],l=i[1],c=i[2],u=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new _(i,u));const h=this.reflection.getFunctionInfo(e);h===null&&console.error(`Function ${e} not found in reflection data`);for(const d in n)for(const T in n[d]){const C=n[d][T];
97r.variables.forEach(w=>{var A;const F=w.node;if(F?.attributes){let b=null,g=null;for(const v of F.attributes)v.name==="binding"?b=v.value:v.name==="group"&&(g=v.value);if(T===b&&d===g){let v=!1;for(const N of h.resources)if(N.name===w.name&&N.group===parseInt(d)&&N.binding===parseInt(T)){v=!0;break}if(v)if(C.texture!==void 0&&C.descriptor!==void 0){const N=new At(C.texture,this.getTypeInfo(F.type),C.descriptor,(A=C.texture.view)!==null&&A!==void 0?A:null);w.value=N}else C.uniform!==void 0?w.value=new Te(C.uniform,this.getTypeInfo(F.type)):w.value=new Te(C,this.getTypeInfo(F.type))}}})}const f=new _([0,0,0],u);r.setVariable("@workgroup_id",f);for(let d=0;d<c;++d)for(let T=0;T<l;++T)for(let C=0;C<a;++C)f.data[0]=C,f.data[1]=T,f.data[2]=d,this._dispatchWorkgroup(o,[C,T,d],r)}execStatement(e,i){if(e instanceof Yl)return this.evalExpression(e.value,i);if(e instanceof Gl){if(e.condition){const n=this.evalExpression(e.condition,i);if(!(n instanceof S))throw new Error("Invalid break-if condition");if(!n.value)return null}return He._breakObj}if(e instanceof jl)return He._continueObj;if(e instanceof Bi)this._let(e,i);else if(e instanceof gt)this._var(e,i);else if(e instanceof In)this._const(e,i);else if(e instanceof Ir)this._override(e,i);else if(e instanceof Wi)this._function(e,i);else{if(e instanceof $l)return this._if(e,i);if(e instanceof Wl)return this._switch(e,i);if(e instanceof zl)return this._for(e,i);if(e instanceof Ll)return this._while(e,i);if(e instanceof Xl)return this._loop(e,i);if(e instanceof sr){const n=i.clone();return n.currentFunctionName=i.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof Vl)this._assign(e,i);else if(e instanceof Hl)this._increment(e,i);else{if(e instanceof Et)return null;if(e instanceof Pr)this._call(e,i);else{if(e instanceof Kl||e instanceof wr)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,i){return e instanceof nt?this._evalBinaryOp(e,i):e instanceof Ne?this._evalLiteral(e,i):e instanceof Ye?this._evalVariable(e,i):e instanceof li?this._evalCall(e,i):e instanceof mt?this._evalCreate(e,i):e instanceof ql?this._evalConst(e,i):e instanceof Zl?this._evalBitcast(e,i):e instanceof Re?this._evalUnaryOp(e,i):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var i;if(e instanceof M){const s=this.reflection.getTypeInfo(e);if(s!==null)return s}let n=(i=this.typeInfo[e])!==null&&i!==void 0?i:null;return n!==null||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,i){for(const n in e){const s=e[n],r=this.reflection.getOverrideInfo(n);r!==null?(r.type===null&&(r.type=this.getTypeInfo("u32")),He._numericScalarTypes.has(r.type.name)?i.setVariable(n,new S(s,r.type)):He._vectorTypes.has(r.type.name)?i.setVariable(n,new _(s,r.type)):console.error(`Invalid constant type for ${n}`)):console.error(`Override ${n} does not exist in the shader.`)}}_dispatchWorkgroup(e,i,n){const s=[1,1,1];for(const d of e.node.attributes)if(d.name==="workgroup_size"){if(d.value.length>0){const T=n.getVariableValue(d.value[0]);s[0]=T instanceof S?T.value:parseInt(d.value[0])}if(d.value.length>1){const T=n.getVariableValue(d.value[1]);s[1]=T instanceof S?T.value:parseInt(d.value[1])}if(d.value.length>2){const T=n.getVariableValue(d.value[2]);s[2]=T instanceof S?T.value:parseInt(d.value[2])}}const r=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new _(s,r));const a=s[0],l=s[1],c=s[2],u=new _([0,0,0],r),h=new _([0,0,0],r),f=new S(0,o);n.setVariable("@local_invocation_id",u),n.setVariable("@global_invocation_id",h),n.setVariable("@local_invocation_index",f);for(let d=0,T=0;d<c;++d)for(let C=0;C<l;++C)for(let w=0;w<a;++w,++T)u.data[0]=w,u.data[1]=C,u.data[2]=d,h.data[0]=w+i[0]*s[0],h.data[1]=C+i[1]*s[1],h.data[2]=d+i[2]*s[2],f.value=T,this._dispatchExec(e,n)}_dispatchExec(e,i){for(const n of e.node.args)for(const s of n.attributes)if(s.name==="builtin"){const r=`@${s.value}`,o=i.getVariable(r);o!==void 0&&i.variables.set(n.name,o)}this._execStatements(e.node.body,i)}getVariableName(e,i){for(;e instanceof Re;)e=e.right;return e instanceof Ye?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,i){for(const n of e){if(Array.isArray(n)){const r=i.clone(),o=this._execStatements(n,r);if(o)return o;continue}
97const s=this.execStatement(n,i);if(s)return s}return null}_call(e,i){const n=i.clone();n.currentFunctionName=e.name;const s=i.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,i)}_increment(e,i){const n=this.getVariableName(e.variable,i),s=i.getVariable(n);s?e.operator==="++"?s.value instanceof S?s.value.value++:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):e.operator==="--"?s.value instanceof S?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,i){if(e instanceof Ye){const n=this.getVariableName(e,i),s=i.getVariable(n);return s===null?(console.error(`Variable ${n} not found. Line ${e.line}`),null):s.value.getSubData(this,e.postfix,i)}if(e instanceof Re){if(e.operator==="*"){const n=this._getVariableData(e.right,i);return n instanceof ei?n.reference.getSubData(this,e.postfix,i):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const n=this._getVariableData(e.right,i);return new ei(n)}}return null}_assign(e,i){let n=null,s="<var>",r=null;if(e.variable instanceof Re){const l=this._getVariableData(e.variable,i),c=this.evalExpression(e.value,i),u=e.operator;if(u==="="){if(l instanceof S||l instanceof _||l instanceof se){if(c instanceof S||c instanceof _||c instanceof se&&l.data.length===c.data.length)return void l.data.set(c.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(l instanceof Te&&c instanceof Te&&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 S||l instanceof _||l instanceof se?c instanceof S||c instanceof _||c instanceof se?void l.data.set(c.data.map((h,f)=>l.data[f]+h)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(l instanceof S||l instanceof _||l instanceof se)&&(c instanceof S||c instanceof _||c instanceof se)?void l.data.set(c.data.map((h,f)=>l.data[f]-h)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Re){if(e.variable.operator==="*"){s=this.getVariableName(e.variable.right,i);const l=i.getVariable(s);if(!(l&&l.value instanceof ei))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 Re;){if(u.postfix){c=u.postfix;break}u=u.right}}c&&(n=n.getSubData(this,c,i))}}else{r=e.variable.postfix,s=this.getVariableName(e.variable,i);const l=i.getVariable(s);if(l===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);n=l.value}if(n instanceof ei&&(n=n.reference),n===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);const o=this.evalExpression(e.value,i),a=e.operator;if(a!=="="){const l=n.getSubData(this,r,i);if(l instanceof _&&o instanceof S){const c=l.data,u=o.value;if(a==="+=")for(let h=0;h<c.length;++h)c[h]+=u;else if(a==="-=")for(let h=0;h<c.length;++h)c[h]-=u;else if(a==="*=")for(let h=0;h<c.length;++h)c[h]*=u;else if(a==="/=")for(let h=0;h<c.length;++h)c[h]/=u;else if(a==="%=")for(let h=0;h<c.length;++h)c[h]%=u;else if(a==="&=")for(let h=0;h<c.length;++h)c[h]&=u;else if(a==="|=")for(let h=0;h<c.length;++h)c[h]|=u;else if(a==="^=")for(let h=0;h<c.length;++h)c[h]^=u;else if(a==="<<=")for(let h=0;h<c.length;++h)c[h]<<=u;else if(a===">>=")for(let h=0;h<c.length;++h)c[h]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(l instanceof _&&o instanceof _){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 h=0;h<c.length;++h)c[h]+=u[h];else if(a==="-=")for(let h=0;h<c.length;++h)c[h]-=u[h];else if(a==="*=")for(let h=0;h<c.length;++h)c[h]*=u[h];else if(a==="/=")for(let h=0;h<c.length;++h)c[h]/=u[h];else if(a==="%=")for(let h=0;h<c.length;++h)c[h]%=u[h];else if(a==="&=")for(let h=0;h<c.length;++h)c[h]&=u[h];else if(a==="|=")for(let h=0;h<c.length;++h)c[h]|=u[h];else if(a==="^=")for(let h=0;h<c.length;++h)c[h]^=u[h];else if(a==="<<=")for(let h=0;h<c.length;++h)c[h]<<=u[h];else if(a===">>=")for(let h=0;h<c.length;++h)c[h]>>=u[h];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(l instanceof S&&o instanceof S))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 Te&&n.setDataValue(this,l,r,i))}if(n instanceof Te)n.setDataValue(this,o,r,i);else if(r){if(!(n instanceof _||n instanceof se))return void console.error(`Variable ${s} is not a vector or matrix. Line ${e.line}`);if(r instanceof pi){const l=this.evalExpression(r.index,i).value;if(n instanceof _){if(!(o instanceof S))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[l]=o.value}else{if(!(n instanceof se))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{const c=this.evalExpression(r.index,i).value;if(c<0)return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(o instanceof _))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 Yt){const l=r.value;if(!(n instanceof _))return void console.error(`Invalid assignment to ${l}
97. Variable ${s} is not a vector. Line ${e.line}`);if(o instanceof S){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 _))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 S&&o instanceof S?n.value=o.value:n instanceof _&&o instanceof _||n instanceof se&&o instanceof se?n.data.set(o.data):console.error(`Invalid assignment to ${s}. Line ${e.line}`)}_function(e,i){const n=new qm(e);i.functions.set(e.name,n)}_const(e,i){let n=null;e.value!==null&&(n=this.evalExpression(e.value,i)),i.createVariable(e.name,n,e)}_override(e,i){const n=i.getVariable(e.name);if(n===null||n.value===null){let s=null;e.value!==null&&(s=this.evalExpression(e.value,i)),i.createVariable(e.name,s,e)}}_let(e,i){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,i),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Re||(n=n.clone())}else{const s=e.type.name;if(He._defaultableTypes.has(s)){const r=new mt(e.type,[]);n=this._evalCreate(r,i)}}i.createVariable(e.name,n,e)}_var(e,i){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,i),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Re||(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(He._defaultableTypes.has(s)||e.type instanceof Ui||e.type instanceof Et||e.type instanceof E){const r=new mt(e.type,[]);n=this._evalCreate(r,i)}if(n===null){const r=this.getTypeInfo(e.type);r!==null&&(n=new Te(new ArrayBuffer(0),r,0))}}i.createVariable(e.name,n,e)}_switch(e,i){i=i.clone();const n=this.evalExpression(e.condition,i);if(!(n instanceof S))return console.error(`Invalid if condition. Line ${e.line}`),null;let s=null;for(const r of e.cases)if(r instanceof ec)for(const o of r.selectors){if(o instanceof Nn){s=r;continue}const a=this.evalExpression(o,i);if(!(a instanceof S))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===n.value)return this._execStatements(r.body,i)}else r instanceof tc&&(s=r);return s?this._execStatements(s.body,i):null}_if(e,i){i=i.clone();const n=this.evalExpression(e.condition,i);if(!(n instanceof S))return console.error(`Invalid if condition. Line ${e.line}`),null;if(n.value)return this._execStatements(e.body,i);for(const s of e.elseif){const r=this.evalExpression(s.condition,i);if(!(r instanceof S))return console.error(`Invalid if condition. Line ${e.line}`),null;if(r.value)return this._execStatements(s.body,i)}return e.else?this._execStatements(e.else,i):null}_getScalarValue(e){return e instanceof S?e.value:(console.error("Expected scalar value.",e),0)}_for(e,i){for(i=i.clone(),this.execStatement(e.init,i);this._getScalarValue(this.evalExpression(e.condition,i));){const n=this._execStatements(e.body,i);if(n===He._breakObj)break;if(n!==null&&n!==He._continueObj)return n;
97this.execStatement(e.increment,i)}return null}_loop(e,i){for(i=i.clone();;){const n=this._execStatements(e.body,i);if(n===He._breakObj)break;if(n===He._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,i)===He._breakObj)break}else if(n!==null)return n}return null}_while(e,i){for(i=i.clone();this._getScalarValue(this.evalExpression(e.condition,i));){const n=this._execStatements(e.body,i);if(n===He._breakObj)break;if(n!==He._continueObj&&n!==null)return n}return null}_evalBitcast(e,i){const n=this.evalExpression(e.value,i),s=e.type;if(n instanceof S){const r=da(n.value,n.typeInfo.name,s.name);return new S(r,this.getTypeInfo(s))}if(n instanceof _){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,h,f){if(h===f)return u;const d=new Array(u.length);for(let T=0;T<u.length;T++)d[T]=da(u[T],h,f);return d})(Array.from(n.data),o,l);return new _(c,this.getTypeInfo(s))}return console.error(`TODO: bitcast for ${n.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,i){return i.getVariableValue(e.name).clone().getSubData(this,e.postfix,i)}_evalCreate(e,i){var n;if(e instanceof mt){if(e.type===null)return rr.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,i);case"atomic<u32>":return new S(0,this.getTypeInfo("u32"));case"atomic<i32>":return new S(0,this.getTypeInfo("i32"));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,i);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,i)}}const s=e instanceof mt?e.type.name:e.name,r=e instanceof mt?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 Te(new ArrayBuffer(r.size),r,0);if(r instanceof Ot){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,i);o.setData(this,u,l.type,l.offset,i)}}else if(r instanceof Ut){let a=0;if(e.args)for(let l=0;l<e.args.length;++l){const c=e.args[l],u=this.evalExpression(c,i);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,i),a+=r.stride}}else console.error(`Unknown type "${s}". Line ${e.line}`);return e instanceof mt?o.getSubData(this,e.postfix,i):o}_evalLiteral(e,i){const n=this.getTypeInfo(e.type),s=n.name;return s==="x32"||s==="u32"||s==="f32"||s==="f16"||s==="i32"||s==="bool"?new S(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,i):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,i):e.value}_evalVariable(e,i){const n=i.getVariableValue(e.name);return n===null?n:n.getSubData(this,e.postfix,i)}_resolveAtomicType(e){return e instanceof Lt&&e.name==="atomic"&&e.format?e.format:e}_maxFormatTypeInfo(e){e=e.map(n=>this._resolveAtomicType(n));let i=e[0];if(i==null)return null;if(i.name==="f32")return i;for(let n=1;n<e.length;++n){const s=He._priority.get(i.name);He._priority.get(e[n].name)<s&&(i=e[n])}return i.name==="x32"?this.getTypeInfo("i32"):i}_evalUnaryOp(e,i){const n=this.evalExpression(e.right,i);if(e.operator==="&")return new ei(n);if(e.operator==="*")return n instanceof ei?n.reference.getSubData(this,e.postfix,i):(console.error(`Invalid dereference. Line ${e.line}`),null);const s=n instanceof S?n.value:n instanceof _?Array.from(n.data):null;switch(e.operator){case"+":{if(X(s)){const a=s.map((l,c)=>+l);return new _(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new S(+r,o)}case"-":{if(X(s)){const a=s.map((l,c)=>-l);return new _(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new S(-r,o)}case"!":{if(X(s)){const a=s.map((l,c)=>l?0:1);return new _(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new S(r?0:1,o)}case"~":{if(X(s)){const a=s.map((l,c)=>~l);return new _(a,n.typeInfo)}const r=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new S(~r,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}
97_isMatrixType(e){return e.typeInfo.getTypeName().startsWith("mat")}_isVectorType(e){return e.typeInfo.getTypeName().startsWith("vec")}_evalBinaryOp(e,i){const n=this.evalExpression(e.left,i),s=this.evalExpression(e.right,i),r=n instanceof S?n.value:n instanceof _||n instanceof se?Array.from(n.data):n instanceof Te?n.toArray():null,o=s instanceof S?s.value:s instanceof _||s instanceof se?Array.from(s.data):s instanceof Te?s.toArray():null;switch(e.operator){case"+":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d+h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f+u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u+f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a+l,c)}case"-":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d-h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f-u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u-f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a-l,c)}case"*":{if(X(r)&&X(o)){const u=r,h=o;if(this._isMatrixType(n)&&this._isMatrixType(s)){const f=(function(w,A,F,b){if(We[A.name]===void 0||We[b.name]===void 0)return null;const g=We[A.name][0],v=We[A.name][1],N=We[b.name][0];if(g!==We[b.name][1])return null;const B=new Array(N*v);for(let W=0;W<v;W++)for(let Y=0;Y<N;Y++){let q=0;for(let ee=0;ee<g;ee++)q+=w[ee*v+W]*F[Y*g+ee];B[W*N+Y]=q}return B})(u,n.typeInfo,h,s.typeInfo);if(f===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const d=We[s.typeInfo.name][0],T=We[n.typeInfo.name][1],C=this.getTypeInfo(`mat${d}x${T}f`);return new se(f,C)}if(this._isMatrixType(n)&&this._isVectorType(s)){const f=(function(d,T,C,w){if(We[T.name]===void 0||Bs[w.name]===void 0)return null;const A=We[T.name][0],F=We[T.name][1];if(A!==C.length)return null;const b=new Array(F);for(let g=0;g<F;g++){let v=0;for(let N=0;N<A;N++)v+=d[N*F+g]*C[N];b[g]=v}return b})(u,n.typeInfo,h,s.typeInfo);return f===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new _(f,s.typeInfo)}if(this._isVectorType(n)&&this._isMatrixType(s)){const f=(function(d,T,C,w){if(Bs[T.name]===void 0||We[w.name]===void 0)return null;const A=We[w.name][0],F=We[w.name][1];if(F!==d.length)return null;const b=[];for(let g=0;g<A;g++){let v=0;for(let N=0;N<F;N++)v+=d[N]*C[N*A+g];b[g]=v}return b})(u,n.typeInfo,h,s.typeInfo);return f===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new _(f,n.typeInfo)}{if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d*h[T]);return new _(f,n.typeInfo)}}if(X(r)){const u=o,h=r.map((f,d)=>f*u);return this._isMatrixType(n)?new se(h,n.typeInfo):new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u*f);return s instanceof se?new se(h,s.typeInfo):new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a*l,c)}case"%":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d%h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f%u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u%f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a%l,c)}case"/":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d/h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f/u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u/f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a/l,c)}case"&":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d&h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f&u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u&f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a&l,c)}case"|":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d|h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f|u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u|f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a|l,c)}case"^":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d^h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f^u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u^f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a^l,c)}case"<<":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d<<h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f<<u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u<<f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a<<l,c)}case">>":{if(X(r)&&X(o)){const u=r,h=o;if(u.length!==h.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const f=u.map((d,T)=>d>>h[T]);return new _(f,n.typeInfo)}if(X(r)){const u=o,h=r.map((f,d)=>f>>u);return new _(h,n.typeInfo)}if(X(o)){const u=r,h=o.map((f,d)=>u>>f);return new _(h,s.typeInfo)}const a=r,l=o,c=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new S(a>>l,c)}case">":if(X(r)&&X(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,h)=>u>l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c>a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a>c?1:0);return new _(l,s.typeInfo)}return new S(r>o?1:0,this.getTypeInfo("bool"));case"<":if(X(r)&&X(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,h)=>u<l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c<a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a<c?1:0);return new _(l,s.typeInfo)}return new S(r<o?1:0,this.getTypeInfo("bool"));case"==":if(X(r)&&X(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,h)=>u===l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c===a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a===c?1:0);return new _(l,s.typeInfo)}return new S(r===o?1:0,this.getTypeInfo("bool"));case"!=":if(X(r)&&X(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,h)=>u!==l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c!==a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a!==c?1:0);return new _(l,s.typeInfo)}return new S(r!==o?1:0,this.getTypeInfo("bool"));case">=":if(X(r)&&X(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,h)=>u>=l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c>=a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a>=c?1:0);return new _(l,s.typeInfo)}return new S(r>=o?1:0,this.getTypeInfo("bool"));case"<=":if(X(r)&&X(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,h)=>u<=l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c<=a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a<=c?1:0);return new _(l,s.typeInfo)}return new S(r<=o?1:0,this.getTypeInfo("bool"));case"&&":if(X(r)&&X(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,h)=>u&&l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c&&a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a&&c?1:0);return new _(l,s.typeInfo)}return new S(r&&o?1:0,this.getTypeInfo("bool"));case"||":if(X(r)&&X(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,h)=>u||l[h]?1:0);return new _(c,n.typeInfo)}if(X(r)){const a=o,l=r.map((c,u)=>c||a?1:0);return new _(l,n.typeInfo)}if(X(o)){const a=r,l=o.map((c,u)=>a||c?1:0);return new _(l,s.typeInfo)}return new S(r||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}
97_evalCall(e,i){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const n=i.clone();n.currentFunctionName=e.name;const s=i.getFunction(e.name);if(!s)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,i):(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,i){switch(e.name){case"all":return this.builtins.All(e,i);case"any":return this.builtins.Any(e,i);case"select":return this.builtins.Select(e,i);case"arrayLength":return this.builtins.ArrayLength(e,i);case"abs":return this.builtins.Abs(e,i);case"acos":return this.builtins.Acos(e,i);case"acosh":return this.builtins.Acosh(e,i);case"asin":return this.builtins.Asin(e,i);case"asinh":return this.builtins.Asinh(e,i);case"atan":return this.builtins.Atan(e,i);case"atanh":return this.builtins.Atanh(e,i);case"atan2":return this.builtins.Atan2(e,i);case"ceil":return this.builtins.Ceil(e,i);case"clamp":return this.builtins.Clamp(e,i);case"cos":return this.builtins.Cos(e,i);case"cosh":return this.builtins.Cosh(e,i);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,i);case"countOneBits":return this.builtins.CountOneBits(e,i);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,i);case"cross":return this.builtins.Cross(e,i);case"degrees":return this.builtins.Degrees(e,i);case"determinant":return this.builtins.Determinant(e,i);case"distance":return this.builtins.Distance(e,i);case"dot":return this.builtins.Dot(e,i);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,i);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,i);case"exp":return this.builtins.Exp(e,i);case"exp2":return this.builtins.Exp2(e,i);case"extractBits":return this.builtins.ExtractBits(e,i);case"faceForward":return this.builtins.FaceForward(e,i);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,i);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,i);case"floor":return this.builtins.Floor(e,i);case"fma":return this.builtins.Fma(e,i);case"fract":return this.builtins.Fract(e,i);case"frexp":return this.builtins.Frexp(e,i);case"insertBits":return this.builtins.InsertBits(e,i);case"inverseSqrt":return this.builtins.InverseSqrt(e,i);case"ldexp":return this.builtins.Ldexp(e,i);case"length":return this.builtins.Length(e,i);case"log":return this.builtins.Log(e,i);case"log2":return this.builtins.Log2(e,i);case"max":return this.builtins.Max(e,i);case"min":return this.builtins.Min(e,i);case"mix":return this.builtins.Mix(e,i);case"modf":return this.builtins.Modf(e,i);case"normalize":return this.builtins.Normalize(e,i);case"pow":return this.builtins.Pow(e,i);case"quantizeToF16":return this.builtins.QuantizeToF16(e,i);case"radians":return this.builtins.Radians(e,i);case"reflect":return this.builtins.Reflect(e,i);case"refract":return this.builtins.Refract(e,i);case"reverseBits":return this.builtins.ReverseBits(e,i);case"round":return this.builtins.Round(e,i);case"saturate":return this.builtins.Saturate(e,i);case"sign":return this.builtins.Sign(e,i);case"sin":return this.builtins.Sin(e,i);case"sinh":return this.builtins.Sinh(e,i);case"smoothstep":return this.builtins.SmoothStep(e,i);case"sqrt":return this.builtins.Sqrt(e,i);case"step":return this.builtins.Step(e,i);case"tan":return this.builtins.Tan(e,i);case"tanh":return this.builtins.Tanh(e,i);case"transpose":return this.builtins.Transpose(e,i);case"trunc":return this.builtins.Trunc(e,i);case"dpdx":return this.builtins.Dpdx(e,i);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,i);case"dpdxFine":return this.builtins.DpdxFine(e,i);case"dpdy":return this.builtins.Dpdy(e,i);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,i);case"dpdyFine":return this.builtins.DpdyFine(e,i);case"fwidth":return this.builtins.Fwidth(e,i);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,i);case"fwidthFine":return this.builtins.FwidthFine(e,i);case"textureDimensions":return this.builtins.TextureDimensions(e,i);case"textureGather":return this.builtins.TextureGather(e,i);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,i);case"textureLoad":return this.builtins.TextureLoad(e,i);case"textureNumLayers":return this.builtins.TextureNumLayers(e,i);case"textureNumLevels":return this.builtins.TextureNumLevels(e,i);case"textureNumSamples":return this.builtins.TextureNumSamples(e,i);case"textureSample":return this.builtins.TextureSample(e,i);case"textureSampleBias":return this.builtins.TextureSampleBias(e,i);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,i);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,i);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,i);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,i);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,i);case"textureStore":return this.builtins.TextureStore(e,i);case"atomicLoad":return this.builtins.AtomicLoad(e,i);case"atomicStore":return this.builtins.AtomicStore(e,i);case"atomicAdd":return this.builtins.AtomicAdd(e,i);case"atomicSub":return this.builtins.AtomicSub(e,i);case"atomicMax":return this.builtins.AtomicMax(e,i);case"atomicMin":return this.builtins.AtomicMin(e,i);case"atomicAnd":return this.builtins.AtomicAnd(e,i);case"atomicOr":return this.builtins.AtomicOr(e,i);case"atomicXor":return this.builtins.AtomicXor(e,i);case"atomicExchange":return this.builtins.AtomicExchange(e,i);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,i);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,i);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,i);case"pack4xI8":return this.builtins.Pack4xI8(e,i);case"pack4xU8":return this.builtins.Pack4xU8(e,i);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,i);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,i);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,i);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,i);case"pack2x16float":return this.builtins.Pack2x16float(e,i);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,i);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,i);case"unpack4xI8":return this.builtins.Unpack4xI8(e,i);case"unpack4xU8":return this.builtins.Unpack4xU8(e,i);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,i);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,i);case"unpack2x16float":return this.builtins.Unpack2x16float(e,i);case"storageBarrier":return this.builtins.StorageBarrier(e,i);case"textureBarrier":return this.builtins.TextureBarrier(e,i);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,i);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,i);case"subgroupAdd":return this.builtins.SubgroupAdd(e,i);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,i);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,i);case"subgroupAll":return this.builtins.SubgroupAll(e,i);case"subgroupAnd":return this.builtins.SubgroupAnd(e,i);case"subgroupAny":return this.builtins.SubgroupAny(e,i);case"subgroupBallot":return this.builtins.SubgroupBallot(e,i);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,i);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,i);case"subgroupElect":return this.builtins.SubgroupElect(e,i);case"subgroupMax":return this.builtins.SubgroupMax(e,i);case"subgroupMin":return this.builtins.SubgroupMin(e,i);case"subgroupMul":return this.builtins.SubgroupMul(e,i);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,i);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,i);
97case"subgroupOr":return this.builtins.SubgroupOr(e,i);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,i);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,i);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,i);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,i);case"subgroupXor":return this.builtins.SubgroupXor(e,i);case"quadBroadcast":return this.builtins.QuadBroadcast(e,i);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,i);case"quadSwapX":return this.builtins.QuadSwapX(e,i);case"quadSwapY":return this.builtins.QuadSwapY(e,i)}const n=i.getFunction(e.name);if(n){const s=i.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,i){if(!e.args||e.args.length===0)return new S(0,this.getTypeInfo(e.type));const n=this.evalExpression(e.args[0],i);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,i).clone()}_callConstructorVec(e,i){const n=this.getTypeInfo(e.type),s=e.type.getTypeName(),r=Bs[s];if(r===void 0)return console.error(`Invalid vec constructor ${s}. Line ${e.line}`),null;const o=[];if(e instanceof Ne)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,i);if(l instanceof _){const c=l.data;for(let u=0;u<c.length;++u){let h=c[u];o.push(h)}}else if(l instanceof S){let c=l.value;o.push(c)}}if(e.type instanceof E&&e.type.format===null&&(e.type.format=E.f32),o.length===0){const a=new Array(r).fill(0);return new _(a,n).getSubData(this,e.postfix,i)}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 _(o.length>r?o.slice(0,r):o,n).getSubData(this,e.postfix,i)}_callConstructorMatrix(e,i){const n=this.getTypeInfo(e.type),s=e.type.getTypeName(),r=We[s];if(r===void 0)return console.error(`Invalid matrix constructor ${s}. Line ${e.line}`),null;const o=[];if(e instanceof Ne)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,i);l instanceof _?o.push(...l.data):l instanceof S?o.push(l.value):l instanceof se&&o.push(...l.data)}if(n instanceof Lt&&n.format===null&&(n.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(r[2]).fill(0);return new se(a,n).getSubData(this,e.postfix,i)}return o.length!==r[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new se(o,n).getSubData(this,e.postfix,i)}};rt._numericScalarTypes=new Set(["f32","i32","u32","bool","f16"]),rt._vectorTypes=new Set(["vec2","vec3","vec4","vec2f","vec3f","vec4f","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2h","vec3h","vec4h","vec2b","vec3b","vec4b"]),rt._matrixTypes=new Set(["mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","mat2x2f","mat2x3f","mat2x4f","mat3x2f","mat3x3f","mat3x4f","mat4x2f","mat4x3f","mat4x4f","mat2x2h","mat2x3h","mat2x4h","mat3x2h","mat3x3h","mat3x4h","mat4x2h","mat4x3h","mat4x4h"]),rt._defaultableTypes=new Set([...rt._numericScalarTypes,...rt._vectorTypes,...rt._matrixTypes,"array"]),rt._breakObj=new ha(new tt("BREAK",null),null),rt._continueObj=new ha(new tt("CONTINUE",null),null),rt._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);let Jm=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},eg=class cc{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new Jm,this._exec=new rt,this._forwardTypeCount=0}static Parse(e){return new cc().parse(e)}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const i=[];for(;!this._isAtEnd();){const n=this._global_decl_or_directive();if(!n)break;i.push(n)}if(this._deferArrayCountEval.length>0){for(const n of this._deferArrayCountEval){const s=n.arrayType,r=n.countNode;if(r instanceof Ye){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 i)n.search(s=>
97{s instanceof ua||s instanceof Pn?s.type=this._forwardType(s.type):s instanceof Ui?s.format=this._forwardType(s.format):s instanceof gt||s instanceof Bi||s instanceof In?s.type=this._forwardType(s.type):s instanceof Wi?s.returnType=this._forwardType(s.returnType):s instanceof ca&&(s.type=this._forwardType(s.type))});return i}_forwardType(e){if(e instanceof la){const i=this._getType(e.name);if(i)return i}else e instanceof Pn?e.type=this._forwardType(e.type):e instanceof Ui&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const i=new sc(e);this._tokens=i.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,i){return e.line=i??this._currentLine,e}_error(e,i){return new Error(`${i}. Line: ${e.line}`)}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type===p.eof}_match(e){if(e instanceof y)return!!this._check(e)&&(this._advance(),!0);for(let i=0,n=e.length;i<n;++i){const s=e[i];if(this._check(s))return this._advance(),!0}return!1}_consume(e,i){if(this._check(e))return this._advance();throw this._error(this._peek(),i)}_check(e){if(this._isAtEnd())return!1;const i=this._peek();if(Array.isArray(e)){const n=i.type;let s=!1;for(const r of e){if(n===r)return!0;r===p.tokens.name&&(s=!0)}if(s){const r=p.tokens.name.rule.exec(i.lexeme);if(r&&r.index===0&&r[0]===i.lexeme)return!0}return!1}if(i.type===e)return!0;if(e===p.tokens.name){const n=p.tokens.name.rule.exec(i.lexeme);return n&&n.index===0&&n[0]===i.lexeme}return!1}_advance(){var e,i;return this._currentLine=(i=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&i!==void 0?i:-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(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.const_assert)){const i=this._global_assert();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([i]),i}if(this._match(p.keywords.alias)){const i=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([i]),i}if(this._match(p.keywords.diagnostic)){const i=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([i]),i}if(this._match(p.keywords.requires)){const i=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([i]),i}if(this._match(p.keywords.enable)){const i=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([i]),i}const e=this._attribute();if(this._check(p.keywords.var)){const i=this._global_variable_decl();return i!=null&&(i.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([i]),i}if(this._check(p.keywords.override)){const i=this._override_variable_decl();return i!=null&&(i.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([i]),i}if(this._check(p.keywords.let)){const i=this._global_let_decl();return i!=null&&(i.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([i]),i}if(this._check(p.keywords.const)){const i=this._global_const_decl();return i!=null&&(i.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([i]),i}if(this._check(p.keywords.struct)){const i=this._struct_decl();return i!=null&&(i.attributes=e),this._exec.reflection.updateAST([i]),i}if(this._check(p.keywords.fn)){const i=this._function_decl();return i!=null&&(i.attributes=e),this._exec.reflection.updateAST([i]),i}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;const e=this._currentLine,i=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");const n=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;const a=this._attribute(),l=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");const c=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=c,n.push(this._updateNode(new ca(l,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let s=null;if(this._match(p.tokens.arrow)){const a=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=a)}
97const r=this._compound_statement(),o=this._currentLine;return this._updateNode(new Wi(i,n,s,r,e,o),e)}_compound_statement(){const e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){const i=this._statement();i!==null&&e.push(i)}return this._consume(p.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._check(p.tokens.attr)&&this._attribute(),this._check(p.keywords.if))return this._if_statement();if(this._check(p.keywords.switch))return this._switch_statement();if(this._check(p.keywords.loop))return this._loop_statement();if(this._check(p.keywords.for))return this._for_statement();if(this._check(p.keywords.while))return this._while_statement();if(this._check(p.keywords.continuing))return this._continuing_statement();if(this._check(p.keywords.static_assert))return this._static_assert_statement();if(this._check(p.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(p.keywords.return))e=this._return_statement();else if(this._check([p.keywords.var,p.keywords.let,p.keywords.const]))e=this._variable_statement();else if(this._match(p.keywords.discard))e=this._updateNode(new Lm);else if(this._match(p.keywords.break)){const i=this._updateNode(new Gl);if(this._currentLoop.length>0){const n=this._currentLoop[this._currentLoop.length-1];i.loopId=n.id}e=i,this._check(p.keywords.if)&&(this._advance(),i.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){const i=this._updateNode(new jl);if(!(this._currentLoop.length>0))throw this._error(this._peek(),"Continue statement must be inside a loop");{const n=this._currentLoop[this._currentLoop.length-1];i.loopId=n.id}e=i}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(p.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(p.keywords.static_assert))return null;const e=this._currentLine,i=this._optional_paren_expression();return this._updateNode(new aa(i),e)}_global_assert(){const e=this._currentLine,i=this._short_circuit_or_expression();return this._updateNode(new aa(i),e)}_while_statement(){if(!this._match(p.keywords.while))return null;const e=this._updateNode(new Ll(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.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(p.keywords.continuing))return null;const i=this._currentLine,n=this._compound_statement();return this._updateNode(new sr(n,e),i)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");const e=this._updateNode(new zl(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(p.tokens.semicolon)?null:this._for_init(),this._consume(p.tokens.semicolon,"Expected ';'."),e.condition=this._check(p.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(p.tokens.semicolon,"Expected ';'."),e.increment=this._check(p.tokens.paren_right)?null:this._for_increment(),this._consume(p.tokens.paren_right,"Expected ')'."),this._check(p.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(p.keywords.var)){const e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let i=null;return this._match(p.tokens.equal)&&(i=this._short_circuit_or_expression()),this._updateNode(new gt(e.name,e.type,e.storage,e.access,i),e.line)}if(this._match(p.keywords.let)){const e=this._currentLine,i=this._consume(p.tokens.name,"Expected name for let.").toString();let n=null;if(this._match(p.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}this._consume(p.tokens.equal,"Expected '=' for let.");const s=this._short_circuit_or_expression();return this._updateNode(new Bi(i,n,null,null,s),e)}if(this._match(p.keywords.const)){const e=this._currentLine,i=this._consume(p.tokens.name,"Expected name for const.").toString();let n=null;if(this._match(p.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}this._consume(p.tokens.equal,"Expected '=' for const.");const s=this._short_circuit_or_expression();return n===null&&s instanceof Ne&&(n=s.type),this._updateNode(new In(i,n,null,null,s),e)}return null}
97_increment_decrement_statement(){const e=this._current,i=this._unary_expression();if(i===null)return null;if(!this._check(p.increment_operators))return this._current=e,null;const n=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new Hl(n.type===p.tokens.plus_plus?oi.increment:oi.decrement,i))}_assignment_statement(){let e=null;const i=this._currentLine;if(this._check(p.tokens.brace_right))return null;let n=this._match(p.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e===null)return null;const s=this._consume(p.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new Vl(Mi.parse(s.lexeme),e,r),i)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;const e=this._currentLine,i=this._current,n=this._consume(p.tokens.ident,"Expected function name."),s=this._argument_expression_list();return s===null?(this._current=i,null):this._updateNode(new Pr(n.lexeme,s),e)}_loop_statement(){if(!this._match(p.keywords.loop))return null;this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Xl([],null));this._currentLoop.push(e);let i=this._statement();for(;i!==null;){if(Array.isArray(i))for(let n of i)e.body.push(n);else e.body.push(i);if(i instanceof sr){e.continuing=i;break}i=this._statement()}return this._currentLoop.pop(),this._consume(p.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(p.keywords.switch))return null;const e=this._updateNode(new Wl(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.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(p.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let i=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){const n=this._case_selectors();for(const r of n)if(r instanceof Nn){if(i)throw this._error(this._previous(),"Multiple default cases in switch statement.");i=!0;break}this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch case.");const s=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new ec(n,s)))}if(this._match(p.keywords.default)){if(i)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch default.");const n=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new tc(n)))}}return e}_case_selectors(){const e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new Nn)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new Nn)):e.push(this._shift_expression());return e}_case_body(){if(this._match(p.keywords.fallthrough))return this._consume(p.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e===null)return[];Array.isArray(e)||(e=[e]);const i=this._case_body();return i.length===0?e:[...e,i[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;const e=this._currentLine,i=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();const n=this._compound_statement();let s=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),s=this._elseif_statement(s));let r=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new $l(i,n,s,r),e)}_match_elseif(){return this._tokens[this._current].type===p.keywords.else&&this._tokens[this._current+1].type===p.keywords.if&&(this._advance(),this._advance(),!0)}
97_elseif_statement(e=[]){const i=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new zm(i,n))),this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(p.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new Yl(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new nt(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(p.tokens.and_and);)e=this._updateNode(new nt(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(p.tokens.or);)e=this._updateNode(new nt(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(p.tokens.xor);)e=this._updateNode(new nt(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(p.tokens.and);)e=this._updateNode(new nt(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([p.tokens.equal_equal,p.tokens.not_equal])?this._updateNode(new nt(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([p.tokens.less_than,p.tokens.greater_than,p.tokens.less_than_equal,p.tokens.greater_than_equal]);)e=this._updateNode(new nt(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([p.tokens.shift_left,p.tokens.shift_right]);)e=this._updateNode(new nt(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([p.tokens.plus,p.tokens.minus]);)e=this._updateNode(new nt(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([p.tokens.star,p.tokens.forward_slash,p.tokens.modulo]);)e=this._updateNode(new nt(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([p.tokens.minus,p.tokens.bang,p.tokens.tilde,p.tokens.star,p.tokens.and])?this._updateNode(new Re(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),i=this._postfix_expression();return i&&(e.postfix=i),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");const i=this._updateNode(new pi(e)),n=this._postfix_expression();return n&&(i.postfix=n),i}if(this._match(p.tokens.period)){const e=this._consume(p.tokens.name,"Expected member name."),i=this._postfix_expression(),n=this._updateNode(new Yt(e.lexeme));return i&&(n.postfix=i),n}return null}_getStruct(e){var i;if(this._context.aliases.has(e)){const n=(i=this._context.aliases.get(e))===null||i===void 0?void 0:i.type;return n??null}if(this._context.structs.has(e)){const n=this._context.structs.get(e);return n??null}return null}_getType(e){const i=this._getStruct(e);if(i!==null)return i;switch(e){case"void":return M.void;case"bool":return M.bool;case"i32":return M.i32;case"u32":return M.u32;case"f32":return M.f32;case"f16":return M.f16;case"vec2f":return E.vec2f;case"vec3f":return E.vec3f;case"vec4f":return E.vec4f;case"vec2i":return E.vec2i;case"vec3i":return E.vec3i;case"vec4i":return E.vec4i;case"vec2u":return E.vec2u;case"vec3u":return E.vec3u;case"vec4u":return E.vec4u;case"vec2h":return E.vec2h;case"vec3h":return E.vec3h;case"vec4h":return E.vec4h;case"mat2x2f":return E.mat2x2f;case"mat2x3f":return E.mat2x3f;case"mat2x4f":return E.mat2x4f;case"mat3x2f":return E.mat3x2f;case"mat3x3f":return E.mat3x3f;case"mat3x4f":return E.mat3x4f;
97case"mat4x2f":return E.mat4x2f;case"mat4x3f":return E.mat4x3f;case"mat4x4f":return E.mat4x4f;case"mat2x2h":return E.mat2x2h;case"mat2x3h":return E.mat2x3h;case"mat2x4h":return E.mat2x4h;case"mat3x2h":return E.mat3x2h;case"mat3x3h":return E.mat3x3h;case"mat3x4h":return E.mat3x4h;case"mat4x2h":return E.mat4x2h;case"mat4x3h":return E.mat4x3h;case"mat4x4h":return E.mat4x4h;case"mat2x2i":return E.mat2x2i;case"mat2x3i":return E.mat2x3i;case"mat2x4i":return E.mat2x4i;case"mat3x2i":return E.mat3x2i;case"mat3x3i":return E.mat3x3i;case"mat3x4i":return E.mat3x4i;case"mat4x2i":return E.mat4x2i;case"mat4x3i":return E.mat4x3i;case"mat4x4i":return E.mat4x4i;case"mat2x2u":return E.mat2x2u;case"mat2x3u":return E.mat2x3u;case"mat2x4u":return E.mat2x4u;case"mat3x2u":return E.mat3x2u;case"mat3x3u":return E.mat3x3u;case"mat3x4u":return E.mat3x4u;case"mat4x2u":return E.mat4x2u;case"mat4x3u":return E.mat4x3u;case"mat4x4u":return E.mat4x4u}return null}_validateTypeRange(e,i){if(i.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}`)}else if(i.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}`)}_primary_expression(){if(this._match(p.tokens.ident)){const n=this._previous().toString();if(this._check(p.tokens.paren_left)){const s=this._argument_expression_list(),r=this._getType(n);return r!==null?this._updateNode(new mt(r,s)):this._updateNode(new li(n,s))}if(this._context.constants.has(n)){const s=this._context.constants.get(n);if(s)return this._updateNode(new ql(n,s.value))}return this._updateNode(new Ye(n))}if(this._match(p.tokens.int_literal)){const n=this._previous().toString();let s=n.endsWith("i")||n.endsWith("i")?M.i32:n.endsWith("u")||n.endsWith("U")?M.u32:M.x32;const r=parseInt(n);return this._validateTypeRange(r,s),this._updateNode(new Ne(new S(r,this._exec.getTypeInfo(s)),s))}if(this._match(p.tokens.uint_literal)){const n=parseInt(this._previous().toString());return this._validateTypeRange(n,M.u32),this._updateNode(new Ne(new S(n,this._exec.getTypeInfo(M.u32)),M.u32))}if(this._match([p.tokens.decimal_float_literal,p.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?M.f16:M.f32);const o=s?M.f16:M.f32;return this._updateNode(new Ne(new S(r,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let n=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new Ne(new S(n?1:0,this._exec.getTypeInfo(M.bool)),M.bool))}if(this._check(p.tokens.paren_left))return this._paren_expression();if(this._match(p.keywords.bitcast)){this._consume(p.tokens.less_than,"Expected '<'.");const n=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");const s=this._paren_expression();return this._updateNode(new Zl(n,s))}const e=this._type_decl(),i=this._argument_expression_list();return this._updateNode(new mt(e,i))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;const e=[];do{if(this._check(p.tokens.paren_right))break;const i=this._short_circuit_or_expression();e.push(i)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for argument list"),e}_optional_paren_expression(){let e=this._match(p.tokens.paren_left);const i=this._short_circuit_or_expression();return i.hasParen=e,e&&this._consume(p.tokens.paren_right,"Expected ')'."),i}_paren_expression(){this._consume(p.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(p.tokens.paren_right,"Expected ')'."),e.hasParen=!0,e}_struct_decl(){if(!this._match(p.keywords.struct))return null;const e=this._currentLine,i=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(p.tokens.brace_right);){const o=this._attribute(),a=this._consume(p.tokens.name,"Expected variable name.").toString();this._consume(p.tokens.colon,"Expected ':' for struct member type.");const l=this._attribute(),c=this._type_decl();c!=null&&(c.attributes=l),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new ua(a,c,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");const s=this._currentLine,r=this._updateNode(new Et(i,n,e,s),e);return this._context.structs.set(i,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){const i=this._const_expression();e.value=i}if(e.type!==null&&e.value instanceof Ne){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}`);
97e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof Ne&&(e.type=e.value.type.name==="x32"?M.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(p.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(p.keywords.const))return null;const i=this._consume(p.tokens.name,"Expected variable name"),n=this._currentLine;let s=null;if(this._match(p.tokens.colon)){const l=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=l)}let r=null;this._consume(p.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let l=[M.f32],c=o.constEvaluate(this._exec,l);c instanceof S&&this._validateTypeRange(c.value,l[0]),l[0]instanceof E&&l[0].format===null&&c.typeInfo instanceof Lt&&c.typeInfo.format!==null&&(c.typeInfo.format.name==="f16"?l[0].format=M.f16:c.typeInfo.format.name==="f32"?l[0].format=M.f32:c.typeInfo.format.name==="i32"?l[0].format=M.i32:c.typeInfo.format.name==="u32"?l[0].format=M.u32:c.typeInfo.format.name==="bool"?l[0].format=M.bool:console.error(`TODO: implement template format type ${c.typeInfo.format.name}`)),r=this._updateNode(new Ne(c,l[0])),this._exec.context.setVariable(i.toString(),c)}catch{r=o}if(s!==null&&r instanceof Ne){if(r.type.name!=="x32"&&s.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.n
97ame} to ${s.name}`);r.type=s,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else s===null&&r instanceof Ne&&(s=(e=r?.type)!==null&&e!==void 0?e:M.f32,s===M.x32&&(s=M.i32));const a=this._updateNode(new In(i.toString(),s,"","",r),n);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;const e=this._currentLine,i=this._consume(p.tokens.name,"Expected variable name");let n=null;if(this._match(p.tokens.colon)){const r=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=r)}let s=null;if(this._match(p.tokens.equal)&&(s=this._const_expression()),n!==null&&s instanceof Ne){if(s.type.name!=="x32"&&n.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${n.name}`);s.type=n}else n===null&&s instanceof Ne&&(n=s.type.name==="x32"?M.i32:s.type);return s instanceof Ne&&s.isScalar&&this._validateTypeRange(s.scalarValue,n),this._updateNode(new Bi(i.toString(),n,"","",s),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;const e=this._currentLine;let i="",n="";this._match(p.tokens.less_than)&&(i=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(n=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));const s=this._consume(p.tokens.name,"Expected variable name");let r=null;if(this._match(p.tokens.colon)){const o=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=o)}return this._updateNode(new gt(s.toString(),r,i,n,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;const e=this._consume(p.tokens.name,"Expected variable name");let i=null;if(this._match(p.tokens.colon)){const n=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=n)}return this._updateNode(new Ir(e.toString(),i,null))}_diagnostic(){this._consume(p.tokens.paren_left,"Expected '('");const e=this._consume(p.tokens.ident,"Expected severity control name.");this._consume(p.tokens.comma,"Expected ','");let i=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(i+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new Kl(e.toString(),i))}_enable_directive(){const e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new Bm(e.toString()))}_requires_directive(){const e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){const i=this._consume(p.tokens.ident,"identity expected.");e.push(i.toString())}return this._updateNode(new Um(e))}_type_alias(){const e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let i=this._type_decl();if(i===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);const n=this._updateNode(new wr(e.toString(),i));return this._context.aliases.set(n.name,n),n}_type_decl(){var e,i,n;if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){const o=this._advance().toString();if(this._context.structs.has(o))return(e=this._context.structs.get(o))!==null&&e!==void 0?e:null;if(this._context.aliases.has(o))return(n=(i=this._context.aliases.get(o))===null||i===void 0?void 0:i.type)!==null&&n!==void 0?n:null;if(!this._getType(o)){const a=this._updateNode(new la(o));return this._forwardTypeCount++,a}return this._updateNode(new M(o))}let s=this._texture_sampler_types();if(s)return s;if(this._check(p.template_types)){let o=this._advance().toString(),a=null,l=null;return this._match(p.tokens.less_than)&&(a=this._type_decl(),l=null,this._match(p.tokens.comma)&&(l=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new E(o,a,l))}if(this._match(p.keywords.ptr)){let o=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");const a=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");const l=this._type_decl();let c=null;return this._match(p.tokens.comma)&&(c=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new Pn(o,a.toString(),l,c))}const r=this._attribute();if(this._match(p.keywords.array)){let o=null,a=-1;const l=this._previous();let c=null;if(this._match(p.tokens.less_than)){o=this._type_decl(),this._context.aliases.has(o.name)&&(o=this._context.aliases.get(o.name).type);let h="";if(this._match(p.tokens.comma)){c=this._shift_expression();try{h=c.constEvaluate(this._exec).toString(),c=null}catch{h="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),a=h?parseInt(h):0}const u=this._updateNode(new Ui(l.toString(),r,o,a));return c&&this._deferArrayCountEval.push({arrayType:u,countNode:c}),u}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new ki(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new ki(this._previous().toString(),null,null));if(this._match(p.sampled_texture_type)||this._match(p.multisampled_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const i=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new ki(e.toString(),i,null))}if(this._match(p.storage_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const i=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");const n=this._consume(p.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new ki(e.toString(),i,n))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){const i=this._consume(p.attribute_name,"Expected attribute name"),n=this._updateNode(new ic(i.toString(),null));if(this._match(p.tokens.paren_left)){if(n.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{const s=this._consume(p.literal_or_ident,"Expected attribute value").toString();Array.isArray(n.value)||(n.value=[n.value]),n.value.push(s)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(n)}return e.length===0?null:e}},tg=class extends Li{constructor(e){super(),e!==void 0&&this.update(e)}update(e){const i=new eg().parse(e);this.updateAST(i)}};var pa;(t=>{t[t.Running=0]="Running",t[t.AtBarrier=1]="AtBarrier",t[t.Done=2]="Done"})(pa||(pa={}));function ig(t){const e={attributes:[],bindings:[]};let i;try{i=ng(t)}
97catch(r){return V.error(r.message)(),e}for(const r of i.uniforms){const o=[];for(const a of r.type?.members||[])o.push({name:a.name,type:_a(a.type)});e.bindings.push({type:"uniform",name:r.name,group:r.group,location:r.binding,members:o})}for(const r of i.textures)e.bindings.push({type:"texture",name:r.name,group:r.group,location:r.binding});for(const r of i.samplers)e.bindings.push({type:"sampler",name:r.name,group:r.group,location:r.binding});const n=i.entry.vertex[0],s=n?.inputs.length||0;for(let r=0;r<s;r++){const o=n.inputs[r];if(o.locationType==="location"){const a=_a(o.type);e.attributes.push({name:o.name,location:Number(o.location),type:a})}}return e}function _a(t){return t?.format?`${t.name}<${t.format.name}>`:t.name}function ng(t){try{return new tg(t)}catch(e){if(e instanceof Error)throw e;let i="WGSL parse error";throw typeof e=="object"&&e?.message&&(i+=`: ${e.message} `),typeof e=="object"&&e?.token&&(i+=e.token.line||""),new Error(i,{cause:e})}}const Us={};function is(t="id"){Us[t]=Us[t]||1;const e=Us[t]++;return`${t}-${e}`}class ma{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||is("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&G.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function sg(t,e){if(e instanceof ma)return e;const i=rg(t,e),{attributes:n,bufferLayout:s}=og(t,e);return new ma({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:i,attributes:n})}function rg(t,e){if(!e.indices)return;const i=e.indices.value;return t.createBuffer({usage:G.INDEX,data:i})}function og(t,e){const i=[],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]=t.createBuffer({data:o.value,id:`${r}-buffer`});const{value:l,size:c,normalized:u}=o;i.push({name:a,format:wd(l,c,u)})}}const s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:i,vertexCount:s}}class Mr{static defaultProps={...ai.defaultProps};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Mr(e),e._lumaData.defaultPipelineFactory}device;cachingEnabled;destroyPolicy;debug;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}createRenderPipeline(e){if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const i={...ai.defaultProps,...e},n=this._renderPipelineCache,s=this._hashRenderPipeline(i);let r=n[s]?.pipeline;return r?(n[s].useCount++,this.debug&&V.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(r=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:is("unnamed-cached")}),r.hash=s,n[s]={pipeline:r,useCount:1},this.debug&&V.log(3,`${this}: ${r} created, count=${n[s].useCount}`)()),r}createComputePipeline(e){if(!this.cachingEnabled)return this.device.createComputePipeline(e);const i={...Hn.defaultProps,...e},n=this._computePipelineCache,s=this._hashComputePipeline(i);let r=n[s]?.pipeline;return r?(n[s].useCount++,this.debug&&V.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(r=this.device.createComputePipeline({...i,id:i.id?`${i.id}-cached`:void 0}),r.hash=s,n[s]={pipeline:r,useCount:1},this.debug&&V.log(3,`${this}: ${r} created, count=${n[s].useCount}`)()),r}release(e){if(!this.cachingEnabled){e.destroy();return}const i=this._getCache(e),n=e.hash;i[n].useCount--,i[n].useCount===0?(this._destroyPipeline(e),this.debug&&V.log(3,`${this}: ${e} released and destroyed`)()):i[n].useCount<0?(V.error(`${this}: ${e} released, useCount < 0, resetting`)(),i[n].useCount=0):this.debug&&V.log(3,`${this}: ${e} released, count=${i[n].useCount}`)()}_destroyPipeline(e){const i=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete i[e.hash],e.destroy(),!0}}_getCache(e){let i;if(e instanceof Hn&&(i=this._computePipelineCache),e instanceof ai&&(i=this._renderPipelineCache),!i)throw new Error(`${this}`);
97if(!i[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return i}_hashComputePipeline(e){const{type:i}=this.device,n=this._getHash(e.shader.source);return`${i}/C/${n}`}_hashRenderPipeline(e){const i=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/${i}/${n}V${s}BL${r}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${i}/${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]}}class kr{static defaultProps={...vr.defaultProps};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new kr(e),e._lumaData.defaultShaderFactory}device;cachingEnabled;destroyPolicy;debug;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const i=this._hashShader(e);let n=this._cache[i];if(n)n.useCount++,this.debug&&V.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[i]=n={shader:s,useCount:1},this.debug&&V.log(3,`${this}: Created new shader ${s.id}`)()}return n.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const i=this._hashShader(e),n=this._cache[i];if(n)if(n.useCount--,n.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[i],n.shader.destroy(),this.debug&&V.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&&V.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}function ag(t,e){const i={},n="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(const s of t.attributes)if(s){const r=`${s.location} ${s.name}: ${s.type}`;i[`in ${r}`]={[n]:s.stepMode||"vertex"}}for(const s of t.varyings||[]){const r=`${s.location} ${s.name}`;i[`out ${r}`]={[n]:JSON.stringify(s)}}return i}let Fe=null,Ls=null;
97function lg(t,{id:e,minimap:i,opaque:n,top:s="0",left:r="0",rgbaScale:o=1}){Fe||(Fe=document.createElement("canvas"),Fe.id=e,Fe.title=e,Fe.style.zIndex="100",Fe.style.position="absolute",Fe.style.top=s,Fe.style.left=r,Fe.style.border="blue 5px solid",Fe.style.transform="scaleY(-1)",document.body.appendChild(Fe),Ls=Fe.getContext("2d")),(Fe.width!==t.width||Fe.height!==t.height)&&(Fe.width=t.width/2,Fe.height=t.height/2,Fe.style.width="400px",Fe.style.height="400px");const a=t.device.readPixelsToArrayWebGL(t),l=Ls?.createImageData(t.width,t.height);if(l){for(let u=0;u<a.length;u+=4)l.data[0+u+0]=a[u+0]*o,l.data[0+u+1]=a[u+1]*o,l.data[0+u+2]=a[u+2]*o,l.data[0+u+3]=n?255:a[u+3]*o;Ls?.putImageData(l,0,0)}}function or(t,e,i){if(t===e)return!0;if(!i||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!or(t[n],e[n],i-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const r of n)if(!e.hasOwnProperty(r)||!or(t[r],e[r],i-1))return!1;return!0}return!1}class zs{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(i=>i.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(i=>i.attribute):[e.name]}mergeBufferLayouts(e,i){const n=[...e];for(const s of i){const r=n.findIndex(o=>o.name===s.name);r<0?n.push(s):n[r]=s}return n}getBufferIndex(e){const i=this.bufferLayouts.findIndex(n=>n.name===e);return i===-1&&V.warn(`BufferLayout: Missing buffer for "${e}".`)(),i}}function cg(t,e){const i=Object.fromEntries(t.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=>i[u])),c=Math.min(...a.map(u=>i[u]));return l-c}),n}function ug(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function hg(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function fg(t){return ug(t)||hg(t)}function dg(t){return fg(t)||typeof t=="number"||typeof t=="boolean"}function pg(t){const e={bindings:{},uniforms:{}};return Object.keys(t).forEach(i=>{const n=t[i];dg(n)?e.uniforms[i]=n:e.bindings[i]=n}),e}class _g{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,i){Object.assign(this.options,i);const n=Cr(Object.values(e).filter(s=>s.dependencies));for(const s of n)e[s.name]=s;V.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&&V.warn(`Module name: ${s} vs ${r.name}`)()}destroy(){}setProps(e){for(const i of Object.keys(e)){const n=i,s=e[n]||{},r=this.modules[n];if(!r){this.options.disableWarnings||V.warn(`Module ${i} not found`)();continue}const o=this.moduleUniforms[n],a=this.moduleBindings[n],l=r.getUniforms?.(s,o)||s,{uniforms:c,bindings:u}=pg(l);this.moduleUniforms[n]={...o,...c},this.moduleBindings[n]={...a,...u}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const i of Object.values(this.moduleBindings))Object.assign(e,i);return e}getDebugTable(){const e={};for(const[i,n]of Object.entries(this.moduleUniforms))for(const[s,r]of Object.entries(n))e[`${i}.${s}`]={type:this.modules[i].uniformTypes?.[s],value:String(r)};return e}_addModule(e){const i=e.name;this.moduleUniforms[i]=e.defaultUniforms||{},this.moduleBindings[i]={}}}let mg="";async function gg(t,e){const i=new Image;return i.crossOrigin="anonymous",i.src=t.startsWith("http")?t:mg+t,await i.decode(),e?await createImageBitmap(i,e):await createImageBitmap(i)}const Tg=["+X","-X","+Y","-Y","+Z","-Z"],Sg=["+X","-X","+Y","-Y","+Z","-Z"];class zi{device;id;props;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(e,i){this.device=e;const n=is("async-texture");this.props={...zi.defaultProps,id:n,...i},this.id=this.props.id,i={...i}
97,typeof i?.data=="string"&&i.dimension==="2d"&&(i.data=gg(i.data)),i.mipmaps&&(i.mipLevels="auto"),this.ready=new Promise((s,r)=>{this.resolveReady=()=>{this.isReady=!0,s()},this.rejectReady=r}),this.initAsync(i)}async initAsync(e){const i=e.data,n=await uc(i).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(),V.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 di?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 i=this.texture;this.texture=i.clone(e),i.destroy()}return!0}isTextureLevelData(e){const i=e?.data;return ArrayBuffer.isView(i)}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 n=Object.values(e)[0];return{width:n.width,height:n.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,i){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,i=0){if(!this.texture)throw new Error("Texture not initialized");const n=this._normalizeTextureData(e);n.length>1&&this.props.mipmaps!==!1&&V.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:i,mipLevel:s,flipY:!0}):this.texture.copyImageData({data:r.data,mipLevel:s})}}_setTexture3DData(e,i){if(this.texture?.props.dimension!=="3d")throw new Error(this.id);for(let n=0;n<i.length;n++)this._setTexture2DData(i[n],n)}_setTextureCubeData(e,i){if(this.texture?.props.dimension!=="cube")throw new Error(this.id);for(const[n,s]of Object.entries(i)){const r=Sg.indexOf(n);this._setTexture2DData(s,r)}}_setTextureArrayData(e,i){if(this.texture?.props.dimension!=="2d-array")throw new Error(this.id);for(let n=0;n<i.length;n++)this._setTexture2DData(i[n],n)}_setTextureCubeArrayData(e,i){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,i,n,s=0){Array.isArray(i)&&i.length>1&&this.props.mipmaps!==!1&&V.warn(`${this.id} has mipmap and multiple LODs.`)();const r=Tg.indexOf(n);this._setTexture2DData(i,r)}_normalizeTextureData(e){const i=this.texture;let n;return ArrayBuffer.isView(e)?n=[{data:e,width:i.width,height:i.height}]:Array.isArray(e)?n=e:n=[e],n}static defaultProps={...j.defaultProps,data:null,mipmaps:!1}}async function uc(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(uc));if(t&&typeof t=="object"&&t.constructor===Object){const e=t,i=await Promise.all(Object.values(e)),n=Object.keys(e),s={};for(let r=0;r<n.length;r++)s[n[r]]=i[r];return s}return t}const Xt=2,xg=1e4;class ge{static defaultProps={...ai.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:ri.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,i){this.props={...ge.defaultProps,...i},i=this.props,this.id=i.id||is("model"),this.device=e,Object.assign(this.userData,i.userData);const n=Object.fromEntries(this.props.modules?.map(l=>[l.name,l])||[]),s=i.shaderInputs||new _g(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);const r=vg(e),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:l,getUniforms:c}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:r,...this.props,modules:o});this.source=l,this._getModuleUniforms=c,this.props.shaderLayout||=ig(this.source)}else{const{vs:l,fs:c,getUniforms:u}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:r,...this.props,modules:o});this.vs=l,this.fs=c,this._getModuleUniforms=u}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,i.geometry&&this.setGeometry(i.geometry),this.pipelineFactory=i.pipelineFactory||Mr.getDefaultPipelineFactory(this.device),this.shaderFactory=i.shaderFactory||kr.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 i&&(this.isInstanced=i.isInstanced),i.instanceCount&&this.setInstanceCount(i.instanceCount),i.vertexCount&&this.setVertexCount(i.vertexCount),i.indexBuffer&&this.setIndexBuffer(i.indexBuffer),i.attributes&&this.setAttributes(i.attributes),i.constantAttributes&&this.setConstantAttributes(i.constantAttributes),i.bindings&&this.setBindings(i.bindings),i.transformFeedback&&(this.transformFeedback=i.transformFeedback),Object.seal(this)}destroy(){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(),this._gpuGeometry?.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||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const i=this._areBindingsLoading();if(i)return V.info(Xt,`>>> DRAWING ABORTED ${this.id}: ${i} 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){this._gpuGeometry?.destroy();const i=e&&sg(this.device,e);if(i){this.setTopology(i.topology||"triangle-list");const n=new zs(this.bufferLayout);this.bufferLayout=n.mergeBufferLayouts(i.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i)}this._gpuGeometry=i}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const i=new zs(this.bufferLayout);this.bufferLayout=this._gpuGeometry?i.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){or(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 Se(this.shaderInputs.modules);for(const[i,n]of Object.entries(this.shaderInputs.modules))if(yg(n)){const s=this._uniformStore.getManagedUniformBuffer(this.device,i);this.bindings[`${i}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,i){const n=i?.disableWarnings??this.props.disableWarnings;e.indices&&V.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=cg(this.pipeline.shaderLayout,this.bufferLayout);const s=new zs(this.bufferLayout);for(const[r,o]of Object.entries(e)){const a=s.getBufferLayout(r);if(!a){n||V.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const l=s.getAttributeNamesForBuffer(a);let c=!1;for(const u of l){const h=this._attributeInfos[u];if(h){const f=this.device.type==="webgpu"?s.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(f,o),c=!0}}!c&&!n&&V.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,i){for(const[n,s]of Object.entries(e)){const r=this._attributeInfos[n];r?this.vertexArray.setConstantWebGL(r.location,s):(i?.disableWarnings??this.props.disableWarnings)||V.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 zi&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[i,n]of Object.entries(this.bindings))n instanceof zi?n.isReady&&(e[i]=n.texture):e[i]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(const i of Object.values(this.bindings))i instanceof yr?e=Math.max(e,i.texture.updateTimestamp):i instanceof G||i instanceof j?e=Math.max(e,i.updateTimestamp):i instanceof zi?e=i.texture?Math.max(e,i.texture.updateTimestamp):1/0:i instanceof di||(e=Math.max(e,i.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const i={...e.attributes};for(const[n]of Object.entries(i))!this.pipeline.shaderLayout.attributes.find(s=>s.name===n)&&n!=="positions"&&delete i[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(i,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,i=null;this.pipeline&&(V.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,i=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=Tl(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),i&&this.shaderFactory.release(i)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=V.level>3?0:xg;
97V.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,V.group(Xt,`>>> DRAWING MODEL ${this.id}`,{collapsed:V.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=ag(this.pipeline.shaderLayout,this.id);V.table(Xt,e)();const i=this.shaderInputs.getDebugTable();V.table(Xt,i)();const n=this._getAttributeDebugTable();V.table(Xt,this._attributeInfos)(),V.table(Xt,n)(),V.groupEnd(Xt)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const i=this.device.props.debugFramebuffers;if(this._drawCount++,!i)return;const n=e.props.framebuffer;n&&lg(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[i,n]of Object.entries(this._attributeInfos)){const s=this.vertexArray.attributes[n.location];e[n.location]={name:i,type:n.shaderType,values:s?this._getBufferOrConstantValues(s,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:i}=this.vertexArray,n=i.indexType==="uint32"?new Uint32Array(i.debugData):new Uint16Array(i.debugData);e.indices={name:"indices",type:i.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,i){const n=Id(i);return(e instanceof G?new n(e.debugData):e).toString()}}function yg(t){return!!(t.uniformTypes&&!Eg(t.uniformTypes))}function vg(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function Eg(t){for(const e in t)return!1;return!0}var Ag=`<div class="gl-box"> 98 <svg viewBox="0 0 55 60"> 99 <text x="27" y="56" class="gl-fps">00 FPS</text> 100 <text x="28" y="8" class="gl-mem"></text> 101 <rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect> 102 <polyline class="gl-chart"></polyline> 103 </svg> 104 <svg viewBox="0 0 14 60" class="gl-cpu-svg"> 105 <line x1="7" y1="38" x2="7" y2="11" class="opacity"/> 106 <line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/> 107 <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"/> 108 </svg> 109 <svg viewBox="0 0 14 60" class="gl-gpu-svg"> 110 <line x1="7" y1="38" x2="7" y2="11" class="opacity"/> 111 <line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/> 112 <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"/> 113 </svg> 114</div>`,Rg=`#gl-bench { 115 position:absolute; 116 left:0; 117 top:0; 118 z-index:1000; 119 -webkit-user-select: none; 120 -moz-user-select: none; 121 user-select: none; 122} 123 124#gl-bench div { 125 position: relative; 126 display: block; 127 margin: 4px; 128 padding: 0 7px 0 10px; 129 background: #6c6; 130 border-radius: 15px; 131 cursor: pointer; 132 opacity: 0.9; 133} 134 135#gl-bench svg { 136 height: 60px; 137 margin: 0 -1px; 138} 139 140#gl-bench text { 141 font-size: 12px; 142 font-family: Helvetica,Arial,sans-serif; 143 font-weight: 700; 144 dominant-baseline: middle; 145 text-anchor: middle; 146} 147 148#gl-bench .gl-mem { 149 font-size: 9px; 150} 151 152#gl-bench line { 153 stroke-width: 5; 154 stroke: #112211; 155 stroke-linecap: round; 156} 157 158#gl-bench polyline { 159 fill: none; 160 stroke: #112211; 161 stroke-linecap: round; 162 stroke-linejoin: round; 163 stroke-width: 3.5; 164} 165 166#gl-bench rect { 167 fill: #448844; 168} 169 170#gl-bench .opacity { 171 stroke: #448844; 172} 173`;class Cg{constructor(e,i={}){this.css=Rg,this.svg=Ag,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuA
173ccums=[],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"],a=>{a.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,i),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let n,s=0,r,o=a=>{++s<20?n=requestAnimationFrame(o):(this.detected=Math.ceil(1e3*s/(a-r)/70),cancelAnimationFrame(n)),r||(r=a)};if(requestAnimationFrame(o),e){const a=async(c,u)=>Promise.resolve(setTimeout(()=>{e.getError();const h=this.now()-c;u.forEach((f,d)=>{f&&(this.gpuAccums[d]+=h)})},0)),l=(c,u,h)=>function(){const f=u.now();c.apply(h,arguments),u.trackGPU&&u.finished.push(a(f,u.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(c=>{e[c]&&(e[c]=l(e[c],this,e))}),e.getExtension=((c,u)=>function(){let h=c.apply(e,arguments);return h&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(f=>{h[f]&&(h[f]=l(h[f],u,h))}),h})(e.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let a=document.createElement("div");a.id="gl-bench",this.dom.appendChild(a),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=a,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((l,c,u)=>{const h=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],f=Object.assign({},h);return h.forEach(d=>f[d]=c.getElementsByClassName(d)),this.nodes=f,(d,T,C,w,A,F,b)=>{f["gl-cpu"][d].style.strokeDasharray=(T*.27).toFixed(0)+" 100",f["gl-gpu"][d].style.strokeDasharray=(C*.27).toFixed(0)+" 100",f["gl-mem"][d].innerHTML=u[d]?u[d]:w?"mem: "+w.toFixed(0)+"mb":"",f["gl-fps"][d].innerHTML=A.toFixed(0)+" FPS",l(u[d],T,C,w,A,F,b)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((l,c)=>{let u={"gl-chart":c.getElementsByClassName("gl-chart")};return(h,f,d)=>{let T="",C=f.length;for(let w=0;w<C;w++){let A=(d+w+1)%C;f[A]!=null&&(T=T+" "+(55*w/(C-1)).toFixed(1)+","+(45-f[A]*22/60/this.detected).toFixed(1))}u["gl-chart"][h].setAttribute("points",T),l(this.names[h],f,d)}})(this.chartLogger,this.dom)}}addUI(e){this.names.indexOf(e)==-1&&(this.names.push(e),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(e){this.frameId++;const i=e||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=i;else{let n=i-this.paramTime;if(n>=1e3){const s=this.frameId-this.paramFrame,r=s/n*1e3;for(let o=0;o<this.names.length;o++){const a=this.cpuAccums[o]/n*100,l=this.gpuAccums[o]/n*100,c=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(o,a,l,c,r,n,s),this.cpuAccums[o]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[o]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=i}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=i,this.circularId=0;else{let n=i-this.chartTime,s=this.chartHz*n/1e3;for(;--s>0&&this.detected;){const o=(this.frameId-this.chartFrame)/n*1e3;this.chart[this.circularId%this.chartLen]=o;for(let a=0;a<this.names.length;a++)this.chartLogger(a,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=i}}}begin(e){this.updateAccums(e)}end(e){this.updateAccums(e)}updateAccums(e){let i=this.names.indexOf(e);i==-1&&(i=this.names.length,this.addUI(e));const n=this.now(),s=n-this.t0;for(let r=0;r<i+1;r++)this.activeAccums[r]&&(this.cpuAccums[r]+=s);this.activeAccums[i]=!this.activeAccums[i],this.t0=n}}const bg={passive:!1},$i={capture:!0,passive:!1};function Hs(t){t.stopImmediatePropagation()}function ci(t){t.preventDefault(),t.stopImmediatePropagation()}function hc(t){var e=t.document.documentElement,i=Me(t).on("dragstart.drag",ci,$i);"onselectstart"in e?i.on("selectstart.drag",ci,$i):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function fc(t,e){var i=t.document.documentElement,n=Me(t).on("dragstart.drag",null);e&&(n.on("click.drag",ci,$i),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in i?n.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const fn=t=>()=>t;function ar(t,{sourceEvent:e,subject:i,target:n,identifier:s,active:r,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:i,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}})}ar.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Ig(t){return!t.ctrlKey&&!t.button}function Pg(){return this.parentNode}function wg(t,e){return e??{x:t.x,y:t.y}}function Ng(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mg(){var t=Ig,e=Pg,i=wg,n=Ng,s={},r=Qn("start","drag","end"),o=0,a,l,c,u,h=0;function f(g){g.on("mousedown.drag",d).filter(n).on("touchstart.drag",w
vendor: 11,324 bytes, line 173
173).on("touchmove.drag",A,bg).on("touchend.drag touchcancel.drag",F).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(g,v){if(!(u||!t.call(this,g,v))){var N=b(this,e.call(this,g,v),g,v,"mouse");N&&(Me(g.view).on("mousemove.drag",T,$i).on("mouseup.drag",C,$i),hc(g.view),Hs(g),c=!1,a=g.clientX,l=g.clientY,N("start",g))}}function T(g){if(ci(g),!c){var v=g.clientX-a,N=g.clientY-l;c=v*v+N*N>h}s.mouse("drag",g)}function C(g){Me(g.view).on("mousemove.drag mouseup.drag",null),fc(g.view,c),ci(g),s.mouse("end",g)}function w(g,v){if(t.call(this,g,v)){var N=g.changedTouches,B=e.call(this,g,v),W=N.length,Y,q;for(Y=0;Y<W;++Y)(q=b(this,B,g,v,N[Y].identifier,N[Y]))&&(Hs(g),q("start",g,N[Y]))}}function A(g){var v=g.changedTouches,N=v.length,B,W;for(B=0;B<N;++B)(W=s[v[B].identifier])&&(ci(g),W("drag",g,v[B]))}function F(g){var v=g.changedTouches,N=v.length,B,W;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),B=0;B<N;++B)(W=s[v[B].identifier])&&(Hs(g),W("end",g,v[B]))}function b(g,v,N,B,W,Y){var q=r.copy(),ee=vt(Y||N,v),ne,re,I;if((I=i.call(g,new ar("beforestart",{sourceEvent:N,target:f,identifier:W,active:o,x:ee[0],y:ee[1],dx:0,dy:0,dispatch:q}),B))!=null)return ne=I.x-ee[0]||0,re=I.y-ee[1]||0,function U(k,$,Z){var ie=ee,te;switch(k){case"start":s[W]=U,te=o++;break;case"end":delete s[W],--o;case"drag":ee=vt(Z||$,v),te=o;break}q.call(k,g,new ar(k,{sourceEvent:$,subject:I,target:f,identifier:W,active:te,x:ee[0]+ne,y:ee[1]+re,dx:ee[0]-ie[0],dy:ee[1]-ie[1],dispatch:q}),B)}}return f.filter=function(g){return arguments.length?(t=typeof g=="function"?g:fn(!!g),f):t},f.container=function(g){return arguments.length?(e=typeof g=="function"?g:fn(g),f):e},f.subject=function(g){return arguments.length?(i=typeof g=="function"?g:fn(g),f):i},f.touchable=function(g){return arguments.length?(n=typeof g=="function"?g:fn(!!g),f):n},f.on=function(){var g=r.on.apply(r,arguments);return g===r?f:g},f.clickDistance=function(g){return arguments.length?(h=(g=+g)*g,f):Math.sqrt(h)},f}const dn=t=>()=>t;function kg(t,{sourceEvent:e,target:i,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function Ct(t,e,i){this.k=t,this.x=e,this.y=i}Ct.prototype={constructor:Ct,scale:function(t){return t===1?this:new Ct(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Ct(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Hi=new Ct(1,0,0);Ct.prototype;function Vs(t){t.stopImmediatePropagation()}function bi(t){t.preventDefault(),t.stopImmediatePropagation()}function Fg(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Dg(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function ga(){return this.__zoom||Hi}function Og(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Bg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ug(t,e,i){var n=t.invertX(e[0][0])-i[0][0],s=t.invertX(e[1][0])-i[1][0],r=t.invertY(e[0][1])-i[0][1],o=t.invertY(e[1][1])-i[1][1];return t.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 Lg(){var t=Fg,e=Dg,i=Ug,n=Og,s=Bg,r=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Jc,c=Qn("start","zoom","end"),u,h,f,d=500,T=150,C=0,w=10;function A(I){I.property("__zoom",ga).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",Y).on("dblclick.zoom",q).filter(s).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",re).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(I,U,k,$){var Z=I.selection?I.selection():I;Z.property("__zoom",ga),I!==Z?v(I,U,k,$):Z.interrupt().each(function(){N(this,arguments).event($).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},A.scaleBy=function(I,U,k,$){A.scaleTo(I,function(){var Z=this.__zoom.k,ie=typeof U=="function"?U.apply(this,arguments):U;return Z*ie},k,$)},A.scaleTo=function(I,U,k,$){A.transform(I,function(){var Z=e.apply(this,arguments),ie=this.__zoom,te=k==null?g(Z):typeof k=="function"?k.apply(this,arguments):k,O=ie.invert(te),H=typeof U=="function"?U.apply(this,arguments):U;return i(b(F(ie,H),te,O),Z,o)},k,$)},A.translateBy=function(I,U,k,$){A.transform(I,function(){return i(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof k=="function"?k.apply(this,arguments):k),e.apply(this,arguments),o)},null,$)},A.translateTo=function(I,U,k,$,Z){A.transform(I,function(){var ie=e.apply(this,arguments),te=this.__zoom,O=$==null?g(ie):typeof $=="function"?$.apply(this,arguments):$;return i(Hi.translate(O[0],O[1]).scale(te.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof k=="function"?-k.apply(this,arguments):-k),ie,o)},$,Z)};function F(I,U){return U=Math.max(r[0],Math.min(r[1],U)),U===I.k?I:new Ct(U,I.x,I.y)}function b(I,U,k){var $=U[0]-k[0]*I.k,Z=U[1]-k[1]*I.k;return $===I.x&&Z===I.y?I:new Ct(I.k,$,Z)}function g(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function v(I,U,k,$){I.on("start.zoom",function(){N(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event($).end()}).tween("zoom",function(){var Z=this,ie=arguments,te=N(Z,ie).event($),O=e.apply(Z,ie),H=k==null?g(O):typeof k=="function"?k.apply(Z,ie):k,ae=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),Q=Z.__zoom,oe=typeof U=="function"?U.apply(Z,ie):U,Ce=l(Q.invert(H).concat(ae/Q.k),oe.invert(H).concat(ae/oe.k));return function(Ve){if(Ve===1)Ve=oe;else{var Qe=Ce(Ve),_i=ae/Qe[2];Ve=new Ct(_i,H[0]-Qe[0]*_i,H[1]-Qe[1]*_i)}te.zoom(null,Ve)}})}function N(I,U,k){return!k&&I.__zooming||new B(I,U)}function B(I,U){this.that=I,this.args=U,this.active=0,this.sourceEvent=null,this.extent=e.apply(I,U),this.taps=0}B.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,U){return this.mouse&&I!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=U.invert(this.touch1[0])),this.that.__zoom=U,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var U=Me(this.that).datum();c.call(I,this.that,new kg(I,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:c}),U)}};function W(I,...U){if(!t.apply(this,arguments))return;var k=N(this,U).event(I),$=this.__zoom,Z=Math.max(r[0],Math.min(r[1],$.k*Math.pow(2,n.apply(this,arguments)))),ie=vt(I);if(k.wheel)(k.mouse[0][0]!==ie[0]||k.mouse[0][1]!==ie[1])&&(k.mouse[1]=$.invert(k.mouse[0]=ie)),clearTimeout(k.wheel);else{if($.k===Z)return;k.mouse=[ie,$.invert(ie)],Sn(this),k.start()}bi(I),k.wheel=setTimeout(te,T),k.zoom("mouse",i(b(F($,Z),k.mouse[0],k.mouse[1]),k.extent,o));function te(){k.wheel=null,k.end()}}function Y(I,...U){if(f||!t.apply(this,arguments))return;var k=I.currentTarget,$=N(this,U,!0).event(I),Z=Me(I.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",ae,!0),ie=vt(I,k),te=I.clientX,O=I.clientY;hc(I.view),Vs(I),$.mouse=[ie,this.__zoom.invert(ie)],Sn(this),$.start();function H(Q){if(bi(Q),!$.moved){var oe=Q.clientX-te,Ce=Q.clientY-O;$.moved=oe*oe+Ce*Ce>C}$.event(Q).zoom("mouse",i(b($.that.__zoom,$.mouse[0]=vt(Q,k),$.mouse[1]),$.extent,o))}function ae(Q){Z.on("mousemove.zoom mouseup.zoom",null),fc(Q.view,$.moved),bi(Q),$.event(Q).end()}}function q(I,...U){if(t.apply(this,arguments)){var k=this.__zoom,$=vt(I.changedTouches?I.changedTouches[0]:I,this),Z=k.invert($),ie=k.k*(I.shiftKey?.5:2),te=i(b(F(k,ie),$,Z),e.apply(this,U),o);bi(I),a>0?Me(this).transition().duration(a).call(v,te,$,I):Me(this).call(A.transform,te,$,I)}}function ee(I,...U){if(t.apply(this,arguments)){var k=I.touches,$=k.length,Z=N(this,U,I.changedTouches.length===$).event(I),ie,te,O,H;for(Vs(I),te=0;te<$;++te)O=k[te],H=vt(O,this),H=[H,this.__zoom.invert(H),O.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==H[2]&&(Z.touch1=H,Z.taps=0):(Z.touch0=H,ie=!0,Z.taps=1+!!u);u&&(u=clearTimeout(u)),ie&&(Z.taps<2&&(h=H[0],u=setTimeout(function(){u=null},d)),Sn(this),Z.start())}}function ne(I,...U){if(this.__zooming){var k=N(this,U).event(I),$=I.changedTouches,Z=$.length,ie,te,O,H;for(bi(I),ie=0;ie<Z;++ie)te=$[ie],O=vt(te,this),k.touch0&&k.touch0[2]===te.identifier?k.touch0[0]=O:k.touch1&&k.touch1[2]===te.identifier&&(k.touch1[0]=O);if(te=k.that.__zoom,k.touch1){var ae=k.touch0[0],Q=k.touch0[1],oe=k.touch1[0],Ce=k.touch1[1],Ve=(Ve=oe[0]-ae[0])*Ve+(Ve=oe[1]-ae[1])*Ve,Qe=(Qe=Ce[0]-Q[0])*Qe+(Qe=Ce[1]-Q[1])*Qe;te=F(te,Math.sqrt(Ve/Qe)),O=[(ae[0]+oe[0])/2,(ae[1]+oe[1])/2],H=[(Q[0]+Ce[0])/2,(Q[1]+Ce[1])/2]}else if(k.touch0)O=k.touch0[0],H=k.touch0[1];else return;k.zoom("touch",i(b(te,O,H),k.extent,o))}}function re(I,...U){if(this.__zooming){var k=N(this,U).event(I),$=I.changedTouches,Z=$.length,ie,te;for(Vs(I),f&&clearTimeout(f),f=setTimeout(function(){f=null},d),ie=0;ie<Z;++ie)te=$[ie],k.touch0&&k.touch0[2]===te.identifier?delete k.touch0:k.touch1&&k.touch1[2]===te.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(te=vt(te,this),Math.hypot(h[0]-te[0],h[1]-te[1])<w)){var O=Me(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return A.wheelDelta=function(I){return arguments.length?(n=typeof I=="function"?I:dn(+I),A):n},A.filter=function(I){return arguments.length?(t=typeof I=="function"?I:dn(!!I),A):t},A.touchable=function(I){return arguments.length?(s=typeof I=="function"?I:dn(!!I),A):s},A.extent=function(I){return arguments.length?(e=typeof I=="function"?I:dn([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),A):e},A.scaleExtent=function(I){return arguments.length?(r[0]=+I[0],r[1]=+I[1],A):[r[0],r[1]]},A.translateExtent=function(I){return arguments.length?(o[0][0]=+I[0][0],o[1][0]=+I[1][0],o[0][1]=+I[0][1],o[1][1]=+I[1][1],A):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},A.constrain=function(I){return arguments.length?(i=I,A):i},A.duration=function(I){return arguments.length?(a=+I,A):a},A.interpolate=function(I){return arguments.length?(l=I,A):l},A.on=function(){var I=c.on.apply(c,arguments);return I===c?A:I},A.clickDistance=function(I){return arguments.length?(C=(I=+I)*I,A):Math.sqrt(C)},A.tapDistance=function(I){return arguments.length?(w=+I,A):w},A}var lr;(
vendor: 32,708 bytes, line 173
173function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}
173)(lr||(lr={}));const cr=.001,kn=64,zg=4,Ta=2;class Hg{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=g_(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.searchArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.maxPointSize=kn,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=bt.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,jg],this.focusedPointRingColor=[1,1,1,qg],this.outlinedPointRingColor=[1,1,1,1],this.highlightedPointSet=void 0,this.outlinedPointSet=void 0,this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=oo(),this.scalePointY=oo(),this.random=new Cl,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(cr,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 i=Xg(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",i>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",i>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=i<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,i){return this.random.float(e,i)}adjustSpaceSize(e,i){(e<=0||!isFinite(e))&&(console.error(`Invalid spaceSize value: ${e}. Using default value of ${bt.spaceSize}`),e=bt.spaceSize);const n=2;if(e<n&&(console.warn(`spaceSize (${e}) is too small. Using minimum value of ${n}`),e=n),!Number.isFinite(i)||i<=0||i<n){console.warn(`Invalid webglMaxTextureSize: ${i}. Using configSpaceSize without WebGL limit adjustment.`),this.adjustedSpaceSize=e;return}e>=i?(this.adjustedSpaceSize=Math.max(i/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,i){const{adjustedSpaceSize:n}=this;this.screenSize=[e,i],this.scalePointX.domain([0,n]).range([(e-n)/2,(e+n)/2]),this.scalePointY.domain([n,0]).range([(i-n)/2,(i+n)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const i=Rt(e);this.hoveredPointRingColor[0]=i[0],this.hoveredPointRingColor[1]=i[1],this.hoveredPointRingColor[2]=i[2]}setFocusedPointRingColor(e){const i=Rt(e);this.focusedPointRingColor[0]=i[0],this.focusedPointRingColor[1]=i[1],this.focusedPointRingColor[2]=i[2]}setOutlinedPointRingColor(e){const i=Rt(e);this.outlinedPointRingColor[0]=i[0],this.outlinedPointRingColor[1]=i[1],this.outlinedPointRingColor[2]=i[2],this.outlinedPointRingColor[3]=i[3]}setHighlightedPointSet(e){this.highlightedPointSet=e?new Set(e):void 0}setOutlinedPointSet(e){this.outlinedPointSet=e?new Set(e):void 0}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const i=Rt(e);this.greyoutPointColor[0]=i[0],this.greyoutPointColor[1]=i[1],this.greyoutPointColor[2]=i[2],this.greyoutPointColor[3]=i[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkContextMenu||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const i=Rt(e);this.hoveredLinkColor[0]=i[0],this.hoveredLinkColor[1]=i[1],this.hoveredLinkColor[2]=i[2],this.hoveredLinkColor[3]=i[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 Vg=t=>Array.isArray(t);function Rt(t){let e;if(Vg(t))e=t;else{const i=Ks(t),n=i?.rgb();e=[(n?.r??0)/255,(n?.g??0)/255,(n?.b??0)/255,i?.opacity??1]}return e}function Xg(t,e,i){return .2126*t+.7152*e+.0722*i}function Ke(t,e,i=0,n=0,s,r){return t.readPixelsToArrayWebGL(e,{sourceX:i,sourceY:n,sourceWidth:s,sourceHeight:r})}function Sa(t){const e=[];for(let i=0;i<t.length;i+=4)t[i]!==0&&e.push(i/4);return e}function xa(t,e){switch(t.info.type){case"webgl":{const i=t.gl.getParameter(lr.ALIASED_POINT_SIZE_RANGE);return(i?.[1]??kn)/e}case"webgpu":return kn/e;default:return kn/e}}function Wg(t,e,i){return Math.min(Math.max(t,e),i)}function et(t){return t!=null&&!Number.isNaN(t)}function $g(t,e){return m_.sanitize(t,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}var he=(t=>(t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Triangle=2]="Triangle",t[t.Diamond=3]="Diamond",t[t.Pentagon=4]="Pentagon",t[t.Hexagon=5]="Hexagon",t[t.Star=6]="Star",t[t.Cross=7]="Cross",t[t.None=8]="None",t))(he||{});class Yg{constructor(e){this.sourcePointsNumber=0,this.targetPointsNumber=0,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&&(this.sourcePointsNumber=this.pointPositions?this.pointPositions.length/2:0,this.pointPositions=this.inputPointPositions,this.targetPointsNumber=this.pointPositions?this.pointPositions.length/2:0)}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=Rt(this._config.pointDefaultColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let i=0;i<this.pointColors.length/4;i++)this.pointColors[i*4]=e[0],this.pointColors[i*4+1]=e[1],this.pointColors[i*4+2]=e[2],this.pointColors[i*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let i=0;i<this.pointColors.length/4;i++)et(this.pointColors[i*4])||(this.pointColors[i*4]=e[0]),et(this.pointColors[i*4+1])||(this.pointColors[i*4+1]=e[1]),et(this.pointColors[i*4+2])||(this.pointColors[i*4+2]=e[2]),et(this.pointColors[i*4+3])||(this.pointColors[i*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}const e=this._config.pointDefaultSize;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 i=0;i<this.pointSizes.length;i++)et(this.pointSizes[i])||(this.pointSizes[i]=e)}}
173updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const{pointDefaultShape:e}=this._config,i=typeof e=="string"?Number(e):e,n=i>=0&&i<=8?i:bt.pointDefaultShape;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(n);else{this.pointShapes=new Float32Array(this.inputPointShapes);const s=this.pointShapes;for(let r=0;r<s.length;r++){const o=s[r];(o==null||!et(o)||o<0||o>8)&&(s[r]=n)}}}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 i=0;i<e.length;i++){const n=e[i],s=n===void 0?NaN:n;!Number.isFinite(s)||s<0?e[i]=-1:e[i]=Math.trunc(s)}this.pointImageIndices=e}}updatePointImageSizes(){var e;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}const i=this._config.pointDefaultSize;if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(i);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let n=0;n<this.pointImageSizes.length;n++)et(this.pointImageSizes[n])||(this.pointImageSizes[n]=((e=this.pointSizes)==null?void 0:e[n])??i)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Rt(this._config.linkDefaultColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let i=0;i<this.linkColors.length/4;i++)this.linkColors[i*4]=e[0],this.linkColors[i*4+1]=e[1],this.linkColors[i*4+2]=e[2],this.linkColors[i*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let i=0;i<this.linkColors.length/4;i++)et(this.linkColors[i*4])||(this.linkColors[i*4]=e[0]),et(this.linkColors[i*4+1])||(this.linkColors[i*4+1]=e[1]),et(this.linkColors[i*4+2])||(this.linkColors[i*4+2]=e[2]),et(this.linkColors[i*4+3])||(this.linkColors[i*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}const e=this._config.linkDefaultWidth;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 i=0;i<this.linkWidths.length;i++)et(this.linkWidths[i])||(this.linkWidths[i]=e)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}const e=this._config.linkDefaultArrows;this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+e):this.linkArrows=this.linkArrowsBoolean.map(i=>+i)}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}
173this.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()}getNeighboringPointIndices(e){var i,n;const s=Array.isArray(e)?e:[e],r=this.pointsNumber??0,o=new Set;for(const a of s)if(!(a<0||a>=r)){for(const[l]of((i=this.sourceIndexToTargetIndices)==null?void 0:i[a])??[])o.add(l);for(const[l]of((n=this.targetIndexToSourceIndices)==null?void 0:n[a])??[])o.add(l)}return[...o]}getConnectedLinkIndices(e){var i;const n=Array.isArray(e)?e:[e],s=this.pointsNumber??0,r=new Set(n),o=new Set;for(const a of r)if(!(a<0||a>=s))for(const[l,c]of((i=this.sourceIndexToTargetIndices)==null?void 0:i[a])??[])r.has(l)&&o.add(c);return[...o]}getConnectedPointIndices(e){const i=Array.isArray(e)?e:[e],n=new Set;if(this.links===void 0)return[];const s=this.linksNumber??0;for(const r of i){if(r<0||r>=s)continue;const o=this.links[r*2],a=this.links[r*2+1];o!==void 0&&n.add(o),a!==void 0&&n.add(a)}return[...n]}_createAdjacencyLists(){var e,i;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]=[]),(i=this.targetIndexToSourceIndices[r])==null||i.push([s,n]))}}_calculateDegrees(){var e,i,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]=((i=(e=this.targetIndexToSourceIndices)==null?void 0:e[r])==null?void 0:i.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)}}var Ie=(t=>(t.Positions="positions",t.PointColors="pointColors",t.PointSizes="pointSizes",t.LinkColors="linkColors",t.LinkWidths="linkWidths",t))(Ie||{}),dc=(t=>(t.Linear="linear",t.QuadIn="quad-in",t.QuadOut="quad-out",t.QuadInOut="quad-in-out",t.CubicIn="cubic-in",t.CubicOut="cubic-out",t.CubicInOut="cubic-in-out",t.SinIn="sin-in",t.SinOut="sin-out",t.SinInOut="sin-in-out",t.ExpIn="exp-in",t.ExpOut="exp-out",t.ExpInOut="exp-in-out",t.CircleIn="circle-in",t.CircleOut="circle-out",t.CircleInOut="circle-in-out",t))(dc||{});const Kg={linear:sl,"quad-in":rl,"quad-out":ol,"quad-in-out":al,"cubic-in":qf,"cubic-out":Zf,"cubic-in-out":ll,"sin-in":Qf,"sin-out":Jf,"sin-in-out":ed,"exp-in":td,"exp-out":id,"exp-in-out":nd,"circle-in":sd,"circle-out":rd,"circle-in-out":od};class Gg{constructor(e){this.progress=1,this.startTime=0,this.pendingProperties=new Set,this.activeProperties=new Set,this.config=e}get isPending(){return this.pendingProperties.size>0}get isActive(){return this.activeProperties.size>0}isPendingFor(e){return this.pendingProperties.has(e)}isActiveFor(e){return this.activeProperties.has(e)}queue(e){this.pendingProperties.add(e)}dequeue(e){this.pendingProperties.delete(e)}start(){var e,i,n,s;if(!this.isPending)return;const{transitionDuration:r}=this.config;if(r<=0){const o=this.isActive;this.pendingProperties.clear(),this.clearActiveCycle(),o&&((i=(e=this.config).onTransitionEnd)==null||i.call(e,!0));return}this.isActive&&this.end(!0),this.startTime=performance.now(),this.progress=0,this.activeProperties=new Set(this.pendingProperties),this.pendingProperties.clear(),(s=(n=this.config).onTransitionStart)==null||s.call(n)}step(){var e,i;if(!this.isActive)return;const{transitionDuration:n}=this.config;if(n<=0){this.end(!0);return}const s=Math.min((performance.now()-this.startTime)/n,1),r=this.applyEasing(s);this.progress=r,(i=(e=this.config).onTransition)==null||i.call(e,r),s>=1&&this.end(!1)}end(e){var i,n;this.isActive&&(this.clearActiveCycle(),(n=(i=this.config).onTransitionEnd)==null||n.call(i,e))}abort(){this.pendingProperties.clear(),this.clearActiveCycle()}applyEasing(e){return(Kg[this.config.transitionEasing]??sl)(e)}clearActiveCycle(){this.startTime=0,this.progress=1,this.activeProperties.clear()}}const bt={enableSimulation:!0,transitionDuration:800,transitionEasing:dc.CubicInOut,backgroundColor:"#222222",spaceSize:4096,pointDefaultColor:"#b3b3b3",pointDefaultSize:4,pointDefaultShape:he.Circle,pointOpacity:1,pointGreyoutOpacity:void 0,pointGreyoutColor:void 0,pointSizeScale:1,scalePointsOnZoom:!1,hoveredPointCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",focusedPointRingColor:"white",focusedPointIndex:void 0,highlightedPointIndices:void 0,outlinedPointIndices:void 0,outlinedPointRingColor:"white",renderLinks:!0,linkDefaultColor:"#666666",linkDefaultWidth:1,linkOpacity:1,linkGreyoutOpacity:.1,linkWidthScale:1,scaleLinksOnZoom:!1,linkBlending:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkDefaultArrows:!1,linkArrowsSizeScale:1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredLinkCursor:"auto",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,highlightedLinkIndices:void 0,focusedLinkIndex:void 0,focusedLinkWidthIncrease:5,simulationDecay:5e3,simulationGravity:.25,simulationCenter:0,simulationRepulsion:1,simulationRepulsionTheta:1.15,simulationLinkSpring:1,simulationLinkDistance:10,simulationLinkDistRandomVariationRange:[1,1.2],simulationRepulsionFromMouse:2,simulationFriction:.85,simulationCluster:.1,simulationCollision:0,simulationCollisionRadius:void 0,simulationCollisionPadding:0,enableRightClickRepulsion:!1,onSimulationStart:void 0,onSimulationTick:void 0,onSimulationEnd:void 0,onSimulationPause:void 0,onSimulationUnpause:void 0,onTransitionStart:void 0,onTransition:void 0,onTransitionEnd:void 0,onClick:void 0,onPointClick:void 0,onLinkClick:void 0,onBackgroun
173dClick:void 0,onContextMenu:void 0,onPointContextMenu:void 0,onLinkContextMenu:void 0,onBackgroundContextMenu:void 0,onMouseMove:void 0,onPointMouseOver:void 0,onPointMouseOut:void 0,onLinkMouseOver:void 0,onLinkMouseOut:void 0,onZoomStart:void 0,onZoom:void 0,onZoomEnd:void 0,onDragStart:void 0,onDrag:void 0,onDragEnd:void 0,showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,enableZoom:!0,enableSimulationDuringZoom:!1,initialZoomLevel:void 0,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,fitViewByPointsInRect:void 0,fitViewByPointIndices:void 0,pointSamplingDistance:100,linkSamplingDistance:100,randomSeed:void 0,rescalePositions:void 0,attribution:""},jg=.7,qg=.95;function pc(){const t={};for(const[e,i]of Object.entries(bt))t[e]=Array.isArray(i)?[...i]:i;return t}function Zg(t){Object.assign(t,pc())}function Xs(t,e,i=!1){const n={};for(const[s,r]of Object.entries(e))if(r!==void 0)n[s]=r;else if(i){const o=bt[s];n[s]=Array.isArray(o)?[...o]:o}Object.assign(t,n)}class wt{constructor(e,i,n,s,r){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=i,this.store=n,this.data=s,r&&(this.points=r)}}const Qg=`#version 300 es 174precision highp float; 175 176in vec4 rgba; 177out vec4 fragColor; 178 179void main() { 180 fragColor = rgba; 181}`,Jg=`#version 300 es 182precision highp float; 183 184uniform sampler2D positionsTexture; 185 186#ifdef USE_UNIFORM_BUFFERS 187layout(std140) uniform calculateCentermassUniforms { 188 float pointsTextureSize; 189} calculateCentermass; 190 191#define pointsTextureSize calculateCentermass.pointsTextureSize 192#else 193uniform float pointsTextureSize; 194#endif 195 196in vec2 pointIndices; 197 198out vec4 rgba; 199 200void main() { 201 vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize); 202 rgba = vec4(pointPosition.xy, 1.0, 0.0); 203 204 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 205 gl_PointSize = 1.0; 206} 207`,eT=`#version 300 es 208precision highp float; 209 210uniform sampler2D positionsTexture; 211uniform sampler2D centermassTexture; 212 213#ifdef USE_UNIFORM_BUFFERS 214layout(std140) uniform forceCenterUniforms { 215 float centerForce; 216 float alpha; 217} forceCenter; 218 219#define centerForce forceCenter.centerForce 220#define alpha forceCenter.alpha 221#else 222uniform float centerForce; 223uniform float alpha; 224#endif 225 226in vec2 textureCoords; 227out vec4 fragColor; 228 229void main() { 230 vec4 pointPosition = texture(positionsTexture, textureCoords); 231 vec4 velocity = vec4(0.0); 232 vec4 centermassValues = texture(centermassTexture, vec2(0.0)); 233 vec2 centermassPosition = centermassValues.xy / centermassValues.b; 234 vec2 distVector = centermassPosition - pointPosition.xy; 235 float dist = sqrt(dot(distVector, distVector)); 236 if (dist > 0.0) { 237 float angle = atan(distVector.y, distVector.x); 238 float addV = alpha * centerForce * dist * 0.01; 239 velocity.rg += addV * vec2(cos(angle), sin(angle)); 240 } 241 242 fragColor = velocity; 243}`;function Gi(t){const e=new Float32Array(t*t*2);for(let i=0;i<t;i++)for(let n=0;n<t;n++){const s=i*t*2+n*2;e[s+0]=n,e[s+1]=i}return e}function qn(t,e,i,n,s,r){const o=s?s.length/r:0,a=e.length/r;if(o===a&&i&&!i.destroyed&&n&&!n.destroyed){const u=n,h=i;return h.write(e),{source:u,target:h,previous:new Float32Array(e)}}const l=new Float32Array(e.length),c=Math.min(o,a);for(let u=0;u<c*r;u+=1)l[u]=s?.[u]??e[u]??0;for(let u=c*r;u<e.length;u+=1)l[u]=e[u]??0;return i&&!i.destroyed&&i.destroy(),n&&!n.destroyed&&n.destroy(),{source:t.createBuffer({data:l,usage:G.VERTEX|G.COPY_DST}),target:t.createBuffer({data:e,usage:G.VERTEX|G.COPY_DST}),previous:new Float32Array(e)}}function ue(t,e){const i=Oi.getInfo(t);return e*(i.bytesPerPixel??0)}const Ge=`#version 300 es 244#ifdef GL_ES 245precision highp float; 246#endif 247 248in vec2 vertexCoord; // Vertex coordinates in normalized device coordinates 249out vec2 textureCoords; // Texture coordinates to pass to the fragment shader 250 251void main() { 252 // Convert vertex coordinates from [-1, 1] range to [0, 1] range for texture sampling 253 textureCoords = (vertexCoord + 1.0) / 2.0; 254 gl_Position = vec4(vertexCoord, 0, 1); 255} 256`;class ya extends wt{create(){var e;const{device:i,store:n}=this,{pointsTextureSize:s}=n;if(s){if(this.centermassTexture||(this.centermassTexture=i.createTexture({width:1,height:1,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST})),this.centermassTexture.copyImageData({data:new Float32Array(4).fill(0),b
256ytesPerRow:ue("rgba32float",1),mipLevel:0,x:0,y:0}),this.centermassFbo||(this.centermassFbo=i.createFramebuffer({width:1,height:1,colorAttachments:[this.centermassTexture]})),!this.pointIndices||this.previousPointsTextureSize!==n.pointsTextureSize){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const r=Gi(n.pointsTextureSize);this.pointIndices=i.createBuffer({data:r,usage:G.VERTEX|G.COPY_DST}),(e=this.calculateCentermassCommand)==null||e.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=s}}initPrograms(){const{device:e,store:i,points:n}=this;!n||!i.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 Se({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32"}}})),this.forceUniformStore||(this.forceUniformStore=new Se({forceCenterUniforms:{uniformTypes:{centerForce:"f32",alpha:"f32"}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new ge(e,{fs:Qg,vs:Jg,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 ge(e,{fs:eT,vs:Ge,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:i,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||i.pointsTextureSize!==this.previousPointsTextureSize||!this.pointIndices)return;const s=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:i.pointsTextureSize??0}}),this.calculateCentermassCommand.setBindings({positionsTexture:n.previousPositionTexture}),this.calculateCentermassCommand.draw(s),s.end(),this.forceUniformStore.setUniforms({forceCenterUniforms:{centerForce:this.config.simulationCenter,alpha:i.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,i,n,s;(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(i=this.runCommand)==null||i.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 tT=`#version 300 es 257precision highp float; 258 259uniform sampler2D positionsTexture; 260uniform sampler2D sizeTexture; 261 262#ifdef USE_UNIFORM_BUFFERS 263layout(std140) uniform buildGridUniforms { 264 float pointsTextureSize; 265 float gridTextureSize; 266 float cellSize; 267 vec2 gridOffset; // Offset for multi-pass (0-1 range, multiplied by cellSize) 268} buildGrid; 269 270#define pointsTextureSize buildGrid.pointsTextureSize 271#define gridTextureSize buildGrid.gridTextureSize 272#define cellSize buildGrid.cellSize 273#define gridOffset buildGrid.gridOffset 274#else 275uniform float pointsTextureSize; 276uniform float gridTextureSize; 277uniform float cellSize; 278uniform vec2 gridOffset; 279#endif 280 281in vec2 pointIndices; 282 283out vec4 cellData; // xy = position, z = size, w = count (1.0) 284 285void main() { 286 vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize); 287 vec4 pointSize = texture(sizeTexture, pointIndices / pointsTextureSize); 288 289 // Output: position sum, size sum, count 290 cellData = vec4(pointPosition.xy, pointSize.r, 1.0); 291 292 // Apply grid offset for multi-pass collision detection 293 vec2 offsetPosition = pointPosition.xy + gridOffset * cellSize; 294 295 // Calculate which grid cell this point belongs to 296 float cellX = floor(offsetPosition.x / cellSize); 297 float cellY = floor(offsetPosition.y / cellSize); 298 299 // Clamp to grid bounds 300 cellX = clamp(cellX, 0.0, gridTextureSize - 1.0); 301 cellY = clamp(cellY, 0.0, gridTextureSize - 1.0); 302 303 // Convert to clip space coordinates 304 vec2 gridPosition = 2.0 * (vec2(cellX, cellY) + 0.5) / gridTextureSize - 1.0; 305 306 gl_Position = vec4(gridPosition, 0.0, 1.0); 307 gl_PointSize = 1.0; 308} 309`,iT=`#version 300 es 310precision highp float; 311 312in vec4 cellData; 313out vec4 fragColor; 314 315void main() { 316 // Output accumulated cell data (blended additively) 317 // xy = sum of positions, z = sum of sizes, w = count 318 fragColor = cellData; 319} 320`,nT=`#version 300 es 321precision highp float; 322 323uniform sampler2D positionsTexture; 324uniform sampler2D sizeTexture; 325uniform sampler2D gridTexture; 326 327#ifdef USE_UNIFORM_BUFFERS 328layout(std140) uniform forceCollisionUniforms { 329 float pointsTextureSize; 330 float gridTextureSize; 331 float cellSize; 332 float alpha; 333 float collisionStrength; 334 float collisionRadius; 335 float collisionPadding; 336 float pointsNumber; 337 vec2 gridOffset; // Must match the offset used when building the grid 338} forceCollision; 339 340#define pointsTextureSize forceCollision.pointsTextureSize 341#define gridTextureSize forceCollision.gridTextureSize 342#define cellSize forceCollision.cellSize 343#define alpha forceCollision.alpha 344#define collisionStrength forceCollision.collisionStrength 345#define collisionRadius forceCollision.collisionRadius 346#define collisionPadding forceCollision.collisionPadding 347#define pointsNumber forceCollision.pointsNumber 348#define gridOffset forceCollision.gridOffset 349#else 350uniform float pointsTextureSize; 351uniform float gridTextureSize; 352uniform float cellSize; 353uniform float alpha; 354uniform float collisionStrength; 355uniform float collisionRadius; 356uniform float collisionPadding; 357uniform float pointsNumber; 358uniform vec2 gridOffset; 359#endif 360 361in vec2 textureCoords; 362out vec4 fragColor; 363 364void main() { 365 vec4 pointPosition = texture(positionsTexture, textureCoords); 366 vec4 velocity = vec4(0.0); 367 368 // Get current point's index 369 float currentIndex = pointPosition.b; 370 371 // Skip if this is an empty texel 372 if (currentIndex < 0.0 || currentIndex >= pointsNumber) { 373 fragColor = velocity; 374 return; 375 } 376 377 // Get current point's size for collision radius 378 vec4 currentSizeData = texture(sizeTexture, textureCoords); 379 float currentSize = currentSizeData.r; 380 float currentCollisionRadius = (collisionRadius > 0.0 ? collisionRadius : currentSize * 0.5) + collisionPadding; 381 382 vec2 currentPos = pointPosition.rg; 383 384 // Apply the same offset used when building the grid 385 vec2 offsetPos = currentPos + gridOffset * cellSize; 386 387 // Calculate which grid cell this point is in (with offset). 388 // Clamp to the grid bounds to match build-grid.vert, so a point that drifts 389 // outside the space still reads the edge cell it was binned into. 390 float myCellX = clamp(floor(offsetPos.x / cellSize), 0.0, gridTextureSize - 1.0); 391 float myCellY = clamp(floor(offsetPos.y / cellSize), 0.0, gridTextureSize - 1.0); 392 393 // Track total neighbor count for damping 394 float totalNeighbors = 0.0; 395 396 // Check 3x3 neighborhood of cells 397 for (int dx = -1; dx <= 1; dx++) { 398 for (int dy = -1; dy <= 1; dy++) { 399 float neighborCellX = myCellX + float(dx); 400 float neighborCellY = myCellY + float(dy); 401 402 // Skip cells outside grid bounds 403 if (neighborCellX < 0.0 || neighborCellX >= gridTextureSize || 404 neighborCellY < 0.0 || neighborCellY >= gridTextureSize) { 405 continue; 406 } 407 408 // Sample the grid cell 409 vec2 gridCoord = (vec2(neighborCellX, neighborCellY) + 0.5) / gridTextureSize; 410 vec4 cellData = texture(gridTexture, gridCoord); 411 412 float cellCount = cellData.w; 413 if (cellCount < 0.5) continue; // Empty cell 414 415 // Scale force by number of points in cell 416 // Subtract 1 if this is our own cell to avoid self-collision
417 float effectiveCount = cellCount; 418 if (dx == 0 && dy == 0) { 419 effectiveCount = max(0.0, cellCount - 1.0); 420 } 421 422 totalNeighbors += effectiveCount; 423 424 // Get average position and size in this cell 425 vec2 avgPos = cellData.xy / cellCount; 426 float avgSize = cellData.z / cellCount; 427 float otherCollisionRadius = (collisionRadius > 0.0 ? collisionRadius : avgSize * 0.5) + collisionPadding; 428 429 // Calculate combined collision radius 430 float combinedRadius = currentCollisionRadius + otherCollisionRadius; 431 432 // Calculate distance vector to average position (using original positions) 433 vec2 distVector = currentPos - avgPos; 434 float dist = length(distVector); 435 436 // Check for collision 437 if (dist < combinedRadius && dist > 0.001) { 438 // Calculate overlap ratio (0 = just touching, 1 = fully overlapping) 439 float overlapRatio = (combinedRadius - dist) / combinedRadius; 440 441 // Soft collision curve: use square root for gentler force near edges 442 // This prevents the "ping-pong" effect at boundaries 443 float softOverlap = sqrt(overlapRatio) * combinedRadius * 0.5; 444 445 // Direction to push apart (normalized) 446 vec2 direction = distVector / dist; 447 448 // Apply repulsion force with soft curve 449 // Divide by 4 since we run 4 passes with different offsets 450 float force = alpha * collisionStrength * softOverlap * 0.25 * effectiveCount; 451 452 // Clamp maximum force to prevent instability 453 force = min(force, combinedRadius * 0.5); 454 455 velocity.rg += force * direction; 456 } else if (dist <= 0.001 && effectiveCount > 0.0) { 457 // Points at same position - push based on index 458 float angle = currentIndex * 0.618033988749895; 459 float force = min(alpha * collisionStrength * combinedRadius * 0.1, combinedRadius * 0.3); 460 velocity.rg += force * effectiveCount * vec2(cos(angle), sin(angle)); 461 } 462 } 463 } 464 465 // Apply density-based damping: reduce force when surrounded by many neighbors 466 // This prevents chaotic oscillations in dense clusters 467 if (totalNeighbors > 2.0) { 468 float damping = 2.0 / totalNeighbors; 469 velocity.rg *= damping; 470 } 471 472 // Cap the per-pass correction so overlaps resolve by relaxation over a few 473 // frames instead of overshooting in one. Across the 4 offset passes the 474 // total displacement stays within ~40% of this point's collision radius, 475 // which converges without the ping-pong of full-overlap corrections. 476 float maxCorrection = currentCollisionRadius * 0.1; 477 float correction = length(velocity.rg); 478 if (correction > maxCorrection) { 479 velocity.rg *= maxCorrection / correction; 480 } 481 482 fragColor = velocity; 483} 484`,Ii=[[0,0],[.5,0],[0,.5],[.5,.5]];class va extends wt{constructor(){super(...arguments),this.gridTargets=[],this.gridTextureSize=0,this.cellSize=0}create(){var e,i;const{device:n,store:s,data:r,config:o}=this;if(!s.pointsTextureSize||r.pointsNumber===void 0)return;const a=o.pointDefaultSize??bt.pointDefaultSize;let l=a;if(r.pointSizes)for(const d of r.pointSizes)l=Math.max(l,d);const c=o.simulationCollisionRadius??0,u=o.simulationCollisionPadding??0,h=(c>0?c:l*.5)+u;this.cellSize=Math.max(h,8),this.gridTextureSize=Math.min(512,Math.max(32,Math.ceil(s.adjustedSpaceSize/this.cellSize))),this.cellSize=s.adjustedSpaceSize/this.gridTextureSize,this.gridTargets.length===Ii.length&&this.gridTargets.every(d=>!d.texture.destroyed&&!d.fbo.destroyed&&d.texture.width===this.gridTextureSize)||(this.destroyGridTargets(),this.gridTargets=Ii.map(()=>{const d=n.createTexture({width:this.gridTextureSize,height:this.gridTextureSize,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST}),T=n.createFramebuffer({width:this.gridTextureSize,height:this.gridTextureSize,colorAttachments:[d]});return{texture:d,fbo:T}}));const f=new Float32Array(s.pointsTextureSize*s.pointsTextureSize*4);for(let d=0;d<r.pointsNumber;d++)f[d*4]=((e=r.pointSizes)==null?void 0:e[d])??a;(!this.sizeTexture||this.sizeTexture.destroyed||this.sizeTexture.width!==s.pointsTextureSize||this.sizeTexture.height!==s.pointsTextureSize)&&(this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=n.createTexture({width:s.pointsTextureSize,height:s.pointsTextureSize,format:"rgba32float",usage:j.SAMPLE|j.COPY_DST})),this.sizeTexture.copyImageData({data:f,bytesPerRow:ue("rgba32float",s.pointsTextureSize),mipLevel:0,x:0,y:0}),(!this.pointIndices||this.previousPointsTextureSize!==s.pointsTextureSize)&&(this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=n.createBuffer({data:Gi(s.pointsTextureSize),usage:G.VERTEX|G.COPY_DST}),(i=this.buildGridCommand)==null||i.setAttributes({pointIndices:this.pointIndices}
484)),this.previousPointsTextureSize=s.pointsTextureSize,this.previousSpaceSize=s.adjustedSpaceSize}initPrograms(){const{device:e,store:i,data:n}=this;!n.pointsNumber||!i.pointsTextureSize||(this.buildGridUniformStore||(this.buildGridUniformStore=new Se({buildGridUniforms:{uniformTypes:{pointsTextureSize:"f32",gridTextureSize:"f32",cellSize:"f32",gridOffset:"vec2<f32>"}}})),this.buildGridCommand||(this.buildGridCommand=new ge(e,{fs:iT,vs:tT,topology:"point-list",vertexCount:n.pointsNumber,attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{buildGridUniforms:this.buildGridUniformStore.getManagedUniformBuffer(e,"buildGridUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceUniformStore||(this.forceUniformStore=new Se({forceCollisionUniforms:{uniformTypes:{pointsTextureSize:"f32",gridTextureSize:"f32",cellSize:"f32",alpha:"f32",collisionStrength:"f32",collisionRadius:"f32",collisionPadding:"f32",pointsNumber:"f32",gridOffset:"vec2<f32>"}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceCommand||(this.forceCommand=new ge(e,{fs:nT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCollisionUniforms:this.forceUniformStore.getManagedUniformBuffer(e,"forceCollisionUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,store:i,data:n,points:s,config:r}=this;if(!s||!this.buildGridCommand||!this.buildGridUniformStore||!this.forceCommand||!this.forceUniformStore||!this.pointIndices||n.pointsNumber===void 0||!s.previousPositionTexture||s.previousPositionTexture.destroyed||!s.velocityFbo||s.velocityFbo.destroyed||!this.sizeTexture||this.sizeTexture.destroyed||this.gridTargets.length!==Ii.length||i.pointsTextureSize!==this.previousPointsTextureSize||i.adjustedSpaceSize!==this.previousSpaceSize)return;const o=r.simulationCollisionRadius??0,a=r.simulationCollisionPadding??0;this.buildGridCommand.setVertexCount(n.pointsNumber),this.buildGridCommand.setBindings({positionsTexture:s.previousPositionTexture,sizeTexture:this.sizeTexture});for(const[c,u]of Ii.entries()){const h=this.gridTargets[c];if(!h||h.fbo.destroyed||h.texture.destroyed)continue;this.buildGridUniformStore.setUniforms({buildGridUniforms:{pointsTextureSize:i.pointsTextureSize??0,gridTextureSize:this.gridTextureSize,cellSize:this.cellSize,gridOffset:u}});const f=e.beginRenderPass({framebuffer:h.fbo,clearColor:[0,0,0,0]});this.buildGridCommand.draw(f),f.end()}this.forceCommand.setBindings({positionsTexture:s.previousPositionTexture,sizeTexture:this.sizeTexture});const l=e.beginRenderPass({framebuffer:s.velocityFbo,clearColor:[0,0,0,0]});for(const[c,u]of Ii.entries()){const h=this.gridTargets[c];!h||h.texture.destroyed||(this.forceUniformStore.setUniforms({forceCollisionUniforms:{pointsTextureSize:i.pointsTextureSize??0,gridTextureSize:this.gridTextureSize,cellSize:this.cellSize,alpha:i.alpha,collisionStrength:r.simulationCollision??0,collisionRadius:o,collisionPadding:a,pointsNumber:n.pointsNumber,gridOffset:u}}),this.forceCommand.setBindings({gridTexture:h.texture}),this.forceCommand.draw(l))}l.end()}destroy(){var e,i,n,s;(e=this.buildGridCommand)==null||e.destroy(),this.buildGridCommand=void 0,(i=this.forceCommand)==null||i.destroy(),this.forceCommand=void 0,this.destroyGridTargets(),this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,(n=this.buildGridUniformStore)==null||n.destroy(),this.buildGridUniformStore=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}destroyGridTargets(){for(const e of this.gridTargets)e.fbo&&!e.fbo.destroyed&&e.fbo.destroy();for(const e of this.gridTargets)e.texture&&!e.texture.destroyed&&e.texture.destroy();this.gridTargets=[]}}const sT=`#version 300 es 485precision highp float; 486 487uniform sampler2D positionsTexture; 488 489#ifdef USE_UNIFORM_BUFFERS 490layout(std140) uniform forceGravityUniforms { 491 float gravity; 492 float spaceSize; 493 float alpha; 494} forceGravity; 495 496#define gravity forceGravity.gravity 497#define spaceSize forceGravity.spaceSize 498#define alpha forceGravity.alpha 499#else 500uniform float gravity; 501uniform float spaceSize; 502uniform float alpha; 503#endif 504 505in vec2 textureCoords; 506out vec4 fragColor; 507 508void main() { 509 vec4 pointPosition = texture(positionsTexture, textureCoords); 510 511 vec4 velocity = vec4(0.0); 512 513 vec2 centerPosition = vec2(spaceSize * 0.5); 514 vec2 distVector = centerPosition - pointPosition.rg; 515 float dist = sqrt(dot(distVector, distVector)); 516 if (dist > 0.0) { 517 float angle = atan(distVector.y, distVector.x); 518 float additionalVelocity = alpha * gravity * dist * 0.1; 519 velocity.rg += additionalVelocity * vec2(cos(angle), sin(angle)); 520 } 521 522 fragColor = velocity; 523}`;class Ea extends wt{initPrograms(){const{device:e,points:i,store:n}=this;!i||!n.pointsTextureSize||(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new Se({forceGravityUniforms:{uniformTypes:{gravity:"f32",spaceSize:"f32",alpha:"f32"}}}
523)),this.runCommand||(this.runCommand=new ge(e,{fs:sT,vs:Ge,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:i,store:n}=this;if(!i||!this.runCommand||!this.uniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!i.velocityFbo||i.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceGravityUniforms:{gravity:this.config.simulationGravity,spaceSize:n.adjustedSpaceSize,alpha:n.alpha}}),this.runCommand.setBindings({positionsTexture:i.previousPositionTexture});const s=e.beginRenderPass({framebuffer:i.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,i;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(i=this.uniformStore)==null||i.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}function rT(t){return`#version 300 es 524precision highp float; 525 526uniform sampler2D positionsTexture; 527uniform sampler2D linkInfoTexture; // Texture storing first link indices and amount 528uniform sampler2D linkIndicesTexture; 529uniform sampler2D linkPropertiesTexture; // Texture storing link bias and strength 530uniform sampler2D linkRandomDistanceTexture; 531 532#ifdef USE_UNIFORM_BUFFERS 533layout(std140) uniform forceLinkUniforms { 534 float linkSpring; 535 float linkDistance; 536 vec2 linkDistRandomVariationRange; 537 float pointsTextureSize; 538 float linksTextureSize; 539 float alpha; 540} forceLink; 541 542#define linkSpring forceLink.linkSpring 543#define linkDistance forceLink.linkDistance 544#define linkDistRandomVariationRange forceLink.linkDistRandomVariationRange 545#define pointsTextureSize forceLink.pointsTextureSize 546#define linksTextureSize forceLink.linksTextureSize 547#define alpha forceLink.alpha 548#else 549uniform float linkSpring; 550uniform float linkDistance; 551uniform vec2 linkDistRandomVariationRange; 552uniform float pointsTextureSize; 553uniform float linksTextureSize; 554uniform float alpha; 555#endif 556 557in vec2 textureCoords; 558out vec4 fragColor; 559 560const float MAX_LINKS = ${t}.0; 561 562void main() { 563 vec4 pointPosition = texture(positionsTexture, textureCoords); 564 vec4 velocity = vec4(0.0); 565 566 vec4 linkInfo = texture(linkInfoTexture, textureCoords); 567 float iCount = linkInfo.r; 568 float jCount = linkInfo.g; 569 float linkAmount = linkInfo.b; 570 if (linkAmount > 0.0) { 571 for (float i = 0.0; i < MAX_LINKS; i += 1.0) { 572 if (i < linkAmount) { 573 if (iCount >= linksTextureSize) { 574 iCount = 0.0; 575 jCount += 1.0; 576 } 577 vec2 linkTextureIndex = (vec2(iCount, jCount) + 0.5) / linksTextureSize; 578 vec4 connectedPointIndex = texture(linkIndicesTexture, linkTextureIndex); 579 vec4 biasAndStrength = texture(linkPropertiesTexture, linkTextureIndex); 580 vec4 randomMinDistance = texture(linkRandomDistanceTexture, linkTextureIndex); 581 float bias = biasAndStrength.r; 582 float strength = biasAndStrength.g; 583 float randomMinLinkDist = randomMinDistance.r * (linkDistRandomVariationRange.g - linkDistRandomVariationRange.r) + linkDistRandomVariationRange.r; 584 randomMinLinkDist *= linkDistance; 585 586 iCount += 1.0; 587 588 vec4 connectedPointPosition = texture(positionsTexture, (connectedPointIndex.rg + 0.5) / pointsTextureSize); 589 float x = connectedPointPosition.x - (pointPosition.x + velocity.x); 590 float y = connectedPointPosition.y - (pointPosition.y + velocity.y); 591 float l = sqrt(x * x + y * y); 592 593 // Apply the link force 594 l = max(l, randomMinLinkDist * 0.99); 595 l = (l - randomMinLinkDist) / l; 596 l *= linkSpring * alpha; 597 l *= strength; 598 l *= bias; 599 x *= l; 600 y *= l; 601 velocity.x += x; 602 velocity.y += y; 603 } 604 } 605 } 606 607 fragColor = vec4(velocity.rg, 0.0, 0.0); 608} 609 `}function ce(t,e){return!t||t.length!==2?e:[t[0],t[1]]}function we(t,e){return!t||t.length!==4?e:[t[0],t[1],t[2],t[3]]}var ur=(t=>(t.OUTGOING="outgoing",t.INCOMING="incoming",t))(ur||{});class pn extends wt{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){var i;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?.forEach((d,T)=>{d&&(this.linkFirstIndicesAndAmount[T*4+0]=u%r,this.linkFirstIndicesAndAmount[T*4+1]=Math.floor(u/r),this.linkFirstIndicesAndAmount[T*4+2]=d.length??0,d.forEach(([C,w])=>{var A,F,b;this.indices[u*4+0]=C%s,this.indices[u*4+1]=Math.floor(C/s);const g=((A=o.degree)==null?void 0:A[C])??0,v=((F=o.degree)==null?void 0:F[T])??0,N=g+v,B=N!==0?g/N:.5,W=Math.min(g,v);let Y=((b=o.linkStrength)==null?void 0:b[w])??1/Math.max(W,1);Y=Math.sqrt(Y),a[u*4+0]=B,a[u*4+1]=Y,l[u*4]=this.store.getRandomFloat(0,1),u+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,d.length??0))});const h=!this.linkFirstIndicesAndAmountTexture||this.linkFirstIndicesAndAmountTexture.width!==s||this.linkFirstIndicesAndAmountTexture.height!==s,f=!this.indicesTexture||this.indicesTexture.width!==r||this.indicesTexture.height!==r;h&&(this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=n.createTexture({width:s,height:s,format:"rgba32float",usage:j.SAMPLE|j.COPY_DST})),this.linkFirstIndicesAndAmountTexture.copyImageData({data:this.linkFirstIndicesAndAmount,bytesPerRow:ue("rgba32float",s),mipLevel:0,x:0,y:0}),f&&(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:j.SAMPLE|j.COPY_DST}),this.biasAndStrengthTexture=n.createTexture({width:r,height:r,format:"rgba32float",usage:j.SAMPLE|j.COPY_DST}),this.randomDistanceTexture=n.createTexture({width:r,height:r,format:"rgba32float",usage:j.SAMPLE|j.COPY_DST})),this.indicesTexture.copyImageData({data:this.indices,bytesPerRow:ue("rgba32float",r),mipLevel:0,x:0,y:0}),this.biasAndStrengthTexture.copyImageData({data:a,bytesPerRow:ue("rgba32float",r),mipLevel:0,x:0,y:0}),this.randomDistanceTexture.copyImageData({data:l,bytesPerRow:ue("rgba32float",r),mipLevel:0,x:0,y:0}),this.previousMaxPointDegree!==void 0&&this.previousMaxPointDegree!==this.maxPointDegree&&((i=this.runCommand)==null||i.destroy(),this.runCommand=void 0),this.previousMaxPointDegree=this.maxPointDegree,this.previousPointsTextureSize=s,this.previousLinksTextureSize=r}initPrograms(){const{device:e,store:i,points:n}=this;!n||!i.pointsTextureSize||!i.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 Se({forceLinkUniforms:{uniformTypes:{linkSpring:"f32",linkDistance:"f32",linkDistRandomVariationRange:"vec2<f32>",pointsTextureSize:"f32",linksTextureSize:"f32",alpha:"f32"}}}
609)),this.runCommand||(this.runCommand=new ge(e,{fs:rT(this.maxPointDegree),vs:Ge,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:i,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||i.pointsTextureSize!==this.previousPointsTextureSize||i.linksTextureSize!==this.previousLinksTextureSize)return;this.uniformStore.setUniforms({forceLinkUniforms:{linkSpring:this.config.simulationLinkSpring,linkDistance:this.config.simulationLinkDistance,linkDistRandomVariationRange:ce(this.config.simulationLinkDistRandomVariationRange,[0,0]),pointsTextureSize:i.pointsTextureSize,linksTextureSize:i.linksTextureSize,alpha:i.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,i;(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,(i=this.uniformStore)==null||i.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const oT=`#version 300 es 610precision highp float; 611 612in vec4 vColor; 613out vec4 fragColor; 614 615void main() { 616 fragColor = vColor; 617}`,aT=`#version 300 es 618precision highp float; 619 620uniform sampler2D positionsTexture; 621 622#ifdef USE_UNIFORM_BUFFERS 623layout(std140) uniform calculateLevelsUniforms { 624 float pointsTextureSize; 625 float levelTextureSize; 626 float cellSize; 627} calculateLevels; 628 629#define pointsTextureSize calculateLevels.pointsTextureSize 630#define levelTextureSize calculateLevels.levelTextureSize 631#define cellSize calculateLevels.cellSize 632#else 633uniform float pointsTextureSize; 634uniform float levelTextureSize; 635uniform float cellSize; 636#endif 637 638in vec2 pointIndices; 639 640out vec4 vColor; 641 642void main() { 643 vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize); 644 vColor = vec4(pointPosition.rg, 1.0, 0.0); 645 646 float n = floor(pointPosition.x / cellSize); 647 float m = floor(pointPosition.y / cellSize); 648 649 vec2 levelPosition = 2.0 * (vec2(n, m) + 0.5) / levelTextureSize - 1.0; 650 651 gl_Position = vec4(levelPosition, 0.0, 1.0); 652 gl_PointSize = 1.0; 653}`,lT=`#version 300 es 654precision highp float; 655 656uniform sampler2D positionsTexture; 657uniform sampler2D levelFbo; 658 659#ifdef USE_UNIFORM_BUFFERS 660layout(std140) uniform forceUniforms { 661 float level; 662 float levels; 663 float levelTextureSize; 664 float alpha; 665 float repulsion; 666 float spaceSize; 667 float theta; 668} force; 669 670#define level force.level 671#define levels force.levels 672#define levelTextureSize force.levelTextureSize 673#define alpha force.alpha 674#define repulsion force.repulsion 675#define spaceSize force.spaceSize 676#define theta force.theta 677#else 678uniform float level; 679uniform float levels; 680uniform float levelTextureSize; 681uniform float repulsion; 682uniform float alpha; 683uniform float spaceSize; 684uniform float theta; 685#endif 686 687in vec2 textureCoords; 688out vec4 fragColor; 689 690const float MAX_LEVELS_NUM = 14.0; 691 692vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) { 693 vec2 add = vec2(0.0); 694 vec4 centermass = texture(levelFbo, ij); 695 if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) { 696 vec2 centermassPosition = vec2(centermass.rg / centermass.b); 697 vec2 distVector = pp - centermassPosition; 698 float l = dot(distVector, distVector); 699 float dist = sqrt(l); 700 if (l > 0.0) { 701 float c = alpha * repulsion * centermass.b; 702 703 float distanceMin2 = 1.0; 704 if (l < distanceMin2) l = sqrt(distanceMin2 * l); 705 float addV = c / sqrt(l); 706 add = addV * normalize(distVector); 707 } 708 } 709 return add; 710} 711 712void main() { 713 vec4 pointPosition = texture(positionsTexture, textureCoords); 714 float x = pointPosition.x; 715 float y = pointPosition.y; 716 717 float left = 0.0; 718 float top = 0.0; 719 float right = spaceSize; 720 float bottom = spaceSize; 721 722 float n_left = 0.0; 723 float n_top = 0.0; 724 float n_right = 0.0; 725 float n_bottom = 0.0; 726 727 float cellSize = 0.0; 728 729 // Iterate over levels to adjust the boundaries based on the current level 730 for (float i = 0.0; i < MAX_LEVELS_NUM; i += 1.0) { 731 if (i <= level) { 732 left += cellSize * n_left; 733 top += cellSize * n_top; 734 right -= cellSize * n_right; 735 bottom -= cellSize * n_bottom; 736 737 cellSize = pow(2.0 , levels - i - 1.0); 738 739 float dist_left = x - left; 740 n_left = max(0.0, floor(dist_left / cellSize - theta)); 741 742 float dist_top = y - top; 743 n_top = max(0.0, floor(dist_top / cellSize - theta)); 744 745 float dist_right = right - x; 746 n_right = max(0.0, floor(dist_right / cellSize - theta)); 747 748 float dist_bottom = bottom - y; 749 n_bottom = max(0.0, floor(dist_bottom / cellSize - theta)); 750 751 } 752 } 753 754 vec4 velocity = vec4(vec2(0.0), 1.0, 0.0); 755 756 // Calculate the additional velocity based on neighboring cells 757 for (float i = 0.0; i < 12.0; i += 1.0) { 758 for (float j = 0.0; j < 4.0; j += 1.0) { 759 float n = left + cellSize * j; 760 float m = top + cellSize * n_top + cellSize * i; 761 762 if (n < (left + n_left * cellSize) && m < bottom) { 763 velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy); 764 } 765 766 n = left + cellSize * i; 767 m = top + cellSize * j; 768 769 if (n < (right - n_right * cellSize) && m < (top + n_top * cellSize)) { 770 velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy); 771 } 772 773 n = right - n_right * cellSize + cellSize * j; 774 m = top + cellSize * i; 775 776 if (n < right && m < (bottom - n_bottom * cellSize)) { 777 velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy); 778 } 779 780 n = left + n_left * cellSize + cellSize * i; 781 m = bottom - n_bottom * cellSize + cellSize * j; 782 783 if (n < right && m < bottom) { 784 velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy); 785 } 786 } 787 } 788 789 fragColor = velocity; 790}`,cT=`#version 300 es 791precision highp float; 792 793uniform sampler2D positionsTexture; 794uniform sampler2D levelFbo; 795uniform sampler2D randomValues; 796 797#ifdef USE_UNIFORM_BUFFERS 798layout(std140) uniform forceCenterUniforms { 799 float levelTextureSize; 800 float alpha; 801 float repulsion; 802} forceCenter; 803 804#define levelTextureSize forceCenter.levelTextureSize 805#define repulsion forceCenter.repulsion 806#define alpha forceCenter.alpha 807#else 808uniform float levelTextureSize; 809uniform float alpha; 810uniform float repulsion; 811#endif 812 813in vec2 textureCoords; 814out vec4 fragColor; 815 816// Calculate the additional velocity based on the center of mass 817vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) { 818 vec2 add = vec2(0.0); 819 vec4 centermass = texture(levelFbo, ij); 820 if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) { 821 vec2 centermassPosition = vec2(centermass.rg / centermass.b); 822 vec2 distVector = pp - centermassPosition; 823 float l = dot(distVector, distVector); 824 float dist = sqrt(l); 825 if (l > 0.0) { 826 float angle = atan(distVector.y, distVector.x); 827 float c = alpha * repulsion * centermass.b; 828 829 float distanceMin2 = 1.0; 830 if (l < distanceMin2) l = sqrt(distanceMin2 * l); 831 float addV = c / sqrt(l); 832 add = addV * vec2(cos(angle), sin(angle)); 833 } 834 } 835 return add; 836} 837 838void main() { 839 vec4 pointPosition = texture(positionsTexture, textureCoords); 840 vec4 random = texture(randomValues, textureCoords); 841 842 vec4 velocity = vec4(0.0); 843 844 // Calculate additional velocity based on the point position 845 velocity.xy += calculateAdditionalVelocity(pointPosition.xy / levelTextureSize, pointPosition.xy); 846 // Apply random factor to the velocity 847 velocity.xy += velocity.xy * random.rg; 848 849 fragColor = velocity; 850}`;class Aa extends wt{constructor(){super(...arguments),this.levels=0,this.levelTargets=new Map}create(){var e;const{device:i,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),b
850ytesPerRow:ue("rgba32float",a),mipLevel:0,x:0,y:0});continue}l&&(l.fbo.destroyed||l.fbo.destroy(),l.texture.destroyed||l.texture.destroy());const c=i.createTexture({width:a,height:a,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST});c.copyImageData({data:new Float32Array(a*a*4).fill(0),bytesPerRow:ue("rgba32float",a),mipLevel:0,x:0,y:0});const u=i.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=i.createTexture({width:n.pointsTextureSize,height:n.pointsTextureSize,format:"rgba32float",usage:j.SAMPLE|j.COPY_DST})),this.randomValuesTexture.copyImageData({data:r,bytesPerRow:ue("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=Gi(n.pointsTextureSize);this.pointIndices=i.createBuffer({data:o,usage:G.VERTEX|G.COPY_DST}),(e=this.calculateLevelsCommand)==null||e.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=n.pointsTextureSize,this.previousSpaceSize=n.adjustedSpaceSize}initPrograms(){const{device:e,store:i,data:n,points:s}=this;!n.pointsNumber||!s||!i.pointsTextureSize||(this.calculateLevelsUniformStore||(this.calculateLevelsUniformStore=new Se({calculateLevelsUniforms:{uniformTypes:{pointsTextureSize:"f32",levelTextureSize:"f32",cellSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize,levelTextureSize:0,cellSize:0}}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=new ge(e,{fs:oT,vs:aT,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 Se({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:i.alpha,repulsion:this.config.simulationRepulsion,spaceSize:i.adjustedSpaceSize,theta:this.config.simulationRepulsionTheta}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceCommand||(this.forceCommand=new ge(e,{fs:lT,vs:Ge,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 Se({forceCenterUniforms:{uniformTypes:{levelTextureSize:"f32",alpha:"f32",repulsion:"f32"},defaultUniforms:{levelTextureSize:0,alpha:i.alpha,repulsion:this.config.simulationRepulsion}}})),this.forceFromItsOwnCentermassCommand||(this.forceFromItsOwnCentermassCommand=new ge(e,{fs:cT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0}
850,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,i,n,s,r,o;(e=this.calculateLevelsCommand)==null||e.destroy(),this.calculateLevelsCommand=void 0,(i=this.forceCommand)==null||i.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:i,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=i.adjustedSpaceSize/a;this.calculateLevelsUniformStore.setUniforms({calculateLevelsUniforms:{pointsTextureSize:i.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:i,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:i.alpha,repulsion:this.config.simulationRepulsion,spaceSize:i.adjustedSpaceSize,theta:this.config.simulationRepulsionTheta}}),this.forceCommand.setBindings({positionsTexture:n.previousPositionTexture,levelFbo:o.texture}),this.forceCommand.draw(s),r===this.levels-1&&(this.forceCenterUniformStore.setUniforms({forceCenterUniforms:{levelTextureSize:a,alpha:i.alpha,repulsion:this.config.simulationRepulsion}}),this.forceFromItsOwnCentermassCommand.setBindings({positionsTexture:n.previousPositionTexture,randomValues:this.randomValuesTexture,levelFbo:o.texture}),this.forceFromItsOwnCentermassCommand.draw(s))}s.end()}}const uT=`#version 300 es 851precision highp float; 852 853uniform sampler2D positionsTexture; 854 855#ifdef USE_UNIFORM_BUFFERS 856layout(std140) uniform forceMouseUniforms { 857 float repulsion; 858 vec2 mousePos; 859} forceMouse; 860 861#define repulsion forceMouse.repulsion 862#define mousePos forceMouse.mousePos 863#else 864uniform float repulsion; 865uniform vec2 mousePos; 866#endif 867 868in vec2 textureCoords; 869out vec4 fragColor; 870 871void main() { 872 vec4 pointPosition = texture(positionsTexture, textureCoords); 873 vec4 velocity = vec4(0.0); 874 vec2 mouse = mousePos; 875 // Move particles away from the mouse position using a repulsive force 876 vec2 distVector = mouse - pointPosition.rg; 877 float dist = sqrt(dot(distVector, distVector)); 878 dist = max(dist, 10.0); 879 float angle = atan(distVector.y, distVector.x); 880 float addV = 100.0 * repulsion / (dist * dist); 881 velocity.rg -= addV * vec2(cos(angle), sin(angle)); 882 883 fragColor = velocity; 884}`;class Ra extends wt{initPrograms(){const{device:e,points:i}=this;i&&(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new Se({forceMouseUniforms:{uniformTypes:{repulsion:"f32",mousePos:"vec2<f32>"}}})),this.runCommand||(this.runCommand=new ge(e,{fs:uT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0}
884,bindings:{forceMouseUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceMouseUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,points:i,store:n}=this;if(!i||!this.runCommand||!this.uniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!i.velocityFbo||i.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceMouseUniforms:{repulsion:this.config.simulationRepulsionFromMouse,mousePos:ce(n.mousePosition,[0,0])}}),this.runCommand.setBindings({positionsTexture:i.previousPositionTexture});const s=e.beginRenderPass({framebuffer:i.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,i;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(i=this.uniformStore)==null||i.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const hT=`#version 300 es 885#ifdef GL_ES 886precision highp float; 887#endif 888 889in vec4 rgba; 890 891out vec4 fragColor; 892 893void main() { 894 fragColor = rgba; 895}`,fT=`#version 300 es 896#ifdef GL_ES 897precision highp float; 898#endif 899 900uniform sampler2D positionsTexture; 901uniform sampler2D clusterTexture; 902 903#ifdef USE_UNIFORM_BUFFERS 904layout(std140) uniform calculateCentermassUniforms { 905 float pointsTextureSize; 906 float clustersTextureSize; 907} calculateCentermass; 908 909#define pointsTextureSize calculateCentermass.pointsTextureSize 910#define clustersTextureSize calculateCentermass.clustersTextureSize 911#else 912uniform float pointsTextureSize; 913uniform float clustersTextureSize; 914#endif 915 916in vec2 pointIndices; 917 918out vec4 rgba; 919 920void main() { 921 vec4 pointPosition = texture(positionsTexture, pointIndices / pointsTextureSize); 922 rgba = vec4(pointPosition.xy, 1.0, 0.0); 923 924 vec4 pointClusterIndices = texture(clusterTexture, pointIndices / pointsTextureSize); 925 vec2 xy = vec2(0.0); 926 if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) { 927 xy = 2.0 * (pointClusterIndices.xy + 0.5) / clustersTextureSize - 1.0; 928 } 929 930 gl_Position = vec4(xy, 0.0, 1.0); 931 gl_PointSize = 1.0; 932} 933`,dT=`#version 300 es 934#ifdef GL_ES 935precision highp float; 936#endif 937 938uniform sampler2D positionsTexture; 939uniform sampler2D centermassTexture; 940uniform sampler2D clusterTexture; 941uniform sampler2D clusterPositionsTexture; 942uniform sampler2D clusterForceCoefficient; 943 944#ifdef USE_UNIFORM_BUFFERS 945layout(std140) uniform applyForcesUniforms { 946 float alpha; 947 float clustersTextureSize; 948 float clusterCoefficient; 949} applyForces; 950 951#define alpha applyForces.alpha 952#define clustersTextureSize applyForces.clustersTextureSize 953#define clusterCoefficient applyForces.clusterCoefficient 954#else 955uniform float alpha; 956uniform float clustersTextureSize; 957uniform float clusterCoefficient; 958#endif 959 960in vec2 textureCoords; 961 962out vec4 fragColor; 963 964 965void main() { 966 vec4 pointPosition = texture(positionsTexture, textureCoords); 967 vec4 velocity = vec4(0.0); 968 vec4 pointClusterIndices = texture(clusterTexture, textureCoords); 969 // no cluster, so no forces 970 if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) { 971 // positioning points to custom cluster position or either to the center of mass 972 vec2 clusterPositions = texture(clusterPositionsTexture, pointClusterIndices.xy / clustersTextureSize).xy; 973 if (clusterPositions.x < 0.0 || clusterPositions.y < 0.0) { 974 vec4 centermassValues = texture(centermassTexture, pointClusterIndices.xy / clustersTextureSize); 975 clusterPositions = centermassValues.xy / centermassValues.b; 976 } 977 vec4 clusterCustomCoeff = texture(clusterForceCoefficient, textureCoords); 978 vec2 distVector = clusterPositions.xy - pointPosition.xy; 979 float dist = length(distVector); 980 if (dist > 0.0) { 981 float addV = alpha * dist * clusterCoefficient * clusterCustomCoeff.r; 982 velocity.rg += addV * normalize(distVector); 983 } 984 } 985 986 fragColor = velocity; 987}`;class pT extends wt{constructor(){super(...arguments),this.cachedCentroidPositions=null}create(){var e,i;this.cachedCentroidPositions=null;const{device:n,store:s,data:r}=this,{pointsTextureSize:o}=s;
987if(r.pointsNumber===void 0||!r.pointClusters&&!r.clusterPositions)return;this.clusterCount=(r.pointClusters??[]).reduce((d,T)=>T===void 0||T<0?d:Math.max(d,T),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),h=new Float32Array(c).fill(-1),f=new Float32Array(l).fill(1);if(r.clusterPositions)for(let d=0;d<this.clusterCount;++d)h[d*4+0]=r.clusterPositions[d*2+0]??-1,h[d*4+1]=r.clusterPositions[d*2+1]??-1;for(let d=0;d<r.pointsNumber;++d){const T=(e=r.pointClusters)==null?void 0:e[d];T===void 0?(u[d*4+0]=-1,u[d*4+1]=-1):(u[d*4+0]=T%this.clustersTextureSize,u[d*4+1]=Math.floor(T/this.clustersTextureSize)),r.clusterStrength&&(f[d*4+0]=r.clusterStrength[d]??1)}if(!this.clusterTexture||a?(this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=n.createTexture({width:o,height:o,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST}),this.clusterTexture.copyImageData({data:u,bytesPerRow:ue("rgba32float",o),mipLevel:0,x:0,y:0})):this.clusterTexture.copyImageData({data:u,bytesPerRow:ue("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.cluster
987sTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST}),this.clusterPositionsTexture.copyImageData({data:h,bytesPerRow:ue("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0})):this.clusterPositionsTexture.copyImageData({data:h,bytesPerRow:ue("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:j.SAMPLE|j.RENDER|j.COPY_DST}),this.clusterForceCoefficientTexture.copyImageData({data:f,bytesPerRow:ue("rgba32float",o),mipLevel:0,x:0,y:0})):this.clusterForceCoefficientTexture.copyImageData({data:f,bytesPerRow:ue("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.cluster
987sTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST}),this.centermassTexture.copyImageData({data:new Float32Array(c).fill(0),bytesPerRow:ue("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:ue("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==o){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const d=Gi(s.pointsTextureSize);this.pointIndices=n.createBuffer({data:d,usage:G.VERTEX|G.COPY_DST}),(i=this.calculateCentermassCommand)==null||i.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=o,this.previousClustersTextureSize=this.clustersTextureSize,this.previousClusterCount=this.clusterCount}initPrograms(){const{device:e,store:i,data:n}=this;n.pointsNumber===void 0||!n.pointClusters&&!n.clusterPositions||(this.calculateCentermassUniformStore||(this.calculateCentermassUniformStore=new Se({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32",clustersTextureSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize,clustersTextureSize:this.cluster
987sTextureSize??0}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new ge(e,{fs:hT,vs:fT,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 Se({applyForcesUniforms:{uniformTypes:{alpha:"f32",clustersTextureSize:"f32",clusterCoefficient:"f32"},defaultUniforms:{alpha:i.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster}}})),this.applyForcesVertexCoordBuffer||(this.applyForcesVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.applyForcesCommand||(this.applyForcesCommand=new ge(e,{fs:dT,vs:Ge,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:i}=this;if(!i||!this.calculateCentermassCommand||!this.calculateCentermassUniformStore||!this.pointIndices||!this.centermassFbo||this.centermassFbo.destroyed||!this.clusterTexture||this.clusterTexture.destroyed||!i.previousPositionTexture||i.previousPositionTexture.destroyed)return;this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.calculateCentermassUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:this.store.pointsTextureSize,clustersTextureSize:this.cluster
987sTextureSize??0}}),this.calculateCentermassCommand.setBindings({clusterTexture:this.clusterTexture,positionsTexture:i.previousPositionTexture});const n=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateCentermassCommand.draw(n),n.end()}getCentroidPositions(){var e;const{config:{enableSimulation:i},store:{isSimulationRunning:n}}=this,s=!i||!n;if(s&&(e=this.points)!=null&&e.areClusterCentroidsUpToDate&&this.cachedCentroidPositions)return this.cachedCentroidPositions;if(this.calculateCentermass(),!this.centermassFbo||this.centermassFbo.destroyed||this.clusterCount===void 0)return[];const r=Ke(this.device,this.centermassFbo),o=[];o.length=this.clusterCount*2;for(let a=0;a<o.length/2;a+=1){const l=r[a*4+0],c=r[a*4+1],u=r[a*4+2];l!==void 0&&c!==void 0&&u!==void 0&&(o[a*2]=l/u,o[a*2+1]=c/u)}return s&&this.points&&(this.cachedCentroidPositions=o,this.points.areClusterCentroidsUpToDate=!0),o}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.cluster
987sTextureSize??0,clusterCoefficient:this.config.simulationCluster}}),this.applyForcesCommand.setBindings({clusterTexture:this.clusterTexture,centermassTexture:this.centermassTexture,clusterPositionsTexture:this.clusterPositionsTexture,clusterForceCoefficient:this.clusterForceCoefficientTexture,positionsTexture:this.points.previousPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.points.velocityFbo,clearColor:[0,0,0,0]});this.applyForcesCommand.draw(i),i.end()}destroy(){var e,i,n,s;this.cachedCentroidPositions=null,(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(i=this.applyForcesCommand)==null||i.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}}const _T=` 988 #gl-bench { 989 position:absolute; 990 right:0; 991 top:0; 992 z-index:1000; 993 -webkit-user-select: none; 994 -moz-user-select: none; 995 user-select: none; 996 } 997 #gl-bench div { 998 position: relative; 999 display: block; 1000 margin: 4px; 1001 padding: 0 7px 0 10px; 1002 background: #5f69de; 1003 border-radius: 15px; 1004 cursor: pointer; 1005 opacity: 0.9; 1006 } 1007 #gl-bench svg { 1008 height: 60px; 1009 margin: 0 -1px; 1010 } 1011 #gl-bench text { 1012 font-size: 12px; 1013 font-family: Helvetica,Arial,sans-serif; 1014 font-weight: 700; 1015 dominant-baseline: middle; 1016 text-anchor: middle; 1017 } 1018 #gl-bench .gl-mem { 1019 font-size: 9px; 1020 } 1021 #gl-bench line { 1022 stroke-width: 5; 1023 stroke: #112211; 1024 stroke-linecap: round; 1025 } 1026 #gl-bench polyline { 1027 fill: none; 1028 stroke: #112211; 1029 stroke-linecap: round; 1030 stroke-linejoin: round; 1031 stroke-width: 3.5; 1032 } 1033 #gl-bench rect { 1034 fill: #8288e4; 1035 } 1036 #gl-bench .opacity { 1037 stroke: #8288e4; 1038 } 1039`;class Ca{constructor(e){this.destroy();const i=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new Cg(i,{css:_T})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var i,n;(i=this.bench)==null||i.end("frame"),(n=this.bench)==null||n.nextFrame(e)}destroy(){this.bench=void 0,Me("#gl-bench").remove()}}const mT=` 1040vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) { 1041 vec2 divident = (1.0 - t) * (1.0 - t) * A + 2.0 * (1.0 - t) * t * w * ControlPoint + t * t * B; 1042 float divisor = (1.0 - t) * (1.0 - t) + 2.0 * (1.0 - t) * t * w + t * t; 1043 return divident / divisor; 1044} 1045`,ba={name:"conicParametricCurve",vs:mT},gT=`#version 300 es 1046#ifdef GL_ES 1047precision highp float; 1048#endif 1049 1050in vec4 rgbaColor; 1051in vec2 pos; 1052in float arrowLength; 1053in float useArrow; 1054in float smoothing; 1055in float arrowWidthFactor; 1056in float linkIndex; 1057 1058#ifdef USE_UNIFORM_BUFFERS 1059layout(std140) uniform drawLineFragmentUniforms { 1060 float renderMode; 1061} drawLineFrag; 1062 1063#define renderMode drawLineFrag.renderMode 1064#else 1065// renderMode: 0.0 = normal rendering, 1.0 = index buffer rendering for picking 1066uniform float renderMode; 1067#endif 1068 1069out vec4 fragColor; 1070 1071float map(float value, float min1, float max1, float min2, float max2) { 1072 return min2 + (value - min1) * (max2 - min2) / (max1 - min1); 1073} 1074 1075void main() { 1076 float opacity = 1.0; 1077 vec3 color = rgbaColor.rgb; 1078 1079 if (useArrow > 0.5) { 1080 float end_arrow = 0.5 + arrowLength / 2.0; 1081 float start_arrow = end_arrow - arrowLength; 1082 float arrowWidthDelta = arrowWidthFactor / 2.0; 1083 float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothing / 2.0, abs(pos.y)); 1084 float arrowOpacity = 1.0; 1085 if (pos.x > start_arrow && pos.x < start_arrow + arrowLength) { 1086 float xmapped = map(pos.x, start_arrow, end_arrow, 0.0, 1.0); 1087 arrowOpacity = rgbaColor.a * smoothstep(xmapped - smoothing, xmapped, map(abs(pos.y), 0.5, 0.0, 0.0, 1.0)); 1088 if (linkOpacity != arrowOpacity) { 1089 linkOpacity = max(linkOpacity, arrowOpacity); 1090 } 1091 } 1092 opacity = linkOpacity; 1093 } else opacity = rgbaColor.a * smoothstep(0.5, 0.5 - smoothing, abs(pos.y)); 1094 1095 if (renderMode > 0.0) { 1096 if (opacity <= 0.0) discard; 1097 fragColor = vec4(linkIndex, 0.0, 0.0, 1.0); 1098 } else fragColor = vec4(color, opacity); 1099 1100} 1101`,TT=`#version 300 es 1102#ifdef GL_ES 1103precision highp float; 1104#endif 1105 1106in vec2 position, pointA, pointB; 1107in vec4 sourceColor; 1108in vec4 targetColor; 1109in float sourceWidth; 1110in float targetWidth; 1111in float arrow; 1112in float linkIndices; 1113 1114uniform sampler2D positionsTexture; 1115uniform sampler2D linkStatus; 1116 1117#ifdef USE_UNIFORM_BUFFERS 1118layout(std140) uniform drawLineUniforms { 1119 mat4 transformationMatrix; 1120 float pointsTextureSize; 1121 float widthScale; 1122 float linkArrowsSizeScale; 1123 float spaceSize; 1124 vec2 screenSize; 1125 vec2 linkVisibilityDistanceRange; 1126 float linkVisibilityMinTransparency; 1127 float linkOpacity; 1128 float greyoutOpacity; 1129 float curvedWeight; 1130 float curvedLinkControlPointDistance; 1131 float curvedLinkSegments; 1132 float scaleLinksOnZoom; 1133 float maxPointSize; 1134 float renderMode; 1135 float hoveredLinkIndex; 1136 vec4 hoveredLinkColor; 1137 float hoveredLinkWidthIncrease; 1138 float isLinkHighlightingActive; 1139 float linkStatusTextureSize; 1140 float focusedLinkIndex; 1141 float focusedLinkWidthIncrease; 1142 float transitionProgress; 1143 float animateColors; 1144 float animateWidths; 1145} drawLine; 1146 1147#define transformationMatrix drawLine.transformationMatrix 1148#define pointsTextureSize drawLine.pointsTextureSize 1149#define widthScale drawLine.widthScale 1150#define linkArrowsSizeScale drawLine.linkArrowsSizeScale 1151#define spaceSize drawLine.spaceSize 1152#define screenSize drawLine.screenSize 1153#define linkVisibilityDistanceRange drawLine.linkVisibilityDistanceRange 1154#define linkVisibilityMinTransparency drawLine.linkVisibilityMinTransparency 1155#define linkOpacity drawLine.linkOpacity 1156#define greyoutOpacity drawLine.greyoutOpacity 1157#define curvedWeight drawLine.curvedWeight 1158#define curvedLinkControlPointDistance drawLine.curvedLinkControlPointDistance 1159#define curvedLinkSegments drawLine.curvedLinkSegments 1160#define scaleLinksOnZoom drawLine.scaleLinksOnZoom 1161#define maxPointSize drawLine.maxPointSize 1162#define renderMode drawLine.renderMode 1163#define hoveredLinkIndex drawLine.hoveredLinkIndex 1164#define hoveredLinkColor drawLine.hoveredLinkColor 1165#define hoveredLinkWidthIncrease drawLine.hoveredLinkWidthIncrease 1166#define isLinkHighlightingActive drawLine.isLinkHighlightingActive 1167#define linkStatusTextureSize drawLine.linkStatusTextureSize 1168#define focusedLinkIndex drawLine.focusedLinkIndex 1169#define focusedLinkWidthIncrease drawLine.focusedLinkWidthIncrease 1170#define transitionProgress drawLine.transitionProgress 1171#define animateColors drawLine.animateColors 1172#define animateWidths drawLine.animateWidths 1173#else 1174uniform mat3 transformationMatrix; 1175uniform float pointsTextureSize; 1176uniform float widthScale; 1177uniform float linkArrowsSizeScale; 1178uniform float spaceSize; 1179uniform vec2 screenSize; 1180uniform vec2 linkVisibilityDistanceRange; 1181uniform float linkVisibilityMinTransparency; 1182uniform float linkOpacity; 1183uniform float greyoutOpacity; 1184uniform float curvedWeight; 1185uniform float curvedLinkControlPointDistance; 1186uniform float curvedLinkSegments; 1187uniform bool scaleLinksOnZoom; 1188uniform float maxPointSize; 1189// renderMode: 0.0 = normal rendering, 1.0 = index buffer rendering for picking 1190uniform float renderMode; 1191uniform float hoveredLinkIndex; 1192uniform vec4 hoveredLinkColor; 1193uniform float hoveredLinkWidthIncrease; 1194uniform float isLinkHighlightingActive; 1195uniform float linkStatusTextureSize; 1196uniform float focusedLinkIndex; 1197uniform float focusedLinkWidthIncrease; 1198uniform float transitionProgress; 1199uniform float animateColors; 1200uniform float animateWidths; 1201#endif 1202 1203out vec4 rgbaColor; 1204out vec2 pos; 1205out float arrowLength; 1206out float useArrow; 1207out float smoothing; 1208out float arrowWidthFactor; 1209out float linkIndex; 1210 1211float map(float value, float min1, float max1, float min2, float max2) { 1212 return min2 + (value - min1) * (max2 - min2) / (max1 - min1); 1213} 1214 1215float calculateLinkWidth(float width) { 1216 float linkWidth; 1217 if (scaleLinksOnZoom > 0.0) { 1218 // Use original width if links should scale with zoom 1219 linkWidth = width; 1220 } else { 1221 // Adjust width based on zoom level to maintain visual size 1222 linkWidth = width / transformationMatrix[0][0]; 1223 // Apply a non-linear scaling to avoid extreme widths 1224 linkWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01)); 1225 } 1226 // Limit link width based on whether it has an arrow 1227 if (useArrow > 0.5) { 1228 return min(linkWidth, (maxPointSize * 2.0) / transformationMatrix[0][0]); 1229 } else { 1230 return min(linkWidth, maxPointSize / transformationMatrix[0][0]); 1231 } 1232} 1233 1234float calculateArrowWidth(float arrowWidth) { 1235 if (scaleLinksOnZoom > 0.0) { 1236 return arrowWidth; 1237 } else { 1238 // Apply the same scaling logic as calculateLinkWidth to maintain proportionality 1239 arrowWidth = arrowWidth / transformationMatrix[0][0]; 1240 // Apply the same non-linear scaling to avoid extreme widths 1241 arrowWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01)); 1242 return arrowWidth; 1243 } 1244} 1245 1246void main() { 1247 pos = position; 1248 linkIndex = linkIndices; 1249 1250 vec2 pointTexturePosA = (pointA + 0.5) / pointsTextureSize; 1251 vec2 pointTexturePosB = (pointB + 0.5) / pointsTextureSize; 1252 1253 vec4 pointPositionA = texture(positionsTexture, pointTexturePosA); 1254 vec4 pointPositionB = texture(positionsTexture, pointTexturePosB); 1255 vec2 a = pointPositionA.xy; 1256 vec2 b = pointPositionB.xy; 1257 1258 // Calculate direction vector and its perpendicular 1259 vec2 xBasis = b - a; 1260 vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); 1261 1262 // Calculate link distance and control point for curved link 1263 float linkDist = length(xBasis); 1264 float h = curvedLinkControlPointDistance; 1265 vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h; 1266 1267 // Convert link distance to screen pixels 1268 float linkDistPx = linkDist * transformationMatrix[0][0]; 1269 1270 float lineWidthBase = animateWidths > 0.0 1271 ? mix(sourceWidth, targetWidth, transitionProgress) 1272 : targetWidth; 1273 vec4 lineColor = animateColors > 0.0 1274 ? mix(sourceColor, targetColor, transitionProgress) 1275 : targetColor; 1276 1277 // Calculate line width using the width scale 1278 float linkWidth = lineWidthBase * widthScale; 1279 float k = 2.0; 1280 // Arrow width is proportionally larger than the line width 1281 float arrowWidth = linkWidth * k; 1282 arrowWidth *= linkArrowsSizeScale; 1283 1284 // Ensure arrow width difference is non-negative to prevent unwanted changes to link width 1285 float arrowWidthDifference = max(0.0, arrowWidth - linkWidth); 1286 1287 // Calculate arrow width in pixels 1288 float arrowWidthPx = calculateArrowWidth(arrowWidth); 1289 1290 // Calculate arrow length proportional to its width 1291 // 0.866 is approximately sqrt(3)/2 - related to equilateral triangle geometry 1292 // Cap the length to avoid overly long arrows on short links 1293 arrowLength = min(0.3, (0.866 * arrowWidthPx * 2.0) / linkDist); 1294 1295 useArrow = arrow; 1296 if (useArrow > 0.5) { 1297 linkWidth += arrowWidthDifference; 1298 } 1299 1300 arrowWidthFactor = arrowWidthDifference / linkWidth; 1301 1302 // Calculate final link width in pixels with smoothing 1303 float linkWidthPx = calculateLinkWidth(linkWidth); 1304 1305 if (renderMode > 0.0) { 1306 // Add 5 pixels padding for better hover detection 1307 linkWidthPx += 5.0 / transformationMatrix[0][0]; 1308 // Match the visible-pass width increases so the pickable area covers the full rendered link 1309 if (hoveredLinkIndex == linkIndex) { 1310 linkWidthPx += hoveredLinkWidthIncrease / transformationMatrix[0][0]; 1311 } 1312 if (focusedLinkIndex == linkIndex) { 1313 linkWidthPx += focusedLinkWidthIncrease / transformationMatrix[0][0]; 1314 } 1315 } else { 1316 // Add pixel increase if this is the hovered link 1317 if (hoveredLinkIndex == linkIndex) { 1318 linkWidthPx += hoveredLinkWidthIncrease / transformationMatrix[0][0]; 1319 } 1320 // Add pixel increase if this is the focused link 1321 if (focusedLinkIndex == linkIndex) { 1322 linkWidthPx += focusedLinkWidthIncrease / transformationMatrix[0][0]; 1323 } 1324 }
1325 float smoothingPx = 0.5 / transformationMatrix[0][0]; 1326 smoothing = smoothingPx / linkWidthPx; 1327 linkWidthPx += smoothingPx; 1328 1329 1330 1331 // Calculate final color with opacity based on link distance 1332 vec3 rgbColor = lineColor.rgb; 1333 // Adjust opacity based on link distance 1334 float opacity = lineColor.a * linkOpacity * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0)); 1335 1336 // Apply greyed-out opacity from link status texture 1337 if (isLinkHighlightingActive > 0.0 && linkStatusTextureSize > 0.0) { 1338 float texX = mod(linkIndices, linkStatusTextureSize); 1339 float texY = floor(linkIndices / linkStatusTextureSize); 1340 vec2 linkStatusCoord = (vec2(texX, texY) + 0.5) / linkStatusTextureSize; 1341 vec4 linkStatusValue = texture(linkStatus, linkStatusCoord); 1342 if (linkStatusValue.r > 0.0) { 1343 opacity *= greyoutOpacity; 1344 } 1345 } 1346 1347 // Pass final color to fragment shader 1348 rgbaColor = vec4(rgbColor, opacity); 1349 1350 // Apply hover color if this is the hovered link and hover color is defined 1351 if (hoveredLinkIndex == linkIndex && hoveredLinkColor.a > -0.5) { 1352 // Keep existing RGB values but multiply opacity with hover color opacity 1353 rgbaColor.rgb = hoveredLinkColor.rgb; 1354 rgbaColor.a *= hoveredLinkColor.a; 1355 } 1356 1357 // Calculate position on the curved path 1358 float t = position.x; 1359 float w = curvedWeight; 1360 1361 float tPrev = t - 1.0 / curvedLinkSegments; 1362 float tNext = t + 1.0 / curvedLinkSegments; 1363 1364 vec2 pointCurr = conicParametricCurve(a, b, controlPoint, t, w); 1365 1366 vec2 pointPrev = conicParametricCurve(a, b, controlPoint, max(0.0, tPrev), w); 1367 vec2 pointNext = conicParametricCurve(a, b, controlPoint, min(tNext, 1.0), w); 1368 1369 vec2 xBasisCurved = pointNext - pointPrev; 1370 vec2 yBasisCurved = normalize(vec2(-xBasisCurved.y, xBasisCurved.x)); 1371 1372 pointCurr += yBasisCurved * linkWidthPx * position.y; 1373 1374 // Transform to clip space coordinates 1375 vec2 p = 2.0 * pointCurr / spaceSize - 1.0; 1376 p *= spaceSize / screenSize; 1377 1378 #ifdef USE_UNIFORM_BUFFERS 1379 mat3 transformMat3 = mat3(transformationMatrix); 1380 vec3 final = transformMat3 * vec3(p, 1); 1381 #else 1382 vec3 final = transformationMatrix * vec3(p, 1); 1383 #endif 1384 1385 gl_Position = vec4(final.rg, 0, 1); 1386}`,ST=`#version 300 es 1387#ifdef GL_ES 1388precision highp float; 1389#endif 1390 1391in vec4 rgba; 1392 1393out vec4 fragColor; 1394 1395void main() { 1396 fragColor = rgba; 1397} 1398`,xT=`#version 300 es 1399#ifdef GL_ES 1400precision highp float; 1401#endif 1402 1403in vec2 pointA; 1404in vec2 pointB; 1405in float linkIndices; 1406 1407uniform sampler2D positionsTexture; 1408 1409#ifdef USE_UNIFORM_BUFFERS 1410layout(std140) uniform fillSampledLinksUniforms { 1411 float pointsTextureSize; 1412 mat4 transformationMatrix; 1413 float spaceSize; 1414 vec2 screenSize; 1415 float curvedWeight; 1416 float curvedLinkControlPointDistance; 1417 float curvedLinkSegments; 1418} fillSampledLinks; 1419 1420#define pointsTextureSize fillSampledLinks.pointsTextureSize 1421#define transformationMatrix fillSampledLinks.transformationMatrix 1422#define spaceSize fillSampledLinks.spaceSize 1423#define screenSize fillSampledLinks.screenSize 1424#define curvedWeight fillSampledLinks.curvedWeight 1425#define curvedLinkControlPointDistance fillSampledLinks.curvedLinkControlPointDistance 1426#define curvedLinkSegments fillSampledLinks.curvedLinkSegments 1427#else 1428uniform float pointsTextureSize; 1429uniform float spaceSize; 1430uniform vec2 screenSize; 1431uniform float curvedWeight; 1432uniform float curvedLinkControlPointDistance; 1433uniform float curvedLinkSegments; 1434uniform mat3 transformationMatrix; 1435#endif 1436 1437out vec4 rgba; 1438 1439void main() { 1440 vec4 posA = texture(positionsTexture, (pointA + 0.5) / pointsTextureSize); 1441 vec4 posB = texture(positionsTexture, (pointB + 0.5) / pointsTextureSize); 1442 vec2 a = posA.rg; 1443 vec2 b = posB.rg; 1444 1445 vec2 tangent = b - a; 1446 float angle = -atan(tangent.y, tangent.x); 1447 1448 vec2 mid; 1449 if (curvedLinkSegments <= 1.0) { 1450 mid = (a + b) * 0.5; 1451 } else if (curvedLinkControlPointDistance != 0.0 && curvedWeight != 0.0) { 1452 vec2 xBasis = b - a; 1453 vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); 1454 float linkDist = length(xBasis); 1455 float h = curvedLinkControlPointDistance; 1456 vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h; 1457 mid = conicParametricCurve(a, b, controlPoint, 0.5, curvedWeight); 1458 } else { 1459 mid = (a + b) * 0.5; 1460 } 1461 1462 vec2 p = 2.0 * mid / spaceSize - 1.0; 1463 p *= spaceSize / screenSize; 1464 #ifdef USE_UNIFORM_BUFFERS 1465 mat3 transformMat3 = mat3(transformationMatrix); 1466 vec3 final = transformMat3 * vec3(p, 1); 1467 #else 1468 vec3 final = transformationMatrix * vec3(p, 1); 1469 #endif 1470 1471 vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0;
1472 rgba = vec4(linkIndices, mid.x, mid.y, angle); 1473 float i = (pointScreenPosition.x + 0.5) / screenSize.x; 1474 float j = (pointScreenPosition.y + 0.5) / screenSize.y; 1475 gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0); 1476 1477 gl_PointSize = 1.0; 1478} 1479`,yT=`#version 300 es 1480#ifdef GL_ES 1481precision highp float; 1482#endif 1483 1484uniform sampler2D linkIndexTexture; 1485 1486#ifdef USE_UNIFORM_BUFFERS 1487layout(std140) uniform hoveredLineIndexUniforms { 1488 vec2 mousePosition; 1489 vec2 screenSize; 1490} hoveredLine; 1491 1492#define mousePosition hoveredLine.mousePosition 1493#define screenSize hoveredLine.screenSize 1494#else 1495uniform vec2 mousePosition; 1496uniform vec2 screenSize; 1497#endif 1498 1499out vec4 fragColor; 1500 1501void main() { 1502 // Convert mouse position to texture coordinates 1503 vec2 texCoord = mousePosition / screenSize; 1504 1505 // Read the link index from the linkIndexFbo texture at mouse position 1506 vec4 linkIndexData = texture(linkIndexTexture, texCoord); 1507 1508 // Extract the link index (stored in the red channel) 1509 float linkIndex = linkIndexData.r; 1510 1511 // Check if there's a valid link at this position (alpha > 0) 1512 if (linkIndexData.a > 0.0 && linkIndex >= 0.0) { 1513 // Output the link index 1514 fragColor = vec4(linkIndex, 0.0, 0.0, 1.0); 1515 } else { 1516 // No link at this position, output -1 to indicate no hover 1517 fragColor = vec4(-1.0, 0.0, 0.0, 0.0); 1518 } 1519} `,vT=`#version 300 es 1520#ifdef GL_ES 1521precision highp float; 1522#endif 1523 1524in vec2 vertexCoord; 1525 1526void main() { 1527 gl_Position = vec4(vertexCoord, 0.0, 1.0); 1528} `,ET=t=>{const e=Dc().exponent(2).range([0,1]).domain([-1,1]),i=Oc(0,t).map(s=>-.5+s/t);i.push(.5);const n=new Array(i.length*2);return i.forEach((s,r)=>{n[r*2]=[e(s*2),.5],n[r*2+1]=[e(s*2),-.5]}),n};class AT extends wt{constructor(){super(...arguments),this.linkStatusTextureSize=0,this.transitionProgress=1,this.shouldAnimateLinkColors=!1,this.shouldAnimateLinkWidths=!1}initPrograms(){const{device:e,config:i,store:n,data:s}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST,data:new Float32Array(4).fill(0)})),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=e.createFramebuffer({width:1,height:1,colorAttachments:[this.hoveredLineIndexTexture]})),this.curveLineGeometry||this.updateCurveLineGeometry();const r=this.data.linksNumber??0;this.pointABuffer||(this.pointABuffer=e.createBuffer({data:new Float32Array(r*2),usage:G.VERTEX|G.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=e.createBuffer({data:new Float32Array(r*2),usage:G.VERTEX|G.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=e.createBuffer({data:new Float32Array(r),usage:G.VERTEX|G.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=e.createBuffer({data:new Float32Array(r),usage:G.VERTEX|G.COPY_DST})),this.drawLineUniformStore||(this.drawLineUniformStore=new Se({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",isLinkHighlightingActive:"f32",linkStatusTextureSize:"f32",focusedLinkIndex:"f32",focusedLinkWidthIncrease:"f32",transitionProgress:"f32",animateColors:"f32",animateWidths:"f32"},defaultUniforms:{transformationMatrix:n.transformationMatrix4x4,pointsTextureSize:n.pointsTextureSize,widthScale:i.linkWidthScale,linkArrowsSizeScale:i.linkArrowsSizeScale,spaceSize:n.adjustedSpaceSize,screenSize:ce(n.screenSize,[0,0]),linkVisibilityDistanceRange:ce(i.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:i.linkVisibilityMinTransparency,linkOpacity:i.linkOpacity,greyoutOpacity:i.linkGreyoutOpacity,curvedWeight:i.curvedLinkWeight,curvedLinkControlPointDistance:i.curvedLinkControlPointDistance,curvedLinkSegments:i.curvedLinks?i.curvedLinkSegments:1,scaleLinksOnZoom:i.scaleLinksOnZoom?1:0,maxPointSize:n.maxPointSize,renderMode:0,hoveredLinkIndex:n.hoveredLinkIndex??-1,hoveredLinkColor:we(n.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:i.hoveredLinkWidthIncrease,isLinkHighlightingActive:0,linkStatusTextureSize:0,focusedLinkIndex:i.focusedLinkIndex??-1,focusedLinkWidthIncrease:i.focusedLinkWidthIncrease,transitionProgress:1,animateColors:0,animateWidths:0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}}
1528)),this.drawCurveCommand||(this.drawCurveCommand=this.createDrawCurveCommand(this.getLinkBlendParameters(this.config.linkBlending))),this.isLinkBlendingActive=this.config.linkBlending,this.quadBuffer||(this.quadBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:G.VERTEX|G.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new Se({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:ce(n.screenMousePosition,[0,0]),screenSize:ce(n.screenSize,[0,0])}}})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=new ge(e,{vs:vT,fs:yT,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.quadBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(e,"hoveredLineIndexUniforms")}})),this.fillSampledLinksUniformStore||(this.fillSampledLinksUniformStore=new Se({fillSampledLinksUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32"},defaultUniforms:{pointsTextureSize:n.pointsTextureSize??0,transformationMatrix:n.transformationMatrix4x4,spaceSize:n.adjustedSpaceSize,screenSize:ce(n.screenSize,[0,0]),curvedWeight:i.curvedLinkWeight,curvedLinkControlPointDistance:i.curvedLinkControlPointDistance,curvedLinkSegments:i.curvedLinks?i.curvedLinkSegments:1}}})),this.fillSampledLinksFboCommand||(this.fillSampledLinksFboCommand=new ge(e,{fs:ST,vs:xT,modules:[ba],topology:"point-list",vertexCount:s.linksNumber??0,attributes:{...this.pointABuffer&&{pointA:this.pointABuffer},...this.pointBBuffer&&{pointB:this.pointBBuffer},...this.linkIndexBuffer&&{linkIndices:this.linkIndexBuffer}},bufferLayout:[{name:"pointA",format:"float32x2"},{name:"pointB",format:"float32x2"},{name:"linkIndices",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledLinksUniforms:this.fillSampledLinksUniformStore.getManagedUniformBuffer(e,"fillSampledLinksUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.updateSampledLinksGrid(),this.updateLinkStatus()}draw(e){const{config:i,points:n,store:s}=this;if(!n||!n.currentPositionTexture||n.currentPositionTexture.destroyed||((!this.pointABuffer||!this.pointBBuffer)&&this.updatePointsBuffer(),this.targetColorBuffer||this.updateColor(),this.targetWidthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!this.drawCurveCommand||!this.drawLineUniformStore||!this.linkStatusTexture))return;this.updateLinkBlending();const r=i.highlightedLinkIndices!==void 0;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:s.transformationMatrix4x4,pointsTextureSize:s.pointsTextureSize,widthScale:i.linkWidthScale,linkArrowsSizeScale:i.linkArrowsSizeScale,spaceSize:s.adjustedSpaceSize,screenSize:ce(s.screenSize,[0,0]),linkVisibilityDistanceRange:ce(i.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:i.linkVisibilityMinTransparency,linkOpacity:i.linkOpacity,greyoutOpacity:i.linkGreyoutOpacity,curvedWeight:i.curvedLinkWeight,curvedLinkControlPointDistance:i.curvedLinkControlPointDistance,curvedLinkSegments:i.curvedLinks?i.curvedLinkSegments:1,scaleLinksOnZoom:i.scaleLinksOnZoom?1:0,maxPointSize:s.maxPointSize,renderMode:0,hoveredLinkIndex:s.hoveredLinkIndex??-1,hoveredLinkColor:we(s.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:i.hoveredLinkWidthIncrease,isLinkHighlightingActive:r?1:0,linkStatusTextureSize:this.linkStatusTextureSize,focusedLinkIndex:i.focusedLinkIndex??-1,focusedLinkWidthIncrease:i.focusedLinkWidthIncrease,transitionProgress:this.transitionProgress,animateColors:this.shouldAnimateLinkColors?1:0,animateWidths:this.shouldAnimateLinkWidths?1:0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({positionsTexture:n.currentPositionTexture,linkStatus:this.linkStatusTexture}
1528),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e)}updateLinkIndexFbo(){var e,i;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||((i=this.previousScreenSize)==null?void 0:i[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:j.SAMPLE|j.RENDER|j.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(o*a*4).fill(0),bytesPerRow:ue("rgba32float",o),mipLevel:0,x:0,y:0}),this.linkIndexFbo=n.createFramebuffer({width:o,height:a,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[o,a])}updateSampledLinksGrid(){const{store:{screenSize:e},config:{linkSamplingDistance:i},device:n}=this;let s=i??Math.min(...e)/2;s===0&&(s=bt.linkSamplingDistance);const r=Math.ceil(e[0]/s),o=Math.ceil(e[1]/s);r===0||o===0||(!this.sampledLinksFbo||this.sampledLinksFbo.width!==r||this.sampledLinksFbo.height!==o)&&(this.sampledLinksFbo&&!this.sampledLinksFbo.destroyed&&this.sampledLinksFbo.destroy(),this.sampledLinksFbo=n.createFramebuffer({width:r,height:o,c
1528olorAttachments:["rgba32float"]}))}updatePointsBuffer(){var e;const{device:i,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],h=n.links[c*2+1],f=u%s.pointsTextureSize,d=Math.floor(u/s.pointsTextureSize),T=h%s.pointsTextureSize,C=Math.floor(h/s.pointsTextureSize);r[c*2]=f,r[c*2+1]=d,o[c*2]=T,o[c*2+1]=C}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=i.createBuffer({data:r,usage:G.VERTEX|G.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||a!==n.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=i.createBuffer({data:o,usage:G.VERTEX|G.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=i.createBuffer({data:l,usage:G.VERTEX|G.COPY_DST})):this.linkIndexBuffer.write(l),this.setDrawCurveCommandAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer}),this.fillSampledLinksFboCommand&&this.fillSampledLinksFboCommand.setAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer}),this.updateSampledLinksGrid(),this.config.highlightedLinkIndices!==void 0&&this.updateLinkStatus()}updateColor(){const{data:e}=this,i=e.linksNumber??0,n=e.linkColors??new Float32Array(i*4).fill(0),{source:s,target:r,previous:o}=qn(this.device,n,this.sourceColorBuffer,this.targetColorBuffer,this.previousColorData,4);this.sourceColorBuffer=s,this.targetColorBuffer=r,this.previousColorData=o,this.setDrawCurveCommandAttributes({...this.sourceColorBuffer&&{sourceColor:this.sourceColorBuffer},...this.targetColorBuffer&&{targetColor:this.targetColorBuffer}})}updateWidth(){const{data:e}=this,i=e.linksNumber??0,n=e.linkWidths??new Float32Array(i).fill(0),{source:s,target:r,previous:o}=qn(this.device,n,this.sourceWidthBuffer,this.targetWidthBuffer,this.previousWidthData,1);this.sourceWidthBuffer=s,this.targetWidthBuffer=r,this.previousWidthData=o,this.setDrawCurveCommandAttributes({...this.sourceWidthBuffer&&{sourceWidth:this.sourceWidthBuffer},...this.targetWidthBuffer&&{targetWidth:this.targetWidthBuffer}})}updateArrow(){const{device:e,data:i}=this,n=i.linksNumber??0,s=i.linkArrows?new Float32Array(i.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:G.VERTEX|G.COPY_DST})):this.arrowBuffer.write(s):this.arrowBuffer=e.createBuffer({data:s,usage:G.VERTEX|G.COPY_DST}),this.setDrawCurveCommandAttributes({arrow:this.arrowBuffer})}updateLinkStatus(){const{device:e,config:i,data:n}=this,s=n.linksNumber??0;if(!s){this.linkStatusTexture||this.ensureLinkStatusPlaceholder();return}const{highlightedLinkIndices:r}=i;if(r===void 0){this.linkStatusTexture||this.ensureLinkStatusPlaceholder(),this.linkStatusTextureSize=0;return}const o=Math.ceil(Math.sqrt(s));this.linkStatusTextureSize=o;const a=new Float32Array(o*o*4);for(let c=0;c<s;c++)a[c*4]=1;for(const c of r)c>=0&&c<s&&(a[c*4]=0);const l={data:a,bytesPerRow:ue("rgba32float",o),mipLevel:0,x:0,y:0};!this.linkStatusTexture||this.linkStatusTexture.width!==o||this.linkStatusTexture.height!==o?(this.linkStatusTexture&&!this.linkStatusTexture.destroyed&&this.linkStatusTexture.destroy(),this.linkStatusTexture=e.createTexture({width:o,height:o,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST}),this.linkStatusTexture.copyImageData(l)):this.linkStatusTexture.copyImageData(l)}updateCurveLineGeometry(){var e,i;const{device:n,config:{curvedLinks:s,curvedLinkSegments:r}}=this;this.curveLineGeometry=ET(s?r:1);const o=new Float32Array(this.curveLineGeometry.length*2);for(let a=0;a<this.curveLineGeometry.length;a++)o[a*2]=this.curveLineGeometry[a][0],o[a*2+1]=this.curveLineGeometry[a][1];!this.curveLineBuffer||this.curveLineBuffer.byteLength!==o.byteLength?(this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=n.createBuffer({data:o,usage:G.VERTEX|G.COPY_DST}
1528)):this.curveLineBuffer.write(o),this.setDrawCurveCommandAttributes({position:this.curveLineBuffer}),(e=this.drawCurveCommand)==null||e.setVertexCount(this.curveLineGeometry.length),(i=this.drawCurvePickingCommand)==null||i.setVertexCount(this.curveLineGeometry.length)}updateLinkBlending(){var e;const i=this.config.linkBlending;i!==this.isLinkBlendingActive&&((e=this.drawCurveCommand)==null||e.setParameters(this.getLinkBlendParameters(i)),this.isLinkBlendingActive=i)}getSampledLinkPositionsMap(){const e=new Map;if(!this.sampledLinksFbo||this.sampledLinksFbo.destroyed)return e;const i=this.points;if(!(i!=null&&i.currentPositionTexture)||i.currentPositionTexture.destroyed)return e;if(this.fillSampledLinksFboCommand&&this.fillSampledLinksUniformStore&&this.sampledLinksFbo){this.fillSampledLinksFboCommand.setVertexCount(this.data.linksNumber??0),this.fillSampledLinksUniformStore.setUniforms({fillSampledLinksUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize,screenSize:ce(this.store.screenSize,[0,0]),curvedWeight:this.config.curvedLinkWeight,curvedLinkControlPointDistance:this.config.curvedLinkControlPointDistance,curvedLinkSegments:this.config.curvedLinks?this.config.curvedLinkSegments:1}}),this.fillSampledLinksFboCommand.setBindings({positionsTexture:i.currentPositionTexture});const s=this.device.beginRenderPass({framebuffer:this.sampledLinksFbo,clearColor:[-1,-1,-1,-1]});this.fillSampledLinksFboCommand.draw(s),s.end()}const n=Ke(this.device,this.sampledLinksFbo);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];r!==void 0&&r>=0&&o!==void 0&&a!==void 0&&l!==void 0&&e.set(Math.round(r),[o,a,l])}return e}getSampledLinks(){const e=[],i=[],n=[];if(!this.sampledLinksFbo||this.sampledLinksFbo.destroyed)return{indices:e,positions:i,angles:n};const s=this.points;if(!(s!=null&&s.currentPositionTexture)||s.currentPositionTexture.destroyed)return{indices:e,positions:i,angles:n};if(this.fillSampledLinksFboCommand&&this.fillSampledLinksUniformStore&&this.sampledLinksFbo){this.fillSampledLinksFboCommand.setVertexCount(this.data.linksNumber??0),this.fillSampledLinksUniformStore.setUniforms({fillSampledLinksUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize,screenSize:ce(this.store.screenSize,[0,0]),curvedWeight:this.config.curvedLinkWeight,curvedLinkControlPointDistance:this.config.curvedLinkControlPointDistance,curvedLinkSegments:this.config.curvedLinks?this.config.curvedLinkSegments:1}}),this.fillSampledLinksFboCommand.setBindings({positionsTexture:s.currentPositionTexture});const o=this.device.beginRenderPass({framebuffer:this.sampledLinksFbo,clearColor:[-1,-1,-1,-1]});this.fillSampledLinksFboCommand.draw(o),o.end()}const r=Ke(this.device,this.sampledLinksFbo);for(let o=0;o<r.length/4;o++){const a=r[o*4],l=r[o*4+1],c=r[o*4+2],u=r[o*4+3];a!==void 0&&a>=0&&l!==void 0&&c!==void 0&&u!==void 0&&(e.push(Math.round(a)),i.push(l,c),n.push(u))}return{indices:e,positions:i,angles:n}}findHoveredLine(){const{config:e,points:i,store:n}=this;if(!i||!i.currentPositionTexture||i.currentPositionTexture.destroyed||!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawLineUniformStore||!this.linkStatusTexture||!this.linkIndexTexture||this.linkIndexTexture.destroyed)return;this.drawCurvePickingCommand||(this.drawCurvePickingCommand=this.createDrawCurveCommand(this.getLinkBlendParameters(!1)));const s=e.highlightedLinkIndices!==void 0;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:n.transformationMatrix4x4,pointsTextureSize:n.pointsTextureSize,widthScale:e.linkWidthScale,linkArrowsSizeScale:e.linkArrowsSizeScale,spaceSize:n.adjustedSpaceSize,screenSize:ce(n.screenSize,[0,0]),linkVisibilityDistanceRange:ce(e.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:e.linkVisibilityMinTransparency,linkOpacity:e.linkOpacity,greyoutOpacity:e.linkGreyoutOpacity,curvedWeight:e.curvedLinkWeight,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom?1:0,maxPointSize:n.maxPointSize,renderMode:1,hoveredLinkIndex:n.hoveredLinkIndex??-1,hoveredLinkColor:we(n.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease,isLinkHighlightingActive:s?1:0,linkStatusTextureSize:this.linkStatusTextureSize,focusedLinkIndex:e.focusedLinkIndex??-1,focusedLinkWidthIncrease:e.focusedLinkWidthIncrease,transitionProgress:this.transitionProgress,animateColors:this.shouldAnimateLinkColors?1:0,animateWidths:this.shouldAnimateLinkWidths?1:0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurvePickingCommand.setBindings({positionsTexture:i.currentPositionTexture,linkStatus:this.linkStatusTexture}),this.drawCurvePickingCommand.setInstanceCount(this.data.linksNumber??0);const r=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurvePickingCommand.draw(r),r.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:ce(n.screenMousePosition,[0,0]),screenSize:ce(n.screenSize,[0,0])}}),this.hoveredLineIndexCommand.setBindings({linkIndexTexture:this.linkIndexTexture});const o=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(o),o.end()}}setTransitionProgress(e,i=!1,n=!1){this.transitionProgress=e,this.shouldAnimateLinkColors=i,this.shouldAnimateLinkWidths=n}destroy(){var e,i,n,s,r,o,a;
1528(e=this.drawCurveCommand)==null||e.destroy(),this.drawCurveCommand=void 0,(i=this.drawCurvePickingCommand)==null||i.destroy(),this.drawCurvePickingCommand=void 0,this.isLinkBlendingActive=void 0,(n=this.hoveredLineIndexCommand)==null||n.destroy(),this.hoveredLineIndexCommand=void 0,(s=this.fillSampledLinksFboCommand)==null||s.destroy(),this.fillSampledLinksFboCommand=void 0,this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexFbo=void 0,this.sampledLinksFbo&&!this.sampledLinksFbo.destroyed&&this.sampledLinksFbo.destroy(),this.sampledLinksFbo=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,this.linkStatusTexture&&!this.linkStatusTexture.destroyed&&this.linkStatusTexture.destroy(),this.linkStatusTexture=void 0,(r=this.drawLineUniformStore)==null||r.destroy(),this.drawLineUniformStore=void 0,(o=this.hoveredLineIndexUniformStore)==null||o.destroy(),this.hoveredLineIndexUniformStore=void 0,(a=this.fillSampledLinksUniformStore)==null||a.destroy(),this.fillSampledLinksUniformStore=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.sourceColorBuffer&&!this.sourceColorBuffer.destroyed&&this.sourceColorBuffer.destroy(),this.sourceColorBuffer=void 0,this.targetColorBuffer&&!this.targetColorBuffer.destroyed&&this.targetColorBuffer.destroy(),this.targetColorBuffer=void 0,this.previousColorData=void 0,this.sourceWidthBuffer&&!this.sourceWidthBuffer.destroyed&&this.sourceWidthBuffer.destroy(),this.sourceWidthBuffer=void 0,this.targetWidthBuffer&&!this.targetWidthBuffer.destroyed&&this.targetWidthBuffer.destroy(),this.targetWidthBuffer=void 0,this.previousWidthData=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}createDrawCurveCommand(e){var i;if(!this.drawLineUniformStore)throw new Error("Draw line uniforms must be initialized before creating link draw commands");return new ge(this.device,{vs:TT,fs:gT,modules:[ba],topology:"triangle-strip",vertexCount:((i=this.curveLineGeometry)==null?void 0:i.length)??0,attributes:this.getDrawCurveCommandAttributes(),bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"sourceColor",format:"float32x4",stepMode:"instance"},{name:"targetColor",format:"float32x4",stepMode:"instance"},{name:"sourceWidth",format:"float32",stepMode:"instance"},{name:"targetWidth",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(this.device,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineFragmentUniforms")},parameters:e})}getDrawCurveCommandAttributes(){const e={};return this.curveLineBuffer&&(e.position=this.curveLineBuffer),this.pointABuffer&&(e.pointA=this.pointABuffer),this.pointBBuffer&&(e.pointB=this.pointBBuffer),this.sourceColorBuffer&&(e.sourceColor=this.sourceColorBuffer),this.targetColorBuffer&&(e.targetColor=this.targetColorBuffer),this.sourceWidthBuffer&&(e.sourceWidth=this.sourceWidthBuffer),this.targetWidthBuffer&&(e.targetWidth=this.targetWidthBuffer),this.arrowBuffer&&(e.arrow=this.arrowBuffer),this.linkIndexBuffer&&(e.linkIndices=this.linkIndexBuffer),e}
1528setDrawCurveCommandAttributes(e){var i,n;(i=this.drawCurveCommand)==null||i.setAttributes(e),(n=this.drawCurvePickingCommand)==null||n.setAttributes(e)}getLinkBlendParameters(e){const i={cullMode:"back",depthWriteEnabled:!1,depthCompare:"always"};return e?{...i,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"}:{...i,blend:!1}}ensureLinkStatusPlaceholder(){this.linkStatusTexture&&!this.linkStatusTexture.destroyed||(this.linkStatusTexture=this.device.createTexture({width:1,height:1,format:"rgba32float",usage:j.SAMPLE|j.RENDER|j.COPY_DST,data:new Float32Array(4).fill(0)}),this.linkStatusTextureSize=0)}}const RT=`#version 300 es 1529#ifdef GL_ES 1530precision highp float; 1531#endif 1532 1533uniform sampler2D imageAtlasTexture; 1534 1535#ifdef USE_UNIFORM_BUFFERS 1536layout(std140) uniform drawFragmentUniforms { 1537 float greyoutOpacity; 1538 float pointOpacity; 1539 float isDarkenGreyout; 1540 vec4 backgroundColor; 1541 vec4 outlineColor; 1542 float outlineWidth; 1543} drawFragment; 1544 1545#define greyoutOpacity drawFragment.greyoutOpacity 1546#define pointOpacity drawFragment.pointOpacity 1547#define isDarkenGreyout drawFragment.isDarkenGreyout 1548#define backgroundColor drawFragment.backgroundColor 1549#define outlineColor drawFragment.outlineColor 1550#define outlineWidth drawFragment.outlineWidth 1551#else 1552uniform float greyoutOpacity; 1553uniform float pointOpacity; 1554uniform float isDarkenGreyout; 1555uniform vec4 backgroundColor; 1556uniform vec4 outlineColor; 1557uniform float outlineWidth; 1558#endif 1559 1560 1561in float pointShape; 1562in float isGreyedOut; 1563in float isOutlined; 1564in vec4 shapeColor; 1565in vec4 imageAtlasUV; 1566in float shapeSize; 1567in float imageSizeVarying; 1568in float overallSize; 1569 1570out vec4 fragColor; 1571 1572// Smoothing controls the smoothness of the point's edge 1573const float smoothing = 0.9; 1574 1575// Shape constants 1576const float CIRCLE = 0.0; 1577const float SQUARE = 1.0; 1578const float TRIANGLE = 2.0; 1579const float DIAMOND = 3.0; 1580const float PENTAGON = 4.0; 1581const float HEXAGON = 5.0; 1582const float STAR = 6.0; 1583const float CROSS = 7.0; 1584const float NONE = 8.0; 1585 1586// Distance functions for different shapes 1587float circleDistance(vec2 p) { 1588 return dot(p, p); 1589} 1590 1591// Function to apply greyout logic to image colors 1592vec4 applyGreyoutToImage(vec4 imageColor, float isGreyedOutValue) { 1593 vec3 finalColor = imageColor.rgb; 1594 float finalAlpha = imageColor.a; 1595 1596 if (isGreyedOutValue > 0.0) { 1597 float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color) 1598 1599 if (isDarkenGreyout > 0.0) { 1600 finalColor = mix(finalColor, vec3(0.2), blendFactor); 1601 } else { 1602 finalColor = mix(finalColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 1603 } 1604 } 1605 1606 return vec4(finalColor, finalAlpha); 1607} 1608 1609float squareDistance(vec2 p) { 1610 vec2 d = abs(p) - vec2(0.8); 1611 return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); 1612} 1613 1614float triangleDistance(vec2 p) { 1615 const float k = sqrt(3.0); // â1.732; slope of 60° lines for an equilateral triangle 1616 p.x = abs(p.x) - 0.9; // fold the X axis and shift: brings left and right halves together 1617 p.y = p.y + 0.55; // move the whole shape up slightly so it is centred vertically 1618 1619 // reflect points that fall outside the main triangle back inside, to reuse the same maths 1620 if (p.x + k * p.y > 0.0) 1621 p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0; 1622 1623 p.x -= clamp(p.x, -1.0, 0.0); // clip any remainder on the left side 1624 1625 // Return signed distance: negative = inside; positive = outside 1626 return -length(p) * sign(p.y); 1627} 1628 1629float diamondDistance(vec2 p) { 1630 // aspect > 1 â taller diamond 1631 const float aspect = 1.2; 1632 return abs(p.x) + abs(p.y) / aspect - 0.8; 1633} 1634 1635float pentagonDistance(vec2 p) { 1636 // Regular pentagon signed-distance (Inigo Quilez) 1637 const vec3 k = vec3(0.809016994, 0.587785252, 0.726542528); 1638 p.x = abs(p.x); 1639 1640 // Reflect across the two tilted edges â only if point is outside 1641 p -= 2.0 * min(dot(vec2(-k.x, k.y), p), 0.0) * vec2(-k.x, k.y); 1642 p -= 2.0 * min(dot(vec2( k.x, k.y), p), 0.0) * vec2( k.x, k.y); 1643 1644 // Clip against the top horizontal edge (keeps top point sharp) 1645 p -= vec2(clamp(p.x, -k.z * k.x, k.z * k.x), k.z); 1646 1647 // Return signed distance (negative â inside, positive â outside) 1648 return length(p) * sign(p.y); 1649} 1650 1651float hexagonDistance(vec2 p) { 1652 const vec3 k = vec3(-0.866025404, 0.5, 0.577350269); 1653 p = abs(p); 1654 p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy; 1655 p -= vec2(clamp(p.x, -k.z * 0.8, k.z * 0.8), 0.8); 1656 return length(p) * sign(p.y); 1657} 1658 1659float starDistance(vec2 p) { 1660 // 5-point star signed-distance function (adapted from Inigo Quilez) 1661 // r â outer radius, rf â inner/outer radius ratio 1662 const float r = 0.9; 1663 const float rf = 0.45; 1664 1665 // Pre-computed rotation vectors for the star arms (36° increments) 1666 const vec2 k1 = vec2(0.809016994, -0.587785252); 1667 const vec2 k2 = vec2(-k1.x, k1.y); 1668 1669 // Fold the plane into a single arm sector 1670 p.x = abs(p.x); 1671 p -= 2.0 * max(dot(k1, p), 0.0) * k1; 1672 p -= 2.0 * max(dot(k2, p), 0.0) * k2; 1673 p.x = abs(p.x); 1674 1675 // Translate so the top tip of the star lies on the X-axis 1676 p.y -= r;
1677 1678 // Vector describing the edge between an outer tip and its adjacent inner point 1679 vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0); 1680 // Project the point onto that edge and clamp the projection to the segment 1681 float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r); 1682 1683 // Return signed distance (negative => inside, positive => outside) 1684 return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y); 1685} 1686 1687float crossDistance(vec2 p) { 1688 // Signed distance function for a cross (union of two rectangles) 1689 // Adapted from Inigo Quilez (https://iquilezles.org/) 1690 // Each arm has half-sizes 0.3 (thickness) and 0.8 (length) 1691 p = abs(p); 1692 if (p.y > p.x) p = p.yx; // exploit symmetry 1693 1694 vec2 q = p - vec2(0.8, 0.3); // subtract half-sizes (length, thickness) 1695 1696 // Standard rectangle SDF, then take union of the two arms 1697 return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0); 1698} 1699 1700float getShapeDistance(vec2 p, float shape) { 1701 if (shape == SQUARE) return squareDistance(p); 1702 else if (shape == TRIANGLE) return triangleDistance(p); 1703 else if (shape == DIAMOND) return diamondDistance(p); 1704 else if (shape == PENTAGON) return pentagonDistance(p); 1705 else if (shape == HEXAGON) return hexagonDistance(p); 1706 else if (shape == STAR) return starDistance(p); 1707 else if (shape == CROSS) return crossDistance(p); 1708 else return circleDistance(p); // Default to circle 1709} 1710 1711void main() { 1712 // Discard the fragment if the point is fully transparent and has no image 1713 if (shapeColor.a == 0.0 && imageAtlasUV.x == -1.0) { 1714 discard; 1715 } 1716 1717 // Discard the fragment if the point has no shape and no image 1718 if (pointShape == NONE && imageAtlasUV.x == -1.0) { 1719 discard; 1720 } 1721 1722 // Calculate coordinates within the point 1723 vec2 pointCoord = 2.0 * gl_PointCoord - 1.0; 1724 1725 vec4 finalShapeColor = vec4(0.0); 1726 vec4 finalImageColor = vec4(0.0); 1727 1728 // Handle shape rendering with centering logic 1729 if (pointShape != NONE) { 1730 // Calculate shape coordinates with centering 1731 vec2 shapeCoord = pointCoord; 1732 if (overallSize > shapeSize && shapeSize > 0.0) { 1733 // Shape is smaller than overall size, center it 1734 float scale = shapeSize / overallSize; 1735 shapeCoord = pointCoord / scale; 1736 } 1737 1738 float opacity; 1739 if (pointShape == CIRCLE) { 1740 // For circles, use the original distance calculation 1741 float pointCenterDistance = dot(shapeCoord, shapeCoord); 1742 opacity = 1.0 - smoothstep(smoothing, 1.0, pointCenterDistance); 1743 } else { 1744 // For other shapes, use the shape distance function 1745 float shapeDistance = getShapeDistance(shapeCoord, pointShape); 1746 opacity = 1.0 - smoothstep(-0.01, 0.01, shapeDistance); 1747 } 1748 opacity *= shapeColor.a; 1749 1750 finalShapeColor = vec4(shapeColor.rgb, opacity); 1751 } 1752 1753 // Handle image rendering with centering logic 1754 if (imageAtlasUV.x != -1.0) { 1755 // Calculate image coordinates with centering 1756 vec2 imageCoord = pointCoord; 1757 if (overallSize > imageSizeVarying && imageSizeVarying > 0.0) { 1758 // Image is smaller than overall size, center it 1759 float scale = imageSizeVarying / overallSize; 1760 imageCoord = pointCoord / scale; 1761 1762 // Check if we're outside the valid image area 1763 if (abs(imageCoord.x) > 1.0 || abs(imageCoord.y) > 1.0) { 1764 // We're outside the image bounds, don't render the image 1765 finalImageColor = vec4(0.0); 1766 } else { 1767 // Sample from texture atlas 1768 vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5); 1769 vec4 imageColor = texture(imageAtlasTexture, atlasUV); 1770 finalImageColor = applyGreyoutToImage(imageColor, isGreyedOut); 1771 } 1772 } else { 1773 // Image is same size or larger than overall size, no scaling needed 1774 // Sample from texture atlas 1775 vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5); 1776 vec4 imageColor = texture(imageAtlasTexture, atlasUV); 1777 finalImageColor = applyGreyoutToImage(imageColor, isGreyedOut); 1778 } 1779 } 1780 1781 float finalPointAlpha = max(finalShapeColor.a, finalImageColor.a); 1782 if (isGreyedOut > 0.0 && greyoutOpacity != -1.0) { 1783 finalPointAlpha *= greyoutOpacity; 1784 } else { 1785 finalPointAlpha *= pointOpacity; 1786 } 1787 1788 // Blend image color above point color 1789 fragColor = vec4( 1790 mix(finalShapeColor.rgb, finalImageColor.rgb, finalImageColor.a), 1791 finalPointAlpha 1792 ); 1793 1794 // Render outline ring around the point 1795 if (isOutlined > 0.0) { 1796 float r = length(pointCoord); 1797 const float ringSmoothing = 1.025; 1798 float rSafe = max(r, 1e-6); 1799 float wSafe = max(outlineWidth, 1e-6); 1800 float outerEdge = smoothstep(rSafe, rSafe * ringSmoothing, 1.0); 1801 float innerEdge = smoothstep(wSafe, wSafe * ringSmoothing, r); 1802 float ringAlpha = outerEdge * innerEdge; 1803 1804 // Grey out the ring color when the point is greyed 1805 vec3 ringColor = outlineColor.rgb; 1806 if (isGreyedOut > 0.0) { 1807 float blendFactor = 0.65; 1808 if (isDarkenGreyout > 0.0) { 1809 ringColor = mix(ringColor, vec3(0.2), blendFactor); 1810 } else { 1811 ringColor = mix(ringColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 1812 } 1813 } 1814 1815 float ringOpacity = ringAlpha * outlineColor.a; 1816 // Composite ring on top of existing fragment 1817 fragColor = vec4( 1818 mix(fragColor.rgb, ringColor, ringOpacity), 1819 max(fragColor.a, ringOpacity) 1820 ); 1821 } 1822} 1823`,CT=`#version 300 es 1824#ifdef GL_ES 1825precision highp float; 1826#endif 1827 1828in vec2 pointIndices; 1829in float sourceSize; 1830in float targetSize; 1831in vec4 sourceColor; 1832in vec4 targetColor; 1833in float shape; 1834in float imageIndex; 1835in float imageSize; 1836 1837uniform sampler2D positionsTexture; 1838uniform sampler2D pointStatus; 1839uniform sampler2D imageAtlasCoords; 1840 1841#ifdef USE_UNIFORM_BUFFERS 1842layout(std140) uniform drawVertexUniforms { 1843 float ratio; 1844 mat4 transformationMatrix; 1845 float pointsTextureSize; 1846 float sizeScale; 1847 float spaceSize; 1848 vec2 screenSize; 1849 vec4 greyoutColor; 1850 vec4 backgroundColor; 1851 float scalePointsOnZoom; 1852 float maxPointSize; 1853 float isDarkenGreyout; 1854 float skipHighlighted; 1855 float skipGreyed; 1856 float hasImages; 1857 float imageCount; 1858 float imageAtlasCoordsTextureSize; 1859 float transitionProgress; 1860 float animateColors; 1861 float animateSizes; 1862} drawVertex; 1863 1864#define ratio drawVertex.ratio 1865#define transformationMatrix drawVertex.transformationMatrix 1866#define pointsTextureSize drawVertex.pointsTextureSize 1867#define sizeScale drawVertex.sizeScale 1868#define spaceSize drawVertex.spaceSize 1869#define screenSize drawVertex.screenSize 1870#define greyoutColor drawVertex.greyoutColor 1871#define backgroundColor drawVertex.backgroundColor 1872#define scalePointsOnZoom drawVertex.scalePointsOnZoom 1873#define maxPointSize drawVertex.maxPointSize 1874#define isDarkenGreyout drawVertex.isDarkenGreyout 1875#define skipHighlighted drawVertex.skipHighlighted 1876#define skipGreyed drawVertex.skipGreyed 1877#define hasImages drawVertex.hasImages 1878#define imageCount drawVertex.imageCount 1879#define imageAtlasCoordsTextureSize drawVertex.imageAtlasCoordsTextureSize 1880#define transitionProgress drawVertex.transitionProgress 1881#define animateColors drawVertex.animateColors 1882#define animateSizes drawVertex.animateSizes 1883#else 1884uniform float ratio; 1885uniform mat3 transformationMatrix; 1886uniform float pointsTextureSize; 1887uniform float sizeScale; 1888uniform float spaceSize; 1889uniform vec2 screenSize; 1890uniform vec4 greyoutColor; 1891uniform vec4 backgroundColor; 1892uniform float scalePointsOnZoom; 1893uniform float maxPointSize; 1894uniform float isDarkenGreyout; 1895uniform float skipHighlighted; 1896uniform float skipGreyed; 1897uniform float hasImages; 1898uniform float imageCount; 1899uniform float imageAtlasCoordsTextureSize; 1900uniform float transitionProgress; 1901uniform float animateColors; 1902uniform float animateSizes; 1903#endif 1904 1905out float pointShape; 1906out float isGreyedOut; 1907out float isOutlined; 1908out vec4 shapeColor; 1909out vec4 imageAtlasUV; 1910out float shapeSize; 1911out float imageSizeVarying; 1912out float overallSize; 1913 1914float calculatePointSize(float size) { 1915 float pSize; 1916 1917 if (scalePointsOnZoom > 0.0) { 1918 pSize = size * ratio * transformationMatrix[0][0]; 1919 } else { 1920 pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01)); 1921 } 1922 1923 return min(pSize, maxPointSize * ratio); 1924} 1925 1926const float outlineRingScale = 1.3; 1927 1928void main() { 1929 // Read point status texture: R = greyout, G = outlined 1930 vec4 status = texture(pointStatus, (pointIndices + 0.5) / pointsTextureSize); 1931 isGreyedOut = status.r; 1932 isOutlined = status.g; 1933 float isHighlighted = (status.r == 0.0) ? 1.0 : 0.0; 1934 1935 // Discard point based on rendering mode 1936 if (skipHighlighted > 0.0 && isHighlighted > 0.0) { 1937 gl_Position = vec4(2.0, 2.0, 2.0, 1.0); 1938 gl_PointSize = 0.0; 1939 return; 1940 } 1941 if (skipGreyed > 0.0 && isHighlighted <= 0.0) { 1942 gl_Position = vec4(2.0, 2.0, 2.0, 1.0); 1943 gl_PointSize = 0.0; 1944 return; 1945 } 1946 1947 // Position 1948 vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize); 1949 vec2 point = pointPosition.rg; 1950 1951 // Transform point position to normalized device coordinates 1952 // Convert from space coordinates [0, spaceSize] to normalized [-1, 1] 1953 vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0; 1954 1955 // Apply aspect ratio correction - this is needed to map the square space to the rectangular screen 1956 // The transformation matrix handles zoom/pan, but we need this to handle aspect ratio 1957 normalizedPosition *= spaceSize / screenSize; 1958 1959 #ifdef USE_UNIFORM_BUFFERS 1960 mat3 transformMat3 = mat3(transformationMatrix); 1961 vec3 finalPosition = transformMat3 * vec3(normalizedPosition, 1); 1962 #else 1963 vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1); 1964 #endif 1965 gl_Position = vec4(finalPosition.rg, 0, 1); 1966 1967 float pointSize = animateSizes > 0.0 1968 ? mix(sourceSize, targetSize, transitionProgress) 1969 : targetSize; 1970 vec4 pointColor = animateColors > 0.0 1971 ? mix(sourceColor, targetColor, transitionProgress) 1972 : targetColor; 1973 1974 // Calculate sizes for shape and image 1975 float shapeSizeValue = calculatePointSize(pointSize * sizeScale); 1976 float imageSizeValue = calculatePointSize(imageSize * sizeScale); 1977 1978 // Use the larger of the two sizes for the overall point size 1979 float overallSizeValue = max(shapeSizeValue, imageSizeValue); 1980 1981 // Scale up point sprite to fit outline ring; clamp to hardware gl_PointSize limit so the 1982 // sprite never gets silently clipped â the point body is unaffected, only the ring narrows. 1983 if (isOutlined > 0.0) { 1984 overallSizeValue *= outlineRingScale; 1985 overallSizeValue = min(overallSizeValue, maxPointSize * ratio); 1986 } 1987 1988 gl_PointSize = overallSizeValue; 1989 1990 // Pass size information to fragment shader 1991 shapeSize = shapeSizeValue; 1992 imageSizeVarying = imageSizeValue; 1993 overallSize = overallSizeValue; 1994 1995 shapeColor = pointColor; 1996 pointShape = shape; 1997 1998 // Adjust color of greyed-out points 1999 if (isGreyedOut > 0.0) { 2000 if (greyoutColor[0] != -1.0) { 2001 shapeColor = greyoutColor; 2002 } else { 2003 // If greyoutColor is not set, make color lighter or darker based on isDarkenGreyout 2004 float blendFactor = 0.65; 2005 2006 #ifdef USE_UNIFORM_BUFFERS 2007 if (isDarkenGreyout > 0.0) { 2008 shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor); 2009 } else { 2010 shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 2011 } 2012 #else 2013 if (isDarkenGreyout > 0.0) { 2014 shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor); 2015 } else { 2016 shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 2017 } 2018 #endif 2019 } 2020 } 2021 2022 #ifdef USE_UNIFORM_BUFFERS 2023 if (hasImages <= 0.0 || imageIndex < 0.0 || imageIndex >= imageCount) { 2024 imageAtlasUV = vec4(-1.0); 2025 } else { 2026 float atlasCoordIndex = imageIndex; 2027 float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize); 2028 float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize); 2029 vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize; 2030 vec4 atlasCoords = texture(imageAtlasCoords, atlasCoordTexCoord); 2031 imageAtlasUV = atlasCoords; 2032 } 2033 #else 2034 if (hasImages <= 0.0 || imageIndex < 0.0 || imageIndex >= imageCount) { 2035 imageAtlasUV = vec4(-1.0); 2036 } else { 2037 float atlasCoordIndex = imageIndex; 2038 float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize); 2039 float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize); 2040 vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize; 2041 vec4 atlasCoords = texture(imageAtlasCoords, atlasCoordTexCoord); 2042 imageAtlasUV = atlasCoords; 2043 } 2044 #endif 2045} 2046`,bT=`#version 300 es 2047#ifdef GL_ES 2048precision highp float; 2049#endif 2050 2051uniform sampler2D positionsTexture; 2052uniform sampler2D pointSize; 2053 2054#ifdef USE_UNIFORM_BUFFERS 2055layout(std140) uniform findPointsInRectUniforms { 2056 float sizeScale; 2057 float spaceSize; 2058 vec2 screenSize; 2059 float ratio; 2060 mat4 transformationMatrix; 2061 vec2 rect0; 2062 vec2 rect1; 2063 float scalePointsOnZoom; 2064 float maxPointSize; 2065} findPointsInRect; 2066 2067#define sizeScale findPointsInRect.sizeScale 2068#define spaceSize findPointsInRect.spaceSize 2069#define screenSize findPointsInRect.screenSize 2070#define ratio findPointsInRect.ratio 2071#define transformationMatrix findPointsInRect.transformationMatrix 2072#define rect0 findPointsInRect.rect0 2073#define rect1 findPointsInRect.rect1 2074#define scalePointsOnZoom findPointsInRect.scalePointsOnZoom 2075#define maxPointSize findPointsInRect.maxPointSize 2076#else 2077uniform float sizeScale; 2078uniform float spaceSize; 2079uniform vec2 screenSize; 2080uniform float ratio; 2081uniform mat3 transformationMatrix; 2082uniform vec2 rect0; 2083uniform vec2 rect1; 2084uniform float scalePointsOnZoom; 2085uniform float maxPointSize; 2086#endif 2087 2088in vec2 textureCoords; 2089 2090out vec4 fragColor; 2091 2092float pointSizeF(float size) { 2093 float pSize; 2094 // Extract top-left element from mat4 (or use mat3 conversion) 2095 #ifdef USE_UNIFORM_BUFFERS 2096 float scale = transformationMatrix[0][0]; // mat4 first element 2097 #else 2098 float scale = transformationMatrix[0][0]; // mat3 first element 2099 #endif 2100 if (scalePointsOnZoom > 0.0) { 2101 pSize = size * ratio * scale; 2102 } else { 2103 pSize = size * ratio * min(5.0, max(1.0, scale * 0.01)); 2104 } 2105 return min(pSize, maxPointSize * ratio); 2106} 2107 2108void main() { 2109 vec4 pointPosition = texture(positionsTexture, textureCoords); 2110 vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0; 2111 p *= spaceSize / screenSize; 2112 #ifdef USE_UNIFORM_BUFFERS 2113 // Convert mat4 to mat3 for vec3 multiplication 2114 mat3 transformMat3 = mat3(transformationMatrix); 2115 vec3 final = transformMat3 * vec3(p, 1); 2116 #else 2117 vec3 final = transformationMatrix * vec3(p, 1); 2118 #endif 2119 2120 vec4 pSize = texture(pointSize, textureCoords); 2121 float size = pSize.r * sizeScale; 2122
2123 float left = 2.0 * (rect0.x - 0.5 * pointSizeF(size)) / screenSize.x - 1.0; 2124 float right = 2.0 * (rect1.x + 0.5 * pointSizeF(size)) / screenSize.x - 1.0; 2125 float top = 2.0 * (rect0.y - 0.5 * pointSizeF(size)) / screenSize.y - 1.0; 2126 float bottom = 2.0 * (rect1.y + 0.5 * pointSizeF(size)) / screenSize.y - 1.0; 2127 2128 fragColor = vec4(0.0, 0.0, pointPosition.r, pointPosition.g); 2129 if (final.x >= left && final.x <= right && final.y >= top && final.y <= bottom) { 2130 fragColor.r = 1.0; 2131 } 2132} 2133 2134`,IT=`#version 300 es 2135#ifdef GL_ES 2136precision highp float; 2137#endif 2138 2139uniform sampler2D positionsTexture; 2140uniform sampler2D polygonPathTexture; // Texture containing polygon path points 2141 2142#ifdef USE_UNIFORM_BUFFERS 2143layout(std140) uniform findPointsInPolygonUniforms { 2144 float spaceSize; 2145 vec2 screenSize; 2146 mat4 transformationMatrix; 2147 float polygonPathLength; 2148} findPointsInPolygon; 2149 2150#define spaceSize findPointsInPolygon.spaceSize 2151#define screenSize findPointsInPolygon.screenSize 2152#define transformationMatrix findPointsInPolygon.transformationMatrix 2153#define polygonPathLength int(findPointsInPolygon.polygonPathLength) 2154#else 2155uniform int polygonPathLength; 2156uniform float spaceSize; 2157uniform vec2 screenSize; 2158uniform mat3 transformationMatrix; 2159#endif 2160 2161in vec2 textureCoords; 2162 2163out vec4 fragColor; 2164 2165// Get a point from the polygon path texture at a specific index 2166vec2 getPolygonPoint(sampler2D pathTexture, int index, int pathLength) { 2167 if (index >= pathLength) return vec2(0.0); 2168 2169 // Calculate texture coordinates for the index 2170 int textureSize = int(ceil(sqrt(float(pathLength)))); 2171 int x = index - (index / textureSize) * textureSize; 2172 int y = index / textureSize; 2173 2174 vec2 texCoord = (vec2(float(x), float(y)) + 0.5) / float(textureSize); 2175 vec4 pathData = texture(pathTexture, texCoord); 2176 2177 return pathData.xy; 2178} 2179 2180// Point-in-polygon algorithm using ray casting 2181bool pointInPolygon(vec2 point, sampler2D pathTexture, int pathLength) { 2182 bool inside = false;
2183 2184 for (int i = 0; i < 2048; i++) { 2185 if (i >= pathLength) break; 2186 2187 int j = int(mod(float(i + 1), float(pathLength))); 2188 2189 vec2 pi = getPolygonPoint(pathTexture, i, pathLength); 2190 vec2 pj = getPolygonPoint(pathTexture, j, pathLength); 2191 2192 if (((pi.y > point.y) != (pj.y > point.y)) && 2193 (point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x)) { 2194 inside = !inside; 2195 } 2196 } 2197 2198 return inside; 2199} 2200 2201void main() { 2202 vec4 pointPosition = texture(positionsTexture, textureCoords); 2203 vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0; 2204 p *= spaceSize / screenSize; 2205 #ifdef USE_UNIFORM_BUFFERS 2206 // Convert mat4 to mat3 for vec3 multiplication 2207 mat3 transformMat3 = mat3(transformationMatrix); 2208 vec3 final = transformMat3 * vec3(p, 1); 2209 #else 2210 vec3 final = transformationMatrix * vec3(p, 1); 2211 #endif 2212 2213 // Convert to screen coordinates for polygon check 2214 vec2 screenPos = (final.xy + 1.0) * screenSize / 2.0; 2215 2216 fragColor = vec4(0.0, 0.0, pointPosition.r, pointPosition.g); 2217 2218 // Check if point center is inside the polygon 2219 if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) { 2220 fragColor.r = 1.0; 2221 } 2222} `,PT=`#version 300 es 2223#ifdef GL_ES 2224precision highp float; 2225#endif 2226 2227#ifdef USE_UNIFORM_BUFFERS 2228layout(std140) uniform drawHighlightedUniforms { 2229 float size; 2230 mat4 transformationMatrix; 2231 float pointsTextureSize; 2232 float sizeScale; 2233 float spaceSize; 2234 vec2 screenSize; 2235 float scalePointsOnZoom; 2236 float pointIndex; 2237 float maxPointSize; 2238 vec4 color; 2239 float universalPointOpacity; 2240 float greyoutOpacity; 2241 float isDarkenGreyout; 2242 vec4 backgroundColor; 2243 vec4 greyoutColor; 2244 float width; 2245} drawHighlighted; 2246 2247#define width drawHighlighted.width 2248#else 2249uniform float width; 2250#endif 2251 2252in vec2 vertexPosition; 2253in float pointOpacity; 2254in vec3 rgbColor; 2255 2256out vec4 fragColor; 2257 2258const float smoothing = 1.05; 2259 2260void main () { 2261 float r = dot(vertexPosition, vertexPosition); 2262 float opacity = smoothstep(r, r * smoothing, 1.0); 2263 float stroke = smoothstep(width, width * smoothing, r); 2264 fragColor = vec4(rgbColor, opacity * stroke * pointOpacity); 2265}`,wT=`#version 300 es 2266#ifdef GL_ES 2267precision highp float; 2268#endif 2269 2270in vec2 vertexCoord; 2271 2272uniform sampler2D positionsTexture; 2273uniform sampler2D pointStatus; 2274 2275#ifdef USE_UNIFORM_BUFFERS 2276layout(std140) uniform drawHighlightedUniforms { 2277 float size; 2278 mat4 transformationMatrix; 2279 float pointsTextureSize; 2280 float sizeScale; 2281 float spaceSize; 2282 vec2 screenSize; 2283 float scalePointsOnZoom; 2284 float pointIndex; 2285 float maxPointSize; 2286 vec4 color; 2287 float universalPointOpacity; 2288 float greyoutOpacity; 2289 float isDarkenGreyout; 2290 vec4 backgroundColor; 2291 vec4 greyoutColor; 2292 float width; 2293} drawHighlighted; 2294 2295#define size drawHighlighted.size 2296#define transformationMatrix drawHighlighted.transformationMatrix 2297#define pointsTextureSize drawHighlighted.pointsTextureSize 2298#define sizeScale drawHighlighted.sizeScale 2299#define spaceSize drawHighlighted.spaceSize 2300#define screenSize drawHighlighted.screenSize 2301#define scalePointsOnZoom drawHighlighted.scalePointsOnZoom 2302#define pointIndex drawHighlighted.pointIndex 2303#define maxPointSize drawHighlighted.maxPointSize 2304#define color drawHighlighted.color 2305#define universalPointOpacity drawHighlighted.universalPointOpacity 2306#define greyoutOpacity drawHighlighted.greyoutOpacity 2307#define isDarkenGreyout drawHighlighted.isDarkenGreyout 2308#define backgroundColor drawHighlighted.backgroundColor 2309#define greyoutColor drawHighlighted.greyoutColor 2310#else 2311uniform float size; 2312uniform mat3 transformationMatrix; 2313uniform float pointsTextureSize; 2314uniform float sizeScale; 2315uniform float spaceSize; 2316uniform vec2 screenSize; 2317uniform float scalePointsOnZoom; 2318uniform float pointIndex; 2319uniform float maxPointSize; 2320uniform vec4 color; 2321uniform float universalPointOpacity; 2322uniform float greyoutOpacity; 2323uniform float isDarkenGreyout; 2324uniform vec4 backgroundColor; 2325uniform vec4 greyoutColor; 2326uniform float width; 2327#endif 2328out vec2 vertexPosition; 2329out float pointOpacity; 2330out vec3 rgbColor; 2331 2332float calculatePointSize(float pointSize) { 2333 float pSize; 2334 2335 if (scalePointsOnZoom > 0.0) { 2336 pSize = pointSize * transformationMatrix[0][0]; 2337 } else { 2338 pSize = pointSize * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01)); 2339 } 2340 2341 return min(pSize, maxPointSize); 2342} 2343 2344const float relativeRingRadius = 1.3; 2345 2346void main () { 2347 vertexPosition = vertexCoord; 2348 2349 vec2 textureCoordinates = vec2(mod(pointIndex, pointsTextureSize), floor(pointIndex / pointsTextureSize)) + 0.5; 2350 vec4 pointPosition = texture(positionsTexture, textureCoordinates / pointsTextureSize); 2351 2352 rgbColor = color.rgb; 2353 pointOpacity = color.a * universalPointOpacity; 2354 vec4 greyoutStatus = texture(pointStatus, textureCoordinates / pointsTextureSize); 2355 if (greyoutStatus.r > 0.0) { 2356 if (greyoutColor[0] != -1.0) { 2357 rgbColor = greyoutColor.rgb; 2358 pointOpacity = greyoutColor.a; 2359 } else { 2360 // If greyoutColor is not set, make color lighter or darker based on isDarkenGreyout 2361 float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color) 2362 2363 #ifdef USE_UNIFORM_BUFFERS 2364 if (isDarkenGreyout > 0.0) { 2365 // Darken the color 2366 rgbColor = mix(rgbColor, vec3(0.2), blendFactor); 2367 } else { 2368 // Lighten the color 2369 rgbColor = mix(rgbColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 2370 } 2371 #else 2372 if (isDarkenGreyout > 0.0) { 2373 // Darken the color 2374 rgbColor = mix(rgbColor, vec3(0.2), blendFactor); 2375 } else { 2376 // Lighten the color 2377 rgbColor = mix(rgbColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor); 2378 } 2379 #endif 2380 } 2381 2382 if (greyoutOpacity != -1.0) { 2383 pointOpacity *= greyoutOpacity; 2384 } 2385 } 2386 2387 // Calculate point radius 2388 float pointSize = (calculatePointSize(size * sizeScale) * relativeRingRadius) / transformationMatrix[0][0]; 2389 float radius = pointSize * 0.5; 2390 2391 // Calculate point position in screen space 2392 vec2 a = pointPosition.xy; 2393 vec2 b = pointPosition.xy + vec2(0.0, radius); 2394 vec2 xBasis = b - a; 2395 vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); 2396 vec2 pointPositionInScreenSpace = a + xBasis * vertexCoord.x + yBasis * radius * vertexCoord.y; 2397 2398 // Transform point position to normalized device coordinates 2399 vec2 p = 2.0 * pointPositionInScreenSpace / spaceSize - 1.0; 2400 p *= spaceSize / screenSize; 2401 #ifdef USE_UNIFORM_BUFFERS 2402 mat3 transformMat3 = mat3(transformationMatrix); 2403 vec3 final = transformMat3 * vec3(p, 1); 2404 #else 2405 vec3 final = transformationMatrix * vec3(p, 1); 2406 #endif 2407 2408 gl_Position = vec4(final.rg, 0, 1); 2409}`,NT=`#version 300 es 2410#ifdef GL_ES 2411precision highp float; 2412#endif 2413 2414in vec4 rgba; 2415 2416out vec4 fragColor; 2417 2418void main() { 2419 if (rgba.g <= 0.0) { 2420 discard; 2421 } 2422 fragColor = rgba; 2423}`,MT=`#version 300 es 2424#ifdef GL_ES 2425precision highp float; 2426#endif 2427 2428in vec2 pointIndices; 2429in float size; 2430in float imageSize; 2431 2432uniform sampler2D positionsTexture; 2433uniform sampler2D pointStatus; 2434 2435#ifdef USE_UNIFORM_BUFFERS 2436layout(std140) uniform findHoveredPointUniforms { 2437 float pointsTextureSize; 2438 float sizeScale; 2439 float spaceSize; 2440 vec2 screenSize; 2441 float ratio; 2442 mat4 transformationMatrix; 2443 vec2 mousePosition; 2444 float scalePointsOnZoom; 2445 float maxPointSize; 2446 float skipHighlighted; 2447 float skipGreyed; 2448} findHoveredPoint; 2449 2450#define pointsTextureSize findHoveredPoint.pointsTextureSize 2451#define sizeScale findHoveredPoint.sizeScale 2452#define spaceSize findHoveredPoint.spaceSize 2453#define screenSize findHoveredPoint.screenSize 2454#define ratio findHoveredPoint.ratio 2455#define transformationMatrix findHoveredPoint.transformationMatrix 2456#define mousePosition findHoveredPoint.mousePosition 2457#define scalePointsOnZoom findHoveredPoint.scalePointsOnZoom 2458#define maxPointSize findHoveredPoint.maxPointSize 2459#define skipHighlighted findHoveredPoint.skipHighlighted 2460#define skipGreyed findHoveredPoint.skipGreyed 2461#else 2462uniform float pointsTextureSize; 2463uniform float sizeScale; 2464uniform float spaceSize; 2465uniform vec2 screenSize; 2466uniform float ratio; 2467uniform mat3 transformationMatrix; 2468uniform vec2 mousePosition; 2469uniform float scalePointsOnZoom; 2470uniform float maxPointSize; 2471uniform float skipHighlighted; 2472uniform float skipGreyed; 2473#endif 2474 2475out vec4 rgba; 2476 2477float calculatePointSize(float size) { 2478 float pSize; 2479 2480 if (scalePointsOnZoom > 0.0) { 2481 pSize = size * ratio * transformationMatrix[0][0]; 2482 } else { 2483 pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01)); 2484 } 2485 2486 return min(pSize, maxPointSize * ratio); 2487} 2488 2489float euclideanDistance (float x1, float x2, float y1, float y2) {
2490 return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); 2491} 2492 2493void main() { 2494 vec4 greyoutStatus = texture(pointStatus, (pointIndices + 0.5) / pointsTextureSize); 2495 float isHighlighted = (greyoutStatus.r == 0.0) ? 1.0 : 0.0; 2496 2497 if (skipHighlighted > 0.0 && isHighlighted > 0.0) { 2498 rgba = vec4(0.0); 2499 gl_Position = vec4(0.5, 0.5, 0.0, 1.0); 2500 gl_PointSize = 1.0; 2501 return; 2502 } 2503 if (skipGreyed > 0.0 && isHighlighted <= 0.0) { 2504 rgba = vec4(0.0); 2505 gl_Position = vec4(0.5, 0.5, 0.0, 1.0); 2506 gl_PointSize = 1.0; 2507 return; 2508 } 2509 2510 vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize); 2511 vec2 point = pointPosition.rg; 2512 2513 vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0; 2514 normalizedPosition *= spaceSize / screenSize; 2515 2516 #ifdef USE_UNIFORM_BUFFERS 2517 mat3 transformMat3 = mat3(transformationMatrix); 2518 vec3 finalPosition = transformMat3 * vec3(normalizedPosition, 1); 2519 #else 2520 vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1); 2521 #endif 2522 2523 float shapeSizeValue = calculatePointSize(size * sizeScale); 2524 float imageSizeValue = calculatePointSize(imageSize * sizeScale); 2525 float pointRadius = 0.5 * max(shapeSizeValue, imageSizeValue); 2526 vec2 pointScreenPosition = (finalPosition.xy + 1.0) * screenSize / 2.0; 2527 2528 rgba = vec4(0.0); 2529 gl_Position = vec4(0.5, 0.5, 0.0, 1.0); 2530 2531 if (euclideanDistance(pointScreenPosition.x, mousePosition.x, pointScreenPosition.y, mousePosition.y) < pointRadius / ratio) { 2532 float index = pointIndices.g * pointsTextureSize + pointIndices.r; 2533 rgba = vec4(index, max(size, imageSize), pointPosition.xy); 2534 gl_Position = vec4(-0.5, -0.5, 0.0, 1.0); 2535 } 2536 2537 gl_PointSize = 1.0; 2538}`,kT=`#version 300 es 2539#ifdef GL_ES 2540precision highp float; 2541#endif 2542 2543in vec4 rgba; 2544 2545out vec4 fragColor; 2546 2547void main() { 2548 fragColor = rgba; 2549}`,FT=`#version 300 es 2550#ifdef GL_ES 2551precision highp float; 2552#endif 2553 2554in vec2 pointIndices; 2555 2556uniform sampler2D positionsTexture; 2557 2558#ifdef USE_UNIFORM_BUFFERS 2559layout(std140) uniform fillSampledPointsUniforms { 2560 float pointsTextureSize; 2561 mat4 transformationMatrix; 2562 float spaceSize; 2563 vec2 screenSize; 2564} fillSampledPoints; 2565 2566#define pointsTextureSize fillSampledPoints.pointsTextureSize 2567#define transformationMatrix fillSampledPoints.transformationMatrix 2568#define spaceSize fillSampledPoints.spaceSize 2569#define screenSize fillSampledPoints.screenSize 2570#else 2571uniform float pointsTextureSize; 2572uniform float spaceSize; 2573uniform vec2 screenSize; 2574uniform mat3 transformationMatrix; 2575#endif 2576 2577out vec4 rgba; 2578 2579void main() { 2580 vec4 pointPosition = texture(positionsTexture, (pointIndices + 0.5) / pointsTextureSize); 2581 vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0; 2582 p *= spaceSize / screenSize; 2583 #ifdef USE_UNIFORM_BUFFERS 2584 // Convert mat4 to mat3 for vec3 multiplication 2585 mat3 transformMat3 = mat3(transformationMatrix); 2586 vec3 final = transformMat3 * vec3(p, 1); 2587 #else 2588 vec3 final = transformationMatrix * vec3(p, 1); 2589 #endif 2590 2591 vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0; 2592 float index = pointIndices.g * pointsTextureSize + pointIndices.r; 2593 rgba = vec4(index, 1.0, pointPosition.xy); 2594 float i = (pointScreenPosition.x + 0.5) / screenSize.x; 2595 float j = (pointScreenPosition.y + 0.5) / screenSize.y; 2596 gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0); 2597 2598 gl_PointSize = 1.0; 2599}`,DT=`#version 300 es 2600#ifdef GL_ES 2601precision highp float; 2602#endif 2603 2604uniform sampler2D positionsTexture; 2605uniform sampler2D velocity; 2606uniform sampler2D pinnedStatusTexture; 2607 2608#ifdef USE_UNIFORM_BUFFERS 2609layout(std140) uniform updatePositionUniforms { 2610 float friction; 2611 float spaceSize; 2612} updatePosition; 2613 2614#define friction updatePosition.friction 2615#define spaceSize updatePosition.spaceSize 2616#else 2617uniform float friction; 2618uniform float spaceSize; 2619#endif 2620 2621in vec2 textureCoords; 2622 2623out vec4 fragColor; 2624 2625void main() { 2626 vec4 pointPosition = texture(positionsTexture, textureCoords); 2627 vec4 pointVelocity = texture(velocity, textureCoords); 2628 2629 // Check if point is pinned 2630 // pinnedStatusTexture has the same size and layout as positionsTexture 2631 // Each pixel corresponds to a point: red channel > 0.5 means the point is pinned 2632 vec4 pinnedStatus = texture(pinnedStatusTexture, textureCoords); 2633 2634 // If pinned, don't update position 2635 if (pinnedStatus.r > 0.5) { 2636 fragColor = pointPosition; 2637 return; 2638 } 2639 2640 // Friction 2641 pointVelocity.rg *= friction; 2642 2643 pointPosition.rg += pointVelocity.rg; 2644 2645 pointPosition.r = clamp(pointPosition.r, 0.0, spaceSize); 2646 pointPosition.g = clamp(pointPosition.g, 0.0, spaceSize); 2647 2648 fragColor = pointPosition; 2649}`,OT=`#version 300 es 2650#ifdef GL_ES 2651precision highp float; 2652#endif 2653 2654uniform sampler2D sourceTexture; 2655uniform sampler2D targetTexture; 2656 2657#ifdef USE_UNIFORM_BUFFERS 2658layout(std140) uniform interpolatePositionUniforms { 2659 float progress; 2660} interpolatePosition; 2661 2662#define progress interpolatePosition.progress 2663#else 2664uniform float progress; 2665#endif 2666 2667in vec2 textureCoords; 2668 2669out vec4 fragColor; 2670 2671void main() { 2672 vec4 source = texture(sourceTexture, textureCoords); 2673 vec4 target = texture(targetTexture, textureCoords); 2674 vec2 position = mix(source.rg, target.rg, progress); 2675 fragColor = vec4(position, source.b, 1.0); 2676} 2677`,BT=`#version 300 es 2678#ifdef GL_ES 2679precision highp float; 2680#endif 2681 2682uniform sampler2D positionsTexture; 2683uniform sampler2D trackedIndices; 2684 2685#ifdef USE_UNIFORM_BUFFERS 2686layout(std140) uniform trackPointsUniforms { 2687 float pointsTextureSize; 2688} trackPoints; 2689 2690#define pointsTextureSize trackPoints.pointsTextureSize 2691#else 2692uniform float pointsTextureSize; 2693#endif 2694 2695in vec2 textureCoords; 2696 2697out vec4 fragColor; 2698 2699void main() { 2700 vec4 trackedPointIndices = texture(trackedIndices, textureCoords); 2701 if (trackedPointIndices.r < 0.0) discard; 2702 vec4 pointPosition = texture(positionsTexture, (trackedPointIndices.rg + 0.5) / pointsTextureSize); 2703 2704 fragColor = vec4(pointPosition.rg, 1.0, 1.0); 2705} 2706 2707`,UT=`#version 300 es 2708#ifdef GL_ES 2709precision highp float; 2710#endif 2711 2712uniform sampler2D positionsTexture; 2713 2714#ifdef USE_UNIFORM_BUFFERS 2715layout(std140) uniform dragPointUniforms { 2716 vec2 mousePos; 2717 float index; 2718} dragPoint; 2719 2720#define mousePos dragPoint.mousePos 2721#define index dragPoint.index 2722#else 2723uniform vec2 mousePos; 2724uniform float index; 2725#endif 2726 2727in vec2 textureCoords; 2728 2729out vec4 fragColor; 2730 2731void main() { 2732 vec4 pointPosition = texture(positionsTexture, textureCoords); 2733 2734 // Check if a point is being dragged 2735 if (index >= 0.0 && index == pointPosition.b) { 2736 pointPosition.rg = mousePos.rg; 2737 } 2738 2739 fragColor = pointPosition; 2740}`;function LT(t,e=16384){if(!(t!=null&&t.length))return null;let i=0;for(const c of t){const u=Math.max(c.width,c.height);u>i&&(i=u)}if(i===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const n=i,s=Math.ceil(Math.sqrt(t.length));let r=s*i,o=1;r>
2740e&&(o=e/r,i=Math.max(1,Math.floor(i*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 t.entries()){const h=u.width,f=u.height;if(h===0||f===0)continue;const d=Math.min(1,i/Math.max(h,f)),T=Math.floor(h*d),C=Math.floor(f*d),w=Math.floor(c/s),A=c%s*i,F=w*i;l[c*4]=A/r,l[c*4+1]=F/r,l[c*4+2]=(A+T)/r,l[c*4+3]=(F+C)/r;for(let b=0;b<C;b++)for(let g=0;g<T;g++){const v=Math.floor(g*(h/T)),N=(Math.floor(b*(f/C))*h+v)*4,B=((F+b)*r+(A+g))*4;a[B]=u.data[N]??0,a[B+1]=u.data[N+1]??0,a[B+2]=u.data[N+2]??0,a[B+3]=u.data[N+3]??255}}return{atlasData:a,atlasSize:r,atlasCoords:l,atlasCoordsSize:s}}function zT(t,e,i){const n=new Float32Array(e*e*4);if(!t)return n;for(let s=0;s<i;++s)n[s*4+0]=t[s*2+0],n[s*4+1]=t[s*2+1],n[s*4+2]=s;return n}function HT(t,e,i,n,s){const r=new Float32Array(s*s*4);for(let o=0;o<i;o+=1)r[o*4+0]=t[o*4+0],r[o*4+1]=t[o*4+1],r[o*4+2]=o;for(let o=i;o<n;o+=1)r[o*4+0]=e[o*4+0],r[o*4+1]=e[o*4+1],r[o*4+2]=o;return r}class VT extends wt{constructor(){super(...arguments),this.imageCount=0,this.areClusterCentroidsUpToDate=!1,this.isPositionsUpToDate=!1,this.polygonPathLength=0,this.transitionProgress=1,this.shouldAnimatePointColors=!1,this.shouldAnimatePointSizes=!1}updatePositions(){var e;const{device:i,store:n,data:s,config:{rescalePositions:r,enableSimulation:o}}=this,{pointsTextureSize:a}=n;if(!a||!s.pointPositions||s.pointsNumber===void 0)return!1;let l=r;r===void 0&&!o&&(l=!0),this.shouldSkipRescale&&(l=!1),l?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;const c=s.sourcePointsNumber,u=s.targetPointsNumber,h=c===u,f=((e=this.transition)==null?void 0:e.isPendingFor(Ie.Positions))===!0&&this.config.transitionDuration>0&&!!this.currentPositionTexture,d=zT(s.pointPositions,a,u);let T;if(f&&(this.createTransitionResources(),this.sourcePositionTexture&&this.targetPositionTexture)){if(h){const A=this.currentPositionTexture;if(A&&!A.destroyed){const F=this.device.createCommandEncoder();F.copyTextureToTexture({sourceTexture:A,destinationTexture:this.sourcePositionTexture,width:a,height:a}),this.device.submit(F.finish())}}else if(this.currentPositionFbo){const A=Ke(i,this.currentPositionFbo);T=HT(A,d,Math.min(c,u),u,a),this.writePositionTexture(this.sourcePositionTexture,T,a)}else this.writePositionTexture(this.sourcePositionTexture,d,a);this.writePositionTexture(this.targetPositionTexture,d,a)}this.ensurePositionTextures(a),f?T&&(this.writePositionTexture(this.currentPositionTexture,T,a),this.writePositionTexture(this.previousPositionTexture,T,a)):(this.writePositionTexture(this.currentPositionTexture,d,a),this.writePositionTexture(this.previousPositionTexture,d,a)),this.areClusterCentroidsUpToDate=!1,this.isPositionsUpToDate=!1,this.config.enableSimulation&&this.ensureSimulationResources(),!this.searchTexture||this.searchTexture.width!==a||this.searchTexture.height!==a?(this.searchTexture&&!this.searchTexture.destroyed&&this.searchTexture.destroy(),this.searchFbo&&!this.searchFbo.destroyed&&this.searchFbo.destroy(),this.searchTexture=i.createTexture({width:a,height:a,format:"rgba32float"}),this.searchTexture.copyImageData({data:d,bytesPerRow:ue("rgba32float",a),mipLevel:0,x:0,y:0}),this.searchFbo=i.createFramebuffer({width:a,height:a,colorAttachments:[this.searchTexture]})):this.searchTexture.copyImageData({data:d,bytesPerRow:ue("rgba32float",a),mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=i.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const C=Gi(n.pointsTextureSize),w=C.byteLength;return!this.drawPointIndices||this.drawPointIndices.byteLength!==w?(this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=i.createBuffer({data:C,usage:G.VERTEX|G.COPY_DST})):this.drawPointIndices.write(C),this.drawCommand&&this.drawCommand.setAttributes({pointIndices:this.drawPointIndices}),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==w?(this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=i.createBuffer({data:C,usage:G.VERTEX|G.COPY_DST})):this.hoveredPointIndices.write(C),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==w?(this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=i.createBuffer({data:C,usage:G.VERTEX|G.COPY_DST})):this.sampledPointIndices.write(C),this.fillSampledPointsFboCommand&&this.fillSampledPointsFboCommand.setAttributes({pointIndices:this.sampledPointIndices}),this.updatePointStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),f||this.trackPoints(),f}initPrograms(){var e,i,n;const{device:s,config:r,store:o,data:a}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.targetColorBuffer||this.updateColor(),this.targetSizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.pointStatusTexture||this.updatePointStatus(),r.enableSimulation&&this.ensureUpdatePositionProgram(),this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new Se({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:ce(o.mousePosition,[0,0]),index:((e=o.hoveredPoint)==null?void 0:e.index)??-1}}})),this.dragPointCommand||(this.dragPointCommand=new ge(s,{fs:UT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0}
2740,bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(s,"dragPointUniforms")}})),this.drawUniformStore||(this.drawUniformStore=new Se({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",skipHighlighted:"f32",skipGreyed:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32",transitionProgress:"f32",animateColors:"f32",animateSizes:"f32"},defaultUniforms:{ratio:r.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,spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0]),greyoutColor:we(o.greyoutPointColor,[0,0,0,1]),backgroundColor:we(o.backgroundColor,[0,0,0,1]),scalePointsOnZoom:r.scalePointsOnZoom?1:0,maxPointSize:o.maxPointSize,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,skipHighlighted:0,skipGreyed:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0,transitionProgress:1,animateColors:0,animateSizes:0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>",outlineColor:"vec4<f32>",outlineWidth:"f32"},defaultUniforms:{greyoutOpacity:r.pointGreyoutOpacity??-1,pointOpacity:r.pointOpacity,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:we(o.backgroundColor,[0,0,0,1]),outlineColor:we(o.outlinedPointRingColor,[1,1,1,1]),outlineWidth:.9}}})),this.drawCommand||(this.drawCommand=new ge(s,{fs:RT,vs:CT,topology:"point-list",vertexCount:a.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sourceSizeBuffer&&{sourceSize:this.sourceSizeBuffer},...this.targetSizeBuffer&&{targetSize:this.targetSizeBuffer},...this.sourceColorBuffer&&{sourceColor:this.sourceColorBuffer},...this.targetColorBuffer&&{targetColor:this.targetColorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"sourceSize",format:"float32"},{name:"targetSize",format:"float32"},{name:"sourceColor",format:"float32x4"},{name:"targetColor",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.findPointsInRectVertexCoordBuffer||(this.findPointsInRectVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsInRectUniformStore||(this.findPointsInRectUniformStore=new Se({findPointsInRectUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",rect0:"vec2<f32>",rect1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:r.pointSizeScale,spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0]),ratio:r.pixelRatio,transformationMatrix:o.transformationMatrix4x4,rect0:ce((i=o.searchArea)==null?void 0:i[0],[0,0]),rect1:ce((n=o.searchArea)==null?void 0:n[1],[0,0]),scalePointsOnZoom:r.scalePointsOnZoom?1:0,maxPointSize:o.maxPointSize}}})),this.findPointsInRectCommand||(this.findPointsInRectCommand=new ge(s,{fs:bT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsInRectVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0}
2740,bindings:{findPointsInRectUniforms:this.findPointsInRectUniformStore.getManagedUniformBuffer(s,"findPointsInRectUniforms")}})),this.findPointsInPolygonVertexCoordBuffer||(this.findPointsInPolygonVertexCoordBuffer=s.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsInPolygonUniformStore||(this.findPointsInPolygonUniformStore=new Se({findPointsInPolygonUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0]),transformationMatrix:o.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsInPolygonCommand||(this.findPointsInPolygonCommand=new ge(s,{fs:IT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsInPolygonVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsInPolygonUniforms:this.findPointsInPolygonUniformStore.getManagedUniformBuffer(s,"findPointsInPolygonUniforms")}})),this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new Se({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",skipHighlighted:"f32",skipGreyed:"f32"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0,sizeScale:r.pointSizeScale,spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0]),ratio:r.pixelRatio,transformationMatrix:o.transformationMatrix4x4,mousePosition:ce(o.screenMousePosition,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom?1:0,maxPointSize:o.maxPointSize,skipHighlighted:0,skipGreyed:0}}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=new ge(s,{fs:NT,vs:MT,topology:"point-list",vertexCount:a.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.targetSizeBuffer&&{size:this.targetSizeBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"imageSize",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 Se({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0,transformationMatrix:o.transformationMatrix4x4,spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0])}}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=new ge(s,{fs:kT,vs:FT,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 Se({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,spaceSize:o.adjustedSpaceSize,screenSize:ce(o.screenSize,[0,0]),scalePointsOnZoom:r.scalePointsOnZoom?1:0,pointIndex:-1,maxPointSize:o.maxPointSize,color:[0,0,0,1],universalPointOpacity:r.pointOpacity,greyoutOpacity:r.pointGreyoutOpacity??-1,isDarkenGreyout:o.isDarkenGreyout??!1?1:0,backgroundColor:we(o.backgroundColor,[0,0,0,1]),greyoutColor:we(o.greyoutPointColor,[0,0,0,1]),width:.85}}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=new ge(s,{fs:PT,vs:wT,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0}
2740,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 Se({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:o.pointsTextureSize??0}}})),this.trackPointsCommand||(this.trackPointsCommand=new ge(s,{fs:BT,vs:Ge,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(){const{store:{pointsTextureSize:e},data:i}=this;if(!e)return;const n=i.pointColors,{source:s,target:r,previous:o}=qn(this.device,n,this.sourceColorBuffer,this.targetColorBuffer,this.previousColorData,4);this.sourceColorBuffer=s,this.targetColorBuffer=r,this.previousColorData=o,this.drawCommand&&this.drawCommand.setAttributes({...this.sourceColorBuffer&&{sourceColor:this.sourceColorBuffer},...this.targetColorBuffer&&{targetColor:this.targetColorBuffer}})}updatePointStatus(){const{device:e,config:i,data:n,store:{pointsTextureSize:s}}=this;if(!s||n.pointsNumber===void 0)return;const{highlightedPointIndices:r,outlinedPointIndices:o}=i,a=r!==void 0,l=o!==void 0,c=new Float32Array(s*s*4);if(a){for(let h=0;h<c.length;h+=4)c[h]=1;for(const h of r)h>=0&&h<n.pointsNumber&&(c[h*4]=0)}if(l)for(const h of o)h>=0&&h<n.pointsNumber&&(c[h*4+1]=1);const u={data:c,bytesPerRow:ue("rgba32float",s),mipLevel:0,x:0,y:0};!this.pointStatusTexture||this.pointStatusTexture.width!==s||this.pointStatusTexture.height!==s?(this.pointStatusTexture&&!this.pointStatusTexture.destroyed&&this.pointStatusTexture.destroy(),this.pointStatusTexture=e.createTexture({width:s,height:s,format:"rgba32float"}),this.pointStatusTexture.copyImageData(u)):this.pointStatusTexture.copyImageData(u)}updatePinnedStatus(){const{device:e,store:{pointsTextureSize:i},data:n}=this;if(!i)return;const s=new Float32Array(i*i*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!==i||this.pinnedStatusTexture.height!==i?(this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=e.createTexture({width:i,height:i,format:"rgba32float"}),this.pinnedStatusTexture.copyImageData({data:s,bytesPerRow:ue("rgba32float",i),mipLevel:0,x:0,y:0})):this.pinnedStatusTexture.copyImageData({data:s,bytesPerRow:ue("rgba32float",i),mipLevel:0,x:0,y:0})}updateSize(){var e;const{device:i,store:{pointsTextureSize:n},data:s}=this;if(!n||s.pointsNumber===void 0)return;const r=s.pointSizes,{source:o,target:a,previous:l}=qn(this.device,r,this.sourceSizeBuffer,this.targetSizeBuffer,this.previousSizeData,1);this.sourceSizeBuffer=o,this.targetSizeBuffer=a,this.previousSizeData=l,this.drawCommand&&this.drawCommand.setAttributes({...this.sourceSizeBuffer&&{sourceSize:this.sourceSizeBuffer},...this.targetSizeBuffer&&{targetSize:this.targetSizeBuffer}});const c=new Float32Array(n*n*4);for(let u=0;u<s.pointsNumber;u++){const h=r[u],f=((e=s.pointImageSizes)==null?void 0:e[u])??h;c[u*4]=Math.max(h,f)}if(!this.sizeTexture||this.sizeTexture.width!==n||this.sizeTexture.height!==n){this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy();const u=i.createTexture({width:n,height:n,format:"rgba32float"});this.sizeTexture=u,u.copyImageData({data:c,bytesPerRow:ue("rgba32float",n),mipLevel:0,x:0,y:0})}else this.sizeTexture.copyImageData({data:c,bytesPerRow:ue("rgba32float",n),mipLevel:0,x:0,y:0})}updateShape(){const{device:e,data:i}=this;if(i.pointsNumber===void 0||i.pointShapes===void 0)return;const n=i.pointShapes,s=n.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==s?(this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=e.createBuffer({data:n,usage:G.VERTEX|G.COPY_DST})):this.shapeBuffer.write(n),this.drawCommand&&this.drawCommand.setAttributes({shape:this.shapeBuffer})}updateImageIndices(){const{device:e,data:i}=this;if(i.pointsNumber===void 0||i.pointImageIndices===void 0)return;const n=i.pointImageIndices,s=n.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==s?(this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=e.createBuffer({data:n,usage:G.VERTEX|G.COPY_DST})):this.imageIndicesBuffer.write(n),this.drawCommand&&this.drawCommand.setAttributes({imageIndex:this.imageIndicesBuffer})}updateImageSizes(){const{device:e,data:i}=this;if(i.pointsNumber===void 0||i.pointImageSizes===void 0)return;const n=i.pointImageSizes,s=n.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==s?(this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=e.createBuffer({data:n,usage:G.VERTEX|G.COPY_DST})):this.imageSizesBuffer.write(n),this.drawCommand&&this.drawCommand.setAttributes({imageSize:this.imageSizesBuffer}),this.findHoveredPointCommand&&this.findHoveredPointCommand.setAttributes({imageSize:this.imageSizesBuffer})}createAtlas(){var e;const{device:i,data:n,store:s}=this;if(!((e=n.inputImageData)!=null&&e.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=i.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=i.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const r=LT(n.inputImageData,s.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=n.inputImageData.length;const{atlasData:o,atlasSize:a,atlasCoords:l,atlasCoordsSize:c}=r;this.imageAtlasCoordsTextureSize=c,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=i.createTexture({width:a,height:a,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:o,bytesPerRow:ue("rgba8unorm",a),rowsPerImage:a,mipLevel:0,x:0,y:0}),this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=i.createTexture({width:c,height:c,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:l,bytesPerRow:ue("rgba32float",c),rowsPerImage:c,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:i},device:n}=this;let s=i??Math.min(...e)/2;s===0&&(s=bt.pointSamplingDistance);const r=Math.ceil(e[0]/s),o=Math.ceil(e[1]/s);r===0||o===0||(!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,c
2740olorAttachments:["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 i=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(i),i.end()}setTransitionProgress(e,i=!1,n=!1){this.transitionProgress=e,this.shouldAnimatePointColors=i,this.shouldAnimatePointSizes=n}draw(e){var i,n,s,r;const{data:o,config:a,store:l}=this;if(this.targetColorBuffer||this.updateColor(),this.targetSizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.pointStatusTexture||this.pointStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!o.pointsNumber||o.pointsNumber===0||!l.screenSize||l.screenSize[0]===0||l.screenSize[1]===0)return;this.drawCommand.setVertexCount(o.pointsNumber);const c={ratio:a.pixelRatio,transformationMatrix:l.transformationMatrix4x4,pointsTextureSize:l.pointsTextureSize??0,sizeScale:a.pointSizeScale,spaceSize:l.adjustedSpaceSize,screenSize:ce(l.screenSize,[0,0]),greyoutColor:we(l.greyoutPointColor,[-1,-1,-1,-1]),backgroundColor:we(l.backgroundColor,[0,0,0,1]),scalePointsOnZoom:a.scalePointsOnZoom?1:0,maxPointSize:l.maxPointSize,isDarkenGreyout:l.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0,transitionProgress:this.transitionProgress,animateColors:this.shouldAnimatePointColors?1:0,animateSizes:this.shouldAnimatePointSizes?1:0},u={greyoutOpacity:a.pointGreyoutOpacity??-1,pointOpacity:a.pointOpacity,isDarkenGreyout:l.isDarkenGreyout??!1?1:0,backgroundColor:we(l.backgroundColor,[0,0,0,1]),outlineColor:we(l.outlinedPointRingColor,[1,1,1,1]),outlineWidth:.9};if(a.highlightedPointIndices!==void 0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...c,skipHighlighted:1,skipGreyed:0},drawFragmentUniforms:u}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...c,skipHighlighted:0,skipGreyed:1},drawFragmentUniforms:u}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...c,skipHighlighted:0,skipGreyed:0},drawFragmentUniforms:u}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),a.renderHoveredPointRing&&l.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.pointStatusTexture||this.pointStatusTexture.destroyed)return;const h=((i=o.pointSizes)==null?void 0:i[l.hoveredPoint.index])??1,f=((n=o.pointImageSizes)==null?void 0:n[l.hoveredPoint.index])??h;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:Math.max(h,f),transformationMatrix:l.transformationMatrix4x4,pointsTextureSize:l.pointsTextureSize??0,sizeScale:a.pointSizeScale,spaceSize:l.adjustedSpaceSize,screenSize:ce(l.screenSize,[0,0]),scalePointsOnZoom:a.scalePointsOnZoom?1:0,pointIndex:l.hoveredPoint.index,maxPointSize:l.maxPointSize,color:we(l.hoveredPointRingColor,[0,0,0,1]),universalPointOpacity:a.pointOpacity,greyoutOpacity:a.pointGreyoutOpacity??-1,isDarkenGreyout:l.isDarkenGreyout??!1?1:0,backgroundColor:we(l.backgroundColor,[0,0,0,1]),greyoutColor:we(l.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture}),this.drawHighlightedCommand.draw(e)}if(l.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.pointStatusTexture||this.pointStatusTexture.destroyed)return;const h=((s=o.pointSizes)==null?void 0:s[l.focusedPoint.index])??1,f=((r=o.pointImageSizes)==null?void 0:r[l.focusedPoint.index])??h;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:Math.max(h,f),transformationMatrix:l.transformationMatrix4x4,pointsTextureSize:l.pointsTextureSize??0,sizeScale:a.pointSizeScale,spaceSize:l.adjustedSpaceSize,screenSize:ce(l.screenSize,[0,0]),scalePointsOnZoom:a.scalePointsOnZoom?1:0,pointIndex:l.focusedPoint.index,maxPointSize:l.maxPointSize,color:we(l.focu
2740sedPointRingColor,[0,0,0,1]),universalPointOpacity:a.pointOpacity,greyoutOpacity:a.pointGreyoutOpacity??-1,isDarkenGreyout:l.isDarkenGreyout??!1?1:0,backgroundColor:we(l.backgroundColor,[0,0,0,1]),greyoutColor:we(l.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture}),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,spaceSize:this.store.adjustedSpaceSize}}),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.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:ce(this.store.mousePosition,[0,0]),index:((e=this.store.hoveredPoint)==null?void 0:e.index)??-1}}),this.dragPointCommand.setBindings({positionsTexture:this.previousPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(i),i.end(),this.isPositionsUpToDate=!1}findPointsInRect(){var e,i;if(!this.findPointsInRectCommand||!this.findPointsInRectUniformStore||!this.searchFbo||this.searchFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return!1;this.findPointsInRectUniformStore.setUniforms({findPointsInRectUniforms:{spaceSize:this.store.adjustedSpaceSize,screenSize:ce(this.store.screenSize,[0,0]),sizeScale:this.config.pointSizeScale,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio,rect0:ce((e=this.store.searchArea)==null?void 0:e[0],[0,0]),rect1:ce((i=this.store.searchArea)==null?void 0:i[1],[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom?1:0,maxPointSize:this.store.maxPointSize}}),this.findPointsInRectCommand.setBindings({positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const n=this.device.beginRenderPass({framebuffer:this.searchFbo});return this.findPointsInRectCommand.draw(n),n.end(),!0}findPointsInPolygon(){if(!this.findPointsInPolygonCommand||!this.findPointsInPolygonUniformStore||!this.searchFbo||this.searchFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return!1;this.findPointsInPolygonUniformStore.setUniforms({findPointsInPolygonUniforms:{spaceSize:this.store.adjustedSpaceSize,screenSize:ce(this.store.screenSize,[0,0]),transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsInPolygonCommand.setBindings({positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.searchFbo});return this.findPointsInPolygonCommand.draw(e),e.end(),!0}updatePolygonPath(e){const{device:i}=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=i.createTexture({width:n,height:n,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:s,bytesPerRow:ue("rgba32float",n),mipLevel:0,x:0,y:0})):this.polygonPathTexture.copyImageData({data:s,bytesPerRow:ue("rgba32float",n),mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed||!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||(this.pointStatusTexture||this.updatePointStatus(),!this.pointStatusTexture||this.pointStatusTexture.destroyed))return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.targetSizeBuffer&&{size:this.targetSizeBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}});const e={ratio:this.config.pixelRatio,sizeScale:this.config.pointSizeScale,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize,screenSize:ce(this.store.screenSize,[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom?1:0,mousePosition:ce(this.store.screenMousePosition,[0,0]),maxPointSize:this.store.maxPointSize},i={positionsTexture:this.currentPositionTexture,pointStatus:this.pointStatusTexture},n=this.device.beginRenderPass({framebuffer:this.hoveredFbo,clearColor:[0,0,0,0]});this.config.highlightedPointIndices!==void 0?(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipHighlighted:1,skipGreyed:0}}),this.findHoveredPointCommand.setBindings(i),this.findHoveredPointCommand.draw(n),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipHighlighted:0,skipGreyed:1}}),this.findHoveredPointCommand.setBindings(i),this.findHoveredPointCommand.draw(n)):(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipHighlighted:0,skipGreyed:0}}),this.findHoveredPointCommand.setBindings(i),this.findHoveredPointCommand.draw(n)),n.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:i},device:n}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!i)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%i,r[o*4+1]=Math.floor(a/i),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:ue("rgba32float",s),mipLevel:0,x:0,y:0})):this.trackedIndicesTexture.copyImageData({data:r,bytesPerRow:ue("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:i}}=this;if((!e||!i)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const n=Ke(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||!i)&&(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,screenSize:ce(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 i=Ke(this.device,this.sampledPointsFbo);for(let n=0;n<i.length/4;n++){const s=i[n*4],r=!!i[n*4+1],o=i[n*4+2],a=i[n*4+3];r&&s!==void 0&&o!==void 0&&a!==void 0&&e.set(s,[o,a])}return e}getSampledPoints(){const e=[],i=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:i};if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:i};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize,screenSize:ce(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=Ke(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),i.push(a,l))}return{indices:e,positions:i}}getTrackedPositionsArray(){const e=[];
2740if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const i=Ke(this.device,this.trackedPositionsFbo);for(let n=0;n<i.length/4;n+=1){const s=i[n*4],r=i[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,i,n,s,r,o,a,l,c,u,h,f,d,T,C,w,A,F,b,g;(e=this.drawCommand)==null||e.destroy(),this.drawCommand=void 0,(i=this.drawHighlightedCommand)==null||i.destroy(),this.drawHighlightedCommand=void 0,(n=this.interpolatePositionCommand)==null||n.destroy(),this.interpolatePositionCommand=void 0,(s=this.updatePositionCommand)==null||s.destroy(),this.updatePositionCommand=void 0,(r=this.dragPointCommand)==null||r.destroy(),this.dragPointCommand=void 0,(o=this.findPointsInRectCommand)==null||o.destroy(),this.findPointsInRectCommand=void 0,(a=this.findPointsInPolygonCommand)==null||a.destroy(),this.findPointsInPolygonCommand=void 0,(l=this.findHoveredPointCommand)==null||l.destroy(),this.findHoveredPointCommand=void 0,(c=this.fillSampledPointsFboCommand)==null||c.destroy(),this.fillSampledPointsFboCommand=void 0,(u=this.trackPointsCommand)==null||u.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.sourcePositionFbo&&!this.sourcePositionFbo.destroyed&&this.sourcePositionFbo.destroy(),this.sourcePositionFbo=void 0,this.targetPositionFbo&&!this.targetPositionFbo.destroyed&&this.targetPositionFbo.destroy(),this.targetPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.searchFbo&&!this.searchFbo.destroyed&&this.searchFbo.destroy(),this.searchFbo=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.sourcePositionTexture&&!this.sourcePositionTexture.destroyed&&this.sourcePositionTexture.destroy(),this.sourcePositionTexture=void 0,this.targetPositionTexture&&!this.targetPositionTexture.destroyed&&this.targetPositionTexture.destroy(),this.targetPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.searchTexture&&!this.searchTexture.destroyed&&this.searchTexture.destroy(),this.searchTexture=void 0,this.pointStatusTexture&&!this.pointStatusTexture.destroyed&&this.pointStatusTexture.destroy(),this.pointStatusTexture=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,(h=this.interpolatePositionUniformStore)==null||h.destroy(),this.interpolatePositionUniformStore=void 0,(f=this.updatePositionUniformStore)==null||f.destroy(),this.updatePositionUniformStore=void 0,(d=this.dragPointUniformStore)==null||d.destroy(),this.dragPointUniformStore=void 0,(T=this.drawUniformStore)==null||T.destroy(),this.drawUniformStore=void 0,(C=this.findPointsInRectUniformStore)==null||C.destroy(),this.findPointsInRectUniformStore=void 0,(w=this.findPointsInPolygonUniformStore)==null||w.destroy(),this.findPointsInPolygonUniformStore=void 0,(A=this.findHoveredPointUniformStore)==null||A.destroy(),this.findHoveredPointUniformStore=void 0,(F=this.fillSampledPointsUniformStore)==null||F.destroy(),this.fillSampledPointsUniformStore=void 0,(b=this.drawHighlightedUniformStore)==null||b.destroy(),this.drawHighlightedUniformStore=void 0,(g=this.trackPointsUniformStore)==null||g.destroy(),this.trackPointsUniformStore=void 0,this.sourceColorBuffer&&!this.sourceColorBuffer.destroyed&&this.sourceColorBuffer.destroy(),this.sourceColorBuffer=void 0,this.targetColorBuffer&&!this.targetColorBuffer.destroyed&&this.targetColorBuffer.destroy(),this.targetColorBuffer=void 0,this.previousColorData=void 0,this.sourceSizeBuffer&&!this.sourceSizeBuffer.destroyed&&this.sourceSizeBuffer.destroy(),this.sourceSizeBuffer=void 0,this.targetSizeBuffer&&!this.targetSizeBuffer.destroyed&&this.targetSizeBuffer.destroy(),this.targetSizeBuffer=void 0,this.previousSizeData=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.interpolatePositionVertexCoordBuffer&&!this.interpolatePositionVertexCoordBuffer.destroyed&&this.interpolatePositionVertexCoordBuffer.destroy(),this.interpolatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsInRectVertexCoordBuffer&&!this.findPointsInRectVertexCoordBuffer.destroyed&&this.findPointsInRectVertexCoordBuffer.destroy(),this.findPointsInRectVertexCoordBuffer=void 0,this.findPointsInPolygonVertexCoordBuffer&&!this.findPointsInPolygonVertexCoordBuffer.destroyed&&this.findPointsInPolygonVertexCoordBuffer.destroy(),this.findPointsInPolygonVertexCoordBuffer=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}ensureSimulationResources(){const{store:{pointsTextureSize:e},device:i}=this;if(!e)return;this.ensureUpdatePositionProgram();const n=new Float32Array(e*e*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==e||this.velocityTexture.height!==e?(this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=i.createTexture({width:e,height:e,format:"rgba32float"}),this.velocityTexture.copyImageData({data:n,bytesPerRow:ue("rgba32float",e),mipLevel:0,x:0,y:0}),this.velocityFbo=i.createFramebuffer({width:e,height:e,colorAttachments:[this.velocityTexture]}
2740)):this.velocityTexture.copyImageData({data:n,bytesPerRow:ue("rgba32float",e),mipLevel:0,x:0,y:0})}createTransitionResources(){const{store:{pointsTextureSize:e},device:i}=this;if(!e)return;const n=new Float32Array(e*e*4).fill(0),s=j.SAMPLE|j.RENDER|j.COPY_SRC|j.COPY_DST;(!this.sourcePositionTexture||this.sourcePositionTexture.width!==e||this.sourcePositionTexture.height!==e)&&(this.sourcePositionFbo&&!this.sourcePositionFbo.destroyed&&this.sourcePositionFbo.destroy(),this.sourcePositionTexture&&!this.sourcePositionTexture.destroyed&&this.sourcePositionTexture.destroy(),this.sourcePositionTexture=i.createTexture({width:e,height:e,format:"rgba32float",usage:s}),this.sourcePositionFbo=i.createFramebuffer({width:e,height:e,colorAttachments:[this.sourcePositionTexture]})),this.sourcePositionTexture.copyImageData({data:n,bytesPerRow:ue("rgba32float",e),mipLevel:0,x:0,y:0}),(!this.targetPositionTexture||this.targetPositionTexture.width!==e||this.targetPositionTexture.height!==e)&&(this.targetPositionFbo&&!this.targetPositionFbo.destroyed&&this.targetPositionFbo.destroy(),this.targetPositionTexture&&!this.targetPositionTexture.destroyed&&this.targetPositionTexture.destroy(),this.targetPositionTexture=i.createTexture({width:e,height:e,format:"rgba32float",usage:s}),this.targetPositionFbo=i.createFramebuffer({width:e,height:e,colorAttachments:[this.targetPositionTexture]})),this.targetPositionTexture.copyImageData({data:n,bytesPerRow:ue("rgba32float",e),mipLevel:0,x:0,y:0}),this.interpolatePositionVertexCoordBuffer||(this.interpolatePositionVertexCoordBuffer=i.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.interpolatePositionUniformStore||(this.interpolatePositionUniformStore=new Se({interpolatePositionUniforms:{uniformTypes:{progress:"f32"},defaultUniforms:{progress:0}}})),this.interpolatePositionCommand||(this.interpolatePositionCommand=new ge(i,{fs:OT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.interpolatePositionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{interpolatePositionUniforms:this.interpolatePositionUniformStore.getManagedUniformBuffer(i,"interpolatePositionUniforms")}}))}destroyTransitionResources(){var e,i;(e=this.interpolatePositionCommand)==null||e.destroy(),this.interpolatePositionCommand=void 0,(i=this.interpolatePositionUniformStore)==null||i.destroy(),this.interpolatePositionUniformStore=void 0,this.interpolatePositionVertexCoordBuffer&&!this.interpolatePositionVertexCoordBuffer.destroyed&&this.interpolatePositionVertexCoordBuffer.destroy(),this.interpolatePositionVertexCoordBuffer=void 0,this.sourcePositionFbo&&!this.sourcePositionFbo.destroyed&&this.sourcePositionFbo.destroy(),this.sourcePositionFbo=void 0,this.sourcePositionTexture&&!this.sourcePositionTexture.destroyed&&this.sourcePositionTexture.destroy(),this.sourcePositionTexture=void 0,this.targetPositionFbo&&!this.targetPositionFbo.destroyed&&this.targetPositionFbo.destroy(),this.targetPositionFbo=void 0,this.targetPositionTexture&&!this.targetPositionTexture.destroyed&&this.targetPositionTexture.destroy(),this.targetPositionTexture=void 0}interpolatePosition(e){if(!this.interpolatePositionCommand||!this.interpolatePositionUniformStore||!this.sourcePositionTexture||this.sourcePositionTexture.destroyed||!this.targetPositionTexture||this.targetPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed)return;this.interpolatePositionUniformStore.setUniforms({interpolatePositionUniforms:{progress:e}}),this.interpolatePositionCommand.setBindings({sourceTexture:this.sourcePositionTexture,targetTexture:this.targetPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.interpolatePositionCommand.draw(i),i.end(),this.isPositionsUpToDate=!1,this.areClusterCentroidsUpToDate=!1}destroySimulationResources(){var e,i;(e=this.updatePositionCommand)==null||e.destroy(),this.updatePositionCommand=void 0,(i=this.updatePositionUniformStore)==null||i.destroy(),this.updatePositionUniformStore=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=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,i=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=i,this.areClusterCentroidsUpToDate=!1}ensurePositionTextures(e){(!this.currentPositionTexture||this.currentPositionTexture.width!==e||this.currentPositionTexture.height!==e)&&(this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionTexture=this.device.createTexture({width:e,height:e,format:"rgba32float"}),this.currentPositionFbo=this.device.createFramebuffer({width:e,height:e,colorAttachments:[this.currentPositionTexture]}
2740)),(!this.previousPositionTexture||this.previousPositionTexture.width!==e||this.previousPositionTexture.height!==e)&&(this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionTexture=this.device.createTexture({width:e,height:e,format:"rgba32float"}),this.previousPositionFbo=this.device.createFramebuffer({width:e,height:e,colorAttachments:[this.previousPositionTexture]}))}writePositionTexture(e,i,n){e.copyImageData({data:i,bytesPerRow:ue("rgba32float",n),mipLevel:0,x:0,y:0})}ensureUpdatePositionProgram(){const{device:e,config:i,store:n}=this;this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new Se({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:i.simulationFriction,spaceSize:n.adjustedSpaceSize}}})),this.updatePositionCommand||(this.updatePositionCommand=new ge(e,{fs:DT,vs:Ge,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.updatePositionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(e,"updatePositionUniforms")}}))}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const i=this.data.pointPositions,n=i.length/2;let s=1/0,r=-1/0,o=1/0,a=-1/0;for(let A=0;A<i.length;A+=2){const F=i[A],b=i[A+1];s=Math.min(s,F),r=Math.max(r,F),o=Math.min(o,b),a=Math.max(a,b)}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 h=e*e*.001,f=n>h?e*Math.max(1.2,Math.sqrt(n)/e):e*.1,d=f/u,T=(e-f)/2,C=(u-l)/2*d+T,w=(u-c)/2*d+T;this.scaleX=A=>(A-s)*d+C,this.scaleY=A=>(A-o)*d+w;for(let A=0;A<n;A++)this.data.pointPositions[A*2]=this.scaleX(i[A*2]),this.data.pointPositions[A*2+1]=this.scaleY(i[A*2+1])}}class XT{constructor(e,i){this.eventTransform=Hi,this.behavior=Lg().scaleExtent([.001,1/0]).on("start",n=>{var s,r;this.isRunning=!0;const o=!!n.sourceEvent;o&&(this.shouldEnableSimulationDuringZoomOverride=void 0),(r=(s=this.config).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,h=u[0],f=u[1];if(!h||!f)return;T_(c,h,f),Vo(c,c,[o,a]),Ms(c,c,[l,l]),Vo(c,c,[h/2,f/2]),Ms(c,c,[h/2,f/2]),Ms(c,c,[1,-1]);const d=!!n.sourceEvent;(r=(s=this.config).onZoom)==null||r.call(s,n,d)}).on("end",n=>{var s,r;this.isRunning=!1;const o=!!n.sourceEvent;(r=(s=this.config).onZoomEnd)==null||r.call(s,n,o)}),this.isRunning=!1,this.shouldEnableSimulationDuringZoomOverride=void 0,this.store=e,this.config=i}getTransform(e,i,n=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:s}}=this,r=s[0],o=s[1];let a=1/0,l=-1/0,c=1/0,u=-1/0;for(let g=0;g<e.length;g+=2){const v=e[g],N=e[g+1];v<a&&(a=v),v>l&&(l=v),N<c&&(c=N),N>u&&(u=N)}const h=[this.store.scaleX(a),this.store.scaleX(l)],f=[this.store.scaleY(c),this.store.scaleY(u)];h[0]===h[1]&&(h[0]-=.5,h[1]+=.5),f[0]===f[1]&&(f[0]+=.5,f[1]-=.5);const d=r*(1-n*2)/(h[1]-h[0]),T=o*(1-n*2)/(f[0]-f[1]),C=Wg(i??Math.min(d,T),...this.behavior.scaleExtent()),w=(h[1]+h[0])/2,A=(f[1]+f[0])/2,F=r/2-w*C,b=o/2-A*C;return Hi.translate(F,b).scale(C)}getDistanceToPoint(e){const{x:i,y:n,k:s}=this.eventTransform,r=this.getTransform(e,s),o=i-r.x,a=n-r.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:i},eventTransform:{x:n,y:s,k:r}}=this,o=i[0],a=i[1],l=(o/2-n)/r,c=(a/2-s)/r,u=this.store.scaleX(e[0]),h=this.store.scaleY(e[1]),f=(l+u)/2,d=(c+h)/2,T=1,C=o/2-f*T,w=a/2-d*T;return Hi.translate(C,w).scale(T)}convertScreenToSpacePosition(e){const{eventTransform:{x:i,y:n,k:s},store:{screenSize:r}}=this,o=r[0],a=r[1],l=(e[0]-i)/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 i=this.eventTransform.applyX(this.store.scaleX(e[0])),n=this.eventTransform.applyY(this.store.scaleY(e[1]));return[i,n]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:i},store:{maxPointSize:n},eventTransform:{k:s}}=this;let r=e*2;return i?r*=s:r*=Math.min(5,Math.max(1,s*.01)),Math.min(r,n)/2}}
2740class WT{constructor(e,i,n){this.isActive=!1,this.behavior=Mg().subject(s=>{if(!(this.transition.isActiveFor(Ie.Positions)||this.transition.isActiveFor(Ie.PointSizes)))return this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:s.x,y:s.y}:void 0}).on("start",s=>{var r,o;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(o=(r=this.config).onDragStart)==null||o.call(r,s))}).on("drag",s=>{var r,o;(o=(r=this.config).onDrag)==null||o.call(r,s)}).on("end",s=>{var r,o;this.isActive=!1,this.store.draggingPointIndex=void 0,(o=(r=this.config).onDragEnd)==null||o.call(r,s)}),this.store=e,this.config=i,this.transition=n}}const $T=500,Ia=10;class YT{constructor(e,i,n){if(this.config=pc(),this.graph=new Yg(this.config),this.isReady=!1,this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this._longPressStartX=0,this._longPressStartY=0,this._shouldSuppressNextClick=!1,this.store=new Hg,this.zoomInstance=new XT(this.store,this.config),this.transition=new Gg(this.config),this.dragInstance=new WT(this.store,this.config,this.transition),this._findHoveredItemExecutionCount=0,this._isPointerOnCanvas=!1,this._lastMouseX=0,this._lastMouseY=0,this._lastCheckedMouseX=0,this._lastCheckedMouseY=0,this._shouldForceHoverDetection=!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.isForceCollisionReady=!1,this._isDestroyed=!1,i&&Xs(this.config,i),n)this.deviceInitPromise=n,this.shouldDestroyDevice=!1;else{const r=document.createElement("canvas");this.deviceInitPromise=this.createDevice(r),this.shouldDestroyDevice=!0}const s=this.deviceInitPromise.then(r=>{if(this._isDestroyed)return this.shouldDestroyDevice&&r.destroy(),r;this.device=r,this.isReady=!0;const o=this.validateDevice(r);n&&o.setProps({useDevicePixels:this.config.pixelRatio}),this.store.div=e;const a=o.canvas;a.parentNode!==this.store.div&&(a.parentNode&&a.parentNode.removeChild(a),this.store.div.appendChild(a)),this.addAttribution(),a.style.width="100%",a.style.height="100%",this.canvas=a,this.updateCanvasTouchAction();const l=this.canvas.clientWidth,c=this.canvas.clientHeight;return this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(l,c),this.canvasD3Selection=Me(this.canvas).call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("pointerenter.cosmos",u=>{u.isPrimary&&(this._isPointerOnCanvas=!0,this._lastMouseX=u.clientX,this._lastMouseY=u.clientY)}).on("pointermove.cosmos",u=>{var h,f,d,T;if(u.isPrimary){if(this._isPointerOnCanvas=!0,this._lastMouseX=u.clientX,this._lastMouseY=u.clientY,this.currentEvent=u,this.updateMousePosition(u),this.isRightClickMouse=(u.buttons&2)!==0,this._longPressTimerId!==void 0){const C=Math.abs(u.clientX-this._longPressStartX),w=Math.abs(u.clientY-this._longPressStartY);(C>Ia||w>
2740Ia)&&this.cancelLongPress()}(T=(d=this.config).onMouseMove)==null||T.call(d,(h=this.store.hoveredPoint)==null?void 0:h.index,(f=this.store.hoveredPoint)==null?void 0:f.position,this.currentEvent)}}).on("pointerleave.cosmos pointercancel.cosmos",u=>{u.isPrimary&&(this.cancelLongPress(),this._isPointerOnCanvas=!1,u.pointerType==="mouse"&&(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()))}).on("pointerdown.cosmos",u=>{u.isPrimary&&(this.currentEvent=u,this._shouldSuppressNextClick=!1,this._lastMouseX=u.clientX,this._lastMouseY=u.clientY,this.updateMousePosition(u),this.findHoveredItem(!0),u.pointerType!=="mouse"&&(this._longPressStartX=u.clientX,this._longPressStartY=u.clientY,this.cancelLongPress(),this._longPressTimerId=window.setTimeout(()=>{this._longPressTimerId=void 0,!this._isDestroyed&&(this.findHoveredItem(!0),this._shouldSuppressNextClick=!0,this.fireContextMenu(u))},$T)))}).on("pointerup.cosmos",u=>{u.isPrimary&&(this.cancelLongPress(),this.isRightClickMouse=(u.buttons&2)!==0)}).on("click.cosmos",this.onClick.bind(this)).on("contextmenu.cosmos",this.onContextMenu.bind(this)),Me(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._shouldForceHoverDetection=!0}),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.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1),this.store.maxPointSize=xa(r,this.config.pixelRatio),this.store.isSimulationRunning=this.config.enableSimulation,this.points=new VT(r,this.config,this.store,this.graph),this.points.transition=this.transition,this.lines=new AT(r,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new Ea(r,this.config,this.store,this.graph,this.points),this.forceCenter=new ya(r,this.config,this.store,this.graph,this.points),this.forceManyBody=new Aa(r,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new pn(r,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new pn(r,this.config,this.store,this.graph,this.points),this.forceMouse=new Ra(r,this.config,this.store,this.graph,this.points),this.forceCollision=new va(r,this.config,this.store,this.graph,this.points)),this.clusters=new pT(r,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Rt(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor),this.store.setOutlinedPointRingColor(this.config.outlinedPointRingColor),this.store.setHighlightedPointSet(this.config.highlightedPointIndices),this.store.setOutlinedPointSet(this.config.outlinedPointIndices),this.store.setHoveredLinkColor(this.config.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Ca(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),r}).catch(r=>{throw this.device=void 0,this.isReady=!1,console.error("Device initialization failed:",r),r});this.ready=s.then(()=>{})}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){if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const i={...this.config};Zg(this.config),Xs(this.config,e),this.preserveInitOnlyFields(i),this.updateStateFromConfig(i)}setConfigPartial(e){if(this._isDestroyed||this.ensureDevice(()=>this.setConfigPartial(e)))return;const i={...this.config};Xs(this.config,e,!0),this.preserveInitOnlyFields(i),this.updateStateFromConfig(i)}setPointPositions(e,i){var n;if(this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,i)))return;this.graph.inputPointPositions=e,this.points.shouldSkipRescale=i,this.isPointPositionsUpdateNeeded=!0;const s=(n=this.points)==null?void 0:n.currentPositionTexture;s&&!s.destroyed&&this.transition.queue(Ie.Positions),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,this.transition.queue(Ie.PointColors))}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,this.transition.queue(Ie.PointSizes))}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var i;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(i=this.points)==null||i.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,this.transition.queue(Ie.LinkColors))}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,this.transition.queue(Ie.LinkWidths))}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)}
2740setPointClusters(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 i;this._isDestroyed||this.ensureDevice(()=>this.setPinnedPoints(e))||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,(i=this.points)==null||i.updatePinnedStatus())}render(e){var i,n,s;if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:r,fitViewDelay:o,fitViewPadding:a,fitViewDuration:l,fitViewByPointsInRect:c,fitViewByPointIndices:u,initialZoomLevel:h}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Me(this.canvas).style("cursor",null),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit());return}this._isFirstRenderAfterInit&&r&&h===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{u?this.fitViewByPointIndices(u,l,a):c?this.setZoomTransformByPointPositions(new Float32Array(this.flatten(c)),l,void 0,a):this.fitView(l,a)},o)),this.update(e),this.transition.isPendingFor(Ie.Positions)&&this.store.isSimulationRunning&&this.config.transitionDuration>0&&!this._isFirstRenderAfterInit&&(this.store.isSimulationRunning=!1,(n=(i=this.config).onSimulationPause)==null||n.call(i));const f=(s=this.points)==null?void 0:s.currentPositionTexture;this.transition.isPending&&(!f||f.destroyed)&&this.transition.abort(),this.transition.start(),this._shouldForceHoverDetection=!0,this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,i=700,n=3,s=!0,r=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,i,n,s,r))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,a=Ke(this.device,this.points.currentPositionFbo);if(e===void 0)return;const l=a[e*4+0],c=a[e*4+1];if(l===void 0||c===void 0)return;const u=this.zoomInstance.getDistanceToPoint([l,c]),h=s?n:Math.max(this.getZoomLevel(),n);if(u<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions(new Float32Array([l,c]),i,h,void 0,r);else{this.zoomInstance.shouldEnableSimulationDuringZoomOverride=r;const f=this.zoomInstance.getTransform([l,c],h),d=this.zoomInstance.getMiddlePointTransform([l,c]);this.canvasD3Selection.transition().ease(rl).duration(i/2).call(this.zoomInstance.behavior.transform,d).transition().ease(ol).duration(i/2).call(this.zoomInstance.behavior.transform,f)}}zoom(e,i=0,n=!0){this._isDestroyed||this.setZoomLevel(e,i,n)}setZoomLevel(e,i=0,n=!0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,i,n))||this.canvasD3Selection&&(this.zoomInstance.shouldEnableSimulationDuringZoomOverride=n,i===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(i).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=[],i=Ke(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let n=0;n<this.graph.pointsNumber;n+=1){const s=i[n*4+0],r=i[n*4+1];s!==void 0&&r!==void 0&&(e[n*2]=s,e[n*2+1]=r)}return e}getClusterPositions(){return this._isDestroyed||!this.device||!this.cluster
2740s?[]:this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0?[]:this.clusters.getCentroidPositions()}fitView(e=250,i=.1,n=!0){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,i,n))||this.setZoomTransformByPointPositions(this.getFitViewPositions(),e,void 0,i,n)}fitViewByPointIndices(e,i=250,n=.1,s=!0){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,i,n,s)))return;const r=this.getFitViewPositions(),o=new Float32Array(e.length*2);for(const[a,l]of e.entries())o[a*2]=r[l*2],o[a*2+1]=r[l*2+1];this.setZoomTransformByPointPositions(o,i,void 0,n,s)}fitViewByPointPositions(e,i=250,n=.1,s=!0){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,i,n,s))||this.setZoomTransformByPointPositions(new Float32Array(e),i,void 0,n,s)}setZoomTransformByPointPositions(e,i=250,n,s=.1,r=!0){var o;if(this._isDestroyed||this.ensureDevice(()=>this.setZoomTransformByPointPositions(e,i,n,s,r)))return;this.zoomInstance.shouldEnableSimulationDuringZoomOverride=r,this.resizeCanvas();const a=this.zoomInstance.getTransform(e,n,s);(o=this.canvasD3Selection)==null||o.transition().ease(al).duration(i).call(this.zoomInstance.behavior.transform,a)}findPointsInRect(e){if(this._isDestroyed)return[];if(!this.isReady||!this.device||!this.points)return[];const i=this.store.screenSize[1];return this.store.searchArea=[[e[0][0],i-e[1][1]],[e[1][0],i-e[0][1]]],this.points.findPointsInRect()?Sa(Ke(this.device,this.points.searchFbo)):[]}findPointsInPolygon(e){if(this._isDestroyed)return[];if(!this.isReady||!this.device||!this.points)return[];if(e.length<3)return console.warn("Polygon path requires at least 3 points to form a polygon."),[];const i=this.store.screenSize[1],n=e.map(([s,r])=>[s,i-r]);return this.points.updatePolygonPath(n),this.points.findPointsInPolygon()?Sa(Ke(this.device,this.points.searchFbo)):[]}getNeighboringPointIndices(e){return this._isDestroyed?[]:this.graph.getNeighboringPointIndices(e)}getConnectedLinkIndices(e){return this._isDestroyed?[]:this.graph.getConnectedLinkIndices(e)}getConnectedPointIndices(e){return this._isDestroyed?[]:this.graph.getConnectedPointIndices(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 i,n;if(this._isDestroyed)return;const s=(i=this.graph.pointSizes)==null?void 0:i[e],r=(n=this.graph.pointImageSizes)==null?void 0:n[e];if(!(s===void 0&&r===void 0))return Math.max(s??0,r??0)}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()}getSampledLinkPositionsMap(){return this._isDestroyed||!this.lines?new Map:this.lines.getSampledLinkPositionsMap()}getSampledLinks(){return this._isDestroyed||!this.lines?{indices:[],positions:[],angles:[]}:this.lines.getSampledLinks()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var i,n;if(this._isDestroyed||this.ensureDevice(()=>this.start(e))||!this.config.enableSimulation||!this.graph.pointsNumber)return;this.transition.isActiveFor(Ie.Positions)&&this.transition.end(!0);const s=this.store.isSimulationRunning;this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,s||(n=(i=this.config).onSimulationStart)==null||n.call(i)}stop(){var e,i;if(this._isDestroyed)return;const n=this.store.isSimulationRunning||this.store.alpha>0||this.store.simulationProgress>0;this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,n&&((i=(e=this.config).onSimulationEnd)==null||i.call(e))}pause(){var e,i;this._isDestroyed||this.ensureDevice(()=>this.pause())||this.store.isSimulationRunning&&(this.store.isSimulationRunning=!1,(i=(e=this.config).onSimulationPause)==null||i.call(e))}unpause(){var e,i;this._isDestroyed||this.ensureDevice(()=>this.unpause())||this.config.enableSimulation&&(this.store.isSimulationRunning||(this.transition.isActiveFor(Ie.Positions)&&this.transition.end(!0),this.store.isSimulationRunning=!0,(i=(e=this.config).onSimulationUnpause)==null||i.call(e)))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,i,n,s,r,o,a,l,c,u,h,f,d,T;this._isDestroyed||(this._isDestroyed=!0,this.isReady=!1,this.transition.abort(),window.clearTimeout(this._fitViewOnInitTimeoutID),this.cancelLongPress(),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on(".cosmos",null).on(".drag",null).on(".zoom",null),Me(d
2740ocument).on(".cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(i=this.dragInstance)!=null&&i.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(),(h=this.forceLinkOutgoing)==null||h.destroy(),(f=this.forceMouse)==null||f.destroy(),(d=this.forceCollision)==null||d.destroy(),this.device&&this.shouldDestroyDevice&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit(),this.device.destroy()),this.shouldDestroyDevice&&this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(T=document.getElementById("gl-bench-style"))==null||T.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0)}create(){var e,i,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.isForceManyBodyUpdateNeeded||this.isPointSizeUpdateNeeded)&&(this.isForceCollisionReady=!1),this.isForceLinkUpdateNeeded&&((i=this.forceLinkIncoming)==null||i.create(ur.INCOMING),(n=this.forceLinkOutgoing)==null||n.create(ur.OUTGOING)),this.isForceCenterUpdateNeeded&&((s=this.forceCenter)==null||s.create()),this.isPointClusterUpdateNeeded&&((r=this.cluster
2740s)==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 i=new Array(e.length/2);for(let n=0;n<e.length/2;n++)i[n]=[e[n*2],e[n*2+1]];return i}preserveInitOnlyFields(e){this.config.initialZoomLevel=e.initialZoomLevel,this.config.randomSeed=e.randomSeed,this.config.attribution=e.attribution}getFitViewPositions(){return this.transition.isActive&&this.transition.isActiveFor(Ie.Positions)&&this.graph.pointPositions&&this.graph.pointPositions?new Float32Array(this.graph.pointPositions):new Float32Array(this.getPointPositions())}updateStateFromConfig(e){var i,n,s,r,o,a,l,c,u,h,f,d,T;this.applyEnableSimulationConfigChange(e),e.pointDefaultColor!==this.config.pointDefaultColor&&(this.graph.updatePointColor(),(i=this.points)==null||i.updateColor()),e.pointDefaultSize!==this.config.pointDefaultSize&&(this.graph.updatePointSize(),(n=this.points)==null||n.updateSize()),e.pointDefaultShape!==this.config.pointDefaultShape&&(this.graph.updatePointShape(),(s=this.points)==null||s.updateShape()),e.linkDefaultColor!==this.config.linkDefaultColor&&(this.graph.updateLinkColor(),(r=this.lines)==null||r.updateColor()),e.linkDefaultWidth!==this.config.linkDefaultWidth&&(this.graph.updateLinkWidth(),(o=this.lines)==null||o.updateWidth()),e.linkDefaultArrows!==this.config.linkDefaultArrows&&(this.graph.updateArrows(),(a=this.lines)==null||a.updateArrow()),e.linkBlending!==this.config.linkBlending&&((l=this.lines)==null||l.updateLinkBlending()),(e.curvedLinkSegments!==this.config.curvedLinkSegments||e.curvedLinks!==this.config.curvedLinks)&&((c=this.lines)==null||c.updateCurveLineGeometry()),e.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Rt(this.config.backgroundColor)),e.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor),e.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor),e.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor),e.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor),e.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),e.outlinedPointRingColor!==this.config.outlinedPointRingColor&&this.store.setOutlinedPointRingColor(this.config.outlinedPointRingColor),e.highlightedPointIndices!==this.config.highlightedPointIndices&&this.store.setHighlightedPointSet(this.config.highlightedPointIndices),e.outlinedPointIndices!==this.config.outlinedPointIndices&&this.store.setOutlinedPointSet(this.config.outlinedPointIndices),(e.highlightedPointIndices!==this.config.highlightedPointIndices||e.outlinedPointIndices!==this.config.outlinedPointIndices)&&((u=this.points)==null||u.updatePointStatus()),e.highlightedLinkIndices!==this.config.highlightedLinkIndices&&((h=this.lines)==null||h.updateLinkStatus()),(e.simulationCollisionRadius!==this.config.simulationCollisionRadius||e.simulationCollisionPadding!==this.config.simulationCollisionPadding||(this.config.simulationCollisionRadius===void 0||this.config.simulationCollisionRadius===0)&&e.pointDefaultSize!==this.config.pointDefaultSize)&&(this.isForceCollisionReady=!1),e.pixelRatio!==this.config.pixelRatio&&(f=this.device)!=null&&f.canvasContext&&(this.device.canvasContext.setProps({useDevicePixels:this.config.pixelRatio}),this.store.maxPointSize=xa(this.device,this.config.pixelRatio)),e.spaceSize!==this.config.spaceSize&&(this.store.adjustSpaceSize(this.config.spaceSize,((d=this.device)==null?void 0:d.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),e.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Ca(this.canvas):((T=this.fpsMonitor)==null||T.destroy(),this.fpsMonitor=void 0)),(e.enableZoom!==this.config.enableZoom||e.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(e.onLinkClick!==this.config.onLinkClick||e.onLinkContextMenu!==this.config.onLinkContextMenu||e.onLinkMouseOver!==this.config.onLinkMouseOver||e.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}applyEnableSimulationConfigChange(e){var i,n,s,r,o;
2740if(e.enableSimulation===this.config.enableSimulation)return;if(this.config.enableSimulation){this.transition.end(!0),this.transition.dequeue(Ie.Positions),this.ensureSimulationModules(),(i=this.points)==null||i.ensureSimulationResources(),this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0,this.create(),this.initPrograms(),this.store.simulationProgress=0,this.store.alpha=1,this.store.isSimulationRunning=!0,this._shouldForceHoverDetection=!0,(s=(n=this.config).onSimulationStart)==null||s.call(n);return}const a=this.store.isSimulationRunning||this.store.alpha>0||this.store.simulationProgress>0;this.store.isSimulationRunning=!1,this.store.alpha=0,this.store.simulationProgress=0,this._shouldForceHoverDetection=!0,a&&((o=(r=this.config).onSimulationEnd)==null||o.call(r)),this.destroySimulationModules()}ensureDevice(e){return this.isReady?!1:(this.ready.then(()=>{this._isDestroyed||e()}).catch(i=>{console.error("Device initialization failed",i)}),!0)}validateDevice(e){const i=e.canvasContext;if(i===null||i.type==="offscreen-canvas")throw new Error("Device must have an HTMLCanvasElement canvas context. OffscreenCanvas and compute-only devices are not supported.");return i}async createDevice(e){return await $d.createDevice({type:"webgl",adapters:[Op],createCanvasContext:{canvas:e,useDevicePixels:this.config.pixelRatio,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:i}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(i.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((i.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.alpha=e}runSimulationStep(e=!1){var i,n,s,r,o,a,l,c,u,h,f,d,T,C,w,A,F,b,g,v,N,B,W,Y,q,ee,ne,re,I,U,k;const{config:{simulationGravity:$,simulationCenter:Z,simulationCollision:ie,enableSimulation:te},store:{isSimulationRunning:O}}=this;if(!te)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((i=this.points)==null||i.swapFbo(),(n=this.forceMouse)==null||n.run(),(s=this.points)==null||s.updatePosition());const H=this.zoomInstance.shouldEnableSimulationDuringZoomOverride??this.config.enableSimulationDuringZoom;(e||O&&!(this.zoomInstance.isRunning&&!H))&&($&&((r=this.points)==null||r.swapFbo(),(o=this.forceGravity)==null||o.run(),(a=this.points)==null||a.updatePosition()),Z&&((l=this.points)==null||l.swapFbo(),(c=this.forceCenter)==null||c.run(),(u=this.points)==null||u.updatePosition()),(h=this.points)==null||h.swapFbo(),(f=this.forceManyBody)==null||f.run(),(d=this.points)==null||d.updatePosition(),this.store.linksTextureSize&&((T=this.points)==null||T.swapFbo(),(C=this.forceLinkIncoming)==null||C.run(),(w=this.points)==null||w.updatePosition(),(A=this.points)==null||A.swapFbo(),(F=this.forceLinkOutgoing)==null||F.run(),(b=this.points)==null||b.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((g=this.points)==null||g.swapFbo(),(v=this.cluster
2740s)==null||v.run(),(N=this.points)==null||N.updatePosition()),ie&&(this.isForceCollisionReady||((B=this.forceCollision)==null||B.create(),(W=this.forceCollision)==null||W.initPrograms(),this.isForceCollisionReady=!0),(Y=this.points)==null||Y.swapFbo(),(q=this.forceCollision)==null||q.run(),(ee=this.points)==null||ee.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,cr/this.store.alpha)),(U=(I=this.config).onSimulationTick)==null||U.call(I,this.store.alpha,(ne=this.store.hoveredPoint)==null?void 0:ne.index,(re=this.store.hoveredPoint)==null?void 0:re.position)),(k=this.points)==null||k.trackPoints()}initPrograms(){var e,i,n,s,r,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(i=this.forceManyBody)==null||i.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())}ensureSimulationModules(){!this.device||!this.points||(this.forceGravity||(this.forceGravity=new Ea(this.device,this.config,this.store,this.graph,this.points)),this.forceCenter||(this.forceCenter=new ya(this.device,this.config,this.store,this.graph,this.points)),this.forceManyBody||(this.forceManyBody=new Aa(this.device,this.config,this.store,this.graph,this.points)),this.forceLinkIncoming||(this.forceLinkIncoming=new pn(this.device,this.config,this.store,this.graph,this.points)),this.forceLinkOutgoing||(this.forceLinkOutgoing=new pn(this.device,this.config,this.store,this.graph,this.points)),this.forceMouse||(this.forceMouse=new Ra(this.device,this.config,this.store,this.graph,this.points)),this.forceCollision||(this.forceCollision=new va(this.device,this.config,this.store,this.graph,this.points)))}destroySimulationModules(){var e,i,n,s,r,o,a,l;(e=this.forceGravity)==null||e.destroy(),this.forceGravity=void 0,(i=this.forceCenter)==null||i.destroy(),this.forceCenter=void 0,(n=this.forceManyBody)==null||n.destroy(),this.forceManyBody=void 0,(s=this.forceLinkIncoming)==null||s.destroy(),this.forceLinkIncoming=void 0,(r=this.forceLinkOutgoing)==null||r.destroy(),this.forceLinkOutgoing=void 0,(o=this.forceMouse)==null||o.destroy(),this.forceMouse=void 0,(a=this.forceCollision)==null||a.destroy(),this.forceCollision=void 0,this.isForceCollisionReady=!1,(l=this.points)==null||l.destroySimulationResources()}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:i}}=this;e<cr&&i&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(n=>{this.renderFrame(n),this._isDestroyed||this.frame()})}renderFrame(e){var i,n,s,r,o,a,l,c,u,h,f;if(this._isDestroyed||!this.store.pointsTextureSize)return;const d=e??performance.now();(i=this.fpsMonitor)==null||i.begin(),this.resizeCanvas();const T=this.transition.isActiveFor(Ie.Positions),C=this.transition.isActiveFor(Ie.PointColors),w=this.transition.isActiveFor(Ie.PointSizes),A=this.transition.isActiveFor(Ie.LinkColors),F=this.transition.isActiveFor(Ie.LinkWidths);if(this.transition.isActive&&(this.transition.step(),T&&((n=this.points)==null||n.interpolatePosition(this.transition.progress),(s=this.points)==null||s.trackPoints())),(r=this.points)==null||r.setTransitionProgress(this.transition.progress,C,w),(o=this.lines)==null||o.setTransitionProgress(this.transition.progress,A,F),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),this.device){const b=this.store.backgroundColor??[0,0,0,1],g=this.device.beginRenderPass({clearColor:b,clearDepth:1,clearStencil:0}),{config:{renderLinks:v}}=this;v!==!1&&this.store.linksTextureSize&&this.graph.linksNumber&&this.graph.linksNumber>0&&((a=this.lines)==null||a.draw(g)),(l=this.points)==null||l.draw(g),this.dragInstance.isActive&&((c=this.points)==null||c.swapFbo(),(u=this.points)==null||u.drag(),(h=this.points)==null||h.trackPoints()),g.end(),this.device.submit()}(f=this.fpsMonitor)==null||f.end(d),this.currentEvent=void 0}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,i;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(i=(e=this.config).onSimulationEnd)==null||i.call(e),this._shouldForceHoverDetection=!0}
2740onClick(e){var i,n,s,r,o,a,l,c,u,h;if(this._shouldSuppressNextClick){this._shouldSuppressNextClick=!1;return}(r=(s=this.config).onClick)==null||r.call(s,(i=this.store.hoveredPoint)==null?void 0:i.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):(h=(u=this.config).onBackgroundClick)==null||h.call(u,e)}updateMousePosition(e){if(!e)return;const i=e.offsetX??e.x,n=e.offsetY??e.y;i===void 0||n===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([i,n]),this.store.screenMousePosition=[i,this.store.screenSize[1]-n])}onContextMenu(e){e.preventDefault(),this.cancelLongPress(),this._shouldSuppressNextClick=!0,this.fireContextMenu(e)}cancelLongPress(){this._longPressTimerId!==void 0&&(window.clearTimeout(this._longPressTimerId),this._longPressTimerId=void 0)}fireContextMenu(e){var i,n,s,r,o,a,l,c,u,h;(r=(s=this.config).onContextMenu)==null||r.call(s,(i=this.store.hoveredPoint)==null?void 0:i.index,(n=this.store.hoveredPoint)==null?void 0:n.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointContextMenu)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkContextMenu)==null||c.call(l,this.store.hoveredLinkIndex,e):(h=(u=this.config).onBackgroundContextMenu)==null||h.call(u,e)}resizeCanvas(e=!1){var i,n,s,r;if(this._isDestroyed)return;const o=this.canvas.clientWidth,a=this.canvas.clientHeight,[l,c]=this.store.screenSize;if(e||l!==o||c!==a){const{k:u}=this.zoomInstance.eventTransform,h=this.zoomInstance.convertScreenToSpacePosition([l/2,c/2]);this.store.updateScreenSize(o,a),(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform(h,u)),(n=this.points)==null||n.updateSampledPointsGrid(),(s=this.lines)==null||s.updateSampledLinksGrid(),this.store.isLinkHoveringEnabled&&((r=this.lines)==null||r.updateLinkIndexFbo())}}updateZoomDragBehaviors(){var e,i,n,s;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(i=this.canvasD3Selection)==null||i.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),this.updateCanvasTouchAction()}updateCanvasTouchAction(){this.canvas.style.touchAction=this.config.enableDrag||this.config.enableZoom?"none":""}findHoveredItem(e=!1){var i,n,s,r,o,a,l,c,u,h;if(this._isDestroyed||!e&&!this._isPointerOnCanvas||this.transition.isActiveFor(Ie.PointSizes))return;if(!e&&this._findHoveredItemExecutionCount<zg){this._findHoveredItemExecutionCount+=1;return}const f=Math.abs(this._lastMouseX-this._lastCheckedMouseX),d=Math.abs(this._lastMouseY-this._lastCheckedMouseY),T=f>Ta||d>Ta;if(!e&&!T&&!this._shouldForceHoverDetection)return;this._lastCheckedMouseX=this._lastMouseX,this._lastCheckedMouseY=this._lastMouseY,this._shouldForceHoverDetection=!1,this._findHoveredItemExecutionCount=0;const C=this.findHoveredPoint();let w={mouseover:!1,mouseout:!1};if(this.graph.linksNumber&&this.store.isLinkHoveringEnabled?w=this.findHoveredLine():this.store.hoveredLinkIndex!==void 0&&(w.mouseout=!0,this.store.hoveredLinkIndex=void 0),C.mouseout&&((n=(i=this.config).onPointMouseOut)==null||n.call(i,this.currentEvent)),w.mouseout&&((r=(s=this.config).onLinkMouseOut)==null||r.call(s,this.currentEvent)),C.mouseover&&this.store.hoveredPoint){const A=this.store.hoveredPoint.index;(c=(l=this.config).onPointMouseOver)==null||c.call(l,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent,((o=this.store.highlightedPointSet)==null?void 0:o.has(A))??!1,((a=this.store.outlinedPointSet)==null?void 0:a.has(A))??!1)}w.mouseover&&this.store.hoveredLinkIndex!==void 0&&((h=(u=this.config).onLinkMouseOver)==null||h.call(u,this.store.hoveredLinkIndex)),this.updateCanvasCursor()}findHoveredPoint(){if(this._isDestroyed||!this.device||!this.points)return{mouseover:!1,mou
2740seout:!1};this.points.findHoveredPoint();let e=!1,i=!1;const n=Ke(this.device,this.points.hoveredFbo,0,0,2,2),s=n[0],r=n[1],o=n[2],a=n[3];return r>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==s)&&(e=!0),this.store.hoveredPoint={index:s,position:[o,a]}):(this.store.hoveredPoint&&(i=!0),this.store.hoveredPoint=void 0),{mouseover:e,mouseout:i}}findHoveredLine(){if(this._isDestroyed||!this.lines)return{mouseover:!1,mouseout:!1};if(this.store.hoveredPoint){const s=this.store.hoveredLinkIndex!==void 0;return s&&(this.store.hoveredLinkIndex=void 0),{mouseover:!1,mouseout:s}}this.lines.findHoveredLine();let e=!1,i=!1;if(!this.device)return{mouseover:!1,mouseout:!1};const n=Ke(this.device,this.lines.hoveredLineIndexFbo)[0];return n>=0?(this.store.hoveredLinkIndex!==n&&(e=!0),this.store.hoveredLinkIndex=n):(this.store.hoveredLinkIndex!==void 0&&(i=!0),this.store.hoveredLinkIndex=void 0),{mouseover:e,mouseout:i}}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:i}=this.config;this.dragInstance.isActive?Me(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Me(this.canvas).style("cursor",e):Me(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Me(this.canvas).style("cursor",i):Me(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=` 2741 user-select: none; 2742 position: absolute; 2743 bottom: 0; 2744 right: 0; 2745 color: var(--cosmosgl-attribution-color); 2746 margin: 0 0.6rem 0.6rem 0; 2747 font-size: 0.7rem; 2748 font-family: inherit; 2749 `,this.attributionDivElement.innerHTML=$g(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 pt=4.5,ui={listing:{color:"#1f78b4",shape:he.Pentagon,size:11},"listing:government":{color:"#1f78b4",shape:he.Pentagon,size:11},"listing:private":{color:"#e31a1c",shape:he.Pentagon,size:11},"listing:enhancement":{color:"#9333ea",shape:he.Pentagon,size:11},"listing:bundle":{color:"#d97706",shape:he.Pentagon,size:11},program:{color:"#64748b",shape:he.Triangle,size:10},practice:{color:"#33a02c",shape:he.Pentagon,size:10},state:{color:"#ff7f00",shape:he.Square,size:12},county:{color:"#fdbf6f",shape:he.Diamond,size:7},document:{color:"#b2df8a",shape:he.Square,size:8},section:{color:"#cab2d6",shape:he.Diamond,size:7},canonical:{color:"#b15928",shape:he.Diamond,size:9},claim:{color:"#fb9a99",shape:he.Hexagon,size:6.5},component:{color:"#a6cee3",shape:he.Cross,size:6},scenario:{color:"#ffff99",shape:he.Square,size:6},year:{color:"#e879f9",shape:he.Circle,size:6.5},"dgn:constraint":{color:"#ef4444",shape:he.Triangle,size:pt},"dgn:eligibility_rule":{color:"#f97316",shape:he.Star,size:pt},"dgn:eligibility_condition":{color:"#fbbf24",shape:he.Cross,size:pt},"dgn:activity":{color:"#2dd4bf",shape:he.Circle,size:pt},"dgn:practice_effect":{color:"#34d399",shape:he.Hexagon,size:pt},"dgn:land_type":{color:"#7dd3fc",shape:he.Diamond,size:pt},"dgn:practice_component":{color:"#a6cee3",shape:he.Cross,size:pt},"dgn:supporting_document":{color:"#9ca3af",shape:he.Square,size:pt},"dgn:geographic_scope":{color:"#fdbf6f",shape:he.Diamond,size:pt},dgn:{color:"#c9a648",shape:he.Diamond,size:pt},other:{color:"#8b93a7",shape:he.Circle,size:7}};function _c(t){if(t.subkind!==void 0){const e=`${t.kind}:${t.subkind}`;if(e in ui)return e}return t.kind in ui?t.kind:"other"}function Pa(t){return ui[_c(t)]}const wa={"listing:government":"gov listing","listing:private":"private listing","listing:enhancement":"CSP enhancement","listing:bundle":"CSP bundle"};function KT(t){return t in wa?wa[t]:(t.startsWith("dgn:")?t.slice(4):t).replace(/_/g," ")}const Na="#ff3b30",Ws="#4ade80",Ma="#0b0f17",GT="#31415f";function jT(t,e){const i=t.replace("#","");return[parseInt(i.slice(0,2),16)/255,parseInt(i.slice(2,4),16)/255,parseInt(i.slice(4,6),16)/255,e]}const hr=4096,ka=.16,$s=24,qT=14,ZT=260,QT=80,JT=12,_n="74,222,128";function eS(t){const e=t.replace("#","");return`${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)}`}function tS(t,e,i){if(e===i)return[e];const n=new Map;n.set(e,e);let s=[e];for(;s.length>0;){const r=[];for(const o of s)for(const a of t.get(o)??[])if(!n.has(a)){if(n.set(a,o),a===i){const l=[];let c=i;for(;c!==void 0&&c!==e;)l.push(c),c=n.get(c);return l.push(e),l.reverse()}r.push(a)}s=r}return null}function iS(t,e,i){const n=[];let s=e;for(const r of t){if(s!==null&&s!==r){const o=tS(i,s,r);if(o!==null)for(let a=1;a<o.length-1;a++)n.push({index:o[a],kind:"pass"})}n.push({index:r,kind:"visit"}),s=r}return n}function nS(t,e){if(t.length<=e)return t;const i=[],n=t.length/e;for(let s=0;s<e;s++)i.push(t[Math.floor(s*n)]);return i}const sS={[he.Square]:"1,1 9,1 9,9 1,9",[he.Triangle]:"5,0.5 9.5,9 0.5,9",[he.Diamond]:"5,0.5 9.5,5 5,9.5 0.5,5",[he.Pentagon]:"5,0.5 9.7,3.9 7.9,9.5 2.1,9.5 0.3,3.9",[he.Hexagon]:"2.5,0.7 7.5,0.7 10,5 7.5,9.3 2.5,9.3 0,5",[he.Star]:"5,0 6.1,3.5 9.8,3.5 6.8,5.7 7.9,9.1 5,7 2.1,9.1 3.2,5.7 0.2,3.5 3.9,3.5",[he.Cross]:"4,0.5 6,0.5 6,4 9.5,4 9.5,6 6,6 6,9.5 4,9.5 4,6 0.5,6 0.5,4 4,4"};function rS({shape:t,color:e}){const i=sS[t];return D.jsx("svg",{viewBox:"0 0 10 10",className:"h-2 w-2 flex-shrink-0",fill:e,children:i!==void 0?D.jsx("polygon",{points:i}):D.jsx("circle",{cx:"5",cy:"5",r:"4.5"})})}function oS(t){const e=(Math.sin(t*12.9898)*43758.5453%1+1)%1,i=(Math.sin(t*78.233)*12543.633%1+1)%1;
2749return[hr/2+(e-.5)*1400,hr/2+(i-.5)*1400]}function aS({subgraph:t,reading:e,read:i,cited:n,selectedId:s,reducedMotion:r,caption:o,onNodeClick:a}){const l=J.useRef(null),c=J.useRef(null),u=J.useRef(a);u.current=a;const h=J.useRef(null),f=J.useRef({pos:null,trail:[],phase:0}),d=J.useRef(null),T=J.useRef(null),C=J.useMemo(()=>t.nodes.map(b=>b.id),[t]),w=J.useMemo(()=>new Map(C.map((b,g)=>[b,g])),[C]),A=J.useMemo(()=>{const b=new Map;return t.links.forEach(g=>{const v=w.get(g.source),N=w.get(g.target);if(v===void 0||N===void 0||v===N)return;const B=b.get(v);B===void 0?b.set(v,[N]):B.push(N);const W=b.get(N);W===void 0?b.set(N,[v]):W.push(v)}),b},[t,w]);J.useEffect(()=>{const b=l.current;if(!b||t.nodes.length===0)return;const g=new YT(b,{spaceSize:hr,backgroundColor:Ma,enableSimulation:!0,simulationRepulsion:1.2,simulationLinkSpring:.4,simulationLinkDistance:18,simulationGravity:.25,simulationDecay:2500,simulationFriction:.92,transitionDuration:0,pointSizeScale:1,scalePointsOnZoom:!0,outlinedPointRingColor:Ws,focusedPointRingColor:"#ffffff",linkDefaultColor:GT,linkDefaultWidth:1,linkDefaultArrows:!1,linkVisibilityDistanceRange:[0,1e5],fitViewOnInit:!1,enableDrag:!1,onClick:ne=>{const re=ne===void 0?null:t.nodes[ne]?.id??null;u.current(re)}}),v=t.nodes.length,N=new Float32Array(v*2),B=new Float32Array(v);t.nodes.forEach((ne,re)=>{const[I,U]=oS(re);N[re*2]=I,N[re*2+1]=U,B[re]=Pa(ne).shape}),g.setPointPositions(N),g.setPointShapes(B);const W=[],Y=new Map(t.nodes.map((ne,re)=>[ne.id,re]));t.links.forEach(ne=>{const re=Y.get(ne.source),I=Y.get(ne.target);re!==void 0&&I!==void 0&&W.push(re,I)}),g.setLinks(new Float32Array(W)),g.render(),g.start(.9);const q=window.setTimeout(()=>g.fitView(400,.25),350),ee=window.setTimeout(()=>g.fitView(600,.2),2200);return c.current=g,()=>{window.clearTimeout(q),window.clearTimeout(ee),c.current=null,g.destroy()}},[t]),J.useEffect(()=>{const b=c.current;if(!b)return;const g=e.size>0||i.size>0||n.size>0,v=new Float32Array(t.nodes.length*4),N=new Float32Array(t.nodes.length),B=[];t.nodes.forEach((Y,q)=>{const ee=Pa(Y),ne=e.has(Y.id)||i.has(Y.id)||n.has(Y.id);v.set(jT(ee.color,g&&!ne?.3:.95),q*4);const re=ee.size;let I=e.has(Y.id)?re*1.35:re;Y.id===s&&(I=re*1.7),N[q]=I,n.has(Y.id)&&B.push(q)}),b.setPointColors(v),b.setPointSizes(N);const W=s!==null?w.get(s):void 0;b.setConfigPartial({outlinedPointIndices:B,focusedPointIndex:W}),b.render()},[t,e,i,n,s,w]),J.useEffect(()=>{if(r)return;const b=e.size===0&&n.size>0,g=b?n:e,v=[];if(g.forEach(B=>{const W=w.get(B);W!==void 0&&v.push(W)}),v.length===0){d.current=null;return}const N=nS(v,JT);d.current={queue:iS(N,T.current,A),ringIndices:N,pulseHex:b?Ws:Na,arrivedAt:null,lastVisited:null}},[e,n,w,A,r]),J.useEffect(()=>{if(r)return;const b=h.current;if(!b)return;const g=b.getContext("2d");if(!g)return;const v=f.current;v.pos=null,v.trail=[],T.current=null;let N=0;const B=()=>{N=window.requestAnimationFrame(B);const W=b.clientWidth,Y=b.clientHeight,q=window.devicePixelRatio||1;(b.width!==Math.round(W*q)||b.height!==Math.round(Y*q))&&(b.width=Math.round(W*q),b.height=Math.round(Y*q)),g.setTransform(q,0,0,q,0,0),g.clearRect(0,0,W,Y);const ee=c.current;if(!ee)return;v.phase+=.13;const ne=()=>{for(let H=0;H<v.trail.length-1;H++){const ae=v.trail[H],Q=v.trail[H+1],oe=H/v.trail.length;g.strokeStyle=`rgba(${_n},${.05+.3*oe})`,g.lineWidth=1+2*oe,g.beginPath(),g.moveTo(ae.x,ae.y),g.lineTo(Q.x,Q.y),g.stroke()}},re=(H,ae)=>{const Q=5+Math.sin(v.phase),oe=g.createRadialGradient(H,ae,0,H,ae,Q*3);oe.addColorStop(0,`rgba(${_n},0.55)`),oe.addColorStop(1,`rgba(${_n},0)`),g.fillStyle=oe,g.beginPath(),g.arc(H,ae,Q*3,0,Math.PI*2),g.fill(),g.fillStyle="#ffffff",g.strokeStyle=`rgba(${_n},0.95)`,g.lineWidth=2,g.beginPath(),g.arc(H,ae,Q,0,Math.PI*2),g.fill(),g.stroke()},I=()=>{v.pos!==null&&(v.pos.x+=Math.sin(v.phase*.6)*.35,v.pos.y+=Math.cos(v.phase*.45)*.35,v.trail.push({x:v.pos.x,y:v.pos.y}),v.trail.length>$s&&v.trail.shift(),ne(),re(v.pos.x,v.pos.y))},U=d.current;if(!U){I();return}const k=ee.getPointPositions(),$=U.queue[0];let Z=!1;if($===void 0)v.pos!==null&&(v.pos.x+=Math.sin(v.phase*.6)*.35,v.pos.y+=Math.cos(v.phase*.45)*.35,v.trail.push({x:v.pos.x,y:v.pos.y}),v.trail.length>$s&&v.trail.shift());else{const H=k[$.index*2],ae=k[$.index*2+1];if(!Number.isFinite(H)||!Number.isFinite(ae)){U.queue.shift(),U.arrivedAt=null,I();return}const[Q,oe]=ee.spaceToScreenPosition([H,ae]);if(!Number.isFinite(Q)||!Number.isFinite(oe)){I();return}v.pos===null&&(v.pos={x:Q,y:oe}),v.pos.x+=(Q-v.pos.x)*ka,v.pos.y+=(oe-v.pos.y)*ka,v.trail.push({x:v.pos.x,y:v.pos.y}),v.trail.length>$s&&v.trail.shift(),Z=Math.hypot(Q-v.pos.x,oe-v.pos.y)<qT;const Ce=performance.now();Z&&U.arrivedAt===null&&(U.arrivedAt=Ce),Z&&$.kind==="visit"&&(U.lastVisited=$.index);const Ve=$.kind==="visit"?ZT:QT;Z&&U.arrivedAt!==null&&Ce-U.arrivedAt>Ve&&(T.current=$.index,U.queue.shift(),U.arrivedAt=null)}ne();
2749const ie=eS(U.pulseHex),te=7+2.5*Math.sin(v.phase),O=$===void 0?U.lastVisited:$.kind==="visit"&&Z?$.index:null;U.ringIndices.forEach(H=>{const[ae,Q]=ee.spaceToScreenPosition([k[H*2],k[H*2+1]]);if(!Number.isFinite(ae)||!Number.isFinite(Q))return;const oe=H===O;g.strokeStyle=`rgba(${ie},${oe?.85:.22})`,g.lineWidth=oe?2:1,g.beginPath(),g.arc(ae,Q,oe?te:6,0,Math.PI*2),g.stroke()}),v.pos!==null&&re(v.pos.x,v.pos.y)};return N=window.requestAnimationFrame(B),()=>window.cancelAnimationFrame(N)},[t,r]);const F=J.useMemo(()=>{const b=new Set(t.nodes.map(g=>_c(g)));return Object.keys(ui).filter(g=>g!=="other"&&b.has(g)).map(g=>({key:g,label:KT(g),color:ui[g].color,shape:ui[g].shape}))},[t]);return D.jsxs("div",{className:"relative h-full w-full overflow-hidden rounded-lg",style:{background:Ma},children:[D.jsx("div",{ref:l,className:"absolute inset-0"}),!r&&D.jsx("canvas",{ref:h,className:"pointer-events-none absolute inset-0 h-full w-full"}),o!==null&&D.jsx("p",{className:"pointer-events-none absolute left-2 right-2 top-1.5 truncate font-mono text-[10px] text-white/80",children:o}),D.jsxs("div",{className:"pointer-events-none absolute bottom-1.5 left-2 right-2 flex flex-wrap gap-x-2.5 gap-y-0.5",children:[F.map(b=>D.jsxs("span",{className:"flex items-center gap-1 font-mono text-[9px] text-white/60",children:[D.jsx(rS,{shape:b.shape,color:b.color}),b.label]},b.key)),D.jsxs("span",{className:"ml-1.5 flex items-center gap-1 border-l border-white/20 pl-2.5 font-mono text-[9px] text-white/60",children:[D.jsx("span",{className:"inline-block h-2 w-2 rounded-full border",style:{borderColor:Na}}),"reading"]}),D.jsxs("span",{className:"flex items-center gap-1 font-mono text-[9px] text-white/60",children:[D.jsx("span",{className:"inline-block h-2 w-2 rounded-full border",style:{borderColor:Ws}}),"cited"]})]})]})}function Fa({ids:t,nodeLabels:e,onNodeClick:i,cited:n}){return t.length===0?null:D.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:t.map(s=>D.jsx("button",{type:"button",onClick:()=>i(s),title:s,className:Oa("max-w-[14rem] truncate rounded-sm px-1.5 py-0.5 font-mono text-[10px] transition-colors",n?"bg-leaf/15 text-leaf hover:bg-leaf/25":"bg-dusk-100 text-charcoal-400 hover:bg-dusk-200 hover:text-charcoal-500"),children:e.get(s)??s},s))})}function ti({children:t}){return D.jsx("span",{className:"mr-1.5 rounded-sm bg-charcoal-500/10 px-1 py-px font-mono text-[9px] uppercase tracking-widest text-charcoal-400",children:t})}function lS({event:t,nodeLabels:e,onNodeClick:i}){switch(t.type){case"decompose":return D.jsxs("div",{children:[D.jsxs("p",{className:"text-xs text-charcoal-500",children:[D.jsx(ti,{children:"decompose"}),t.intent??""]}),(t.sub_questions??[]).map((n,s)=>D.jsx("p",{className:"mt-0.5 border-l-2 border-dusk-200 pl-2 text-xs text-charcoal-400",children:n},s))]});case"phase":return D.jsxs("p",{className:"text-xs text-charcoal-500",children:[D.jsx(ti,{children:t.tag??"phase"}),t.name??"",t.why?D.jsx("span",{className:"block text-[11px] text-dusk-400",children:t.why}):null]});case"thought":return D.jsx("p",{className:"text-xs italic text-dusk-400",children:t.text??""});case"tool_call":return D.jsxs("div",{children:[D.jsxs("p",{className:"text-xs text-charcoal-500",children:[D.jsx(ti,{children:"tool"}),D.jsx("span",{className:"font-mono text-[11px]",children:t.tool??""})]}),D.jsx(Fa,{ids:t.node_ids??[],nodeLabels:e,onNodeClick:i})]});case"tool_result":return D.jsxs("p",{className:"text-xs text-charcoal-400",children:[D.jsx(ti,{children:"result"}),t.summary??""]});case"context":return D.jsxs("p",{className:"text-xs text-charcoal-400",children:[D.jsx(ti,{children:"context"}),t.touched_count??0," nodes read ·"," ",(t.survivors??[]).length," kept for the answer"]});case"answer":return D.jsxs("div",{children:[D.jsx("p",{className:"text-xs text-charcoal-500",children:D.jsx(ti,{children:"answer"})}),D.jsx("div",{className:"mt-1 text-xs leading-relaxed text-charcoal-500 [&_a]:underline [&_li]:ml-4 [&_ol]:list-decimal [&_p+p]:mt-1.5 [&_strong]:font-semibold [&_ul]:list-disc",children:D.jsx(Bc,{remarkPlugins:[Uc],children:t.markdown??""})}
2749),D.jsx(Fa,{ids:t.cited_nodes??[],nodeLabels:e,onNodeClick:i,cited:!0})]});default:return null}}const cS=new Set(["decompose","phase","thought","tool_call","tool_result","context","answer"]);function uS({events:t,activeEventIndex:e,nodeLabels:i,reducedMotion:n,onNodeClick:s}){const r=J.useRef(null);return J.useEffect(()=>{r.current?.scrollIntoView({block:"nearest",behavior:n?"auto":"smooth"})},[e,n]),D.jsx("div",{className:"space-y-2",children:t.map((o,a)=>{if(!cS.has(o.type))return null;const l=a===e;return D.jsx("div",{ref:l?r:void 0,className:Oa("rounded-md border px-2.5 py-1.5 transition-colors",l?"border-leaf/50 bg-leaf/5":"border-dusk-100 bg-white"),children:D.jsx(lS,{event:o,nodeLabels:i,onNodeClick:s})},a)})})}const Ys="https://bark-api.ncx.com/",hS=1200,fS=500,dS=6,pS=5200,_S=2e3,Da=[];function mS({accountId:t,queryId:e,liveEvents:i}){const n=Lc(),s=(i?.length??0)>0,[r,o]=J.useState(null),[a,l]=J.useState(null),[c,u]=J.useState(!1),[h,f]=J.useState(null),d=J.useMemo(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]);J.useEffect(()=>{if(s||e===void 0||!n)return;let O=!1;return fetch(`${Ys}land-legacy/accounts/${t}/traces/${e}`,{credentials:"include",headers:{Authorization:`Bearer ${n}`}}).then(H=>{if(H.status===404)return null;if(!H.ok)throw new Error(`trace fetch failed (${H.status})`);return H.json()}).then(H=>{O||(H===null?u(!0):o(H.events??[]))}).catch(()=>{O||u(!0)}),()=>{O=!0}},[s,e,t,n]),J.useEffect(()=>{if(e===void 0||!n)return;let O=!1;return fetch(`${Ys}land-legacy/accounts/${t}/traces/${e}/subgraph`,{credentials:"include",headers:{Authorization:`Bearer ${n}`}}).then(H=>H.ok?H.json():null).then(H=>{!O&&H!==null&&l(H)}).catch(()=>{}),()=>{O=!0}},[e,t,n]);const T=s?i??Da:r??Da,C=J.useMemo(()=>{const O=[];return T.forEach((H,ae)=>{H.type==="tool_call"&&O.push({eventIndex:ae,nodeIds:H.node_ids??[]})}),O},[T]),w=J.useMemo(()=>T.findIndex(O=>O.type==="answer"),[T]),A=J.useMemo(()=>w>=0?T[w].cited_nodes??[]:[],[T,w]),F=C.length+(w>=0?1:0),[b,g]=J.useState(0),[v,N]=J.useState(!d);J.useEffect(()=>{F!==0&&g(d?F-1:O=>Math.min(O,F-1))},[F,d]),J.useEffect(()=>{if(!v||d||F<=1)return;const O=b>=F-1,H=C[Math.min(b,C.length-1)]?.nodeIds.length??0,ae=Math.min(hS+fS*Math.min(H,dS),pS),Q=window.setTimeout(()=>g(oe=>oe>=F-1?0:oe+1),O?_S:ae);return()=>window.clearTimeout(Q)},[v,d,b,F,C]);const B=w>=0&&F>0&&b===F-1,{reading:W,read:Y,cited:q}=J.useMemo(()=>{const O=new Set,H=new Set,ae=new Set;if(F===0)return{reading:O,read:H,cited:ae};const Q=B?C.length-1:Math.min(b,C.length-1);for(let oe=0;oe<=Q;oe++)for(const Ce of C[oe].nodeIds)!B&&oe===Q?O.add(Ce):H.add(Ce);return B&&A.forEach(oe=>ae.add(oe)),{reading:O,read:H,cited:ae}},[C,b,F,B,A]),ee=F===0?null:B?w:C[Math.min(b,C.length-1)]?.eventIndex??null,ne=J.useMemo(()=>{if(F===0)return null;if(B)return`Citing sources â ${A.length} node${A.length!==1?"s":""}`;const O=C[Math.min(b,C.length-1)];return O?`Looking up ${T[O.eventIndex]?.tool??"â¦"} â ${O.nodeIds.length} node${O.nodeIds.length!==1?"s":""}`:null},[F,B,A,C,b,T]),re=J.useMemo(()=>{const O=new Map;return a?.nodes.forEach(H=>O.set(H.id,H.label)),O},[a]),I=J.useRef(new Map),U=J.useCallback(async O=>{const H=I.current;if(H.has(O))return H.get(O)??null;if(e===void 0||!n)return null;const ae=await fetch(`${Ys}land-legacy/accounts/${t}/traces/${e}/node?node=${encodeURIComponent(O)}`,{credentials:"include",headers:{Authorization:`Bearer ${n}`}});if(!ae.ok)return H.set(O,null),null;const Q=await ae.json();return H.set(O,Q),Q},[t,e,n]),k=J.useCallback(async O=>{if(!a)return[];let H=a.links.filter(Q=>Q.rel==="grounded_in"&&Q.target===O).map(Q=>Q.source);H.length===0&&(H=a.nodes.filter(Q=>Q.kind==="claim").map(Q=>Q.id));const ae=[];for(const Q of H){const oe=await U(Q);for(const Ce of oe?.content?.evidence??[])Ce.quote&&ae.push(Ce.quote)}return ae},[a,U]),$=J.useCallback(O=>{f(O)},[]),Z=J.useCallback(()=>{N(!1),g(O=>Math.max(0,O-1))},[]),ie=J.useCallback(()=>{N(!1),g(O=>Math.min(Math.max(0,F-1),O+1))},[F]);if(c&&!s)return D.jsx("p",{className:"py-1 text-xs italic text-dusk-400",children:"No trace available for this answer."});const te=a?.question??"";return D.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-dusk-100 bg-neutral-50 p-3",children:[D.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[D.jsxs("p",{className:"min-w-0 flex-1 truncate text-xs text-dusk-400",title:te,children:[D.jsx("span",{className:"mr-1.5 font-mono text-[9px] uppercase tracking-widest text-leaf",children:"How I foun
2749d this"}),te]}),F>0&&D.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[D.jsx("button",{type:"button",onClick:Z,disabled:b===0,className:"rounded-sm p-1 text-dusk-400 transition-colors hover:text-charcoal-500 disabled:opacity-30","aria-label":"Previous step",children:D.jsx(zc,{className:"h-3.5 w-3.5"})}),D.jsx("button",{type:"button",onClick:()=>N(O=>!O),className:"rounded-sm p-1 text-charcoal-400 transition-colors hover:text-charcoal-500","aria-label":v?"Pause replay":"Play replay",children:v?D.jsx(Xc,{className:"h-3.5 w-3.5"}):D.jsx($c,{className:"h-3.5 w-3.5"})}),D.jsx("button",{type:"button",onClick:ie,disabled:b>=F-1,className:"rounded-sm p-1 text-dusk-400 transition-colors hover:text-charcoal-500 disabled:opacity-30","aria-label":"Next step",children:D.jsx(Hc,{className:"h-3.5 w-3.5"})}),D.jsxs("span",{className:"ml-1 font-mono text-[10px] text-dusk-400",children:[Math.min(b+1,F),"/",F,B?" · citing sources":""]})]})]}),D.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[D.jsx("div",{className:"h-64 min-w-0 flex-1 lg:h-80",children:a&&a.nodes.length>0?D.jsx(aS,{subgraph:a,reading:W,read:Y,cited:q,selectedId:h,reducedMotion:d,caption:ne,onNodeClick:$}):D.jsx("div",{className:"flex h-full items-center justify-center rounded-lg bg-charcoal-500/90",children:D.jsx("p",{className:"px-4 text-center text-xs text-white/50",children:e===void 0?"The graph appears when the answer completes.":"Loading graphâ¦"})})}),D.jsx("div",{className:"max-h-64 overflow-y-auto lg:max-h-80 lg:w-80 lg:flex-shrink-0",children:D.jsx(uS,{events:T,activeEventIndex:ee,nodeLabels:re,reducedMotion:d,onNodeClick:O=>f(O)})})]}),h!==null&&D.jsx(ru,{nodeId:h,fetchNodeDetail:U,quotesForCanonical:k,onClose:()=>f(null)})]})}const nx=Object.freeze(Object.defineProperty({__proto__:null,default:mS},Symbol.toStringTag,{value:"Module"}));export{G as B,ES as D,nx as P,je as R,vr as S,j as T,fd as a,vS as b,di as c,yr as d,np as e,ai as f,AS as g,RS as h,Ki as i,bd as j,Id as k,V as l,Xi as m,yS as n,CS as o,bS as p,Oi as t,Tr as u}; 2750//# sourceMappingURL=ProgramsGraphTrace-C4KQYE2u.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.