@cosmos.gl/graph 2.7.0-beta.0 → 2.7.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +18 -5
- package/dist/{index-FUIgayhu.js → index-B1_1MjaX.js} +1909 -1819
- package/dist/index-B1_1MjaX.js.map +1 -0
- package/dist/index.d.ts +66 -6
- package/dist/index.js +1 -1
- package/dist/index.min.js +46 -34
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +0 -3
- package/dist/modules/GraphData/index.d.ts +1 -0
- package/dist/modules/Points/index.d.ts +2 -4
- package/dist/{webgl-device-B9ewDj5L.js → webgl-device-DzkMihDq.js} +2 -2
- package/dist/{webgl-device-B9ewDj5L.js.map → webgl-device-DzkMihDq.js.map} +1 -1
- package/package.json +5 -1
- package/.eslintrc +0 -147
- package/.github/SECURITY.md +0 -13
- package/.github/dco.yml +0 -4
- package/.github/workflows/github_pages.yml +0 -54
- package/.storybook/main.ts +0 -26
- package/.storybook/manager-head.html +0 -1
- package/.storybook/manager.ts +0 -14
- package/.storybook/preview.ts +0 -29
- package/.storybook/style.css +0 -3
- package/CHARTER.md +0 -69
- package/CODE_OF_CONDUCT.md +0 -178
- package/CONTRIBUTING.md +0 -22
- package/GOVERNANCE.md +0 -21
- package/cosmos-2-0-migration-notes.md +0 -98
- package/cosmos_awesome.md +0 -96
- package/dist/index-FUIgayhu.js.map +0 -1
- package/dist/stories/beginners/basic-set-up/data-gen.d.ts +0 -4
- package/dist/stories/beginners/basic-set-up/index.d.ts +0 -6
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +0 -19
- package/dist/stories/beginners/link-hovering/index.d.ts +0 -6
- package/dist/stories/beginners/point-labels/data.d.ts +0 -13
- package/dist/stories/beginners/point-labels/index.d.ts +0 -10
- package/dist/stories/beginners/point-labels/labels.d.ts +0 -8
- package/dist/stories/beginners/quick-start.d.ts +0 -6
- package/dist/stories/beginners/remove-points/config.d.ts +0 -2
- package/dist/stories/beginners/remove-points/data-gen.d.ts +0 -4
- package/dist/stories/beginners/remove-points/index.d.ts +0 -6
- package/dist/stories/beginners.stories.d.ts +0 -10
- package/dist/stories/clusters/polygon-selection/index.d.ts +0 -6
- package/dist/stories/clusters/polygon-selection/polygon.d.ts +0 -20
- package/dist/stories/clusters/radial.d.ts +0 -6
- package/dist/stories/clusters/with-labels.d.ts +0 -6
- package/dist/stories/clusters/worm.d.ts +0 -6
- package/dist/stories/clusters.stories.d.ts +0 -9
- package/dist/stories/create-cluster-labels.d.ts +0 -4
- package/dist/stories/create-cosmos.d.ts +0 -17
- package/dist/stories/create-story.d.ts +0 -16
- package/dist/stories/experiments/full-mesh.d.ts +0 -6
- package/dist/stories/experiments/mesh-with-holes.d.ts +0 -6
- package/dist/stories/experiments.stories.d.ts +0 -7
- package/dist/stories/generate-mesh-data.d.ts +0 -12
- package/dist/stories/geospatial/moscow-metro-stations/index.d.ts +0 -16
- package/dist/stories/geospatial/moscow-metro-stations/moscow-metro-coords.d.ts +0 -1
- package/dist/stories/geospatial/moscow-metro-stations/point-colors.d.ts +0 -1
- package/dist/stories/geospatial.stories.d.ts +0 -6
- package/dist/stories/shapes/all-shapes/index.d.ts +0 -6
- package/dist/stories/shapes/image-example/index.d.ts +0 -6
- package/dist/stories/shapes.stories.d.ts +0 -7
- package/dist/stories/test-luma-migration.d.ts +0 -6
- package/dist/stories/test.stories.d.ts +0 -6
- package/logo.svg +0 -3
- package/rollup.config.js +0 -70
- package/src/config.ts +0 -728
- package/src/declaration.d.ts +0 -12
- package/src/graph/utils/error-message.ts +0 -23
- package/src/helper.ts +0 -113
- package/src/index.ts +0 -1769
- package/src/modules/Clusters/calculate-centermass.frag +0 -12
- package/src/modules/Clusters/calculate-centermass.vert +0 -38
- package/src/modules/Clusters/force-cluster.frag +0 -55
- package/src/modules/Clusters/index.ts +0 -578
- package/src/modules/Drag/index.ts +0 -33
- package/src/modules/FPSMonitor/css.ts +0 -53
- package/src/modules/FPSMonitor/index.ts +0 -28
- package/src/modules/ForceCenter/calculate-centermass.frag +0 -9
- package/src/modules/ForceCenter/calculate-centermass.vert +0 -26
- package/src/modules/ForceCenter/force-center.frag +0 -37
- package/src/modules/ForceCenter/index.ts +0 -284
- package/src/modules/ForceGravity/force-gravity.frag +0 -40
- package/src/modules/ForceGravity/index.ts +0 -107
- package/src/modules/ForceLink/force-spring.ts +0 -89
- package/src/modules/ForceLink/index.ts +0 -293
- package/src/modules/ForceManyBody/calculate-level.frag +0 -9
- package/src/modules/ForceManyBody/calculate-level.vert +0 -37
- package/src/modules/ForceManyBody/force-centermass.frag +0 -61
- package/src/modules/ForceManyBody/force-level.frag +0 -138
- package/src/modules/ForceManyBody/index.ts +0 -525
- package/src/modules/ForceManyBody/quadtree-frag-shader.ts +0 -89
- package/src/modules/ForceManyBodyQuadtree/calculate-level.frag +0 -9
- package/src/modules/ForceManyBodyQuadtree/calculate-level.vert +0 -25
- package/src/modules/ForceManyBodyQuadtree/index.ts +0 -157
- package/src/modules/ForceManyBodyQuadtree/quadtree-frag-shader.ts +0 -93
- package/src/modules/ForceMouse/force-mouse.frag +0 -35
- package/src/modules/ForceMouse/index.ts +0 -102
- package/src/modules/GraphData/index.ts +0 -383
- package/src/modules/Lines/draw-curve-line.frag +0 -59
- package/src/modules/Lines/draw-curve-line.vert +0 -248
- package/src/modules/Lines/geometry.ts +0 -18
- package/src/modules/Lines/hovered-line-index.frag +0 -43
- package/src/modules/Lines/hovered-line-index.vert +0 -13
- package/src/modules/Lines/index.ts +0 -661
- package/src/modules/Points/atlas-utils.ts +0 -137
- package/src/modules/Points/drag-point.frag +0 -34
- package/src/modules/Points/draw-highlighted.frag +0 -44
- package/src/modules/Points/draw-highlighted.vert +0 -145
- package/src/modules/Points/draw-points.frag +0 -259
- package/src/modules/Points/draw-points.vert +0 -203
- package/src/modules/Points/fill-sampled-points.frag +0 -12
- package/src/modules/Points/fill-sampled-points.vert +0 -51
- package/src/modules/Points/find-hovered-point.frag +0 -15
- package/src/modules/Points/find-hovered-point.vert +0 -90
- package/src/modules/Points/find-points-on-area-selection.frag +0 -88
- package/src/modules/Points/find-points-on-polygon-selection.frag +0 -89
- package/src/modules/Points/index.ts +0 -2292
- package/src/modules/Points/track-positions.frag +0 -30
- package/src/modules/Points/update-position.frag +0 -39
- package/src/modules/Shared/buffer.ts +0 -39
- package/src/modules/Shared/clear.frag +0 -10
- package/src/modules/Shared/quad.vert +0 -13
- package/src/modules/Store/index.ts +0 -283
- package/src/modules/Zoom/index.ts +0 -148
- package/src/modules/core-module.ts +0 -28
- package/src/stories/1. welcome.mdx +0 -75
- package/src/stories/2. configuration.mdx +0 -111
- package/src/stories/3. api-reference.mdx +0 -591
- package/src/stories/beginners/basic-set-up/data-gen.ts +0 -33
- package/src/stories/beginners/basic-set-up/index.ts +0 -167
- package/src/stories/beginners/basic-set-up/style.css +0 -35
- package/src/stories/beginners/link-hovering/data-generator.ts +0 -198
- package/src/stories/beginners/link-hovering/index.ts +0 -65
- package/src/stories/beginners/link-hovering/style.css +0 -73
- package/src/stories/beginners/point-labels/data.ts +0 -73
- package/src/stories/beginners/point-labels/index.ts +0 -69
- package/src/stories/beginners/point-labels/labels.ts +0 -46
- package/src/stories/beginners/point-labels/style.css +0 -16
- package/src/stories/beginners/quick-start.ts +0 -54
- package/src/stories/beginners/remove-points/config.ts +0 -25
- package/src/stories/beginners/remove-points/data-gen.ts +0 -30
- package/src/stories/beginners/remove-points/index.ts +0 -96
- package/src/stories/beginners/remove-points/style.css +0 -31
- package/src/stories/beginners.stories.ts +0 -130
- package/src/stories/clusters/polygon-selection/index.ts +0 -52
- package/src/stories/clusters/polygon-selection/polygon.ts +0 -143
- package/src/stories/clusters/polygon-selection/style.css +0 -8
- package/src/stories/clusters/radial.ts +0 -24
- package/src/stories/clusters/with-labels.ts +0 -54
- package/src/stories/clusters/worm.ts +0 -40
- package/src/stories/clusters.stories.ts +0 -77
- package/src/stories/create-cluster-labels.ts +0 -50
- package/src/stories/create-cosmos.ts +0 -72
- package/src/stories/create-story.ts +0 -51
- package/src/stories/experiments/full-mesh.ts +0 -13
- package/src/stories/experiments/mesh-with-holes.ts +0 -13
- package/src/stories/experiments.stories.ts +0 -43
- package/src/stories/generate-mesh-data.ts +0 -125
- package/src/stories/geospatial/moscow-metro-stations/index.ts +0 -66
- package/src/stories/geospatial/moscow-metro-stations/moscow-metro-coords.ts +0 -1
- package/src/stories/geospatial/moscow-metro-stations/point-colors.ts +0 -46
- package/src/stories/geospatial/moscow-metro-stations/style.css +0 -30
- package/src/stories/geospatial.stories.ts +0 -30
- package/src/stories/shapes/all-shapes/index.ts +0 -73
- package/src/stories/shapes/image-example/icons/box.png +0 -0
- package/src/stories/shapes/image-example/icons/lego.png +0 -0
- package/src/stories/shapes/image-example/icons/s.png +0 -0
- package/src/stories/shapes/image-example/icons/swift.png +0 -0
- package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
- package/src/stories/shapes/image-example/index.ts +0 -246
- package/src/stories/shapes.stories.ts +0 -37
- package/src/stories/test-luma-migration.ts +0 -195
- package/src/stories/test.stories.ts +0 -25
- package/src/variables.ts +0 -68
- package/tsconfig.json +0 -41
- package/vite.config.ts +0 -52
package/dist/index.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(de,Ne){typeof exports=="object"&&typeof module<"u"?Ne(exports):typeof define=="function"&&define.amd?define(["exports"],Ne):(de=typeof globalThis<"u"?globalThis:de||self,Ne(de.Cosmos={}))})(this,function(de){"use strict";var t0=Object.defineProperty;var n0=(de,Ne,Mt)=>Ne in de?t0(de,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Mt}):de[Ne]=Mt;var m=(de,Ne,Mt)=>n0(de,typeof Ne!="symbol"?Ne+"":Ne,Mt);var Ne="http://www.w3.org/1999/xhtml";const Mt={svg:"http://www.w3.org/2000/svg",xhtml:Ne,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ai(n){var e=n+="",t=e.indexOf(":");return t>=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),Mt.hasOwnProperty(e)?{space:Mt[e],local:n}:n}function Vu(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Ne&&e.documentElement.namespaceURI===Ne?e.createElement(n):e.createElementNS(t,n)}}function Hu(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Uo(n){var e=ai(n);return(e.local?Hu:Vu)(e)}function Wu(){}function Vr(n){return n==null?Wu:function(){return this.querySelector(n)}}function $u(n){typeof n!="function"&&(n=Vr(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=new Array(o),c,l,u=0;u<o;++u)(c=s[u])&&(l=n.call(c,c.__data__,u,s))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new Xe(i,this._parents)}function Xu(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function Yu(){return[]}function zo(n){return n==null?Yu:function(){return this.querySelectorAll(n)}}function qu(n){return function(){return Xu(n.apply(this,arguments))}}function ju(n){typeof n=="function"?n=qu(n):n=zo(n);for(var e=this._groups,t=e.length,i=[],r=[],s=0;s<t;++s)for(var o=e[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(i.push(n.call(c,c.__data__,l,o)),r.push(c));return new Xe(i,r)}function Lo(n){return function(){return this.matches(n)}}function Vo(n){return function(e){return e.matches(n)}}var Ku=Array.prototype.find;function Zu(n){return function(){return Ku.call(this.children,n)}}function Qu(){return this.firstElementChild}function Ju(n){return this.select(n==null?Qu:Zu(typeof n=="function"?n:Vo(n)))}var Gu=Array.prototype.filter;function ef(){return Array.from(this.children)}function tf(n){return function(){return Gu.call(this.children,n)}}function nf(n){return this.selectAll(n==null?ef:tf(typeof n=="function"?n:Vo(n)))}function rf(n){typeof n!="function"&&(n=Lo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],c,l=0;l<o;++l)(c=s[l])&&n.call(c,c.__data__,l,s)&&a.push(c);return new Xe(i,this._parents)}function Ho(n){return new Array(n.length)}function sf(){return new Xe(this._enter||this._groups.map(Ho),this._parents)}function ci(n,e){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=e}ci.prototype={constructor:ci,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,e){return this._parent.insertBefore(n,e)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function of(n){return function(){return n}}function af(n,e,t,i,r,s){for(var o=0,a,c=e.length,l=s.length;o<l;++o)(a=e[o])?(a.__data__=s[o],i[o]=a):t[o]=new ci(n,s[o]);for(;o<c;++o)(a=e[o])&&(r[o]=a)}function cf(n,e,t,i,r,s,o){var a,c,l=new Map,u=e.length,f=s.length,h=new Array(u),d;for(a=0;a<u;++a)(c=e[a])&&(h[a]=d=o.call(c,c.__data__,a,e)+"",l.has(d)?r[a]=c:l.set(d,c));for(a=0;a<f;++a)d=o.call(n,s[a],a,s)+"",(c=l.get(d))?(i[a]=c,c.__data__=s[a],l.delete(d)):t[a]=new ci(n,s[a]);for(a=0;a<u;++a)(c=e[a])&&l.get(h[a])===c&&(r[a]=c)}function lf(n){return n.__data__}function uf(n,e){if(!arguments.length)return Array.from(this,lf);var t=e?cf:af,i=this._parents,r=this._groups;typeof n!="function"&&(n=of(n));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var u=i[l],f=r[l],h=f.length,d=ff(n.call(u,u&&u.__data__,l,i)),_=d.length,I=a[l]=new Array(_),C=o[l]=new Array(_),w=c[l]=new Array(h);t(u,f,I,C,w,d,e);for(var M=0,E=0,x,R;M<_;++M)if(x=I[M]){for(M>=E&&(E=M+1);!(R=C[E])&&++E<_;);x._next=R||null}}return o=new Xe(o,i),o._enter=a,o._exit=c,o}function ff(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function hf(){return new Xe(this._exit||this._groups.map(Ho),this._parents)}function df(n,e,t){var i=this.enter(),r=this,s=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?s.remove():t(s),i&&r?i.merge(r).order():r}function pf(n){for(var e=n.selection?n.selection():n,t=this._groups,i=e._groups,r=t.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var l=t[c],u=i[c],f=l.length,h=a[c]=new Array(f),d,_=0;_<f;++_)(d=l[_]||u[_])&&(h[_]=d);for(;c<r;++c)a[c]=t[c];return new Xe(a,this._parents)}function mf(){for(var n=this._groups,e=-1,t=n.length;++e<t;)for(var i=n[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function gf(n){n||(n=_f);function e(f,h){return f&&h?n(f.__data__,h.__data__):!f-!h}for(var t=this._groups,i=t.length,r=new Array(i),s=0;s<i;++s){for(var o=t[s],a=o.length,c=r[s]=new Array(a),l,u=0;u<a;++u)(l=o[u])&&(c[u]=l);c.sort(e)}return new Xe(r,this._parents).order()}function _f(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function xf(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function yf(){return Array.from(this)}function vf(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function bf(){let n=0;for(const e of this)++n;return n}function Sf(){return!this.node()}function Tf(n){for(var e=this._groups,t=0,i=e.length;t<i;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&n.call(a,a.__data__,s,r);return this}function wf(n){return function(){this.removeAttribute(n)}}function Af(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Cf(n,e){return function(){this.setAttribute(n,e)}}function Pf(n,e){return function(){this.setAttributeNS(n.space,n.local,e)}}function If(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(n):this.setAttribute(n,t)}}function Rf(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}function Ef(n,e){var t=ai(n);if(arguments.length<2){var i=this.node();return t.local?i.getAttributeNS(t.space,t.local):i.getAttribute(t)}return this.each((e==null?t.local?Af:wf:typeof e=="function"?t.local?Rf:If:t.local?Pf:Cf)(t,e))}function Wo(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function kf(n){return function(){this.style.removeProperty(n)}}function Ff(n,e,t){return function(){this.style.setProperty(n,e,t)}}function Df(n,e,t){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,t)}}function Mf(n,e,t){return arguments.length>1?this.each((e==null?kf:typeof e=="function"?Df:Ff)(n,e,t??"")):Qt(this.node(),n)}function Qt(n,e){return n.style.getPropertyValue(e)||Wo(n).getComputedStyle(n,null).getPropertyValue(e)}function Nf(n){return function(){delete this[n]}}function Of(n,e){return function(){this[n]=e}}function Bf(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function Uf(n,e){return arguments.length>1?this.each((e==null?Nf:typeof e=="function"?Bf:Of)(n,e)):this.node()[n]}function $o(n){return n.trim().split(/^|\s+/)}function Hr(n){return n.classList||new Xo(n)}function Xo(n){this._node=n,this._names=$o(n.getAttribute("class")||"")}Xo.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Yo(n,e){for(var t=Hr(n),i=-1,r=e.length;++i<r;)t.add(e[i])}function qo(n,e){for(var t=Hr(n),i=-1,r=e.length;++i<r;)t.remove(e[i])}function zf(n){return function(){Yo(this,n)}}function Lf(n){return function(){qo(this,n)}}function Vf(n,e){return function(){(e.apply(this,arguments)?Yo:qo)(this,n)}}function Hf(n,e){var t=$o(n+"");if(arguments.length<2){for(var i=Hr(this.node()),r=-1,s=t.length;++r<s;)if(!i.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?Vf:e?zf:Lf)(t,e))}function Wf(){this.textContent=""}function $f(n){return function(){this.textContent=n}}function Xf(n){return function(){var e=n.apply(this,arguments);this.textContent=e??""}}function Yf(n){return arguments.length?this.each(n==null?Wf:(typeof n=="function"?Xf:$f)(n)):this.node().textContent}function qf(){this.innerHTML=""}function jf(n){return function(){this.innerHTML=n}}function Kf(n){return function(){var e=n.apply(this,arguments);this.innerHTML=e??""}}function Zf(n){return arguments.length?this.each(n==null?qf:(typeof n=="function"?Kf:jf)(n)):this.node().innerHTML}function Qf(){this.nextSibling&&this.parentNode.appendChild(this)}function Jf(){return this.each(Qf)}function Gf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eh(){return this.each(Gf)}function th(n){var e=typeof n=="function"?n:Uo(n);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nh(){return null}function ih(n,e){var t=typeof n=="function"?n:Uo(n),i=e==null?nh:typeof e=="function"?e:Vr(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),i.apply(this,arguments)||null)})}function rh(){var n=this.parentNode;n&&n.removeChild(this)}function sh(){return this.each(rh)}function oh(){var n=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function ah(){var n=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function ch(n){return this.select(n?ah:oh)}function lh(n){return arguments.length?this.property("__data__",n):this.node().__data__}function uh(n){return function(e){n.call(this,e,this.__data__)}}function fh(n){return n.trim().split(/^|\s+/).map(function(e){var t="",i=e.indexOf(".");return i>=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function hh(n){return function(){var e=this.__on;if(e){for(var t=0,i=-1,r=e.length,s;t<r;++t)s=e[t],(!n.type||s.type===n.type)&&s.name===n.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function dh(n,e,t){return function(){var i=this.__on,r,s=uh(e);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=t),r.value=e;return}}this.addEventListener(n.type,s,t),r={type:n.type,name:n.name,value:e,listener:s,options:t},i?i.push(r):this.__on=[r]}}function ph(n,e,t){var i=fh(n+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<s;++r)if((o=i[r]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?dh:hh,r=0;r<s;++r)this.each(a(i[r],e,t));return this}function jo(n,e,t){var i=Wo(n),r=i.CustomEvent;typeof r=="function"?r=new r(e,t):(r=i.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),n.dispatchEvent(r)}function mh(n,e){return function(){return jo(this,n,e)}}function gh(n,e){return function(){return jo(this,n,e.apply(this,arguments))}}function _h(n,e){return this.each((typeof e=="function"?gh:mh)(n,e))}function*xh(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Ko=[null];function Xe(n,e){this._groups=n,this._parents=e}function wn(){return new Xe([[document.documentElement]],Ko)}function yh(){return this}Xe.prototype=wn.prototype={constructor:Xe,select:$u,selectAll:ju,selectChild:Ju,selectChildren:nf,filter:rf,data:uf,enter:sf,exit:hf,join:df,merge:pf,selection:yh,order:mf,sort:gf,call:xf,nodes:yf,node:vf,size:bf,empty:Sf,each:Tf,attr:Ef,style:Mf,property:Uf,classed:Hf,text:Yf,html:Zf,raise:Jf,lower:eh,append:th,insert:ih,remove:sh,clone:ch,datum:lh,on:ph,dispatch:_h,[Symbol.iterator]:xh};function Se(n){return typeof n=="string"?new Xe([[document.querySelector(n)]],[document.documentElement]):new Xe([[n]],Ko)}function vh(n){let e;for(;e=n.sourceEvent;)n=e;return n}function gt(n,e){if(n=vh(n),e===void 0&&(e=n.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var i=t.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[n.clientX-r.left-e.clientLeft,n.clientY-r.top-e.clientTop]}}return[n.pageX,n.pageY]}var bh={value:()=>{}};function li(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new ui(t)}function ui(n){this._=n}function Sh(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}ui.prototype=li.prototype={constructor:ui,on:function(n,e){var t=this._,i=Sh(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(n=i[s]).type)&&(r=Th(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(n=i[s]).type)t[r]=Zo(t[r],n.name,e);else if(e==null)for(r in t)t[r]=Zo(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new ui(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function Th(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function Zo(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=bh,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var Jt=0,An=0,Cn=0,Qo=1e3,fi,Pn,hi=0,Nt=0,di=0,In=typeof performance=="object"&&performance.now?performance:Date,Jo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Wr(){return Nt||(Jo(wh),Nt=In.now()+di)}function wh(){Nt=0}function pi(){this._call=this._time=this._next=null}pi.prototype=Go.prototype={constructor:pi,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Wr():+t)+(e==null?0:+e),!this._next&&Pn!==this&&(Pn?Pn._next=this:fi=this,Pn=this),this._call=n,this._time=t,$r()},stop:function(){this._call&&(this._call=null,this._time=1/0,$r())}};function Go(n,e,t){var i=new pi;return i.restart(n,e,t),i}function Ah(){Wr(),++Jt;for(var n=fi,e;n;)(e=Nt-n._time)>=0&&n._call.call(null,e),n=n._next;--Jt}function ea(){Nt=(hi=In.now())+di,Jt=An=0;try{Ah()}finally{Jt=0,Ph(),Nt=0}}function Ch(){var n=In.now(),e=n-hi;e>Qo&&(di-=e,hi=n)}function Ph(){for(var n,e=fi,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:fi=t);Pn=n,$r(i)}function $r(n){if(!Jt){An&&(An=clearTimeout(An));var e=n-Nt;e>24?(n<1/0&&(An=setTimeout(ea,n-In.now()-di)),Cn&&(Cn=clearInterval(Cn))):(Cn||(hi=In.now(),Cn=setInterval(Ch,Qo)),Jt=1,Jo(ea))}}function ta(n,e,t){var i=new pi;return e=e==null?0:+e,i.restart(r=>{i.stop(),n(r+e)},e,t),i}var Ih=li("start","end","cancel","interrupt"),Rh=[],na=0,ia=1,Xr=2,mi=3,ra=4,Yr=5,gi=6;function _i(n,e,t,i,r,s){var o=n.__transition;if(!o)n.__transition={};else if(t in o)return;Eh(n,t,{name:e,index:i,group:r,on:Ih,tween:Rh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:na})}function qr(n,e){var t=et(n,e);if(t.state>na)throw new Error("too late; already scheduled");return t}function ct(n,e){var t=et(n,e);if(t.state>mi)throw new Error("too late; already running");return t}function et(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Eh(n,e,t){var i=n.__transition,r;i[e]=t,t.timer=Go(s,0,t.time);function s(l){t.state=ia,t.timer.restart(o,t.delay,t.time),t.delay<=l&&o(l-t.delay)}function o(l){var u,f,h,d;if(t.state!==ia)return c();for(u in i)if(d=i[u],d.name===t.name){if(d.state===mi)return ta(o);d.state===ra?(d.state=gi,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[u]):+u<e&&(d.state=gi,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[u])}if(ta(function(){t.state===mi&&(t.state=ra,t.timer.restart(a,t.delay,t.time),a(l))}),t.state=Xr,t.on.call("start",n,n.__data__,t.index,t.group),t.state===Xr){for(t.state=mi,r=new Array(h=t.tween.length),u=0,f=-1;u<h;++u)(d=t.tween[u].value.call(n,n.__data__,t.index,t.group))&&(r[++f]=d);r.length=f+1}}function a(l){for(var u=l<t.duration?t.ease.call(null,l/t.duration):(t.timer.restart(c),t.state=Yr,1),f=-1,h=r.length;++f<h;)r[f].call(n,u);t.state===Yr&&(t.on.call("end",n,n.__data__,t.index,t.group),c())}function c(){t.state=gi,t.timer.stop(),delete i[e];for(var l in i)return;delete n.__transition}}function xi(n,e){var t=n.__transition,i,r,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((i=t[o]).name!==e){s=!1;continue}r=i.state>Xr&&i.state<Yr,i.state=gi,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete t[o]}s&&delete n.__transition}}function kh(n){return this.each(function(){xi(this,n)})}function jr(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function sa(n,e){var t=Object.create(n.prototype);for(var i in e)t[i]=e[i];return t}function Rn(){}var En=.7,yi=1/En,Gt="\\s*([+-]?\\d+)\\s*",kn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fh=/^#([0-9a-f]{3,8})$/,Dh=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Mh=new RegExp(`^rgb\\(${lt},${lt},${lt}\\)$`),Nh=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${kn}\\)$`),Oh=new RegExp(`^rgba\\(${lt},${lt},${lt},${kn}\\)$`),Bh=new RegExp(`^hsl\\(${kn},${lt},${lt}\\)$`),Uh=new RegExp(`^hsla\\(${kn},${lt},${lt},${kn}\\)$`),oa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};jr(Rn,It,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:zh,formatHsl:Lh,formatRgb:ca,toString:ca});function aa(){return this.rgb().formatHex()}function zh(){return this.rgb().formatHex8()}function Lh(){return da(this).formatHsl()}function ca(){return this.rgb().formatRgb()}function It(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=Fh.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?la(e):t===3?new He(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?vi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?vi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Dh.exec(n))?new He(e[1],e[2],e[3],1):(e=Mh.exec(n))?new He(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Nh.exec(n))?vi(e[1],e[2],e[3],e[4]):(e=Oh.exec(n))?vi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Bh.exec(n))?ha(e[1],e[2]/100,e[3]/100,1):(e=Uh.exec(n))?ha(e[1],e[2]/100,e[3]/100,e[4]):oa.hasOwnProperty(n)?la(oa[n]):n==="transparent"?new He(NaN,NaN,NaN,0):null}function la(n){return new He(n>>16&255,n>>8&255,n&255,1)}function vi(n,e,t,i){return i<=0&&(n=e=t=NaN),new He(n,e,t,i)}function Vh(n){return n instanceof Rn||(n=It(n)),n?(n=n.rgb(),new He(n.r,n.g,n.b,n.opacity)):new He}function Kr(n,e,t,i){return arguments.length===1?Vh(n):new He(n,e,t,i??1)}function He(n,e,t,i){this.r=+n,this.g=+e,this.b=+t,this.opacity=+i}jr(He,Kr,sa(Rn,{brighter(n){return n=n==null?yi:Math.pow(yi,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?En:Math.pow(En,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new He(Ot(this.r),Ot(this.g),Ot(this.b),bi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ua,formatHex:ua,formatHex8:Hh,formatRgb:fa,toString:fa}));function ua(){return`#${Bt(this.r)}${Bt(this.g)}${Bt(this.b)}`}function Hh(){return`#${Bt(this.r)}${Bt(this.g)}${Bt(this.b)}${Bt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fa(){const n=bi(this.opacity);return`${n===1?"rgb(":"rgba("}${Ot(this.r)}, ${Ot(this.g)}, ${Ot(this.b)}${n===1?")":`, ${n})`}`}function bi(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Ot(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function Bt(n){return n=Ot(n),(n<16?"0":"")+n.toString(16)}function ha(n,e,t,i){return i<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new tt(n,e,t,i)}function da(n){if(n instanceof tt)return new tt(n.h,n.s,n.l,n.opacity);if(n instanceof Rn||(n=It(n)),!n)return new tt;if(n instanceof tt)return n;n=n.rgb();var e=n.r/255,t=n.g/255,i=n.b/255,r=Math.min(e,t,i),s=Math.max(e,t,i),o=NaN,a=s-r,c=(s+r)/2;return a?(e===s?o=(t-i)/a+(t<i)*6:t===s?o=(i-e)/a+2:o=(e-t)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new tt(o,a,c,n.opacity)}function Wh(n,e,t,i){return arguments.length===1?da(n):new tt(n,e,t,i??1)}function tt(n,e,t,i){this.h=+n,this.s=+e,this.l=+t,this.opacity=+i}jr(tt,Wh,sa(Rn,{brighter(n){return n=n==null?yi:Math.pow(yi,n),new tt(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?En:Math.pow(En,n),new tt(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,r=2*t-i;return new He(Zr(n>=240?n-240:n+120,r,i),Zr(n,r,i),Zr(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new tt(pa(this.h),Si(this.s),Si(this.l),bi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=bi(this.opacity);return`${n===1?"hsl(":"hsla("}${pa(this.h)}, ${Si(this.s)*100}%, ${Si(this.l)*100}%${n===1?")":`, ${n})`}`}}));function pa(n){return n=(n||0)%360,n<0?n+360:n}function Si(n){return Math.max(0,Math.min(1,n||0))}function Zr(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const Qr=n=>()=>n;function $h(n,e){return function(t){return n+t*e}}function Xh(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(i){return Math.pow(n+i*e,t)}}function Yh(n){return(n=+n)==1?ma:function(e,t){return t-e?Xh(e,t,n):Qr(isNaN(e)?t:e)}}function ma(n,e){var t=e-n;return t?$h(n,t):Qr(isNaN(n)?e:n)}const Ti=function n(e){var t=Yh(e);function i(r,s){var o=t((r=Kr(r)).r,(s=Kr(s)).r),a=t(r.g,s.g),c=t(r.b,s.b),l=ma(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return i.gamma=n,i}(1);function qh(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,i=e.slice(),r;return function(s){for(r=0;r<t;++r)i[r]=n[r]*(1-s)+e[r]*s;return i}}function jh(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Kh(n,e){var t=e?e.length:0,i=n?Math.min(t,n.length):0,r=new Array(i),s=new Array(t),o;for(o=0;o<i;++o)r[o]=es(n[o],e[o]);for(;o<t;++o)s[o]=e[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function Zh(n,e){var t=new Date;return n=+n,e=+e,function(i){return t.setTime(n*(1-i)+e*i),t}}function nt(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function Qh(n,e){var t={},i={},r;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in n?t[r]=es(n[r],e[r]):i[r]=e[r];return function(s){for(r in t)i[r]=t[r](s);return i}}var Jr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gr=new RegExp(Jr.source,"g");function Jh(n){return function(){return n}}function Gh(n){return function(e){return n(e)+""}}function ga(n,e){var t=Jr.lastIndex=Gr.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(n=n+"",e=e+"";(i=Jr.exec(n))&&(r=Gr.exec(e));)(s=r.index)>t&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:nt(i,r)})),t=Gr.lastIndex;return t<e.length&&(s=e.slice(t),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?Gh(c[0].x):Jh(e):(e=c.length,function(l){for(var u=0,f;u<e;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function es(n,e){var t=typeof e,i;return e==null||t==="boolean"?Qr(e):(t==="number"?nt:t==="string"?(i=It(e))?(e=i,Ti):ga:e instanceof It?Ti:e instanceof Date?Zh:jh(e)?qh:Array.isArray(e)?Kh:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Qh:nt)(n,e)}function ed(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}var _a=180/Math.PI,ts={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xa(n,e,t,i,r,s){var o,a,c;return(o=Math.sqrt(n*n+e*e))&&(n/=o,e/=o),(c=n*t+e*i)&&(t-=n*c,i-=e*c),(a=Math.sqrt(t*t+i*i))&&(t/=a,i/=a,c/=a),n*i<e*t&&(n=-n,e=-e,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,n)*_a,skewX:Math.atan(c)*_a,scaleX:o,scaleY:a}}var wi;function td(n){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return e.isIdentity?ts:xa(e.a,e.b,e.c,e.d,e.e,e.f)}function nd(n){return n==null||(wi||(wi=document.createElementNS("http://www.w3.org/2000/svg","g")),wi.setAttribute("transform",n),!(n=wi.transform.baseVal.consolidate()))?ts:(n=n.matrix,xa(n.a,n.b,n.c,n.d,n.e,n.f))}function ya(n,e,t,i){function r(l){return l.length?l.pop()+" ":""}function s(l,u,f,h,d,_){if(l!==f||u!==h){var I=d.push("translate(",null,e,null,t);_.push({i:I-4,x:nt(l,f)},{i:I-2,x:nt(u,h)})}else(f||h)&&d.push("translate("+f+e+h+t)}function o(l,u,f,h){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:nt(l,u)})):u&&f.push(r(f)+"rotate("+u+i)}function a(l,u,f,h){l!==u?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:nt(l,u)}):u&&f.push(r(f)+"skewX("+u+i)}function c(l,u,f,h,d,_){if(l!==f||u!==h){var I=d.push(r(d)+"scale(",null,",",null,")");_.push({i:I-4,x:nt(l,f)},{i:I-2,x:nt(u,h)})}else(f!==1||h!==1)&&d.push(r(d)+"scale("+f+","+h+")")}return function(l,u){var f=[],h=[];return l=n(l),u=n(u),s(l.translateX,l.translateY,u.translateX,u.translateY,f,h),o(l.rotate,u.rotate,f,h),a(l.skewX,u.skewX,f,h),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,h),l=u=null,function(d){for(var _=-1,I=h.length,C;++_<I;)f[(C=h[_]).i]=C.x(d);return f.join("")}}}var id=ya(td,"px, ","px)","deg)"),rd=ya(nd,", ",")",")"),sd=1e-12;function va(n){return((n=Math.exp(n))+1/n)/2}function od(n){return((n=Math.exp(n))-1/n)/2}function ad(n){return((n=Math.exp(2*n))-1)/(n+1)}const cd=function n(e,t,i){function r(s,o){var a=s[0],c=s[1],l=s[2],u=o[0],f=o[1],h=o[2],d=u-a,_=f-c,I=d*d+_*_,C,w;if(I<sd)w=Math.log(h/l)/e,C=function(L){return[a+L*d,c+L*_,l*Math.exp(e*L*w)]};else{var M=Math.sqrt(I),E=(h*h-l*l+i*I)/(2*l*t*M),x=(h*h-l*l-i*I)/(2*h*t*M),R=Math.log(Math.sqrt(E*E+1)-E),B=Math.log(Math.sqrt(x*x+1)-x);w=(B-R)/e,C=function(L){var W=L*w,q=va(R),J=l/(t*M)*(q*ad(e*W+R)-od(R));return[a+J*d,c+J*_,l*q/va(e*W+R)]}}return C.duration=w*1e3*e/Math.SQRT2,C}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return n(o,a,c)},r}(Math.SQRT2,2,4);function ld(n,e){var t,i;return function(){var r=ct(this,n),s=r.tween;if(s!==t){i=t=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function ud(n,e,t){var i,r;if(typeof t!="function")throw new Error;return function(){var s=ct(this,n),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:e,value:t},c=0,l=r.length;c<l;++c)if(r[c].name===e){r[c]=a;break}c===l&&r.push(a)}s.tween=r}}function fd(n,e){var t=this._id;if(n+="",arguments.length<2){for(var i=et(this.node(),t).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===n)return o.value;return null}return this.each((e==null?ld:ud)(t,n,e))}function ns(n,e,t){var i=n._id;return n.each(function(){var r=ct(this,i);(r.value||(r.value={}))[e]=t.apply(this,arguments)}),function(r){return et(r,i).value[e]}}function ba(n,e){var t;return(typeof e=="number"?nt:e instanceof It?Ti:(t=It(e))?(e=t,Ti):ga)(n,e)}function hd(n){return function(){this.removeAttribute(n)}}function dd(n){return function(){this.removeAttributeNS(n.space,n.local)}}function pd(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttribute(n);return o===r?null:o===i?s:s=e(i=o,t)}}function md(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttributeNS(n.space,n.local);return o===r?null:o===i?s:s=e(i=o,t)}}function gd(n,e,t){var i,r,s;return function(){var o,a=t(this),c;return a==null?void this.removeAttribute(n):(o=this.getAttribute(n),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=e(i=o,a)))}}function _d(n,e,t){var i,r,s;return function(){var o,a=t(this),c;return a==null?void this.removeAttributeNS(n.space,n.local):(o=this.getAttributeNS(n.space,n.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=e(i=o,a)))}}function xd(n,e){var t=ai(n),i=t==="transform"?rd:ba;return this.attrTween(n,typeof e=="function"?(t.local?_d:gd)(t,i,ns(this,"attr."+n,e)):e==null?(t.local?dd:hd)(t):(t.local?md:pd)(t,i,e))}function yd(n,e){return function(t){this.setAttribute(n,e.call(this,t))}}function vd(n,e){return function(t){this.setAttributeNS(n.space,n.local,e.call(this,t))}}function bd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&vd(n,s)),t}return r._value=e,r}function Sd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&yd(n,s)),t}return r._value=e,r}function Td(n,e){var t="attr."+n;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var i=ai(n);return this.tween(t,(i.local?bd:Sd)(i,e))}function wd(n,e){return function(){qr(this,n).delay=+e.apply(this,arguments)}}function Ad(n,e){return e=+e,function(){qr(this,n).delay=e}}function Cd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?wd:Ad)(e,n)):et(this.node(),e).delay}function Pd(n,e){return function(){ct(this,n).duration=+e.apply(this,arguments)}}function Id(n,e){return e=+e,function(){ct(this,n).duration=e}}function Rd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?Pd:Id)(e,n)):et(this.node(),e).duration}function Ed(n,e){if(typeof e!="function")throw new Error;return function(){ct(this,n).ease=e}}function kd(n){var e=this._id;return arguments.length?this.each(Ed(e,n)):et(this.node(),e).ease}function Fd(n,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;ct(this,n).ease=t}}function Dd(n){if(typeof n!="function")throw new Error;return this.each(Fd(this._id,n))}function Md(n){typeof n!="function"&&(n=Lo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],c,l=0;l<o;++l)(c=s[l])&&n.call(c,c.__data__,l,s)&&a.push(c);return new _t(i,this._parents,this._name,this._id)}function Nd(n){if(n._id!==this._id)throw new Error;for(var e=this._groups,t=n._groups,i=e.length,r=t.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=e[a],l=t[a],u=c.length,f=o[a]=new Array(u),h,d=0;d<u;++d)(h=c[d]||l[d])&&(f[d]=h);for(;a<i;++a)o[a]=e[a];return new _t(o,this._parents,this._name,this._id)}function Od(n){return(n+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Bd(n,e,t){var i,r,s=Od(e)?qr:ct;return function(){var o=s(this,n),a=o.on;a!==i&&(r=(i=a).copy()).on(e,t),o.on=r}}function Ud(n,e){var t=this._id;return arguments.length<2?et(this.node(),t).on.on(n):this.each(Bd(t,n,e))}function zd(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Ld(){return this.on("end.remove",zd(this._id))}function Vd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=Vr(n));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,l=s[o]=new Array(c),u,f,h=0;h<c;++h)(u=a[h])&&(f=n.call(u,u.__data__,h,a))&&("__data__"in u&&(f.__data__=u.__data__),l[h]=f,_i(l[h],e,t,h,l,et(u,t)));return new _t(s,this._parents,e,t)}function Hd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=zo(n));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var h=n.call(u,u.__data__,f,c),d,_=et(u,t),I=0,C=h.length;I<C;++I)(d=h[I])&&_i(d,e,t,I,h,_);s.push(h),o.push(u)}return new _t(s,o,e,t)}var Wd=wn.prototype.constructor;function $d(){return new Wd(this._groups,this._parents)}function Xd(n,e){var t,i,r;return function(){var s=Qt(this,n),o=(this.style.removeProperty(n),Qt(this,n));return s===o?null:s===t&&o===i?r:r=e(t=s,i=o)}}function Sa(n){return function(){this.style.removeProperty(n)}}function Yd(n,e,t){var i,r=t+"",s;return function(){var o=Qt(this,n);return o===r?null:o===i?s:s=e(i=o,t)}}function qd(n,e,t){var i,r,s;return function(){var o=Qt(this,n),a=t(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(n),Qt(this,n))),o===c?null:o===i&&c===r?s:(r=c,s=e(i=o,a))}}function jd(n,e){var t,i,r,s="style."+e,o="end."+s,a;return function(){var c=ct(this,n),l=c.on,u=c.value[s]==null?a||(a=Sa(e)):void 0;(l!==t||r!==u)&&(i=(t=l).copy()).on(o,r=u),c.on=i}}function Kd(n,e,t){var i=(n+="")=="transform"?id:ba;return e==null?this.styleTween(n,Xd(n,i)).on("end.style."+n,Sa(n)):typeof e=="function"?this.styleTween(n,qd(n,i,ns(this,"style."+n,e))).each(jd(this._id,n)):this.styleTween(n,Yd(n,i,e),t).on("end.style."+n,null)}function Zd(n,e,t){return function(i){this.style.setProperty(n,e.call(this,i),t)}}function Qd(n,e,t){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&Zd(n,o,t)),i}return s._value=e,s}function Jd(n,e,t){var i="style."+(n+="");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;return this.tween(i,Qd(n,e,t??""))}function Gd(n){return function(){this.textContent=n}}function ep(n){return function(){var e=n(this);this.textContent=e??""}}function tp(n){return this.tween("text",typeof n=="function"?ep(ns(this,"text",n)):Gd(n==null?"":n+""))}function np(n){return function(e){this.textContent=n.call(this,e)}}function ip(n){var e,t;function i(){var r=n.apply(this,arguments);return r!==t&&(e=(t=r)&&np(r)),e}return i._value=n,i}function rp(n){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(n==null)return this.tween(e,null);if(typeof n!="function")throw new Error;return this.tween(e,ip(n))}function sp(){for(var n=this._name,e=this._id,t=Ta(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var u=et(c,e);_i(c,n,t,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new _t(i,this._parents,n,t)}function op(){var n,e,t=this,i=t._id,r=t.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};t.each(function(){var l=ct(this,i),u=l.on;u!==n&&(e=(n=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(c)),l.on=e}),r===0&&s()})}var ap=0;function _t(n,e,t,i){this._groups=n,this._parents=e,this._name=t,this._id=i}function Ta(){return++ap}var xt=wn.prototype;_t.prototype={constructor:_t,select:Vd,selectAll:Hd,selectChild:xt.selectChild,selectChildren:xt.selectChildren,filter:Md,merge:Nd,selection:$d,transition:sp,call:xt.call,nodes:xt.nodes,node:xt.node,size:xt.size,empty:xt.empty,each:xt.each,on:Ud,attr:xd,attrTween:Td,style:Kd,styleTween:Jd,text:tp,textTween:rp,remove:Ld,tween:fd,delay:Cd,duration:Rd,ease:kd,easeVarying:Dd,end:op,[Symbol.iterator]:xt[Symbol.iterator]};function cp(n){return n*n}function lp(n){return n*(2-n)}function up(n){return((n*=2)<=1?n*n:--n*(2-n)+1)/2}function fp(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var hp={time:null,delay:0,duration:250,ease:fp};function dp(n,e){for(var t;!(t=n.__transition)||!(t=t[e]);)if(!(n=n.parentNode))throw new Error(`transition ${e} not found`);return t}function pp(n){var e,t;n instanceof _t?(e=n._id,n=n._name):(e=Ta(),(t=hp).time=Wr(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&_i(c,n,e,l,o,t||dp(c,e));return new _t(i,this._parents,n,e)}wn.prototype.interrupt=kh,wn.prototype.transition=pp;function wa(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}class Aa{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=wa(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(wa()-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 mp{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:i}=e;let r=this.stats[t];return r||(e instanceof Aa?r=e:r=new Aa(t,i),this.stats[t]=r),r}}class gp{constructor(){m(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new mp({id:e})),this.stats.get(e)}}const Ca=new gp,Ai=globalThis,en=globalThis.process||{},_p=globalThis.navigator||{};function Pa(n){var i,r;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((r=process.versions)!=null&&r.electron))return!0;const t=typeof navigator<"u"&&navigator.userAgent;return!!(t&&t.indexOf("Electron")>=0)}function Ut(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||Pa()}function xp(n){return Ut()?Pa()?"Electron":(_p.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const Ia="4.1.0";function yp(n){try{const e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class vp{constructor(e,t,i="sessionStorage"){this.storage=yp(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function bp(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Sp(n,e=8){const t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Ci;(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ci||(Ci={}));const Tp=10;function Ra(n){return typeof n!="string"?n:(n=n.toUpperCase(),Ci[n]||Ci.WHITE)}function wp(n,e,t){return!Ut&&typeof n=="string"&&(e&&(n=`\x1B[${Ra(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Ra(t)+Tp}m${n}\x1B[49m`)),n}function Ap(n,e=["constructor"]){const t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(const s of i){const o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}function is(n,e){if(!n)throw new Error("Assertion failed")}function tn(){var e,t,i;let n;if(Ut()&&Ai.performance)n=(t=(e=Ai==null?void 0:Ai.performance)==null?void 0:e.now)==null?void 0:t.call(e);else if("hrtime"in en){const r=(i=en==null?void 0:en.hrtime)==null?void 0:i.call(en);n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}const nn={debug:Ut()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Cp={enabled:!0,level:0};function rn(){}const Ea={},ka={once:!0};class Fa{constructor({id:e}={id:""}){this.VERSION=Ia,this._startTs=tn(),this._deltaTs=tn(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new vp(`__probe-${this.id}__`,Cp),this.timeStamp(`${this.id} started`),Ap(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((tn()-this._startTs).toPrecision(10))}getDelta(){return Number((tn()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,nn.warn,arguments,ka)}error(e){return this._getLogFunction(0,e,nn.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,nn.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,nn.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,nn.debug||nn.info,arguments,ka)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||rn,i&&[i],{tag:Ip(t)}):rn}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||rn)}group(e,t,i={collapsed:!1}){const r=Ma({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return r.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||rn)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Da(e)}_getLogFunction(e,t,i,r,s){if(this._shouldLog(e)){s=Ma({logLevel:e,message:t,args:r,opts:s}),i=i||s.method,is(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=tn();const o=s.tag||s.message;if(s.once&&o)if(!Ea[o])Ea[o]=tn();else return rn;return t=Pp(this.id,s.message,s),i.bind(console,t,...s.args)}return rn}}Fa.VERSION=Ia;function Da(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return is(Number.isFinite(e)&&e>=0),e}function Ma(n){const{logLevel:e,message:t}=n;n.logLevel=Da(e);const i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break}typeof n.message=="function"&&(n.message=n.message());const r=typeof n.message;return is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}function Pp(n,e,t){if(typeof e=="string"){const i=t.time?Sp(bp(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=wp(e,t.color,t.background)}return e}function Ip(n){for(const e in n)for(const t in n[e])return t||"untitled";return"empty"}const F=new Fa({id:"luma.gl"}),rs={};function Pi(n="id"){rs[n]=rs[n]||1;const e=rs[n]++;return`${n}-${e}`}class ae{constructor(e,t,i){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"_device");m(this,"destroyed",!1);m(this,"allocatedBytes",0);m(this,"_attachedResources",new Set);if(!e)throw new Error("no device");this._device=e,this.props=Rp(t,i);const r=this.props.id!=="undefined"?this.props.id:Pi(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}m(ae,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Rp(n,e){const t={...e};for(const i in n)n[i]!==void 0&&(t[i]=n[i]);return t}const Re=class Re extends ae{constructor(t,i){const r={...i};(i.usage||0)&Re.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?r.indexType="uint32":i.data instanceof Uint16Array&&(r.indexType="uint16")),delete r.data;super(t,r,Re.defaultProps);m(this,"usage");m(this,"indexType");m(this,"updateTimestamp");m(this,"debugData",new ArrayBuffer(0));this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(t){return this.device.createBuffer({...this.props,...t})}_setDebugData(t,i,r){const s=ArrayBuffer.isView(t)?t.buffer:t,o=Math.min(t?t.byteLength:r,Re.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):i===0&&r===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(i,i+o)}};m(Re,"INDEX",16),m(Re,"VERTEX",32),m(Re,"UNIFORM",64),m(Re,"STORAGE",128),m(Re,"INDIRECT",256),m(Re,"QUERY_RESOLVE",512),m(Re,"MAP_READ",1),m(Re,"MAP_WRITE",2),m(Re,"COPY_SRC",4),m(Re,"COPY_DST",8),m(Re,"DEBUG_DATA_MAX_LENGTH",32),m(Re,"defaultProps",{...ae.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let z=Re;function Na(n){const[e,t,i]=ss[n],r=n.includes("norm"),s=!r&&!n.startsWith("float"),o=n.startsWith("s");return{signedType:e,primitiveType:t,byteLength:i,normalized:r,integer:s,signed:o}}function Ep(n){const e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function kp(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Oa(n){const e=ArrayBuffer.isView(n)?n.constructor:n;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(ss).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function Ba(n){const[,,,,e]=ss[n];return e}const ss={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 os(n){let e;n.endsWith("-webgl")&&(n.replace("-webgl",""),e=!0);const[t,i]=n.split("x"),r=t,s=i?parseInt(i):1,o=Na(r),a={type:r,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function Fp(n,e,t){const i=t?Ep(n):n;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}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`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function Dp(n,e,t){if(!e||e>4)throw new Error(`size ${e}`);const i=e,r=Oa(n);return Fp(r,i,t)}function Mp(n){let e;switch(n.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?e:`${e}x${n.components}`}const Ee="texture-compression-bc",ce="texture-compression-astc",ut="texture-compression-etc2",Np="texture-compression-etc1-webgl",Ii="texture-compression-pvrtc-webgl",as="texture-compression-atc-webgl",Ri="float32-renderable-webgl",cs="float16-renderable-webgl",Op="rgb9e5ufloat-renderable-webgl",ls="snorm8-renderable-webgl",Fn="norm16-renderable-webgl",us="snorm16-renderable-webgl",Ei="float32-filterable",Ua="float16-filterable-webgl";function za(n){const e=Bp[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}const Bp={...{r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ls},rg8snorm:{render:ls},"rgb8snorm-webgl":{},rgba8snorm:{render:ls},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Fn},rg16unorm:{render:Fn},"rgb16unorm-webgl":{f:Fn},rgba16unorm:{render:Fn},r16snorm:{f:us},rg16snorm:{render:us},"rgb16snorm-webgl":{f:Fn},rgba16snorm:{render:us},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:cs,filter:"float16-filterable-webgl"},rg16float:{render:cs,filter:Ua},rgba16float:{render:cs,filter:Ua},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Ri,filter:Ei},rg32float:{render:!1,filter:Ei},"rgb32float-webgl":{render:Ri,filter:Ei},rgba32float:{render:Ri,filter:Ei},"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:Op},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ri},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}},...{"bc1-rgb-unorm-webgl":{f:Ee},"bc1-rgb-unorm-srgb-webgl":{f:Ee},"bc1-rgba-unorm":{f:Ee},"bc1-rgba-unorm-srgb":{f:Ee},"bc2-rgba-unorm":{f:Ee},"bc2-rgba-unorm-srgb":{f:Ee},"bc3-rgba-unorm":{f:Ee},"bc3-rgba-unorm-srgb":{f:Ee},"bc4-r-unorm":{f:Ee},"bc4-r-snorm":{f:Ee},"bc5-rg-unorm":{f:Ee},"bc5-rg-snorm":{f:Ee},"bc6h-rgb-ufloat":{f:Ee},"bc6h-rgb-float":{f:Ee},"bc7-rgba-unorm":{f:Ee},"bc7-rgba-unorm-srgb":{f:Ee},"etc2-rgb8unorm":{f:ut},"etc2-rgb8unorm-srgb":{f:ut},"etc2-rgb8a1unorm":{f:ut},"etc2-rgb8a1unorm-srgb":{f:ut},"etc2-rgba8unorm":{f:ut},"etc2-rgba8unorm-srgb":{f:ut},"eac-r11unorm":{f:ut},"eac-r11snorm":{f:ut},"eac-rg11unorm":{f:ut},"eac-rg11snorm":{f:ut},"astc-4x4-unorm":{f:ce},"astc-4x4-unorm-srgb":{f:ce},"astc-5x4-unorm":{f:ce},"astc-5x4-unorm-srgb":{f:ce},"astc-5x5-unorm":{f:ce},"astc-5x5-unorm-srgb":{f:ce},"astc-6x5-unorm":{f:ce},"astc-6x5-unorm-srgb":{f:ce},"astc-6x6-unorm":{f:ce},"astc-6x6-unorm-srgb":{f:ce},"astc-8x5-unorm":{f:ce},"astc-8x5-unorm-srgb":{f:ce},"astc-8x6-unorm":{f:ce},"astc-8x6-unorm-srgb":{f:ce},"astc-8x8-unorm":{f:ce},"astc-8x8-unorm-srgb":{f:ce},"astc-10x5-unorm":{f:ce},"astc-10x5-unorm-srgb":{f:ce},"astc-10x6-unorm":{f:ce},"astc-10x6-unorm-srgb":{f:ce},"astc-10x8-unorm":{f:ce},"astc-10x8-unorm-srgb":{f:ce},"astc-10x10-unorm":{f:ce},"astc-10x10-unorm-srgb":{f:ce},"astc-12x10-unorm":{f:ce},"astc-12x10-unorm-srgb":{f:ce},"astc-12x12-unorm":{f:ce},"astc-12x12-unorm-srgb":{f:ce},"pvrtc-rgb4unorm-webgl":{f:Ii},"pvrtc-rgba4unorm-webgl":{f:Ii},"pvrtc-rbg2unorm-webgl":{f:Ii},"pvrtc-rgba2unorm-webgl":{f:Ii},"etc1-rbg-unorm-webgl":{f:Np},"atc-rgb-unorm-webgl":{f:as},"atc-rgba-unorm-webgl":{f:as},"atc-rgbai-unorm-webgl":{f:as}}},Up=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],zp=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class Lp{getInfo(e){return La(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 Up.some(t=>e.startsWith(t))}getCapabilities(e){const t=za(e),i={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=La(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=r==null?void 0:r.signed,a=r==null?void 0:r.integer,c=r==null?void 0:r.webgl;return i.render&&(i.render=!o),i.filter&&(i.filter=!s&&!o&&!a&&!c),i}}const sn=new Lp;function La(n){let e=Vp(n);if(sn.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const i=Hp(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}const t=zp.exec(n);if(t){const[,i,r,s,o,a]=t,c=`${s}${r}`,l=Na(c),u=l.byteLength*8,f=i.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:h,bytesPerPixel:l.byteLength*i.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function Vp(n){var s;const e=za(n),t=e.bytesPerPixel||1,i=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:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||((s=e.channels)==null?void 0:s.length)||1,bytesPerPixel:t,bitsPerChannel:i,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 Hp(n){const t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){const[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return null}function Wp(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function $p(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}class Xp{}class Yp{constructor(e=[],t){m(this,"features");m(this,"disabledFeatures");this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const yr=class yr{constructor(e){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"statsManager",Ca);m(this,"timestamp",0);m(this,"_reused",!1);m(this,"_lumaData",{});m(this,"_textureCaps",{});this.props={...yr.defaultProps,...e},this.id=this.props.id||Pi(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return os(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return sn.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){const r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return Wp(e)}getExternalImageSize(e){return $p(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 sn.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:F.error(e.message,t,...i)}debug(){if(this.props.debug)debugger;else F.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
2
|
-
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=sn.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&z.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};m(yr,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[i,r]=e.getDevicePixelSize();F.log(1,`${e} resized => ${i}x${r}px`)()},onPositionChange:(e,t)=>{const[i,r]=e.getPosition();F.log(1,`${e} repositioned => ${i},${r}`)()},onVisibilityChange:e=>F.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>F.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:F.get("debug")||void 0,debugShaders:F.get("debug-shaders")||void 0,debugFramebuffers:!!F.get("debug-framebuffers"),debugFactories:!!F.get("debug-factories"),debugWebGL:!!F.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let zt=yr;const qp="set luma.log.level=1 (or higher) to trace rendering",Va="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ni=class ni{constructor(){m(this,"stats",Ca);m(this,"log",F);m(this,"VERSION","9.2.3");m(this,"spector");m(this,"preregisteredAdapters",new Map);if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw F.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),F.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");F.error("This version of luma.gl has already been initialized")()}F.log(1,`${this.VERSION} - ${qp}`)(),globalThis.luma=this}async createDevice(e={}){const t={...ni.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(Va);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){var s;const i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(Va);return await((s=r==null?void 0:r.attach)==null?void 0:s.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>{var r;return(r=i.isSupported)==null?void 0:r.call(i)}).map(i=>i.type)}getBestAvailableAdapterType(e=[]){var r,s;const t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(const o of t)if((s=(r=i.get(o))==null?void 0:r.isSupported)!=null&&s.call(r))return o;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));const r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){var s;const r=this._getAdapterMap(t).get("webgl");r||F.warn("enforceWebGL2: webgl adapter not found")(),(s=r==null?void 0:r.enforceWebGL2)==null||s.call(r,e)}setDefaultDeviceProps(e){Object.assign(ni.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?F.warn("WebGL1 is not supported",e)():F.warn("Unknown handle type",e)(),null)}};m(ni,"defaultProps",{...zt.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let fs=ni;const jp=new fs;class Kp{get pageLoaded(){return Jp()}}const Zp=Ut()&&typeof document<"u",Qp=()=>Zp&&document.readyState==="complete";let ki=null;function Jp(){return ki||(Qp()||typeof window>"u"?ki=Promise.resolve():ki=new Promise(n=>window.addEventListener("load",()=>n()))),ki}function Gp(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}const qt=class qt{constructor(e){m(this,"id");m(this,"props");m(this,"canvas");m(this,"htmlCanvas");m(this,"offscreenCanvas");m(this,"type");m(this,"initialized");m(this,"isInitialized",!1);m(this,"isVisible",!0);m(this,"cssWidth");m(this,"cssHeight");m(this,"devicePixelRatio");m(this,"devicePixelWidth");m(this,"devicePixelHeight");m(this,"drawingBufferWidth");m(this,"drawingBufferHeight");m(this,"_initializedResolvers",Gp());m(this,"_resizeObserver");m(this,"_intersectionObserver");m(this,"_position");m(this,"destroyed",!1);var t,i;if(this.props={...qt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Ut()?e.canvas?typeof e.canvas=="string"?this.canvas=tm(e.canvas):this.canvas=e.canvas:this.canvas=nm(e):this.canvas={width:e.width||1,height:e.height||1},qt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):qt.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((i=this.htmlCanvas)==null?void 0:i.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],qt.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(r=>this._handleIntersection(r)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(r=>this._handleResize(r));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return im(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(r=>r.target===this.canvas);if(!t)return;const i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){var c,l;const t=e.find(u=>u.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;const i=this.getDevicePixelSize(),r=((c=t.devicePixelContentBoxSize)==null?void 0:c[0].inlineSize)||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=((l=t.devicePixelContentBoxSize)==null?void 0:l[0].blockSize)||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(r,o)),this.devicePixelHeight=Math.max(1,Math.min(s,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var t,i,r;const e=(t=this.htmlCanvas)==null?void 0:t.getBoundingClientRect();if(e){const s=[e.left,e.top];if(this._position??(this._position=s),s[0]!==this._position[0]||s[1]!==this._position[1]){const a=this._position;this._position=s,(r=(i=this.device.props).onPositionChange)==null||r.call(i,this,{oldPosition:a})}}}};m(qt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Fi=qt;function em(n){if(typeof n=="string"){const e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function tm(n){const e=document.getElementById(n);if(!Fi.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function nm(n){const{width:e,height:t}=n,i=document.createElement("canvas");i.id=Pi("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n!=null&&n.visible||(i.style.visibility="hidden");const r=em((n==null?void 0:n.container)||null);return r.insertBefore(i,r.firstChild),i}function im(n,e,t,i,r){const s=n,o=Ha(s[0],e,t);let a=Wa(s[1],e,i,r),c=Ha(s[0]+1,e,t);const l=c===t-1?c:c-1;c=Wa(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function Ha(n,e,t){return Math.min(Math.round(n*e),t-1)}function Wa(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}const ii=class ii extends ae{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=ii.normalizeProps(e,t),super(e,t,ii.defaultProps)}static normalizeProps(e,t){return t}};m(ii,"defaultProps",{...ae.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let on=ii;const rm={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},we=class we extends ae{constructor(t,i){i=we.normalizeProps(t,i);super(t,i,we.defaultProps);m(this,"dimension");m(this,"baseDimension");m(this,"format");m(this,"width");m(this,"height");m(this,"depth");m(this,"mipLevels");m(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=rm[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(t.isExternalImage(i.data)){const r=t.getExternalImageSize(i.data);this.width=(r==null?void 0:r.width)||1,this.height=(r==null?void 0:r.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&F.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(t){this.sampler=t instanceof on?t:this.device.createSampler(t)}clone(t){return this.device.createTexture({...this.props,...t})}static normalizeProps(t,i){const r={...i},{width:s,height:o}=r;return typeof s=="number"&&(r.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(r.height=Math.max(1,Math.ceil(o))),r}_initializeData(t){this.device.isExternalImage(t)?this.copyExternalImage({image:t,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}):t&&this.copyImageData({data:t,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(t){const{width:i,height:r,depth:s}=this,o={...we.defaultCopyDataOptions,width:i,height:r,depth:s,...t},a=this.device.getTextureFormatInfo(this.format);if(!t.bytesPerRow&&!a.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return o.bytesPerRow=t.bytesPerRow||i*(a.bytesPerPixel||4),o.rowsPerImage=t.rowsPerImage||r,o}_normalizeCopyExternalImageOptions(t){const i=this.device.getExternalImageSize(t.image),r={...we.defaultCopyExternalImageOptions,...i,...t};return r.width=Math.min(r.width,this.width-r.x),r.height=Math.min(r.height,this.height-r.y),r}};m(we,"SAMPLE",4),m(we,"STORAGE",8),m(we,"RENDER",16),m(we,"COPY_SRC",1),m(we,"COPY_DST",2),m(we,"TEXTURE",4),m(we,"RENDER_ATTACHMENT",16),m(we,"defaultProps",{...ae.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:we.TEXTURE|we.RENDER_ATTACHMENT|we.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),m(we,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),m(we,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let G=we;const vr=class vr extends ae{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,vr.defaultProps)}};m(vr,"defaultProps",{...ae.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Di=vr;function sm(n,e,t){let i="";const r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++)for(i+=$a(r[a-1],a,t);s.length>o&&s[o].lineNum===a;){const c=s[o++];i+=hs(c,r,c.lineNum,{...t,inlineSource:!1})}for(;s.length>o;){const a=s[o++];i+=hs(a,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(const a of n)i+=hs(a,r,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return i}}function hs(n,e,t,i){if(i!=null&&i.inlineSource){const s=om(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^
|
|
1
|
+
(function(he,Ne){typeof exports=="object"&&typeof module<"u"?Ne(exports):typeof define=="function"&&define.amd?define(["exports"],Ne):(he=typeof globalThis<"u"?globalThis:he||self,Ne(he.Cosmos={}))})(this,function(he){"use strict";var tb=Object.defineProperty;var nb=(he,Ne,Mt)=>Ne in he?tb(he,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Mt}):he[Ne]=Mt;var m=(he,Ne,Mt)=>nb(he,typeof Ne!="symbol"?Ne+"":Ne,Mt);var Ne="http://www.w3.org/1999/xhtml";const Mt={svg:"http://www.w3.org/2000/svg",xhtml:Ne,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ai(n){var e=n+="",t=e.indexOf(":");return t>=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),Mt.hasOwnProperty(e)?{space:Mt[e],local:n}:n}function Vu(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Ne&&e.documentElement.namespaceURI===Ne?e.createElement(n):e.createElementNS(t,n)}}function Hu(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Uo(n){var e=ai(n);return(e.local?Hu:Vu)(e)}function Wu(){}function Vr(n){return n==null?Wu:function(){return this.querySelector(n)}}function $u(n){typeof n!="function"&&(n=Vr(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=new Array(o),l,c,u=0;u<o;++u)(l=s[u])&&(c=n.call(l,l.__data__,u,s))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new Xe(i,this._parents)}function Xu(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function Yu(){return[]}function zo(n){return n==null?Yu:function(){return this.querySelectorAll(n)}}function qu(n){return function(){return Xu(n.apply(this,arguments))}}function ju(n){typeof n=="function"?n=qu(n):n=zo(n);for(var e=this._groups,t=e.length,i=[],r=[],s=0;s<t;++s)for(var o=e[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(i.push(n.call(l,l.__data__,c,o)),r.push(l));return new Xe(i,r)}function Lo(n){return function(){return this.matches(n)}}function Vo(n){return function(e){return e.matches(n)}}var Ku=Array.prototype.find;function Zu(n){return function(){return Ku.call(this.children,n)}}function Qu(){return this.firstElementChild}function Ju(n){return this.select(n==null?Qu:Zu(typeof n=="function"?n:Vo(n)))}var Gu=Array.prototype.filter;function ef(){return Array.from(this.children)}function tf(n){return function(){return Gu.call(this.children,n)}}function nf(n){return this.selectAll(n==null?ef:tf(typeof n=="function"?n:Vo(n)))}function rf(n){typeof n!="function"&&(n=Lo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new Xe(i,this._parents)}function Ho(n){return new Array(n.length)}function sf(){return new Xe(this._enter||this._groups.map(Ho),this._parents)}function li(n,e){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=e}li.prototype={constructor:li,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,e){return this._parent.insertBefore(n,e)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function of(n){return function(){return n}}function af(n,e,t,i,r,s){for(var o=0,a,l=e.length,c=s.length;o<c;++o)(a=e[o])?(a.__data__=s[o],i[o]=a):t[o]=new li(n,s[o]);for(;o<l;++o)(a=e[o])&&(r[o]=a)}function lf(n,e,t,i,r,s,o){var a,l,c=new Map,u=e.length,f=s.length,h=new Array(u),d;for(a=0;a<u;++a)(l=e[a])&&(h[a]=d=o.call(l,l.__data__,a,e)+"",c.has(d)?r[a]=l:c.set(d,l));for(a=0;a<f;++a)d=o.call(n,s[a],a,s)+"",(l=c.get(d))?(i[a]=l,l.__data__=s[a],c.delete(d)):t[a]=new li(n,s[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(h[a])===l&&(r[a]=l)}function cf(n){return n.__data__}function uf(n,e){if(!arguments.length)return Array.from(this,cf);var t=e?lf:af,i=this._parents,r=this._groups;typeof n!="function"&&(n=of(n));for(var s=r.length,o=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var u=i[c],f=r[c],h=f.length,d=ff(n.call(u,u&&u.__data__,c,i)),_=d.length,I=a[c]=new Array(_),C=o[c]=new Array(_),w=l[c]=new Array(h);t(u,f,I,C,w,d,e);for(var M=0,E=0,x,R;M<_;++M)if(x=I[M]){for(M>=E&&(E=M+1);!(R=C[E])&&++E<_;);x._next=R||null}}return o=new Xe(o,i),o._enter=a,o._exit=l,o}function ff(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function hf(){return new Xe(this._exit||this._groups.map(Ho),this._parents)}function df(n,e,t){var i=this.enter(),r=this,s=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?s.remove():t(s),i&&r?i.merge(r).order():r}function pf(n){for(var e=n.selection?n.selection():n,t=this._groups,i=e._groups,r=t.length,s=i.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=i[l],f=c.length,h=a[l]=new Array(f),d,_=0;_<f;++_)(d=c[_]||u[_])&&(h[_]=d);for(;l<r;++l)a[l]=t[l];return new Xe(a,this._parents)}function mf(){for(var n=this._groups,e=-1,t=n.length;++e<t;)for(var i=n[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function gf(n){n||(n=_f);function e(f,h){return f&&h?n(f.__data__,h.__data__):!f-!h}for(var t=this._groups,i=t.length,r=new Array(i),s=0;s<i;++s){for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new Xe(r,this._parents).order()}function _f(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function xf(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function yf(){return Array.from(this)}function vf(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function bf(){let n=0;for(const e of this)++n;return n}function Sf(){return!this.node()}function Tf(n){for(var e=this._groups,t=0,i=e.length;t<i;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&n.call(a,a.__data__,s,r);return this}function wf(n){return function(){this.removeAttribute(n)}}function Af(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Cf(n,e){return function(){this.setAttribute(n,e)}}function Pf(n,e){return function(){this.setAttributeNS(n.space,n.local,e)}}function If(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(n):this.setAttribute(n,t)}}function Rf(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}function Ef(n,e){var t=ai(n);if(arguments.length<2){var i=this.node();return t.local?i.getAttributeNS(t.space,t.local):i.getAttribute(t)}return this.each((e==null?t.local?Af:wf:typeof e=="function"?t.local?Rf:If:t.local?Pf:Cf)(t,e))}function Wo(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function kf(n){return function(){this.style.removeProperty(n)}}function Df(n,e,t){return function(){this.style.setProperty(n,e,t)}}function Ff(n,e,t){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,t)}}function Mf(n,e,t){return arguments.length>1?this.each((e==null?kf:typeof e=="function"?Ff:Df)(n,e,t??"")):Qt(this.node(),n)}function Qt(n,e){return n.style.getPropertyValue(e)||Wo(n).getComputedStyle(n,null).getPropertyValue(e)}function Nf(n){return function(){delete this[n]}}function Of(n,e){return function(){this[n]=e}}function Bf(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function Uf(n,e){return arguments.length>1?this.each((e==null?Nf:typeof e=="function"?Bf:Of)(n,e)):this.node()[n]}function $o(n){return n.trim().split(/^|\s+/)}function Hr(n){return n.classList||new Xo(n)}function Xo(n){this._node=n,this._names=$o(n.getAttribute("class")||"")}Xo.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Yo(n,e){for(var t=Hr(n),i=-1,r=e.length;++i<r;)t.add(e[i])}function qo(n,e){for(var t=Hr(n),i=-1,r=e.length;++i<r;)t.remove(e[i])}function zf(n){return function(){Yo(this,n)}}function Lf(n){return function(){qo(this,n)}}function Vf(n,e){return function(){(e.apply(this,arguments)?Yo:qo)(this,n)}}function Hf(n,e){var t=$o(n+"");if(arguments.length<2){for(var i=Hr(this.node()),r=-1,s=t.length;++r<s;)if(!i.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?Vf:e?zf:Lf)(t,e))}function Wf(){this.textContent=""}function $f(n){return function(){this.textContent=n}}function Xf(n){return function(){var e=n.apply(this,arguments);this.textContent=e??""}}function Yf(n){return arguments.length?this.each(n==null?Wf:(typeof n=="function"?Xf:$f)(n)):this.node().textContent}function qf(){this.innerHTML=""}function jf(n){return function(){this.innerHTML=n}}function Kf(n){return function(){var e=n.apply(this,arguments);this.innerHTML=e??""}}function Zf(n){return arguments.length?this.each(n==null?qf:(typeof n=="function"?Kf:jf)(n)):this.node().innerHTML}function Qf(){this.nextSibling&&this.parentNode.appendChild(this)}function Jf(){return this.each(Qf)}function Gf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eh(){return this.each(Gf)}function th(n){var e=typeof n=="function"?n:Uo(n);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nh(){return null}function ih(n,e){var t=typeof n=="function"?n:Uo(n),i=e==null?nh:typeof e=="function"?e:Vr(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),i.apply(this,arguments)||null)})}function rh(){var n=this.parentNode;n&&n.removeChild(this)}function sh(){return this.each(rh)}function oh(){var n=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function ah(){var n=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function lh(n){return this.select(n?ah:oh)}function ch(n){return arguments.length?this.property("__data__",n):this.node().__data__}function uh(n){return function(e){n.call(this,e,this.__data__)}}function fh(n){return n.trim().split(/^|\s+/).map(function(e){var t="",i=e.indexOf(".");return i>=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function hh(n){return function(){var e=this.__on;if(e){for(var t=0,i=-1,r=e.length,s;t<r;++t)s=e[t],(!n.type||s.type===n.type)&&s.name===n.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function dh(n,e,t){return function(){var i=this.__on,r,s=uh(e);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=t),r.value=e;return}}this.addEventListener(n.type,s,t),r={type:n.type,name:n.name,value:e,listener:s,options:t},i?i.push(r):this.__on=[r]}}function ph(n,e,t){var i=fh(n+""),r,s=i.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(r=0,u=a[l];r<s;++r)if((o=i[r]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?dh:hh,r=0;r<s;++r)this.each(a(i[r],e,t));return this}function jo(n,e,t){var i=Wo(n),r=i.CustomEvent;typeof r=="function"?r=new r(e,t):(r=i.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),n.dispatchEvent(r)}function mh(n,e){return function(){return jo(this,n,e)}}function gh(n,e){return function(){return jo(this,n,e.apply(this,arguments))}}function _h(n,e){return this.each((typeof e=="function"?gh:mh)(n,e))}function*xh(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Ko=[null];function Xe(n,e){this._groups=n,this._parents=e}function wn(){return new Xe([[document.documentElement]],Ko)}function yh(){return this}Xe.prototype=wn.prototype={constructor:Xe,select:$u,selectAll:ju,selectChild:Ju,selectChildren:nf,filter:rf,data:uf,enter:sf,exit:hf,join:df,merge:pf,selection:yh,order:mf,sort:gf,call:xf,nodes:yf,node:vf,size:bf,empty:Sf,each:Tf,attr:Ef,style:Mf,property:Uf,classed:Hf,text:Yf,html:Zf,raise:Jf,lower:eh,append:th,insert:ih,remove:sh,clone:lh,datum:ch,on:ph,dispatch:_h,[Symbol.iterator]:xh};function Se(n){return typeof n=="string"?new Xe([[document.querySelector(n)]],[document.documentElement]):new Xe([[n]],Ko)}function vh(n){let e;for(;e=n.sourceEvent;)n=e;return n}function gt(n,e){if(n=vh(n),e===void 0&&(e=n.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var i=t.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[n.clientX-r.left-e.clientLeft,n.clientY-r.top-e.clientTop]}}return[n.pageX,n.pageY]}var bh={value:()=>{}};function ci(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new ui(t)}function ui(n){this._=n}function Sh(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}ui.prototype=ci.prototype={constructor:ui,on:function(n,e){var t=this._,i=Sh(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(n=i[s]).type)&&(r=Th(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(n=i[s]).type)t[r]=Zo(t[r],n.name,e);else if(e==null)for(r in t)t[r]=Zo(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new ui(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function Th(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function Zo(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=bh,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var Jt=0,An=0,Cn=0,Qo=1e3,fi,Pn,hi=0,Nt=0,di=0,In=typeof performance=="object"&&performance.now?performance:Date,Jo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Wr(){return Nt||(Jo(wh),Nt=In.now()+di)}function wh(){Nt=0}function pi(){this._call=this._time=this._next=null}pi.prototype=Go.prototype={constructor:pi,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Wr():+t)+(e==null?0:+e),!this._next&&Pn!==this&&(Pn?Pn._next=this:fi=this,Pn=this),this._call=n,this._time=t,$r()},stop:function(){this._call&&(this._call=null,this._time=1/0,$r())}};function Go(n,e,t){var i=new pi;return i.restart(n,e,t),i}function Ah(){Wr(),++Jt;for(var n=fi,e;n;)(e=Nt-n._time)>=0&&n._call.call(null,e),n=n._next;--Jt}function ea(){Nt=(hi=In.now())+di,Jt=An=0;try{Ah()}finally{Jt=0,Ph(),Nt=0}}function Ch(){var n=In.now(),e=n-hi;e>Qo&&(di-=e,hi=n)}function Ph(){for(var n,e=fi,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:fi=t);Pn=n,$r(i)}function $r(n){if(!Jt){An&&(An=clearTimeout(An));var e=n-Nt;e>24?(n<1/0&&(An=setTimeout(ea,n-In.now()-di)),Cn&&(Cn=clearInterval(Cn))):(Cn||(hi=In.now(),Cn=setInterval(Ch,Qo)),Jt=1,Jo(ea))}}function ta(n,e,t){var i=new pi;return e=e==null?0:+e,i.restart(r=>{i.stop(),n(r+e)},e,t),i}var Ih=ci("start","end","cancel","interrupt"),Rh=[],na=0,ia=1,Xr=2,mi=3,ra=4,Yr=5,gi=6;function _i(n,e,t,i,r,s){var o=n.__transition;if(!o)n.__transition={};else if(t in o)return;Eh(n,t,{name:e,index:i,group:r,on:Ih,tween:Rh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:na})}function qr(n,e){var t=et(n,e);if(t.state>na)throw new Error("too late; already scheduled");return t}function lt(n,e){var t=et(n,e);if(t.state>mi)throw new Error("too late; already running");return t}function et(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Eh(n,e,t){var i=n.__transition,r;i[e]=t,t.timer=Go(s,0,t.time);function s(c){t.state=ia,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,f,h,d;if(t.state!==ia)return l();for(u in i)if(d=i[u],d.name===t.name){if(d.state===mi)return ta(o);d.state===ra?(d.state=gi,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[u]):+u<e&&(d.state=gi,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[u])}if(ta(function(){t.state===mi&&(t.state=ra,t.timer.restart(a,t.delay,t.time),a(c))}),t.state=Xr,t.on.call("start",n,n.__data__,t.index,t.group),t.state===Xr){for(t.state=mi,r=new Array(h=t.tween.length),u=0,f=-1;u<h;++u)(d=t.tween[u].value.call(n,n.__data__,t.index,t.group))&&(r[++f]=d);r.length=f+1}}function a(c){for(var u=c<t.duration?t.ease.call(null,c/t.duration):(t.timer.restart(l),t.state=Yr,1),f=-1,h=r.length;++f<h;)r[f].call(n,u);t.state===Yr&&(t.on.call("end",n,n.__data__,t.index,t.group),l())}function l(){t.state=gi,t.timer.stop(),delete i[e];for(var c in i)return;delete n.__transition}}function xi(n,e){var t=n.__transition,i,r,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((i=t[o]).name!==e){s=!1;continue}r=i.state>Xr&&i.state<Yr,i.state=gi,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete t[o]}s&&delete n.__transition}}function kh(n){return this.each(function(){xi(this,n)})}function jr(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function sa(n,e){var t=Object.create(n.prototype);for(var i in e)t[i]=e[i];return t}function Rn(){}var En=.7,yi=1/En,Gt="\\s*([+-]?\\d+)\\s*",kn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ct="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Dh=/^#([0-9a-f]{3,8})$/,Fh=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Mh=new RegExp(`^rgb\\(${ct},${ct},${ct}\\)$`),Nh=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${kn}\\)$`),Oh=new RegExp(`^rgba\\(${ct},${ct},${ct},${kn}\\)$`),Bh=new RegExp(`^hsl\\(${kn},${ct},${ct}\\)$`),Uh=new RegExp(`^hsla\\(${kn},${ct},${ct},${kn}\\)$`),oa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};jr(Rn,It,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:zh,formatHsl:Lh,formatRgb:la,toString:la});function aa(){return this.rgb().formatHex()}function zh(){return this.rgb().formatHex8()}function Lh(){return da(this).formatHsl()}function la(){return this.rgb().formatRgb()}function It(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=Dh.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?ca(e):t===3?new He(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?vi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?vi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Fh.exec(n))?new He(e[1],e[2],e[3],1):(e=Mh.exec(n))?new He(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Nh.exec(n))?vi(e[1],e[2],e[3],e[4]):(e=Oh.exec(n))?vi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Bh.exec(n))?ha(e[1],e[2]/100,e[3]/100,1):(e=Uh.exec(n))?ha(e[1],e[2]/100,e[3]/100,e[4]):oa.hasOwnProperty(n)?ca(oa[n]):n==="transparent"?new He(NaN,NaN,NaN,0):null}function ca(n){return new He(n>>16&255,n>>8&255,n&255,1)}function vi(n,e,t,i){return i<=0&&(n=e=t=NaN),new He(n,e,t,i)}function Vh(n){return n instanceof Rn||(n=It(n)),n?(n=n.rgb(),new He(n.r,n.g,n.b,n.opacity)):new He}function Kr(n,e,t,i){return arguments.length===1?Vh(n):new He(n,e,t,i??1)}function He(n,e,t,i){this.r=+n,this.g=+e,this.b=+t,this.opacity=+i}jr(He,Kr,sa(Rn,{brighter(n){return n=n==null?yi:Math.pow(yi,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?En:Math.pow(En,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new He(Ot(this.r),Ot(this.g),Ot(this.b),bi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ua,formatHex:ua,formatHex8:Hh,formatRgb:fa,toString:fa}));function ua(){return`#${Bt(this.r)}${Bt(this.g)}${Bt(this.b)}`}function Hh(){return`#${Bt(this.r)}${Bt(this.g)}${Bt(this.b)}${Bt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fa(){const n=bi(this.opacity);return`${n===1?"rgb(":"rgba("}${Ot(this.r)}, ${Ot(this.g)}, ${Ot(this.b)}${n===1?")":`, ${n})`}`}function bi(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Ot(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function Bt(n){return n=Ot(n),(n<16?"0":"")+n.toString(16)}function ha(n,e,t,i){return i<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new tt(n,e,t,i)}function da(n){if(n instanceof tt)return new tt(n.h,n.s,n.l,n.opacity);if(n instanceof Rn||(n=It(n)),!n)return new tt;if(n instanceof tt)return n;n=n.rgb();var e=n.r/255,t=n.g/255,i=n.b/255,r=Math.min(e,t,i),s=Math.max(e,t,i),o=NaN,a=s-r,l=(s+r)/2;return a?(e===s?o=(t-i)/a+(t<i)*6:t===s?o=(i-e)/a+2:o=(e-t)/a+4,a/=l<.5?s+r:2-s-r,o*=60):a=l>0&&l<1?0:o,new tt(o,a,l,n.opacity)}function Wh(n,e,t,i){return arguments.length===1?da(n):new tt(n,e,t,i??1)}function tt(n,e,t,i){this.h=+n,this.s=+e,this.l=+t,this.opacity=+i}jr(tt,Wh,sa(Rn,{brighter(n){return n=n==null?yi:Math.pow(yi,n),new tt(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?En:Math.pow(En,n),new tt(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,r=2*t-i;return new He(Zr(n>=240?n-240:n+120,r,i),Zr(n,r,i),Zr(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new tt(pa(this.h),Si(this.s),Si(this.l),bi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=bi(this.opacity);return`${n===1?"hsl(":"hsla("}${pa(this.h)}, ${Si(this.s)*100}%, ${Si(this.l)*100}%${n===1?")":`, ${n})`}`}}));function pa(n){return n=(n||0)%360,n<0?n+360:n}function Si(n){return Math.max(0,Math.min(1,n||0))}function Zr(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const Qr=n=>()=>n;function $h(n,e){return function(t){return n+t*e}}function Xh(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(i){return Math.pow(n+i*e,t)}}function Yh(n){return(n=+n)==1?ma:function(e,t){return t-e?Xh(e,t,n):Qr(isNaN(e)?t:e)}}function ma(n,e){var t=e-n;return t?$h(n,t):Qr(isNaN(n)?e:n)}const Ti=function n(e){var t=Yh(e);function i(r,s){var o=t((r=Kr(r)).r,(s=Kr(s)).r),a=t(r.g,s.g),l=t(r.b,s.b),c=ma(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=l(u),r.opacity=c(u),r+""}}return i.gamma=n,i}(1);function qh(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,i=e.slice(),r;return function(s){for(r=0;r<t;++r)i[r]=n[r]*(1-s)+e[r]*s;return i}}function jh(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Kh(n,e){var t=e?e.length:0,i=n?Math.min(t,n.length):0,r=new Array(i),s=new Array(t),o;for(o=0;o<i;++o)r[o]=es(n[o],e[o]);for(;o<t;++o)s[o]=e[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function Zh(n,e){var t=new Date;return n=+n,e=+e,function(i){return t.setTime(n*(1-i)+e*i),t}}function nt(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function Qh(n,e){var t={},i={},r;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in n?t[r]=es(n[r],e[r]):i[r]=e[r];return function(s){for(r in t)i[r]=t[r](s);return i}}var Jr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gr=new RegExp(Jr.source,"g");function Jh(n){return function(){return n}}function Gh(n){return function(e){return n(e)+""}}function ga(n,e){var t=Jr.lastIndex=Gr.lastIndex=0,i,r,s,o=-1,a=[],l=[];for(n=n+"",e=e+"";(i=Jr.exec(n))&&(r=Gr.exec(e));)(s=r.index)>t&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:nt(i,r)})),t=Gr.lastIndex;return t<e.length&&(s=e.slice(t),a[o]?a[o]+=s:a[++o]=s),a.length<2?l[0]?Gh(l[0].x):Jh(e):(e=l.length,function(c){for(var u=0,f;u<e;++u)a[(f=l[u]).i]=f.x(c);return a.join("")})}function es(n,e){var t=typeof e,i;return e==null||t==="boolean"?Qr(e):(t==="number"?nt:t==="string"?(i=It(e))?(e=i,Ti):ga:e instanceof It?Ti:e instanceof Date?Zh:jh(e)?qh:Array.isArray(e)?Kh:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Qh:nt)(n,e)}function ed(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}var _a=180/Math.PI,ts={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xa(n,e,t,i,r,s){var o,a,l;return(o=Math.sqrt(n*n+e*e))&&(n/=o,e/=o),(l=n*t+e*i)&&(t-=n*l,i-=e*l),(a=Math.sqrt(t*t+i*i))&&(t/=a,i/=a,l/=a),n*i<e*t&&(n=-n,e=-e,l=-l,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,n)*_a,skewX:Math.atan(l)*_a,scaleX:o,scaleY:a}}var wi;function td(n){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return e.isIdentity?ts:xa(e.a,e.b,e.c,e.d,e.e,e.f)}function nd(n){return n==null||(wi||(wi=document.createElementNS("http://www.w3.org/2000/svg","g")),wi.setAttribute("transform",n),!(n=wi.transform.baseVal.consolidate()))?ts:(n=n.matrix,xa(n.a,n.b,n.c,n.d,n.e,n.f))}function ya(n,e,t,i){function r(c){return c.length?c.pop()+" ":""}function s(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push("translate(",null,e,null,t);_.push({i:I-4,x:nt(c,f)},{i:I-2,x:nt(u,h)})}else(f||h)&&d.push("translate("+f+e+h+t)}function o(c,u,f,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:nt(c,u)})):u&&f.push(r(f)+"rotate("+u+i)}function a(c,u,f,h){c!==u?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:nt(c,u)}):u&&f.push(r(f)+"skewX("+u+i)}function l(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push(r(d)+"scale(",null,",",null,")");_.push({i:I-4,x:nt(c,f)},{i:I-2,x:nt(u,h)})}else(f!==1||h!==1)&&d.push(r(d)+"scale("+f+","+h+")")}return function(c,u){var f=[],h=[];return c=n(c),u=n(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,h),o(c.rotate,u.rotate,f,h),a(c.skewX,u.skewX,f,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,h),c=u=null,function(d){for(var _=-1,I=h.length,C;++_<I;)f[(C=h[_]).i]=C.x(d);return f.join("")}}}var id=ya(td,"px, ","px)","deg)"),rd=ya(nd,", ",")",")"),sd=1e-12;function va(n){return((n=Math.exp(n))+1/n)/2}function od(n){return((n=Math.exp(n))-1/n)/2}function ad(n){return((n=Math.exp(2*n))-1)/(n+1)}const ld=function n(e,t,i){function r(s,o){var a=s[0],l=s[1],c=s[2],u=o[0],f=o[1],h=o[2],d=u-a,_=f-l,I=d*d+_*_,C,w;if(I<sd)w=Math.log(h/c)/e,C=function(L){return[a+L*d,l+L*_,c*Math.exp(e*L*w)]};else{var M=Math.sqrt(I),E=(h*h-c*c+i*I)/(2*c*t*M),x=(h*h-c*c-i*I)/(2*h*t*M),R=Math.log(Math.sqrt(E*E+1)-E),O=Math.log(Math.sqrt(x*x+1)-x);w=(O-R)/e,C=function(L){var W=L*w,q=va(R),Q=c/(t*M)*(q*ad(e*W+R)-od(R));return[a+Q*d,l+Q*_,c*q/va(e*W+R)]}}return C.duration=w*1e3*e/Math.SQRT2,C}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,l=a*a;return n(o,a,l)},r}(Math.SQRT2,2,4);function cd(n,e){var t,i;return function(){var r=lt(this,n),s=r.tween;if(s!==t){i=t=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function ud(n,e,t){var i,r;if(typeof t!="function")throw new Error;return function(){var s=lt(this,n),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:e,value:t},l=0,c=r.length;l<c;++l)if(r[l].name===e){r[l]=a;break}l===c&&r.push(a)}s.tween=r}}function fd(n,e){var t=this._id;if(n+="",arguments.length<2){for(var i=et(this.node(),t).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===n)return o.value;return null}return this.each((e==null?cd:ud)(t,n,e))}function ns(n,e,t){var i=n._id;return n.each(function(){var r=lt(this,i);(r.value||(r.value={}))[e]=t.apply(this,arguments)}),function(r){return et(r,i).value[e]}}function ba(n,e){var t;return(typeof e=="number"?nt:e instanceof It?Ti:(t=It(e))?(e=t,Ti):ga)(n,e)}function hd(n){return function(){this.removeAttribute(n)}}function dd(n){return function(){this.removeAttributeNS(n.space,n.local)}}function pd(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttribute(n);return o===r?null:o===i?s:s=e(i=o,t)}}function md(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttributeNS(n.space,n.local);return o===r?null:o===i?s:s=e(i=o,t)}}function gd(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(n):(o=this.getAttribute(n),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function _d(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(n.space,n.local):(o=this.getAttributeNS(n.space,n.local),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function xd(n,e){var t=ai(n),i=t==="transform"?rd:ba;return this.attrTween(n,typeof e=="function"?(t.local?_d:gd)(t,i,ns(this,"attr."+n,e)):e==null?(t.local?dd:hd)(t):(t.local?md:pd)(t,i,e))}function yd(n,e){return function(t){this.setAttribute(n,e.call(this,t))}}function vd(n,e){return function(t){this.setAttributeNS(n.space,n.local,e.call(this,t))}}function bd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&vd(n,s)),t}return r._value=e,r}function Sd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&yd(n,s)),t}return r._value=e,r}function Td(n,e){var t="attr."+n;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var i=ai(n);return this.tween(t,(i.local?bd:Sd)(i,e))}function wd(n,e){return function(){qr(this,n).delay=+e.apply(this,arguments)}}function Ad(n,e){return e=+e,function(){qr(this,n).delay=e}}function Cd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?wd:Ad)(e,n)):et(this.node(),e).delay}function Pd(n,e){return function(){lt(this,n).duration=+e.apply(this,arguments)}}function Id(n,e){return e=+e,function(){lt(this,n).duration=e}}function Rd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?Pd:Id)(e,n)):et(this.node(),e).duration}function Ed(n,e){if(typeof e!="function")throw new Error;return function(){lt(this,n).ease=e}}function kd(n){var e=this._id;return arguments.length?this.each(Ed(e,n)):et(this.node(),e).ease}function Dd(n,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;lt(this,n).ease=t}}function Fd(n){if(typeof n!="function")throw new Error;return this.each(Dd(this._id,n))}function Md(n){typeof n!="function"&&(n=Lo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new _t(i,this._parents,this._name,this._id)}function Nd(n){if(n._id!==this._id)throw new Error;for(var e=this._groups,t=n._groups,i=e.length,r=t.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var l=e[a],c=t[a],u=l.length,f=o[a]=new Array(u),h,d=0;d<u;++d)(h=l[d]||c[d])&&(f[d]=h);for(;a<i;++a)o[a]=e[a];return new _t(o,this._parents,this._name,this._id)}function Od(n){return(n+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Bd(n,e,t){var i,r,s=Od(e)?qr:lt;return function(){var o=s(this,n),a=o.on;a!==i&&(r=(i=a).copy()).on(e,t),o.on=r}}function Ud(n,e){var t=this._id;return arguments.length<2?et(this.node(),t).on.on(n):this.each(Bd(t,n,e))}function zd(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Ld(){return this.on("end.remove",zd(this._id))}function Vd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=Vr(n));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],l=a.length,c=s[o]=new Array(l),u,f,h=0;h<l;++h)(u=a[h])&&(f=n.call(u,u.__data__,h,a))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,_i(c[h],e,t,h,c,et(u,t)));return new _t(s,this._parents,e,t)}function Hd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=zo(n));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var l=i[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var h=n.call(u,u.__data__,f,l),d,_=et(u,t),I=0,C=h.length;I<C;++I)(d=h[I])&&_i(d,e,t,I,h,_);s.push(h),o.push(u)}return new _t(s,o,e,t)}var Wd=wn.prototype.constructor;function $d(){return new Wd(this._groups,this._parents)}function Xd(n,e){var t,i,r;return function(){var s=Qt(this,n),o=(this.style.removeProperty(n),Qt(this,n));return s===o?null:s===t&&o===i?r:r=e(t=s,i=o)}}function Sa(n){return function(){this.style.removeProperty(n)}}function Yd(n,e,t){var i,r=t+"",s;return function(){var o=Qt(this,n);return o===r?null:o===i?s:s=e(i=o,t)}}function qd(n,e,t){var i,r,s;return function(){var o=Qt(this,n),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(n),Qt(this,n))),o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a))}}function jd(n,e){var t,i,r,s="style."+e,o="end."+s,a;return function(){var l=lt(this,n),c=l.on,u=l.value[s]==null?a||(a=Sa(e)):void 0;(c!==t||r!==u)&&(i=(t=c).copy()).on(o,r=u),l.on=i}}function Kd(n,e,t){var i=(n+="")=="transform"?id:ba;return e==null?this.styleTween(n,Xd(n,i)).on("end.style."+n,Sa(n)):typeof e=="function"?this.styleTween(n,qd(n,i,ns(this,"style."+n,e))).each(jd(this._id,n)):this.styleTween(n,Yd(n,i,e),t).on("end.style."+n,null)}function Zd(n,e,t){return function(i){this.style.setProperty(n,e.call(this,i),t)}}function Qd(n,e,t){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&Zd(n,o,t)),i}return s._value=e,s}function Jd(n,e,t){var i="style."+(n+="");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;return this.tween(i,Qd(n,e,t??""))}function Gd(n){return function(){this.textContent=n}}function ep(n){return function(){var e=n(this);this.textContent=e??""}}function tp(n){return this.tween("text",typeof n=="function"?ep(ns(this,"text",n)):Gd(n==null?"":n+""))}function np(n){return function(e){this.textContent=n.call(this,e)}}function ip(n){var e,t;function i(){var r=n.apply(this,arguments);return r!==t&&(e=(t=r)&&np(r)),e}return i._value=n,i}function rp(n){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(n==null)return this.tween(e,null);if(typeof n!="function")throw new Error;return this.tween(e,ip(n))}function sp(){for(var n=this._name,e=this._id,t=Ta(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=et(l,e);_i(l,n,t,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new _t(i,this._parents,n,t)}function op(){var n,e,t=this,i=t._id,r=t.size();return new Promise(function(s,o){var a={value:o},l={value:function(){--r===0&&s()}};t.each(function(){var c=lt(this,i),u=c.on;u!==n&&(e=(n=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),r===0&&s()})}var ap=0;function _t(n,e,t,i){this._groups=n,this._parents=e,this._name=t,this._id=i}function Ta(){return++ap}var xt=wn.prototype;_t.prototype={constructor:_t,select:Vd,selectAll:Hd,selectChild:xt.selectChild,selectChildren:xt.selectChildren,filter:Md,merge:Nd,selection:$d,transition:sp,call:xt.call,nodes:xt.nodes,node:xt.node,size:xt.size,empty:xt.empty,each:xt.each,on:Ud,attr:xd,attrTween:Td,style:Kd,styleTween:Jd,text:tp,textTween:rp,remove:Ld,tween:fd,delay:Cd,duration:Rd,ease:kd,easeVarying:Fd,end:op,[Symbol.iterator]:xt[Symbol.iterator]};function lp(n){return n*n}function cp(n){return n*(2-n)}function up(n){return((n*=2)<=1?n*n:--n*(2-n)+1)/2}function fp(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var hp={time:null,delay:0,duration:250,ease:fp};function dp(n,e){for(var t;!(t=n.__transition)||!(t=t[e]);)if(!(n=n.parentNode))throw new Error(`transition ${e} not found`);return t}function pp(n){var e,t;n instanceof _t?(e=n._id,n=n._name):(e=Ta(),(t=hp).time=Wr(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&_i(l,n,e,c,o,t||dp(l,e));return new _t(i,this._parents,n,e)}wn.prototype.interrupt=kh,wn.prototype.transition=pp;function wa(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}class Aa{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=wa(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(wa()-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 mp{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:i}=e;let r=this.stats[t];return r||(e instanceof Aa?r=e:r=new Aa(t,i),this.stats[t]=r),r}}class gp{constructor(){m(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new mp({id:e})),this.stats.get(e)}}const Ca=new gp,Ai=globalThis,en=globalThis.process||{},_p=globalThis.navigator||{};function Pa(n){var i,r;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((r=process.versions)!=null&&r.electron))return!0;const t=typeof navigator<"u"&&navigator.userAgent;return!!(t&&t.indexOf("Electron")>=0)}function Ut(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||Pa()}function xp(n){return Ut()?Pa()?"Electron":(_p.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const Ia="4.1.0";function yp(n){try{const e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class vp{constructor(e,t,i="sessionStorage"){this.storage=yp(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function bp(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Sp(n,e=8){const t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Ci;(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ci||(Ci={}));const Tp=10;function Ra(n){return typeof n!="string"?n:(n=n.toUpperCase(),Ci[n]||Ci.WHITE)}function wp(n,e,t){return!Ut&&typeof n=="string"&&(e&&(n=`\x1B[${Ra(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Ra(t)+Tp}m${n}\x1B[49m`)),n}function Ap(n,e=["constructor"]){const t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(const s of i){const o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}function is(n,e){if(!n)throw new Error("Assertion failed")}function tn(){var e,t,i;let n;if(Ut()&&Ai.performance)n=(t=(e=Ai==null?void 0:Ai.performance)==null?void 0:e.now)==null?void 0:t.call(e);else if("hrtime"in en){const r=(i=en==null?void 0:en.hrtime)==null?void 0:i.call(en);n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}const nn={debug:Ut()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Cp={enabled:!0,level:0};function rn(){}const Ea={},ka={once:!0};class Da{constructor({id:e}={id:""}){this.VERSION=Ia,this._startTs=tn(),this._deltaTs=tn(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new vp(`__probe-${this.id}__`,Cp),this.timeStamp(`${this.id} started`),Ap(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((tn()-this._startTs).toPrecision(10))}getDelta(){return Number((tn()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,nn.warn,arguments,ka)}error(e){return this._getLogFunction(0,e,nn.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,nn.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,nn.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,nn.debug||nn.info,arguments,ka)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||rn,i&&[i],{tag:Ip(t)}):rn}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||rn)}group(e,t,i={collapsed:!1}){const r=Ma({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return r.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||rn)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Fa(e)}_getLogFunction(e,t,i,r,s){if(this._shouldLog(e)){s=Ma({logLevel:e,message:t,args:r,opts:s}),i=i||s.method,is(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=tn();const o=s.tag||s.message;if(s.once&&o)if(!Ea[o])Ea[o]=tn();else return rn;return t=Pp(this.id,s.message,s),i.bind(console,t,...s.args)}return rn}}Da.VERSION=Ia;function Fa(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return is(Number.isFinite(e)&&e>=0),e}function Ma(n){const{logLevel:e,message:t}=n;n.logLevel=Fa(e);const i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break}typeof n.message=="function"&&(n.message=n.message());const r=typeof n.message;return is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}function Pp(n,e,t){if(typeof e=="string"){const i=t.time?Sp(bp(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=wp(e,t.color,t.background)}return e}function Ip(n){for(const e in n)for(const t in n[e])return t||"untitled";return"empty"}const D=new Da({id:"luma.gl"}),rs={};function Pi(n="id"){rs[n]=rs[n]||1;const e=rs[n]++;return`${n}-${e}`}class oe{constructor(e,t,i){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"_device");m(this,"destroyed",!1);m(this,"allocatedBytes",0);m(this,"_attachedResources",new Set);if(!e)throw new Error("no device");this._device=e,this.props=Rp(t,i);const r=this.props.id!=="undefined"?this.props.id:Pi(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}m(oe,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Rp(n,e){const t={...e};for(const i in n)n[i]!==void 0&&(t[i]=n[i]);return t}const Re=class Re extends oe{constructor(t,i){const r={...i};(i.usage||0)&Re.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?r.indexType="uint32":i.data instanceof Uint16Array&&(r.indexType="uint16")),delete r.data;super(t,r,Re.defaultProps);m(this,"usage");m(this,"indexType");m(this,"updateTimestamp");m(this,"debugData",new ArrayBuffer(0));this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(t){return this.device.createBuffer({...this.props,...t})}_setDebugData(t,i,r){const s=ArrayBuffer.isView(t)?t.buffer:t,o=Math.min(t?t.byteLength:r,Re.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):i===0&&r===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(i,i+o)}};m(Re,"INDEX",16),m(Re,"VERTEX",32),m(Re,"UNIFORM",64),m(Re,"STORAGE",128),m(Re,"INDIRECT",256),m(Re,"QUERY_RESOLVE",512),m(Re,"MAP_READ",1),m(Re,"MAP_WRITE",2),m(Re,"COPY_SRC",4),m(Re,"COPY_DST",8),m(Re,"DEBUG_DATA_MAX_LENGTH",32),m(Re,"defaultProps",{...oe.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let z=Re;function Na(n){const[e,t,i]=ss[n],r=n.includes("norm"),s=!r&&!n.startsWith("float"),o=n.startsWith("s");return{signedType:e,primitiveType:t,byteLength:i,normalized:r,integer:s,signed:o}}function Ep(n){const e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function kp(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Oa(n){const e=ArrayBuffer.isView(n)?n.constructor:n;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(ss).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function Ba(n){const[,,,,e]=ss[n];return e}const ss={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 os(n){let e;n.endsWith("-webgl")&&(n.replace("-webgl",""),e=!0);const[t,i]=n.split("x"),r=t,s=i?parseInt(i):1,o=Na(r),a={type:r,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function Dp(n,e,t){const i=t?Ep(n):n;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}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`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function Fp(n,e,t){if(!e||e>4)throw new Error(`size ${e}`);const i=e,r=Oa(n);return Dp(r,i,t)}function Mp(n){let e;switch(n.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?e:`${e}x${n.components}`}const Ee="texture-compression-bc",ae="texture-compression-astc",ut="texture-compression-etc2",Np="texture-compression-etc1-webgl",Ii="texture-compression-pvrtc-webgl",as="texture-compression-atc-webgl",Ri="float32-renderable-webgl",ls="float16-renderable-webgl",Op="rgb9e5ufloat-renderable-webgl",cs="snorm8-renderable-webgl",Dn="norm16-renderable-webgl",us="snorm16-renderable-webgl",Ei="float32-filterable",Ua="float16-filterable-webgl";function za(n){const e=Bp[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}const Bp={...{r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:cs},rg8snorm:{render:cs},"rgb8snorm-webgl":{},rgba8snorm:{render:cs},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Dn},rg16unorm:{render:Dn},"rgb16unorm-webgl":{f:Dn},rgba16unorm:{render:Dn},r16snorm:{f:us},rg16snorm:{render:us},"rgb16snorm-webgl":{f:Dn},rgba16snorm:{render:us},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:ls,filter:"float16-filterable-webgl"},rg16float:{render:ls,filter:Ua},rgba16float:{render:ls,filter:Ua},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Ri,filter:Ei},rg32float:{render:!1,filter:Ei},"rgb32float-webgl":{render:Ri,filter:Ei},rgba32float:{render:Ri,filter:Ei},"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:Op},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ri},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}},...{"bc1-rgb-unorm-webgl":{f:Ee},"bc1-rgb-unorm-srgb-webgl":{f:Ee},"bc1-rgba-unorm":{f:Ee},"bc1-rgba-unorm-srgb":{f:Ee},"bc2-rgba-unorm":{f:Ee},"bc2-rgba-unorm-srgb":{f:Ee},"bc3-rgba-unorm":{f:Ee},"bc3-rgba-unorm-srgb":{f:Ee},"bc4-r-unorm":{f:Ee},"bc4-r-snorm":{f:Ee},"bc5-rg-unorm":{f:Ee},"bc5-rg-snorm":{f:Ee},"bc6h-rgb-ufloat":{f:Ee},"bc6h-rgb-float":{f:Ee},"bc7-rgba-unorm":{f:Ee},"bc7-rgba-unorm-srgb":{f:Ee},"etc2-rgb8unorm":{f:ut},"etc2-rgb8unorm-srgb":{f:ut},"etc2-rgb8a1unorm":{f:ut},"etc2-rgb8a1unorm-srgb":{f:ut},"etc2-rgba8unorm":{f:ut},"etc2-rgba8unorm-srgb":{f:ut},"eac-r11unorm":{f:ut},"eac-r11snorm":{f:ut},"eac-rg11unorm":{f:ut},"eac-rg11snorm":{f:ut},"astc-4x4-unorm":{f:ae},"astc-4x4-unorm-srgb":{f:ae},"astc-5x4-unorm":{f:ae},"astc-5x4-unorm-srgb":{f:ae},"astc-5x5-unorm":{f:ae},"astc-5x5-unorm-srgb":{f:ae},"astc-6x5-unorm":{f:ae},"astc-6x5-unorm-srgb":{f:ae},"astc-6x6-unorm":{f:ae},"astc-6x6-unorm-srgb":{f:ae},"astc-8x5-unorm":{f:ae},"astc-8x5-unorm-srgb":{f:ae},"astc-8x6-unorm":{f:ae},"astc-8x6-unorm-srgb":{f:ae},"astc-8x8-unorm":{f:ae},"astc-8x8-unorm-srgb":{f:ae},"astc-10x5-unorm":{f:ae},"astc-10x5-unorm-srgb":{f:ae},"astc-10x6-unorm":{f:ae},"astc-10x6-unorm-srgb":{f:ae},"astc-10x8-unorm":{f:ae},"astc-10x8-unorm-srgb":{f:ae},"astc-10x10-unorm":{f:ae},"astc-10x10-unorm-srgb":{f:ae},"astc-12x10-unorm":{f:ae},"astc-12x10-unorm-srgb":{f:ae},"astc-12x12-unorm":{f:ae},"astc-12x12-unorm-srgb":{f:ae},"pvrtc-rgb4unorm-webgl":{f:Ii},"pvrtc-rgba4unorm-webgl":{f:Ii},"pvrtc-rbg2unorm-webgl":{f:Ii},"pvrtc-rgba2unorm-webgl":{f:Ii},"etc1-rbg-unorm-webgl":{f:Np},"atc-rgb-unorm-webgl":{f:as},"atc-rgba-unorm-webgl":{f:as},"atc-rgbai-unorm-webgl":{f:as}}},Up=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],zp=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class Lp{getInfo(e){return La(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 Up.some(t=>e.startsWith(t))}getCapabilities(e){const t=za(e),i={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=La(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=r==null?void 0:r.signed,a=r==null?void 0:r.integer,l=r==null?void 0:r.webgl;return i.render&&(i.render=!o),i.filter&&(i.filter=!s&&!o&&!a&&!l),i}}const sn=new Lp;function La(n){let e=Vp(n);if(sn.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const i=Hp(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}const t=zp.exec(n);if(t){const[,i,r,s,o,a]=t,l=`${s}${r}`,c=Na(l),u=c.byteLength*8,f=i.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:c.signedType,components:f,channels:i,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*i.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function Vp(n){var s;const e=za(n),t=e.bytesPerPixel||1,i=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:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||((s=e.channels)==null?void 0:s.length)||1,bytesPerPixel:t,bitsPerChannel:i,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 Hp(n){const t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){const[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return null}function Wp(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function $p(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}class Xp{}class Yp{constructor(e=[],t){m(this,"features");m(this,"disabledFeatures");this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const yr=class yr{constructor(e){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"statsManager",Ca);m(this,"timestamp",0);m(this,"_reused",!1);m(this,"_lumaData",{});m(this,"_textureCaps",{});this.props={...yr.defaultProps,...e},this.id=this.props.id||Pi(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return os(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return sn.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){const r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return Wp(e)}getExternalImageSize(e){return $p(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 sn.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:D.error(e.message,t,...i)}debug(){if(this.props.debug)debugger;else D.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
2
|
+
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=sn.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&z.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};m(yr,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[i,r]=e.getDevicePixelSize();D.log(1,`${e} resized => ${i}x${r}px`)()},onPositionChange:(e,t)=>{const[i,r]=e.getPosition();D.log(1,`${e} repositioned => ${i},${r}`)()},onVisibilityChange:e=>D.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>D.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:D.get("debug")||void 0,debugShaders:D.get("debug-shaders")||void 0,debugFramebuffers:!!D.get("debug-framebuffers"),debugFactories:!!D.get("debug-factories"),debugWebGL:!!D.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let zt=yr;const qp="set luma.log.level=1 (or higher) to trace rendering",Va="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ni=class ni{constructor(){m(this,"stats",Ca);m(this,"log",D);m(this,"VERSION","9.2.3");m(this,"spector");m(this,"preregisteredAdapters",new Map);if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw D.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),D.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");D.error("This version of luma.gl has already been initialized")()}D.log(1,`${this.VERSION} - ${qp}`)(),globalThis.luma=this}async createDevice(e={}){const t={...ni.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(Va);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){var s;const i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(Va);return await((s=r==null?void 0:r.attach)==null?void 0:s.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>{var r;return(r=i.isSupported)==null?void 0:r.call(i)}).map(i=>i.type)}getBestAvailableAdapterType(e=[]){var r,s;const t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(const o of t)if((s=(r=i.get(o))==null?void 0:r.isSupported)!=null&&s.call(r))return o;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));const r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){var s;const r=this._getAdapterMap(t).get("webgl");r||D.warn("enforceWebGL2: webgl adapter not found")(),(s=r==null?void 0:r.enforceWebGL2)==null||s.call(r,e)}setDefaultDeviceProps(e){Object.assign(ni.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?D.warn("WebGL1 is not supported",e)():D.warn("Unknown handle type",e)(),null)}};m(ni,"defaultProps",{...zt.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let fs=ni;const jp=new fs;class Kp{get pageLoaded(){return Jp()}}const Zp=Ut()&&typeof document<"u",Qp=()=>Zp&&document.readyState==="complete";let ki=null;function Jp(){return ki||(Qp()||typeof window>"u"?ki=Promise.resolve():ki=new Promise(n=>window.addEventListener("load",()=>n()))),ki}function Gp(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}const qt=class qt{constructor(e){m(this,"id");m(this,"props");m(this,"canvas");m(this,"htmlCanvas");m(this,"offscreenCanvas");m(this,"type");m(this,"initialized");m(this,"isInitialized",!1);m(this,"isVisible",!0);m(this,"cssWidth");m(this,"cssHeight");m(this,"devicePixelRatio");m(this,"devicePixelWidth");m(this,"devicePixelHeight");m(this,"drawingBufferWidth");m(this,"drawingBufferHeight");m(this,"_initializedResolvers",Gp());m(this,"_resizeObserver");m(this,"_intersectionObserver");m(this,"_position");m(this,"destroyed",!1);var t,i;if(this.props={...qt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Ut()?e.canvas?typeof e.canvas=="string"?this.canvas=tm(e.canvas):this.canvas=e.canvas:this.canvas=nm(e):this.canvas={width:e.width||1,height:e.height||1},qt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):qt.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((i=this.htmlCanvas)==null?void 0:i.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],qt.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(r=>this._handleIntersection(r)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(r=>this._handleResize(r));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return im(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(r=>r.target===this.canvas);if(!t)return;const i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){var l,c;const t=e.find(u=>u.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;const i=this.getDevicePixelSize(),r=((l=t.devicePixelContentBoxSize)==null?void 0:l[0].inlineSize)||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=((c=t.devicePixelContentBoxSize)==null?void 0:c[0].blockSize)||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(r,o)),this.devicePixelHeight=Math.max(1,Math.min(s,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var t,i,r;const e=(t=this.htmlCanvas)==null?void 0:t.getBoundingClientRect();if(e){const s=[e.left,e.top];if(this._position??(this._position=s),s[0]!==this._position[0]||s[1]!==this._position[1]){const a=this._position;this._position=s,(r=(i=this.device.props).onPositionChange)==null||r.call(i,this,{oldPosition:a})}}}};m(qt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Di=qt;function em(n){if(typeof n=="string"){const e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function tm(n){const e=document.getElementById(n);if(!Di.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function nm(n){const{width:e,height:t}=n,i=document.createElement("canvas");i.id=Pi("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n!=null&&n.visible||(i.style.visibility="hidden");const r=em((n==null?void 0:n.container)||null);return r.insertBefore(i,r.firstChild),i}function im(n,e,t,i,r){const s=n,o=Ha(s[0],e,t);let a=Wa(s[1],e,i,r),l=Ha(s[0]+1,e,t);const c=l===t-1?l:l-1;l=Wa(s[1]+1,e,i,r);let u;return r?(l=l===0?l:l+1,u=a,a=l):u=l===i-1?l:l-1,{x:o,y:a,width:Math.max(c-o+1,1),height:Math.max(u-a+1,1)}}function Ha(n,e,t){return Math.min(Math.round(n*e),t-1)}function Wa(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}const ii=class ii extends oe{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=ii.normalizeProps(e,t),super(e,t,ii.defaultProps)}static normalizeProps(e,t){return t}};m(ii,"defaultProps",{...oe.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let on=ii;const rm={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},we=class we extends oe{constructor(t,i){i=we.normalizeProps(t,i);super(t,i,we.defaultProps);m(this,"dimension");m(this,"baseDimension");m(this,"format");m(this,"width");m(this,"height");m(this,"depth");m(this,"mipLevels");m(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=rm[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(t.isExternalImage(i.data)){const r=t.getExternalImageSize(i.data);this.width=(r==null?void 0:r.width)||1,this.height=(r==null?void 0:r.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&D.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(t){this.sampler=t instanceof on?t:this.device.createSampler(t)}clone(t){return this.device.createTexture({...this.props,...t})}static normalizeProps(t,i){const r={...i},{width:s,height:o}=r;return typeof s=="number"&&(r.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(r.height=Math.max(1,Math.ceil(o))),r}_initializeData(t){this.device.isExternalImage(t)?this.copyExternalImage({image:t,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}):t&&this.copyImageData({data:t,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(t){const{width:i,height:r,depth:s}=this,o={...we.defaultCopyDataOptions,width:i,height:r,depth:s,...t},a=this.device.getTextureFormatInfo(this.format);if(!t.bytesPerRow&&!a.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return o.bytesPerRow=t.bytesPerRow||i*(a.bytesPerPixel||4),o.rowsPerImage=t.rowsPerImage||r,o}_normalizeCopyExternalImageOptions(t){const i=this.device.getExternalImageSize(t.image),r={...we.defaultCopyExternalImageOptions,...i,...t};return r.width=Math.min(r.width,this.width-r.x),r.height=Math.min(r.height,this.height-r.y),r}};m(we,"SAMPLE",4),m(we,"STORAGE",8),m(we,"RENDER",16),m(we,"COPY_SRC",1),m(we,"COPY_DST",2),m(we,"TEXTURE",4),m(we,"RENDER_ATTACHMENT",16),m(we,"defaultProps",{...oe.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:we.TEXTURE|we.RENDER_ATTACHMENT|we.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),m(we,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),m(we,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let J=we;const vr=class vr extends oe{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,vr.defaultProps)}};m(vr,"defaultProps",{...oe.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Fi=vr;function sm(n,e,t){let i="";const r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++)for(i+=$a(r[a-1],a,t);s.length>o&&s[o].lineNum===a;){const l=s[o++];i+=hs(l,r,l.lineNum,{...t,inlineSource:!1})}for(;s.length>o;){const a=s[o++];i+=hs(a,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(const a of n)i+=hs(a,r,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return i}}function hs(n,e,t,i){if(i!=null&&i.inlineSource){const s=om(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^
|
|
3
3
|
`:"";return`
|
|
4
4
|
${s}${o}${n.type.toUpperCase()}: ${n.message}
|
|
5
5
|
|
|
6
|
-
`}const r=n.type==="error"?"red":"#8B4000";return i!=null&&i.html?`<div class='luma-compiler-log-error' style="color:${r};"><b> ${n.type.toUpperCase()}: ${n.message}</b></div>`:`${n.type.toUpperCase()}: ${n.message}`}function om(n,e,t){let i="";for(let r=e-2;r<=e;r++){const s=n[r-1];s!==void 0&&(i+=$a(s,e,t))}return i}function $a(n,e,t){const i=t!=null&&t.html?
|
|
7
|
-
`}`}function am(n,e){let t="";for(let i=n.length;i<e;++i)t+=" ";return t+n}function
|
|
6
|
+
`}const r=n.type==="error"?"red":"#8B4000";return i!=null&&i.html?`<div class='luma-compiler-log-error' style="color:${r};"><b> ${n.type.toUpperCase()}: ${n.message}</b></div>`:`${n.type.toUpperCase()}: ${n.message}`}function om(n,e,t){let i="";for(let r=e-2;r<=e;r++){const s=n[r-1];s!==void 0&&(i+=$a(s,e,t))}return i}function $a(n,e,t){const i=t!=null&&t.html?lm(n):n;return`${am(String(e),4)}: ${i}${t!=null&&t.html?"<br/>":`
|
|
7
|
+
`}`}function am(n,e){let t="";for(let i=n.length;i<e;++i)t+=" ";return t+n}function lm(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}const br=class br extends oe{constructor(t,i){i={...i,debugShaders:i.debugShaders||t.props.debugShaders||"errors"};super(t,{id:cm(i),...i},br.defaultProps);m(this,"stage");m(this,"source");m(this,"compilationStatus","pending");this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const t=this.props.debugShaders;switch(t){case"never":return;case"errors":if(this.compilationStatus==="success")return;break}const i=await this.getCompilationInfo();t==="warnings"&&(i==null?void 0:i.length)===0||this._displayShaderLog(i,this.id)}_displayShaderLog(t,i){var u;if(typeof document>"u"||!(document!=null&&document.createElement))return;const r=i,s=`${this.stage} shader "${r}"`;let o=sm(t,this.source,{showSourceCode:"all",html:!0});const a=this.getTranslatedSource();a&&(o+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${a}</pre></code>`);const l=document.createElement("Button");l.innerHTML=`
|
|
8
8
|
<h1>Compilation error in ${s}</h1><br /><br />
|
|
9
9
|
<code style="user-select:text;"><pre>
|
|
10
10
|
${o}
|
|
11
|
-
</pre></code>`,c.style.top="10px",c.style.left="10px",c.style.position="absolute",c.style.zIndex="9999",c.style.width="100%",c.style.textAlign="left",document.body.appendChild(c),(u=document.getElementsByClassName("luma-compiler-log-error")[0])==null||u.scrollIntoView(),c.onclick=()=>{const f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}};m(br,"defaultProps",{...ae.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Mi=br;function lm(n){return um(n.source)||n.id||Pi(`unnamed ${n.stage}-shader`)}function um(n,e="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n);return i?i[1]:e}const Sr=class Sr extends ae{constructor(t,i={}){super(t,i,Sr.defaultProps);m(this,"width");m(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(t){const i=this.colorAttachments.map(s=>s.texture.clone(t)),r=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(t);return this.device.createFramebuffer({...this.props,colorAttachments:i,depthStencilAttachment:r})}resize(t){let i=!t;if(t){const[r,s]=Array.isArray(t)?t:[t.width,t.height];i=i||s!==this.height||r!==this.width,this.width=r,this.height=s}i&&(F.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((i,r)=>{if(typeof i=="string"){const s=this.createColorTexture(i,r);return this.attachResource(s),s.view}return i instanceof G?i.view:i});const t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){const i=this.createDepthStencilTexture(t);this.attachResource(i),this.depthStencilAttachment=i.view}else t instanceof G?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t,i){return this.device.createTexture({id:`${this.id}-color-attachment-${i}`,usage:G.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(t){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:G.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,i){for(let r=0;r<this.colorAttachments.length;++r)if(this.colorAttachments[r]){const s=this.colorAttachments[r].texture.clone({width:t,height:i});this.destroyAttachedResource(this.colorAttachments[r]),this.colorAttachments[r]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){const r=this.depthStencilAttachment.texture.clone({width:t,height:i});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=r.view,this.attachResource(r)}this.updateAttachments()}};m(Sr,"defaultProps",{...ae.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let Ni=Sr;const Tr=class Tr extends ae{constructor(t,i){super(t,i,Tr.defaultProps);m(this,"shaderLayout");m(this,"bufferLayout");m(this,"linkStatus","pending");m(this,"hash","");this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};m(Tr,"defaultProps",{...ae.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Lt=Tr;const at=class at extends ae{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=at.normalizeProps(e,t),super(e,t,at.defaultProps)}static normalizeProps(e,t){return t}};m(at,"defaultClearColor",[0,0,0,1]),m(at,"defaultClearDepth",1),m(at,"defaultClearStencil",0),m(at,"defaultProps",{...ae.defaultProps,framebuffer:null,parameters:void 0,clearColor:at.defaultClearColor,clearColors:void 0,clearDepth:at.defaultClearDepth,clearStencil:at.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let ds=at;const wr=class wr extends ae{constructor(t,i){super(t,i,wr.defaultProps);m(this,"hash","");m(this,"shaderLayout");this.shaderLayout=i.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};m(wr,"defaultProps",{...ae.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Oi=wr;const Ar=class Ar extends ae{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ar.defaultProps)}};m(Ar,"defaultProps",{...ae.defaultProps,measureExecutionTime:void 0});let ps=Ar;const Cr=class Cr extends ae{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Cr.defaultProps)}};m(Cr,"defaultProps",{...ae.defaultProps});let ms=Cr;function Xa(n){return pm[n]}function fm(n){const[e,t]=dm[n],i=e==="i32"||e==="u32",r=e!=="u32",s=hm[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:r}}const hm={f32:4,f16:2,i32:4,u32:4},dm={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]},pm={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function Ya(n,e){const t={};for(const i of n.attributes){const r=gm(n,e,i.name);r&&(t[i.name]=r)}return t}function mm(n,e,t=16){const i=Ya(n,e),r=new Array(t).fill(null);for(const s of Object.values(i))r[s.location]=s;return r}function gm(n,e,t){const i=_m(n,t),r=xm(e,t);if(!i)return null;const s=fm(i.type),o=Mp(s),a=(r==null?void 0:r.vertexFormat)||o,c=os(a);return{attributeName:(r==null?void 0:r.attributeName)||i.name,bufferName:(r==null?void 0:r.bufferName)||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:s.integer,stepMode:(r==null?void 0:r.stepMode)||i.stepMode||"vertex",byteOffset:(r==null?void 0:r.byteOffset)||0,byteStride:(r==null?void 0:r.byteStride)||0}}function _m(n,e){const t=n.attributes.find(i=>i.name===e);return t||F.warn(`shader layout attribute "${e}" not present in shader`),t||null}function xm(n,e){ym(n);let t=vm(n,e);return t||(t=bm(n,e),t)?t:(F.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ym(n){for(const e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&F.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function vm(n,e){for(const t of n)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function bm(n,e){var t;for(const i of n){let r=i.byteStride;if(typeof i.byteStride!="number")for(const o of i.attributes||[]){const a=os(o.format);r+=a.byteLength}const s=(t=i.attributes)==null?void 0:t.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:r}}return null}const Pr=class Pr extends ae{constructor(t,i){super(t,i,Pr.defaultProps);m(this,"maxVertexAttributes");m(this,"attributeInfos");m(this,"indexBuffer",null);m(this,"attributes");this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=mm(i.shaderLayout,i.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(t,i){this.device.reportError(new Error("constant attributes not supported"),this)()}};m(Pr,"defaultProps",{...ae.defaultProps,shaderLayout:void 0,bufferLayout:[]});let gs=Pr;const Ir=class Ir extends ae{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Ir.defaultProps)}};m(Ir,"defaultProps",{...ae.defaultProps,layout:void 0,buffers:{}});let _s=Ir;const Rr=class Rr extends ae{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Rr.defaultProps)}};m(Rr,"defaultProps",{...ae.defaultProps,type:void 0,count:void 0});let xs=Rr,Bi;function qa(n){return(!Bi||Bi.byteLength<n)&&(Bi=new ArrayBuffer(n)),Bi}function Sm(n,e){const t=qa(n.BYTES_PER_ELEMENT*e);return new n(t,0,e)}function Tm(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ui(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":Tm(n)}const wm=1024;class Am{constructor(e,t={}){m(this,"layout",{});m(this,"byteLength");let i=0;for(const[s,o]of Object.entries(e)){const a=Xa(o),{type:c,components:l}=a,u=l*((t==null?void 0:t[s])??1);i=kp(i,u);const f=i;i+=u,this.layout[s]={type:c,size:u,offset:f}}i+=(4-i%4)%4;const r=i*4;this.byteLength=Math.max(r,wm)}getData(e){const t=qa(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[r,s]of Object.entries(e)){const o=this.layout[r];if(!o){F.warn(`Supplied uniform value ${r} not present in uniform block layout`)();continue}const{type:a,size:c,offset:l}=o,u=i[a];if(c===1){if(typeof s!="number"&&typeof s!="boolean"){F.warn(`Supplied value for single component uniform ${r} is not a number: ${s}`)();continue}u[l]=Number(s)}else{if(!Ui(s)){F.warn(`Supplied value for multi component / array uniform ${r} is not a numeric array: ${s}`)();continue}u.set(s,l)}}return new Uint8Array(t,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}function Cm(n,e,t=16){if(n!==e)return!1;const i=n,r=e;if(!Ui(i))return!1;if(Ui(r)&&i.length===r.length){for(let s=0;s<i.length;++s)if(r[s]!==i[s])return!1}return!0}function Pm(n){return Ui(n)?n.slice():n}class Im{constructor(e){m(this,"name");m(this,"uniforms",{});m(this,"modifiedUniforms",{});m(this,"modified",!0);m(this,"bindingLayout",{});m(this,"needsRedraw","initialized");var t;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&(e!=null&&e.shaderLayout)){const i=(t=e==null?void 0:e.shaderLayout.bindings)==null?void 0:t.find(s=>s.type==="uniform"&&s.name===(e==null?void 0:e.name));if(!i)throw new Error(e==null?void 0:e.name);const r=i;for(const s of r.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Cm(this.uniforms[e],t)||(this.uniforms[e]=Pm(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}class ge{constructor(e){m(this,"uniformBlocks",new Map);m(this,"uniformBufferLayouts",new Map);m(this,"uniformBuffers",new Map);for(const[t,i]of Object.entries(e)){const r=t,s=new Am(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(r,s);const o=new Im({name:t});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(r,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[i,r]of Object.entries(e))(t=this.uniformBlocks.get(i))==null||t.setUniforms(r);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var i,r;const t=((i=this.uniformBlocks.get(e))==null?void 0:i.getAllUniforms())||{};return(r=this.uniformBufferLayouts.get(e))==null?void 0:r.getData(t)}createUniformBuffer(e,t,i){i&&this.setUniforms(i);const r=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:z.UNIFORM|z.COPY_DST,byteLength:r}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const i=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:z.UNIFORM|z.COPY_DST,byteLength:i});this.uniformBuffers.set(t,r)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(t);e||(e=i)}return e&&F.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var s;const t=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),r=!1;if(i&&(t!=null&&t.needsRedraw)){r||(r=t.needsRedraw);const o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i==null||i.write(o);const a=(s=this.uniformBlocks.get(e))==null?void 0:s.getAllUniforms();F.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}}var Rt;(function(n){n[n.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",n[n.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",n[n.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n[n.ZERO=0]="ZERO",n[n.ONE=1]="ONE",n[n.SRC_COLOR=768]="SRC_COLOR",n[n.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.DST_ALPHA=772]="DST_ALPHA",n[n.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",n[n.DST_COLOR=774]="DST_COLOR",n[n.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",n[n.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",n[n.CONSTANT_COLOR=32769]="CONSTANT_COLOR",n[n.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",n[n.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",n[n.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",n[n.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",n[n.BLEND_EQUATION=32777]="BLEND_EQUATION",n[n.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",n[n.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",n[n.BLEND_DST_RGB=32968]="BLEND_DST_RGB",n[n.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",n[n.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",n[n.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",n[n.BLEND_COLOR=32773]="BLEND_COLOR",n[n.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",n[n.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",n[n.LINE_WIDTH=2849]="LINE_WIDTH",n[n.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",n[n.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",n[n.CULL_FACE_MODE=2885]="CULL_FACE_MODE",n[n.FRONT_FACE=2886]="FRONT_FACE",n[n.DEPTH_RANGE=2928]="DEPTH_RANGE",n[n.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",n[n.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",n[n.DEPTH_FUNC=2932]="DEPTH_FUNC",n[n.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",n[n.STENCIL_FUNC=2962]="STENCIL_FUNC",n[n.STENCIL_FAIL=2964]="STENCIL_FAIL",n[n.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",n[n.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",n[n.STENCIL_REF=2967]="STENCIL_REF",n[n.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",n[n.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",n[n.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",n[n.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",n[n.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",n[n.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",n[n.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",n[n.VIEWPORT=2978]="VIEWPORT",n[n.SCISSOR_BOX=3088]="SCISSOR_BOX",n[n.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",n[n.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",n[n.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",n[n.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",n[n.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",n[n.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",n[n.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",n[n.RED_BITS=3410]="RED_BITS",n[n.GREEN_BITS=3411]="GREEN_BITS",n[n.BLUE_BITS=3412]="BLUE_BITS",n[n.ALPHA_BITS=3413]="ALPHA_BITS",n[n.DEPTH_BITS=3414]="DEPTH_BITS",n[n.STENCIL_BITS=3415]="STENCIL_BITS",n[n.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",n[n.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",n[n.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",n[n.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",n[n.SAMPLES=32937]="SAMPLES",n[n.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",n[n.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",n[n.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",n[n.VENDOR=7936]="VENDOR",n[n.RENDERER=7937]="RENDERER",n[n.VERSION=7938]="VERSION",n[n.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",n[n.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",n[n.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",n[n.STATIC_DRAW=35044]="STATIC_DRAW",n[n.STREAM_DRAW=35040]="STREAM_DRAW",n[n.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BUFFER_SIZE=34660]="BUFFER_SIZE",n[n.BUFFER_USAGE=34661]="BUFFER_USAGE",n[n.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",n[n.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",n[n.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",n[n.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",n[n.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",n[n.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",n[n.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",n[n.CULL_FACE=2884]="CULL_FACE",n[n.FRONT=1028]="FRONT",n[n.BACK=1029]="BACK",n[n.FRONT_AND_BACK=1032]="FRONT_AND_BACK",n[n.BLEND=3042]="BLEND",n[n.DEPTH_TEST=2929]="DEPTH_TEST",n[n.DITHER=3024]="DITHER",n[n.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",n[n.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",n[n.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",n[n.SCISSOR_TEST=3089]="SCISSOR_TEST",n[n.STENCIL_TEST=2960]="STENCIL_TEST",n[n.NO_ERROR=0]="NO_ERROR",n[n.INVALID_ENUM=1280]="INVALID_ENUM",n[n.INVALID_VALUE=1281]="INVALID_VALUE",n[n.INVALID_OPERATION=1282]="INVALID_OPERATION",n[n.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",n[n.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",n[n.CW=2304]="CW",n[n.CCW=2305]="CCW",n[n.DONT_CARE=4352]="DONT_CARE",n[n.FASTEST=4353]="FASTEST",n[n.NICEST=4354]="NICEST",n[n.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.INT=5124]="INT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.DOUBLE=5130]="DOUBLE",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.ALPHA=6406]="ALPHA",n[n.RGB=6407]="RGB",n[n.RGBA=6408]="RGBA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",n[n.VERTEX_SHADER=35633]="VERTEX_SHADER",n[n.COMPILE_STATUS=35713]="COMPILE_STATUS",n[n.DELETE_STATUS=35712]="DELETE_STATUS",n[n.LINK_STATUS=35714]="LINK_STATUS",n[n.VALIDATE_STATUS=35715]="VALIDATE_STATUS",n[n.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",n[n.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",n[n.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",n[n.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",n[n.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",n[n.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",n[n.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",n[n.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",n[n.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",n[n.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",n[n.SHADER_TYPE=35663]="SHADER_TYPE",n[n.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",n[n.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",n[n.NEVER=512]="NEVER",n[n.LESS=513]="LESS",n[n.EQUAL=514]="EQUAL",n[n.LEQUAL=515]="LEQUAL",n[n.GREATER=516]="GREATER",n[n.NOTEQUAL=517]="NOTEQUAL",n[n.GEQUAL=518]="GEQUAL",n[n.ALWAYS=519]="ALWAYS",n[n.KEEP=7680]="KEEP",n[n.REPLACE=7681]="REPLACE",n[n.INCR=7682]="INCR",n[n.DECR=7683]="DECR",n[n.INVERT=5386]="INVERT",n[n.INCR_WRAP=34055]="INCR_WRAP",n[n.DECR_WRAP=34056]="DECR_WRAP",n[n.NEAREST=9728]="NEAREST",n[n.LINEAR=9729]="LINEAR",n[n.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",n[n.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",n[n.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",n[n.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE=5890]="TEXTURE",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n[n.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",n[n.TEXTURE0=33984]="TEXTURE0",n[n.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",n[n.REPEAT=10497]="REPEAT",n[n.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n[n.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",n[n.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_CUBE=35680]="SAMPLER_CUBE",n[n.LOW_FLOAT=36336]="LOW_FLOAT",n[n.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",n[n.HIGH_FLOAT=36338]="HIGH_FLOAT",n[n.LOW_INT=36339]="LOW_INT",n[n.MEDIUM_INT=36340]="MEDIUM_INT",n[n.HIGH_INT=36341]="HIGH_INT",n[n.FRAMEBUFFER=36160]="FRAMEBUFFER",n[n.RENDERBUFFER=36161]="RENDERBUFFER",n[n.RGBA4=32854]="RGBA4",n[n.RGB5_A1=32855]="RGB5_A1",n[n.RGB565=36194]="RGB565",n[n.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",n[n.STENCIL_INDEX=6401]="STENCIL_INDEX",n[n.STENCIL_INDEX8=36168]="STENCIL_INDEX8",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n[n.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",n[n.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",n[n.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",n[n.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",n[n.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",n[n.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",n[n.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",n[n.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",n[n.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",n[n.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",n[n.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",n[n.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",n[n.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",n[n.NONE=0]="NONE",n[n.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",n[n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",n[n.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",n[n.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",n[n.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",n[n.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",n[n.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",n[n.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",n[n.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",n[n.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",n[n.READ_BUFFER=3074]="READ_BUFFER",n[n.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",n[n.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",n[n.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",n[n.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",n[n.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",n[n.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",n[n.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",n[n.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",n[n.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",n[n.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",n[n.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",n[n.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",n[n.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",n[n.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",n[n.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",n[n.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",n[n.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",n[n.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",n[n.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",n[n.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",n[n.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",n[n.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",n[n.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",n[n.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",n[n.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",n[n.RED=6403]="RED",n[n.RGB8=32849]="RGB8",n[n.RGBA8=32856]="RGBA8",n[n.RGB10_A2=32857]="RGB10_A2",n[n.TEXTURE_3D=32879]="TEXTURE_3D",n[n.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",n[n.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",n[n.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",n[n.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",n[n.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",n[n.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",n[n.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",n[n.SRGB=35904]="SRGB",n[n.SRGB8=35905]="SRGB8",n[n.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",n[n.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",n[n.RGBA32F=34836]="RGBA32F",n[n.RGB32F=34837]="RGB32F",n[n.RGBA16F=34842]="RGBA16F",n[n.RGB16F=34843]="RGB16F",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",n[n.R11F_G11F_B10F=35898]="R11F_G11F_B10F",n[n.RGB9_E5=35901]="RGB9_E5",n[n.RGBA32UI=36208]="RGBA32UI",n[n.RGB32UI=36209]="RGB32UI",n[n.RGBA16UI=36214]="RGBA16UI",n[n.RGB16UI=36215]="RGB16UI",n[n.RGBA8UI=36220]="RGBA8UI",n[n.RGB8UI=36221]="RGB8UI",n[n.RGBA32I=36226]="RGBA32I",n[n.RGB32I=36227]="RGB32I",n[n.RGBA16I=36232]="RGBA16I",n[n.RGB16I=36233]="RGB16I",n[n.RGBA8I=36238]="RGBA8I",n[n.RGB8I=36239]="RGB8I",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.R8=33321]="R8",n[n.RG8=33323]="RG8",n[n.R16F=33325]="R16F",n[n.R32F=33326]="R32F",n[n.RG16F=33327]="RG16F",n[n.RG32F=33328]="RG32F",n[n.R8I=33329]="R8I",n[n.R8UI=33330]="R8UI",n[n.R16I=33331]="R16I",n[n.R16UI=33332]="R16UI",n[n.R32I=33333]="R32I",n[n.R32UI=33334]="R32UI",n[n.RG8I=33335]="RG8I",n[n.RG8UI=33336]="RG8UI",n[n.RG16I=33337]="RG16I",n[n.RG16UI=33338]="RG16UI",n[n.RG32I=33339]="RG32I",n[n.RG32UI=33340]="RG32UI",n[n.R8_SNORM=36756]="R8_SNORM",n[n.RG8_SNORM=36757]="RG8_SNORM",n[n.RGB8_SNORM=36758]="RGB8_SNORM",n[n.RGBA8_SNORM=36759]="RGBA8_SNORM",n[n.RGB10_A2UI=36975]="RGB10_A2UI",n[n.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",n[n.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.HALF_FLOAT=5131]="HALF_FLOAT",n[n.RG=33319]="RG",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",n[n.CURRENT_QUERY=34917]="CURRENT_QUERY",n[n.QUERY_RESULT=34918]="QUERY_RESULT",n[n.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",n[n.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",n[n.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",n[n.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",n[n.DRAW_BUFFER0=34853]="DRAW_BUFFER0",n[n.DRAW_BUFFER1=34854]="DRAW_BUFFER1",n[n.DRAW_BUFFER2=34855]="DRAW_BUFFER2",n[n.DRAW_BUFFER3=34856]="DRAW_BUFFER3",n[n.DRAW_BUFFER4=34857]="DRAW_BUFFER4",n[n.DRAW_BUFFER5=34858]="DRAW_BUFFER5",n[n.DRAW_BUFFER6=34859]="DRAW_BUFFER6",n[n.DRAW_BUFFER7=34860]="DRAW_BUFFER7",n[n.DRAW_BUFFER8=34861]="DRAW_BUFFER8",n[n.DRAW_BUFFER9=34862]="DRAW_BUFFER9",n[n.DRAW_BUFFER10=34863]="DRAW_BUFFER10",n[n.DRAW_BUFFER11=34864]="DRAW_BUFFER11",n[n.DRAW_BUFFER12=34865]="DRAW_BUFFER12",n[n.DRAW_BUFFER13=34866]="DRAW_BUFFER13",n[n.DRAW_BUFFER14=34867]="DRAW_BUFFER14",n[n.DRAW_BUFFER15=34868]="DRAW_BUFFER15",n[n.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",n[n.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",n[n.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",n[n.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",n[n.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",n[n.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",n[n.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",n[n.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",n[n.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",n[n.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",n[n.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",n[n.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",n[n.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",n[n.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",n[n.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",n[n.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",n[n.SAMPLER_3D=35679]="SAMPLER_3D",n[n.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",n[n.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",n[n.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",n[n.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",n[n.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",n[n.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",n[n.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",n[n.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",n[n.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",n[n.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",n[n.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",n[n.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",n[n.MAX_SAMPLES=36183]="MAX_SAMPLES",n[n.SAMPLER_BINDING=35097]="SAMPLER_BINDING",n[n.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",n[n.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",n[n.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",n[n.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",n[n.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",n[n.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",n[n.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",n[n.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",n[n.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",n[n.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",n[n.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",n[n.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",n[n.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",n[n.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",n[n.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",n[n.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",n[n.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",n[n.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",n[n.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",n[n.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",n[n.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",n[n.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",n[n.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",n[n.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",n[n.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",n[n.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",n[n.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",n[n.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",n[n.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",n[n.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",n[n.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",n[n.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",n[n.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",n[n.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",n[n.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",n[n.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",n[n.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",n[n.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",n[n.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",n[n.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",n[n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n[n.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",n[n.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",n[n.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",n[n.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",n[n.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",n[n.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",n[n.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",n[n.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",n[n.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",n[n.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",n[n.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",n[n.UNIFORM_TYPE=35383]="UNIFORM_TYPE",n[n.UNIFORM_SIZE=35384]="UNIFORM_SIZE",n[n.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",n[n.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",n[n.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",n[n.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",n[n.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",n[n.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",n[n.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",n[n.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",n[n.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",n[n.OBJECT_TYPE=37138]="OBJECT_TYPE",n[n.SYNC_CONDITION=37139]="SYNC_CONDITION",n[n.SYNC_STATUS=37140]="SYNC_STATUS",n[n.SYNC_FLAGS=37141]="SYNC_FLAGS",n[n.SYNC_FENCE=37142]="SYNC_FENCE",n[n.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",n[n.UNSIGNALED=37144]="UNSIGNALED",n[n.SIGNALED=37145]="SIGNALED",n[n.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",n[n.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",n[n.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",n[n.WAIT_FAILED=37149]="WAIT_FAILED",n[n.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",n[n.COLOR=6144]="COLOR",n[n.DEPTH=6145]="DEPTH",n[n.STENCIL=6146]="STENCIL",n[n.MIN=32775]="MIN",n[n.MAX=32776]="MAX",n[n.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",n[n.STREAM_READ=35041]="STREAM_READ",n[n.STREAM_COPY=35042]="STREAM_COPY",n[n.STATIC_READ=35045]="STATIC_READ",n[n.STATIC_COPY=35046]="STATIC_COPY",n[n.DYNAMIC_READ=35049]="DYNAMIC_READ",n[n.DYNAMIC_COPY=35050]="DYNAMIC_COPY",n[n.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",n[n.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",n[n.INVALID_INDEX=4294967295]="INVALID_INDEX",n[n.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",n[n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",n[n.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",n[n.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",n[n.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",n[n.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",n[n.R16_EXT=33322]="R16_EXT",n[n.RG16_EXT=33324]="RG16_EXT",n[n.RGB16_EXT=32852]="RGB16_EXT",n[n.RGBA16_EXT=32859]="RGBA16_EXT",n[n.R16_SNORM_EXT=36760]="R16_SNORM_EXT",n[n.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",n[n.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",n[n.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",n[n.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",n[n.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",n[n.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",n[n.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",n[n.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",n[n.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",n[n.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",n[n.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",n[n.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",n[n.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",n[n.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",n[n.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",n[n.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",n[n.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",n[n.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",n[n.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",n[n.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",n[n.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",n[n.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",n[n.LINE_WEBGL=6913]="LINE_WEBGL",n[n.FILL_WEBGL=6914]="FILL_WEBGL",n[n.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",n[n.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",n[n.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",n[n.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",n[n.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",n[n.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",n[n.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",n[n.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",n[n.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",n[n.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",n[n.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",n[n.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",n[n.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",n[n.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",n[n.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",n[n.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",n[n.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",n[n.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",n[n.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",n[n.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",n[n.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",n[n.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",n[n.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",n[n.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Rt||(Rt={}));const Rm={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:{}},Em=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),km=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),Fm=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}});function Dm(n=!0){const e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){const r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&Mm(r),r}return this.originalGetContext(t,i)}}function Mm(n){n.getExtension("EXT_color_buffer_float");const e={...Rm,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Em(n),OES_vertex_array_object:km(n),ANGLE_instanced_arrays:Fm(n)},t=n.getExtension;n.getExtension=function(r){const s=t.call(n,r);return s||(r in e?e[r]:null)};const i=n.getSupportedExtensions;n.getSupportedExtensions=function(){const r=i.apply(n)||[];return r==null?void 0:r.concat(Object.keys(e))}}async function ja(n,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",n),new Promise((r,s)=>{i.onload=r,i.onerror=o=>s(new Error(`Unable to load script '${n}': ${o}`)),t.appendChild(i)})}const Nm=1;let fe=null,Ka=!1;const ys={debugSpectorJS:F.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function Om(n){if(!globalThis.SPECTOR)try{await ja(n.debugSpectorJSUrl||ys.debugSpectorJSUrl)}catch(e){F.warn(String(e))}}function Bm(n){var e;if(n={...ys,...n},!n.debugSpectorJS)return null;if(!fe&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){F.probe(Nm,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;fe=new t,globalThis.luma&&(globalThis.luma.spector=fe)}if(!fe)return null;if(Ka||(Ka=!0,fe.spyCanvases(),fe==null||fe.onCaptureStarted.add(t=>F.info("Spector capture started:",t)()),fe==null||fe.onCapture.add(t=>{F.info("Spector capture complete:",t)(),fe==null||fe.getResultUI(),fe==null||fe.resultView.display(),fe==null||fe.resultView.addCapture(t)})),n.gl){const t=n.gl,i=t.device;fe==null||fe.startCapture(n.gl,500),t.device=i,new Promise(r=>setTimeout(r,2e3)).then(r=>{F.info("Spector capture stopped after 2 seconds")(),fe==null||fe.stopCapture()})}return fe}const Um="https://unpkg.com/webgl-debug@2.0.1/index.js";function Za(n){return n.luma=n.luma||{},n.luma}async function zm(){Ut()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await ja(Um))}function Lm(n,e={}){return e.debugWebGL||e.traceWebGL?Hm(n,e):Vm(n)}function Vm(n){const e=Za(n);return e.realContext?e.realContext:n}function Hm(n,e){if(!globalThis.WebGLDebugUtils)return F.warn("webgl-debug not loaded")(),n;const t=Za(n);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Rt,...n});const i=globalThis.WebGLDebugUtils.makeDebugContext(n,Wm.bind(null,e),$m.bind(null,e));for(const o in Rt)!(o in i)&&typeof Rt[o]=="number"&&(i[o]=Rt[o]);class r{}Object.setPrototypeOf(i,Object.getPrototypeOf(n)),Object.setPrototypeOf(r,i);const s=Object.create(r);return t.realContext=n,t.debugContext=s,s.debug=!0,s}function Qa(n,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(n,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${n}(${t})`}function Wm(n,e,t,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);const r=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,i),o=`${r} in gl.${t}(${s})`;F.error(o)();debugger}function $m(n,e,t){let i="";F.level>=1&&(i=Qa(e,t),n.traceWebGL&&F.log(1,i)());for(const r of t)if(r===void 0){i=i||Qa(e,t);debugger}}const zi=1;class Xm extends Kp{constructor(){super();m(this,"type","webgl");zt.defaultProps={...zt.defaultProps,...ys}}enforceWebGL2(t){Dm(t)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&t instanceof WebGLRenderingContext&&F.warn("WebGL1 is not supported",t)(),!1)}async attach(t,i={}){const{WebGLDevice:r}=await Promise.resolve().then(()=>Sc);if(t instanceof r)return t;if((t==null?void 0:t.device)instanceof r)return t.device;if(!Ym(t))throw new Error("Invalid WebGL2RenderingContext");const s=i.createCanvasContext===!0?{}:i.createCanvasContext;return new r({...i,_handle:t,createCanvasContext:{canvas:t.canvas,autoResize:!1,...s}})}async create(t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>Sc);F.groupCollapsed(zi,"WebGLDevice created")();try{const r=[];(t.debugWebGL||t.debug)&&r.push(zm()),t.debugSpectorJS&&r.push(Om(t));const s=await Promise.allSettled(r);for(const c of s)c.status==="rejected"&&F.error(`Failed to initialize debug libraries ${c.reason}`)();const o=new i(t),a=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return F.probe(zi,a)(),F.table(zi,o.info)(),o}finally{F.groupEnd(zi)()}}}function Ym(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&Number.isFinite(n._version))}const qm=new Xm,vs={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},ye=(n,e,t)=>e?n.enable(t):n.disable(t),Ja=(n,e,t)=>n.hint(t,e),Ye=(n,e,t)=>n.pixelStorei(t,e),Ga=(n,e,t)=>{const i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Dn=(n,e,t)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};function bs(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}const jm={3042:ye,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:ye,2885:(n,e)=>n.cullFace(e),2929:ye,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:ye,35723:Ja,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>{var t;return(t=n.bindTransformFeedback)==null?void 0:t.call(n,36386,e)},34229:(n,e)=>n.bindVertexArray(e),36006:Ga,36010:Ga,34964:Dn,36662:Dn,36663:Dn,35053:Dn,35055:Dn,2886:(n,e)=>n.frontFace(e),33170:Ja,2849:(n,e)=>n.lineWidth(e),32823:ye,32824:"polygonOffset",10752:"polygonOffset",35977:ye,32926:ye,32928:ye,32938:"sampleCoverage",32939:"sampleCoverage",3089:ye,3088:(n,e)=>n.scissor(...e),2960:ye,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:ye,10754:ye,12288:ye,12289:ye,12290:ye,12291:ye,12292:ye,12293:ye,12294:ye,12295:ye,3333:Ye,3317:Ye,37440:Ye,37441:Ye,37443:Ye,3330:Ye,3332:Ye,3331:Ye,3314:Ye,32878:Ye,3316:Ye,3315:Ye,32877:Ye,framebuffer:(n,e)=>{const t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{const t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=bs(e)?e:[e,e];const[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=bs(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=bs(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};function _e(n,e,t){return e[n]!==void 0?e[n]:t[n]}const Km={blendEquation:(n,e,t)=>n.blendEquationSeparate(_e(32777,e,t),_e(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(_e(32969,e,t),_e(32968,e,t),_e(32971,e,t),_e(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(_e(32824,e,t),_e(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(_e(32938,e,t),_e(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,_e(2962,e,t),_e(2967,e,t),_e(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,_e(34816,e,t),_e(36003,e,t),_e(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,_e(2964,e,t),_e(2965,e,t),_e(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,_e(34817,e,t),_e(34818,e,t),_e(34819,e,t))},ec={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ft=(n,e)=>n.isEnabled(e),tc={3042:ft,2884:ft,2929:ft,3024:ft,32823:ft,32926:ft,32928:ft,3089:ft,2960:ft,35977:ft},Zm=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function an(n,e){if(Jm(e))return;const t={};for(const r in e){const s=Number(r),o=jm[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}const i=n.state&&n.state.cache;if(i)for(const r in t){const s=Km[r];s(n,e,i)}}function nc(n,e=vs){if(typeof e=="number"){const r=e,s=tc[r];return s?s(n,r):n.getParameter(r)}const t=Array.isArray(e)?e:Object.keys(e),i={};for(const r of t){const s=tc[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function Qm(n){an(n,vs)}function Jm(n){for(const e in n)return!1;return!0}function Gm(n,e){if(n===e)return!0;if(ic(n)&&ic(e)&&n.length===e.length){for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}return!1}function ic(n){return Array.isArray(n)||ArrayBuffer.isView(n)}class Vt{constructor(e,t){m(this,"gl");m(this,"program",null);m(this,"stateStack",[]);m(this,"enable",!0);m(this,"cache",null);m(this,"log");m(this,"initialized",!1);this.gl=e,this.log=(t==null?void 0:t.log)||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];an(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?nc(e):Object.assign({},vs),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,tg(e);for(const i in ec){const r=ec[i];eg(e,i,r)}rc(e,"getParameter"),rc(e,"isEnabled")}_updateCache(e){let t=!1,i;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const s in e){const o=e[s],a=this.cache[s];Gm(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}function rc(n,e){const t=n[e].bind(n);n[e]=function(r){if(r===void 0||Zm.has(r))return t(r);const s=Vt.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function eg(n,e,t){if(!n[e])return;const i=n[e].bind(n);n[e]=function(...s){const o=Vt.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function tg(n){const e=n.useProgram.bind(n);n.useProgram=function(i){const r=Vt.get(n);r.program!==i&&(e(i),r.program=i)}}function ng(n,e,t){let i="";const r={preserveDrawingBuffer:!0,...t};let s=null;if(s||(s=n.getContext("webgl2",r)),r.failIfMajorPerformanceCaveat&&(i||(i="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!s&&!t.failIfMajorPerformanceCaveat&&(r.failIfMajorPerformanceCaveat=!1,s=n.getContext("webgl2",r),s.luma||(s.luma={}),s.luma.softwareRenderer=!0),s||(s=n.getContext("webgl",{}),s&&(s=null,i||(i="Your browser only supports WebGL1"))),!s)throw i||(i="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${i}`);const{onContextLost:o,onContextRestored:a}=e;return n.addEventListener("webglcontextlost",c=>o(c),!1),n.addEventListener("webglcontextrestored",c=>a(c),!1),s.luma||(s.luma={}),s}function cn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}function ig(n,e){const t=n.getParameter(7936),i=n.getParameter(7937);cn(n,"WEBGL_debug_renderer_info",e);const r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=sc(a,c),f=rg(a,c),h=sg(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function sc(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function rg(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function sg(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(sc(n,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function oc(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}const Mn="WEBGL_compressed_texture_s3tc",Nn="WEBGL_compressed_texture_s3tc_srgb",ln="EXT_texture_compression_rgtc",un="EXT_texture_compression_bptc",og="WEBGL_compressed_texture_etc",ag="WEBGL_compressed_texture_astc",cg="WEBGL_compressed_texture_etc1",lg="WEBGL_compressed_texture_pvrtc",ug="WEBGL_compressed_texture_atc",ac="EXT_texture_norm16",cc="EXT_render_snorm",fg="EXT_color_buffer_float",Ss={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[cc],"norm16-renderable-webgl":[ac],"snorm16-renderable-webgl":[ac,cc],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Mn,Nn,ln,un],"texture-compression-bc5-webgl":[ln],"texture-compression-bc7-webgl":[un],"texture-compression-etc2":[og],"texture-compression-astc":[ag],"texture-compression-etc1-webgl":[cg],"texture-compression-pvrtc-webgl":[lg],"texture-compression-atc-webgl":[ug]};function hg(n){return n in Ss}function dg(n,e,t){return(Ss[e]||[]).every(r=>cn(n,r,t))}const Ts={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:fg,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Mn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Nn},"bc1-rgba-unorm":{gl:33777,x:Mn},"bc1-rgba-unorm-srgb":{gl:35916,x:Nn},"bc2-rgba-unorm":{gl:33778,x:Mn},"bc2-rgba-unorm-srgb":{gl:35918,x:Nn},"bc3-rgba-unorm":{gl:33779,x:Mn},"bc3-rgba-unorm-srgb":{gl:35919,x:Nn},"bc4-r-unorm":{gl:36283,x:ln},"bc4-r-snorm":{gl:36284,x:ln},"bc5-rg-unorm":{gl:36285,x:ln},"bc5-rg-snorm":{gl:36286,x:ln},"bc6h-rgb-ufloat":{gl:36495,x:un},"bc6h-rgb-float":{gl:36494,x:un},"bc7-rgba-unorm":{gl:36492,x:un},"bc7-rgba-unorm-srgb":{gl:36493,x:un},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function pg(n,e,t){let i=e.create;const r=Ts[e.format];return(r==null?void 0:r.gl)===void 0&&(i=!1),r!=null&&r.x&&(i=i&&!!cn(n,r.x,t)),{format:e.format,create:i&&e.create,render:i&&e.render,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function lc(n){var r;const e=Ts[n],t=_g(n),i=sn.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:(e==null?void 0:e.dataFormat)||gg(i.channels,i.integer,i.normalized,t),type:i.dataType?oc(i.dataType):((r=e==null?void 0:e.types)==null?void 0:r[0])||5121,compressed:i.compressed||!1}}function mg(n){switch(sn.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function gg(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function _g(n){const e=Ts[n],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}const uc={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class xg extends Yp{constructor(t,i,r){super([],r);m(this,"gl");m(this,"extensions");m(this,"testedFeatures",new Set);this.gl=t,this.extensions=i,cn(t,"EXT_color_buffer_float",i)}*[Symbol.iterator](){const t=this.getFeatures();for(const i of t)this.has(i)&&(yield i);return[]}has(t){var i;return(i=this.disabledFeatures)!=null&&i[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),hg(t)&&dg(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){const t=this.getFeatures().filter(i=>i!=="polygon-mode-webgl");for(const i of t)this.has(i)}getFeatures(){return[...Object.keys(uc),...Object.keys(Ss)]}getWebGLFeature(t){const i=uc[t];return typeof i=="string"?!!cn(this.gl,i,this.extensions):!!i}}class yg extends Xp{constructor(t){super();m(this,"gl");m(this,"limits",{});this.gl=t}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}class On extends Ni{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"colorAttachments",[]);m(this,"depthStencilAttachment",null);const r=i.handle===null;this.device=t,this.gl=t.gl,this.handle=this.props.handle||r?this.props.handle:this.gl.createFramebuffer(),r||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const t=this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i<this.colorAttachments.length;++i){const r=this.colorAttachments[i];if(r){const s=36064+i;this._attachTextureView(s,r)}}if(this.depthStencilAttachment){const i=mg(this.depthStencilAttachment.props.format);this._attachTextureView(i,this.depthStencilAttachment)}if(this.device.props.debug){const i=this.gl.checkFramebufferStatus(36160);if(i!==36053)throw new Error(`Framebuffer ${bg(i)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,i){const{gl:r}=this.device,{texture:s}=i,o=i.props.baseMipLevel,a=i.props.baseArrayLayer;switch(r.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:r.framebufferTextureLayer(36160,t,s.handle,o,a);break;case 34067:const c=vg(a);r.framebufferTexture2D(36160,t,c,s.handle,o);break;case 3553:r.framebufferTexture2D(36160,t,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}r.bindTexture(s.glTarget,null)}}function vg(n){return n<34069?n+34069:n}function bg(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}class Sg extends Fi{constructor(t,i){super(i);m(this,"device");m(this,"handle",null);m(this,"_framebuffer",null);this.device=t,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._updateDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new On(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}const ws={};function Tg(n="id"){ws[n]=ws[n]||1;const e=ws[n]++;return`${n}-${e}`}class Bn extends z{constructor(t,i={}){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"glTarget");m(this,"glUsage");m(this,"glIndexType",5123);m(this,"byteLength",0);m(this,"bytesUsed",0);this.device=t,this.gl=this.device.gl;const r=typeof i=="object"?i.handle:void 0;this.handle=r||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=wg(this.props.usage),this.glUsage=Ag(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,i.data?this._initWithData(i.data,i.byteOffset,i.byteLength):this._initWithByteLength(i.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(t,i=0,r=t.byteLength+i){const s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bufferSubData(s,i,t),this.gl.bindBuffer(s,null),this.bytesUsed=r,this.byteLength=r,this._setDebugData(t,i,r),this.trackAllocatedMemory(r)}_initWithByteLength(t){let i=t;t===0&&(i=new Float32Array(0));const r=this.glTarget;return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bindBuffer(r,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}write(t,i=0){const r=ArrayBuffer.isView(t)?t:new Uint8Array(t),s=36663;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,i,r),this.gl.bindBuffer(s,null),this._setDebugData(t,i,t.byteLength)}async mapAndWriteAsync(t,i=0,r=this.byteLength-i){const s=new ArrayBuffer(r);await t(s,"copied"),this.write(s,i)}async readAsync(t=0,i){return this.readSyncWebGL(t,i)}async mapAndReadAsync(t,i=0,r){const s=await this.readAsync(i,r);return await t(s.buffer,"copied")}readSyncWebGL(t=0,i){i=i??this.byteLength-t;const r=new Uint8Array(i),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,r,s,i),this.gl.bindBuffer(36662,null),this._setDebugData(r,t,i),r}}function wg(n){return n&z.INDEX?34963:n&z.VERTEX?34962:n&z.UNIFORM?35345:34962}function Ag(n){return n&z.INDEX||n&z.VERTEX?35044:n&z.UNIFORM?35048:35044}function Cg(n){const e=n.split(/\r?\n/),t=[];for(const i of e){if(i.length<=1)continue;const r=i.split(":");if(r.length===2){const[f,h]=r;t.push({message:h.trim(),type:fc(f),lineNum:0,linePos:0});continue}const[s,o,a,...c]=r;let l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:c.join(":").trim(),type:fc(s),lineNum:l,linePos:u})}return t}function fc(n){const e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}class Pg extends Mi{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");switch(this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const t=this.device.gl.getShaderInfoLog(this.handle);return t?Cg(t):[]}getTranslatedSource(){const i=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(i==null?void 0:i.getTranslatedShaderSource(this.handle))||null}async _compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
12
|
-
${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}F.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),F.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function Ig(n,e,t,i){if(Fg(e))return i(n);const r=n;r.pushState();try{return Rg(n,e),an(r.gl,t),i(n)}finally{r.popState()}}function Rg(n,e){const t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Ht("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){const s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Ht("provokingVertex",e.provokingVertex,{first:36429,last:36430});s==null||s.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){const s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Ht("polygonMode",e.polygonMode,{fill:6914,line:6913});s==null||s.polygonModeWEBGL(1028,o),s==null||s.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(kg("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(As("depthCompare",e.depthCompare))),e.stencilWriteMask){const r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&F.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const r=e.stencilReadMask||4294967295,s=As("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const r=Cs("stencilPassOperation",e.stencilPassOperation),s=Cs("stencilFailOperation",e.stencilFailOperation),o=Cs("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const r=hc("blendColorOperation",e.blendColorOperation||"add"),s=hc("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);const o=Li("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Li("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=Li("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=Li("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function As(n,e){return Ht(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Cs(n,e){return Ht(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function hc(n,e){return Ht(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Li(n,e,t="color"){return Ht(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Eg(n,e){return`Illegal parameter ${e} for ${n}`}function Ht(n,e,t){if(!(e in t))throw new Error(Eg(n,e));return t[e]}function kg(n,e){return e}function Fg(n){let e=!0;for(const t in n){e=!1;break}return e}function dc(n){const e={};return n.addressModeU&&(e[10242]=Ps(n.addressModeU)),n.addressModeV&&(e[10243]=Ps(n.addressModeV)),n.addressModeW&&(e[32882]=Ps(n.addressModeW)),n.magFilter&&(e[10240]=Is(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=Dg(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=As("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function Ps(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Is(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function Dg(n,e="none"){if(!e)return Is(n);switch(e){case"none":return Is(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}class Mg extends on{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"parameters");this.device=t,this.parameters=dc(i),this.handle=i.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(const[i,r]of Object.entries(t)){const s=Number(i);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,r);break;default:this.device.gl.samplerParameteri(this.handle,s,r);break}}}}function Un(n,e,t){if(Ng(e))return t(n);const{nocatch:i=!0}=e,r=Vt.get(n);r.push(),an(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function Ng(n){for(const e in n)return!1;return!0}class fn extends Di{constructor(t,i){super(t,{...G.defaultProps,...i});m(this,"device");m(this,"gl");m(this,"handle");m(this,"texture");this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=i.texture}}class zn extends G{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"sampler");m(this,"view");m(this,"glTarget");m(this,"glFormat");m(this,"glType");m(this,"glInternalFormat");m(this,"compressed");m(this,"_textureUnit",0);this.device=t,this.gl=this.device.gl;const r=lc(this.props.format);this.glTarget=Og(this.props.dimension),this.glInternalFormat=r.internalFormat,this.glFormat=r.format,this.glType=r.type,this.compressed=r.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:s,width:o,height:a,depth:c,mipLevels:l,glTarget:u,glInternalFormat:f}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(u,l,f,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,l,f,o,a,c);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(i.data),this.setSampler(this.props.sampler),this.view=new fn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(t){return new fn(this.device,{...t,texture:this})}setSampler(t={}){super.setSampler(t);const i=dc(this.sampler.props);this._setSamplerParameters(i)}copyImageData(t){const i=this._normalizeCopyImageDataOptions(t),r=i.data,{width:s,height:o,depth:a}=this,{mipLevel:c=0,byteOffset:l=0,x:u=0,y:f=0,z:h=0}=i,{glFormat:d,glType:_,compressed:I}=this,C=pc(this.glTarget,this.dimension,a),w=this.compressed?{}:{3314:i.bytesPerRow,32878:i.rowsPerImage};this.gl.bindTexture(C,this.handle),Un(this.gl,w,()=>{switch(this.dimension){case"2d":case"cube":I?this.gl.compressedTexSubImage2D(C,c,u,f,s,o,d,r,l):this.gl.texSubImage2D(C,c,u,f,s,o,d,_,r,l);break;case"2d-array":case"3d":I?this.gl.compressedTexSubImage3D(C,c,u,f,h,s,o,a,d,r,l):this.gl.texSubImage3D(C,c,u,f,h,s,o,a,d,_,r,l);break;default:}}),this.gl.bindTexture(C,null)}copyExternalImage(t){const i=this._normalizeCopyExternalImageOptions(t);if(i.sourceX||i.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:r,glType:s}=this,{image:o,depth:a,mipLevel:c,x:l,y:u,z:f,width:h,height:d}=i,_=pc(this.glTarget,this.dimension,a),I=i.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Un(this.gl,I,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(_,c,l,u,h,d,r,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(_,c,l,u,f,h,d,a,r,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:i.width,height:i.height}}generateMipmapsWebGL(t){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(F.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(t!=null&&t.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(r){F.warn(`Error generating mipmap for ${this}: ${r.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){F.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[i,r]of Object.entries(t)){const s=Number(i),o=r;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,this.handle),t}_unbind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,null),t}}function Og(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(n)}function pc(n,e,t){return e==="cube"?34069+t:n}function Bg(n){return Vg[n]}function Rs(n){return Lg[n]}function Ug(n){return!!mc[n]}function zg(n){return mc[n]}const Lg={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},mc={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Vg={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Hg(n,e){const t={attributes:[],bindings:[]};t.attributes=Wg(n,e);const i=Yg(n,e);for(const a of i){const c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}const r=Xg(n,e);let s=0;for(const a of r)if(Ug(a.type)){const{viewDimension:c,sampleType:l}=zg(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:c,sampleType:l}),a.textureUnit=s,s+=1}r.length&&(t.uniforms=r);const o=$g(n,e);return o!=null&&o.length&&(t.varyings=o),t}function Wg(n,e){const t=[],i=n.getProgramParameter(e,35721);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a}=s,c=n.getAttribLocation(e,o);if(c>=0){const l=Rs(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function $g(n,e){const t=[],i=n.getProgramParameter(e,35971);for(let r=0;r<i;r++){const s=n.getTransformFeedbackVarying(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a,size:c}=s,l=Rs(a),{type:u,components:f}=Xa(l);t.push({location:r,name:o,type:u,size:c*f})}return t.sort((r,s)=>r.location-s.location),t}function Xg(n,e){const t=[],i=n.getProgramParameter(e,35718);for(let r=0;r<i;r++){const s=n.getActiveUniform(e,r);if(!s)throw new Error("activeInfo");const{name:o,size:a,type:c}=s,{name:l,isArray:u}=qg(o);let f=n.getUniformLocation(e,l);const h={location:f,name:l,size:a,type:c,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){const _=`${l}[${d}]`;f=n.getUniformLocation(e,_);const I={...h,name:_,location:f};t.push(I)}}return t}function Yg(n,e){const t=(s,o)=>n.getActiveUniformBlockParameter(e,s,o),i=[],r=n.getProgramParameter(e,35382);for(let s=0;s<r;s++){const o={name:n.getActiveUniformBlockName(e,s)||"",location:t(s,35391),byteLength:t(s,35392),vertex:t(s,35396),fragment:t(s,35398),uniformCount:t(s,35394),uniforms:[]},a=t(s,35395)||[],c=n.getActiveUniforms(e,a,35383),l=n.getActiveUniforms(e,a,35384),u=n.getActiveUniforms(e,a,35387),f=n.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){const d=n.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");const _=Rs(c[h]);o.uniforms.push({name:d.name,format:_,type:c[h],arrayLength:l[h],byteOffset:u[h],byteStride:f[h]})}i.push(o)}return i.sort((s,o)=>s.location-o.location),i}function qg(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(n);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${n}`);return{name:t[1],length:t[2]?1:0,isArray:!!t[2]}}function jg(n,e,t,i){const r=n;let s=i;s===!0&&(s=1),s===!1&&(s=0);const o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function Kg(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function Zg(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}const gc=4;class Qg extends Lt{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"vs");m(this,"fs");m(this,"introspectedLayout");m(this,"uniforms",{});m(this,"bindings",{});m(this,"varyings",null);m(this,"_uniformCount",0);m(this,"_uniformSetters",{});this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=i.vs,this.fs=i.fs;const{varyings:r,bufferMode:s=35981}=i;r&&r.length>0&&(this.varyings=r,this.device.gl.transformFeedbackVaryings(this.handle,r,s)),this._linkShaders(),F.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Hg(this.device.gl,this.handle),F.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=i.shaderLayout?Jg(this.introspectedLayout,i.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(t,i){for(const[r,s]of Object.entries(t)){const o=this.shaderLayout.bindings.find(a=>a.name===r)||this.shaderLayout.bindings.find(a=>a.name===`${r}Uniforms`);if(!o){const a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");i!=null&&i.disableWarnings||F.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)();continue}switch(s||F.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof Bn)&&!(s.buffer instanceof Bn))throw new Error("buffer value");break;case"texture":if(!(s instanceof fn||s instanceof zn||s instanceof On))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":F.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}}draw(t){var C;const{renderPass:i,parameters:r=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f}=t,h=Kg(s),d=!!o.indexBuffer,_=(C=o.indexBuffer)==null?void 0:C.glIndexType;if(this.linkStatus!=="success")return F.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return F.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(i),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const I=i;return Ig(this.device,r,I.glParameters,()=>{d&&l?this.device.gl.drawElementsInstanced(h,a||0,_,u,c||0):d?this.device.gl.drawElements(h,a||0,_,u):l?this.device.gl.drawArraysInstanced(h,u,a||0,c||0):this.device.gl.drawArrays(h,u,a||0),f&&f.end()}),o.unbindAfterRender(i),!0}async _linkShaders(){const{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),F.time(gc,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),F.timeEnd(gc,`linkProgram for ${this.id}`)(),F.level,!this.device.features.has("compilation-status-async-webgl")){const r=this._getLinkStatus();this._reportLinkStatus(r);return}F.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),F.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const i=this._getLinkStatus();this._reportLinkStatus(i)}async _reportLinkStatus(t){var i;switch(t){case"success":return;default:const r=t==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((i=this.fs)==null?void 0:i.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const s=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${s}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(const i of this.shaderLayout.bindings)!this.bindings[i.name]&&!this.bindings[i.name.replace(/Uniforms$/,"")]&&(F.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:t}=this.device;t.useProgram(this.handle);let i=0,r=0;for(const s of this.shaderLayout.bindings){const o=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":const{name:a}=s,c=t.getUniformBlockIndex(this.handle,a);if(c===4294967295)throw new Error(`Invalid uniform block name ${a}`);t.uniformBlockBinding(this.handle,r,c),o instanceof Bn?t.bindBufferBase(35345,r,o.handle):t.bindBufferRange(35345,r,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),r+=1;break;case"texture":if(!(o instanceof fn||o instanceof zn||o instanceof On))throw new Error("texture");let l;if(o instanceof fn)l=o.texture;else if(o instanceof zn)l=o;else if(o instanceof On&&o.colorAttachments[0]instanceof fn)F.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=o.colorAttachments[0].texture;else throw new Error("No texture");t.activeTexture(33984+i),t.bindTexture(l.glTarget,l.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(const t of this.shaderLayout.uniforms||[]){const{name:i,location:r,type:s,textureUnit:o}=t,a=this.uniforms[i]??o;a!==void 0&&jg(this.device.gl,r,s,a)}}}function Jg(n,e){const t={...n,attributes:n.attributes.map(i=>({...i}))};for(const i of(e==null?void 0:e.attributes)||[]){const r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):F.warn(`shader layout attribute ${i.name} not present in shader`)}return t}class Gg extends ms{constructor(t){super(t,{});m(this,"device");m(this,"handle",null);m(this,"commands",[]);this.device=t}_executeCommands(t=this.commands){for(const i of t)switch(i.name){case"copy-buffer-to-buffer":e_(this.device,i.options);break;case"copy-buffer-to-texture":t_(this.device,i.options);break;case"copy-texture-to-buffer":n_(this.device,i.options);break;case"copy-texture-to-texture":i_(this.device,i.options);break;default:throw new Error(i.name)}}}function e_(n,e){const t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function t_(n,e){throw new Error("Not implemented")}function n_(n,e){const{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:c=[0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==0||f||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:_}=_c(t);let I;try{const C=l,w=s||d.width,M=o||d.height,E=lc(d.colorAttachments[0].texture.props.format),x=E.format,R=E.type;n.gl.bindBuffer(35051,C.handle),I=n.gl.bindFramebuffer(36160,d.handle),n.gl.readPixels(c[0],c[1],w,M,x,R,u)}finally{n.gl.bindBuffer(35051,null),I!==void 0&&n.gl.bindFramebuffer(36160,I),_&&d.destroy()}}function i_(n,e){const{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0],destinationTexture:o}=e;let{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e;const{framebuffer:l,destroyFramebuffer:u}=_c(t),[f,h]=r,[d,_,I]=s,C=n.gl.bindFramebuffer(36160,l.handle);let w,M;if(o instanceof zn)w=o,a=Number.isFinite(a)?a:w.width,c=Number.isFinite(c)?c:w.height,w._bind(0),M=w.glTarget;else throw new Error("invalid destination");switch(M){case 3553:case 34067:n.gl.copyTexSubImage2D(M,i,d,_,f,h,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(M,i,d,_,I,f,h,a,c);break}w&&w._unbind(),n.gl.bindFramebuffer(36160,C),u&&l.destroy()}function _c(n){if(n instanceof G){const{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}const r_=[1,2,4,8];class s_ extends ds{constructor(t,i){var o;super(t,i);m(this,"device");m(this,"handle",null);m(this,"glParameters",{});this.device=t;let r;if(!((o=i==null?void 0:i.parameters)!=null&&o.viewport))if(i!=null&&i.framebuffer){const{width:a,height:c}=i.framebuffer;r=[0,0,a,c]}else{const[a,c]=t.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,a,c]}this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters});const s=this.props.framebuffer;if(this.props.framebuffer&&(s!=null&&s.handle)){const a=this.props.framebuffer.colorAttachments.map((c,l)=>36064+l);this.device.gl.drawBuffers(a)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){const i={...this.glParameters};i.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(i.depthMask=!this.props.depthReadOnly),i.stencilMask=this.props.stencilReadOnly?0:1,i[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(i.viewport=t.viewport.slice(0,4),i.depthRange=[t.viewport[4],t.viewport[5]]):i.viewport=t.viewport),t.scissorRect&&(i.scissorTest=!0,i.scissor=t.scissorRect),t.blendConstant&&(i.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),i[2967]=t.stencilReference),"colorMask"in t&&(i.colorMask=r_.map(r=>!!(r&t.colorMask))),this.glParameters=i,an(this.device.gl,i)}beginOcclusionQuery(t){const i=this.props.occlusionQuerySet;i==null||i.beginOcclusionQuery()}endOcclusionQuery(){const t=this.props.occlusionQuerySet;t==null||t.endOcclusionQuery()}clear(){const t={...this.glParameters};let i=0;this.props.clearColors&&this.props.clearColors.forEach((r,s)=>{r&&this.clearColorBuffer(s,r)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(i|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(i|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(i|=1024,t.clearStencil=this.props.clearStencil),i!==0&&Un(this.device.gl,t,()=>{this.device.gl.clear(i)})}clearColorBuffer(t=0,i=[0,0,0,0]){Un(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(i.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,i);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,i);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,i);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class xc extends ps{constructor(t,i){super(t,i);m(this,"device");m(this,"handle",null);m(this,"commandBuffer");this.device=t,this.commandBuffer=new Gg(t)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(t){return new s_(this.device,t)}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,i,r){}}function o_(n){const{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s;let a=0;for(let c=i;a<s;a++)e[c++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+o-a),a=o);return n.target}class Es extends gs{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"buffer",null);m(this,"bufferValue",null);this.device=t,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return xp()==="Chrome"}destroy(){var t;super.destroy(),this.buffer&&((t=this.buffer)==null||t.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){const i=t;if(i&&i.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,i?i.handle:null),this.indexBuffer=i,this.device.gl.bindVertexArray(null)}setBuffer(t,i){const r=i;if(r.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:s,type:o,stride:a,offset:c,normalized:l,integer:u,divisor:f}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,r.handle),u?this.device.gl.vertexAttribIPointer(t,s,o,a,c):this.device.gl.vertexAttribPointer(t,s,o,l,a,c),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,f||0),this.attributes[t]=r,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,i){this._enable(t,!1),this.attributes[t]=i}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){const i=this.attributes[t];ArrayBuffer.isView(i)&&this.device.setConstantAttributeWebGL(t,i)}}_getAccessor(t){const i=this.attributeInfos[t];if(!i)throw new Error(`Unknown attribute location ${t}`);const r=oc(i.bufferDataType);return{size:i.bufferComponents,type:r,stride:i.byteStride,offset:i.byteOffset,normalized:i.normalized,integer:i.integer,divisor:i.stepMode==="instance"?1:0}}_enable(t,i=!0){const s=Es.isConstantAttributeZeroSupported(this.device)||t!==0;(i||s)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),i?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,i){const r=a_(i),s=r.byteLength*t,o=r.length*t;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),a||(a=!c_(r,this.bufferValue)),a){const c=Sm(i.constructor,o);o_({target:c,source:r,start:0,count:o}),this.buffer.write(c),this.bufferValue=i}return this.buffer}}function a_(n){return Array.isArray(n)?new Float32Array(n):n}function c_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}class l_ extends _s{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"layout");m(this,"buffers",{});m(this,"unusedBuffers",{});m(this,"bindOnUse",!0);m(this,"_bound",!1);this.device=t,this.gl=t.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,i.buffers&&this.setBuffers(i.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zg(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const i in t)this.setBuffer(i,t[i])})}setBuffer(t,i){const r=this._getVaryingIndex(t),{buffer:s,byteLength:o,byteOffset:a}=this._getBufferRange(i);if(r<0){this.unusedBuffers[t]=s,F.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[r]={buffer:s,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(r,s,a,o)}getBuffer(t){if(yc(t))return this.buffers[t]||null;const i=this._getVaryingIndex(t);return i>=0?this.buffers[i]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let i;return this._bound?i=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,i=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),i}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof Bn)return{buffer:t,byteOffset:0,byteLength:t.byteLength};const{buffer:i,byteOffset:r=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:i,byteOffset:r,byteLength:s}}_getVaryingIndex(t){if(yc(t))return Number(t);for(const i of this.layout.varyings||[])if(t===i.name)return i.location;return-1}_bindBuffers(){for(const t in this.buffers){const{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),i,s,r)}}_unbindBuffers(){for(const t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,i,r=0,s){const o=i&&i.handle;!o||s===void 0?this.gl.bindBufferBase(35982,t,o):this.gl.bindBufferRange(35982,t,o,r,s)}}function yc(n){return typeof n=="number"?Number.isInteger(n):/^\d+$/.test(n)}class u_ extends xs{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"target",null);m(this,"_queryPending",!1);m(this,"_pollingPromise",null);if(this.device=t,i.count>1)throw new Error("WebGL QuerySet can only have one value");const r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");this.handle=r,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(t){return this._begin(t!=null&&t.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let i=0;return this._pollingPromise=new Promise((r,s)=>{const o=()=>{this.isResultAvailable()?(r(this.getResult()),this._pollingPromise=null):i++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}}function vc(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function f_(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function h_(n){return d_[n]}const d_={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function p_(n,e){var M;const{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{};const{framebuffer:f,deleteFramebuffer:h}=bc(n),{gl:d,handle:_}=f;o||(o=f.width),a||(a=f.height);const I=(M=f.colorAttachments[r])==null?void 0:M.texture;if(!I)throw new Error(`Invalid framebuffer attachment ${r}`);c=(I==null?void 0:I.depth)||1,l||(l=(I==null?void 0:I.glFormat)||6408),u||(u=(I==null?void 0:I.glType)||5121),s=__(s,u,l,o,a);const C=Oa(s);u=u||Bg(C);const w=d.bindFramebuffer(36160,_);return d.readBuffer(36064+r),d.readPixels(t,i,o,a,l,u,s),d.readBuffer(36064),d.bindFramebuffer(36160,w||null),h&&f.destroy(),s}function m_(n,e){const{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{};let{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{};const{framebuffer:u,deleteFramebuffer:f}=bc(n);a=a||u.width,c=c||u.height;const h=u;l=l||5121;let d=t;if(!d){const I=vc(s),C=f_(l),w=o+a*c*I*C;d=h.device.createBuffer({byteLength:w})}const _=n.device.createCommandEncoder();return _.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:d,byteOffset:o}),_.destroy(),f&&u.destroy(),d}function bc(n){return n instanceof Ni?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:g_(n),deleteFramebuffer:!0}}function g_(n,e){const{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function __(n,e,t,i,r,s){if(n)return n;e||(e=5121);const o=h_(e),a=Ba(o),c=vc(t);return new a(i*r*c)}class x_ extends zt{constructor(t){var f,h;super({...t,id:t.id||Tg("webgl-device")});m(this,"type","webgl");m(this,"handle");m(this,"features");m(this,"limits");m(this,"info");m(this,"canvasContext");m(this,"preferredColorFormat","rgba8unorm");m(this,"preferredDepthFormat","depth24plus");m(this,"commandEncoder");m(this,"lost");m(this,"_resolveContextLost");m(this,"gl");m(this,"_constants");m(this,"_extensions",{});m(this,"_polyfilled",!1);m(this,"spectorJS");const i=zt._getCanvasContextProps(t);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let r=(h=(f=i.canvas)==null?void 0:f.gl)==null?void 0:h.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Sg(this,i),this.lost=new Promise(d=>{this._resolveContextLost=d});const s={...t.webgl};i.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference);const a=this.props._handle||ng(this.canvasContext.canvas,{onContextLost:d=>{var _;return(_=this._resolveContextLost)==null?void 0:_.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:d=>console.log("WebGL context restored")},s);if(!a)throw new Error("WebGL context creation failed");if(r=a.device,r){if(t._reuseDevices)return F.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=Bm({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=ig(this.gl,this._extensions),this.limits=new yg(this.gl),this.features=new xg(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Vt(this.gl,{log:(...d)=>F.log(1,...d)()}).trackState(this.gl,{copyState:!1});const l=t.debugWebGL||t.debug,u=t.debugWebGL;l&&(this.gl=Lm(this.gl,{debugWebGL:l,traceWebGL:u}),F.warn("WebGL debug mode activated. Performance reduced.")(),t.debugWebGL&&(F.level=Math.max(F.level,1))),this.commandEncoder=new xc(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){switch(t){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){const i=this._normalizeBufferProps(t);return new Bn(this,i)}createTexture(t){return new zn(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Mg(this,t)}createShader(t){return new Pg(this,t)}createFramebuffer(t){return new On(this,t)}createVertexArray(t){return new Es(this,t)}createTransformFeedback(t){return new l_(this,t)}createQuerySet(t){return new u_(this,t)}createRenderPipeline(t){return new Qg(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(t={}){return new xc(this,t)}submit(t){t||(t=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),t._executeCommands()}readPixelsToArrayWebGL(t,i){return p_(t,i)}readPixelsToBufferWebGL(t,i){return m_(t,i)}setParametersWebGL(t){an(this.gl,t)}getParametersWebGL(t){return nc(this.gl,t)}withParametersWebGL(t,i){return Un(this.gl,t,i)}resetWebGL(){F.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Qm(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return pg(this.gl,t,this._extensions)}loseDevice(){var s;let t=!1;const r=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return r&&(t=!0,r.loseContext()),(s=this._resolveContextLost)==null||s.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){Vt.get(this.gl).push()}popState(){Vt.get(this.gl).pop()}getGLKey(t,i){const r=Number(t);for(const s in this.gl)if(this.gl[s]===r)return`GL.${s}`;return i!=null&&i.emptyIfUnknown?"":String(t)}getGLKeys(t){const i={emptyIfUnknown:!0};return Object.entries(t).reduce((r,[s,o])=>(r[`${s}:${this.getGLKey(s,i)}`]=`${o}:${this.getGLKey(o,i)}`,r),{})}setConstantAttributeWebGL(t,i){const r=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(r).fill(null);const s=this._constants[t];switch(s&&S_(s,i)&&F.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=i,i.constructor){case Float32Array:y_(this,t,i);break;case Int32Array:v_(this,t,i);break;case Uint32Array:b_(this,t,i);break;default:throw new Error("constant")}}getExtension(t){return cn(this.gl,t,this._extensions),this._extensions}_setWebGLDebugMetadata(t,i,r){t.luma=i;const s={props:r.spector,id:r.spector.id};t.__SPECTOR_Metadata=s}}function y_(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break}}function v_(n,e,t){n.gl.vertexAttribI4iv(e,t)}function b_(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function S_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}const Sc=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:x_},Symbol.toStringTag,{value:"Module"})),T_="#b3b3b3",w_=void 0,ks=void 0,A_=1,C_=4,P_="#666666",I_=.1,R_=1,E_=1,Tc="#222222",H={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,useClassicQuadtree:!1,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,repulsionQuadtreeLevels:12,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},k_=.7,F_=.95,D_=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:wc,setPrototypeOf:Ac,isFrozen:M_,getPrototypeOf:N_,getOwnPropertyDescriptor:O_}=Object;let{freeze:Oe,seal:Ke,create:Cc}=Object,{apply:Fs,construct:Ds}=typeof Reflect<"u"&&Reflect;Oe||(Oe=function(e){return e}),Ke||(Ke=function(e){return e}),Fs||(Fs=function(e,t,i){return e.apply(t,i)}),Ds||(Ds=function(e,t){return new e(...t)});const Vi=Ue(Array.prototype.forEach),B_=Ue(Array.prototype.lastIndexOf),Pc=Ue(Array.prototype.pop),Ln=Ue(Array.prototype.push),U_=Ue(Array.prototype.splice),Hi=Ue(String.prototype.toLowerCase),Ms=Ue(String.prototype.toString),Ic=Ue(String.prototype.match),Vn=Ue(String.prototype.replace),z_=Ue(String.prototype.indexOf),L_=Ue(String.prototype.trim),it=Ue(Object.prototype.hasOwnProperty),Be=Ue(RegExp.prototype.test),Hn=V_(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Fs(n,e,i)}}function V_(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Ds(n,t)}}function ne(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Hi;Ac&&Ac(n,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const s=t(r);s!==r&&(M_(e)||(e[i]=s),r=s)}n[r]=!0}return n}function H_(n){for(let e=0;e<n.length;e++)it(n,e)||(n[e]=null);return n}function yt(n){const e=Cc(null);for(const[t,i]of wc(n))it(n,t)&&(Array.isArray(i)?e[t]=H_(i):i&&typeof i=="object"&&i.constructor===Object?e[t]=yt(i):e[t]=i);return e}function Wn(n,e){for(;n!==null;){const i=O_(n,e);if(i){if(i.get)return Ue(i.get);if(typeof i.value=="function")return Ue(i.value)}n=N_(n)}function t(){return null}return t}const Rc=Oe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ns=Oe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Os=Oe(["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"]),W_=Oe(["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"]),Bs=Oe(["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"]),$_=Oe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ec=Oe(["#text"]),kc=Oe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Us=Oe(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fc=Oe(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wi=Oe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),X_=Ke(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y_=Ke(/<%[\w\W]*|[\w\W]*%>/gm),q_=Ke(/\$\{[\w\W]*/gm),j_=Ke(/^data-[\-\w.\u00B7-\uFFFF]+$/),K_=Ke(/^aria-[\-\w]+$/),Dc=Ke(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Z_=Ke(/^(?:\w+script|data):/i),Q_=Ke(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Mc=Ke(/^html$/i),J_=Ke(/^[a-z][.\w]*(-[.\w]+)+$/i);var Nc=Object.freeze({__proto__:null,ARIA_ATTR:K_,ATTR_WHITESPACE:Q_,CUSTOM_ELEMENT:J_,DATA_ATTR:j_,DOCTYPE_NAME:Mc,ERB_EXPR:Y_,IS_ALLOWED_URI:Dc,IS_SCRIPT_OR_DATA:Z_,MUSTACHE_EXPR:X_,TMPLIT_EXPR:q_});const $n={element:1,text:3,progressingInstruction:7,comment:8,document:9},G_=function(){return typeof window>"u"?null:window},ex=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Oc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Bc(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:G_();const e=Y=>Bc(Y);if(e.version="3.2.6",e.removed=[],!n||!n.document||n.document.nodeType!==$n.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const i=t,r=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:l,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:h,trustedTypes:d}=n,_=c.prototype,I=Wn(_,"cloneNode"),C=Wn(_,"remove"),w=Wn(_,"nextSibling"),M=Wn(_,"childNodes"),E=Wn(_,"parentNode");if(typeof o=="function"){const Y=t.createElement("template");Y.content&&Y.content.ownerDocument&&(t=Y.content.ownerDocument)}let x,R="";const{implementation:B,createNodeIterator:L,createDocumentFragment:W,getElementsByTagName:q}=t,{importNode:J}=i;let O=Oc();e.isSupported=typeof wc=="function"&&typeof E=="function"&&B&&B.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:oe,ERB_EXPR:te,TMPLIT_EXPR:P,DATA_ATTR:V,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:K,CUSTOM_ELEMENT:j}=Nc;let{IS_ALLOWED_URI:ee}=Nc,Q=null;const he=ne({},[...Rc,...Ns,...Os,...Bs,...Ec]);let ue=null;const be=ne({},[...kc,...Us,...Fc,...Wi]);let ie=Object.seal(Cc(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}})),Le=null,Ve=null,Ge=!0,Kt=!0,bu=!1,Su=!0,_n=!1,Mr=!0,Zt=!1,Ro=!1,Eo=!1,xn=!1,Nr=!1,Or=!1,Tu=!0,wu=!1;const qb="user-content-";let ko=!0,ri=!1,yn={},vn=null;const Au=ne({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Cu=null;const Pu=ne({},["audio","video","img","source","image","track"]);let Fo=null;const Iu=ne({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Br="http://www.w3.org/1998/Math/MathML",Ur="http://www.w3.org/2000/svg",At="http://www.w3.org/1999/xhtml";let bn=At,Do=!1,Mo=null;const jb=ne({},[Br,Ur,At],Ms);let zr=ne({},["mi","mo","mn","ms","mtext"]),Lr=ne({},["annotation-xml"]);const Kb=ne({},["title","style","font","a","script"]);let si=null;const Zb=["application/xhtml+xml","text/html"],Qb="text/html";let Pe=null,Sn=null;const Jb=t.createElement("form"),Ru=function(y){return y instanceof RegExp||y instanceof Function},No=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Sn&&Sn===y)){if((!y||typeof y!="object")&&(y={}),y=yt(y),si=Zb.indexOf(y.PARSER_MEDIA_TYPE)===-1?Qb:y.PARSER_MEDIA_TYPE,Pe=si==="application/xhtml+xml"?Ms:Hi,Q=it(y,"ALLOWED_TAGS")?ne({},y.ALLOWED_TAGS,Pe):he,ue=it(y,"ALLOWED_ATTR")?ne({},y.ALLOWED_ATTR,Pe):be,Mo=it(y,"ALLOWED_NAMESPACES")?ne({},y.ALLOWED_NAMESPACES,Ms):jb,Fo=it(y,"ADD_URI_SAFE_ATTR")?ne(yt(Iu),y.ADD_URI_SAFE_ATTR,Pe):Iu,Cu=it(y,"ADD_DATA_URI_TAGS")?ne(yt(Pu),y.ADD_DATA_URI_TAGS,Pe):Pu,vn=it(y,"FORBID_CONTENTS")?ne({},y.FORBID_CONTENTS,Pe):Au,Le=it(y,"FORBID_TAGS")?ne({},y.FORBID_TAGS,Pe):yt({}),Ve=it(y,"FORBID_ATTR")?ne({},y.FORBID_ATTR,Pe):yt({}),yn=it(y,"USE_PROFILES")?y.USE_PROFILES:!1,Ge=y.ALLOW_ARIA_ATTR!==!1,Kt=y.ALLOW_DATA_ATTR!==!1,bu=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Su=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,_n=y.SAFE_FOR_TEMPLATES||!1,Mr=y.SAFE_FOR_XML!==!1,Zt=y.WHOLE_DOCUMENT||!1,xn=y.RETURN_DOM||!1,Nr=y.RETURN_DOM_FRAGMENT||!1,Or=y.RETURN_TRUSTED_TYPE||!1,Eo=y.FORCE_BODY||!1,Tu=y.SANITIZE_DOM!==!1,wu=y.SANITIZE_NAMED_PROPS||!1,ko=y.KEEP_CONTENT!==!1,ri=y.IN_PLACE||!1,ee=y.ALLOWED_URI_REGEXP||Dc,bn=y.NAMESPACE||At,zr=y.MATHML_TEXT_INTEGRATION_POINTS||zr,Lr=y.HTML_INTEGRATION_POINTS||Lr,ie=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Ru(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ie.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Ru(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ie.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),_n&&(Kt=!1),Nr&&(xn=!0),yn&&(Q=ne({},Ec),ue=[],yn.html===!0&&(ne(Q,Rc),ne(ue,kc)),yn.svg===!0&&(ne(Q,Ns),ne(ue,Us),ne(ue,Wi)),yn.svgFilters===!0&&(ne(Q,Os),ne(ue,Us),ne(ue,Wi)),yn.mathMl===!0&&(ne(Q,Bs),ne(ue,Fc),ne(ue,Wi))),y.ADD_TAGS&&(Q===he&&(Q=yt(Q)),ne(Q,y.ADD_TAGS,Pe)),y.ADD_ATTR&&(ue===be&&(ue=yt(ue)),ne(ue,y.ADD_ATTR,Pe)),y.ADD_URI_SAFE_ATTR&&ne(Fo,y.ADD_URI_SAFE_ATTR,Pe),y.FORBID_CONTENTS&&(vn===Au&&(vn=yt(vn)),ne(vn,y.FORBID_CONTENTS,Pe)),ko&&(Q["#text"]=!0),Zt&&ne(Q,["html","head","body"]),Q.table&&(ne(Q,["tbody"]),delete Le.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Hn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Hn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=y.TRUSTED_TYPES_POLICY,R=x.createHTML("")}else x===void 0&&(x=ex(d,r)),x!==null&&typeof R=="string"&&(R=x.createHTML(""));Oe&&Oe(y),Sn=y}},Eu=ne({},[...Ns,...Os,...W_]),ku=ne({},[...Bs,...$_]),Gb=function(y){let N=E(y);(!N||!N.tagName)&&(N={namespaceURI:bn,tagName:"template"});const X=Hi(y.tagName),me=Hi(N.tagName);return Mo[y.namespaceURI]?y.namespaceURI===Ur?N.namespaceURI===At?X==="svg":N.namespaceURI===Br?X==="svg"&&(me==="annotation-xml"||zr[me]):!!Eu[X]:y.namespaceURI===Br?N.namespaceURI===At?X==="math":N.namespaceURI===Ur?X==="math"&&Lr[me]:!!ku[X]:y.namespaceURI===At?N.namespaceURI===Ur&&!Lr[me]||N.namespaceURI===Br&&!zr[me]?!1:!ku[X]&&(Kb[X]||!Eu[X]):!!(si==="application/xhtml+xml"&&Mo[y.namespaceURI]):!1},mt=function(y){Ln(e.removed,{element:y});try{E(y).removeChild(y)}catch{C(y)}},Tn=function(y,N){try{Ln(e.removed,{attribute:N.getAttributeNode(y),from:N})}catch{Ln(e.removed,{attribute:null,from:N})}if(N.removeAttribute(y),y==="is")if(xn||Nr)try{mt(N)}catch{}else try{N.setAttribute(y,"")}catch{}},Fu=function(y){let N=null,X=null;if(Eo)y="<remove></remove>"+y;else{const Ae=Ic(y,/^[\r\n\t ]+/);X=Ae&&Ae[0]}si==="application/xhtml+xml"&&bn===At&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const me=x?x.createHTML(y):y;if(bn===At)try{N=new h().parseFromString(me,si)}catch{}if(!N||!N.documentElement){N=B.createDocument(bn,"template",null);try{N.documentElement.innerHTML=Do?R:me}catch{}}const De=N.body||N.documentElement;return y&&X&&De.insertBefore(t.createTextNode(X),De.childNodes[0]||null),bn===At?q.call(N,Zt?"html":"body")[0]:Zt?N.documentElement:De},Du=function(y){return L.call(y.ownerDocument||y,y,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Oo=function(y){return y instanceof f&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof u)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Mu=function(y){return typeof a=="function"&&y instanceof a};function Ct(Y,y,N){Vi(Y,X=>{X.call(e,y,N,Sn)})}const Nu=function(y){let N=null;if(Ct(O.beforeSanitizeElements,y,null),Oo(y))return mt(y),!0;const X=Pe(y.nodeName);if(Ct(O.uponSanitizeElement,y,{tagName:X,allowedTags:Q}),Mr&&y.hasChildNodes()&&!Mu(y.firstElementChild)&&Be(/<[/\w!]/g,y.innerHTML)&&Be(/<[/\w!]/g,y.textContent)||y.nodeType===$n.progressingInstruction||Mr&&y.nodeType===$n.comment&&Be(/<[/\w]/g,y.data))return mt(y),!0;if(!Q[X]||Le[X]){if(!Le[X]&&Bu(X)&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,X)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(X)))return!1;if(ko&&!vn[X]){const me=E(y)||y.parentNode,De=M(y)||y.childNodes;if(De&&me){const Ae=De.length;for(let $e=Ae-1;$e>=0;--$e){const Pt=I(De[$e],!0);Pt.__removalCount=(y.__removalCount||0)+1,me.insertBefore(Pt,w(y))}}}return mt(y),!0}return y instanceof c&&!Gb(y)||(X==="noscript"||X==="noembed"||X==="noframes")&&Be(/<\/no(script|embed|frames)/i,y.innerHTML)?(mt(y),!0):(_n&&y.nodeType===$n.text&&(N=y.textContent,Vi([oe,te,P],me=>{N=Vn(N,me," ")}),y.textContent!==N&&(Ln(e.removed,{element:y.cloneNode()}),y.textContent=N)),Ct(O.afterSanitizeElements,y,null),!1)},Ou=function(y,N,X){if(Tu&&(N==="id"||N==="name")&&(X in t||X in Jb))return!1;if(!(Kt&&!Ve[N]&&Be(V,N))){if(!(Ge&&Be(D,N))){if(!ue[N]||Ve[N]){if(!(Bu(y)&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,y)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(y))&&(ie.attributeNameCheck instanceof RegExp&&Be(ie.attributeNameCheck,N)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(N))||N==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,X)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(X))))return!1}else if(!Fo[N]){if(!Be(ee,Vn(X,K,""))){if(!((N==="src"||N==="xlink:href"||N==="href")&&y!=="script"&&z_(X,"data:")===0&&Cu[y])){if(!(bu&&!Be($,Vn(X,K,"")))){if(X)return!1}}}}}}return!0},Bu=function(y){return y!=="annotation-xml"&&Ic(y,j)},Uu=function(y){Ct(O.beforeSanitizeAttributes,y,null);const{attributes:N}=y;if(!N||Oo(y))return;const X={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ue,forceKeepAttr:void 0};let me=N.length;for(;me--;){const De=N[me],{name:Ae,namespaceURI:$e,value:Pt}=De,oi=Pe(Ae),Bo=Pt;let Me=Ae==="value"?Bo:L_(Bo);if(X.attrName=oi,X.attrValue=Me,X.keepAttr=!0,X.forceKeepAttr=void 0,Ct(O.uponSanitizeAttribute,y,X),Me=X.attrValue,wu&&(oi==="id"||oi==="name")&&(Tn(Ae,y),Me=qb+Me),Mr&&Be(/((--!?|])>)|<\/(style|title)/i,Me)){Tn(Ae,y);continue}if(X.forceKeepAttr)continue;if(!X.keepAttr){Tn(Ae,y);continue}if(!Su&&Be(/\/>/i,Me)){Tn(Ae,y);continue}_n&&Vi([oe,te,P],Lu=>{Me=Vn(Me,Lu," ")});const zu=Pe(y.nodeName);if(!Ou(zu,oi,Me)){Tn(Ae,y);continue}if(x&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!$e)switch(d.getAttributeType(zu,oi)){case"TrustedHTML":{Me=x.createHTML(Me);break}case"TrustedScriptURL":{Me=x.createScriptURL(Me);break}}if(Me!==Bo)try{$e?y.setAttributeNS($e,Ae,Me):y.setAttribute(Ae,Me),Oo(y)?mt(y):Pc(e.removed)}catch{Tn(Ae,y)}}Ct(O.afterSanitizeAttributes,y,null)},e0=function Y(y){let N=null;const X=Du(y);for(Ct(O.beforeSanitizeShadowDOM,y,null);N=X.nextNode();)Ct(O.uponSanitizeShadowNode,N,null),Nu(N),Uu(N),N.content instanceof s&&Y(N.content);Ct(O.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(Y){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=null,X=null,me=null,De=null;if(Do=!Y,Do&&(Y="<!-->"),typeof Y!="string"&&!Mu(Y))if(typeof Y.toString=="function"){if(Y=Y.toString(),typeof Y!="string")throw Hn("dirty is not a string, aborting")}else throw Hn("toString is not a function");if(!e.isSupported)return Y;if(Ro||No(y),e.removed=[],typeof Y=="string"&&(ri=!1),ri){if(Y.nodeName){const Pt=Pe(Y.nodeName);if(!Q[Pt]||Le[Pt])throw Hn("root node is forbidden and cannot be sanitized in-place")}}else if(Y instanceof a)N=Fu("<!---->"),X=N.ownerDocument.importNode(Y,!0),X.nodeType===$n.element&&X.nodeName==="BODY"||X.nodeName==="HTML"?N=X:N.appendChild(X);else{if(!xn&&!_n&&!Zt&&Y.indexOf("<")===-1)return x&&Or?x.createHTML(Y):Y;if(N=Fu(Y),!N)return xn?null:Or?R:""}N&&Eo&&mt(N.firstChild);const Ae=Du(ri?Y:N);for(;me=Ae.nextNode();)Nu(me),Uu(me),me.content instanceof s&&e0(me.content);if(ri)return Y;if(xn){if(Nr)for(De=W.call(N.ownerDocument);N.firstChild;)De.appendChild(N.firstChild);else De=N;return(ue.shadowroot||ue.shadowrootmode)&&(De=J.call(i,De,!0)),De}let $e=Zt?N.outerHTML:N.innerHTML;return Zt&&Q["!doctype"]&&N.ownerDocument&&N.ownerDocument.doctype&&N.ownerDocument.doctype.name&&Be(Mc,N.ownerDocument.doctype.name)&&($e="<!DOCTYPE "+N.ownerDocument.doctype.name+`>
|
|
13
|
-
`+$e),_n&&Vi([
|
|
11
|
+
</pre></code>`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(u=document.getElementsByClassName("luma-compiler-log-error")[0])==null||u.scrollIntoView(),l.onclick=()=>{const f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}};m(br,"defaultProps",{...oe.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Mi=br;function cm(n){return um(n.source)||n.id||Pi(`unnamed ${n.stage}-shader`)}function um(n,e="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n);return i?i[1]:e}const Sr=class Sr extends oe{constructor(t,i={}){super(t,i,Sr.defaultProps);m(this,"width");m(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(t){const i=this.colorAttachments.map(s=>s.texture.clone(t)),r=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(t);return this.device.createFramebuffer({...this.props,colorAttachments:i,depthStencilAttachment:r})}resize(t){let i=!t;if(t){const[r,s]=Array.isArray(t)?t:[t.width,t.height];i=i||s!==this.height||r!==this.width,this.width=r,this.height=s}i&&(D.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((i,r)=>{if(typeof i=="string"){const s=this.createColorTexture(i,r);return this.attachResource(s),s.view}return i instanceof J?i.view:i});const t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){const i=this.createDepthStencilTexture(t);this.attachResource(i),this.depthStencilAttachment=i.view}else t instanceof J?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t,i){return this.device.createTexture({id:`${this.id}-color-attachment-${i}`,usage:J.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(t){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:J.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,i){for(let r=0;r<this.colorAttachments.length;++r)if(this.colorAttachments[r]){const s=this.colorAttachments[r].texture.clone({width:t,height:i});this.destroyAttachedResource(this.colorAttachments[r]),this.colorAttachments[r]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){const r=this.depthStencilAttachment.texture.clone({width:t,height:i});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=r.view,this.attachResource(r)}this.updateAttachments()}};m(Sr,"defaultProps",{...oe.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let Ni=Sr;const Tr=class Tr extends oe{constructor(t,i){super(t,i,Tr.defaultProps);m(this,"shaderLayout");m(this,"bufferLayout");m(this,"linkStatus","pending");m(this,"hash","");this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};m(Tr,"defaultProps",{...oe.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Lt=Tr;const at=class at extends oe{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=at.normalizeProps(e,t),super(e,t,at.defaultProps)}static normalizeProps(e,t){return t}};m(at,"defaultClearColor",[0,0,0,1]),m(at,"defaultClearDepth",1),m(at,"defaultClearStencil",0),m(at,"defaultProps",{...oe.defaultProps,framebuffer:null,parameters:void 0,clearColor:at.defaultClearColor,clearColors:void 0,clearDepth:at.defaultClearDepth,clearStencil:at.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let ds=at;const wr=class wr extends oe{constructor(t,i){super(t,i,wr.defaultProps);m(this,"hash","");m(this,"shaderLayout");this.shaderLayout=i.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};m(wr,"defaultProps",{...oe.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Oi=wr;const Ar=class Ar extends oe{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ar.defaultProps)}};m(Ar,"defaultProps",{...oe.defaultProps,measureExecutionTime:void 0});let ps=Ar;const Cr=class Cr extends oe{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Cr.defaultProps)}};m(Cr,"defaultProps",{...oe.defaultProps});let ms=Cr;function Xa(n){return pm[n]}function fm(n){const[e,t]=dm[n],i=e==="i32"||e==="u32",r=e!=="u32",s=hm[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:r}}const hm={f32:4,f16:2,i32:4,u32:4},dm={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]},pm={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function Ya(n,e){const t={};for(const i of n.attributes){const r=gm(n,e,i.name);r&&(t[i.name]=r)}return t}function mm(n,e,t=16){const i=Ya(n,e),r=new Array(t).fill(null);for(const s of Object.values(i))r[s.location]=s;return r}function gm(n,e,t){const i=_m(n,t),r=xm(e,t);if(!i)return null;const s=fm(i.type),o=Mp(s),a=(r==null?void 0:r.vertexFormat)||o,l=os(a);return{attributeName:(r==null?void 0:r.attributeName)||i.name,bufferName:(r==null?void 0:r.bufferName)||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:s.integer,stepMode:(r==null?void 0:r.stepMode)||i.stepMode||"vertex",byteOffset:(r==null?void 0:r.byteOffset)||0,byteStride:(r==null?void 0:r.byteStride)||0}}function _m(n,e){const t=n.attributes.find(i=>i.name===e);return t||D.warn(`shader layout attribute "${e}" not present in shader`),t||null}function xm(n,e){ym(n);let t=vm(n,e);return t||(t=bm(n,e),t)?t:(D.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ym(n){for(const e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&D.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function vm(n,e){for(const t of n)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function bm(n,e){var t;for(const i of n){let r=i.byteStride;if(typeof i.byteStride!="number")for(const o of i.attributes||[]){const a=os(o.format);r+=a.byteLength}const s=(t=i.attributes)==null?void 0:t.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:r}}return null}const Pr=class Pr extends oe{constructor(t,i){super(t,i,Pr.defaultProps);m(this,"maxVertexAttributes");m(this,"attributeInfos");m(this,"indexBuffer",null);m(this,"attributes");this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=mm(i.shaderLayout,i.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(t,i){this.device.reportError(new Error("constant attributes not supported"),this)()}};m(Pr,"defaultProps",{...oe.defaultProps,shaderLayout:void 0,bufferLayout:[]});let gs=Pr;const Ir=class Ir extends oe{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Ir.defaultProps)}};m(Ir,"defaultProps",{...oe.defaultProps,layout:void 0,buffers:{}});let _s=Ir;const Rr=class Rr extends oe{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Rr.defaultProps)}};m(Rr,"defaultProps",{...oe.defaultProps,type:void 0,count:void 0});let xs=Rr,Bi;function qa(n){return(!Bi||Bi.byteLength<n)&&(Bi=new ArrayBuffer(n)),Bi}function Sm(n,e){const t=qa(n.BYTES_PER_ELEMENT*e);return new n(t,0,e)}function Tm(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ui(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":Tm(n)}const wm=1024;class Am{constructor(e,t={}){m(this,"layout",{});m(this,"byteLength");let i=0;for(const[s,o]of Object.entries(e)){const a=Xa(o),{type:l,components:c}=a,u=c*((t==null?void 0:t[s])??1);i=kp(i,u);const f=i;i+=u,this.layout[s]={type:l,size:u,offset:f}}i+=(4-i%4)%4;const r=i*4;this.byteLength=Math.max(r,wm)}getData(e){const t=qa(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[r,s]of Object.entries(e)){const o=this.layout[r];if(!o){D.warn(`Supplied uniform value ${r} not present in uniform block layout`)();continue}const{type:a,size:l,offset:c}=o,u=i[a];if(l===1){if(typeof s!="number"&&typeof s!="boolean"){D.warn(`Supplied value for single component uniform ${r} is not a number: ${s}`)();continue}u[c]=Number(s)}else{if(!Ui(s)){D.warn(`Supplied value for multi component / array uniform ${r} is not a numeric array: ${s}`)();continue}u.set(s,c)}}return new Uint8Array(t,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}function Cm(n,e,t=16){if(n!==e)return!1;const i=n,r=e;if(!Ui(i))return!1;if(Ui(r)&&i.length===r.length){for(let s=0;s<i.length;++s)if(r[s]!==i[s])return!1}return!0}function Pm(n){return Ui(n)?n.slice():n}class Im{constructor(e){m(this,"name");m(this,"uniforms",{});m(this,"modifiedUniforms",{});m(this,"modified",!0);m(this,"bindingLayout",{});m(this,"needsRedraw","initialized");var t;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&(e!=null&&e.shaderLayout)){const i=(t=e==null?void 0:e.shaderLayout.bindings)==null?void 0:t.find(s=>s.type==="uniform"&&s.name===(e==null?void 0:e.name));if(!i)throw new Error(e==null?void 0:e.name);const r=i;for(const s of r.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Cm(this.uniforms[e],t)||(this.uniforms[e]=Pm(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}class ge{constructor(e){m(this,"uniformBlocks",new Map);m(this,"uniformBufferLayouts",new Map);m(this,"uniformBuffers",new Map);for(const[t,i]of Object.entries(e)){const r=t,s=new Am(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(r,s);const o=new Im({name:t});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(r,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[i,r]of Object.entries(e))(t=this.uniformBlocks.get(i))==null||t.setUniforms(r);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var i,r;const t=((i=this.uniformBlocks.get(e))==null?void 0:i.getAllUniforms())||{};return(r=this.uniformBufferLayouts.get(e))==null?void 0:r.getData(t)}createUniformBuffer(e,t,i){i&&this.setUniforms(i);const r=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:z.UNIFORM|z.COPY_DST,byteLength:r}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const i=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:z.UNIFORM|z.COPY_DST,byteLength:i});this.uniformBuffers.set(t,r)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(t);e||(e=i)}return e&&D.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var s;const t=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),r=!1;if(i&&(t!=null&&t.needsRedraw)){r||(r=t.needsRedraw);const o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i==null||i.write(o);const a=(s=this.uniformBlocks.get(e))==null?void 0:s.getAllUniforms();D.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}}var Rt;(function(n){n[n.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",n[n.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",n[n.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n[n.ZERO=0]="ZERO",n[n.ONE=1]="ONE",n[n.SRC_COLOR=768]="SRC_COLOR",n[n.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.DST_ALPHA=772]="DST_ALPHA",n[n.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",n[n.DST_COLOR=774]="DST_COLOR",n[n.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",n[n.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",n[n.CONSTANT_COLOR=32769]="CONSTANT_COLOR",n[n.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",n[n.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",n[n.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",n[n.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",n[n.BLEND_EQUATION=32777]="BLEND_EQUATION",n[n.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",n[n.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",n[n.BLEND_DST_RGB=32968]="BLEND_DST_RGB",n[n.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",n[n.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",n[n.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",n[n.BLEND_COLOR=32773]="BLEND_COLOR",n[n.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",n[n.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",n[n.LINE_WIDTH=2849]="LINE_WIDTH",n[n.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",n[n.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",n[n.CULL_FACE_MODE=2885]="CULL_FACE_MODE",n[n.FRONT_FACE=2886]="FRONT_FACE",n[n.DEPTH_RANGE=2928]="DEPTH_RANGE",n[n.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",n[n.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",n[n.DEPTH_FUNC=2932]="DEPTH_FUNC",n[n.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",n[n.STENCIL_FUNC=2962]="STENCIL_FUNC",n[n.STENCIL_FAIL=2964]="STENCIL_FAIL",n[n.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",n[n.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",n[n.STENCIL_REF=2967]="STENCIL_REF",n[n.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",n[n.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",n[n.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",n[n.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",n[n.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",n[n.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",n[n.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",n[n.VIEWPORT=2978]="VIEWPORT",n[n.SCISSOR_BOX=3088]="SCISSOR_BOX",n[n.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",n[n.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",n[n.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",n[n.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",n[n.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",n[n.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",n[n.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",n[n.RED_BITS=3410]="RED_BITS",n[n.GREEN_BITS=3411]="GREEN_BITS",n[n.BLUE_BITS=3412]="BLUE_BITS",n[n.ALPHA_BITS=3413]="ALPHA_BITS",n[n.DEPTH_BITS=3414]="DEPTH_BITS",n[n.STENCIL_BITS=3415]="STENCIL_BITS",n[n.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",n[n.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",n[n.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",n[n.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",n[n.SAMPLES=32937]="SAMPLES",n[n.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",n[n.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",n[n.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",n[n.VENDOR=7936]="VENDOR",n[n.RENDERER=7937]="RENDERER",n[n.VERSION=7938]="VERSION",n[n.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",n[n.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",n[n.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",n[n.STATIC_DRAW=35044]="STATIC_DRAW",n[n.STREAM_DRAW=35040]="STREAM_DRAW",n[n.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BUFFER_SIZE=34660]="BUFFER_SIZE",n[n.BUFFER_USAGE=34661]="BUFFER_USAGE",n[n.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",n[n.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",n[n.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",n[n.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",n[n.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",n[n.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",n[n.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",n[n.CULL_FACE=2884]="CULL_FACE",n[n.FRONT=1028]="FRONT",n[n.BACK=1029]="BACK",n[n.FRONT_AND_BACK=1032]="FRONT_AND_BACK",n[n.BLEND=3042]="BLEND",n[n.DEPTH_TEST=2929]="DEPTH_TEST",n[n.DITHER=3024]="DITHER",n[n.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",n[n.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",n[n.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",n[n.SCISSOR_TEST=3089]="SCISSOR_TEST",n[n.STENCIL_TEST=2960]="STENCIL_TEST",n[n.NO_ERROR=0]="NO_ERROR",n[n.INVALID_ENUM=1280]="INVALID_ENUM",n[n.INVALID_VALUE=1281]="INVALID_VALUE",n[n.INVALID_OPERATION=1282]="INVALID_OPERATION",n[n.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",n[n.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",n[n.CW=2304]="CW",n[n.CCW=2305]="CCW",n[n.DONT_CARE=4352]="DONT_CARE",n[n.FASTEST=4353]="FASTEST",n[n.NICEST=4354]="NICEST",n[n.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.INT=5124]="INT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.DOUBLE=5130]="DOUBLE",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.ALPHA=6406]="ALPHA",n[n.RGB=6407]="RGB",n[n.RGBA=6408]="RGBA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",n[n.VERTEX_SHADER=35633]="VERTEX_SHADER",n[n.COMPILE_STATUS=35713]="COMPILE_STATUS",n[n.DELETE_STATUS=35712]="DELETE_STATUS",n[n.LINK_STATUS=35714]="LINK_STATUS",n[n.VALIDATE_STATUS=35715]="VALIDATE_STATUS",n[n.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",n[n.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",n[n.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",n[n.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",n[n.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",n[n.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",n[n.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",n[n.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",n[n.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",n[n.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",n[n.SHADER_TYPE=35663]="SHADER_TYPE",n[n.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",n[n.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",n[n.NEVER=512]="NEVER",n[n.LESS=513]="LESS",n[n.EQUAL=514]="EQUAL",n[n.LEQUAL=515]="LEQUAL",n[n.GREATER=516]="GREATER",n[n.NOTEQUAL=517]="NOTEQUAL",n[n.GEQUAL=518]="GEQUAL",n[n.ALWAYS=519]="ALWAYS",n[n.KEEP=7680]="KEEP",n[n.REPLACE=7681]="REPLACE",n[n.INCR=7682]="INCR",n[n.DECR=7683]="DECR",n[n.INVERT=5386]="INVERT",n[n.INCR_WRAP=34055]="INCR_WRAP",n[n.DECR_WRAP=34056]="DECR_WRAP",n[n.NEAREST=9728]="NEAREST",n[n.LINEAR=9729]="LINEAR",n[n.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",n[n.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",n[n.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",n[n.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE=5890]="TEXTURE",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n[n.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",n[n.TEXTURE0=33984]="TEXTURE0",n[n.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",n[n.REPEAT=10497]="REPEAT",n[n.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n[n.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",n[n.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_CUBE=35680]="SAMPLER_CUBE",n[n.LOW_FLOAT=36336]="LOW_FLOAT",n[n.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",n[n.HIGH_FLOAT=36338]="HIGH_FLOAT",n[n.LOW_INT=36339]="LOW_INT",n[n.MEDIUM_INT=36340]="MEDIUM_INT",n[n.HIGH_INT=36341]="HIGH_INT",n[n.FRAMEBUFFER=36160]="FRAMEBUFFER",n[n.RENDERBUFFER=36161]="RENDERBUFFER",n[n.RGBA4=32854]="RGBA4",n[n.RGB5_A1=32855]="RGB5_A1",n[n.RGB565=36194]="RGB565",n[n.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",n[n.STENCIL_INDEX=6401]="STENCIL_INDEX",n[n.STENCIL_INDEX8=36168]="STENCIL_INDEX8",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n[n.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",n[n.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",n[n.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",n[n.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",n[n.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",n[n.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",n[n.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",n[n.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",n[n.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",n[n.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",n[n.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",n[n.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",n[n.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",n[n.NONE=0]="NONE",n[n.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",n[n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",n[n.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",n[n.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",n[n.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",n[n.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",n[n.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",n[n.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",n[n.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",n[n.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",n[n.READ_BUFFER=3074]="READ_BUFFER",n[n.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",n[n.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",n[n.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",n[n.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",n[n.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",n[n.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",n[n.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",n[n.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",n[n.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",n[n.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",n[n.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",n[n.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",n[n.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",n[n.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",n[n.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",n[n.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",n[n.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",n[n.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",n[n.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",n[n.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",n[n.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",n[n.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",n[n.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",n[n.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",n[n.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",n[n.RED=6403]="RED",n[n.RGB8=32849]="RGB8",n[n.RGBA8=32856]="RGBA8",n[n.RGB10_A2=32857]="RGB10_A2",n[n.TEXTURE_3D=32879]="TEXTURE_3D",n[n.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",n[n.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",n[n.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",n[n.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",n[n.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",n[n.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",n[n.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",n[n.SRGB=35904]="SRGB",n[n.SRGB8=35905]="SRGB8",n[n.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",n[n.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",n[n.RGBA32F=34836]="RGBA32F",n[n.RGB32F=34837]="RGB32F",n[n.RGBA16F=34842]="RGBA16F",n[n.RGB16F=34843]="RGB16F",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",n[n.R11F_G11F_B10F=35898]="R11F_G11F_B10F",n[n.RGB9_E5=35901]="RGB9_E5",n[n.RGBA32UI=36208]="RGBA32UI",n[n.RGB32UI=36209]="RGB32UI",n[n.RGBA16UI=36214]="RGBA16UI",n[n.RGB16UI=36215]="RGB16UI",n[n.RGBA8UI=36220]="RGBA8UI",n[n.RGB8UI=36221]="RGB8UI",n[n.RGBA32I=36226]="RGBA32I",n[n.RGB32I=36227]="RGB32I",n[n.RGBA16I=36232]="RGBA16I",n[n.RGB16I=36233]="RGB16I",n[n.RGBA8I=36238]="RGBA8I",n[n.RGB8I=36239]="RGB8I",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.R8=33321]="R8",n[n.RG8=33323]="RG8",n[n.R16F=33325]="R16F",n[n.R32F=33326]="R32F",n[n.RG16F=33327]="RG16F",n[n.RG32F=33328]="RG32F",n[n.R8I=33329]="R8I",n[n.R8UI=33330]="R8UI",n[n.R16I=33331]="R16I",n[n.R16UI=33332]="R16UI",n[n.R32I=33333]="R32I",n[n.R32UI=33334]="R32UI",n[n.RG8I=33335]="RG8I",n[n.RG8UI=33336]="RG8UI",n[n.RG16I=33337]="RG16I",n[n.RG16UI=33338]="RG16UI",n[n.RG32I=33339]="RG32I",n[n.RG32UI=33340]="RG32UI",n[n.R8_SNORM=36756]="R8_SNORM",n[n.RG8_SNORM=36757]="RG8_SNORM",n[n.RGB8_SNORM=36758]="RGB8_SNORM",n[n.RGBA8_SNORM=36759]="RGBA8_SNORM",n[n.RGB10_A2UI=36975]="RGB10_A2UI",n[n.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",n[n.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.HALF_FLOAT=5131]="HALF_FLOAT",n[n.RG=33319]="RG",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",n[n.CURRENT_QUERY=34917]="CURRENT_QUERY",n[n.QUERY_RESULT=34918]="QUERY_RESULT",n[n.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",n[n.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",n[n.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",n[n.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",n[n.DRAW_BUFFER0=34853]="DRAW_BUFFER0",n[n.DRAW_BUFFER1=34854]="DRAW_BUFFER1",n[n.DRAW_BUFFER2=34855]="DRAW_BUFFER2",n[n.DRAW_BUFFER3=34856]="DRAW_BUFFER3",n[n.DRAW_BUFFER4=34857]="DRAW_BUFFER4",n[n.DRAW_BUFFER5=34858]="DRAW_BUFFER5",n[n.DRAW_BUFFER6=34859]="DRAW_BUFFER6",n[n.DRAW_BUFFER7=34860]="DRAW_BUFFER7",n[n.DRAW_BUFFER8=34861]="DRAW_BUFFER8",n[n.DRAW_BUFFER9=34862]="DRAW_BUFFER9",n[n.DRAW_BUFFER10=34863]="DRAW_BUFFER10",n[n.DRAW_BUFFER11=34864]="DRAW_BUFFER11",n[n.DRAW_BUFFER12=34865]="DRAW_BUFFER12",n[n.DRAW_BUFFER13=34866]="DRAW_BUFFER13",n[n.DRAW_BUFFER14=34867]="DRAW_BUFFER14",n[n.DRAW_BUFFER15=34868]="DRAW_BUFFER15",n[n.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",n[n.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",n[n.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",n[n.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",n[n.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",n[n.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",n[n.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",n[n.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",n[n.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",n[n.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",n[n.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",n[n.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",n[n.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",n[n.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",n[n.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",n[n.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",n[n.SAMPLER_3D=35679]="SAMPLER_3D",n[n.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",n[n.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",n[n.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",n[n.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",n[n.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",n[n.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",n[n.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",n[n.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",n[n.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",n[n.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",n[n.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",n[n.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",n[n.MAX_SAMPLES=36183]="MAX_SAMPLES",n[n.SAMPLER_BINDING=35097]="SAMPLER_BINDING",n[n.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",n[n.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",n[n.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",n[n.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",n[n.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",n[n.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",n[n.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",n[n.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",n[n.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",n[n.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",n[n.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",n[n.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",n[n.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",n[n.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",n[n.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",n[n.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",n[n.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",n[n.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",n[n.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",n[n.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",n[n.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",n[n.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",n[n.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",n[n.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",n[n.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",n[n.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",n[n.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",n[n.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",n[n.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",n[n.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",n[n.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",n[n.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",n[n.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",n[n.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",n[n.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",n[n.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",n[n.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",n[n.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",n[n.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",n[n.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",n[n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n[n.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",n[n.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",n[n.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",n[n.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",n[n.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",n[n.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",n[n.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",n[n.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",n[n.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",n[n.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",n[n.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",n[n.UNIFORM_TYPE=35383]="UNIFORM_TYPE",n[n.UNIFORM_SIZE=35384]="UNIFORM_SIZE",n[n.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",n[n.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",n[n.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",n[n.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",n[n.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",n[n.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",n[n.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",n[n.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",n[n.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",n[n.OBJECT_TYPE=37138]="OBJECT_TYPE",n[n.SYNC_CONDITION=37139]="SYNC_CONDITION",n[n.SYNC_STATUS=37140]="SYNC_STATUS",n[n.SYNC_FLAGS=37141]="SYNC_FLAGS",n[n.SYNC_FENCE=37142]="SYNC_FENCE",n[n.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",n[n.UNSIGNALED=37144]="UNSIGNALED",n[n.SIGNALED=37145]="SIGNALED",n[n.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",n[n.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",n[n.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",n[n.WAIT_FAILED=37149]="WAIT_FAILED",n[n.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",n[n.COLOR=6144]="COLOR",n[n.DEPTH=6145]="DEPTH",n[n.STENCIL=6146]="STENCIL",n[n.MIN=32775]="MIN",n[n.MAX=32776]="MAX",n[n.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",n[n.STREAM_READ=35041]="STREAM_READ",n[n.STREAM_COPY=35042]="STREAM_COPY",n[n.STATIC_READ=35045]="STATIC_READ",n[n.STATIC_COPY=35046]="STATIC_COPY",n[n.DYNAMIC_READ=35049]="DYNAMIC_READ",n[n.DYNAMIC_COPY=35050]="DYNAMIC_COPY",n[n.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",n[n.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",n[n.INVALID_INDEX=4294967295]="INVALID_INDEX",n[n.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",n[n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",n[n.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",n[n.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",n[n.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",n[n.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",n[n.R16_EXT=33322]="R16_EXT",n[n.RG16_EXT=33324]="RG16_EXT",n[n.RGB16_EXT=32852]="RGB16_EXT",n[n.RGBA16_EXT=32859]="RGBA16_EXT",n[n.R16_SNORM_EXT=36760]="R16_SNORM_EXT",n[n.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",n[n.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",n[n.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",n[n.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",n[n.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",n[n.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",n[n.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",n[n.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",n[n.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",n[n.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",n[n.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",n[n.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",n[n.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",n[n.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",n[n.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",n[n.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",n[n.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",n[n.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",n[n.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",n[n.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",n[n.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",n[n.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",n[n.LINE_WEBGL=6913]="LINE_WEBGL",n[n.FILL_WEBGL=6914]="FILL_WEBGL",n[n.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",n[n.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",n[n.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",n[n.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",n[n.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",n[n.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",n[n.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",n[n.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",n[n.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",n[n.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",n[n.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",n[n.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",n[n.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",n[n.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",n[n.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",n[n.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",n[n.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",n[n.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",n[n.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",n[n.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",n[n.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",n[n.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",n[n.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",n[n.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Rt||(Rt={}));const Rm={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:{}},Em=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),km=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),Dm=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}});function Fm(n=!0){const e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){const r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&Mm(r),r}return this.originalGetContext(t,i)}}function Mm(n){n.getExtension("EXT_color_buffer_float");const e={...Rm,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Em(n),OES_vertex_array_object:km(n),ANGLE_instanced_arrays:Dm(n)},t=n.getExtension;n.getExtension=function(r){const s=t.call(n,r);return s||(r in e?e[r]:null)};const i=n.getSupportedExtensions;n.getSupportedExtensions=function(){const r=i.apply(n)||[];return r==null?void 0:r.concat(Object.keys(e))}}async function ja(n,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",n),new Promise((r,s)=>{i.onload=r,i.onerror=o=>s(new Error(`Unable to load script '${n}': ${o}`)),t.appendChild(i)})}const Nm=1;let ue=null,Ka=!1;const ys={debugSpectorJS:D.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function Om(n){if(!globalThis.SPECTOR)try{await ja(n.debugSpectorJSUrl||ys.debugSpectorJSUrl)}catch(e){D.warn(String(e))}}function Bm(n){var e;if(n={...ys,...n},!n.debugSpectorJS)return null;if(!ue&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){D.probe(Nm,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;ue=new t,globalThis.luma&&(globalThis.luma.spector=ue)}if(!ue)return null;if(Ka||(Ka=!0,ue.spyCanvases(),ue==null||ue.onCaptureStarted.add(t=>D.info("Spector capture started:",t)()),ue==null||ue.onCapture.add(t=>{D.info("Spector capture complete:",t)(),ue==null||ue.getResultUI(),ue==null||ue.resultView.display(),ue==null||ue.resultView.addCapture(t)})),n.gl){const t=n.gl,i=t.device;ue==null||ue.startCapture(n.gl,500),t.device=i,new Promise(r=>setTimeout(r,2e3)).then(r=>{D.info("Spector capture stopped after 2 seconds")(),ue==null||ue.stopCapture()})}return ue}const Um="https://unpkg.com/webgl-debug@2.0.1/index.js";function Za(n){return n.luma=n.luma||{},n.luma}async function zm(){Ut()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await ja(Um))}function Lm(n,e={}){return e.debugWebGL||e.traceWebGL?Hm(n,e):Vm(n)}function Vm(n){const e=Za(n);return e.realContext?e.realContext:n}function Hm(n,e){if(!globalThis.WebGLDebugUtils)return D.warn("webgl-debug not loaded")(),n;const t=Za(n);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Rt,...n});const i=globalThis.WebGLDebugUtils.makeDebugContext(n,Wm.bind(null,e),$m.bind(null,e));for(const o in Rt)!(o in i)&&typeof Rt[o]=="number"&&(i[o]=Rt[o]);class r{}Object.setPrototypeOf(i,Object.getPrototypeOf(n)),Object.setPrototypeOf(r,i);const s=Object.create(r);return t.realContext=n,t.debugContext=s,s.debug=!0,s}function Qa(n,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(n,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${n}(${t})`}function Wm(n,e,t,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);const r=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,i),o=`${r} in gl.${t}(${s})`;D.error(o)();debugger}function $m(n,e,t){let i="";D.level>=1&&(i=Qa(e,t),n.traceWebGL&&D.log(1,i)());for(const r of t)if(r===void 0){i=i||Qa(e,t);debugger}}const zi=1;class Xm extends Kp{constructor(){super();m(this,"type","webgl");zt.defaultProps={...zt.defaultProps,...ys}}enforceWebGL2(t){Fm(t)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&t instanceof WebGLRenderingContext&&D.warn("WebGL1 is not supported",t)(),!1)}async attach(t,i={}){const{WebGLDevice:r}=await Promise.resolve().then(()=>Sl);if(t instanceof r)return t;if((t==null?void 0:t.device)instanceof r)return t.device;if(!Ym(t))throw new Error("Invalid WebGL2RenderingContext");const s=i.createCanvasContext===!0?{}:i.createCanvasContext;return new r({...i,_handle:t,createCanvasContext:{canvas:t.canvas,autoResize:!1,...s}})}async create(t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>Sl);D.groupCollapsed(zi,"WebGLDevice created")();try{const r=[];(t.debugWebGL||t.debug)&&r.push(zm()),t.debugSpectorJS&&r.push(Om(t));const s=await Promise.allSettled(r);for(const l of s)l.status==="rejected"&&D.error(`Failed to initialize debug libraries ${l.reason}`)();const o=new i(t),a=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return D.probe(zi,a)(),D.table(zi,o.info)(),o}finally{D.groupEnd(zi)()}}}function Ym(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&Number.isFinite(n._version))}const qm=new Xm,vs={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},ye=(n,e,t)=>e?n.enable(t):n.disable(t),Ja=(n,e,t)=>n.hint(t,e),Ye=(n,e,t)=>n.pixelStorei(t,e),Ga=(n,e,t)=>{const i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Fn=(n,e,t)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};function bs(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}const jm={3042:ye,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:ye,2885:(n,e)=>n.cullFace(e),2929:ye,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:ye,35723:Ja,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>{var t;return(t=n.bindTransformFeedback)==null?void 0:t.call(n,36386,e)},34229:(n,e)=>n.bindVertexArray(e),36006:Ga,36010:Ga,34964:Fn,36662:Fn,36663:Fn,35053:Fn,35055:Fn,2886:(n,e)=>n.frontFace(e),33170:Ja,2849:(n,e)=>n.lineWidth(e),32823:ye,32824:"polygonOffset",10752:"polygonOffset",35977:ye,32926:ye,32928:ye,32938:"sampleCoverage",32939:"sampleCoverage",3089:ye,3088:(n,e)=>n.scissor(...e),2960:ye,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:ye,10754:ye,12288:ye,12289:ye,12290:ye,12291:ye,12292:ye,12293:ye,12294:ye,12295:ye,3333:Ye,3317:Ye,37440:Ye,37441:Ye,37443:Ye,3330:Ye,3332:Ye,3331:Ye,3314:Ye,32878:Ye,3316:Ye,3315:Ye,32877:Ye,framebuffer:(n,e)=>{const t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{const t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=bs(e)?e:[e,e];const[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=bs(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=bs(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};function _e(n,e,t){return e[n]!==void 0?e[n]:t[n]}const Km={blendEquation:(n,e,t)=>n.blendEquationSeparate(_e(32777,e,t),_e(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(_e(32969,e,t),_e(32968,e,t),_e(32971,e,t),_e(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(_e(32824,e,t),_e(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(_e(32938,e,t),_e(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,_e(2962,e,t),_e(2967,e,t),_e(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,_e(34816,e,t),_e(36003,e,t),_e(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,_e(2964,e,t),_e(2965,e,t),_e(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,_e(34817,e,t),_e(34818,e,t),_e(34819,e,t))},el={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ft=(n,e)=>n.isEnabled(e),tl={3042:ft,2884:ft,2929:ft,3024:ft,32823:ft,32926:ft,32928:ft,3089:ft,2960:ft,35977:ft},Zm=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function an(n,e){if(Jm(e))return;const t={};for(const r in e){const s=Number(r),o=jm[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}const i=n.state&&n.state.cache;if(i)for(const r in t){const s=Km[r];s(n,e,i)}}function nl(n,e=vs){if(typeof e=="number"){const r=e,s=tl[r];return s?s(n,r):n.getParameter(r)}const t=Array.isArray(e)?e:Object.keys(e),i={};for(const r of t){const s=tl[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function Qm(n){an(n,vs)}function Jm(n){for(const e in n)return!1;return!0}function Gm(n,e){if(n===e)return!0;if(il(n)&&il(e)&&n.length===e.length){for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}return!1}function il(n){return Array.isArray(n)||ArrayBuffer.isView(n)}class Vt{constructor(e,t){m(this,"gl");m(this,"program",null);m(this,"stateStack",[]);m(this,"enable",!0);m(this,"cache",null);m(this,"log");m(this,"initialized",!1);this.gl=e,this.log=(t==null?void 0:t.log)||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];an(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?nl(e):Object.assign({},vs),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,tg(e);for(const i in el){const r=el[i];eg(e,i,r)}rl(e,"getParameter"),rl(e,"isEnabled")}_updateCache(e){let t=!1,i;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const s in e){const o=e[s],a=this.cache[s];Gm(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}function rl(n,e){const t=n[e].bind(n);n[e]=function(r){if(r===void 0||Zm.has(r))return t(r);const s=Vt.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function eg(n,e,t){if(!n[e])return;const i=n[e].bind(n);n[e]=function(...s){const o=Vt.get(n),{valueChanged:a,oldValue:l}=t(o._updateCache,...s);return a&&i(...s),l},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function tg(n){const e=n.useProgram.bind(n);n.useProgram=function(i){const r=Vt.get(n);r.program!==i&&(e(i),r.program=i)}}function ng(n,e,t){let i="";const r={preserveDrawingBuffer:!0,...t};let s=null;if(s||(s=n.getContext("webgl2",r)),r.failIfMajorPerformanceCaveat&&(i||(i="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!s&&!t.failIfMajorPerformanceCaveat&&(r.failIfMajorPerformanceCaveat=!1,s=n.getContext("webgl2",r),s.luma||(s.luma={}),s.luma.softwareRenderer=!0),s||(s=n.getContext("webgl",{}),s&&(s=null,i||(i="Your browser only supports WebGL1"))),!s)throw i||(i="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${i}`);const{onContextLost:o,onContextRestored:a}=e;return n.addEventListener("webglcontextlost",l=>o(l),!1),n.addEventListener("webglcontextrestored",l=>a(l),!1),s.luma||(s.luma={}),s}function ln(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}function ig(n,e){const t=n.getParameter(7936),i=n.getParameter(7937);ln(n,"WEBGL_debug_renderer_info",e);const r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,l=o||i,c=n.getParameter(7938),u=sl(a,l),f=rg(a,l),h=sg(a,l);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:l,version:c,shadingLanguage:"glsl",shadingLanguageVersion:300}}function sl(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function rg(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function sg(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(sl(n,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ol(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}const Mn="WEBGL_compressed_texture_s3tc",Nn="WEBGL_compressed_texture_s3tc_srgb",cn="EXT_texture_compression_rgtc",un="EXT_texture_compression_bptc",og="WEBGL_compressed_texture_etc",ag="WEBGL_compressed_texture_astc",lg="WEBGL_compressed_texture_etc1",cg="WEBGL_compressed_texture_pvrtc",ug="WEBGL_compressed_texture_atc",al="EXT_texture_norm16",ll="EXT_render_snorm",fg="EXT_color_buffer_float",Ss={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[ll],"norm16-renderable-webgl":[al],"snorm16-renderable-webgl":[al,ll],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Mn,Nn,cn,un],"texture-compression-bc5-webgl":[cn],"texture-compression-bc7-webgl":[un],"texture-compression-etc2":[og],"texture-compression-astc":[ag],"texture-compression-etc1-webgl":[lg],"texture-compression-pvrtc-webgl":[cg],"texture-compression-atc-webgl":[ug]};function hg(n){return n in Ss}function dg(n,e,t){return(Ss[e]||[]).every(r=>ln(n,r,t))}const Ts={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:fg,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Mn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Nn},"bc1-rgba-unorm":{gl:33777,x:Mn},"bc1-rgba-unorm-srgb":{gl:35916,x:Nn},"bc2-rgba-unorm":{gl:33778,x:Mn},"bc2-rgba-unorm-srgb":{gl:35918,x:Nn},"bc3-rgba-unorm":{gl:33779,x:Mn},"bc3-rgba-unorm-srgb":{gl:35919,x:Nn},"bc4-r-unorm":{gl:36283,x:cn},"bc4-r-snorm":{gl:36284,x:cn},"bc5-rg-unorm":{gl:36285,x:cn},"bc5-rg-snorm":{gl:36286,x:cn},"bc6h-rgb-ufloat":{gl:36495,x:un},"bc6h-rgb-float":{gl:36494,x:un},"bc7-rgba-unorm":{gl:36492,x:un},"bc7-rgba-unorm-srgb":{gl:36493,x:un},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function pg(n,e,t){let i=e.create;const r=Ts[e.format];return(r==null?void 0:r.gl)===void 0&&(i=!1),r!=null&&r.x&&(i=i&&!!ln(n,r.x,t)),{format:e.format,create:i&&e.create,render:i&&e.render,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function cl(n){var r;const e=Ts[n],t=_g(n),i=sn.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:(e==null?void 0:e.dataFormat)||gg(i.channels,i.integer,i.normalized,t),type:i.dataType?ol(i.dataType):((r=e==null?void 0:e.types)==null?void 0:r[0])||5121,compressed:i.compressed||!1}}function mg(n){switch(sn.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function gg(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function _g(n){const e=Ts[n],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}const ul={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class xg extends Yp{constructor(t,i,r){super([],r);m(this,"gl");m(this,"extensions");m(this,"testedFeatures",new Set);this.gl=t,this.extensions=i,ln(t,"EXT_color_buffer_float",i)}*[Symbol.iterator](){const t=this.getFeatures();for(const i of t)this.has(i)&&(yield i);return[]}has(t){var i;return(i=this.disabledFeatures)!=null&&i[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),hg(t)&&dg(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){const t=this.getFeatures().filter(i=>i!=="polygon-mode-webgl");for(const i of t)this.has(i)}getFeatures(){return[...Object.keys(ul),...Object.keys(Ss)]}getWebGLFeature(t){const i=ul[t];return typeof i=="string"?!!ln(this.gl,i,this.extensions):!!i}}class yg extends Xp{constructor(t){super();m(this,"gl");m(this,"limits",{});this.gl=t}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}class On extends Ni{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"colorAttachments",[]);m(this,"depthStencilAttachment",null);const r=i.handle===null;this.device=t,this.gl=t.gl,this.handle=this.props.handle||r?this.props.handle:this.gl.createFramebuffer(),r||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const t=this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i<this.colorAttachments.length;++i){const r=this.colorAttachments[i];if(r){const s=36064+i;this._attachTextureView(s,r)}}if(this.depthStencilAttachment){const i=mg(this.depthStencilAttachment.props.format);this._attachTextureView(i,this.depthStencilAttachment)}if(this.device.props.debug){const i=this.gl.checkFramebufferStatus(36160);if(i!==36053)throw new Error(`Framebuffer ${bg(i)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,i){const{gl:r}=this.device,{texture:s}=i,o=i.props.baseMipLevel,a=i.props.baseArrayLayer;switch(r.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:r.framebufferTextureLayer(36160,t,s.handle,o,a);break;case 34067:const l=vg(a);r.framebufferTexture2D(36160,t,l,s.handle,o);break;case 3553:r.framebufferTexture2D(36160,t,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}r.bindTexture(s.glTarget,null)}}function vg(n){return n<34069?n+34069:n}function bg(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}class Sg extends Di{constructor(t,i){super(i);m(this,"device");m(this,"handle",null);m(this,"_framebuffer",null);this.device=t,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._updateDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new On(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}const ws={};function Tg(n="id"){ws[n]=ws[n]||1;const e=ws[n]++;return`${n}-${e}`}class Bn extends z{constructor(t,i={}){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"glTarget");m(this,"glUsage");m(this,"glIndexType",5123);m(this,"byteLength",0);m(this,"bytesUsed",0);this.device=t,this.gl=this.device.gl;const r=typeof i=="object"?i.handle:void 0;this.handle=r||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=wg(this.props.usage),this.glUsage=Ag(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,i.data?this._initWithData(i.data,i.byteOffset,i.byteLength):this._initWithByteLength(i.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(t,i=0,r=t.byteLength+i){const s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bufferSubData(s,i,t),this.gl.bindBuffer(s,null),this.bytesUsed=r,this.byteLength=r,this._setDebugData(t,i,r),this.trackAllocatedMemory(r)}_initWithByteLength(t){let i=t;t===0&&(i=new Float32Array(0));const r=this.glTarget;return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bindBuffer(r,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}write(t,i=0){const r=ArrayBuffer.isView(t)?t:new Uint8Array(t),s=36663;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,i,r),this.gl.bindBuffer(s,null),this._setDebugData(t,i,t.byteLength)}async mapAndWriteAsync(t,i=0,r=this.byteLength-i){const s=new ArrayBuffer(r);await t(s,"copied"),this.write(s,i)}async readAsync(t=0,i){return this.readSyncWebGL(t,i)}async mapAndReadAsync(t,i=0,r){const s=await this.readAsync(i,r);return await t(s.buffer,"copied")}readSyncWebGL(t=0,i){i=i??this.byteLength-t;const r=new Uint8Array(i),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,r,s,i),this.gl.bindBuffer(36662,null),this._setDebugData(r,t,i),r}}function wg(n){return n&z.INDEX?34963:n&z.VERTEX?34962:n&z.UNIFORM?35345:34962}function Ag(n){return n&z.INDEX||n&z.VERTEX?35044:n&z.UNIFORM?35048:35044}function Cg(n){const e=n.split(/\r?\n/),t=[];for(const i of e){if(i.length<=1)continue;const r=i.split(":");if(r.length===2){const[f,h]=r;t.push({message:h.trim(),type:fl(f),lineNum:0,linePos:0});continue}const[s,o,a,...l]=r;let c=parseInt(a,10);isNaN(c)&&(c=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:l.join(":").trim(),type:fl(s),lineNum:c,linePos:u})}return t}function fl(n){const e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}class Pg extends Mi{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");switch(this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const t=this.device.gl.getShaderInfoLog(this.handle);return t?Cg(t):[]}getTranslatedSource(){const i=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(i==null?void 0:i.getTranslatedShaderSource(this.handle))||null}async _compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
12
|
+
${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}D.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),D.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function Ig(n,e,t,i){if(Dg(e))return i(n);const r=n;r.pushState();try{return Rg(n,e),an(r.gl,t),i(n)}finally{r.popState()}}function Rg(n,e){const t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Ht("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){const s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Ht("provokingVertex",e.provokingVertex,{first:36429,last:36430});s==null||s.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){const s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Ht("polygonMode",e.polygonMode,{fill:6914,line:6913});s==null||s.polygonModeWEBGL(1028,o),s==null||s.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(kg("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(As("depthCompare",e.depthCompare))),e.stencilWriteMask){const r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&D.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const r=e.stencilReadMask||4294967295,s=As("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const r=Cs("stencilPassOperation",e.stencilPassOperation),s=Cs("stencilFailOperation",e.stencilFailOperation),o=Cs("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const r=hl("blendColorOperation",e.blendColorOperation||"add"),s=hl("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);const o=Li("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Li("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=Li("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),c=Li("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,l,c)}}function As(n,e){return Ht(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Cs(n,e){return Ht(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function hl(n,e){return Ht(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Li(n,e,t="color"){return Ht(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Eg(n,e){return`Illegal parameter ${e} for ${n}`}function Ht(n,e,t){if(!(e in t))throw new Error(Eg(n,e));return t[e]}function kg(n,e){return e}function Dg(n){let e=!0;for(const t in n){e=!1;break}return e}function dl(n){const e={};return n.addressModeU&&(e[10242]=Ps(n.addressModeU)),n.addressModeV&&(e[10243]=Ps(n.addressModeV)),n.addressModeW&&(e[32882]=Ps(n.addressModeW)),n.magFilter&&(e[10240]=Is(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=Fg(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=As("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function Ps(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Is(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function Fg(n,e="none"){if(!e)return Is(n);switch(e){case"none":return Is(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}class Mg extends on{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"parameters");this.device=t,this.parameters=dl(i),this.handle=i.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(const[i,r]of Object.entries(t)){const s=Number(i);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,r);break;default:this.device.gl.samplerParameteri(this.handle,s,r);break}}}}function Un(n,e,t){if(Ng(e))return t(n);const{nocatch:i=!0}=e,r=Vt.get(n);r.push(),an(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function Ng(n){for(const e in n)return!1;return!0}class fn extends Fi{constructor(t,i){super(t,{...J.defaultProps,...i});m(this,"device");m(this,"gl");m(this,"handle");m(this,"texture");this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=i.texture}}class zn extends J{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"sampler");m(this,"view");m(this,"glTarget");m(this,"glFormat");m(this,"glType");m(this,"glInternalFormat");m(this,"compressed");m(this,"_textureUnit",0);this.device=t,this.gl=this.device.gl;const r=cl(this.props.format);this.glTarget=Og(this.props.dimension),this.glInternalFormat=r.internalFormat,this.glFormat=r.format,this.glType=r.type,this.compressed=r.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:s,width:o,height:a,depth:l,mipLevels:c,glTarget:u,glInternalFormat:f}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(u,c,f,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,c,f,o,a,l);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(i.data),this.setSampler(this.props.sampler),this.view=new fn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(t){return new fn(this.device,{...t,texture:this})}setSampler(t={}){super.setSampler(t);const i=dl(this.sampler.props);this._setSamplerParameters(i)}copyImageData(t){const i=this._normalizeCopyImageDataOptions(t),r=i.data,{width:s,height:o,depth:a}=this,{mipLevel:l=0,byteOffset:c=0,x:u=0,y:f=0,z:h=0}=i,{glFormat:d,glType:_,compressed:I}=this,C=pl(this.glTarget,this.dimension,a),w=this.compressed?{}:{3314:i.bytesPerRow,32878:i.rowsPerImage};this.gl.bindTexture(C,this.handle),Un(this.gl,w,()=>{switch(this.dimension){case"2d":case"cube":I?this.gl.compressedTexSubImage2D(C,l,u,f,s,o,d,r,c):this.gl.texSubImage2D(C,l,u,f,s,o,d,_,r,c);break;case"2d-array":case"3d":I?this.gl.compressedTexSubImage3D(C,l,u,f,h,s,o,a,d,r,c):this.gl.texSubImage3D(C,l,u,f,h,s,o,a,d,_,r,c);break;default:}}),this.gl.bindTexture(C,null)}copyExternalImage(t){const i=this._normalizeCopyExternalImageOptions(t);if(i.sourceX||i.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:r,glType:s}=this,{image:o,depth:a,mipLevel:l,x:c,y:u,z:f,width:h,height:d}=i,_=pl(this.glTarget,this.dimension,a),I=i.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Un(this.gl,I,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(_,l,c,u,h,d,r,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(_,l,c,u,f,h,d,a,r,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:i.width,height:i.height}}generateMipmapsWebGL(t){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(D.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(t!=null&&t.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(r){D.warn(`Error generating mipmap for ${this}: ${r.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){D.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[i,r]of Object.entries(t)){const s=Number(i),o=r;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,this.handle),t}_unbind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,null),t}}function Og(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(n)}function pl(n,e,t){return e==="cube"?34069+t:n}function Bg(n){return Vg[n]}function Rs(n){return Lg[n]}function Ug(n){return!!ml[n]}function zg(n){return ml[n]}const Lg={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},ml={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Vg={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Hg(n,e){const t={attributes:[],bindings:[]};t.attributes=Wg(n,e);const i=Yg(n,e);for(const a of i){const l=a.uniforms.map(c=>({name:c.name,format:c.format,byteOffset:c.byteOffset,byteStride:c.byteStride,arrayLength:c.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:l})}const r=Xg(n,e);let s=0;for(const a of r)if(Ug(a.type)){const{viewDimension:l,sampleType:c}=zg(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:l,sampleType:c}),a.textureUnit=s,s+=1}r.length&&(t.uniforms=r);const o=$g(n,e);return o!=null&&o.length&&(t.varyings=o),t}function Wg(n,e){const t=[],i=n.getProgramParameter(e,35721);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a}=s,l=n.getAttribLocation(e,o);if(l>=0){const c=Rs(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:l,stepMode:u,type:c})}}return t.sort((r,s)=>r.location-s.location),t}function $g(n,e){const t=[],i=n.getProgramParameter(e,35971);for(let r=0;r<i;r++){const s=n.getTransformFeedbackVarying(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a,size:l}=s,c=Rs(a),{type:u,components:f}=Xa(c);t.push({location:r,name:o,type:u,size:l*f})}return t.sort((r,s)=>r.location-s.location),t}function Xg(n,e){const t=[],i=n.getProgramParameter(e,35718);for(let r=0;r<i;r++){const s=n.getActiveUniform(e,r);if(!s)throw new Error("activeInfo");const{name:o,size:a,type:l}=s,{name:c,isArray:u}=qg(o);let f=n.getUniformLocation(e,c);const h={location:f,name:c,size:a,type:l,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){const _=`${c}[${d}]`;f=n.getUniformLocation(e,_);const I={...h,name:_,location:f};t.push(I)}}return t}function Yg(n,e){const t=(s,o)=>n.getActiveUniformBlockParameter(e,s,o),i=[],r=n.getProgramParameter(e,35382);for(let s=0;s<r;s++){const o={name:n.getActiveUniformBlockName(e,s)||"",location:t(s,35391),byteLength:t(s,35392),vertex:t(s,35396),fragment:t(s,35398),uniformCount:t(s,35394),uniforms:[]},a=t(s,35395)||[],l=n.getActiveUniforms(e,a,35383),c=n.getActiveUniforms(e,a,35384),u=n.getActiveUniforms(e,a,35387),f=n.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){const d=n.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");const _=Rs(l[h]);o.uniforms.push({name:d.name,format:_,type:l[h],arrayLength:c[h],byteOffset:u[h],byteStride:f[h]})}i.push(o)}return i.sort((s,o)=>s.location-o.location),i}function qg(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(n);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${n}`);return{name:t[1],length:t[2]?1:0,isArray:!!t[2]}}function jg(n,e,t,i){const r=n;let s=i;s===!0&&(s=1),s===!1&&(s=0);const o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function Kg(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function Zg(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}const gl=4;class Qg extends Lt{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"vs");m(this,"fs");m(this,"introspectedLayout");m(this,"uniforms",{});m(this,"bindings",{});m(this,"varyings",null);m(this,"_uniformCount",0);m(this,"_uniformSetters",{});this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=i.vs,this.fs=i.fs;const{varyings:r,bufferMode:s=35981}=i;r&&r.length>0&&(this.varyings=r,this.device.gl.transformFeedbackVaryings(this.handle,r,s)),this._linkShaders(),D.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Hg(this.device.gl,this.handle),D.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=i.shaderLayout?Jg(this.introspectedLayout,i.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(t,i){for(const[r,s]of Object.entries(t)){const o=this.shaderLayout.bindings.find(a=>a.name===r)||this.shaderLayout.bindings.find(a=>a.name===`${r}Uniforms`);if(!o){const a=this.shaderLayout.bindings.map(l=>`"${l.name}"`).join(", ");i!=null&&i.disableWarnings||D.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)();continue}switch(s||D.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof Bn)&&!(s.buffer instanceof Bn))throw new Error("buffer value");break;case"texture":if(!(s instanceof fn||s instanceof zn||s instanceof On))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":D.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}}draw(t){var C;const{renderPass:i,parameters:r=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:l,isInstanced:c=!1,firstVertex:u=0,transformFeedback:f}=t,h=Kg(s),d=!!o.indexBuffer,_=(C=o.indexBuffer)==null?void 0:C.glIndexType;if(this.linkStatus!=="success")return D.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return D.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(i),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const I=i;return Ig(this.device,r,I.glParameters,()=>{d&&c?this.device.gl.drawElementsInstanced(h,a||0,_,u,l||0):d?this.device.gl.drawElements(h,a||0,_,u):c?this.device.gl.drawArraysInstanced(h,u,a||0,l||0):this.device.gl.drawArrays(h,u,a||0),f&&f.end()}),o.unbindAfterRender(i),!0}async _linkShaders(){const{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),D.time(gl,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),D.timeEnd(gl,`linkProgram for ${this.id}`)(),D.level,!this.device.features.has("compilation-status-async-webgl")){const r=this._getLinkStatus();this._reportLinkStatus(r);return}D.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),D.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const i=this._getLinkStatus();this._reportLinkStatus(i)}async _reportLinkStatus(t){var i;switch(t){case"success":return;default:const r=t==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((i=this.fs)==null?void 0:i.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const s=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${s}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(const i of this.shaderLayout.bindings)!this.bindings[i.name]&&!this.bindings[i.name.replace(/Uniforms$/,"")]&&(D.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:t}=this.device;t.useProgram(this.handle);let i=0,r=0;for(const s of this.shaderLayout.bindings){const o=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":const{name:a}=s,l=t.getUniformBlockIndex(this.handle,a);if(l===4294967295)throw new Error(`Invalid uniform block name ${a}`);t.uniformBlockBinding(this.handle,r,l),o instanceof Bn?t.bindBufferBase(35345,r,o.handle):t.bindBufferRange(35345,r,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),r+=1;break;case"texture":if(!(o instanceof fn||o instanceof zn||o instanceof On))throw new Error("texture");let c;if(o instanceof fn)c=o.texture;else if(o instanceof zn)c=o;else if(o instanceof On&&o.colorAttachments[0]instanceof fn)D.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=o.colorAttachments[0].texture;else throw new Error("No texture");t.activeTexture(33984+i),t.bindTexture(c.glTarget,c.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(const t of this.shaderLayout.uniforms||[]){const{name:i,location:r,type:s,textureUnit:o}=t,a=this.uniforms[i]??o;a!==void 0&&jg(this.device.gl,r,s,a)}}}function Jg(n,e){const t={...n,attributes:n.attributes.map(i=>({...i}))};for(const i of(e==null?void 0:e.attributes)||[]){const r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):D.warn(`shader layout attribute ${i.name} not present in shader`)}return t}class Gg extends ms{constructor(t){super(t,{});m(this,"device");m(this,"handle",null);m(this,"commands",[]);this.device=t}_executeCommands(t=this.commands){for(const i of t)switch(i.name){case"copy-buffer-to-buffer":e_(this.device,i.options);break;case"copy-buffer-to-texture":t_(this.device,i.options);break;case"copy-texture-to-buffer":n_(this.device,i.options);break;case"copy-texture-to-texture":i_(this.device,i.options);break;default:throw new Error(i.name)}}}function e_(n,e){const t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function t_(n,e){throw new Error("Not implemented")}function n_(n,e){const{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:l=[0,0],destinationBuffer:c,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==0||f||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:_}=_l(t);let I;try{const C=c,w=s||d.width,M=o||d.height,E=cl(d.colorAttachments[0].texture.props.format),x=E.format,R=E.type;n.gl.bindBuffer(35051,C.handle),I=n.gl.bindFramebuffer(36160,d.handle),n.gl.readPixels(l[0],l[1],w,M,x,R,u)}finally{n.gl.bindBuffer(35051,null),I!==void 0&&n.gl.bindFramebuffer(36160,I),_&&d.destroy()}}function i_(n,e){const{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0],destinationTexture:o}=e;let{width:a=e.destinationTexture.width,height:l=e.destinationTexture.height}=e;const{framebuffer:c,destroyFramebuffer:u}=_l(t),[f,h]=r,[d,_,I]=s,C=n.gl.bindFramebuffer(36160,c.handle);let w,M;if(o instanceof zn)w=o,a=Number.isFinite(a)?a:w.width,l=Number.isFinite(l)?l:w.height,w._bind(0),M=w.glTarget;else throw new Error("invalid destination");switch(M){case 3553:case 34067:n.gl.copyTexSubImage2D(M,i,d,_,f,h,a,l);break;case 35866:case 32879:n.gl.copyTexSubImage3D(M,i,d,_,I,f,h,a,l);break}w&&w._unbind(),n.gl.bindFramebuffer(36160,C),u&&c.destroy()}function _l(n){if(n instanceof J){const{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}const r_=[1,2,4,8];class s_ extends ds{constructor(t,i){var o;super(t,i);m(this,"device");m(this,"handle",null);m(this,"glParameters",{});this.device=t;let r;if(!((o=i==null?void 0:i.parameters)!=null&&o.viewport))if(i!=null&&i.framebuffer){const{width:a,height:l}=i.framebuffer;r=[0,0,a,l]}else{const[a,l]=t.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,a,l]}this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters});const s=this.props.framebuffer;if(this.props.framebuffer&&(s!=null&&s.handle)){const a=this.props.framebuffer.colorAttachments.map((l,c)=>36064+c);this.device.gl.drawBuffers(a)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){const i={...this.glParameters};i.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(i.depthMask=!this.props.depthReadOnly),i.stencilMask=this.props.stencilReadOnly?0:1,i[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(i.viewport=t.viewport.slice(0,4),i.depthRange=[t.viewport[4],t.viewport[5]]):i.viewport=t.viewport),t.scissorRect&&(i.scissorTest=!0,i.scissor=t.scissorRect),t.blendConstant&&(i.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),i[2967]=t.stencilReference),"colorMask"in t&&(i.colorMask=r_.map(r=>!!(r&t.colorMask))),this.glParameters=i,an(this.device.gl,i)}beginOcclusionQuery(t){const i=this.props.occlusionQuerySet;i==null||i.beginOcclusionQuery()}endOcclusionQuery(){const t=this.props.occlusionQuerySet;t==null||t.endOcclusionQuery()}clear(){const t={...this.glParameters};let i=0;this.props.clearColors&&this.props.clearColors.forEach((r,s)=>{r&&this.clearColorBuffer(s,r)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(i|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(i|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(i|=1024,t.clearStencil=this.props.clearStencil),i!==0&&Un(this.device.gl,t,()=>{this.device.gl.clear(i)})}clearColorBuffer(t=0,i=[0,0,0,0]){Un(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(i.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,i);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,i);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,i);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class xl extends ps{constructor(t,i){super(t,i);m(this,"device");m(this,"handle",null);m(this,"commandBuffer");this.device=t,this.commandBuffer=new Gg(t)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(t){return new s_(this.device,t)}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,i,r){}}function o_(n){const{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s;let a=0;for(let l=i;a<s;a++)e[l++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+o-a),a=o);return n.target}class Es extends gs{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"buffer",null);m(this,"bufferValue",null);this.device=t,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return xp()==="Chrome"}destroy(){var t;super.destroy(),this.buffer&&((t=this.buffer)==null||t.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){const i=t;if(i&&i.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,i?i.handle:null),this.indexBuffer=i,this.device.gl.bindVertexArray(null)}setBuffer(t,i){const r=i;if(r.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:s,type:o,stride:a,offset:l,normalized:c,integer:u,divisor:f}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,r.handle),u?this.device.gl.vertexAttribIPointer(t,s,o,a,l):this.device.gl.vertexAttribPointer(t,s,o,c,a,l),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,f||0),this.attributes[t]=r,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,i){this._enable(t,!1),this.attributes[t]=i}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){const i=this.attributes[t];ArrayBuffer.isView(i)&&this.device.setConstantAttributeWebGL(t,i)}}_getAccessor(t){const i=this.attributeInfos[t];if(!i)throw new Error(`Unknown attribute location ${t}`);const r=ol(i.bufferDataType);return{size:i.bufferComponents,type:r,stride:i.byteStride,offset:i.byteOffset,normalized:i.normalized,integer:i.integer,divisor:i.stepMode==="instance"?1:0}}_enable(t,i=!0){const s=Es.isConstantAttributeZeroSupported(this.device)||t!==0;(i||s)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),i?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,i){const r=a_(i),s=r.byteLength*t,o=r.length*t;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),a||(a=!l_(r,this.bufferValue)),a){const l=Sm(i.constructor,o);o_({target:l,source:r,start:0,count:o}),this.buffer.write(l),this.bufferValue=i}return this.buffer}}function a_(n){return Array.isArray(n)?new Float32Array(n):n}function l_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}class c_ extends _s{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"layout");m(this,"buffers",{});m(this,"unusedBuffers",{});m(this,"bindOnUse",!0);m(this,"_bound",!1);this.device=t,this.gl=t.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,i.buffers&&this.setBuffers(i.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zg(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const i in t)this.setBuffer(i,t[i])})}setBuffer(t,i){const r=this._getVaryingIndex(t),{buffer:s,byteLength:o,byteOffset:a}=this._getBufferRange(i);if(r<0){this.unusedBuffers[t]=s,D.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[r]={buffer:s,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(r,s,a,o)}getBuffer(t){if(yl(t))return this.buffers[t]||null;const i=this._getVaryingIndex(t);return i>=0?this.buffers[i]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let i;return this._bound?i=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,i=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),i}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof Bn)return{buffer:t,byteOffset:0,byteLength:t.byteLength};const{buffer:i,byteOffset:r=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:i,byteOffset:r,byteLength:s}}_getVaryingIndex(t){if(yl(t))return Number(t);for(const i of this.layout.varyings||[])if(t===i.name)return i.location;return-1}_bindBuffers(){for(const t in this.buffers){const{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),i,s,r)}}_unbindBuffers(){for(const t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,i,r=0,s){const o=i&&i.handle;!o||s===void 0?this.gl.bindBufferBase(35982,t,o):this.gl.bindBufferRange(35982,t,o,r,s)}}function yl(n){return typeof n=="number"?Number.isInteger(n):/^\d+$/.test(n)}class u_ extends xs{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"target",null);m(this,"_queryPending",!1);m(this,"_pollingPromise",null);if(this.device=t,i.count>1)throw new Error("WebGL QuerySet can only have one value");const r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");this.handle=r,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(t){return this._begin(t!=null&&t.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let i=0;return this._pollingPromise=new Promise((r,s)=>{const o=()=>{this.isResultAvailable()?(r(this.getResult()),this._pollingPromise=null):i++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}}function vl(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function f_(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function h_(n){return d_[n]}const d_={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function p_(n,e){var M;const{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:l,sourceFormat:c,sourceType:u}=e||{};const{framebuffer:f,deleteFramebuffer:h}=bl(n),{gl:d,handle:_}=f;o||(o=f.width),a||(a=f.height);const I=(M=f.colorAttachments[r])==null?void 0:M.texture;if(!I)throw new Error(`Invalid framebuffer attachment ${r}`);l=(I==null?void 0:I.depth)||1,c||(c=(I==null?void 0:I.glFormat)||6408),u||(u=(I==null?void 0:I.glType)||5121),s=__(s,u,c,o,a);const C=Oa(s);u=u||Bg(C);const w=d.bindFramebuffer(36160,_);return d.readBuffer(36064+r),d.readPixels(t,i,o,a,c,u,s),d.readBuffer(36064),d.bindFramebuffer(36160,w||null),h&&f.destroy(),s}function m_(n,e){const{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=e||{};const{framebuffer:u,deleteFramebuffer:f}=bl(n);a=a||u.width,l=l||u.height;const h=u;c=c||5121;let d=t;if(!d){const I=vl(s),C=f_(c),w=o+a*l*I*C;d=h.device.createBuffer({byteLength:w})}const _=n.device.createCommandEncoder();return _.copyTextureToBuffer({sourceTexture:n,width:a,height:l,origin:[i,r],destinationBuffer:d,byteOffset:o}),_.destroy(),f&&u.destroy(),d}function bl(n){return n instanceof Ni?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:g_(n),deleteFramebuffer:!0}}function g_(n,e){const{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function __(n,e,t,i,r,s){if(n)return n;e||(e=5121);const o=h_(e),a=Ba(o),l=vl(t);return new a(i*r*l)}class x_ extends zt{constructor(t){var f,h;super({...t,id:t.id||Tg("webgl-device")});m(this,"type","webgl");m(this,"handle");m(this,"features");m(this,"limits");m(this,"info");m(this,"canvasContext");m(this,"preferredColorFormat","rgba8unorm");m(this,"preferredDepthFormat","depth24plus");m(this,"commandEncoder");m(this,"lost");m(this,"_resolveContextLost");m(this,"gl");m(this,"_constants");m(this,"_extensions",{});m(this,"_polyfilled",!1);m(this,"spectorJS");const i=zt._getCanvasContextProps(t);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let r=(h=(f=i.canvas)==null?void 0:f.gl)==null?void 0:h.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Sg(this,i),this.lost=new Promise(d=>{this._resolveContextLost=d});const s={...t.webgl};i.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference);const a=this.props._handle||ng(this.canvasContext.canvas,{onContextLost:d=>{var _;return(_=this._resolveContextLost)==null?void 0:_.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:d=>console.log("WebGL context restored")},s);if(!a)throw new Error("WebGL context creation failed");if(r=a.device,r){if(t._reuseDevices)return D.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=Bm({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=ig(this.gl,this._extensions),this.limits=new yg(this.gl),this.features=new xg(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Vt(this.gl,{log:(...d)=>D.log(1,...d)()}).trackState(this.gl,{copyState:!1});const c=t.debugWebGL||t.debug,u=t.debugWebGL;c&&(this.gl=Lm(this.gl,{debugWebGL:c,traceWebGL:u}),D.warn("WebGL debug mode activated. Performance reduced.")(),t.debugWebGL&&(D.level=Math.max(D.level,1))),this.commandEncoder=new xl(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){switch(t){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){const i=this._normalizeBufferProps(t);return new Bn(this,i)}createTexture(t){return new zn(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Mg(this,t)}createShader(t){return new Pg(this,t)}createFramebuffer(t){return new On(this,t)}createVertexArray(t){return new Es(this,t)}createTransformFeedback(t){return new c_(this,t)}createQuerySet(t){return new u_(this,t)}createRenderPipeline(t){return new Qg(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(t={}){return new xl(this,t)}submit(t){t||(t=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),t._executeCommands()}readPixelsToArrayWebGL(t,i){return p_(t,i)}readPixelsToBufferWebGL(t,i){return m_(t,i)}setParametersWebGL(t){an(this.gl,t)}getParametersWebGL(t){return nl(this.gl,t)}withParametersWebGL(t,i){return Un(this.gl,t,i)}resetWebGL(){D.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Qm(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return pg(this.gl,t,this._extensions)}loseDevice(){var s;let t=!1;const r=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return r&&(t=!0,r.loseContext()),(s=this._resolveContextLost)==null||s.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){Vt.get(this.gl).push()}popState(){Vt.get(this.gl).pop()}getGLKey(t,i){const r=Number(t);for(const s in this.gl)if(this.gl[s]===r)return`GL.${s}`;return i!=null&&i.emptyIfUnknown?"":String(t)}getGLKeys(t){const i={emptyIfUnknown:!0};return Object.entries(t).reduce((r,[s,o])=>(r[`${s}:${this.getGLKey(s,i)}`]=`${o}:${this.getGLKey(o,i)}`,r),{})}setConstantAttributeWebGL(t,i){const r=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(r).fill(null);const s=this._constants[t];switch(s&&S_(s,i)&&D.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=i,i.constructor){case Float32Array:y_(this,t,i);break;case Int32Array:v_(this,t,i);break;case Uint32Array:b_(this,t,i);break;default:throw new Error("constant")}}getExtension(t){return ln(this.gl,t,this._extensions),this._extensions}_setWebGLDebugMetadata(t,i,r){t.luma=i;const s={props:r.spector,id:r.spector.id};t.__SPECTOR_Metadata=s}}function y_(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break}}function v_(n,e,t){n.gl.vertexAttribI4iv(e,t)}function b_(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function S_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}const Sl=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:x_},Symbol.toStringTag,{value:"Module"})),T_="#b3b3b3",w_=void 0,ks=void 0,A_=1,C_=4,P_="#666666",I_=.1,R_=1,E_=1,Tl="#222222",V={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,useClassicQuadtree:!1,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,repulsionQuadtreeLevels:12,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},k_=.7,D_=.95,F_=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:wl,setPrototypeOf:Al,isFrozen:M_,getPrototypeOf:N_,getOwnPropertyDescriptor:O_}=Object;let{freeze:Oe,seal:Ke,create:Cl}=Object,{apply:Ds,construct:Fs}=typeof Reflect<"u"&&Reflect;Oe||(Oe=function(e){return e}),Ke||(Ke=function(e){return e}),Ds||(Ds=function(e,t,i){return e.apply(t,i)}),Fs||(Fs=function(e,t){return new e(...t)});const Vi=Ue(Array.prototype.forEach),B_=Ue(Array.prototype.lastIndexOf),Pl=Ue(Array.prototype.pop),Ln=Ue(Array.prototype.push),U_=Ue(Array.prototype.splice),Hi=Ue(String.prototype.toLowerCase),Ms=Ue(String.prototype.toString),Il=Ue(String.prototype.match),Vn=Ue(String.prototype.replace),z_=Ue(String.prototype.indexOf),L_=Ue(String.prototype.trim),it=Ue(Object.prototype.hasOwnProperty),Be=Ue(RegExp.prototype.test),Hn=V_(TypeError);function Ue(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ds(n,e,i)}}function V_(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Fs(n,t)}}function te(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Hi;Al&&Al(n,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const s=t(r);s!==r&&(M_(e)||(e[i]=s),r=s)}n[r]=!0}return n}function H_(n){for(let e=0;e<n.length;e++)it(n,e)||(n[e]=null);return n}function yt(n){const e=Cl(null);for(const[t,i]of wl(n))it(n,t)&&(Array.isArray(i)?e[t]=H_(i):i&&typeof i=="object"&&i.constructor===Object?e[t]=yt(i):e[t]=i);return e}function Wn(n,e){for(;n!==null;){const i=O_(n,e);if(i){if(i.get)return Ue(i.get);if(typeof i.value=="function")return Ue(i.value)}n=N_(n)}function t(){return null}return t}const Rl=Oe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ns=Oe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Os=Oe(["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"]),W_=Oe(["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"]),Bs=Oe(["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"]),$_=Oe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),El=Oe(["#text"]),kl=Oe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Us=Oe(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Dl=Oe(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wi=Oe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),X_=Ke(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y_=Ke(/<%[\w\W]*|[\w\W]*%>/gm),q_=Ke(/\$\{[\w\W]*/gm),j_=Ke(/^data-[\-\w.\u00B7-\uFFFF]+$/),K_=Ke(/^aria-[\-\w]+$/),Fl=Ke(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Z_=Ke(/^(?:\w+script|data):/i),Q_=Ke(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ml=Ke(/^html$/i),J_=Ke(/^[a-z][.\w]*(-[.\w]+)+$/i);var Nl=Object.freeze({__proto__:null,ARIA_ATTR:K_,ATTR_WHITESPACE:Q_,CUSTOM_ELEMENT:J_,DATA_ATTR:j_,DOCTYPE_NAME:Ml,ERB_EXPR:Y_,IS_ALLOWED_URI:Fl,IS_SCRIPT_OR_DATA:Z_,MUSTACHE_EXPR:X_,TMPLIT_EXPR:q_});const $n={element:1,text:3,progressingInstruction:7,comment:8,document:9},G_=function(){return typeof window>"u"?null:window},ex=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ol=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Bl(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:G_();const e=Y=>Bl(Y);if(e.version="3.2.6",e.removed=[],!n||!n.document||n.document.nodeType!==$n.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const i=t,r=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:h,trustedTypes:d}=n,_=l.prototype,I=Wn(_,"cloneNode"),C=Wn(_,"remove"),w=Wn(_,"nextSibling"),M=Wn(_,"childNodes"),E=Wn(_,"parentNode");if(typeof o=="function"){const Y=t.createElement("template");Y.content&&Y.content.ownerDocument&&(t=Y.content.ownerDocument)}let x,R="";const{implementation:O,createNodeIterator:L,createDocumentFragment:W,getElementsByTagName:q}=t,{importNode:Q}=i;let B=Ol();e.isSupported=typeof wl=="function"&&typeof E=="function"&&O&&O.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:fe,ERB_EXPR:ne,TMPLIT_EXPR:P,DATA_ATTR:H,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:Z,CUSTOM_ELEMENT:j}=Nl;let{IS_ALLOWED_URI:ee}=Nl,G=null;const pe=te({},[...Rl,...Ns,...Os,...Bs,...El]);let ce=null;const be=te({},[...kl,...Us,...Dl,...Wi]);let ie=Object.seal(Cl(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}})),Le=null,Ve=null,Ge=!0,Kt=!0,bu=!1,Su=!0,_n=!1,Mr=!0,Zt=!1,Ro=!1,Eo=!1,xn=!1,Nr=!1,Or=!1,Tu=!0,wu=!1;const q0="user-content-";let ko=!0,ri=!1,yn={},vn=null;const Au=te({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Cu=null;const Pu=te({},["audio","video","img","source","image","track"]);let Do=null;const Iu=te({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Br="http://www.w3.org/1998/Math/MathML",Ur="http://www.w3.org/2000/svg",At="http://www.w3.org/1999/xhtml";let bn=At,Fo=!1,Mo=null;const j0=te({},[Br,Ur,At],Ms);let zr=te({},["mi","mo","mn","ms","mtext"]),Lr=te({},["annotation-xml"]);const K0=te({},["title","style","font","a","script"]);let si=null;const Z0=["application/xhtml+xml","text/html"],Q0="text/html";let Pe=null,Sn=null;const J0=t.createElement("form"),Ru=function(y){return y instanceof RegExp||y instanceof Function},No=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Sn&&Sn===y)){if((!y||typeof y!="object")&&(y={}),y=yt(y),si=Z0.indexOf(y.PARSER_MEDIA_TYPE)===-1?Q0:y.PARSER_MEDIA_TYPE,Pe=si==="application/xhtml+xml"?Ms:Hi,G=it(y,"ALLOWED_TAGS")?te({},y.ALLOWED_TAGS,Pe):pe,ce=it(y,"ALLOWED_ATTR")?te({},y.ALLOWED_ATTR,Pe):be,Mo=it(y,"ALLOWED_NAMESPACES")?te({},y.ALLOWED_NAMESPACES,Ms):j0,Do=it(y,"ADD_URI_SAFE_ATTR")?te(yt(Iu),y.ADD_URI_SAFE_ATTR,Pe):Iu,Cu=it(y,"ADD_DATA_URI_TAGS")?te(yt(Pu),y.ADD_DATA_URI_TAGS,Pe):Pu,vn=it(y,"FORBID_CONTENTS")?te({},y.FORBID_CONTENTS,Pe):Au,Le=it(y,"FORBID_TAGS")?te({},y.FORBID_TAGS,Pe):yt({}),Ve=it(y,"FORBID_ATTR")?te({},y.FORBID_ATTR,Pe):yt({}),yn=it(y,"USE_PROFILES")?y.USE_PROFILES:!1,Ge=y.ALLOW_ARIA_ATTR!==!1,Kt=y.ALLOW_DATA_ATTR!==!1,bu=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Su=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,_n=y.SAFE_FOR_TEMPLATES||!1,Mr=y.SAFE_FOR_XML!==!1,Zt=y.WHOLE_DOCUMENT||!1,xn=y.RETURN_DOM||!1,Nr=y.RETURN_DOM_FRAGMENT||!1,Or=y.RETURN_TRUSTED_TYPE||!1,Eo=y.FORCE_BODY||!1,Tu=y.SANITIZE_DOM!==!1,wu=y.SANITIZE_NAMED_PROPS||!1,ko=y.KEEP_CONTENT!==!1,ri=y.IN_PLACE||!1,ee=y.ALLOWED_URI_REGEXP||Fl,bn=y.NAMESPACE||At,zr=y.MATHML_TEXT_INTEGRATION_POINTS||zr,Lr=y.HTML_INTEGRATION_POINTS||Lr,ie=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Ru(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ie.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Ru(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ie.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),_n&&(Kt=!1),Nr&&(xn=!0),yn&&(G=te({},El),ce=[],yn.html===!0&&(te(G,Rl),te(ce,kl)),yn.svg===!0&&(te(G,Ns),te(ce,Us),te(ce,Wi)),yn.svgFilters===!0&&(te(G,Os),te(ce,Us),te(ce,Wi)),yn.mathMl===!0&&(te(G,Bs),te(ce,Dl),te(ce,Wi))),y.ADD_TAGS&&(G===pe&&(G=yt(G)),te(G,y.ADD_TAGS,Pe)),y.ADD_ATTR&&(ce===be&&(ce=yt(ce)),te(ce,y.ADD_ATTR,Pe)),y.ADD_URI_SAFE_ATTR&&te(Do,y.ADD_URI_SAFE_ATTR,Pe),y.FORBID_CONTENTS&&(vn===Au&&(vn=yt(vn)),te(vn,y.FORBID_CONTENTS,Pe)),ko&&(G["#text"]=!0),Zt&&te(G,["html","head","body"]),G.table&&(te(G,["tbody"]),delete Le.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Hn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Hn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=y.TRUSTED_TYPES_POLICY,R=x.createHTML("")}else x===void 0&&(x=ex(d,r)),x!==null&&typeof R=="string"&&(R=x.createHTML(""));Oe&&Oe(y),Sn=y}},Eu=te({},[...Ns,...Os,...W_]),ku=te({},[...Bs,...$_]),G0=function(y){let N=E(y);(!N||!N.tagName)&&(N={namespaceURI:bn,tagName:"template"});const X=Hi(y.tagName),me=Hi(N.tagName);return Mo[y.namespaceURI]?y.namespaceURI===Ur?N.namespaceURI===At?X==="svg":N.namespaceURI===Br?X==="svg"&&(me==="annotation-xml"||zr[me]):!!Eu[X]:y.namespaceURI===Br?N.namespaceURI===At?X==="math":N.namespaceURI===Ur?X==="math"&&Lr[me]:!!ku[X]:y.namespaceURI===At?N.namespaceURI===Ur&&!Lr[me]||N.namespaceURI===Br&&!zr[me]?!1:!ku[X]&&(K0[X]||!Eu[X]):!!(si==="application/xhtml+xml"&&Mo[y.namespaceURI]):!1},mt=function(y){Ln(e.removed,{element:y});try{E(y).removeChild(y)}catch{C(y)}},Tn=function(y,N){try{Ln(e.removed,{attribute:N.getAttributeNode(y),from:N})}catch{Ln(e.removed,{attribute:null,from:N})}if(N.removeAttribute(y),y==="is")if(xn||Nr)try{mt(N)}catch{}else try{N.setAttribute(y,"")}catch{}},Du=function(y){let N=null,X=null;if(Eo)y="<remove></remove>"+y;else{const Ae=Il(y,/^[\r\n\t ]+/);X=Ae&&Ae[0]}si==="application/xhtml+xml"&&bn===At&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const me=x?x.createHTML(y):y;if(bn===At)try{N=new h().parseFromString(me,si)}catch{}if(!N||!N.documentElement){N=O.createDocument(bn,"template",null);try{N.documentElement.innerHTML=Fo?R:me}catch{}}const Fe=N.body||N.documentElement;return y&&X&&Fe.insertBefore(t.createTextNode(X),Fe.childNodes[0]||null),bn===At?q.call(N,Zt?"html":"body")[0]:Zt?N.documentElement:Fe},Fu=function(y){return L.call(y.ownerDocument||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Oo=function(y){return y instanceof f&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof u)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Mu=function(y){return typeof a=="function"&&y instanceof a};function Ct(Y,y,N){Vi(Y,X=>{X.call(e,y,N,Sn)})}const Nu=function(y){let N=null;if(Ct(B.beforeSanitizeElements,y,null),Oo(y))return mt(y),!0;const X=Pe(y.nodeName);if(Ct(B.uponSanitizeElement,y,{tagName:X,allowedTags:G}),Mr&&y.hasChildNodes()&&!Mu(y.firstElementChild)&&Be(/<[/\w!]/g,y.innerHTML)&&Be(/<[/\w!]/g,y.textContent)||y.nodeType===$n.progressingInstruction||Mr&&y.nodeType===$n.comment&&Be(/<[/\w]/g,y.data))return mt(y),!0;if(!G[X]||Le[X]){if(!Le[X]&&Bu(X)&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,X)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(X)))return!1;if(ko&&!vn[X]){const me=E(y)||y.parentNode,Fe=M(y)||y.childNodes;if(Fe&&me){const Ae=Fe.length;for(let $e=Ae-1;$e>=0;--$e){const Pt=I(Fe[$e],!0);Pt.__removalCount=(y.__removalCount||0)+1,me.insertBefore(Pt,w(y))}}}return mt(y),!0}return y instanceof l&&!G0(y)||(X==="noscript"||X==="noembed"||X==="noframes")&&Be(/<\/no(script|embed|frames)/i,y.innerHTML)?(mt(y),!0):(_n&&y.nodeType===$n.text&&(N=y.textContent,Vi([fe,ne,P],me=>{N=Vn(N,me," ")}),y.textContent!==N&&(Ln(e.removed,{element:y.cloneNode()}),y.textContent=N)),Ct(B.afterSanitizeElements,y,null),!1)},Ou=function(y,N,X){if(Tu&&(N==="id"||N==="name")&&(X in t||X in J0))return!1;if(!(Kt&&!Ve[N]&&Be(H,N))){if(!(Ge&&Be(F,N))){if(!ce[N]||Ve[N]){if(!(Bu(y)&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,y)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(y))&&(ie.attributeNameCheck instanceof RegExp&&Be(ie.attributeNameCheck,N)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(N))||N==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&Be(ie.tagNameCheck,X)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(X))))return!1}else if(!Do[N]){if(!Be(ee,Vn(X,Z,""))){if(!((N==="src"||N==="xlink:href"||N==="href")&&y!=="script"&&z_(X,"data:")===0&&Cu[y])){if(!(bu&&!Be($,Vn(X,Z,"")))){if(X)return!1}}}}}}return!0},Bu=function(y){return y!=="annotation-xml"&&Il(y,j)},Uu=function(y){Ct(B.beforeSanitizeAttributes,y,null);const{attributes:N}=y;if(!N||Oo(y))return;const X={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ce,forceKeepAttr:void 0};let me=N.length;for(;me--;){const Fe=N[me],{name:Ae,namespaceURI:$e,value:Pt}=Fe,oi=Pe(Ae),Bo=Pt;let Me=Ae==="value"?Bo:L_(Bo);if(X.attrName=oi,X.attrValue=Me,X.keepAttr=!0,X.forceKeepAttr=void 0,Ct(B.uponSanitizeAttribute,y,X),Me=X.attrValue,wu&&(oi==="id"||oi==="name")&&(Tn(Ae,y),Me=q0+Me),Mr&&Be(/((--!?|])>)|<\/(style|title)/i,Me)){Tn(Ae,y);continue}if(X.forceKeepAttr)continue;if(!X.keepAttr){Tn(Ae,y);continue}if(!Su&&Be(/\/>/i,Me)){Tn(Ae,y);continue}_n&&Vi([fe,ne,P],Lu=>{Me=Vn(Me,Lu," ")});const zu=Pe(y.nodeName);if(!Ou(zu,oi,Me)){Tn(Ae,y);continue}if(x&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!$e)switch(d.getAttributeType(zu,oi)){case"TrustedHTML":{Me=x.createHTML(Me);break}case"TrustedScriptURL":{Me=x.createScriptURL(Me);break}}if(Me!==Bo)try{$e?y.setAttributeNS($e,Ae,Me):y.setAttribute(Ae,Me),Oo(y)?mt(y):Pl(e.removed)}catch{Tn(Ae,y)}}Ct(B.afterSanitizeAttributes,y,null)},eb=function Y(y){let N=null;const X=Fu(y);for(Ct(B.beforeSanitizeShadowDOM,y,null);N=X.nextNode();)Ct(B.uponSanitizeShadowNode,N,null),Nu(N),Uu(N),N.content instanceof s&&Y(N.content);Ct(B.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(Y){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=null,X=null,me=null,Fe=null;if(Fo=!Y,Fo&&(Y="<!-->"),typeof Y!="string"&&!Mu(Y))if(typeof Y.toString=="function"){if(Y=Y.toString(),typeof Y!="string")throw Hn("dirty is not a string, aborting")}else throw Hn("toString is not a function");if(!e.isSupported)return Y;if(Ro||No(y),e.removed=[],typeof Y=="string"&&(ri=!1),ri){if(Y.nodeName){const Pt=Pe(Y.nodeName);if(!G[Pt]||Le[Pt])throw Hn("root node is forbidden and cannot be sanitized in-place")}}else if(Y instanceof a)N=Du("<!---->"),X=N.ownerDocument.importNode(Y,!0),X.nodeType===$n.element&&X.nodeName==="BODY"||X.nodeName==="HTML"?N=X:N.appendChild(X);else{if(!xn&&!_n&&!Zt&&Y.indexOf("<")===-1)return x&&Or?x.createHTML(Y):Y;if(N=Du(Y),!N)return xn?null:Or?R:""}N&&Eo&&mt(N.firstChild);const Ae=Fu(ri?Y:N);for(;me=Ae.nextNode();)Nu(me),Uu(me),me.content instanceof s&&eb(me.content);if(ri)return Y;if(xn){if(Nr)for(Fe=W.call(N.ownerDocument);N.firstChild;)Fe.appendChild(N.firstChild);else Fe=N;return(ce.shadowroot||ce.shadowrootmode)&&(Fe=Q.call(i,Fe,!0)),Fe}let $e=Zt?N.outerHTML:N.innerHTML;return Zt&&G["!doctype"]&&N.ownerDocument&&N.ownerDocument.doctype&&N.ownerDocument.doctype.name&&Be(Ml,N.ownerDocument.doctype.name)&&($e="<!DOCTYPE "+N.ownerDocument.doctype.name+`>
|
|
13
|
+
`+$e),_n&&Vi([fe,ne,P],Pt=>{$e=Vn($e,Pt," ")}),x&&Or?x.createHTML($e):$e},e.setConfig=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};No(Y),Ro=!0},e.clearConfig=function(){Sn=null,Ro=!1},e.isValidAttribute=function(Y,y,N){Sn||No({});const X=Pe(Y),me=Pe(y);return Ou(X,me,N)},e.addHook=function(Y,y){typeof y=="function"&&Ln(B[Y],y)},e.removeHook=function(Y,y){if(y!==void 0){const N=B_(B[Y],y);return N===-1?void 0:U_(B[Y],N,1)[0]}return Pl(B[Y])},e.removeHooks=function(Y){B[Y]=[]},e.removeAllHooks=function(){B=Ol()},e}var tx=Bl();const Ul=n=>typeof n=="function",zs=n=>Array.isArray(n),zl=n=>n instanceof Object,Ll=n=>n instanceof Object?n.constructor.name!=="Function"&&n.constructor.name!=="Object":!1,Ls=n=>zl(n)&&!zs(n)&&!Ul(n)&&!Ll(n);function vt(n){let e;if(zs(n))e=n;else{const t=It(n),i=t==null?void 0:t.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function Vl(n,e,t){return .2126*n+.7152*e+.0722*t}function We(n,e,t=0,i=0,r,s){return n.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:i,sourceWidth:r,sourceHeight:s})}function Hl(n,e,t){return Math.min(Math.max(n,e),t)}function qe(n){return n!=null&&!Number.isNaN(n)}function Wl(n,e){return tx.sanitize(n,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class nx{constructor(){this.enableSimulation=V.enableSimulation,this.backgroundColor=Tl,this.spaceSize=V.spaceSize,this.pointColor=T_,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=w_,this.pointGreyoutColor=ks,this.pointSize=C_,this.pointDefaultSize=void 0,this.pointOpacity=A_,this.pointSizeScale=V.pointSizeScale,this.hoveredPointCursor=V.hoveredPointCursor,this.hoveredLinkCursor=V.hoveredLinkCursor,this.renderHoveredPointRing=V.renderHoveredPointRing,this.hoveredPointRingColor=V.hoveredPointRingColor,this.focusedPointRingColor=V.focusedPointRingColor,this.focusedPointIndex=V.focusedPointIndex,this.linkColor=P_,this.linkDefaultColor=void 0,this.linkOpacity=R_,this.linkGreyoutOpacity=I_,this.linkWidth=E_,this.linkDefaultWidth=void 0,this.linkWidthScale=V.linkWidthScale,this.hoveredLinkColor=V.hoveredLinkColor,this.hoveredLinkWidthIncrease=V.hoveredLinkWidthIncrease,this.renderLinks=V.renderLinks,this.curvedLinks=V.curvedLinks,this.curvedLinkSegments=V.curvedLinkSegments,this.curvedLinkWeight=V.curvedLinkWeight,this.curvedLinkControlPointDistance=V.curvedLinkControlPointDistance,this.linkArrows=V.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=V.linkArrowsSizeScale,this.scaleLinksOnZoom=V.scaleLinksOnZoom,this.linkVisibilityDistanceRange=V.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=V.linkVisibilityMinTransparency,this.useClassicQuadtree=V.useClassicQuadtree,this.simulationDecay=V.simulation.decay,this.simulationGravity=V.simulation.gravity,this.simulationCenter=V.simulation.center,this.simulationRepulsion=V.simulation.repulsion,this.simulationRepulsionTheta=V.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=V.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=V.simulation.linkSpring,this.simulationLinkDistance=V.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=V.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=V.simulation.repulsionFromMouse,this.enableRightClickRepulsion=V.enableRightClickRepulsion,this.simulationFriction=V.simulation.friction,this.simulationCluster=V.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=V.showFPSMonitor,this.pixelRatio=V.pixelRatio,this.scalePointsOnZoom=V.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=V.enableZoom,this.enableSimulationDuringZoom=V.enableSimulationDuringZoom,this.enableDrag=V.enableDrag,this.fitViewOnInit=V.fitViewOnInit,this.fitViewDelay=V.fitViewDelay,this.fitViewPadding=V.fitViewPadding,this.fitViewDuration=V.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=V.pointSamplingDistance,this.attribution=V.attribution,this.rescalePositions=V.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,i){Ls(e[i])&&Ls(t[i])?Object.keys(t[i]).forEach(r=>{this.deepMergeConfig(e[i],t[i],r)}):e[i]=t[i]}getConfig(){return this}}function Vs(n,e){if(!n)throw new Error(e||"shadertools: assertion failed.")}const Hs={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}};function ix(n){const e={};for(const[t,i]of Object.entries(n))e[t]=rx(i);return e}function rx(n){let e=$l(n);if(e!=="object")return{value:n,...Hs[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...Hs[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=$l(n.value),{...n,...Hs[e],type:e}):{type:"object",value:null};throw new Error("props")}function $l(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}const sx={vertex:`#ifdef MODULE_LOGDEPTH
|
|
14
14
|
logdepth_adjustPosition(gl_Position);
|
|
15
15
|
#endif
|
|
16
16
|
`,fragment:`#ifdef MODULE_MATERIAL
|
|
@@ -33,9 +33,9 @@ ${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(t
|
|
|
33
33
|
#ifdef MODULE_LOGDEPTH
|
|
34
34
|
logdepth_setFragDepth();
|
|
35
35
|
#endif
|
|
36
|
-
`},
|
|
36
|
+
`},Xl=/void\s+main\s*\([^)]*\)\s*\{\n?/,Yl=/}\n?[^{}]*$/,Ws=[],$i="__LUMA_INJECT_DECLARATIONS__";function ox(n){const e={vertex:{},fragment:{}};for(const t in n){let i=n[t];const r=ax(t);typeof i=="string"&&(i={order:0,injection:i}),e[r][t]=i}return e}function ax(n){const e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function Xi(n,e,t,i=!1){const r=e==="vertex";for(const s in t){const o=t[s];o.sort((l,c)=>l.order-c.order),Ws.length=o.length;for(let l=0,c=o.length;l<c;++l)Ws[l]=o[l].injection;const a=`${Ws.join(`
|
|
37
37
|
`)}
|
|
38
|
-
`;switch(s){case"vs:#decl":r&&(n=n.replace($i,a));break;case"vs:#main-start":r&&(n=n.replace(
|
|
38
|
+
`;switch(s){case"vs:#decl":r&&(n=n.replace($i,a));break;case"vs:#main-start":r&&(n=n.replace(Xl,l=>l+a));break;case"vs:#main-end":r&&(n=n.replace(Yl,l=>a+l));break;case"fs:#decl":r||(n=n.replace($i,a));break;case"fs:#main-start":r||(n=n.replace(Xl,l=>l+a));break;case"fs:#main-end":r||(n=n.replace(Yl,l=>a+l));break;default:n=n.replace(s,l=>l+a)}}return n=n.replace($i,""),i&&(n=n.replace(/\}\s*$/,s=>s+sx[e])),n}function Yi(n){n.map(e=>lx(e))}function lx(n){if(n.instance)return;Yi(n.dependencies||[]);const{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:ox(i),parsedDeprecations:cx(t)};e&&(r.propValidators=ix(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,l])=>{const c=l==null?void 0:l.value;return c&&(o[a]=c),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function ql(n,e,t){var i;(i=n.deprecations)==null||i.forEach(r=>{var s;(s=r.regex)!=null&&s.test(e)&&(r.deprecated?t.deprecated(r.old,r.new)():t.removed(r.old,r.new)())})}function cx(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}function $s(n){Yi(n);const e={},t={};jl({modules:n,level:0,moduleMap:e,moduleDepth:t});const i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Yi(i),i}function jl(n){const{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(const s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]<t)&&(r[s.name]=t);for(const s of e)s.dependencies&&jl({modules:s.dependencies,level:t+1,moduleMap:i,moduleDepth:r})}function ux(n){switch(n==null?void 0:n.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
39
39
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
40
40
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
41
41
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -59,17 +59,17 @@ ${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(t
|
|
|
59
59
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
60
60
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
61
61
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
62
|
-
`}}function fx(n,e){var i;if(Number(((i=n.match(/^#version[ \t]+(\d+)/m))==null?void 0:i[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=
|
|
63
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],hx=[...
|
|
62
|
+
`}}function fx(n,e){var i;if(Number(((i=n.match(/^#version[ \t]+(\d+)/m))==null?void 0:i[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=Zl(n,hx),n;case"fragment":return n=Zl(n,dx),n;default:throw new Error(e)}}const Kl=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
63
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],hx=[...Kl,[Xs("attribute"),"in $1"],[Xs("varying"),"out $1"]],dx=[...Kl,[Xs("varying"),"in $1"]];function Zl(n,e){for(const[t,i]of e)n=n.replace(t,i);return n}function Xs(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Ql(n,e){let t="";for(const i in n){const r=n[i];if(t+=`void ${r.signature} {
|
|
64
64
|
`,r.header&&(t+=` ${r.header}`),e[i]){const s=e[i];s.sort((o,a)=>o.order-a.order);for(const o of s)t+=` ${o.injection}
|
|
65
65
|
`}r.footer&&(t+=` ${r.footer}`),t+=`}
|
|
66
|
-
`}return t}function
|
|
66
|
+
`}return t}function Jl(n){const e={vertex:{},fragment:{}};for(const t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();const[s,o]=r.split(":"),a=r.replace(/\(.+/,""),l=Object.assign(i,{signature:o});switch(s){case"vs":e.vertex[a]=l;break;case"fs":e.fragment[a]=l;break;default:throw new Error(s)}}return e}function px(n,e){return{name:mx(n,e),language:"glsl",version:gx(n)}}function mx(n,e="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function gx(n){let e=100;const t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){const i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}const Gl=`
|
|
67
67
|
|
|
68
68
|
${$i}
|
|
69
69
|
`,_x=`precision highp float;
|
|
70
|
-
`;function xx(n){const e=$s(n.modules||[]);return{source:vx(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e}),getUniforms:
|
|
70
|
+
`;function xx(n){const e=$s(n.modules||[]);return{source:vx(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e}),getUniforms:tc(e)}}function yx(n){const{vs:e,fs:t}=n,i=$s(n.modules||[]);return{vs:ec(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:ec(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:tc(i)}}function vx(n,e){var I;const{source:t,stage:i,modules:r,hookFunctions:s=[],inject:o={},log:a}=e;Vs(typeof t=="string","shader source must be a string");const l=t;let c="";const u=Jl(s),f={},h={},d={};for(const C in o){const w=typeof o[C]=="string"?{injection:o[C],order:0}:o[C],M=/^(v|f)s:(#)?([\w-]+)$/.exec(C);if(M){const E=M[2],x=M[3];E?x==="decl"?h[C]=[w]:d[C]=[w]:f[C]=[w]}else d[C]=[w]}const _=r;for(const C of _){a&&ql(C,l,a);const w=nc(C,"wgsl");c+=w;const M=((I=C.injections)==null?void 0:I[i])||{};for(const E in M){const x=/^(v|f)s:#([\w-]+)$/.exec(E);if(x){const O=x[2]==="decl"?h:d;O[E]=O[E]||[],O[E].push(M[E])}else f[E]=f[E]||[],f[E].push(M[E])}}return c+=Gl,c=Xi(c,i,h),c+=Ql(u[i],f),c+=l,c=Xi(c,i,d),c}function ec(n,e){var O;const{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:l={},prologue:c=!0,log:u}=e;Vs(typeof t=="string","shader source must be a string");const f=r==="glsl"?px(t).version:-1,h=n.shaderLanguageVersion,d=f===100?"#version 100":"#version 300 es",I=t.split(`
|
|
71
71
|
`).slice(1).join(`
|
|
72
|
-
`),C={};s.forEach(L=>{Object.assign(C,L.defines)}),Object.assign(C,o);let w="";switch(r){case"wgsl":break;case"glsl":w=
|
|
72
|
+
`),C={};s.forEach(L=>{Object.assign(C,L.defines)}),Object.assign(C,o);let w="";switch(r){case"wgsl":break;case"glsl":w=c?`${d}
|
|
73
73
|
|
|
74
74
|
// ----- PROLOGUE -------------------------
|
|
75
75
|
${`#define SHADER_TYPE_${i.toUpperCase()}`}
|
|
@@ -82,18 +82,18 @@ ${i==="fragment"?_x:""}
|
|
|
82
82
|
${bx(C)}
|
|
83
83
|
|
|
84
84
|
`:`${d}
|
|
85
|
-
`;break}const M=
|
|
86
|
-
`)}return e}function
|
|
85
|
+
`;break}const M=Jl(a),E={},x={},R={};for(const L in l){const W=typeof l[L]=="string"?{injection:l[L],order:0}:l[L],q=/^(v|f)s:(#)?([\w-]+)$/.exec(L);if(q){const Q=q[2],B=q[3];Q?B==="decl"?x[L]=[W]:R[L]=[W]:E[L]=[W]}else R[L]=[W]}for(const L of s){u&&ql(L,I,u);const W=nc(L,i);w+=W;const q=((O=L.instance)==null?void 0:O.normalizedInjections[i])||{};for(const Q in q){const B=/^(v|f)s:#([\w-]+)$/.exec(Q);if(B){const ne=B[2]==="decl"?x:R;ne[Q]=ne[Q]||[],ne[Q].push(q[Q])}else E[Q]=E[Q]||[],E[Q].push(q[Q])}}return w+="// ----- MAIN SHADER SOURCE -------------------------",w+=Gl,w=Xi(w,i,x),w+=Ql(M[i],E),w+=I,w=Xi(w,i,R),r==="glsl"&&f!==h&&(w=fx(w,i)),w.trim()}function tc(n){return function(t){var r;const i={};for(const s of n){const o=(r=s.getUniforms)==null?void 0:r.call(s,t,i);Object.assign(i,o)}return i}}function bx(n={}){let e="";for(const t in n){const i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]}
|
|
86
|
+
`)}return e}function nc(n,e){let t;switch(e){case"vertex":t=n.vs||"";break;case"fragment":t=n.fs||"";break;case"wgsl":t=n.source||"";break;default:Vs(!1)}if(!n.name)throw new Error("Shader module must have a name");const i=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let r=`// ----- MODULE ${n.name} ---------------
|
|
87
87
|
|
|
88
88
|
`;return e!=="wgsl"&&(r+=`#define MODULE_${i}
|
|
89
89
|
`),r+=`${t}
|
|
90
90
|
`,r}const Sx=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Tx=/^\s*\#\s*endif\s*$/;function wx(n,e){var o;const t=n.split(`
|
|
91
|
-
`),i=[];let r=!0,s=null;for(const a of t){const
|
|
92
|
-
`)}const jt=class jt{constructor(){m(this,"_hookFunctions",[]);m(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return jt.defaultShaderAssembler=jt.defaultShaderAssembler||new jt,jt.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,{source:r,getUniforms:s}=xx({...e,source:e.source,modules:t,hookFunctions:i});return{source:e.platformInfo.shaderLanguage==="wgsl"?wx(r):r,getUniforms:s,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),i=this._hookFunctions;return{...yx({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:i}),modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let r=0;for(let s=0,o=this._defaultModules.length;s<o;++s){const a=this._defaultModules[s],c=a.name;t[r++]=a,i[c]=!0}for(let s=0,o=e.length;s<o;++s){const a=e[s],c=a.name;i[c]||(t[r++]=a,i[c]=!0)}return t.length=r,Yi(t),t}};m(jt,"defaultShaderAssembler");let Ys=jt;class Ze{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class il{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i,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 Et extends Ze{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class kt extends Ze{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class qs extends Ze{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class Wt extends Ze{constructor(e,t,i,r){super(e,i),this.format=t,this.access=r}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 Ft;(n=>{n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(Ft||(Ft={}));class qi{constructor(e,t,i,r,s,o,a){this.name=e,this.type=t,this.group=i,this.binding=r,this.attributes=s,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 Ax{constructor(e,t){this.name=e,this.type=t}}class Cx{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r,this.interpolation=null}}class rl{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r}}class Px{constructor(e,t,i,r){this.name=e,this.type=t,this.attributes=i,this.id=r}}class Ix{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Rx{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class Ex{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function kx(n){var e=(32768&n)>>15,t=(31744&n)>>10,i=1023&n;return t==0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):t==31?i?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,t-15)*(1+i/Math.pow(2,10))}const sl=new Float32Array(1),Fx=new Int32Array(sl.buffer),ke=new Uint16Array(1);function Dx(n){sl[0]=n;const e=Fx[0],t=e>>31&1;let i=e>>23&255,r=8388607&e;if(i===255)return ke[0]=t<<15|31744|(r!==0?512:0),ke[0];if(i===0){if(r===0)return ke[0]=t<<15,ke[0];r|=8388608;let s=113;for(;!(8388608&r);)r<<=1,s--;return i=127-s,r&=8388607,i>0?(r=(r>>126-i)+(r>>127-i&1),ke[0]=t<<15|i<<10|r>>13,ke[0]):(ke[0]=t<<15,ke[0])}return i=i-127+15,i>=31?(ke[0]=t<<15|31744,ke[0]):i<=0?i<-10?(ke[0]=t<<15,ke[0]):(r=(8388608|r)>>1-i,ke[0]=t<<15|r>>13,ke[0]):(r>>=13,ke[0]=t<<15|i<<10|r,ke[0])}const js=new Uint32Array(1),ol=new Float32Array(js.buffer,0,1);function al(n){const e=112+(n>>6&31)<<23|(63&n)<<17;return js[0]=e,ol[0]}function Mx(n,e,t,i,r,s,o,a,c){const l=i*(o>>=r)*(s>>=r)+t*o+e*a;switch(c){case"r8unorm":return[re(n,l,"8unorm",1)[0]];case"r8snorm":return[re(n,l,"8snorm",1)[0]];case"r8uint":return[re(n,l,"8uint",1)[0]];case"r8sint":return[re(n,l,"8sint",1)[0]];case"rg8unorm":{const u=re(n,l,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=re(n,l,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=re(n,l,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=re(n,l,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=re(n,l,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=re(n,l,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=re(n,l,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=re(n,l,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=re(n,l,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[re(n,l,"16uint",1)[0]];case"r16sint":return[re(n,l,"16sint",1)[0]];case"r16float":return[re(n,l,"16float",1)[0]];case"rg16uint":{const u=re(n,l,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=re(n,l,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=re(n,l,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=re(n,l,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=re(n,l,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=re(n,l,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[re(n,l,"32uint",1)[0]];case"r32sint":return[re(n,l,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[re(n,l,"32float",1)[0]];case"rg32uint":{const u=re(n,l,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=re(n,l,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=re(n,l,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=re(n,l,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=re(n,l,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=re(n,l,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(n.buffer,l,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[al(2047&u),al(f),function(d){const _=112+(d>>5&31)<<23|(31&d)<<18;return js[0]=_,ol[0]}(h),1]}}return null}function re(n,e,t,i){const r=[0,0,0,0];for(let s=0;s<i;++s)switch(t){case"8unorm":r[s]=n[e]/255,e++;break;case"8snorm":r[s]=n[e]/255*2-1,e++;break;case"8uint":r[s]=n[e],e++;break;case"8sint":r[s]=n[e]-127,e++;break;case"16uint":r[s]=n[e]|n[e+1]<<8,e+=2;break;case"16sint":r[s]=(n[e]|n[e+1]<<8)-32768,e+=2;break;case"16float":r[s]=kx(n[e]|n[e+1]<<8),e+=2;break;case"32uint":case"32sint":r[s]=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24,e+=4;break;case"32float":r[s]=new Float32Array(n.buffer,e,1)[0],e+=4}return r}function se(n,e,t,i,r){for(let s=0;s<i;++s)switch(t){case"8unorm":n[e]=255*r[s],e++;break;case"8snorm":n[e]=.5*(r[s]+1)*255,e++;break;case"8uint":n[e]=r[s],e++;break;case"8sint":n[e]=r[s]+127,e++;break;case"16uint":new Uint16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16sint":new Int16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16float":{const o=Dx(r[s]);new Uint16Array(n.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32sint":new Int32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32float":new Float32Array(n.buffer,e,1)[0]=r[s],e+=4}return r}const Ks={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class Qe{constructor(){this.id=Qe._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(ji.instance);for(const i of e)i instanceof Array?this.searchBlock(i,t):i.search(t);t(Ki.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}Qe._id=0;class ji extends Qe{}ji.instance=new ji;class Ki extends Qe{}Ki.instance=new Ki;const cl=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class pe extends Qe{constructor(){super()}}class Xn extends pe{constructor(e,t,i,r,s,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=i,this.body=r,this.startLine=s,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class Nx extends pe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class ll extends pe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Zs extends pe{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class ul extends pe{constructor(e,t,i,r){super(),this.init=e,this.condition=t,this.increment=i,this.body=r}get astNodeType(){return"for"}search(e){var t,i,r;(t=this.init)===null||t===void 0||t.search(e),(i=this.condition)===null||i===void 0||i.search(e),(r=this.increment)===null||r===void 0||r.search(e),this.searchBlock(this.body,e)}}class bt extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class Qs extends pe{constructor(e,t,i){super(),this.attributes=null,this.name=e,this.type=t,this.value=i}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Yn extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class Zi extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}var hn,qn,A,b;(n=>{n.increment="++",n.decrement="--"})(hn||(hn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return n[t]}})(hn||(hn={}));class fl extends pe{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(n=>{n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(qn||(qn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(qn||(qn={}));class hl extends pe{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Js extends pe{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return cl.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class dl extends pe{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),(t=this.continuing)===null||t===void 0||t.search(e)}}class pl extends pe{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class ml extends pe{constructor(e,t,i,r){super(),this.condition=e,this.body=t,this.elseif=i,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class gl extends pe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Ox extends pe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class Bx extends pe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class _l extends pe{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class Gs extends pe{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class Ux extends pe{constructor(){super()}get astNodeType(){return"discard"}}class xl extends pe{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}let yl=class extends pe{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}};class k extends pe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=k._priority.get(t.name);k._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?k.i32:t}getTypeName(){return this.name}}k.x32=new k("x32"),k.f32=new k("f32"),k.i32=new k("i32"),k.u32=new k("u32"),k.f16=new k("f16"),k.bool=new k("bool"),k.void=new k("void"),k._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class vl extends k{constructor(e){super(e)}}class St extends k{constructor(e,t,i,r){super(e),this.members=t,this.startLine=i,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class T extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}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}}T.vec2f=new T("vec2",k.f32,null),T.vec3f=new T("vec3",k.f32,null),T.vec4f=new T("vec4",k.f32,null),T.vec2i=new T("vec2",k.i32,null),T.vec3i=new T("vec3",k.i32,null),T.vec4i=new T("vec4",k.i32,null),T.vec2u=new T("vec2",k.u32,null),T.vec3u=new T("vec3",k.u32,null),T.vec4u=new T("vec4",k.u32,null),T.vec2h=new T("vec2",k.f16,null),T.vec3h=new T("vec3",k.f16,null),T.vec4h=new T("vec4",k.f16,null),T.vec2b=new T("vec2",k.bool,null),T.vec3b=new T("vec3",k.bool,null),T.vec4b=new T("vec4",k.bool,null),T.mat2x2f=new T("mat2x2",k.f32,null),T.mat2x3f=new T("mat2x3",k.f32,null),T.mat2x4f=new T("mat2x4",k.f32,null),T.mat3x2f=new T("mat3x2",k.f32,null),T.mat3x3f=new T("mat3x3",k.f32,null),T.mat3x4f=new T("mat3x4",k.f32,null),T.mat4x2f=new T("mat4x2",k.f32,null),T.mat4x3f=new T("mat4x3",k.f32,null),T.mat4x4f=new T("mat4x4",k.f32,null),T.mat2x2h=new T("mat2x2",k.f16,null),T.mat2x3h=new T("mat2x3",k.f16,null),T.mat2x4h=new T("mat2x4",k.f16,null),T.mat3x2h=new T("mat3x2",k.f16,null),T.mat3x3h=new T("mat3x3",k.f16,null),T.mat3x4h=new T("mat3x4",k.f16,null),T.mat4x2h=new T("mat4x2",k.f16,null),T.mat4x3h=new T("mat4x3",k.f16,null),T.mat4x4h=new T("mat4x4",k.f16,null),T.mat2x2i=new T("mat2x2",k.i32,null),T.mat2x3i=new T("mat2x3",k.i32,null),T.mat2x4i=new T("mat2x4",k.i32,null),T.mat3x2i=new T("mat3x2",k.i32,null),T.mat3x3i=new T("mat3x3",k.i32,null),T.mat3x4i=new T("mat3x4",k.i32,null),T.mat4x2i=new T("mat4x2",k.i32,null),T.mat4x3i=new T("mat4x3",k.i32,null),T.mat4x4i=new T("mat4x4",k.i32,null),T.mat2x2u=new T("mat2x2",k.u32,null),T.mat2x3u=new T("mat2x3",k.u32,null),T.mat2x4u=new T("mat2x4",k.u32,null),T.mat3x2u=new T("mat3x2",k.u32,null),T.mat3x3u=new T("mat3x3",k.u32,null),T.mat3x4u=new T("mat3x4",k.u32,null),T.mat4x2u=new T("mat4x2",k.u32,null),T.mat4x3u=new T("mat4x3",k.u32,null),T.mat4x4u=new T("mat4x4",k.u32,null);class Qi extends k{constructor(e,t,i,r){super(e),this.storage=t,this.type=i,this.access=r}get astNodeType(){return"pointer"}}class jn extends k{constructor(e,t,i,r){super(e),this.attributes=t,this.format=i,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class Kn extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class rt extends Qe{constructor(){super(),this.postfix=null}}class $t extends rt{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class ht extends rt{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class eo extends rt{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return cl.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class je extends rt{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class bl extends rt{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const i=e.evalExpression(this.initializer,e.context);return i!==null&&this.postfix?i.getSubData(e,this.postfix,e.context):i}return null}search(e){this.initializer.search(e)}}class Te extends rt{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof v}get isVector(){return this.value instanceof g||this.value instanceof Z}get scalarValue(){return this.value instanceof v?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof g||this.value instanceof Z?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class Sl extends rt{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class dn extends rt{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Tl extends rt{constructor(){super()}}class ve extends Tl{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class st extends Tl{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?k.f32:e.name==="u32"||t.name==="u32"?k.u32:k.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class wl extends Qe{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Ji extends rt{constructor(){super()}get astNodeType(){return"default"}}class Al extends wl{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Cl extends wl{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Pl extends Qe{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class zx extends Qe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Il extends Qe{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class Rl extends Qe{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Je{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Je._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Je._id=0;class to extends Je{constructor(){super(new Ze("void",null),null)}toString(){return"void"}}to.void=new to;class pn extends Je{constructor(e){super(new qs("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,r){this.reference.setDataValue(e,t,i,r)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class v extends Je{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new v(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new v(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new v(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,r){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);let s=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?s=Math.floor(s):this.typeInfo.name==="bool"&&(s=s?1:0),this.data[0]=s}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Lx(n,e,t){const i=e.length;return i===2?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec2i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec2u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):i===3?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec3i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec3u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):i===4?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec4i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec4u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}class g extends Je{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const r=this.typeInfo.name;r==="vec2f"||r==="vec3f"||r==="vec4f"?this.data=new Float32Array(e):r==="vec2i"||r==="vec3i"||r==="vec4i"?this.data=new Int32Array(e):r==="vec2u"||r==="vec3u"||r==="vec4u"?this.data=new Uint32Array(e):r==="vec2h"||r==="vec3h"||r==="vec4h"?this.data=new Float32Array(e):r==="vec2b"||r==="vec3b"||r==="vec4b"?this.data=new Int32Array(e):r==="vec2"||r==="vec3"||r==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${r}`)}}clone(){if(this.data instanceof Float32Array)return new g(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new g(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new g(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,r){i instanceof $t?console.error("TODO: Set vector postfix"):t instanceof g?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof Wt)r=this.typeInfo.format||r;else{const o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?r=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?r=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?r=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?r=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let s=this;for(;t!==null&&s!==null;){if(t instanceof dn){const o=t.index;let a=-1;if(o instanceof Te){if(!(o.value instanceof v))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const c=e.evalExpression(o,i);if(!(c instanceof v))return console.error("GetSubData: Unknown index type",o),null;a=c.value}if(a<0||a>=s.data.length)return console.error("GetSubData: Index out of range",a),null;if(s.data instanceof Float32Array){const c=new Float32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(c,r)}if(s.data instanceof Int32Array){const c=new Int32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(c,r)}if(s.data instanceof Uint32Array){const c=new Uint32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(c,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof $t))return console.error("GetSubData: Unknown postfix",t),null;{const o=t.value.toLowerCase();if(o.length===1){let c=0;if(o==="x"||o==="r")c=0;else if(o==="y"||o==="g")c=1;else if(o==="z"||o==="b")c=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;c=3}if(this.data instanceof Float32Array){let l=new Float32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new v(l,r,this)}if(this.data instanceof Int32Array){let l=new Int32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new v(l,r,this)}if(this.data instanceof Uint32Array){let l=new Uint32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new v(l,r,this)}}const a=[];for(const c of o)c==="x"||c==="r"?a.push(this.data[0]):c==="y"||c==="g"?a.push(this.data[1]):c==="z"||c==="b"?a.push(this.data[2]):c==="w"||c==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${c}`);s=Lx(e,a,r.name)}t=t.postfix}return s}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class Z extends Je{constructor(e,t,i=null){super(t,i),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new Z(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,i,r){i instanceof $t?console.error("TODO: Set matrix postfix"):t instanceof Z?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;const r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof Wt)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return console.error(`GetDataValue: Unknown type ${r}`),null;e.getTypeInfo("f16")}if(t instanceof dn){const s=t.index;let o=-1;if(s instanceof Te){if(!(s.value instanceof v))return console.error(`GetDataValue: Invalid array index ${s.value}`),null;o=s.value.value}else{const l=e.evalExpression(s,i);if(!(l instanceof v))return console.error("GetDataValue: Unknown index type",s),null;o=l.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const a=r.endsWith("h")?"h":"f";let c;if(r==="mat2x2"||r==="mat2x2f"||r==="mat2x2h"||r==="mat3x2"||r==="mat3x2f"||r==="mat3x2h"||r==="mat4x2"||r==="mat4x2f"||r==="mat4x2h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(r==="mat2x3"||r==="mat2x3f"||r==="mat2x3h"||r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h"||r==="mat4x3"||r==="mat4x3f"||r==="mat4x3h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(r!=="mat2x4"&&r!=="mat2x4f"&&r!=="mat2x4h"&&r!=="mat3x4"&&r!=="mat3x4f"&&r!=="mat3x4h"&&r!=="mat4x4"&&r!=="mat4x4f"&&r!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${r}`),null;c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?c.getSubData(e,t.postfix,i):c}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class xe extends Je{constructor(e,t,i=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=i}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new xe(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,i,r){if(t===null)return void console.log("setDataValue: NULL data.");let s=this.offset,o=this.typeInfo;for(;i;){if(i instanceof dn)if(o instanceof kt){const a=i.index;if(a instanceof Te){if(!(a.value instanceof v))return void console.error(`SetDataValue: Invalid index type ${a.value}`);s+=a.value.value*o.stride}else{const c=e.evalExpression(a,r);if(!(c instanceof v))return void console.error("SetDataValue: Unknown index type",a);s+=c.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(i instanceof $t))return void console.error("SetDataValue: Unknown postfix type",i);{const a=i.value;if(o instanceof Et){let c=!1;for(const l of o.members)if(l.name===a){s+=l.offset,o=l.type,c=!0;break}if(!c)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Ze){const c=o.getTypeName();let l=0;if(a==="x"||a==="r")l=0;else if(a==="y"||a==="g")l=1;else if(a==="z"||a==="b")l=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);l=3}if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);const u=t.value;return c==="vec2f"?void(new Float32Array(this.buffer,s,2)[l]=u):c==="vec3f"?void(new Float32Array(this.buffer,s,3)[l]=u):c==="vec4f"?void(new Float32Array(this.buffer,s,4)[l]=u):c==="vec2i"?void(new Int32Array(this.buffer,s,2)[l]=u):c==="vec3i"?void(new Int32Array(this.buffer,s,3)[l]=u):c==="vec4i"?void(new Int32Array(this.buffer,s,4)[l]=u):c==="vec2u"?void(new Uint32Array(this.buffer,s,2)[l]=u):c==="vec3u"?void(new Uint32Array(this.buffer,s,3)[l]=u):c==="vec4u"?void(new Uint32Array(this.buffer,s,4)[l]=u):void console.error(`SetDataValue: Type ${c} is not a struct`)}}}i=i.postfix}this.setData(e,t,o,s,r)}setData(e,t,i,r,s){const o=i.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,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,r,9);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,r,16);return void(t instanceof Z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]))}if(t instanceof xe){if(i===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,i){var r,s,o;if(t===null)return this;let a=this.offset,c=this.typeInfo;for(;t;){if(t instanceof dn){const u=t.index,f=u instanceof rt?e.evalExpression(u,i):u;let h=0;if(f instanceof v?h=f.value:typeof f=="number"?h=f:console.error("GetDataValue: Invalid index type",u),c instanceof kt)a+=h*c.stride,c=c.format;else{const d=c.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,c=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${c.getTypeName()} is not an array`)}}else{if(!(t instanceof $t))return console.error("GetDataValue: Unknown postfix type",t),null;{const u=t.value;if(c instanceof Et){let f=!1;for(const h of c.members)if(h.name===u){a+=h.offset,c=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(c instanceof Ze){const f=c.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f";const d=[];for(let _=0;_<u.length;++_){const I=u[_].toLowerCase();let C=0;if(I==="x"||I==="r")C=0;else if(I==="y"||I==="g")C=1;else if(I==="z"||I==="b")C=2;else{if(I!=="w"&&I!=="a")return console.error(`Unknown member ${u}`),null;C=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*C+4?(console.log("Insufficient buffer data"),null):new v(new Float32Array(this.buffer,a+4*C,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new v(new Float32Array(this.buffer,a+4*C,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new v(new Int32Array(this.buffer,a+4*C,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new v(new Int32Array(this.buffer,a+4*C,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new v(new Uint32Array(this.buffer,a+4*C,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[C]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const w=new Float32Array(this.buffer,a,3);d.push(w[C])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[C]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[C]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[C]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[C]);else if(f==="vec2u"){h="u";const w=new Uint32Array(this.buffer,a,2);d.push(w[C])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[C])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[C]))}return d.length===2?c=e.getTypeInfo(`vec2${h}`):d.length===3?c=e.getTypeInfo(`vec3${h}`):d.length===4?c=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new g(d,c,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}const l=c.getTypeName();return l==="f32"?new v(new Float32Array(this.buffer,a,1),c,this):l==="i32"?new v(new Int32Array(this.buffer,a,1),c,this):l==="u32"?new v(new Uint32Array(this.buffer,a,1),c,this):l==="vec2f"?new g(new Float32Array(this.buffer,a,2),c,this):l==="vec3f"?new g(new Float32Array(this.buffer,a,3),c,this):l==="vec4f"?new g(new Float32Array(this.buffer,a,4),c,this):l==="vec2i"?new g(new Int32Array(this.buffer,a,2),c,this):l==="vec3i"?new g(new Int32Array(this.buffer,a,3),c,this):l==="vec4i"?new g(new Int32Array(this.buffer,a,4),c,this):l==="vec2u"?new g(new Uint32Array(this.buffer,a,2),c,this):l==="vec3u"?new g(new Uint32Array(this.buffer,a,3),c,this):l==="vec4u"?new g(new Uint32Array(this.buffer,a,4),c,this):c instanceof Wt&&c.name==="atomic"?((r=c.format)===null||r===void 0?void 0:r.name)==="u32"?new v(new Uint32Array(this.buffer,a,1)[0],c.format,this):((s=c.format)===null||s===void 0?void 0:s.name)==="i32"?new v(new Int32Array(this.buffer,a,1)[0],c.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=c.format)===null||o===void 0?void 0:o.name}`),null):new xe(this.buffer,c,a,this)}toString(){let e="";if(this.typeInfo instanceof kt)if(this.typeInfo.format.name==="f32"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="i32"){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="u32"){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="vec2f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let i=1;i<t.length/2;++i)e+=`, [${t[2*i]}, ${t[2*i+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}, ${t[i+3]}]`}else e="[...]";else this.typeInfo instanceof Et?e+="{...}":e="[...]";return e}}class Tt extends Je{constructor(e,t,i,r){super(t,null),this.data=e,this.descriptor=i,this.view=r}clone(){return new Tt(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>0?(e=i[0])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.width)!==null&&t!==void 0?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?(e=i[1])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?(e=i[2])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i<t.length;++i)t[i]=Math.max(1,t[i]>>e);return t}get texelByteSize(){const e=this.format,t=Ks[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Ks[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Ks[e],i=this.width;if(!e||i<=0||!t)return-1;const r=this.height,s=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*(o==="1d"?1:r/t.blockHeight)*t.bytesPerBlock*s}getPixel(e,t,i=0,r=0){const s=this.texelByteSize,o=this.bytesPerRow,a=this.height,c=this.data[r];return Mx(new Uint8Array(c),e,t,i,r,a,o,s,this.format)}setPixel(e,t,i,r,s){const o=this.texelByteSize,a=this.bytesPerRow,c=this.height,l=this.data[r];(function(u,f,h,d,_,I,C,w,M,E){const x=d*(C>>=_)*(I>>=_)+h*C+f*w;switch(M){case"r8unorm":return void se(u,x,"8unorm",1,E);case"r8snorm":return void se(u,x,"8snorm",1,E);case"r8uint":return void se(u,x,"8uint",1,E);case"r8sint":return void se(u,x,"8sint",1,E);case"rg8unorm":return void se(u,x,"8unorm",2,E);case"rg8snorm":return void se(u,x,"8snorm",2,E);case"rg8uint":return void se(u,x,"8uint",2,E);case"rg8sint":return void se(u,x,"8sint",2,E);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void se(u,x,"8unorm",4,E);case"rgba8snorm":return void se(u,x,"8snorm",4,E);case"rgba8uint":return void se(u,x,"8uint",4,E);case"rgba8sint":return void se(u,x,"8sint",4,E);case"r16uint":return void se(u,x,"16uint",1,E);case"r16sint":return void se(u,x,"16sint",1,E);case"r16float":return void se(u,x,"16float",1,E);case"rg16uint":return void se(u,x,"16uint",2,E);case"rg16sint":return void se(u,x,"16sint",2,E);case"rg16float":return void se(u,x,"16float",2,E);case"rgba16uint":return void se(u,x,"16uint",4,E);case"rgba16sint":return void se(u,x,"16sint",4,E);case"rgba16float":return void se(u,x,"16float",4,E);case"r32uint":return void se(u,x,"32uint",1,E);case"r32sint":return void se(u,x,"32sint",1,E);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void se(u,x,"32float",1,E);case"rg32uint":return void se(u,x,"32uint",2,E);case"rg32sint":return void se(u,x,"32sint",2,E);case"rg32float":return void se(u,x,"32float",2,E);case"rgba32uint":return void se(u,x,"32uint",4,E);case"rgba32sint":return void se(u,x,"32sint",4,E);case"rgba32float":return void se(u,x,"32float",4,E);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(l),e,t,i,r,c,a,o,this.format,s)}}(n=>{n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(b||(b={}));class S{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class p{}A=p,p.none=new S("",b.reserved,""),p.eof=new S("EOF",b.token,""),p.reserved={asm:new S("asm",b.reserved,"asm"),bf16:new S("bf16",b.reserved,"bf16"),do:new S("do",b.reserved,"do"),enum:new S("enum",b.reserved,"enum"),f16:new S("f16",b.reserved,"f16"),f64:new S("f64",b.reserved,"f64"),handle:new S("handle",b.reserved,"handle"),i8:new S("i8",b.reserved,"i8"),i16:new S("i16",b.reserved,"i16"),i64:new S("i64",b.reserved,"i64"),mat:new S("mat",b.reserved,"mat"),premerge:new S("premerge",b.reserved,"premerge"),regardless:new S("regardless",b.reserved,"regardless"),typedef:new S("typedef",b.reserved,"typedef"),u8:new S("u8",b.reserved,"u8"),u16:new S("u16",b.reserved,"u16"),u64:new S("u64",b.reserved,"u64"),unless:new S("unless",b.reserved,"unless"),using:new S("using",b.reserved,"using"),vec:new S("vec",b.reserved,"vec"),void:new S("void",b.reserved,"void")},p.keywords={array:new S("array",b.keyword,"array"),atomic:new S("atomic",b.keyword,"atomic"),bool:new S("bool",b.keyword,"bool"),f32:new S("f32",b.keyword,"f32"),i32:new S("i32",b.keyword,"i32"),mat2x2:new S("mat2x2",b.keyword,"mat2x2"),mat2x3:new S("mat2x3",b.keyword,"mat2x3"),mat2x4:new S("mat2x4",b.keyword,"mat2x4"),mat3x2:new S("mat3x2",b.keyword,"mat3x2"),mat3x3:new S("mat3x3",b.keyword,"mat3x3"),mat3x4:new S("mat3x4",b.keyword,"mat3x4"),mat4x2:new S("mat4x2",b.keyword,"mat4x2"),mat4x3:new S("mat4x3",b.keyword,"mat4x3"),mat4x4:new S("mat4x4",b.keyword,"mat4x4"),ptr:new S("ptr",b.keyword,"ptr"),sampler:new S("sampler",b.keyword,"sampler"),sampler_comparison:new S("sampler_comparison",b.keyword,"sampler_comparison"),struct:new S("struct",b.keyword,"struct"),texture_1d:new S("texture_1d",b.keyword,"texture_1d"),texture_2d:new S("texture_2d",b.keyword,"texture_2d"),texture_2d_array:new S("texture_2d_array",b.keyword,"texture_2d_array"),texture_3d:new S("texture_3d",b.keyword,"texture_3d"),texture_cube:new S("texture_cube",b.keyword,"texture_cube"),texture_cube_array:new S("texture_cube_array",b.keyword,"texture_cube_array"),texture_multisampled_2d:new S("texture_multisampled_2d",b.keyword,"texture_multisampled_2d"),texture_storage_1d:new S("texture_storage_1d",b.keyword,"texture_storage_1d"),texture_storage_2d:new S("texture_storage_2d",b.keyword,"texture_storage_2d"),texture_storage_2d_array:new S("texture_storage_2d_array",b.keyword,"texture_storage_2d_array"),texture_storage_3d:new S("texture_storage_3d",b.keyword,"texture_storage_3d"),texture_depth_2d:new S("texture_depth_2d",b.keyword,"texture_depth_2d"),texture_depth_2d_array:new S("texture_depth_2d_array",b.keyword,"texture_depth_2d_array"),texture_depth_cube:new S("texture_depth_cube",b.keyword,"texture_depth_cube"),texture_depth_cube_array:new S("texture_depth_cube_array",b.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new S("texture_depth_multisampled_2d",b.keyword,"texture_depth_multisampled_2d"),texture_external:new S("texture_external",b.keyword,"texture_external"),u32:new S("u32",b.keyword,"u32"),vec2:new S("vec2",b.keyword,"vec2"),vec3:new S("vec3",b.keyword,"vec3"),vec4:new S("vec4",b.keyword,"vec4"),bitcast:new S("bitcast",b.keyword,"bitcast"),block:new S("block",b.keyword,"block"),break:new S("break",b.keyword,"break"),case:new S("case",b.keyword,"case"),continue:new S("continue",b.keyword,"continue"),continuing:new S("continuing",b.keyword,"continuing"),default:new S("default",b.keyword,"default"),diagnostic:new S("diagnostic",b.keyword,"diagnostic"),discard:new S("discard",b.keyword,"discard"),else:new S("else",b.keyword,"else"),enable:new S("enable",b.keyword,"enable"),fallthrough:new S("fallthrough",b.keyword,"fallthrough"),false:new S("false",b.keyword,"false"),fn:new S("fn",b.keyword,"fn"),for:new S("for",b.keyword,"for"),function:new S("function",b.keyword,"function"),if:new S("if",b.keyword,"if"),let:new S("let",b.keyword,"let"),const:new S("const",b.keyword,"const"),loop:new S("loop",b.keyword,"loop"),while:new S("while",b.keyword,"while"),private:new S("private",b.keyword,"private"),read:new S("read",b.keyword,"read"),read_write:new S("read_write",b.keyword,"read_write"),return:new S("return",b.keyword,"return"),requires:new S("requires",b.keyword,"requires"),storage:new S("storage",b.keyword,"storage"),switch:new S("switch",b.keyword,"switch"),true:new S("true",b.keyword,"true"),alias:new S("alias",b.keyword,"alias"),type:new S("type",b.keyword,"type"),uniform:new S("uniform",b.keyword,"uniform"),var:new S("var",b.keyword,"var"),override:new S("override",b.keyword,"override"),workgroup:new S("workgroup",b.keyword,"workgroup"),write:new S("write",b.keyword,"write"),r8unorm:new S("r8unorm",b.keyword,"r8unorm"),r8snorm:new S("r8snorm",b.keyword,"r8snorm"),r8uint:new S("r8uint",b.keyword,"r8uint"),r8sint:new S("r8sint",b.keyword,"r8sint"),r16uint:new S("r16uint",b.keyword,"r16uint"),r16sint:new S("r16sint",b.keyword,"r16sint"),r16float:new S("r16float",b.keyword,"r16float"),rg8unorm:new S("rg8unorm",b.keyword,"rg8unorm"),rg8snorm:new S("rg8snorm",b.keyword,"rg8snorm"),rg8uint:new S("rg8uint",b.keyword,"rg8uint"),rg8sint:new S("rg8sint",b.keyword,"rg8sint"),r32uint:new S("r32uint",b.keyword,"r32uint"),r32sint:new S("r32sint",b.keyword,"r32sint"),r32float:new S("r32float",b.keyword,"r32float"),rg16uint:new S("rg16uint",b.keyword,"rg16uint"),rg16sint:new S("rg16sint",b.keyword,"rg16sint"),rg16float:new S("rg16float",b.keyword,"rg16float"),rgba8unorm:new S("rgba8unorm",b.keyword,"rgba8unorm"),rgba8unorm_srgb:new S("rgba8unorm_srgb",b.keyword,"rgba8unorm_srgb"),rgba8snorm:new S("rgba8snorm",b.keyword,"rgba8snorm"),rgba8uint:new S("rgba8uint",b.keyword,"rgba8uint"),rgba8sint:new S("rgba8sint",b.keyword,"rgba8sint"),bgra8unorm:new S("bgra8unorm",b.keyword,"bgra8unorm"),bgra8unorm_srgb:new S("bgra8unorm_srgb",b.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new S("rgb10a2unorm",b.keyword,"rgb10a2unorm"),rg11b10float:new S("rg11b10float",b.keyword,"rg11b10float"),rg32uint:new S("rg32uint",b.keyword,"rg32uint"),rg32sint:new S("rg32sint",b.keyword,"rg32sint"),rg32float:new S("rg32float",b.keyword,"rg32float"),rgba16uint:new S("rgba16uint",b.keyword,"rgba16uint"),rgba16sint:new S("rgba16sint",b.keyword,"rgba16sint"),rgba16float:new S("rgba16float",b.keyword,"rgba16float"),rgba32uint:new S("rgba32uint",b.keyword,"rgba32uint"),rgba32sint:new S("rgba32sint",b.keyword,"rgba32sint"),rgba32float:new S("rgba32float",b.keyword,"rgba32float"),static_assert:new S("static_assert",b.keyword,"static_assert")},p.tokens={decimal_float_literal:new S("decimal_float_literal",b.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 S("hex_float_literal",b.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 S("int_literal",b.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new S("uint_literal",b.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new S("name",b.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new S("ident",b.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new S("and",b.token,"&"),and_and:new S("and_and",b.token,"&&"),arrow:new S("arrow ",b.token,"->"),attr:new S("attr",b.token,"@"),forward_slash:new S("forward_slash",b.token,"/"),bang:new S("bang",b.token,"!"),bracket_left:new S("bracket_left",b.token,"["),bracket_right:new S("bracket_right",b.token,"]"),brace_left:new S("brace_left",b.token,"{"),brace_right:new S("brace_right",b.token,"}"),colon:new S("colon",b.token,":"),comma:new S("comma",b.token,","),equal:new S("equal",b.token,"="),equal_equal:new S("equal_equal",b.token,"=="),not_equal:new S("not_equal",b.token,"!="),greater_than:new S("greater_than",b.token,">"),greater_than_equal:new S("greater_than_equal",b.token,">="),shift_right:new S("shift_right",b.token,">>"),less_than:new S("less_than",b.token,"<"),less_than_equal:new S("less_than_equal",b.token,"<="),shift_left:new S("shift_left",b.token,"<<"),modulo:new S("modulo",b.token,"%"),minus:new S("minus",b.token,"-"),minus_minus:new S("minus_minus",b.token,"--"),period:new S("period",b.token,"."),plus:new S("plus",b.token,"+"),plus_plus:new S("plus_plus",b.token,"++"),or:new S("or",b.token,"|"),or_or:new S("or_or",b.token,"||"),paren_left:new S("paren_left",b.token,"("),paren_right:new S("paren_right",b.token,")"),semicolon:new S("semicolon",b.token,";"),star:new S("star",b.token,"*"),tilde:new S("tilde",b.token,"~"),underscore:new S("underscore",b.token,"_"),xor:new S("xor",b.token,"^"),plus_equal:new S("plus_equal",b.token,"+="),minus_equal:new S("minus_equal",b.token,"-="),times_equal:new S("times_equal",b.token,"*="),division_equal:new S("division_equal",b.token,"/="),modulo_equal:new S("modulo_equal",b.token,"%="),and_equal:new S("and_equal",b.token,"&="),or_equal:new S("or_equal",b.token,"|="),xor_equal:new S("xor_equal",b.token,"^="),shift_right_equal:new S("shift_right_equal",b.token,">>="),shift_left_equal:new S("shift_left_equal",b.token,"<<=")},p.simpleTokens={"@":A.tokens.attr,"{":A.tokens.brace_left,"}":A.tokens.brace_right,":":A.tokens.colon,",":A.tokens.comma,"(":A.tokens.paren_left,")":A.tokens.paren_right,";":A.tokens.semicolon},p.literalTokens={"&":A.tokens.and,"&&":A.tokens.and_and,"->":A.tokens.arrow,"/":A.tokens.forward_slash,"!":A.tokens.bang,"[":A.tokens.bracket_left,"]":A.tokens.bracket_right,"=":A.tokens.equal,"==":A.tokens.equal_equal,"!=":A.tokens.not_equal,">":A.tokens.greater_than,">=":A.tokens.greater_than_equal,">>":A.tokens.shift_right,"<":A.tokens.less_than,"<=":A.tokens.less_than_equal,"<<":A.tokens.shift_left,"%":A.tokens.modulo,"-":A.tokens.minus,"--":A.tokens.minus_minus,".":A.tokens.period,"+":A.tokens.plus,"++":A.tokens.plus_plus,"|":A.tokens.or,"||":A.tokens.or_or,"*":A.tokens.star,"~":A.tokens.tilde,_:A.tokens.underscore,"^":A.tokens.xor,"+=":A.tokens.plus_equal,"-=":A.tokens.minus_equal,"*=":A.tokens.times_equal,"/=":A.tokens.division_equal,"%=":A.tokens.modulo_equal,"&=":A.tokens.and_equal,"|=":A.tokens.or_equal,"^=":A.tokens.xor_equal,">>=":A.tokens.shift_right_equal,"<<=":A.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:A.tokens.decimal_float_literal,hex_float_literal:A.tokens.hex_float_literal,int_literal:A.tokens.int_literal,uint_literal:A.tokens.uint_literal,ident:A.tokens.ident},p.storage_class=[A.keywords.function,A.keywords.private,A.keywords.workgroup,A.keywords.uniform,A.keywords.storage],p.access_mode=[A.keywords.read,A.keywords.write,A.keywords.read_write],p.sampler_type=[A.keywords.sampler,A.keywords.sampler_comparison],p.sampled_texture_type=[A.keywords.texture_1d,A.keywords.texture_2d,A.keywords.texture_2d_array,A.keywords.texture_3d,A.keywords.texture_cube,A.keywords.texture_cube_array],p.multisampled_texture_type=[A.keywords.texture_multisampled_2d],p.storage_texture_type=[A.keywords.texture_storage_1d,A.keywords.texture_storage_2d,A.keywords.texture_storage_2d_array,A.keywords.texture_storage_3d],p.depth_texture_type=[A.keywords.texture_depth_2d,A.keywords.texture_depth_2d_array,A.keywords.texture_depth_cube,A.keywords.texture_depth_cube_array,A.keywords.texture_depth_multisampled_2d],p.texture_external_type=[A.keywords.texture_external],p.any_texture_type=[...A.sampled_texture_type,...A.multisampled_texture_type,...A.storage_texture_type,...A.depth_texture_type,...A.texture_external_type],p.texel_format=[A.keywords.r8unorm,A.keywords.r8snorm,A.keywords.r8uint,A.keywords.r8sint,A.keywords.r16uint,A.keywords.r16sint,A.keywords.r16float,A.keywords.rg8unorm,A.keywords.rg8snorm,A.keywords.rg8uint,A.keywords.rg8sint,A.keywords.r32uint,A.keywords.r32sint,A.keywords.r32float,A.keywords.rg16uint,A.keywords.rg16sint,A.keywords.rg16float,A.keywords.rgba8unorm,A.keywords.rgba8unorm_srgb,A.keywords.rgba8snorm,A.keywords.rgba8uint,A.keywords.rgba8sint,A.keywords.bgra8unorm,A.keywords.bgra8unorm_srgb,A.keywords.rgb10a2unorm,A.keywords.rg11b10float,A.keywords.rg32uint,A.keywords.rg32sint,A.keywords.rg32float,A.keywords.rgba16uint,A.keywords.rgba16sint,A.keywords.rgba16float,A.keywords.rgba32uint,A.keywords.rgba32sint,A.keywords.rgba32float],p.const_literal=[A.tokens.int_literal,A.tokens.uint_literal,A.tokens.decimal_float_literal,A.tokens.hex_float_literal,A.keywords.true,A.keywords.false],p.literal_or_ident=[A.tokens.ident,A.tokens.int_literal,A.tokens.uint_literal,A.tokens.decimal_float_literal,A.tokens.hex_float_literal,A.tokens.name],p.element_count_expression=[A.tokens.int_literal,A.tokens.uint_literal,A.tokens.ident],p.template_types=[A.keywords.vec2,A.keywords.vec3,A.keywords.vec4,A.keywords.mat2x2,A.keywords.mat2x3,A.keywords.mat2x4,A.keywords.mat3x2,A.keywords.mat3x3,A.keywords.mat3x4,A.keywords.mat4x2,A.keywords.mat4x3,A.keywords.mat4x4,A.keywords.atomic,A.keywords.bitcast,...A.any_texture_type],p.attribute_name=[A.tokens.ident,A.keywords.block,A.keywords.diagnostic],p.assignment_operators=[A.tokens.equal,A.tokens.plus_equal,A.tokens.minus_equal,A.tokens.times_equal,A.tokens.division_equal,A.tokens.modulo_equal,A.tokens.and_equal,A.tokens.or_equal,A.tokens.xor_equal,A.tokens.shift_right_equal,A.tokens.shift_left_equal],p.increment_operators=[A.tokens.plus_plus,A.tokens.minus_minus];class El{constructor(e,t,i,r,s){this.type=e,this.lexeme=t,this.line=i,this.start=r,this.end=s}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Vx{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 El(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
91
|
+
`),i=[];let r=!0,s=null;for(const a of t){const l=a.match(Sx),c=a.match(Tx);l?(s=l[1],r=!!((o=e==null?void 0:e.defines)!=null&&o[s])):c?r=!0:r&&i.push(a)}return i.join(`
|
|
92
|
+
`)}const jt=class jt{constructor(){m(this,"_hookFunctions",[]);m(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return jt.defaultShaderAssembler=jt.defaultShaderAssembler||new jt,jt.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,{source:r,getUniforms:s}=xx({...e,source:e.source,modules:t,hookFunctions:i});return{source:e.platformInfo.shaderLanguage==="wgsl"?wx(r):r,getUniforms:s,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),i=this._hookFunctions;return{...yx({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:i}),modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let r=0;for(let s=0,o=this._defaultModules.length;s<o;++s){const a=this._defaultModules[s],l=a.name;t[r++]=a,i[l]=!0}for(let s=0,o=e.length;s<o;++s){const a=e[s],l=a.name;i[l]||(t[r++]=a,i[l]=!0)}return t.length=r,Yi(t),t}};m(jt,"defaultShaderAssembler");let Ys=jt;class Ze{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class ic{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i,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 Et extends Ze{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class kt extends Ze{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class qs extends Ze{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class Wt extends Ze{constructor(e,t,i,r){super(e,i),this.format=t,this.access=r}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 Dt;(n=>{n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(Dt||(Dt={}));class qi{constructor(e,t,i,r,s,o,a){this.name=e,this.type=t,this.group=i,this.binding=r,this.attributes=s,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 Ax{constructor(e,t){this.name=e,this.type=t}}class Cx{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r,this.interpolation=null}}class rc{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r}}class Px{constructor(e,t,i,r){this.name=e,this.type=t,this.attributes=i,this.id=r}}class Ix{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Rx{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class Ex{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function kx(n){var e=(32768&n)>>15,t=(31744&n)>>10,i=1023&n;return t==0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):t==31?i?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,t-15)*(1+i/Math.pow(2,10))}const sc=new Float32Array(1),Dx=new Int32Array(sc.buffer),ke=new Uint16Array(1);function Fx(n){sc[0]=n;const e=Dx[0],t=e>>31&1;let i=e>>23&255,r=8388607&e;if(i===255)return ke[0]=t<<15|31744|(r!==0?512:0),ke[0];if(i===0){if(r===0)return ke[0]=t<<15,ke[0];r|=8388608;let s=113;for(;!(8388608&r);)r<<=1,s--;return i=127-s,r&=8388607,i>0?(r=(r>>126-i)+(r>>127-i&1),ke[0]=t<<15|i<<10|r>>13,ke[0]):(ke[0]=t<<15,ke[0])}return i=i-127+15,i>=31?(ke[0]=t<<15|31744,ke[0]):i<=0?i<-10?(ke[0]=t<<15,ke[0]):(r=(8388608|r)>>1-i,ke[0]=t<<15|r>>13,ke[0]):(r>>=13,ke[0]=t<<15|i<<10|r,ke[0])}const js=new Uint32Array(1),oc=new Float32Array(js.buffer,0,1);function ac(n){const e=112+(n>>6&31)<<23|(63&n)<<17;return js[0]=e,oc[0]}function Mx(n,e,t,i,r,s,o,a,l){const c=i*(o>>=r)*(s>>=r)+t*o+e*a;switch(l){case"r8unorm":return[re(n,c,"8unorm",1)[0]];case"r8snorm":return[re(n,c,"8snorm",1)[0]];case"r8uint":return[re(n,c,"8uint",1)[0]];case"r8sint":return[re(n,c,"8sint",1)[0]];case"rg8unorm":{const u=re(n,c,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=re(n,c,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=re(n,c,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=re(n,c,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=re(n,c,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=re(n,c,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=re(n,c,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=re(n,c,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=re(n,c,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[re(n,c,"16uint",1)[0]];case"r16sint":return[re(n,c,"16sint",1)[0]];case"r16float":return[re(n,c,"16float",1)[0]];case"rg16uint":{const u=re(n,c,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=re(n,c,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=re(n,c,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=re(n,c,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=re(n,c,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=re(n,c,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[re(n,c,"32uint",1)[0]];case"r32sint":return[re(n,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[re(n,c,"32float",1)[0]];case"rg32uint":{const u=re(n,c,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=re(n,c,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=re(n,c,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=re(n,c,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=re(n,c,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=re(n,c,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(n.buffer,c,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[ac(2047&u),ac(f),function(d){const _=112+(d>>5&31)<<23|(31&d)<<18;return js[0]=_,oc[0]}(h),1]}}return null}function re(n,e,t,i){const r=[0,0,0,0];for(let s=0;s<i;++s)switch(t){case"8unorm":r[s]=n[e]/255,e++;break;case"8snorm":r[s]=n[e]/255*2-1,e++;break;case"8uint":r[s]=n[e],e++;break;case"8sint":r[s]=n[e]-127,e++;break;case"16uint":r[s]=n[e]|n[e+1]<<8,e+=2;break;case"16sint":r[s]=(n[e]|n[e+1]<<8)-32768,e+=2;break;case"16float":r[s]=kx(n[e]|n[e+1]<<8),e+=2;break;case"32uint":case"32sint":r[s]=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24,e+=4;break;case"32float":r[s]=new Float32Array(n.buffer,e,1)[0],e+=4}return r}function se(n,e,t,i,r){for(let s=0;s<i;++s)switch(t){case"8unorm":n[e]=255*r[s],e++;break;case"8snorm":n[e]=.5*(r[s]+1)*255,e++;break;case"8uint":n[e]=r[s],e++;break;case"8sint":n[e]=r[s]+127,e++;break;case"16uint":new Uint16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16sint":new Int16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16float":{const o=Fx(r[s]);new Uint16Array(n.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32sint":new Int32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32float":new Float32Array(n.buffer,e,1)[0]=r[s],e+=4}return r}const Ks={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class Qe{constructor(){this.id=Qe._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(ji.instance);for(const i of e)i instanceof Array?this.searchBlock(i,t):i.search(t);t(Ki.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}Qe._id=0;class ji extends Qe{}ji.instance=new ji;class Ki extends Qe{}Ki.instance=new Ki;const lc=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class de extends Qe{constructor(){super()}}class Xn extends de{constructor(e,t,i,r,s,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=i,this.body=r,this.startLine=s,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class Nx extends de{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class cc extends de{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Zs extends de{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class uc extends de{constructor(e,t,i,r){super(),this.init=e,this.condition=t,this.increment=i,this.body=r}get astNodeType(){return"for"}search(e){var t,i,r;(t=this.init)===null||t===void 0||t.search(e),(i=this.condition)===null||i===void 0||i.search(e),(r=this.increment)===null||r===void 0||r.search(e),this.searchBlock(this.body,e)}}class bt extends de{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class Qs extends de{constructor(e,t,i){super(),this.attributes=null,this.name=e,this.type=t,this.value=i}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Yn extends de{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class Zi extends de{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}var hn,qn,A,b;(n=>{n.increment="++",n.decrement="--"})(hn||(hn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return n[t]}})(hn||(hn={}));class fc extends de{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(n=>{n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(qn||(qn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(qn||(qn={}));class hc extends de{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Js extends de{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return lc.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class dc extends de{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),(t=this.continuing)===null||t===void 0||t.search(e)}}class pc extends de{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class mc extends de{constructor(e,t,i,r){super(),this.condition=e,this.body=t,this.elseif=i,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class gc extends de{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Ox extends de{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class Bx extends de{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class _c extends de{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class Gs extends de{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class Ux extends de{constructor(){super()}get astNodeType(){return"discard"}}class xc extends de{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}let yc=class extends de{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}};class k extends de{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=k._priority.get(t.name);k._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?k.i32:t}getTypeName(){return this.name}}k.x32=new k("x32"),k.f32=new k("f32"),k.i32=new k("i32"),k.u32=new k("u32"),k.f16=new k("f16"),k.bool=new k("bool"),k.void=new k("void"),k._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class vc extends k{constructor(e){super(e)}}class St extends k{constructor(e,t,i,r){super(e),this.members=t,this.startLine=i,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class T extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}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}}T.vec2f=new T("vec2",k.f32,null),T.vec3f=new T("vec3",k.f32,null),T.vec4f=new T("vec4",k.f32,null),T.vec2i=new T("vec2",k.i32,null),T.vec3i=new T("vec3",k.i32,null),T.vec4i=new T("vec4",k.i32,null),T.vec2u=new T("vec2",k.u32,null),T.vec3u=new T("vec3",k.u32,null),T.vec4u=new T("vec4",k.u32,null),T.vec2h=new T("vec2",k.f16,null),T.vec3h=new T("vec3",k.f16,null),T.vec4h=new T("vec4",k.f16,null),T.vec2b=new T("vec2",k.bool,null),T.vec3b=new T("vec3",k.bool,null),T.vec4b=new T("vec4",k.bool,null),T.mat2x2f=new T("mat2x2",k.f32,null),T.mat2x3f=new T("mat2x3",k.f32,null),T.mat2x4f=new T("mat2x4",k.f32,null),T.mat3x2f=new T("mat3x2",k.f32,null),T.mat3x3f=new T("mat3x3",k.f32,null),T.mat3x4f=new T("mat3x4",k.f32,null),T.mat4x2f=new T("mat4x2",k.f32,null),T.mat4x3f=new T("mat4x3",k.f32,null),T.mat4x4f=new T("mat4x4",k.f32,null),T.mat2x2h=new T("mat2x2",k.f16,null),T.mat2x3h=new T("mat2x3",k.f16,null),T.mat2x4h=new T("mat2x4",k.f16,null),T.mat3x2h=new T("mat3x2",k.f16,null),T.mat3x3h=new T("mat3x3",k.f16,null),T.mat3x4h=new T("mat3x4",k.f16,null),T.mat4x2h=new T("mat4x2",k.f16,null),T.mat4x3h=new T("mat4x3",k.f16,null),T.mat4x4h=new T("mat4x4",k.f16,null),T.mat2x2i=new T("mat2x2",k.i32,null),T.mat2x3i=new T("mat2x3",k.i32,null),T.mat2x4i=new T("mat2x4",k.i32,null),T.mat3x2i=new T("mat3x2",k.i32,null),T.mat3x3i=new T("mat3x3",k.i32,null),T.mat3x4i=new T("mat3x4",k.i32,null),T.mat4x2i=new T("mat4x2",k.i32,null),T.mat4x3i=new T("mat4x3",k.i32,null),T.mat4x4i=new T("mat4x4",k.i32,null),T.mat2x2u=new T("mat2x2",k.u32,null),T.mat2x3u=new T("mat2x3",k.u32,null),T.mat2x4u=new T("mat2x4",k.u32,null),T.mat3x2u=new T("mat3x2",k.u32,null),T.mat3x3u=new T("mat3x3",k.u32,null),T.mat3x4u=new T("mat3x4",k.u32,null),T.mat4x2u=new T("mat4x2",k.u32,null),T.mat4x3u=new T("mat4x3",k.u32,null),T.mat4x4u=new T("mat4x4",k.u32,null);class Qi extends k{constructor(e,t,i,r){super(e),this.storage=t,this.type=i,this.access=r}get astNodeType(){return"pointer"}}class jn extends k{constructor(e,t,i,r){super(e),this.attributes=t,this.format=i,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class Kn extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class rt extends Qe{constructor(){super(),this.postfix=null}}class $t extends rt{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class ht extends rt{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class eo extends rt{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return lc.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class je extends rt{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class bc extends rt{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const i=e.evalExpression(this.initializer,e.context);return i!==null&&this.postfix?i.getSubData(e,this.postfix,e.context):i}return null}search(e){this.initializer.search(e)}}class Te extends rt{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof v}get isVector(){return this.value instanceof g||this.value instanceof K}get scalarValue(){return this.value instanceof v?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof g||this.value instanceof K?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class Sc extends rt{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class dn extends rt{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Tc extends rt{constructor(){super()}}class ve extends Tc{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class st extends Tc{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?k.f32:e.name==="u32"||t.name==="u32"?k.u32:k.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class wc extends Qe{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Ji extends rt{constructor(){super()}get astNodeType(){return"default"}}class Ac extends wc{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Cc extends wc{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Pc extends Qe{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class zx extends Qe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Ic extends Qe{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class Rc extends Qe{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Je{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Je._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Je._id=0;class to extends Je{constructor(){super(new Ze("void",null),null)}toString(){return"void"}}to.void=new to;class pn extends Je{constructor(e){super(new qs("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,r){this.reference.setDataValue(e,t,i,r)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class v extends Je{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new v(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new v(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new v(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,r){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);let s=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?s=Math.floor(s):this.typeInfo.name==="bool"&&(s=s?1:0),this.data[0]=s}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Lx(n,e,t){const i=e.length;return i===2?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec2i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec2u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):i===3?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec3i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec3u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):i===4?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec4i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec4u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}class g extends Je{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const r=this.typeInfo.name;r==="vec2f"||r==="vec3f"||r==="vec4f"?this.data=new Float32Array(e):r==="vec2i"||r==="vec3i"||r==="vec4i"?this.data=new Int32Array(e):r==="vec2u"||r==="vec3u"||r==="vec4u"?this.data=new Uint32Array(e):r==="vec2h"||r==="vec3h"||r==="vec4h"?this.data=new Float32Array(e):r==="vec2b"||r==="vec3b"||r==="vec4b"?this.data=new Int32Array(e):r==="vec2"||r==="vec3"||r==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${r}`)}}clone(){if(this.data instanceof Float32Array)return new g(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new g(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new g(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,r){i instanceof $t?console.error("TODO: Set vector postfix"):t instanceof g?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof Wt)r=this.typeInfo.format||r;else{const o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?r=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?r=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?r=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?r=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let s=this;for(;t!==null&&s!==null;){if(t instanceof dn){const o=t.index;let a=-1;if(o instanceof Te){if(!(o.value instanceof v))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const l=e.evalExpression(o,i);if(!(l instanceof v))return console.error("GetSubData: Unknown index type",o),null;a=l.value}if(a<0||a>=s.data.length)return console.error("GetSubData: Index out of range",a),null;if(s.data instanceof Float32Array){const l=new Float32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Int32Array){const l=new Int32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Uint32Array){const l=new Uint32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof $t))return console.error("GetSubData: Unknown postfix",t),null;{const o=t.value.toLowerCase();if(o.length===1){let l=0;if(o==="x"||o==="r")l=0;else if(o==="y"||o==="g")l=1;else if(o==="z"||o==="b")l=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;l=3}if(this.data instanceof Float32Array){let c=new Float32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Int32Array){let c=new Int32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Uint32Array){let c=new Uint32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,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}`);s=Lx(e,a,r.name)}t=t.postfix}return s}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class K extends Je{constructor(e,t,i=null){super(t,i),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new K(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,i,r){i instanceof $t?console.error("TODO: Set matrix postfix"):t instanceof K?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;const r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof Wt)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return console.error(`GetDataValue: Unknown type ${r}`),null;e.getTypeInfo("f16")}if(t instanceof dn){const s=t.index;let o=-1;if(s instanceof Te){if(!(s.value instanceof v))return console.error(`GetDataValue: Invalid array index ${s.value}`),null;o=s.value.value}else{const c=e.evalExpression(s,i);if(!(c instanceof v))return console.error("GetDataValue: Unknown index type",s),null;o=c.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const a=r.endsWith("h")?"h":"f";let l;if(r==="mat2x2"||r==="mat2x2f"||r==="mat2x2h"||r==="mat3x2"||r==="mat3x2f"||r==="mat3x2h"||r==="mat4x2"||r==="mat4x2f"||r==="mat4x2h")l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(r==="mat2x3"||r==="mat2x3f"||r==="mat2x3h"||r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h"||r==="mat4x3"||r==="mat4x3f"||r==="mat4x3h")l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(r!=="mat2x4"&&r!=="mat2x4f"&&r!=="mat2x4h"&&r!=="mat3x4"&&r!=="mat3x4f"&&r!=="mat3x4h"&&r!=="mat4x4"&&r!=="mat4x4f"&&r!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${r}`),null;l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?l.getSubData(e,t.postfix,i):l}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class xe extends Je{constructor(e,t,i=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=i}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new xe(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,i,r){if(t===null)return void console.log("setDataValue: NULL data.");let s=this.offset,o=this.typeInfo;for(;i;){if(i instanceof dn)if(o instanceof kt){const a=i.index;if(a instanceof Te){if(!(a.value instanceof v))return void console.error(`SetDataValue: Invalid index type ${a.value}`);s+=a.value.value*o.stride}else{const l=e.evalExpression(a,r);if(!(l instanceof v))return void console.error("SetDataValue: Unknown index type",a);s+=l.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(i instanceof $t))return void console.error("SetDataValue: Unknown postfix type",i);{const a=i.value;if(o instanceof Et){let l=!1;for(const c of o.members)if(c.name===a){s+=c.offset,o=c.type,l=!0;break}if(!l)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Ze){const l=o.getTypeName();let c=0;if(a==="x"||a==="r")c=0;else if(a==="y"||a==="g")c=1;else if(a==="z"||a==="b")c=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);c=3}if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);const u=t.value;return l==="vec2f"?void(new Float32Array(this.buffer,s,2)[c]=u):l==="vec3f"?void(new Float32Array(this.buffer,s,3)[c]=u):l==="vec4f"?void(new Float32Array(this.buffer,s,4)[c]=u):l==="vec2i"?void(new Int32Array(this.buffer,s,2)[c]=u):l==="vec3i"?void(new Int32Array(this.buffer,s,3)[c]=u):l==="vec4i"?void(new Int32Array(this.buffer,s,4)[c]=u):l==="vec2u"?void(new Uint32Array(this.buffer,s,2)[c]=u):l==="vec3u"?void(new Uint32Array(this.buffer,s,3)[c]=u):l==="vec4u"?void(new Uint32Array(this.buffer,s,4)[c]=u):void console.error(`SetDataValue: Type ${l} is not a struct`)}}}i=i.postfix}this.setData(e,t,o,s,r)}setData(e,t,i,r,s){const o=i.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,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,r,9);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,r,16);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]))}if(t instanceof xe){if(i===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,i){var r,s,o;if(t===null)return this;let a=this.offset,l=this.typeInfo;for(;t;){if(t instanceof dn){const u=t.index,f=u instanceof rt?e.evalExpression(u,i):u;let h=0;if(f instanceof v?h=f.value:typeof f=="number"?h=f:console.error("GetDataValue: Invalid index type",u),l instanceof kt)a+=h*l.stride,l=l.format;else{const d=l.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,l=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${l.getTypeName()} is not an array`)}}else{if(!(t instanceof $t))return console.error("GetDataValue: Unknown postfix type",t),null;{const u=t.value;if(l instanceof Et){let f=!1;for(const h of l.members)if(h.name===u){a+=h.offset,l=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(l instanceof Ze){const f=l.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f";const d=[];for(let _=0;_<u.length;++_){const I=u[_].toLowerCase();let C=0;if(I==="x"||I==="r")C=0;else if(I==="y"||I==="g")C=1;else if(I==="z"||I==="b")C=2;else{if(I!=="w"&&I!=="a")return console.error(`Unknown member ${u}`),null;C=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*C+4?(console.log("Insufficient buffer data"),null):new v(new Float32Array(this.buffer,a+4*C,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new v(new Float32Array(this.buffer,a+4*C,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new v(new Int32Array(this.buffer,a+4*C,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new v(new Int32Array(this.buffer,a+4*C,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new v(new Uint32Array(this.buffer,a+4*C,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[C]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const w=new Float32Array(this.buffer,a,3);d.push(w[C])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[C]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[C]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[C]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[C]);else if(f==="vec2u"){h="u";const w=new Uint32Array(this.buffer,a,2);d.push(w[C])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[C])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[C]))}return d.length===2?l=e.getTypeInfo(`vec2${h}`):d.length===3?l=e.getTypeInfo(`vec3${h}`):d.length===4?l=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new g(d,l,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}const c=l.getTypeName();return c==="f32"?new v(new Float32Array(this.buffer,a,1),l,this):c==="i32"?new v(new Int32Array(this.buffer,a,1),l,this):c==="u32"?new v(new Uint32Array(this.buffer,a,1),l,this):c==="vec2f"?new g(new Float32Array(this.buffer,a,2),l,this):c==="vec3f"?new g(new Float32Array(this.buffer,a,3),l,this):c==="vec4f"?new g(new Float32Array(this.buffer,a,4),l,this):c==="vec2i"?new g(new Int32Array(this.buffer,a,2),l,this):c==="vec3i"?new g(new Int32Array(this.buffer,a,3),l,this):c==="vec4i"?new g(new Int32Array(this.buffer,a,4),l,this):c==="vec2u"?new g(new Uint32Array(this.buffer,a,2),l,this):c==="vec3u"?new g(new Uint32Array(this.buffer,a,3),l,this):c==="vec4u"?new g(new Uint32Array(this.buffer,a,4),l,this):l instanceof Wt&&l.name==="atomic"?((r=l.format)===null||r===void 0?void 0:r.name)==="u32"?new v(new Uint32Array(this.buffer,a,1)[0],l.format,this):((s=l.format)===null||s===void 0?void 0:s.name)==="i32"?new v(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 xe(this.buffer,l,a,this)}toString(){let e="";if(this.typeInfo instanceof kt)if(this.typeInfo.format.name==="f32"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="i32"){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="u32"){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="vec2f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let i=1;i<t.length/2;++i)e+=`, [${t[2*i]}, ${t[2*i+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}, ${t[i+3]}]`}else e="[...]";else this.typeInfo instanceof Et?e+="{...}":e="[...]";return e}}class Tt extends Je{constructor(e,t,i,r){super(t,null),this.data=e,this.descriptor=i,this.view=r}clone(){return new Tt(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>0?(e=i[0])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.width)!==null&&t!==void 0?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?(e=i[1])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?(e=i[2])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i<t.length;++i)t[i]=Math.max(1,t[i]>>e);return t}get texelByteSize(){const e=this.format,t=Ks[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Ks[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Ks[e],i=this.width;if(!e||i<=0||!t)return-1;const r=this.height,s=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*(o==="1d"?1:r/t.blockHeight)*t.bytesPerBlock*s}getPixel(e,t,i=0,r=0){const s=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[r];return Mx(new Uint8Array(l),e,t,i,r,a,o,s,this.format)}setPixel(e,t,i,r,s){const o=this.texelByteSize,a=this.bytesPerRow,l=this.height,c=this.data[r];(function(u,f,h,d,_,I,C,w,M,E){const x=d*(C>>=_)*(I>>=_)+h*C+f*w;switch(M){case"r8unorm":return void se(u,x,"8unorm",1,E);case"r8snorm":return void se(u,x,"8snorm",1,E);case"r8uint":return void se(u,x,"8uint",1,E);case"r8sint":return void se(u,x,"8sint",1,E);case"rg8unorm":return void se(u,x,"8unorm",2,E);case"rg8snorm":return void se(u,x,"8snorm",2,E);case"rg8uint":return void se(u,x,"8uint",2,E);case"rg8sint":return void se(u,x,"8sint",2,E);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void se(u,x,"8unorm",4,E);case"rgba8snorm":return void se(u,x,"8snorm",4,E);case"rgba8uint":return void se(u,x,"8uint",4,E);case"rgba8sint":return void se(u,x,"8sint",4,E);case"r16uint":return void se(u,x,"16uint",1,E);case"r16sint":return void se(u,x,"16sint",1,E);case"r16float":return void se(u,x,"16float",1,E);case"rg16uint":return void se(u,x,"16uint",2,E);case"rg16sint":return void se(u,x,"16sint",2,E);case"rg16float":return void se(u,x,"16float",2,E);case"rgba16uint":return void se(u,x,"16uint",4,E);case"rgba16sint":return void se(u,x,"16sint",4,E);case"rgba16float":return void se(u,x,"16float",4,E);case"r32uint":return void se(u,x,"32uint",1,E);case"r32sint":return void se(u,x,"32sint",1,E);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void se(u,x,"32float",1,E);case"rg32uint":return void se(u,x,"32uint",2,E);case"rg32sint":return void se(u,x,"32sint",2,E);case"rg32float":return void se(u,x,"32float",2,E);case"rgba32uint":return void se(u,x,"32uint",4,E);case"rgba32sint":return void se(u,x,"32sint",4,E);case"rgba32float":return void se(u,x,"32float",4,E);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(c),e,t,i,r,l,a,o,this.format,s)}}(n=>{n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(b||(b={}));class S{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class p{}A=p,p.none=new S("",b.reserved,""),p.eof=new S("EOF",b.token,""),p.reserved={asm:new S("asm",b.reserved,"asm"),bf16:new S("bf16",b.reserved,"bf16"),do:new S("do",b.reserved,"do"),enum:new S("enum",b.reserved,"enum"),f16:new S("f16",b.reserved,"f16"),f64:new S("f64",b.reserved,"f64"),handle:new S("handle",b.reserved,"handle"),i8:new S("i8",b.reserved,"i8"),i16:new S("i16",b.reserved,"i16"),i64:new S("i64",b.reserved,"i64"),mat:new S("mat",b.reserved,"mat"),premerge:new S("premerge",b.reserved,"premerge"),regardless:new S("regardless",b.reserved,"regardless"),typedef:new S("typedef",b.reserved,"typedef"),u8:new S("u8",b.reserved,"u8"),u16:new S("u16",b.reserved,"u16"),u64:new S("u64",b.reserved,"u64"),unless:new S("unless",b.reserved,"unless"),using:new S("using",b.reserved,"using"),vec:new S("vec",b.reserved,"vec"),void:new S("void",b.reserved,"void")},p.keywords={array:new S("array",b.keyword,"array"),atomic:new S("atomic",b.keyword,"atomic"),bool:new S("bool",b.keyword,"bool"),f32:new S("f32",b.keyword,"f32"),i32:new S("i32",b.keyword,"i32"),mat2x2:new S("mat2x2",b.keyword,"mat2x2"),mat2x3:new S("mat2x3",b.keyword,"mat2x3"),mat2x4:new S("mat2x4",b.keyword,"mat2x4"),mat3x2:new S("mat3x2",b.keyword,"mat3x2"),mat3x3:new S("mat3x3",b.keyword,"mat3x3"),mat3x4:new S("mat3x4",b.keyword,"mat3x4"),mat4x2:new S("mat4x2",b.keyword,"mat4x2"),mat4x3:new S("mat4x3",b.keyword,"mat4x3"),mat4x4:new S("mat4x4",b.keyword,"mat4x4"),ptr:new S("ptr",b.keyword,"ptr"),sampler:new S("sampler",b.keyword,"sampler"),sampler_comparison:new S("sampler_comparison",b.keyword,"sampler_comparison"),struct:new S("struct",b.keyword,"struct"),texture_1d:new S("texture_1d",b.keyword,"texture_1d"),texture_2d:new S("texture_2d",b.keyword,"texture_2d"),texture_2d_array:new S("texture_2d_array",b.keyword,"texture_2d_array"),texture_3d:new S("texture_3d",b.keyword,"texture_3d"),texture_cube:new S("texture_cube",b.keyword,"texture_cube"),texture_cube_array:new S("texture_cube_array",b.keyword,"texture_cube_array"),texture_multisampled_2d:new S("texture_multisampled_2d",b.keyword,"texture_multisampled_2d"),texture_storage_1d:new S("texture_storage_1d",b.keyword,"texture_storage_1d"),texture_storage_2d:new S("texture_storage_2d",b.keyword,"texture_storage_2d"),texture_storage_2d_array:new S("texture_storage_2d_array",b.keyword,"texture_storage_2d_array"),texture_storage_3d:new S("texture_storage_3d",b.keyword,"texture_storage_3d"),texture_depth_2d:new S("texture_depth_2d",b.keyword,"texture_depth_2d"),texture_depth_2d_array:new S("texture_depth_2d_array",b.keyword,"texture_depth_2d_array"),texture_depth_cube:new S("texture_depth_cube",b.keyword,"texture_depth_cube"),texture_depth_cube_array:new S("texture_depth_cube_array",b.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new S("texture_depth_multisampled_2d",b.keyword,"texture_depth_multisampled_2d"),texture_external:new S("texture_external",b.keyword,"texture_external"),u32:new S("u32",b.keyword,"u32"),vec2:new S("vec2",b.keyword,"vec2"),vec3:new S("vec3",b.keyword,"vec3"),vec4:new S("vec4",b.keyword,"vec4"),bitcast:new S("bitcast",b.keyword,"bitcast"),block:new S("block",b.keyword,"block"),break:new S("break",b.keyword,"break"),case:new S("case",b.keyword,"case"),continue:new S("continue",b.keyword,"continue"),continuing:new S("continuing",b.keyword,"continuing"),default:new S("default",b.keyword,"default"),diagnostic:new S("diagnostic",b.keyword,"diagnostic"),discard:new S("discard",b.keyword,"discard"),else:new S("else",b.keyword,"else"),enable:new S("enable",b.keyword,"enable"),fallthrough:new S("fallthrough",b.keyword,"fallthrough"),false:new S("false",b.keyword,"false"),fn:new S("fn",b.keyword,"fn"),for:new S("for",b.keyword,"for"),function:new S("function",b.keyword,"function"),if:new S("if",b.keyword,"if"),let:new S("let",b.keyword,"let"),const:new S("const",b.keyword,"const"),loop:new S("loop",b.keyword,"loop"),while:new S("while",b.keyword,"while"),private:new S("private",b.keyword,"private"),read:new S("read",b.keyword,"read"),read_write:new S("read_write",b.keyword,"read_write"),return:new S("return",b.keyword,"return"),requires:new S("requires",b.keyword,"requires"),storage:new S("storage",b.keyword,"storage"),switch:new S("switch",b.keyword,"switch"),true:new S("true",b.keyword,"true"),alias:new S("alias",b.keyword,"alias"),type:new S("type",b.keyword,"type"),uniform:new S("uniform",b.keyword,"uniform"),var:new S("var",b.keyword,"var"),override:new S("override",b.keyword,"override"),workgroup:new S("workgroup",b.keyword,"workgroup"),write:new S("write",b.keyword,"write"),r8unorm:new S("r8unorm",b.keyword,"r8unorm"),r8snorm:new S("r8snorm",b.keyword,"r8snorm"),r8uint:new S("r8uint",b.keyword,"r8uint"),r8sint:new S("r8sint",b.keyword,"r8sint"),r16uint:new S("r16uint",b.keyword,"r16uint"),r16sint:new S("r16sint",b.keyword,"r16sint"),r16float:new S("r16float",b.keyword,"r16float"),rg8unorm:new S("rg8unorm",b.keyword,"rg8unorm"),rg8snorm:new S("rg8snorm",b.keyword,"rg8snorm"),rg8uint:new S("rg8uint",b.keyword,"rg8uint"),rg8sint:new S("rg8sint",b.keyword,"rg8sint"),r32uint:new S("r32uint",b.keyword,"r32uint"),r32sint:new S("r32sint",b.keyword,"r32sint"),r32float:new S("r32float",b.keyword,"r32float"),rg16uint:new S("rg16uint",b.keyword,"rg16uint"),rg16sint:new S("rg16sint",b.keyword,"rg16sint"),rg16float:new S("rg16float",b.keyword,"rg16float"),rgba8unorm:new S("rgba8unorm",b.keyword,"rgba8unorm"),rgba8unorm_srgb:new S("rgba8unorm_srgb",b.keyword,"rgba8unorm_srgb"),rgba8snorm:new S("rgba8snorm",b.keyword,"rgba8snorm"),rgba8uint:new S("rgba8uint",b.keyword,"rgba8uint"),rgba8sint:new S("rgba8sint",b.keyword,"rgba8sint"),bgra8unorm:new S("bgra8unorm",b.keyword,"bgra8unorm"),bgra8unorm_srgb:new S("bgra8unorm_srgb",b.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new S("rgb10a2unorm",b.keyword,"rgb10a2unorm"),rg11b10float:new S("rg11b10float",b.keyword,"rg11b10float"),rg32uint:new S("rg32uint",b.keyword,"rg32uint"),rg32sint:new S("rg32sint",b.keyword,"rg32sint"),rg32float:new S("rg32float",b.keyword,"rg32float"),rgba16uint:new S("rgba16uint",b.keyword,"rgba16uint"),rgba16sint:new S("rgba16sint",b.keyword,"rgba16sint"),rgba16float:new S("rgba16float",b.keyword,"rgba16float"),rgba32uint:new S("rgba32uint",b.keyword,"rgba32uint"),rgba32sint:new S("rgba32sint",b.keyword,"rgba32sint"),rgba32float:new S("rgba32float",b.keyword,"rgba32float"),static_assert:new S("static_assert",b.keyword,"static_assert")},p.tokens={decimal_float_literal:new S("decimal_float_literal",b.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 S("hex_float_literal",b.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 S("int_literal",b.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new S("uint_literal",b.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new S("name",b.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new S("ident",b.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new S("and",b.token,"&"),and_and:new S("and_and",b.token,"&&"),arrow:new S("arrow ",b.token,"->"),attr:new S("attr",b.token,"@"),forward_slash:new S("forward_slash",b.token,"/"),bang:new S("bang",b.token,"!"),bracket_left:new S("bracket_left",b.token,"["),bracket_right:new S("bracket_right",b.token,"]"),brace_left:new S("brace_left",b.token,"{"),brace_right:new S("brace_right",b.token,"}"),colon:new S("colon",b.token,":"),comma:new S("comma",b.token,","),equal:new S("equal",b.token,"="),equal_equal:new S("equal_equal",b.token,"=="),not_equal:new S("not_equal",b.token,"!="),greater_than:new S("greater_than",b.token,">"),greater_than_equal:new S("greater_than_equal",b.token,">="),shift_right:new S("shift_right",b.token,">>"),less_than:new S("less_than",b.token,"<"),less_than_equal:new S("less_than_equal",b.token,"<="),shift_left:new S("shift_left",b.token,"<<"),modulo:new S("modulo",b.token,"%"),minus:new S("minus",b.token,"-"),minus_minus:new S("minus_minus",b.token,"--"),period:new S("period",b.token,"."),plus:new S("plus",b.token,"+"),plus_plus:new S("plus_plus",b.token,"++"),or:new S("or",b.token,"|"),or_or:new S("or_or",b.token,"||"),paren_left:new S("paren_left",b.token,"("),paren_right:new S("paren_right",b.token,")"),semicolon:new S("semicolon",b.token,";"),star:new S("star",b.token,"*"),tilde:new S("tilde",b.token,"~"),underscore:new S("underscore",b.token,"_"),xor:new S("xor",b.token,"^"),plus_equal:new S("plus_equal",b.token,"+="),minus_equal:new S("minus_equal",b.token,"-="),times_equal:new S("times_equal",b.token,"*="),division_equal:new S("division_equal",b.token,"/="),modulo_equal:new S("modulo_equal",b.token,"%="),and_equal:new S("and_equal",b.token,"&="),or_equal:new S("or_equal",b.token,"|="),xor_equal:new S("xor_equal",b.token,"^="),shift_right_equal:new S("shift_right_equal",b.token,">>="),shift_left_equal:new S("shift_left_equal",b.token,"<<=")},p.simpleTokens={"@":A.tokens.attr,"{":A.tokens.brace_left,"}":A.tokens.brace_right,":":A.tokens.colon,",":A.tokens.comma,"(":A.tokens.paren_left,")":A.tokens.paren_right,";":A.tokens.semicolon},p.literalTokens={"&":A.tokens.and,"&&":A.tokens.and_and,"->":A.tokens.arrow,"/":A.tokens.forward_slash,"!":A.tokens.bang,"[":A.tokens.bracket_left,"]":A.tokens.bracket_right,"=":A.tokens.equal,"==":A.tokens.equal_equal,"!=":A.tokens.not_equal,">":A.tokens.greater_than,">=":A.tokens.greater_than_equal,">>":A.tokens.shift_right,"<":A.tokens.less_than,"<=":A.tokens.less_than_equal,"<<":A.tokens.shift_left,"%":A.tokens.modulo,"-":A.tokens.minus,"--":A.tokens.minus_minus,".":A.tokens.period,"+":A.tokens.plus,"++":A.tokens.plus_plus,"|":A.tokens.or,"||":A.tokens.or_or,"*":A.tokens.star,"~":A.tokens.tilde,_:A.tokens.underscore,"^":A.tokens.xor,"+=":A.tokens.plus_equal,"-=":A.tokens.minus_equal,"*=":A.tokens.times_equal,"/=":A.tokens.division_equal,"%=":A.tokens.modulo_equal,"&=":A.tokens.and_equal,"|=":A.tokens.or_equal,"^=":A.tokens.xor_equal,">>=":A.tokens.shift_right_equal,"<<=":A.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:A.tokens.decimal_float_literal,hex_float_literal:A.tokens.hex_float_literal,int_literal:A.tokens.int_literal,uint_literal:A.tokens.uint_literal,ident:A.tokens.ident},p.storage_class=[A.keywords.function,A.keywords.private,A.keywords.workgroup,A.keywords.uniform,A.keywords.storage],p.access_mode=[A.keywords.read,A.keywords.write,A.keywords.read_write],p.sampler_type=[A.keywords.sampler,A.keywords.sampler_comparison],p.sampled_texture_type=[A.keywords.texture_1d,A.keywords.texture_2d,A.keywords.texture_2d_array,A.keywords.texture_3d,A.keywords.texture_cube,A.keywords.texture_cube_array],p.multisampled_texture_type=[A.keywords.texture_multisampled_2d],p.storage_texture_type=[A.keywords.texture_storage_1d,A.keywords.texture_storage_2d,A.keywords.texture_storage_2d_array,A.keywords.texture_storage_3d],p.depth_texture_type=[A.keywords.texture_depth_2d,A.keywords.texture_depth_2d_array,A.keywords.texture_depth_cube,A.keywords.texture_depth_cube_array,A.keywords.texture_depth_multisampled_2d],p.texture_external_type=[A.keywords.texture_external],p.any_texture_type=[...A.sampled_texture_type,...A.multisampled_texture_type,...A.storage_texture_type,...A.depth_texture_type,...A.texture_external_type],p.texel_format=[A.keywords.r8unorm,A.keywords.r8snorm,A.keywords.r8uint,A.keywords.r8sint,A.keywords.r16uint,A.keywords.r16sint,A.keywords.r16float,A.keywords.rg8unorm,A.keywords.rg8snorm,A.keywords.rg8uint,A.keywords.rg8sint,A.keywords.r32uint,A.keywords.r32sint,A.keywords.r32float,A.keywords.rg16uint,A.keywords.rg16sint,A.keywords.rg16float,A.keywords.rgba8unorm,A.keywords.rgba8unorm_srgb,A.keywords.rgba8snorm,A.keywords.rgba8uint,A.keywords.rgba8sint,A.keywords.bgra8unorm,A.keywords.bgra8unorm_srgb,A.keywords.rgb10a2unorm,A.keywords.rg11b10float,A.keywords.rg32uint,A.keywords.rg32sint,A.keywords.rg32float,A.keywords.rgba16uint,A.keywords.rgba16sint,A.keywords.rgba16float,A.keywords.rgba32uint,A.keywords.rgba32sint,A.keywords.rgba32float],p.const_literal=[A.tokens.int_literal,A.tokens.uint_literal,A.tokens.decimal_float_literal,A.tokens.hex_float_literal,A.keywords.true,A.keywords.false],p.literal_or_ident=[A.tokens.ident,A.tokens.int_literal,A.tokens.uint_literal,A.tokens.decimal_float_literal,A.tokens.hex_float_literal,A.tokens.name],p.element_count_expression=[A.tokens.int_literal,A.tokens.uint_literal,A.tokens.ident],p.template_types=[A.keywords.vec2,A.keywords.vec3,A.keywords.vec4,A.keywords.mat2x2,A.keywords.mat2x3,A.keywords.mat2x4,A.keywords.mat3x2,A.keywords.mat3x3,A.keywords.mat3x4,A.keywords.mat4x2,A.keywords.mat4x3,A.keywords.mat4x4,A.keywords.atomic,A.keywords.bitcast,...A.any_texture_type],p.attribute_name=[A.tokens.ident,A.keywords.block,A.keywords.diagnostic],p.assignment_operators=[A.tokens.equal,A.tokens.plus_equal,A.tokens.minus_equal,A.tokens.times_equal,A.tokens.division_equal,A.tokens.modulo_equal,A.tokens.and_equal,A.tokens.or_equal,A.tokens.xor_equal,A.tokens.shift_right_equal,A.tokens.shift_left_equal],p.increment_operators=[A.tokens.plus_plus,A.tokens.minus_minus];class Ec{constructor(e,t,i,r,s){this.type=e,this.lexeme=t,this.line=i,this.start=r,this.end=s}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Vx{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 Ec(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
93
93
|
`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
|
|
94
94
|
`;){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==`
|
|
95
|
-
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}const t=p.simpleTokens[e];if(t)return this._addToken(t),!0;let i=p.none;const r=this._isAlpha(e),s=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(r){const o=p.keywords[e];if(o)return this._addToken(o),!0}if(r||s)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
|
|
96
|
-
`&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new El(e,t,this._line,this._start,this._current))}}function U(n){return Array.isArray(n)||(n==null?void 0:n.buffer)instanceof ArrayBuffer}const Gi=new Float32Array(1),Hx=new Uint32Array(Gi.buffer),Wx=new Uint32Array(Gi.buffer),er=new Int32Array(1),$x=new Float32Array(er.buffer),Xx=new Uint32Array(er.buffer),tr=new Uint32Array(1),Yx=new Float32Array(tr.buffer),qx=new Int32Array(tr.buffer);function kl(n,e,t){if(e===t)return n;if(e==="f32"){if(t==="i32"||t==="x32")return Gi[0]=n,Hx[0];if(t==="u32")return Gi[0]=n,Wx[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return er[0]=n,$x[0];if(t==="u32")return er[0]=n,Xx[0]}else if(e==="u32"){if(t==="f32")return tr[0]=n,Yx[0];if(t==="i32"||t==="x32")return tr[0]=n,qx[0]}return console.error(`Unsupported cast from ${e} to ${t}`),n}class jx{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class nr{constructor(e,t){this.align=e,this.size=t}}class dt{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Ex,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(const t of e)t instanceof Xn&&this._functions.set(t.name,new jx(t));for(const t of e)if(t instanceof St){const i=this.getTypeInfo(t,null);i instanceof Et&&this.structs.push(i)}for(const t of e)if(t instanceof Gs)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof Qs){const i=t,r=this._getAttributeNum(i.attributes,"id",0),s=i.type!=null?this.getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Px(i.name,s,i.attributes,r));continue}if(this._isUniformVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new qi(i.name,o,r,s,i.attributes,Ft.Uniform,i.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),c=new qi(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Storage,i.access);c.access||(c.access="read"),this.storage.push(c);continue}if(this._isTextureVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),c=new qi(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Texture,i.access);c.access||(c.access="read"),a?this.storage.push(c):this.textures.push(c);continue}if(this._isSamplerVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new qi(i.name,o,r,s,i.attributes,Ft.Sampler,i.access);this.samplers.push(a);continue}}for(const t of e)if(t instanceof Xn){const i=this._getAttribute(t,"vertex"),r=this._getAttribute(t,"fragment"),s=this._getAttribute(t,"compute"),o=i||r||s,a=new Rx(t.name,o==null?void 0:o.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(c=>new Ix(c.name,this.getTypeInfo(c.type,c.attributes),c.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(i=>{var r,s,o;if(i instanceof Rl){if(i.value)if(U(i.value))for(const a of i.value)for(const c of this.overrides)a===c.name&&((r=t.info)===null||r===void 0||r.overrides.push(c));else for(const a of this.overrides)i.value===a.name&&((s=t.info)===null||s===void 0||s.overrides.push(a))}else if(i instanceof je)for(const a of this.overrides)i.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const r of e.calls){const s=(i=this._functions.get(r.name))===null||i===void 0?void 0:i.info;s&&t.add(s)}}findResource(e,t,i){if(i){for(const r of this.entry.compute)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.vertex)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.fragment)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}}for(const r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(const r of this.storage)if(r.group==e&&r.binding==t)return r;for(const r of this.textures)if(r.group==e&&r.binding==t)return r;for(const r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],r=this,s=[];return e.search(o=>{if(o instanceof ji)s.push({});else if(o instanceof Ki)s.pop();else if(o instanceof bt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof ht){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Yn){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof je){const a=o;if(s.length>0&&s[s.length-1][a.name])return;const c=r._findResource(a.name);c&&i.push(c)}else if(o instanceof eo){const a=o,c=r._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=r._findResources(c.node,t)),i.push(...c.resources))}else if(o instanceof Js){const a=o,c=r._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=r._findResources(c.node,t)),i.push(...c.resources))}}),[...new Map(i.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function t(i,r){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),r>=e[i].length&&(e[i].length=r+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof St)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);i!==null&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof St)this._getStructOutputs(i.type,t);else{const r=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(r!==null){const s=this.getTypeInfo(i.type,i.type.attributes),o=this._parseInt(r.value),a=new rl(i.name,s,r.name,o);t.push(a)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new rl("",i,t.name,r)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(const i of e)if(i.type instanceof St)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof St)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),s=this._parseInt(t.value),o=new Cx(e.name,r,t.name,s);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Ax(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof Qi){const r=e.type?this.getTypeInfo(e.type,e.attributes):null,s=new qs(e.name,r,t);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof jn){const r=e,s=r.format?this.getTypeInfo(r.format,r.attributes):null,o=new kt(r.name,t);return o.format=s,o.count=r.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof St){const r=e,s=new Et(r.name,t);s.startLine=r.startLine,s.endLine=r.endLine;for(const o of r.members){const a=this.getTypeInfo(o.type,o.attributes);s.members.push(new il(o.name,a,o.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Kn){const r=e,s=r.format instanceof k,o=r.format?s?this.getTypeInfo(r.format,null):new Ze(r.format,null):null,a=new Wt(r.name,o,t,r.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof T){const r=e,s=r.format?this.getTypeInfo(r.format,null):null,o=new Wt(r.name,s,t,r.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const i=new Ze(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,r;const s=this._getTypeSize(e);if(e.size=(t=s==null?void 0:s.size)!==null&&t!==void 0?t:0,e instanceof kt&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,(r=o==null?void 0:o.align)!==null&&r!==void 0?r:0),this._updateTypeInfo(e.format)}e instanceof qs&&this._updateTypeInfo(e.format),e instanceof Et&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,r=0,s=0,o=0;for(let a=0,c=e.members.length;a<c;++a){const l=e.members[a],u=this._getTypeSize(l);if(!u)continue;(t=this._getAlias(l.type.name))!==null&&t!==void 0||l.type;const f=u.align,h=u.size;i=this._roundUp(f,i+r),r=h,s=i,o=Math.max(o,f),l.offset=i,l.size=h,this._updateTypeInfo(l.type)}e.size=this._roundUp(o,s+r),e.align=o}_getTypeSize(e){var t,i;if(e==null)return null;const r=this._getAttributeNum(e.attributes,"size",0),s=this._getAttributeNum(e.attributes,"align",0);if(e instanceof il&&(e=e.type),e instanceof Ze){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=dt._typeInfo[e.name];if(o!==void 0){const a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new nr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}{const o=dt._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new nr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}if(e instanceof kt){let o=e,a=8,c=8;const l=this._getTypeSize(o.format);return l!==null&&(c=l.size,a=l.align),c=o.count*this._getAttributeNum((i=e==null?void 0:e.attributes)!==null&&i!==void 0?i:null,"stride",this._roundUp(a,c)),r&&(c=r),new nr(Math.max(s,a),Math.max(r,c))}if(e instanceof Et){let o=0,a=0,c=0,l=0,u=0;for(const f of e.members){const h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),c=this._roundUp(h.align,c+l),l=h.size,u=c)}return a=this._roundUp(o,u+l),new nr(Math.max(s,o),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof bt&&e.storage=="uniform"}_isStorageVar(e){return e instanceof bt&&e.storage=="storage"}_isTextureVar(e){return e instanceof bt&&e.type!==null&&dt._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof bt&&e.type!==null&&dt._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){const i=e;if(!i||!i.attributes)return null;const r=i.attributes;for(let s of r)if(s.name==t)return s;return null}_getAttributeNum(e,t,i){if(e===null)return i;for(let r of e)if(r.name==t){let s=r!==null&&r.value!==null?r.value:i;return s instanceof Array&&(s=s[0]),typeof s=="number"?s:typeof s=="string"?parseInt(s):i}return i}_roundUp(e,t){return Math.ceil(t/e)*e}}dt._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}},dt._textureTypes=p.any_texture_type.map(n=>n.name),dt._samplerTypes=p.sampler_type.map(n=>n.name);let no=0;class io{constructor(e,t,i){this.id=no++,this.name=e,this.value=t,this.node=i}clone(){return new io(this.name,this.value,this.node)}}class ro{constructor(e){this.id=no++,this.name=e.name,this.node=e}clone(){return new ro(this.node)}}class so{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=no++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new io(e,t,i??null))}setVariable(e,t,i){const r=this.getVariable(e);r!==null?r.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return(t=i==null?void 0:i.value)!==null&&t!==void 0?t:null}clone(){return new so(this)}}class Kx{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class Zx{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let r=!0;if(i instanceof g)return i.data.forEach(s=>{s||(r=!1)}),new v(r?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=i.data.some(s=>s);return new v(r?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof v))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.evalExpression(i,t);if(r instanceof xe&&r.typeInfo.size===0){const s=r.typeInfo,o=r.buffer.byteLength/s.stride;return new v(o,this.getTypeInfo("u32"))}return new v(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.abs(s)),i.typeInfo);const r=i;return new v(Math.abs(r.value),r.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acos(s)),i.typeInfo);const r=i;return new v(Math.acos(r.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acosh(s)),i.typeInfo);const r=i;return new v(Math.acosh(r.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asin(s)),i.typeInfo);const r=i;return new v(Math.asin(r.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asinh(s)),i.typeInfo);const r=i;return new v(Math.asinh(r.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atan(s)),i.typeInfo);const r=i;return new v(Math.atan(r.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atanh(s)),i.typeInfo);const r=i;return new v(Math.atanh(r.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,c)=>Math.atan2(a,r.data[c])),i.typeInfo);const s=i,o=r;return new v(Math.atan2(s.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.ceil(s)),i.typeInfo);const r=i;return new v(Math.ceil(r.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((l,u)=>this._clamp(l,r.data[u],s.data[u])),i.typeInfo);const o=i,a=r,c=s;return new v(this._clamp(o.value,a.value,c.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cos(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cosh(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.clz32(s)),i.typeInfo);const r=i;return new v(Math.clz32(r.value),i.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countOneBits(s)),i.typeInfo);const r=i;return new v(this._countOneBits(r.value),i.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countTrailingZeros(s)),i.typeInfo);const r=i;return new v(this._countTrailingZeros(r.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){if(i.data.length!==3||r.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const s=i.data,o=r.data;return new g([s[1]*o[2]-o[1]*s[2],s[2]*o[0]-o[2]*s[0],s[0]*o[1]-o[0]*s[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return i instanceof g?new g(i.data.map(s=>s*r),i.typeInfo):new v(i.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Z){const r=i.data,s=i.typeInfo.getTypeName(),o=s.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h")return new v(r[0]*r[3]-r[1]*r[2],o);if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);if(s==="mat2x4"||s==="mat2x4f"||s==="mat2x4h")console.error(`TODO: Determinant for ${s}`);else if(s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h")console.error(`TODO: Determinant for ${s}`);else{if(s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);s==="mat3x4"||s==="mat3x4f"||s==="mat3x4h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h"?console.error(`TODO: Determinant for ${s}`):s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h"||console.error(`TODO: Determinant for ${s}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){let a=0;for(let c=0;c<i.data.length;++c)a+=(i.data[c]-r.data[c])*(i.data[c]-r.data[c]);return new v(Math.sqrt(a),this.getTypeInfo("f32"))}const s=i,o=r;return new v(Math.abs(s.value-o.value),i.typeInfo)}_dot(e,t){let i=0;for(let r=0;r<e.length;++r)i+=t[r]*e[r];return i}Dot(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return i instanceof g&&r instanceof g?new v(this._dot(i.data,r.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.exp(s)),i.typeInfo);const r=i;return new v(Math.exp(r.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.pow(2,s)),i.typeInfo);const r=i;return new v(Math.pow(2,r.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=r.value,a=s.value;if(i instanceof g)return new g(i.data.map(l=>l>>o&(1<<a)-1),i.typeInfo);if(i.typeInfo.name!=="i32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;const c=i.value;return new v(c>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g){const o=this._dot(r.data,s.data);return new g(o<0?Array.from(i.data):i.data.map(a=>-a),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstLeadingBit(s)),i.typeInfo);const r=i;return new v(this._firstLeadingBit(r.value),i.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstTrailingBit(s)),i.typeInfo);const r=i;return new v(this._firstTrailingBit(r.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.floor(s)),i.typeInfo);const r=i;return new v(Math.floor(r.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return i.data.length!==r.data.length||i.data.length!==s.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new g(i.data.map((l,u)=>l*r.data[u]+s.data[u]),i.typeInfo);const o=i,a=r,c=s;return new v(o.value*a.value+c.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>s-Math.floor(s)),i.typeInfo);const r=i;return new v(r.value-Math.floor(r.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const a=s.value,c=(1<<o.value)-1<<a,l=~c;if(i instanceof g&&r instanceof g)return new g(i.data.map((h,d)=>h&l|r.data[d]<<a&c),i.typeInfo);const u=i.value,f=r.value;return new v(u&l|f<<a&c,i.typeInfo)}InverseSqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>1/Math.sqrt(s)),i.typeInfo);const r=i;return new v(1/Math.sqrt(r.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){let s=0;return i.data.forEach(o=>{s+=o*o}),new v(Math.sqrt(s),this.getTypeInfo("f32"))}const r=i;return new v(Math.abs(r.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log(s)),i.typeInfo);const r=i;return new v(Math.log(r.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log2(s)),i.typeInfo);const r=i;return new v(Math.log2(r.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,c)=>Math.max(a,r.data[c])),i.typeInfo);const s=i,o=r;return new v(Math.max(s.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,c)=>Math.min(a,r.data[c])),i.typeInfo);const s=i,o=r;return new v(Math.min(s.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((c,l)=>i.data[l]*(1-s.data[l])+r.data[l]*s.data[l]),i.typeInfo);const o=r,a=s;return new v(i.value*(1-a.value)+o.value*a.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((o,a)=>o%r.data[a]),i.typeInfo);const s=r;return new v(i.value%s.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=this.Length(e,t).value;return new g(i.data.map(s=>s/r),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,c)=>Math.pow(a,r.data[c])),i.typeInfo);const s=i,o=r;return new v(Math.pow(s.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r),i.typeInfo):new v(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r*Math.PI/180),i.typeInfo):new v(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){const s=this._dot(i.data,r.data);return new g(i.data.map((o,a)=>o-2*s*r.data[a]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof v){const o=this._dot(r.data,i.data);return new g(i.data.map((a,c)=>{const l=1-s.value*s.value*(1-o*o);if(l<0)return 0;const u=Math.sqrt(l);return s.value*a-(s.value*o+u)*r.data[c]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.round(s)),i.typeInfo);const r=i;return new v(Math.round(r.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.min(Math.max(s,0),1)),i.typeInfo);const r=i;return new v(Math.min(Math.max(r.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sign(s)),i.typeInfo);const r=i;return new v(Math.sign(r.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sin(s)),i.typeInfo);const r=i;return new v(Math.sin(r.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sinh(s)),i.typeInfo);const r=i;return new v(Math.sinh(r.value),i.typeInfo)}_smoothstep(e,t,i){const r=Math.min(Math.max((i-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(s instanceof g&&i instanceof g&&r instanceof g)return new g(s.data.map((l,u)=>this._smoothstep(i.data[u],r.data[u],l)),s.typeInfo);const o=i,a=r,c=s;return new v(this._smoothstep(o.value,a.value,c.value),s.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sqrt(s)),i.typeInfo);const r=i;return new v(Math.sqrt(r.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof g&&i instanceof g)return new g(r.data.map((o,a)=>o<i.data[a]?0:1),r.typeInfo);const s=i;return new v(r.value<s.value?0:1,s.typeInfo)}Tan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tan(s)),i.typeInfo);const r=i;return new v(Math.tan(r.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tanh(s)),i.typeInfo);const r=i;return new v(Math.tanh(r.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof Z))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const r=this._getTransposeType(i.typeInfo);if(i.typeInfo.name==="mat2x2"||i.typeInfo.name==="mat2x2f"||i.typeInfo.name==="mat2x2h"){const s=i.data;return new Z([s[0],s[2],s[1],s[3]],r)}if(i.typeInfo.name==="mat2x3"||i.typeInfo.name==="mat2x3f"||i.typeInfo.name==="mat2x3h"){const s=i.data;return new Z([s[0],s[3],s[6],s[1],s[4],s[7]],r)}if(i.typeInfo.name==="mat2x4"||i.typeInfo.name==="mat2x4f"||i.typeInfo.name==="mat2x4h"){const s=i.data;return new Z([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13]],r)}if(i.typeInfo.name==="mat3x2"||i.typeInfo.name==="mat3x2f"||i.typeInfo.name==="mat3x2h"){const s=i.data;return new Z([s[0],s[3],s[1],s[4],s[2],s[5]],r)}if(i.typeInfo.name==="mat3x3"||i.typeInfo.name==="mat3x3f"||i.typeInfo.name==="mat3x3h"){const s=i.data;return new Z([s[0],s[3],s[6],s[1],s[4],s[7],s[2],s[5],s[8]],r)}if(i.typeInfo.name==="mat3x4"||i.typeInfo.name==="mat3x4f"||i.typeInfo.name==="mat3x4h"){const s=i.data;return new Z([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14]],r)}if(i.typeInfo.name==="mat4x2"||i.typeInfo.name==="mat4x2f"||i.typeInfo.name==="mat4x2h"){const s=i.data;return new Z([s[0],s[4],s[1],s[5],s[2],s[6]],r)}if(i.typeInfo.name==="mat4x3"||i.typeInfo.name==="mat4x3f"||i.typeInfo.name==="mat4x3h"){const s=i.data;return new Z([s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]],r)}if(i.typeInfo.name==="mat4x4"||i.typeInfo.name==="mat4x4f"||i.typeInfo.name==="mat4x4h"){const s=i.data;return new Z([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]],r)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.trunc(s)),i.typeInfo);const r=i;return new v(Math.trunc(r.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof je){const s=i.name,o=t.getVariableValue(s);if(o instanceof Tt){if(r<0||r>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const a=o.getMipLevelSize(r),c=o.dimension;return c==="1d"?new v(a[0],this.getTypeInfo("u32")):c==="3d"?new g(a,this.getTypeInfo("vec3u")):c==="2d"?new g(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${c} not found. Line ${e.line}`),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof je){const o=i.name,a=t.getVariableValue(o);if(a instanceof Tt){const c=Math.floor(r.data[0]),l=Math.floor(r.data[1]);if(c<0||c>=a.width||l<0||l>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const u=a.getPixel(c,l,0,s);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new g(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof je){const a=i.name,c=t.getVariableValue(a);if(c instanceof Tt){const l=c.getMipLevelSize(0),u=Math.floor(r.data[0]),f=Math.floor(r.data[1]);return u<0||u>=l[0]||f<0||f>=l[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(c.setPixel(u,f,0,s,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t);return t.getVariable(r).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t);return c instanceof v&&a instanceof v&&(c.value=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value+=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicSub(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value-=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicMax(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=Math.max(c.value,a.value)),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicMin(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=Math.min(c.value,a.value)),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicAnd(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=c.value&a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicOr(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=c.value|a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicXor(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=c.value^a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicExchange(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),c=s.value.getSubData(this.exec,i.postfix,t),l=new v(c.value,c.typeInfo);return c instanceof v&&a instanceof v&&(c.value=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,c,i.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const oo={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},ze={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class Fe extends Kx{constructor(e,t){var i;super(),this.ast=e??[],this.reflection=new dt,this.reflection.updateAST(this.ast),this.context=(i=t==null?void 0:t.clone())!==null&&i!==void 0?i:new so,this.builtins=new Zx(this),this.typeInfo={bool:this.getTypeInfo(k.bool),i32:this.getTypeInfo(k.i32),u32:this.getTypeInfo(k.u32),f32:this.getTypeInfo(k.f32),f16:this.getTypeInfo(k.f16),vec2f:this.getTypeInfo(T.vec2f),vec2u:this.getTypeInfo(T.vec2u),vec2i:this.getTypeInfo(T.vec2i),vec2h:this.getTypeInfo(T.vec2h),vec3f:this.getTypeInfo(T.vec3f),vec3u:this.getTypeInfo(T.vec3u),vec3i:this.getTypeInfo(T.vec3i),vec3h:this.getTypeInfo(T.vec3h),vec4f:this.getTypeInfo(T.vec4f),vec4u:this.getTypeInfo(T.vec4u),vec4i:this.getTypeInfo(T.vec4i),vec4h:this.getTypeInfo(T.vec4h),mat2x2f:this.getTypeInfo(T.mat2x2f),mat2x3f:this.getTypeInfo(T.mat2x3f),mat2x4f:this.getTypeInfo(T.mat2x4f),mat3x2f:this.getTypeInfo(T.mat3x2f),mat3x3f:this.getTypeInfo(T.mat3x3f),mat3x4f:this.getTypeInfo(T.mat3x4f),mat4x2f:this.getTypeInfo(T.mat4x2f),mat4x3f:this.getTypeInfo(T.mat4x3f),mat4x4f:this.getTypeInfo(T.mat4x4f)}}getVariableValue(e){var t,i;const r=(i=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&i!==void 0?i:null;if(r===null)return null;if(r instanceof v)return r.value;if(r instanceof g||r instanceof Z)return Array.from(r.data);if(r instanceof xe&&r.typeInfo instanceof kt){if(r.typeInfo.format.name==="u32")return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="i32")return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="f32")return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,r){const s=this.context.clone();(r=r??{}).constants&&this._setOverrides(r.constants,s),this._execStatements(this.ast,s);const o=s.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const a=t[0],c=t[1],l=t[2],u=this.getTypeInfo("vec3u");s.setVariable("@num_workgroups",new g(t,u));const f=this.reflection.getFunctionInfo(e);f===null&&console.error(`Function ${e} not found in reflection data`);for(const h in i)for(const d in i[h]){const _=i[h][d];s.variables.forEach(I=>{var C;const w=I.node;if(w!=null&&w.attributes){let M=null,E=null;for(const x of w.attributes)x.name==="binding"?M=x.value:x.name==="group"&&(E=x.value);if(d==M&&h==E){let x=!1;for(const R of f.resources)if(R.name===I.name&&R.group===parseInt(h)&&R.binding===parseInt(d)){x=!0;break}if(x)if(_.texture!==void 0&&_.descriptor!==void 0){const R=new Tt(_.texture,this.getTypeInfo(w.type),_.descriptor,(C=_.texture.view)!==null&&C!==void 0?C:null);I.value=R}else _.uniform!==void 0?I.value=new xe(_.uniform,this.getTypeInfo(w.type)):I.value=new xe(_,this.getTypeInfo(w.type))}}})}for(let h=0;h<l;++h)for(let d=0;d<c;++d)for(let _=0;_<a;++_)s.setVariable("@workgroup_id",new g([_,d,h],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[_,d,h],s)}execStatement(e,t){if(e instanceof gl)return this.evalExpression(e.value,t);if(e instanceof xl){if(e.condition){const i=this.evalExpression(e.condition,t);if(!(i instanceof v))throw new Error("Invalid break-if condition");if(!i.value)return null}return Fe._breakObj}if(e instanceof yl)return Fe._continueObj;if(e instanceof Yn)this._let(e,t);else if(e instanceof bt)this._var(e,t);else if(e instanceof Zi)this._const(e,t);else if(e instanceof Xn)this._function(e,t);else{if(e instanceof ml)return this._if(e,t);if(e instanceof pl)return this._switch(e,t);if(e instanceof ul)return this._for(e,t);if(e instanceof ll)return this._while(e,t);if(e instanceof dl)return this._loop(e,t);if(e instanceof Zs){const i=t.clone();return i.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,i)}if(e instanceof hl)this._assign(e,t);else if(e instanceof fl)this._increment(e,t);else{if(e instanceof St)return null;if(e instanceof Qs){const i=e.name;t.getVariable(i)===null&&t.setVariable(i,new v(0,this.getTypeInfo("u32")))}else if(e instanceof Js)this._call(e,t);else{if(e instanceof _l||e instanceof Gs)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof st?this._evalBinaryOp(e,t):e instanceof Te?this._evalLiteral(e,t):e instanceof je?this._evalVariable(e,t):e instanceof eo?this._evalCall(e,t):e instanceof ht?this._evalCreate(e,t):e instanceof bl?this._evalConst(e,t):e instanceof Sl?this._evalBitcast(e,t):e instanceof ve?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof k){const r=this.reflection.getTypeInfo(e);if(r!==null)return r}let i=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return i!==null||(i=this.reflection.getTypeInfoByName(e)),i}_setOverrides(e,t){for(const i in e){const r=e[i],s=this.reflection.getOverrideInfo(i);s!==null?(s.type===null&&(s.type=this.getTypeInfo("u32")),s.type.name==="u32"||s.type.name==="i32"||s.type.name==="f32"||s.type.name==="f16"?t.setVariable(i,new v(r,s.type)):s.type.name==="bool"?t.setVariable(i,new v(r?1:0,s.type)):s.type.name==="vec2"||s.type.name==="vec3"||s.type.name==="vec4"||s.type.name==="vec2f"||s.type.name==="vec3f"||s.type.name==="vec4f"||s.type.name==="vec2i"||s.type.name==="vec3i"||s.type.name==="vec4i"||s.type.name==="vec2u"||s.type.name==="vec3u"||s.type.name==="vec4u"||s.type.name==="vec2h"||s.type.name==="vec3h"||s.type.name==="vec4h"?t.setVariable(i,new g(r,s.type)):console.error(`Invalid constant type for ${i}`)):console.error(`Override ${i} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,i){const r=[1,1,1];for(const u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){const f=i.getVariableValue(u.value[0]);r[0]=f instanceof v?f.value:parseInt(u.value[0])}if(u.value.length>1){const f=i.getVariableValue(u.value[1]);r[1]=f instanceof v?f.value:parseInt(u.value[1])}if(u.value.length>2){const f=i.getVariableValue(u.value[2]);r[2]=f instanceof v?f.value:parseInt(u.value[2])}}const s=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new g(r,s));const a=r[0],c=r[1],l=r[2];for(let u=0,f=0;u<l;++u)for(let h=0;h<c;++h)for(let d=0;d<a;++d,++f){const _=[d,h,u],I=[d+t[0]*r[0],h+t[1]*r[1],u+t[2]*r[2]];i.setVariable("@local_invocation_id",new g(_,s)),i.setVariable("@global_invocation_id",new g(I,s)),i.setVariable("@local_invocation_index",new v(f,o)),this._dispatchExec(e,i)}}_dispatchExec(e,t){for(const i of e.node.args)for(const r of i.attributes)if(r.name==="builtin"){const s=`@${r.value}`,o=t.getVariable(s);o!==void 0&&t.variables.set(i.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof ve;)e=e.right;return e instanceof je?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(const i of e){if(i instanceof Array){const s=t.clone(),o=this._execStatements(i,s);if(o)return o;continue}const r=this.execStatement(i,t);if(r)return r}return null}_call(e,t){const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(r){for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.setVariable(o.name,a,o)}this._execStatements(r.node.body,i)}else e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const i=this.getVariableName(e.variable,t),r=t.getVariable(i);r?e.operator==="++"?r.value instanceof v?r.value.value++:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):e.operator==="--"?r.value instanceof v?r.value.value--:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${i} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof je){const i=this.getVariableName(e,t),r=t.getVariable(i);return r===null?(console.error(`Variable ${i} not found. Line ${e.line}`),null):r.value.getSubData(this,e.postfix,t)}if(e instanceof ve){if(e.operator==="*"){const i=this._getVariableData(e.right,t);return i instanceof pn?i.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const i=this._getVariableData(e.right,t);return new pn(i)}}return null}_assign(e,t){let i=null,r="<var>",s=null;if(e.variable instanceof ve){const c=this._getVariableData(e.variable,t),l=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(c instanceof v||c instanceof g||c instanceof Z){if(l instanceof v||l instanceof g||l instanceof Z&&c.data.length===l.data.length)return void c.data.set(l.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(c instanceof xe&&l instanceof xe&&c.buffer.byteLength-c.offset>=l.buffer.byteLength-l.offset)return void(c.buffer.byteLength%4==0?new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4).set(new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4)):new Uint8Array(c.buffer,c.offset,c.typeInfo.size).set(new Uint8Array(l.buffer,l.offset,l.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return c instanceof v||c instanceof g||c instanceof Z?l instanceof v||l instanceof g||l instanceof Z?void c.data.set(l.data.map((f,h)=>c.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(c instanceof v||c instanceof g||c instanceof Z)&&(l instanceof v||l instanceof g||l instanceof Z)?void c.data.set(l.data.map((f,h)=>c.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof ve){if(e.variable.operator==="*"){r=this.getVariableName(e.variable.right,t);const c=t.getVariable(r);if(!(c&&c.value instanceof pn))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);i=c.value.reference;let l=e.variable.postfix;if(!l){let u=e.variable.right;for(;u instanceof ve;){if(u.postfix){l=u.postfix;break}u=u.right}}l&&(i=i.getSubData(this,l,t))}}else{s=e.variable.postfix,r=this.getVariableName(e.variable,t);const c=t.getVariable(r);if(c===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);i=c.value}if(i instanceof pn&&(i=i.reference),i===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),a=e.operator;if(a!=="="){const c=i.getSubData(this,s,t);if(c instanceof g&&o instanceof v){const l=c.data,u=o.value;if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u;else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u;else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u;else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u;else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u;else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u;else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u;else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u;else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u;else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(c instanceof g&&o instanceof g){const l=c.data,u=o.data;if(l.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u[f];else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u[f];else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u[f];else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u[f];else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u[f];else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u[f];else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u[f];else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u[f];else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u[f];else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(c instanceof v&&o instanceof v))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?c.value+=o.value:a==="-="?c.value-=o.value:a==="*="?c.value*=o.value:a==="/="?c.value/=o.value:a==="%="?c.value%=o.value:a==="&="?c.value&=o.value:a==="|="?c.value|=o.value:a==="^="?c.value^=o.value:a==="<<="?c.value<<=o.value:a===">>="?c.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}return void(i instanceof xe&&i.setDataValue(this,c,s,t))}if(i instanceof xe)i.setDataValue(this,o,s,t);else if(s){if(!(i instanceof g||i instanceof Z))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(s instanceof dn){const c=this.evalExpression(s.index,t).value;if(i instanceof g){if(!(o instanceof v))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[c]=o.value}else{if(!(i instanceof Z))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const l=this.evalExpression(s.index,t).value;if(l<0)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const u=i.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(l<2&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*l]=o.data[0],i.data[2*l+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(l<2&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*l]=o.data[0],i.data[3*l+1]=o.data[1],i.data[3*l+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(l<2&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*l]=o.data[0],i.data[4*l+1]=o.data[1],i.data[4*l+2]=o.data[2],i.data[4*l+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(l<3&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*l]=o.data[0],i.data[2*l+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(l<3&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*l]=o.data[0],i.data[3*l+1]=o.data[1],i.data[3*l+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(l<3&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*l]=o.data[0],i.data[4*l+1]=o.data[1],i.data[4*l+2]=o.data[2],i.data[4*l+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(l<4&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*l]=o.data[0],i.data[2*l+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(l<4&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*l]=o.data[0],i.data[3*l+1]=o.data[1],i.data[3*l+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(l<4&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*l]=o.data[0],i.data[4*l+1]=o.data[1],i.data[4*l+2]=o.data[2],i.data[4*l+3]=o.data[3]}}}}}else if(s instanceof $t){const c=s.value;if(!(i instanceof g))return void console.error(`Invalid assignment to ${c}. Variable ${r} is not a vector. Line ${e.line}`);if(o instanceof v){if(c.length>1)return void console.error(`Invalid assignment to ${c} for variable ${r}. Line ${e.line}`);if(c==="x")i.data[0]=o.value;else if(c==="y"){if(i.data.length<2)return void console.error(`Invalid assignment to ${c} for variable ${r}. Line ${e.line}`);i.data[1]=o.value}else if(c==="z"){if(i.data.length<3)return void console.error(`Invalid assignment to ${c} for variable ${r}. Line ${e.line}`);i.data[2]=o.value}else if(c==="w"){if(i.data.length<4)return void console.error(`Invalid assignment to ${c} for variable ${r}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(c.length!==o.data.length)return void console.error(`Invalid assignment to ${c} for variable ${r}. Line ${e.line}`);for(let l=0;l<c.length;++l){const u=c[l];if(u==="x"||u==="r")i.data[0]=o.data[l];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[1]=o.data[l]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[2]=o.data[l]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[3]=o.data[l]}}}}}else i instanceof v&&o instanceof v?i.value=o.value:i instanceof g&&o instanceof g||i instanceof Z&&o instanceof Z?i.data.set(o.data):console.error(`Invalid assignment to ${r}. Line ${e.line}`)}_function(e,t){const i=new ro(e);t.functions.set(e.name,i)}_const(e,t){let i=null;e.value!==null&&(i=this.evalExpression(e.value,t)),t.createVariable(e.name,i,e)}_let(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ve||(i=i.clone())}else{const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||r==="array"){const s=new ht(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_var(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ve||(i=i.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||e.type instanceof jn||e.type instanceof St||e.type instanceof T){const s=new ht(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_switch(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;let r=null;for(const s of e.cases)if(s instanceof Al)for(const o of s.selectors){if(o instanceof Ji){r=s;continue}const a=this.evalExpression(o,t);if(!(a instanceof v))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===i.value)return this._execStatements(s.body,t)}else s instanceof Cl&&(r=s);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(e.body,t);for(const r of e.elseif){const s=this.evalExpression(r.condition,t);if(!(s instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(s.value)return this._execStatements(r.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof v?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i!==null&&i!==Fe._continueObj)return i;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i===Fe._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===Fe._breakObj)break}else if(i!==null)return i}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i!==Fe._continueObj&&i!==null)return i}return null}_evalBitcast(e,t){const i=this.evalExpression(e.value,t),r=e.type;if(i instanceof v){const s=kl(i.value,i.typeInfo.name,r.name);return new v(s,this.getTypeInfo(r))}if(i instanceof g){const s=i.typeInfo.getTypeName();let o="";if(s.endsWith("f"))o="f32";else if(s.endsWith("i"))o="i32";else if(s.endsWith("u"))o="u32";else if(s.endsWith("b"))o="bool";else{if(!s.endsWith("h"))return console.error(`Unknown vector type ${s}. Line ${e.line}`),null;o="f16"}const a=r.getTypeName();let c="";if(a.endsWith("f"))c="f32";else if(a.endsWith("i"))c="i32";else if(a.endsWith("u"))c="u32";else if(a.endsWith("b"))c="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${c}. Line ${e.line}`),null;c="f16"}const l=function(u,f,h){if(f===h)return u;const d=new Array(u.length);for(let _=0;_<u.length;_++)d[_]=kl(u[_],f,h);return d}(Array.from(i.data),o,c);return new g(l,this.getTypeInfo(r))}return console.error(`TODO: bitcast for ${i.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var i;if(e instanceof ht){if(e.type===null)return to.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}const r=e instanceof ht?e.type.name:e.name,s=e instanceof ht?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(s===null)return console.error(`Unknown type ${r}. Line ${e.line}`),null;if(s.size===0)return null;const o=new xe(new ArrayBuffer(s.size),s,0);if(s instanceof Et){if(e.args)for(let a=0;a<e.args.length;++a){const c=s.members[a],l=e.args[a],u=this.evalExpression(l,t);o.setData(this,u,c.type,c.offset,t)}}else if(s instanceof kt){let a=0;if(e.args)for(let c=0;c<e.args.length;++c){const l=e.args[c],u=this.evalExpression(l,t);s.format===null&&(((i=u.typeInfo)===null||i===void 0?void 0:i.name)==="x32"?s.format=this.getTypeInfo("i32"):s.format=u.typeInfo),o.setData(this,u,s.format,a,t),a+=s.stride}}else console.error(`Unknown type "${r}". Line ${e.line}`);return e instanceof ht?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){const i=this.getTypeInfo(e.type),r=i.name;return r==="x32"||r==="u32"||r==="f32"||r==="f16"||r==="i32"||r==="bool"?new v(e.scalarValue,i):r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"?this._callConstructorVec(e,t):r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const i=t.getVariableValue(e.name);return i===null?i:i.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=Fe._priority.get(t.name);Fe._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const i=this.evalExpression(e.right,t);if(e.operator==="&")return new pn(i);if(e.operator==="*")return i instanceof pn?i.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);const r=i instanceof v?i.value:i instanceof g?Array.from(i.data):null;switch(e.operator){case"+":{if(U(r)){const a=r.map((c,l)=>+c);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(+s,o)}case"-":{if(U(r)){const a=r.map((c,l)=>-c);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(-s,o)}case"!":{if(U(r)){const a=r.map((c,l)=>c?0:1);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(s?0:1,o)}case"~":{if(U(r)){const a=r.map((c,l)=>~c);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(~s,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),s=i instanceof v?i.value:i instanceof g||i instanceof Z?Array.from(i.data):null,o=r instanceof v?r.value:r instanceof g||r instanceof Z?Array.from(r.data):null;switch(e.operator){case"+":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d+f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h+u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u+h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a+c,l)}case"-":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d-f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h-u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u-h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a-c,l)}case"*":{if(U(s)&&U(o)){const u=s,f=o;if(i instanceof Z&&r instanceof Z){const h=function(C,w,M,E){if(ze[w.name]===void 0||ze[E.name]===void 0)return null;const x=ze[w.name][0],R=ze[w.name][1],B=ze[E.name][0];if(x!==ze[E.name][1])return null;const L=new Array(B*R);for(let W=0;W<R;W++)for(let q=0;q<B;q++){let J=0;for(let O=0;O<x;O++)J+=C[O*R+W]*M[q*x+O];L[W*B+q]=J}return L}(u,i.typeInfo,f,r.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const d=ze[r.typeInfo.name][0],_=ze[i.typeInfo.name][1],I=this.getTypeInfo(`mat${d}x${_}f`);return new Z(h,I)}if(i instanceof Z&&r instanceof g){const h=function(d,_,I,C){if(ze[_.name]===void 0||oo[C.name]===void 0)return null;const w=ze[_.name][0],M=ze[_.name][1];if(w!==I.length)return null;const E=new Array(M);for(let x=0;x<M;x++){let R=0;for(let B=0;B<w;B++)R+=d[B*M+x]*I[B];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,r.typeInfo)}if(i instanceof g&&r instanceof Z){const h=function(d,_,I,C){if(oo[_.name]===void 0||ze[C.name]===void 0)return null;const w=ze[C.name][0],M=ze[C.name][1];if(M!==d.length)return null;const E=[];for(let x=0;x<w;x++){let R=0;for(let B=0;B<M;B++)R+=d[B]*I[B*w+x];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,i.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d*f[_]);return new g(h,i.typeInfo)}}if(U(s)){const u=o,f=s.map((h,d)=>h*u);return i instanceof Z?new Z(f,i.typeInfo):new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u*h);return r instanceof Z?new Z(f,r.typeInfo):new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a*c,l)}case"%":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d%f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h%u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u%h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a%c,l)}case"/":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d/f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h/u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u/h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a/c,l)}case"&":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d&f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h&u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u&h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a&c,l)}case"|":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d|f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h|u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u|h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a|c,l)}case"^":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d^f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h^u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u^h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a^c,l)}case"<<":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d<<f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h<<u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u<<h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a<<c,l)}case">>":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d>>f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h>>u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u>>h);return new g(f,r.typeInfo)}const a=s,c=o,l=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a>>c,l)}case">":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u>c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l>a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a>l?1:0);return new g(c,r.typeInfo)}return new v(s>o?1:0,this.getTypeInfo("bool"));case"<":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u<c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l<a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a<l?1:0);return new g(c,r.typeInfo)}return new v(s<o?1:0,this.getTypeInfo("bool"));case"==":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u===c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l==a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a==l?1:0);return new g(c,r.typeInfo)}return new v(s===o?1:0,this.getTypeInfo("bool"));case"!=":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u!==c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l!==a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a!==l?1:0);return new g(c,r.typeInfo)}return new v(s!==o?1:0,this.getTypeInfo("bool"));case">=":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u>=c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l>=a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a>=l?1:0);return new g(c,r.typeInfo)}return new v(s>=o?1:0,this.getTypeInfo("bool"));case"<=":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u<=c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l<=a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a<=l?1:0);return new g(c,r.typeInfo)}return new v(s<=o?1:0,this.getTypeInfo("bool"));case"&&":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u&&c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l&&a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a&&l?1:0);return new g(c,r.typeInfo)}return new v(s&&o?1:0,this.getTypeInfo("bool"));case"||":if(U(s)&&U(o)){const a=s,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const l=a.map((u,f)=>u||c[f]?1:0);return new g(l,i.typeInfo)}if(U(s)){const a=o,c=s.map((l,u)=>l||a?1:0);return new g(c,i.typeInfo)}if(U(o)){const a=s,c=o.map((l,u)=>a||l?1:0);return new g(c,r.typeInfo)}return new v(s||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.createVariable(o.name,a,o)}return this._execStatements(r.node.body,i)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const i=t.getFunction(e.name);if(i){const r=t.clone();for(let s=0;s<i.node.args.length;++s){const o=i.node.args[s],a=this.evalExpression(e.args[s],r);r.setVariable(o.name,a,o)}return this._execStatements(i.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new v(0,this.getTypeInfo(e.type));const i=this.evalExpression(e.args[0],t);return i.typeInfo=this.getTypeInfo(e.type),i.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=oo[r];if(s===void 0)return console.error(`Invalid vec constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Te)if(e.isVector){const a=e.vectorValue;for(const c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const c=this.evalExpression(a,t);if(c instanceof g){const l=c.data;for(let u=0;u<l.length;++u){let f=l[u];o.push(f)}}else if(c instanceof v){let l=c.value;o.push(l)}}if(e.type instanceof T&&e.type.format===null&&(e.type.format=T.f32),o.length===0){const a=new Array(s).fill(0);return new g(a,i).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<s;)o.push(o[0]);return o.length<s?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new g(o.length>s?o.slice(0,s):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=ze[r];if(s===void 0)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Te)if(e.isVector){const a=e.vectorValue;for(const c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const c=this.evalExpression(a,t);c instanceof g?o.push(...c.data):c instanceof v?o.push(c.value):c instanceof Z&&o.push(...c.data)}if(i instanceof Wt&&i.format===null&&(i.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(s[2]).fill(0);return new Z(a,i).getSubData(this,e.postfix,t)}return o.length!==s[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new Z(o,i).getSubData(this,e.postfix,t)}}Fe._breakObj=new Je(new Ze("BREAK",null),null),Fe._continueObj=new Je(new Ze("CONTINUE",null),null),Fe._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class Qx{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class Jx{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new Qx,this._exec=new Fe,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const i=this._global_decl_or_directive();if(!i)break;t.push(i)}if(this._deferArrayCountEval.length>0){for(const i of this._deferArrayCountEval){const r=i.arrayType,s=i.countNode;if(s instanceof je){const o=s.name,a=this._context.constants.get(o);if(a)try{const c=a.constEvaluate(this._exec);r.count=c}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const i of t)i.search(r=>{r instanceof Il||r instanceof Qi?r.type=this._forwardType(r.type):r instanceof jn?r.format=this._forwardType(r.format):r instanceof bt||r instanceof Yn||r instanceof Zi?r.type=this._forwardType(r.type):r instanceof Xn?r.returnType=this._forwardType(r.returnType):r instanceof Pl&&(r.type=this._forwardType(r.type))});return t}_forwardType(e){if(e instanceof vl){const t=this._getType(e.name);if(t)return t}else e instanceof Qi?e.type=this._forwardType(e.type):e instanceof jn&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const t=new Vx(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof S)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t<i;++t){const r=e[t];if(this._check(r))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const i=t.type;let r=!1;for(const s of e){if(i===s)return!0;s===p.tokens.name&&(r=!0)}if(r){const s=p.tokens.name.rule.exec(t.lexeme);if(s&&s.index==0&&s[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){const i=p.tokens.name.rule.exec(t.lexeme);return i&&i.index==0&&i[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){const t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){const t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){const t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){const t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}const e=this._attribute();if(this._check(p.keywords.var)){const t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){const t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){const t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){const t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){const t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){const t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");const i=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;const a=this._attribute(),c=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");const l=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=l,i.push(this._updateNode(new Pl(c,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(p.tokens.arrow)){const a=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=a)}const s=this._compound_statement(),o=this._currentLine;return this._updateNode(new Xn(t,i,r,s,e,o),e)}_compound_statement(){const e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){const t=this._statement();t!==null&&e.push(t)}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 Ux);else if(this._match(p.keywords.break)){const t=this._updateNode(new xl);if(this._currentLoop.length>0){const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){const t=this._updateNode(new yl);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t}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,t=this._optional_paren_expression();return this._updateNode(new Nx(t),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 t=this._currentLine,i=this._compound_statement();return this._updateNode(new Zs(i,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");const e=this._updateNode(new ul(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 t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new bt(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new Yn(t,i,null,null,r),e)}if(this._match(p.keywords.const)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return i===null&&r instanceof Te&&(i=r.type),this._updateNode(new Zi(t,i,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;const i=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new fl(i.type===p.tokens.plus_plus?hn.increment:hn.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let i=this._match(p.tokens.underscore);if(i||(e=this._unary_expression()),!i&&e==null)return null;const r=this._consume(p.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return this._updateNode(new hl(qn.parse(r.lexeme),e,s),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume(p.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=t,null):this._updateNode(new Js(i.lexeme,r),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 dl([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof Zs){e.continuing=t;break}t=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 pl(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 t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){const i=this._case_selectors();for(const s of i)if(s instanceof Ji){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!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 r=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Al(i,r)))}if(this._match(p.keywords.default)){if(t)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 i=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Cl(i)))}}return e}_case_selectors(){const e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new Ji)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new Ji)):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[];e instanceof Array||(e=[e]);const t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();const i=this._compound_statement();let r=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let s=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),s=this._compound_statement()),this._updateNode(new ml(t,i,r,s),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)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new zx(t,i))),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 gl(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 ve(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new dn(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match(p.tokens.period)){const e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new $t(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return k.void;case"bool":return k.bool;case"i32":return k.i32;case"u32":return k.u32;case"f32":return k.f32;case"f16":return k.f16;case"vec2f":return T.vec2f;case"vec3f":return T.vec3f;case"vec4f":return T.vec4f;case"vec2i":return T.vec2i;case"vec3i":return T.vec3i;case"vec4i":return T.vec4i;case"vec2u":return T.vec2u;case"vec3u":return T.vec3u;case"vec4u":return T.vec4u;case"vec2h":return T.vec2h;case"vec3h":return T.vec3h;case"vec4h":return T.vec4h;case"mat2x2f":return T.mat2x2f;case"mat2x3f":return T.mat2x3f;case"mat2x4f":return T.mat2x4f;case"mat3x2f":return T.mat3x2f;case"mat3x3f":return T.mat3x3f;case"mat3x4f":return T.mat3x4f;case"mat4x2f":return T.mat4x2f;case"mat4x3f":return T.mat4x3f;case"mat4x4f":return T.mat4x4f;case"mat2x2h":return T.mat2x2h;case"mat2x3h":return T.mat2x3h;case"mat2x4h":return T.mat2x4h;case"mat3x2h":return T.mat3x2h;case"mat3x3h":return T.mat3x3h;case"mat3x4h":return T.mat3x4h;case"mat4x2h":return T.mat4x2h;case"mat4x3h":return T.mat4x3h;case"mat4x4h":return T.mat4x4h;case"mat2x2i":return T.mat2x2i;case"mat2x3i":return T.mat2x3i;case"mat2x4i":return T.mat2x4i;case"mat3x2i":return T.mat3x2i;case"mat3x3i":return T.mat3x3i;case"mat3x4i":return T.mat3x4i;case"mat4x2i":return T.mat4x2i;case"mat4x3i":return T.mat4x3i;case"mat4x4i":return T.mat4x4i;case"mat2x2u":return T.mat2x2u;case"mat2x3u":return T.mat2x3u;case"mat2x4u":return T.mat2x4u;case"mat3x2u":return T.mat3x2u;case"mat3x3u":return T.mat3x3u;case"mat3x4u":return T.mat3x4u;case"mat4x2u":return T.mat4x2u;case"mat4x3u":return T.mat4x3u;case"mat4x4u":return T.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){const i=this._previous().toString();if(this._check(p.tokens.paren_left)){const r=this._argument_expression_list(),s=this._getType(i);return s!==null?this._updateNode(new ht(s,r)):this._updateNode(new eo(i,r))}if(this._context.constants.has(i)){const r=this._context.constants.get(i);return this._updateNode(new bl(i,r.value))}return this._updateNode(new je(i))}if(this._match(p.tokens.int_literal)){const i=this._previous().toString();let r=i.endsWith("i")||i.endsWith("i")?k.i32:i.endsWith("u")||i.endsWith("U")?k.u32:k.x32;const s=parseInt(i);return this._validateTypeRange(s,r),this._updateNode(new Te(new v(s,this._exec.getTypeInfo(r)),r))}if(this._match(p.tokens.uint_literal)){const i=parseInt(this._previous().toString());return this._validateTypeRange(i,k.u32),this._updateNode(new Te(new v(i,this._exec.getTypeInfo(k.u32)),k.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let i=this._previous().toString(),r=i.endsWith("h");r&&(i=i.substring(0,i.length-1));const s=parseFloat(i);this._validateTypeRange(s,r?k.f16:k.f32);const o=r?k.f16:k.f32;return this._updateNode(new Te(new v(s,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let i=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new Te(new v(i?1:0,this._exec.getTypeInfo(k.bool)),k.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 i=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");const r=this._paren_expression();return this._updateNode(new Sl(i,r))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new ht(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;const e=[];do{if(this._check(p.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_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}_struct_decl(){if(!this._match(p.keywords.struct))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");const i=[];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 c=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=c),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new Il(a,l,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,s=this._updateNode(new St(t,i,e,r),e);return this._context.structs.set(t,s),s}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){const t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof Te){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof Te&&(e.type=e.value.type.name==="x32"?k.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 t=this._consume(p.tokens.name,"Expected variable name"),i=this._currentLine;let r=null;if(this._match(p.tokens.colon)){const c=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=c)}let s=null;this._consume(p.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let c=[k.f32],l=o.constEvaluate(this._exec,c);l instanceof v&&this._validateTypeRange(l.value,c[0]),c[0]instanceof T&&c[0].format===null&&l.typeInfo instanceof Wt&&l.typeInfo.format!==null&&(l.typeInfo.format.name==="f16"?c[0].format=k.f16:l.typeInfo.format.name==="f32"?c[0].format=k.f32:l.typeInfo.format.name==="i32"?c[0].format=k.i32:l.typeInfo.format.name==="u32"?c[0].format=k.u32:l.typeInfo.format.name==="bool"?c[0].format=k.bool:console.error(`TODO: impelement template format type ${l.typeInfo.format.name}`)),s=this._updateNode(new Te(l,c[0])),this._exec.context.setVariable(t.toString(),l)}catch{s=o}if(r!==null&&s instanceof Te){if(s.type.name!=="x32"&&r.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${r.name}. Line:${this._currentLine}`);s.type=r,s.isScalar&&this._validateTypeRange(s.scalarValue,s.type)}else r===null&&s instanceof Te&&(r=(e=s==null?void 0:s.type)!==null&&e!==void 0?e:k.f32,r===k.x32&&(r=k.i32));const a=this._updateNode(new Zi(t.toString(),r,"","",s),i);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;const e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name");let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}let r=null;if(this._match(p.tokens.equal)&&(r=this._const_expression()),i!==null&&r instanceof Te){if(r.type.name!=="x32"&&i.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${i.name}. Line:${this._currentLine}`);r.type=i}else i===null&&r instanceof Te&&(i=r.type.name==="x32"?k.i32:r.type);return r instanceof Te&&r.isScalar&&this._validateTypeRange(r.scalarValue,i),this._updateNode(new Yn(t.toString(),i,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));const r=this._consume(p.tokens.name,"Expected variable name");let s=null;if(this._match(p.tokens.colon)){const o=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=o)}return this._updateNode(new bt(r.toString(),s,t,i,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;const e=this._consume(p.tokens.name,"Expected variable name");let t=null;if(this._match(p.tokens.colon)){const i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}return this._updateNode(new Qs(e.toString(),t,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 t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new _l(e.toString(),t))}_enable_directive(){const e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new Ox(e.toString()))}_requires_directive(){const e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){const t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new Bx(e))}_type_alias(){const e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new Gs(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){const i=this._advance().toString();if(this._context.structs.has(i))return this._context.structs.get(i);if(this._context.aliases.has(i))return this._context.aliases.get(i).type;if(!this._getType(i)){const r=this._updateNode(new vl(i));return this._forwardTypeCount++,r}return this._updateNode(new k(i))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let i=this._advance().toString(),r=null,s=null;return this._match(p.tokens.less_than)&&(r=this._type_decl(),s=null,this._match(p.tokens.comma)&&(s=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new T(i,r,s))}if(this._match(p.keywords.ptr)){let i=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");const r=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");const s=this._type_decl();let o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new Qi(i,r.toString(),s,o))}const t=this._attribute();if(this._match(p.keywords.array)){let i=null,r=-1;const s=this._previous();let o=null;if(this._match(p.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let c="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{c=o.constEvaluate(this._exec).toString(),o=null}catch{c="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),r=c?parseInt(c):0}const a=this._updateNode(new jn(s.toString(),t,i,r));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Kn(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Kn(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 t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Kn(e.toString(),t,null))}if(this._match(p.storage_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");const i=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 Kn(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){const t=this._consume(p.attribute_name,"Expected attribute name"),i=this._updateNode(new Rl(t.toString(),null));if(this._match(p.tokens.paren_left)){if(i.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{const r=this._consume(p.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(r)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(i)}return e.length==0?null:e}}class Gx extends dt{constructor(e){super(),e&&this.update(e)}update(e){const t=new Jx().parse(e);this.updateAST(t)}}function ey(n){var s;const e={attributes:[],bindings:[]};let t;try{t=ty(n)}catch(o){return F.error(o.message)(),e}for(const o of t.uniforms){const a=[];for(const c of((s=o.type)==null?void 0:s.members)||[])a.push({name:c.name,type:Fl(c.type)});e.bindings.push({type:"uniform",name:o.name,group:o.group,location:o.binding,members:a})}for(const o of t.textures)e.bindings.push({type:"texture",name:o.name,group:o.group,location:o.binding});for(const o of t.samplers)e.bindings.push({type:"sampler",name:o.name,group:o.group,location:o.binding});const i=t.entry.vertex[0],r=(i==null?void 0:i.inputs.length)||0;for(let o=0;o<r;o++){const a=i.inputs[o];if(a.locationType==="location"){const c=Fl(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:c})}}return e}function Fl(n){return n!=null&&n.format?`${n.name}<${n.format.name}>`:n.name}function ty(n){try{return new Gx(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(t+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(t+=e.token.line||""),new Error(t,{cause:e})}}const ao={};function ir(n="id"){ao[n]=ao[n]||1;const e=ao[n]++;return`${n}-${e}`}class Dl{constructor(e){m(this,"id");m(this,"userData",{});m(this,"topology");m(this,"bufferLayout",[]);m(this,"vertexCount");m(this,"indices");m(this,"attributes");if(this.id=e.id||ir("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&z.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function ny(n,e){if(e instanceof Dl)return e;const t=iy(n,e),{attributes:i,bufferLayout:r}=ry(n,e);return new Dl({topology:e.topology||"triangle-list",bufferLayout:r,vertexCount:e.vertexCount,indices:t,attributes:i})}function iy(n,e){if(!e.indices)return;const t=e.indices.value;return n.createBuffer({usage:z.INDEX,data:t})}function ry(n,e){const t=[],i={};for(const[s,o]of Object.entries(e.attributes)){let a=s;switch(s){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){i[a]=n.createBuffer({data:o.value,id:`${s}-buffer`});const{value:c,size:l,normalized:u}=o;t.push({name:a,format:Dp(c,l,u)})}}const r=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:t,vertexCount:r}}const Er=class Er{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_hashCounter",0);m(this,"_hashes",{});m(this,"_renderPipelineCache",{});m(this,"_computePipelineCache",{});this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Er(e),e._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var o;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const t={...Lt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&F.warn(`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:ir("unnamed-cached")}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&F.warn(`${this}: ${s} created, count=${i[r].useCount}`)()),s}createComputePipeline(e){var o;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const t={...Oi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&F.warn(`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&F.warn(`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.debug&&F.warn(`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(F.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.debug&&F.warn(`${this}: ${e} released, count=${t[i].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Oi&&(t=this._computePipelineCache),e instanceof Lt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device,i=this._getHash(e.shader.source);return`${t}/C/${i}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r="-",s=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${i}V${r}BL${s}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${i}V${r}T${e.topology}P${a}BL${s}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};m(Er,"defaultProps",{...Lt.defaultProps});let co=Er;const kr=class kr{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_cache",{});this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(e){var t;return(t=e._lumaData).defaultShaderFactory||(t.defaultShaderFactory=new kr(e)),e._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let i=this._cache[t];if(i)i.useCount++,this.debug&&F.warn(`${this}: Reusing shader ${i.shader.id} count=${i.useCount}`)();else{const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:r,useCount:1},this.debug&&F.warn(`${this}: Created new shader ${r.id}`)()}return i.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],i.shader.destroy(),this.debug&&F.warn(`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&F.warn(`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};m(kr,"defaultProps",{...Mi.defaultProps});let lo=kr;function sy(n,e){var r;const t={},i="Values";if(n.attributes.length===0&&!((r=n.varyings)!=null&&r.length))return{"No attributes or varyings":{[i]:"N/A"}};for(const s of n.attributes)if(s){const o=`${s.location} ${s.name}: ${s.type}`;t[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(const s of n.varyings||[]){const o=`${s.location} ${s.name}`;t[`out ${o}`]={[i]:JSON.stringify(s)}}return t}let Ce=null,Xt=null;function oy(n,{id:e,minimap:t,opaque:i,top:r="0",left:s="0",rgbaScale:o=1}){Ce||(Ce=document.createElement("canvas"),Ce.id=e,Ce.title=e,Ce.style.zIndex="100",Ce.style.position="absolute",Ce.style.top=r,Ce.style.left=s,Ce.style.border="blue 5px solid",Ce.style.transform="scaleY(-1)",document.body.appendChild(Ce),Xt=Ce.getContext("2d")),(Ce.width!==n.width||Ce.height!==n.height)&&(Ce.width=n.width/2,Ce.height=n.height/2,Ce.style.width="400px",Ce.style.height="400px");const a=n.device.readPixelsToArrayWebGL(n),c=Xt==null?void 0:Xt.createImageData(n.width,n.height);if(c){for(let u=0;u<a.length;u+=4)c.data[0+u+0]=a[u+0]*o,c.data[0+u+1]=a[u+1]*o,c.data[0+u+2]=a[u+2]*o,c.data[0+u+3]=i?255:a[u+3]*o;Xt==null||Xt.putImageData(c,0,0)}}function uo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!uo(n[i],e[i],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof n=="object"&&typeof e=="object"){const i=Object.keys(n),r=Object.keys(e);if(i.length!==r.length)return!1;for(const s of i)if(!e.hasOwnProperty(s)||!uo(n[s],e[s],t-1))return!1;return!0}return!1}class fo{constructor(e){m(this,"bufferLayouts");this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?(t=e.attributes)==null?void 0:t.map(i=>i.attribute):[e.name]}mergeBufferLayouts(e,t){const i=[...e];for(const r of t){const s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}getBufferIndex(e){const t=this.bufferLayouts.findIndex(i=>i.name===e);return t===-1&&F.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function ay(n,e){const t=Object.fromEntries(n.attributes.map(r=>[r.name,r.location])),i=e.slice();return i.sort((r,s)=>{const o=r.attributes?r.attributes.map(u=>u.attribute):[r.name],a=s.attributes?s.attributes.map(u=>u.attribute):[s.name],c=Math.min(...o.map(u=>t[u])),l=Math.min(...a.map(u=>t[u]));return c-l}),i}function cy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function ly(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function uy(n){return cy(n)||ly(n)}function fy(n){return uy(n)||typeof n=="number"||typeof n=="boolean"}function hy(n){const e={bindings:{},uniforms:{}};return Object.keys(n).forEach(t=>{const i=n[t];fy(i)?e.uniforms[t]=i:e.bindings[t]=i}),e}class dy{constructor(e,t){m(this,"options",{disableWarnings:!1});m(this,"modules");m(this,"moduleUniforms");m(this,"moduleBindings");Object.assign(this.options,t);const i=$s(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;F.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,s]of Object.entries(e))this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&F.warn(`Module name: ${r} vs ${s.name}`)()}destroy(){}setProps(e){var t;for(const i of Object.keys(e)){const r=i,s=e[r]||{},o=this.modules[r];if(!o){this.options.disableWarnings||F.warn(`Module ${i} not found`)();continue}const a=this.moduleUniforms[r],c=this.moduleBindings[r],l=((t=o.getUniforms)==null?void 0:t.call(o,s,a))||s,{uniforms:u,bindings:f}=hy(l);this.moduleUniforms[r]={...a,...u},this.moduleBindings[r]={...c,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var t;const e={};for(const[i,r]of Object.entries(this.moduleUniforms))for(const[s,o]of Object.entries(r))e[`${i}.${s}`]={type:(t=this.modules[i].uniformTypes)==null?void 0:t[s],value:String(o)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}let py="";async function my(n,e){const t=new Image;return t.crossOrigin="anonymous",t.src=n.startsWith("http")?n:py+n,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}const gy=["+X","-X","+Y","-Y","+Z","-Z"],_y=["+X","-X","+Y","-Y","+Z","-Z"],Fr=class Fr{constructor(e,t){m(this,"device");m(this,"id");m(this,"props");m(this,"texture");m(this,"sampler");m(this,"view");m(this,"ready");m(this,"isReady",!1);m(this,"destroyed",!1);m(this,"resolveReady",()=>{});m(this,"rejectReady",()=>{});this.device=e;const i=ir("async-texture");this.props={...Fr.defaultProps,id:i,...t},this.id=this.props.id,t={...t},typeof(t==null?void 0:t.data)=="string"&&t.dimension==="2d"&&(t.data=my(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((r,s)=>{this.resolveReady=()=>{this.isReady=!0,r()},this.rejectReady=s}),this.initAsync(t)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,i=await Ml(t).then(void 0,this.rejectReady);if(this.destroyed)return;const r=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(i);if(!r)throw new Error("Texture size could not be determined");const s={...r,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(s.width,s.height);if(s.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,i);break;case"2d":this._setTexture2DData(i);break;case"3d":this._setTexture3DData(this.texture,i);break;case"2d-array":this._setTextureArrayData(this.texture,i);break;case"cube":this._setTextureCubeData(this.texture,i);break;case"cube-array":this._setTextureCubeArrayData(this.texture,i);break}this.props.mipmaps&&this.generateMipmaps(),F.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 on?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=e==null?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){const i=Object.values(e)[0];return{width:i.width,height:i.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const i=this._normalizeTextureData(e);i.length>1&&this.props.mipmaps!==!1&&F.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let r=0;r<i.length;r++){const s=i[r];this.device.isExternalImage(s)?this.texture.copyExternalImage({image:s,depth:t,mipLevel:r,flipY:!0}):this.texture.copyImageData({data:s.data,mipLevel:r})}}_setTexture3DData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="3d")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="cube")throw new Error(this.id);for(const[r,s]of Object.entries(t)){const o=_y.indexOf(r);this._setTexture2DData(s,o)}}_setTextureArrayData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="2d-array")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,i,r=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&F.warn(`${this.id} has mipmap and multiple LODs.`)();const s=gy.indexOf(i);this._setTexture2DData(t,s)}_normalizeTextureData(e){const t=this.texture;let i;return ArrayBuffer.isView(e)?i=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?i=e:i=[e],i}};m(Fr,"defaultProps",{...G.defaultProps,data:null,mipmaps:!1});let Zn=Fr;async function Ml(n){if(n=await n,Array.isArray(n))return await Promise.all(n.map(Ml));if(n&&typeof n=="object"&&n.constructor===Object){const e=n,t=await Promise.all(Object.values(e)),i=Object.keys(e),r={};for(let s=0;s<i.length;s++)r[i[s]]=t[s];return r}return n}const Yt=2,xy=1e4,Dr=class Dr{constructor(e,t){m(this,"device");m(this,"id");m(this,"source");m(this,"vs");m(this,"fs");m(this,"pipelineFactory");m(this,"shaderFactory");m(this,"userData",{});m(this,"parameters");m(this,"topology");m(this,"bufferLayout");m(this,"isInstanced");m(this,"instanceCount",0);m(this,"vertexCount");m(this,"indexBuffer",null);m(this,"bufferAttributes",{});m(this,"constantAttributes",{});m(this,"bindings",{});m(this,"vertexArray");m(this,"transformFeedback",null);m(this,"pipeline");m(this,"shaderInputs");m(this,"_uniformStore");m(this,"_attributeInfos",{});m(this,"_gpuGeometry",null);m(this,"props");m(this,"_pipelineNeedsUpdate","newly created");m(this,"_needsRedraw","initializing");m(this,"_destroyed",!1);m(this,"_lastDrawTimestamp",-1);m(this,"_lastLogTime",0);m(this,"_logOpen",!1);m(this,"_drawCount",0);var c,l,u,f;this.props={...Dr.defaultProps,...t},t=this.props,this.id=t.id||ir("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(((c=this.props.modules)==null?void 0:c.map(h=>[h.name,h]))||[]),r=t.shaderInputs||new dy(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(r);const s=vy(e),o=(((l=this.props.modules)==null?void 0:l.length)>0?this.props.modules:(u=this.shaderInputs)==null?void 0:u.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:h,getUniforms:d}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:s,...this.props,modules:o});this.source=h,this._getModuleUniforms=d,(f=this.props).shaderLayout||(f.shaderLayout=ey(this.source))}else{const{vs:h,fs:d,getUniforms:_}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:o});this.vs=h,this.fs=d,this._getModuleUniforms=_}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||co.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||lo.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return F.info(Yt,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const r=this._getBindings();this.pipeline.setBindings(r,{disableWarnings:this.props.disableWarnings});const{indexBuffer:s}=this.vertexArray,o=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;i=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),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var i;(i=this._gpuGeometry)==null||i.destroy();const t=e&&ny(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const r=new fo(this.bufferLayout);this.bufferLayout=r.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new fo(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){uo(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 ge(this.shaderInputs.modules);for(const[t,i]of Object.entries(this.shaderInputs.modules))if(yy(i)){const r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const i=(t==null?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&F.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=ay(this.pipeline.shaderLayout,this.bufferLayout);const r=new fo(this.bufferLayout);for(const[s,o]of Object.entries(e)){const a=r.getBufferLayout(s);if(!a){i||F.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const c=r.getAttributeNamesForBuffer(a);let l=!1;for(const u of c){const f=this._attributeInfos[u];if(f){const h=this.device.type==="webgpu"?r.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),l=!0}}!l&&!i&&F.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,r]of Object.entries(e)){const s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):((t==null?void 0:t.disableWarnings)??this.props.disableWarnings)||F.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Zn&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,i]of Object.entries(this.bindings))i instanceof Zn?i.isReady&&(e[t]=i.texture):e[t]=i;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof Di?e=Math.max(e,t.texture.updateTimestamp):t instanceof z||t instanceof G?e=Math.max(e,t.updateTimestamp):t instanceof Zn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof on||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(F.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let r=null;this.source?r=i:this.fs&&(r=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:i,fs:r}),this._attributeInfos=Ya(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=F.level>3?0:xy;F.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,F.group(Yt,`>>> DRAWING MODEL ${this.id}`,{collapsed:F.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=sy(this.pipeline.shaderLayout,this.id);F.table(Yt,e)();const t=this.shaderInputs.getDebugTable();F.table(Yt,t)();const i=this._getAttributeDebugTable();F.table(Yt,this._attributeInfos)(),F.table(Yt,i)(),F.groupEnd(Yt)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const i=e.props.framebuffer;i&&oy(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,i]of Object.entries(this._attributeInfos)){const r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){const i=Ba(t);return(e instanceof z?new i(e.debugData):e).toString()}};m(Dr,"defaultProps",{...Lt.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:Ys.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let le=Dr;function yy(n){return!!(n.uniformTypes&&!by(n.uniformTypes))}function vy(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}function by(n){for(const e in n)return!1;return!0}class Dt{constructor(e,t,i,r,s){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=t,this.store=i,this.data=r,s&&(this.points=s)}}const Sy=`#version 300 es
|
|
95
|
+
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}const t=p.simpleTokens[e];if(t)return this._addToken(t),!0;let i=p.none;const r=this._isAlpha(e),s=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(r){const o=p.keywords[e];if(o)return this._addToken(o),!0}if(r||s)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.indexOf(this._tokens[l].type)!=-1||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.indexOf(this._tokens[c].type)===-1;++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 f=0;f<u;++f)if(l+=this._peekAhead(f),o=this._findType(l),o!==p.none){c=f;break}if(o===p.none)return i!==p.none&&(this._current--,this._addToken(i),!0);e=l,this._current+=c+1}if(i=o,this._isAtEnd())break;e+=this._advance()}return i!==p.none&&(this._addToken(i),!0)}_findType(e){for(const i in p.regexTokens){const r=p.regexTokens[i];if(this._match(e,r.rule))return r}return p.literalTokens[e]||p.none}_match(e,t){const i=t.exec(e);return i&&i.index==0&&i[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&e!=="_"&&e!=="."&&e!=="("&&e!==")"&&e!=="["&&e!=="]"&&e!=="{"&&e!=="}"&&e!==","&&e!==";"&&e!==":"&&e!=="="&&e!=="!"&&e!=="<"&&e!==">"&&e!=="+"&&e!=="-"&&e!=="*"&&e!=="/"&&e!=="%"&&e!=="&"&&e!=="|"&&e!=="^"&&e!=="~"&&e!=="@"&&e!=="#"&&e!=="?"&&e!=="'"&&e!=="`"&&e!=='"'&&e!=="\\"&&e!==`
|
|
96
|
+
`&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Ec(e,t,this._line,this._start,this._current))}}function U(n){return Array.isArray(n)||(n==null?void 0:n.buffer)instanceof ArrayBuffer}const Gi=new Float32Array(1),Hx=new Uint32Array(Gi.buffer),Wx=new Uint32Array(Gi.buffer),er=new Int32Array(1),$x=new Float32Array(er.buffer),Xx=new Uint32Array(er.buffer),tr=new Uint32Array(1),Yx=new Float32Array(tr.buffer),qx=new Int32Array(tr.buffer);function kc(n,e,t){if(e===t)return n;if(e==="f32"){if(t==="i32"||t==="x32")return Gi[0]=n,Hx[0];if(t==="u32")return Gi[0]=n,Wx[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return er[0]=n,$x[0];if(t==="u32")return er[0]=n,Xx[0]}else if(e==="u32"){if(t==="f32")return tr[0]=n,Yx[0];if(t==="i32"||t==="x32")return tr[0]=n,qx[0]}return console.error(`Unsupported cast from ${e} to ${t}`),n}class jx{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class nr{constructor(e,t){this.align=e,this.size=t}}class dt{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Ex,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(const t of e)t instanceof Xn&&this._functions.set(t.name,new jx(t));for(const t of e)if(t instanceof St){const i=this.getTypeInfo(t,null);i instanceof Et&&this.structs.push(i)}for(const t of e)if(t instanceof Gs)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof Qs){const i=t,r=this._getAttributeNum(i.attributes,"id",0),s=i.type!=null?this.getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Px(i.name,s,i.attributes,r));continue}if(this._isUniformVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new qi(i.name,o,r,s,i.attributes,Dt.Uniform,i.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new qi(i.name,o,r,s,i.attributes,a?Dt.StorageTexture:Dt.Storage,i.access);l.access||(l.access="read"),this.storage.push(l);continue}if(this._isTextureVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new qi(i.name,o,r,s,i.attributes,a?Dt.StorageTexture:Dt.Texture,i.access);l.access||(l.access="read"),a?this.storage.push(l):this.textures.push(l);continue}if(this._isSamplerVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new qi(i.name,o,r,s,i.attributes,Dt.Sampler,i.access);this.samplers.push(a);continue}}for(const t of e)if(t instanceof Xn){const i=this._getAttribute(t,"vertex"),r=this._getAttribute(t,"fragment"),s=this._getAttribute(t,"compute"),o=i||r||s,a=new Rx(t.name,o==null?void 0:o.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(l=>new Ix(l.name,this.getTypeInfo(l.type,l.attributes),l.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(i=>{var r,s,o;if(i instanceof Rc){if(i.value)if(U(i.value))for(const a of i.value)for(const l of this.overrides)a===l.name&&((r=t.info)===null||r===void 0||r.overrides.push(l));else for(const a of this.overrides)i.value===a.name&&((s=t.info)===null||s===void 0||s.overrides.push(a))}else if(i instanceof je)for(const a of this.overrides)i.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const r of e.calls){const s=(i=this._functions.get(r.name))===null||i===void 0?void 0:i.info;s&&t.add(s)}}findResource(e,t,i){if(i){for(const r of this.entry.compute)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.vertex)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.fragment)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}}for(const r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(const r of this.storage)if(r.group==e&&r.binding==t)return r;for(const r of this.textures)if(r.group==e&&r.binding==t)return r;for(const r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],r=this,s=[];return e.search(o=>{if(o instanceof ji)s.push({});else if(o instanceof Ki)s.pop();else if(o instanceof bt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof ht){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Yn){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof je){const a=o;if(s.length>0&&s[s.length-1][a.name])return;const l=r._findResource(a.name);l&&i.push(l)}else if(o instanceof eo){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}else if(o instanceof Js){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}}),[...new Map(i.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function t(i,r){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),r>=e[i].length&&(e[i].length=r+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof St)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);i!==null&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof St)this._getStructOutputs(i.type,t);else{const r=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(r!==null){const s=this.getTypeInfo(i.type,i.type.attributes),o=this._parseInt(r.value),a=new rc(i.name,s,r.name,o);t.push(a)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new rc("",i,t.name,r)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(const i of e)if(i.type instanceof St)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof St)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),s=this._parseInt(t.value),o=new Cx(e.name,r,t.name,s);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Ax(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof Qi){const r=e.type?this.getTypeInfo(e.type,e.attributes):null,s=new qs(e.name,r,t);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof jn){const r=e,s=r.format?this.getTypeInfo(r.format,r.attributes):null,o=new kt(r.name,t);return o.format=s,o.count=r.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof St){const r=e,s=new Et(r.name,t);s.startLine=r.startLine,s.endLine=r.endLine;for(const o of r.members){const a=this.getTypeInfo(o.type,o.attributes);s.members.push(new ic(o.name,a,o.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Kn){const r=e,s=r.format instanceof k,o=r.format?s?this.getTypeInfo(r.format,null):new Ze(r.format,null):null,a=new Wt(r.name,o,t,r.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof T){const r=e,s=r.format?this.getTypeInfo(r.format,null):null,o=new Wt(r.name,s,t,r.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const i=new Ze(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,r;const s=this._getTypeSize(e);if(e.size=(t=s==null?void 0:s.size)!==null&&t!==void 0?t:0,e instanceof kt&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,(r=o==null?void 0:o.align)!==null&&r!==void 0?r:0),this._updateTypeInfo(e.format)}e instanceof qs&&this._updateTypeInfo(e.format),e instanceof Et&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,r=0,s=0,o=0;for(let a=0,l=e.members.length;a<l;++a){const c=e.members[a],u=this._getTypeSize(c);if(!u)continue;(t=this._getAlias(c.type.name))!==null&&t!==void 0||c.type;const f=u.align,h=u.size;i=this._roundUp(f,i+r),r=h,s=i,o=Math.max(o,f),c.offset=i,c.size=h,this._updateTypeInfo(c.type)}e.size=this._roundUp(o,s+r),e.align=o}_getTypeSize(e){var t,i;if(e==null)return null;const r=this._getAttributeNum(e.attributes,"size",0),s=this._getAttributeNum(e.attributes,"align",0);if(e instanceof ic&&(e=e.type),e instanceof Ze){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=dt._typeInfo[e.name];if(o!==void 0){const a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new nr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}{const o=dt._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new nr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}if(e instanceof kt){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((i=e==null?void 0:e.attributes)!==null&&i!==void 0?i:null,"stride",this._roundUp(a,l)),r&&(l=r),new nr(Math.max(s,a),Math.max(r,l))}if(e instanceof Et){let o=0,a=0,l=0,c=0,u=0;for(const f of e.members){const h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),l=this._roundUp(h.align,l+c),c=h.size,u=l)}return a=this._roundUp(o,u+c),new nr(Math.max(s,o),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof bt&&e.storage=="uniform"}_isStorageVar(e){return e instanceof bt&&e.storage=="storage"}_isTextureVar(e){return e instanceof bt&&e.type!==null&&dt._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof bt&&e.type!==null&&dt._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){const i=e;if(!i||!i.attributes)return null;const r=i.attributes;for(let s of r)if(s.name==t)return s;return null}_getAttributeNum(e,t,i){if(e===null)return i;for(let r of e)if(r.name==t){let s=r!==null&&r.value!==null?r.value:i;return s instanceof Array&&(s=s[0]),typeof s=="number"?s:typeof s=="string"?parseInt(s):i}return i}_roundUp(e,t){return Math.ceil(t/e)*e}}dt._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}},dt._textureTypes=p.any_texture_type.map(n=>n.name),dt._samplerTypes=p.sampler_type.map(n=>n.name);let no=0;class io{constructor(e,t,i){this.id=no++,this.name=e,this.value=t,this.node=i}clone(){return new io(this.name,this.value,this.node)}}class ro{constructor(e){this.id=no++,this.name=e.name,this.node=e}clone(){return new ro(this.node)}}class so{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=no++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new io(e,t,i??null))}setVariable(e,t,i){const r=this.getVariable(e);r!==null?r.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return(t=i==null?void 0:i.value)!==null&&t!==void 0?t:null}clone(){return new so(this)}}class Kx{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class Zx{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let r=!0;if(i instanceof g)return i.data.forEach(s=>{s||(r=!1)}),new v(r?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=i.data.some(s=>s);return new v(r?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof v))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.evalExpression(i,t);if(r instanceof xe&&r.typeInfo.size===0){const s=r.typeInfo,o=r.buffer.byteLength/s.stride;return new v(o,this.getTypeInfo("u32"))}return new v(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.abs(s)),i.typeInfo);const r=i;return new v(Math.abs(r.value),r.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acos(s)),i.typeInfo);const r=i;return new v(Math.acos(r.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acosh(s)),i.typeInfo);const r=i;return new v(Math.acosh(r.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asin(s)),i.typeInfo);const r=i;return new v(Math.asin(r.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asinh(s)),i.typeInfo);const r=i;return new v(Math.asinh(r.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atan(s)),i.typeInfo);const r=i;return new v(Math.atan(r.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atanh(s)),i.typeInfo);const r=i;return new v(Math.atanh(r.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.atan2(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.atan2(s.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.ceil(s)),i.typeInfo);const r=i;return new v(Math.ceil(r.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((c,u)=>this._clamp(c,r.data[u],s.data[u])),i.typeInfo);const o=i,a=r,l=s;return new v(this._clamp(o.value,a.value,l.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cos(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cosh(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.clz32(s)),i.typeInfo);const r=i;return new v(Math.clz32(r.value),i.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countOneBits(s)),i.typeInfo);const r=i;return new v(this._countOneBits(r.value),i.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countTrailingZeros(s)),i.typeInfo);const r=i;return new v(this._countTrailingZeros(r.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){if(i.data.length!==3||r.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const s=i.data,o=r.data;return new g([s[1]*o[2]-o[1]*s[2],s[2]*o[0]-o[2]*s[0],s[0]*o[1]-o[0]*s[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return i instanceof g?new g(i.data.map(s=>s*r),i.typeInfo):new v(i.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof K){const r=i.data,s=i.typeInfo.getTypeName(),o=s.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h")return new v(r[0]*r[3]-r[1]*r[2],o);if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);if(s==="mat2x4"||s==="mat2x4f"||s==="mat2x4h")console.error(`TODO: Determinant for ${s}`);else if(s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h")console.error(`TODO: Determinant for ${s}`);else{if(s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);s==="mat3x4"||s==="mat3x4f"||s==="mat3x4h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h"?console.error(`TODO: Determinant for ${s}`):s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h"||console.error(`TODO: Determinant for ${s}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){let a=0;for(let l=0;l<i.data.length;++l)a+=(i.data[l]-r.data[l])*(i.data[l]-r.data[l]);return new v(Math.sqrt(a),this.getTypeInfo("f32"))}const s=i,o=r;return new v(Math.abs(s.value-o.value),i.typeInfo)}_dot(e,t){let i=0;for(let r=0;r<e.length;++r)i+=t[r]*e[r];return i}Dot(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return i instanceof g&&r instanceof g?new v(this._dot(i.data,r.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.exp(s)),i.typeInfo);const r=i;return new v(Math.exp(r.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.pow(2,s)),i.typeInfo);const r=i;return new v(Math.pow(2,r.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=r.value,a=s.value;if(i instanceof g)return new g(i.data.map(c=>c>>o&(1<<a)-1),i.typeInfo);if(i.typeInfo.name!=="i32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;const l=i.value;return new v(l>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g){const o=this._dot(r.data,s.data);return new g(o<0?Array.from(i.data):i.data.map(a=>-a),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstLeadingBit(s)),i.typeInfo);const r=i;return new v(this._firstLeadingBit(r.value),i.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstTrailingBit(s)),i.typeInfo);const r=i;return new v(this._firstTrailingBit(r.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.floor(s)),i.typeInfo);const r=i;return new v(Math.floor(r.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return i.data.length!==r.data.length||i.data.length!==s.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new g(i.data.map((c,u)=>c*r.data[u]+s.data[u]),i.typeInfo);const o=i,a=r,l=s;return new v(o.value*a.value+l.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>s-Math.floor(s)),i.typeInfo);const r=i;return new v(r.value-Math.floor(r.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const a=s.value,l=(1<<o.value)-1<<a,c=~l;if(i instanceof g&&r instanceof g)return new g(i.data.map((h,d)=>h&c|r.data[d]<<a&l),i.typeInfo);const u=i.value,f=r.value;return new v(u&c|f<<a&l,i.typeInfo)}InverseSqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>1/Math.sqrt(s)),i.typeInfo);const r=i;return new v(1/Math.sqrt(r.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){let s=0;return i.data.forEach(o=>{s+=o*o}),new v(Math.sqrt(s),this.getTypeInfo("f32"))}const r=i;return new v(Math.abs(r.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log(s)),i.typeInfo);const r=i;return new v(Math.log(r.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log2(s)),i.typeInfo);const r=i;return new v(Math.log2(r.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.max(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.max(s.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.min(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.min(s.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((l,c)=>i.data[c]*(1-s.data[c])+r.data[c]*s.data[c]),i.typeInfo);const o=r,a=s;return new v(i.value*(1-a.value)+o.value*a.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((o,a)=>o%r.data[a]),i.typeInfo);const s=r;return new v(i.value%s.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=this.Length(e,t).value;return new g(i.data.map(s=>s/r),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.pow(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.pow(s.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r),i.typeInfo):new v(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r*Math.PI/180),i.typeInfo):new v(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){const s=this._dot(i.data,r.data);return new g(i.data.map((o,a)=>o-2*s*r.data[a]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof v){const o=this._dot(r.data,i.data);return new g(i.data.map((a,l)=>{const c=1-s.value*s.value*(1-o*o);if(c<0)return 0;const u=Math.sqrt(c);return s.value*a-(s.value*o+u)*r.data[l]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.round(s)),i.typeInfo);const r=i;return new v(Math.round(r.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.min(Math.max(s,0),1)),i.typeInfo);const r=i;return new v(Math.min(Math.max(r.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sign(s)),i.typeInfo);const r=i;return new v(Math.sign(r.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sin(s)),i.typeInfo);const r=i;return new v(Math.sin(r.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sinh(s)),i.typeInfo);const r=i;return new v(Math.sinh(r.value),i.typeInfo)}_smoothstep(e,t,i){const r=Math.min(Math.max((i-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(s instanceof g&&i instanceof g&&r instanceof g)return new g(s.data.map((c,u)=>this._smoothstep(i.data[u],r.data[u],c)),s.typeInfo);const o=i,a=r,l=s;return new v(this._smoothstep(o.value,a.value,l.value),s.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sqrt(s)),i.typeInfo);const r=i;return new v(Math.sqrt(r.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof g&&i instanceof g)return new g(r.data.map((o,a)=>o<i.data[a]?0:1),r.typeInfo);const s=i;return new v(r.value<s.value?0:1,s.typeInfo)}Tan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tan(s)),i.typeInfo);const r=i;return new v(Math.tan(r.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tanh(s)),i.typeInfo);const r=i;return new v(Math.tanh(r.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof K))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const r=this._getTransposeType(i.typeInfo);if(i.typeInfo.name==="mat2x2"||i.typeInfo.name==="mat2x2f"||i.typeInfo.name==="mat2x2h"){const s=i.data;return new K([s[0],s[2],s[1],s[3]],r)}if(i.typeInfo.name==="mat2x3"||i.typeInfo.name==="mat2x3f"||i.typeInfo.name==="mat2x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7]],r)}if(i.typeInfo.name==="mat2x4"||i.typeInfo.name==="mat2x4f"||i.typeInfo.name==="mat2x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13]],r)}if(i.typeInfo.name==="mat3x2"||i.typeInfo.name==="mat3x2f"||i.typeInfo.name==="mat3x2h"){const s=i.data;return new K([s[0],s[3],s[1],s[4],s[2],s[5]],r)}if(i.typeInfo.name==="mat3x3"||i.typeInfo.name==="mat3x3f"||i.typeInfo.name==="mat3x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7],s[2],s[5],s[8]],r)}if(i.typeInfo.name==="mat3x4"||i.typeInfo.name==="mat3x4f"||i.typeInfo.name==="mat3x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14]],r)}if(i.typeInfo.name==="mat4x2"||i.typeInfo.name==="mat4x2f"||i.typeInfo.name==="mat4x2h"){const s=i.data;return new K([s[0],s[4],s[1],s[5],s[2],s[6]],r)}if(i.typeInfo.name==="mat4x3"||i.typeInfo.name==="mat4x3f"||i.typeInfo.name==="mat4x3h"){const s=i.data;return new K([s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]],r)}if(i.typeInfo.name==="mat4x4"||i.typeInfo.name==="mat4x4f"||i.typeInfo.name==="mat4x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]],r)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.trunc(s)),i.typeInfo);const r=i;return new v(Math.trunc(r.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof je){const s=i.name,o=t.getVariableValue(s);if(o instanceof Tt){if(r<0||r>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const a=o.getMipLevelSize(r),l=o.dimension;return l==="1d"?new v(a[0],this.getTypeInfo("u32")):l==="3d"?new g(a,this.getTypeInfo("vec3u")):l==="2d"?new g(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${l} not found. Line ${e.line}`),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof je){const o=i.name,a=t.getVariableValue(o);if(a instanceof Tt){const l=Math.floor(r.data[0]),c=Math.floor(r.data[1]);if(l<0||l>=a.width||c<0||c>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const u=a.getPixel(l,c,0,s);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new g(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof je){const r=i.name,s=t.getVariableValue(r);return s instanceof Tt?new v(s.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof je){const a=i.name,l=t.getVariableValue(a);if(l instanceof Tt){const c=l.getMipLevelSize(0),u=Math.floor(r.data[0]),f=Math.floor(r.data[1]);return u<0||u>=c[0]||f<0||f>=c[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(l.setPixel(u,f,0,s,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t);return t.getVariable(r).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value+=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicSub(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value-=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMax(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.max(l.value,a.value)),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMin(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.min(l.value,a.value)),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicAnd(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value&a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicOr(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value|a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicXor(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value^a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicExchange(e,t){let i=e.args[0];i instanceof ve&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof xe&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const oo={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},ze={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class De extends Kx{constructor(e,t){var i;super(),this.ast=e??[],this.reflection=new dt,this.reflection.updateAST(this.ast),this.context=(i=t==null?void 0:t.clone())!==null&&i!==void 0?i:new so,this.builtins=new Zx(this),this.typeInfo={bool:this.getTypeInfo(k.bool),i32:this.getTypeInfo(k.i32),u32:this.getTypeInfo(k.u32),f32:this.getTypeInfo(k.f32),f16:this.getTypeInfo(k.f16),vec2f:this.getTypeInfo(T.vec2f),vec2u:this.getTypeInfo(T.vec2u),vec2i:this.getTypeInfo(T.vec2i),vec2h:this.getTypeInfo(T.vec2h),vec3f:this.getTypeInfo(T.vec3f),vec3u:this.getTypeInfo(T.vec3u),vec3i:this.getTypeInfo(T.vec3i),vec3h:this.getTypeInfo(T.vec3h),vec4f:this.getTypeInfo(T.vec4f),vec4u:this.getTypeInfo(T.vec4u),vec4i:this.getTypeInfo(T.vec4i),vec4h:this.getTypeInfo(T.vec4h),mat2x2f:this.getTypeInfo(T.mat2x2f),mat2x3f:this.getTypeInfo(T.mat2x3f),mat2x4f:this.getTypeInfo(T.mat2x4f),mat3x2f:this.getTypeInfo(T.mat3x2f),mat3x3f:this.getTypeInfo(T.mat3x3f),mat3x4f:this.getTypeInfo(T.mat3x4f),mat4x2f:this.getTypeInfo(T.mat4x2f),mat4x3f:this.getTypeInfo(T.mat4x3f),mat4x4f:this.getTypeInfo(T.mat4x4f)}}getVariableValue(e){var t,i;const r=(i=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&i!==void 0?i:null;if(r===null)return null;if(r instanceof v)return r.value;if(r instanceof g||r instanceof K)return Array.from(r.data);if(r instanceof xe&&r.typeInfo instanceof kt){if(r.typeInfo.format.name==="u32")return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="i32")return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="f32")return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,r){const s=this.context.clone();(r=r??{}).constants&&this._setOverrides(r.constants,s),this._execStatements(this.ast,s);const o=s.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const a=t[0],l=t[1],c=t[2],u=this.getTypeInfo("vec3u");s.setVariable("@num_workgroups",new g(t,u));const f=this.reflection.getFunctionInfo(e);f===null&&console.error(`Function ${e} not found in reflection data`);for(const h in i)for(const d in i[h]){const _=i[h][d];s.variables.forEach(I=>{var C;const w=I.node;if(w!=null&&w.attributes){let M=null,E=null;for(const x of w.attributes)x.name==="binding"?M=x.value:x.name==="group"&&(E=x.value);if(d==M&&h==E){let x=!1;for(const R of f.resources)if(R.name===I.name&&R.group===parseInt(h)&&R.binding===parseInt(d)){x=!0;break}if(x)if(_.texture!==void 0&&_.descriptor!==void 0){const R=new Tt(_.texture,this.getTypeInfo(w.type),_.descriptor,(C=_.texture.view)!==null&&C!==void 0?C:null);I.value=R}else _.uniform!==void 0?I.value=new xe(_.uniform,this.getTypeInfo(w.type)):I.value=new xe(_,this.getTypeInfo(w.type))}}})}for(let h=0;h<c;++h)for(let d=0;d<l;++d)for(let _=0;_<a;++_)s.setVariable("@workgroup_id",new g([_,d,h],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[_,d,h],s)}execStatement(e,t){if(e instanceof gc)return this.evalExpression(e.value,t);if(e instanceof xc){if(e.condition){const i=this.evalExpression(e.condition,t);if(!(i instanceof v))throw new Error("Invalid break-if condition");if(!i.value)return null}return De._breakObj}if(e instanceof yc)return De._continueObj;if(e instanceof Yn)this._let(e,t);else if(e instanceof bt)this._var(e,t);else if(e instanceof Zi)this._const(e,t);else if(e instanceof Xn)this._function(e,t);else{if(e instanceof mc)return this._if(e,t);if(e instanceof pc)return this._switch(e,t);if(e instanceof uc)return this._for(e,t);if(e instanceof cc)return this._while(e,t);if(e instanceof dc)return this._loop(e,t);if(e instanceof Zs){const i=t.clone();return i.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,i)}if(e instanceof hc)this._assign(e,t);else if(e instanceof fc)this._increment(e,t);else{if(e instanceof St)return null;if(e instanceof Qs){const i=e.name;t.getVariable(i)===null&&t.setVariable(i,new v(0,this.getTypeInfo("u32")))}else if(e instanceof Js)this._call(e,t);else{if(e instanceof _c||e instanceof Gs)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof st?this._evalBinaryOp(e,t):e instanceof Te?this._evalLiteral(e,t):e instanceof je?this._evalVariable(e,t):e instanceof eo?this._evalCall(e,t):e instanceof ht?this._evalCreate(e,t):e instanceof bc?this._evalConst(e,t):e instanceof Sc?this._evalBitcast(e,t):e instanceof ve?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof k){const r=this.reflection.getTypeInfo(e);if(r!==null)return r}let i=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return i!==null||(i=this.reflection.getTypeInfoByName(e)),i}_setOverrides(e,t){for(const i in e){const r=e[i],s=this.reflection.getOverrideInfo(i);s!==null?(s.type===null&&(s.type=this.getTypeInfo("u32")),s.type.name==="u32"||s.type.name==="i32"||s.type.name==="f32"||s.type.name==="f16"?t.setVariable(i,new v(r,s.type)):s.type.name==="bool"?t.setVariable(i,new v(r?1:0,s.type)):s.type.name==="vec2"||s.type.name==="vec3"||s.type.name==="vec4"||s.type.name==="vec2f"||s.type.name==="vec3f"||s.type.name==="vec4f"||s.type.name==="vec2i"||s.type.name==="vec3i"||s.type.name==="vec4i"||s.type.name==="vec2u"||s.type.name==="vec3u"||s.type.name==="vec4u"||s.type.name==="vec2h"||s.type.name==="vec3h"||s.type.name==="vec4h"?t.setVariable(i,new g(r,s.type)):console.error(`Invalid constant type for ${i}`)):console.error(`Override ${i} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,i){const r=[1,1,1];for(const u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){const f=i.getVariableValue(u.value[0]);r[0]=f instanceof v?f.value:parseInt(u.value[0])}if(u.value.length>1){const f=i.getVariableValue(u.value[1]);r[1]=f instanceof v?f.value:parseInt(u.value[1])}if(u.value.length>2){const f=i.getVariableValue(u.value[2]);r[2]=f instanceof v?f.value:parseInt(u.value[2])}}const s=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new g(r,s));const a=r[0],l=r[1],c=r[2];for(let u=0,f=0;u<c;++u)for(let h=0;h<l;++h)for(let d=0;d<a;++d,++f){const _=[d,h,u],I=[d+t[0]*r[0],h+t[1]*r[1],u+t[2]*r[2]];i.setVariable("@local_invocation_id",new g(_,s)),i.setVariable("@global_invocation_id",new g(I,s)),i.setVariable("@local_invocation_index",new v(f,o)),this._dispatchExec(e,i)}}_dispatchExec(e,t){for(const i of e.node.args)for(const r of i.attributes)if(r.name==="builtin"){const s=`@${r.value}`,o=t.getVariable(s);o!==void 0&&t.variables.set(i.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof ve;)e=e.right;return e instanceof je?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(const i of e){if(i instanceof Array){const s=t.clone(),o=this._execStatements(i,s);if(o)return o;continue}const r=this.execStatement(i,t);if(r)return r}return null}_call(e,t){const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(r){for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.setVariable(o.name,a,o)}this._execStatements(r.node.body,i)}else e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const i=this.getVariableName(e.variable,t),r=t.getVariable(i);r?e.operator==="++"?r.value instanceof v?r.value.value++:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):e.operator==="--"?r.value instanceof v?r.value.value--:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${i} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof je){const i=this.getVariableName(e,t),r=t.getVariable(i);return r===null?(console.error(`Variable ${i} not found. Line ${e.line}`),null):r.value.getSubData(this,e.postfix,t)}if(e instanceof ve){if(e.operator==="*"){const i=this._getVariableData(e.right,t);return i instanceof pn?i.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const i=this._getVariableData(e.right,t);return new pn(i)}}return null}_assign(e,t){let i=null,r="<var>",s=null;if(e.variable instanceof ve){const l=this._getVariableData(e.variable,t),c=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(l instanceof v||l instanceof g||l instanceof K){if(c instanceof v||c instanceof g||c instanceof K&&l.data.length===c.data.length)return void l.data.set(c.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(l instanceof xe&&c instanceof xe&&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 v||l instanceof g||l instanceof K?c instanceof v||c instanceof g||c instanceof K?void l.data.set(c.data.map((f,h)=>l.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(l instanceof v||l instanceof g||l instanceof K)&&(c instanceof v||c instanceof g||c instanceof K)?void l.data.set(c.data.map((f,h)=>l.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof ve){if(e.variable.operator==="*"){r=this.getVariableName(e.variable.right,t);const l=t.getVariable(r);if(!(l&&l.value instanceof pn))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);i=l.value.reference;let c=e.variable.postfix;if(!c){let u=e.variable.right;for(;u instanceof ve;){if(u.postfix){c=u.postfix;break}u=u.right}}c&&(i=i.getSubData(this,c,t))}}else{s=e.variable.postfix,r=this.getVariableName(e.variable,t);const l=t.getVariable(r);if(l===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);i=l.value}if(i instanceof pn&&(i=i.reference),i===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),a=e.operator;if(a!=="="){const l=i.getSubData(this,s,t);if(l instanceof g&&o instanceof v){const c=l.data,u=o.value;if(a==="+=")for(let f=0;f<c.length;++f)c[f]+=u;else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u;else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u;else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u;else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u;else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u;else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u;else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u;else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u;else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(l instanceof g&&o instanceof g){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 f=0;f<c.length;++f)c[f]+=u[f];else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u[f];else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u[f];else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u[f];else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u[f];else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u[f];else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u[f];else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u[f];else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u[f];else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(l instanceof v&&o instanceof v))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(i instanceof xe&&i.setDataValue(this,l,s,t))}if(i instanceof xe)i.setDataValue(this,o,s,t);else if(s){if(!(i instanceof g||i instanceof K))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(s instanceof dn){const l=this.evalExpression(s.index,t).value;if(i instanceof g){if(!(o instanceof v))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[l]=o.value}else{if(!(i instanceof K))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const c=this.evalExpression(s.index,t).value;if(c<0)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const u=i.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(c<2&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.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 ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.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 ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.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 ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.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 ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.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 ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.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 ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.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 ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(c<4&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}}}}}else if(s instanceof $t){const l=s.value;if(!(i instanceof g))return void console.error(`Invalid assignment to ${l}. Variable ${r} is not a vector. Line ${e.line}`);if(o instanceof v){if(l.length>1)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);if(l==="x")i.data[0]=o.value;else if(l==="y"){if(i.data.length<2)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[1]=o.value}else if(l==="z"){if(i.data.length<3)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[2]=o.value}else if(l==="w"){if(i.data.length<4)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(l.length!==o.data.length)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);for(let c=0;c<l.length;++c){const u=l[c];if(u==="x"||u==="r")i.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 ${r}. Line ${e.line}`);i.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 ${r}. Line ${e.line}`);i.data[2]=o.data[c]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[3]=o.data[c]}}}}}else i instanceof v&&o instanceof v?i.value=o.value:i instanceof g&&o instanceof g||i instanceof K&&o instanceof K?i.data.set(o.data):console.error(`Invalid assignment to ${r}. Line ${e.line}`)}_function(e,t){const i=new ro(e);t.functions.set(e.name,i)}_const(e,t){let i=null;e.value!==null&&(i=this.evalExpression(e.value,t)),t.createVariable(e.name,i,e)}_let(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ve||(i=i.clone())}else{const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||r==="array"){const s=new ht(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_var(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ve||(i=i.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||e.type instanceof jn||e.type instanceof St||e.type instanceof T){const s=new ht(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_switch(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;let r=null;for(const s of e.cases)if(s instanceof Ac)for(const o of s.selectors){if(o instanceof Ji){r=s;continue}const a=this.evalExpression(o,t);if(!(a instanceof v))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===i.value)return this._execStatements(s.body,t)}else s instanceof Cc&&(r=s);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(e.body,t);for(const r of e.elseif){const s=this.evalExpression(r.condition,t);if(!(s instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(s.value)return this._execStatements(r.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof v?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===De._breakObj)break;if(i!==null&&i!==De._continueObj)return i;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const i=this._execStatements(e.body,t);if(i===De._breakObj)break;if(i===De._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===De._breakObj)break}else if(i!==null)return i}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===De._breakObj)break;if(i!==De._continueObj&&i!==null)return i}return null}_evalBitcast(e,t){const i=this.evalExpression(e.value,t),r=e.type;if(i instanceof v){const s=kc(i.value,i.typeInfo.name,r.name);return new v(s,this.getTypeInfo(r))}if(i instanceof g){const s=i.typeInfo.getTypeName();let o="";if(s.endsWith("f"))o="f32";else if(s.endsWith("i"))o="i32";else if(s.endsWith("u"))o="u32";else if(s.endsWith("b"))o="bool";else{if(!s.endsWith("h"))return console.error(`Unknown vector type ${s}. Line ${e.line}`),null;o="f16"}const a=r.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,f,h){if(f===h)return u;const d=new Array(u.length);for(let _=0;_<u.length;_++)d[_]=kc(u[_],f,h);return d}(Array.from(i.data),o,l);return new g(c,this.getTypeInfo(r))}return console.error(`TODO: bitcast for ${i.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var i;if(e instanceof ht){if(e.type===null)return to.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}const r=e instanceof ht?e.type.name:e.name,s=e instanceof ht?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(s===null)return console.error(`Unknown type ${r}. Line ${e.line}`),null;if(s.size===0)return null;const o=new xe(new ArrayBuffer(s.size),s,0);if(s instanceof Et){if(e.args)for(let a=0;a<e.args.length;++a){const l=s.members[a],c=e.args[a],u=this.evalExpression(c,t);o.setData(this,u,l.type,l.offset,t)}}else if(s instanceof kt){let a=0;if(e.args)for(let l=0;l<e.args.length;++l){const c=e.args[l],u=this.evalExpression(c,t);s.format===null&&(((i=u.typeInfo)===null||i===void 0?void 0:i.name)==="x32"?s.format=this.getTypeInfo("i32"):s.format=u.typeInfo),o.setData(this,u,s.format,a,t),a+=s.stride}}else console.error(`Unknown type "${r}". Line ${e.line}`);return e instanceof ht?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){const i=this.getTypeInfo(e.type),r=i.name;return r==="x32"||r==="u32"||r==="f32"||r==="f16"||r==="i32"||r==="bool"?new v(e.scalarValue,i):r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"?this._callConstructorVec(e,t):r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const i=t.getVariableValue(e.name);return i===null?i:i.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=De._priority.get(t.name);De._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const i=this.evalExpression(e.right,t);if(e.operator==="&")return new pn(i);if(e.operator==="*")return i instanceof pn?i.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);const r=i instanceof v?i.value:i instanceof g?Array.from(i.data):null;switch(e.operator){case"+":{if(U(r)){const a=r.map((l,c)=>+l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(+s,o)}case"-":{if(U(r)){const a=r.map((l,c)=>-l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(-s,o)}case"!":{if(U(r)){const a=r.map((l,c)=>l?0:1);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(s?0:1,o)}case"~":{if(U(r)){const a=r.map((l,c)=>~l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(~s,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),s=i instanceof v?i.value:i instanceof g||i instanceof K?Array.from(i.data):null,o=r instanceof v?r.value:r instanceof g||r instanceof K?Array.from(r.data):null;switch(e.operator){case"+":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d+f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h+u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u+h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a+l,c)}case"-":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d-f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h-u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u-h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a-l,c)}case"*":{if(U(s)&&U(o)){const u=s,f=o;if(i instanceof K&&r instanceof K){const h=function(C,w,M,E){if(ze[w.name]===void 0||ze[E.name]===void 0)return null;const x=ze[w.name][0],R=ze[w.name][1],O=ze[E.name][0];if(x!==ze[E.name][1])return null;const L=new Array(O*R);for(let W=0;W<R;W++)for(let q=0;q<O;q++){let Q=0;for(let B=0;B<x;B++)Q+=C[B*R+W]*M[q*x+B];L[W*O+q]=Q}return L}(u,i.typeInfo,f,r.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const d=ze[r.typeInfo.name][0],_=ze[i.typeInfo.name][1],I=this.getTypeInfo(`mat${d}x${_}f`);return new K(h,I)}if(i instanceof K&&r instanceof g){const h=function(d,_,I,C){if(ze[_.name]===void 0||oo[C.name]===void 0)return null;const w=ze[_.name][0],M=ze[_.name][1];if(w!==I.length)return null;const E=new Array(M);for(let x=0;x<M;x++){let R=0;for(let O=0;O<w;O++)R+=d[O*M+x]*I[O];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,r.typeInfo)}if(i instanceof g&&r instanceof K){const h=function(d,_,I,C){if(oo[_.name]===void 0||ze[C.name]===void 0)return null;const w=ze[C.name][0],M=ze[C.name][1];if(M!==d.length)return null;const E=[];for(let x=0;x<w;x++){let R=0;for(let O=0;O<M;O++)R+=d[O]*I[O*w+x];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,i.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d*f[_]);return new g(h,i.typeInfo)}}if(U(s)){const u=o,f=s.map((h,d)=>h*u);return i instanceof K?new K(f,i.typeInfo):new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u*h);return r instanceof K?new K(f,r.typeInfo):new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a*l,c)}case"%":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d%f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h%u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u%h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a%l,c)}case"/":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d/f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h/u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u/h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a/l,c)}case"&":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d&f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h&u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u&h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a&l,c)}case"|":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d|f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h|u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u|h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a|l,c)}case"^":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d^f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h^u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u^h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a^l,c)}case"<<":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d<<f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h<<u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u<<h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a<<l,c)}case">>":{if(U(s)&&U(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d>>f[_]);return new g(h,i.typeInfo)}if(U(s)){const u=o,f=s.map((h,d)=>h>>u);return new g(f,i.typeInfo)}if(U(o)){const u=s,f=o.map((h,d)=>u>>h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a>>l,c)}case">":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c>a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a>c?1:0);return new g(l,r.typeInfo)}return new v(s>o?1:0,this.getTypeInfo("bool"));case"<":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c<a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a<c?1:0);return new g(l,r.typeInfo)}return new v(s<o?1:0,this.getTypeInfo("bool"));case"==":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u===l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c==a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a==c?1:0);return new g(l,r.typeInfo)}return new v(s===o?1:0,this.getTypeInfo("bool"));case"!=":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u!==l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c!==a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a!==c?1:0);return new g(l,r.typeInfo)}return new v(s!==o?1:0,this.getTypeInfo("bool"));case">=":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>=l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c>=a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a>=c?1:0);return new g(l,r.typeInfo)}return new v(s>=o?1:0,this.getTypeInfo("bool"));case"<=":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<=l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c<=a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a<=c?1:0);return new g(l,r.typeInfo)}return new v(s<=o?1:0,this.getTypeInfo("bool"));case"&&":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u&&l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c&&a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a&&c?1:0);return new g(l,r.typeInfo)}return new v(s&&o?1:0,this.getTypeInfo("bool"));case"||":if(U(s)&&U(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u||l[f]?1:0);return new g(c,i.typeInfo)}if(U(s)){const a=o,l=s.map((c,u)=>c||a?1:0);return new g(l,i.typeInfo)}if(U(o)){const a=s,l=o.map((c,u)=>a||c?1:0);return new g(l,r.typeInfo)}return new v(s||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.createVariable(o.name,a,o)}return this._execStatements(r.node.body,i)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const i=t.getFunction(e.name);if(i){const r=t.clone();for(let s=0;s<i.node.args.length;++s){const o=i.node.args[s],a=this.evalExpression(e.args[s],r);r.setVariable(o.name,a,o)}return this._execStatements(i.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new v(0,this.getTypeInfo(e.type));const i=this.evalExpression(e.args[0],t);return i.typeInfo=this.getTypeInfo(e.type),i.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=oo[r];if(s===void 0)return console.error(`Invalid vec constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Te)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);if(l instanceof g){const c=l.data;for(let u=0;u<c.length;++u){let f=c[u];o.push(f)}}else if(l instanceof v){let c=l.value;o.push(c)}}if(e.type instanceof T&&e.type.format===null&&(e.type.format=T.f32),o.length===0){const a=new Array(s).fill(0);return new g(a,i).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<s;)o.push(o[0]);return o.length<s?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new g(o.length>s?o.slice(0,s):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=ze[r];if(s===void 0)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Te)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);l instanceof g?o.push(...l.data):l instanceof v?o.push(l.value):l instanceof K&&o.push(...l.data)}if(i instanceof Wt&&i.format===null&&(i.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(s[2]).fill(0);return new K(a,i).getSubData(this,e.postfix,t)}return o.length!==s[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new K(o,i).getSubData(this,e.postfix,t)}}De._breakObj=new Je(new Ze("BREAK",null),null),De._continueObj=new Je(new Ze("CONTINUE",null),null),De._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class Qx{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class Jx{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new Qx,this._exec=new De,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const i=this._global_decl_or_directive();if(!i)break;t.push(i)}if(this._deferArrayCountEval.length>0){for(const i of this._deferArrayCountEval){const r=i.arrayType,s=i.countNode;if(s instanceof je){const o=s.name,a=this._context.constants.get(o);if(a)try{const l=a.constEvaluate(this._exec);r.count=l}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const i of t)i.search(r=>{r instanceof Ic||r instanceof Qi?r.type=this._forwardType(r.type):r instanceof jn?r.format=this._forwardType(r.format):r instanceof bt||r instanceof Yn||r instanceof Zi?r.type=this._forwardType(r.type):r instanceof Xn?r.returnType=this._forwardType(r.returnType):r instanceof Pc&&(r.type=this._forwardType(r.type))});return t}_forwardType(e){if(e instanceof vc){const t=this._getType(e.name);if(t)return t}else e instanceof Qi?e.type=this._forwardType(e.type):e instanceof jn&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const t=new Vx(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof S)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t<i;++t){const r=e[t];if(this._check(r))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const i=t.type;let r=!1;for(const s of e){if(i===s)return!0;s===p.tokens.name&&(r=!0)}if(r){const s=p.tokens.name.rule.exec(t.lexeme);if(s&&s.index==0&&s[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){const i=p.tokens.name.rule.exec(t.lexeme);return i&&i.index==0&&i[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){const t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){const t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){const t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){const t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}const e=this._attribute();if(this._check(p.keywords.var)){const t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){const t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){const t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){const t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){const t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){const t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");const i=[];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,i.push(this._updateNode(new Pc(l,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(p.tokens.arrow)){const a=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=a)}const s=this._compound_statement(),o=this._currentLine;return this._updateNode(new Xn(t,i,r,s,e,o),e)}_compound_statement(){const e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){const t=this._statement();t!==null&&e.push(t)}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 Ux);else if(this._match(p.keywords.break)){const t=this._updateNode(new xc);if(this._currentLoop.length>0){const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){const t=this._updateNode(new yc);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t}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,t=this._optional_paren_expression();return this._updateNode(new Nx(t),e)}_while_statement(){if(!this._match(p.keywords.while))return null;const e=this._updateNode(new cc(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 t=this._currentLine,i=this._compound_statement();return this._updateNode(new Zs(i,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");const e=this._updateNode(new uc(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 t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new bt(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new Yn(t,i,null,null,r),e)}if(this._match(p.keywords.const)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return i===null&&r instanceof Te&&(i=r.type),this._updateNode(new Zi(t,i,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;const i=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new fc(i.type===p.tokens.plus_plus?hn.increment:hn.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let i=this._match(p.tokens.underscore);if(i||(e=this._unary_expression()),!i&&e==null)return null;const r=this._consume(p.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return this._updateNode(new hc(qn.parse(r.lexeme),e,s),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume(p.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=t,null):this._updateNode(new Js(i.lexeme,r),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 dc([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof Zs){e.continuing=t;break}t=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 pc(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 t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){const i=this._case_selectors();for(const s of i)if(s instanceof Ji){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!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 r=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Ac(i,r)))}if(this._match(p.keywords.default)){if(t)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 i=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Cc(i)))}}return e}_case_selectors(){const e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new Ji)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new Ji)):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[];e instanceof Array||(e=[e]);const t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();const i=this._compound_statement();let r=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let s=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),s=this._compound_statement()),this._updateNode(new mc(t,i,r,s),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)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new zx(t,i))),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 gc(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 st(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 ve(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new dn(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match(p.tokens.period)){const e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new $t(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return k.void;case"bool":return k.bool;case"i32":return k.i32;case"u32":return k.u32;case"f32":return k.f32;case"f16":return k.f16;case"vec2f":return T.vec2f;case"vec3f":return T.vec3f;case"vec4f":return T.vec4f;case"vec2i":return T.vec2i;case"vec3i":return T.vec3i;case"vec4i":return T.vec4i;case"vec2u":return T.vec2u;case"vec3u":return T.vec3u;case"vec4u":return T.vec4u;case"vec2h":return T.vec2h;case"vec3h":return T.vec3h;case"vec4h":return T.vec4h;case"mat2x2f":return T.mat2x2f;case"mat2x3f":return T.mat2x3f;case"mat2x4f":return T.mat2x4f;case"mat3x2f":return T.mat3x2f;case"mat3x3f":return T.mat3x3f;case"mat3x4f":return T.mat3x4f;case"mat4x2f":return T.mat4x2f;case"mat4x3f":return T.mat4x3f;case"mat4x4f":return T.mat4x4f;case"mat2x2h":return T.mat2x2h;case"mat2x3h":return T.mat2x3h;case"mat2x4h":return T.mat2x4h;case"mat3x2h":return T.mat3x2h;case"mat3x3h":return T.mat3x3h;case"mat3x4h":return T.mat3x4h;case"mat4x2h":return T.mat4x2h;case"mat4x3h":return T.mat4x3h;case"mat4x4h":return T.mat4x4h;case"mat2x2i":return T.mat2x2i;case"mat2x3i":return T.mat2x3i;case"mat2x4i":return T.mat2x4i;case"mat3x2i":return T.mat3x2i;case"mat3x3i":return T.mat3x3i;case"mat3x4i":return T.mat3x4i;case"mat4x2i":return T.mat4x2i;case"mat4x3i":return T.mat4x3i;case"mat4x4i":return T.mat4x4i;case"mat2x2u":return T.mat2x2u;case"mat2x3u":return T.mat2x3u;case"mat2x4u":return T.mat2x4u;case"mat3x2u":return T.mat3x2u;case"mat3x3u":return T.mat3x3u;case"mat3x4u":return T.mat3x4u;case"mat4x2u":return T.mat4x2u;case"mat4x3u":return T.mat4x3u;case"mat4x4u":return T.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){const i=this._previous().toString();if(this._check(p.tokens.paren_left)){const r=this._argument_expression_list(),s=this._getType(i);return s!==null?this._updateNode(new ht(s,r)):this._updateNode(new eo(i,r))}if(this._context.constants.has(i)){const r=this._context.constants.get(i);return this._updateNode(new bc(i,r.value))}return this._updateNode(new je(i))}if(this._match(p.tokens.int_literal)){const i=this._previous().toString();let r=i.endsWith("i")||i.endsWith("i")?k.i32:i.endsWith("u")||i.endsWith("U")?k.u32:k.x32;const s=parseInt(i);return this._validateTypeRange(s,r),this._updateNode(new Te(new v(s,this._exec.getTypeInfo(r)),r))}if(this._match(p.tokens.uint_literal)){const i=parseInt(this._previous().toString());return this._validateTypeRange(i,k.u32),this._updateNode(new Te(new v(i,this._exec.getTypeInfo(k.u32)),k.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let i=this._previous().toString(),r=i.endsWith("h");r&&(i=i.substring(0,i.length-1));const s=parseFloat(i);this._validateTypeRange(s,r?k.f16:k.f32);const o=r?k.f16:k.f32;return this._updateNode(new Te(new v(s,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let i=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new Te(new v(i?1:0,this._exec.getTypeInfo(k.bool)),k.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 i=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");const r=this._paren_expression();return this._updateNode(new Sc(i,r))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new ht(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;const e=[];do{if(this._check(p.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_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}_struct_decl(){if(!this._match(p.keywords.struct))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");const i=[];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."),i.push(this._updateNode(new Ic(a,c,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,s=this._updateNode(new St(t,i,e,r),e);return this._context.structs.set(t,s),s}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){const t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof Te){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof Te&&(e.type=e.value.type.name==="x32"?k.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 t=this._consume(p.tokens.name,"Expected variable name"),i=this._currentLine;let r=null;if(this._match(p.tokens.colon)){const l=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=l)}let s=null;this._consume(p.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let l=[k.f32],c=o.constEvaluate(this._exec,l);c instanceof v&&this._validateTypeRange(c.value,l[0]),l[0]instanceof T&&l[0].format===null&&c.typeInfo instanceof Wt&&c.typeInfo.format!==null&&(c.typeInfo.format.name==="f16"?l[0].format=k.f16:c.typeInfo.format.name==="f32"?l[0].format=k.f32:c.typeInfo.format.name==="i32"?l[0].format=k.i32:c.typeInfo.format.name==="u32"?l[0].format=k.u32:c.typeInfo.format.name==="bool"?l[0].format=k.bool:console.error(`TODO: impelement template format type ${c.typeInfo.format.name}`)),s=this._updateNode(new Te(c,l[0])),this._exec.context.setVariable(t.toString(),c)}catch{s=o}if(r!==null&&s instanceof Te){if(s.type.name!=="x32"&&r.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${r.name}. Line:${this._currentLine}`);s.type=r,s.isScalar&&this._validateTypeRange(s.scalarValue,s.type)}else r===null&&s instanceof Te&&(r=(e=s==null?void 0:s.type)!==null&&e!==void 0?e:k.f32,r===k.x32&&(r=k.i32));const a=this._updateNode(new Zi(t.toString(),r,"","",s),i);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;const e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name");let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}let r=null;if(this._match(p.tokens.equal)&&(r=this._const_expression()),i!==null&&r instanceof Te){if(r.type.name!=="x32"&&i.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${i.name}. Line:${this._currentLine}`);r.type=i}else i===null&&r instanceof Te&&(i=r.type.name==="x32"?k.i32:r.type);return r instanceof Te&&r.isScalar&&this._validateTypeRange(r.scalarValue,i),this._updateNode(new Yn(t.toString(),i,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));const r=this._consume(p.tokens.name,"Expected variable name");let s=null;if(this._match(p.tokens.colon)){const o=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=o)}return this._updateNode(new bt(r.toString(),s,t,i,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;const e=this._consume(p.tokens.name,"Expected variable name");let t=null;if(this._match(p.tokens.colon)){const i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}return this._updateNode(new Qs(e.toString(),t,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 t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new _c(e.toString(),t))}_enable_directive(){const e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new Ox(e.toString()))}_requires_directive(){const e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){const t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new Bx(e))}_type_alias(){const e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new Gs(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){const i=this._advance().toString();if(this._context.structs.has(i))return this._context.structs.get(i);if(this._context.aliases.has(i))return this._context.aliases.get(i).type;if(!this._getType(i)){const r=this._updateNode(new vc(i));return this._forwardTypeCount++,r}return this._updateNode(new k(i))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let i=this._advance().toString(),r=null,s=null;return this._match(p.tokens.less_than)&&(r=this._type_decl(),s=null,this._match(p.tokens.comma)&&(s=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new T(i,r,s))}if(this._match(p.keywords.ptr)){let i=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");const r=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");const s=this._type_decl();let o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new Qi(i,r.toString(),s,o))}const t=this._attribute();if(this._match(p.keywords.array)){let i=null,r=-1;const s=this._previous();let o=null;if(this._match(p.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let l="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{l=o.constEvaluate(this._exec).toString(),o=null}catch{l="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),r=l?parseInt(l):0}const a=this._updateNode(new jn(s.toString(),t,i,r));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Kn(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Kn(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 t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Kn(e.toString(),t,null))}if(this._match(p.storage_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");const i=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 Kn(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){const t=this._consume(p.attribute_name,"Expected attribute name"),i=this._updateNode(new Rc(t.toString(),null));if(this._match(p.tokens.paren_left)){if(i.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{const r=this._consume(p.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(r)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(i)}return e.length==0?null:e}}class Gx extends dt{constructor(e){super(),e&&this.update(e)}update(e){const t=new Jx().parse(e);this.updateAST(t)}}function ey(n){var s;const e={attributes:[],bindings:[]};let t;try{t=ty(n)}catch(o){return D.error(o.message)(),e}for(const o of t.uniforms){const a=[];for(const l of((s=o.type)==null?void 0:s.members)||[])a.push({name:l.name,type:Dc(l.type)});e.bindings.push({type:"uniform",name:o.name,group:o.group,location:o.binding,members:a})}for(const o of t.textures)e.bindings.push({type:"texture",name:o.name,group:o.group,location:o.binding});for(const o of t.samplers)e.bindings.push({type:"sampler",name:o.name,group:o.group,location:o.binding});const i=t.entry.vertex[0],r=(i==null?void 0:i.inputs.length)||0;for(let o=0;o<r;o++){const a=i.inputs[o];if(a.locationType==="location"){const l=Dc(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:l})}}return e}function Dc(n){return n!=null&&n.format?`${n.name}<${n.format.name}>`:n.name}function ty(n){try{return new Gx(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(t+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(t+=e.token.line||""),new Error(t,{cause:e})}}const ao={};function ir(n="id"){ao[n]=ao[n]||1;const e=ao[n]++;return`${n}-${e}`}class Fc{constructor(e){m(this,"id");m(this,"userData",{});m(this,"topology");m(this,"bufferLayout",[]);m(this,"vertexCount");m(this,"indices");m(this,"attributes");if(this.id=e.id||ir("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&z.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function ny(n,e){if(e instanceof Fc)return e;const t=iy(n,e),{attributes:i,bufferLayout:r}=ry(n,e);return new Fc({topology:e.topology||"triangle-list",bufferLayout:r,vertexCount:e.vertexCount,indices:t,attributes:i})}function iy(n,e){if(!e.indices)return;const t=e.indices.value;return n.createBuffer({usage:z.INDEX,data:t})}function ry(n,e){const t=[],i={};for(const[s,o]of Object.entries(e.attributes)){let a=s;switch(s){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){i[a]=n.createBuffer({data:o.value,id:`${s}-buffer`});const{value:l,size:c,normalized:u}=o;t.push({name:a,format:Fp(l,c,u)})}}const r=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:t,vertexCount:r}}const Er=class Er{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_hashCounter",0);m(this,"_hashes",{});m(this,"_renderPipelineCache",{});m(this,"_computePipelineCache",{});this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Er(e),e._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var o;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const t={...Lt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.warn(`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:ir("unnamed-cached")}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.warn(`${this}: ${s} created, count=${i[r].useCount}`)()),s}createComputePipeline(e){var o;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const t={...Oi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.warn(`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.warn(`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.debug&&D.warn(`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(D.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.debug&&D.warn(`${this}: ${e} released, count=${t[i].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Oi&&(t=this._computePipelineCache),e instanceof Lt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device,i=this._getHash(e.shader.source);return`${t}/C/${i}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r="-",s=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${i}V${r}BL${s}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${i}V${r}T${e.topology}P${a}BL${s}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};m(Er,"defaultProps",{...Lt.defaultProps});let lo=Er;const kr=class kr{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_cache",{});this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(e){var t;return(t=e._lumaData).defaultShaderFactory||(t.defaultShaderFactory=new kr(e)),e._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let i=this._cache[t];if(i)i.useCount++,this.debug&&D.warn(`${this}: Reusing shader ${i.shader.id} count=${i.useCount}`)();else{const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:r,useCount:1},this.debug&&D.warn(`${this}: Created new shader ${r.id}`)()}return i.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],i.shader.destroy(),this.debug&&D.warn(`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&D.warn(`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};m(kr,"defaultProps",{...Mi.defaultProps});let co=kr;function sy(n,e){var r;const t={},i="Values";if(n.attributes.length===0&&!((r=n.varyings)!=null&&r.length))return{"No attributes or varyings":{[i]:"N/A"}};for(const s of n.attributes)if(s){const o=`${s.location} ${s.name}: ${s.type}`;t[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(const s of n.varyings||[]){const o=`${s.location} ${s.name}`;t[`out ${o}`]={[i]:JSON.stringify(s)}}return t}let Ce=null,Xt=null;function oy(n,{id:e,minimap:t,opaque:i,top:r="0",left:s="0",rgbaScale:o=1}){Ce||(Ce=document.createElement("canvas"),Ce.id=e,Ce.title=e,Ce.style.zIndex="100",Ce.style.position="absolute",Ce.style.top=r,Ce.style.left=s,Ce.style.border="blue 5px solid",Ce.style.transform="scaleY(-1)",document.body.appendChild(Ce),Xt=Ce.getContext("2d")),(Ce.width!==n.width||Ce.height!==n.height)&&(Ce.width=n.width/2,Ce.height=n.height/2,Ce.style.width="400px",Ce.style.height="400px");const a=n.device.readPixelsToArrayWebGL(n),l=Xt==null?void 0:Xt.createImageData(n.width,n.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]=i?255:a[u+3]*o;Xt==null||Xt.putImageData(l,0,0)}}function uo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!uo(n[i],e[i],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof n=="object"&&typeof e=="object"){const i=Object.keys(n),r=Object.keys(e);if(i.length!==r.length)return!1;for(const s of i)if(!e.hasOwnProperty(s)||!uo(n[s],e[s],t-1))return!1;return!0}return!1}class fo{constructor(e){m(this,"bufferLayouts");this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?(t=e.attributes)==null?void 0:t.map(i=>i.attribute):[e.name]}mergeBufferLayouts(e,t){const i=[...e];for(const r of t){const s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}getBufferIndex(e){const t=this.bufferLayouts.findIndex(i=>i.name===e);return t===-1&&D.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function ay(n,e){const t=Object.fromEntries(n.attributes.map(r=>[r.name,r.location])),i=e.slice();return i.sort((r,s)=>{const o=r.attributes?r.attributes.map(u=>u.attribute):[r.name],a=s.attributes?s.attributes.map(u=>u.attribute):[s.name],l=Math.min(...o.map(u=>t[u])),c=Math.min(...a.map(u=>t[u]));return l-c}),i}function ly(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function cy(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function uy(n){return ly(n)||cy(n)}function fy(n){return uy(n)||typeof n=="number"||typeof n=="boolean"}function hy(n){const e={bindings:{},uniforms:{}};return Object.keys(n).forEach(t=>{const i=n[t];fy(i)?e.uniforms[t]=i:e.bindings[t]=i}),e}class dy{constructor(e,t){m(this,"options",{disableWarnings:!1});m(this,"modules");m(this,"moduleUniforms");m(this,"moduleBindings");Object.assign(this.options,t);const i=$s(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;D.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,s]of Object.entries(e))this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&D.warn(`Module name: ${r} vs ${s.name}`)()}destroy(){}setProps(e){var t;for(const i of Object.keys(e)){const r=i,s=e[r]||{},o=this.modules[r];if(!o){this.options.disableWarnings||D.warn(`Module ${i} not found`)();continue}const a=this.moduleUniforms[r],l=this.moduleBindings[r],c=((t=o.getUniforms)==null?void 0:t.call(o,s,a))||s,{uniforms:u,bindings:f}=hy(c);this.moduleUniforms[r]={...a,...u},this.moduleBindings[r]={...l,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var t;const e={};for(const[i,r]of Object.entries(this.moduleUniforms))for(const[s,o]of Object.entries(r))e[`${i}.${s}`]={type:(t=this.modules[i].uniformTypes)==null?void 0:t[s],value:String(o)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}let py="";async function my(n,e){const t=new Image;return t.crossOrigin="anonymous",t.src=n.startsWith("http")?n:py+n,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}const gy=["+X","-X","+Y","-Y","+Z","-Z"],_y=["+X","-X","+Y","-Y","+Z","-Z"],Dr=class Dr{constructor(e,t){m(this,"device");m(this,"id");m(this,"props");m(this,"texture");m(this,"sampler");m(this,"view");m(this,"ready");m(this,"isReady",!1);m(this,"destroyed",!1);m(this,"resolveReady",()=>{});m(this,"rejectReady",()=>{});this.device=e;const i=ir("async-texture");this.props={...Dr.defaultProps,id:i,...t},this.id=this.props.id,t={...t},typeof(t==null?void 0:t.data)=="string"&&t.dimension==="2d"&&(t.data=my(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((r,s)=>{this.resolveReady=()=>{this.isReady=!0,r()},this.rejectReady=s}),this.initAsync(t)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,i=await Mc(t).then(void 0,this.rejectReady);if(this.destroyed)return;const r=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(i);if(!r)throw new Error("Texture size could not be determined");const s={...r,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(s.width,s.height);if(s.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,i);break;case"2d":this._setTexture2DData(i);break;case"3d":this._setTexture3DData(this.texture,i);break;case"2d-array":this._setTextureArrayData(this.texture,i);break;case"cube":this._setTextureCubeData(this.texture,i);break;case"cube-array":this._setTextureCubeArrayData(this.texture,i);break}this.props.mipmaps&&this.generateMipmaps(),D.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 on?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=e==null?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){const i=Object.values(e)[0];return{width:i.width,height:i.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const i=this._normalizeTextureData(e);i.length>1&&this.props.mipmaps!==!1&&D.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let r=0;r<i.length;r++){const s=i[r];this.device.isExternalImage(s)?this.texture.copyExternalImage({image:s,depth:t,mipLevel:r,flipY:!0}):this.texture.copyImageData({data:s.data,mipLevel:r})}}_setTexture3DData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="3d")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="cube")throw new Error(this.id);for(const[r,s]of Object.entries(t)){const o=_y.indexOf(r);this._setTexture2DData(s,o)}}_setTextureArrayData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="2d-array")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,i,r=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&D.warn(`${this.id} has mipmap and multiple LODs.`)();const s=gy.indexOf(i);this._setTexture2DData(t,s)}_normalizeTextureData(e){const t=this.texture;let i;return ArrayBuffer.isView(e)?i=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?i=e:i=[e],i}};m(Dr,"defaultProps",{...J.defaultProps,data:null,mipmaps:!1});let Zn=Dr;async function Mc(n){if(n=await n,Array.isArray(n))return await Promise.all(n.map(Mc));if(n&&typeof n=="object"&&n.constructor===Object){const e=n,t=await Promise.all(Object.values(e)),i=Object.keys(e),r={};for(let s=0;s<i.length;s++)r[i[s]]=t[s];return r}return n}const Yt=2,xy=1e4,Fr=class Fr{constructor(e,t){m(this,"device");m(this,"id");m(this,"source");m(this,"vs");m(this,"fs");m(this,"pipelineFactory");m(this,"shaderFactory");m(this,"userData",{});m(this,"parameters");m(this,"topology");m(this,"bufferLayout");m(this,"isInstanced");m(this,"instanceCount",0);m(this,"vertexCount");m(this,"indexBuffer",null);m(this,"bufferAttributes",{});m(this,"constantAttributes",{});m(this,"bindings",{});m(this,"vertexArray");m(this,"transformFeedback",null);m(this,"pipeline");m(this,"shaderInputs");m(this,"_uniformStore");m(this,"_attributeInfos",{});m(this,"_gpuGeometry",null);m(this,"props");m(this,"_pipelineNeedsUpdate","newly created");m(this,"_needsRedraw","initializing");m(this,"_destroyed",!1);m(this,"_lastDrawTimestamp",-1);m(this,"_lastLogTime",0);m(this,"_logOpen",!1);m(this,"_drawCount",0);var l,c,u,f;this.props={...Fr.defaultProps,...t},t=this.props,this.id=t.id||ir("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(((l=this.props.modules)==null?void 0:l.map(h=>[h.name,h]))||[]),r=t.shaderInputs||new dy(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(r);const s=vy(e),o=(((c=this.props.modules)==null?void 0:c.length)>0?this.props.modules:(u=this.shaderInputs)==null?void 0:u.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:h,getUniforms:d}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:s,...this.props,modules:o});this.source=h,this._getModuleUniforms=d,(f=this.props).shaderLayout||(f.shaderLayout=ey(this.source))}else{const{vs:h,fs:d,getUniforms:_}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:o});this.vs=h,this.fs=d,this._getModuleUniforms=_}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||lo.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||co.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return D.info(Yt,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const r=this._getBindings();this.pipeline.setBindings(r,{disableWarnings:this.props.disableWarnings});const{indexBuffer:s}=this.vertexArray,o=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;i=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),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var i;(i=this._gpuGeometry)==null||i.destroy();const t=e&&ny(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const r=new fo(this.bufferLayout);this.bufferLayout=r.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new fo(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){uo(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 ge(this.shaderInputs.modules);for(const[t,i]of Object.entries(this.shaderInputs.modules))if(yy(i)){const r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const i=(t==null?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&D.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=ay(this.pipeline.shaderLayout,this.bufferLayout);const r=new fo(this.bufferLayout);for(const[s,o]of Object.entries(e)){const a=r.getBufferLayout(s);if(!a){i||D.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const l=r.getAttributeNamesForBuffer(a);let c=!1;for(const u of l){const f=this._attributeInfos[u];if(f){const h=this.device.type==="webgpu"?r.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),c=!0}}!c&&!i&&D.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,r]of Object.entries(e)){const s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):((t==null?void 0:t.disableWarnings)??this.props.disableWarnings)||D.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Zn&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,i]of Object.entries(this.bindings))i instanceof Zn?i.isReady&&(e[t]=i.texture):e[t]=i;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof Fi?e=Math.max(e,t.texture.updateTimestamp):t instanceof z||t instanceof J?e=Math.max(e,t.updateTimestamp):t instanceof Zn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof on||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(D.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let r=null;this.source?r=i:this.fs&&(r=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:i,fs:r}),this._attributeInfos=Ya(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=D.level>3?0:xy;D.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,D.group(Yt,`>>> DRAWING MODEL ${this.id}`,{collapsed:D.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=sy(this.pipeline.shaderLayout,this.id);D.table(Yt,e)();const t=this.shaderInputs.getDebugTable();D.table(Yt,t)();const i=this._getAttributeDebugTable();D.table(Yt,this._attributeInfos)(),D.table(Yt,i)(),D.groupEnd(Yt)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const i=e.props.framebuffer;i&&oy(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,i]of Object.entries(this._attributeInfos)){const r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){const i=Ba(t);return(e instanceof z?new i(e.debugData):e).toString()}};m(Fr,"defaultProps",{...Lt.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:Ys.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let le=Fr;function yy(n){return!!(n.uniformTypes&&!by(n.uniformTypes))}function vy(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}function by(n){for(const e in n)return!1;return!0}class Ft{constructor(e,t,i,r,s){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=t,this.store=i,this.data=r,s&&(this.points=s)}}const Sy=`#version 300 es
|
|
97
97
|
precision highp float;
|
|
98
98
|
|
|
99
99
|
in vec4 rgba;
|
|
@@ -186,7 +186,7 @@ void main() {
|
|
|
186
186
|
textureCoords = (vertexCoord + 1.0) / 2.0;
|
|
187
187
|
gl_Position = vec4(vertexCoord, 0, 1);
|
|
188
188
|
}
|
|
189
|
-
`;class Ay extends
|
|
189
|
+
`;class Ay extends Ft{create(){var s;const{device:e,store:t}=this,{pointsTextureSize:i}=t;if(!i)return;(!this.centermassTexture||this.centermassTexture.destroyed)&&(this.centermassTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST})),this.centermassTexture.copyImageData({data:new Float32Array(4).fill(0),bytesPerRow:1,mipLevel:0,x:0,y:0}),(!this.centermassFbo||this.centermassFbo.destroyed)&&(this.centermassFbo=e.createFramebuffer({width:1,height:1,colorAttachments:[this.centermassTexture]}));const r=Qn(i);!this.pointIndices||this.pointIndices.byteLength!==r.byteLength?((s=this.pointIndices)==null||s.destroy(),this.pointIndices=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.pointIndices.write(r),this.previousPointsTextureSize=i}initPrograms(){const{device:e,store:t,points:i}=this;!i||!t.pointsTextureSize||!this.centermassFbo||this.centermassFbo.destroyed||!this.centermassTexture||this.centermassTexture.destroyed||this.pointIndices&&((!this.clearVertexCoordBuffer||this.clearVertexCoordBuffer.destroyed)&&(this.clearVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),(!this.forceVertexCoordBuffer||this.forceVertexCoordBuffer.destroyed)&&(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.calculateUniformStore||(this.calculateUniformStore=new ge({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32"}}})),this.forceUniformStore||(this.forceUniformStore=new ge({forceCenterUniforms:{uniformTypes:{centerForce:"f32",alpha:"f32"}}})),this.clearCentermassCommand||(this.clearCentermassCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.calculateCentermassCommand?this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0):this.calculateCentermassCommand=new le(e,{fs:Sy,vs:Ty,topology:"point-list",vertexCount:this.data.pointsNumber??0,attributes:{pointIndices:this.pointIndices},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms"),positionsTexture:i.previousPositionTexture},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}}),this.runCommand||(this.runCommand=new le(e,{fs:wy,vs:Ie,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"),positionsTexture:i.previousPositionTexture,centermassTexture:this.centermassTexture},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(e){const{device:t,store:i,points:r}=this;if(!r||!this.centermassFbo||!this.centermassTexture||!this.calculateCentermassCommand||!this.calculateUniformStore||!this.runCommand||!this.forceUniformStore||!r.previousPositionTexture||r.previousPositionTexture.destroyed||!e&&(!r.velocityFbo||r.velocityFbo.destroyed)||i.pointsTextureSize!==this.previousPointsTextureSize)return;const s=t.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:i.pointsTextureSize??0}}),this.calculateCentermassCommand.setBindings({calculateCentermassUniforms:this.calculateUniformStore.getManagedUniformBuffer(t,"calculateCentermassUniforms"),positionsTexture:r.previousPositionTexture}),this.calculateCentermassCommand.draw(s),s.end(),this.forceUniformStore.setUniforms({forceCenterUniforms:{centerForce:this.config.simulationCenter??0,alpha:i.alpha}}),this.runCommand.setBindings({forceCenterUniforms:this.forceUniformStore.getManagedUniformBuffer(t,"forceCenterUniforms"),positionsTexture:r.previousPositionTexture,centermassTexture:this.centermassTexture});const o=e??t.beginRenderPass({framebuffer:r.velocityFbo});this.runCommand.draw(o),e||o.end()}destroy(){var e,t,i,r,s,o;(e=this.calculateUniformStore)==null||e.destroy(),this.calculateUniformStore=void 0,(t=this.forceUniformStore)==null||t.destroy(),this.forceUniformStore=void 0,(i=this.clearCentermassCommand)==null||i.destroy(),this.clearCentermassCommand=void 0,(r=this.calculateCentermassCommand)==null||r.destroy(),this.calculateCentermassCommand=void 0,(s=this.runCommand)==null||s.destroy(),this.runCommand=void 0,this.clearVertexCoordBuffer&&!this.clearVertexCoordBuffer.destroyed&&this.clearVertexCoordBuffer.destroy(),this.clearVertexCoordBuffer=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0,(o=this.pointIndices)==null||o.destroy(),this.pointIndices=void 0,this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.previousPointsTextureSize=void 0}}const Cy=`#version 300 es
|
|
190
190
|
precision highp float;
|
|
191
191
|
|
|
192
192
|
uniform sampler2D positionsTexture;
|
|
@@ -225,7 +225,7 @@ void main() {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
fragColor = velocity;
|
|
228
|
-
}`;class Py extends
|
|
228
|
+
}`;class Py extends Ft{initPrograms(){const{device:e,points:t,store:i}=this;!t||!i.pointsTextureSize||((!this.vertexCoordBuffer||this.vertexCoordBuffer.destroyed)&&(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ge({forceGravityUniforms:{uniformTypes:{gravity:"f32",spaceSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new le(e,{fs:Cy,vs:Ie,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"),positionsTexture:t.previousPositionTexture},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(e){const{device:t,points:i,store:r}=this;if(!i||!this.runCommand||!this.uniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!e&&(!i.velocityFbo||i.velocityFbo.destroyed))return;this.uniformStore.setUniforms({forceGravityUniforms:{gravity:this.config.simulationGravity??0,spaceSize:r.adjustedSpaceSize??0,alpha:r.alpha}}),this.runCommand.setBindings({forceGravityUniforms:this.uniformStore.getManagedUniformBuffer(t,"forceGravityUniforms"),positionsTexture:i.previousPositionTexture});const s=e??t.beginRenderPass({framebuffer:i.velocityFbo});this.runCommand.draw(s),e||s.end()}destroy(){var e;(e=this.uniformStore)==null||e.destroy(),this.uniformStore=void 0,this.runCommand&&!this.runCommand.destroyed&&this.runCommand.destroy(),this.runCommand=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}function Iy(n){return`#version 300 es
|
|
229
229
|
precision highp float;
|
|
230
230
|
|
|
231
231
|
uniform sampler2D positionsTexture;
|
|
@@ -311,7 +311,7 @@ void main() {
|
|
|
311
311
|
|
|
312
312
|
fragColor = vec4(velocity.rg, 0.0, 0.0);
|
|
313
313
|
}
|
|
314
|
-
`}var ho=(n=>(n.OUTGOING="outgoing",n.INCOMING="incoming",n))(ho||{});class
|
|
314
|
+
`}var ho=(n=>(n.OUTGOING="outgoing",n.INCOMING="incoming",n))(ho||{});class Nc extends Ft{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){var h;const{device:t,store:{pointsTextureSize:i,linksTextureSize:r},data:s}=this;if(!i||!r)return;this.linkFirstIndicesAndAmount=new Float32Array(i*i*4),this.indices=new Float32Array(r*r*4);const o=new Float32Array(r*r*4),a=new Float32Array(r*r*4),l=e==="incoming"?s.sourceIndexToTargetIndices:s.targetIndexToSourceIndices;this.maxPointDegree=0;let c=0;l==null||l.forEach((d,_)=>{d&&(this.linkFirstIndicesAndAmount[_*4+0]=c%r,this.linkFirstIndicesAndAmount[_*4+1]=Math.floor(c/r),this.linkFirstIndicesAndAmount[_*4+2]=d.length??0,d.forEach(([I,C])=>{var L,W,q;this.indices[c*4+0]=I%i,this.indices[c*4+1]=Math.floor(I/i);const w=((L=s.degree)==null?void 0:L[I])??0,M=((W=s.degree)==null?void 0:W[_])??0,E=w+M,x=E!==0?w/E:.5,R=Math.min(w,M);let O=((q=s.linkStrength)==null?void 0:q[C])??1/Math.max(R,1);O=Math.sqrt(O),o[c*4+0]=x,o[c*4+1]=O,a[c*4]=this.store.getRandomFloat(0,1),c+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,d.length??0))});const u=!this.linkFirstIndicesAndAmountTexture||this.linkFirstIndicesAndAmountTexture.width!==i||this.linkFirstIndicesAndAmountTexture.height!==i,f=!this.indicesTexture||this.indicesTexture.width!==r||this.indicesTexture.height!==r;u&&(this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=t.createTexture({width:i,height:i,format:"rgba32float",usage:J.SAMPLE|J.COPY_DST})),this.linkFirstIndicesAndAmountTexture.copyImageData({data:this.linkFirstIndicesAndAmount,bytesPerRow:i,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=t.createTexture({width:r,height:r,format:"rgba32float",usage:J.SAMPLE|J.COPY_DST}),this.biasAndStrengthTexture=t.createTexture({width:r,height:r,format:"rgba32float",usage:J.SAMPLE|J.COPY_DST}),this.randomDistanceTexture=t.createTexture({width:r,height:r,format:"rgba32float",usage:J.SAMPLE|J.COPY_DST})),this.indicesTexture.copyImageData({data:this.indices,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.biasAndStrengthTexture.copyImageData({data:o,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.randomDistanceTexture.copyImageData({data:a,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.previousMaxPointDegree!==void 0&&this.previousMaxPointDegree!==this.maxPointDegree&&((h=this.runCommand)==null||h.destroy(),this.runCommand=void 0),this.previousMaxPointDegree=this.maxPointDegree,this.previousPointsTextureSize=i,this.previousLinksTextureSize=r}initPrograms(){const{device:e,store:t,points:i}=this;!i||!t.pointsTextureSize||!t.linksTextureSize||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||((!this.vertexCoordBuffer||this.vertexCoordBuffer.destroyed)&&(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ge({forceLinkUniforms:{uniformTypes:{linkSpring:"f32",linkDistance:"f32",linkDistRandomVariationRange:"vec2<f32>",pointsTextureSize:"f32",linksTextureSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new le(e,{fs:Iy(this.maxPointDegree),vs:Ie,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"),positionsTexture:i.previousPositionTexture,linkInfoTexture:this.linkFirstIndicesAndAmountTexture,linkIndicesTexture:this.indicesTexture,linkPropertiesTexture:this.biasAndStrengthTexture,linkRandomDistanceTexture:this.randomDistanceTexture},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(e){var o,a;const{device:t,store:i,points:r}=this;if(!r||!this.runCommand||!this.uniformStore||!r.previousPositionTexture||r.previousPositionTexture.destroyed||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||!e&&(!r.velocityFbo||r.velocityFbo.destroyed)||i.pointsTextureSize!==this.previousPointsTextureSize||i.linksTextureSize!==this.previousLinksTextureSize)return;this.uniformStore.setUniforms({forceLinkUniforms:{linkSpring:this.config.simulationLinkSpring??0,linkDistance:this.config.simulationLinkDistance??0,linkDistRandomVariationRange:[((o=this.config.simulationLinkDistRandomVariationRange)==null?void 0:o[0])??0,((a=this.config.simulationLinkDistRandomVariationRange)==null?void 0:a[1])??0],pointsTextureSize:i.pointsTextureSize,linksTextureSize:i.linksTextureSize,alpha:i.alpha}}),this.runCommand.setBindings({forceLinkUniforms:this.uniformStore.getManagedUniformBuffer(t,"forceLinkUniforms"),positionsTexture:r.previousPositionTexture,linkInfoTexture:this.linkFirstIndicesAndAmountTexture,linkIndicesTexture:this.indicesTexture,linkPropertiesTexture:this.biasAndStrengthTexture,linkRandomDistanceTexture:this.randomDistanceTexture});const s=e??t.beginRenderPass({framebuffer:r.velocityFbo});this.runCommand.draw(s),e||s.end()}destroy(){var e,t;(e=this.uniformStore)==null||e.destroy(),this.uniformStore=void 0,(t=this.runCommand)==null||t.destroy(),this.runCommand=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=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}}const Ry=`#version 300 es
|
|
315
315
|
precision highp float;
|
|
316
316
|
|
|
317
317
|
in vec4 vColor;
|
|
@@ -492,7 +492,7 @@ void main() {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
fragColor = velocity;
|
|
495
|
-
}`,
|
|
495
|
+
}`,Dy=`#version 300 es
|
|
496
496
|
precision highp float;
|
|
497
497
|
|
|
498
498
|
uniform sampler2D positionsTexture;
|
|
@@ -552,7 +552,7 @@ void main() {
|
|
|
552
552
|
velocity.xy += velocity.xy * random.rg;
|
|
553
553
|
|
|
554
554
|
fragColor = velocity;
|
|
555
|
-
}`;class
|
|
555
|
+
}`;class Fy extends Ft{constructor(){super(...arguments),this.levels=0,this.levelTargets=new Map}create(){var a;const{device:e,store:t}=this;if(!t.pointsTextureSize)return;this.levels=Math.log2(t.adjustedSpaceSize);for(let l=0;l<this.levels;l+=1){const c=Math.pow(2,l+1),u=this.levelTargets.get(l);if(u&&u.texture.width===c&&u.texture.height===c){u.texture.copyImageData({data:new Float32Array(c*c*4).fill(0),bytesPerRow:c,mipLevel:0,x:0,y:0});continue}u&&(u.texture.destroyed||u.texture.destroy(),u.fbo.destroyed||u.fbo.destroy());const f=e.createTexture({width:c,height:c,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST});f.copyImageData({data:new Float32Array(c*c*4).fill(0),bytesPerRow:c,mipLevel:0,x:0,y:0});const h=e.createFramebuffer({width:c,height:c,colorAttachments:[f]});this.levelTargets.set(l,{texture:f,fbo:h})}for(const[l,c]of Array.from(this.levelTargets.entries()))l>=this.levels&&(c.texture.destroyed||c.texture.destroy(),c.fbo.destroyed||c.fbo.destroy(),this.levelTargets.delete(l));const i=t.pointsTextureSize*t.pointsTextureSize,r=new Float32Array(i*4);for(let l=0;l<i;++l)r[l*4]=t.getRandomFloat(-1,1)*1e-5,r[l*4+1]=t.getRandomFloat(-1,1)*1e-5;(!this.randomValuesTexture||this.randomValuesTexture.destroyed)&&(this.randomValuesTexture=e.createTexture({width:t.pointsTextureSize,height:t.pointsTextureSize,format:"rgba32float",usage:J.SAMPLE|J.COPY_DST})),this.randomValuesTexture.copyImageData({data:r,bytesPerRow:t.pointsTextureSize,mipLevel:0,x:0,y:0});const s=Qn(t.pointsTextureSize),o=s.byteLength;!this.pointIndices||this.pointIndices.byteLength!==o?((a=this.pointIndices)==null||a.destroy(),this.pointIndices=e.createBuffer({data:s,usage:z.VERTEX|z.COPY_DST})):this.pointIndices.write(s),this.previousPointsTextureSize=t.pointsTextureSize,this.previousSpaceSize=t.adjustedSpaceSize}initPrograms(){const{device:e,store:t,data:i,points:r}=this;!i.pointsNumber||!r||!t.pointsTextureSize||(this.clearLevelsCommand||(this.clearLevelsVertexCoordBuffer||(this.clearLevelsVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearLevelsCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearLevelsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),this.calculateLevelsCommand||(this.calculateLevelsUniformStore||(this.calculateLevelsUniformStore=new ge({calculateLevelsUniforms:{uniformTypes:{pointsTextureSize:"f32",levelTextureSize:"f32",cellSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,levelTextureSize:0,cellSize:0}}})),this.calculateLevelsCommand=new le(e,{fs:Ry,vs:Ey,topology:"point-list",vertexCount:i.pointsNumber,attributes:{pointIndices:this.pointIndices},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateLevelsUniforms:this.calculateLevelsUniformStore.getManagedUniformBuffer(e,"calculateLevelsUniforms"),positionsTexture:r.previousPositionTexture},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceCommand||(this.forceUniformStore||(this.forceUniformStore=new ge({forceUniforms:{uniformTypes:{level:"f32",levels:"f32",levelTextureSize:"f32",alpha:"f32",repulsion:"f32",spaceSize:"f32",theta:"f32"},defaultUniforms:{level:0,levels:this.levels,levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:t.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceCommand=new le(e,{fs:ky,vs:Ie,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"),positionsTexture:r.previousPositionTexture},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceFromItsOwnCentermassCommand||(this.forceCenterUniformStore||(this.forceCenterUniformStore=new ge({forceCenterUniforms:{uniformTypes:{levelTextureSize:"f32",alpha:"f32",repulsion:"f32"},defaultUniforms:{levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceFromItsOwnCentermassCommand=new le(e,{fs:Dy,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCenterUniforms:this.forceCenterUniformStore.getManagedUniformBuffer(e,"forceCenterUniforms"),positionsTexture:r.previousPositionTexture,randomValues:this.randomValuesTexture},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})))}run(e){this.store.pointsTextureSize!==this.previousPointsTextureSize||this.store.adjustedSpaceSize!==this.previousSpaceSize||(this.drawLevels(),this.drawForces(e))}destroy(){var e,t,i,r,s,o,a,l;(e=this.calculateLevelsUniformStore)==null||e.destroy(),this.calculateLevelsUniformStore=void 0,(t=this.forceUniformStore)==null||t.destroy(),this.forceUniformStore=void 0,(i=this.forceCenterUniformStore)==null||i.destroy(),this.forceCenterUniformStore=void 0,(r=this.clearLevelsCommand)==null||r.destroy(),this.clearLevelsCommand=void 0,(s=this.calculateLevelsCommand)==null||s.destroy(),this.calculateLevelsCommand=void 0,(o=this.forceCommand)==null||o.destroy(),this.forceCommand=void 0,(a=this.forceFromItsOwnCentermassCommand)==null||a.destroy(),this.forceFromItsOwnCentermassCommand=void 0,(l=this.pointIndices)==null||l.destroy(),this.pointIndices=void 0,this.randomValuesTexture&&!this.randomValuesTexture.destroyed&&this.randomValuesTexture.destroy(),this.randomValuesTexture=void 0;for(const c of this.levelTargets.values())c.texture.destroyed||c.texture.destroy(),c.fbo.destroyed||c.fbo.destroy();this.levelTargets.clear(),this.clearLevelsVertexCoordBuffer&&!this.clearLevelsVertexCoordBuffer.destroyed&&this.clearLevelsVertexCoordBuffer.destroy(),this.clearLevelsVertexCoordBuffer=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0}drawLevels(){const{device:e,store:t,data:i,points:r}=this;if(!(!r||!i.pointsNumber||!this.calculateLevelsCommand||!this.calculateLevelsUniformStore||!this.clearLevelsCommand)&&!(!r.previousPositionTexture||r.previousPositionTexture.destroyed))for(let s=0;s<this.levels;s+=1){const o=this.levelTargets.get(s);if(!o||o.fbo.destroyed||o.texture.destroyed)continue;const a=Math.pow(2,s+1),l=(t.adjustedSpaceSize??0)/a;this.calculateLevelsUniformStore.setUniforms({calculateLevelsUniforms:{pointsTextureSize:t.pointsTextureSize??0,levelTextureSize:a,cellSize:l}}),this.calculateLevelsCommand.setVertexCount(i.pointsNumber),this.calculateLevelsCommand.setBindings({calculateLevelsUniforms:this.calculateLevelsUniformStore.getManagedUniformBuffer(e,"calculateLevelsUniforms"),positionsTexture:r.previousPositionTexture});const c=e.beginRenderPass({framebuffer:o.fbo,clearColor:[0,0,0,0]});this.clearLevelsCommand.draw(c),this.calculateLevelsCommand.draw(c),c.end()}}drawForces(e){const{device:t,store:i,points:r}=this;if(!r||!this.forceCommand||!this.forceUniformStore||!this.forceFromItsOwnCentermassCommand||!this.forceCenterUniformStore||!r.previousPositionTexture||r.previousPositionTexture.destroyed||!this.randomValuesTexture||this.randomValuesTexture.destroyed||!e&&(!r.velocityFbo||r.velocityFbo.destroyed))return;this.forceCommand.setBindings({forceUniforms:this.forceUniformStore.getManagedUniformBuffer(t,"forceUniforms"),positionsTexture:r.previousPositionTexture}),this.forceFromItsOwnCentermassCommand.setBindings({forceCenterUniforms:this.forceCenterUniformStore.getManagedUniformBuffer(t,"forceCenterUniforms"),positionsTexture:r.previousPositionTexture,randomValues:this.randomValuesTexture});const s=e??t.beginRenderPass({framebuffer:r.velocityFbo});for(let o=0;o<this.levels;o+=1){const a=this.levelTargets.get(o);if(!a||a.texture.destroyed)continue;const l=Math.pow(2,o+1);this.forceUniformStore.setUniforms({forceUniforms:{level:o,levels:this.levels,levelTextureSize:l,alpha:i.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:i.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}),this.forceCommand.setBindings({forceUniforms:this.forceUniformStore.getManagedUniformBuffer(t,"forceUniforms"),positionsTexture:r.previousPositionTexture,levelFbo:a.texture}),this.forceCommand.draw(s),o===this.levels-1&&(this.forceCenterUniformStore.setUniforms({forceCenterUniforms:{levelTextureSize:l,alpha:i.alpha,repulsion:this.config.simulationRepulsion??0}}),this.forceFromItsOwnCentermassCommand.setBindings({forceCenterUniforms:this.forceCenterUniformStore.getManagedUniformBuffer(t,"forceCenterUniforms"),positionsTexture:r.previousPositionTexture,randomValues:this.randomValuesTexture,levelFbo:a.texture}),this.forceFromItsOwnCentermassCommand.draw(s))}e||s.end()}}const My=`#version 300 es
|
|
556
556
|
precision highp float;
|
|
557
557
|
|
|
558
558
|
uniform sampler2D positionsTexture;
|
|
@@ -586,7 +586,7 @@ void main() {
|
|
|
586
586
|
velocity.rg -= addV * vec2(cos(angle), sin(angle));
|
|
587
587
|
|
|
588
588
|
fragColor = velocity;
|
|
589
|
-
}`;class Ny extends
|
|
589
|
+
}`;class Ny extends Ft{initPrograms(){const{device:e,points:t}=this;t&&((!this.vertexCoordBuffer||this.vertexCoordBuffer.destroyed)&&(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new ge({forceMouseUniforms:{uniformTypes:{repulsion:"f32",mousePos:"vec2<f32>"}}})),this.runCommand||(this.runCommand=new le(e,{fs:My,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceMouseUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceMouseUniforms"),positionsTexture:t.previousPositionTexture},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(e){const{device:t,points:i,store:r}=this;if(!i||!this.runCommand||!this.uniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!e&&(!i.velocityFbo||i.velocityFbo.destroyed))return;this.uniformStore.setUniforms({forceMouseUniforms:{repulsion:this.config.simulationRepulsionFromMouse??0,mousePos:[r.mousePosition[0]??0,r.mousePosition[1]??0]}}),this.runCommand.setBindings({forceMouseUniforms:this.uniformStore.getManagedUniformBuffer(t,"forceMouseUniforms"),positionsTexture:i.previousPositionTexture});const s=e??t.beginRenderPass({framebuffer:i.velocityFbo});this.runCommand.draw(s),e||s.end()}destroy(){var e,t;(e=this.uniformStore)==null||e.destroy(),this.uniformStore=void 0,(t=this.runCommand)==null||t.destroy(),this.runCommand=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const Oy=`#version 300 es
|
|
590
590
|
#ifdef GL_ES
|
|
591
591
|
precision highp float;
|
|
592
592
|
#endif
|
|
@@ -689,7 +689,7 @@ void main() {
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
fragColor = velocity;
|
|
692
|
-
}`;class zy extends Dt{create(){var f;const{device:e,store:t,data:i}=this,{pointsTextureSize:r}=t;if(i.pointsNumber===void 0||!i.pointClusters&&!i.clusterPositions)return;this.clusterCount=(i.pointClusters??[]).reduce((h,d)=>d===void 0||d<0?h:Math.max(h,d),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const s=this.previousPointsTextureSize!==r||this.previousClustersTextureSize!==this.clustersTextureSize||this.previousClusterCount!==this.clusterCount,o=r*r*4,a=this.clustersTextureSize*this.clustersTextureSize*4,c=new Float32Array(o),l=new Float32Array(a).fill(-1),u=new Float32Array(o).fill(1);if(i.clusterPositions)for(let h=0;h<this.clusterCount;++h)l[h*4+0]=i.clusterPositions[h*2+0]??-1,l[h*4+1]=i.clusterPositions[h*2+1]??-1;for(let h=0;h<i.pointsNumber;++h){const d=(f=i.pointClusters)==null?void 0:f[h];d===void 0?(c[h*4+0]=-1,c[h*4+1]=-1):(c[h*4+0]=d%this.clustersTextureSize,c[h*4+1]=Math.floor(d/this.clustersTextureSize)),i.clusterStrength&&(u[h*4+0]=i.clusterStrength[h]??1)}if(!this.clusterTexture||s?(this.clusterFbo&&!this.clusterFbo.destroyed&&this.clusterFbo.destroy(),this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.clusterTexture.copyImageData({data:c,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.clusterFbo=e.createFramebuffer({width:r,height:r,colorAttachments:[this.clusterTexture]})):this.clusterTexture.copyImageData({data:c,bytesPerRow:r,mipLevel:0,x:0,y:0}),!this.clusterPositionsTexture||s?(this.clusterPositionsFbo&&!this.clusterPositionsFbo.destroyed&&this.clusterPositionsFbo.destroy(),this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.clusterPositionsTexture.copyImageData({data:l,bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),this.clusterPositionsFbo=e.createFramebuffer({width:this.clustersTextureSize,height:this.clustersTextureSize,colorAttachments:[this.clusterPositionsTexture]})):this.clusterPositionsTexture.copyImageData({data:l,bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),!this.clusterForceCoefficientTexture||s?(this.clusterForceCoefficientFbo&&!this.clusterForceCoefficientFbo.destroyed&&this.clusterForceCoefficientFbo.destroy(),this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.clusterForceCoefficientFbo=e.createFramebuffer({width:r,height:r,colorAttachments:[this.clusterForceCoefficientTexture]})):this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:r,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=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),this.centermassFbo=e.createFramebuffer({width:this.clustersTextureSize,height:this.clustersTextureSize,colorAttachments:[this.centermassTexture]})):this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==r){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const h=Qn(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})}this.previousPointsTextureSize=r,this.previousClustersTextureSize=this.clustersTextureSize,this.previousClusterCount=this.clusterCount}initPrograms(){const{device:e,store:t,data:i,points:r}=this;if(!(!i.pointClusters&&!i.clusterPositions)){if(this.clearCentermassCommand||(this.clearCentermassVertexCoordBuffer||(this.clearCentermassVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearCentermassCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearCentermassVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),!this.calculateCentermassCommand){if(!this.pointIndices){const s=Qn(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:s,usage:z.VERTEX|z.COPY_DST})}this.calculateCentermassUniformStore||(this.calculateCentermassUniformStore=new ge({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32",clustersTextureSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}})),this.calculateCentermassCommand=new le(e,{fs:Oy,vs:By,topology:"point-list",vertexCount:i.pointsNumber??0,attributes:{pointIndices:this.pointIndices},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms"),...this.clusterTexture&&{clusterTexture:this.clusterTexture},...(r==null?void 0:r.previousPositionTexture)&&{positionsTexture:r.previousPositionTexture}},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})}this.applyForcesCommand||(this.applyForcesUniformStore||(this.applyForcesUniformStore=new ge({applyForcesUniforms:{uniformTypes:{alpha:"f32",clustersTextureSize:"f32",clusterCoefficient:"f32"},defaultUniforms:{alpha:t.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}})),this.applyForcesVertexCoordBuffer||(this.applyForcesVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.applyForcesCommand=new le(e,{fs:Uy,vs:Ie,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"),...this.clusterTexture&&{clusterTexture:this.clusterTexture},...this.centermassTexture&&{centermassTexture:this.centermassTexture},...this.clusterPositionsTexture&&{clusterPositionsTexture:this.clusterPositionsTexture},...this.clusterForceCoefficientTexture&&{clusterForceCoefficient:this.clusterForceCoefficientTexture},...(r==null?void 0:r.previousPositionTexture)&&{positionsTexture:r.previousPositionTexture}}}))}}calculateCentermass(){var t,i;if(!this.calculateCentermassCommand||!this.calculateCentermassUniformStore||!this.centermassFbo||this.centermassFbo.destroyed||!this.clusterTexture||this.clusterTexture.destroyed||!((t=this.points)!=null&&t.previousPositionTexture)||this.points.previousPositionTexture.destroyed)return;this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.calculateCentermassUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:this.store.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}),this.calculateCentermassCommand.setBindings({calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(this.device,"calculateCentermassUniforms"),clusterTexture:this.clusterTexture,positionsTexture:this.points.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.centermassFbo});(i=this.clearCentermassCommand)==null||i.draw(e),this.calculateCentermassCommand.draw(e),e.end()}run(e){var t,i;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)&&!(!((t=this.points)!=null&&t.previousPositionTexture)||this.points.previousPositionTexture.destroyed)&&!(!((i=this.points)!=null&&i.velocityFbo)||this.points.velocityFbo.destroyed)))if(this.applyForcesUniformStore.setUniforms({applyForcesUniforms:{alpha:this.store.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}),this.applyForcesCommand.setBindings({applyForcesUniforms:this.applyForcesUniformStore.getManagedUniformBuffer(this.device,"applyForcesUniforms"),clusterTexture:this.clusterTexture,centermassTexture:this.centermassTexture,clusterPositionsTexture:this.clusterPositionsTexture,clusterForceCoefficient:this.clusterForceCoefficientTexture,positionsTexture:this.points.previousPositionTexture}),e)this.applyForcesCommand.draw(e);else{const r=this.device.beginRenderPass({framebuffer:this.points.velocityFbo});this.applyForcesCommand.draw(r),r.end()}}destroy(){var e,t,i,r,s;(e=this.calculateCentermassUniformStore)==null||e.destroy(),this.calculateCentermassUniformStore=void 0,(t=this.applyForcesUniformStore)==null||t.destroy(),this.applyForcesUniformStore=void 0,(i=this.clearCentermassCommand)==null||i.destroy(),this.clearCentermassCommand=void 0,(r=this.calculateCentermassCommand)==null||r.destroy(),this.calculateCentermassCommand=void 0,(s=this.applyForcesCommand)==null||s.destroy(),this.applyForcesCommand=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.clusterFbo&&!this.clusterFbo.destroyed&&this.clusterFbo.destroy(),this.clusterFbo=void 0,this.clusterPositionsFbo&&!this.clusterPositionsFbo.destroyed&&this.clusterPositionsFbo.destroy(),this.clusterPositionsFbo=void 0,this.clusterForceCoefficientFbo&&!this.clusterForceCoefficientFbo.destroyed&&this.clusterForceCoefficientFbo.destroy(),this.clusterForceCoefficientFbo=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,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.clearCentermassVertexCoordBuffer&&!this.clearCentermassVertexCoordBuffer.destroyed&&this.clearCentermassVertexCoordBuffer.destroy(),this.clearCentermassVertexCoordBuffer=void 0,this.applyForcesVertexCoordBuffer&&!this.applyForcesVertexCoordBuffer.destroyed&&this.applyForcesVertexCoordBuffer.destroy(),this.applyForcesVertexCoordBuffer=void 0}}function Ol(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Ly(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var rr={exports:{}},Vy=rr.exports,Bl;function Hy(){return Bl||(Bl=1,function(n,e){(function(t,i){n.exports=i()})(Vy,function(){var t=`<div class="gl-box">
|
|
692
|
+
}`;class zy extends Ft{create(){var f;const{device:e,store:t,data:i}=this,{pointsTextureSize:r}=t;if(i.pointsNumber===void 0||!i.pointClusters&&!i.clusterPositions)return;this.clusterCount=(i.pointClusters??[]).reduce((h,d)=>d===void 0||d<0?h:Math.max(h,d),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const s=this.previousPointsTextureSize!==r||this.previousClustersTextureSize!==this.clustersTextureSize||this.previousClusterCount!==this.clusterCount,o=r*r*4,a=this.clustersTextureSize*this.clustersTextureSize*4,l=new Float32Array(o),c=new Float32Array(a).fill(-1),u=new Float32Array(o).fill(1);if(i.clusterPositions)for(let h=0;h<this.clusterCount;++h)c[h*4+0]=i.clusterPositions[h*2+0]??-1,c[h*4+1]=i.clusterPositions[h*2+1]??-1;for(let h=0;h<i.pointsNumber;++h){const d=(f=i.pointClusters)==null?void 0:f[h];d===void 0?(l[h*4+0]=-1,l[h*4+1]=-1):(l[h*4+0]=d%this.clustersTextureSize,l[h*4+1]=Math.floor(d/this.clustersTextureSize)),i.clusterStrength&&(u[h*4+0]=i.clusterStrength[h]??1)}if(!this.clusterTexture||s?(this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.clusterTexture.copyImageData({data:l,bytesPerRow:r,mipLevel:0,x:0,y:0})):this.clusterTexture.copyImageData({data:l,bytesPerRow:r,mipLevel:0,x:0,y:0}),!this.clusterPositionsTexture||s?(this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.clusterPositionsTexture.copyImageData({data:c,bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0})):this.clusterPositionsTexture.copyImageData({data:c,bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),!this.clusterForceCoefficientTexture||s?(this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:r,mipLevel:0,x:0,y:0})):this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:r,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=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),this.centermassFbo=e.createFramebuffer({width:this.clustersTextureSize,height:this.clustersTextureSize,colorAttachments:[this.centermassTexture]})):this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:this.clustersTextureSize,mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==r){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const h=Qn(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})}this.previousPointsTextureSize=r,this.previousClustersTextureSize=this.clustersTextureSize,this.previousClusterCount=this.clusterCount}initPrograms(){const{device:e,store:t,data:i,points:r}=this;if(!(!i.pointClusters&&!i.clusterPositions)){if(this.clearCentermassCommand||(this.clearCentermassVertexCoordBuffer||(this.clearCentermassVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearCentermassCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearCentermassVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),!this.calculateCentermassCommand){if(!this.pointIndices){const s=Qn(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:s,usage:z.VERTEX|z.COPY_DST})}this.calculateCentermassUniformStore||(this.calculateCentermassUniformStore=new ge({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32",clustersTextureSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}})),this.calculateCentermassCommand=new le(e,{fs:Oy,vs:By,topology:"point-list",vertexCount:i.pointsNumber??0,attributes:{pointIndices:this.pointIndices},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms"),...this.clusterTexture&&{clusterTexture:this.clusterTexture},...(r==null?void 0:r.previousPositionTexture)&&{positionsTexture:r.previousPositionTexture}},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})}this.applyForcesCommand||(this.applyForcesUniformStore||(this.applyForcesUniformStore=new ge({applyForcesUniforms:{uniformTypes:{alpha:"f32",clustersTextureSize:"f32",clusterCoefficient:"f32"},defaultUniforms:{alpha:t.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}})),this.applyForcesVertexCoordBuffer||(this.applyForcesVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.applyForcesCommand=new le(e,{fs:Uy,vs:Ie,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"),...this.clusterTexture&&{clusterTexture:this.clusterTexture},...this.centermassTexture&&{centermassTexture:this.centermassTexture},...this.clusterPositionsTexture&&{clusterPositionsTexture:this.clusterPositionsTexture},...this.clusterForceCoefficientTexture&&{clusterForceCoefficient:this.clusterForceCoefficientTexture},...(r==null?void 0:r.previousPositionTexture)&&{positionsTexture:r.previousPositionTexture}}}))}}calculateCentermass(){var t,i;if(!this.calculateCentermassCommand||!this.calculateCentermassUniformStore||!this.centermassFbo||this.centermassFbo.destroyed||!this.clusterTexture||this.clusterTexture.destroyed||!((t=this.points)!=null&&t.previousPositionTexture)||this.points.previousPositionTexture.destroyed)return;this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.calculateCentermassUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:this.store.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}),this.calculateCentermassCommand.setBindings({calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(this.device,"calculateCentermassUniforms"),clusterTexture:this.clusterTexture,positionsTexture:this.points.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.centermassFbo});(i=this.clearCentermassCommand)==null||i.draw(e),this.calculateCentermassCommand.draw(e),e.end()}run(e){var t,i;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)&&!(!((t=this.points)!=null&&t.previousPositionTexture)||this.points.previousPositionTexture.destroyed)&&!(!((i=this.points)!=null&&i.velocityFbo)||this.points.velocityFbo.destroyed)))if(this.applyForcesUniformStore.setUniforms({applyForcesUniforms:{alpha:this.store.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}),this.applyForcesCommand.setBindings({applyForcesUniforms:this.applyForcesUniformStore.getManagedUniformBuffer(this.device,"applyForcesUniforms"),clusterTexture:this.clusterTexture,centermassTexture:this.centermassTexture,clusterPositionsTexture:this.clusterPositionsTexture,clusterForceCoefficient:this.clusterForceCoefficientTexture,positionsTexture:this.points.previousPositionTexture}),e)this.applyForcesCommand.draw(e);else{const r=this.device.beginRenderPass({framebuffer:this.points.velocityFbo});this.applyForcesCommand.draw(r),r.end()}}destroy(){var e,t,i,r,s;(e=this.calculateCentermassUniformStore)==null||e.destroy(),this.calculateCentermassUniformStore=void 0,(t=this.applyForcesUniformStore)==null||t.destroy(),this.applyForcesUniformStore=void 0,(i=this.clearCentermassCommand)==null||i.destroy(),this.clearCentermassCommand=void 0,(r=this.calculateCentermassCommand)==null||r.destroy(),this.calculateCentermassCommand=void 0,(s=this.applyForcesCommand)==null||s.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,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.clearCentermassVertexCoordBuffer&&!this.clearCentermassVertexCoordBuffer.destroyed&&this.clearCentermassVertexCoordBuffer.destroy(),this.clearCentermassVertexCoordBuffer=void 0,this.applyForcesVertexCoordBuffer&&!this.applyForcesVertexCoordBuffer.destroyed&&this.applyForcesVertexCoordBuffer.destroy(),this.applyForcesVertexCoordBuffer=void 0}}function Oc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Ly(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var rr={exports:{}},Vy=rr.exports,Bc;function Hy(){return Bc||(Bc=1,function(n,e){(function(t,i){n.exports=i()})(Vy,function(){var t=`<div class="gl-box">
|
|
693
693
|
<svg viewBox="0 0 55 60">
|
|
694
694
|
<text x="27" y="56" class="gl-fps">00 FPS</text>
|
|
695
695
|
<text x="28" y="8" class="gl-mem"></text>
|
|
@@ -765,7 +765,7 @@ void main() {
|
|
|
765
765
|
#gl-bench .opacity {
|
|
766
766
|
stroke: #448844;
|
|
767
767
|
}
|
|
768
|
-
`;class r{constructor(o,a={}){this.css=i,this.svg=t,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],h=>{h.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,a),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let c
|
|
768
|
+
`;class r{constructor(o,a={}){this.css=i,this.svg=t,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],h=>{h.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,a),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let l,c=0,u,f=h=>{++c<20?l=requestAnimationFrame(f):(this.detected=Math.ceil(1e3*c/(h-u)/70),cancelAnimationFrame(l)),u||(u=h)};if(requestAnimationFrame(f),o){const h=async(_,I)=>Promise.resolve(setTimeout(()=>{o.getError();const C=this.now()-_;I.forEach((w,M)=>{w&&(this.gpuAccums[M]+=C)})},0)),d=(_,I,C)=>function(){const w=I.now();_.apply(C,arguments),I.trackGPU&&I.finished.push(h(w,I.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(_=>{o[_]&&(o[_]=d(o[_],this,o))}),o.getExtension=((_,I)=>function(){let C=_.apply(o,arguments);return C&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(w=>{C[w]&&(C[w]=d(C[w],I,C))}),C})(o.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let h=document.createElement("div");h.id="gl-bench",this.dom.appendChild(h),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=h,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((d,_,I)=>{const C=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],w=Object.assign({},C);return C.forEach(M=>w[M]=_.getElementsByClassName(M)),this.nodes=w,(M,E,x,R,O,L,W)=>{w["gl-cpu"][M].style.strokeDasharray=(E*.27).toFixed(0)+" 100",w["gl-gpu"][M].style.strokeDasharray=(x*.27).toFixed(0)+" 100",w["gl-mem"][M].innerHTML=I[M]?I[M]:R?"mem: "+R.toFixed(0)+"mb":"",w["gl-fps"][M].innerHTML=O.toFixed(0)+" FPS",d(I[M],E,x,R,O,L,W)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((d,_)=>{let I={"gl-chart":_.getElementsByClassName("gl-chart")};return(C,w,M)=>{let E="",x=w.length;for(let R=0;R<x;R++){let O=(M+R+1)%x;w[O]!=null&&(E=E+" "+(55*R/(x-1)).toFixed(1)+","+(45-w[O]*22/60/this.detected).toFixed(1))}I["gl-chart"][C].setAttribute("points",E),d(this.names[C],w,M)}})(this.chartLogger,this.dom)}}addUI(o){this.names.indexOf(o)==-1&&(this.names.push(o),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(o){this.frameId++;const a=o||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=a;else{let l=a-this.paramTime;if(l>=1e3){const c=this.frameId-this.paramFrame,u=c/l*1e3;for(let f=0;f<this.names.length;f++){const h=this.cpuAccums[f]/l*100,d=this.gpuAccums[f]/l*100,_=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(f,h,d,_,u,l,c),this.cpuAccums[f]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[f]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=a}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=a,this.circularId=0;else{let l=a-this.chartTime,c=this.chartHz*l/1e3;for(;--c>0&&this.detected;){const f=(this.frameId-this.chartFrame)/l*1e3;this.chart[this.circularId%this.chartLen]=f;for(let h=0;h<this.names.length;h++)this.chartLogger(h,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=a}}}begin(o){this.updateAccums(o)}end(o){this.updateAccums(o)}updateAccums(o){let a=this.names.indexOf(o);a==-1&&(a=this.names.length,this.addUI(o));const l=this.now(),c=l-this.t0;for(let u=0;u<a+1;u++)this.activeAccums[u]&&(this.cpuAccums[u]+=c);this.activeAccums[a]=!this.activeAccums[a],this.t0=l}}return r})}(rr)),rr.exports}var Wy=Hy();const $y=Oc(Wy),Xy=`
|
|
769
769
|
#gl-bench {
|
|
770
770
|
position:absolute;
|
|
771
771
|
right:0;
|
|
@@ -817,7 +817,7 @@ void main() {
|
|
|
817
817
|
#gl-bench .opacity {
|
|
818
818
|
stroke: #8288e4;
|
|
819
819
|
}
|
|
820
|
-
`;class
|
|
820
|
+
`;class Uc{constructor(e){this.destroy();const t=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new $y(t,{css:Xy})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var t,i;(t=this.bench)==null||t.end("frame"),(i=this.bench)==null||i.nextFrame(e)}destroy(){this.bench=void 0,Se("#gl-bench").remove()}}var zc=(n=>(n[n.Circle=0]="Circle",n[n.Square=1]="Square",n[n.Triangle=2]="Triangle",n[n.Diamond=3]="Diamond",n[n.Pentagon=4]="Pentagon",n[n.Hexagon=5]="Hexagon",n[n.Star=6]="Star",n[n.Cross=7]="Cross",n[n.None=8]="None",n))(zc||{});class Yy{constructor(e){this._config=e}get pointsNumber(){return this.pointPositions&&this.pointPositions.length/2}get linksNumber(){return this.links&&this.links.length/2}updatePoints(){this.pointPositions=this.inputPointPositions}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=vt(this._config.pointDefaultColor??this._config.pointColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let t=0;t<this.pointColors.length/4;t++)this.pointColors[t*4]=e[0],this.pointColors[t*4+1]=e[1],this.pointColors[t*4+2]=e[2],this.pointColors[t*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let t=0;t<this.pointColors.length/4;t++)qe(this.pointColors[t*4])||(this.pointColors[t*4]=e[0]),qe(this.pointColors[t*4+1])||(this.pointColors[t*4+1]=e[1]),qe(this.pointColors[t*4+2])||(this.pointColors[t*4+2]=e[2]),qe(this.pointColors[t*4+3])||(this.pointColors[t*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}const e=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(e);else{this.pointSizes=this.inputPointSizes;for(let t=0;t<this.pointSizes.length;t++)qe(this.pointSizes[t])||(this.pointSizes[t]=e)}}updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const e=0;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(e);else{this.pointShapes=new Float32Array(this.inputPointShapes);const t=this.pointShapes;for(let i=0;i<t.length;i++){const r=t[i];(r==null||!qe(r)||r<0||r>8)&&(t[i]=e)}}}updatePointImageIndices(){if(this.pointsNumber===void 0){this.pointImageIndices=void 0;return}if(this.inputPointImageIndices===void 0||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let t=0;t<e.length;t++){const i=e[t],r=i===void 0?NaN:i;!Number.isFinite(r)||r<0?e[t]=-1:e[t]=Math.trunc(r)}this.pointImageIndices=e}}updatePointImageSizes(){var t;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}const e=this._config.pointDefaultSize??this._config.pointSize;if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(e);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let i=0;i<this.pointImageSizes.length;i++)qe(this.pointImageSizes[i])||(this.pointImageSizes[i]=((t=this.pointSizes)==null?void 0:t[i])??e)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=vt(this._config.linkDefaultColor??this._config.linkColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let t=0;t<this.linkColors.length/4;t++)this.linkColors[t*4]=e[0],this.linkColors[t*4+1]=e[1],this.linkColors[t*4+2]=e[2],this.linkColors[t*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let t=0;t<this.linkColors.length/4;t++)qe(this.linkColors[t*4])||(this.linkColors[t*4]=e[0]),qe(this.linkColors[t*4+1])||(this.linkColors[t*4+1]=e[1]),qe(this.linkColors[t*4+2])||(this.linkColors[t*4+2]=e[2]),qe(this.linkColors[t*4+3])||(this.linkColors[t*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}const e=this._config.linkDefaultWidth??this._config.linkWidth;if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(e);else{this.linkWidths=this.inputLinkWidths;for(let t=0;t<this.linkWidths.length;t++)qe(this.linkWidths[t])||(this.linkWidths[t]=e)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}const e=this._config.linkDefaultArrows??this._config.linkArrows;this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+e):this.linkArrows=this.linkArrowsBoolean.map(t=>+t)}updateLinkStrength(){this.linksNumber===void 0&&(this.linkStrength=void 0),this.inputLinkStrength===void 0||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(this.pointsNumber===void 0){this.pointClusters=void 0,this.clusterPositions=void 0;return}this.inputPointClusters===void 0||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,this.inputClusterPositions===void 0?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,this.inputClusterStrength===void 0||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var t,i,r,s;return[...((i=(t=this.sourceIndexToTargetIndices)==null?void 0:t[e])==null?void 0:i.map(o=>o[0]))||[],...((s=(r=this.targetIndexToSourceIndices)==null?void 0:r[e])==null?void 0:s.map(o=>o[0]))||[]]}_createAdjacencyLists(){var e,t;if(this.linksNumber===void 0||this.links===void 0){this.sourceIndexToTargetIndices=void 0,this.targetIndexToSourceIndices=void 0;return}this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let i=0;i<this.linksNumber;i++){const r=this.links[i*2],s=this.links[i*2+1];r!==void 0&&s!==void 0&&(this.sourceIndexToTargetIndices[r]===void 0&&(this.sourceIndexToTargetIndices[r]=[]),(e=this.sourceIndexToTargetIndices[r])==null||e.push([s,i]),this.targetIndexToSourceIndices[s]===void 0&&(this.targetIndexToSourceIndices[s]=[]),(t=this.targetIndexToSourceIndices[s])==null||t.push([r,i]))}}_calculateDegrees(){var e,t,i,r;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 s=0;s<this.pointsNumber;s++)this.inDegree[s]=((t=(e=this.targetIndexToSourceIndices)==null?void 0:e[s])==null?void 0:t.length)??0,this.outDegree[s]=((r=(i=this.sourceIndexToTargetIndices)==null?void 0:i[s])==null?void 0:r.length)??0,this.degree[s]=(this.inDegree[s]??0)+(this.outDegree[s]??0)}}const qy=`#version 300 es
|
|
821
821
|
#ifdef GL_ES
|
|
822
822
|
precision highp float;
|
|
823
823
|
#endif
|
|
@@ -1176,7 +1176,7 @@ out vec2 vTexCoord;
|
|
|
1176
1176
|
void main() {
|
|
1177
1177
|
vTexCoord = (vertexCoord + 1.0) / 2.0;
|
|
1178
1178
|
gl_Position = vec4(vertexCoord, 0.0, 1.0);
|
|
1179
|
-
} `;function sr(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function Qy(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function Ll(n){let e,t,i;n.length!==2?(e=sr,t=(a,c)=>sr(n(a),c),i=(a,c)=>n(a)-c):(e=n===sr||n===Qy?n:Jy,t=n,i=n);function r(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const f=l+u>>>1;t(a[f],c)<0?l=f+1:u=f}while(l<u)}return l}function s(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const f=l+u>>>1;t(a[f],c)<=0?l=f+1:u=f}while(l<u)}return l}function o(a,c,l=0,u=a.length){const f=r(a,c,l,u-1);return f>l&&i(a[f-1],c)>-i(a[f],c)?f-1:f}return{left:r,center:o,right:s}}function Jy(){return 0}function Gy(n){return n===null?NaN:+n}const ev=Ll(sr).right;Ll(Gy).center;function Vl(n,e){let t,i;for(const r of n)r!=null&&(t===void 0?r>=r&&(t=i=r):(t>r&&(t=r),i<r&&(i=r)));return[t,i]}var po=Math.sqrt(50),mo=Math.sqrt(10),go=Math.sqrt(2);function tv(n,e,t){var i,r=-1,s,o,a;if(e=+e,n=+n,t=+t,n===e&&t>0)return[n];if((i=e<n)&&(s=n,n=e,e=s),(a=Hl(n,e,t))===0||!isFinite(a))return[];if(a>0){let c=Math.round(n/a),l=Math.round(e/a);for(c*a<n&&++c,l*a>e&&--l,o=new Array(s=l-c+1);++r<s;)o[r]=(c+r)*a}else{a=-a;let c=Math.round(n*a),l=Math.round(e*a);for(c/a<n&&++c,l/a>e&&--l,o=new Array(s=l-c+1);++r<s;)o[r]=(c+r)/a}return i&&o.reverse(),o}function Hl(n,e,t){var i=(e-n)/Math.max(0,t),r=Math.floor(Math.log(i)/Math.LN10),s=i/Math.pow(10,r);return r>=0?(s>=po?10:s>=mo?5:s>=go?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(s>=po?10:s>=mo?5:s>=go?2:1)}function nv(n,e,t){var i=Math.abs(e-n)/Math.max(0,t),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=i/r;return s>=po?r*=10:s>=mo?r*=5:s>=go&&(r*=2),e<n?-r:r}function iv(n,e,t){n=+n,e=+e,t=(r=arguments.length)<2?(e=n,n=0,1):r<3?1:+t;for(var i=-1,r=Math.max(0,Math.ceil((e-n)/t))|0,s=new Array(r);++i<r;)s[i]=n+i*t;return s}function Wl(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function rv(n){return function(){return n}}function sv(n){return+n}var $l=[0,1];function pt(n){return n}function _o(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:rv(isNaN(e)?NaN:.5)}function ov(n,e){var t;return n>e&&(t=n,n=e,e=t),function(i){return Math.max(n,Math.min(e,i))}}function av(n,e,t){var i=n[0],r=n[1],s=e[0],o=e[1];return r<i?(i=_o(r,i),s=t(o,s)):(i=_o(i,r),s=t(s,o)),function(a){return s(i(a))}}function cv(n,e,t){var i=Math.min(n.length,e.length)-1,r=new Array(i),s=new Array(i),o=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++o<i;)r[o]=_o(n[o],n[o+1]),s[o]=t(e[o],e[o+1]);return function(a){var c=ev(n,a,1,i)-1;return s[c](r[c](a))}}function Xl(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Yl(){var n=$l,e=$l,t=es,i,r,s,o=pt,a,c,l;function u(){var h=Math.min(n.length,e.length);return o!==pt&&(o=ov(n[0],n[h-1])),a=h>2?cv:av,c=l=null,f}function f(h){return h==null||isNaN(h=+h)?s:(c||(c=a(n.map(i),e,t)))(i(o(h)))}return f.invert=function(h){return o(r((l||(l=a(e,n.map(i),nt)))(h)))},f.domain=function(h){return arguments.length?(n=Array.from(h,sv),u()):n.slice()},f.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},f.rangeRound=function(h){return e=Array.from(h),t=ed,u()},f.clamp=function(h){return arguments.length?(o=h?!0:pt,u()):o!==pt},f.interpolate=function(h){return arguments.length?(t=h,u()):t},f.unknown=function(h){return arguments.length?(s=h,f):s},function(h,d){return i=h,r=d,u()}}function lv(){return Yl()(pt,pt)}function uv(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function or(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,i=n.slice(0,t);return[i.length>1?i[0]+i.slice(2):i,+n.slice(t+1)]}function mn(n){return n=or(Math.abs(n)),n?n[1]:NaN}function fv(n,e){return function(t,i){for(var r=t.length,s=[],o=0,a=n[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(t.substring(r-=a,r+a)),!((c+=a+1)>i));)a=n[o=(o+1)%n.length];return s.reverse().join(e)}}function hv(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var dv=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ar(n){if(!(e=dv.exec(n)))throw new Error("invalid format: "+n);var e;return new xo({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ar.prototype=xo.prototype;function xo(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}xo.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function pv(n){e:for(var e=n.length,t=1,i=-1,r;t<e;++t)switch(n[t]){case".":i=r=t;break;case"0":i===0&&(i=t),r=t;break;default:if(!+n[t])break e;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var ql;function mv(n,e){var t=or(n,e);if(!t)return n+"";var i=t[0],r=t[1],s=r-(ql=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+or(n,Math.max(0,e+s-1))[0]}function jl(n,e){var t=or(n,e);if(!t)return n+"";var i=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const Kl={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:uv,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>jl(n*100,e),r:jl,s:mv,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Zl(n){return n}var Ql=Array.prototype.map,Jl=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function gv(n){var e=n.grouping===void 0||n.thousands===void 0?Zl:fv(Ql.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?Zl:hv(Ql.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",c=n.nan===void 0?"NaN":n.nan+"";function l(f){f=ar(f);var h=f.fill,d=f.align,_=f.sign,I=f.symbol,C=f.zero,w=f.width,M=f.comma,E=f.precision,x=f.trim,R=f.type;R==="n"?(M=!0,R="g"):Kl[R]||(E===void 0&&(E=12),x=!0,R="g"),(C||h==="0"&&d==="=")&&(C=!0,h="0",d="=");var B=I==="$"?t:I==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",L=I==="$"?i:/[%p]/.test(R)?o:"",W=Kl[R],q=/[defgprs%]/.test(R);E=E===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function J(O){var oe=B,te=L,P,V,D;if(R==="c")te=W(O)+te,O="";else{O=+O;var $=O<0||1/O<0;if(O=isNaN(O)?c:W(Math.abs(O),E),x&&(O=pv(O)),$&&+O==0&&_!=="+"&&($=!1),oe=($?_==="("?_:a:_==="-"||_==="("?"":_)+oe,te=(R==="s"?Jl[8+ql/3]:"")+te+($&&_==="("?")":""),q){for(P=-1,V=O.length;++P<V;)if(D=O.charCodeAt(P),48>D||D>57){te=(D===46?r+O.slice(P+1):O.slice(P))+te,O=O.slice(0,P);break}}}M&&!C&&(O=e(O,1/0));var K=oe.length+O.length+te.length,j=K<w?new Array(w-K+1).join(h):"";switch(M&&C&&(O=e(j+O,j.length?w-te.length:1/0),j=""),d){case"<":O=oe+O+te+j;break;case"=":O=oe+j+O+te;break;case"^":O=j.slice(0,K=j.length>>1)+oe+O+te+j.slice(K);break;default:O=j+oe+O+te;break}return s(O)}return J.toString=function(){return f+""},J}function u(f,h){var d=l((f=ar(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(mn(h)/3)))*3,I=Math.pow(10,-_),C=Jl[8+_/3];return function(w){return d(I*w)+C}}return{format:l,formatPrefix:u}}var cr,Gl,eu;_v({thousands:",",grouping:[3],currency:["$",""]});function _v(n){return cr=gv(n),Gl=cr.format,eu=cr.formatPrefix,cr}function xv(n){return Math.max(0,-mn(Math.abs(n)))}function yv(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(mn(e)/3)))*3-mn(Math.abs(n)))}function vv(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,mn(e)-mn(n))+1}function bv(n,e,t,i){var r=nv(n,e,t),s;switch(i=ar(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return i.precision==null&&!isNaN(s=yv(r,o))&&(i.precision=s),eu(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=vv(r,Math.max(Math.abs(n),Math.abs(e))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=xv(r))&&(i.precision=s-(i.type==="%")*2);break}}return Gl(i)}function tu(n){var e=n.domain;return n.ticks=function(t){var i=e();return tv(i[0],i[i.length-1],t??10)},n.tickFormat=function(t,i){var r=e();return bv(r[0],r[r.length-1],t??10,i)},n.nice=function(t){t==null&&(t=10);var i=e(),r=0,s=i.length-1,o=i[r],a=i[s],c,l,u=10;for(a<o&&(l=o,o=a,a=l,l=r,r=s,s=l);u-- >0;){if(l=Hl(o,a,t),l===c)return i[r]=o,i[s]=a,e(i);if(l>0)o=Math.floor(o/l)*l,a=Math.ceil(a/l)*l;else if(l<0)o=Math.ceil(o*l)/l,a=Math.floor(a*l)/l;else break;c=l}return n},n}function yo(){var n=lv();return n.copy=function(){return Xl(n,yo())},Wl.apply(n,arguments),tu(n)}function nu(n){return function(e){return e<0?-Math.pow(-e,n):Math.pow(e,n)}}function Sv(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function Tv(n){return n<0?-n*n:n*n}function wv(n){var e=n(pt,pt),t=1;function i(){return t===1?n(pt,pt):t===.5?n(Sv,Tv):n(nu(t),nu(1/t))}return e.exponent=function(r){return arguments.length?(t=+r,i()):t},tu(e)}function iu(){var n=wv(Yl());return n.copy=function(){return Xl(n,iu()).exponent(n.exponent())},Wl.apply(n,arguments),n}const Av=n=>{const e=iu().exponent(2).range([0,1]).domain([-1,1]),t=iv(0,n).map(r=>-.5+r/n);t.push(.5);const i=new Array(t.length*2);return t.forEach((r,s)=>{i[s*2]=[e(r*2),.5],i[s*2+1]=[e(r*2),-.5]}),i};class Cv extends Dt{initPrograms(){var s,o,a;const{device:e,config:t,store:i}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.hoveredLineIndexTexture.copyImageData({data:new Float32Array(4).fill(0),bytesPerRow:1,mipLevel:0,x:0,y:0}),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:z.VERTEX|z.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=e.createBuffer({data:new Float32Array(r*2),usage:z.VERTEX|z.COPY_DST})),this.colorBuffer||(this.colorBuffer=e.createBuffer({data:new Float32Array(r*4),usage:z.VERTEX|z.COPY_DST})),this.widthBuffer||(this.widthBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.drawCurveCommand||(this.drawLineUniformStore||(this.drawLineUniformStore=new ge({drawLineUniforms:{uniformTypes:{transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",widthScale:"f32",linkArrowsSizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",linkVisibilityDistanceRange:"vec2<f32>",linkVisibilityMinTransparency:"f32",linkOpacity:"f32",greyoutOpacity:"f32",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32",scaleLinksOnZoom:"f32",maxPointSize:"f32",renderMode:"f32",hoveredLinkIndex:"f32",hoveredLinkColor:"vec4<f32>",hoveredLinkWidthIncrease:"f32"},defaultUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],linkVisibilityDistanceRange:t.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??H.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:i.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}})),this.drawCurveCommand=new le(e,{vs:jy,fs:qy,topology:"triangle-strip",vertexCount:((s=this.curveLineGeometry)==null?void 0:s.length)??0,attributes:{position:this.curveLineBuffer,pointA:this.pointABuffer,pointB:this.pointBBuffer,color:this.colorBuffer,width:this.widthBuffer,arrow:this.arrowBuffer,linkIndices:this.linkIndexBuffer},bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"color",format:"float32x4",stepMode:"instance"},{name:"width",format:"float32",stepMode:"instance"},{name:"arrow",format:"float32",stepMode:"instance"},{name:"linkIndices",format:"float32",stepMode:"instance"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineFragmentUniforms"),...((o=this.points)==null?void 0:o.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((a=this.points)==null?void 0:a.greyoutStatusTexture)&&{pointGreyoutStatus:this.points.greyoutStatusTexture}},parameters:{cullMode:"back",blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.hoveredLineIndexCommand||(this.quadBuffer||(this.quadBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:z.VERTEX|z.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new ge({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:i.screenMousePosition??[0,0],screenSize:i.screenSize??[0,0]}}})),this.hoveredLineIndexCommand=new le(e,{vs:Zy,fs:Ky,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.linkIndexTexture&&{linkIndexTexture:this.linkIndexTexture}}}))}draw(e){var r,s,o;if(!this.pointABuffer||!this.pointBBuffer||(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!this.drawCurveCommand||!this.drawLineUniformStore))return;const{config:t,store:i}=this;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],linkVisibilityDistanceRange:t.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??H.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:i.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineFragmentUniforms"),...((r=this.points)==null?void 0:r.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((o=(s=this.points)==null?void 0:s.greyoutStatusFbo)==null?void 0:o.colorAttachments[0])&&{pointGreyoutStatus:this.points.greyoutStatusFbo.colorAttachments[0]}}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e)}updateLinkIndexFbo(){var a,c;const{device:e,store:t}=this;if(!this.store.isLinkHoveringEnabled)return;const i=t.screenSize??[0,0],r=i[0],s=i[1];if(!r||!s)return;const o=((a=this.previousScreenSize)==null?void 0:a[0])!==r||((c=this.previousScreenSize)==null?void 0:c[1])!==s;(!this.linkIndexTexture||o)&&(this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=e.createTexture({width:r,height:s,format:"rgba32float",usage:G.SAMPLE|G.RENDER|G.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(r*s*4).fill(0),bytesPerRow:r,mipLevel:0,x:0,y:0}),this.linkIndexFbo=e.createFramebuffer({width:r,height:s,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[r,s])}updatePointsBuffer(){var c;const{device:e,data:t,store:i}=this;if(t.linksNumber===void 0||t.links===void 0)return;const r=new Float32Array(t.linksNumber*2),s=new Float32Array(t.linksNumber*2);for(let l=0;l<t.linksNumber;l++){const u=t.links[l*2],f=t.links[l*2+1],h=u%i.pointsTextureSize,d=Math.floor(u/i.pointsTextureSize),_=f%i.pointsTextureSize,I=Math.floor(f/i.pointsTextureSize);r[l*2]=h,r[l*2+1]=d,s[l*2]=_,s[l*2+1]=I}const o=(((c=this.pointABuffer)==null?void 0:c.byteLength)??0)/(Float32Array.BYTES_PER_ELEMENT*2);!this.pointABuffer||o!==t.linksNumber?(this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||o!==t.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=e.createBuffer({data:s,usage:z.VERTEX|z.COPY_DST})):this.pointBBuffer.write(s);const a=new Float32Array(t.linksNumber);for(let l=0;l<t.linksNumber;l++)a[l]=l;!this.linkIndexBuffer||o!==t.linksNumber?(this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=e.createBuffer({data:a,usage:z.VERTEX|z.COPY_DST})):this.linkIndexBuffer.write(a)}updateColor(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkColors??new Float32Array(i*4).fill(0);this.colorBuffer?(this.colorBuffer.byteLength??0)/(Float32Array.BYTES_PER_ELEMENT*4)!==i?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.colorBuffer.write(r):this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateWidth(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkWidths??new Float32Array(i).fill(0);this.widthBuffer?(this.widthBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.widthBuffer.write(r):this.widthBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateArrow(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkArrows?new Float32Array(t.linkArrows):new Float32Array(i).fill(0);this.arrowBuffer?(this.arrowBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.arrowBuffer.write(r):this.arrowBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateCurveLineGeometry(){const{device:e,config:{curvedLinks:t,curvedLinkSegments:i}}=this;this.curveLineGeometry=Av(t?i??H.curvedLinkSegments:1);const r=new Float32Array(this.curveLineGeometry.length*2);for(let s=0;s<this.curveLineGeometry.length;s++)r[s*2]=this.curveLineGeometry[s][0],r[s*2+1]=this.curveLineGeometry[s][1];this.curveLineBuffer?this.curveLineBuffer.write(r):this.curveLineBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setVertexCount(this.curveLineGeometry.length)}findHoveredLine(){var s,o,a;if(!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawCurveCommand||!this.drawLineUniformStore)return;const{config:e,store:t}=this;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:t.transformationMatrix4x4,pointsTextureSize:t.pointsTextureSize,widthScale:e.linkWidthScale??1,linkArrowsSizeScale:e.linkArrowsSizeScale??1,spaceSize:t.adjustedSpaceSize??0,screenSize:t.screenSize??[0,0],linkVisibilityDistanceRange:e.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:e.linkVisibilityMinTransparency??0,linkOpacity:e.linkOpacity??1,greyoutOpacity:e.linkGreyoutOpacity??1,curvedWeight:e.curvedLinkWeight??0,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance??0,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments??H.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom??!0?1:0,maxPointSize:t.maxPointSize??100,renderMode:1,hoveredLinkIndex:t.hoveredLinkIndex??-1,hoveredLinkColor:t.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurveCommand.setBindings({drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineFragmentUniforms"),...((s=this.points)==null?void 0:s.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((a=(o=this.points)==null?void 0:o.greyoutStatusFbo)==null?void 0:a.colorAttachments[0])&&{pointGreyoutStatus:this.points.greyoutStatusFbo.colorAttachments[0]}}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]}).end();const r=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurveCommand.draw(r),r.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:t.screenMousePosition??[0,0],screenSize:t.screenSize??[0,0]}}),this.hoveredLineIndexCommand.setBindings({hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(this.device,"hoveredLineIndexUniforms"),...this.linkIndexTexture&&{linkIndexTexture:this.linkIndexTexture}});const c=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(c),c.end()}}}const Pv=`#version 300 es
|
|
1179
|
+
} `;function sr(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function Qy(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function Lc(n){let e,t,i;n.length!==2?(e=sr,t=(a,l)=>sr(n(a),l),i=(a,l)=>n(a)-l):(e=n===sr||n===Qy?n:Jy,t=n,i=n);function r(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<0?c=f+1:u=f}while(c<u)}return c}function s(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<=0?c=f+1:u=f}while(c<u)}return c}function o(a,l,c=0,u=a.length){const f=r(a,l,c,u-1);return f>c&&i(a[f-1],l)>-i(a[f],l)?f-1:f}return{left:r,center:o,right:s}}function Jy(){return 0}function Gy(n){return n===null?NaN:+n}const ev=Lc(sr).right;Lc(Gy).center;function Vc(n,e){let t,i;for(const r of n)r!=null&&(t===void 0?r>=r&&(t=i=r):(t>r&&(t=r),i<r&&(i=r)));return[t,i]}var po=Math.sqrt(50),mo=Math.sqrt(10),go=Math.sqrt(2);function tv(n,e,t){var i,r=-1,s,o,a;if(e=+e,n=+n,t=+t,n===e&&t>0)return[n];if((i=e<n)&&(s=n,n=e,e=s),(a=Hc(n,e,t))===0||!isFinite(a))return[];if(a>0){let l=Math.round(n/a),c=Math.round(e/a);for(l*a<n&&++l,c*a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)*a}else{a=-a;let l=Math.round(n*a),c=Math.round(e*a);for(l/a<n&&++l,c/a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)/a}return i&&o.reverse(),o}function Hc(n,e,t){var i=(e-n)/Math.max(0,t),r=Math.floor(Math.log(i)/Math.LN10),s=i/Math.pow(10,r);return r>=0?(s>=po?10:s>=mo?5:s>=go?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(s>=po?10:s>=mo?5:s>=go?2:1)}function nv(n,e,t){var i=Math.abs(e-n)/Math.max(0,t),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=i/r;return s>=po?r*=10:s>=mo?r*=5:s>=go&&(r*=2),e<n?-r:r}function iv(n,e,t){n=+n,e=+e,t=(r=arguments.length)<2?(e=n,n=0,1):r<3?1:+t;for(var i=-1,r=Math.max(0,Math.ceil((e-n)/t))|0,s=new Array(r);++i<r;)s[i]=n+i*t;return s}function Wc(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function rv(n){return function(){return n}}function sv(n){return+n}var $c=[0,1];function pt(n){return n}function _o(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:rv(isNaN(e)?NaN:.5)}function ov(n,e){var t;return n>e&&(t=n,n=e,e=t),function(i){return Math.max(n,Math.min(e,i))}}function av(n,e,t){var i=n[0],r=n[1],s=e[0],o=e[1];return r<i?(i=_o(r,i),s=t(o,s)):(i=_o(i,r),s=t(s,o)),function(a){return s(i(a))}}function lv(n,e,t){var i=Math.min(n.length,e.length)-1,r=new Array(i),s=new Array(i),o=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++o<i;)r[o]=_o(n[o],n[o+1]),s[o]=t(e[o],e[o+1]);return function(a){var l=ev(n,a,1,i)-1;return s[l](r[l](a))}}function Xc(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Yc(){var n=$c,e=$c,t=es,i,r,s,o=pt,a,l,c;function u(){var h=Math.min(n.length,e.length);return o!==pt&&(o=ov(n[0],n[h-1])),a=h>2?lv:av,l=c=null,f}function f(h){return h==null||isNaN(h=+h)?s:(l||(l=a(n.map(i),e,t)))(i(o(h)))}return f.invert=function(h){return o(r((c||(c=a(e,n.map(i),nt)))(h)))},f.domain=function(h){return arguments.length?(n=Array.from(h,sv),u()):n.slice()},f.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},f.rangeRound=function(h){return e=Array.from(h),t=ed,u()},f.clamp=function(h){return arguments.length?(o=h?!0:pt,u()):o!==pt},f.interpolate=function(h){return arguments.length?(t=h,u()):t},f.unknown=function(h){return arguments.length?(s=h,f):s},function(h,d){return i=h,r=d,u()}}function cv(){return Yc()(pt,pt)}function uv(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function or(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,i=n.slice(0,t);return[i.length>1?i[0]+i.slice(2):i,+n.slice(t+1)]}function mn(n){return n=or(Math.abs(n)),n?n[1]:NaN}function fv(n,e){return function(t,i){for(var r=t.length,s=[],o=0,a=n[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),s.push(t.substring(r-=a,r+a)),!((l+=a+1)>i));)a=n[o=(o+1)%n.length];return s.reverse().join(e)}}function hv(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var dv=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ar(n){if(!(e=dv.exec(n)))throw new Error("invalid format: "+n);var e;return new xo({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ar.prototype=xo.prototype;function xo(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}xo.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function pv(n){e:for(var e=n.length,t=1,i=-1,r;t<e;++t)switch(n[t]){case".":i=r=t;break;case"0":i===0&&(i=t),r=t;break;default:if(!+n[t])break e;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var qc;function mv(n,e){var t=or(n,e);if(!t)return n+"";var i=t[0],r=t[1],s=r-(qc=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+or(n,Math.max(0,e+s-1))[0]}function jc(n,e){var t=or(n,e);if(!t)return n+"";var i=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const Kc={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:uv,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>jc(n*100,e),r:jc,s:mv,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Zc(n){return n}var Qc=Array.prototype.map,Jc=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function gv(n){var e=n.grouping===void 0||n.thousands===void 0?Zc:fv(Qc.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?Zc:hv(Qc.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function c(f){f=ar(f);var h=f.fill,d=f.align,_=f.sign,I=f.symbol,C=f.zero,w=f.width,M=f.comma,E=f.precision,x=f.trim,R=f.type;R==="n"?(M=!0,R="g"):Kc[R]||(E===void 0&&(E=12),x=!0,R="g"),(C||h==="0"&&d==="=")&&(C=!0,h="0",d="=");var O=I==="$"?t:I==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",L=I==="$"?i:/[%p]/.test(R)?o:"",W=Kc[R],q=/[defgprs%]/.test(R);E=E===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function Q(B){var fe=O,ne=L,P,H,F;if(R==="c")ne=W(B)+ne,B="";else{B=+B;var $=B<0||1/B<0;if(B=isNaN(B)?l:W(Math.abs(B),E),x&&(B=pv(B)),$&&+B==0&&_!=="+"&&($=!1),fe=($?_==="("?_:a:_==="-"||_==="("?"":_)+fe,ne=(R==="s"?Jc[8+qc/3]:"")+ne+($&&_==="("?")":""),q){for(P=-1,H=B.length;++P<H;)if(F=B.charCodeAt(P),48>F||F>57){ne=(F===46?r+B.slice(P+1):B.slice(P))+ne,B=B.slice(0,P);break}}}M&&!C&&(B=e(B,1/0));var Z=fe.length+B.length+ne.length,j=Z<w?new Array(w-Z+1).join(h):"";switch(M&&C&&(B=e(j+B,j.length?w-ne.length:1/0),j=""),d){case"<":B=fe+B+ne+j;break;case"=":B=fe+j+B+ne;break;case"^":B=j.slice(0,Z=j.length>>1)+fe+B+ne+j.slice(Z);break;default:B=j+fe+B+ne;break}return s(B)}return Q.toString=function(){return f+""},Q}function u(f,h){var d=c((f=ar(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(mn(h)/3)))*3,I=Math.pow(10,-_),C=Jc[8+_/3];return function(w){return d(I*w)+C}}return{format:c,formatPrefix:u}}var lr,Gc,eu;_v({thousands:",",grouping:[3],currency:["$",""]});function _v(n){return lr=gv(n),Gc=lr.format,eu=lr.formatPrefix,lr}function xv(n){return Math.max(0,-mn(Math.abs(n)))}function yv(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(mn(e)/3)))*3-mn(Math.abs(n)))}function vv(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,mn(e)-mn(n))+1}function bv(n,e,t,i){var r=nv(n,e,t),s;switch(i=ar(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return i.precision==null&&!isNaN(s=yv(r,o))&&(i.precision=s),eu(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=vv(r,Math.max(Math.abs(n),Math.abs(e))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=xv(r))&&(i.precision=s-(i.type==="%")*2);break}}return Gc(i)}function tu(n){var e=n.domain;return n.ticks=function(t){var i=e();return tv(i[0],i[i.length-1],t??10)},n.tickFormat=function(t,i){var r=e();return bv(r[0],r[r.length-1],t??10,i)},n.nice=function(t){t==null&&(t=10);var i=e(),r=0,s=i.length-1,o=i[r],a=i[s],l,c,u=10;for(a<o&&(c=o,o=a,a=c,c=r,r=s,s=c);u-- >0;){if(c=Hc(o,a,t),c===l)return i[r]=o,i[s]=a,e(i);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return n},n}function yo(){var n=cv();return n.copy=function(){return Xc(n,yo())},Wc.apply(n,arguments),tu(n)}function nu(n){return function(e){return e<0?-Math.pow(-e,n):Math.pow(e,n)}}function Sv(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function Tv(n){return n<0?-n*n:n*n}function wv(n){var e=n(pt,pt),t=1;function i(){return t===1?n(pt,pt):t===.5?n(Sv,Tv):n(nu(t),nu(1/t))}return e.exponent=function(r){return arguments.length?(t=+r,i()):t},tu(e)}function iu(){var n=wv(Yc());return n.copy=function(){return Xc(n,iu()).exponent(n.exponent())},Wc.apply(n,arguments),n}const Av=n=>{const e=iu().exponent(2).range([0,1]).domain([-1,1]),t=iv(0,n).map(r=>-.5+r/n);t.push(.5);const i=new Array(t.length*2);return t.forEach((r,s)=>{i[s*2]=[e(r*2),.5],i[s*2+1]=[e(r*2),-.5]}),i};class Cv extends Ft{initPrograms(){var s,o,a;const{device:e,config:t,store:i}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.hoveredLineIndexTexture.copyImageData({data:new Float32Array(4).fill(0),bytesPerRow:1,mipLevel:0,x:0,y:0}),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:z.VERTEX|z.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=e.createBuffer({data:new Float32Array(r*2),usage:z.VERTEX|z.COPY_DST})),this.colorBuffer||(this.colorBuffer=e.createBuffer({data:new Float32Array(r*4),usage:z.VERTEX|z.COPY_DST})),this.widthBuffer||(this.widthBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=e.createBuffer({data:new Float32Array(r),usage:z.VERTEX|z.COPY_DST})),this.drawCurveCommand||(this.drawLineUniformStore||(this.drawLineUniformStore=new ge({drawLineUniforms:{uniformTypes:{transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",widthScale:"f32",linkArrowsSizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",linkVisibilityDistanceRange:"vec2<f32>",linkVisibilityMinTransparency:"f32",linkOpacity:"f32",greyoutOpacity:"f32",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32",scaleLinksOnZoom:"f32",maxPointSize:"f32",renderMode:"f32",hoveredLinkIndex:"f32",hoveredLinkColor:"vec4<f32>",hoveredLinkWidthIncrease:"f32"},defaultUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],linkVisibilityDistanceRange:t.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:i.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}})),this.drawCurveCommand=new le(e,{vs:jy,fs:qy,topology:"triangle-strip",vertexCount:((s=this.curveLineGeometry)==null?void 0:s.length)??0,attributes:{position:this.curveLineBuffer,pointA:this.pointABuffer,pointB:this.pointBBuffer,color:this.colorBuffer,width:this.widthBuffer,arrow:this.arrowBuffer,linkIndices:this.linkIndexBuffer},bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"color",format:"float32x4",stepMode:"instance"},{name:"width",format:"float32",stepMode:"instance"},{name:"arrow",format:"float32",stepMode:"instance"},{name:"linkIndices",format:"float32",stepMode:"instance"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineFragmentUniforms"),...((o=this.points)==null?void 0:o.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((a=this.points)==null?void 0:a.greyoutStatusTexture)&&{pointGreyoutStatus:this.points.greyoutStatusTexture}},parameters:{cullMode:"back",blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.hoveredLineIndexCommand||(this.quadBuffer||(this.quadBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:z.VERTEX|z.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new ge({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:i.screenMousePosition??[0,0],screenSize:i.screenSize??[0,0]}}})),this.hoveredLineIndexCommand=new le(e,{vs:Zy,fs:Ky,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.linkIndexTexture&&{linkIndexTexture:this.linkIndexTexture}}}))}draw(e){var r,s;if(!this.pointABuffer||!this.pointBBuffer||(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!this.drawCurveCommand||!this.drawLineUniformStore))return;const{config:t,store:i}=this;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],linkVisibilityDistanceRange:t.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:i.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineFragmentUniforms"),...((r=this.points)==null?void 0:r.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((s=this.points)==null?void 0:s.greyoutStatusTexture)&&{pointGreyoutStatus:this.points.greyoutStatusTexture}}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e)}updateLinkIndexFbo(){var a,l;const{device:e,store:t}=this;if(!this.store.isLinkHoveringEnabled)return;const i=t.screenSize??[0,0],r=i[0],s=i[1];if(!r||!s)return;const o=((a=this.previousScreenSize)==null?void 0:a[0])!==r||((l=this.previousScreenSize)==null?void 0:l[1])!==s;(!this.linkIndexTexture||o)&&(this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=e.createTexture({width:r,height:s,format:"rgba32float",usage:J.SAMPLE|J.RENDER|J.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(r*s*4).fill(0),bytesPerRow:r,mipLevel:0,x:0,y:0}),this.linkIndexFbo=e.createFramebuffer({width:r,height:s,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[r,s])}updatePointsBuffer(){var l;const{device:e,data:t,store:i}=this;if(t.linksNumber===void 0||t.links===void 0)return;const r=new Float32Array(t.linksNumber*2),s=new Float32Array(t.linksNumber*2);for(let c=0;c<t.linksNumber;c++){const u=t.links[c*2],f=t.links[c*2+1],h=u%i.pointsTextureSize,d=Math.floor(u/i.pointsTextureSize),_=f%i.pointsTextureSize,I=Math.floor(f/i.pointsTextureSize);r[c*2]=h,r[c*2+1]=d,s[c*2]=_,s[c*2+1]=I}const o=(((l=this.pointABuffer)==null?void 0:l.byteLength)??0)/(Float32Array.BYTES_PER_ELEMENT*2);!this.pointABuffer||o!==t.linksNumber?(this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||o!==t.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=e.createBuffer({data:s,usage:z.VERTEX|z.COPY_DST})):this.pointBBuffer.write(s);const a=new Float32Array(t.linksNumber);for(let c=0;c<t.linksNumber;c++)a[c]=c;!this.linkIndexBuffer||o!==t.linksNumber?(this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=e.createBuffer({data:a,usage:z.VERTEX|z.COPY_DST})):this.linkIndexBuffer.write(a)}updateColor(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkColors??new Float32Array(i*4).fill(0);this.colorBuffer?(this.colorBuffer.byteLength??0)/(Float32Array.BYTES_PER_ELEMENT*4)!==i?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.colorBuffer.write(r):this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateWidth(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkWidths??new Float32Array(i).fill(0);this.widthBuffer?(this.widthBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.widthBuffer.write(r):this.widthBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateArrow(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkArrows?new Float32Array(t.linkArrows):new Float32Array(i).fill(0);this.arrowBuffer?(this.arrowBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.arrowBuffer.write(r):this.arrowBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})}updateCurveLineGeometry(){const{device:e,config:{curvedLinks:t,curvedLinkSegments:i}}=this;this.curveLineGeometry=Av(t?i??V.curvedLinkSegments:1);const r=new Float32Array(this.curveLineGeometry.length*2);for(let s=0;s<this.curveLineGeometry.length;s++)r[s*2]=this.curveLineGeometry[s][0],r[s*2+1]=this.curveLineGeometry[s][1];this.curveLineBuffer?this.curveLineBuffer.write(r):this.curveLineBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setVertexCount(this.curveLineGeometry.length)}findHoveredLine(){var s,o;if(!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawCurveCommand||!this.drawLineUniformStore)return;const{config:e,store:t}=this;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:t.transformationMatrix4x4,pointsTextureSize:t.pointsTextureSize,widthScale:e.linkWidthScale??1,linkArrowsSizeScale:e.linkArrowsSizeScale??1,spaceSize:t.adjustedSpaceSize??0,screenSize:t.screenSize??[0,0],linkVisibilityDistanceRange:e.linkVisibilityDistanceRange??[0,0],linkVisibilityMinTransparency:e.linkVisibilityMinTransparency??0,linkOpacity:e.linkOpacity??1,greyoutOpacity:e.linkGreyoutOpacity??1,curvedWeight:e.curvedLinkWeight??0,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance??0,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom??!0?1:0,maxPointSize:t.maxPointSize??100,renderMode:1,hoveredLinkIndex:t.hoveredLinkIndex??-1,hoveredLinkColor:t.hoveredLinkColor??[-1,-1,-1,-1],hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurveCommand.setBindings({drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(this.device,"drawLineFragmentUniforms"),...((s=this.points)==null?void 0:s.currentPositionTexture)&&{positionsTexture:this.points.currentPositionTexture},...((o=this.points)==null?void 0:o.greyoutStatusTexture)&&{pointGreyoutStatus:this.points.greyoutStatusTexture}}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]}).end();const r=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurveCommand.draw(r),r.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:t.screenMousePosition??[0,0],screenSize:t.screenSize??[0,0]}}),this.hoveredLineIndexCommand.setBindings({hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(this.device,"hoveredLineIndexUniforms"),...this.linkIndexTexture&&{linkIndexTexture:this.linkIndexTexture}});const a=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(a),a.end()}}}const Pv=`#version 300 es
|
|
1180
1180
|
#ifdef GL_ES
|
|
1181
1181
|
precision highp float;
|
|
1182
1182
|
#endif
|
|
@@ -1856,7 +1856,7 @@ void main () {
|
|
|
1856
1856
|
float opacity = smoothstep(r, r * smoothing, 1.0);
|
|
1857
1857
|
float stroke = smoothstep(width, width * smoothing, r);
|
|
1858
1858
|
fragColor = vec4(rgbColor, opacity * stroke * pointOpacity);
|
|
1859
|
-
}`,
|
|
1859
|
+
}`,Dv=`#version 300 es
|
|
1860
1860
|
#ifdef GL_ES
|
|
1861
1861
|
precision highp float;
|
|
1862
1862
|
#endif
|
|
@@ -2000,7 +2000,7 @@ void main () {
|
|
|
2000
2000
|
#endif
|
|
2001
2001
|
|
|
2002
2002
|
gl_Position = vec4(final.rg, 0, 1);
|
|
2003
|
-
}`,
|
|
2003
|
+
}`,Fv=`#version 300 es
|
|
2004
2004
|
#ifdef GL_ES
|
|
2005
2005
|
precision highp float;
|
|
2006
2006
|
#endif
|
|
@@ -2171,6 +2171,7 @@ precision highp float;
|
|
|
2171
2171
|
|
|
2172
2172
|
uniform sampler2D positionsTexture;
|
|
2173
2173
|
uniform sampler2D velocity;
|
|
2174
|
+
uniform sampler2D pinnedStatusTexture;
|
|
2174
2175
|
|
|
2175
2176
|
#ifdef USE_UNIFORM_BUFFERS
|
|
2176
2177
|
layout(std140) uniform updatePositionUniforms {
|
|
@@ -2193,6 +2194,17 @@ void main() {
|
|
|
2193
2194
|
vec4 pointPosition = texture(positionsTexture, textureCoords);
|
|
2194
2195
|
vec4 pointVelocity = texture(velocity, textureCoords);
|
|
2195
2196
|
|
|
2197
|
+
// Check if point is pinned
|
|
2198
|
+
// pinnedStatusTexture has the same size and layout as positionsTexture
|
|
2199
|
+
// Each pixel corresponds to a point: red channel > 0.5 means the point is pinned
|
|
2200
|
+
vec4 pinnedStatus = texture(pinnedStatusTexture, textureCoords);
|
|
2201
|
+
|
|
2202
|
+
// If pinned, don't update position
|
|
2203
|
+
if (pinnedStatus.r > 0.5) {
|
|
2204
|
+
fragColor = pointPosition;
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2196
2208
|
// Friction
|
|
2197
2209
|
pointVelocity.rg *= friction;
|
|
2198
2210
|
|
|
@@ -2265,7 +2277,7 @@ void main() {
|
|
|
2265
2277
|
}
|
|
2266
2278
|
|
|
2267
2279
|
fragColor = pointPosition;
|
|
2268
|
-
}`;function Lv(n,e=16384){if(!(n!=null&&n.length))return null;let t=0;for(const l of n){const u=Math.max(l.width,l.height);u>t&&(t=u)}if(t===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const i=t,r=Math.ceil(Math.sqrt(n.length));let s=r*t,o=1;s>e&&(o=e/s,t=Math.max(1,Math.floor(t*o)),s=Math.max(1,Math.floor(s*o)),console.warn(`🖼️ Atlas scaling required: Original size ${(i*r).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${s.toLocaleString()}px (${Math.round(o*100)}% of original quality)`));const a=new Uint8Array(s*s*4).fill(0),c=new Float32Array(r*r*4).fill(-1);for(const[l,u]of n.entries()){const f=u.width,h=u.height;if(f===0||h===0)continue;const d=Math.min(1,t/Math.max(f,h)),_=Math.floor(f*d),I=Math.floor(h*d),C=Math.floor(l/r),M=l%r*t,E=C*t;c[l*4]=M/s,c[l*4+1]=E/s,c[l*4+2]=(M+_)/s,c[l*4+3]=(E+I)/s;for(let x=0;x<I;x++)for(let R=0;R<_;R++){const B=Math.floor(R*(f/_)),W=(Math.floor(x*(h/I))*f+B)*4,q=((E+x)*s+(M+R))*4;a[q]=u.data[W]??0,a[q+1]=u.data[W+1]??0,a[q+2]=u.data[W+2]??0,a[q+3]=u.data[W+3]??255}}return{atlasData:a,atlasSize:s,atlasCoords:c,atlasCoordsSize:r}}class Vv extends Dt{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){var _,I,C;const{device:e,store:t,data:i,config:{rescalePositions:r,enableSimulation:s}}=this,{pointsTextureSize:o}=t;if(!o||!i.pointPositions||i.pointsNumber===void 0)return;const a=o*o*4,c=new Float32Array(a),l=o*o*4*4,u=c.byteLength;u!==l&&console.error("Texture data size mismatch:",{pointsTextureSize:o,expectedBytes:l,actualBytes:u,textureDataSize:a,dataLength:c.length});let f=r;r===void 0&&!s&&(f=!0),this.shouldSkipRescale&&(f=!1),f?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let w=0;w<i.pointsNumber;++w)c[w*4+0]=i.pointPositions[w*2+0],c[w*4+1]=i.pointPositions[w*2+1],c[w*4+2]=w;if(!this.currentPositionTexture||this.currentPositionTexture.width!==o||this.currentPositionTexture.height!==o?(this.currentPositionTexture&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&this.currentPositionFbo.destroy(),this.currentPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.currentPositionTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.currentPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.currentPositionTexture]})):this.currentPositionTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),!this.previousPositionTexture||this.previousPositionTexture.width!==o||this.previousPositionTexture.height!==o?(this.previousPositionTexture&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&this.previousPositionFbo.destroy(),this.previousPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.previousPositionTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.previousPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.previousPositionTexture]})):this.previousPositionTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.config.enableSimulation){const w=new Float32Array(o*o*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==o||this.velocityTexture.height!==o?(this.velocityTexture&&this.velocityTexture.destroy(),this.velocityFbo&&this.velocityFbo.destroy(),this.velocityTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.velocityTexture.copyImageData({data:w,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.velocityFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.velocityTexture]})):this.velocityTexture.copyImageData({data:w,bytesPerRow:o,mipLevel:0,x:0,y:0})}!this.selectedTexture||this.selectedTexture.width!==o||this.selectedTexture.height!==o?(this.selectedTexture&&this.selectedTexture.destroy(),this.selectedFbo&&this.selectedFbo.destroy(),this.selectedTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.selectedTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.selectedFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.selectedTexture]})):this.selectedTexture.copyImageData({data:c,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=e.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const h=Qn(t.pointsTextureSize),d=h.byteLength;!this.drawPointIndices||this.drawPointIndices.byteLength!==d?((_=this.drawPointIndices)==null||_.destroy(),this.drawPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.drawPointIndices.write(h),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==d?((I=this.hoveredPointIndices)==null||I.destroy(),this.hoveredPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.hoveredPointIndices.write(h),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==d?((C=this.sampledPointIndices)==null||C.destroy(),this.sampledPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.sampledPointIndices.write(h),this.updateGreyoutStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){var s,o,a;const{device:e,config:t,store:i,data:r}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.greyoutStatusTexture||this.updateGreyoutStatus(),t.enableSimulation&&(this.updatePositionCommand||(this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new ge({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:t.simulationFriction??0,spaceSize:i.adjustedSpaceSize??0}}})),this.updatePositionCommand=new le(e,{fs:Bv,vs:Ie,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"),...this.previousPositionTexture&&{positionsTexture:this.previousPositionTexture},...this.velocityTexture&&{velocity:this.velocityTexture}}}))),this.dragPointCommand||(this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new ge({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:i.mousePosition??[0,0],index:((s=i.hoveredPoint)==null?void 0:s.index)??-1}}})),this.dragPointCommand=new le(e,{fs:zv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(e,"dragPointUniforms"),...this.previousPositionTexture&&{positionsTexture:this.previousPositionTexture}}})),this.drawCommand||(this.drawUniformStore||(this.drawUniformStore=new ge({drawVertexUniforms:{uniformTypes:{ratio:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",greyoutColor:"vec4<f32>",backgroundColor:"vec4<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",isDarkenGreyout:"f32",skipSelected:"f32",skipUnselected:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32"},defaultUniforms:{ratio:t.pixelRatio??H.pixelRatio,transformationMatrix:(()=>{const c=i.transform??[1,0,0,0,1,0,0,0,1];return[c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]})(),pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],greyoutColor:i.greyoutPointColor??[0,0,0,1],backgroundColor:i.backgroundColor??[0,0,0,1],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,skipSelected:0,skipUnselected:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>"},defaultUniforms:{greyoutOpacity:t.pointGreyoutOpacity??-1,pointOpacity:t.pointOpacity??1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:i.backgroundColor??[0,0,0,1]}}})),this.drawCommand=new le(e,{fs:Pv,vs:Iv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"color",format:"float32x4"},{name:"shape",format:"float32"},{name:"imageIndex",format:"float32"},{name:"imageSize",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawFragmentUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.greyoutStatusTexture&&{pointGreyoutStatus:this.greyoutStatusTexture},...this.imageAtlasTexture&&{imageAtlasTexture:this.imageAtlasTexture},...this.imageAtlasCoordsTexture&&{imageAtlasCoords:this.imageAtlasCoordsTexture}},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.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionVertexCoordBuffer||(this.findPointsOnAreaSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnAreaSelectionUniformStore||(this.findPointsOnAreaSelectionUniformStore=new ge({findPointsOnAreaSelectionUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",selection0:"vec2<f32>",selection1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],ratio:t.pixelRatio??H.pixelRatio,transformationMatrix:i.transformationMatrix4x4,selection0:((o=i.selectedArea)==null?void 0:o[0])??[0,0],selection1:((a=i.selectedArea)==null?void 0:a[1])??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findPointsOnAreaSelectionCommand=new le(e,{fs:Rv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnAreaSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnAreaSelectionUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.sizeTexture&&{pointSize:this.sizeTexture}}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionVertexCoordBuffer||(this.findPointsOnPolygonSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnPolygonSelectionUniformStore||(this.findPointsOnPolygonSelectionUniformStore=new ge({findPointsOnPolygonSelectionUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],transformationMatrix:i.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsOnPolygonSelectionCommand=new le(e,{fs:Ev,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnPolygonSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnPolygonSelectionUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.polygonPathTexture&&{polygonPathTexture:this.polygonPathTexture}}})),this.clearHoveredFboCommand||(this.clearHoveredFboVertexCoordBuffer||(this.clearHoveredFboVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearHoveredFboCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearHoveredFboVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),this.findHoveredPointCommand||(this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new ge({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],ratio:t.pixelRatio??H.pixelRatio,transformationMatrix:i.transformationMatrix4x4,mousePosition:i.screenMousePosition??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findHoveredPointCommand=new le(e,{fs:Dv,vs:Mv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(e,"findHoveredPointUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture}},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboVertexCoordBuffer||(this.clearSampledPointsFboVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearSampledPointsFboCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearSampledPointsFboVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),this.fillSampledPointsFboCommand||(this.fillSampledPointsUniformStore||(this.fillSampledPointsUniformStore=new ge({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,transformationMatrix:i.transformationMatrix4x4,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0]}}})),this.fillSampledPointsFboCommand=new le(e,{fs:Nv,vs:Ov,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.sampledPointIndices&&{pointIndices:this.sampledPointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(e,"fillSampledPointsUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture}},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.drawHighlightedCommand||(this.drawHighlightedVertexCoordBuffer||(this.drawHighlightedVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.drawHighlightedUniformStore||(this.drawHighlightedUniformStore=new ge({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:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,pointIndex:-1,maxPointSize:i.maxPointSize??100,color:[0,0,0,1],universalPointOpacity:t.pointOpacity??1,greyoutOpacity:t.pointGreyoutOpacity??-1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:i.backgroundColor??[0,0,0,1],greyoutColor:i.greyoutPointColor??[0,0,0,1],width:.85}}})),this.drawHighlightedCommand=new le(e,{fs:kv,vs:Fv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(e,"drawHighlightedUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.greyoutStatusTexture&&{pointGreyoutStatusTexture:this.greyoutStatusTexture}},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.trackPointsCommand||(this.trackPointsVertexCoordBuffer||(this.trackPointsVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.trackPointsUniformStore||(this.trackPointsUniformStore=new ge({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0}}})),this.trackPointsCommand=new le(e,{fs:Uv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.trackPointsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(e,"trackPointsUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.trackedIndicesTexture&&{trackedIndices:this.trackedIndicesTexture}}}))}updateColor(){var o;const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=i.pointColors,s=r.byteLength;!this.colorBuffer||this.colorBuffer.byteLength!==s?((o=this.colorBuffer)==null||o.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.colorBuffer.write(r)}updateGreyoutStatus(){const{device:e,store:{selectedIndices:t,pointsTextureSize:i}}=this;if(!i)return;const r=new Float32Array(i*i*4).fill(t?1:0);if(t)for(const s of t)r[s*4]=0;!this.greyoutStatusTexture||this.greyoutStatusTexture.width!==i||this.greyoutStatusTexture.height!==i?(this.greyoutStatusTexture&&this.greyoutStatusTexture.destroy(),this.greyoutStatusFbo&&this.greyoutStatusFbo.destroy(),this.greyoutStatusTexture=e.createTexture({width:i,height:i,format:"rgba32float"}),this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0}),this.greyoutStatusFbo=e.createFramebuffer({width:i,height:i,colorAttachments:[this.greyoutStatusTexture]})):this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})}updateSize(){var a;const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t||i.pointsNumber===void 0||i.pointSizes===void 0)return;const r=i.pointSizes,s=r.byteLength;!this.sizeBuffer||this.sizeBuffer.byteLength!==s?((a=this.sizeBuffer)==null||a.destroy(),this.sizeBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.sizeBuffer.write(r);const o=new Float32Array(t*t*4);for(let c=0;c<i.pointsNumber;c++)o[c*4]=i.pointSizes[c];!this.sizeTexture||this.sizeTexture.width!==t||this.sizeTexture.height!==t?(this.sizeTexture&&this.sizeTexture.destroy(),this.sizeFbo&&this.sizeFbo.destroy(),this.sizeTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.sizeTexture.copyImageData({data:o,bytesPerRow:t,mipLevel:0,x:0,y:0}),this.sizeFbo=e.createFramebuffer({width:t,height:t,colorAttachments:[this.sizeTexture]})):this.sizeTexture.copyImageData({data:o,bytesPerRow:t,mipLevel:0,x:0,y:0})}updateShape(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointShapes===void 0)return;const i=t.pointShapes,r=i.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==r?((s=this.shapeBuffer)==null||s.destroy(),this.shapeBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.shapeBuffer.write(i)}updateImageIndices(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageIndices===void 0)return;const i=t.pointImageIndices,r=i.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==r?((s=this.imageIndicesBuffer)==null||s.destroy(),this.imageIndicesBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.imageIndicesBuffer.write(i)}updateImageSizes(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageSizes===void 0)return;const i=t.pointImageSizes,r=i.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==r?((s=this.imageSizesBuffer)==null||s.destroy(),this.imageSizesBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.imageSizesBuffer.write(i)}createAtlas(){var l,u,f;const{device:e,data:t,store:i}=this;if(!((l=t.inputImageData)!=null&&l.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=e.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=e.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const r=Lv(t.inputImageData,i.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=t.inputImageData.length;const{atlasData:s,atlasSize:o,atlasCoords:a,atlasCoordsSize:c}=r;this.imageAtlasCoordsTextureSize=c,(u=this.imageAtlasTexture)==null||u.destroy(),this.imageAtlasTexture=e.createTexture({width:o,height:o,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:s,bytesPerRow:o,rowsPerImage:o,mipLevel:0,x:0,y:0}),(f=this.imageAtlasCoordsTexture)==null||f.destroy(),this.imageAtlasCoordsTexture=e.createTexture({width:c,height:c,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:a,bytesPerRow:c,rowsPerImage:c,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},device:i}=this;let r=t??Math.min(...e)/2;r===0&&(r=H.pointSamplingDistance);const s=Math.ceil(e[0]/r),o=Math.ceil(e[1]/r);(!this.sampledPointsFbo||this.sampledPointsFbo.width!==s||this.sampledPointsFbo.height!==o)&&(this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=i.createFramebuffer({width:s,height:o,colorAttachments:["rgba32float"]}))}trackPoints(){var t;if(!((t=this.trackedIndices)!=null&&t.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({trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(this.device,"trackPointsUniforms"),positionsTexture:this.currentPositionTexture,trackedIndices:this.trackedIndicesTexture});const e=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(e),e.end()}draw(e){var a,c;const{data:t,config:i,store:r}=this;if(this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!t.pointsNumber||t.pointsNumber===0||!r.screenSize||r.screenSize[0]===0||r.screenSize[1]===0)return;this.drawCommand.setVertexCount(t.pointsNumber);const s={ratio:i.pixelRatio??H.pixelRatio,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],greyoutColor:r.greyoutPointColor??[-1,-1,-1,-1],backgroundColor:r.backgroundColor??[0,0,0,1],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0},o={greyoutOpacity:i.pointGreyoutOpacity??-1,pointOpacity:i.pointOpacity??1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1]};if(r.selectedIndices&&r.selectedIndices.length>0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:1,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:1},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),i.renderHoveredPointRing&&r.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const l=((a=t.pointSizes)==null?void 0:a[r.hoveredPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:l,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.hoveredPoint.index,maxPointSize:r.maxPointSize??100,color:r.hoveredPointRingColor,universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1],greyoutColor:r.greyoutPointColor??[0,0,0,1],width:.85}}),this.drawHighlightedCommand.setBindings({drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(this.device,"drawHighlightedUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}if(r.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const l=((c=t.pointSizes)==null?void 0:c[r.focusedPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:l,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.focusedPoint.index,maxPointSize:r.maxPointSize??100,color:r.focusedPointRingColor,universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1],greyoutColor:r.greyoutPointColor??[0,0,0,1],width:.85}}),this.drawHighlightedCommand.setBindings({drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(this.device,"drawHighlightedUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}}updatePosition(){if(!this.updatePositionCommand||!this.updatePositionUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.velocityTexture||this.velocityTexture.destroyed)return;this.updatePositionUniformStore.setUniforms({updatePositionUniforms:{friction:this.config.simulationFriction??0,spaceSize:this.store.adjustedSpaceSize??0}}),this.updatePositionCommand.setBindings({updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(this.device,"updatePositionUniforms"),positionsTexture:this.previousPositionTexture,velocity:this.velocityTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.updatePositionCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var t;if(!this.dragPointCommand||!this.dragPointUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed)return;this.dragPointUniformStore.setUniforms({dragPointUniforms:{mousePos:this.store.mousePosition??[0,0],index:((t=this.store.hoveredPoint)==null?void 0:t.index)??-1}}),this.dragPointCommand.setBindings({dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(this.device,"dragPointUniforms"),positionsTexture:this.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var t,i;if(!this.findPointsOnAreaSelectionCommand||!this.findPointsOnAreaSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return;this.findPointsOnAreaSelectionUniformStore.setUniforms({findPointsOnAreaSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],sizeScale:this.config.pointSizeScale??1,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio??H.pixelRatio,selection0:((t=this.store.selectedArea)==null?void 0:t[0])??[0,0],selection1:((i=this.store.selectedArea)==null?void 0:i[1])??[0,0],scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,maxPointSize:this.store.maxPointSize??100}}),this.findPointsOnAreaSelectionCommand.setBindings({findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(this.device,"findPointsOnAreaSelectionUniforms"),positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnAreaSelectionCommand.draw(e),e.end()}findPointsOnPolygonSelection(){if(!this.findPointsOnPolygonSelectionCommand||!this.findPointsOnPolygonSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return;this.findPointsOnPolygonSelectionUniformStore.setUniforms({findPointsOnPolygonSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsOnPolygonSelectionCommand.setBindings({findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(this.device,"findPointsOnPolygonSelectionUniforms"),positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnPolygonSelectionCommand.draw(e),e.end()}updatePolygonPath(e){const{device:t}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.polygonPathFbo&&!this.polygonPathFbo.destroyed&&this.polygonPathFbo.destroy(),this.polygonPathFbo=void 0;return}const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4);for(const[s,o]of e.entries()){const[a,c]=o;r[s*4]=a,r[s*4+1]=c,r[s*4+2]=0,r[s*4+3]=0}!this.polygonPathTexture||this.polygonPathTexture.width!==i||this.polygonPathTexture.height!==i?(this.polygonPathFbo&&!this.polygonPathFbo.destroyed&&this.polygonPathFbo.destroy(),this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=t.createTexture({width:i,height:i,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0}),this.polygonPathFbo=t.createFramebuffer({width:i,height:i,colorAttachments:[this.polygonPathTexture]})):this.polygonPathTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed)return;if(this.clearHoveredFboCommand){const t=this.device.beginRenderPass({framebuffer:this.hoveredFbo});this.clearHoveredFboCommand.draw(t),t.end()}if(!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed)return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}}),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{ratio:this.config.pixelRatio??H.pixelRatio,sizeScale:this.config.pointSizeScale??1,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,mousePosition:this.store.screenMousePosition??[0,0],maxPointSize:this.store.maxPointSize??100}}),this.findHoveredPointCommand.setBindings({findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(this.device,"findHoveredPointUniforms"),positionsTexture:this.currentPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.hoveredFbo});this.findHoveredPointCommand.draw(e),e.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:t},device:i}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!t)return;const r=Math.ceil(Math.sqrt(e.length)),s=new Float32Array(r*r*4).fill(-1);for(const[o,a]of e.entries())a!==void 0&&(s[o*4]=a%t,s[o*4+1]=Math.floor(a/t),s[o*4+2]=0,s[o*4+3]=0);!this.trackedIndicesTexture||this.trackedIndicesTexture.width!==r||this.trackedIndicesTexture.height!==r?(this.trackedIndicesFbo&&!this.trackedIndicesFbo.destroyed&&this.trackedIndicesFbo.destroy(),this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=i.createTexture({width:r,height:r,format:"rgba32float"}),this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:r,mipLevel:0,x:0,y:0}),this.trackedIndicesFbo=i.createFramebuffer({width:r,height:r,colorAttachments:[this.trackedIndicesTexture]})):this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:r,mipLevel:0,x:0,y:0}),(!this.trackedPositionsFbo||this.trackedPositionsFbo.width!==r||this.trackedPositionsFbo.height!==r)&&(this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=i.createFramebuffer({width:r,height:r,colorAttachments:["rgba32float"]})),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:t}}=this;if((!e||!t)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const i=We(this.device,this.trackedPositionsFbo),r=new Map;for(let s=0;s<i.length/4;s+=1){const o=i[s*4],a=i[s*4+1],c=this.trackedIndices[s];o!==void 0&&a!==void 0&&c!==void 0&&r.set(c,[o,a])}return(!e||!t)&&(this.trackedPositions=r,this.isPositionsUpToDate=!0),r}getSampledPointPositionsMap(){const e=new Map;if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return e;if(this.clearSampledPointsFboCommand){const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.clearSampledPointsFboCommand.draw(i),i.end()}if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return e;this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0]}}),this.fillSampledPointsFboCommand.setBindings({fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(this.device,"fillSampledPointsUniforms"),positionsTexture:this.currentPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.fillSampledPointsFboCommand.draw(i),i.end()}const t=We(this.device,this.sampledPointsFbo);for(let i=0;i<t.length/4;i++){const r=t[i*4],s=!!t[i*4+1],o=t[i*4+2],a=t[i*4+3];s&&r!==void 0&&o!==void 0&&a!==void 0&&e.set(r,[o,a])}return e}getSampledPoints(){const e=[],t=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:t};if(this.clearSampledPointsFboCommand){const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.clearSampledPointsFboCommand.draw(r),r.end()}if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:t};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0]}}),this.fillSampledPointsFboCommand.setBindings({fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(this.device,"fillSampledPointsUniforms"),positionsTexture:this.currentPositionTexture});const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.fillSampledPointsFboCommand.draw(r),r.end()}const i=We(this.device,this.sampledPointsFbo);for(let r=0;r<i.length/4;r++){const s=i[r*4],o=!!i[r*4+1],a=i[r*4+2],c=i[r*4+3];o&&s!==void 0&&a!==void 0&&c!==void 0&&(e.push(s),t.push(a,c))}return{indices:e,positions:t}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const t=We(this.device,this.trackedPositionsFbo);for(let i=0;i<t.length/4;i+=1){const r=t[i*4],s=t[i*4+1],o=this.trackedIndices[i];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}destroy(){var e,t,i,r,s,o,a,c,l,u,f,h,d,_,I,C,w,M,E,x;(e=this.updatePositionUniformStore)==null||e.destroy(),this.updatePositionUniformStore=void 0,(t=this.dragPointUniformStore)==null||t.destroy(),this.dragPointUniformStore=void 0,(i=this.drawUniformStore)==null||i.destroy(),this.drawUniformStore=void 0,(r=this.findPointsOnAreaSelectionUniformStore)==null||r.destroy(),this.findPointsOnAreaSelectionUniformStore=void 0,(s=this.findPointsOnPolygonSelectionUniformStore)==null||s.destroy(),this.findPointsOnPolygonSelectionUniformStore=void 0,(o=this.findHoveredPointUniformStore)==null||o.destroy(),this.findHoveredPointUniformStore=void 0,(a=this.fillSampledPointsUniformStore)==null||a.destroy(),this.fillSampledPointsUniformStore=void 0,(c=this.drawHighlightedUniformStore)==null||c.destroy(),this.drawHighlightedUniformStore=void 0,(l=this.trackPointsUniformStore)==null||l.destroy(),this.trackPointsUniformStore=void 0,(u=this.drawCommand)==null||u.destroy(),this.drawCommand=void 0,(f=this.drawHighlightedCommand)==null||f.destroy(),this.drawHighlightedCommand=void 0,(h=this.updatePositionCommand)==null||h.destroy(),this.updatePositionCommand=void 0,(d=this.dragPointCommand)==null||d.destroy(),this.dragPointCommand=void 0,(_=this.findPointsOnAreaSelectionCommand)==null||_.destroy(),this.findPointsOnAreaSelectionCommand=void 0,(I=this.findPointsOnPolygonSelectionCommand)==null||I.destroy(),this.findPointsOnPolygonSelectionCommand=void 0,(C=this.findHoveredPointCommand)==null||C.destroy(),this.findHoveredPointCommand=void 0,(w=this.clearHoveredFboCommand)==null||w.destroy(),this.clearHoveredFboCommand=void 0,(M=this.clearSampledPointsFboCommand)==null||M.destroy(),this.clearSampledPointsFboCommand=void 0,(E=this.fillSampledPointsFboCommand)==null||E.destroy(),this.fillSampledPointsFboCommand=void 0,(x=this.trackPointsCommand)==null||x.destroy(),this.trackPointsCommand=void 0,this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionFbo=void 0,this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedFbo=void 0,this.hoveredFbo&&!this.hoveredFbo.destroyed&&this.hoveredFbo.destroy(),this.hoveredFbo=void 0,this.greyoutStatusFbo&&!this.greyoutStatusFbo.destroyed&&this.greyoutStatusFbo.destroy(),this.greyoutStatusFbo=void 0,this.sizeFbo&&!this.sizeFbo.destroyed&&this.sizeFbo.destroy(),this.sizeFbo=void 0,this.trackedIndicesFbo&&!this.trackedIndicesFbo.destroyed&&this.trackedIndicesFbo.destroy(),this.trackedIndicesFbo=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.polygonPathFbo&&!this.polygonPathFbo.destroyed&&this.polygonPathFbo.destroy(),this.polygonPathFbo=void 0,this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionTexture=void 0,this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedTexture=void 0,this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=void 0,this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=void 0,this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=void 0,this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=void 0,this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=void 0,this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=void 0,this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=void 0,this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=void 0,this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=void 0,this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsOnAreaSelectionVertexCoordBuffer&&!this.findPointsOnAreaSelectionVertexCoordBuffer.destroyed&&this.findPointsOnAreaSelectionVertexCoordBuffer.destroy(),this.findPointsOnAreaSelectionVertexCoordBuffer=void 0,this.findPointsOnPolygonSelectionVertexCoordBuffer&&!this.findPointsOnPolygonSelectionVertexCoordBuffer.destroyed&&this.findPointsOnPolygonSelectionVertexCoordBuffer.destroy(),this.findPointsOnPolygonSelectionVertexCoordBuffer=void 0,this.clearHoveredFboVertexCoordBuffer&&!this.clearHoveredFboVertexCoordBuffer.destroyed&&this.clearHoveredFboVertexCoordBuffer.destroy(),this.clearHoveredFboVertexCoordBuffer=void 0,this.clearSampledPointsFboVertexCoordBuffer&&!this.clearSampledPointsFboVertexCoordBuffer.destroyed&&this.clearSampledPointsFboVertexCoordBuffer.destroy(),this.clearSampledPointsFboVertexCoordBuffer=void 0,this.drawHighlightedVertexCoordBuffer&&!this.drawHighlightedVertexCoordBuffer.destroyed&&this.drawHighlightedVertexCoordBuffer.destroy(),this.drawHighlightedVertexCoordBuffer=void 0,this.trackPointsVertexCoordBuffer&&!this.trackPointsVertexCoordBuffer.destroyed&&this.trackPointsVertexCoordBuffer.destroy(),this.trackPointsVertexCoordBuffer=void 0}swapFbo(){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionFbo||this.previousPositionFbo.destroyed)return;const e=this.previousPositionTexture,t=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=t}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,i=t.length/2;let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let C=0;C<t.length;C+=2){const w=t[C],M=t[C+1];r=Math.min(r,w),s=Math.max(s,w),o=Math.min(o,M),a=Math.max(a,M)}const c=s-r,l=a-o,u=Math.max(c,l);if(u>e){this.scaleX=void 0,this.scaleY=void 0;return}const f=e*e*.001,d=(i>f?e*Math.max(1.2,Math.sqrt(i)/e):e*.1)/u,_=(u-c)/2*d,I=(u-l)/2*d;this.scaleX=C=>(C-r)*d+_,this.scaleY=C=>(C-o)*d+I;for(let C=0;C<i;C++)this.data.pointPositions[C*2]=this.scaleX(t[C*2]),this.data.pointPositions[C*2+1]=this.scaleY(t[C*2+1])}}var ru=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});function Hv(){var n=new ru(9);return ru!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function su(n,e,t){var i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=o,n[4]=a,n[5]=c,n[6]=h*i+d*o+l,n[7]=h*r+d*a+u,n[8]=h*s+d*c+f,n}function vo(n,e,t){var i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Wv(n,e,t){return n[0]=2/e,n[1]=0,n[2]=0,n[3]=0,n[4]=-2/t,n[5]=0,n[6]=-1,n[7]=1,n[8]=1,n}var lr={exports:{}},$v=lr.exports,ou;function Xv(){return ou||(ou=1,function(n){(function(e,t,i){function r(c){var l=this,u=a();l.next=function(){var f=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=f-(l.c=f|0)},l.c=1,l.s0=u(" "),l.s1=u(" "),l.s2=u(" "),l.s0-=u(c),l.s0<0&&(l.s0+=1),l.s1-=u(c),l.s1<0&&(l.s1+=1),l.s2-=u(c),l.s2<0&&(l.s2+=1),u=null}function s(c,l){return l.c=c.c,l.s0=c.s0,l.s1=c.s1,l.s2=c.s2,l}function o(c,l){var u=new r(c),f=l&&l.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,f&&(typeof f=="object"&&s(f,u),h.state=function(){return s(u,{})}),h}function a(){var c=4022871197,l=function(u){u=String(u);for(var f=0;f<u.length;f++){c+=u.charCodeAt(f);var h=.02519603282416938*c;c=h>>>0,h-=c,h*=c,c=h>>>0,h-=c,c+=h*4294967296}return(c>>>0)*23283064365386963e-26};return l}t&&t.exports?t.exports=o:this.alea=o})($v,n)}(lr)),lr.exports}var ur={exports:{}},Yv=ur.exports,au;function qv(){return au||(au=1,function(n){(function(e,t,i){function r(a){var c=this,l="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var f=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^f^f>>>8},a===(a|0)?c.x=a:l+=a;for(var u=0;u<l.length+64;u++)c.x^=l.charCodeAt(u)|0,c.next()}function s(a,c){return c.x=a.x,c.y=a.y,c.z=a.z,c.w=a.w,c}function o(a,c){var l=new r(a),u=c&&c.state,f=function(){return(l.next()>>>0)/4294967296};return f.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=l.next,f.quick=f,u&&(typeof u=="object"&&s(u,l),f.state=function(){return s(l,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(Yv,n)}(ur)),ur.exports}var fr={exports:{}},jv=fr.exports,cu;function Kv(){return cu||(cu=1,function(n){(function(e,t,i){function r(a){var c=this,l="";c.next=function(){var f=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(f^f<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,a===(a|0)?c.x=a:l+=a;for(var u=0;u<l.length+64;u++)c.x^=l.charCodeAt(u)|0,u==l.length&&(c.d=c.x<<10^c.x>>>4),c.next()}function s(a,c){return c.x=a.x,c.y=a.y,c.z=a.z,c.w=a.w,c.v=a.v,c.d=a.d,c}function o(a,c){var l=new r(a),u=c&&c.state,f=function(){return(l.next()>>>0)/4294967296};return f.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=l.next,f.quick=f,u&&(typeof u=="object"&&s(u,l),f.state=function(){return s(l,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(jv,n)}(fr)),fr.exports}var hr={exports:{}},Zv=hr.exports,lu;function Qv(){return lu||(lu=1,function(n){(function(e,t,i){function r(a){var c=this;c.next=function(){var u=c.x,f=c.i,h,d;return h=u[f],h^=h>>>7,d=h^h<<24,h=u[f+1&7],d^=h^h>>>10,h=u[f+3&7],d^=h^h>>>3,h=u[f+4&7],d^=h^h<<7,h=u[f+7&7],h=h^h<<13,d^=h^h<<9,u[f]=d,c.i=f+1&7,d};function l(u,f){var h,d=[];if(f===(f|0))d[0]=f;else for(f=""+f,h=0;h<f.length;++h)d[h&7]=d[h&7]<<15^f.charCodeAt(h)+d[h+1&7]<<13;for(;d.length<8;)d.push(0);for(h=0;h<8&&d[h]===0;++h);for(h==8?d[7]=-1:d[h],u.x=d,u.i=0,h=256;h>0;--h)u.next()}l(c,a)}function s(a,c){return c.x=a.x.slice(),c.i=a.i,c}function o(a,c){a==null&&(a=+new Date);var l=new r(a),u=c&&c.state,f=function(){return(l.next()>>>0)/4294967296};return f.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=l.next,f.quick=f,u&&(u.x&&s(u,l),f.state=function(){return s(l,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(Zv,n)}(hr)),hr.exports}var dr={exports:{}},Jv=dr.exports,uu;function Gv(){return uu||(uu=1,function(n){(function(e,t,i){function r(a){var c=this;c.next=function(){var u=c.w,f=c.X,h=c.i,d,_;return c.w=u=u+1640531527|0,_=f[h+34&127],d=f[h=h+1&127],_^=_<<13,d^=d<<17,_^=_>>>15,d^=d>>>12,_=f[h]=_^d,c.i=h,_+(u^u>>>16)|0};function l(u,f){var h,d,_,I,C,w=[],M=128;for(f===(f|0)?(d=f,f=null):(f=f+"\0",d=0,M=Math.max(M,f.length)),_=0,I=-32;I<M;++I)f&&(d^=f.charCodeAt((I+32)%f.length)),I===0&&(C=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,I>=0&&(C=C+1640531527|0,h=w[I&127]^=d+C,_=h==0?_+1:0);for(_>=128&&(w[(f&&f.length||0)&127]=-1),_=127,I=4*128;I>0;--I)d=w[_+34&127],h=w[_=_+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,w[_]=d^h;u.w=C,u.X=w,u.i=_}l(c,a)}function s(a,c){return c.i=a.i,c.w=a.w,c.X=a.X.slice(),c}function o(a,c){a==null&&(a=+new Date);var l=new r(a),u=c&&c.state,f=function(){return(l.next()>>>0)/4294967296};return f.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=l.next,f.quick=f,u&&(u.X&&s(u,l),f.state=function(){return s(l,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(Jv,n)}(dr)),dr.exports}var pr={exports:{}},eb=pr.exports,fu;function tb(){return fu||(fu=1,function(n){(function(e,t,i){function r(a){var c=this,l="";c.next=function(){var f=c.b,h=c.c,d=c.d,_=c.a;return f=f<<25^f>>>7^h,h=h-d|0,d=d<<24^d>>>8^_,_=_-f|0,c.b=f=f<<20^f>>>12^h,c.c=h=h-d|0,c.d=d<<16^h>>>16^_,c.a=_-f|0},c.a=0,c.b=0,c.c=-1640531527,c.d=1367130551,a===Math.floor(a)?(c.a=a/4294967296|0,c.b=a|0):l+=a;for(var u=0;u<l.length+20;u++)c.b^=l.charCodeAt(u)|0,c.next()}function s(a,c){return c.a=a.a,c.b=a.b,c.c=a.c,c.d=a.d,c}function o(a,c){var l=new r(a),u=c&&c.state,f=function(){return(l.next()>>>0)/4294967296};return f.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=l.next,f.quick=f,u&&(typeof u=="object"&&s(u,l),f.state=function(){return s(l,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})(eb,n)}(pr)),pr.exports}var mr={exports:{}};const nb=Ly(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ib=mr.exports,hu;function rb(){return hu||(hu=1,function(n){(function(e,t,i){var r=256,s=6,o=52,a="random",c=i.pow(r,s),l=i.pow(2,o),u=l*2,f=r-1,h;function d(x,R,B){var L=[];R=R==!0?{entropy:!0}:R||{};var W=w(C(R.entropy?[x,E(t)]:x??M(),3),L),q=new _(L),J=function(){for(var O=q.g(s),oe=c,te=0;O<l;)O=(O+te)*r,oe*=r,te=q.g(1);for(;O>=u;)O/=2,oe/=2,te>>>=1;return(O+te)/oe};return J.int32=function(){return q.g(4)|0},J.quick=function(){return q.g(4)/4294967296},J.double=J,w(E(q.S),t),(R.pass||B||function(O,oe,te,P){return P&&(P.S&&I(P,q),O.state=function(){return I(q,{})}),te?(i[a]=O,oe):O})(J,W,"global"in R?R.global:this==i,R.state)}function _(x){var R,B=x.length,L=this,W=0,q=L.i=L.j=0,J=L.S=[];for(B||(x=[B++]);W<r;)J[W]=W++;for(W=0;W<r;W++)J[W]=J[q=f&q+x[W%B]+(R=J[W])],J[q]=R;(L.g=function(O){for(var oe,te=0,P=L.i,V=L.j,D=L.S;O--;)oe=D[P=f&P+1],te=te*r+D[f&(D[P]=D[V=f&V+oe])+(D[V]=oe)];return L.i=P,L.j=V,te})(r)}function I(x,R){return R.i=x.i,R.j=x.j,R.S=x.S.slice(),R}function C(x,R){var B=[],L=typeof x,W;if(R&&L=="object")for(W in x)try{B.push(C(x[W],R-1))}catch{}return B.length?B:L=="string"?x:x+"\0"}function w(x,R){for(var B=x+"",L,W=0;W<B.length;)R[f&W]=f&(L^=R[f&W]*19)+B.charCodeAt(W++);return E(R)}function M(){try{var x;return h&&(x=h.randomBytes)?x=x(r):(x=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(x)),E(x)}catch{var R=e.navigator,B=R&&R.plugins;return[+new Date,e,B,e.screen,E(t)]}}function E(x){return String.fromCharCode.apply(0,x)}if(w(i.random(),t),n.exports){n.exports=d;try{h=nb}catch{}}else i["seed"+a]=d})(typeof self<"u"?self:ib,[],Math)}(mr)),mr.exports}var bo,du;function sb(){if(du)return bo;du=1;var n=Xv(),e=qv(),t=Kv(),i=Qv(),r=Gv(),s=tb(),o=rb();return o.alea=n,o.xor128=e,o.xorwow=t,o.xorshift7=i,o.xor4096=r,o.tychei=s,bo=o,bo}var ob=sb();const ab=Ol(ob);function cb(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,ub(i.key),i)}}function So(n,e,t){return e&&cb(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function pu(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,To(n,e)}function To(n,e){return To=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},To(n,e)}function lb(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ub(n){var e=lb(n,"string");return typeof e=="symbol"?e:String(e)}var gr=function(){function n(){}var e=n.prototype;return e._seed=function(i,r){if(i===(i||0))return i;for(var s=""+i,o=0,a=0;a<s.length;++a)o^=s.charCodeAt(a)|0;return o},n}(),mu=function(n){pu(e,n);function e(i,r){var s;return s=n.call(this)||this,s._rng=void 0,s.seed(i,r),s}var t=e.prototype;return t.next=function(){return this._rng()},t.seed=function(r,s){this._rng=r},t.clone=function(r,s){return new e(this._rng,s)},So(e,[{key:"name",get:function(){return"function"}}]),e}(gr),gu=function(){var n=[].slice.call(arguments),e=n,t=e[0],i=t===void 0?"default":t;switch(typeof i){case"object":if(i instanceof gr)return i;break;case"function":return new mu(i);case"number":case"string":default:return new mu(ab.apply(void 0,n))}throw new Error('invalid RNG "'+i+'"')},fb=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){return n.next()*(t-e)+e}};function ot(n){return new hb(n)}var hb=function(e){var t=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(t.n))return t;throw new Error("Expected number to be an integer, got "+t.n)},this.isPositive=function(){if(t.n>0)return t;throw new Error("Expected number to be positive, got "+t.n)},this.lessThan=function(i){if(t.n<i)return t;throw new Error("Expected number to be less than "+i+", got "+t.n)},this.greaterThanOrEqual=function(i){if(t.n>=i)return t;throw new Error("Expected number to be greater than or equal to "+i+", got "+t.n)},this.greaterThan=function(i){if(t.n>i)return t;throw new Error("Expected number to be greater than "+i+", got "+t.n)},this.n=e},db=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),t===void 0&&(t=e===void 0?1:e,e=0),ot(e).isInt(),ot(t).isInt(),function(){return Math.floor(n.next()*(t-e+1)+e)}},pb=function(n){return function(){return n.next()>=.5}},mb=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){var i,r,s;do i=n.next()*2-1,r=n.next()*2-1,s=i*i+r*r;while(!s||s>1);return e+t*r*Math.sqrt(-2*Math.log(s)/s)}},gb=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=1);var i=n.normal(e,t);return function(){return Math.exp(i())}},_b=function(n,e){return e===void 0&&(e=.5),ot(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(n.next()+e)}},xb=function(n,e,t){return e===void 0&&(e=1),t===void 0&&(t=.5),ot(e).isInt().isPositive(),ot(t).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<e;)n.next()<t&&r++;return r}},yb=function(n,e){e===void 0&&(e=.5),ot(e).greaterThan(0).lessThan(1);var t=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(n.next())*t)}},vb=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],bb=function(e){return vb[e]},Sb=.9189385332046727,Tb=function(n,e){if(e===void 0&&(e=1),ot(e).isPositive(),e<10){var t=Math.exp(-e);return function(){for(var c=t,l=0,u=n.next();u>c;)u=u-c,c=e*c/++l;return l}}else{var i=Math.sqrt(e),r=.931+2.53*i,s=-.059+.02483*r,o=1.1239+1.1328/(r-3.4),a=.9277-3.6224/(r-2);return function(){for(;;){var c=void 0,l=n.next();if(l<=.86*a)return c=l/a-.43,Math.floor((2*s/(.5-Math.abs(c))+r)*c+e+.445);l>=a?c=n.next()-.5:(c=l/a-.93,c=(c<0?-.5:.5)-c,l=n.next()*a);var u=.5-Math.abs(c);if(!(u<.013&&l>u)){var f=Math.floor((2*s/u+r)*c+e+.445);if(l=l*o/(s/(u*u)+r),f>=10){var h=(f+.5)*Math.log(e/f)-e-Sb+f-(.08333333333333333-(.002777777777777778-1/(1260*f*f))/(f*f))/f;if(Math.log(l*i)<=h)return f}else if(f>=0){var d,_=(d=bb(f))!=null?d:0;if(Math.log(l)<=f*Math.log(e)-e-_)return f}}}}}},wb=function(n,e){return e===void 0&&(e=1),ot(e).isPositive(),function(){return-Math.log(1-n.next())/e}},Ab=function(n,e){return e===void 0&&(e=1),ot(e).isInt().greaterThanOrEqual(0),function(){for(var t=0,i=0;i<e;++i)t+=n.next();return t}},Cb=function(n,e){e===void 0&&(e=1),ot(e).isInt().isPositive();var t=n.irwinHall(e);return function(){return t()/e}},Pb=function(n,e){e===void 0&&(e=1),ot(e).greaterThanOrEqual(0);var t=1/e;return function(){return 1/Math.pow(1-n.next(),t)}},Ib=function(n){pu(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.next=function(){return Math.random()},t.seed=function(r,s){},t.clone=function(){return new e},So(e,[{key:"name",get:function(){return"default"}}]),e}(gr),_u=function(){function n(t){var i=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return i._rng.next()},this.float=function(r,s){return i.uniform(r,s)()},this.int=function(r,s){return i.uniformInt(r,s)()},this.integer=function(r,s){return i.uniformInt(r,s)()},this.bool=function(){return i.uniformBoolean()()},this.boolean=function(){return i.uniformBoolean()()},this.uniform=function(r,s){return i._memoize("uniform",fb,r,s)},this.uniformInt=function(r,s){return i._memoize("uniformInt",db,r,s)},this.uniformBoolean=function(){return i._memoize("uniformBoolean",pb)},this.normal=function(r,s){return mb(i,r,s)},this.logNormal=function(r,s){return gb(i,r,s)},this.bernoulli=function(r){return _b(i,r)},this.binomial=function(r,s){return xb(i,r,s)},this.geometric=function(r){return yb(i,r)},this.poisson=function(r){return Tb(i,r)},this.exponential=function(r){return wb(i,r)},this.irwinHall=function(r){return Ab(i,r)},this.bates=function(r){return Cb(i,r)},this.pareto=function(r){return Pb(i,r)},t&&t instanceof gr?this.use(t):this.use(new Ib),this._cache={}}var e=n.prototype;return e.clone=function(){var i=[].slice.call(arguments);return i.length?new n(gu.apply(void 0,i)):new n(this.rng.clone())},e.use=function(){this._rng=gu.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(i){if(!Array.isArray(i))throw new Error("Random.choice expected input to be an array, got "+typeof i);var r=i==null?void 0:i.length;if(r>0){var s=this.uniformInt(0,r-1)();return i[s]}else return},e._memoize=function(i,r){var s=[].slice.call(arguments,2),o=""+s.join(";"),a=this._cache[i];return(a===void 0||a.key!==o)&&(a={key:o,distribution:r.apply(void 0,[this].concat(s))},this._cache[i]=a),a.distribution},So(n,[{key:"rng",get:function(){return this._rng}}]),n}();new _u;const wo=.001,Ao=64,Rb=4;class Eb{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Hv(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=Ao,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=H.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,k_],this.focusedPointRingColor=[1,1,1,F_],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=yo(),this.scalePointY=yo(),this.random=new _u,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(wo,1/e)}get backgroundColor(){return this._backgroundColor}get transformationMatrix4x4(){const e=this.transform;if(e.length!==9)throw new Error(`Transform must be a 9-element array (3x3 matrix), got ${e.length} elements`);return[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]}set backgroundColor(e){this._backgroundColor=e;const t=Vc(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",t>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",t>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=t<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,t){return this.random.float(e,t)}adjustSpaceSize(e,t){e>=t?(this.adjustedSpaceSize=t/2,console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}setWebGLMaxTextureSize(e){this.webglMaxTextureSize=e}updateScreenSize(e,t){const{adjustedSpaceSize:i}=this;this.screenSize=[e,t],this.scalePointX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scalePointY.domain([i,0]).range([(t-i)/2,(t+i)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=vt(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=vt(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const t=vt(e);this.greyoutPointColor[0]=t[0],this.greyoutPointColor[1]=t[1],this.greyoutPointColor[2]=t[2],this.greyoutPointColor[3]=t[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const t=vt(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const kb={passive:!1},Gn={capture:!0,passive:!1};function Co(n){n.stopImmediatePropagation()}function gn(n){n.preventDefault(),n.stopImmediatePropagation()}function xu(n){var e=n.document.documentElement,t=Se(n).on("dragstart.drag",gn,Gn);"onselectstart"in e?t.on("selectstart.drag",gn,Gn):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function yu(n,e){var t=n.document.documentElement,i=Se(n).on("dragstart.drag",null);e&&(i.on("click.drag",gn,Gn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in t?i.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const _r=n=>()=>n;function Po(n,{sourceEvent:e,subject:t,target:i,identifier:r,active:s,x:o,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Po.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Fb(n){return!n.ctrlKey&&!n.button}function Db(){return this.parentNode}function Mb(n,e){return e??{x:n.x,y:n.y}}function Nb(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ob(){var n=Fb,e=Db,t=Mb,i=Nb,r={},s=li("start","drag","end"),o=0,a,c,l,u,f=0;function h(x){x.on("mousedown.drag",d).filter(i).on("touchstart.drag",C).on("touchmove.drag",w,kb).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(x,R){if(!(u||!n.call(this,x,R))){var B=E(this,e.call(this,x,R),x,R,"mouse");B&&(Se(x.view).on("mousemove.drag",_,Gn).on("mouseup.drag",I,Gn),xu(x.view),Co(x),l=!1,a=x.clientX,c=x.clientY,B("start",x))}}function _(x){if(gn(x),!l){var R=x.clientX-a,B=x.clientY-c;l=R*R+B*B>f}r.mouse("drag",x)}function I(x){Se(x.view).on("mousemove.drag mouseup.drag",null),yu(x.view,l),gn(x),r.mouse("end",x)}function C(x,R){if(n.call(this,x,R)){var B=x.changedTouches,L=e.call(this,x,R),W=B.length,q,J;for(q=0;q<W;++q)(J=E(this,L,x,R,B[q].identifier,B[q]))&&(Co(x),J("start",x,B[q]))}}function w(x){var R=x.changedTouches,B=R.length,L,W;for(L=0;L<B;++L)(W=r[R[L].identifier])&&(gn(x),W("drag",x,R[L]))}function M(x){var R=x.changedTouches,B=R.length,L,W;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),L=0;L<B;++L)(W=r[R[L].identifier])&&(Co(x),W("end",x,R[L]))}function E(x,R,B,L,W,q){var J=s.copy(),O=gt(q||B,R),oe,te,P;if((P=t.call(x,new Po("beforestart",{sourceEvent:B,target:h,identifier:W,active:o,x:O[0],y:O[1],dx:0,dy:0,dispatch:J}),L))!=null)return oe=P.x-O[0]||0,te=P.y-O[1]||0,function V(D,$,K){var j=O,ee;switch(D){case"start":r[W]=V,ee=o++;break;case"end":delete r[W],--o;case"drag":O=gt(K||$,R),ee=o;break}J.call(D,x,new Po(D,{sourceEvent:$,subject:P,target:h,identifier:W,active:ee,x:O[0]+oe,y:O[1]+te,dx:O[0]-j[0],dy:O[1]-j[1],dispatch:J}),L)}}return h.filter=function(x){return arguments.length?(n=typeof x=="function"?x:_r(!!x),h):n},h.container=function(x){return arguments.length?(e=typeof x=="function"?x:_r(x),h):e},h.subject=function(x){return arguments.length?(t=typeof x=="function"?x:_r(x),h):t},h.touchable=function(x){return arguments.length?(i=typeof x=="function"?x:_r(!!x),h):i},h.on=function(){var x=s.on.apply(s,arguments);return x===s?h:x},h.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,h):Math.sqrt(f)},h}const xr=n=>()=>n;function Bb(n,{sourceEvent:e,target:t,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function wt(n,e,t){this.k=n,this.x=e,this.y=t}wt.prototype={constructor:wt,scale:function(n){return n===1?this:new wt(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new wt(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ei=new wt(1,0,0);wt.prototype;function Io(n){n.stopImmediatePropagation()}function ti(n){n.preventDefault(),n.stopImmediatePropagation()}function Ub(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function zb(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function vu(){return this.__zoom||ei}function Lb(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function Vb(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hb(n,e,t){var i=n.invertX(e[0][0])-t[0][0],r=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],o=n.invertY(e[1][1])-t[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Wb(){var n=Ub,e=zb,t=Hb,i=Lb,r=Vb,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=cd,l=li("start","zoom","end"),u,f,h,d=500,_=150,I=0,C=10;function w(P){P.property("__zoom",vu).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",J).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",oe).on("touchend.zoom touchcancel.zoom",te).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(P,V,D,$){var K=P.selection?P.selection():P;K.property("__zoom",vu),P!==K?R(P,V,D,$):K.interrupt().each(function(){B(this,arguments).event($).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},w.scaleBy=function(P,V,D,$){w.scaleTo(P,function(){var K=this.__zoom.k,j=typeof V=="function"?V.apply(this,arguments):V;return K*j},D,$)},w.scaleTo=function(P,V,D,$){w.transform(P,function(){var K=e.apply(this,arguments),j=this.__zoom,ee=D==null?x(K):typeof D=="function"?D.apply(this,arguments):D,Q=j.invert(ee),he=typeof V=="function"?V.apply(this,arguments):V;return t(E(M(j,he),ee,Q),K,o)},D,$)},w.translateBy=function(P,V,D,$){w.transform(P,function(){return t(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof D=="function"?D.apply(this,arguments):D),e.apply(this,arguments),o)},null,$)},w.translateTo=function(P,V,D,$,K){w.transform(P,function(){var j=e.apply(this,arguments),ee=this.__zoom,Q=$==null?x(j):typeof $=="function"?$.apply(this,arguments):$;return t(ei.translate(Q[0],Q[1]).scale(ee.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof D=="function"?-D.apply(this,arguments):-D),j,o)},$,K)};function M(P,V){return V=Math.max(s[0],Math.min(s[1],V)),V===P.k?P:new wt(V,P.x,P.y)}function E(P,V,D){var $=V[0]-D[0]*P.k,K=V[1]-D[1]*P.k;return $===P.x&&K===P.y?P:new wt(P.k,$,K)}function x(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function R(P,V,D,$){P.on("start.zoom",function(){B(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){B(this,arguments).event($).end()}).tween("zoom",function(){var K=this,j=arguments,ee=B(K,j).event($),Q=e.apply(K,j),he=D==null?x(Q):typeof D=="function"?D.apply(K,j):D,ue=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),be=K.__zoom,ie=typeof V=="function"?V.apply(K,j):V,Le=c(be.invert(he).concat(ue/be.k),ie.invert(he).concat(ue/ie.k));return function(Ve){if(Ve===1)Ve=ie;else{var Ge=Le(Ve),Kt=ue/Ge[2];Ve=new wt(Kt,he[0]-Ge[0]*Kt,he[1]-Ge[1]*Kt)}ee.zoom(null,Ve)}})}function B(P,V,D){return!D&&P.__zooming||new L(P,V)}function L(P,V){this.that=P,this.args=V,this.active=0,this.sourceEvent=null,this.extent=e.apply(P,V),this.taps=0}L.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,V){return this.mouse&&P!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var V=Se(this.that).datum();l.call(P,this.that,new Bb(P,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:l}),V)}};function W(P,...V){if(!n.apply(this,arguments))return;var D=B(this,V).event(P),$=this.__zoom,K=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),j=gt(P);if(D.wheel)(D.mouse[0][0]!==j[0]||D.mouse[0][1]!==j[1])&&(D.mouse[1]=$.invert(D.mouse[0]=j)),clearTimeout(D.wheel);else{if($.k===K)return;D.mouse=[j,$.invert(j)],xi(this),D.start()}ti(P),D.wheel=setTimeout(ee,_),D.zoom("mouse",t(E(M($,K),D.mouse[0],D.mouse[1]),D.extent,o));function ee(){D.wheel=null,D.end()}}function q(P,...V){if(h||!n.apply(this,arguments))return;var D=P.currentTarget,$=B(this,V,!0).event(P),K=Se(P.view).on("mousemove.zoom",he,!0).on("mouseup.zoom",ue,!0),j=gt(P,D),ee=P.clientX,Q=P.clientY;xu(P.view),Io(P),$.mouse=[j,this.__zoom.invert(j)],xi(this),$.start();function he(be){if(ti(be),!$.moved){var ie=be.clientX-ee,Le=be.clientY-Q;$.moved=ie*ie+Le*Le>I}$.event(be).zoom("mouse",t(E($.that.__zoom,$.mouse[0]=gt(be,D),$.mouse[1]),$.extent,o))}function ue(be){K.on("mousemove.zoom mouseup.zoom",null),yu(be.view,$.moved),ti(be),$.event(be).end()}}function J(P,...V){if(n.apply(this,arguments)){var D=this.__zoom,$=gt(P.changedTouches?P.changedTouches[0]:P,this),K=D.invert($),j=D.k*(P.shiftKey?.5:2),ee=t(E(M(D,j),$,K),e.apply(this,V),o);ti(P),a>0?Se(this).transition().duration(a).call(R,ee,$,P):Se(this).call(w.transform,ee,$,P)}}function O(P,...V){if(n.apply(this,arguments)){var D=P.touches,$=D.length,K=B(this,V,P.changedTouches.length===$).event(P),j,ee,Q,he;for(Io(P),ee=0;ee<$;++ee)Q=D[ee],he=gt(Q,this),he=[he,this.__zoom.invert(he),Q.identifier],K.touch0?!K.touch1&&K.touch0[2]!==he[2]&&(K.touch1=he,K.taps=0):(K.touch0=he,j=!0,K.taps=1+!!u);u&&(u=clearTimeout(u)),j&&(K.taps<2&&(f=he[0],u=setTimeout(function(){u=null},d)),xi(this),K.start())}}function oe(P,...V){if(this.__zooming){var D=B(this,V).event(P),$=P.changedTouches,K=$.length,j,ee,Q,he;for(ti(P),j=0;j<K;++j)ee=$[j],Q=gt(ee,this),D.touch0&&D.touch0[2]===ee.identifier?D.touch0[0]=Q:D.touch1&&D.touch1[2]===ee.identifier&&(D.touch1[0]=Q);if(ee=D.that.__zoom,D.touch1){var ue=D.touch0[0],be=D.touch0[1],ie=D.touch1[0],Le=D.touch1[1],Ve=(Ve=ie[0]-ue[0])*Ve+(Ve=ie[1]-ue[1])*Ve,Ge=(Ge=Le[0]-be[0])*Ge+(Ge=Le[1]-be[1])*Ge;ee=M(ee,Math.sqrt(Ve/Ge)),Q=[(ue[0]+ie[0])/2,(ue[1]+ie[1])/2],he=[(be[0]+Le[0])/2,(be[1]+Le[1])/2]}else if(D.touch0)Q=D.touch0[0],he=D.touch0[1];else return;D.zoom("touch",t(E(ee,Q,he),D.extent,o))}}function te(P,...V){if(this.__zooming){var D=B(this,V).event(P),$=P.changedTouches,K=$.length,j,ee;for(Io(P),h&&clearTimeout(h),h=setTimeout(function(){h=null},d),j=0;j<K;++j)ee=$[j],D.touch0&&D.touch0[2]===ee.identifier?delete D.touch0:D.touch1&&D.touch1[2]===ee.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(ee=gt(ee,this),Math.hypot(f[0]-ee[0],f[1]-ee[1])<C)){var Q=Se(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return w.wheelDelta=function(P){return arguments.length?(i=typeof P=="function"?P:xr(+P),w):i},w.filter=function(P){return arguments.length?(n=typeof P=="function"?P:xr(!!P),w):n},w.touchable=function(P){return arguments.length?(r=typeof P=="function"?P:xr(!!P),w):r},w.extent=function(P){return arguments.length?(e=typeof P=="function"?P:xr([[+P[0][0],+P[0][1]],[+P[1][0],+P[1][1]]]),w):e},w.scaleExtent=function(P){return arguments.length?(s[0]=+P[0],s[1]=+P[1],w):[s[0],s[1]]},w.translateExtent=function(P){return arguments.length?(o[0][0]=+P[0][0],o[1][0]=+P[1][0],o[0][1]=+P[0][1],o[1][1]=+P[1][1],w):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},w.constrain=function(P){return arguments.length?(t=P,w):t},w.duration=function(P){return arguments.length?(a=+P,w):a},w.interpolate=function(P){return arguments.length?(c=P,w):c},w.on=function(){var P=l.on.apply(l,arguments);return P===l?w:P},w.clickDistance=function(P){return arguments.length?(I=(P=+P)*P,w):Math.sqrt(I)},w.tapDistance=function(P){return arguments.length?(C=+P,w):C},w}class $b{constructor(e,t){this.eventTransform=ei,this.behavior=Wb().scaleExtent([.001,1/0]).on("start",i=>{var s,o;this.isRunning=!0;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomStart)==null||o.call(s,i,r)}).on("zoom",i=>{var h,d;this.eventTransform=i.transform;const{eventTransform:{x:r,y:s,k:o},store:{transform:a,screenSize:c}}=this,l=c[0],u=c[1];if(!l||!u)return;Wv(a,l,u),su(a,a,[r,s]),vo(a,a,[o,o]),su(a,a,[l/2,u/2]),vo(a,a,[l/2,u/2]),vo(a,a,[1,-1]);const f=!!i.sourceEvent;(d=(h=this.config)==null?void 0:h.onZoom)==null||d.call(h,i,f)}).on("end",i=>{var s,o;this.isRunning=!1;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomEnd)==null||o.call(s,i,r)}),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,i=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:r}}=this,s=r[0],o=r[1],a=Vl(e.map(w=>w[0])),c=Vl(e.map(w=>w[1]));a[0]=this.store.scaleX(a[0]),a[1]=this.store.scaleX(a[1]),c[0]=this.store.scaleY(c[0]),c[1]=this.store.scaleY(c[1]),a[0]===a[1]&&(a[0]-=.5,a[1]+=.5),c[0]===c[1]&&(c[0]+=.5,c[1]-=.5);const l=s*(1-i*2)/(a[1]-a[0]),u=o*(1-i*2)/(c[0]-c[1]),f=Hc(t??Math.min(l,u),...this.behavior.scaleExtent()),h=(a[1]+a[0])/2,d=(c[1]+c[0])/2,_=s/2-h*f,I=o/2-d*f;return ei.translate(_,I).scale(f)}getDistanceToPoint(e){const{x:t,y:i,k:r}=this.eventTransform,s=this.getTransform([e],r),o=t-s.x,a=i-s.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:i,y:r,k:s}}=this,o=t[0],a=t[1],c=(o/2-i)/s,l=(a/2-r)/s,u=this.store.scaleX(e[0]),f=this.store.scaleY(e[1]),h=(c+u)/2,d=(l+f)/2,_=1,I=o/2-h*_,C=a/2-d*_;return ei.translate(I,C).scale(_)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:i,k:r},store:{screenSize:s}}=this,o=s[0],a=s[1],c=(e[0]-t)/r,l=(e[1]-i)/r,u=[c,a-l];return u[0]-=(o-this.store.adjustedSpaceSize)/2,u[1]-=(a-this.store.adjustedSpaceSize)/2,u}convertSpaceToScreenPosition(e){const t=this.eventTransform.applyX(this.store.scaleX(e[0])),i=this.eventTransform.applyY(this.store.scaleY(e[1]));return[t,i]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:i},eventTransform:{k:r}}=this;let s=e*2;return t?s*=r:s*=Math.min(5,Math.max(1,r*.01)),Math.min(s,i)/2}}class Xb{constructor(e,t){this.isActive=!1,this.behavior=Ob().subject(i=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:i.x,y:i.y}:void 0).on("start",i=>{var r,s;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(s=(r=this.config)==null?void 0:r.onDragStart)==null||s.call(r,i))}).on("drag",i=>{var r,s;(s=(r=this.config)==null?void 0:r.onDrag)==null||s.call(r,i)}).on("end",i=>{var r,s;this.isActive=!1,this.store.draggingPointIndex=void 0,(s=(r=this.config)==null?void 0:r.onDragEnd)==null||s.call(r,i)}),this.store=e,this.config=t}}class Yb{constructor(e,t){this.config=new nx,this.graph=new Yy(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new Eb,this.zoomInstance=new $b(this.store,this.config),this.dragInstance=new Xb(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,t&&this.config.init(t),this.store.div=e;const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",this.store.div.appendChild(i),this.addAttribution(),this.canvas=i,this.deviceInitPromise=this.createDevice(i).then(r=>{this.device=r;const s=i.clientWidth,o=i.clientHeight;i.width=s*this.config.pixelRatio,i.height=o*this.config.pixelRatio,this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(s,o),this.canvasD3Selection=Se(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",l=>{this._isMouseOnCanvas=!1,this.currentEvent=l,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(l),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(l),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),Se(document).on("keydown.cosmos",l=>{l.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",l=>{l.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",l=>{this.currentEvent=l}).on("zoom.detect",l=>{!!l.sourceEvent&&this.updateMousePosition(l.sourceEvent),this.currentEvent=l}).on("end.detect",l=>{this.currentEvent=l}),this.dragInstance.behavior.on("start.detect",l=>{this.currentEvent=l,this.updateCanvasCursor()}).on("drag.detect",l=>{this.dragInstance.isActive&&this.updateMousePosition(l),this.currentEvent=l}).on("end.detect",l=>{this.currentEvent=l,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1);const a=r.gl.getParameter(Rt.ALIASED_POINT_SIZE_RANGE),c=this.config.pixelRatio??(typeof window<"u"&&window.devicePixelRatio||2);return this.store.maxPointSize=((a==null?void 0:a[1])??Ao)/c,this.points=new Vv(r,this.config,this.store,this.graph),this.lines=new Cv(r,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new Py(r,this.config,this.store,this.graph,this.points),this.forceCenter=new Ay(r,this.config,this.store,this.graph,this.points),this.forceManyBody=new Dy(r,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Nl(r,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Nl(r,this.config,this.store,this.graph,this.points),this.forceMouse=new Ny(r,this.config,this.store,this.graph,this.points)),this.clusters=new zy(r,this.config,this.store,this.graph,this.points),this.store.backgroundColor=vt(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??H.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??H.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??ks),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??H.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Ul(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),r}).catch(r=>{throw console.error("Device initialization failed:",r),r})}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i,r,s,o,a,c,l,u,f;if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const t={...this.config};if(this.config.init(e),t.pointColor!==this.config.pointColor&&(this.graph.updatePointColor(),(i=this.points)==null||i.updateColor()),t.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),(r=this.points)==null||r.updateSize()),t.linkColor!==this.config.linkColor&&(this.graph.updateLinkColor(),(s=this.lines)==null||s.updateColor()),t.linkWidth!==this.config.linkWidth&&(this.graph.updateLinkWidth(),(o=this.lines)==null||o.updateWidth()),t.linkArrows!==this.config.linkArrows&&(this.graph.updateArrows(),(a=this.lines)==null||a.updateArrow()),(t.curvedLinkSegments!==this.config.curvedLinkSegments||t.curvedLinks!==this.config.curvedLinks)&&((c=this.lines)==null||c.updateCurveLineGeometry()),t.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=vt(this.config.backgroundColor??Tc)),t.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??H.hoveredPointRingColor),t.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??H.focusedPointRingColor),t.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??ks),t.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??H.hoveredLinkColor),t.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),t.pixelRatio!==this.config.pixelRatio&&(l=this.device)!=null&&l.canvasContext){const h=this.config.pixelRatio!==void 0?this.config.pixelRatio:!0;this.device.canvasContext.setProps({useDevicePixels:h});const d=this.device.gl.getParameter(Rt.ALIASED_POINT_SIZE_RANGE),_=this.config.pixelRatio??H.pixelRatio;this.store.maxPointSize=((d==null?void 0:d[1])??Ao)/_}(t.spaceSize!==this.config.spaceSize||t.simulationRepulsionQuadtreeLevels!==this.config.simulationRepulsionQuadtreeLevels)&&(this.store.adjustSpaceSize(this.config.spaceSize,((u=this.device)==null?void 0:u.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),t.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Ul(this.canvas):((f=this.fpsMonitor)==null||f.destroy(),this.fpsMonitor=void 0)),(t.enableZoom!==this.config.enableZoom||t.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(t.onLinkClick!==this.config.onLinkClick||t.onLinkMouseOver!==this.config.onLinkMouseOver||t.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,t))||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=t,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||this.ensureDevice(()=>this.setPointColors(e))||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointSizes(e))||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(t=this.points)==null||t.createAtlas())}setPointImageIndices(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageIndices(e))||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageSizes(e))||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||this.ensureDevice(()=>this.setLinks(e))||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkColors(e))||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkWidths(e))||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkArrows(e))||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkStrength(e))||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusters(e))||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||this.ensureDevice(()=>this.setClusterPositions(e))||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusterStrength(e))||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}render(e){if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:i,fitViewPadding:r,fitViewDuration:s,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:c}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Se(this.canvas).style("cursor",null),this.device&&this.device.beginRenderPass({clearColor:[0,0,1,1],clearDepth:1,clearStencil:0}).end();return}this._isFirstRenderAfterInit&&t&&c===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{a?this.fitViewByPointIndices(a,s,r):o?this.setZoomTransformByPointPositions(o,s,void 0,r):this.fitView(s,r)},i)),this._isFirstRenderAfterInit=!1,this.update(e)}zoomToPointByIndex(e,t=700,i=D_,r=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,t,i,r))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:s}}=this,o=We(this.device,this.points.currentPositionFbo);if(e===void 0)return;const a=o[e*4+0],c=o[e*4+1];if(a===void 0||c===void 0)return;const l=this.zoomInstance.getDistanceToPoint([a,c]),u=r?i:Math.max(this.getZoomLevel(),i);if(l<Math.min(s[0],s[1]))this.setZoomTransformByPointPositions([a,c],t,u);else{const f=this.zoomInstance.getTransform([[a,c]],u),h=this.zoomInstance.getMiddlePointTransform([a,c]);this.canvasD3Selection.transition().ease(cp).duration(t/2).call(this.zoomInstance.behavior.transform,h).transition().ease(lp).duration(t/2).call(this.zoomInstance.behavior.transform,f)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,t))||this.canvasD3Selection&&(t===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.device||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],t=We(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=t[i*4+0],s=t[i*4+1];r!==void 0&&s!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}getClusterPositions(){if(this._isDestroyed||!this.device||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],t=We(this.device,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=t[i*4+0],s=t[i*4+1],o=t[i*4+2];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r/o,e[i*2+1]=s/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,t))||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,t)}fitViewByPointIndices(e,t=250,i=.1){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,t,i)))return;const r=this.getPointPositions(),s=new Array(e.length*2);for(const[o,a]of e.entries())s[o*2]=r[a*2],s[o*2+1]=r[a*2+1];this.setZoomTransformByPointPositions(s,t,void 0,i)}fitViewByPointPositions(e,t=250,i=.1){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,t,i))||this.setZoomTransformByPointPositions(e,t,void 0,i)}getPointsInRect(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;const t=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection(),We(this.device,this.points.selectedFbo).map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),We(this.device,this.points.selectedFbo).map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}selectPointsInRect(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInRect(e))&&!(!this.device||!this.points)){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const i=We(this.device,this.points.selectedFbo);this.store.selectedIndices=i.map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInPolygon(e))&&!(!this.device||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=We(this.device,this.points.selectedFbo);this.store.selectedIndices=r.map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointByIndex(e,t)))if(t){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.selectPointsByIndices(e))||this.points&&(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(t=>t!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||this.ensureDevice(()=>this.unselectPoints())||this.points&&(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;if(!this._isDestroyed)return(t=this.graph.pointSizes)==null?void 0:t[e]}trackPointPositionsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.trackPointPositionsByIndices(e))||this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var t,i;this._isDestroyed||this.ensureDevice(()=>this.start(e))||this.graph.pointsNumber&&(e>0&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,(i=(t=this.config).onSimulationStart)==null||i.call(t)),this.store.alpha=e,this.stopFrames(),this.frame())}pause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.pause())||(this.store.isSimulationRunning=!1,(t=(e=this.config).onSimulationPause)==null||t.call(e))}unpause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.unpause())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationUnpause)==null||t.call(e))}restart(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.restart())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationRestart)==null||t.call(e))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||(this.store.isSimulationRunning=!1,this.stopFrames(),this.frame())}destroy(){var e,t,i,r;this._isDestroyed||(window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),Se(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(t=this.dragInstance)!=null&&t.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.destroy()),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(r=document.getElementById("gl-bench-style"))==null||r.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,t,i,r,s;this._isDestroyed||this.ensureDevice(()=>this.create())||this.points&&this.lines&&(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((t=this.forceLinkIncoming)==null||t.create(ho.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(ho.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((s=this.clusters)==null||s.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let i=0;i<e.length/2;i++)t[i]=[e[i*2],e[i*2+1]];return t}ensureDevice(e){return this.device?!1:(this.deviceInitPromise.then(()=>{e()}).catch(t=>{console.error("Device initialization failed",t)}),!0)}async createDevice(e){const t=this.config.pixelRatio!==void 0?this.config.pixelRatio:!0;return await jp.createDevice({type:"webgl",adapters:[qm],createCanvasContext:{canvas:e,useDevicePixels:t,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:t}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((t.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.start(e)}initPrograms(){var e,t,i,r,s,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(t=this.forceManyBody)==null||t.initPrograms(),(i=this.forceCenter)==null||i.initPrograms(),(r=this.forceLinkIncoming)==null||r.initPrograms(),(s=this.forceLinkOutgoing)==null||s.initPrograms(),(o=this.forceMouse)==null||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{config:{simulationGravity:e,simulationCenter:t,renderLinks:i,enableSimulation:r},store:{alpha:s,isSimulationRunning:o}}=this;s<wo&&o&&this.end(),this.store.pointsTextureSize&&(this.requestAnimationFrameId=window.requestAnimationFrame(a=>{var c,l,u,f,h,d,_,I,C,w,M,E,x,R,B,L,W,q,J,O,oe,te,P,V,D,$,K,j;if((c=this.fpsMonitor)==null||c.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),r&&(this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((l=this.forceMouse)==null||l.run(),(u=this.points)==null||u.updatePosition()),o&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom)&&((f=this.points)!=null&&f.velocityFbo&&!this.points.velocityFbo.destroyed&&this.device&&this.device.beginRenderPass({framebuffer:this.points.velocityFbo,clearColor:[0,0,0,0]}).end(),e&&((h=this.forceGravity)==null||h.run(),(d=this.points)==null||d.updatePosition()),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((_=this.forceMouse)==null||_.run(),(I=this.points)==null||I.updatePosition()),t&&((C=this.forceCenter)==null||C.run(),(w=this.points)==null||w.updatePosition()),(M=this.forceManyBody)==null||M.run(),(E=this.points)==null||E.updatePosition(),this.store.linksTextureSize&&((x=this.forceLinkIncoming)==null||x.run(),(R=this.points)==null||R.updatePosition(),(B=this.forceLinkOutgoing)==null||B.run(),(L=this.points)==null||L.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((W=this.clusters)==null||W.run(),(q=this.points)==null||q.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??H.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,wo/this.store.alpha)),(te=(oe=this.config).onSimulationTick)==null||te.call(oe,this.store.alpha,(J=this.store.hoveredPoint)==null?void 0:J.index,(O=this.store.hoveredPoint)==null?void 0:O.position)),(P=this.points)==null||P.trackPoints()),this.device){const ee=this.store.backgroundColor??[0,0,0,1],Q=this.device.beginRenderPass({clearColor:ee,clearDepth:1,clearStencil:0});i!==!1&&!!this.store.linksTextureSize&&!!this.graph.linksNumber&&this.graph.linksNumber>0&&((V=this.lines)==null||V.draw(Q)),(D=this.points)==null||D.draw(Q),this.dragInstance.isActive&&(($=this.points)==null||$.drag(),(K=this.points)==null||K.drag()),Q.end(),this.device.submit()}(j=this.fpsMonitor)==null||j.end(a),this.currentEvent=void 0,this._isDestroyed||this.frame()}))}stopFrames(){this.requestAnimationFrameId&&window.cancelAnimationFrame(this.requestAnimationFrameId)}end(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(t=(e=this.config).onSimulationEnd)==null||t.call(e)}onClick(e){var t,i,r,s,o,a,c,l,u,f;(s=(r=this.config).onClick)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.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?(l=(c=this.config).onLinkClick)==null||l.call(c,this.store.hoveredLinkIndex,e):(f=(u=this.config).onBackgroundClick)==null||f.call(u,e)}updateMousePosition(e){if(!e)return;const t=e.offsetX??e.x,i=e.offsetY??e.y;t===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([t,i]),this.store.screenMousePosition=[t,this.store.screenSize[1]-i])}onMouseMove(e){var t,i,r,s;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(s=(r=this.config).onMouseMove)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var o,a,c;if(this._isDestroyed)return;const t=this.canvas.clientWidth,i=this.canvas.clientHeight,[r,s]=this.store.screenSize;if(e||r!==t||s!==i){const{k:l}=this.zoomInstance.eventTransform,u=this.zoomInstance.convertScreenToSpacePosition([r/2,s/2]);this.store.updateScreenSize(t,i),(o=this.canvasD3Selection)==null||o.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([u],l)),(a=this.points)==null||a.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((c=this.lines)==null||c.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,t=250,i,r){var o;this.resizeCanvas();const s=this.zoomInstance.getTransform(this.pair(e),i,r);(o=this.canvasD3Selection)==null||o.transition().ease(up).duration(t).call(this.zoomInstance.behavior.transform,s)}updateZoomDragBehaviors(){var e,t,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(t=this.canvasD3Selection)==null||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!(this._isDestroyed||!this._isMouseOnCanvas)){if(this._findHoveredItemExecutionCount<Rb){this._findHoveredItemExecutionCount+=1;return}if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const e=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var c,l,u,f;if(this._isDestroyed||!this.device||!this.points)return;this.points.findHoveredPoint();let e=!1,t=!1;const i=We(this.device,this.points.hoveredFbo,0,0,2,2),r=i[0],s=i[1],o=i[2],a=i[3];s>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==r)&&(e=!0),this.store.hoveredPoint={index:r,position:[o,a]}):(this.store.hoveredPoint&&(t=!0),this.store.hoveredPoint=void 0),e&&this.store.hoveredPoint&&((l=(c=this.config).onPointMouseOver)==null||l.call(c,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),t&&((f=(u=this.config).onPointMouseOut)==null||f.call(u,this.currentEvent))}findHoveredLine(){var s,o,a,c,l,u;if(this._isDestroyed||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(o=(s=this.config).onLinkMouseOut)==null||o.call(s,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,t=!1;if(!this.device)return;const r=We(this.device,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(t=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((c=(a=this.config).onLinkMouseOver)==null||c.call(a,this.store.hoveredLinkIndex)),t&&((u=(l=this.config).onLinkMouseOut)==null||u.call(l,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?Se(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Se(this.canvas).style("cursor",e):Se(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Se(this.canvas).style("cursor",t):Se(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
|
|
2280
|
+
}`;function Lv(n,e=16384){if(!(n!=null&&n.length))return null;let t=0;for(const c of n){const u=Math.max(c.width,c.height);u>t&&(t=u)}if(t===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const i=t,r=Math.ceil(Math.sqrt(n.length));let s=r*t,o=1;s>e&&(o=e/s,t=Math.max(1,Math.floor(t*o)),s=Math.max(1,Math.floor(s*o)),console.warn(`🖼️ Atlas scaling required: Original size ${(i*r).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${s.toLocaleString()}px (${Math.round(o*100)}% of original quality)`));const a=new Uint8Array(s*s*4).fill(0),l=new Float32Array(r*r*4).fill(-1);for(const[c,u]of n.entries()){const f=u.width,h=u.height;if(f===0||h===0)continue;const d=Math.min(1,t/Math.max(f,h)),_=Math.floor(f*d),I=Math.floor(h*d),C=Math.floor(c/r),M=c%r*t,E=C*t;l[c*4]=M/s,l[c*4+1]=E/s,l[c*4+2]=(M+_)/s,l[c*4+3]=(E+I)/s;for(let x=0;x<I;x++)for(let R=0;R<_;R++){const O=Math.floor(R*(f/_)),W=(Math.floor(x*(h/I))*f+O)*4,q=((E+x)*s+(M+R))*4;a[q]=u.data[W]??0,a[q+1]=u.data[W+1]??0,a[q+2]=u.data[W+2]??0,a[q+3]=u.data[W+3]??255}}return{atlasData:a,atlasSize:s,atlasCoords:l,atlasCoordsSize:r}}class Vv extends Ft{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){var _,I,C;const{device:e,store:t,data:i,config:{rescalePositions:r,enableSimulation:s}}=this,{pointsTextureSize:o}=t;if(!o||!i.pointPositions||i.pointsNumber===void 0)return;const a=o*o*4,l=new Float32Array(a),c=o*o*4*4,u=l.byteLength;u!==c&&console.error("Texture data size mismatch:",{pointsTextureSize:o,expectedBytes:c,actualBytes:u,textureDataSize:a,dataLength:l.length});let f=r;r===void 0&&!s&&(f=!0),this.shouldSkipRescale&&(f=!1),f?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let w=0;w<i.pointsNumber;++w)l[w*4+0]=i.pointPositions[w*2+0],l[w*4+1]=i.pointPositions[w*2+1],l[w*4+2]=w;if(!this.currentPositionTexture||this.currentPositionTexture.width!==o||this.currentPositionTexture.height!==o?(this.currentPositionTexture&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&this.currentPositionFbo.destroy(),this.currentPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.currentPositionTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.currentPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.currentPositionTexture]})):this.currentPositionTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),!this.previousPositionTexture||this.previousPositionTexture.width!==o||this.previousPositionTexture.height!==o?(this.previousPositionTexture&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&this.previousPositionFbo.destroy(),this.previousPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.previousPositionTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.previousPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.previousPositionTexture]})):this.previousPositionTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.config.enableSimulation){const w=new Float32Array(o*o*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==o||this.velocityTexture.height!==o?(this.velocityTexture&&this.velocityTexture.destroy(),this.velocityFbo&&this.velocityFbo.destroy(),this.velocityTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.velocityTexture.copyImageData({data:w,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.velocityFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.velocityTexture]})):this.velocityTexture.copyImageData({data:w,bytesPerRow:o,mipLevel:0,x:0,y:0})}!this.selectedTexture||this.selectedTexture.width!==o||this.selectedTexture.height!==o?(this.selectedTexture&&this.selectedTexture.destroy(),this.selectedFbo&&this.selectedFbo.destroy(),this.selectedTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.selectedTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.selectedFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.selectedTexture]})):this.selectedTexture.copyImageData({data:l,bytesPerRow:o,mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=e.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const h=Qn(t.pointsTextureSize),d=h.byteLength;!this.drawPointIndices||this.drawPointIndices.byteLength!==d?((_=this.drawPointIndices)==null||_.destroy(),this.drawPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.drawPointIndices.write(h),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==d?((I=this.hoveredPointIndices)==null||I.destroy(),this.hoveredPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.hoveredPointIndices.write(h),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==d?((C=this.sampledPointIndices)==null||C.destroy(),this.sampledPointIndices=e.createBuffer({data:h,usage:z.VERTEX|z.COPY_DST})):this.sampledPointIndices.write(h),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){var s,o,a;const{device:e,config:t,store:i,data:r}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.greyoutStatusTexture||this.updateGreyoutStatus(),t.enableSimulation&&(this.updatePositionCommand||(this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new ge({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:t.simulationFriction??0,spaceSize:i.adjustedSpaceSize??0}}})),this.updatePositionCommand=new le(e,{fs:Bv,vs:Ie,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"),...this.previousPositionTexture&&{positionsTexture:this.previousPositionTexture},...this.velocityTexture&&{velocity:this.velocityTexture},...this.pinnedStatusTexture&&{pinnedStatusTexture:this.pinnedStatusTexture}}}))),this.dragPointCommand||(this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new ge({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:i.mousePosition??[0,0],index:((s=i.hoveredPoint)==null?void 0:s.index)??-1}}})),this.dragPointCommand=new le(e,{fs:zv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(e,"dragPointUniforms"),...this.previousPositionTexture&&{positionsTexture:this.previousPositionTexture}}})),this.drawCommand||(this.drawUniformStore||(this.drawUniformStore=new ge({drawVertexUniforms:{uniformTypes:{ratio:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",greyoutColor:"vec4<f32>",backgroundColor:"vec4<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",isDarkenGreyout:"f32",skipSelected:"f32",skipUnselected:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32"},defaultUniforms:{ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:(()=>{const l=i.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:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],greyoutColor:i.greyoutPointColor??[0,0,0,1],backgroundColor:i.backgroundColor??[0,0,0,1],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,skipSelected:0,skipUnselected:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>"},defaultUniforms:{greyoutOpacity:t.pointGreyoutOpacity??-1,pointOpacity:t.pointOpacity??1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:i.backgroundColor??[0,0,0,1]}}})),this.drawCommand=new le(e,{fs:Pv,vs:Iv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"color",format:"float32x4"},{name:"shape",format:"float32"},{name:"imageIndex",format:"float32"},{name:"imageSize",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawFragmentUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.greyoutStatusTexture&&{pointGreyoutStatus:this.greyoutStatusTexture},...this.imageAtlasTexture&&{imageAtlasTexture:this.imageAtlasTexture},...this.imageAtlasCoordsTexture&&{imageAtlasCoords:this.imageAtlasCoordsTexture}},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.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionVertexCoordBuffer||(this.findPointsOnAreaSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnAreaSelectionUniformStore||(this.findPointsOnAreaSelectionUniformStore=new ge({findPointsOnAreaSelectionUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",selection0:"vec2<f32>",selection1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,selection0:((o=i.selectedArea)==null?void 0:o[0])??[0,0],selection1:((a=i.selectedArea)==null?void 0:a[1])??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findPointsOnAreaSelectionCommand=new le(e,{fs:Rv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnAreaSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnAreaSelectionUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.sizeTexture&&{pointSize:this.sizeTexture}}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionVertexCoordBuffer||(this.findPointsOnPolygonSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnPolygonSelectionUniformStore||(this.findPointsOnPolygonSelectionUniformStore=new ge({findPointsOnPolygonSelectionUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],transformationMatrix:i.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsOnPolygonSelectionCommand=new le(e,{fs:Ev,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnPolygonSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnPolygonSelectionUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.polygonPathTexture&&{polygonPathTexture:this.polygonPathTexture}}})),this.clearHoveredFboCommand||(this.clearHoveredFboVertexCoordBuffer||(this.clearHoveredFboVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearHoveredFboCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearHoveredFboVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),this.findHoveredPointCommand||(this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new ge({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,mousePosition:i.screenMousePosition??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findHoveredPointCommand=new le(e,{fs:Fv,vs:Mv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(e,"findHoveredPointUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture}},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboVertexCoordBuffer||(this.clearSampledPointsFboVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.clearSampledPointsFboCommand=new le(e,{fs:Jn,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.clearSampledPointsFboVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}]})),this.fillSampledPointsFboCommand||(this.fillSampledPointsUniformStore||(this.fillSampledPointsUniformStore=new ge({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,transformationMatrix:i.transformationMatrix4x4,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0]}}})),this.fillSampledPointsFboCommand=new le(e,{fs:Nv,vs:Ov,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.sampledPointIndices&&{pointIndices:this.sampledPointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(e,"fillSampledPointsUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture}},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.drawHighlightedCommand||(this.drawHighlightedVertexCoordBuffer||(this.drawHighlightedVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.drawHighlightedUniformStore||(this.drawHighlightedUniformStore=new ge({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:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:i.screenSize??[0,0],scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,pointIndex:-1,maxPointSize:i.maxPointSize??100,color:[0,0,0,1],universalPointOpacity:t.pointOpacity??1,greyoutOpacity:t.pointGreyoutOpacity??-1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:i.backgroundColor??[0,0,0,1],greyoutColor:i.greyoutPointColor??[0,0,0,1],width:.85}}})),this.drawHighlightedCommand=new le(e,{fs:kv,vs:Dv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(e,"drawHighlightedUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.greyoutStatusTexture&&{pointGreyoutStatusTexture:this.greyoutStatusTexture}},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.trackPointsCommand||(this.trackPointsVertexCoordBuffer||(this.trackPointsVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.trackPointsUniformStore||(this.trackPointsUniformStore=new ge({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0}}})),this.trackPointsCommand=new le(e,{fs:Uv,vs:Ie,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.trackPointsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(e,"trackPointsUniforms"),...this.currentPositionTexture&&{positionsTexture:this.currentPositionTexture},...this.trackedIndicesTexture&&{trackedIndices:this.trackedIndicesTexture}}}))}updateColor(){var o;const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=i.pointColors,s=r.byteLength;!this.colorBuffer||this.colorBuffer.byteLength!==s?((o=this.colorBuffer)==null||o.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.colorBuffer.write(r)}updateGreyoutStatus(){const{device:e,store:{selectedIndices:t,pointsTextureSize:i}}=this;if(!i)return;const r=new Float32Array(i*i*4).fill(t?1:0);if(t)for(const s of t)r[s*4]=0;!this.greyoutStatusTexture||this.greyoutStatusTexture.width!==i||this.greyoutStatusTexture.height!==i?(this.greyoutStatusTexture&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=e.createTexture({width:i,height:i,format:"rgba32float"}),this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})):this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})}updatePinnedStatus(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=new Float32Array(t*t*4).fill(0);if(i.inputPinnedPoints&&i.pointsNumber!==void 0)for(const s of i.inputPinnedPoints)s>=0&&s<i.pointsNumber&&(r[s*4]=1);!this.pinnedStatusTexture||this.pinnedStatusTexture.width!==t||this.pinnedStatusTexture.height!==t?(this.pinnedStatusTexture&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:t,mipLevel:0,x:0,y:0})):this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:t,mipLevel:0,x:0,y:0})}updateSize(){var a;const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t||i.pointsNumber===void 0||i.pointSizes===void 0)return;const r=i.pointSizes,s=r.byteLength;!this.sizeBuffer||this.sizeBuffer.byteLength!==s?((a=this.sizeBuffer)==null||a.destroy(),this.sizeBuffer=e.createBuffer({data:r,usage:z.VERTEX|z.COPY_DST})):this.sizeBuffer.write(r);const o=new Float32Array(t*t*4);for(let l=0;l<i.pointsNumber;l++)o[l*4]=i.pointSizes[l];!this.sizeTexture||this.sizeTexture.width!==t||this.sizeTexture.height!==t?(this.sizeTexture&&this.sizeTexture.destroy(),this.sizeTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.sizeTexture.copyImageData({data:o,bytesPerRow:t,mipLevel:0,x:0,y:0})):this.sizeTexture.copyImageData({data:o,bytesPerRow:t,mipLevel:0,x:0,y:0})}updateShape(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointShapes===void 0)return;const i=t.pointShapes,r=i.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==r?((s=this.shapeBuffer)==null||s.destroy(),this.shapeBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.shapeBuffer.write(i)}updateImageIndices(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageIndices===void 0)return;const i=t.pointImageIndices,r=i.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==r?((s=this.imageIndicesBuffer)==null||s.destroy(),this.imageIndicesBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.imageIndicesBuffer.write(i)}updateImageSizes(){var s;const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageSizes===void 0)return;const i=t.pointImageSizes,r=i.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==r?((s=this.imageSizesBuffer)==null||s.destroy(),this.imageSizesBuffer=e.createBuffer({data:i,usage:z.VERTEX|z.COPY_DST})):this.imageSizesBuffer.write(i)}createAtlas(){var c,u,f;const{device:e,data:t,store:i}=this;if(!((c=t.inputImageData)!=null&&c.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=e.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=e.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const r=Lv(t.inputImageData,i.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=t.inputImageData.length;const{atlasData:s,atlasSize:o,atlasCoords:a,atlasCoordsSize:l}=r;this.imageAtlasCoordsTextureSize=l,(u=this.imageAtlasTexture)==null||u.destroy(),this.imageAtlasTexture=e.createTexture({width:o,height:o,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:s,bytesPerRow:o,rowsPerImage:o,mipLevel:0,x:0,y:0}),(f=this.imageAtlasCoordsTexture)==null||f.destroy(),this.imageAtlasCoordsTexture=e.createTexture({width:l,height:l,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:a,bytesPerRow:l,rowsPerImage:l,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},device:i}=this;let r=t??Math.min(...e)/2;r===0&&(r=V.pointSamplingDistance);const s=Math.ceil(e[0]/r),o=Math.ceil(e[1]/r);(!this.sampledPointsFbo||this.sampledPointsFbo.width!==s||this.sampledPointsFbo.height!==o)&&(this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=i.createFramebuffer({width:s,height:o,colorAttachments:["rgba32float"]}))}trackPoints(){var t;if(!((t=this.trackedIndices)!=null&&t.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({trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(this.device,"trackPointsUniforms"),positionsTexture:this.currentPositionTexture,trackedIndices:this.trackedIndicesTexture});const e=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(e),e.end()}draw(e){var a,l;const{data:t,config:i,store:r}=this;if(this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!t.pointsNumber||t.pointsNumber===0||!r.screenSize||r.screenSize[0]===0||r.screenSize[1]===0)return;this.drawCommand.setVertexCount(t.pointsNumber);const s={ratio:i.pixelRatio??V.pixelRatio,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],greyoutColor:r.greyoutPointColor??[-1,-1,-1,-1],backgroundColor:r.backgroundColor??[0,0,0,1],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0},o={greyoutOpacity:i.pointGreyoutOpacity??-1,pointOpacity:i.pointOpacity??1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1]};if(r.selectedIndices&&r.selectedIndices.length>0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:1,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:1},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(this.device,"drawFragmentUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),i.renderHoveredPointRing&&r.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((a=t.pointSizes)==null?void 0:a[r.hoveredPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.hoveredPoint.index,maxPointSize:r.maxPointSize??100,color:r.hoveredPointRingColor,universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1],greyoutColor:r.greyoutPointColor??[0,0,0,1],width:.85}}),this.drawHighlightedCommand.setBindings({drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(this.device,"drawHighlightedUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}if(r.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((l=t.pointSizes)==null?void 0:l[r.focusedPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:r.screenSize??[0,0],scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.focusedPoint.index,maxPointSize:r.maxPointSize??100,color:r.focusedPointRingColor,universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:r.backgroundColor??[0,0,0,1],greyoutColor:r.greyoutPointColor??[0,0,0,1],width:.85}}),this.drawHighlightedCommand.setBindings({drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(this.device,"drawHighlightedUniforms"),positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}}updatePosition(){if(!this.updatePositionCommand||!this.updatePositionUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.velocityTexture||this.velocityTexture.destroyed||!this.pinnedStatusTexture||this.pinnedStatusTexture.destroyed)return;this.updatePositionUniformStore.setUniforms({updatePositionUniforms:{friction:this.config.simulationFriction??0,spaceSize:this.store.adjustedSpaceSize??0}}),this.updatePositionCommand.setBindings({updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(this.device,"updatePositionUniforms"),positionsTexture:this.previousPositionTexture,velocity:this.velocityTexture,pinnedStatusTexture:this.pinnedStatusTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.updatePositionCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var t;if(!this.dragPointCommand||!this.dragPointUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed)return;this.dragPointUniformStore.setUniforms({dragPointUniforms:{mousePos:this.store.mousePosition??[0,0],index:((t=this.store.hoveredPoint)==null?void 0:t.index)??-1}}),this.dragPointCommand.setBindings({dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(this.device,"dragPointUniforms"),positionsTexture:this.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var t,i;if(!this.findPointsOnAreaSelectionCommand||!this.findPointsOnAreaSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return;this.findPointsOnAreaSelectionUniformStore.setUniforms({findPointsOnAreaSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],sizeScale:this.config.pointSizeScale??1,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio??V.pixelRatio,selection0:((t=this.store.selectedArea)==null?void 0:t[0])??[0,0],selection1:((i=this.store.selectedArea)==null?void 0:i[1])??[0,0],scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,maxPointSize:this.store.maxPointSize??100}}),this.findPointsOnAreaSelectionCommand.setBindings({findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(this.device,"findPointsOnAreaSelectionUniforms"),positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnAreaSelectionCommand.draw(e),e.end()}findPointsOnPolygonSelection(){if(!this.findPointsOnPolygonSelectionCommand||!this.findPointsOnPolygonSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return;this.findPointsOnPolygonSelectionUniformStore.setUniforms({findPointsOnPolygonSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsOnPolygonSelectionCommand.setBindings({findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(this.device,"findPointsOnPolygonSelectionUniforms"),positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnPolygonSelectionCommand.draw(e),e.end()}updatePolygonPath(e){const{device:t}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0;return}const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4);for(const[s,o]of e.entries()){const[a,l]=o;r[s*4]=a,r[s*4+1]=l,r[s*4+2]=0,r[s*4+3]=0}!this.polygonPathTexture||this.polygonPathTexture.width!==i||this.polygonPathTexture.height!==i?(this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=t.createTexture({width:i,height:i,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})):this.polygonPathTexture.copyImageData({data:r,bytesPerRow:i,mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed)return;if(this.clearHoveredFboCommand){const t=this.device.beginRenderPass({framebuffer:this.hoveredFbo});this.clearHoveredFboCommand.draw(t),t.end()}if(!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed)return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}}),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{ratio:this.config.pixelRatio??V.pixelRatio,sizeScale:this.config.pointSizeScale??1,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0],scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,mousePosition:this.store.screenMousePosition??[0,0],maxPointSize:this.store.maxPointSize??100}}),this.findHoveredPointCommand.setBindings({findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(this.device,"findHoveredPointUniforms"),positionsTexture:this.currentPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.hoveredFbo});this.findHoveredPointCommand.draw(e),e.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:t},device:i}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!t)return;const r=Math.ceil(Math.sqrt(e.length)),s=new Float32Array(r*r*4).fill(-1);for(const[o,a]of e.entries())a!==void 0&&(s[o*4]=a%t,s[o*4+1]=Math.floor(a/t),s[o*4+2]=0,s[o*4+3]=0);!this.trackedIndicesTexture||this.trackedIndicesTexture.width!==r||this.trackedIndicesTexture.height!==r?(this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=i.createTexture({width:r,height:r,format:"rgba32float"}),this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:r,mipLevel:0,x:0,y:0})):this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:r,mipLevel:0,x:0,y:0}),(!this.trackedPositionsFbo||this.trackedPositionsFbo.width!==r||this.trackedPositionsFbo.height!==r)&&(this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=i.createFramebuffer({width:r,height:r,colorAttachments:["rgba32float"]})),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:t}}=this;if((!e||!t)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const i=We(this.device,this.trackedPositionsFbo),r=new Map;for(let s=0;s<i.length/4;s+=1){const o=i[s*4],a=i[s*4+1],l=this.trackedIndices[s];o!==void 0&&a!==void 0&&l!==void 0&&r.set(l,[o,a])}return(!e||!t)&&(this.trackedPositions=r,this.isPositionsUpToDate=!0),r}getSampledPointPositionsMap(){const e=new Map;if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return e;if(this.clearSampledPointsFboCommand){const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.clearSampledPointsFboCommand.draw(i),i.end()}if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return e;this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0]}}),this.fillSampledPointsFboCommand.setBindings({fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(this.device,"fillSampledPointsUniforms"),positionsTexture:this.currentPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.fillSampledPointsFboCommand.draw(i),i.end()}const t=We(this.device,this.sampledPointsFbo);for(let i=0;i<t.length/4;i++){const r=t[i*4],s=!!t[i*4+1],o=t[i*4+2],a=t[i*4+3];s&&r!==void 0&&o!==void 0&&a!==void 0&&e.set(r,[o,a])}return e}getSampledPoints(){const e=[],t=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:t};if(this.clearSampledPointsFboCommand){const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.clearSampledPointsFboCommand.draw(r),r.end()}if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:t};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:this.store.screenSize??[0,0]}}),this.fillSampledPointsFboCommand.setBindings({fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(this.device,"fillSampledPointsUniforms"),positionsTexture:this.currentPositionTexture});const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo});this.fillSampledPointsFboCommand.draw(r),r.end()}const i=We(this.device,this.sampledPointsFbo);for(let r=0;r<i.length/4;r++){const s=i[r*4],o=!!i[r*4+1],a=i[r*4+2],l=i[r*4+3];o&&s!==void 0&&a!==void 0&&l!==void 0&&(e.push(s),t.push(a,l))}return{indices:e,positions:t}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const t=We(this.device,this.trackedPositionsFbo);for(let i=0;i<t.length/4;i+=1){const r=t[i*4],s=t[i*4+1],o=this.trackedIndices[i];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}destroy(){var e,t,i,r,s,o,a,l,c,u,f,h,d,_,I,C,w,M,E,x;(e=this.updatePositionUniformStore)==null||e.destroy(),this.updatePositionUniformStore=void 0,(t=this.dragPointUniformStore)==null||t.destroy(),this.dragPointUniformStore=void 0,(i=this.drawUniformStore)==null||i.destroy(),this.drawUniformStore=void 0,(r=this.findPointsOnAreaSelectionUniformStore)==null||r.destroy(),this.findPointsOnAreaSelectionUniformStore=void 0,(s=this.findPointsOnPolygonSelectionUniformStore)==null||s.destroy(),this.findPointsOnPolygonSelectionUniformStore=void 0,(o=this.findHoveredPointUniformStore)==null||o.destroy(),this.findHoveredPointUniformStore=void 0,(a=this.fillSampledPointsUniformStore)==null||a.destroy(),this.fillSampledPointsUniformStore=void 0,(l=this.drawHighlightedUniformStore)==null||l.destroy(),this.drawHighlightedUniformStore=void 0,(c=this.trackPointsUniformStore)==null||c.destroy(),this.trackPointsUniformStore=void 0,(u=this.drawCommand)==null||u.destroy(),this.drawCommand=void 0,(f=this.drawHighlightedCommand)==null||f.destroy(),this.drawHighlightedCommand=void 0,(h=this.updatePositionCommand)==null||h.destroy(),this.updatePositionCommand=void 0,(d=this.dragPointCommand)==null||d.destroy(),this.dragPointCommand=void 0,(_=this.findPointsOnAreaSelectionCommand)==null||_.destroy(),this.findPointsOnAreaSelectionCommand=void 0,(I=this.findPointsOnPolygonSelectionCommand)==null||I.destroy(),this.findPointsOnPolygonSelectionCommand=void 0,(C=this.findHoveredPointCommand)==null||C.destroy(),this.findHoveredPointCommand=void 0,(w=this.clearHoveredFboCommand)==null||w.destroy(),this.clearHoveredFboCommand=void 0,(M=this.clearSampledPointsFboCommand)==null||M.destroy(),this.clearSampledPointsFboCommand=void 0,(E=this.fillSampledPointsFboCommand)==null||E.destroy(),this.fillSampledPointsFboCommand=void 0,(x=this.trackPointsCommand)==null||x.destroy(),this.trackPointsCommand=void 0,this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionFbo=void 0,this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedFbo=void 0,this.hoveredFbo&&!this.hoveredFbo.destroyed&&this.hoveredFbo.destroy(),this.hoveredFbo=void 0,this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=void 0,this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=void 0,this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionTexture=void 0,this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedTexture=void 0,this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=void 0,this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=void 0,this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=void 0,this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=void 0,this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=void 0,this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=void 0,this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=void 0,this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=void 0,this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=void 0,this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=void 0,this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsOnAreaSelectionVertexCoordBuffer&&!this.findPointsOnAreaSelectionVertexCoordBuffer.destroyed&&this.findPointsOnAreaSelectionVertexCoordBuffer.destroy(),this.findPointsOnAreaSelectionVertexCoordBuffer=void 0,this.findPointsOnPolygonSelectionVertexCoordBuffer&&!this.findPointsOnPolygonSelectionVertexCoordBuffer.destroyed&&this.findPointsOnPolygonSelectionVertexCoordBuffer.destroy(),this.findPointsOnPolygonSelectionVertexCoordBuffer=void 0,this.clearHoveredFboVertexCoordBuffer&&!this.clearHoveredFboVertexCoordBuffer.destroyed&&this.clearHoveredFboVertexCoordBuffer.destroy(),this.clearHoveredFboVertexCoordBuffer=void 0,this.clearSampledPointsFboVertexCoordBuffer&&!this.clearSampledPointsFboVertexCoordBuffer.destroyed&&this.clearSampledPointsFboVertexCoordBuffer.destroy(),this.clearSampledPointsFboVertexCoordBuffer=void 0,this.drawHighlightedVertexCoordBuffer&&!this.drawHighlightedVertexCoordBuffer.destroyed&&this.drawHighlightedVertexCoordBuffer.destroy(),this.drawHighlightedVertexCoordBuffer=void 0,this.trackPointsVertexCoordBuffer&&!this.trackPointsVertexCoordBuffer.destroyed&&this.trackPointsVertexCoordBuffer.destroy(),this.trackPointsVertexCoordBuffer=void 0}swapFbo(){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionFbo||this.previousPositionFbo.destroyed)return;const e=this.previousPositionTexture,t=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=t}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,i=t.length/2;let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let C=0;C<t.length;C+=2){const w=t[C],M=t[C+1];r=Math.min(r,w),s=Math.max(s,w),o=Math.min(o,M),a=Math.max(a,M)}const l=s-r,c=a-o,u=Math.max(l,c);if(u>e){this.scaleX=void 0,this.scaleY=void 0;return}const f=e*e*.001,d=(i>f?e*Math.max(1.2,Math.sqrt(i)/e):e*.1)/u,_=(u-l)/2*d,I=(u-c)/2*d;this.scaleX=C=>(C-r)*d+_,this.scaleY=C=>(C-o)*d+I;for(let C=0;C<i;C++)this.data.pointPositions[C*2]=this.scaleX(t[C*2]),this.data.pointPositions[C*2+1]=this.scaleY(t[C*2+1])}}var ru=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});function Hv(){var n=new ru(9);return ru!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function su(n,e,t){var i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=o,n[4]=a,n[5]=l,n[6]=h*i+d*o+c,n[7]=h*r+d*a+u,n[8]=h*s+d*l+f,n}function vo(n,e,t){var i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Wv(n,e,t){return n[0]=2/e,n[1]=0,n[2]=0,n[3]=0,n[4]=-2/t,n[5]=0,n[6]=-1,n[7]=1,n[8]=1,n}var cr={exports:{}},$v=cr.exports,ou;function Xv(){return ou||(ou=1,function(n){(function(e,t,i){function r(l){var c=this,u=a();c.next=function(){var f=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=f-(c.c=f|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 s(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 r(l),f=c&&c.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,f&&(typeof f=="object"&&s(f,u),h.state=function(){return s(u,{})}),h}function a(){var l=4022871197,c=function(u){u=String(u);for(var f=0;f<u.length;f++){l+=u.charCodeAt(f);var h=.02519603282416938*l;l=h>>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=o:this.alea=o})($v,n)}(cr)),cr.exports}var ur={exports:{}},Yv=ur.exports,au;function qv(){return au||(au=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var f=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^f^f>>>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 s(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 r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(Yv,n)}(ur)),ur.exports}var fr={exports:{}},jv=fr.exports,lu;function Kv(){return lu||(lu=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=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^(f^f<<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 s(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 r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(jv,n)}(fr)),fr.exports}var hr={exports:{}},Zv=hr.exports,cu;function Qv(){return cu||(cu=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.x,f=l.i,h,d;return h=u[f],h^=h>>>7,d=h^h<<24,h=u[f+1&7],d^=h^h>>>10,h=u[f+3&7],d^=h^h>>>3,h=u[f+4&7],d^=h^h<<7,h=u[f+7&7],h=h^h<<13,d^=h^h<<9,u[f]=d,l.i=f+1&7,d};function c(u,f){var h,d=[];if(f===(f|0))d[0]=f;else for(f=""+f,h=0;h<f.length;++h)d[h&7]=d[h&7]<<15^f.charCodeAt(h)+d[h+1&7]<<13;for(;d.length<8;)d.push(0);for(h=0;h<8&&d[h]===0;++h);for(h==8?d[7]=-1:d[h],u.x=d,u.i=0,h=256;h>0;--h)u.next()}c(l,a)}function s(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 r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.x&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(Zv,n)}(hr)),hr.exports}var dr={exports:{}},Jv=dr.exports,uu;function Gv(){return uu||(uu=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.w,f=l.X,h=l.i,d,_;return l.w=u=u+1640531527|0,_=f[h+34&127],d=f[h=h+1&127],_^=_<<13,d^=d<<17,_^=_>>>15,d^=d>>>12,_=f[h]=_^d,l.i=h,_+(u^u>>>16)|0};function c(u,f){var h,d,_,I,C,w=[],M=128;for(f===(f|0)?(d=f,f=null):(f=f+"\0",d=0,M=Math.max(M,f.length)),_=0,I=-32;I<M;++I)f&&(d^=f.charCodeAt((I+32)%f.length)),I===0&&(C=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,I>=0&&(C=C+1640531527|0,h=w[I&127]^=d+C,_=h==0?_+1:0);for(_>=128&&(w[(f&&f.length||0)&127]=-1),_=127,I=4*128;I>0;--I)d=w[_+34&127],h=w[_=_+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,w[_]=d^h;u.w=C,u.X=w,u.i=_}c(l,a)}function s(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 r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.X&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(Jv,n)}(dr)),dr.exports}var pr={exports:{}},e0=pr.exports,fu;function t0(){return fu||(fu=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=l.b,h=l.c,d=l.d,_=l.a;return f=f<<25^f>>>7^h,h=h-d|0,d=d<<24^d>>>8^_,_=_-f|0,l.b=f=f<<20^f>>>12^h,l.c=h=h-d|0,l.d=d<<16^h>>>16^_,l.a=_-f|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 s(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 r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})(e0,n)}(pr)),pr.exports}var mr={exports:{}};const n0=Ly(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var i0=mr.exports,hu;function r0(){return hu||(hu=1,function(n){(function(e,t,i){var r=256,s=6,o=52,a="random",l=i.pow(r,s),c=i.pow(2,o),u=c*2,f=r-1,h;function d(x,R,O){var L=[];R=R==!0?{entropy:!0}:R||{};var W=w(C(R.entropy?[x,E(t)]:x??M(),3),L),q=new _(L),Q=function(){for(var B=q.g(s),fe=l,ne=0;B<c;)B=(B+ne)*r,fe*=r,ne=q.g(1);for(;B>=u;)B/=2,fe/=2,ne>>>=1;return(B+ne)/fe};return Q.int32=function(){return q.g(4)|0},Q.quick=function(){return q.g(4)/4294967296},Q.double=Q,w(E(q.S),t),(R.pass||O||function(B,fe,ne,P){return P&&(P.S&&I(P,q),B.state=function(){return I(q,{})}),ne?(i[a]=B,fe):B})(Q,W,"global"in R?R.global:this==i,R.state)}function _(x){var R,O=x.length,L=this,W=0,q=L.i=L.j=0,Q=L.S=[];for(O||(x=[O++]);W<r;)Q[W]=W++;for(W=0;W<r;W++)Q[W]=Q[q=f&q+x[W%O]+(R=Q[W])],Q[q]=R;(L.g=function(B){for(var fe,ne=0,P=L.i,H=L.j,F=L.S;B--;)fe=F[P=f&P+1],ne=ne*r+F[f&(F[P]=F[H=f&H+fe])+(F[H]=fe)];return L.i=P,L.j=H,ne})(r)}function I(x,R){return R.i=x.i,R.j=x.j,R.S=x.S.slice(),R}function C(x,R){var O=[],L=typeof x,W;if(R&&L=="object")for(W in x)try{O.push(C(x[W],R-1))}catch{}return O.length?O:L=="string"?x:x+"\0"}function w(x,R){for(var O=x+"",L,W=0;W<O.length;)R[f&W]=f&(L^=R[f&W]*19)+O.charCodeAt(W++);return E(R)}function M(){try{var x;return h&&(x=h.randomBytes)?x=x(r):(x=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(x)),E(x)}catch{var R=e.navigator,O=R&&R.plugins;return[+new Date,e,O,e.screen,E(t)]}}function E(x){return String.fromCharCode.apply(0,x)}if(w(i.random(),t),n.exports){n.exports=d;try{h=n0}catch{}}else i["seed"+a]=d})(typeof self<"u"?self:i0,[],Math)}(mr)),mr.exports}var bo,du;function s0(){if(du)return bo;du=1;var n=Xv(),e=qv(),t=Kv(),i=Qv(),r=Gv(),s=t0(),o=r0();return o.alea=n,o.xor128=e,o.xorwow=t,o.xorshift7=i,o.xor4096=r,o.tychei=s,bo=o,bo}var o0=s0();const a0=Oc(o0);function l0(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,u0(i.key),i)}}function So(n,e,t){return e&&l0(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function pu(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,To(n,e)}function To(n,e){return To=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},To(n,e)}function c0(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function u0(n){var e=c0(n,"string");return typeof e=="symbol"?e:String(e)}var gr=function(){function n(){}var e=n.prototype;return e._seed=function(i,r){if(i===(i||0))return i;for(var s=""+i,o=0,a=0;a<s.length;++a)o^=s.charCodeAt(a)|0;return o},n}(),mu=function(n){pu(e,n);function e(i,r){var s;return s=n.call(this)||this,s._rng=void 0,s.seed(i,r),s}var t=e.prototype;return t.next=function(){return this._rng()},t.seed=function(r,s){this._rng=r},t.clone=function(r,s){return new e(this._rng,s)},So(e,[{key:"name",get:function(){return"function"}}]),e}(gr),gu=function(){var n=[].slice.call(arguments),e=n,t=e[0],i=t===void 0?"default":t;switch(typeof i){case"object":if(i instanceof gr)return i;break;case"function":return new mu(i);case"number":case"string":default:return new mu(a0.apply(void 0,n))}throw new Error('invalid RNG "'+i+'"')},f0=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){return n.next()*(t-e)+e}};function ot(n){return new h0(n)}var h0=function(e){var t=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(t.n))return t;throw new Error("Expected number to be an integer, got "+t.n)},this.isPositive=function(){if(t.n>0)return t;throw new Error("Expected number to be positive, got "+t.n)},this.lessThan=function(i){if(t.n<i)return t;throw new Error("Expected number to be less than "+i+", got "+t.n)},this.greaterThanOrEqual=function(i){if(t.n>=i)return t;throw new Error("Expected number to be greater than or equal to "+i+", got "+t.n)},this.greaterThan=function(i){if(t.n>i)return t;throw new Error("Expected number to be greater than "+i+", got "+t.n)},this.n=e},d0=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),t===void 0&&(t=e===void 0?1:e,e=0),ot(e).isInt(),ot(t).isInt(),function(){return Math.floor(n.next()*(t-e+1)+e)}},p0=function(n){return function(){return n.next()>=.5}},m0=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){var i,r,s;do i=n.next()*2-1,r=n.next()*2-1,s=i*i+r*r;while(!s||s>1);return e+t*r*Math.sqrt(-2*Math.log(s)/s)}},g0=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=1);var i=n.normal(e,t);return function(){return Math.exp(i())}},_0=function(n,e){return e===void 0&&(e=.5),ot(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(n.next()+e)}},x0=function(n,e,t){return e===void 0&&(e=1),t===void 0&&(t=.5),ot(e).isInt().isPositive(),ot(t).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<e;)n.next()<t&&r++;return r}},y0=function(n,e){e===void 0&&(e=.5),ot(e).greaterThan(0).lessThan(1);var t=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(n.next())*t)}},v0=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],b0=function(e){return v0[e]},S0=.9189385332046727,T0=function(n,e){if(e===void 0&&(e=1),ot(e).isPositive(),e<10){var t=Math.exp(-e);return function(){for(var l=t,c=0,u=n.next();u>l;)u=u-l,l=e*l/++c;return c}}else{var i=Math.sqrt(e),r=.931+2.53*i,s=-.059+.02483*r,o=1.1239+1.1328/(r-3.4),a=.9277-3.6224/(r-2);return function(){for(;;){var l=void 0,c=n.next();if(c<=.86*a)return l=c/a-.43,Math.floor((2*s/(.5-Math.abs(l))+r)*l+e+.445);c>=a?l=n.next()-.5:(l=c/a-.93,l=(l<0?-.5:.5)-l,c=n.next()*a);var u=.5-Math.abs(l);if(!(u<.013&&c>u)){var f=Math.floor((2*s/u+r)*l+e+.445);if(c=c*o/(s/(u*u)+r),f>=10){var h=(f+.5)*Math.log(e/f)-e-S0+f-(.08333333333333333-(.002777777777777778-1/(1260*f*f))/(f*f))/f;if(Math.log(c*i)<=h)return f}else if(f>=0){var d,_=(d=b0(f))!=null?d:0;if(Math.log(c)<=f*Math.log(e)-e-_)return f}}}}}},w0=function(n,e){return e===void 0&&(e=1),ot(e).isPositive(),function(){return-Math.log(1-n.next())/e}},A0=function(n,e){return e===void 0&&(e=1),ot(e).isInt().greaterThanOrEqual(0),function(){for(var t=0,i=0;i<e;++i)t+=n.next();return t}},C0=function(n,e){e===void 0&&(e=1),ot(e).isInt().isPositive();var t=n.irwinHall(e);return function(){return t()/e}},P0=function(n,e){e===void 0&&(e=1),ot(e).greaterThanOrEqual(0);var t=1/e;return function(){return 1/Math.pow(1-n.next(),t)}},I0=function(n){pu(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.next=function(){return Math.random()},t.seed=function(r,s){},t.clone=function(){return new e},So(e,[{key:"name",get:function(){return"default"}}]),e}(gr),_u=function(){function n(t){var i=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return i._rng.next()},this.float=function(r,s){return i.uniform(r,s)()},this.int=function(r,s){return i.uniformInt(r,s)()},this.integer=function(r,s){return i.uniformInt(r,s)()},this.bool=function(){return i.uniformBoolean()()},this.boolean=function(){return i.uniformBoolean()()},this.uniform=function(r,s){return i._memoize("uniform",f0,r,s)},this.uniformInt=function(r,s){return i._memoize("uniformInt",d0,r,s)},this.uniformBoolean=function(){return i._memoize("uniformBoolean",p0)},this.normal=function(r,s){return m0(i,r,s)},this.logNormal=function(r,s){return g0(i,r,s)},this.bernoulli=function(r){return _0(i,r)},this.binomial=function(r,s){return x0(i,r,s)},this.geometric=function(r){return y0(i,r)},this.poisson=function(r){return T0(i,r)},this.exponential=function(r){return w0(i,r)},this.irwinHall=function(r){return A0(i,r)},this.bates=function(r){return C0(i,r)},this.pareto=function(r){return P0(i,r)},t&&t instanceof gr?this.use(t):this.use(new I0),this._cache={}}var e=n.prototype;return e.clone=function(){var i=[].slice.call(arguments);return i.length?new n(gu.apply(void 0,i)):new n(this.rng.clone())},e.use=function(){this._rng=gu.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(i){if(!Array.isArray(i))throw new Error("Random.choice expected input to be an array, got "+typeof i);var r=i==null?void 0:i.length;if(r>0){var s=this.uniformInt(0,r-1)();return i[s]}else return},e._memoize=function(i,r){var s=[].slice.call(arguments,2),o=""+s.join(";"),a=this._cache[i];return(a===void 0||a.key!==o)&&(a={key:o,distribution:r.apply(void 0,[this].concat(s))},this._cache[i]=a),a.distribution},So(n,[{key:"rng",get:function(){return this._rng}}]),n}();new _u;const wo=.001,Ao=64,R0=4;class E0{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Hv(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=Ao,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=V.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,k_],this.focusedPointRingColor=[1,1,1,D_],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=yo(),this.scalePointY=yo(),this.random=new _u,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(wo,1/e)}get backgroundColor(){return this._backgroundColor}get transformationMatrix4x4(){const e=this.transform;if(e.length!==9)throw new Error(`Transform must be a 9-element array (3x3 matrix), got ${e.length} elements`);return[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]}set backgroundColor(e){this._backgroundColor=e;const t=Vl(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",t>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",t>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=t<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,t){return this.random.float(e,t)}adjustSpaceSize(e,t){e>=t?(this.adjustedSpaceSize=t/2,console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}setWebGLMaxTextureSize(e){this.webglMaxTextureSize=e}updateScreenSize(e,t){const{adjustedSpaceSize:i}=this;this.screenSize=[e,t],this.scalePointX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scalePointY.domain([i,0]).range([(t-i)/2,(t+i)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=vt(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=vt(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const t=vt(e);this.greyoutPointColor[0]=t[0],this.greyoutPointColor[1]=t[1],this.greyoutPointColor[2]=t[2],this.greyoutPointColor[3]=t[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const t=vt(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const k0={passive:!1},Gn={capture:!0,passive:!1};function Co(n){n.stopImmediatePropagation()}function gn(n){n.preventDefault(),n.stopImmediatePropagation()}function xu(n){var e=n.document.documentElement,t=Se(n).on("dragstart.drag",gn,Gn);"onselectstart"in e?t.on("selectstart.drag",gn,Gn):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function yu(n,e){var t=n.document.documentElement,i=Se(n).on("dragstart.drag",null);e&&(i.on("click.drag",gn,Gn),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in t?i.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const _r=n=>()=>n;function Po(n,{sourceEvent:e,subject:t,target:i,identifier:r,active:s,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,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}})}Po.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function D0(n){return!n.ctrlKey&&!n.button}function F0(){return this.parentNode}function M0(n,e){return e??{x:n.x,y:n.y}}function N0(){return navigator.maxTouchPoints||"ontouchstart"in this}function O0(){var n=D0,e=F0,t=M0,i=N0,r={},s=ci("start","drag","end"),o=0,a,l,c,u,f=0;function h(x){x.on("mousedown.drag",d).filter(i).on("touchstart.drag",C).on("touchmove.drag",w,k0).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(x,R){if(!(u||!n.call(this,x,R))){var O=E(this,e.call(this,x,R),x,R,"mouse");O&&(Se(x.view).on("mousemove.drag",_,Gn).on("mouseup.drag",I,Gn),xu(x.view),Co(x),c=!1,a=x.clientX,l=x.clientY,O("start",x))}}function _(x){if(gn(x),!c){var R=x.clientX-a,O=x.clientY-l;c=R*R+O*O>f}r.mouse("drag",x)}function I(x){Se(x.view).on("mousemove.drag mouseup.drag",null),yu(x.view,c),gn(x),r.mouse("end",x)}function C(x,R){if(n.call(this,x,R)){var O=x.changedTouches,L=e.call(this,x,R),W=O.length,q,Q;for(q=0;q<W;++q)(Q=E(this,L,x,R,O[q].identifier,O[q]))&&(Co(x),Q("start",x,O[q]))}}function w(x){var R=x.changedTouches,O=R.length,L,W;for(L=0;L<O;++L)(W=r[R[L].identifier])&&(gn(x),W("drag",x,R[L]))}function M(x){var R=x.changedTouches,O=R.length,L,W;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),L=0;L<O;++L)(W=r[R[L].identifier])&&(Co(x),W("end",x,R[L]))}function E(x,R,O,L,W,q){var Q=s.copy(),B=gt(q||O,R),fe,ne,P;if((P=t.call(x,new Po("beforestart",{sourceEvent:O,target:h,identifier:W,active:o,x:B[0],y:B[1],dx:0,dy:0,dispatch:Q}),L))!=null)return fe=P.x-B[0]||0,ne=P.y-B[1]||0,function H(F,$,Z){var j=B,ee;switch(F){case"start":r[W]=H,ee=o++;break;case"end":delete r[W],--o;case"drag":B=gt(Z||$,R),ee=o;break}Q.call(F,x,new Po(F,{sourceEvent:$,subject:P,target:h,identifier:W,active:ee,x:B[0]+fe,y:B[1]+ne,dx:B[0]-j[0],dy:B[1]-j[1],dispatch:Q}),L)}}return h.filter=function(x){return arguments.length?(n=typeof x=="function"?x:_r(!!x),h):n},h.container=function(x){return arguments.length?(e=typeof x=="function"?x:_r(x),h):e},h.subject=function(x){return arguments.length?(t=typeof x=="function"?x:_r(x),h):t},h.touchable=function(x){return arguments.length?(i=typeof x=="function"?x:_r(!!x),h):i},h.on=function(){var x=s.on.apply(s,arguments);return x===s?h:x},h.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,h):Math.sqrt(f)},h}const xr=n=>()=>n;function B0(n,{sourceEvent:e,target:t,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function wt(n,e,t){this.k=n,this.x=e,this.y=t}wt.prototype={constructor:wt,scale:function(n){return n===1?this:new wt(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new wt(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ei=new wt(1,0,0);wt.prototype;function Io(n){n.stopImmediatePropagation()}function ti(n){n.preventDefault(),n.stopImmediatePropagation()}function U0(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function z0(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function vu(){return this.__zoom||ei}function L0(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function V0(){return navigator.maxTouchPoints||"ontouchstart"in this}function H0(n,e,t){var i=n.invertX(e[0][0])-t[0][0],r=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],o=n.invertY(e[1][1])-t[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function W0(){var n=U0,e=z0,t=H0,i=L0,r=V0,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=ld,c=ci("start","zoom","end"),u,f,h,d=500,_=150,I=0,C=10;function w(P){P.property("__zoom",vu).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",Q).filter(r).on("touchstart.zoom",B).on("touchmove.zoom",fe).on("touchend.zoom touchcancel.zoom",ne).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(P,H,F,$){var Z=P.selection?P.selection():P;Z.property("__zoom",vu),P!==Z?R(P,H,F,$):Z.interrupt().each(function(){O(this,arguments).event($).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},w.scaleBy=function(P,H,F,$){w.scaleTo(P,function(){var Z=this.__zoom.k,j=typeof H=="function"?H.apply(this,arguments):H;return Z*j},F,$)},w.scaleTo=function(P,H,F,$){w.transform(P,function(){var Z=e.apply(this,arguments),j=this.__zoom,ee=F==null?x(Z):typeof F=="function"?F.apply(this,arguments):F,G=j.invert(ee),pe=typeof H=="function"?H.apply(this,arguments):H;return t(E(M(j,pe),ee,G),Z,o)},F,$)},w.translateBy=function(P,H,F,$){w.transform(P,function(){return t(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,$)},w.translateTo=function(P,H,F,$,Z){w.transform(P,function(){var j=e.apply(this,arguments),ee=this.__zoom,G=$==null?x(j):typeof $=="function"?$.apply(this,arguments):$;return t(ei.translate(G[0],G[1]).scale(ee.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof F=="function"?-F.apply(this,arguments):-F),j,o)},$,Z)};function M(P,H){return H=Math.max(s[0],Math.min(s[1],H)),H===P.k?P:new wt(H,P.x,P.y)}function E(P,H,F){var $=H[0]-F[0]*P.k,Z=H[1]-F[1]*P.k;return $===P.x&&Z===P.y?P:new wt(P.k,$,Z)}function x(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function R(P,H,F,$){P.on("start.zoom",function(){O(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event($).end()}).tween("zoom",function(){var Z=this,j=arguments,ee=O(Z,j).event($),G=e.apply(Z,j),pe=F==null?x(G):typeof F=="function"?F.apply(Z,j):F,ce=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),be=Z.__zoom,ie=typeof H=="function"?H.apply(Z,j):H,Le=l(be.invert(pe).concat(ce/be.k),ie.invert(pe).concat(ce/ie.k));return function(Ve){if(Ve===1)Ve=ie;else{var Ge=Le(Ve),Kt=ce/Ge[2];Ve=new wt(Kt,pe[0]-Ge[0]*Kt,pe[1]-Ge[1]*Kt)}ee.zoom(null,Ve)}})}function O(P,H,F){return!F&&P.__zooming||new L(P,H)}function L(P,H){this.that=P,this.args=H,this.active=0,this.sourceEvent=null,this.extent=e.apply(P,H),this.taps=0}L.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,H){return this.mouse&&P!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var H=Se(this.that).datum();c.call(P,this.that,new B0(P,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:c}),H)}};function W(P,...H){if(!n.apply(this,arguments))return;var F=O(this,H).event(P),$=this.__zoom,Z=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),j=gt(P);if(F.wheel)(F.mouse[0][0]!==j[0]||F.mouse[0][1]!==j[1])&&(F.mouse[1]=$.invert(F.mouse[0]=j)),clearTimeout(F.wheel);else{if($.k===Z)return;F.mouse=[j,$.invert(j)],xi(this),F.start()}ti(P),F.wheel=setTimeout(ee,_),F.zoom("mouse",t(E(M($,Z),F.mouse[0],F.mouse[1]),F.extent,o));function ee(){F.wheel=null,F.end()}}function q(P,...H){if(h||!n.apply(this,arguments))return;var F=P.currentTarget,$=O(this,H,!0).event(P),Z=Se(P.view).on("mousemove.zoom",pe,!0).on("mouseup.zoom",ce,!0),j=gt(P,F),ee=P.clientX,G=P.clientY;xu(P.view),Io(P),$.mouse=[j,this.__zoom.invert(j)],xi(this),$.start();function pe(be){if(ti(be),!$.moved){var ie=be.clientX-ee,Le=be.clientY-G;$.moved=ie*ie+Le*Le>I}$.event(be).zoom("mouse",t(E($.that.__zoom,$.mouse[0]=gt(be,F),$.mouse[1]),$.extent,o))}function ce(be){Z.on("mousemove.zoom mouseup.zoom",null),yu(be.view,$.moved),ti(be),$.event(be).end()}}function Q(P,...H){if(n.apply(this,arguments)){var F=this.__zoom,$=gt(P.changedTouches?P.changedTouches[0]:P,this),Z=F.invert($),j=F.k*(P.shiftKey?.5:2),ee=t(E(M(F,j),$,Z),e.apply(this,H),o);ti(P),a>0?Se(this).transition().duration(a).call(R,ee,$,P):Se(this).call(w.transform,ee,$,P)}}function B(P,...H){if(n.apply(this,arguments)){var F=P.touches,$=F.length,Z=O(this,H,P.changedTouches.length===$).event(P),j,ee,G,pe;for(Io(P),ee=0;ee<$;++ee)G=F[ee],pe=gt(G,this),pe=[pe,this.__zoom.invert(pe),G.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==pe[2]&&(Z.touch1=pe,Z.taps=0):(Z.touch0=pe,j=!0,Z.taps=1+!!u);u&&(u=clearTimeout(u)),j&&(Z.taps<2&&(f=pe[0],u=setTimeout(function(){u=null},d)),xi(this),Z.start())}}function fe(P,...H){if(this.__zooming){var F=O(this,H).event(P),$=P.changedTouches,Z=$.length,j,ee,G,pe;for(ti(P),j=0;j<Z;++j)ee=$[j],G=gt(ee,this),F.touch0&&F.touch0[2]===ee.identifier?F.touch0[0]=G:F.touch1&&F.touch1[2]===ee.identifier&&(F.touch1[0]=G);if(ee=F.that.__zoom,F.touch1){var ce=F.touch0[0],be=F.touch0[1],ie=F.touch1[0],Le=F.touch1[1],Ve=(Ve=ie[0]-ce[0])*Ve+(Ve=ie[1]-ce[1])*Ve,Ge=(Ge=Le[0]-be[0])*Ge+(Ge=Le[1]-be[1])*Ge;ee=M(ee,Math.sqrt(Ve/Ge)),G=[(ce[0]+ie[0])/2,(ce[1]+ie[1])/2],pe=[(be[0]+Le[0])/2,(be[1]+Le[1])/2]}else if(F.touch0)G=F.touch0[0],pe=F.touch0[1];else return;F.zoom("touch",t(E(ee,G,pe),F.extent,o))}}function ne(P,...H){if(this.__zooming){var F=O(this,H).event(P),$=P.changedTouches,Z=$.length,j,ee;for(Io(P),h&&clearTimeout(h),h=setTimeout(function(){h=null},d),j=0;j<Z;++j)ee=$[j],F.touch0&&F.touch0[2]===ee.identifier?delete F.touch0:F.touch1&&F.touch1[2]===ee.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(ee=gt(ee,this),Math.hypot(f[0]-ee[0],f[1]-ee[1])<C)){var G=Se(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return w.wheelDelta=function(P){return arguments.length?(i=typeof P=="function"?P:xr(+P),w):i},w.filter=function(P){return arguments.length?(n=typeof P=="function"?P:xr(!!P),w):n},w.touchable=function(P){return arguments.length?(r=typeof P=="function"?P:xr(!!P),w):r},w.extent=function(P){return arguments.length?(e=typeof P=="function"?P:xr([[+P[0][0],+P[0][1]],[+P[1][0],+P[1][1]]]),w):e},w.scaleExtent=function(P){return arguments.length?(s[0]=+P[0],s[1]=+P[1],w):[s[0],s[1]]},w.translateExtent=function(P){return arguments.length?(o[0][0]=+P[0][0],o[1][0]=+P[1][0],o[0][1]=+P[0][1],o[1][1]=+P[1][1],w):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},w.constrain=function(P){return arguments.length?(t=P,w):t},w.duration=function(P){return arguments.length?(a=+P,w):a},w.interpolate=function(P){return arguments.length?(l=P,w):l},w.on=function(){var P=c.on.apply(c,arguments);return P===c?w:P},w.clickDistance=function(P){return arguments.length?(I=(P=+P)*P,w):Math.sqrt(I)},w.tapDistance=function(P){return arguments.length?(C=+P,w):C},w}class $0{constructor(e,t){this.eventTransform=ei,this.behavior=W0().scaleExtent([.001,1/0]).on("start",i=>{var s,o;this.isRunning=!0;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomStart)==null||o.call(s,i,r)}).on("zoom",i=>{var h,d;this.eventTransform=i.transform;const{eventTransform:{x:r,y:s,k:o},store:{transform:a,screenSize:l}}=this,c=l[0],u=l[1];if(!c||!u)return;Wv(a,c,u),su(a,a,[r,s]),vo(a,a,[o,o]),su(a,a,[c/2,u/2]),vo(a,a,[c/2,u/2]),vo(a,a,[1,-1]);const f=!!i.sourceEvent;(d=(h=this.config)==null?void 0:h.onZoom)==null||d.call(h,i,f)}).on("end",i=>{var s,o;this.isRunning=!1;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomEnd)==null||o.call(s,i,r)}),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,i=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:r}}=this,s=r[0],o=r[1],a=Vc(e.map(w=>w[0])),l=Vc(e.map(w=>w[1]));a[0]=this.store.scaleX(a[0]),a[1]=this.store.scaleX(a[1]),l[0]=this.store.scaleY(l[0]),l[1]=this.store.scaleY(l[1]),a[0]===a[1]&&(a[0]-=.5,a[1]+=.5),l[0]===l[1]&&(l[0]+=.5,l[1]-=.5);const c=s*(1-i*2)/(a[1]-a[0]),u=o*(1-i*2)/(l[0]-l[1]),f=Hl(t??Math.min(c,u),...this.behavior.scaleExtent()),h=(a[1]+a[0])/2,d=(l[1]+l[0])/2,_=s/2-h*f,I=o/2-d*f;return ei.translate(_,I).scale(f)}getDistanceToPoint(e){const{x:t,y:i,k:r}=this.eventTransform,s=this.getTransform([e],r),o=t-s.x,a=i-s.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:i,y:r,k:s}}=this,o=t[0],a=t[1],l=(o/2-i)/s,c=(a/2-r)/s,u=this.store.scaleX(e[0]),f=this.store.scaleY(e[1]),h=(l+u)/2,d=(c+f)/2,_=1,I=o/2-h*_,C=a/2-d*_;return ei.translate(I,C).scale(_)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:i,k:r},store:{screenSize:s}}=this,o=s[0],a=s[1],l=(e[0]-t)/r,c=(e[1]-i)/r,u=[l,a-c];return u[0]-=(o-this.store.adjustedSpaceSize)/2,u[1]-=(a-this.store.adjustedSpaceSize)/2,u}convertSpaceToScreenPosition(e){const t=this.eventTransform.applyX(this.store.scaleX(e[0])),i=this.eventTransform.applyY(this.store.scaleY(e[1]));return[t,i]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:i},eventTransform:{k:r}}=this;let s=e*2;return t?s*=r:s*=Math.min(5,Math.max(1,r*.01)),Math.min(s,i)/2}}class X0{constructor(e,t){this.isActive=!1,this.behavior=O0().subject(i=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:i.x,y:i.y}:void 0).on("start",i=>{var r,s;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(s=(r=this.config)==null?void 0:r.onDragStart)==null||s.call(r,i))}).on("drag",i=>{var r,s;(s=(r=this.config)==null?void 0:r.onDrag)==null||s.call(r,i)}).on("end",i=>{var r,s;this.isActive=!1,this.store.draggingPointIndex=void 0,(s=(r=this.config)==null?void 0:r.onDragEnd)==null||s.call(r,i)}),this.store=e,this.config=t}}class Y0{constructor(e,t){this.config=new nx,this.graph=new Yy(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new E0,this.zoomInstance=new $0(this.store,this.config),this.dragInstance=new X0(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,t&&this.config.init(t),this.store.div=e;const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",this.store.div.appendChild(i),this.addAttribution(),this.canvas=i,this.deviceInitPromise=this.createDevice(i).then(r=>{this.device=r;const s=i.clientWidth,o=i.clientHeight;i.width=s*this.config.pixelRatio,i.height=o*this.config.pixelRatio,this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(s,o),this.canvasD3Selection=Se(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",l=>{this._isMouseOnCanvas=!1,this.currentEvent=l,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(l),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(l),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),Se(document).on("keydown.cosmos",l=>{l.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",l=>{l.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",l=>{this.currentEvent=l}).on("zoom.detect",l=>{!!l.sourceEvent&&this.updateMousePosition(l.sourceEvent),this.currentEvent=l}).on("end.detect",l=>{this.currentEvent=l}),this.dragInstance.behavior.on("start.detect",l=>{this.currentEvent=l,this.updateCanvasCursor()}).on("drag.detect",l=>{this.dragInstance.isActive&&this.updateMousePosition(l),this.currentEvent=l}).on("end.detect",l=>{this.currentEvent=l,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1);const a=r.gl.getParameter(Rt.ALIASED_POINT_SIZE_RANGE);return this.store.maxPointSize=((a==null?void 0:a[1])??Ao)/this.config.pixelRatio,this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Vv(r,this.config,this.store,this.graph),this.lines=new Cv(r,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new Py(r,this.config,this.store,this.graph,this.points),this.forceCenter=new Ay(r,this.config,this.store,this.graph,this.points),this.forceManyBody=new Fy(r,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Nc(r,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Nc(r,this.config,this.store,this.graph,this.points),this.forceMouse=new Ny(r,this.config,this.store,this.graph,this.points)),this.clusters=new zy(r,this.config,this.store,this.graph,this.points),this.store.backgroundColor=vt(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??ks),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Uc(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),r}).catch(r=>{throw console.error("Device initialization failed:",r),r})}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i,r,s,o,a,l,c,u,f;if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const t={...this.config};if(this.config.init(e),(t.pointDefaultColor!==this.config.pointDefaultColor||t.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),(i=this.points)==null||i.updateColor()),(t.pointDefaultSize!==this.config.pointDefaultSize||t.pointSize!==this.config.pointSize)&&(this.graph.updatePointSize(),(r=this.points)==null||r.updateSize()),(t.linkDefaultColor!==this.config.linkDefaultColor||t.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),(s=this.lines)==null||s.updateColor()),(t.linkDefaultWidth!==this.config.linkDefaultWidth||t.linkWidth!==this.config.linkWidth)&&(this.graph.updateLinkWidth(),(o=this.lines)==null||o.updateWidth()),(t.linkDefaultArrows!==this.config.linkDefaultArrows||t.linkArrows!==this.config.linkArrows)&&(this.graph.updateArrows(),(a=this.lines)==null||a.updateArrow()),(t.curvedLinkSegments!==this.config.curvedLinkSegments||t.curvedLinks!==this.config.curvedLinks)&&((l=this.lines)==null||l.updateCurveLineGeometry()),t.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=vt(this.config.backgroundColor??Tl)),t.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),t.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),t.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??ks),t.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),t.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),t.pixelRatio!==this.config.pixelRatio&&(c=this.device)!=null&&c.canvasContext){this.device.canvasContext.setProps({useDevicePixels:this.config.pixelRatio});const h=this.device.gl.getParameter(Rt.ALIASED_POINT_SIZE_RANGE);this.store.maxPointSize=((h==null?void 0:h[1])??Ao)/this.config.pixelRatio}(t.spaceSize!==this.config.spaceSize||t.simulationRepulsionQuadtreeLevels!==this.config.simulationRepulsionQuadtreeLevels)&&(this.store.adjustSpaceSize(this.config.spaceSize,((u=this.device)==null?void 0:u.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),t.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Uc(this.canvas):((f=this.fpsMonitor)==null||f.destroy(),this.fpsMonitor=void 0)),(t.enableZoom!==this.config.enableZoom||t.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(t.onLinkClick!==this.config.onLinkClick||t.onLinkMouseOver!==this.config.onLinkMouseOver||t.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,t))||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=t,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||this.ensureDevice(()=>this.setPointColors(e))||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointSizes(e))||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(t=this.points)==null||t.createAtlas())}setPointImageIndices(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageIndices(e))||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageSizes(e))||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||this.ensureDevice(()=>this.setLinks(e))||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkColors(e))||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkWidths(e))||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkArrows(e))||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkStrength(e))||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusters(e))||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||this.ensureDevice(()=>this.setClusterPositions(e))||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusterStrength(e))||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setPinnedPoints(e))||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,(t=this.points)==null||t.updatePinnedStatus())}render(e){if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:i,fitViewPadding:r,fitViewDuration:s,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Se(this.canvas).style("cursor",null),this.device&&this.device.beginRenderPass({clearColor:[0,0,1,1],clearDepth:1,clearStencil:0}).end();return}this._isFirstRenderAfterInit&&t&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{a?this.fitViewByPointIndices(a,s,r):o?this.setZoomTransformByPointPositions(o,s,void 0,r):this.fitView(s,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,t=700,i=F_,r=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,t,i,r))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:s}}=this,o=We(this.device,this.points.currentPositionFbo);if(e===void 0)return;const a=o[e*4+0],l=o[e*4+1];if(a===void 0||l===void 0)return;const c=this.zoomInstance.getDistanceToPoint([a,l]),u=r?i:Math.max(this.getZoomLevel(),i);if(c<Math.min(s[0],s[1]))this.setZoomTransformByPointPositions([a,l],t,u);else{const f=this.zoomInstance.getTransform([[a,l]],u),h=this.zoomInstance.getMiddlePointTransform([a,l]);this.canvasD3Selection.transition().ease(lp).duration(t/2).call(this.zoomInstance.behavior.transform,h).transition().ease(cp).duration(t/2).call(this.zoomInstance.behavior.transform,f)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,t))||this.canvasD3Selection&&(t===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.device||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],t=We(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=t[i*4+0],s=t[i*4+1];r!==void 0&&s!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}getClusterPositions(){if(this._isDestroyed||!this.device||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],t=We(this.device,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=t[i*4+0],s=t[i*4+1],o=t[i*4+2];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r/o,e[i*2+1]=s/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,t))||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,t)}fitViewByPointIndices(e,t=250,i=.1){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,t,i)))return;const r=this.getPointPositions(),s=new Array(e.length*2);for(const[o,a]of e.entries())s[o*2]=r[a*2],s[o*2+1]=r[a*2+1];this.setZoomTransformByPointPositions(s,t,void 0,i)}fitViewByPointPositions(e,t=250,i=.1){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,t,i))||this.setZoomTransformByPointPositions(e,t,void 0,i)}getPointsInRect(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;const t=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection(),We(this.device,this.points.selectedFbo).map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),We(this.device,this.points.selectedFbo).map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}selectPointsInRect(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInRect(e))&&!(!this.device||!this.points)){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const i=We(this.device,this.points.selectedFbo);this.store.selectedIndices=i.map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInPolygon(e))&&!(!this.device||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=We(this.device,this.points.selectedFbo);this.store.selectedIndices=r.map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointByIndex(e,t)))if(t){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.selectPointsByIndices(e))||this.points&&(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(t=>t!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||this.ensureDevice(()=>this.unselectPoints())||this.points&&(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;if(!this._isDestroyed)return(t=this.graph.pointSizes)==null?void 0:t[e]}trackPointPositionsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.trackPointPositionsByIndices(e))||this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var t,i;this._isDestroyed||this.ensureDevice(()=>this.start(e))||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(t=this.config).onSimulationStart)==null||i.call(t))}stop(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(t=(e=this.config).onSimulationEnd)==null||t.call(e))}pause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.pause())||(this.store.isSimulationRunning=!1,(t=(e=this.config).onSimulationPause)==null||t.call(e))}unpause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.unpause())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationUnpause)==null||t.call(e))}restart(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.restart())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationRestart)==null||t.call(e))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,t,i,r;this._isDestroyed||(window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),Se(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(t=this.dragInstance)!=null&&t.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.destroy()),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(r=document.getElementById("gl-bench-style"))==null||r.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,t,i,r,s;this._isDestroyed||this.ensureDevice(()=>this.create())||this.points&&this.lines&&(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((t=this.forceLinkIncoming)==null||t.create(ho.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(ho.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((s=this.clusters)==null||s.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let i=0;i<e.length/2;i++)t[i]=[e[i*2],e[i*2+1]];return t}ensureDevice(e){return this.device?!1:(this.deviceInitPromise.then(()=>{e()}).catch(t=>{console.error("Device initialization failed",t)}),!0)}async createDevice(e){return await jp.createDevice({type:"webgl",adapters:[qm],createCanvasContext:{canvas:e,useDevicePixels:this.config.pixelRatio,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:t}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((t.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var a,l,c,u,f,h,d,_,I,C,w,M,E,x,R,O,L,W,q,Q;const{config:{simulationGravity:t,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:s}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((a=this.forceMouse)==null||a.run(),(l=this.points)==null||l.updatePosition()),(e||s&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&((c=this.points)!=null&&c.velocityFbo&&!this.points.velocityFbo.destroyed&&this.device&&this.device.beginRenderPass({framebuffer:this.points.velocityFbo,clearColor:[0,0,0,0]}).end(),t&&((u=this.forceGravity)==null||u.run(),(f=this.points)==null||f.updatePosition()),i&&((h=this.forceCenter)==null||h.run(),(d=this.points)==null||d.updatePosition()),(_=this.forceManyBody)==null||_.run(),(I=this.points)==null||I.updatePosition(),this.store.linksTextureSize&&((C=this.forceLinkIncoming)==null||C.run(),(w=this.points)==null||w.updatePosition(),(M=this.forceLinkOutgoing)==null||M.run(),(E=this.points)==null||E.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((x=this.clusters)==null||x.run(),(R=this.points)==null||R.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??V.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,wo/this.store.alpha)),(q=(W=this.config).onSimulationTick)==null||q.call(W,this.store.alpha,(O=this.store.hoveredPoint)==null?void 0:O.index,(L=this.store.hoveredPoint)==null?void 0:L.position)),(Q=this.points)==null||Q.trackPoints()}initPrograms(){var e,t,i,r,s,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(t=this.forceManyBody)==null||t.initPrograms(),(i=this.forceCenter)==null||i.initPrograms(),(r=this.forceLinkIncoming)==null||r.initPrograms(),(s=this.forceLinkOutgoing)==null||s.initPrograms(),(o=this.forceMouse)==null||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:t}}=this;e<wo&&t&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var t,i,r,s,o,a,l;if(!this._isDestroyed&&this.store.pointsTextureSize){if((t=this.fpsMonitor)==null||t.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),this.device){const c=this.store.backgroundColor??[0,0,0,1],u=this.device.beginRenderPass({clearColor:c,clearDepth:1,clearStencil:0}),{config:{renderLinks:f}}=this;f!==!1&&!!this.store.linksTextureSize&&!!this.graph.linksNumber&&this.graph.linksNumber>0&&((i=this.lines)==null||i.draw(u)),(r=this.points)==null||r.draw(u),this.dragInstance.isActive&&((s=this.points)==null||s.drag(),(o=this.points)==null||o.drag(),(a=this.points)==null||a.trackPoints()),u.end(),this.device.submit()}(l=this.fpsMonitor)==null||l.end(e??performance.now()),this.currentEvent=void 0}}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(t=(e=this.config).onSimulationEnd)==null||t.call(e)}onClick(e){var t,i,r,s,o,a,l,c,u,f;(s=(r=this.config).onClick)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.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):(f=(u=this.config).onBackgroundClick)==null||f.call(u,e)}updateMousePosition(e){if(!e)return;const t=e.offsetX??e.x,i=e.offsetY??e.y;t===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([t,i]),this.store.screenMousePosition=[t,this.store.screenSize[1]-i])}onMouseMove(e){var t,i,r,s;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(s=(r=this.config).onMouseMove)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var o,a,l;if(this._isDestroyed)return;const t=this.canvas.clientWidth,i=this.canvas.clientHeight,[r,s]=this.store.screenSize;if(e||r!==t||s!==i){const{k:c}=this.zoomInstance.eventTransform,u=this.zoomInstance.convertScreenToSpacePosition([r/2,s/2]);this.store.updateScreenSize(t,i),(o=this.canvasD3Selection)==null||o.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([u],c)),(a=this.points)==null||a.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((l=this.lines)==null||l.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,t=250,i,r){var o;this.resizeCanvas();const s=this.zoomInstance.getTransform(this.pair(e),i,r);(o=this.canvasD3Selection)==null||o.transition().ease(up).duration(t).call(this.zoomInstance.behavior.transform,s)}updateZoomDragBehaviors(){var e,t,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(t=this.canvasD3Selection)==null||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!(this._isDestroyed||!this._isMouseOnCanvas)){if(this._findHoveredItemExecutionCount<R0){this._findHoveredItemExecutionCount+=1;return}if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const e=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var l,c,u,f;if(this._isDestroyed||!this.device||!this.points)return;this.points.findHoveredPoint();let e=!1,t=!1;const i=We(this.device,this.points.hoveredFbo,0,0,2,2),r=i[0],s=i[1],o=i[2],a=i[3];s>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==r)&&(e=!0),this.store.hoveredPoint={index:r,position:[o,a]}):(this.store.hoveredPoint&&(t=!0),this.store.hoveredPoint=void 0),e&&this.store.hoveredPoint&&((c=(l=this.config).onPointMouseOver)==null||c.call(l,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),t&&((f=(u=this.config).onPointMouseOut)==null||f.call(u,this.currentEvent))}findHoveredLine(){var s,o,a,l,c,u;if(this._isDestroyed||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(o=(s=this.config).onLinkMouseOut)==null||o.call(s,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,t=!1;if(!this.device)return;const r=We(this.device,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(t=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(a=this.config).onLinkMouseOver)==null||l.call(a,this.store.hoveredLinkIndex)),t&&((u=(c=this.config).onLinkMouseOut)==null||u.call(c,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?Se(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Se(this.canvas).style("cursor",e):Se(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Se(this.canvas).style("cursor",t):Se(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
|
|
2269
2281
|
user-select: none;
|
|
2270
2282
|
position: absolute;
|
|
2271
2283
|
bottom: 0;
|
|
@@ -2274,5 +2286,5 @@ void main() {
|
|
|
2274
2286
|
margin: 0 0.6rem 0.6rem 0;
|
|
2275
2287
|
font-size: 0.7rem;
|
|
2276
2288
|
font-family: inherit;
|
|
2277
|
-
`,this.attributionDivElement.innerHTML=
|
|
2289
|
+
`,this.attributionDivElement.innerHTML=Wl(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))}}he.Graph=Y0,he.PointShape=zc,he.clamp=Hl,he.getRgbaColor=vt,he.isAClassInstance=Ll,he.isArray=zs,he.isFunction=Ul,he.isNumber=qe,he.isObject=zl,he.isPlainObject=Ls,he.readPixels=We,he.rgbToBrightness=Vl,he.sanitizeHtml=Wl,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})});
|
|
2278
2290
|
//# sourceMappingURL=index.min.js.map
|