@cosmos.gl/graph 2.6.1 → 2.6.2-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,2 +1,1691 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Cosmos={})}(this,(function(e){"use strict";var t="http://www.w3.org/1999/xhtml",n={svg:"http://www.w3.org/2000/svg",xhtml:t,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function i(e){var t=e+="",i=t.indexOf(":");return i>=0&&"xmlns"!==(t=e.slice(0,i))&&(e=e.slice(i+1)),n.hasOwnProperty(t)?{space:n[t],local:e}:e}function r(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===t&&n.documentElement.namespaceURI===t?n.createElement(e):n.createElementNS(i,e)}}function o(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function a(e){var t=i(e);return(t.local?o:r)(t)}function s(){}function u(e){return null==e?s:function(){return this.querySelector(e)}}function l(){return[]}function c(e){return null==e?l:function(){return this.querySelectorAll(e)}}function f(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function h(e){return function(){return this.matches(e)}}function d(e){return function(t){return t.matches(e)}}var p=Array.prototype.find;function m(){return this.firstElementChild}var v=Array.prototype.filter;function g(){return Array.from(this.children)}function y(e){return new Array(e.length)}function b(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function x(e,t,n,i,r,o){for(var a,s=0,u=t.length,l=o.length;s<l;++s)(a=t[s])?(a.__data__=o[s],i[s]=a):n[s]=new b(e,o[s]);for(;s<u;++s)(a=t[s])&&(r[s]=a)}function S(e,t,n,i,r,o,a){var s,u,l,c=new Map,f=t.length,h=o.length,d=new Array(f);for(s=0;s<f;++s)(u=t[s])&&(d[s]=l=a.call(u,u.__data__,s,t)+"",c.has(l)?r[s]=u:c.set(l,u));for(s=0;s<h;++s)l=a.call(e,o[s],s,o)+"",(u=c.get(l))?(i[s]=u,u.__data__=o[s],c.delete(l)):n[s]=new b(e,o[s]);for(s=0;s<f;++s)(u=t[s])&&c.get(d[s])===u&&(r[s]=u)}function w(e){return e.__data__}function k(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function C(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function T(e){return function(){this.removeAttribute(e)}}function P(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _(e,t){return function(){this.setAttribute(e,t)}}function A(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function z(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function I(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function D(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function M(e){return function(){this.style.removeProperty(e)}}function F(e,t,n){return function(){this.style.setProperty(e,t,n)}}function E(e,t,n){return function(){var i=t.apply(this,arguments);null==i?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function L(e,t){return e.style.getPropertyValue(t)||D(e).getComputedStyle(e,null).getPropertyValue(t)}function O(e){return function(){delete this[e]}}function N(e,t){return function(){this[e]=t}}function R(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function j(e){return e.trim().split(/^|\s+/)}function B(e){return e.classList||new V(e)}function V(e){this._node=e,this._names=j(e.getAttribute("class")||"")}function U(e,t){for(var n=B(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function G(e,t){for(var n=B(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function H(e){return function(){U(this,e)}}function W(e){return function(){G(this,e)}}function q(e,t){return function(){(t.apply(this,arguments)?U:G)(this,e)}}function Y(){this.textContent=""}function $(e){return function(){this.textContent=e}}function X(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function Z(){this.innerHTML=""}function Q(e){return function(){this.innerHTML=e}}function K(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function J(){this.nextSibling&&this.parentNode.appendChild(this)}function ee(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function te(){return null}function ne(){var e=this.parentNode;e&&e.removeChild(this)}function ie(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function re(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oe(e){return function(){var t=this.__on;if(t){for(var n,i=0,r=-1,o=t.length;i<o;++i)n=t[i],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function ae(e,t,n){return function(){var i,r=this.__on,o=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var a=0,s=r.length;a<s;++a)if((i=r[a]).type===e.type&&i.name===e.name)return this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),void(i.value=t);this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function se(e,t,n){var i=D(e),r=i.CustomEvent;"function"==typeof r?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ue(e,t){return function(){return se(this,e,t)}}function le(e,t){return function(){return se(this,e,t.apply(this,arguments))}}b.prototype={constructor:b,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},V.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var ce=[null];function fe(e,t){this._groups=e,this._parents=t}function he(){return new fe([[document.documentElement]],ce)}function de(e){return"string"==typeof e?new fe([[document.querySelector(e)]],[document.documentElement]):new fe([[e]],ce)}fe.prototype=he.prototype={constructor:fe,select:function(e){"function"!=typeof e&&(e=u(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o,a,s=t[r],l=s.length,c=i[r]=new Array(l),f=0;f<l;++f)(o=s[f])&&(a=e.call(o,o.__data__,f,s))&&("__data__"in o&&(a.__data__=o.__data__),c[f]=a);return new fe(i,this._parents)},selectAll:function(e){e="function"==typeof e?f(e):c(e);for(var t=this._groups,n=t.length,i=[],r=[],o=0;o<n;++o)for(var a,s=t[o],u=s.length,l=0;l<u;++l)(a=s[l])&&(i.push(e.call(a,a.__data__,l,s)),r.push(a));return new fe(i,r)},selectChild:function(e){return this.select(null==e?m:function(e){return function(){return p.call(this.children,e)}}("function"==typeof e?e:d(e)))},selectChildren:function(e){return this.selectAll(null==e?g:function(e){return function(){return v.call(this.children,e)}}("function"==typeof e?e:d(e)))},filter:function(e){"function"!=typeof e&&(e=h(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o,a=t[r],s=a.length,u=i[r]=[],l=0;l<s;++l)(o=a[l])&&e.call(o,o.__data__,l,a)&&u.push(o);return new fe(i,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,w);var n,i=t?S:x,r=this._parents,o=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var a=o.length,s=new Array(a),u=new Array(a),l=new Array(a),c=0;c<a;++c){var f=r[c],h=o[c],d=h.length,p=k(e.call(f,f&&f.__data__,c,r)),m=p.length,v=u[c]=new Array(m),g=s[c]=new Array(m);i(f,h,v,g,l[c]=new Array(d),p,t);for(var y,b,C=0,T=0;C<m;++C)if(y=v[C]){for(C>=T&&(T=C+1);!(b=g[T])&&++T<m;);y._next=b||null}}return(s=new fe(s,r))._enter=u,s._exit=l,s},enter:function(){return new fe(this._enter||this._groups.map(y),this._parents)},exit:function(){return new fe(this._exit||this._groups.map(y),this._parents)},join:function(e,t,n){var i=this.enter(),r=this,o=this.exit();return"function"==typeof e?(i=e(i))&&(i=i.selection()):i=i.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?o.remove():n(o),i&&r?i.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,o=i.length,a=Math.min(r,o),s=new Array(r),u=0;u<a;++u)for(var l,c=n[u],f=i[u],h=c.length,d=s[u]=new Array(h),p=0;p<h;++p)(l=c[p]||f[p])&&(d[p]=l);for(;u<r;++u)s[u]=n[u];return new fe(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i,r=e[t],o=r.length-1,a=r[o];--o>=0;)(i=r[o])&&(a&&4^i.compareDocumentPosition(a)&&a.parentNode.insertBefore(i,a),a=i);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=C);for(var n=this._groups,i=n.length,r=new Array(i),o=0;o<i;++o){for(var a,s=n[o],u=s.length,l=r[o]=new Array(u),c=0;c<u;++c)(a=s[c])&&(l[c]=a);l.sort(t)}return new fe(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length;r<o;++r){var a=i[r];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r,o=t[n],a=0,s=o.length;a<s;++a)(r=o[a])&&e.call(r,r.__data__,a,o);return this},attr:function(e,t){var n=i(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==t?n.local?P:T:"function"==typeof t?n.local?I:z:n.local?A:_)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?M:"function"==typeof t?E:F)(e,t,null==n?"":n)):L(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?O:"function"==typeof t?R:N)(e,t)):this.node()[e]},classed:function(e,t){var n=j(e+"");if(arguments.length<2){for(var i=B(this.node()),r=-1,o=n.length;++r<o;)if(!i.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?q:t?H:W)(n,t))},text:function(e){return arguments.length?this.each(null==e?Y:("function"==typeof e?X:$)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?Z:("function"==typeof e?K:Q)(e)):this.node().innerHTML},raise:function(){return this.each(J)},lower:function(){return this.each(ee)},append:function(e){var t="function"==typeof e?e:a(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:a(e),i=null==t?te:"function"==typeof t?t:u(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)}))},remove:function(){return this.each(ne)},clone:function(e){return this.select(e?re:ie)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var i,r,o=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=o.length;if(!(arguments.length<2)){for(s=t?ae:oe,i=0;i<a;++i)this.each(s(o[i],t,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(i=0,u=s[l];i<a;++i)if((r=o[i]).type===u.type&&r.name===u.name)return u.value},dispatch:function(e,t){return this.each(("function"==typeof t?le:ue)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i,r=e[t],o=0,a=r.length;o<a;++o)(i=r[o])&&(yield i)}};var pe=0;function me(){this._="@"+(++pe).toString(36)}function ve(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,[(i=i.matrixTransform(t.getScreenCTM().inverse())).x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}me.prototype={constructor:me,get:function(e){for(var t=this._;!(t in e);)if(!(e=e.parentNode))return;return e[t]},set:function(e,t){return e[this._]=t},remove:function(e){return this._ in e&&delete e[this._]},toString:function(){return this._}};var ge={value:()=>{}};function ye(){for(var e,t=0,n=arguments.length,i={};t<n;++t){if(!(e=arguments[t]+"")||e in i||/[\s.]/.test(e))throw new Error("illegal type: "+e);i[e]=[]}return new be(i)}function be(e){this._=e}function xe(e,t){for(var n,i=0,r=e.length;i<r;++i)if((n=e[i]).name===t)return n.value}function Se(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=ge,e=e.slice(0,i).concat(e.slice(i+1));break}return null!=n&&e.push({name:t,value:n}),e}be.prototype=ye.prototype={constructor:be,on:function(e,t){var n,i,r=this._,o=(i=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!i.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=o[a]).type)r[n]=Se(r[n],e.name,t);else if(null==t)for(n in r)r[n]=Se(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=o[a]).type)&&(n=xe(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new be(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,i,r=new Array(n),o=0;o<n;++o)r[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=0,n=(i=this._[e]).length;o<n;++o)i[o].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)}};var we,ke,Ce=0,Te=0,Pe=0,_e=1e3,Ae=0,ze=0,Ie=0,De="object"==typeof performance&&performance.now?performance:Date,Me="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fe(){return ze||(Me(Ee),ze=De.now()+Ie)}function Ee(){ze=0}function Le(){this._call=this._time=this._next=null}function Oe(e,t,n){var i=new Le;return i.restart(e,t,n),i}function Ne(){ze=(Ae=De.now())+Ie,Ce=Te=0;try{!function(){Fe(),++Ce;for(var e,t=we;t;)(e=ze-t._time)>=0&&t._call.call(null,e),t=t._next;--Ce}()}finally{Ce=0,function(){var e,t,n=we,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:we=t);ke=e,je(i)}(),ze=0}}function Re(){var e=De.now(),t=e-Ae;t>_e&&(Ie-=t,Ae=e)}function je(e){Ce||(Te&&(Te=clearTimeout(Te)),e-ze>24?(e<1/0&&(Te=setTimeout(Ne,e-De.now()-Ie)),Pe&&(Pe=clearInterval(Pe))):(Pe||(Ae=De.now(),Pe=setInterval(Re,_e)),Ce=1,Me(Ne)))}function Be(e,t,n){var i=new Le;return t=null==t?0:+t,i.restart((n=>{i.stop(),e(n+t)}),t,n),i}Le.prototype=Oe.prototype={constructor:Le,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Fe():+n)+(null==t?0:+t),this._next||ke===this||(ke?ke._next=this:we=this,ke=this),this._call=e,this._time=n,je()},stop:function(){this._call&&(this._call=null,this._time=1/0,je())}};var Ve=ye("start","end","cancel","interrupt"),Ue=[],Ge=0,He=1,We=2,qe=3,Ye=4,$e=5,Xe=6;function Ze(e,t,n,i,r,o){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var i,r=e.__transition;function o(e){n.state=He,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(o){var l,c,f,h;if(n.state!==He)return u();for(l in r)if((h=r[l]).name===n.name){if(h.state===qe)return Be(a);h.state===Ye?(h.state=Xe,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[l]):+l<t&&(h.state=Xe,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[l])}if(Be((function(){n.state===qe&&(n.state=Ye,n.timer.restart(s,n.delay,n.time),s(o))})),n.state=We,n.on.call("start",e,e.__data__,n.index,n.group),n.state===We){for(n.state=qe,i=new Array(f=n.tween.length),l=0,c=-1;l<f;++l)(h=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++c]=h);i.length=c+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(u),n.state=$e,1),o=-1,a=i.length;++o<a;)i[o].call(e,r);n.state===$e&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){for(var i in n.state=Xe,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Oe(o,0,n.time)}(e,n,{name:t,index:i,group:r,on:Ve,tween:Ue,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ge})}function Qe(e,t){var n=Je(e,t);if(n.state>Ge)throw new Error("too late; already scheduled");return n}function Ke(e,t){var n=Je(e,t);if(n.state>qe)throw new Error("too late; already running");return n}function Je(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function et(e,t){var n,i,r,o=e.__transition,a=!0;if(o){for(r in t=null==t?null:t+"",o)(n=o[r]).name===t?(i=n.state>We&&n.state<$e,n.state=Xe,n.timer.stop(),n.on.call(i?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[r]):a=!1;a&&delete e.__transition}}function tt(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function nt(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function it(){}var rt=.7,ot=1/rt,at="\\s*([+-]?\\d+)\\s*",st="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",lt=/^#([0-9a-f]{3,8})$/,ct=new RegExp(`^rgb\\(${at},${at},${at}\\)$`),ft=new RegExp(`^rgb\\(${ut},${ut},${ut}\\)$`),ht=new RegExp(`^rgba\\(${at},${at},${at},${st}\\)$`),dt=new RegExp(`^rgba\\(${ut},${ut},${ut},${st}\\)$`),pt=new RegExp(`^hsl\\(${st},${ut},${ut}\\)$`),mt=new RegExp(`^hsla\\(${st},${ut},${ut},${st}\\)$`),vt={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};function gt(){return this.rgb().formatHex()}function yt(){return this.rgb().formatRgb()}function bt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=lt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?xt(t):3===n?new Ct(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?St(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?St(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=ct.exec(e))?new Ct(t[1],t[2],t[3],1):(t=ft.exec(e))?new Ct(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=ht.exec(e))?St(t[1],t[2],t[3],t[4]):(t=dt.exec(e))?St(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=pt.exec(e))?It(t[1],t[2]/100,t[3]/100,1):(t=mt.exec(e))?It(t[1],t[2]/100,t[3]/100,t[4]):vt.hasOwnProperty(e)?xt(vt[e]):"transparent"===e?new Ct(NaN,NaN,NaN,0):null}function xt(e){return new Ct(e>>16&255,e>>8&255,255&e,1)}function St(e,t,n,i){return i<=0&&(e=t=n=NaN),new Ct(e,t,n,i)}function wt(e){return e instanceof it||(e=bt(e)),e?new Ct((e=e.rgb()).r,e.g,e.b,e.opacity):new Ct}function kt(e,t,n,i){return 1===arguments.length?wt(e):new Ct(e,t,n,null==i?1:i)}function Ct(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}function Tt(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function Pt(){const e=_t(this.opacity);return`${1===e?"rgb(":"rgba("}${At(this.r)}, ${At(this.g)}, ${At(this.b)}${1===e?")":`, ${e})`}`}function _t(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function At(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function zt(e){return((e=At(e))<16?"0":"")+e.toString(16)}function It(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Mt(e,t,n,i)}function Dt(e){if(e instanceof Mt)return new Mt(e.h,e.s,e.l,e.opacity);if(e instanceof it||(e=bt(e)),!e)return new Mt;if(e instanceof Mt)return e;var t=(e=e.rgb()).r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),a=NaN,s=o-r,u=(o+r)/2;return s?(a=t===o?(n-i)/s+6*(n<i):n===o?(i-t)/s+2:(t-n)/s+4,s/=u<.5?o+r:2-o-r,a*=60):s=u>0&&u<1?0:a,new Mt(a,s,u,e.opacity)}function Mt(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}function Ft(e){return(e=(e||0)%360)<0?e+360:e}function Et(e){return Math.max(0,Math.min(1,e||0))}function Lt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}tt(it,bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:gt,formatHex:gt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Dt(this).formatHsl()},formatRgb:yt,toString:yt}),tt(Ct,kt,nt(it,{brighter(e){return e=null==e?ot:Math.pow(ot,e),new Ct(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?rt:Math.pow(rt,e),new Ct(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ct(At(this.r),At(this.g),At(this.b),_t(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:Tt,formatHex:Tt,formatHex8:function(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Pt,toString:Pt})),tt(Mt,(function(e,t,n,i){return 1===arguments.length?Dt(e):new Mt(e,t,n,null==i?1:i)}),nt(it,{brighter(e){return e=null==e?ot:Math.pow(ot,e),new Mt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?rt:Math.pow(rt,e),new Mt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Ct(Lt(e>=240?e-240:e+120,r,i),Lt(e,r,i),Lt(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Mt(Ft(this.h),Et(this.s),Et(this.l),_t(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 e=_t(this.opacity);return`${1===e?"hsl(":"hsla("}${Ft(this.h)}, ${100*Et(this.s)}%, ${100*Et(this.l)}%${1===e?")":`, ${e})`}`}}));const Ot=Math.PI/180,Nt=180/Math.PI,Rt=.96422,jt=1,Bt=.82521,Vt=4/29,Ut=6/29,Gt=3*Ut*Ut,Ht=Ut*Ut*Ut;function Wt(e){if(e instanceof qt)return new qt(e.l,e.a,e.b,e.opacity);if(e instanceof Qt)return Kt(e);e instanceof Ct||(e=wt(e));var t,n,i=Zt(e.r),r=Zt(e.g),o=Zt(e.b),a=Yt((.2225045*i+.7168786*r+.0606169*o)/jt);return i===r&&r===o?t=n=a:(t=Yt((.4360747*i+.3850649*r+.1430804*o)/Rt),n=Yt((.0139322*i+.0971045*r+.7141733*o)/Bt)),new qt(116*a-16,500*(t-a),200*(a-n),e.opacity)}function qt(e,t,n,i){this.l=+e,this.a=+t,this.b=+n,this.opacity=+i}function Yt(e){return e>Ht?Math.pow(e,1/3):e/Gt+Vt}function $t(e){return e>Ut?e*e*e:Gt*(e-Vt)}function Xt(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Zt(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Qt(e,t,n,i){this.h=+e,this.c=+t,this.l=+n,this.opacity=+i}function Kt(e){if(isNaN(e.h))return new qt(e.l,0,0,e.opacity);var t=e.h*Ot;return new qt(e.l,Math.cos(t)*e.c,Math.sin(t)*e.c,e.opacity)}tt(qt,(function(e,t,n,i){return 1===arguments.length?Wt(e):new qt(e,t,n,null==i?1:i)}),nt(it,{brighter(e){return new qt(this.l+18*(null==e?1:e),this.a,this.b,this.opacity)},darker(e){return new qt(this.l-18*(null==e?1:e),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return new Ct(Xt(3.1338561*(t=Rt*$t(t))-1.6168667*(e=jt*$t(e))-.4906146*(n=Bt*$t(n))),Xt(-.9787684*t+1.9161415*e+.033454*n),Xt(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}})),tt(Qt,(function(e,t,n,i){return 1===arguments.length?function(e){if(e instanceof Qt)return new Qt(e.h,e.c,e.l,e.opacity);if(e instanceof qt||(e=Wt(e)),0===e.a&&0===e.b)return new Qt(NaN,0<e.l&&e.l<100?0:NaN,e.l,e.opacity);var t=Math.atan2(e.b,e.a)*Nt;return new Qt(t<0?t+360:t,Math.sqrt(e.a*e.a+e.b*e.b),e.l,e.opacity)}(e):new Qt(e,t,n,null==i?1:i)}),nt(it,{brighter(e){return new Qt(this.h,this.c,this.l+18*(null==e?1:e),this.opacity)},darker(e){return new Qt(this.h,this.c,this.l-18*(null==e?1:e),this.opacity)},rgb(){return Kt(this).rgb()}}));var Jt=-.14861,en=1.78277,tn=-.29227,nn=-.90649,rn=1.97294,on=rn*nn,an=rn*en,sn=en*tn-nn*Jt;function un(e,t,n,i){return 1===arguments.length?function(e){if(e instanceof ln)return new ln(e.h,e.s,e.l,e.opacity);e instanceof Ct||(e=wt(e));var t=e.r/255,n=e.g/255,i=e.b/255,r=(sn*i+on*t-an*n)/(sn+on-an),o=i-r,a=(rn*(n-r)-tn*o)/nn,s=Math.sqrt(a*a+o*o)/(rn*r*(1-r)),u=s?Math.atan2(a,o)*Nt-120:NaN;return new ln(u<0?u+360:u,s,r,e.opacity)}(e):new ln(e,t,n,null==i?1:i)}function ln(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}tt(ln,un,nt(it,{brighter(e){return e=null==e?ot:Math.pow(ot,e),new ln(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?rt:Math.pow(rt,e),new ln(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*Ot,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),i=Math.cos(e),r=Math.sin(e);return new Ct(255*(t+n*(Jt*i+en*r)),255*(t+n*(tn*i+nn*r)),255*(t+n*(rn*i)),this.opacity)}}));var cn=e=>()=>e;function fn(e,t){return function(n){return e+n*t}}function hn(e){return 1==(e=+e)?dn:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}(t,n,e):cn(isNaN(t)?n:t)}}function dn(e,t){var n=t-e;return n?fn(e,n):cn(isNaN(e)?t:e)}var pn=function e(t){var n=hn(t);function i(e,t){var i=n((e=kt(e)).r,(t=kt(t)).r),r=n(e.g,t.g),o=n(e.b,t.b),a=dn(e.opacity,t.opacity);return function(t){return e.r=i(t),e.g=r(t),e.b=o(t),e.opacity=a(t),e+""}}return i.gamma=e,i}(1);function mn(e,t){t||(t=[]);var n,i=e?Math.min(t.length,e.length):0,r=t.slice();return function(o){for(n=0;n<i;++n)r[n]=e[n]*(1-o)+t[n]*o;return r}}function vn(e,t){var n,i=t?t.length:0,r=e?Math.min(i,e.length):0,o=new Array(r),a=new Array(i);for(n=0;n<r;++n)o[n]=kn(e[n],t[n]);for(;n<i;++n)a[n]=t[n];return function(e){for(n=0;n<r;++n)a[n]=o[n](e);return a}}function gn(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function yn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function bn(e,t){var n,i={},r={};for(n in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)n in e?i[n]=kn(e[n],t[n]):r[n]=t[n];return function(e){for(n in i)r[n]=i[n](e);return r}}var xn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Sn=new RegExp(xn.source,"g");function wn(e,t){var n,i,r,o=xn.lastIndex=Sn.lastIndex=0,a=-1,s=[],u=[];for(e+="",t+="";(n=xn.exec(e))&&(i=Sn.exec(t));)(r=i.index)>o&&(r=t.slice(o,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,u.push({i:a,x:yn(n,i)})),o=Sn.lastIndex;return o<t.length&&(r=t.slice(o),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(e){return function(t){return e(t)+""}}(u[0].x):function(e){return function(){return e}}(t):(t=u.length,function(e){for(var n,i=0;i<t;++i)s[(n=u[i]).i]=n.x(e);return s.join("")})}function kn(e,t){var n,i,r=typeof t;return null==t||"boolean"===r?cn(t):("number"===r?yn:"string"===r?(n=bt(t))?(t=n,pn):wn:t instanceof bt?pn:t instanceof Date?gn:(i=t,!ArrayBuffer.isView(i)||i instanceof DataView?Array.isArray(t)?vn:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?bn:yn:mn))(e,t)}function Cn(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var Tn,Pn=180/Math.PI,_n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function An(e,t,n,i,r,o){var a,s,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*i)&&(n-=e*u,i-=t*u),(s=Math.sqrt(n*n+i*i))&&(n/=s,i/=s,u/=s),e*i<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*Pn,skewX:Math.atan(u)*Pn,scaleX:a,scaleY:s}}function zn(e,t,n,i){function r(e){return e.length?e.pop()+" ":""}return function(o,a){var s=[],u=[];return o=e(o),a=e(a),function(e,i,r,o,a,s){if(e!==r||i!==o){var u=a.push("translate(",null,t,null,n);s.push({i:u-4,x:yn(e,r)},{i:u-2,x:yn(i,o)})}else(r||o)&&a.push("translate("+r+t+o+n)}(o.translateX,o.translateY,a.translateX,a.translateY,s,u),function(e,t,n,o){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),o.push({i:n.push(r(n)+"rotate(",null,i)-2,x:yn(e,t)})):t&&n.push(r(n)+"rotate("+t+i)}(o.rotate,a.rotate,s,u),function(e,t,n,o){e!==t?o.push({i:n.push(r(n)+"skewX(",null,i)-2,x:yn(e,t)}):t&&n.push(r(n)+"skewX("+t+i)}(o.skewX,a.skewX,s,u),function(e,t,n,i,o,a){if(e!==n||t!==i){var s=o.push(r(o)+"scale(",null,",",null,")");a.push({i:s-4,x:yn(e,n)},{i:s-2,x:yn(t,i)})}else 1===n&&1===i||o.push(r(o)+"scale("+n+","+i+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(e){for(var t,n=-1,i=u.length;++n<i;)s[(t=u[n]).i]=t.x(e);return s.join("")}}}var In=zn((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?_n:An(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Dn=zn((function(e){return null==e?_n:(Tn||(Tn=document.createElementNS("http://www.w3.org/2000/svg","g")),Tn.setAttribute("transform",e),(e=Tn.transform.baseVal.consolidate())?An((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):_n)}),", ",")",")");function Mn(e){return((e=Math.exp(e))+1/e)/2}var Fn=function e(t,n,i){function r(e,r){var o,a,s=e[0],u=e[1],l=e[2],c=r[0],f=r[1],h=r[2],d=c-s,p=f-u,m=d*d+p*p;if(m<1e-12)a=Math.log(h/l)/t,o=function(e){return[s+e*d,u+e*p,l*Math.exp(t*e*a)]};else{var v=Math.sqrt(m),g=(h*h-l*l+i*m)/(2*l*n*v),y=(h*h-l*l-i*m)/(2*h*n*v),b=Math.log(Math.sqrt(g*g+1)-g),x=Math.log(Math.sqrt(y*y+1)-y);a=(x-b)/t,o=function(e){var i,r=e*a,o=Mn(b),c=l/(n*v)*(o*(i=t*r+b,((i=Math.exp(2*i))-1)/(i+1))-function(e){return((e=Math.exp(e))-1/e)/2}(b));return[s+c*d,u+c*p,l*o/Mn(t*r+b)]}}return o.duration=1e3*a*t/Math.SQRT2,o}return r.rho=function(t){var n=Math.max(.001,+t),i=n*n;return e(n,i,i*i)},r}(Math.SQRT2,2,4);function En(e){return function t(n){function i(t,i){var r=e((t=un(t)).h,(i=un(i)).h),o=dn(t.s,i.s),a=dn(t.l,i.l),s=dn(t.opacity,i.opacity);return function(e){return t.h=r(e),t.s=o(e),t.l=a(Math.pow(e,n)),t.opacity=s(e),t+""}}return n=+n,i.gamma=t,i}(1)}function Ln(e,t){var n,i;return function(){var r=Ke(this,e),o=r.tween;if(o!==n)for(var a=0,s=(i=n=o).length;a<s;++a)if(i[a].name===t){(i=i.slice()).splice(a,1);break}r.tween=i}}function On(e,t,n){var i,r;if("function"!=typeof n)throw new Error;return function(){var o=Ke(this,e),a=o.tween;if(a!==i){r=(i=a).slice();for(var s={name:t,value:n},u=0,l=r.length;u<l;++u)if(r[u].name===t){r[u]=s;break}u===l&&r.push(s)}o.tween=r}}function Nn(e,t,n){var i=e._id;return e.each((function(){var e=Ke(this,i);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return Je(e,i).value[t]}}function Rn(e,t){var n;return("number"==typeof t?yn:t instanceof bt?pn:(n=bt(t))?(t=n,pn):wn)(e,t)}function jn(e){return function(){this.removeAttribute(e)}}function Bn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vn(e,t,n){var i,r,o=n+"";return function(){var a=this.getAttribute(e);return a===o?null:a===i?r:r=t(i=a,n)}}function Un(e,t,n){var i,r,o=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===o?null:a===i?r:r=t(i=a,n)}}function Gn(e,t,n){var i,r,o;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(e))===(s=u+"")?null:a===i&&s===r?o:(r=s,o=t(i=a,u));this.removeAttribute(e)}}function Hn(e,t,n){var i,r,o;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(e.space,e.local))===(s=u+"")?null:a===i&&s===r?o:(r=s,o=t(i=a,u));this.removeAttributeNS(e.space,e.local)}}function Wn(e,t){var n,i;function r(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function qn(e,t){var n,i;function r(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function Yn(e,t){return function(){Qe(this,e).delay=+t.apply(this,arguments)}}function $n(e,t){return t=+t,function(){Qe(this,e).delay=t}}function Xn(e,t){return function(){Ke(this,e).duration=+t.apply(this,arguments)}}function Zn(e,t){return t=+t,function(){Ke(this,e).duration=t}}En((function(e,t){var n=t-e;return n?fn(e,n>180||n<-180?n-360*Math.round(n/360):n):cn(isNaN(e)?t:e)})),En(dn);var Qn=he.prototype.constructor;function Kn(e){return function(){this.style.removeProperty(e)}}var Jn=0;function ei(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function ti(){return++Jn}var ni=he.prototype;function ii(e){return e*e}function ri(e){return e*(2-e)}function oi(e){return((e*=2)<=1?e*e:--e*(2-e)+1)/2}ei.prototype={constructor:ei,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=u(e));for(var i=this._groups,r=i.length,o=new Array(r),a=0;a<r;++a)for(var s,l,c=i[a],f=c.length,h=o[a]=new Array(f),d=0;d<f;++d)(s=c[d])&&(l=e.call(s,s.__data__,d,c))&&("__data__"in s&&(l.__data__=s.__data__),h[d]=l,Ze(h[d],t,n,d,h,Je(s,n)));return new ei(o,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=c(e));for(var i=this._groups,r=i.length,o=[],a=[],s=0;s<r;++s)for(var u,l=i[s],f=l.length,h=0;h<f;++h)if(u=l[h]){for(var d,p=e.call(u,u.__data__,h,l),m=Je(u,n),v=0,g=p.length;v<g;++v)(d=p[v])&&Ze(d,t,n,v,p,m);o.push(p),a.push(u)}return new ei(o,a,t,n)},selectChild:ni.selectChild,selectChildren:ni.selectChildren,filter:function(e){"function"!=typeof e&&(e=h(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o,a=t[r],s=a.length,u=i[r]=[],l=0;l<s;++l)(o=a[l])&&e.call(o,o.__data__,l,a)&&u.push(o);return new ei(i,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,o=Math.min(i,r),a=new Array(i),s=0;s<o;++s)for(var u,l=t[s],c=n[s],f=l.length,h=a[s]=new Array(f),d=0;d<f;++d)(u=l[d]||c[d])&&(h[d]=u);for(;s<i;++s)a[s]=t[s];return new ei(a,this._parents,this._name,this._id)},selection:function(){return new Qn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=ti(),i=this._groups,r=i.length,o=0;o<r;++o)for(var a,s=i[o],u=s.length,l=0;l<u;++l)if(a=s[l]){var c=Je(a,t);Ze(a,e,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ei(i,this._parents,e,n)},call:ni.call,nodes:ni.nodes,node:ni.node,size:ni.size,empty:ni.empty,each:ni.each,on:function(e,t){var n=this._id;return arguments.length<2?Je(this.node(),n).on.on(e):this.each(function(e,t,n){var i,r,o=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?Qe:Ke;return function(){var a=o(this,e),s=a.on;s!==i&&(r=(i=s).copy()).on(t,n),a.on=r}}(n,e,t))},attr:function(e,t){var n=i(e),r="transform"===n?Dn:Rn;return this.attrTween(e,"function"==typeof t?(n.local?Hn:Gn)(n,r,Nn(this,"attr."+e,t)):null==t?(n.local?Bn:jn)(n):(n.local?Un:Vn)(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=i(e);return this.tween(n,(r.local?Wn:qn)(r,t))},style:function(e,t,n){var i="transform"==(e+="")?In:Rn;return null==t?this.styleTween(e,function(e,t){var n,i,r;return function(){var o=L(this,e),a=(this.style.removeProperty(e),L(this,e));return o===a?null:o===n&&a===i?r:r=t(n=o,i=a)}}(e,i)).on("end.style."+e,Kn(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var i,r,o;return function(){var a=L(this,e),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(e),u=s=L(this,e)),a===u?null:a===i&&u===r?o:(r=u,o=t(i=a,s))}}(e,i,Nn(this,"style."+e,t))).each(function(e,t){var n,i,r,o,a="style."+t,s="end."+a;return function(){var u=Ke(this,e),l=u.on,c=null==u.value[a]?o||(o=Kn(t)):void 0;l===n&&r===c||(i=(n=l).copy()).on(s,r=c),u.on=i}}(this._id,e)):this.styleTween(e,function(e,t,n){var i,r,o=n+"";return function(){var a=L(this,e);return a===o?null:a===i?r:r=t(i=a,n)}}(e,i,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==t)return this.tween(i,null);if("function"!=typeof t)throw new Error;return this.tween(i,function(e,t,n){var i,r;function o(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&function(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}(e,o,n)),i}return o._value=t,o}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(Nn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function i(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&function(e){return function(t){this.textContent=e.call(this,t)}}(i)),t}return i._value=e,i}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i,r=Je(this.node(),n).tween,o=0,a=r.length;o<a;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((null==t?Ln:On)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Yn:$n)(t,e)):Je(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Xn:Zn)(t,e)):Je(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){Ke(this,e).ease=t}}(t,e)):Je(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;Ke(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,i=n._id,r=n.size();return new Promise((function(o,a){var s={value:a},u={value:function(){0==--r&&o()}};n.each((function(){var n=Ke(this,i),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(u)),n.on=t})),0===r&&o()}))},[Symbol.iterator]:ni[Symbol.iterator]};function ai(e){return 1.0009775171065494*(Math.pow(2,-10*e)-.0009765625)}!function e(t){function n(e){return Math.pow(e,t)}return t=+t,n.exponent=e,n}(3),function e(t){function n(e){return 1-Math.pow(1-e,t)}return t=+t,n.exponent=e,n}(3),function e(t){function n(e){return((e*=2)<=1?Math.pow(e,t):2-Math.pow(2-e,t))/2}return t=+t,n.exponent=e,n}(3);var si=1.70158;!function e(t){function n(e){return(e=+e)*e*(t*(e-1)+e)}return t=+t,n.overshoot=e,n}(si),function e(t){function n(e){return--e*e*((e+1)*t+e)+1}return t=+t,n.overshoot=e,n}(si),function e(t){function n(e){return((e*=2)<1?e*e*((t+1)*e-t):(e-=2)*e*((t+1)*e+t)+2)/2}return t=+t,n.overshoot=e,n}(si);var ui=2*Math.PI;!function e(t,n){var i=Math.asin(1/(t=Math.max(1,t)))*(n/=ui);function r(e){return t*ai(- --e)*Math.sin((i-e)/n)}return r.amplitude=function(t){return e(t,n*ui)},r.period=function(n){return e(t,n)},r}(1,.3),function e(t,n){var i=Math.asin(1/(t=Math.max(1,t)))*(n/=ui);function r(e){return 1-t*ai(e=+e)*Math.sin((e+i)/n)}return r.amplitude=function(t){return e(t,n*ui)},r.period=function(n){return e(t,n)},r}(1,.3),function e(t,n){var i=Math.asin(1/(t=Math.max(1,t)))*(n/=ui);function r(e){return((e=2*e-1)<0?t*ai(-e)*Math.sin((i-e)/n):2-t*ai(e)*Math.sin((i+e)/n))/2}return r.amplitude=function(t){return e(t,n*ui)},r.period=function(n){return e(t,n)},r}(1,.3);var li={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function ci(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}he.prototype.interrupt=function(e){return this.each((function(){et(this,e)}))},he.prototype.transition=function(e){var t,n;e instanceof ei?(t=e._id,e=e._name):(t=ti(),(n=li).time=Fe(),e=null==e?null:e+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var a,s=i[o],u=s.length,l=0;l<u;++l)(a=s[l])&&Ze(a,e,t,l,s,n||ci(a,t));return new ei(i,this._parents,e,t)};var fi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},hi={exports:{}};!function(e,t){e.exports=function(){var e=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},t=function(e,t){for(var n=Object.keys(t),i=0;i<n.length;++i)e[n[i]]=t[n[i]];return e},n="\n";function i(e){return"undefined"!=typeof atob?atob(e):"base64:"+e}function r(e){var t=new Error("(regl) "+e);throw console.error(t),t}function o(e,t){e||r(t)}function a(e){return e?": "+e:""}function s(e,t,n){e in t||r("unknown parameter ("+e+")"+a(n)+". possible values: "+Object.keys(t).join())}function u(t,n){e(t)||r("invalid parameter type"+a(n)+". must be a typed array")}function l(e,t){switch(t){case"number":return"number"==typeof e;case"object":return"object"==typeof e;case"string":return"string"==typeof e;case"boolean":return"boolean"==typeof e;case"function":return"function"==typeof e;case"undefined":return void 0===e;case"symbol":return"symbol"==typeof e}}function c(e,t,n){l(e,t)||r("invalid parameter type"+a(n)+". expected "+t+", got "+typeof e)}function f(e,t){e>=0&&(0|e)===e||r("invalid parameter type, ("+e+")"+a(t)+". must be a nonnegative integer")}function h(e,t,n){t.indexOf(e)<0&&r("invalid value"+a(n)+". must be one of: "+t)}var d=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(e){Object.keys(e).forEach((function(e){d.indexOf(e)<0&&r('invalid regl constructor argument "'+e+'". must be one of '+d)}))}function m(e,t){for(e+="";e.length<t;)e=" "+e;return e}function v(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function g(e,t){this.number=e,this.line=t,this.errors=[]}function y(e,t,n){this.file=e,this.line=t,this.message=n}function b(){var e=new Error,t=(e.stack||e).toString(),n=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(t);if(n)return n[1];var i=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(t);return i?i[1]:"unknown"}function x(){var e=new Error,t=(e.stack||e).toString(),n=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(t);if(n)return n[1];var i=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(t);return i?i[1]:"unknown"}function S(e,t){var n=e.split("\n"),r=1,o=0,a={unknown:new v,0:new v};a.unknown.name=a[0].name=t||b(),a.unknown.lines.push(new g(0,""));for(var s=0;s<n.length;++s){var u=n[s],l=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(u);if(l)switch(l[1]){case"line":var c=/(\d+)(\s+\d+)?/.exec(l[2]);c&&(r=0|c[1],c[2]&&((o=0|c[2])in a||(a[o]=new v)));break;case"define":var f=/SHADER_NAME(_B64)?\s+(.*)$/.exec(l[2]);f&&(a[o].name=f[1]?i(f[2]):f[2])}a[o].lines.push(new g(r++,u))}return Object.keys(a).forEach((function(e){var t=a[e];t.lines.forEach((function(e){t.index[e.number]=e}))})),a}function w(e){var t=[];return e.split("\n").forEach((function(e){if(!(e.length<5)){var n=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(e);n?t.push(new y(0|n[1],0|n[2],n[3].trim())):e.length>0&&t.push(new y("unknown",0,e))}})),t}function k(e,t){t.forEach((function(t){var n=e[t.file];if(n){var i=n.index[t.line];if(i)return i.errors.push(t),void(n.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)}))}function C(e,t,i,r,a){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var s=e.getShaderInfoLog(t),u=r===e.FRAGMENT_SHADER?"fragment":"vertex";D(i,"string",u+" shader source must be a string",a);var l=S(i,a),c=w(s);k(l,c),Object.keys(l).forEach((function(e){var t=l[e];if(t.hasErrors){var i=[""],r=[""];o("file number "+e+": "+t.name+"\n","color:red;text-decoration:underline;font-weight:bold"),t.lines.forEach((function(e){if(e.errors.length>0){o(m(e.number,4)+"| ","background-color:yellow; font-weight:bold"),o(e.line+n,"color:red; background-color:yellow; font-weight:bold");var t=0;e.errors.forEach((function(i){var r=i.message,a=/^\s*'(.*)'\s*:\s*(.*)$/.exec(r);if(a){var s=a[1];r=a[2],"assign"===s&&(s="="),t=Math.max(e.line.indexOf(s,t),0)}else t=0;o(m("| ",6)),o(m("^^^",t+3)+n,"font-weight:bold"),o(m("| ",6)),o(r+n,"font-weight:bold")})),o(m("| ",6)+n)}else o(m(e.number,4)+"| "),o(e.line+n,"color:red")})),"undefined"==typeof document||window.chrome?console.log(i.join("")):(r[0]=i.join("%c"),console.log.apply(console,r))}function o(e,t){i.push(e),r.push(t||"")}})),o.raise("Error compiling "+u+" shader, "+l[0].name)}}function T(e,t,i,r,a){if(!e.getProgramParameter(t,e.LINK_STATUS)){var s=e.getProgramInfoLog(t),u=S(i,a),l='Error linking program with vertex shader, "'+S(r,a)[0].name+'", and fragment shader "'+u[0].name+'"';"undefined"!=typeof document?console.log("%c"+l+n+"%c"+s,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(l+n+s),o.raise(l)}}function P(e){e._commandRef=b()}function _(e,t,n,i){function r(e){return e?i.id(e):0}function o(e,t){Object.keys(t).forEach((function(t){e[i.id(t)]=!0}))}P(e),e._fragId=r(e.static.frag),e._vertId=r(e.static.vert);var a=e._uniformSet={};o(a,t.static),o(a,t.dynamic);var s=e._attributeSet={};o(s,n.static),o(s,n.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic}function A(e,t){var n=x();r(e+" in command "+(t||b())+("unknown"===n?"":" called from "+n))}function z(e,t,n){e||A(t,n||b())}function I(e,t,n,i){e in t||A("unknown parameter ("+e+")"+a(n)+". possible values: "+Object.keys(t).join(),i||b())}function D(e,t,n,i){l(e,t)||A("invalid parameter type"+a(n)+". expected "+t+", got "+typeof e,i||b())}function M(e){e()}function F(e,t,n){e.texture?h(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):h(e.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}var E=33071,L=9728,O=9984,N=9985,R=9986,j=9987,B=5121,V=5122,U=5123,G=5124,H=5125,W=5126,q=32819,Y=32820,$=33635,X=34042,Z=36193,Q={};function K(e,t){return e===Y||e===q||e===$?2:e===X?4:Q[e]*t}function J(e){return!(e&e-1||!e)}function ee(e,t,n){var i,r=t.width,a=t.height,s=t.channels;o(r>0&&r<=n.maxTextureSize&&a>0&&a<=n.maxTextureSize,"invalid texture shape"),e.wrapS===E&&e.wrapT===E||o(J(r)&&J(a),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==r&&1!==a&&o(e.minFilter!==O&&e.minFilter!==R&&e.minFilter!==N&&e.minFilter!==j,"min filter requires mipmap"):(o(J(r)&&J(a),"texture must be a square power of 2 to support mipmapping"),o(t.mipmask===(r<<1)-1,"missing or incomplete mipmap data")),t.type===W&&(n.extensions.indexOf("oes_texture_float_linear")<0&&o(e.minFilter===L&&e.magFilter===L,"filter not supported, must enable oes_texture_float_linear"),o(!e.genMipmaps,"mipmap generation not supported with float textures"));var u=t.images;for(i=0;i<16;++i)if(u[i]){var l=r>>i,c=a>>i;o(t.mipmask&1<<i,"missing mipmap data");var f=u[i];if(o(f.width===l&&f.height===c,"invalid shape for mip images"),o(f.format===t.format&&f.internalformat===t.internalformat&&f.type===t.type,"incompatible type for mip image"),f.compressed);else if(f.data){var h=Math.ceil(K(f.type,s)*l/f.unpackAlignment)*f.unpackAlignment;o(f.data.byteLength===h*c,"invalid data for image, buffer size is inconsistent with image format")}else f.element||f.copy}else e.genMipmaps||o(0==(t.mipmask&1<<i),"extra mipmap data");t.compressed&&o(!e.genMipmaps,"mipmap generation for compressed images not supported")}function te(e,t,n,i){var r=e.width,a=e.height,s=e.channels;o(r>0&&r<=i.maxTextureSize&&a>0&&a<=i.maxTextureSize,"invalid texture shape"),o(r===a,"cube map must be square"),o(t.wrapS===E&&t.wrapT===E,"wrap mode not supported by cube map");for(var u=0;u<n.length;++u){var l=n[u];o(l.width===r&&l.height===a,"inconsistent cube map face shape"),t.genMipmaps&&(o(!l.compressed,"can not generate mipmap for compressed textures"),o(1===l.mipmask,"can not specify mipmaps and generate mipmaps"));for(var c=l.images,f=0;f<16;++f){var h=c[f];if(h){var d=r>>f,p=a>>f;o(l.mipmask&1<<f,"missing mipmap data"),o(h.width===d&&h.height===p,"invalid shape for mip images"),o(h.format===e.format&&h.internalformat===e.internalformat&&h.type===e.type,"incompatible type for mip image"),h.compressed||(h.data?o(h.data.byteLength===d*p*Math.max(K(h.type,s),h.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):h.element||h.copy)}}}}Q[5120]=Q[B]=1,Q[V]=Q[U]=Q[Z]=Q[$]=Q[q]=Q[Y]=2,Q[G]=Q[H]=Q[W]=Q[X]=4;var ne=t(o,{optional:M,raise:r,commandRaise:A,command:z,parameter:s,commandParameter:I,constructor:p,type:c,commandType:D,isTypedArray:u,nni:f,oneOf:h,shaderError:C,linkError:T,callSite:x,saveCommandRef:P,saveDrawInfo:_,framebufferFormat:F,guessCommand:b,texture2D:ee,textureCube:te}),ie=0,re=0,oe=5,ae=6;function se(e,t){this.id=ie++,this.type=e,this.data=t}function ue(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function le(e){if(0===e.length)return[];var t=e.charAt(0),n=e.charAt(e.length-1);if(e.length>1&&t===n&&('"'===t||"'"===t))return['"'+ue(e.substr(1,e.length-2))+'"'];var i=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(i)return le(e.substr(0,i.index)).concat(le(i[1])).concat(le(e.substr(i.index+i[0].length)));var r=e.split(".");if(1===r.length)return['"'+ue(e)+'"'];for(var o=[],a=0;a<r.length;++a)o=o.concat(le(r[a]));return o}function ce(e){return"["+le(e).join("][")+"]"}function fe(e,t){return new se(e,ce(t+""))}function he(e){return"function"==typeof e&&!e._reglType||e instanceof se}function de(e,t){return"function"==typeof e?new se(re,e):"number"==typeof e||"boolean"==typeof e?new se(oe,e):Array.isArray(e)?new se(ae,e.map((function(e,n){return de(e,t+"["+n+"]")}))):e instanceof se?e:void ne(!1,"invalid option type in uniform "+t)}var pe={DynamicVariable:se,define:fe,isDynamic:he,unbox:de,accessor:ce},me={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},ve="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function ge(){var e={"":0},t=[""];return{id:function(n){var i=e[n];return i||(i=e[n]=t.length,t.push(n),i)},str:function(e){return t[e]}}}function ye(e,n,i){var r,o=document.createElement("canvas");function a(){var t=window.innerWidth,n=window.innerHeight;if(e!==document.body){var r=o.getBoundingClientRect();t=r.right-r.left,n=r.bottom-r.top}o.width=i*t,o.height=i*n}function s(){r?r.disconnect():window.removeEventListener("resize",a),e.removeChild(o)}return t(o.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),e.appendChild(o),e===document.body&&(o.style.position="absolute",t(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(r=new ResizeObserver((function(){setTimeout(a)}))).observe(e):window.addEventListener("resize",a,!1),a(),{canvas:o,onDestroy:s}}function be(e,t){function n(n){try{return e.getContext(n,t)}catch(e){return null}}return n("webgl")||n("experimental-webgl")||n("webgl-experimental")}function xe(e){return"string"==typeof e.nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect}function Se(e){return"function"==typeof e.drawArrays||"function"==typeof e.drawElements}function we(e){return"string"==typeof e?e.split():(ne(Array.isArray(e),"invalid extension array"),e)}function ke(e){return"string"==typeof e?(ne("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(e)):e}function Ce(e){var t,n,i,r,o=e||{},a={},s=[],u=[],l="undefined"==typeof window?1:window.devicePixelRatio,c=!1,f=function(e){e&&ne.raise(e)},h=function(){};if("string"==typeof o?(ne("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),t=document.querySelector(o),ne(t,"invalid query string for element")):"object"==typeof o?xe(o)?t=o:Se(o)?i=(r=o).canvas:(ne.constructor(o),"gl"in o?r=o.gl:"canvas"in o?i=ke(o.canvas):"container"in o&&(n=ke(o.container)),"attributes"in o&&(a=o.attributes,ne.type(a,"object","invalid context attributes")),"extensions"in o&&(s=we(o.extensions)),"optionalExtensions"in o&&(u=we(o.optionalExtensions)),"onDone"in o&&(ne.type(o.onDone,"function","invalid or missing onDone callback"),f=o.onDone),"profile"in o&&(c=!!o.profile),"pixelRatio"in o&&(l=+o.pixelRatio,ne(l>0,"invalid pixel ratio"))):ne.raise("invalid arguments to regl"),t&&("canvas"===t.nodeName.toLowerCase()?i=t:n=t),!r){if(!i){ne("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var d=ye(n||document.body,f,l);if(!d)return null;i=d.canvas,h=d.onDestroy}void 0===a.premultipliedAlpha&&(a.premultipliedAlpha=!0),r=be(i,a)}return r?{gl:r,canvas:i,container:n,extensions:s,optionalExtensions:u,pixelRatio:l,profile:c,onDone:f,onDestroy:h}:(h(),f("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Te(e,t){var n={};function i(t){ne.type(t,"string","extension name must be string");var i,r=t.toLowerCase();try{i=n[r]=e.getExtension(r)}catch(e){}return!!i}for(var r=0;r<t.extensions.length;++r){var o=t.extensions[r];if(!i(o))return t.onDestroy(),t.onDone('"'+o+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(i),{extensions:n,restore:function(){Object.keys(n).forEach((function(e){if(n[e]&&!i(e))throw new Error("(regl): error restoring extension "+e)}))}}}function Pe(e,t){for(var n=Array(e),i=0;i<e;++i)n[i]=t(i);return n}var _e=5120,Ae=5121,ze=5122,Ie=5123,De=5124,Me=5125,Fe=5126;function Ee(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}function Le(e){var t,n;return t=(e>65535)<<4,t|=n=((e>>>=t)>255)<<3,t|=n=((e>>>=n)>15)<<2,(t|=n=((e>>>=n)>3)<<1)|(e>>>=n)>>1}function Oe(){var e=Pe(8,(function(){return[]}));function t(t){var n=Ee(t),i=e[Le(n)>>2];return i.length>0?i.pop():new ArrayBuffer(n)}function n(t){e[Le(t.byteLength)>>2].push(t)}function i(e,n){var i=null;switch(e){case _e:i=new Int8Array(t(n),0,n);break;case Ae:i=new Uint8Array(t(n),0,n);break;case ze:i=new Int16Array(t(2*n),0,n);break;case Ie:i=new Uint16Array(t(2*n),0,n);break;case De:i=new Int32Array(t(4*n),0,n);break;case Me:i=new Uint32Array(t(4*n),0,n);break;case Fe:i=new Float32Array(t(4*n),0,n);break;default:return null}return i.length!==n?i.subarray(0,n):i}function r(e){n(e.buffer)}return{alloc:t,free:n,allocType:i,freeType:r}}var Ne=Oe();Ne.zero=Oe();var Re=3408,je=3410,Be=3411,Ve=3412,Ue=3413,Ge=3414,He=3415,We=33901,qe=33902,Ye=3379,$e=3386,Xe=34921,Ze=36347,Qe=36348,Ke=35661,Je=35660,et=34930,tt=36349,nt=34076,it=34024,rt=7936,ot=7937,at=7938,st=35724,ut=34047,lt=36063,ct=34852,ft=3553,ht=34067,dt=34069,pt=33984,mt=6408,vt=5126,gt=5121,yt=36160,bt=36053,xt=36064,St=16384,wt=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter(ut));var i=1,r=1;t.webgl_draw_buffers&&(i=e.getParameter(ct),r=e.getParameter(lt));var o=!!t.oes_texture_float;if(o){var a=e.createTexture();e.bindTexture(ft,a),e.texImage2D(ft,0,mt,1,1,0,mt,vt,null);var s=e.createFramebuffer();if(e.bindFramebuffer(yt,s),e.framebufferTexture2D(yt,xt,ft,a,0),e.bindTexture(ft,null),e.checkFramebufferStatus(yt)!==bt)o=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(St);var u=Ne.allocType(vt,4);e.readPixels(0,0,1,1,mt,vt,u),e.getError()?o=!1:(e.deleteFramebuffer(s),e.deleteTexture(a),o=1===u[0]),Ne.freeType(u)}}var l=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=e.createTexture(),f=Ne.allocType(gt,36);e.activeTexture(pt),e.bindTexture(ht,c),e.texImage2D(dt,0,mt,3,3,0,mt,gt,f),Ne.freeType(f),e.bindTexture(ht,null),e.deleteTexture(c),l=!e.getError()}return{colorBits:[e.getParameter(je),e.getParameter(Be),e.getParameter(Ve),e.getParameter(Ue)],depthBits:e.getParameter(Ge),stencilBits:e.getParameter(He),subpixelBits:e.getParameter(Re),extensions:Object.keys(t).filter((function(e){return!!t[e]})),maxAnisotropic:n,maxDrawbuffers:i,maxColorAttachments:r,pointSizeDims:e.getParameter(We),lineWidthDims:e.getParameter(qe),maxViewportDims:e.getParameter($e),maxCombinedTextureUnits:e.getParameter(Ke),maxCubeMapSize:e.getParameter(nt),maxRenderbufferSize:e.getParameter(it),maxTextureUnits:e.getParameter(et),maxTextureSize:e.getParameter(Ye),maxAttributes:e.getParameter(Xe),maxVertexUniforms:e.getParameter(Ze),maxVertexTextureUnits:e.getParameter(Je),maxVaryingVectors:e.getParameter(Qe),maxFragmentUniforms:e.getParameter(tt),glsl:e.getParameter(st),renderer:e.getParameter(ot),vendor:e.getParameter(rt),version:e.getParameter(at),readFloat:o,npotTextureCube:l}};function kt(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||e(t.data))}var Ct=function(e){return Object.keys(e).map((function(t){return e[t]}))},Tt={shape:Dt,flatten:It};function Pt(e,t,n){for(var i=0;i<t;++i)n[i]=e[i]}function _t(e,t,n,i){for(var r=0,o=0;o<t;++o)for(var a=e[o],s=0;s<n;++s)i[r++]=a[s]}function At(e,t,n,i,r,o){for(var a=o,s=0;s<t;++s)for(var u=e[s],l=0;l<n;++l)for(var c=u[l],f=0;f<i;++f)r[a++]=c[f]}function zt(e,t,n,i,r){for(var o=1,a=n+1;a<t.length;++a)o*=t[a];var s=t[n];if(t.length-n==4){var u=t[n+1],l=t[n+2],c=t[n+3];for(a=0;a<s;++a)At(e[a],u,l,c,i,r),r+=o}else for(a=0;a<s;++a)zt(e[a],t,n+1,i,r),r+=o}function It(e,t,n,i){var r=1;if(t.length)for(var o=0;o<t.length;++o)r*=t[o];else r=0;var a=i||Ne.allocType(n,r);switch(t.length){case 0:break;case 1:Pt(e,t[0],a);break;case 2:_t(e,t[0],t[1],a);break;case 3:At(e,t[0],t[1],t[2],a,0);break;default:zt(e,t,0,a,0)}return a}function Dt(e){for(var t=[],n=e;n.length;n=n[0])t.push(n.length);return t}var Mt={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Ft={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},Et={dynamic:35048,stream:35040,static:35044},Lt=Tt.flatten,Ot=Tt.shape,Nt=35044,Rt=35040,jt=5121,Bt=5126,Vt=[];function Ut(e){return 0|Mt[Object.prototype.toString.call(e)]}function Gt(e,t){for(var n=0;n<t.length;++n)e[n]=t[n]}function Ht(e,t,n,i,r,o,a){for(var s=0,u=0;u<n;++u)for(var l=0;l<i;++l)e[s++]=t[r*u+o*l+a]}function Wt(t,n,i,r){var o=0,a={};function s(e){this.id=o++,this.buffer=t.createBuffer(),this.type=e,this.usage=Nt,this.byteLength=0,this.dimension=1,this.dtype=jt,this.persistentData=null,i.profile&&(this.stats={size:0})}s.prototype.bind=function(){t.bindBuffer(this.type,this.buffer)},s.prototype.destroy=function(){d(this)};var u=[];function l(e,t){var n=u.pop();return n||(n=new s(e)),n.bind(),h(n,t,Rt,0,1,!1),n}function c(e){u.push(e)}function f(e,n,i){e.byteLength=n.byteLength,t.bufferData(e.type,n,i)}function h(t,n,i,r,o,a){var s,u;if(t.usage=i,Array.isArray(n)){if(t.dtype=r||Bt,n.length>0)if(Array.isArray(n[0])){s=Ot(n);for(var l=1,c=1;c<s.length;++c)l*=s[c];t.dimension=l,f(t,u=Lt(n,s,t.dtype),i),a?t.persistentData=u:Ne.freeType(u)}else if("number"==typeof n[0]){t.dimension=o;var h=Ne.allocType(t.dtype,n.length);Gt(h,n),f(t,h,i),a?t.persistentData=h:Ne.freeType(h)}else e(n[0])?(t.dimension=n[0].length,t.dtype=r||Ut(n[0])||Bt,f(t,u=Lt(n,[n.length,n[0].length],t.dtype),i),a?t.persistentData=u:Ne.freeType(u)):ne.raise("invalid buffer data")}else if(e(n))t.dtype=r||Ut(n),t.dimension=o,f(t,n,i),a&&(t.persistentData=new Uint8Array(new Uint8Array(n.buffer)));else if(kt(n)){s=n.shape;var d=n.stride,p=n.offset,m=0,v=0,g=0,y=0;1===s.length?(m=s[0],v=1,g=d[0],y=0):2===s.length?(m=s[0],v=s[1],g=d[0],y=d[1]):ne.raise("invalid shape"),t.dtype=r||Ut(n.data)||Bt,t.dimension=v;var b=Ne.allocType(t.dtype,m*v);Ht(b,n.data,m,v,g,y,p),f(t,b,i),a?t.persistentData=b:Ne.freeType(b)}else n instanceof ArrayBuffer?(t.dtype=jt,t.dimension=o,f(t,n,i),a&&(t.persistentData=new Uint8Array(new Uint8Array(n)))):ne.raise("invalid buffer data")}function d(e){n.bufferCount--,r(e);var i=e.buffer;ne(i,"buffer must not be deleted already"),t.deleteBuffer(i),e.buffer=null,delete a[e.id]}function p(r,o,u,l){n.bufferCount++;var c=new s(o);function f(n){var r=Nt,o=null,a=0,s=0,u=1;return Array.isArray(n)||e(n)||kt(n)||n instanceof ArrayBuffer?o=n:"number"==typeof n?a=0|n:n&&(ne.type(n,"object","buffer arguments must be an object, a number or an array"),"data"in n&&(ne(null===o||Array.isArray(o)||e(o)||kt(o),"invalid data for buffer"),o=n.data),"usage"in n&&(ne.parameter(n.usage,Et,"invalid buffer usage"),r=Et[n.usage]),"type"in n&&(ne.parameter(n.type,Ft,"invalid buffer type"),s=Ft[n.type]),"dimension"in n&&(ne.type(n.dimension,"number","invalid dimension"),u=0|n.dimension),"length"in n&&(ne.nni(a,"buffer length must be a nonnegative integer"),a=0|n.length)),c.bind(),o?h(c,o,r,s,u,l):(a&&t.bufferData(c.type,a,r),c.dtype=s||jt,c.usage=r,c.dimension=u,c.byteLength=a),i.profile&&(c.stats.size=c.byteLength*Vt[c.dtype]),f}function p(e,n){ne(n+e.byteLength<=c.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+e.byteLength+" starting from offset "+n+" to a buffer of size "+c.byteLength),t.bufferSubData(c.type,n,e)}function m(t,n){var i,r=0|(n||0);if(c.bind(),e(t)||t instanceof ArrayBuffer)p(t,r);else if(Array.isArray(t)){if(t.length>0)if("number"==typeof t[0]){var o=Ne.allocType(c.dtype,t.length);Gt(o,t),p(o,r),Ne.freeType(o)}else if(Array.isArray(t[0])||e(t[0])){i=Ot(t);var a=Lt(t,i,c.dtype);p(a,r),Ne.freeType(a)}else ne.raise("invalid buffer data")}else if(kt(t)){i=t.shape;var s=t.stride,u=0,l=0,h=0,d=0;1===i.length?(u=i[0],l=1,h=s[0],d=0):2===i.length?(u=i[0],l=i[1],h=s[0],d=s[1]):ne.raise("invalid shape");var m=Array.isArray(t.data)?c.dtype:Ut(t.data),v=Ne.allocType(m,u*l);Ht(v,t.data,u,l,h,d,t.offset),p(v,r),Ne.freeType(v)}else ne.raise("invalid data for buffer subdata");return f}return a[c.id]=c,u||f(r),f._reglType="buffer",f._buffer=c,f.subdata=m,i.profile&&(f.stats=c.stats),f.destroy=function(){d(c)},f}function m(){Ct(a).forEach((function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)}))}return i.profile&&(n.getTotalBufferSize=function(){var e=0;return Object.keys(a).forEach((function(t){e+=a[t].stats.size})),e}),{create:p,createStream:l,destroyStream:c,clear:function(){Ct(a).forEach(d),u.forEach(d)},getBuffer:function(e){return e&&e._buffer instanceof s?e._buffer:null},restore:m,_initBuffer:h}}Vt[5120]=1,Vt[5122]=2,Vt[5124]=4,Vt[5121]=1,Vt[5123]=2,Vt[5125]=4,Vt[5126]=4;var qt={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},Yt=0,$t=1,Xt=4,Zt=5120,Qt=5121,Kt=5122,Jt=5123,en=5124,tn=5125,nn=34963,rn=35040,on=35044;function an(t,n,i,r){var o={},a=0,s={uint8:Qt,uint16:Jt};function u(e){this.id=a++,o[this.id]=this,this.buffer=e,this.primType=Xt,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(s.uint32=tn),u.prototype.bind=function(){this.buffer.bind()};var l=[];function c(e){var t=l.pop();return t||(t=new u(i.create(null,nn,!0,!1)._buffer)),h(t,e,rn,-1,-1,0,0),t}function f(e){l.push(e)}function h(r,o,a,s,u,l,c){var f;if(r.buffer.bind(),o){var h=c;c||e(o)&&(!kt(o)||e(o.data))||(h=n.oes_element_index_uint?tn:Jt),i._initBuffer(r.buffer,o,a,h,3)}else t.bufferData(nn,l,a),r.buffer.dtype=f||Qt,r.buffer.usage=a,r.buffer.dimension=3,r.buffer.byteLength=l;if(f=c,!c){switch(r.buffer.dtype){case Qt:case Zt:f=Qt;break;case Jt:case Kt:f=Jt;break;case tn:case en:f=tn;break;default:ne.raise("unsupported type for element array")}r.buffer.dtype=f}r.type=f,ne(f!==tn||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=u;d<0&&(d=r.buffer.byteLength,f===Jt?d>>=1:f===tn&&(d>>=2)),r.vertCount=d;var p=s;if(s<0){p=Xt;var m=r.buffer.dimension;1===m&&(p=Yt),2===m&&(p=$t),3===m&&(p=Xt)}r.primType=p}function d(e){r.elementsCount--,ne(null!==e.buffer,"must not double destroy elements"),delete o[e.id],e.buffer.destroy(),e.buffer=null}function p(t,n){var o=i.create(null,nn,!0),a=new u(o._buffer);function l(t){if(t)if("number"==typeof t)o(t),a.primType=Xt,a.vertCount=0|t,a.type=Qt;else{var n=null,i=on,r=-1,u=-1,c=0,f=0;Array.isArray(t)||e(t)||kt(t)?n=t:(ne.type(t,"object","invalid arguments for elements"),"data"in t&&(n=t.data,ne(Array.isArray(n)||e(n)||kt(n),"invalid data for element buffer")),"usage"in t&&(ne.parameter(t.usage,Et,"invalid element buffer usage"),i=Et[t.usage]),"primitive"in t&&(ne.parameter(t.primitive,qt,"invalid element buffer primitive"),r=qt[t.primitive]),"count"in t&&(ne("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),u=0|t.count),"type"in t&&(ne.parameter(t.type,s,"invalid buffer type"),f=s[t.type]),"length"in t?c=0|t.length:(c=u,f===Jt||f===Kt?c*=2:f!==tn&&f!==en||(c*=4))),h(a,n,i,r,u,c,f)}else o(),a.primType=Xt,a.vertCount=0,a.type=Qt;return l}return r.elementsCount++,l(t),l._reglType="elements",l._elements=a,l.subdata=function(e,t){return o.subdata(e,t),l},l.destroy=function(){d(a)},l}return{create:p,createStream:c,destroyStream:f,getElements:function(e){return"function"==typeof e&&e._elements instanceof u?e._elements:null},clear:function(){Ct(o).forEach(d)}}}var sn=new Float32Array(1),un=new Uint32Array(sn.buffer),ln=5123;function cn(e){for(var t=Ne.allocType(ln,e.length),n=0;n<e.length;++n)if(isNaN(e[n]))t[n]=65535;else if(e[n]===1/0)t[n]=31744;else if(e[n]===-1/0)t[n]=64512;else{sn[0]=e[n];var i=un[0],r=i>>>31<<15,o=(i<<1>>>24)-127,a=i>>13&1023;if(o<-24)t[n]=r;else if(o<-14){var s=-14-o;t[n]=r+(a+1024>>s)}else t[n]=o>15?r+31744:r+(o+15<<10)+a}return t}function fn(t){return Array.isArray(t)||e(t)}var hn=function(e){return!(e&e-1||!e)},dn=34467,pn=3553,mn=34067,vn=34069,gn=6408,yn=6406,bn=6407,xn=6409,Sn=6410,wn=32854,kn=32855,Cn=36194,Tn=32819,Pn=32820,_n=33635,An=34042,zn=6402,In=34041,Dn=35904,Mn=35906,Fn=36193,En=33776,Ln=33777,On=33778,Nn=33779,Rn=35986,jn=35987,Bn=34798,Vn=35840,Un=35841,Gn=35842,Hn=35843,Wn=36196,qn=5121,Yn=5123,$n=5125,Xn=5126,Zn=10242,Qn=10243,Kn=10497,Jn=33071,ei=33648,ti=10240,ni=10241,ii=9728,ri=9729,oi=9984,ai=9985,si=9986,ui=9987,li=33170,ci=4352,fi=4353,hi=4354,di=34046,pi=3317,mi=37440,vi=37441,gi=37443,yi=37444,bi=33984,xi=[oi,si,ai,ui],Si=[0,xn,Sn,bn,gn],wi={};function ki(e){return"[object "+e+"]"}wi[xn]=wi[yn]=wi[zn]=1,wi[In]=wi[Sn]=2,wi[bn]=wi[Dn]=3,wi[gn]=wi[Mn]=4;var Ci=ki("HTMLCanvasElement"),Ti=ki("OffscreenCanvas"),Pi=ki("CanvasRenderingContext2D"),_i=ki("ImageBitmap"),Ai=ki("HTMLImageElement"),zi=ki("HTMLVideoElement"),Ii=Object.keys(Mt).concat([Ci,Ti,Pi,_i,Ai,zi]),Di=[];Di[qn]=1,Di[Xn]=4,Di[Fn]=2,Di[Yn]=2,Di[$n]=4;var Mi=[];function Fi(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function Ei(e){return!!Array.isArray(e)&&!(0===e.length||!fn(e[0]))}function Li(e){return Object.prototype.toString.call(e)}function Oi(e){return Li(e)===Ci}function Ni(e){return Li(e)===Ti}function Ri(e){return Li(e)===Pi}function ji(e){return Li(e)===_i}function Bi(e){return Li(e)===Ai}function Vi(e){return Li(e)===zi}function Ui(e){if(!e)return!1;var t=Li(e);return Ii.indexOf(t)>=0||Fi(e)||Ei(e)||kt(e)}function Gi(e){return 0|Mt[Object.prototype.toString.call(e)]}function Hi(e,t){var n=t.length;switch(e.type){case qn:case Yn:case $n:case Xn:var i=Ne.allocType(e.type,n);i.set(t),e.data=i;break;case Fn:e.data=cn(t);break;default:ne.raise("unsupported texture type, must specify a typed array")}}function Wi(e,t){return Ne.allocType(e.type===Fn?Xn:e.type,t)}function qi(e,t){e.type===Fn?(e.data=cn(t),Ne.freeType(t)):e.data=t}function Yi(e,t,n,i,r,o){for(var a=e.width,s=e.height,u=e.channels,l=Wi(e,a*s*u),c=0,f=0;f<s;++f)for(var h=0;h<a;++h)for(var d=0;d<u;++d)l[c++]=t[n*h+i*f+r*d+o];qi(e,l)}function $i(e,t,n,i,r,o){var a;if(a=void 0!==Mi[e]?Mi[e]:wi[e]*Di[t],o&&(a*=6),r){for(var s=0,u=n;u>=1;)s+=a*u*u,u/=2;return s}return a*n*i}function Xi(n,i,r,o,a,s,u){var l={"don't care":ci,"dont care":ci,nice:hi,fast:fi},c={repeat:Kn,clamp:Jn,mirror:ei},f={nearest:ii,linear:ri},h=t({mipmap:ui,"nearest mipmap nearest":oi,"linear mipmap nearest":ai,"nearest mipmap linear":si,"linear mipmap linear":ui},f),d={none:0,browser:yi},p={uint8:qn,rgba4:Tn,rgb565:_n,"rgb5 a1":Pn},m={alpha:yn,luminance:xn,"luminance alpha":Sn,rgb:bn,rgba:gn,rgba4:wn,"rgb5 a1":kn,rgb565:Cn},v={};i.ext_srgb&&(m.srgb=Dn,m.srgba=Mn),i.oes_texture_float&&(p.float32=p.float=Xn),i.oes_texture_half_float&&(p.float16=p["half float"]=Fn),i.webgl_depth_texture&&(t(m,{depth:zn,"depth stencil":In}),t(p,{uint16:Yn,uint32:$n,"depth stencil":An})),i.webgl_compressed_texture_s3tc&&t(v,{"rgb s3tc dxt1":En,"rgba s3tc dxt1":Ln,"rgba s3tc dxt3":On,"rgba s3tc dxt5":Nn}),i.webgl_compressed_texture_atc&&t(v,{"rgb atc":Rn,"rgba atc explicit alpha":jn,"rgba atc interpolated alpha":Bn}),i.webgl_compressed_texture_pvrtc&&t(v,{"rgb pvrtc 4bppv1":Vn,"rgb pvrtc 2bppv1":Un,"rgba pvrtc 4bppv1":Gn,"rgba pvrtc 2bppv1":Hn}),i.webgl_compressed_texture_etc1&&(v["rgb etc1"]=Wn);var g=Array.prototype.slice.call(n.getParameter(dn));Object.keys(v).forEach((function(e){var t=v[e];g.indexOf(t)>=0&&(m[e]=t)}));var y=Object.keys(m);r.textureFormats=y;var b=[];Object.keys(m).forEach((function(e){var t=m[e];b[t]=e}));var x=[];Object.keys(p).forEach((function(e){var t=p[e];x[t]=e}));var S=[];Object.keys(f).forEach((function(e){var t=f[e];S[t]=e}));var w=[];Object.keys(h).forEach((function(e){var t=h[e];w[t]=e}));var k=[];Object.keys(c).forEach((function(e){var t=c[e];k[t]=e}));var C=y.reduce((function(e,t){var n=m[t];return n===xn||n===yn||n===xn||n===Sn||n===zn||n===In||i.ext_srgb&&(n===Dn||n===Mn)?e[n]=n:n===kn||t.indexOf("rgba")>=0?e[n]=gn:e[n]=bn,e}),{});function T(){this.internalformat=gn,this.format=gn,this.type=qn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=yi,this.width=0,this.height=0,this.channels=0}function P(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function _(e,t){if("object"==typeof t&&t){if("premultiplyAlpha"in t&&(ne.type(t.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(ne.type(t.flipY,"boolean","invalid texture flip"),e.flipY=t.flipY),"alignment"in t&&(ne.oneOf(t.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=t.alignment),"colorSpace"in t&&(ne.parameter(t.colorSpace,d,"invalid colorSpace"),e.colorSpace=d[t.colorSpace]),"type"in t){var n=t.type;ne(i.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),ne(i.oes_texture_half_float||!("half float"===n||"float16"===n),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),ne(i.webgl_depth_texture||!("uint16"===n||"uint32"===n||"depth stencil"===n),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),ne.parameter(n,p,"invalid texture type"),e.type=p[n]}var o=e.width,a=e.height,s=e.channels,u=!1;"shape"in t?(ne(Array.isArray(t.shape)&&t.shape.length>=2,"shape must be an array"),o=t.shape[0],a=t.shape[1],3===t.shape.length&&(s=t.shape[2],ne(s>0&&s<=4,"invalid number of channels"),u=!0),ne(o>=0&&o<=r.maxTextureSize,"invalid width"),ne(a>=0&&a<=r.maxTextureSize,"invalid height")):("radius"in t&&(o=a=t.radius,ne(o>=0&&o<=r.maxTextureSize,"invalid radius")),"width"in t&&(o=t.width,ne(o>=0&&o<=r.maxTextureSize,"invalid width")),"height"in t&&(a=t.height,ne(a>=0&&a<=r.maxTextureSize,"invalid height")),"channels"in t&&(s=t.channels,ne(s>0&&s<=4,"invalid number of channels"),u=!0)),e.width=0|o,e.height=0|a,e.channels=0|s;var l=!1;if("format"in t){var c=t.format;ne(i.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),ne.parameter(c,m,"invalid texture format");var f=e.internalformat=m[c];e.format=C[f],c in p&&("type"in t||(e.type=p[c])),c in v&&(e.compressed=!0),l=!0}!u&&l?e.channels=wi[e.format]:u&&!l?e.channels!==Si[e.format]&&(e.format=e.internalformat=Si[e.channels]):l&&u&&ne(e.channels===wi[e.format],"number of channels inconsistent with specified format")}}function A(e){n.pixelStorei(mi,e.flipY),n.pixelStorei(vi,e.premultiplyAlpha),n.pixelStorei(gi,e.colorSpace),n.pixelStorei(pi,e.unpackAlignment)}function z(){T.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function I(t,n){var i=null;if(Ui(n)?i=n:n&&(ne.type(n,"object","invalid pixel data type"),_(t,n),"x"in n&&(t.xOffset=0|n.x),"y"in n&&(t.yOffset=0|n.y),Ui(n.data)&&(i=n.data)),ne(!t.compressed||i instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){ne(!i,"can not specify copy and data field for the same texture");var o=a.viewportWidth,s=a.viewportHeight;t.width=t.width||o-t.xOffset,t.height=t.height||s-t.yOffset,t.needsCopy=!0,ne(t.xOffset>=0&&t.xOffset<o&&t.yOffset>=0&&t.yOffset<s&&t.width>0&&t.width<=o&&t.height>0&&t.height<=s,"copy texture read out of bounds")}else if(i){if(e(i))t.channels=t.channels||4,t.data=i,"type"in n||t.type!==qn||(t.type=Gi(i));else if(Fi(i))t.channels=t.channels||4,Hi(t,i),t.alignment=1,t.needsFree=!0;else if(kt(i)){var u=i.data;Array.isArray(u)||t.type!==qn||(t.type=Gi(u));var l,c,f,h,d,p,m=i.shape,v=i.stride;3===m.length?(f=m[2],p=v[2]):(ne(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),f=1,p=1),l=m[0],c=m[1],h=v[0],d=v[1],t.alignment=1,t.width=l,t.height=c,t.channels=f,t.format=t.internalformat=Si[f],t.needsFree=!0,Yi(t,u,h,d,p,i.offset)}else if(Oi(i)||Ni(i)||Ri(i))Oi(i)||Ni(i)?t.element=i:t.element=i.canvas,t.width=t.element.width,t.height=t.element.height,t.channels=4;else if(ji(i))t.element=i,t.width=i.width,t.height=i.height,t.channels=4;else if(Bi(i))t.element=i,t.width=i.naturalWidth,t.height=i.naturalHeight,t.channels=4;else if(Vi(i))t.element=i,t.width=i.videoWidth,t.height=i.videoHeight,t.channels=4;else if(Ei(i)){var g=t.width||i[0].length,y=t.height||i.length,b=t.channels;b=fn(i[0][0])?b||i[0][0].length:b||1;for(var x=Tt.shape(i),S=1,w=0;w<x.length;++w)S*=x[w];var k=Wi(t,S);Tt.flatten(i,x,"",k),qi(t,k),t.alignment=1,t.width=g,t.height=y,t.channels=b,t.format=t.internalformat=Si[b],t.needsFree=!0}}else t.width=t.width||1,t.height=t.height||1,t.channels=t.channels||4;t.type===Xn?ne(r.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):t.type===Fn&&ne(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function D(e,t,i){var r=e.element,a=e.data,s=e.internalformat,u=e.format,l=e.type,c=e.width,f=e.height;A(e),r?n.texImage2D(t,i,u,u,l,r):e.compressed?n.compressedTexImage2D(t,i,s,c,f,0,a):e.needsCopy?(o(),n.copyTexImage2D(t,i,u,e.xOffset,e.yOffset,c,f,0)):n.texImage2D(t,i,u,c,f,0,u,l,a||null)}function M(e,t,i,r,a){var s=e.element,u=e.data,l=e.internalformat,c=e.format,f=e.type,h=e.width,d=e.height;A(e),s?n.texSubImage2D(t,a,i,r,c,f,s):e.compressed?n.compressedTexSubImage2D(t,a,i,r,l,h,d,u):e.needsCopy?(o(),n.copyTexSubImage2D(t,a,i,r,e.xOffset,e.yOffset,h,d)):n.texSubImage2D(t,a,i,r,h,d,c,f,u)}var F=[];function E(){return F.pop()||new z}function L(e){e.needsFree&&Ne.freeType(e.data),z.call(e),F.push(e)}function O(){T.call(this),this.genMipmaps=!1,this.mipmapHint=ci,this.mipmask=0,this.images=Array(16)}function N(e,t,n){var i=e.images[0]=E();e.mipmask=1,i.width=e.width=t,i.height=e.height=n,i.channels=e.channels=4}function R(e,t){var n=null;if(Ui(t))P(n=e.images[0]=E(),e),I(n,t),e.mipmask=1;else if(_(e,t),Array.isArray(t.mipmap))for(var i=t.mipmap,r=0;r<i.length;++r)P(n=e.images[r]=E(),e),n.width>>=r,n.height>>=r,I(n,i[r]),e.mipmask|=1<<r;else P(n=e.images[0]=E(),e),I(n,t),e.mipmask=1;P(e,e.images[0]),!e.compressed||e.internalformat!==En&&e.internalformat!==Ln&&e.internalformat!==On&&e.internalformat!==Nn||ne(e.width%4==0&&e.height%4==0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function j(e,t){for(var n=e.images,i=0;i<n.length;++i){if(!n[i])return;D(n[i],t,i)}}var B=[];function V(){var e=B.pop()||new O;T.call(e),e.mipmask=0;for(var t=0;t<16;++t)e.images[t]=null;return e}function U(e){for(var t=e.images,n=0;n<t.length;++n)t[n]&&L(t[n]),t[n]=null;B.push(e)}function G(){this.minFilter=ii,this.magFilter=ii,this.wrapS=Jn,this.wrapT=Jn,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=ci}function H(e,t){if("min"in t){var n=t.min;ne.parameter(n,h),e.minFilter=h[n],xi.indexOf(e.minFilter)>=0&&!("faces"in t)&&(e.genMipmaps=!0)}if("mag"in t){var i=t.mag;ne.parameter(i,f),e.magFilter=f[i]}var o=e.wrapS,a=e.wrapT;if("wrap"in t){var s=t.wrap;"string"==typeof s?(ne.parameter(s,c),o=a=c[s]):Array.isArray(s)&&(ne.parameter(s[0],c),ne.parameter(s[1],c),o=c[s[0]],a=c[s[1]])}else{if("wrapS"in t){var u=t.wrapS;ne.parameter(u,c),o=c[u]}if("wrapT"in t){var d=t.wrapT;ne.parameter(d,c),a=c[d]}}if(e.wrapS=o,e.wrapT=a,"anisotropic"in t){var p=t.anisotropic;ne("number"==typeof p&&p>=1&&p<=r.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var m=!1;switch(typeof t.mipmap){case"string":ne.parameter(t.mipmap,l,"invalid mipmap hint"),e.mipmapHint=l[t.mipmap],e.genMipmaps=!0,m=!0;break;case"boolean":m=e.genMipmaps=t.mipmap;break;case"object":ne(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,m=!0;break;default:ne.raise("invalid mipmap type")}m&&!("min"in t)&&(e.minFilter=oi)}}function W(e,t){n.texParameteri(t,ni,e.minFilter),n.texParameteri(t,ti,e.magFilter),n.texParameteri(t,Zn,e.wrapS),n.texParameteri(t,Qn,e.wrapT),i.ext_texture_filter_anisotropic&&n.texParameteri(t,di,e.anisotropic),e.genMipmaps&&(n.hint(li,e.mipmapHint),n.generateMipmap(t))}var q=0,Y={},$=r.maxTextureUnits,X=Array($).map((function(){return null}));function Z(e){T.call(this),this.mipmask=0,this.internalformat=gn,this.id=q++,this.refCount=1,this.target=e,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new G,u.profile&&(this.stats={size:0})}function Q(e){n.activeTexture(bi),n.bindTexture(e.target,e.texture)}function K(){var e=X[0];e?n.bindTexture(e.target,e.texture):n.bindTexture(pn,null)}function J(e){var t=e.texture;ne(t,"must not double destroy texture");var i=e.unit,r=e.target;i>=0&&(n.activeTexture(bi+i),n.bindTexture(r,null),X[i]=null),n.deleteTexture(t),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete Y[e.id],s.textureCount--}function ee(e,t){var i=new Z(pn);function o(e,t){var n=i.texInfo;G.call(n);var a=V();return"number"==typeof e?N(a,0|e,"number"==typeof t?0|t:0|e):e?(ne.type(e,"object","invalid arguments to regl.texture"),H(n,e),R(a,e)):N(a,1,1),n.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,P(i,a),ne.texture2D(n,a,r),i.internalformat=a.internalformat,o.width=a.width,o.height=a.height,Q(i),j(a,pn),W(n,pn),K(),U(a),u.profile&&(i.stats.size=$i(i.internalformat,i.type,a.width,a.height,n.genMipmaps,!1)),o.format=b[i.internalformat],o.type=x[i.type],o.mag=S[n.magFilter],o.min=w[n.minFilter],o.wrapS=k[n.wrapS],o.wrapT=k[n.wrapT],o}function a(e,t,n,r){ne(!!e,"must specify image data");var a=0|t,s=0|n,u=0|r,l=E();return P(l,i),l.width=0,l.height=0,I(l,e),l.width=l.width||(i.width>>u)-a,l.height=l.height||(i.height>>u)-s,ne(i.type===l.type&&i.format===l.format&&i.internalformat===l.internalformat,"incompatible format for texture.subimage"),ne(a>=0&&s>=0&&a+l.width<=i.width&&s+l.height<=i.height,"texture.subimage write out of bounds"),ne(i.mipmask&1<<u,"missing mipmap data"),ne(l.data||l.element||l.needsCopy,"missing image data"),Q(i),M(l,pn,a,s,u),K(),L(l),o}function l(e,t){var r=0|e,a=0|t||r;if(r===i.width&&a===i.height)return o;o.width=i.width=r,o.height=i.height=a,Q(i);for(var s=0;i.mipmask>>s;++s){var l=r>>s,c=a>>s;if(!l||!c)break;n.texImage2D(pn,s,i.format,l,c,0,i.format,i.type,null)}return K(),u.profile&&(i.stats.size=$i(i.internalformat,i.type,r,a,!1,!1)),o}return Y[i.id]=i,s.textureCount++,o(e,t),o.subimage=a,o.resize=l,o._reglType="texture2d",o._texture=i,u.profile&&(o.stats=i.stats),o.destroy=function(){i.decRef()},o}function te(e,t,i,o,a,l){var c=new Z(mn);Y[c.id]=c,s.cubeCount++;var f=new Array(6);function h(e,t,n,i,o,a){var s,l=c.texInfo;for(G.call(l),s=0;s<6;++s)f[s]=V();if("number"!=typeof e&&e)if("object"==typeof e)if(t)R(f[0],e),R(f[1],t),R(f[2],n),R(f[3],i),R(f[4],o),R(f[5],a);else if(H(l,e),_(c,e),"faces"in e){var d=e.faces;for(ne(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),s=0;s<6;++s)ne("object"==typeof d[s]&&!!d[s],"invalid input for cube map face"),P(f[s],c),R(f[s],d[s])}else for(s=0;s<6;++s)R(f[s],e);else ne.raise("invalid arguments to cube map");else{var p=0|e||1;for(s=0;s<6;++s)N(f[s],p,p)}for(P(c,f[0]),ne.optional((function(){r.npotTextureCube||ne(hn(c.width)&&hn(c.height),"your browser does not support non power or two texture dimensions")})),l.genMipmaps?c.mipmask=(f[0].width<<1)-1:c.mipmask=f[0].mipmask,ne.textureCube(c,l,f,r),c.internalformat=f[0].internalformat,h.width=f[0].width,h.height=f[0].height,Q(c),s=0;s<6;++s)j(f[s],vn+s);for(W(l,mn),K(),u.profile&&(c.stats.size=$i(c.internalformat,c.type,h.width,h.height,l.genMipmaps,!0)),h.format=b[c.internalformat],h.type=x[c.type],h.mag=S[l.magFilter],h.min=w[l.minFilter],h.wrapS=k[l.wrapS],h.wrapT=k[l.wrapT],s=0;s<6;++s)U(f[s]);return h}function d(e,t,n,i,r){ne(!!t,"must specify image data"),ne("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var o=0|n,a=0|i,s=0|r,u=E();return P(u,c),u.width=0,u.height=0,I(u,t),u.width=u.width||(c.width>>s)-o,u.height=u.height||(c.height>>s)-a,ne(c.type===u.type&&c.format===u.format&&c.internalformat===u.internalformat,"incompatible format for texture.subimage"),ne(o>=0&&a>=0&&o+u.width<=c.width&&a+u.height<=c.height,"texture.subimage write out of bounds"),ne(c.mipmask&1<<s,"missing mipmap data"),ne(u.data||u.element||u.needsCopy,"missing image data"),Q(c),M(u,vn+e,o,a,s),K(),L(u),h}function p(e){var t=0|e;if(t!==c.width){h.width=c.width=t,h.height=c.height=t,Q(c);for(var i=0;i<6;++i)for(var r=0;c.mipmask>>r;++r)n.texImage2D(vn+i,r,c.format,t>>r,t>>r,0,c.format,c.type,null);return K(),u.profile&&(c.stats.size=$i(c.internalformat,c.type,h.width,h.height,!1,!0)),h}}return h(e,t,i,o,a,l),h.subimage=d,h.resize=p,h._reglType="textureCube",h._texture=c,u.profile&&(h.stats=c.stats),h.destroy=function(){c.decRef()},h}function ie(){for(var e=0;e<$;++e)n.activeTexture(bi+e),n.bindTexture(pn,null),X[e]=null;Ct(Y).forEach(J),s.cubeCount=0,s.textureCount=0}function re(){for(var e=0;e<$;++e){var t=X[e];t&&(t.bindCount=0,t.unit=-1,X[e]=null)}Ct(Y).forEach((function(e){e.texture=n.createTexture(),n.bindTexture(e.target,e.texture);for(var t=0;t<32;++t)if(0!=(e.mipmask&1<<t))if(e.target===pn)n.texImage2D(pn,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);else for(var i=0;i<6;++i)n.texImage2D(vn+i,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);W(e.texInfo,e.target)}))}function oe(){for(var e=0;e<$;++e){var t=X[e];t&&(t.bindCount=0,t.unit=-1,X[e]=null),n.activeTexture(bi+e),n.bindTexture(pn,null),n.bindTexture(mn,null)}}return t(Z.prototype,{bind:function(){var e=this;e.bindCount+=1;var t=e.unit;if(t<0){for(var i=0;i<$;++i){var r=X[i];if(r){if(r.bindCount>0)continue;r.unit=-1}X[i]=e,t=i;break}t>=$&&ne.raise("insufficient number of texture units"),u.profile&&s.maxTextureUnits<t+1&&(s.maxTextureUnits=t+1),e.unit=t,n.activeTexture(bi+t),n.bindTexture(e.target,e.texture)}return t},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&J(this)}}),u.profile&&(s.getTotalTextureSize=function(){var e=0;return Object.keys(Y).forEach((function(t){e+=Y[t].stats.size})),e}),{create2D:ee,createCube:te,clear:ie,getTexture:function(e){return null},restore:re,refresh:oe}}Mi[wn]=2,Mi[kn]=2,Mi[Cn]=2,Mi[In]=4,Mi[En]=.5,Mi[Ln]=.5,Mi[On]=1,Mi[Nn]=1,Mi[Rn]=.5,Mi[jn]=1,Mi[Bn]=1,Mi[Vn]=.5,Mi[Un]=.25,Mi[Gn]=.5,Mi[Hn]=.25,Mi[Wn]=.5;var Zi=36161,Qi=32854,Ki=32855,Ji=36194,er=33189,tr=36168,nr=34041,ir=35907,rr=34836,or=34842,ar=34843,sr=[];function ur(e,t,n){return sr[e]*t*n}sr[Qi]=2,sr[Ki]=2,sr[Ji]=2,sr[er]=2,sr[tr]=1,sr[nr]=4,sr[ir]=4,sr[rr]=16,sr[or]=8,sr[ar]=6;var lr=function(e,t,n,i,r){var o={rgba4:Qi,rgb565:Ji,"rgb5 a1":Ki,depth:er,stencil:tr,"depth stencil":nr};t.ext_srgb&&(o.srgba=ir),t.ext_color_buffer_half_float&&(o.rgba16f=or,o.rgb16f=ar),t.webgl_color_buffer_float&&(o.rgba32f=rr);var a=[];Object.keys(o).forEach((function(e){var t=o[e];a[t]=e}));var s=0,u={};function l(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=Qi,this.width=0,this.height=0,r.profile&&(this.stats={size:0})}function c(t){var n=t.renderbuffer;ne(n,"must not double destroy renderbuffer"),e.bindRenderbuffer(Zi,null),e.deleteRenderbuffer(n),t.renderbuffer=null,t.refCount=0,delete u[t.id],i.renderbufferCount--}function f(t,s){var c=new l(e.createRenderbuffer());function f(t,i){var s=0,u=0,l=Qi;if("object"==typeof t&&t){var h=t;if("shape"in h){var d=h.shape;ne(Array.isArray(d)&&d.length>=2,"invalid renderbuffer shape"),s=0|d[0],u=0|d[1]}else"radius"in h&&(s=u=0|h.radius),"width"in h&&(s=0|h.width),"height"in h&&(u=0|h.height);"format"in h&&(ne.parameter(h.format,o,"invalid renderbuffer format"),l=o[h.format])}else"number"==typeof t?(s=0|t,u="number"==typeof i?0|i:s):t?ne.raise("invalid arguments to renderbuffer constructor"):s=u=1;if(ne(s>0&&u>0&&s<=n.maxRenderbufferSize&&u<=n.maxRenderbufferSize,"invalid renderbuffer size"),s!==c.width||u!==c.height||l!==c.format)return f.width=c.width=s,f.height=c.height=u,c.format=l,e.bindRenderbuffer(Zi,c.renderbuffer),e.renderbufferStorage(Zi,l,s,u),ne(0===e.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=ur(c.format,c.width,c.height)),f.format=a[c.format],f}function h(t,i){var o=0|t,a=0|i||o;return o===c.width&&a===c.height||(ne(o>0&&a>0&&o<=n.maxRenderbufferSize&&a<=n.maxRenderbufferSize,"invalid renderbuffer size"),f.width=c.width=o,f.height=c.height=a,e.bindRenderbuffer(Zi,c.renderbuffer),e.renderbufferStorage(Zi,c.format,o,a),ne(0===e.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=ur(c.format,c.width,c.height))),f}return u[c.id]=c,i.renderbufferCount++,f(t,s),f.resize=h,f._reglType="renderbuffer",f._renderbuffer=c,r.profile&&(f.stats=c.stats),f.destroy=function(){c.decRef()},f}function h(){Ct(u).forEach((function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(Zi,t.renderbuffer),e.renderbufferStorage(Zi,t.format,t.width,t.height)})),e.bindRenderbuffer(Zi,null)}return l.prototype.decRef=function(){--this.refCount<=0&&c(this)},r.profile&&(i.getTotalRenderbufferSize=function(){var e=0;return Object.keys(u).forEach((function(t){e+=u[t].stats.size})),e}),{create:f,clear:function(){Ct(u).forEach(c)},restore:h}},cr=36160,fr=36161,hr=3553,dr=34069,pr=36064,mr=36096,vr=36128,gr=33306,yr=36053,br=36054,xr=36055,Sr=36057,wr=36061,kr=36193,Cr=5121,Tr=5126,Pr=6407,_r=6408,Ar=6402,zr=[Pr,_r],Ir=[];Ir[_r]=4,Ir[Pr]=3;var Dr=[];Dr[Cr]=1,Dr[Tr]=4,Dr[kr]=2;var Mr=33189,Fr=36168,Er=34041,Lr=[32854,32855,36194,35907,34842,34843,34836],Or={};function Nr(e,n,i,r,o,a){var s={cur:null,next:null,dirty:!1,setFBO:null},u=["rgba"],l=["rgba4","rgb565","rgb5 a1"];n.ext_srgb&&l.push("srgba"),n.ext_color_buffer_half_float&&l.push("rgba16f","rgb16f"),n.webgl_color_buffer_float&&l.push("rgba32f");var c=["uint8"];function f(e,t,n){this.target=e,this.texture=t,this.renderbuffer=n;var i=0,r=0;t?(i=t.width,r=t.height):n&&(i=n.width,r=n.height),this.width=i,this.height=r}function h(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function d(e,t,n){if(e)if(e.texture){var i=e.texture._texture,r=Math.max(1,i.width),o=Math.max(1,i.height);ne(r===t&&o===n,"inconsistent width/height for supplied texture"),i.refCount+=1}else{var a=e.renderbuffer._renderbuffer;ne(a.width===t&&a.height===n,"inconsistent width/height for renderbuffer"),a.refCount+=1}}function p(t,n){n&&(n.texture?e.framebufferTexture2D(cr,t,n.target,n.texture._texture.texture,0):e.framebufferRenderbuffer(cr,t,fr,n.renderbuffer._renderbuffer.renderbuffer))}function m(e){var t=hr,n=null,i=null,r=e;"object"==typeof e&&(r=e.data,"target"in e&&(t=0|e.target)),ne.type(r,"function","invalid attachment data");var o=r._reglType;return"texture2d"===o?(n=r,ne(t===hr)):"textureCube"===o?(n=r,ne(t>=dr&&t<dr+6,"invalid cube map target")):"renderbuffer"===o?(i=r,t=fr):ne.raise("invalid regl object for attachment"),new f(t,n,i)}function v(e,t,n,i,a){if(n){var s=r.create2D({width:e,height:t,format:i,type:a});return s._texture.refCount=0,new f(hr,s,null)}var u=o.create({width:e,height:t,format:i});return u._renderbuffer.refCount=0,new f(fr,null,u)}function g(e){return e&&(e.texture||e.renderbuffer)}function y(e,t,n){e&&(e.texture?e.texture.resize(t,n):e.renderbuffer&&e.renderbuffer.resize(t,n),e.width=t,e.height=n)}n.oes_texture_half_float&&c.push("half float","float16"),n.oes_texture_float&&c.push("float","float32");var b=0,x={};function S(){this.id=b++,x[this.id]=this,this.framebuffer=e.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function w(e){e.colorAttachments.forEach(h),h(e.depthAttachment),h(e.stencilAttachment),h(e.depthStencilAttachment)}function k(t){var n=t.framebuffer;ne(n,"must not double destroy framebuffer"),e.deleteFramebuffer(n),t.framebuffer=null,a.framebufferCount--,delete x[t.id]}function C(t){var n;e.bindFramebuffer(cr,t.framebuffer);var r=t.colorAttachments;for(n=0;n<r.length;++n)p(pr+n,r[n]);for(n=r.length;n<i.maxColorAttachments;++n)e.framebufferTexture2D(cr,pr+n,hr,null,0);e.framebufferTexture2D(cr,gr,hr,null,0),e.framebufferTexture2D(cr,mr,hr,null,0),e.framebufferTexture2D(cr,vr,hr,null,0),p(mr,t.depthAttachment),p(vr,t.stencilAttachment),p(gr,t.depthStencilAttachment);var o=e.checkFramebufferStatus(cr);e.isContextLost()||o===yr||ne.raise("framebuffer configuration not supported, status = "+Or[o]),e.bindFramebuffer(cr,s.next?s.next.framebuffer:null),s.cur=s.next,e.getError()}function T(e,r){var o=new S;function f(e,t){var r;ne(s.next!==o,"can not update framebuffer which is currently in use");var a=0,h=0,p=!0,y=!0,b=null,x=!0,S="rgba",k="uint8",T=1,P=null,_=null,A=null,z=!1;if("number"==typeof e)a=0|e,h=0|t||a;else if(e){ne.type(e,"object","invalid arguments for framebuffer");var I=e;if("shape"in I){var D=I.shape;ne(Array.isArray(D)&&D.length>=2,"invalid shape for framebuffer"),a=D[0],h=D[1]}else"radius"in I&&(a=h=I.radius),"width"in I&&(a=I.width),"height"in I&&(h=I.height);("color"in I||"colors"in I)&&(b=I.color||I.colors,Array.isArray(b)&&ne(1===b.length||n.webgl_draw_buffers,"multiple render targets not supported")),b||("colorCount"in I&&(T=0|I.colorCount,ne(T>0,"invalid color buffer count")),"colorTexture"in I&&(x=!!I.colorTexture,S="rgba4"),"colorType"in I&&(k=I.colorType,x?(ne(n.oes_texture_float||!("float"===k||"float32"===k),"you must enable OES_texture_float in order to use floating point framebuffer objects"),ne(n.oes_texture_half_float||!("half float"===k||"float16"===k),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===k||"float16"===k?(ne(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),S="rgba16f"):"float"!==k&&"float32"!==k||(ne(n.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),S="rgba32f"),ne.oneOf(k,c,"invalid color type")),"colorFormat"in I&&(S=I.colorFormat,u.indexOf(S)>=0?x=!0:l.indexOf(S)>=0?x=!1:ne.optional((function(){x?ne.oneOf(I.colorFormat,u,"invalid color format for texture"):ne.oneOf(I.colorFormat,l,"invalid color format for renderbuffer")})))),("depthTexture"in I||"depthStencilTexture"in I)&&(z=!(!I.depthTexture&&!I.depthStencilTexture),ne(!z||n.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in I&&("boolean"==typeof I.depth?p=I.depth:(P=I.depth,y=!1)),"stencil"in I&&("boolean"==typeof I.stencil?y=I.stencil:(_=I.stencil,p=!1)),"depthStencil"in I&&("boolean"==typeof I.depthStencil?p=y=I.depthStencil:(A=I.depthStencil,p=!1,y=!1))}else a=h=1;var M=null,F=null,E=null,L=null;if(Array.isArray(b))M=b.map(m);else if(b)M=[m(b)];else for(M=new Array(T),r=0;r<T;++r)M[r]=v(a,h,x,S,k);ne(n.webgl_draw_buffers||M.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),ne(M.length<=i.maxColorAttachments,"too many color attachments, not supported"),a=a||M[0].width,h=h||M[0].height,P?F=m(P):p&&!y&&(F=v(a,h,z,"depth","uint32")),_?E=m(_):y&&!p&&(E=v(a,h,!1,"stencil","uint8")),A?L=m(A):!P&&!_&&y&&p&&(L=v(a,h,z,"depth stencil","depth stencil")),ne(!!P+!!_+!!A<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var O=null;for(r=0;r<M.length;++r)if(d(M[r],a,h),ne(!M[r]||M[r].texture&&zr.indexOf(M[r].texture._texture.format)>=0||M[r].renderbuffer&&Lr.indexOf(M[r].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+r+" is invalid"),M[r]&&M[r].texture){var N=Ir[M[r].texture._texture.format]*Dr[M[r].texture._texture.type];null===O?O=N:ne(O===N,"all color attachments much have the same number of bits per pixel.")}return d(F,a,h),ne(!F||F.texture&&F.texture._texture.format===Ar||F.renderbuffer&&F.renderbuffer._renderbuffer.format===Mr,"invalid depth attachment for framebuffer object"),d(E,a,h),ne(!E||E.renderbuffer&&E.renderbuffer._renderbuffer.format===Fr,"invalid stencil attachment for framebuffer object"),d(L,a,h),ne(!L||L.texture&&L.texture._texture.format===Er||L.renderbuffer&&L.renderbuffer._renderbuffer.format===Er,"invalid depth-stencil attachment for framebuffer object"),w(o),o.width=a,o.height=h,o.colorAttachments=M,o.depthAttachment=F,o.stencilAttachment=E,o.depthStencilAttachment=L,f.color=M.map(g),f.depth=g(F),f.stencil=g(E),f.depthStencil=g(L),f.width=o.width,f.height=o.height,C(o),f}function h(e,t){ne(s.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|e,1),i=Math.max(0|t||n,1);if(n===o.width&&i===o.height)return f;for(var r=o.colorAttachments,a=0;a<r.length;++a)y(r[a],n,i);return y(o.depthAttachment,n,i),y(o.stencilAttachment,n,i),y(o.depthStencilAttachment,n,i),o.width=f.width=n,o.height=f.height=i,C(o),f}return a.framebufferCount++,f(e,r),t(f,{resize:h,_reglType:"framebuffer",_framebuffer:o,destroy:function(){k(o),w(o)},use:function(e){s.setFBO({framebuffer:f},e)}})}function P(e){var o=Array(6);function a(e){var i;ne(o.indexOf(s.next)<0,"can not update framebuffer which is currently in use");var l,f={color:null},h=0,d=null,p="rgba",m="uint8",v=1;if("number"==typeof e)h=0|e;else if(e){ne.type(e,"object","invalid arguments for framebuffer");var g=e;if("shape"in g){var y=g.shape;ne(Array.isArray(y)&&y.length>=2,"invalid shape for framebuffer"),ne(y[0]===y[1],"cube framebuffer must be square"),h=y[0]}else"radius"in g&&(h=0|g.radius),"width"in g?(h=0|g.width,"height"in g&&ne(g.height===h,"must be square")):"height"in g&&(h=0|g.height);("color"in g||"colors"in g)&&(d=g.color||g.colors,Array.isArray(d)&&ne(1===d.length||n.webgl_draw_buffers,"multiple render targets not supported")),d||("colorCount"in g&&(v=0|g.colorCount,ne(v>0,"invalid color buffer count")),"colorType"in g&&(ne.oneOf(g.colorType,c,"invalid color type"),m=g.colorType),"colorFormat"in g&&(p=g.colorFormat,ne.oneOf(g.colorFormat,u,"invalid color format for texture"))),"depth"in g&&(f.depth=g.depth),"stencil"in g&&(f.stencil=g.stencil),"depthStencil"in g&&(f.depthStencil=g.depthStencil)}else h=1;if(d)if(Array.isArray(d))for(l=[],i=0;i<d.length;++i)l[i]=d[i];else l=[d];else{l=Array(v);var b={radius:h,format:p,type:m};for(i=0;i<v;++i)l[i]=r.createCube(b)}for(f.color=Array(l.length),i=0;i<l.length;++i){var x=l[i];ne("function"==typeof x&&"textureCube"===x._reglType,"invalid cube map"),h=h||x.width,ne(x.width===h&&x.height===h,"invalid cube map shape"),f.color[i]={target:dr,data:l[i]}}for(i=0;i<6;++i){for(var S=0;S<l.length;++S)f.color[S].target=dr+i;i>0&&(f.depth=o[0].depth,f.stencil=o[0].stencil,f.depthStencil=o[0].depthStencil),o[i]?o[i](f):o[i]=T(f)}return t(a,{width:h,height:h,color:l})}function l(e){var t,n=0|e;if(ne(n>0&&n<=i.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var r=a.color;for(t=0;t<r.length;++t)r[t].resize(n);for(t=0;t<6;++t)o[t].resize(n);return a.width=a.height=n,a}return a(e),t(a,{faces:o,resize:l,_reglType:"framebufferCube",destroy:function(){o.forEach((function(e){e.destroy()}))}})}function _(){s.cur=null,s.next=null,s.dirty=!0,Ct(x).forEach((function(t){t.framebuffer=e.createFramebuffer(),C(t)}))}return t(s,{getFramebuffer:function(e){if("function"==typeof e&&"framebuffer"===e._reglType){var t=e._framebuffer;if(t instanceof S)return t}return null},create:T,createCube:P,clear:function(){Ct(x).forEach(k)},restore:_})}Or[yr]="complete",Or[br]="incomplete attachment",Or[Sr]="incomplete dimensions",Or[xr]="incomplete, missing attachment",Or[wr]="unsupported";var Rr=5126,jr=34962,Br=34963,Vr=["attributes","elements","offset","count","primitive","instances"];function Ur(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Rr,this.offset=0,this.stride=0,this.divisor=0}function Gr(t,n,i,r,o,a,s){for(var u=i.maxAttributes,l=new Array(u),c=0;c<u;++c)l[c]=new Ur;var f=0,h={},d={Record:Ur,scope:{},state:l,currentVAO:null,targetVAO:null,restore:m()?w:function(){},createVAO:k,getVAO:g,destroyBuffer:p,setVAO:m()?y:b,clear:m()?x:function(){}};function p(e){for(var n=0;n<l.length;++n){var i=l[n];i.buffer===e&&(t.disableVertexAttribArray(n),i.buffer=null)}}function m(){return n.oes_vertex_array_object}function v(){return n.angle_instanced_arrays}function g(e){return"function"==typeof e&&e._vao?e._vao:null}function y(e){if(e!==d.currentVAO){var t=m();e?t.bindVertexArrayOES(e.vao):t.bindVertexArrayOES(null),d.currentVAO=e}}function b(e){if(e!==d.currentVAO){if(e)e.bindAttrs();else{for(var n=v(),i=0;i<l.length;++i){var r=l[i];r.buffer?(t.enableVertexAttribArray(i),r.buffer.bind(),t.vertexAttribPointer(i,r.size,r.type,r.normalized,r.stride,r.offfset),n&&r.divisor&&n.vertexAttribDivisorANGLE(i,r.divisor)):(t.disableVertexAttribArray(i),t.vertexAttrib4f(i,r.x,r.y,r.z,r.w))}s.elements?t.bindBuffer(Br,s.elements.buffer.buffer):t.bindBuffer(Br,null)}d.currentVAO=e}}function x(){Ct(h).forEach((function(e){e.destroy()}))}function S(){this.id=++f,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var e=m();this.vao=e?e.createVertexArrayOES():null,h[this.id]=this,this.buffers=[]}function w(){m()&&Ct(h).forEach((function(e){e.refresh()}))}function k(t){var i=new S;function s(t){var r;if(Array.isArray(t))r=t,i.elements&&i.ownsElements&&i.elements.destroy(),i.elements=null,i.ownsElements=!1,i.offset=0,i.count=0,i.instances=-1,i.primitive=4;else{if(ne("object"==typeof t,"invalid arguments for create vao"),ne("attributes"in t,"must specify attributes for vao"),t.elements){var l=t.elements;i.ownsElements?"function"==typeof l&&"elements"===l._reglType?(i.elements.destroy(),i.ownsElements=!1):(i.elements(l),i.ownsElements=!1):a.getElements(t.elements)?(i.elements=t.elements,i.ownsElements=!1):(i.elements=a.create(t.elements),i.ownsElements=!0)}else i.elements=null,i.ownsElements=!1;r=t.attributes,i.offset=0,i.count=-1,i.instances=-1,i.primitive=4,i.elements&&(i.count=i.elements._elements.vertCount,i.primitive=i.elements._elements.primType),"offset"in t&&(i.offset=0|t.offset),"count"in t&&(i.count=0|t.count),"instances"in t&&(i.instances=0|t.instances),"primitive"in t&&(ne(t.primitive in qt,"bad primitive type: "+t.primitive),i.primitive=qt[t.primitive]),ne.optional((()=>{for(var e=Object.keys(t),n=0;n<e.length;++n)ne(Vr.indexOf(e[n])>=0,'invalid option for vao: "'+e[n]+'" valid options are '+Vr)})),ne(Array.isArray(r),"attributes must be an array")}ne(r.length<u,"too many attributes"),ne(r.length>0,"must specify at least one attribute");var c={},f=i.attributes;f.length=r.length;for(var h=0;h<r.length;++h){var d,p=r[h],m=f[h]=new Ur,v=p.data||p;Array.isArray(v)||e(v)||kt(v)?(i.buffers[h]&&(d=i.buffers[h],e(v)&&d._buffer.byteLength>=v.byteLength?d.subdata(v):(d.destroy(),i.buffers[h]=null)),i.buffers[h]||(d=i.buffers[h]=o.create(p,jr,!1,!0)),m.buffer=o.getBuffer(d),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1,c[h]=1):o.getBuffer(p)?(m.buffer=o.getBuffer(p),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1):o.getBuffer(p.buffer)?(m.buffer=o.getBuffer(p.buffer),m.size=0|(+p.size||m.buffer.dimension),m.normalized=!!p.normalized||!1,"type"in p?(ne.parameter(p.type,Ft,"invalid buffer type"),m.type=Ft[p.type]):m.type=m.buffer.dtype,m.offset=0|(p.offset||0),m.stride=0|(p.stride||0),m.divisor=0|(p.divisor||0),m.state=1,ne(m.size>=1&&m.size<=4,"size must be between 1 and 4"),ne(m.offset>=0,"invalid offset"),ne(m.stride>=0&&m.stride<=255,"stride must be between 0 and 255"),ne(m.divisor>=0,"divisor must be positive"),ne(!m.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(ne(h>0,"first attribute must not be a constant"),m.x=+p.x||0,m.y=+p.y||0,m.z=+p.z||0,m.w=+p.w||0,m.state=2):ne(!1,"invalid attribute spec for location "+h)}for(var g=0;g<i.buffers.length;++g)!c[g]&&i.buffers[g]&&(i.buffers[g].destroy(),i.buffers[g]=null);return i.refresh(),s}return r.vaoCount+=1,s.destroy=function(){for(var e=0;e<i.buffers.length;++e)i.buffers[e]&&i.buffers[e].destroy();i.buffers.length=0,i.ownsElements&&(i.elements.destroy(),i.elements=null,i.ownsElements=!1),i.destroy()},s._vao=i,s._reglType="vao",s(t)}return S.prototype.bindAttrs=function(){for(var e=v(),n=this.attributes,i=0;i<n.length;++i){var r=n[i];r.buffer?(t.enableVertexAttribArray(i),t.bindBuffer(jr,r.buffer.buffer),t.vertexAttribPointer(i,r.size,r.type,r.normalized,r.stride,r.offset),e&&r.divisor&&e.vertexAttribDivisorANGLE(i,r.divisor)):(t.disableVertexAttribArray(i),t.vertexAttrib4f(i,r.x,r.y,r.z,r.w))}for(var o=n.length;o<u;++o)t.disableVertexAttribArray(o);var s=a.getElements(this.elements);s?t.bindBuffer(Br,s.buffer.buffer):t.bindBuffer(Br,null)},S.prototype.refresh=function(){var e=m();e&&(e.bindVertexArrayOES(this.vao),this.bindAttrs(),d.currentVAO=null,e.bindVertexArrayOES(null))},S.prototype.destroy=function(){if(this.vao){var e=m();this===d.currentVAO&&(d.currentVAO=null,e.bindVertexArrayOES(null)),e.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),h[this.id]&&(delete h[this.id],r.vaoCount-=1)},d}var Hr=35632,Wr=35633,qr=35718,Yr=35721;function $r(e,n,i,r){var o={},a={};function s(e,t,n,i){this.name=e,this.id=t,this.location=n,this.info=i}function u(e,t){for(var n=0;n<e.length;++n)if(e[n].id===t.id)return void(e[n].location=t.location);e.push(t)}function l(t,i,r){var s=t===Hr?o:a,u=s[i];if(!u){var l=n.str(i);u=e.createShader(t),e.shaderSource(u,l),e.compileShader(u),ne.shaderError(e,u,l,t,r),s[i]=u}return u}var c={},f=[],h=0;function d(e,t){this.id=h++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,r.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function p(t,i,o){var a,c,f=l(Hr,t.fragId),h=l(Wr,t.vertId),d=t.program=e.createProgram();if(e.attachShader(d,f),e.attachShader(d,h),o)for(a=0;a<o.length;++a){var p=o[a];e.bindAttribLocation(d,p[0],p[1])}e.linkProgram(d),ne.linkError(e,d,n.str(t.fragId),n.str(t.vertId),i);var m=e.getProgramParameter(d,qr);r.profile&&(t.stats.uniformsCount=m);var v=t.uniforms;for(a=0;a<m;++a)if(c=e.getActiveUniform(d,a)){if(c.size>1)for(var g=0;g<c.size;++g){var y=c.name.replace("[0]","["+g+"]");u(v,new s(y,n.id(y),e.getUniformLocation(d,y),c))}var b=c.name;c.size>1&&(b=b.replace("[0]","")),u(v,new s(b,n.id(b),e.getUniformLocation(d,b),c))}var x=e.getProgramParameter(d,Yr);r.profile&&(t.stats.attributesCount=x);var S=t.attributes;for(a=0;a<x;++a)(c=e.getActiveAttrib(d,a))&&u(S,new s(c.name,n.id(c.name),e.getAttribLocation(d,c.name),c))}function m(){o={},a={};for(var e=0;e<f.length;++e)p(f[e],null,f[e].attributes.map((function(e){return[e.location,e.name]})))}return r.profile&&(i.getMaxUniformsCount=function(){var e=0;return f.forEach((function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)})),e},i.getMaxAttributesCount=function(){var e=0;return f.forEach((function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)})),e}),{clear:function(){var t=e.deleteShader.bind(e);Ct(o).forEach(t),o={},Ct(a).forEach(t),a={},f.forEach((function(t){e.deleteProgram(t.program)})),f.length=0,c={},i.shaderCount=0},program:function(n,r,s,u){ne.command(n>=0,"missing vertex shader",s),ne.command(r>=0,"missing fragment shader",s);var l=c[r];l||(l=c[r]={});var h=l[n];if(h&&(h.refCount++,!u))return h;var m=new d(r,n);return i.shaderCount++,p(m,s,u),h||(l[n]=m),f.push(m),t(m,{destroy:function(){if(m.refCount--,m.refCount<=0){e.deleteProgram(m.program);var t=f.indexOf(m);f.splice(t,1),i.shaderCount--}l[m.vertId].refCount<=0&&(e.deleteShader(a[m.vertId]),delete a[m.vertId],delete c[m.fragId][m.vertId]),Object.keys(c[m.fragId]).length||(e.deleteShader(o[m.fragId]),delete o[m.fragId],delete c[m.fragId])}})},restore:m,shader:l,frag:-1,vert:-1}}var Xr=6408,Zr=5121,Qr=3333,Kr=5126;function Jr(t,n,i,r,o,a,s){function u(u){var l;null===n.next?(ne(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),l=Zr):(ne(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),l=n.next.colorAttachments[0].texture._texture.type,ne.optional((function(){a.oes_texture_float?(ne(l===Zr||l===Kr,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),l===Kr&&ne(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):ne(l===Zr,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var c=0,f=0,h=r.framebufferWidth,d=r.framebufferHeight,p=null;e(u)?p=u:u&&(ne.type(u,"object","invalid arguments to regl.read()"),c=0|u.x,f=0|u.y,ne(c>=0&&c<r.framebufferWidth,"invalid x offset for regl.read"),ne(f>=0&&f<r.framebufferHeight,"invalid y offset for regl.read"),h=0|(u.width||r.framebufferWidth-c),d=0|(u.height||r.framebufferHeight-f),p=u.data||null),p&&(l===Zr?ne(p instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):l===Kr&&ne(p instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),ne(h>0&&h+c<=r.framebufferWidth,"invalid width for read pixels"),ne(d>0&&d+f<=r.framebufferHeight,"invalid height for read pixels"),i();var m=h*d*4;return p||(l===Zr?p=new Uint8Array(m):l===Kr&&(p=p||new Float32Array(m))),ne.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),ne(p.byteLength>=m,"data buffer for regl.read() too small"),t.pixelStorei(Qr,4),t.readPixels(c,f,h,d,Xr,l,p),p}function l(e){var t;return n.setFBO({framebuffer:e.framebuffer},(function(){t=u(e)})),t}function c(e){return e&&"framebuffer"in e?l(e):u(e)}return c}function eo(e){return Array.prototype.slice.call(e)}function to(e){return eo(e).join("")}function no(){var e=0,n=[],i=[];function r(t){for(var r=0;r<i.length;++r)if(i[r]===t)return n[r];var o="g"+e++;return n.push(o),i.push(t),o}function o(){var n=[];function i(){n.push.apply(n,eo(arguments))}var r=[];function o(){var t="v"+e++;return r.push(t),arguments.length>0&&(n.push(t,"="),n.push.apply(n,eo(arguments)),n.push(";")),t}return t(i,{def:o,toString:function(){return to([r.length>0?"var "+r.join(",")+";":"",to(n)])}})}function a(){var e=o(),n=o(),i=e.toString,r=n.toString;function a(t,i){n(t,i,"=",e.def(t,i),";")}return t((function(){e.apply(e,eo(arguments))}),{def:e.def,entry:e,exit:n,save:a,set:function(t,n,i){a(t,n),e(t,n,"=",i,";")},toString:function(){return i()+r()}})}function s(){var e=to(arguments),n=a(),i=a(),r=n.toString,o=i.toString;return t(n,{then:function(){return n.apply(n,eo(arguments)),this},else:function(){return i.apply(i,eo(arguments)),this},toString:function(){var t=o();return t&&(t="else{"+t+"}"),to(["if(",e,"){",r(),"}",t])}})}var u=o(),l={};function c(e,n){var i=[];function r(){var e="a"+i.length;return i.push(e),e}n=n||0;for(var o=0;o<n;++o)r();var s=a(),u=s.toString;return l[e]=t(s,{arg:r,toString:function(){return to(["function(",i.join(),"){",u(),"}"])}})}function f(){var e=['"use strict";',u,"return {"];Object.keys(l).forEach((function(t){e.push('"',t,'":',l[t].toString(),",")})),e.push("}");var t=to(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,n.concat(t)).apply(null,i)}return{global:u,link:r,block:o,proc:c,scope:a,cond:s,compile:f}}var io="xyzw".split(""),ro=5121,oo=1,ao=2,so=0,uo=1,lo=2,co=3,fo=4,ho=5,po=6,mo="dither",vo="blend.enable",go="blend.color",yo="blend.equation",bo="blend.func",xo="depth.enable",So="depth.func",wo="depth.range",ko="depth.mask",Co="colorMask",To="cull.enable",Po="cull.face",_o="frontFace",Ao="lineWidth",zo="polygonOffset.enable",Io="polygonOffset.offset",Do="sample.alpha",Mo="sample.enable",Fo="sample.coverage",Eo="stencil.enable",Lo="stencil.mask",Oo="stencil.func",No="stencil.opFront",Ro="stencil.opBack",jo="scissor.enable",Bo="scissor.box",Vo="viewport",Uo="profile",Go="framebuffer",Ho="vert",Wo="frag",qo="elements",Yo="primitive",$o="count",Xo="offset",Zo="instances",Qo="vao",Ko="Width",Jo="Height",ea=Go+Ko,ta=Go+Jo,na=Vo+Ko,ia=Vo+Jo,ra="drawingBuffer",oa=ra+Ko,aa=ra+Jo,sa=[bo,yo,Oo,No,Ro,Fo,Vo,Bo,Io],ua=34962,la=34963,ca=3553,fa=34067,ha=2884,da=3042,pa=3024,ma=2960,va=2929,ga=3089,ya=32823,ba=32926,xa=32928,Sa=5126,wa=35664,ka=35665,Ca=35666,Ta=5124,Pa=35667,_a=35668,Aa=35669,za=35670,Ia=35671,Da=35672,Ma=35673,Fa=35674,Ea=35675,La=35676,Oa=35678,Na=35680,Ra=4,ja=1028,Ba=1029,Va=2304,Ua=2305,Ga=32775,Ha=32776,Wa=519,qa=7680,Ya=0,$a=1,Xa=32774,Za=513,Qa=36160,Ka=36064,Ja={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},es=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],ts={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},ns={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},is={frag:35632,vert:35633},rs={cw:Va,ccw:Ua};function os(t){return Array.isArray(t)||e(t)||kt(t)}function as(e){return e.sort((function(e,t){return e===Vo?-1:t===Vo?1:e<t?-1:1}))}function ss(e,t,n,i){this.thisDep=e,this.contextDep=t,this.propDep=n,this.append=i}function us(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function ls(e){return new ss(!1,!1,!1,e)}function cs(e,t){var n=e.type;if(n===so){var i=e.data.length;return new ss(!0,i>=1,i>=2,t)}if(n===fo){var r=e.data;return new ss(r.thisDep,r.contextDep,r.propDep,t)}if(n===ho)return new ss(!1,!1,!1,t);if(n===po){for(var o=!1,a=!1,s=!1,u=0;u<e.data.length;++u){var l=e.data[u];if(l.type===uo)s=!0;else if(l.type===lo)a=!0;else if(l.type===co)o=!0;else if(l.type===so){o=!0;var c=l.data;c>=1&&(a=!0),c>=2&&(s=!0)}else l.type===fo&&(o=o||l.data.thisDep,a=a||l.data.contextDep,s=s||l.data.propDep)}return new ss(o,a,s,t)}return new ss(n===co,n===lo,n===uo,t)}var fs=new ss(!1,!1,!1,(function(){}));function hs(e,n,i,r,o,a,s,u,l,c,f,h,d,p,m){var v=c.Record,g={add:32774,subtract:32778,"reverse subtract":32779};i.ext_blend_minmax&&(g.min=Ga,g.max=Ha);var y=i.angle_instanced_arrays,b=i.webgl_draw_buffers,x=i.oes_vertex_array_object,S={dirty:!0,profile:m.profile},w={},k=[],C={},T={};function P(e){return e.replace(".","_")}function _(e,t,n){var i=P(e);k.push(e),w[i]=S[i]=!!n,C[i]=t}function A(e,t,n){var i=P(e);k.push(e),Array.isArray(n)?(S[i]=n.slice(),w[i]=n.slice()):S[i]=w[i]=n,T[i]=t}_(mo,pa),_(vo,da),A(go,"blendColor",[0,0,0,0]),A(yo,"blendEquationSeparate",[Xa,Xa]),A(bo,"blendFuncSeparate",[$a,Ya,$a,Ya]),_(xo,va,!0),A(So,"depthFunc",Za),A(wo,"depthRange",[0,1]),A(ko,"depthMask",!0),A(Co,Co,[!0,!0,!0,!0]),_(To,ha),A(Po,"cullFace",Ba),A(_o,_o,Ua),A(Ao,Ao,1),_(zo,ya),A(Io,"polygonOffset",[0,0]),_(Do,ba),_(Mo,xa),A(Fo,"sampleCoverage",[1,!1]),_(Eo,ma),A(Lo,"stencilMask",-1),A(Oo,"stencilFunc",[Wa,0,-1]),A(No,"stencilOpSeparate",[ja,qa,qa,qa]),A(Ro,"stencilOpSeparate",[Ba,qa,qa,qa]),_(jo,ga),A(Bo,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),A(Vo,Vo,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var z={gl:e,context:d,strings:n,next:w,current:S,draw:h,elements:a,buffer:o,shader:f,attributes:c.state,vao:c,uniforms:l,framebuffer:u,extensions:i,timer:p,isBufferArgs:os},I={primTypes:qt,compareFuncs:ts,blendFuncs:Ja,blendEquations:g,stencilOps:ns,glTypes:Ft,orientationType:rs};ne.optional((function(){z.isArrayLike=fn})),b&&(I.backBuffer=[Ba],I.drawBuffer=Pe(r.maxDrawbuffers,(function(e){return 0===e?[0]:Pe(e,(function(e){return Ka+e}))})));var D=0;function M(){var e=no(),t=e.link,i=e.global;e.id=D++,e.batchId="0";var r=t(z),o=e.shared={props:"a0"};Object.keys(z).forEach((function(e){o[e]=i.def(r,".",e)})),ne.optional((function(){e.CHECK=t(ne),e.commandStr=ne.guessCommand(),e.command=t(e.commandStr),e.assert=function(e,n,i){e("if(!(",n,"))",this.CHECK,".commandRaise(",t(i),",",this.command,");")},I.invalidBlendCombinations=es}));var a=e.next={},s=e.current={};Object.keys(T).forEach((function(e){Array.isArray(S[e])&&(a[e]=i.def(o.next,".",e),s[e]=i.def(o.current,".",e))}));var u=e.constants={};Object.keys(I).forEach((function(e){u[e]=i.def(JSON.stringify(I[e]))})),e.invoke=function(n,i){switch(i.type){case so:var r=["this",o.context,o.props,e.batchId];return n.def(t(i.data),".call(",r.slice(0,Math.max(i.data.length+1,4)),")");case uo:return n.def(o.props,i.data);case lo:return n.def(o.context,i.data);case co:return n.def("this",i.data);case fo:return i.data.append(e,n),i.data.ref;case ho:return i.data.toString();case po:return i.data.map((function(t){return e.invoke(n,t)}))}},e.attribCache={};var l={};return e.scopeAttrib=function(e){var i=n.id(e);if(i in l)return l[i];var r=c.scope[i];return r||(r=c.scope[i]=new v),l[i]=t(r)},e}function F(e){var t,n=e.static,i=e.dynamic;if(Uo in n){var r=!!n[Uo];(t=ls((function(e,t){return r}))).enable=r}else if(Uo in i){var o=i[Uo];t=cs(o,(function(e,t){return e.invoke(t,o)}))}return t}function E(e,t){var n=e.static,i=e.dynamic;if(Go in n){var r=n[Go];return r?(r=u.getFramebuffer(r),ne.command(r,"invalid framebuffer object"),ls((function(e,t){var n=e.link(r),i=e.shared;t.set(i.framebuffer,".next",n);var o=i.context;return t.set(o,"."+ea,n+".width"),t.set(o,"."+ta,n+".height"),n}))):ls((function(e,t){var n=e.shared;t.set(n.framebuffer,".next","null");var i=n.context;return t.set(i,"."+ea,i+"."+oa),t.set(i,"."+ta,i+"."+aa),"null"}))}if(Go in i){var o=i[Go];return cs(o,(function(e,t){var n=e.invoke(t,o),i=e.shared,r=i.framebuffer,a=t.def(r,".getFramebuffer(",n,")");ne.optional((function(){e.assert(t,"!"+n+"||"+a,"invalid framebuffer object")})),t.set(r,".next",a);var s=i.context;return t.set(s,"."+ea,a+"?"+a+".width:"+s+"."+oa),t.set(s,"."+ta,a+"?"+a+".height:"+s+"."+aa),a}))}return null}function L(e,t,n){var i=e.static,r=e.dynamic;function o(e){if(e in i){var o=i[e];ne.commandType(o,"object","invalid "+e,n.commandStr);var a,s,u=!0,l=0|o.x,c=0|o.y;return"width"in o?(a=0|o.width,ne.command(a>=0,"invalid "+e,n.commandStr)):u=!1,"height"in o?(s=0|o.height,ne.command(s>=0,"invalid "+e,n.commandStr)):u=!1,new ss(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,(function(e,t){var n=e.shared.context,i=a;"width"in o||(i=t.def(n,".",ea,"-",l));var r=s;return"height"in o||(r=t.def(n,".",ta,"-",c)),[l,c,i,r]}))}if(e in r){var f=r[e],h=cs(f,(function(t,n){var i=t.invoke(n,f);ne.optional((function(){t.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+e)}));var r=t.shared.context,o=n.def(i,".x|0"),a=n.def(i,".y|0"),s=n.def('"width" in ',i,"?",i,".width|0:","(",r,".",ea,"-",o,")"),u=n.def('"height" in ',i,"?",i,".height|0:","(",r,".",ta,"-",a,")");return ne.optional((function(){t.assert(n,s+">=0&&"+u+">=0","invalid "+e)})),[o,a,s,u]}));return t&&(h.thisDep=h.thisDep||t.thisDep,h.contextDep=h.contextDep||t.contextDep,h.propDep=h.propDep||t.propDep),h}return t?new ss(t.thisDep,t.contextDep,t.propDep,(function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",ea),t.def(n,".",ta)]})):null}var a=o(Vo);if(a){var s=a;a=new ss(a.thisDep,a.contextDep,a.propDep,(function(e,t){var n=s.append(e,t),i=e.shared.context;return t.set(i,"."+na,n[2]),t.set(i,"."+ia,n[3]),n}))}return{viewport:a,scissor_box:o(Bo)}}function O(e,t){var n=e.static;if("string"==typeof n[Wo]&&"string"==typeof n[Ho]){if(Object.keys(t.dynamic).length>0)return null;var i=t.static,r=Object.keys(i);if(r.length>0&&"number"==typeof i[r[0]]){for(var o=[],a=0;a<r.length;++a)ne("number"==typeof i[r[a]],"must specify all vertex attribute locations when using vaos"),o.push([0|i[r[a]],r[a]]);return o}}return null}function N(e,t,i){var r=e.static,o=e.dynamic;function a(e){if(e in r){var t=n.id(r[e]);ne.optional((function(){f.shader(is[e],t,ne.guessCommand())}));var i=ls((function(){return t}));return i.id=t,i}if(e in o){var a=o[e];return cs(a,(function(t,n){var i=t.invoke(n,a),r=n.def(t.shared.strings,".id(",i,")");return ne.optional((function(){n(t.shared.shader,".shader(",is[e],",",r,",",t.command,");")})),r}))}return null}var s,u=a(Wo),l=a(Ho),c=null;return us(u)&&us(l)?(c=f.program(l.id,u.id,null,i),s=ls((function(e,t){return e.link(c)}))):s=new ss(u&&u.thisDep||l&&l.thisDep,u&&u.contextDep||l&&l.contextDep,u&&u.propDep||l&&l.propDep,(function(e,t){var n,i=e.shared.shader;n=u?u.append(e,t):t.def(i,".",Wo);var r=i+".program("+(l?l.append(e,t):t.def(i,".",Ho))+","+n;return ne.optional((function(){r+=","+e.command})),t.def(r+")")})),{frag:u,vert:l,progVar:s,program:c}}function R(e,t){var n=e.static,i=e.dynamic,r={},o=!1;function s(){if(Qo in n){var e=n[Qo];return null!==e&&null===c.getVAO(e)&&(e=c.createVAO(e)),o=!0,r.vao=e,ls((function(t){var n=c.getVAO(e);return n?t.link(n):"null"}))}if(Qo in i){o=!0;var t=i[Qo];return cs(t,(function(e,n){var i=e.invoke(n,t);return n.def(e.shared.vao+".getVAO("+i+")")}))}return null}var u=s(),l=!1;function f(){if(qo in n){var e=n[qo];if(r.elements=e,os(e)){var s=r.elements=a.create(e,!0);e=a.getElements(s),l=!0}else e&&(e=a.getElements(e),l=!0,ne.command(e,"invalid elements",t.commandStr));var c=ls((function(t,n){if(e){var i=t.link(e);return t.ELEMENTS=i,i}return t.ELEMENTS=null,null}));return c.value=e,c}if(qo in i){l=!0;var f=i[qo];return cs(f,(function(e,t){var n=e.shared,i=n.isBufferArgs,r=n.elements,o=e.invoke(t,f),a=t.def("null"),s=t.def(i,"(",o,")"),u=e.cond(s).then(a,"=",r,".createStream(",o,");").else(a,"=",r,".getElements(",o,");");return ne.optional((function(){e.assert(u.else,"!"+o+"||"+a,"invalid elements")})),t.entry(u),t.exit(e.cond(s).then(r,".destroyStream(",a,");")),e.ELEMENTS=a,a}))}return o?new ss(u.thisDep,u.contextDep,u.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.elements+".getElements("+e.shared.vao+".currentVAO.elements):null")})):null}var h=f();function d(){if(Yo in n){var e=n[Yo];return r.primitive=e,ne.commandParameter(e,qt,"invalid primitve",t.commandStr),ls((function(t,n){return qt[e]}))}if(Yo in i){var a=i[Yo];return cs(a,(function(e,t){var n=e.constants.primTypes,i=e.invoke(t,a);return ne.optional((function(){e.assert(t,i+" in "+n,"invalid primitive, must be one of "+Object.keys(qt))})),t.def(n,"[",i,"]")}))}return l?us(h)?h.value?ls((function(e,t){return t.def(e.ELEMENTS,".primType")})):ls((function(){return Ra})):new ss(h.thisDep,h.contextDep,h.propDep,(function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",Ra)})):o?new ss(u.thisDep,u.contextDep,u.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.primitive:"+Ra)})):null}function p(e,a){if(e in n){var s=0|n[e];return a?r.offset=s:r.instances=s,ne.command(!a||s>=0,"invalid "+e,t.commandStr),ls((function(e,t){return a&&(e.OFFSET=s),s}))}if(e in i){var c=i[e];return cs(c,(function(t,n){var i=t.invoke(n,c);return a&&(t.OFFSET=i,ne.optional((function(){t.assert(n,i+">=0","invalid "+e)}))),i}))}if(a){if(l)return ls((function(e,t){return e.OFFSET=0,0}));if(o)return new ss(u.thisDep,u.contextDep,u.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.offset:0")}))}else if(o)return new ss(u.thisDep,u.contextDep,u.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.instances:-1")}));return null}var m=p(Xo,!0);function v(){if($o in n){var e=0|n[$o];return r.count=e,ne.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),ls((function(){return e}))}if($o in i){var a=i[$o];return cs(a,(function(e,t){var n=e.invoke(t,a);return ne.optional((function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")})),n}))}if(l){if(us(h)){if(h)return m?new ss(m.thisDep,m.contextDep,m.propDep,(function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return ne.optional((function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")})),n})):ls((function(e,t){return t.def(e.ELEMENTS,".vertCount")}));var s=ls((function(){return-1}));return ne.optional((function(){s.MISSING=!0})),s}var c=new ss(h.thisDep||m.thisDep,h.contextDep||m.contextDep,h.propDep||m.propDep,(function(e,t){var n=e.ELEMENTS;return e.OFFSET?t.def(n,"?",n,".vertCount-",e.OFFSET,":-1"):t.def(n,"?",n,".vertCount:-1")}));return ne.optional((function(){c.DYNAMIC=!0})),c}if(o){var f=new ss(u.thisDep,u.contextDep,u.propDep,(function(e,t){return t.def(e.shared.vao,".currentVAO?",e.shared.vao,".currentVAO.count:-1")}));return f}return null}var g=d(),y=v(),b=p(Zo,!1);return{elements:h,primitive:g,count:y,instances:b,offset:m,vao:u,vaoActive:o,elementsActive:l,static:r}}function j(e,t){var n=e.static,i=e.dynamic,o={};return k.forEach((function(e){var a=P(e);function s(t,r){if(e in n){var s=t(n[e]);o[a]=ls((function(){return s}))}else if(e in i){var u=i[e];o[a]=cs(u,(function(e,t){return r(e,t,e.invoke(t,u))}))}}switch(e){case To:case vo:case mo:case Eo:case xo:case jo:case zo:case Do:case Mo:case ko:return s((function(n){return ne.commandType(n,"boolean",e,t.commandStr),n}),(function(t,n,i){return ne.optional((function(){t.assert(n,"typeof "+i+'==="boolean"',"invalid flag "+e,t.commandStr)})),i}));case So:return s((function(n){return ne.commandParameter(n,ts,"invalid "+e,t.commandStr),ts[n]}),(function(t,n,i){var r=t.constants.compareFuncs;return ne.optional((function(){t.assert(n,i+" in "+r,"invalid "+e+", must be one of "+Object.keys(ts))})),n.def(r,"[",i,"]")}));case wo:return s((function(e){return ne.command(fn(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e}),(function(e,t,n){return ne.optional((function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===2&&typeof "+n+'[0]==="number"&&typeof '+n+'[1]==="number"&&'+n+"[0]<="+n+"[1]","depth range must be a 2d array")})),[t.def("+",n,"[0]"),t.def("+",n,"[1]")]}));case bo:return s((function(e){ne.commandType(e,"object","blend.func",t.commandStr);var n="srcRGB"in e?e.srcRGB:e.src,i="srcAlpha"in e?e.srcAlpha:e.src,r="dstRGB"in e?e.dstRGB:e.dst,o="dstAlpha"in e?e.dstAlpha:e.dst;return ne.commandParameter(n,Ja,a+".srcRGB",t.commandStr),ne.commandParameter(i,Ja,a+".srcAlpha",t.commandStr),ne.commandParameter(r,Ja,a+".dstRGB",t.commandStr),ne.commandParameter(o,Ja,a+".dstAlpha",t.commandStr),ne.command(-1===es.indexOf(n+", "+r),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+r+")",t.commandStr),[Ja[n],Ja[r],Ja[i],Ja[o]]}),(function(t,n,i){var r=t.constants.blendFuncs;function o(o,a){var s=n.def('"',o,a,'" in ',i,"?",i,".",o,a,":",i,".",o);return ne.optional((function(){t.assert(n,s+" in "+r,"invalid "+e+"."+o+a+", must be one of "+Object.keys(Ja))})),s}ne.optional((function(){t.assert(n,i+"&&typeof "+i+'==="object"',"invalid blend func, must be an object")}));var a=o("src","RGB"),s=o("dst","RGB");ne.optional((function(){var e=t.constants.invalidBlendCombinations;t.assert(n,e+".indexOf("+a+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var u=n.def(r,"[",a,"]"),l=n.def(r,"[",o("src","Alpha"),"]");return[u,n.def(r,"[",s,"]"),l,n.def(r,"[",o("dst","Alpha"),"]")]}));case yo:return s((function(n){return"string"==typeof n?(ne.commandParameter(n,g,"invalid "+e,t.commandStr),[g[n],g[n]]):"object"==typeof n?(ne.commandParameter(n.rgb,g,e+".rgb",t.commandStr),ne.commandParameter(n.alpha,g,e+".alpha",t.commandStr),[g[n.rgb],g[n.alpha]]):void ne.commandRaise("invalid blend.equation",t.commandStr)}),(function(t,n,i){var r=t.constants.blendEquations,o=n.def(),a=n.def(),s=t.cond("typeof ",i,'==="string"');return ne.optional((function(){function n(e,n,i){t.assert(e,i+" in "+r,"invalid "+n+", must be one of "+Object.keys(g))}n(s.then,e,i),t.assert(s.else,i+"&&typeof "+i+'==="object"',"invalid "+e),n(s.else,e+".rgb",i+".rgb"),n(s.else,e+".alpha",i+".alpha")})),s.then(o,"=",a,"=",r,"[",i,"];"),s.else(o,"=",r,"[",i,".rgb];",a,"=",r,"[",i,".alpha];"),n(s),[o,a]}));case go:return s((function(e){return ne.command(fn(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),Pe(4,(function(t){return+e[t]}))}),(function(e,t,n){return ne.optional((function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")})),Pe(4,(function(e){return t.def("+",n,"[",e,"]")}))}));case Lo:return s((function(e){return ne.commandType(e,"number",a,t.commandStr),0|e}),(function(e,t,n){return ne.optional((function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")})),t.def(n,"|0")}));case Oo:return s((function(n){ne.commandType(n,"object",a,t.commandStr);var i=n.cmp||"keep",r=n.ref||0,o="mask"in n?n.mask:-1;return ne.commandParameter(i,ts,e+".cmp",t.commandStr),ne.commandType(r,"number",e+".ref",t.commandStr),ne.commandType(o,"number",e+".mask",t.commandStr),[ts[i],r,o]}),(function(e,t,n){var i=e.constants.compareFuncs;return ne.optional((function(){function r(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}r(n+"&&typeof ",n,'==="object"'),r('!("cmp" in ',n,")||(",n,".cmp in ",i,")")})),[t.def('"cmp" in ',n,"?",i,"[",n,".cmp]",":",qa),t.def(n,".ref|0"),t.def('"mask" in ',n,"?",n,".mask|0:-1")]}));case No:case Ro:return s((function(n){ne.commandType(n,"object",a,t.commandStr);var i=n.fail||"keep",r=n.zfail||"keep",o=n.zpass||"keep";return ne.commandParameter(i,ns,e+".fail",t.commandStr),ne.commandParameter(r,ns,e+".zfail",t.commandStr),ne.commandParameter(o,ns,e+".zpass",t.commandStr),[e===Ro?Ba:ja,ns[i],ns[r],ns[o]]}),(function(t,n,i){var r=t.constants.stencilOps;function o(o){return ne.optional((function(){t.assert(n,'!("'+o+'" in '+i+")||("+i+"."+o+" in "+r+")","invalid "+e+"."+o+", must be one of "+Object.keys(ns))})),n.def('"',o,'" in ',i,"?",r,"[",i,".",o,"]:",qa)}return ne.optional((function(){t.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+e)})),[e===Ro?Ba:ja,o("fail"),o("zfail"),o("zpass")]}));case Io:return s((function(e){ne.commandType(e,"object",a,t.commandStr);var n=0|e.factor,i=0|e.units;return ne.commandType(n,"number",a+".factor",t.commandStr),ne.commandType(i,"number",a+".units",t.commandStr),[n,i]}),(function(t,n,i){return ne.optional((function(){t.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+e)})),[n.def(i,".factor|0"),n.def(i,".units|0")]}));case Po:return s((function(e){var n=0;return"front"===e?n=ja:"back"===e&&(n=Ba),ne.command(!!n,a,t.commandStr),n}),(function(e,t,n){return ne.optional((function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")})),t.def(n,'==="front"?',ja,":",Ba)}));case Ao:return s((function(e){return ne.command("number"==typeof e&&e>=r.lineWidthDims[0]&&e<=r.lineWidthDims[1],"invalid line width, must be a positive number between "+r.lineWidthDims[0]+" and "+r.lineWidthDims[1],t.commandStr),e}),(function(e,t,n){return ne.optional((function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+r.lineWidthDims[0]+"&&"+n+"<="+r.lineWidthDims[1],"invalid line width")})),n}));case _o:return s((function(e){return ne.commandParameter(e,rs,a,t.commandStr),rs[e]}),(function(e,t,n){return ne.optional((function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),t.def(n+'==="cw"?'+Va+":"+Ua)}));case Co:return s((function(e){return ne.command(fn(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map((function(e){return!!e}))}),(function(e,t,n){return ne.optional((function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")})),Pe(4,(function(e){return"!!"+n+"["+e+"]"}))}));case Fo:return s((function(e){ne.command("object"==typeof e&&e,a,t.commandStr);var n="value"in e?e.value:1,i=!!e.invert;return ne.command("number"==typeof n&&n>=0&&n<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[n,i]}),(function(e,t,n){return ne.optional((function(){e.assert(t,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")})),[t.def('"value" in ',n,"?+",n,".value:1"),t.def("!!",n,".invert")]}))}})),o}function B(e,t){var n=e.static,i=e.dynamic,r={};return Object.keys(n).forEach((function(e){var i,o=n[e];if("number"==typeof o||"boolean"==typeof o)i=ls((function(){return o}));else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?i=ls((function(e){return e.link(o)})):"framebuffer"===a||"framebufferCube"===a?(ne.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),i=ls((function(e){return e.link(o.color[0])}))):ne.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else fn(o)?i=ls((function(t){return t.global.def("[",Pe(o.length,(function(n){return ne.command("number"==typeof o[n]||"boolean"==typeof o[n],"invalid uniform "+e,t.commandStr),o[n]})),"]")})):ne.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);i.value=o,r[e]=i})),Object.keys(i).forEach((function(e){var t=i[e];r[e]=cs(t,(function(e,n){return e.invoke(n,t)}))})),r}function V(e,t){var i=e.static,r=e.dynamic,a={};return Object.keys(i).forEach((function(e){var r=i[e],s=n.id(e),u=new v;if(os(r))u.state=oo,u.buffer=o.getBuffer(o.create(r,ua,!1,!0)),u.type=0;else{var l=o.getBuffer(r);if(l)u.state=oo,u.buffer=l,u.type=0;else if(ne.command("object"==typeof r&&r,"invalid data for attribute "+e,t.commandStr),"constant"in r){var c=r.constant;u.buffer="null",u.state=ao,"number"==typeof c?u.x=c:(ne.command(fn(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,t.commandStr),io.forEach((function(e,t){t<c.length&&(u[e]=c[t])})))}else{l=os(r.buffer)?o.getBuffer(o.create(r.buffer,ua,!1,!0)):o.getBuffer(r.buffer),ne.command(!!l,'missing buffer for attribute "'+e+'"',t.commandStr);var f=0|r.offset;ne.command(f>=0,'invalid offset for attribute "'+e+'"',t.commandStr);var h=0|r.stride;ne.command(h>=0&&h<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var d=0|r.size;ne.command(!("size"in r)||d>0&&d<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var p=!!r.normalized,m=0;"type"in r&&(ne.commandParameter(r.type,Ft,"invalid type for attribute "+e,t.commandStr),m=Ft[r.type]);var g=0|r.divisor;ne.optional((function(){"divisor"in r&&(ne.command(0===g||y,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),ne.command(g>=0,'invalid divisor for attribute "'+e+'"',t.commandStr));var n=t.commandStr,i=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(r).forEach((function(t){ne.command(i.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+i+")",n)}))})),u.buffer=l,u.state=oo,u.size=d,u.normalized=p,u.type=m||l.dtype,u.offset=f,u.stride=h,u.divisor=g}}a[e]=ls((function(e,t){var n=e.attribCache;if(s in n)return n[s];var i={isStream:!1};return Object.keys(u).forEach((function(e){i[e]=u[e]})),u.buffer&&(i.buffer=e.link(u.buffer),i.type=i.type||i.buffer+".dtype"),n[s]=i,i}))})),Object.keys(r).forEach((function(e){var t=r[e];function n(n,i){var r=n.invoke(i,t),o=n.shared,a=n.constants,s=o.isBufferArgs,u=o.buffer;ne.optional((function(){n.assert(i,r+"&&(typeof "+r+'==="object"||typeof '+r+'==="function")&&('+s+"("+r+")||"+u+".getBuffer("+r+")||"+u+".getBuffer("+r+".buffer)||"+s+"("+r+'.buffer)||("constant" in '+r+"&&(typeof "+r+'.constant==="number"||'+o.isArrayLike+"("+r+".constant))))",'invalid dynamic attribute "'+e+'"')}));var l={isStream:i.def(!1)},c=new v;c.state=oo,Object.keys(c).forEach((function(e){l[e]=i.def(""+c[e])}));var f=l.buffer,h=l.type;function d(e){i(l[e],"=",r,".",e,"|0;")}return i("if(",s,"(",r,")){",l.isStream,"=true;",f,"=",u,".createStream(",ua,",",r,");",h,"=",f,".dtype;","}else{",f,"=",u,".getBuffer(",r,");","if(",f,"){",h,"=",f,".dtype;",'}else if("constant" in ',r,"){",l.state,"=",ao,";","if(typeof "+r+'.constant === "number"){',l[io[0]],"=",r,".constant;",io.slice(1).map((function(e){return l[e]})).join("="),"=0;","}else{",io.map((function(e,t){return l[e]+"="+r+".constant.length>"+t+"?"+r+".constant["+t+"]:0;"})).join(""),"}}else{","if(",s,"(",r,".buffer)){",f,"=",u,".createStream(",ua,",",r,".buffer);","}else{",f,"=",u,".getBuffer(",r,".buffer);","}",h,'="type" in ',r,"?",a.glTypes,"[",r,".type]:",f,".dtype;",l.normalized,"=!!",r,".normalized;"),d("size"),d("offset"),d("stride"),d("divisor"),i("}}"),i.exit("if(",l.isStream,"){",u,".destroyStream(",f,");","}"),l}a[e]=cs(t,n)})),a}function U(e){var t=e.static,n=e.dynamic,i={};return Object.keys(t).forEach((function(e){var n=t[e];i[e]=ls((function(e,t){return"number"==typeof n||"boolean"==typeof n?""+n:e.link(n)}))})),Object.keys(n).forEach((function(e){var t=n[e];i[e]=cs(t,(function(e,n){return e.invoke(n,t)}))})),i}function G(e,t,n,r,o){var a=e.static,s=e.dynamic;ne.optional((function(){var e=[Go,Ho,Wo,qo,Yo,Xo,$o,Zo,Uo,Qo].concat(k);function t(t){Object.keys(t).forEach((function(t){ne.command(e.indexOf(t)>=0,'unknown parameter "'+t+'"',o.commandStr)}))}t(a),t(s)}));var u=O(e,t),l=E(e),f=L(e,l,o),h=R(e,o),d=j(e,o),p=N(e,o,u);function m(e){var t=f[e];t&&(d[e]=t)}m(Vo),m(P(Bo));var v=Object.keys(d).length>0,g={framebuffer:l,draw:h,shader:p,state:d,dirty:v,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(g.profile=F(e),g.uniforms=B(n,o),g.drawVAO=g.scopeVAO=h.vao,!g.drawVAO&&p.program&&!u&&i.angle_instanced_arrays&&h.static.elements){var y=!0,b=p.program.attributes.map((function(e){var n=t.static[e];return y=y&&!!n,n}));if(y&&b.length>0){var x=c.getVAO(c.createVAO({attributes:b,elements:h.static.elements}));g.drawVAO=new ss(null,null,null,(function(e,t){return e.link(x)})),g.useVAO=!0}}return u?g.useVAO=!0:g.attributes=V(t,o),g.context=U(r),g}function H(e,t,n){var i=e.shared.context,r=e.scope();Object.keys(n).forEach((function(o){t.save(i,"."+o);var a=n[o].append(e,t);Array.isArray(a)?r(i,".",o,"=[",a.join(),"];"):r(i,".",o,"=",a,";")})),t(r)}function W(e,t,n,i){var r,o=e.shared,a=o.gl,s=o.framebuffer;b&&(r=t.def(o.extensions,".webgl_draw_buffers"));var u,l=e.constants,c=l.drawBuffer,f=l.backBuffer;u=n?n.append(e,t):t.def(s,".next"),i||t("if(",u,"!==",s,".cur){"),t("if(",u,"){",a,".bindFramebuffer(",Qa,",",u,".framebuffer);"),b&&t(r,".drawBuffersWEBGL(",c,"[",u,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",Qa,",null);"),b&&t(r,".drawBuffersWEBGL(",f,");"),t("}",s,".cur=",u,";"),i||t("}")}function q(e,t,n){var i=e.shared,r=i.gl,o=e.current,a=e.next,s=i.current,u=i.next,l=e.cond(s,".dirty");k.forEach((function(t){var i,c,f=P(t);if(!(f in n.state))if(f in a){i=a[f],c=o[f];var h=Pe(S[f].length,(function(e){return l.def(i,"[",e,"]")}));l(e.cond(h.map((function(e,t){return e+"!=="+c+"["+t+"]"})).join("||")).then(r,".",T[f],"(",h,");",h.map((function(e,t){return c+"["+t+"]="+e})).join(";"),";"))}else{i=l.def(u,".",f);var d=e.cond(i,"!==",s,".",f);l(d),f in C?d(e.cond(i).then(r,".enable(",C[f],");").else(r,".disable(",C[f],");"),s,".",f,"=",i,";"):d(r,".",T[f],"(",i,");",s,".",f,"=",i,";")}})),0===Object.keys(n.state).length&&l(s,".dirty=false;"),t(l)}function Y(e,t,n,i){var r=e.shared,o=e.current,a=r.current,s=r.gl;as(Object.keys(n)).forEach((function(r){var u=n[r];if(!i||i(u)){var l=u.append(e,t);if(C[r]){var c=C[r];us(u)?t(s,l?".enable(":".disable(",c,");"):t(e.cond(l).then(s,".enable(",c,");").else(s,".disable(",c,");")),t(a,".",r,"=",l,";")}else if(fn(l)){var f=o[r];t(s,".",T[r],"(",l,");",l.map((function(e,t){return f+"["+t+"]="+e})).join(";"),";")}else t(s,".",T[r],"(",l,");",a,".",r,"=",l,";")}}))}function $(e,t){y&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function X(e,t,n,i,r){var o,a,s,u=e.shared,l=e.stats,c=u.current,f=u.timer,h=n.profile;function d(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(e){e(o=t.def(),"=",d(),";"),"string"==typeof r?e(l,".count+=",r,";"):e(l,".count++;"),p&&(i?e(a=t.def(),"=",f,".getNumPendingQueries();"):e(f,".beginQuery(",l,");"))}function v(e){e(l,".cpuTime+=",d(),"-",o,";"),p&&(i?e(f,".pushScopeStats(",a,",",f,".getNumPendingQueries(),",l,");"):e(f,".endQuery();"))}function g(e){var n=t.def(c,".profile");t(c,".profile=",e,";"),t.exit(c,".profile=",n,";")}if(h){if(us(h))return void(h.enable?(m(t),v(t.exit),g("true")):g("false"));g(s=h.append(e,t))}else s=t.def(c,".profile");var y=e.block();m(y),t("if(",s,"){",y,"}");var b=e.block();v(b),t.exit("if(",s,"){",b,"}")}function Z(e,t,n,i,r){var o=e.shared;function a(e){switch(e){case wa:case Pa:case Ia:return 2;case ka:case _a:case Da:return 3;case Ca:case Aa:case Ma:return 4;default:return 1}}function s(n,i,r){var a=o.gl,s=t.def(n,".location"),u=t.def(o.attributes,"[",s,"]"),l=r.state,c=r.buffer,f=[r.x,r.y,r.z,r.w],h=["buffer","normalized","offset","stride"];function d(){t("if(!",u,".buffer){",a,".enableVertexAttribArray(",s,");}");var n,o=r.type;if(n=r.size?t.def(r.size,"||",i):i,t("if(",u,".type!==",o,"||",u,".size!==",n,"||",h.map((function(e){return u+"."+e+"!=="+r[e]})).join("||"),"){",a,".bindBuffer(",ua,",",c,".buffer);",a,".vertexAttribPointer(",[s,n,o,r.normalized,r.stride,r.offset],");",u,".type=",o,";",u,".size=",n,";",h.map((function(e){return u+"."+e+"="+r[e]+";"})).join(""),"}"),y){var l=r.divisor;t("if(",u,".divisor!==",l,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,l],");",u,".divisor=",l,";}")}}function p(){t("if(",u,".buffer){",a,".disableVertexAttribArray(",s,");",u,".buffer=null;","}if(",io.map((function(e,t){return u+"."+e+"!=="+f[t]})).join("||"),"){",a,".vertexAttrib4f(",s,",",f,");",io.map((function(e,t){return u+"."+e+"="+f[t]+";"})).join(""),"}")}l===oo?d():l===ao?p():(t("if(",l,"===",oo,"){"),d(),t("}else{"),p(),t("}"))}i.forEach((function(i){var o,u=i.name,l=n.attributes[u];if(l){if(!r(l))return;o=l.append(e,t)}else{if(!r(fs))return;var c=e.scopeAttrib(u);ne.optional((function(){e.assert(t,c+".state","missing attribute "+u)})),o={},Object.keys(new v).forEach((function(e){o[e]=t.def(c,".",e)}))}s(e.link(i),a(i.info.type),o)}))}function Q(e,t,i,r,o,a){for(var s,u=e.shared,l=u.gl,c={},f=0;f<r.length;++f){var h=r[f],d=h.name,p=h.info.type,m=h.info.size,v=i.uniforms[d];if(m>1){if(!v)continue;var g=d.replace("[0]","");if(c[g])continue;c[g]=1}var y,b=e.link(h)+".location";if(v){if(!o(v))continue;if(us(v)){var x=v.value;if(ne.command(null!=x,'missing uniform "'+d+'"',e.commandStr),p===Oa||p===Na){ne.command("function"==typeof x&&(p===Oa&&("texture2d"===x._reglType||"framebuffer"===x._reglType)||p===Na&&("textureCube"===x._reglType||"framebufferCube"===x._reglType)),"invalid texture for uniform "+d,e.commandStr);var S=e.link(x._texture||x.color[0]._texture);t(l,".uniform1i(",b,",",S+".bind());"),t.exit(S,".unbind();")}else if(p===Fa||p===Ea||p===La){ne.optional((function(){ne.command(fn(x),"invalid matrix for uniform "+d,e.commandStr),ne.command(p===Fa&&4===x.length||p===Ea&&9===x.length||p===La&&16===x.length,"invalid length for matrix uniform "+d,e.commandStr)}));var w=e.global.def("new Float32Array(["+Array.prototype.slice.call(x)+"])"),k=2;p===Ea?k=3:p===La&&(k=4),t(l,".uniformMatrix",k,"fv(",b,",false,",w,");")}else{switch(p){case Sa:1===m?ne.commandType(x,"number","uniform "+d,e.commandStr):ne.command(fn(x)&&x.length===m,"uniform "+d,e.commandStr),s="1f";break;case wa:ne.command(fn(x)&&x.length&&x.length%2==0&&x.length<=2*m,"uniform "+d,e.commandStr),s="2f";break;case ka:ne.command(fn(x)&&x.length&&x.length%3==0&&x.length<=3*m,"uniform "+d,e.commandStr),s="3f";break;case Ca:ne.command(fn(x)&&x.length&&x.length%4==0&&x.length<=4*m,"uniform "+d,e.commandStr),s="4f";break;case za:1===m?ne.commandType(x,"boolean","uniform "+d,e.commandStr):ne.command(fn(x)&&x.length===m,"uniform "+d,e.commandStr),s="1i";break;case Ta:1===m?ne.commandType(x,"number","uniform "+d,e.commandStr):ne.command(fn(x)&&x.length===m,"uniform "+d,e.commandStr),s="1i";break;case Ia:case Pa:ne.command(fn(x)&&x.length&&x.length%2==0&&x.length<=2*m,"uniform "+d,e.commandStr),s="2i";break;case Da:case _a:ne.command(fn(x)&&x.length&&x.length%3==0&&x.length<=3*m,"uniform "+d,e.commandStr),s="3i";break;case Ma:case Aa:ne.command(fn(x)&&x.length&&x.length%4==0&&x.length<=4*m,"uniform "+d,e.commandStr),s="4i"}m>1?(s+="v",x=e.global.def("["+Array.prototype.slice.call(x)+"]")):x=fn(x)?Array.prototype.slice.call(x):x,t(l,".uniform",s,"(",b,",",x,");")}continue}y=v.append(e,t)}else{if(!o(fs))continue;y=t.def(u.uniforms,"[",n.id(d),"]")}p===Oa?(ne(!Array.isArray(y),"must specify a scalar prop for textures"),t("if(",y,"&&",y,'._reglType==="framebuffer"){',y,"=",y,".color[0];","}")):p===Na&&(ne(!Array.isArray(y),"must specify a scalar prop for cube maps"),t("if(",y,"&&",y,'._reglType==="framebufferCube"){',y,"=",y,".color[0];","}")),ne.optional((function(){function n(n,i){e.assert(t,n,'bad data or missing for uniform "'+d+'". '+i)}function i(e,t){1===t&&ne(!Array.isArray(y),"must not specify an array type for uniform"),n("Array.isArray("+y+") && typeof "+y+'[0]===" '+e+'" || typeof '+y+'==="'+e+'"',"invalid type, expected "+e)}function r(t,i,r){Array.isArray(y)?ne(y.length&&y.length%t==0&&y.length<=t*r,"must have length of "+(1===r?"":"n * ")+t):n(u.isArrayLike+"("+y+")&&"+y+".length && "+y+".length % "+t+" === 0 && "+y+".length<="+t*r,"invalid vector, should have length of "+(1===r?"":"n * ")+t,e.commandStr)}function o(t){ne(!Array.isArray(y),"must not specify a value type"),n("typeof "+y+'==="function"&&'+y+'._reglType==="texture'+(t===ca?"2d":"Cube")+'"',"invalid texture type",e.commandStr)}switch(p){case Ta:i("number",m);break;case Pa:r(2,"number",m);break;case _a:r(3,"number",m);break;case Aa:r(4,"number",m);break;case Sa:i("number",m);break;case wa:r(2,"number",m);break;case ka:r(3,"number",m);break;case Ca:r(4,"number",m);break;case za:i("boolean",m);break;case Ia:r(2,"boolean",m);break;case Da:r(3,"boolean",m);break;case Ma:r(4,"boolean",m);break;case Fa:r(4,"number",m);break;case Ea:r(9,"number",m);break;case La:r(16,"number",m);break;case Oa:o(ca);break;case Na:o(fa)}}));var C=1;switch(p){case Oa:case Na:var T=t.def(y,"._texture");t(l,".uniform1i(",b,",",T,".bind());"),t.exit(T,".unbind();");continue;case Ta:case za:s="1i";break;case Pa:case Ia:s="2i",C=2;break;case _a:case Da:s="3i",C=3;break;case Aa:case Ma:s="4i",C=4;break;case Sa:s="1f";break;case wa:s="2f",C=2;break;case ka:s="3f",C=3;break;case Ca:s="4f",C=4;break;case Fa:s="Matrix2fv";break;case Ea:s="Matrix3fv";break;case La:s="Matrix4fv"}if(-1===s.indexOf("Matrix")&&m>1&&(s+="v",C=1),"M"===s.charAt(0)){t(l,".uniform",s,"(",b,",");var P=Math.pow(p-Fa+2,2),_=e.global.def("new Float32Array(",P,")");Array.isArray(y)?t("false,(",Pe(P,(function(e){return _+"["+e+"]="+y[e]})),",",_,")"):t("false,(Array.isArray(",y,")||",y," instanceof Float32Array)?",y,":(",Pe(P,(function(e){return _+"["+e+"]="+y+"["+e+"]"})),",",_,")"),t(");")}else if(C>1){for(var A=[],z=[],I=0;I<C;++I)Array.isArray(y)?z.push(y[I]):z.push(t.def(y+"["+I+"]")),a&&A.push(t.def());a&&t("if(!",e.batchId,"||",A.map((function(e,t){return e+"!=="+z[t]})).join("||"),"){",A.map((function(e,t){return e+"="+z[t]+";"})).join("")),t(l,".uniform",s,"(",b,",",z.join(","),");"),a&&t("}")}else{if(ne(!Array.isArray(y),"uniform value must not be an array"),a){var D=t.def();t("if(!",e.batchId,"||",D,"!==",y,"){",D,"=",y,";")}t(l,".uniform",s,"(",b,",",y,");"),a&&t("}")}}}function K(e,t,n,i){var r=e.shared,o=r.gl,a=r.draw,s=i.draw;function u(){var u,l=s.elements,c=t;return l?((l.contextDep&&i.contextDynamic||l.propDep)&&(c=n),u=l.append(e,c),s.elementsActive&&c("if("+u+")"+o+".bindBuffer("+la+","+u+".buffer.buffer);")):(u=c.def(),c(u,"=",a,".",qo,";","if(",u,"){",o,".bindBuffer(",la,",",u,".buffer.buffer);}","else if(",r.vao,".currentVAO){",u,"=",e.shared.elements+".getElements("+r.vao,".currentVAO.elements);",x?"":"if("+u+")"+o+".bindBuffer("+la+","+u+".buffer.buffer);","}")),u}function l(){var r,o=s.count,u=t;return o?((o.contextDep&&i.contextDynamic||o.propDep)&&(u=n),r=o.append(e,u),ne.optional((function(){o.MISSING&&e.assert(t,"false","missing vertex count"),o.DYNAMIC&&e.assert(u,r+">=0","missing vertex count")}))):(r=u.def(a,".",$o),ne.optional((function(){e.assert(u,r+">=0","missing vertex count")}))),r}var c=u();function f(r){var o=s[r];return o?o.contextDep&&i.contextDynamic||o.propDep?o.append(e,n):o.append(e,t):t.def(a,".",r)}var h,d,p=f(Yo),m=f(Xo),v=l();if("number"==typeof v){if(0===v)return}else n("if(",v,"){"),n.exit("}");y&&(h=f(Zo),d=e.instancing);var g=c+".type",b=s.elements&&us(s.elements)&&!s.vaoActive;function S(){function e(){n(d,".drawElementsInstancedANGLE(",[p,v,g,m+"<<(("+g+"-"+ro+")>>1)",h],");")}function t(){n(d,".drawArraysInstancedANGLE(",[p,m,v,h],");")}c&&"null"!==c?b?e():(n("if(",c,"){"),e(),n("}else{"),t(),n("}")):t()}function w(){function e(){n(o+".drawElements("+[p,v,g,m+"<<(("+g+"-"+ro+")>>1)"]+");")}function t(){n(o+".drawArrays("+[p,m,v]+");")}c&&"null"!==c?b?e():(n("if(",c,"){"),e(),n("}else{"),t(),n("}")):t()}y&&("number"!=typeof h||h>=0)?"string"==typeof h?(n("if(",h,">0){"),S(),n("}else if(",h,"<0){"),w(),n("}")):S():w()}function J(e,t,n,i,r){var o=M(),a=o.proc("body",r);return ne.optional((function(){o.commandStr=t.commandStr,o.command=o.link(t.commandStr)})),y&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),e(o,a,n,i),o.compile().body}function ee(e,t,n,i){$(e,t),n.useVAO?n.drawVAO?t(e.shared.vao,".setVAO(",n.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),Z(e,t,n,i.attributes,(function(){return!0}))),Q(e,t,n,i.uniforms,(function(){return!0}),!1),K(e,t,t,n)}function te(e,t){var n=e.proc("draw",1);$(e,n),H(e,n,t.context),W(e,n,t.framebuffer),q(e,n,t),Y(e,n,t.state),X(e,n,t,!1,!0);var i=t.shader.progVar.append(e,n);if(n(e.shared.gl,".useProgram(",i,".program);"),t.shader.program)ee(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var r=e.global.def("{}"),o=n.def(i,".id"),a=n.def(r,"[",o,"]");n(e.cond(a).then(a,".call(this,a0);").else(a,"=",r,"[",o,"]=",e.link((function(n){return J(ee,e,t,n,1)})),"(",i,");",a,".call(this,a0);"))}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;"),e.shared.vao&&n(e.shared.vao,".setVAO(null);")}function ie(e,t,n,i){function r(){return!0}e.batchId="a1",$(e,t),Z(e,t,n,i.attributes,r),Q(e,t,n,i.uniforms,r,!1),K(e,t,t,n)}function re(e,t,n,i){$(e,t);var r=n.contextDep,o=t.def(),a="a0",s="a1",u=t.def();e.shared.props=u,e.batchId=o;var l=e.scope(),c=e.scope();function f(e){return e.contextDep&&r||e.propDep}function h(e){return!f(e)}if(t(l.entry,"for(",o,"=0;",o,"<",s,";++",o,"){",u,"=",a,"[",o,"];",c,"}",l.exit),n.needsContext&&H(e,c,n.context),n.needsFramebuffer&&W(e,c,n.framebuffer),Y(e,c,n.state,f),n.profile&&f(n.profile)&&X(e,c,n,!1,!0),i)n.useVAO?n.drawVAO?f(n.drawVAO)?c(e.shared.vao,".setVAO(",n.drawVAO.append(e,c),");"):l(e.shared.vao,".setVAO(",n.drawVAO.append(e,l),");"):l(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(l(e.shared.vao,".setVAO(null);"),Z(e,l,n,i.attributes,h),Z(e,c,n,i.attributes,f)),Q(e,l,n,i.uniforms,h,!1),Q(e,c,n,i.uniforms,f,!0),K(e,l,c,n);else{var d=e.global.def("{}"),p=n.shader.progVar.append(e,c),m=c.def(p,".id"),v=c.def(d,"[",m,"]");c(e.shared.gl,".useProgram(",p,".program);","if(!",v,"){",v,"=",d,"[",m,"]=",e.link((function(t){return J(ie,e,n,t,2)})),"(",p,");}",v,".call(this,a0[",o,"],",o,");")}}function oe(e,t){var n=e.proc("batch",2);e.batchId="0",$(e,n);var i=!1,r=!0;Object.keys(t.context).forEach((function(e){i=i||t.context[e].propDep})),i||(H(e,n,t.context),r=!1);var o=t.framebuffer,a=!1;function s(e){return e.contextDep&&i||e.propDep}o?(o.propDep?i=a=!0:o.contextDep&&i&&(a=!0),a||W(e,n,o)):W(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),q(e,n,t),Y(e,n,t.state,(function(e){return!s(e)})),t.profile&&s(t.profile)||X(e,n,t,!1,"a1"),t.contextDep=i,t.needsContext=r,t.needsFramebuffer=a;var u=t.shader.progVar;if(u.contextDep&&i||u.propDep)re(e,n,t,null);else{var l=u.append(e,n);if(n(e.shared.gl,".useProgram(",l,".program);"),t.shader.program)re(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var c=e.global.def("{}"),f=n.def(l,".id"),h=n.def(c,"[",f,"]");n(e.cond(h).then(h,".call(this,a0,a1);").else(h,"=",c,"[",f,"]=",e.link((function(n){return J(re,e,t,n,2)})),"(",l,");",h,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;"),e.shared.vao&&n(e.shared.vao,".setVAO(null);")}function ae(e,t){var i=e.proc("scope",3);e.batchId="a2";var r=e.shared,o=r.current;function a(n){var o=t.shader[n];o&&i.set(r.shader,"."+n,o.append(e,i))}H(e,i,t.context),t.framebuffer&&t.framebuffer.append(e,i),as(Object.keys(t.state)).forEach((function(n){var o=t.state[n].append(e,i);fn(o)?o.forEach((function(t,r){i.set(e.next[n],"["+r+"]",t)})):i.set(r.next,"."+n,o)})),X(e,i,t,!0,!0),[qo,Xo,$o,Zo,Yo].forEach((function(n){var o=t.draw[n];o&&i.set(r.draw,"."+n,""+o.append(e,i))})),Object.keys(t.uniforms).forEach((function(o){var a=t.uniforms[o].append(e,i);Array.isArray(a)&&(a="["+a.join()+"]"),i.set(r.uniforms,"["+n.id(o)+"]",a)})),Object.keys(t.attributes).forEach((function(n){var r=t.attributes[n].append(e,i),o=e.scopeAttrib(n);Object.keys(new v).forEach((function(e){i.set(o,"."+e,r[e])}))})),t.scopeVAO&&i.set(r.vao,".targetVAO",t.scopeVAO.append(e,i)),a(Ho),a(Wo),Object.keys(t.state).length>0&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}function se(e){if("object"==typeof e&&!fn(e)){for(var t=Object.keys(e),n=0;n<t.length;++n)if(pe.isDynamic(e[t[n]]))return!0;return!1}}function ue(e,t,n){var i=t.static[n];if(i&&se(i)){var r=e.global,o=Object.keys(i),a=!1,s=!1,u=!1,l=e.global.def("{}");o.forEach((function(t){var n=i[t];if(pe.isDynamic(n)){"function"==typeof n&&(n=i[t]=pe.unbox(n));var o=cs(n,null);a=a||o.thisDep,u=u||o.propDep,s=s||o.contextDep}else{switch(r(l,".",t,"="),typeof n){case"number":r(n);break;case"string":r('"',n,'"');break;case"object":Array.isArray(n)&&r("[",n.join(),"]");break;default:r(e.link(n))}r(";")}})),t.dynamic[n]=new pe.DynamicVariable(fo,{thisDep:a,contextDep:s,propDep:u,ref:l,append:c}),delete t.static[n]}function c(e,t){o.forEach((function(n){var r=i[n];if(pe.isDynamic(r)){var o=e.invoke(t,r);t(l,".",n,"=",o,";")}}))}}function le(e,n,i,r,o){var a=M();a.stats=a.link(o),Object.keys(n.static).forEach((function(e){ue(a,n,e)})),sa.forEach((function(t){ue(a,e,t)}));var s=G(e,n,i,r,a);return te(a,s),ae(a,s),oe(a,s),t(a.compile(),{destroy:function(){s.shader.program.destroy()}})}return{next:w,current:S,procs:function(){var e=M(),t=e.proc("poll"),n=e.proc("refresh"),o=e.block();t(o),n(o);var a,s=e.shared,u=s.gl,l=s.next,c=s.current;o(c,".dirty=false;"),W(e,t),W(e,n,null,!0),y&&(a=e.link(y)),i.oes_vertex_array_object&&n(e.link(i.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var f=0;f<r.maxAttributes;++f){var h=n.def(s.attributes,"[",f,"]"),d=e.cond(h,".buffer");d.then(u,".enableVertexAttribArray(",f,");",u,".bindBuffer(",ua,",",h,".buffer.buffer);",u,".vertexAttribPointer(",f,",",h,".size,",h,".type,",h,".normalized,",h,".stride,",h,".offset);").else(u,".disableVertexAttribArray(",f,");",u,".vertexAttrib4f(",f,",",h,".x,",h,".y,",h,".z,",h,".w);",h,".buffer=null;"),n(d),y&&n(a,".vertexAttribDivisorANGLE(",f,",",h,".divisor);")}return n(e.shared.vao,".currentVAO=null;",e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"),Object.keys(C).forEach((function(i){var r=C[i],a=o.def(l,".",i),s=e.block();s("if(",a,"){",u,".enable(",r,")}else{",u,".disable(",r,")}",c,".",i,"=",a,";"),n(s),t("if(",a,"!==",c,".",i,"){",s,"}")})),Object.keys(T).forEach((function(i){var r,a,s=T[i],f=S[i],h=e.block();if(h(u,".",s,"("),fn(f)){var d=f.length;r=e.global.def(l,".",i),a=e.global.def(c,".",i),h(Pe(d,(function(e){return r+"["+e+"]"})),");",Pe(d,(function(e){return a+"["+e+"]="+r+"["+e+"];"})).join("")),t("if(",Pe(d,(function(e){return r+"["+e+"]!=="+a+"["+e+"]"})).join("||"),"){",h,"}")}else r=o.def(l,".",i),a=o.def(c,".",i),h(r,");",c,".",i,"=",r,";"),t("if(",r,"!==",a,"){",h,"}");n(h)})),e.compile()}(),compile:le}}function ds(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var ps=34918,ms=34919,vs=35007,gs=function(e,t){if(!t.ext_disjoint_timer_query)return null;var n=[];function i(){return n.pop()||t.ext_disjoint_timer_query.createQueryEXT()}function r(e){n.push(e)}var o=[];function a(e){var n=i();t.ext_disjoint_timer_query.beginQueryEXT(vs,n),o.push(n),d(o.length-1,o.length,e)}function s(){t.ext_disjoint_timer_query.endQueryEXT(vs)}function u(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var l=[];function c(){return l.pop()||new u}function f(e){l.push(e)}var h=[];function d(e,t,n){var i=c();i.startQueryIndex=e,i.endQueryIndex=t,i.sum=0,i.stats=n,h.push(i)}var p=[],m=[];function v(){var e,n,i=o.length;if(0!==i){m.length=Math.max(m.length,i+1),p.length=Math.max(p.length,i+1),p[0]=0,m[0]=0;var a=0;for(e=0,n=0;n<o.length;++n){var s=o[n];t.ext_disjoint_timer_query.getQueryObjectEXT(s,ms)?(a+=t.ext_disjoint_timer_query.getQueryObjectEXT(s,ps),r(s)):o[e++]=s,p[n+1]=a,m[n+1]=e}for(o.length=e,e=0,n=0;n<h.length;++n){var u=h[n],l=u.startQueryIndex,c=u.endQueryIndex;u.sum+=p[c]-p[l];var d=m[l],v=m[c];v===d?(u.stats.gpuTime+=u.sum/1e6,f(u)):(u.startQueryIndex=d,u.endQueryIndex=v,h[e++]=u)}h.length=e}}return{beginQuery:a,endQuery:s,pushScopeStats:d,update:v,getNumPendingQueries:function(){return o.length},clear:function(){n.push.apply(n,o);for(var e=0;e<n.length;e++)t.ext_disjoint_timer_query.deleteQueryEXT(n[e]);o.length=0,n.length=0},restore:function(){o.length=0,n.length=0}}},ys=16384,bs=256,xs=1024,Ss=34962,ws="webglcontextlost",ks="webglcontextrestored",Cs=1,Ts=2,Ps=3;function _s(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}function As(e){var n=Ce(e);if(!n)return null;var i=n.gl,r=i.getContextAttributes(),o=i.isContextLost(),a=Te(i,n);if(!a)return null;var s=ge(),u=ds(),l=a.extensions,c=gs(i,l),f=ve(),h=i.drawingBufferWidth,d=i.drawingBufferHeight,p={tick:0,time:0,viewportWidth:h,viewportHeight:d,framebufferWidth:h,framebufferHeight:d,drawingBufferWidth:h,drawingBufferHeight:d,pixelRatio:n.pixelRatio},m={},v={elements:null,primitive:4,count:-1,offset:0,instances:-1},g=wt(i,l),y=Wt(i,u,n,S),b=an(i,l,y,u),x=Gr(i,l,g,u,y,b,v);function S(e){return x.destroyBuffer(e)}var w=$r(i,s,u,n),k=Xi(i,l,g,(function(){P.procs.poll()}),p,u,n),C=lr(i,l,g,u,n),T=Nr(i,l,g,k,C,u),P=hs(i,s,l,g,y,b,k,T,m,x,w,v,p,c,n),_=Jr(i,T,P.procs.poll,p,r,l,g),A=P.next,z=i.canvas,I=[],D=[],M=[],F=[n.onDestroy],E=null;function L(){if(0===I.length)return c&&c.update(),void(E=null);E=me.next(L),Y();for(var e=I.length-1;e>=0;--e){var t=I[e];t&&t(p,null,0)}i.flush(),c&&c.update()}function O(){!E&&I.length>0&&(E=me.next(L))}function N(){E&&(me.cancel(L),E=null)}function R(e){e.preventDefault(),o=!0,N(),D.forEach((function(e){e()}))}function j(e){i.getError(),o=!1,a.restore(),w.restore(),y.restore(),k.restore(),C.restore(),T.restore(),x.restore(),c&&c.restore(),P.procs.refresh(),O(),M.forEach((function(e){e()}))}function B(){I.length=0,N(),z&&(z.removeEventListener(ws,R),z.removeEventListener(ks,j)),w.clear(),T.clear(),C.clear(),x.clear(),k.clear(),b.clear(),y.clear(),c&&c.clear(),F.forEach((function(e){e()}))}function V(e){function n(e){var n=t({},e);function i(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach((function(i){n[e+"."+i]=t[i]}))}}return delete n.uniforms,delete n.attributes,delete n.context,delete n.vao,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),i("blend"),i("depth"),i("cull"),i("stencil"),i("polygonOffset"),i("scissor"),i("sample"),"vao"in e&&(n.vao=e.vao),n}function i(e,t){var n={},i={};return Object.keys(e).forEach((function(r){var o=e[r];if(pe.isDynamic(o))i[r]=pe.unbox(o,r);else{if(t&&Array.isArray(o))for(var a=0;a<o.length;++a)if(pe.isDynamic(o[a]))return void(i[r]=pe.unbox(o,r));n[r]=o}})),{dynamic:i,static:n}}ne(!!e,"invalid args to regl({...})"),ne.type(e,"object","invalid args to regl({...})");var r=i(e.context||{},!0),a=i(e.uniforms||{},!0),s=i(e.attributes||{},!1),u=i(n(e),!1),l={gpuTime:0,cpuTime:0,count:0},c=P.compile(u,s,a,r,l),f=c.draw,h=c.batch,d=c.scope,p=[];function m(e){for(;p.length<e;)p.push(null);return p}function v(e,t){var n;if(o&&ne.raise("context lost"),"function"==typeof e)return d.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(n=0;n<e;++n)d.call(this,null,t,n);else{if(!Array.isArray(e))return d.call(this,e,t,0);for(n=0;n<e.length;++n)d.call(this,e[n],t,n)}else if("number"==typeof e){if(e>0)return h.call(this,m(0|e),0|e)}else{if(!Array.isArray(e))return f.call(this,e);if(e.length)return h.call(this,e,e.length)}}return t(v,{stats:l,destroy:function(){c.destroy()}})}z&&(z.addEventListener(ws,R,!1),z.addEventListener(ks,j,!1));var U=T.setFBO=V({framebuffer:pe.define.call(null,Cs,"framebuffer")});function G(e,t){var n=0;P.procs.poll();var r=t.color;r&&(i.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=ys),"depth"in t&&(i.clearDepth(+t.depth),n|=bs),"stencil"in t&&(i.clearStencil(0|t.stencil),n|=xs),ne(!!n,"called regl.clear with no buffer specified"),i.clear(n)}function H(e){if(ne("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var n=0;n<6;++n)U(t({framebuffer:e.framebuffer.faces[n]},e),G);else U(e,G);else G(null,e)}function W(e){function t(){var t=_s(I,e);function n(){var e=_s(I,n);I[e]=I[I.length-1],I.length-=1,I.length<=0&&N()}ne(t>=0,"cannot cancel a frame twice"),I[t]=n}return ne.type(e,"function","regl.frame() callback must be a function"),I.push(e),O(),{cancel:t}}function q(){var e=A.viewport,t=A.scissor_box;e[0]=e[1]=t[0]=t[1]=0,p.viewportWidth=p.framebufferWidth=p.drawingBufferWidth=e[2]=t[2]=i.drawingBufferWidth,p.viewportHeight=p.framebufferHeight=p.drawingBufferHeight=e[3]=t[3]=i.drawingBufferHeight}function Y(){p.tick+=1,p.time=X(),q(),P.procs.poll()}function $(){k.refresh(),q(),P.procs.refresh(),c&&c.update()}function X(){return(ve()-f)/1e3}function Z(e,t){var n;switch(ne.type(t,"function","listener callback must be a function"),e){case"frame":return W(t);case"lost":n=D;break;case"restore":n=M;break;case"destroy":n=F;break;default:ne.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(t),{cancel:function(){for(var e=0;e<n.length;++e)if(n[e]===t)return n[e]=n[n.length-1],void n.pop()}}}$();var Q=t(V,{clear:H,prop:pe.define.bind(null,Cs),context:pe.define.bind(null,Ts),this:pe.define.bind(null,Ps),draw:V({}),buffer:function(e){return y.create(e,Ss,!1,!1)},elements:function(e){return b.create(e,!1)},texture:k.create2D,cube:k.createCube,renderbuffer:C.create,framebuffer:T.create,framebufferCube:T.createCube,vao:x.createVAO,attributes:r,frame:W,on:Z,limits:g,hasExtension:function(e){return g.extensions.indexOf(e.toLowerCase())>=0},read:_,destroy:B,_gl:i,_refresh:$,poll:function(){Y(),c&&c.update()},now:X,stats:u});return n.onDone(null,Q),Q}return As}()}(hi);var di=hi.exports;const pi=void 0,mi="#222222",vi={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: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},{entries:gi,setPrototypeOf:yi,isFrozen:bi,getPrototypeOf:xi,getOwnPropertyDescriptor:Si}=Object;let{freeze:wi,seal:ki,create:Ci}=Object,{apply:Ti,construct:Pi}="undefined"!=typeof Reflect&&Reflect;wi||(wi=function(e){return e}),ki||(ki=function(e){return e}),Ti||(Ti=function(e,t,n){return e.apply(t,n)}),Pi||(Pi=function(e,t){return new e(...t)});const _i=Ui(Array.prototype.forEach),Ai=Ui(Array.prototype.lastIndexOf),zi=Ui(Array.prototype.pop),Ii=Ui(Array.prototype.push),Di=Ui(Array.prototype.splice),Mi=Ui(String.prototype.toLowerCase),Fi=Ui(String.prototype.toString),Ei=Ui(String.prototype.match),Li=Ui(String.prototype.replace),Oi=Ui(String.prototype.indexOf),Ni=Ui(String.prototype.trim),Ri=Ui(Object.prototype.hasOwnProperty),ji=Ui(RegExp.prototype.test),Bi=(Vi=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Pi(Vi,t)});var Vi;function Ui(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Ti(e,t,i)}}function Gi(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Mi;yi&&yi(e,null);let i=t.length;for(;i--;){let r=t[i];if("string"==typeof r){const e=n(r);e!==r&&(bi(t)||(t[i]=e),r=e)}e[r]=!0}return e}function Hi(e){for(let t=0;t<e.length;t++){Ri(e,t)||(e[t]=null)}return e}function Wi(e){const t=Ci(null);for(const[n,i]of gi(e)){Ri(e,n)&&(Array.isArray(i)?t[n]=Hi(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=Wi(i):t[n]=i)}return t}function qi(e,t){for(;null!==e;){const n=Si(e,t);if(n){if(n.get)return Ui(n.get);if("function"==typeof n.value)return Ui(n.value)}e=xi(e)}return function(){return null}}const Yi=wi(["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"]),$i=wi(["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"]),Xi=wi(["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"]),Zi=wi(["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"]),Qi=wi(["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"]),Ki=wi(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ji=wi(["#text"]),er=wi(["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"]),tr=wi(["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"]),nr=wi(["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"]),ir=wi(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rr=ki(/\{\{[\w\W]*|[\w\W]*\}\}/gm),or=ki(/<%[\w\W]*|[\w\W]*%>/gm),ar=ki(/\$\{[\w\W]*/gm),sr=ki(/^data-[\-\w.\u00B7-\uFFFF]+$/),ur=ki(/^aria-[\-\w]+$/),lr=ki(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cr=ki(/^(?:\w+script|data):/i),fr=ki(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),hr=ki(/^html$/i),dr=ki(/^[a-z][.\w]*(-[.\w]+)+$/i);var pr=Object.freeze({__proto__:null,ARIA_ATTR:ur,ATTR_WHITESPACE:fr,CUSTOM_ELEMENT:dr,DATA_ATTR:sr,DOCTYPE_NAME:hr,ERB_EXPR:or,IS_ALLOWED_URI:lr,IS_SCRIPT_OR_DATA:cr,MUSTACHE_EXPR:rr,TMPLIT_EXPR:ar});const mr=1,vr=3,gr=7,yr=8,br=9,xr=function(){return"undefined"==typeof window?null:window};var Sr=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xr();const n=t=>e(t);if(n.version="3.2.6",n.removed=[],!t||!t.document||t.document.nodeType!==br||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const r=i,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:u,Element:l,NodeFilter:c,NamedNodeMap:f=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:h,DOMParser:d,trustedTypes:p}=t,m=l.prototype,v=qi(m,"cloneNode"),g=qi(m,"remove"),y=qi(m,"nextSibling"),b=qi(m,"childNodes"),x=qi(m,"parentNode");if("function"==typeof s){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let S,w="";const{implementation:k,createNodeIterator:C,createDocumentFragment:T,getElementsByTagName:P}=i,{importNode:_}=r;let A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof gi&&"function"==typeof x&&k&&void 0!==k.createHTMLDocument;const{MUSTACHE_EXPR:z,ERB_EXPR:I,TMPLIT_EXPR:D,DATA_ATTR:M,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:E,ATTR_WHITESPACE:L,CUSTOM_ELEMENT:O}=pr;let{IS_ALLOWED_URI:N}=pr,R=null;const j=Gi({},[...Yi,...$i,...Xi,...Qi,...Ji]);let B=null;const V=Gi({},[...er,...tr,...nr,...ir]);let U=Object.seal(Ci(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}})),G=null,H=null,W=!0,q=!0,Y=!1,$=!0,X=!1,Z=!0,Q=!1,K=!1,J=!1,ee=!1,te=!1,ne=!1,ie=!0,re=!1,oe=!0,ae=!1,se={},ue=null;const le=Gi({},["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 ce=null;const fe=Gi({},["audio","video","img","source","image","track"]);let he=null;const de=Gi({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pe="http://www.w3.org/1998/Math/MathML",me="http://www.w3.org/2000/svg",ve="http://www.w3.org/1999/xhtml";let ge=ve,ye=!1,be=null;const xe=Gi({},[pe,me,ve],Fi);let Se=Gi({},["mi","mo","mn","ms","mtext"]),we=Gi({},["annotation-xml"]);const ke=Gi({},["title","style","font","a","script"]);let Ce=null;const Te=["application/xhtml+xml","text/html"];let Pe=null,_e=null;const Ae=i.createElement("form"),ze=function(e){return e instanceof RegExp||e instanceof Function},Ie=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!_e||_e!==e){if(e&&"object"==typeof e||(e={}),e=Wi(e),Ce=-1===Te.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Pe="application/xhtml+xml"===Ce?Fi:Mi,R=Ri(e,"ALLOWED_TAGS")?Gi({},e.ALLOWED_TAGS,Pe):j,B=Ri(e,"ALLOWED_ATTR")?Gi({},e.ALLOWED_ATTR,Pe):V,be=Ri(e,"ALLOWED_NAMESPACES")?Gi({},e.ALLOWED_NAMESPACES,Fi):xe,he=Ri(e,"ADD_URI_SAFE_ATTR")?Gi(Wi(de),e.ADD_URI_SAFE_ATTR,Pe):de,ce=Ri(e,"ADD_DATA_URI_TAGS")?Gi(Wi(fe),e.ADD_DATA_URI_TAGS,Pe):fe,ue=Ri(e,"FORBID_CONTENTS")?Gi({},e.FORBID_CONTENTS,Pe):le,G=Ri(e,"FORBID_TAGS")?Gi({},e.FORBID_TAGS,Pe):Wi({}),H=Ri(e,"FORBID_ATTR")?Gi({},e.FORBID_ATTR,Pe):Wi({}),se=!!Ri(e,"USE_PROFILES")&&e.USE_PROFILES,W=!1!==e.ALLOW_ARIA_ATTR,q=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,X=e.SAFE_FOR_TEMPLATES||!1,Z=!1!==e.SAFE_FOR_XML,Q=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ie=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ae=e.IN_PLACE||!1,N=e.ALLOWED_URI_REGEXP||lr,ge=e.NAMESPACE||ve,Se=e.MATHML_TEXT_INTEGRATION_POINTS||Se,we=e.HTML_INTEGRATION_POINTS||we,U=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ze(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ze(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&(q=!1),te&&(ee=!0),se&&(R=Gi({},Ji),B=[],!0===se.html&&(Gi(R,Yi),Gi(B,er)),!0===se.svg&&(Gi(R,$i),Gi(B,tr),Gi(B,ir)),!0===se.svgFilters&&(Gi(R,Xi),Gi(B,tr),Gi(B,ir)),!0===se.mathMl&&(Gi(R,Qi),Gi(B,nr),Gi(B,ir))),e.ADD_TAGS&&(R===j&&(R=Wi(R)),Gi(R,e.ADD_TAGS,Pe)),e.ADD_ATTR&&(B===V&&(B=Wi(B)),Gi(B,e.ADD_ATTR,Pe)),e.ADD_URI_SAFE_ATTR&&Gi(he,e.ADD_URI_SAFE_ATTR,Pe),e.FORBID_CONTENTS&&(ue===le&&(ue=Wi(ue)),Gi(ue,e.FORBID_CONTENTS,Pe)),oe&&(R["#text"]=!0),Q&&Gi(R,["html","head","body"]),R.table&&(Gi(R,["tbody"]),delete G.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=e.TRUSTED_TYPES_POLICY,w=S.createHTML("")}else void 0===S&&(S=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,o)),null!==S&&"string"==typeof w&&(w=S.createHTML(""));wi&&wi(e),_e=e}},De=Gi({},[...$i,...Xi,...Zi]),Me=Gi({},[...Qi,...Ki]),Fe=function(e){Ii(n.removed,{element:e});try{x(e).removeChild(e)}catch(t){g(e)}},Ee=function(e,t){try{Ii(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Ii(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Fe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Le=function(e){let t=null,n=null;if(J)e="<remove></remove>"+e;else{const t=Ei(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Ce&&ge===ve&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=S?S.createHTML(e):e;if(ge===ve)try{t=(new d).parseFromString(r,Ce)}catch(e){}if(!t||!t.documentElement){t=k.createDocument(ge,"template",null);try{t.documentElement.innerHTML=ye?w:r}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),ge===ve?P.call(t,Q?"html":"body")[0]:Q?t.documentElement:o},Oe=function(e){return C.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ne=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof f)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Re=function(e){return"function"==typeof u&&e instanceof u};function je(e,t,i){_i(e,(e=>{e.call(n,t,i,_e)}))}const Be=function(e){let t=null;if(je(A.beforeSanitizeElements,e,null),Ne(e))return Fe(e),!0;const i=Pe(e.nodeName);if(je(A.uponSanitizeElement,e,{tagName:i,allowedTags:R}),Z&&e.hasChildNodes()&&!Re(e.firstElementChild)&&ji(/<[/\w!]/g,e.innerHTML)&&ji(/<[/\w!]/g,e.textContent))return Fe(e),!0;if(e.nodeType===gr)return Fe(e),!0;if(Z&&e.nodeType===yr&&ji(/<[/\w]/g,e.data))return Fe(e),!0;if(!R[i]||G[i]){if(!G[i]&&Ue(i)){if(U.tagNameCheck instanceof RegExp&&ji(U.tagNameCheck,i))return!1;if(U.tagNameCheck instanceof Function&&U.tagNameCheck(i))return!1}if(oe&&!ue[i]){const t=x(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const r=v(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,y(e))}}}return Fe(e),!0}return e instanceof l&&!function(e){let t=x(e);t&&t.tagName||(t={namespaceURI:ge,tagName:"template"});const n=Mi(e.tagName),i=Mi(t.tagName);return!!be[e.namespaceURI]&&(e.namespaceURI===me?t.namespaceURI===ve?"svg"===n:t.namespaceURI===pe?"svg"===n&&("annotation-xml"===i||Se[i]):Boolean(De[n]):e.namespaceURI===pe?t.namespaceURI===ve?"math"===n:t.namespaceURI===me?"math"===n&&we[i]:Boolean(Me[n]):e.namespaceURI===ve?!(t.namespaceURI===me&&!we[i])&&!(t.namespaceURI===pe&&!Se[i])&&!Me[n]&&(ke[n]||!De[n]):!("application/xhtml+xml"!==Ce||!be[e.namespaceURI]))}(e)?(Fe(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!ji(/<\/no(script|embed|frames)/i,e.innerHTML)?(X&&e.nodeType===vr&&(t=e.textContent,_i([z,I,D],(e=>{t=Li(t,e," ")})),e.textContent!==t&&(Ii(n.removed,{element:e.cloneNode()}),e.textContent=t)),je(A.afterSanitizeElements,e,null),!1):(Fe(e),!0)},Ve=function(e,t,n){if(ie&&("id"===t||"name"===t)&&(n in i||n in Ae))return!1;if(q&&!H[t]&&ji(M,t));else if(W&&ji(F,t));else if(!B[t]||H[t]){if(!(Ue(e)&&(U.tagNameCheck instanceof RegExp&&ji(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&ji(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t))||"is"===t&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&ji(U.tagNameCheck,n)||U.tagNameCheck instanceof Function&&U.tagNameCheck(n))))return!1}else if(he[t]);else if(ji(N,Li(n,L,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Oi(n,"data:")||!ce[e]){if(Y&&!ji(E,Li(n,L,"")));else if(n)return!1}else;return!0},Ue=function(e){return"annotation-xml"!==e&&Ei(e,O)},Ge=function(e){je(A.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Ne(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let r=t.length;for(;r--;){const o=t[r],{name:a,namespaceURI:s,value:u}=o,l=Pe(a),c=u;let f="value"===a?c:Ni(c);if(i.attrName=l,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,je(A.uponSanitizeAttribute,e,i),f=i.attrValue,!re||"id"!==l&&"name"!==l||(Ee(a,e),f="user-content-"+f),Z&&ji(/((--!?|])>)|<\/(style|title)/i,f)){Ee(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){Ee(a,e);continue}if(!$&&ji(/\/>/i,f)){Ee(a,e);continue}X&&_i([z,I,D],(e=>{f=Li(f,e," ")}));const h=Pe(e.nodeName);if(Ve(h,l,f)){if(S&&"object"==typeof p&&"function"==typeof p.getAttributeType)if(s);else switch(p.getAttributeType(h,l)){case"TrustedHTML":f=S.createHTML(f);break;case"TrustedScriptURL":f=S.createScriptURL(f)}if(f!==c)try{s?e.setAttributeNS(s,a,f):e.setAttribute(a,f),Ne(e)?Fe(e):zi(n.removed)}catch(t){Ee(a,e)}}else Ee(a,e)}je(A.afterSanitizeAttributes,e,null)},He=function e(t){let n=null;const i=Oe(t);for(je(A.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)je(A.uponSanitizeShadowNode,n,null),Be(n),Ge(n),n.content instanceof a&&e(n.content);je(A.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,o=null,s=null,l=null;if(ye=!e,ye&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Re(e)){if("function"!=typeof e.toString)throw Bi("toString is not a function");if("string"!=typeof(e=e.toString()))throw Bi("dirty is not a string, aborting")}if(!n.isSupported)return e;if(K||Ie(t),n.removed=[],"string"==typeof e&&(ae=!1),ae){if(e.nodeName){const t=Pe(e.nodeName);if(!R[t]||G[t])throw Bi("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof u)i=Le("\x3c!----\x3e"),o=i.ownerDocument.importNode(e,!0),o.nodeType===mr&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else{if(!ee&&!X&&!Q&&-1===e.indexOf("<"))return S&&ne?S.createHTML(e):e;if(i=Le(e),!i)return ee?null:ne?w:""}i&&J&&Fe(i.firstChild);const c=Oe(ae?e:i);for(;s=c.nextNode();)Be(s),Ge(s),s.content instanceof a&&He(s.content);if(ae)return e;if(ee){if(te)for(l=T.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(B.shadowroot||B.shadowrootmode)&&(l=_.call(r,l,!0)),l}let f=Q?i.outerHTML:i.innerHTML;return Q&&R["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&ji(hr,i.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+f),X&&_i([z,I,D],(e=>{f=Li(f,e," ")})),S&&ne?S.createHTML(f):f},n.setConfig=function(){Ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),K=!0},n.clearConfig=function(){_e=null,K=!1},n.isValidAttribute=function(e,t,n){_e||Ie({});const i=Pe(e),r=Pe(t);return Ve(i,r,n)},n.addHook=function(e,t){"function"==typeof t&&Ii(A[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=Ai(A[e],t);return-1===n?void 0:Di(A[e],n,1)[0]}return zi(A[e])},n.removeHooks=function(e){A[e]=[]},n.removeAllHooks=function(){A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const wr=e=>"function"==typeof e,kr=e=>Array.isArray(e),Cr=e=>e instanceof Object,Tr=e=>e instanceof Object&&("Function"!==e.constructor.name&&"Object"!==e.constructor.name),Pr=e=>Cr(e)&&!kr(e)&&!wr(e)&&!Tr(e);function _r(e){var t;let n;if(kr(e))n=e;else{const i=bt(e),r=null==i?void 0:i.rgb();n=[(null==r?void 0:r.r)||0,(null==r?void 0:r.g)||0,(null==r?void 0:r.b)||0,null!==(t=null==i?void 0:i.opacity)&&void 0!==t?t:1]}return[n[0]/255,n[1]/255,n[2]/255,n[3]]}function Ar(e,t,n){return.2126*e+.7152*t+.0722*n}function zr(e,t){let n=new Float32Array;return e({framebuffer:t})((()=>{n=e.read()})),n}function Ir(e,t,n){return Math.min(Math.max(e,t),n)}function Dr(e){return null!=e&&!Number.isNaN(e)}function Mr(e,t){return Sr.sanitize(e,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...t})}class Fr{constructor(){this.enableSimulation=vi.enableSimulation,this.backgroundColor=mi,this.spaceSize=vi.spaceSize,this.pointColor="#b3b3b3",this.pointDefaultColor=void 0,this.pointGreyoutOpacity=undefined,this.pointGreyoutColor=pi,this.pointSize=4,this.pointOpacity=1,this.pointSizeScale=vi.pointSizeScale,this.hoveredPointCursor=vi.hoveredPointCursor,this.hoveredLinkCursor=vi.hoveredLinkCursor,this.renderHoveredPointRing=vi.renderHoveredPointRing,this.hoveredPointRingColor=vi.hoveredPointRingColor,this.focusedPointRingColor=vi.focusedPointRingColor,this.focusedPointIndex=vi.focusedPointIndex,this.linkColor="#666666",this.linkDefaultColor=void 0,this.linkOpacity=1,this.linkGreyoutOpacity=.1,this.linkWidth=1,this.linkWidthScale=vi.linkWidthScale,this.hoveredLinkColor=vi.hoveredLinkColor,this.hoveredLinkWidthIncrease=vi.hoveredLinkWidthIncrease,this.renderLinks=vi.renderLinks,this.curvedLinks=vi.curvedLinks,this.curvedLinkSegments=vi.curvedLinkSegments,this.curvedLinkWeight=vi.curvedLinkWeight,this.curvedLinkControlPointDistance=vi.curvedLinkControlPointDistance,this.linkArrows=vi.linkArrows,this.linkArrowsSizeScale=vi.linkArrowsSizeScale,this.scaleLinksOnZoom=vi.scaleLinksOnZoom,this.linkVisibilityDistanceRange=vi.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=vi.linkVisibilityMinTransparency,this.useClassicQuadtree=vi.useClassicQuadtree,this.simulationDecay=vi.simulation.decay,this.simulationGravity=vi.simulation.gravity,this.simulationCenter=vi.simulation.center,this.simulationRepulsion=vi.simulation.repulsion,this.simulationRepulsionTheta=vi.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=vi.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=vi.simulation.linkSpring,this.simulationLinkDistance=vi.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=vi.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=vi.simulation.repulsionFromMouse,this.enableRightClickRepulsion=vi.enableRightClickRepulsion,this.simulationFriction=vi.simulation.friction,this.simulationCluster=vi.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=vi.showFPSMonitor,this.pixelRatio=vi.pixelRatio,this.scalePointsOnZoom=vi.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=vi.enableZoom,this.enableSimulationDuringZoom=vi.enableSimulationDuringZoom,this.enableDrag=vi.enableDrag,this.fitViewOnInit=vi.fitViewOnInit,this.fitViewDelay=vi.fitViewDelay,this.fitViewPadding=vi.fitViewPadding,this.fitViewDuration=vi.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=vi.pointSamplingDistance,this.attribution=vi.attribution,this.rescalePositions=vi.rescalePositions}init(e){Object.keys(e).forEach((t=>{this.deepMergeConfig(this.getConfig(),e,t)}))}deepMergeConfig(e,t,n){Pr(e[n])&&Pr(t[n])?Object.keys(t[n]).forEach((i=>{this.deepMergeConfig(e[n],t[n],i)})):e[n]=t[n]}getConfig(){return this}}class Er{constructor(e,t,n,i,r){this._debugRandomNumber=Math.floor(1e3*Math.random()),this.reglInstance=e,this.config=t,this.store=n,this.data=i,r&&(this.points=r)}}function Lr(e){return{buffer:e.buffer(new Float32Array([-1,-1,1,-1,-1,1,1,1])),size:2}}function Or(e){const t=new Float32Array(e*e*2);for(let n=0;n<e;n++)for(let i=0;i<e;i++){const r=n*e*2+2*i;t[r+0]=i,t[r+1]=n}return t}var Nr="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvoid main(){gl_FragColor=vec4(0.0);}",Rr="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nattribute vec2 vertexCoord;varying vec2 textureCoords;void main(){textureCoords=(vertexCoord+1.0)/2.0;gl_Position=vec4(vertexCoord,0,1);}";class jr extends Er{create(){const{reglInstance:e,store:t}=this;this.centermassTexture||(this.centermassTexture=e.texture()),this.centermassTexture({data:new Float32Array(4).fill(0),shape:[1,1,4],type:"float"}),this.centermassFbo||(this.centermassFbo=e.framebuffer()),this.centermassFbo({color:this.centermassTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(Or(t.pointsTextureSize))}initPrograms(){const{reglInstance:e,config:t,store:n,data:i,points:r}=this;this.clearCentermassCommand||(this.clearCentermassCommand=e({frag:Nr,vert:Rr,framebuffer:()=>this.centermassFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform float pointsTextureSize;attribute vec2 pointIndices;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(positionsTexture,pointIndices/pointsTextureSize);rgba=vec4(pointPosition.xy,1.0,0.0);gl_Position=vec4(0.0,0.0,0.0,1.0);gl_PointSize=1.0;}",framebuffer:()=>this.centermassFbo,primitive:"points",count:()=>{var e;return null!==(e=i.pointsNumber)&&void 0!==e?e:0},attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>null==r?void 0:r.previousPositionFbo,pointsTextureSize:()=>n.pointsTextureSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.runCommand||(this.runCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D centermassTexture;uniform float centerForce;uniform float alpha;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 velocity=vec4(0.0);vec4 centermassValues=texture2D(centermassTexture,vec2(0.0));vec2 centermassPosition=centermassValues.xy/centermassValues.b;vec2 distVector=centermassPosition-pointPosition.xy;float dist=sqrt(dot(distVector,distVector));if(dist>0.0){float angle=atan(distVector.y,distVector.x);float addV=alpha*centerForce*dist*0.01;velocity.rg+=addV*vec2(cos(angle),sin(angle));}gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==r?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==r?void 0:r.previousPositionFbo,centermassTexture:()=>this.centermassFbo,centerForce:()=>t.simulationCenter,alpha:()=>n.alpha}}))}run(){var e,t,n;null===(e=this.clearCentermassCommand)||void 0===e||e.call(this),null===(t=this.calculateCentermassCommand)||void 0===t||t.call(this),null===(n=this.runCommand)||void 0===n||n.call(this)}}var Br;class Vr extends Er{initPrograms(){const{reglInstance:e,config:t,store:n,points:i}=this;this.runCommand||(this.runCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform float gravity;uniform float spaceSize;uniform float alpha;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 velocity=vec4(0.0);vec2 centerPosition=vec2(spaceSize/2.0);vec2 distVector=centerPosition-pointPosition.rg;float dist=sqrt(dot(distVector,distVector));if(dist>0.0){float angle=atan(distVector.y,distVector.x);float additionalVelocity=alpha*gravity*dist*0.1;velocity.rg+=additionalVelocity*vec2(cos(angle),sin(angle));}gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==i?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==i?void 0:i.previousPositionFbo,gravity:()=>t.simulationGravity,spaceSize:()=>n.adjustedSpaceSize,alpha:()=>n.alpha}}))}run(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}}!function(e){e.OUTGOING="outgoing",e.INCOMING="incoming"}(Br||(Br={}));class Ur extends Er{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){const{reglInstance:t,store:{pointsTextureSize:n,linksTextureSize:i},data:r}=this;if(!n||!i)return;this.linkFirstIndicesAndAmount=new Float32Array(n*n*4),this.indices=new Float32Array(i*i*4);const o=new Float32Array(i*i*4),a=new Float32Array(i*i*4),s=e===Br.INCOMING?r.sourceIndexToTargetIndices:r.targetIndexToSourceIndices;this.maxPointDegree=0;let u=0;null==s||s.forEach(((e,t)=>{var s,l;e&&(this.linkFirstIndicesAndAmount[4*t+0]=u%i,this.linkFirstIndicesAndAmount[4*t+1]=Math.floor(u/i),this.linkFirstIndicesAndAmount[4*t+2]=null!==(s=e.length)&&void 0!==s?s:0,e.forEach((([e,i])=>{var s,l,c,f,h,d;this.indices[4*u+0]=e%n,this.indices[4*u+1]=Math.floor(e/n);const p=null!==(l=null===(s=r.degree)||void 0===s?void 0:s[e])&&void 0!==l?l:0,m=null!==(f=null===(c=r.degree)||void 0===c?void 0:c[t])&&void 0!==f?f:0,v=p+m,g=0!==v?p/v:.5,y=Math.min(p,m);let b=null!==(d=null===(h=r.linkStrength)||void 0===h?void 0:h[i])&&void 0!==d?d:1/Math.max(y,1);b=Math.sqrt(b),o[4*u+0]=g,o[4*u+1]=b,a[4*u]=this.store.getRandomFloat(0,1),u+=1})),this.maxPointDegree=Math.max(this.maxPointDegree,null!==(l=e.length)&&void 0!==l?l:0))})),this.linkFirstIndicesAndAmountTexture||(this.linkFirstIndicesAndAmountTexture=t.texture()),this.linkFirstIndicesAndAmountTexture({data:this.linkFirstIndicesAndAmount,shape:[n,n,4],type:"float"}),this.linkFirstIndicesAndAmountFbo||(this.linkFirstIndicesAndAmountFbo=t.framebuffer()),this.linkFirstIndicesAndAmountFbo({color:this.linkFirstIndicesAndAmountTexture,depth:!1,stencil:!1}),this.indicesTexture||(this.indicesTexture=t.texture()),this.indicesTexture({data:this.indices,shape:[i,i,4],type:"float"}),this.indicesFbo||(this.indicesFbo=t.framebuffer()),this.indicesFbo({color:this.indicesTexture,depth:!1,stencil:!1}),this.biasAndStrengthTexture||(this.biasAndStrengthTexture=t.texture()),this.biasAndStrengthTexture({data:o,shape:[i,i,4],type:"float"}),this.biasAndStrengthFbo||(this.biasAndStrengthFbo=t.framebuffer()),this.biasAndStrengthFbo({color:this.biasAndStrengthTexture,depth:!1,stencil:!1}),this.randomDistanceTexture||(this.randomDistanceTexture=t.texture()),this.randomDistanceTexture({data:a,shape:[i,i,4],type:"float"}),this.randomDistanceFbo||(this.randomDistanceFbo=t.framebuffer()),this.randomDistanceFbo({color:this.randomDistanceTexture,depth:!1,stencil:!1})}initPrograms(){const{reglInstance:e,config:t,store:n,points:i}=this;this.runCommand||(this.runCommand=e({frag:()=>`\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D positionsTexture;\nuniform float linkSpring;\nuniform float linkDistance;\nuniform vec2 linkDistRandomVariationRange;\n\nuniform sampler2D linkInfoTexture; // Texture storing first link indices and amount\nuniform sampler2D linkIndicesTexture;\nuniform sampler2D linkPropertiesTexture; // Texture storing link bias and strength\nuniform sampler2D linkRandomDistanceTexture;\n\nuniform float pointsTextureSize;\nuniform float linksTextureSize;\nuniform float alpha;\n\nvarying vec2 textureCoords;\n\nconst float MAX_LINKS = ${this.maxPointDegree}.0;\n\nvoid main() {\n vec4 pointPosition = texture2D(positionsTexture, textureCoords);\n vec4 velocity = vec4(0.0);\n\n vec4 linkInfo = texture2D(linkInfoTexture, textureCoords);\n float iCount = linkInfo.r;\n float jCount = linkInfo.g;\n float linkAmount = linkInfo.b;\n if (linkAmount > 0.0) {\n for (float i = 0.0; i < MAX_LINKS; i += 1.0) {\n if (i < linkAmount) {\n if (iCount >= linksTextureSize) {\n iCount = 0.0;\n jCount += 1.0;\n }\n vec2 linkTextureIndex = (vec2(iCount, jCount) + 0.5) / linksTextureSize;\n vec4 connectedPointIndex = texture2D(linkIndicesTexture, linkTextureIndex);\n vec4 biasAndStrength = texture2D(linkPropertiesTexture, linkTextureIndex);\n vec4 randomMinDistance = texture2D(linkRandomDistanceTexture, linkTextureIndex);\n float bias = biasAndStrength.r;\n float strength = biasAndStrength.g;\n float randomMinLinkDist = randomMinDistance.r * (linkDistRandomVariationRange.g - linkDistRandomVariationRange.r) + linkDistRandomVariationRange.r;\n randomMinLinkDist *= linkDistance;\n\n iCount += 1.0;\n\n vec4 connectedPointPosition = texture2D(positionsTexture, (connectedPointIndex.rg + 0.5) / pointsTextureSize);\n float x = connectedPointPosition.x - (pointPosition.x + velocity.x);\n float y = connectedPointPosition.y - (pointPosition.y + velocity.y);\n float l = sqrt(x * x + y * y);\n\n // Apply the link force\n l = max(l, randomMinLinkDist * 0.99);\n l = (l - randomMinLinkDist) / l;\n l *= linkSpring * alpha;\n l *= strength;\n l *= bias;\n x *= l;\n y *= l;\n velocity.x += x;\n velocity.y += y;\n }\n }\n }\n\n gl_FragColor = vec4(velocity.rg, 0.0, 0.0);\n}\n `,vert:Rr,framebuffer:()=>null==i?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==i?void 0:i.previousPositionFbo,linkSpring:()=>t.simulationLinkSpring,linkDistance:()=>t.simulationLinkDistance,linkDistRandomVariationRange:()=>t.simulationLinkDistRandomVariationRange,linkInfoTexture:()=>this.linkFirstIndicesAndAmountFbo,linkIndicesTexture:()=>this.indicesFbo,linkPropertiesTexture:()=>this.biasAndStrengthFbo,linkRandomDistanceTexture:()=>this.randomDistanceFbo,pointsTextureSize:()=>n.pointsTextureSize,linksTextureSize:()=>n.linksTextureSize,alpha:()=>n.alpha}}))}run(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}}var Gr="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",Hr="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform float pointsTextureSize;uniform float levelTextureSize;uniform float cellSize;attribute vec2 pointIndices;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(positionsTexture,pointIndices/pointsTextureSize);rgba=vec4(pointPosition.rg,1.0,0.0);float n=floor(pointPosition.x/cellSize);float m=floor(pointPosition.y/cellSize);vec2 levelPosition=2.0*(vec2(n,m)+0.5)/levelTextureSize-1.0;gl_Position=vec4(levelPosition,0.0,1.0);gl_PointSize=1.0;}";class Wr extends Er{constructor(){super(...arguments),this.levelsFbos=new Map,this.quadtreeLevels=0}create(){const{reglInstance:e,store:t}=this;if(!t.pointsTextureSize)return;this.quadtreeLevels=Math.log2(t.adjustedSpaceSize);for(let t=0;t<this.quadtreeLevels;t+=1){const n=Math.pow(2,t+1);this.levelsFbos.has(`level[${t}]`)||this.levelsFbos.set(`level[${t}]`,e.framebuffer());const i=this.levelsFbos.get(`level[${t}]`);i&&i({shape:[n,n],colorType:"float",depth:!1,stencil:!1})}const n=new Float32Array(t.pointsTextureSize*t.pointsTextureSize*4);for(let e=0;e<t.pointsTextureSize*t.pointsTextureSize;++e)n[4*e]=1e-5*t.getRandomFloat(-1,1),n[4*e+1]=1e-5*t.getRandomFloat(-1,1);this.randomValuesTexture||(this.randomValuesTexture=e.texture()),this.randomValuesTexture({data:n,shape:[t.pointsTextureSize,t.pointsTextureSize,4],type:"float"}),this.randomValuesFbo||(this.randomValuesFbo=e.framebuffer()),this.randomValuesFbo({color:this.randomValuesTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(Or(t.pointsTextureSize))}initPrograms(){const{reglInstance:e,config:t,store:n,data:i,points:r}=this;this.clearLevelsCommand||(this.clearLevelsCommand=e({frag:Nr,vert:Rr,framebuffer:(e,t)=>t.levelFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=e({frag:Gr,vert:Hr,framebuffer:(e,t)=>t.levelFbo,primitive:"points",count:()=>{var e;return null!==(e=i.pointsNumber)&&void 0!==e?e:0},attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>null==r?void 0:r.previousPositionFbo,pointsTextureSize:()=>n.pointsTextureSize,levelTextureSize:(e,t)=>t.levelTextureSize,cellSize:(e,t)=>t.cellSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.forceCommand||(this.forceCommand=e({frag:"\n#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D levelFbo;uniform float level;uniform float levels;uniform float levelTextureSize;uniform float repulsion;uniform float alpha;uniform float spaceSize;uniform float theta;varying vec2 textureCoords;const float MAX_LEVELS_NUM=14.0;vec2 calculateAdditionalVelocity(vec2 ij,vec2 pp){vec2 add=vec2(0.0);vec4 centermass=texture2D(levelFbo,ij);if(centermass.r>0.0&&centermass.g>0.0&&centermass.b>0.0){vec2 centermassPosition=vec2(centermass.rg/centermass.b);vec2 distVector=pp-centermassPosition;float l=dot(distVector,distVector);float dist=sqrt(l);if(l>0.0){float c=alpha*repulsion*centermass.b;float distanceMin2=1.0;if(l<distanceMin2)l=sqrt(distanceMin2*l);float addV=c/sqrt(l);add=addV*normalize(distVector);}}return add;}void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);float x=pointPosition.x;float y=pointPosition.y;float left=0.0;float top=0.0;float right=spaceSize;float bottom=spaceSize;float n_left=0.0;float n_top=0.0;float n_right=0.0;float n_bottom=0.0;float cellSize=0.0;for(float i=0.0;i<MAX_LEVELS_NUM;i+=1.0){if(i<=level){left+=cellSize*n_left;top+=cellSize*n_top;right-=cellSize*n_right;bottom-=cellSize*n_bottom;cellSize=pow(2.0,levels-i-1.0);float dist_left=x-left;n_left=max(0.0,floor(dist_left/cellSize-theta));float dist_top=y-top;n_top=max(0.0,floor(dist_top/cellSize-theta));float dist_right=right-x;n_right=max(0.0,floor(dist_right/cellSize-theta));float dist_bottom=bottom-y;n_bottom=max(0.0,floor(dist_bottom/cellSize-theta));}}vec4 velocity=vec4(vec2(0.0),1.0,0.0);for(float i=0.0;i<12.0;i+=1.0){for(float j=0.0;j<4.0;j+=1.0){float n=left+cellSize*j;float m=top+cellSize*n_top+cellSize*i;if(n<(left+n_left*cellSize)&&m<bottom){velocity.xy+=calculateAdditionalVelocity(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=left+cellSize*i;m=top+cellSize*j;if(n<(right-n_right*cellSize)&&m<(top+n_top*cellSize)){velocity.xy+=calculateAdditionalVelocity(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=right-n_right*cellSize+cellSize*j;m=top+cellSize*i;if(n<right&&m<(bottom-n_bottom*cellSize)){velocity.xy+=calculateAdditionalVelocity(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=left+n_left*cellSize+cellSize*i;m=bottom-n_bottom*cellSize+cellSize*j;if(n<right&&m<bottom){velocity.xy+=calculateAdditionalVelocity(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}}}gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==r?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==r?void 0:r.previousPositionFbo,level:(e,t)=>t.level,levels:this.quadtreeLevels,levelFbo:(e,t)=>t.levelFbo,levelTextureSize:(e,t)=>t.levelTextureSize,alpha:()=>n.alpha,repulsion:()=>t.simulationRepulsion,spaceSize:()=>n.adjustedSpaceSize,theta:()=>t.simulationRepulsionTheta},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.forceFromItsOwnCentermassCommand||(this.forceFromItsOwnCentermassCommand=e({frag:"\n#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D levelFbo;uniform sampler2D randomValues;uniform float levelTextureSize;uniform float repulsion;uniform float alpha;varying vec2 textureCoords;vec2 calculateAdditionalVelocity(vec2 ij,vec2 pp){vec2 add=vec2(0.0);vec4 centermass=texture2D(levelFbo,ij);if(centermass.r>0.0&&centermass.g>0.0&&centermass.b>0.0){vec2 centermassPosition=vec2(centermass.rg/centermass.b);vec2 distVector=pp-centermassPosition;float l=dot(distVector,distVector);float dist=sqrt(l);if(l>0.0){float angle=atan(distVector.y,distVector.x);float c=alpha*repulsion*centermass.b;float distanceMin2=1.0;if(l<distanceMin2)l=sqrt(distanceMin2*l);float addV=c/sqrt(l);add=addV*vec2(cos(angle),sin(angle));}}return add;}void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 random=texture2D(randomValues,textureCoords);vec4 velocity=vec4(0.0);velocity.xy+=calculateAdditionalVelocity(pointPosition.xy/levelTextureSize,pointPosition.xy);velocity.xy+=velocity.xy*random.rg;gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==r?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==r?void 0:r.previousPositionFbo,randomValues:()=>this.randomValuesFbo,levelFbo:(e,t)=>t.levelFbo,levelTextureSize:(e,t)=>t.levelTextureSize,alpha:()=>n.alpha,repulsion:()=>t.simulationRepulsion,spaceSize:()=>n.adjustedSpaceSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.clearVelocityCommand||(this.clearVelocityCommand=e({frag:Nr,vert:Rr,framebuffer:()=>null==r?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}}))}run(){var e,t,n,i,r;const{store:o}=this;for(let n=0;n<this.quadtreeLevels;n+=1){null===(e=this.clearLevelsCommand)||void 0===e||e.call(this,{levelFbo:this.levelsFbos.get(`level[${n}]`)});const i=Math.pow(2,n+1),r=o.adjustedSpaceSize/i;null===(t=this.calculateLevelsCommand)||void 0===t||t.call(this,{levelFbo:this.levelsFbos.get(`level[${n}]`),levelTextureSize:i,cellSize:r})}null===(n=this.clearVelocityCommand)||void 0===n||n.call(this);for(let e=0;e<this.quadtreeLevels;e+=1){const t=Math.pow(2,e+1);null===(i=this.forceCommand)||void 0===i||i.call(this,{levelFbo:this.levelsFbos.get(`level[${e}]`),levelTextureSize:t,level:e}),e===this.quadtreeLevels-1&&(null===(r=this.forceFromItsOwnCentermassCommand)||void 0===r||r.call(this,{levelFbo:this.levelsFbos.get(`level[${e}]`),levelTextureSize:t,level:e}))}}}function qr(e,t){e=Math.min(e,t);const n=t-e,i="\n float dist = sqrt(l);\n if (dist > 0.0) {\n float c = alpha * repulsion * centermass.b;\n addVelocity += calcAdd(vec2(x, y), l, c);\n addVelocity += addVelocity * random.rg;\n }\n ";return`\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D positionsTexture;\nuniform sampler2D randomValues;\nuniform float spaceSize;\nuniform float repulsion;\nuniform float theta;\nuniform float alpha;\nuniform sampler2D level[${t}];\nvarying vec2 textureCoords;\n\nvec2 calcAdd(vec2 xy, float l, float c) {\n float distanceMin2 = 1.0;\n if (l < distanceMin2) l = sqrt(distanceMin2 * l);\n float add = c / l;\n return add * xy;\n}\n\nvoid main() {\n vec4 pointPosition = texture2D(positionsTexture, textureCoords);\n vec4 random = texture2D(randomValues, textureCoords);\n\n float width0 = spaceSize;\n\n vec2 velocity = vec2(0.0);\n vec2 addVelocity = vec2(0.0);\n\n ${new Array(t).fill(0).map(((e,t)=>`float width${t+1} = width${t} / 2.0;`)).join("\n")}\n\n for (float n = 0.0; n < pow(2.0, ${n}.0); n += 1.0) {\n for (float m = 0.0; m < pow(2.0, ${n}.0); m += 1.0) {\n ${function r(o){if(o>=t)return i;{const t=Math.pow(2,o+1),a=new Array(o+1-n).fill(0).map(((e,t)=>`pow(2.0, ${o-(t+n)}.0) * i${t+n}`)).join("+"),s=new Array(o+1-n).fill(0).map(((e,t)=>`pow(2.0, ${o-(t+n)}.0) * j${t+n}`)).join("+");return`\n for (float ij${o} = 0.0; ij${o} < 4.0; ij${o} += 1.0) {\n float i${o} = 0.0;\n float j${o} = 0.0;\n if (ij${o} == 1.0 || ij${o} == 3.0) i${o} = 1.0;\n if (ij${o} == 2.0 || ij${o} == 3.0) j${o} = 1.0;\n float i = pow(2.0, ${e}.0) * n / width${o+1} + ${a};\n float j = pow(2.0, ${e}.0) * m / width${o+1} + ${s};\n float groupPosX = (i + 0.5) / ${t}.0;\n float groupPosY = (j + 0.5) / ${t}.0;\n \n vec4 centermass = texture2D(level[${o}], vec2(groupPosX, groupPosY));\n if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {\n float x = centermass.r / centermass.b - pointPosition.r;\n float y = centermass.g / centermass.b - pointPosition.g;\n float l = x * x + y * y;\n if ((width${o+1} * width${o+1}) / theta < l) {\n ${i}\n } else {\n ${r(o+1)}\n }\n }\n }\n `}}(n)}\n }\n }\n\n velocity -= addVelocity;\n\n gl_FragColor = vec4(velocity, 0.0, 0.0);\n}\n`}class Yr extends Er{constructor(){super(...arguments),this.levelsTextures=new Map,this.levelsFbos=new Map,this.quadtreeLevels=0}create(){const{reglInstance:e,store:t}=this;if(!t.pointsTextureSize)return;this.quadtreeLevels=Math.log2(t.adjustedSpaceSize);for(let t=0;t<this.quadtreeLevels;t+=1){const n=Math.pow(2,t+1),i=`level[${t}]`;this.levelsTextures.has(i)||this.levelsTextures.set(i,e.texture());const r=this.levelsTextures.get(i);r&&r({data:new Float32Array(n*n*4),shape:[n,n,4],type:"float"}),this.levelsFbos.has(i)||this.levelsFbos.set(i,e.framebuffer());const o=this.levelsFbos.get(i);o&&o({color:this.levelsTextures.get(i),depth:!1,stencil:!1})}const n=new Float32Array(t.pointsTextureSize*t.pointsTextureSize*4);for(let e=0;e<t.pointsTextureSize*t.pointsTextureSize;++e)n[4*e]=1e-5*t.getRandomFloat(-1,1),n[4*e+1]=1e-5*t.getRandomFloat(-1,1);this.randomValuesTexture||(this.randomValuesTexture=e.texture()),this.randomValuesTexture({data:n,shape:[t.pointsTextureSize,t.pointsTextureSize,4],type:"float"}),this.randomValuesFbo||(this.randomValuesFbo=e.framebuffer()),this.randomValuesFbo({color:this.randomValuesTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(Or(t.pointsTextureSize))}initPrograms(){var e;const{reglInstance:t,config:n,store:i,data:r,points:o}=this;this.clearLevelsCommand||(this.clearLevelsCommand=t({frag:Nr,vert:Rr,framebuffer:(e,t)=>t.levelFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(t)}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=t({frag:Gr,vert:Hr,framebuffer:(e,t)=>t.levelFbo,primitive:"points",count:()=>{var e;return null!==(e=r.pointsNumber)&&void 0!==e?e:0},attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>null==o?void 0:o.previousPositionFbo,pointsTextureSize:()=>i.pointsTextureSize,levelTextureSize:(e,t)=>t.levelTextureSize,cellSize:(e,t)=>t.cellSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.quadtreeCommand=t({frag:qr(null!==(e=n.simulationRepulsionQuadtreeLevels)&&void 0!==e?e:this.quadtreeLevels,this.quadtreeLevels),vert:Rr,framebuffer:()=>null==o?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(t)},uniforms:{positionsTexture:()=>null==o?void 0:o.previousPositionFbo,randomValues:()=>this.randomValuesFbo,spaceSize:()=>i.adjustedSpaceSize,repulsion:()=>n.simulationRepulsion,theta:()=>n.simulationRepulsionTheta,alpha:()=>i.alpha,...Object.fromEntries(this.levelsFbos)}})}run(){var e,t,n;const{store:i}=this;for(let n=0;n<this.quadtreeLevels;n+=1){null===(e=this.clearLevelsCommand)||void 0===e||e.call(this,{levelFbo:this.levelsFbos.get(`level[${n}]`)});const r=Math.pow(2,n+1),o=i.adjustedSpaceSize/r;null===(t=this.calculateLevelsCommand)||void 0===t||t.call(this,{levelFbo:this.levelsFbos.get(`level[${n}]`),levelTextureSize:r,cellSize:o})}null===(n=this.quadtreeCommand)||void 0===n||n.call(this)}}class $r extends Er{initPrograms(){const{reglInstance:e,config:t,store:n,points:i}=this;this.runCommand||(this.runCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform float repulsion;uniform vec2 mousePos;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 velocity=vec4(0.0);vec2 mouse=mousePos;vec2 distVector=mouse-pointPosition.rg;float dist=sqrt(dot(distVector,distVector));dist=max(dist,10.0);float angle=atan(distVector.y,distVector.x);float addV=100.0*repulsion/(dist*dist);velocity.rg-=addV*vec2(cos(angle),sin(angle));gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==i?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==i?void 0:i.previousPositionFbo,mousePos:()=>n.mousePosition,repulsion:()=>t.simulationRepulsionFromMouse}}))}run(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}}class Xr extends Er{create(){var e,t,n,i,r;const{reglInstance:o,store:a,data:s}=this,{pointsTextureSize:u}=a;if(void 0===s.pointsNumber||!s.pointClusters&&!s.clusterPositions)return;this.clusterCount=(null!==(e=s.pointClusters)&&void 0!==e?e:[]).reduce(((e,t)=>void 0===t||t<0?e:Math.max(e,t)),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const l=new Float32Array(u*u*4),c=new Float32Array(this.clustersTextureSize*this.clustersTextureSize*4).fill(-1),f=new Float32Array(u*u*4).fill(1);if(s.clusterPositions)for(let e=0;e<this.clusterCount;++e)c[4*e+0]=null!==(t=s.clusterPositions[2*e+0])&&void 0!==t?t:-1,c[4*e+1]=null!==(n=s.clusterPositions[2*e+1])&&void 0!==n?n:-1;for(let e=0;e<s.pointsNumber;++e){const t=null===(i=s.pointClusters)||void 0===i?void 0:i[e];void 0===t?(l[4*e+0]=-1,l[4*e+1]=-1):(l[4*e+0]=t%this.clustersTextureSize,l[4*e+1]=Math.floor(t/this.clustersTextureSize)),s.clusterStrength&&(f[4*e+0]=null!==(r=s.clusterStrength[e])&&void 0!==r?r:1)}this.clusterTexture||(this.clusterTexture=o.texture()),this.clusterTexture({data:l,shape:[u,u,4],type:"float"}),this.clusterFbo||(this.clusterFbo=o.framebuffer()),this.clusterFbo({color:this.clusterTexture,depth:!1,stencil:!1}),this.clusterPositionsTexture||(this.clusterPositionsTexture=o.texture()),this.clusterPositionsTexture({data:c,shape:[this.clustersTextureSize,this.clustersTextureSize,4],type:"float"}),this.clusterPositionsFbo||(this.clusterPositionsFbo=o.framebuffer()),this.clusterPositionsFbo({color:this.clusterPositionsTexture,depth:!1,stencil:!1}),this.clusterForceCoefficientTexture||(this.clusterForceCoefficientTexture=o.texture()),this.clusterForceCoefficientTexture({data:f,shape:[u,u,4],type:"float"}),this.clusterForceCoefficientFbo||(this.clusterForceCoefficientFbo=o.framebuffer()),this.clusterForceCoefficientFbo({color:this.clusterForceCoefficientTexture,depth:!1,stencil:!1}),this.centermassTexture||(this.centermassTexture=o.texture()),this.centermassTexture({data:new Float32Array(this.clustersTextureSize*this.clustersTextureSize*4).fill(0),shape:[this.clustersTextureSize,this.clustersTextureSize,4],type:"float"}),this.centermassFbo||(this.centermassFbo=o.framebuffer()),this.centermassFbo({color:this.centermassTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=o.buffer(0)),this.pointIndices(Or(a.pointsTextureSize))}initPrograms(){const{reglInstance:e,store:t,data:n,points:i}=this;void 0!==n.pointClusters&&(this.clearCentermassCommand||(this.clearCentermassCommand=e({frag:Nr,vert:Rr,framebuffer:()=>this.centermassFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D clusterTexture;uniform float pointsTextureSize;uniform float clustersTextureSize;attribute vec2 pointIndices;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(positionsTexture,pointIndices/pointsTextureSize);rgba=vec4(pointPosition.xy,1.0,0.0);vec4 pointClusterIndices=texture2D(clusterTexture,pointIndices/pointsTextureSize);vec2 xy=vec2(0.0);if(pointClusterIndices.x>=0.0&&pointClusterIndices.y>=0.0){xy=2.0*(pointClusterIndices.xy+0.5)/clustersTextureSize-1.0;}gl_Position=vec4(xy,0.0,1.0);gl_PointSize=1.0;}",framebuffer:()=>this.centermassFbo,primitive:"points",count:()=>{var e;return null!==(e=n.pointsNumber)&&void 0!==e?e:0},attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>null==i?void 0:i.previousPositionFbo,pointsTextureSize:()=>t.pointsTextureSize,clusterTexture:()=>this.clusterFbo,clustersTextureSize:()=>this.clustersTextureSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.applyForcesCommand||(this.applyForcesCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D centermassTexture;uniform sampler2D clusterTexture;uniform sampler2D clusterPositionsTexture;uniform sampler2D clusterForceCoefficient;uniform float alpha;uniform float clustersTextureSize;uniform float clusterCoefficient;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 velocity=vec4(0.0);vec4 pointClusterIndices=texture2D(clusterTexture,textureCoords);if(pointClusterIndices.x>=0.0&&pointClusterIndices.y>=0.0){vec2 clusterPositions=texture2D(clusterPositionsTexture,pointClusterIndices.xy/clustersTextureSize).xy;if(clusterPositions.x<0.0||clusterPositions.y<0.0){vec4 centermassValues=texture2D(centermassTexture,pointClusterIndices.xy/clustersTextureSize);clusterPositions=centermassValues.xy/centermassValues.b;}vec4 clusterCustomCoeff=texture2D(clusterForceCoefficient,textureCoords);vec2 distVector=clusterPositions.xy-pointPosition.xy;float dist=length(distVector);if(dist>0.0){float addV=alpha*dist*clusterCoefficient*clusterCustomCoeff.r;velocity.rg+=addV*normalize(distVector);}}gl_FragColor=velocity;}",vert:Rr,framebuffer:()=>null==i?void 0:i.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>null==i?void 0:i.previousPositionFbo,clusterTexture:()=>this.clusterFbo,centermassTexture:()=>this.centermassFbo,clusterPositionsTexture:()=>this.clusterPositionsFbo,clusterForceCoefficient:()=>this.clusterForceCoefficientFbo,alpha:()=>t.alpha,clustersTextureSize:()=>this.clustersTextureSize,clusterCoefficient:()=>this.config.simulationCluster}})))}calculateCentermass(){var e,t;null===(e=this.clearCentermassCommand)||void 0===e||e.call(this),null===(t=this.calculateCentermassCommand)||void 0===t||t.call(this)}run(){var e;(this.data.pointClusters||this.data.clusterPositions)&&(this.calculateCentermass(),null===(e=this.applyForcesCommand)||void 0===e||e.call(this))}}var Zr={exports:{}};!function(e,t){e.exports=function(){var e='<div class="gl-box">\n <svg viewBox="0 0 55 60">\n <text x="27" y="56" class="gl-fps">00 FPS</text>\n <text x="28" y="8" class="gl-mem"></text>\n <rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect>\n <polyline class="gl-chart"></polyline>\n </svg>\n <svg viewBox="0 0 14 60" class="gl-cpu-svg">\n <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>\n <line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/>\n <path d="M5.35 43c-.464 0-.812.377-.812.812v1.16c-.783.1972-1.421.812-1.595 1.624h-1.16c-.435 0-.812.348-.812.812s.348.812.812.812h1.102v1.653H1.812c-.464 0-.812.377-.812.812 0 .464.377.812.812.812h1.131c.1943.783.812 1.392 1.595 1.595v1.131c0 .464.377.812.812.812.464 0 .812-.377.812-.812V53.15h1.653v1.073c0 .464.377.812.812.812.464 0 .812-.377.812-.812v-1.131c.783-.1943 1.392-.812 1.595-1.595h1.131c.464 0 .812-.377.812-.812 0-.464-.377-.812-.812-.812h-1.073V48.22h1.102c.435 0 .812-.348.812-.812s-.348-.812-.812-.812h-1.16c-.1885-.783-.812-1.421-1.595-1.624v-1.131c0-.464-.377-.812-.812-.812-.464 0-.812.377-.812.812v1.073H6.162v-1.073c0-.464-.377-.812-.812-.812zm.58 3.48h2.088c.754 0 1.363.609 1.363 1.363v2.088c0 .754-.609 1.363-1.363 1.363H5.93c-.754 0-1.363-.609-1.363-1.363v-2.088c0-.754.609-1.363 1.363-1.363z"/>\n </svg>\n <svg viewBox="0 0 14 60" class="gl-gpu-svg">\n <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>\n <line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>\n <path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z"/>\n </svg>\n</div>',t="#gl-bench {\n position:absolute;\n left:0;\n top:0;\n z-index:1000;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n#gl-bench div {\n position: relative;\n display: block;\n margin: 4px;\n padding: 0 7px 0 10px;\n background: #6c6;\n border-radius: 15px;\n cursor: pointer;\n opacity: 0.9;\n}\n\n#gl-bench svg {\n height: 60px;\n margin: 0 -1px;\n}\n\n#gl-bench text {\n font-size: 12px;\n font-family: Helvetica,Arial,sans-serif;\n font-weight: 700;\n dominant-baseline: middle;\n text-anchor: middle;\n}\n\n#gl-bench .gl-mem {\n font-size: 9px;\n}\n\n#gl-bench line {\n stroke-width: 5;\n stroke: #112211;\n stroke-linecap: round;\n}\n\n#gl-bench polyline {\n fill: none;\n stroke: #112211;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-width: 3.5;\n}\n\n#gl-bench rect {\n fill: #448844;\n}\n\n#gl-bench .opacity {\n stroke: #448844;\n}\n";class n{constructor(n,i={}){this.css=t,this.svg=e,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"],(e=>{e.style.display=this.trackGPU?"inline":"none"}))},Object.assign(this,i),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let r,o,a=0,s=e=>{++a<20?r=requestAnimationFrame(s):(this.detected=Math.ceil(1e3*a/(e-o)/70),cancelAnimationFrame(r)),o||(o=e)};if(requestAnimationFrame(s),n){const e=async(e,t)=>Promise.resolve(setTimeout((()=>{n.getError();const i=this.now()-e;t.forEach(((e,t)=>{e&&(this.gpuAccums[t]+=i)}))}),0)),t=(t,n,i)=>function(){const r=n.now();t.apply(i,arguments),n.trackGPU&&n.finished.push(e(r,n.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach((e=>{n[e]&&(n[e]=t(n[e],this,n))})),n.getExtension=((e,i)=>function(){let r=e.apply(n,arguments);return r&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach((e=>{r[e]&&(r[e]=t(r[e],i,r))})),r})(n.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let e=document.createElement("div");e.id="gl-bench",this.dom.appendChild(e),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=e,this.dom.addEventListener("click",(()=>{this.trackGPU=!this.trackGPU,this.updateUI()})),this.paramLogger=((e,t,n)=>{const i=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],r=Object.assign({},i);return i.forEach((e=>r[e]=t.getElementsByClassName(e))),this.nodes=r,(t,i,o,a,s,u,l)=>{r["gl-cpu"][t].style.strokeDasharray=(.27*i).toFixed(0)+" 100",r["gl-gpu"][t].style.strokeDasharray=(.27*o).toFixed(0)+" 100",r["gl-mem"][t].innerHTML=n[t]?n[t]:a?"mem: "+a.toFixed(0)+"mb":"",r["gl-fps"][t].innerHTML=s.toFixed(0)+" FPS",e(n[t],i,o,a,s,u,l)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((e,t)=>{let n={"gl-chart":this.dom.getElementsByClassName("gl-chart")};return(t,i,r)=>{let o="",a=i.length;for(let e=0;e<a;e++){let t=(r+e+1)%a;null!=i[t]&&(o=o+" "+(55*e/(a-1)).toFixed(1)+","+(45-22*i[t]/60/this.detected).toFixed(1))}n["gl-chart"][t].setAttribute("points",o),e(this.names[t],i,r)}})(this.chartLogger)}}addUI(e){-1==this.names.indexOf(e)&&(this.names.push(e),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(e){this.frameId++;const t=e||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=t;else{let e=t-this.paramTime;if(e>=1e3){const n=this.frameId-this.paramFrame,i=n/e*1e3;for(let t=0;t<this.names.length;t++){const r=this.cpuAccums[t]/e*100,o=this.gpuAccums[t]/e*100,a=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(t,r,o,a,i,e,n),this.cpuAccums[t]=0,Promise.all(this.finished).then((()=>{this.gpuAccums[t]=0,this.finished=[]}))}this.paramFrame=this.frameId,this.paramTime=t}}if(this.detected&&this.chartFrame){let e=t-this.chartTime,n=this.chartHz*e/1e3;for(;--n>0&&this.detected;){const n=(this.frameId-this.chartFrame)/e*1e3;this.chart[this.circularId%this.chartLen]=n;for(let e=0;e<this.names.length;e++)this.chartLogger(e,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=t}}else this.chartFrame=this.frameId,this.chartTime=t,this.circularId=0}begin(e){this.updateAccums(e)}end(e){this.updateAccums(e)}updateAccums(e){let t=this.names.indexOf(e);-1==t&&(t=this.names.length,this.addUI(e));const n=this.now(),i=n-this.t0;for(let e=0;e<t+1;e++)this.activeAccums[e]&&(this.cpuAccums[e]+=i);this.activeAccums[t]=!this.activeAccums[t],this.t0=n}}return n}()}(Zr);var Qr=Zr.exports;class Kr{constructor(e){this.destroy();const t=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new Qr(t,{css:"\n #gl-bench {\n position:absolute;\n right:0;\n top:0;\n z-index:1000;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n #gl-bench div {\n position: relative;\n display: block;\n margin: 4px;\n padding: 0 7px 0 10px;\n background: #5f69de;\n border-radius: 15px;\n cursor: pointer;\n opacity: 0.9;\n }\n #gl-bench svg {\n height: 60px;\n margin: 0 -1px;\n }\n #gl-bench text {\n font-size: 12px;\n font-family: Helvetica,Arial,sans-serif;\n font-weight: 700;\n dominant-baseline: middle;\n text-anchor: middle;\n }\n #gl-bench .gl-mem {\n font-size: 9px;\n }\n #gl-bench line {\n stroke-width: 5;\n stroke: #112211;\n stroke-linecap: round;\n }\n #gl-bench polyline {\n fill: none;\n stroke: #112211;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-width: 3.5;\n }\n #gl-bench rect {\n fill: #8288e4;\n }\n #gl-bench .opacity {\n stroke: #8288e4;\n }\n"})}begin(){var e;null===(e=this.bench)||void 0===e||e.begin("frame")}end(e){var t,n;null===(t=this.bench)||void 0===t||t.end("frame"),null===(n=this.bench)||void 0===n||n.nextFrame(e)}destroy(){this.bench=void 0,de("#gl-bench").remove()}}var Jr;e.PointShape=void 0,(Jr=e.PointShape||(e.PointShape={}))[Jr.Circle=0]="Circle",Jr[Jr.Square=1]="Square",Jr[Jr.Triangle=2]="Triangle",Jr[Jr.Diamond=3]="Diamond",Jr[Jr.Pentagon=4]="Pentagon",Jr[Jr.Hexagon=5]="Hexagon",Jr[Jr.Star=6]="Star",Jr[Jr.Cross=7]="Cross",Jr[Jr.None=8]="None";class eo{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(){var e;if(void 0===this.pointsNumber)return void(this.pointColors=void 0);const t=_r(null!==(e=this._config.pointDefaultColor)&&void 0!==e?e:this._config.pointColor);if(void 0===this.inputPointColors||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(4*this.pointsNumber);for(let e=0;e<this.pointColors.length/4;e++)this.pointColors[4*e]=t[0],this.pointColors[4*e+1]=t[1],this.pointColors[4*e+2]=t[2],this.pointColors[4*e+3]=t[3]}else{this.pointColors=this.inputPointColors;for(let e=0;e<this.pointColors.length/4;e++)Dr(this.pointColors[4*e])||(this.pointColors[4*e]=t[0]),Dr(this.pointColors[4*e+1])||(this.pointColors[4*e+1]=t[1]),Dr(this.pointColors[4*e+2])||(this.pointColors[4*e+2]=t[2]),Dr(this.pointColors[4*e+3])||(this.pointColors[4*e+3]=t[3])}}updatePointSize(){if(void 0!==this.pointsNumber)if(void 0===this.inputPointSizes||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointSizes=this.inputPointSizes;for(let e=0;e<this.pointSizes.length;e++)Dr(this.pointSizes[e])||(this.pointSizes[e]=this._config.pointSize)}else this.pointSizes=void 0}updatePointShape(){if(void 0===this.pointsNumber)return void(this.pointShapes=void 0);const t=e.PointShape.Circle;if(void 0===this.inputPointShapes||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(t);else{this.pointShapes=new Float32Array(this.inputPointShapes);const e=this.pointShapes;for(let n=0;n<e.length;n++){const i=e[n];(null==i||!Dr(i)||i<0||i>8)&&(e[n]=t)}}}updatePointImageIndices(){if(void 0!==this.pointsNumber)if(void 0===this.inputPointImageIndices||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let t=0;t<e.length;t++){const n=e[t],i=void 0===n?NaN:n;!Number.isFinite(i)||i<0?e[t]=-1:e[t]=Math.trunc(i)}this.pointImageIndices=e}else this.pointImageIndices=void 0}updatePointImageSizes(){var e,t;if(void 0!==this.pointsNumber)if(void 0===this.inputPointImageSizes||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let n=0;n<this.pointImageSizes.length;n++)Dr(this.pointImageSizes[n])||(this.pointImageSizes[n]=null!==(t=null===(e=this.pointSizes)||void 0===e?void 0:e[n])&&void 0!==t?t:this._config.pointSize)}else this.pointImageSizes=void 0}updateLinks(){this.links=this.inputLinks}updateLinkColor(){var e;if(void 0===this.linksNumber)return void(this.linkColors=void 0);const t=_r(null!==(e=this._config.linkDefaultColor)&&void 0!==e?e:this._config.linkColor);if(void 0===this.inputLinkColors||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(4*this.linksNumber);for(let e=0;e<this.linkColors.length/4;e++)this.linkColors[4*e]=t[0],this.linkColors[4*e+1]=t[1],this.linkColors[4*e+2]=t[2],this.linkColors[4*e+3]=t[3]}else{this.linkColors=this.inputLinkColors;for(let e=0;e<this.linkColors.length/4;e++)Dr(this.linkColors[4*e])||(this.linkColors[4*e]=t[0]),Dr(this.linkColors[4*e+1])||(this.linkColors[4*e+1]=t[1]),Dr(this.linkColors[4*e+2])||(this.linkColors[4*e+2]=t[2]),Dr(this.linkColors[4*e+3])||(this.linkColors[4*e+3]=t[3])}}updateLinkWidth(){if(void 0!==this.linksNumber)if(void 0===this.inputLinkWidths||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(this._config.linkWidth);else{this.linkWidths=this.inputLinkWidths;for(let e=0;e<this.linkWidths.length;e++)Dr(this.linkWidths[e])||(this.linkWidths[e]=this._config.linkWidth)}else this.linkWidths=void 0}updateArrows(){void 0!==this.linksNumber?void 0===this.linkArrowsBoolean||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+this._config.linkArrows):this.linkArrows=this.linkArrowsBoolean.map((e=>+e)):this.linkArrows=void 0}updateLinkStrength(){void 0===this.linksNumber&&(this.linkStrength=void 0),void 0===this.inputLinkStrength||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(void 0===this.pointsNumber)return this.pointClusters=void 0,void(this.clusterPositions=void 0);void 0===this.inputPointClusters||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,void 0===this.inputClusterPositions?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,void 0===this.inputClusterStrength||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var t,n,i,r;return[...(null===(n=null===(t=this.sourceIndexToTargetIndices)||void 0===t?void 0:t[e])||void 0===n?void 0:n.map((e=>e[0])))||[],...(null===(r=null===(i=this.targetIndexToSourceIndices)||void 0===i?void 0:i[e])||void 0===r?void 0:r.map((e=>e[0])))||[]]}_createAdjacencyLists(){var e,t;if(void 0===this.linksNumber||void 0===this.links)return this.sourceIndexToTargetIndices=void 0,void(this.targetIndexToSourceIndices=void 0);this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let n=0;n<this.linksNumber;n++){const i=this.links[2*n],r=this.links[2*n+1];void 0!==i&&void 0!==r&&(void 0===this.sourceIndexToTargetIndices[i]&&(this.sourceIndexToTargetIndices[i]=[]),null===(e=this.sourceIndexToTargetIndices[i])||void 0===e||e.push([r,n]),void 0===this.targetIndexToSourceIndices[r]&&(this.targetIndexToSourceIndices[r]=[]),null===(t=this.targetIndexToSourceIndices[r])||void 0===t||t.push([i,n]))}}_calculateDegrees(){var e,t,n,i,r,o,a,s;if(void 0===this.pointsNumber)return this.degree=void 0,this.inDegree=void 0,void(this.outDegree=void 0);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 u=0;u<this.pointsNumber;u++)this.inDegree[u]=null!==(n=null===(t=null===(e=this.targetIndexToSourceIndices)||void 0===e?void 0:e[u])||void 0===t?void 0:t.length)&&void 0!==n?n:0,this.outDegree[u]=null!==(o=null===(r=null===(i=this.sourceIndexToTargetIndices)||void 0===i?void 0:i[u])||void 0===r?void 0:r.length)&&void 0!==o?o:0,this.degree[u]=(null!==(a=this.inDegree[u])&&void 0!==a?a:0)+(null!==(s=this.outDegree[u])&&void 0!==s?s:0)}}function to(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function no(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function io(e){let t,n,i;function r(e,i,r=0,o=e.length){if(r<o){if(0!==t(i,i))return o;do{const t=r+o>>>1;n(e[t],i)<0?r=t+1:o=t}while(r<o)}return r}return 2!==e.length?(t=to,n=(t,n)=>to(e(t),n),i=(t,n)=>e(t)-n):(t=e===to||e===no?e:ro,n=e,i=e),{left:r,center:function(e,t,n=0,o=e.length){const a=r(e,t,n,o-1);return a>n&&i(e[a-1],t)>-i(e[a],t)?a-1:a},right:function(e,i,r=0,o=e.length){if(r<o){if(0!==t(i,i))return o;do{const t=r+o>>>1;n(e[t],i)<=0?r=t+1:o=t}while(r<o)}return r}}}function ro(){return 0}const oo=io(to).right;function ao(e,t){let n,i;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=i=t):(n>t&&(n=t),i<t&&(i=t)));else{let r=-1;for(let o of e)null!=(o=t(o,++r,e))&&(void 0===n?o>=o&&(n=i=o):(n>o&&(n=o),i<o&&(i=o)))}return[n,i]}io((function(e){return null===e?NaN:+e})).center;var so=Math.sqrt(50),uo=Math.sqrt(10),lo=Math.sqrt(2);function co(e,t,n){var i=(t-e)/Math.max(0,n),r=Math.floor(Math.log(i)/Math.LN10),o=i/Math.pow(10,r);return r>=0?(o>=so?10:o>=uo?5:o>=lo?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=so?10:o>=uo?5:o>=lo?2:1)}function fo(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function ho(e){return+e}var po=[0,1];function mo(e){return e}function vo(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:(n=isNaN(t)?NaN:.5,function(){return n});var n}function go(e,t,n){var i=e[0],r=e[1],o=t[0],a=t[1];return r<i?(i=vo(r,i),o=n(a,o)):(i=vo(i,r),o=n(o,a)),function(e){return o(i(e))}}function yo(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),o=new Array(i),a=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++a<i;)r[a]=vo(e[a],e[a+1]),o[a]=n(t[a],t[a+1]);return function(t){var n=oo(e,t,1,i)-1;return o[n](r[n](t))}}function bo(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function xo(){var e,t,n,i,r,o,a=po,s=po,u=kn,l=mo;function c(){var e,t,n,u=Math.min(a.length,s.length);return l!==mo&&(e=a[0],t=a[u-1],e>t&&(n=e,e=t,t=n),l=function(n){return Math.max(e,Math.min(t,n))}),i=u>2?yo:go,r=o=null,f}function f(t){return null==t||isNaN(t=+t)?n:(r||(r=i(a.map(e),s,u)))(e(l(t)))}return f.invert=function(n){return l(t((o||(o=i(s,a.map(e),yn)))(n)))},f.domain=function(e){return arguments.length?(a=Array.from(e,ho),c()):a.slice()},f.range=function(e){return arguments.length?(s=Array.from(e),c()):s.slice()},f.rangeRound=function(e){return s=Array.from(e),u=Cn,c()},f.clamp=function(e){return arguments.length?(l=!!e||mo,c()):l!==mo},f.interpolate=function(e){return arguments.length?(u=e,c()):u},f.unknown=function(e){return arguments.length?(n=e,f):n},function(n,i){return e=n,t=i,c()}}function So(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function wo(e){return(e=So(Math.abs(e)))?e[1]:NaN}var ko,Co=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function To(e){if(!(t=Co.exec(e)))throw new Error("invalid format: "+e);var t;return new Po({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Po(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function _o(e,t){var n=So(e,t);if(!n)return e+"";var i=n[0],r=n[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")}To.prototype=Po.prototype,Po.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ao={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>_o(100*e,t),r:_o,s:function(e,t){var n=So(e,t);if(!n)return e+"";var i=n[0],r=n[1],o=r-(ko=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,a=i.length;return o===a?i:o>a?i+new Array(o-a+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+So(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function zo(e){return e}var Io,Do,Mo,Fo=Array.prototype.map,Eo=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Lo(e){var t,n,i=void 0===e.grouping||void 0===e.thousands?zo:(t=Fo.call(e.grouping,Number),n=e.thousands+"",function(e,i){for(var r=e.length,o=[],a=0,s=t[0],u=0;r>0&&s>0&&(u+s+1>i&&(s=Math.max(1,i-u)),o.push(e.substring(r-=s,r+s)),!((u+=s+1)>i));)s=t[a=(a+1)%t.length];return o.reverse().join(n)}),r=void 0===e.currency?"":e.currency[0]+"",o=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",s=void 0===e.numerals?zo:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(Fo.call(e.numerals,String)),u=void 0===e.percent?"%":e.percent+"",l=void 0===e.minus?"−":e.minus+"",c=void 0===e.nan?"NaN":e.nan+"";function f(e){var t=(e=To(e)).fill,n=e.align,f=e.sign,h=e.symbol,d=e.zero,p=e.width,m=e.comma,v=e.precision,g=e.trim,y=e.type;"n"===y?(m=!0,y="g"):Ao[y]||(void 0===v&&(v=12),g=!0,y="g"),(d||"0"===t&&"="===n)&&(d=!0,t="0",n="=");var b="$"===h?r:"#"===h&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",x="$"===h?o:/[%p]/.test(y)?u:"",S=Ao[y],w=/[defgprs%]/.test(y);function k(e){var r,o,u,h=b,k=x;if("c"===y)k=S(e)+k,e="";else{var C=(e=+e)<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),v),g&&(e=function(e){e:for(var t,n=e.length,i=1,r=-1;i<n;++i)switch(e[i]){case".":r=t=i;break;case"0":0===r&&(r=i),t=i;break;default:if(!+e[i])break e;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(t+1):e}(e)),C&&0==+e&&"+"!==f&&(C=!1),h=(C?"("===f?f:l:"-"===f||"("===f?"":f)+h,k=("s"===y?Eo[8+ko/3]:"")+k+(C&&"("===f?")":""),w)for(r=-1,o=e.length;++r<o;)if(48>(u=e.charCodeAt(r))||u>57){k=(46===u?a+e.slice(r+1):e.slice(r))+k,e=e.slice(0,r);break}}m&&!d&&(e=i(e,1/0));var T=h.length+e.length+k.length,P=T<p?new Array(p-T+1).join(t):"";switch(m&&d&&(e=i(P+e,P.length?p-k.length:1/0),P=""),n){case"<":e=h+e+k+P;break;case"=":e=h+P+e+k;break;case"^":e=P.slice(0,T=P.length>>1)+h+e+k+P.slice(T);break;default:e=P+h+e+k}return s(e)}return v=void 0===v?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v)),k.toString=function(){return e+""},k}return{format:f,formatPrefix:function(e,t){var n=f(((e=To(e)).type="f",e)),i=3*Math.max(-8,Math.min(8,Math.floor(wo(t)/3))),r=Math.pow(10,-i),o=Eo[8+i/3];return function(e){return n(r*e)+o}}}}function Oo(e,t,n,i){var r,o=function(e,t,n){var i=Math.abs(t-e)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=so?r*=10:o>=uo?r*=5:o>=lo&&(r*=2),t<e?-r:r}(e,t,n);switch((i=To(null==i?",f":i)).type){case"s":var a=Math.max(Math.abs(e),Math.abs(t));return null!=i.precision||isNaN(r=function(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(wo(t)/3)))-wo(Math.abs(e)))}(o,a))||(i.precision=r),Mo(i,a);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=function(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,wo(t)-wo(e))+1}(o,Math.max(Math.abs(e),Math.abs(t))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=function(e){return Math.max(0,-wo(Math.abs(e)))}(o))||(i.precision=r-2*("%"===i.type))}return Do(i)}function No(e){var t=e.domain;return e.ticks=function(e){var n=t();return function(e,t,n){var i,r,o,a,s=-1;if(n=+n,(e=+e)==(t=+t)&&n>0)return[e];if((i=t<e)&&(r=e,e=t,t=r),0===(a=co(e,t,n))||!isFinite(a))return[];if(a>0){let n=Math.round(e/a),i=Math.round(t/a);for(n*a<e&&++n,i*a>t&&--i,o=new Array(r=i-n+1);++s<r;)o[s]=(n+s)*a}else{a=-a;let n=Math.round(e*a),i=Math.round(t*a);for(n/a<e&&++n,i/a>t&&--i,o=new Array(r=i-n+1);++s<r;)o[s]=(n+s)/a}return i&&o.reverse(),o}(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var i=t();return Oo(i[0],i[i.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var i,r,o=t(),a=0,s=o.length-1,u=o[a],l=o[s],c=10;for(l<u&&(r=u,u=l,l=r,r=a,a=s,s=r);c-- >0;){if((r=co(u,l,n))===i)return o[a]=u,o[s]=l,t(o);if(r>0)u=Math.floor(u/r)*r,l=Math.ceil(l/r)*r;else{if(!(r<0))break;u=Math.ceil(u*r)/r,l=Math.floor(l*r)/r}i=r}return e},e}function Ro(){var e=xo()(mo,mo);return e.copy=function(){return bo(e,Ro())},fo.apply(e,arguments),No(e)}function jo(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Bo(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Vo(e){return e<0?-e*e:e*e}function Uo(e){var t=e(mo,mo),n=1;return t.exponent=function(t){return arguments.length?1===(n=+t)?e(mo,mo):.5===n?e(Bo,Vo):e(jo(n),jo(1/n)):n},No(t)}function Go(){var e=Uo(xo());return e.copy=function(){return bo(e,Go()).exponent(e.exponent())},fo.apply(e,arguments),e}Io=Lo({thousands:",",grouping:[3],currency:["$",""]}),Do=Io.format,Mo=Io.formatPrefix;var Ho=new Date,Wo=new Date;function qo(e,t,n,i){function r(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return r.floor=function(t){return e(t=new Date(+t)),t},r.ceil=function(n){return e(n=new Date(n-1)),t(n,1),e(n),n},r.round=function(e){var t=r(e),n=r.ceil(e);return e-t<n-e?t:n},r.offset=function(e,n){return t(e=new Date(+e),null==n?1:Math.floor(n)),e},r.range=function(n,i,o){var a,s=[];if(n=r.ceil(n),o=null==o?1:Math.floor(o),!(n<i&&o>0))return s;do{s.push(a=new Date(+n)),t(n,o),e(n)}while(a<n&&n<i);return s},r.filter=function(n){return qo((function(t){if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,i){if(e>=e)if(i<0)for(;++i<=0;)for(;t(e,-1),!n(e););else for(;--i>=0;)for(;t(e,1),!n(e););}))},n&&(r.count=function(t,i){return Ho.setTime(+t),Wo.setTime(+i),e(Ho),e(Wo),Math.floor(n(Ho,Wo))},r.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?r.filter(i?function(t){return i(t)%e==0}:function(t){return r.count(0,t)%e==0}):r:null}),r}var Yo=qo((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e}));Yo.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?qo((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Yo:null},Yo.range;const $o=1e3,Xo=6e4,Zo=36e5,Qo=864e5,Ko=6048e5;var Jo=qo((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+t*$o)}),(function(e,t){return(t-e)/$o}),(function(e){return e.getUTCSeconds()}));Jo.range;var ea=qo((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*$o)}),(function(e,t){e.setTime(+e+t*Xo)}),(function(e,t){return(t-e)/Xo}),(function(e){return e.getMinutes()}));ea.range;var ta=qo((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*$o-e.getMinutes()*Xo)}),(function(e,t){e.setTime(+e+t*Zo)}),(function(e,t){return(t-e)/Zo}),(function(e){return e.getHours()}));ta.range;var na=qo((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Xo)/Qo),(e=>e.getDate()-1));function ia(e){return qo((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Xo)/Ko}))}na.range;var ra=ia(0),oa=ia(1),aa=ia(2),sa=ia(3),ua=ia(4),la=ia(5),ca=ia(6);ra.range,oa.range,aa.range,sa.range,ua.range,la.range,ca.range;var fa=qo((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()}));fa.range;var ha=qo((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));ha.every=function(e){return isFinite(e=Math.floor(e))&&e>0?qo((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null},ha.range;var da=qo((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*Xo)}),(function(e,t){return(t-e)/Xo}),(function(e){return e.getUTCMinutes()}));da.range;var pa=qo((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+t*Zo)}),(function(e,t){return(t-e)/Zo}),(function(e){return e.getUTCHours()}));pa.range;var ma=qo((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/Qo}),(function(e){return e.getUTCDate()-1}));function va(e){return qo((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/Ko}))}ma.range;var ga=va(0),ya=va(1),ba=va(2),xa=va(3),Sa=va(4),wa=va(5),ka=va(6);ga.range,ya.range,ba.range,xa.range,Sa.range,wa.range,ka.range;var Ca=qo((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()}));Ca.range;var Ta=qo((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()}));function Pa(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function _a(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Aa(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}Ta.every=function(e){return isFinite(e=Math.floor(e))&&e>0?qo((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null},Ta.range;var za,Ia,Da,Ma={"-":"",_:" ",0:"0"},Fa=/^\s*\d+/,Ea=/^%/,La=/[\\^$*+?|[\]().{}]/g;function Oa(e,t,n){var i=e<0?"-":"",r=(i?-e:e)+"",o=r.length;return i+(o<n?new Array(n-o+1).join(t)+r:r)}function Na(e){return e.replace(La,"\\$&")}function Ra(e){return new RegExp("^(?:"+e.map(Na).join("|")+")","i")}function ja(e){return new Map(e.map(((e,t)=>[e.toLowerCase(),t])))}function Ba(e,t,n){var i=Fa.exec(t.slice(n,n+1));return i?(e.w=+i[0],n+i[0].length):-1}function Va(e,t,n){var i=Fa.exec(t.slice(n,n+1));return i?(e.u=+i[0],n+i[0].length):-1}function Ua(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.U=+i[0],n+i[0].length):-1}function Ga(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.V=+i[0],n+i[0].length):-1}function Ha(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.W=+i[0],n+i[0].length):-1}function Wa(e,t,n){var i=Fa.exec(t.slice(n,n+4));return i?(e.y=+i[0],n+i[0].length):-1}function qa(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function Ya(e,t,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return i?(e.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function $a(e,t,n){var i=Fa.exec(t.slice(n,n+1));return i?(e.q=3*i[0]-3,n+i[0].length):-1}function Xa(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.m=i[0]-1,n+i[0].length):-1}function Za(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.d=+i[0],n+i[0].length):-1}function Qa(e,t,n){var i=Fa.exec(t.slice(n,n+3));return i?(e.m=0,e.d=+i[0],n+i[0].length):-1}function Ka(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.H=+i[0],n+i[0].length):-1}function Ja(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.M=+i[0],n+i[0].length):-1}function es(e,t,n){var i=Fa.exec(t.slice(n,n+2));return i?(e.S=+i[0],n+i[0].length):-1}function ts(e,t,n){var i=Fa.exec(t.slice(n,n+3));return i?(e.L=+i[0],n+i[0].length):-1}function ns(e,t,n){var i=Fa.exec(t.slice(n,n+6));return i?(e.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function is(e,t,n){var i=Ea.exec(t.slice(n,n+1));return i?n+i[0].length:-1}function rs(e,t,n){var i=Fa.exec(t.slice(n));return i?(e.Q=+i[0],n+i[0].length):-1}function os(e,t,n){var i=Fa.exec(t.slice(n));return i?(e.s=+i[0],n+i[0].length):-1}function as(e,t){return Oa(e.getDate(),t,2)}function ss(e,t){return Oa(e.getHours(),t,2)}function us(e,t){return Oa(e.getHours()%12||12,t,2)}function ls(e,t){return Oa(1+na.count(ha(e),e),t,3)}function cs(e,t){return Oa(e.getMilliseconds(),t,3)}function fs(e,t){return cs(e,t)+"000"}function hs(e,t){return Oa(e.getMonth()+1,t,2)}function ds(e,t){return Oa(e.getMinutes(),t,2)}function ps(e,t){return Oa(e.getSeconds(),t,2)}function ms(e){var t=e.getDay();return 0===t?7:t}function vs(e,t){return Oa(ra.count(ha(e)-1,e),t,2)}function gs(e){var t=e.getDay();return t>=4||0===t?ua(e):ua.ceil(e)}function ys(e,t){return e=gs(e),Oa(ua.count(ha(e),e)+(4===ha(e).getDay()),t,2)}function bs(e){return e.getDay()}function xs(e,t){return Oa(oa.count(ha(e)-1,e),t,2)}function Ss(e,t){return Oa(e.getFullYear()%100,t,2)}function ws(e,t){return Oa((e=gs(e)).getFullYear()%100,t,2)}function ks(e,t){return Oa(e.getFullYear()%1e4,t,4)}function Cs(e,t){var n=e.getDay();return Oa((e=n>=4||0===n?ua(e):ua.ceil(e)).getFullYear()%1e4,t,4)}function Ts(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Oa(t/60|0,"0",2)+Oa(t%60,"0",2)}function Ps(e,t){return Oa(e.getUTCDate(),t,2)}function _s(e,t){return Oa(e.getUTCHours(),t,2)}function As(e,t){return Oa(e.getUTCHours()%12||12,t,2)}function zs(e,t){return Oa(1+ma.count(Ta(e),e),t,3)}function Is(e,t){return Oa(e.getUTCMilliseconds(),t,3)}function Ds(e,t){return Is(e,t)+"000"}function Ms(e,t){return Oa(e.getUTCMonth()+1,t,2)}function Fs(e,t){return Oa(e.getUTCMinutes(),t,2)}function Es(e,t){return Oa(e.getUTCSeconds(),t,2)}function Ls(e){var t=e.getUTCDay();return 0===t?7:t}function Os(e,t){return Oa(ga.count(Ta(e)-1,e),t,2)}function Ns(e){var t=e.getUTCDay();return t>=4||0===t?Sa(e):Sa.ceil(e)}function Rs(e,t){return e=Ns(e),Oa(Sa.count(Ta(e),e)+(4===Ta(e).getUTCDay()),t,2)}function js(e){return e.getUTCDay()}function Bs(e,t){return Oa(ya.count(Ta(e)-1,e),t,2)}function Vs(e,t){return Oa(e.getUTCFullYear()%100,t,2)}function Us(e,t){return Oa((e=Ns(e)).getUTCFullYear()%100,t,2)}function Gs(e,t){return Oa(e.getUTCFullYear()%1e4,t,4)}function Hs(e,t){var n=e.getUTCDay();return Oa((e=n>=4||0===n?Sa(e):Sa.ceil(e)).getUTCFullYear()%1e4,t,4)}function Ws(){return"+0000"}function qs(){return"%"}function Ys(e){return+e}function $s(e){return Math.floor(+e/1e3)}!function(e){za=function(e){var t=e.dateTime,n=e.date,i=e.time,r=e.periods,o=e.days,a=e.shortDays,s=e.months,u=e.shortMonths,l=Ra(r),c=ja(r),f=Ra(o),h=ja(o),d=Ra(a),p=ja(a),m=Ra(s),v=ja(s),g=Ra(u),y=ja(u),b={a:function(e){return a[e.getDay()]},A:function(e){return o[e.getDay()]},b:function(e){return u[e.getMonth()]},B:function(e){return s[e.getMonth()]},c:null,d:as,e:as,f:fs,g:ws,G:Cs,H:ss,I:us,j:ls,L:cs,m:hs,M:ds,p:function(e){return r[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:Ys,s:$s,S:ps,u:ms,U:vs,V:ys,w:bs,W:xs,x:null,X:null,y:Ss,Y:ks,Z:Ts,"%":qs},x={a:function(e){return a[e.getUTCDay()]},A:function(e){return o[e.getUTCDay()]},b:function(e){return u[e.getUTCMonth()]},B:function(e){return s[e.getUTCMonth()]},c:null,d:Ps,e:Ps,f:Ds,g:Us,G:Hs,H:_s,I:As,j:zs,L:Is,m:Ms,M:Fs,p:function(e){return r[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:Ys,s:$s,S:Es,u:Ls,U:Os,V:Rs,w:js,W:Bs,x:null,X:null,y:Vs,Y:Gs,Z:Ws,"%":qs},S={a:function(e,t,n){var i=d.exec(t.slice(n));return i?(e.w=p.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(e,t,n){var i=f.exec(t.slice(n));return i?(e.w=h.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(e,t,n){var i=g.exec(t.slice(n));return i?(e.m=y.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(e,t,n){var i=m.exec(t.slice(n));return i?(e.m=v.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(e,n,i){return C(e,t,n,i)},d:Za,e:Za,f:ns,g:qa,G:Wa,H:Ka,I:Ka,j:Qa,L:ts,m:Xa,M:Ja,p:function(e,t,n){var i=l.exec(t.slice(n));return i?(e.p=c.get(i[0].toLowerCase()),n+i[0].length):-1},q:$a,Q:rs,s:os,S:es,u:Va,U:Ua,V:Ga,w:Ba,W:Ha,x:function(e,t,i){return C(e,n,t,i)},X:function(e,t,n){return C(e,i,t,n)},y:qa,Y:Wa,Z:Ya,"%":is};function w(e,t){return function(n){var i,r,o,a=[],s=-1,u=0,l=e.length;for(n instanceof Date||(n=new Date(+n));++s<l;)37===e.charCodeAt(s)&&(a.push(e.slice(u,s)),null!=(r=Ma[i=e.charAt(++s)])?i=e.charAt(++s):r="e"===i?" ":"0",(o=t[i])&&(i=o(n,r)),a.push(i),u=s+1);return a.push(e.slice(u,s)),a.join("")}}function k(e,t){return function(n){var i,r,o=Aa(1900,void 0,1);if(C(o,e,n+="",0)!=n.length)return null;if("Q"in o)return new Date(o.Q);if("s"in o)return new Date(1e3*o.s+("L"in o?o.L:0));if(t&&!("Z"in o)&&(o.Z=0),"p"in o&&(o.H=o.H%12+12*o.p),void 0===o.m&&(o.m="q"in o?o.q:0),"V"in o){if(o.V<1||o.V>53)return null;"w"in o||(o.w=1),"Z"in o?(r=(i=_a(Aa(o.y,0,1))).getUTCDay(),i=r>4||0===r?ya.ceil(i):ya(i),i=ma.offset(i,7*(o.V-1)),o.y=i.getUTCFullYear(),o.m=i.getUTCMonth(),o.d=i.getUTCDate()+(o.w+6)%7):(r=(i=Pa(Aa(o.y,0,1))).getDay(),i=r>4||0===r?oa.ceil(i):oa(i),i=na.offset(i,7*(o.V-1)),o.y=i.getFullYear(),o.m=i.getMonth(),o.d=i.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),r="Z"in o?_a(Aa(o.y,0,1)).getUTCDay():Pa(Aa(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(r+5)%7:o.w+7*o.U-(r+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,_a(o)):Pa(o)}}function C(e,t,n,i){for(var r,o,a=0,s=t.length,u=n.length;a<s;){if(i>=u)return-1;if(37===(r=t.charCodeAt(a++))){if(r=t.charAt(a++),!(o=S[r in Ma?t.charAt(a++):r])||(i=o(e,n,i))<0)return-1}else if(r!=n.charCodeAt(i++))return-1}return i}return b.x=w(n,b),b.X=w(i,b),b.c=w(t,b),x.x=w(n,x),x.X=w(i,x),x.c=w(t,x),{format:function(e){var t=w(e+="",b);return t.toString=function(){return e},t},parse:function(e){var t=k(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=w(e+="",x);return t.toString=function(){return e},t},utcParse:function(e){var t=k(e+="",!0);return t.toString=function(){return e},t}}}(e),za.format,za.parse,Ia=za.utcFormat,Da=za.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Xs="%Y-%m-%dT%H:%M:%S.%LZ";Date.prototype.toISOString||Ia(Xs),+new Date("2000-01-01T00:00:00.000Z")||Da(Xs);const Zs=e=>{const t=Go().exponent(2).range([0,1]).domain([-1,1]),n=function(e,t,n){e=+e,t=+t,n=(r=arguments.length)<2?(t=e,e=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((t-e)/n)),o=new Array(r);++i<r;)o[i]=e+i*n;return o}(0,e).map((t=>t/e-.5));n.push(.5);const i=new Array(2*n.length);return n.forEach(((e,n)=>{i[2*n]=[t(2*e),.5],i[2*n+1]=[t(2*e),-.5]})),i};class Qs extends Er{initPrograms(){const{reglInstance:e,config:t,store:n}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=e.framebuffer({color:e.texture({width:1,height:1,format:"rgba",type:"float"}),depth:!1,stencil:!1})),this.drawCurveCommand||(this.drawCurveCommand=e({vert:"precision highp float;\n#define GLSLIFY 1\nattribute vec2 position,pointA,pointB;attribute vec4 color;attribute float width;attribute float arrow;attribute float linkIndices;uniform sampler2D positionsTexture;uniform sampler2D pointGreyoutStatus;uniform mat3 transformationMatrix;uniform float pointsTextureSize;uniform float widthScale;uniform float linkArrowsSizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform vec2 linkVisibilityDistanceRange;uniform float linkVisibilityMinTransparency;uniform float linkOpacity;uniform float greyoutOpacity;uniform float curvedWeight;uniform float curvedLinkControlPointDistance;uniform float curvedLinkSegments;uniform bool scaleLinksOnZoom;uniform float maxPointSize;uniform float renderMode;uniform float hoveredLinkIndex;uniform vec4 hoveredLinkColor;uniform float hoveredLinkWidthIncrease;varying vec4 rgbaColor;varying vec2 pos;varying float arrowLength;varying float useArrow;varying float smoothing;varying float arrowWidthFactor;varying float linkIndex;float map(float value,float min1,float max1,float min2,float max2){return min2+(value-min1)*(max2-min2)/(max1-min1);}vec2 conicParametricCurve(vec2 A,vec2 B,vec2 ControlPoint,float t,float w){vec2 divident=(1.0-t)*(1.0-t)*A+2.0*(1.0-t)*t*w*ControlPoint+t*t*B;float divisor=(1.0-t)*(1.0-t)+2.0*(1.0-t)*t*w+t*t;return divident/divisor;}float calculateLinkWidth(float width){float linkWidth;if(scaleLinksOnZoom){linkWidth=width;}else{linkWidth=width/transformationMatrix[0][0];linkWidth*=min(5.0,max(1.0,transformationMatrix[0][0]*0.01));}if(useArrow>0.5){return min(linkWidth,(maxPointSize*2.0)/transformationMatrix[0][0]);}else{return min(linkWidth,maxPointSize/transformationMatrix[0][0]);}}float calculateArrowWidth(float arrowWidth){if(scaleLinksOnZoom){return arrowWidth;}else{arrowWidth=arrowWidth/transformationMatrix[0][0];arrowWidth*=min(5.0,max(1.0,transformationMatrix[0][0]*0.01));return arrowWidth;}}void main(){pos=position;linkIndex=linkIndices;vec2 pointTexturePosA=(pointA+0.5)/pointsTextureSize;vec2 pointTexturePosB=(pointB+0.5)/pointsTextureSize;vec4 greyoutStatusA=texture2D(pointGreyoutStatus,pointTexturePosA);vec4 greyoutStatusB=texture2D(pointGreyoutStatus,pointTexturePosB);vec4 pointPositionA=texture2D(positionsTexture,pointTexturePosA);vec4 pointPositionB=texture2D(positionsTexture,pointTexturePosB);vec2 a=pointPositionA.xy;vec2 b=pointPositionB.xy;vec2 xBasis=b-a;vec2 yBasis=normalize(vec2(-xBasis.y,xBasis.x));float linkDist=length(xBasis);float h=curvedLinkControlPointDistance;vec2 controlPoint=(a+b)/2.0+yBasis*linkDist*h;float linkDistPx=linkDist*transformationMatrix[0][0];float linkWidth=width*widthScale;float k=2.0;float arrowWidth=linkWidth*k;arrowWidth*=linkArrowsSizeScale;float arrowWidthDifference=max(0.0,arrowWidth-linkWidth);float arrowWidthPx=calculateArrowWidth(arrowWidth);arrowLength=min(0.3,(0.866*arrowWidthPx*2.0)/linkDist);useArrow=arrow;if(useArrow>0.5){linkWidth+=arrowWidthDifference;}arrowWidthFactor=arrowWidthDifference/linkWidth;float linkWidthPx=calculateLinkWidth(linkWidth);if(renderMode>0.0){linkWidthPx+=5.0/transformationMatrix[0][0];}else{if(hoveredLinkIndex==linkIndex){linkWidthPx+=hoveredLinkWidthIncrease/transformationMatrix[0][0];}}float smoothingPx=0.5/transformationMatrix[0][0];smoothing=smoothingPx/linkWidthPx;linkWidthPx+=smoothingPx;vec3 rgbColor=color.rgb;float opacity=color.a*linkOpacity*max(linkVisibilityMinTransparency,map(linkDistPx,linkVisibilityDistanceRange.g,linkVisibilityDistanceRange.r,0.0,1.0));if(greyoutStatusA.r>0.0||greyoutStatusB.r>0.0){opacity*=greyoutOpacity;}rgbaColor=vec4(rgbColor,opacity);if(hoveredLinkIndex==linkIndex&&hoveredLinkColor.a>-0.5){rgbaColor.rgb=hoveredLinkColor.rgb;rgbaColor.a*=hoveredLinkColor.a;}float t=position.x;float w=curvedWeight;float tPrev=t-1.0/curvedLinkSegments;float tNext=t+1.0/curvedLinkSegments;vec2 pointCurr=conicParametricCurve(a,b,controlPoint,t,w);vec2 pointPrev=conicParametricCurve(a,b,controlPoint,max(0.0,tPrev),w);vec2 pointNext=conicParametricCurve(a,b,controlPoint,min(tNext,1.0),w);vec2 xBasisCurved=pointNext-pointPrev;vec2 yBasisCurved=normalize(vec2(-xBasisCurved.y,xBasisCurved.x));pointCurr+=yBasisCurved*linkWidthPx*position.y;vec2 p=2.0*pointCurr/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transformationMatrix*vec3(p,1);gl_Position=vec4(final.rg,0,1);}",frag:"precision highp float;\n#define GLSLIFY 1\nvarying vec4 rgbaColor;varying vec2 pos;varying float arrowLength;varying float useArrow;varying float smoothing;varying float arrowWidthFactor;varying float linkIndex;uniform float renderMode;float map(float value,float min1,float max1,float min2,float max2){return min2+(value-min1)*(max2-min2)/(max1-min1);}void main(){float opacity=1.0;vec3 color=rgbaColor.rgb;if(useArrow>0.5){float end_arrow=0.5+arrowLength/2.0;float start_arrow=end_arrow-arrowLength;float arrowWidthDelta=arrowWidthFactor/2.0;float linkOpacity=rgbaColor.a*smoothstep(0.5-arrowWidthDelta,0.5-arrowWidthDelta-smoothing/2.0,abs(pos.y));float arrowOpacity=1.0;if(pos.x>start_arrow&&pos.x<start_arrow+arrowLength){float xmapped=map(pos.x,start_arrow,end_arrow,0.0,1.0);arrowOpacity=rgbaColor.a*smoothstep(xmapped-smoothing,xmapped,map(abs(pos.y),0.5,0.0,0.0,1.0));if(linkOpacity!=arrowOpacity){linkOpacity=max(linkOpacity,arrowOpacity);}}opacity=linkOpacity;}else opacity=rgbaColor.a*smoothstep(0.5,0.5-smoothing,abs(pos.y));if(renderMode>0.0){if(opacity>0.0){gl_FragColor=vec4(linkIndex,0.0,0.0,1.0);}else{gl_FragColor=vec4(-1.0,0.0,0.0,0.0);}}else gl_FragColor=vec4(color,opacity);}",attributes:{position:{buffer:()=>this.curveLineBuffer,divisor:0},pointA:{buffer:()=>this.pointsBuffer,divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},pointB:{buffer:()=>this.pointsBuffer,divisor:1,offset:2*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},color:{buffer:()=>this.colorBuffer,divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},width:{buffer:()=>this.widthBuffer,divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:1*Float32Array.BYTES_PER_ELEMENT},arrow:{buffer:()=>this.arrowBuffer,divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:1*Float32Array.BYTES_PER_ELEMENT},linkIndices:{buffer:()=>this.linkIndexBuffer,divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:1*Float32Array.BYTES_PER_ELEMENT}},uniforms:{positionsTexture:()=>{var e;return null===(e=this.points)||void 0===e?void 0:e.currentPositionFbo},pointGreyoutStatus:()=>{var e;return null===(e=this.points)||void 0===e?void 0:e.greyoutStatusFbo},transformationMatrix:()=>n.transform,pointsTextureSize:()=>n.pointsTextureSize,widthScale:()=>t.linkWidthScale,linkArrowsSizeScale:()=>t.linkArrowsSizeScale,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,linkVisibilityDistanceRange:()=>t.linkVisibilityDistanceRange,linkVisibilityMinTransparency:()=>t.linkVisibilityMinTransparency,linkOpacity:()=>t.linkOpacity,greyoutOpacity:()=>t.linkGreyoutOpacity,scaleLinksOnZoom:()=>t.scaleLinksOnZoom,maxPointSize:()=>n.maxPointSize,curvedWeight:()=>t.curvedLinkWeight,curvedLinkControlPointDistance:()=>t.curvedLinkControlPointDistance,curvedLinkSegments:()=>{var e;return t.curvedLinks?null!==(e=t.curvedLinkSegments)&&void 0!==e?e:vi.curvedLinkSegments:1},hoveredLinkIndex:()=>{var e;return null!==(e=n.hoveredLinkIndex)&&void 0!==e?e:-1},hoveredLinkColor:()=>n.hoveredLinkColor,hoveredLinkWidthIncrease:()=>t.hoveredLinkWidthIncrease,renderMode:e.prop("renderMode")},cull:{enable:!0,face:"back"},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},framebuffer:e.prop("framebuffer"),count:()=>{var e,t;return null!==(t=null===(e=this.curveLineGeometry)||void 0===e?void 0:e.length)&&void 0!==t?t:0},instances:()=>{var e;return null!==(e=this.data.linksNumber)&&void 0!==e?e:0},primitive:"triangle strip"})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=e({vert:"#define GLSLIFY 1\nattribute vec2 position;varying vec2 vTexCoord;void main(){vTexCoord=position*0.5+0.5;gl_Position=vec4(position,0.0,1.0);}",frag:"precision highp float;\n#define GLSLIFY 1\nuniform sampler2D linkIndexTexture;uniform vec2 mousePosition;uniform vec2 screenSize;varying vec2 vTexCoord;void main(){vec2 texCoord=mousePosition/screenSize;vec4 linkIndexData=texture2D(linkIndexTexture,texCoord);float linkIndex=linkIndexData.r;if(linkIndexData.a>0.0&&linkIndex>=0.0){gl_FragColor=vec4(linkIndex,0.0,0.0,1.0);}else{gl_FragColor=vec4(-1.0,0.0,0.0,0.0);}}",attributes:{position:{buffer:()=>this.quadBuffer}},uniforms:{linkIndexTexture:()=>this.linkIndexFbo,mousePosition:()=>n.screenMousePosition,screenSize:()=>n.screenSize},framebuffer:this.hoveredLineIndexFbo,count:4,primitive:"triangle strip"})),this.quadBuffer||(this.quadBuffer=e.buffer([-1,-1,1,-1,-1,1,1,1]))}draw(){var e;this.pointsBuffer&&(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),null===(e=this.drawCurveCommand)||void 0===e||e.call(this,{framebuffer:null,renderMode:0}))}updateLinkIndexFbo(){const{reglInstance:e,store:t}=this;this.store.isLinkHoveringEnabled&&(this.linkIndexFbo||(this.linkIndexFbo=e.framebuffer()),this.linkIndexFbo({color:e.texture({width:t.screenSize[0],height:t.screenSize[1],format:"rgba",type:"float"}),depth:!1,stencil:!1}))}updatePointsBuffer(){const{reglInstance:e,data:t,store:n}=this;if(void 0===t.linksNumber||void 0===t.links)return;const i=new Float32Array(4*t.linksNumber);for(let e=0;e<t.linksNumber;e++){const r=t.links[2*e],o=t.links[2*e+1],a=r%n.pointsTextureSize,s=Math.floor(r/n.pointsTextureSize),u=o%n.pointsTextureSize,l=Math.floor(o/n.pointsTextureSize),c=4*e;i[c]=a,i[c+1]=s,i[c+2]=u,i[c+3]=l}this.pointsBuffer||(this.pointsBuffer=e.buffer(0)),this.pointsBuffer(i);const r=new Float32Array(t.linksNumber);for(let e=0;e<t.linksNumber;e++)r[e]=e;this.linkIndexBuffer||(this.linkIndexBuffer=e.buffer(0)),this.linkIndexBuffer(r)}updateColor(){var e;const{reglInstance:t,data:n}=this;this.colorBuffer||(this.colorBuffer=t.buffer(0)),this.colorBuffer(null!==(e=n.linkColors)&&void 0!==e?e:new Float32Array)}updateWidth(){var e;const{reglInstance:t,data:n}=this;this.widthBuffer||(this.widthBuffer=t.buffer(0)),this.widthBuffer(null!==(e=n.linkWidths)&&void 0!==e?e:new Float32Array)}updateArrow(){var e;const{reglInstance:t,data:n}=this;this.arrowBuffer||(this.arrowBuffer=t.buffer(0)),this.arrowBuffer(null!==(e=n.linkArrows)&&void 0!==e?e:new Float32Array)}updateCurveLineGeometry(){const{reglInstance:e,config:{curvedLinks:t,curvedLinkSegments:n}}=this;this.curveLineGeometry=Zs(t?null!=n?n:vi.curvedLinkSegments:1),this.curveLineBuffer||(this.curveLineBuffer=e.buffer(0)),this.curveLineBuffer(this.curveLineGeometry)}findHoveredLine(){var e,t;this.data.linksNumber&&this.store.isLinkHoveringEnabled&&(this.linkIndexFbo||this.updateLinkIndexFbo(),this.reglInstance.clear({framebuffer:this.linkIndexFbo,color:[0,0,0,0]}),null===(e=this.drawCurveCommand)||void 0===e||e.call(this,{framebuffer:this.linkIndexFbo,renderMode:1}),null===(t=this.hoveredLineIndexCommand)||void 0===t||t.call(this))}}class Ks extends Er{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){const{reglInstance:e,store:t,data:n,config:{rescalePositions:i,enableSimulation:r}}=this,{pointsTextureSize:o}=t;if(!o||!n.pointPositions||void 0===n.pointsNumber)return;const a=new Float32Array(o*o*4);let s=i;void 0!==i||r||(s=!0),this.shouldSkipRescale&&(s=!1),s?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let e=0;e<n.pointsNumber;++e)a[4*e+0]=n.pointPositions[2*e+0],a[4*e+1]=n.pointPositions[2*e+1],a[4*e+2]=e;this.currentPositionFbo||(this.currentPositionFbo=e.framebuffer()),this.currentPositionFbo({color:e.texture({data:a,shape:[o,o,4],type:"float"}),depth:!1,stencil:!1}),this.previousPositionFbo||(this.previousPositionFbo=e.framebuffer()),this.previousPositionFbo({color:e.texture({data:a,shape:[o,o,4],type:"float"}),depth:!1,stencil:!1}),this.config.enableSimulation&&(this.velocityFbo||(this.velocityFbo=e.framebuffer()),this.velocityFbo({color:e.texture({data:new Float32Array(o*o*4).fill(0),shape:[o,o,4],type:"float"}),depth:!1,stencil:!1})),this.selectedTexture||(this.selectedTexture=e.texture()),this.selectedTexture({data:a,shape:[o,o,4],type:"float"}),this.selectedFbo||(this.selectedFbo=e.framebuffer()),this.selectedFbo({color:this.selectedTexture,depth:!1,stencil:!1}),this.hoveredFbo||(this.hoveredFbo=e.framebuffer()),this.hoveredFbo({shape:[2,2],colorType:"float",depth:!1,stencil:!1}),this.drawPointIndices||(this.drawPointIndices=e.buffer(0)),this.drawPointIndices(Or(t.pointsTextureSize)),this.hoveredPointIndices||(this.hoveredPointIndices=e.buffer(0)),this.hoveredPointIndices(Or(t.pointsTextureSize)),this.sampledPointIndices||(this.sampledPointIndices=e.buffer(0)),this.sampledPointIndices(Or(t.pointsTextureSize)),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){const{reglInstance:e,config:t,store:n,data:i}=this;t.enableSimulation&&(this.updatePositionCommand||(this.updatePositionCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D velocity;uniform sampler2D pinnedStatusTexture;uniform float friction;uniform float spaceSize;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec4 pointVelocity=texture2D(velocity,textureCoords);vec4 pinnedStatus=texture2D(pinnedStatusTexture,textureCoords);if(pinnedStatus.r>0.5){gl_FragColor=pointPosition;return;}pointVelocity.rg*=friction;pointPosition.rg+=pointVelocity.rg;pointPosition.r=clamp(pointPosition.r,0.0,spaceSize);pointPosition.g=clamp(pointPosition.g,0.0,spaceSize);gl_FragColor=pointPosition;}",vert:Rr,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,velocity:()=>this.velocityFbo,friction:()=>t.simulationFriction,spaceSize:()=>n.adjustedSpaceSize,pinnedStatusTexture:()=>this.pinnedStatusFbo}}))),this.dragPointCommand||(this.dragPointCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform vec2 mousePos;uniform float index;varying vec2 textureCoords;void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);if(index>=0.0&&index==pointPosition.b){pointPosition.rg=mousePos.rg;}gl_FragColor=pointPosition;}",vert:Rr,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,mousePos:()=>n.mousePosition,index:()=>{var e,t;return null!==(t=null===(e=n.hoveredPoint)||void 0===e?void 0:e.index)&&void 0!==t?t:-1}}})),this.drawCommand||(this.drawCommand=e({frag:"\n#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform float greyoutOpacity;uniform float pointOpacity;uniform sampler2D imageAtlasTexture;uniform bool isDarkenGreyout;uniform vec4 backgroundColor;varying float pointShape;varying float isGreyedOut;varying vec4 shapeColor;varying vec4 imageAtlasUV;varying float shapeSize;varying float imageSizeVarying;varying float overallSize;const float smoothing=0.9;const float CIRCLE=0.0;const float SQUARE=1.0;const float TRIANGLE=2.0;const float DIAMOND=3.0;const float PENTAGON=4.0;const float HEXAGON=5.0;const float STAR=6.0;const float CROSS=7.0;const float NONE=8.0;float circleDistance(vec2 p){return dot(p,p);}vec4 applyGreyoutToImage(vec4 imageColor){vec3 finalColor=imageColor.rgb;float finalAlpha=imageColor.a;if(isGreyedOut>0.0){float blendFactor=0.65;if(isDarkenGreyout){finalColor=mix(finalColor,vec3(0.2),blendFactor);}else{finalColor=mix(finalColor,max(backgroundColor.rgb,vec3(0.8)),blendFactor);}}return vec4(finalColor,finalAlpha);}float squareDistance(vec2 p){vec2 d=abs(p)-vec2(0.8);return length(max(d,0.0))+min(max(d.x,d.y),0.0);}float triangleDistance(vec2 p){const float k=sqrt(3.0);p.x=abs(p.x)-0.9;p.y=p.y+0.55;if(p.x+k*p.y>0.0)p=vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;p.x-=clamp(p.x,-1.0,0.0);return-length(p)*sign(p.y);}float diamondDistance(vec2 p){const float aspect=1.2;return abs(p.x)+abs(p.y)/aspect-0.8;}float pentagonDistance(vec2 p){const vec3 k=vec3(0.809016994,0.587785252,0.726542528);p.x=abs(p.x);p-=2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);p-=2.0*min(dot(vec2(k.x,k.y),p),0.0)*vec2(k.x,k.y);p-=vec2(clamp(p.x,-k.z*k.x,k.z*k.x),k.z);return length(p)*sign(p.y);}float hexagonDistance(vec2 p){const vec3 k=vec3(-0.866025404,0.5,0.577350269);p=abs(p);p-=2.0*min(dot(k.xy,p),0.0)*k.xy;p-=vec2(clamp(p.x,-k.z*0.8,k.z*0.8),0.8);return length(p)*sign(p.y);}float starDistance(vec2 p){const float r=0.9;const float rf=0.45;const vec2 k1=vec2(0.809016994,-0.587785252);const vec2 k2=vec2(-k1.x,k1.y);p.x=abs(p.x);p-=2.0*max(dot(k1,p),0.0)*k1;p-=2.0*max(dot(k2,p),0.0)*k2;p.x=abs(p.x);p.y-=r;vec2 ba=rf*vec2(-k1.y,k1.x)-vec2(0.0,1.0);float h=clamp(dot(p,ba)/dot(ba,ba),0.0,r);return length(p-ba*h)*sign(p.y*ba.x-p.x*ba.y);}float crossDistance(vec2 p){p=abs(p);if(p.y>p.x)p=p.yx;vec2 q=p-vec2(0.8,0.3);return length(max(q,0.0))+min(max(q.x,q.y),0.0);}float getShapeDistance(vec2 p,float shape){if(shape==SQUARE)return squareDistance(p);else if(shape==TRIANGLE)return triangleDistance(p);else if(shape==DIAMOND)return diamondDistance(p);else if(shape==PENTAGON)return pentagonDistance(p);else if(shape==HEXAGON)return hexagonDistance(p);else if(shape==STAR)return starDistance(p);else if(shape==CROSS)return crossDistance(p);else return circleDistance(p);}void main(){if(shapeColor.a==0.0&&imageAtlasUV.x==-1.0){discard;}if(pointShape==NONE&&imageAtlasUV.x==-1.0){discard;}vec2 pointCoord=2.0*gl_PointCoord-1.0;vec4 finalShapeColor=vec4(0.0);vec4 finalImageColor=vec4(0.0);if(pointShape!=NONE){vec2 shapeCoord=pointCoord;if(overallSize>shapeSize&&shapeSize>0.0){float scale=shapeSize/overallSize;shapeCoord=pointCoord/scale;}float opacity;if(pointShape==CIRCLE){float pointCenterDistance=dot(shapeCoord,shapeCoord);opacity=1.0-smoothstep(smoothing,1.0,pointCenterDistance);}else{float shapeDistance=getShapeDistance(shapeCoord,pointShape);opacity=1.0-smoothstep(-0.01,0.01,shapeDistance);}opacity*=shapeColor.a;finalShapeColor=vec4(shapeColor.rgb,opacity);}if(imageAtlasUV.x!=-1.0){vec2 imageCoord=pointCoord;if(overallSize>imageSizeVarying&&imageSizeVarying>0.0){float scale=imageSizeVarying/overallSize;imageCoord=pointCoord/scale;if(abs(imageCoord.x)>1.0||abs(imageCoord.y)>1.0){finalImageColor=vec4(0.0);}else{vec2 atlasUV=mix(imageAtlasUV.xy,imageAtlasUV.zw,(imageCoord+1.0)*0.5);vec4 imageColor=texture2D(imageAtlasTexture,atlasUV);finalImageColor=applyGreyoutToImage(imageColor);}}else{vec2 atlasUV=mix(imageAtlasUV.xy,imageAtlasUV.zw,(imageCoord+1.0)*0.5);vec4 imageColor=texture2D(imageAtlasTexture,atlasUV);finalImageColor=applyGreyoutToImage(imageColor);}}float finalPointAlpha=max(finalShapeColor.a,finalImageColor.a);if(isGreyedOut>0.0&&greyoutOpacity!=-1.0){finalPointAlpha*=greyoutOpacity;}else{finalPointAlpha*=pointOpacity;}gl_FragColor=vec4(mix(finalShapeColor.rgb,finalImageColor.rgb,finalImageColor.a),finalPointAlpha);}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nattribute vec2 pointIndices;attribute float size;attribute vec4 color;attribute float shape;attribute float imageIndex;attribute float imageSize;uniform sampler2D positionsTexture;uniform sampler2D pointGreyoutStatus;uniform sampler2D imageAtlasCoords;uniform float ratio;uniform mat3 transformationMatrix;uniform float pointsTextureSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform vec4 greyoutColor;uniform vec4 backgroundColor;uniform bool scalePointsOnZoom;uniform float maxPointSize;uniform bool isDarkenGreyout;uniform bool skipSelected;uniform bool skipUnselected;uniform bool hasImages;uniform float imageCount;uniform float imageAtlasCoordsTextureSize;varying float pointShape;varying float isGreyedOut;varying vec4 shapeColor;varying vec4 imageAtlasUV;varying float shapeSize;varying float imageSizeVarying;varying float overallSize;float calculatePointSize(float size){float pSize;if(scalePointsOnZoom){pSize=size*ratio*transformationMatrix[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transformationMatrix[0][0]*0.01));}return min(pSize,maxPointSize*ratio);}void main(){vec4 greyoutStatus=texture2D(pointGreyoutStatus,(pointIndices+0.5)/pointsTextureSize);isGreyedOut=greyoutStatus.r;bool isSelected=greyoutStatus.r==0.0;if(skipSelected&&isSelected){gl_Position=vec4(2.0,2.0,2.0,1.0);gl_PointSize=0.0;return;}if(skipUnselected&&!isSelected){gl_Position=vec4(2.0,2.0,2.0,1.0);gl_PointSize=0.0;return;}vec4 pointPosition=texture2D(positionsTexture,(pointIndices+0.5)/pointsTextureSize);vec2 point=pointPosition.rg;vec2 normalizedPosition=2.0*point/spaceSize-1.0;normalizedPosition*=spaceSize/screenSize;vec3 finalPosition=transformationMatrix*vec3(normalizedPosition,1);gl_Position=vec4(finalPosition.rg,0,1);float shapeSizeValue=calculatePointSize(size*sizeScale);float imageSizeValue=calculatePointSize(imageSize*sizeScale);float overallSizeValue=max(shapeSizeValue,imageSizeValue);gl_PointSize=overallSizeValue;shapeSize=shapeSizeValue;imageSizeVarying=imageSizeValue;overallSize=overallSizeValue;shapeColor=color;pointShape=shape;if(isGreyedOut>0.0){if(greyoutColor[0]!=-1.0){shapeColor=greyoutColor;}else{float blendFactor=0.65;if(isDarkenGreyout){shapeColor.rgb=mix(shapeColor.rgb,vec3(0.2),blendFactor);}else{shapeColor.rgb=mix(shapeColor.rgb,max(backgroundColor.rgb,vec3(0.8)),blendFactor);}}}if(!hasImages||imageIndex<0.0||imageIndex>=imageCount){imageAtlasUV=vec4(-1.0);return;}float atlasCoordIndex=imageIndex;float texX=mod(atlasCoordIndex,imageAtlasCoordsTextureSize);float texY=floor(atlasCoordIndex/imageAtlasCoordsTextureSize);vec2 atlasCoordTexCoord=(vec2(texX,texY)+0.5)/imageAtlasCoordsTextureSize;vec4 atlasCoords=texture2D(imageAtlasCoords,atlasCoordTexCoord);imageAtlasUV=atlasCoords;}",primitive:"points",count:()=>{var e;return null!==(e=i.pointsNumber)&&void 0!==e?e:0},attributes:{pointIndices:{buffer:this.drawPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1},color:{buffer:()=>this.colorBuffer,size:4},shape:{buffer:()=>this.shapeBuffer,size:1},imageIndex:{buffer:()=>this.imageIndicesBuffer,size:1},imageSize:{buffer:()=>this.imageSizesBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointGreyoutStatus:()=>this.greyoutStatusFbo,ratio:()=>t.pixelRatio,sizeScale:()=>t.pointSizeScale,pointsTextureSize:()=>n.pointsTextureSize,transformationMatrix:()=>n.transform,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,pointOpacity:()=>t.pointOpacity,greyoutOpacity:()=>{var e;return null!==(e=t.pointGreyoutOpacity)&&void 0!==e?e:-1},greyoutColor:()=>n.greyoutPointColor,backgroundColor:()=>n.backgroundColor,isDarkenGreyout:()=>n.isDarkenGreyout,scalePointsOnZoom:()=>t.scalePointsOnZoom,maxPointSize:()=>n.maxPointSize,skipSelected:e.prop("skipSelected"),skipUnselected:e.prop("skipUnselected"),imageAtlasTexture:()=>this.imageAtlasTexture,imageAtlasCoords:()=>this.imageAtlasCoordsTexture,hasImages:()=>this.imageCount>0,imageCount:()=>this.imageCount,imageAtlasCoordsTextureSize:()=>this.imageAtlasCoordsTextureSize},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D pointSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float ratio;uniform mat3 transformationMatrix;uniform vec2 selection0;uniform vec2 selection1;uniform bool scalePointsOnZoom;uniform float maxPointSize;varying vec2 textureCoords;float pointSizeF(float size){float pSize;if(scalePointsOnZoom){pSize=size*ratio*transformationMatrix[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transformationMatrix[0][0]*0.01));}return min(pSize,maxPointSize*ratio);}void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec2 p=2.0*pointPosition.rg/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transformationMatrix*vec3(p,1);vec4 pSize=texture2D(pointSize,textureCoords);float size=pSize.r*sizeScale;float left=2.0*(selection0.x-0.5*pointSizeF(size))/screenSize.x-1.0;float right=2.0*(selection1.x+0.5*pointSizeF(size))/screenSize.x-1.0;float top=2.0*(selection0.y-0.5*pointSizeF(size))/screenSize.y-1.0;float bottom=2.0*(selection1.y+0.5*pointSizeF(size))/screenSize.y-1.0;gl_FragColor=vec4(0.0,0.0,pointPosition.rg);if(final.x>=left&&final.x<=right&&final.y>=top&&final.y<=bottom){gl_FragColor.r=1.0;}}",vert:Rr,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointSize:()=>this.sizeFbo,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,sizeScale:()=>t.pointSizeScale,transformationMatrix:()=>n.transform,ratio:()=>t.pixelRatio,selection0:()=>n.selectedArea[0],selection1:()=>n.selectedArea[1],scalePointsOnZoom:()=>t.scalePointsOnZoom,maxPointSize:()=>n.maxPointSize}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D polygonPathTexture;uniform int polygonPathLength;uniform float spaceSize;uniform vec2 screenSize;uniform mat3 transformationMatrix;varying vec2 textureCoords;vec2 getPolygonPoint(sampler2D pathTexture,int index,int pathLength){if(index>=pathLength)return vec2(0.0);int textureSize=int(ceil(sqrt(float(pathLength))));int x=index-(index/textureSize)*textureSize;int y=index/textureSize;vec2 texCoord=(vec2(float(x),float(y))+0.5)/float(textureSize);vec4 pathData=texture2D(pathTexture,texCoord);return pathData.xy;}bool pointInPolygon(vec2 point,sampler2D pathTexture,int pathLength){bool inside=false;for(int i=0;i<2048;i++){if(i>=pathLength)break;int j=int(mod(float(i+1),float(pathLength)));vec2 pi=getPolygonPoint(pathTexture,i,pathLength);vec2 pj=getPolygonPoint(pathTexture,j,pathLength);if(((pi.y>point.y)!=(pj.y>point.y))&&(point.x<(pj.x-pi.x)*(point.y-pi.y)/(pj.y-pi.y)+pi.x)){inside=!inside;}}return inside;}void main(){vec4 pointPosition=texture2D(positionsTexture,textureCoords);vec2 p=2.0*pointPosition.rg/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transformationMatrix*vec3(p,1);vec2 screenPos=(final.xy+1.0)*screenSize/2.0;gl_FragColor=vec4(0.0,0.0,pointPosition.rg);if(pointInPolygon(screenPos,polygonPathTexture,polygonPathLength)){gl_FragColor.r=1.0;}}",vert:Rr,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,transformationMatrix:()=>n.transform,polygonPathTexture:()=>this.polygonPathTexture,polygonPathLength:()=>this.polygonPathLength}})),this.clearHoveredFboCommand||(this.clearHoveredFboCommand=e({frag:Nr,vert:Rr,framebuffer:this.hoveredFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nattribute float size;uniform sampler2D positionsTexture;uniform float pointsTextureSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float ratio;uniform mat3 transformationMatrix;uniform vec2 mousePosition;uniform bool scalePointsOnZoom;uniform float maxPointSize;attribute vec2 pointIndices;varying vec4 rgba;float calculatePointSize(float size){float pSize;if(scalePointsOnZoom){pSize=size*ratio*transformationMatrix[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transformationMatrix[0][0]*0.01));}return min(pSize,maxPointSize*ratio);}float euclideanDistance(float x1,float x2,float y1,float y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}void main(){vec4 pointPosition=texture2D(positionsTexture,(pointIndices+0.5)/pointsTextureSize);vec2 normalizedPoint=2.0*pointPosition.rg/spaceSize-1.0;normalizedPoint*=spaceSize/screenSize;vec3 finalPosition=transformationMatrix*vec3(normalizedPoint,1);float pointRadius=0.5*calculatePointSize(size*sizeScale);vec2 pointScreenPosition=(finalPosition.xy+1.0)*screenSize/2.0;rgba=vec4(0.0);gl_Position=vec4(0.5,0.5,0.0,1.0);if(euclideanDistance(pointScreenPosition.x,mousePosition.x,pointScreenPosition.y,mousePosition.y)<pointRadius/ratio){float index=pointIndices.g*pointsTextureSize+pointIndices.r;rgba=vec4(index,size,pointPosition.xy);gl_Position=vec4(-0.5,-0.5,0.0,1.0);}gl_PointSize=1.0;}",primitive:"points",count:()=>{var e;return null!==(e=i.pointsNumber)&&void 0!==e?e:0},framebuffer:()=>this.hoveredFbo,attributes:{pointIndices:{buffer:this.hoveredPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,ratio:()=>t.pixelRatio,sizeScale:()=>t.pointSizeScale,pointsTextureSize:()=>n.pointsTextureSize,transformationMatrix:()=>n.transform,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,scalePointsOnZoom:()=>t.scalePointsOnZoom,mousePosition:()=>n.screenMousePosition,maxPointSize:()=>n.maxPointSize},depth:{enable:!1,mask:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboCommand=e({frag:Nr,vert:Rr,framebuffer:()=>this.sampledPointsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform float pointsTextureSize;uniform float spaceSize;uniform vec2 screenSize;uniform mat3 transformationMatrix;attribute vec2 pointIndices;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(positionsTexture,(pointIndices+0.5)/pointsTextureSize);vec2 p=2.0*pointPosition.rg/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transformationMatrix*vec3(p,1);vec2 pointScreenPosition=(final.xy+1.0)*screenSize/2.0;float index=pointIndices.g*pointsTextureSize+pointIndices.r;rgba=vec4(index,1.0,pointPosition.xy);float i=(pointScreenPosition.x+0.5)/screenSize.x;float j=(pointScreenPosition.y+0.5)/screenSize.y;gl_Position=vec4(2.0*vec2(i,j)-1.0,0.0,1.0);gl_PointSize=1.0;}",primitive:"points",count:()=>{var e;return null!==(e=i.pointsNumber)&&void 0!==e?e:0},framebuffer:()=>this.sampledPointsFbo,attributes:{pointIndices:{buffer:this.sampledPointIndices,size:2}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointsTextureSize:()=>n.pointsTextureSize,transformationMatrix:()=>n.transform,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize},depth:{enable:!1,mask:!1}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=e({frag:"precision mediump float;\n#define GLSLIFY 1\nuniform float width;varying vec2 vertexPosition;varying float pointOpacity;varying vec3 rgbColor;const float smoothing=1.05;void main(){float r=dot(vertexPosition,vertexPosition);float opacity=smoothstep(r,r*smoothing,1.0);float stroke=smoothstep(width,width*smoothing,r);gl_FragColor=vec4(rgbColor,opacity*stroke*pointOpacity);}",vert:"precision mediump float;\n#define GLSLIFY 1\nattribute vec2 vertexCoord;uniform sampler2D positionsTexture;uniform sampler2D pointGreyoutStatusTexture;uniform float size;uniform mat3 transformationMatrix;uniform float pointsTextureSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform bool scalePointsOnZoom;uniform float pointIndex;uniform float maxPointSize;uniform vec4 color;uniform float universalPointOpacity;uniform float greyoutOpacity;uniform bool isDarkenGreyout;uniform vec4 backgroundColor;uniform vec4 greyoutColor;varying vec2 vertexPosition;varying float pointOpacity;varying vec3 rgbColor;float calculatePointSize(float size){float pSize;if(scalePointsOnZoom){pSize=size*transformationMatrix[0][0];}else{pSize=size*min(5.0,max(1.0,transformationMatrix[0][0]*0.01));}return min(pSize,maxPointSize);}const float relativeRingRadius=1.3;void main(){vertexPosition=vertexCoord;vec2 textureCoordinates=vec2(mod(pointIndex,pointsTextureSize),floor(pointIndex/pointsTextureSize))+0.5;vec4 pointPosition=texture2D(positionsTexture,textureCoordinates/pointsTextureSize);rgbColor=color.rgb;pointOpacity=color.a*universalPointOpacity;vec4 greyoutStatus=texture2D(pointGreyoutStatusTexture,textureCoordinates/pointsTextureSize);if(greyoutStatus.r>0.0){if(greyoutColor[0]!=-1.0){rgbColor=greyoutColor.rgb;pointOpacity=greyoutColor.a;}else{float blendFactor=0.65;if(isDarkenGreyout){rgbColor=mix(rgbColor,vec3(0.2),blendFactor);}else{rgbColor=mix(rgbColor,max(backgroundColor.rgb,vec3(0.8)),blendFactor);}}if(greyoutOpacity!=-1.0){pointOpacity*=greyoutOpacity;}}float pointSize=(calculatePointSize(size*sizeScale)*relativeRingRadius)/transformationMatrix[0][0];float radius=pointSize*0.5;vec2 a=pointPosition.xy;vec2 b=pointPosition.xy+vec2(0.0,radius);vec2 xBasis=b-a;vec2 yBasis=normalize(vec2(-xBasis.y,xBasis.x));vec2 pointPositionInScreenSpace=a+xBasis*vertexCoord.x+yBasis*radius*vertexCoord.y;vec2 p=2.0*pointPositionInScreenSpace/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transformationMatrix*vec3(p,1);gl_Position=vec4(final.rg,0,1);}",attributes:{vertexCoord:Lr(e)},primitive:"triangle strip",count:4,uniforms:{color:e.prop("color"),width:e.prop("width"),pointIndex:e.prop("pointIndex"),size:e.prop("size"),positionsTexture:()=>this.currentPositionFbo,sizeScale:()=>t.pointSizeScale,pointsTextureSize:()=>n.pointsTextureSize,transformationMatrix:()=>n.transform,spaceSize:()=>n.adjustedSpaceSize,screenSize:()=>n.screenSize,scalePointsOnZoom:()=>t.scalePointsOnZoom,maxPointSize:()=>n.maxPointSize,pointGreyoutStatusTexture:()=>this.greyoutStatusFbo,universalPointOpacity:()=>t.pointOpacity,greyoutOpacity:()=>{var e;return null!==(e=t.pointGreyoutOpacity)&&void 0!==e?e:-1},isDarkenGreyout:()=>n.isDarkenGreyout,backgroundColor:()=>n.backgroundColor,greyoutColor:()=>n.greyoutPointColor},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.trackPointsCommand||(this.trackPointsCommand=e({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D positionsTexture;uniform sampler2D trackedIndices;uniform float pointsTextureSize;varying vec2 textureCoords;void main(){vec4 trackedPointIndices=texture2D(trackedIndices,textureCoords);if(trackedPointIndices.r<0.0)discard;vec4 pointPosition=texture2D(positionsTexture,(trackedPointIndices.rg+0.5)/pointsTextureSize);gl_FragColor=vec4(pointPosition.rg,1.0,1.0);}",vert:Rr,framebuffer:()=>this.trackedPositionsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:Lr(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,trackedIndices:()=>this.trackedIndicesFbo,pointsTextureSize:()=>n.pointsTextureSize}}))}updateColor(){const{reglInstance:e,store:{pointsTextureSize:t},data:n}=this;t&&(this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(n.pointColors))}updateGreyoutStatus(){const{reglInstance:e,store:{selectedIndices:t,pointsTextureSize:n}}=this;if(!n)return;const i=new Float32Array(n*n*4).fill(t?1:0);if(t)for(const e of t)i[4*e]=0;this.greyoutStatusTexture||(this.greyoutStatusTexture=e.texture()),this.greyoutStatusTexture({data:i,width:n,height:n,type:"float"}),this.greyoutStatusFbo||(this.greyoutStatusFbo=e.framebuffer()),this.greyoutStatusFbo({color:this.greyoutStatusTexture,depth:!1,stencil:!1})}updatePinnedStatus(){const{reglInstance:e,store:{pointsTextureSize:t},data:n}=this;if(!t)return;const i=new Float32Array(t*t*4).fill(0);if(n.inputPinnedPoints&&void 0!==n.pointsNumber)for(const e of n.inputPinnedPoints)e>=0&&e<n.pointsNumber&&(i[4*e]=1);this.pinnedStatusTexture||(this.pinnedStatusTexture=e.texture()),this.pinnedStatusTexture({data:i,width:t,height:t,type:"float"}),this.pinnedStatusFbo||(this.pinnedStatusFbo=e.framebuffer()),this.pinnedStatusFbo({color:this.pinnedStatusTexture,depth:!1,stencil:!1})}updateSize(){const{reglInstance:e,store:{pointsTextureSize:t},data:n}=this;if(!t||void 0===n.pointsNumber||void 0===n.pointSizes)return;this.sizeBuffer||(this.sizeBuffer=e.buffer(0)),this.sizeBuffer(n.pointSizes);const i=new Float32Array(t*t*4);for(let e=0;e<n.pointsNumber;e++)i[4*e]=n.pointSizes[e];this.sizeTexture||(this.sizeTexture=e.texture()),this.sizeTexture({data:i,width:t,height:t,type:"float"}),this.sizeFbo||(this.sizeFbo=e.framebuffer()),this.sizeFbo({color:this.sizeTexture,depth:!1,stencil:!1})}updateShape(){const{reglInstance:e,data:t}=this;void 0!==t.pointsNumber&&void 0!==t.pointShapes&&(this.shapeBuffer||(this.shapeBuffer=e.buffer(0)),this.shapeBuffer(t.pointShapes))}updateImageIndices(){const{reglInstance:e,data:t}=this;void 0!==t.pointsNumber&&void 0!==t.pointImageIndices&&(this.imageIndicesBuffer||(this.imageIndicesBuffer=e.buffer(0)),this.imageIndicesBuffer(t.pointImageIndices))}updateImageSizes(){const{reglInstance:e,data:t}=this;void 0!==t.pointsNumber&&void 0!==t.pointImageSizes&&(this.imageSizesBuffer||(this.imageSizesBuffer=e.buffer(0)),this.imageSizesBuffer(t.pointImageSizes))}createAtlas(){var e;const{reglInstance:t,data:n,store:i}=this;if(this.imageAtlasTexture||(this.imageAtlasTexture=t.texture()),this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=t.texture()),!(null===(e=n.inputImageData)||void 0===e?void 0:e.length))return this.imageCount=0,void(this.imageAtlasCoordsTextureSize=0);const r=function(e,t=16384){var n,i,r,o;if(!(null==e?void 0:e.length))return null;let a=0;for(const t of e){const e=Math.max(t.width,t.height);e>a&&(a=e)}if(0===a)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const s=a,u=Math.ceil(Math.sqrt(e.length));let l=u*a,c=1;l>t&&(c=t/l,a=Math.max(1,Math.floor(a*c)),l=Math.max(1,Math.floor(l*c)),console.warn(`🖼️ Atlas scaling required: Original size ${(s*u).toLocaleString()}px exceeds WebGL limit ${t.toLocaleString()}px. Scaling down to ${l.toLocaleString()}px (${Math.round(100*c)}% of original quality)`));const f=new Uint8Array(l*l*4).fill(0),h=new Float32Array(u*u*4).fill(-1);for(const[t,s]of e.entries()){const e=s.width,c=s.height;if(0===e||0===c)continue;const d=Math.min(1,a/Math.max(e,c)),p=Math.floor(e*d),m=Math.floor(c*d),v=t%u*a,g=Math.floor(t/u)*a;h[4*t]=v/l,h[4*t+1]=g/l,h[4*t+2]=(v+p)/l,h[4*t+3]=(g+m)/l;for(let t=0;t<m;t++)for(let a=0;a<p;a++){const u=Math.floor(a*(e/p)),h=4*(Math.floor(t*(c/m))*e+u),d=4*((g+t)*l+(v+a));f[d]=null!==(n=s.data[h])&&void 0!==n?n:0,f[d+1]=null!==(i=s.data[h+1])&&void 0!==i?i:0,f[d+2]=null!==(r=s.data[h+2])&&void 0!==r?r:0,f[d+3]=null!==(o=s.data[h+3])&&void 0!==o?o:255}}return{atlasData:f,atlasSize:l,atlasCoords:h,atlasCoordsSize:u}}(n.inputImageData,i.webglMaxTextureSize);if(!r)return void console.warn("Failed to create atlas from image data");this.imageCount=n.inputImageData.length;const{atlasData:o,atlasSize:a,atlasCoords:s,atlasCoordsSize:u}=r;this.imageAtlasCoordsTextureSize=u,this.imageAtlasTexture({data:o,shape:[a,a,4],type:"uint8"}),this.imageAtlasCoordsTexture({data:s,shape:[u,u,4],type:"float"})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},reglInstance:n}=this;let i=null!=t?t:Math.min(...e)/2;0===i&&(i=vi.pointSamplingDistance);const r=Math.ceil(e[0]/i),o=Math.ceil(e[1]/i);this.sampledPointsFbo||(this.sampledPointsFbo=n.framebuffer()),this.sampledPointsFbo({shape:[r,o],depth:!1,stencil:!1,colorType:"float"})}trackPoints(){var e,t;(null===(e=this.trackedIndices)||void 0===e?void 0:e.length)&&(null===(t=this.trackPointsCommand)||void 0===t||t.call(this))}draw(){var e,t,n,i,r,o,a,s,u;const{config:{renderHoveredPointRing:l,pointSize:c},store:f,data:h}=this;this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.imageAtlasCoordsTexture&&this.imageAtlasTexture||this.createAtlas(),f.selectedIndices&&f.selectedIndices.length>0?(null===(e=this.drawCommand)||void 0===e||e.call(this,{skipSelected:!0,skipUnselected:!1}),null===(t=this.drawCommand)||void 0===t||t.call(this,{skipSelected:!1,skipUnselected:!0})):null===(n=this.drawCommand)||void 0===n||n.call(this,{skipSelected:!1,skipUnselected:!1}),l&&f.hoveredPoint&&(null===(i=this.drawHighlightedCommand)||void 0===i||i.call(this,{width:.85,color:f.hoveredPointRingColor,pointIndex:f.hoveredPoint.index,size:null!==(o=null===(r=h.pointSizes)||void 0===r?void 0:r[f.hoveredPoint.index])&&void 0!==o?o:c})),f.focusedPoint&&(null===(a=this.drawHighlightedCommand)||void 0===a||a.call(this,{width:.75,color:f.focusedPointRingColor,pointIndex:f.focusedPoint.index,size:null!==(u=null===(s=h.pointSizes)||void 0===s?void 0:s[f.focusedPoint.index])&&void 0!==u?u:c}))}updatePosition(){var e;null===(e=this.updatePositionCommand)||void 0===e||e.call(this),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var e;null===(e=this.dragPointCommand)||void 0===e||e.call(this),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var e;null===(e=this.findPointsOnAreaSelectionCommand)||void 0===e||e.call(this)}findPointsOnPolygonSelection(){var e;null===(e=this.findPointsOnPolygonSelectionCommand)||void 0===e||e.call(this)}updatePolygonPath(e){const{reglInstance:t}=this;if(this.polygonPathLength=e.length,0===e.length)return this.polygonPathTexture=void 0,void(this.polygonPathFbo=void 0);const n=Math.ceil(Math.sqrt(e.length)),i=new Float32Array(n*n*4);for(const[t,n]of e.entries()){const[e,r]=n;i[4*t]=e,i[4*t+1]=r,i[4*t+2]=0,i[4*t+3]=0}this.polygonPathTexture||(this.polygonPathTexture=t.texture()),this.polygonPathTexture({data:i,width:n,height:n,type:"float"}),this.polygonPathFbo||(this.polygonPathFbo=t.framebuffer()),this.polygonPathFbo({color:this.polygonPathTexture,depth:!1,stencil:!1})}findHoveredPoint(){var e,t;null===(e=this.clearHoveredFboCommand)||void 0===e||e.call(this),null===(t=this.findHoveredPointCommand)||void 0===t||t.call(this)}trackPointsByIndices(e){const{store:{pointsTextureSize:t},reglInstance:n}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(null==e?void 0:e.length)||!t)return;const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4).fill(-1);for(const[n,i]of e.entries())void 0!==i&&(r[4*n]=i%t,r[4*n+1]=Math.floor(i/t),r[4*n+2]=0,r[4*n+3]=0);this.trackedIndicesTexture||(this.trackedIndicesTexture=n.texture()),this.trackedIndicesTexture({data:r,width:i,height:i,type:"float"}),this.trackedIndicesFbo||(this.trackedIndicesFbo=n.framebuffer()),this.trackedIndicesFbo({color:this.trackedIndicesTexture,depth:!1,stencil:!1}),this.trackedPositionsFbo||(this.trackedPositionsFbo=n.framebuffer()),this.trackedPositionsFbo({shape:[i,i],depth:!1,stencil:!1,colorType:"float"}),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;const n=zr(this.reglInstance,this.trackedPositionsFbo),i=new Map;for(let e=0;e<n.length/4;e+=1){const t=n[4*e],r=n[4*e+1],o=this.trackedIndices[e];void 0!==t&&void 0!==r&&void 0!==o&&i.set(o,[t,r])}return e&&t||(this.trackedPositions=i,this.isPositionsUpToDate=!0),i}getSampledPointPositionsMap(){var e,t;const n=new Map;if(!this.sampledPointsFbo)return n;null===(e=this.clearSampledPointsFboCommand)||void 0===e||e.call(this),null===(t=this.fillSampledPointsFboCommand)||void 0===t||t.call(this);const i=zr(this.reglInstance,this.sampledPointsFbo);for(let e=0;e<i.length/4;e++){const t=i[4*e],r=!!i[4*e+1],o=i[4*e+2],a=i[4*e+3];r&&void 0!==t&&void 0!==o&&void 0!==a&&n.set(t,[o,a])}return n}getSampledPoints(){var e,t;const n=[],i=[];if(!this.sampledPointsFbo)return{indices:n,positions:i};null===(e=this.clearSampledPointsFboCommand)||void 0===e||e.call(this),null===(t=this.fillSampledPointsFboCommand)||void 0===t||t.call(this);const r=zr(this.reglInstance,this.sampledPointsFbo);for(let e=0;e<r.length/4;e++){const t=r[4*e],o=!!r[4*e+1],a=r[4*e+2],s=r[4*e+3];o&&void 0!==t&&void 0!==a&&void 0!==s&&(n.push(t),i.push(a,s))}return{indices:n,positions:i}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices)return e;e.length=2*this.trackedIndices.length;const t=zr(this.reglInstance,this.trackedPositionsFbo);for(let n=0;n<t.length/4;n+=1){const i=t[4*n],r=t[4*n+1],o=this.trackedIndices[n];void 0!==i&&void 0!==r&&void 0!==o&&(e[2*n]=i,e[2*n+1]=r)}return e}swapFbo(){const e=this.previousPositionFbo;this.previousPositionFbo=this.currentPositionFbo,this.currentPositionFbo=e}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,n=t.length/2;let i=1/0,r=-1/0,o=1/0,a=-1/0;for(let e=0;e<t.length;e+=2){const n=t[e],s=t[e+1];i=Math.min(i,n),r=Math.max(r,n),o=Math.min(o,s),a=Math.max(a,s)}const s=r-i,u=a-o,l=Math.max(s,u);if(l>e)return this.scaleX=void 0,void(this.scaleY=void 0);const c=(n>e*e*.001?e*Math.max(1.2,Math.sqrt(n)/e):.1*e)/l,f=(l-s)/2*c,h=(l-u)/2*c;this.scaleX=e=>(e-i)*c+f,this.scaleY=e=>(e-o)*c+h;for(let e=0;e<n;e++)this.data.pointPositions[2*e]=this.scaleX(t[2*e]),this.data.pointPositions[2*e+1]=this.scaleY(t[2*e+1])}}var Js="undefined"!=typeof Float32Array?Float32Array:Array;function eu(){var e=new Js(9);return Js!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function tu(e,t,n){var i=t[0],r=t[1],o=t[2],a=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=n[0],d=n[1];return e[0]=i,e[1]=r,e[2]=o,e[3]=a,e[4]=s,e[5]=u,e[6]=h*i+d*a+l,e[7]=h*r+d*s+c,e[8]=h*o+d*u+f,e}function nu(e,t,n){var i=n[0],r=n[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=r*t[3],e[4]=r*t[4],e[5]=r*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function iu(){var e=new Js(3);return Js!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ru(e,t,n){var i=new Js(3);return i[0]=e,i[1]=t,i[2]=n,i}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function ou(){var e=new Js(4);return Js!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}iu(),function(){var e,t=(e=new Js(4),Js!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();iu(),ru(1,0,0),ru(0,1,0),ou(),ou(),eu(),function(){var e,t=(e=new Js(2),Js!=Float32Array&&(e[0]=0,e[1]=0),e)}();var au={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this,n=function(){var e=4022871197,t=function(t){t=String(t);for(var n=0;n<t.length;n++){var i=.02519603282416938*(e+=t.charCodeAt(n));i-=e=i>>>0,e=(i*=e)>>>0,e+=4294967296*(i-=e)}return 2.3283064365386963e-10*(e>>>0)};return t}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function r(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var n=new i(e),o=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.alea=o}(0,e,!1)}(au);var su={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var i=0;i<n.length+64;i++)t.x^=0|n.charCodeAt(i),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.xor128=o}(0,e,!1)}(su);var uu={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var i=0;i<n.length+64;i++)t.x^=0|n.charCodeAt(i),i==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.xorwow=o}(0,e,!1)}(uu);var lu={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this;t.next=function(){var e,n,i=t.x,r=t.i;return e=i[r],n=(e^=e>>>7)^e<<24,n^=(e=i[r+1&7])^e>>>10,n^=(e=i[r+3&7])^e>>>3,n^=(e=i[r+4&7])^e<<7,e=i[r+7&7],n^=(e^=e<<13)^e<<9,i[r]=n,t.i=r+1&7,n},function(e,t){var n,i=[];if(t===(0|t))i[0]=t;else for(t=""+t,n=0;n<t.length;++n)i[7&n]=i[7&n]<<15^t.charCodeAt(n)+i[n+1&7]<<13;for(;i.length<8;)i.push(0);for(n=0;n<8&&0===i[n];++n);for(8==n?i[7]=-1:i[n],e.x=i,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function r(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&(o.x&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.xorshift7=o}(0,e,!1)}(lu);var cu={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this;t.next=function(){var e,n,i=t.w,r=t.X,o=t.i;return t.w=i=i+1640531527|0,n=r[o+34&127],e=r[o=o+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=r[o]=n^e,t.i=o,n+(i^i>>>16)|0},function(e,t){var n,i,r,o,a,s=[],u=128;for(t===(0|t)?(i=t,t=null):(t+="\0",i=0,u=Math.max(u,t.length)),r=0,o=-32;o<u;++o)t&&(i^=t.charCodeAt((o+32)%t.length)),0===o&&(a=i),i^=i<<10,i^=i>>>15,i^=i<<4,i^=i>>>13,o>=0&&(a=a+1640531527|0,r=0==(n=s[127&o]^=i+a)?r+1:0);for(r>=128&&(s[127&(t&&t.length||0)]=-1),r=127,o=512;o>0;--o)i=s[r+34&127],n=s[r=r+1&127],i^=i<<13,n^=n<<17,i^=i>>>15,n^=n>>>12,s[r]=i^n;e.w=a,e.X=s,e.i=r}(t,e)}function r(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&(o.X&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.xor4096=o}(0,e,!1)}(cu);var fu={exports:{}};!function(e){!function(e,t,n){function i(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,i=t.d,r=t.a;return e=e<<25^e>>>7^n,n=n-i|0,i=i<<24^i>>>8^r,r=r-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-i|0,t.d=i<<16^n>>>16^r,t.a=r-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var i=0;i<n.length+20;i++)t.b^=0|n.charCodeAt(i),t.next()}function r(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:n&&n.amd?n((function(){return o})):this.tychei=o}(0,e,!1)}(fu);var hu={exports:{}};!function(e){!function(t,n,i){var r,o=256,a="random",s=i.pow(o,6),u=i.pow(2,52),l=2*u,c=o-1;function f(e,c,f){var g=[],y=m(p((c=1==c?{entropy:!0}:c||{}).entropy?[e,v(n)]:null==e?function(){try{var e;return r&&(e=r.randomBytes)?e=e(o):(e=new Uint8Array(o),(t.crypto||t.msCrypto).getRandomValues(e)),v(e)}catch(e){var i=t.navigator,a=i&&i.plugins;return[+new Date,t,a,t.screen,v(n)]}}():e,3),g),b=new h(g),x=function(){for(var e=b.g(6),t=s,n=0;e<u;)e=(e+n)*o,t*=o,n=b.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|b.g(4)},x.quick=function(){return b.g(4)/4294967296},x.double=x,m(v(b.S),n),(c.pass||f||function(e,t,n,r){return r&&(r.S&&d(r,b),e.state=function(){return d(b,{})}),n?(i[a]=e,t):e})(x,y,"global"in c?c.global:this==i,c.state)}function h(e){var t,n=e.length,i=this,r=0,a=i.i=i.j=0,s=i.S=[];for(n||(e=[n++]);r<o;)s[r]=r++;for(r=0;r<o;r++)s[r]=s[a=c&a+e[r%n]+(t=s[r])],s[a]=t;(i.g=function(e){for(var t,n=0,r=i.i,a=i.j,s=i.S;e--;)t=s[r=c&r+1],n=n*o+s[c&(s[r]=s[a=c&a+t])+(s[a]=t)];return i.i=r,i.j=a,n})(o)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function p(e,t){var n,i=[],r=typeof e;if(t&&"object"==r)for(n in e)try{i.push(p(e[n],t-1))}catch(e){}return i.length?i:"string"==r?e:e+"\0"}function m(e,t){for(var n,i=e+"",r=0;r<i.length;)t[c&r]=c&(n^=19*t[c&r])+i.charCodeAt(r++);return v(t)}function v(e){return String.fromCharCode.apply(0,e)}if(m(i.random(),n),e.exports){e.exports=f;try{r=require("crypto")}catch(e){}}else i["seed"+a]=f}("undefined"!=typeof self?self:fi,[],Math)}(hu);var du=au.exports,pu=su.exports,mu=uu.exports,vu=lu.exports,gu=cu.exports,yu=fu.exports,bu=hu.exports;bu.alea=du,bu.xor128=pu,bu.xorwow=mu,bu.xorshift7=vu,bu.xor4096=gu,bu.tychei=yu;var xu=bu;function Su(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(r=i.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(r,"string"))?o:String(o)),i)}var r,o}function wu(e,t,n){return t&&Su(e.prototype,t),n&&Su(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ku(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Cu(e,t)}function Cu(e,t){return Cu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Cu(e,t)}var Tu=function(){function e(){}return e.prototype._seed=function(e,t){if(e===(e||0))return e;for(var n=""+e,i=0,r=0;r<n.length;++r)i^=0|n.charCodeAt(r);return i},e}(),Pu=function(e){function t(t,n){var i;return(i=e.call(this)||this)._rng=void 0,i.seed(t,n),i}ku(t,e);var n=t.prototype;return n.next=function(){return this._rng()},n.seed=function(e,t){this._rng=e},n.clone=function(e,n){return new t(this._rng,n)},wu(t,[{key:"name",get:function(){return"function"}}]),t}(Tu),_u=function(){var e=[].slice.call(arguments),t=e[0],n=void 0===t?"default":t;switch(typeof n){case"object":if(n instanceof Tu)return n;break;case"function":return new Pu(n);default:return new Pu(xu.apply(void 0,e))}throw new Error('invalid RNG "'+n+'"')},Au=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),function(){return e.next()*(n-t)+t}};function zu(e){return new Iu(e)}var Iu=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(e){if(t.n<e)return t;throw new Error("Expected number to be less than "+e+", got "+t.n)},this.greaterThanOrEqual=function(e){if(t.n>=e)return t;throw new Error("Expected number to be greater than or equal to "+e+", got "+t.n)},this.greaterThan=function(e){if(t.n>e)return t;throw new Error("Expected number to be greater than "+e+", got "+t.n)},this.n=e},Du=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),void 0===n&&(n=void 0===t?1:t,t=0),zu(t).isInt(),zu(n).isInt(),function(){return Math.floor(e.next()*(n-t+1)+t)}},Mu=function(e){return function(){return e.next()>=.5}},Fu=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],Eu=function(e){return Fu[e]},Lu=function(e){function t(){return e.apply(this,arguments)||this}ku(t,e);var n=t.prototype;return n.next=function(){return Math.random()},n.seed=function(e,t){},n.clone=function(){return new t},wu(t,[{key:"name",get:function(){return"default"}}]),t}(Tu),Ou=function(){function e(e){var t=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return t._rng.next()},this.float=function(e,n){return t.uniform(e,n)()},this.int=function(e,n){return t.uniformInt(e,n)()},this.integer=function(e,n){return t.uniformInt(e,n)()},this.bool=function(){return t.uniformBoolean()()},this.boolean=function(){return t.uniformBoolean()()},this.uniform=function(e,n){return t._memoize("uniform",Au,e,n)},this.uniformInt=function(e,n){return t._memoize("uniformInt",Du,e,n)},this.uniformBoolean=function(){return t._memoize("uniformBoolean",Mu)},this.normal=function(e,n){return function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),function(){var i,r,o;do{o=(i=2*e.next()-1)*i+(r=2*e.next()-1)*r}while(!o||o>1);return t+n*r*Math.sqrt(-2*Math.log(o)/o)}}(t,e,n)},this.logNormal=function(e,n){return function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=1);var i=e.normal(t,n);return function(){return Math.exp(i())}}(t,e,n)},this.bernoulli=function(e){return function(e,t){return void 0===t&&(t=.5),zu(t).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(e.next()+t)}}(t,e)},this.binomial=function(e,n){return function(e,t,n){return void 0===t&&(t=1),void 0===n&&(n=.5),zu(t).isInt().isPositive(),zu(n).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<t;)e.next()<n&&r++;return r}}(t,e,n)},this.geometric=function(e){return function(e,t){void 0===t&&(t=.5),zu(t).greaterThan(0).lessThan(1);var n=1/Math.log(1-t);return function(){return Math.floor(1+Math.log(e.next())*n)}}(t,e)},this.poisson=function(e){return function(e,t){if(void 0===t&&(t=1),zu(t).isPositive(),t<10){var n=Math.exp(-t);return function(){for(var i=n,r=0,o=e.next();o>i;)o-=i,i=t*i/++r;return r}}var i=Math.sqrt(t),r=.931+2.53*i,o=.02483*r-.059,a=1.1239+1.1328/(r-3.4),s=.9277-3.6224/(r-2);return function(){for(;;){var n=void 0,u=e.next();if(u<=.86*s)return n=u/s-.43,Math.floor((2*o/(.5-Math.abs(n))+r)*n+t+.445);u>=s?n=e.next()-.5:(n=((n=u/s-.93)<0?-.5:.5)-n,u=e.next()*s);var l=.5-Math.abs(n);if(!(l<.013&&u>l)){var c=Math.floor((2*o/l+r)*n+t+.445);if(u=u*a/(o/(l*l)+r),c>=10){var f=(c+.5)*Math.log(t/c)-t-.9189385332046727+c-(1/12-(1/360-1/(1260*c*c))/(c*c))/c;if(Math.log(u*i)<=f)return c}else if(c>=0){var h,d=null!=(h=Eu(c))?h:0;if(Math.log(u)<=c*Math.log(t)-t-d)return c}}}}}(t,e)},this.exponential=function(e){return function(e,t){return void 0===t&&(t=1),zu(t).isPositive(),function(){return-Math.log(1-e.next())/t}}(t,e)},this.irwinHall=function(e){return function(e,t){return void 0===t&&(t=1),zu(t).isInt().greaterThanOrEqual(0),function(){for(var n=0,i=0;i<t;++i)n+=e.next();return n}}(t,e)},this.bates=function(e){return function(e,t){void 0===t&&(t=1),zu(t).isInt().isPositive();var n=e.irwinHall(t);return function(){return n()/t}}(t,e)},this.pareto=function(e){return function(e,t){void 0===t&&(t=1),zu(t).greaterThanOrEqual(0);var n=1/t;return function(){return 1/Math.pow(1-e.next(),n)}}(t,e)},e&&e instanceof Tu?this.use(e):this.use(new Lu),this._cache={}}var t=e.prototype;return t.clone=function(){var t=[].slice.call(arguments);return t.length?new e(_u.apply(void 0,t)):new e(this.rng.clone())},t.use=function(){this._rng=_u.apply(void 0,[].slice.call(arguments))},t.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},t.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},t.choice=function(e){if(!Array.isArray(e))throw new Error("Random.choice expected input to be an array, got "+typeof e);var t=null==e?void 0:e.length;return t>0?e[this.uniformInt(0,t-1)()]:void 0},t._memoize=function(e,t){var n=[].slice.call(arguments,2),i=""+n.join(";"),r=this._cache[e];return void 0!==r&&r.key===i||(r={key:i,distribution:t.apply(void 0,[this].concat(n))},this._cache[e]=r),r.distribution},wu(e,[{key:"rng",get:function(){return this._rng}}]),e}();new Ou;const Nu=.001;class Ru{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=eu(),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=64,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=vi.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,.7],this.focusedPointRingColor=[1,1,1,.95],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=Ro(),this.scalePointY=Ro(),this.random=new Ou,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Nu,1/e)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e;const t=Ar(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(${255*e[0]}, ${255*e[1]}, ${255*e[2]}, ${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:n}=this;this.screenSize=[e,t],this.scalePointX.domain([0,n]).range([(e-n)/2,(e+n)/2]),this.scalePointY.domain([n,0]).range([(t-n)/2,(t+n)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=_r(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=_r(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(void 0===e)return void(this.greyoutPointColor=[-1,-1,-1,-1]);const t=_r(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(void 0===e)return void(this.hoveredLinkColor=[-1,-1,-1,-1]);const t=_r(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){this.focusedPoint=void 0!==e?{index:e}:void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const ju={passive:!1},Bu={capture:!0,passive:!1};function Vu(e){e.stopImmediatePropagation()}function Uu(e){e.preventDefault(),e.stopImmediatePropagation()}function Gu(e){var t=e.document.documentElement,n=de(e).on("dragstart.drag",Uu,Bu);"onselectstart"in t?n.on("selectstart.drag",Uu,Bu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Hu(e,t){var n=e.document.documentElement,i=de(e).on("dragstart.drag",null);t&&(i.on("click.drag",Uu,Bu),setTimeout((function(){i.on("click.drag",null)}),0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Wu=e=>()=>e;function qu(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:o,x:a,y:s,dx:u,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}function Yu(e){return!e.ctrlKey&&!e.button}function $u(){return this.parentNode}function Xu(e,t){return null==t?{x:e.x,y:e.y}:t}function Zu(){return navigator.maxTouchPoints||"ontouchstart"in this}qu.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Qu=e=>()=>e;function Ku(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Ju(e,t,n){this.k=e,this.x=t,this.y=n}Ju.prototype={constructor:Ju,scale:function(e){return 1===e?this:new Ju(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new Ju(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var el=new Ju(1,0,0);function tl(e){e.stopImmediatePropagation()}function nl(e){e.preventDefault(),e.stopImmediatePropagation()}function il(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function rl(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function ol(){return this.__zoom||el}function al(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function sl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ul(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Ju.prototype;class ll{constructor(e,t){this.eventTransform=el,this.behavior=function(){var e,t,n,i=il,r=rl,o=ul,a=al,s=sl,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,f=Fn,h=ye("start","zoom","end"),d=500,p=150,m=0,v=10;function g(e){e.property("__zoom",ol).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",_).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(e,t){return(t=Math.max(u[0],Math.min(u[1],t)))===e.k?e:new Ju(t,e.x,e.y)}function b(e,t,n){var i=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return i===e.x&&r===e.y?e:new Ju(e.k,i,r)}function x(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function S(e,t,n,i){e.on("start.zoom",(function(){w(this,arguments).event(i).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(i).end()})).tween("zoom",(function(){var e=this,o=arguments,a=w(e,o).event(i),s=r.apply(e,o),u=null==n?x(s):"function"==typeof n?n.apply(e,o):n,l=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=e.__zoom,h="function"==typeof t?t.apply(e,o):t,d=f(c.invert(u).concat(l/c.k),h.invert(u).concat(l/h.k));return function(e){if(1===e)e=h;else{var t=d(e),n=l/t[2];e=new Ju(n,u[0]-t[0]*n,u[1]-t[1]*n)}a.zoom(null,e)}}))}function w(e,t,n){return!n&&e.__zooming||new k(e,t)}function k(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function C(e,...t){if(i.apply(this,arguments)){var n=w(this,t).event(e),r=this.__zoom,s=Math.max(u[0],Math.min(u[1],r.k*Math.pow(2,a.apply(this,arguments)))),c=ve(e);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=r.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[c,r.invert(c)],et(this),n.start()}nl(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),p),n.zoom("mouse",o(b(y(r,s),n.mouse[0],n.mouse[1]),n.extent,l))}}function T(e,...t){if(!n&&i.apply(this,arguments)){var r=e.currentTarget,a=w(this,t,!0).event(e),s=de(e.view).on("mousemove.zoom",(function(e){if(nl(e),!a.moved){var t=e.clientX-c,n=e.clientY-f;a.moved=t*t+n*n>m}a.event(e).zoom("mouse",o(b(a.that.__zoom,a.mouse[0]=ve(e,r),a.mouse[1]),a.extent,l))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Hu(e.view,a.moved),nl(e),a.event(e).end()}),!0),u=ve(e,r),c=e.clientX,f=e.clientY;Gu(e.view),tl(e),a.mouse=[u,this.__zoom.invert(u)],et(this),a.start()}}function P(e,...t){if(i.apply(this,arguments)){var n=this.__zoom,a=ve(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),u=n.k*(e.shiftKey?.5:2),f=o(b(y(n,u),a,s),r.apply(this,t),l);nl(e),c>0?de(this).transition().duration(c).call(S,f,a,e):de(this).call(g.transform,f,a,e)}}function _(n,...r){if(i.apply(this,arguments)){var o,a,s,u,l=n.touches,c=l.length,f=w(this,r,n.changedTouches.length===c).event(n);for(tl(n),a=0;a<c;++a)u=[u=ve(s=l[a],this),this.__zoom.invert(u),s.identifier],f.touch0?f.touch1||f.touch0[2]===u[2]||(f.touch1=u,f.taps=0):(f.touch0=u,o=!0,f.taps=1+!!e);e&&(e=clearTimeout(e)),o&&(f.taps<2&&(t=u[0],e=setTimeout((function(){e=null}),d)),et(this),f.start())}}function A(e,...t){if(this.__zooming){var n,i,r,a,s=w(this,t).event(e),u=e.changedTouches,c=u.length;for(nl(e),n=0;n<c;++n)r=ve(i=u[n],this),s.touch0&&s.touch0[2]===i.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===i.identifier&&(s.touch1[0]=r);if(i=s.that.__zoom,s.touch1){var f=s.touch0[0],h=s.touch0[1],d=s.touch1[0],p=s.touch1[1],m=(m=d[0]-f[0])*m+(m=d[1]-f[1])*m,v=(v=p[0]-h[0])*v+(v=p[1]-h[1])*v;i=y(i,Math.sqrt(m/v)),r=[(f[0]+d[0])/2,(f[1]+d[1])/2],a=[(h[0]+p[0])/2,(h[1]+p[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],a=s.touch0[1]}s.zoom("touch",o(b(i,r,a),s.extent,l))}}function z(e,...i){if(this.__zooming){var r,o,a=w(this,i).event(e),s=e.changedTouches,u=s.length;for(tl(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),d),r=0;r<u;++r)o=s[r],a.touch0&&a.touch0[2]===o.identifier?delete a.touch0:a.touch1&&a.touch1[2]===o.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(o=ve(o,this),Math.hypot(t[0]-o[0],t[1]-o[1])<v)){var l=de(this).on("dblclick.zoom");l&&l.apply(this,arguments)}}}return g.transform=function(e,t,n,i){var r=e.selection?e.selection():e;r.property("__zoom",ol),e!==r?S(e,t,n,i):r.interrupt().each((function(){w(this,arguments).event(i).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},g.scaleBy=function(e,t,n,i){g.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,i)},g.scaleTo=function(e,t,n,i){g.transform(e,(function(){var e=r.apply(this,arguments),i=this.__zoom,a=null==n?x(e):"function"==typeof n?n.apply(this,arguments):n,s=i.invert(a),u="function"==typeof t?t.apply(this,arguments):t;return o(b(y(i,u),a,s),e,l)}),n,i)},g.translateBy=function(e,t,n,i){g.transform(e,(function(){return o(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),l)}),null,i)},g.translateTo=function(e,t,n,i,a){g.transform(e,(function(){var e=r.apply(this,arguments),a=this.__zoom,s=null==i?x(e):"function"==typeof i?i.apply(this,arguments):i;return o(el.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,l)}),i,a)},k.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=de(this.that).datum();h.call(e,this.that,new Ku(e,{sourceEvent:this.sourceEvent,target:g,type:e,transform:this.that.__zoom,dispatch:h}),t)}},g.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:Qu(+e),g):a},g.filter=function(e){return arguments.length?(i="function"==typeof e?e:Qu(!!e),g):i},g.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Qu(!!e),g):s},g.extent=function(e){return arguments.length?(r="function"==typeof e?e:Qu([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),g):r},g.scaleExtent=function(e){return arguments.length?(u[0]=+e[0],u[1]=+e[1],g):[u[0],u[1]]},g.translateExtent=function(e){return arguments.length?(l[0][0]=+e[0][0],l[1][0]=+e[1][0],l[0][1]=+e[0][1],l[1][1]=+e[1][1],g):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},g.constrain=function(e){return arguments.length?(o=e,g):o},g.duration=function(e){return arguments.length?(c=+e,g):c},g.interpolate=function(e){return arguments.length?(f=e,g):f},g.on=function(){var e=h.on.apply(h,arguments);return e===h?g:e},g.clickDistance=function(e){return arguments.length?(m=(e=+e)*e,g):Math.sqrt(m)},g.tapDistance=function(e){return arguments.length?(v=+e,g):v},g}().scaleExtent([.001,1/0]).on("start",(e=>{var t,n;this.isRunning=!0;const i=!!e.sourceEvent;null===(n=null===(t=this.config)||void 0===t?void 0:t.onZoomStart)||void 0===n||n.call(t,e,i)})).on("zoom",(e=>{var t,n;this.eventTransform=e.transform;const{eventTransform:{x:i,y:r,k:o},store:{transform:a,screenSize:s}}=this,u=s[0],l=s[1];if(!u||!l)return;var c,f,h;f=u,h=l,(c=a)[0]=2/f,c[1]=0,c[2]=0,c[3]=0,c[4]=-2/h,c[5]=0,c[6]=-1,c[7]=1,c[8]=1,tu(a,a,[i,r]),nu(a,a,[o,o]),tu(a,a,[u/2,l/2]),nu(a,a,[u/2,l/2]),nu(a,a,[1,-1]);const d=!!e.sourceEvent;null===(n=null===(t=this.config)||void 0===t?void 0:t.onZoom)||void 0===n||n.call(t,e,d)})).on("end",(e=>{var t,n;this.isRunning=!1;const i=!!e.sourceEvent;null===(n=null===(t=this.config)||void 0===t?void 0:t.onZoomEnd)||void 0===n||n.call(t,e,i)})),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,n=.1){if(0===e.length)return this.eventTransform;const{store:{screenSize:i}}=this,r=i[0],o=i[1],a=ao(e.map((e=>e[0]))),s=ao(e.map((e=>e[1])));a[0]=this.store.scaleX(a[0]),a[1]=this.store.scaleX(a[1]),s[0]=this.store.scaleY(s[0]),s[1]=this.store.scaleY(s[1]),a[0]===a[1]&&(a[0]-=.5,a[1]+=.5),s[0]===s[1]&&(s[0]+=.5,s[1]-=.5);const u=r*(1-2*n)/(a[1]-a[0]),l=o*(1-2*n)/(s[0]-s[1]),c=Ir(null!=t?t:Math.min(u,l),...this.behavior.scaleExtent()),f=r/2-(a[1]+a[0])/2*c,h=o/2-(s[1]+s[0])/2*c;return el.translate(f,h).scale(c)}getDistanceToPoint(e){const{x:t,y:n,k:i}=this.eventTransform,r=this.getTransform([e],i),o=t-r.x,a=n-r.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:n,y:i,k:r}}=this,o=t[0],a=t[1],s=(a/2-i)/r,u=o/2-1*(((o/2-n)/r+this.store.scaleX(e[0]))/2),l=a/2-1*((s+this.store.scaleY(e[1]))/2);return el.translate(u,l).scale(1)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:n,k:i},store:{screenSize:r}}=this,o=r[0],a=r[1],s=[(e[0]-t)/i,a-(e[1]-n)/i];return s[0]-=(o-this.store.adjustedSpaceSize)/2,s[1]-=(a-this.store.adjustedSpaceSize)/2,s}convertSpaceToScreenPosition(e){return[this.eventTransform.applyX(this.store.scaleX(e[0])),this.eventTransform.applyY(this.store.scaleY(e[1]))]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:n},eventTransform:{k:i}}=this;let r=2*e;return r*=t?i:Math.min(5,Math.max(1,.01*i)),Math.min(r,n)/2}}class cl{constructor(e,t){this.isActive=!1,this.behavior=function(){var e,t,n,i,r=Yu,o=$u,a=Xu,s=Zu,u={},l=ye("start","drag","end"),c=0,f=0;function h(e){e.on("mousedown.drag",d).filter(s).on("touchstart.drag",v).on("touchmove.drag",g,ju).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(a,s){if(!i&&r.call(this,a,s)){var u=b(this,o.call(this,a,s),a,s,"mouse");u&&(de(a.view).on("mousemove.drag",p,Bu).on("mouseup.drag",m,Bu),Gu(a.view),Vu(a),n=!1,e=a.clientX,t=a.clientY,u("start",a))}}function p(i){if(Uu(i),!n){var r=i.clientX-e,o=i.clientY-t;n=r*r+o*o>f}u.mouse("drag",i)}function m(e){de(e.view).on("mousemove.drag mouseup.drag",null),Hu(e.view,n),Uu(e),u.mouse("end",e)}function v(e,t){if(r.call(this,e,t)){var n,i,a=e.changedTouches,s=o.call(this,e,t),u=a.length;for(n=0;n<u;++n)(i=b(this,s,e,t,a[n].identifier,a[n]))&&(Vu(e),i("start",e,a[n]))}}function g(e){var t,n,i=e.changedTouches,r=i.length;for(t=0;t<r;++t)(n=u[i[t].identifier])&&(Uu(e),n("drag",e,i[t]))}function y(e){var t,n,r=e.changedTouches,o=r.length;for(i&&clearTimeout(i),i=setTimeout((function(){i=null}),500),t=0;t<o;++t)(n=u[r[t].identifier])&&(Vu(e),n("end",e,r[t]))}function b(e,t,n,i,r,o){var s,f,d,p=l.copy(),m=ve(o||n,t);if(null!=(d=a.call(e,new qu("beforestart",{sourceEvent:n,target:h,identifier:r,active:c,x:m[0],y:m[1],dx:0,dy:0,dispatch:p}),i)))return s=d.x-m[0]||0,f=d.y-m[1]||0,function n(o,a,l){var v,g=m;switch(o){case"start":u[r]=n,v=c++;break;case"end":delete u[r],--c;case"drag":m=ve(l||a,t),v=c}p.call(o,e,new qu(o,{sourceEvent:a,subject:d,target:h,identifier:r,active:v,x:m[0]+s,y:m[1]+f,dx:m[0]-g[0],dy:m[1]-g[1],dispatch:p}),i)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:Wu(!!e),h):r},h.container=function(e){return arguments.length?(o="function"==typeof e?e:Wu(e),h):o},h.subject=function(e){return arguments.length?(a="function"==typeof e?e:Wu(e),h):a},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Wu(!!e),h):s},h.on=function(){var e=l.on.apply(l,arguments);return e===l?h:e},h.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,h):Math.sqrt(f)},h}().subject((e=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:e.x,y:e.y}:void 0)).on("start",(e=>{var t,n;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,null===(n=null===(t=this.config)||void 0===t?void 0:t.onDragStart)||void 0===n||n.call(t,e))})).on("drag",(e=>{var t,n;null===(n=null===(t=this.config)||void 0===t?void 0:t.onDrag)||void 0===n||n.call(t,e)})).on("end",(e=>{var t,n;this.isActive=!1,this.store.draggingPointIndex=void 0,null===(n=null===(t=this.config)||void 0===t?void 0:t.onDragEnd)||void 0===n||n.call(t,e)})),this.store=e,this.config=t}}e.Graph=class{constructor(e,t){var n,i,r,o,a,s;this.config=new Fr,this.graph=new eo(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new Ru,this.zoomInstance=new ll(this.store,this.config),this.dragInstance=new cl(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 u=document.createElement("canvas");u.style.width="100%",u.style.height="100%",this.store.div.appendChild(u),this.addAttribution();const l=u.clientWidth,c=u.clientHeight;let f;u.width=l*this.config.pixelRatio,u.height=c*this.config.pixelRatio,this.canvas=u;try{f=di({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch(e){return function(e){const t=document.createElement("div");t.style.cssText="\n color: var(--cosmosgl-error-message-color);\n padding: 0em 2em;\n position: absolute;\n top: 50%; left: 0; right: 0;\n transform: translateY(-50%);\n z-index: 1000;\n font-family: inherit;\n font-size: 1rem;\n text-align: center;\n user-select: none;\n ",t.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",e.appendChild(t)}(this.store.div),void(this._isDestroyed=!0)}this.reglInstance=f,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.setWebGLMaxTextureSize(this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(l,c),this.canvasD3Selection=de(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",(()=>{this._isMouseOnCanvas=!0})).on("mousemove.cosmos",(()=>{this._isMouseOnCanvas=!0})).on("mouseleave.cosmos",(e=>{this._isMouseOnCanvas=!1,this.currentEvent=e,void 0!==this.store.hoveredPoint&&this.config.onPointMouseOut&&this.config.onPointMouseOut(e),void 0!==this.store.hoveredLinkIndex&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(e),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()})),de(document).on("keydown.cosmos",(e=>{"Space"===e.code&&(this.store.isSpaceKeyPressed=!0)})).on("keyup.cosmos",(e=>{"Space"===e.code&&(this.store.isSpaceKeyPressed=!1)})),this.zoomInstance.behavior.on("start.detect",(e=>{this.currentEvent=e})).on("zoom.detect",(e=>{!!e.sourceEvent&&this.updateMousePosition(e.sourceEvent),this.currentEvent=e})).on("end.detect",(e=>{this.currentEvent=e})),this.dragInstance.behavior.on("start.detect",(e=>{this.currentEvent=e,this.updateCanvasCursor()})).on("drag.detect",(e=>{this.dragInstance.isActive&&this.updateMousePosition(e),this.currentEvent=e})).on("end.detect",(e=>{this.currentEvent=e,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(null!==(n=this.config.initialZoomLevel)&&void 0!==n?n:1),this.store.maxPointSize=(null!==(i=this.reglInstance.limits.pointSizeDims[1])&&void 0!==i?i:64)/this.config.pixelRatio,this.points=new Ks(this.reglInstance,this.config,this.store,this.graph),this.lines=new Qs(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new Vr(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new jr(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new Yr(this.reglInstance,this.config,this.store,this.graph,this.points):new Wr(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Ur(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Ur(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new $r(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new Xr(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=_r(this.config.backgroundColor),this.store.setHoveredPointRingColor(null!==(r=this.config.hoveredPointRingColor)&&void 0!==r?r:vi.hoveredPointRingColor),this.store.setFocusedPointRingColor(null!==(o=this.config.focusedPointRingColor)&&void 0!==o?o:vi.focusedPointRingColor),void 0!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(null!==(a=this.config.pointGreyoutColor)&&void 0!==a?a:pi),this.store.setHoveredLinkColor(null!==(s=this.config.hoveredLinkColor)&&void 0!==s?s:vi.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Kr(this.canvas)),void 0!==this.config.randomSeed&&this.store.addRandomSeed(this.config.randomSeed)}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return!this._isDestroyed&&this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var t,n,i,r,o,a,s;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const u={...this.config};this.config.init(e),u.pointDefaultColor===this.config.pointDefaultColor&&u.pointColor===this.config.pointColor||(this.graph.updatePointColor(),this.points.updateColor()),u.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),this.points.updateSize()),u.linkDefaultColor===this.config.linkDefaultColor&&u.linkColor===this.config.linkColor||(this.graph.updateLinkColor(),this.lines.updateColor()),u.linkWidth!==this.config.linkWidth&&(this.graph.updateLinkWidth(),this.lines.updateWidth()),u.linkArrows!==this.config.linkArrows&&(this.graph.updateArrows(),this.lines.updateArrow()),u.curvedLinkSegments===this.config.curvedLinkSegments&&u.curvedLinks===this.config.curvedLinks||this.lines.updateCurveLineGeometry(),u.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=_r(null!==(t=this.config.backgroundColor)&&void 0!==t?t:mi)),u.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(null!==(n=this.config.hoveredPointRingColor)&&void 0!==n?n:vi.hoveredPointRingColor),u.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(null!==(i=this.config.focusedPointRingColor)&&void 0!==i?i:vi.focusedPointRingColor),u.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(null!==(r=this.config.pointGreyoutColor)&&void 0!==r?r:pi),u.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(null!==(o=this.config.hoveredLinkColor)&&void 0!==o?o:vi.hoveredLinkColor),u.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),u.spaceSize===this.config.spaceSize&&u.simulationRepulsionQuadtreeLevels===this.config.simulationRepulsionQuadtreeLevels||(this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),u.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Kr(this.canvas):(null===(a=this.fpsMonitor)||void 0===a||a.destroy(),this.fpsMonitor=void 0)),u.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(null!==(s=this.reglInstance.limits.pointSizeDims[1])&&void 0!==s?s:64)/this.config.pixelRatio),u.enableZoom===this.config.enableZoom&&u.enableDrag===this.config.enableDrag||this.updateZoomDragBehaviors(),u.onLinkClick===this.config.onLinkClick&&u.onLinkMouseOver===this.config.onLinkMouseOver&&u.onLinkMouseOut===this.config.onLinkMouseOut||this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){!this._isDestroyed&&this.points&&(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.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){var e;return this._isDestroyed?new Float32Array:null!==(e=this.graph.pointColors)&&void 0!==e?e:new Float32Array}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){!this._isDestroyed&&this.points&&(this.graph.inputImageData=e,this.points.createAtlas())}setPointImageIndices(e){this._isDestroyed||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){var e;return this._isDestroyed?new Float32Array:null!==(e=this.graph.pointSizes)&&void 0!==e?e:new Float32Array}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){var e;return this._isDestroyed?new Float32Array:null!==(e=this.graph.linkColors)&&void 0!==e?e:new Float32Array}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){var e;return this._isDestroyed?new Float32Array:null!==(e=this.graph.linkWidths)&&void 0!==e?e:new Float32Array}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){!this._isDestroyed&&this.points&&(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,this.points.updatePinnedStatus())}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:n,fitViewPadding:i,fitViewDuration:r,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:s}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber)return this.stopFrames(),de(this.canvas).style("cursor",null),void this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});this._isFirstRenderAfterInit&&t&&void 0===s&&(this._fitViewOnInitTimeoutID=window.setTimeout((()=>{a?this.fitViewByPointIndices(a,r,i):o?this.setZoomTransformByPointPositions(o,r,void 0,i):this.fitView(r,i)}),n)),this._isFirstRenderAfterInit=!1,this.update(e)}zoomToPointByIndex(e,t=700,n=3,i=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:r}}=this,o=zr(this.reglInstance,this.points.currentPositionFbo);if(void 0===e)return;const a=o[4*e+0],s=o[4*e+1];if(void 0===a||void 0===s)return;const u=this.zoomInstance.getDistanceToPoint([a,s]),l=i?n:Math.max(this.getZoomLevel(),n);if(u<Math.min(r[0],r[1]))this.setZoomTransformByPointPositions([a,s],t,l);else{const e=this.zoomInstance.getTransform([[a,s]],l),n=this.zoomInstance.getMiddlePointTransform([a,s]);this.canvasD3Selection.transition().ease(ii).duration(t/2).call(this.zoomInstance.behavior.transform,n).transition().ease(ri).duration(t/2).call(this.zoomInstance.behavior.transform,e)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){!this._isDestroyed&&this.canvasD3Selection&&(0===t?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.reglInstance||!this.points)return[];if(void 0===this.graph.pointsNumber)return[];const e=[],t=zr(this.reglInstance,this.points.currentPositionFbo);e.length=2*this.graph.pointsNumber;for(let n=0;n<this.graph.pointsNumber;n+=1){const i=t[4*n+0],r=t[4*n+1];void 0!==i&&void 0!==r&&(e[2*n]=i,e[2*n+1]=r)}return e}getClusterPositions(){if(this._isDestroyed||!this.reglInstance||!this.clusters)return[];if(void 0===this.graph.pointClusters||void 0===this.clusters.clusterCount)return[];this.clusters.calculateCentermass();const e=[],t=zr(this.reglInstance,this.clusters.centermassFbo);e.length=2*this.clusters.clusterCount;for(let n=0;n<e.length/2;n+=1){const i=t[4*n+0],r=t[4*n+1],o=t[4*n+2];void 0!==i&&void 0!==r&&void 0!==o&&(e[2*n]=i/o,e[2*n+1]=r/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,t)}fitViewByPointIndices(e,t=250,n=.1){if(this._isDestroyed)return;const i=this.getPointPositions(),r=new Array(2*e.length);for(const[t,n]of e.entries())r[2*t]=i[2*n],r[2*t+1]=i[2*n+1];this.setZoomTransformByPointPositions(r,t,void 0,n)}fitViewByPointPositions(e,t=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,t,void 0,n)}getPointsInRect(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;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();return zr(this.reglInstance,this.points.selectedFbo).map(((e,t)=>t%4==0&&0!==e?t/4:-1)).filter((e=>-1!==e))}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],n=e.map((([e,n])=>[e,t-n]));this.points.updatePolygonPath(n),this.points.findPointsOnPolygonSelection();return zr(this.reglInstance,this.points.selectedFbo).map(((e,t)=>t%4==0&&0!==e?t/4:-1)).filter((e=>-1!==e))}selectPointsInRect(e){if(!this._isDestroyed&&this.reglInstance&&this.points){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const n=zr(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=n.map(((e,t)=>t%4==0&&0!==e?t/4:-1)).filter((e=>-1!==e))}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!this._isDestroyed&&this.reglInstance&&this.points){if(e){if(e.length<3)return void console.warn("Polygon path requires at least 3 points to form a polygon.");const t=this.store.screenSize[1],n=e.map((([e,n])=>[e,t-n]));this.points.updatePolygonPath(n),this.points.findPointsOnPolygonSelection();const i=zr(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=i.map(((e,t)=>t%4==0&&0!==e?t/4:-1)).filter((e=>-1!==e))}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){var n;if(!this._isDestroyed)if(t){const t=null!==(n=this.graph.getAdjacentIndices(e))&&void 0!==n?n:[];this.selectPointsByIndices([e,...t])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){!this._isDestroyed&&this.points&&(e?0===e.length?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter((e=>void 0!==e))):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){!this._isDestroyed&&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 null===(t=this.graph.pointSizes)||void 0===t?void 0:t[e]}trackPointPositionsByIndices(e){!this._isDestroyed&&this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!this._isDestroyed&&this.points)return this.points.scaleX}getScaleY(){if(!this._isDestroyed&&this.points)return this.points.scaleY}start(e=1){var t,n;this._isDestroyed||this.graph.pointsNumber&&(e>0&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,null===(n=(t=this.config).onSimulationStart)||void 0===n||n.call(t)),this.store.alpha=e,this.stopFrames(),this.frame())}pause(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!1,null===(t=(e=this.config).onSimulationPause)||void 0===t||t.call(e))}unpause(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!0,null===(t=(e=this.config).onSimulationUnpause)||void 0===t||t.call(e))}restart(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!0,null===(t=(e=this.config).onSimulationRestart)||void 0===t||t.call(e))}step(){this._isDestroyed||(this.store.isSimulationRunning=!1,this.stopFrames(),this.frame())}destroy(){var e,t,n,i;!this._isDestroyed&&this.reglInstance&&(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),de(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(null===(e=this.zoomInstance)||void 0===e?void 0:e.behavior)&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(null===(t=this.dragInstance)||void 0===t?void 0:t.behavior)&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),null===(n=this.fpsMonitor)||void 0===n||n.destroy(),this.reglInstance.destroy(),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0}),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),null===(i=document.getElementById("gl-bench-style"))||void 0===i||i.remove(),this.canvasD3Selection=void 0,this.reglInstance=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,t,n,i,r;!this._isDestroyed&&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&&(null===(e=this.forceManyBody)||void 0===e||e.create()),this.isForceLinkUpdateNeeded&&(null===(t=this.forceLinkIncoming)||void 0===t||t.create(Br.INCOMING),null===(n=this.forceLinkOutgoing)||void 0===n||n.create(Br.OUTGOING)),this.isForceCenterUpdateNeeded&&(null===(i=this.forceCenter)||void 0===i||i.create()),this.isPointClusterUpdateNeeded&&(null===(r=this.clusters)||void 0===r||r.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let n=0;n<e.length/2;n++)t[n]=[e[2*n],e[2*n+1]];return t}update(e=this.store.alpha){var t,n;const{graph:i}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(null!==(t=i.pointsNumber)&&void 0!==t?t:0)),this.store.linksTextureSize=Math.ceil(Math.sqrt(2*(null!==(n=i.linksNumber)&&void 0!==n?n:0))),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.start(e)}initPrograms(){var e,t,n,i,r,o;!this._isDestroyed&&this.points&&this.lines&&this.clusters&&(this.points.initPrograms(),this.lines.initPrograms(),null===(e=this.forceGravity)||void 0===e||e.initPrograms(),null===(t=this.forceLinkIncoming)||void 0===t||t.initPrograms(),null===(n=this.forceLinkOutgoing)||void 0===n||n.initPrograms(),null===(i=this.forceMouse)||void 0===i||i.initPrograms(),null===(r=this.forceManyBody)||void 0===r||r.initPrograms(),null===(o=this.forceCenter)||void 0===o||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{config:{simulationGravity:e,simulationCenter:t,renderLinks:n,enableSimulation:i},store:{alpha:r,isSimulationRunning:o}}=this;r<Nu&&o&&this.end(),this.store.pointsTextureSize&&(this.requestAnimationFrameId=window.requestAnimationFrame((r=>{var a,s,u,l,c,f,h,d,p,m,v,g,y,b,x,S,w,k,C,T,P,_,A,z,I,D,M,F;null===(a=this.fpsMonitor)||void 0===a||a.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),i&&(this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(null===(s=this.forceMouse)||void 0===s||s.run(),null===(u=this.points)||void 0===u||u.updatePosition()),!o||this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom||(e&&(null===(l=this.forceGravity)||void 0===l||l.run(),null===(c=this.points)||void 0===c||c.updatePosition()),t&&(null===(f=this.forceCenter)||void 0===f||f.run(),null===(h=this.points)||void 0===h||h.updatePosition()),null===(d=this.forceManyBody)||void 0===d||d.run(),null===(p=this.points)||void 0===p||p.updatePosition(),this.store.linksTextureSize&&(null===(m=this.forceLinkIncoming)||void 0===m||m.run(),null===(v=this.points)||void 0===v||v.updatePosition(),null===(g=this.forceLinkOutgoing)||void 0===g||g.run(),null===(y=this.points)||void 0===y||y.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&(null===(b=this.clusters)||void 0===b||b.run(),null===(x=this.points)||void 0===x||x.updatePosition()),this.store.alpha+=this.store.addAlpha(null!==(S=this.config.simulationDecay)&&void 0!==S?S:vi.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Nu/this.store.alpha)),null===(k=(w=this.config).onSimulationTick)||void 0===k||k.call(w,this.store.alpha,null===(C=this.store.hoveredPoint)||void 0===C?void 0:C.index,null===(T=this.store.hoveredPoint)||void 0===T?void 0:T.position)),null===(P=this.points)||void 0===P||P.trackPoints()),null===(_=this.reglInstance)||void 0===_||_.clear({color:this.store.backgroundColor,depth:1,stencil:0}),n&&this.store.linksTextureSize&&(null===(A=this.lines)||void 0===A||A.draw()),null===(z=this.points)||void 0===z||z.draw(),this.dragInstance.isActive&&(null===(I=this.points)||void 0===I||I.drag(),null===(D=this.points)||void 0===D||D.drag(),null===(M=this.points)||void 0===M||M.trackPoints()),null===(F=this.fpsMonitor)||void 0===F||F.end(r),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,null===(t=(e=this.config).onSimulationEnd)||void 0===t||t.call(e)}onClick(e){var t,n,i,r,o,a,s,u,l,c;null===(n=(t=this.config).onClick)||void 0===n||n.call(t,null===(i=this.store.hoveredPoint)||void 0===i?void 0:i.index,null===(r=this.store.hoveredPoint)||void 0===r?void 0:r.position,e),this.store.hoveredPoint?null===(a=(o=this.config).onPointClick)||void 0===a||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):void 0!==this.store.hoveredLinkIndex?null===(u=(s=this.config).onLinkClick)||void 0===u||u.call(s,this.store.hoveredLinkIndex,e):null===(c=(l=this.config).onBackgroundClick)||void 0===c||c.call(l,e)}updateMousePosition(e){var t,n;if(!e)return;const i=null!==(t=e.offsetX)&&void 0!==t?t:e.x,r=null!==(n=e.offsetY)&&void 0!==n?n:e.y;void 0!==i&&void 0!==r&&(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([i,r]),this.store.screenMousePosition=[i,this.store.screenSize[1]-r])}onMouseMove(e){var t,n,i,r;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=3===e.which,null===(n=(t=this.config).onMouseMove)||void 0===n||n.call(t,null===(i=this.store.hoveredPoint)||void 0===i?void 0:i.index,null===(r=this.store.hoveredPoint)||void 0===r?void 0:r.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var t,n,i,r;if(this._isDestroyed)return;const o=this.canvas.width,a=this.canvas.height,s=this.canvas.clientWidth,u=this.canvas.clientHeight;if(e||o!==s*this.config.pixelRatio||a!==u*this.config.pixelRatio){const[e,o]=this.store.screenSize,{k:a}=this.zoomInstance.eventTransform,l=this.zoomInstance.convertScreenToSpacePosition([e/2,o/2]);this.store.updateScreenSize(s,u),this.canvas.width=s*this.config.pixelRatio,this.canvas.height=u*this.config.pixelRatio,null===(t=this.reglInstance)||void 0===t||t.poll(),null===(n=this.canvasD3Selection)||void 0===n||n.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([l],a)),null===(i=this.points)||void 0===i||i.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&(null===(r=this.lines)||void 0===r||r.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,t=250,n,i){var r;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),n,i);null===(r=this.canvasD3Selection)||void 0===r||r.transition().ease(oi).duration(t).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,t,n,i;this.config.enableDrag?null===(e=this.canvasD3Selection)||void 0===e||e.call(this.dragInstance.behavior):null===(t=this.canvasD3Selection)||void 0===t||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?null===(n=this.canvasD3Selection)||void 0===n||n.call(this.zoomInstance.behavior):null===(i=this.canvasD3Selection)||void 0===i||i.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(!this._isDestroyed&&this._isMouseOnCanvas&&this.reglInstance)if(this._findHoveredItemExecutionCount<4)this._findHoveredItemExecutionCount+=1;else{if(this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(void 0!==this.store.hoveredLinkIndex){const e=void 0!==this.store.hoveredLinkIndex;this.store.hoveredLinkIndex=void 0,e&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var e,t,n,i,r;if(this._isDestroyed||!this.reglInstance||!this.points)return;this.points.findHoveredPoint();let o=!1,a=!1;const s=zr(this.reglInstance,this.points.hoveredFbo);if(s[1]){const t=s[0];(null===(e=this.store.hoveredPoint)||void 0===e?void 0:e.index)!==t&&(o=!0);const n=s[2],i=s[3];this.store.hoveredPoint={index:t,position:[n,i]}}else this.store.hoveredPoint&&(a=!0),this.store.hoveredPoint=void 0;o&&this.store.hoveredPoint&&(null===(n=(t=this.config).onPointMouseOver)||void 0===n||n.call(t,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),a&&(null===(r=(i=this.config).onPointMouseOut)||void 0===r||r.call(i,this.currentEvent))}findHoveredLine(){var e,t,n,i,r,o;if(this._isDestroyed||!this.reglInstance||!this.lines)return;if(this.store.hoveredPoint)return void(void 0!==this.store.hoveredLinkIndex&&(this.store.hoveredLinkIndex=void 0,null===(t=(e=this.config).onLinkMouseOut)||void 0===t||t.call(e,this.currentEvent)));this.lines.findHoveredLine();let a=!1,s=!1;const u=zr(this.reglInstance,this.lines.hoveredLineIndexFbo)[0];u>=0?(this.store.hoveredLinkIndex!==u&&(a=!0),this.store.hoveredLinkIndex=u):(void 0!==this.store.hoveredLinkIndex&&(s=!0),this.store.hoveredLinkIndex=void 0),a&&void 0!==this.store.hoveredLinkIndex&&(null===(i=(n=this.config).onLinkMouseOver)||void 0===i||i.call(n,this.store.hoveredLinkIndex)),s&&(null===(o=(r=this.config).onLinkMouseOut)||void 0===o||o.call(r,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?de(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?de(this.canvas).style("cursor",e):de(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&void 0!==this.store.hoveredLinkIndex?de(this.canvas).style("cursor",t):de(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText="\n user-select: none;\n position: absolute;\n bottom: 0;\n right: 0;\n color: var(--cosmosgl-attribution-color);\n margin: 0 0.6rem 0.6rem 0;\n font-size: 0.7rem;\n font-family: inherit;\n ",this.attributionDivElement.innerHTML=Mr(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"]}),null===(e=this.store.div)||void 0===e||e.appendChild(this.attributionDivElement))}},e.clamp=Ir,e.getRgbaColor=_r,e.isAClassInstance=Tr,e.isArray=kr,e.isFunction=wr,e.isNumber=Dr,e.isObject=Cr,e.isPlainObject=Pr,e.readPixels=zr,e.rgbToBrightness=Ar,e.sanitizeHtml=Mr,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ (function(Rt,ti){typeof exports=="object"&&typeof module<"u"?ti(exports):typeof define=="function"&&define.amd?define(["exports"],ti):(Rt=typeof globalThis<"u"?globalThis:Rt||self,ti(Rt.Cosmos={}))})(this,function(Rt){"use strict";var ti="http://www.w3.org/1999/xhtml";const lf={svg:"http://www.w3.org/2000/svg",xhtml:ti,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Br(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),lf.hasOwnProperty(e)?{space:lf[e],local:t}:t}function Yc(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===ti&&e.documentElement.namespaceURI===ti?e.createElement(t):e.createElementNS(n,t)}}function Zc(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function uf(t){var e=Br(t);return(e.local?Zc:Yc)(e)}function Qc(){}function ya(t){return t==null?Qc:function(){return this.querySelector(t)}}function Kc(t){typeof t!="function"&&(t=ya(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var o=e[r],s=o.length,f=i[r]=new Array(s),l,u,d=0;d<s;++d)(l=o[d])&&(u=t.call(l,l.__data__,d,o))&&("__data__"in l&&(u.__data__=l.__data__),f[d]=u);return new tn(i,this._parents)}function Jc(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function eh(){return[]}function cf(t){return t==null?eh:function(){return this.querySelectorAll(t)}}function th(t){return function(){return Jc(t.apply(this,arguments))}}function nh(t){typeof t=="function"?t=th(t):t=cf(t);for(var e=this._groups,n=e.length,i=[],r=[],o=0;o<n;++o)for(var s=e[o],f=s.length,l,u=0;u<f;++u)(l=s[u])&&(i.push(t.call(l,l.__data__,u,s)),r.push(l));return new tn(i,r)}function hf(t){return function(){return this.matches(t)}}function df(t){return function(e){return e.matches(t)}}var ih=Array.prototype.find;function rh(t){return function(){return ih.call(this.children,t)}}function oh(){return this.firstElementChild}function ah(t){return this.select(t==null?oh:rh(typeof t=="function"?t:df(t)))}var sh=Array.prototype.filter;function fh(){return Array.from(this.children)}function lh(t){return function(){return sh.call(this.children,t)}}function uh(t){return this.selectAll(t==null?fh:lh(typeof t=="function"?t:df(t)))}function ch(t){typeof t!="function"&&(t=hf(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var o=e[r],s=o.length,f=i[r]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&f.push(l);return new tn(i,this._parents)}function mf(t){return new Array(t.length)}function hh(){return new tn(this._enter||this._groups.map(mf),this._parents)}function Ur(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Ur.prototype={constructor:Ur,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function dh(t){return function(){return t}}function mh(t,e,n,i,r,o){for(var s=0,f,l=e.length,u=o.length;s<u;++s)(f=e[s])?(f.__data__=o[s],i[s]=f):n[s]=new Ur(t,o[s]);for(;s<l;++s)(f=e[s])&&(r[s]=f)}function ph(t,e,n,i,r,o,s){var f,l,u=new Map,d=e.length,y=o.length,S=new Array(d),D;for(f=0;f<d;++f)(l=e[f])&&(S[f]=D=s.call(l,l.__data__,f,e)+"",u.has(D)?r[f]=l:u.set(D,l));for(f=0;f<y;++f)D=s.call(t,o[f],f,o)+"",(l=u.get(D))?(i[f]=l,l.__data__=o[f],u.delete(D)):n[f]=new Ur(t,o[f]);for(f=0;f<d;++f)(l=e[f])&&u.get(S[f])===l&&(r[f]=l)}function vh(t){return t.__data__}function gh(t,e){if(!arguments.length)return Array.from(this,vh);var n=e?ph:mh,i=this._parents,r=this._groups;typeof t!="function"&&(t=dh(t));for(var o=r.length,s=new Array(o),f=new Array(o),l=new Array(o),u=0;u<o;++u){var d=i[u],y=r[u],S=y.length,D=yh(t.call(d,d&&d.__data__,u,i)),q=D.length,Te=f[u]=new Array(q),we=s[u]=new Array(q),fe=l[u]=new Array(S);n(d,y,Te,we,fe,D,e);for(var Ne=0,Ve=0,V,ae;Ne<q;++Ne)if(V=Te[Ne]){for(Ne>=Ve&&(Ve=Ne+1);!(ae=we[Ve])&&++Ve<q;);V._next=ae||null}}return s=new tn(s,i),s._enter=f,s._exit=l,s}function yh(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function xh(){return new tn(this._exit||this._groups.map(mf),this._parents)}function bh(t,e,n){var i=this.enter(),r=this,o=this.exit();return typeof t=="function"?(i=t(i),i&&(i=i.selection())):i=i.append(t+""),e!=null&&(r=e(r),r&&(r=r.selection())),n==null?o.remove():n(o),i&&r?i.merge(r).order():r}function _h(t){for(var e=t.selection?t.selection():t,n=this._groups,i=e._groups,r=n.length,o=i.length,s=Math.min(r,o),f=new Array(r),l=0;l<s;++l)for(var u=n[l],d=i[l],y=u.length,S=f[l]=new Array(y),D,q=0;q<y;++q)(D=u[q]||d[q])&&(S[q]=D);for(;l<r;++l)f[l]=n[l];return new tn(f,this._parents)}function Sh(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var i=t[e],r=i.length-1,o=i[r],s;--r>=0;)(s=i[r])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Th(t){t||(t=wh);function e(y,S){return y&&S?t(y.__data__,S.__data__):!y-!S}for(var n=this._groups,i=n.length,r=new Array(i),o=0;o<i;++o){for(var s=n[o],f=s.length,l=r[o]=new Array(f),u,d=0;d<f;++d)(u=s[d])&&(l[d]=u);l.sort(e)}return new tn(r,this._parents).order()}function wh(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Ah(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Eh(){return Array.from(this)}function Ch(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,o=i.length;r<o;++r){var s=i[r];if(s)return s}return null}function Ph(){let t=0;for(const e of this)++t;return t}function kh(){return!this.node()}function Ih(t){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var r=e[n],o=0,s=r.length,f;o<s;++o)(f=r[o])&&t.call(f,f.__data__,o,r);return this}function Lh(t){return function(){this.removeAttribute(t)}}function Dh(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Fh(t,e){return function(){this.setAttribute(t,e)}}function zh(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Rh(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Mh(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Oh(t,e){var n=Br(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((e==null?n.local?Dh:Lh:typeof e=="function"?n.local?Mh:Rh:n.local?zh:Fh)(n,e))}function pf(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Nh(t){return function(){this.style.removeProperty(t)}}function Gh(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Bh(t,e,n){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function Uh(t,e,n){return arguments.length>1?this.each((e==null?Nh:typeof e=="function"?Bh:Gh)(t,e,n??"")):Pi(this.node(),t)}function Pi(t,e){return t.style.getPropertyValue(e)||pf(t).getComputedStyle(t,null).getPropertyValue(e)}function Vh(t){return function(){delete this[t]}}function $h(t,e){return function(){this[t]=e}}function Hh(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Wh(t,e){return arguments.length>1?this.each((e==null?Vh:typeof e=="function"?Hh:$h)(t,e)):this.node()[t]}function vf(t){return t.trim().split(/^|\s+/)}function xa(t){return t.classList||new gf(t)}function gf(t){this._node=t,this._names=vf(t.getAttribute("class")||"")}gf.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function yf(t,e){for(var n=xa(t),i=-1,r=e.length;++i<r;)n.add(e[i])}function xf(t,e){for(var n=xa(t),i=-1,r=e.length;++i<r;)n.remove(e[i])}function Xh(t){return function(){yf(this,t)}}function jh(t){return function(){xf(this,t)}}function qh(t,e){return function(){(e.apply(this,arguments)?yf:xf)(this,t)}}function Yh(t,e){var n=vf(t+"");if(arguments.length<2){for(var i=xa(this.node()),r=-1,o=n.length;++r<o;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof e=="function"?qh:e?Xh:jh)(n,e))}function Zh(){this.textContent=""}function Qh(t){return function(){this.textContent=t}}function Kh(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Jh(t){return arguments.length?this.each(t==null?Zh:(typeof t=="function"?Kh:Qh)(t)):this.node().textContent}function ed(){this.innerHTML=""}function td(t){return function(){this.innerHTML=t}}function nd(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function id(t){return arguments.length?this.each(t==null?ed:(typeof t=="function"?nd:td)(t)):this.node().innerHTML}function rd(){this.nextSibling&&this.parentNode.appendChild(this)}function od(){return this.each(rd)}function ad(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sd(){return this.each(ad)}function fd(t){var e=typeof t=="function"?t:uf(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function ld(){return null}function ud(t,e){var n=typeof t=="function"?t:uf(t),i=e==null?ld:typeof e=="function"?e:ya(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function cd(){var t=this.parentNode;t&&t.removeChild(this)}function hd(){return this.each(cd)}function dd(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function md(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function pd(t){return this.select(t?md:dd)}function vd(t){return arguments.length?this.property("__data__",t):this.node().__data__}function gd(t){return function(e){t.call(this,e,this.__data__)}}function yd(t){return t.trim().split(/^|\s+/).map(function(e){var n="",i=e.indexOf(".");return i>=0&&(n=e.slice(i+1),e=e.slice(0,i)),{type:e,name:n}})}function xd(t){return function(){var e=this.__on;if(e){for(var n=0,i=-1,r=e.length,o;n<r;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++i]=o;++i?e.length=i:delete this.__on}}}function bd(t,e,n){return function(){var i=this.__on,r,o=gd(e);if(i){for(var s=0,f=i.length;s<f;++s)if((r=i[s]).type===t.type&&r.name===t.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=e;return}}this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function _d(t,e,n){var i=yd(t+""),r,o=i.length,s;if(arguments.length<2){var f=this.node().__on;if(f){for(var l=0,u=f.length,d;l<u;++l)for(r=0,d=f[l];r<o;++r)if((s=i[r]).type===d.type&&s.name===d.name)return d.value}return}for(f=e?bd:xd,r=0;r<o;++r)this.each(f(i[r],e,n));return this}function bf(t,e,n){var i=pf(t),r=i.CustomEvent;typeof r=="function"?r=new r(e,n):(r=i.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function Sd(t,e){return function(){return bf(this,t,e)}}function Td(t,e){return function(){return bf(this,t,e.apply(this,arguments))}}function wd(t,e){return this.each((typeof e=="function"?Td:Sd)(t,e))}function*Ad(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,o=i.length,s;r<o;++r)(s=i[r])&&(yield s)}var _f=[null];function tn(t,e){this._groups=t,this._parents=e}function nr(){return new tn([[document.documentElement]],_f)}function Ed(){return this}tn.prototype=nr.prototype={constructor:tn,select:Kc,selectAll:nh,selectChild:ah,selectChildren:uh,filter:ch,data:gh,enter:hh,exit:xh,join:bh,merge:_h,selection:Ed,order:Sh,sort:Th,call:Ah,nodes:Eh,node:Ch,size:Ph,empty:kh,each:Ih,attr:Oh,style:Uh,property:Wh,classed:Yh,text:Jh,html:id,raise:od,lower:sd,append:fd,insert:ud,remove:hd,clone:pd,datum:vd,on:_d,dispatch:wd,[Symbol.iterator]:Ad};function Ft(t){return typeof t=="string"?new tn([[document.querySelector(t)]],[document.documentElement]):new tn([[t]],_f)}function Cd(t){let e;for(;e=t.sourceEvent;)t=e;return t}function kn(t,e){if(t=Cd(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}var Pd={value:()=>{}};function Vr(){for(var t=0,e=arguments.length,n={},i;t<e;++t){if(!(i=arguments[t]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new $r(n)}function $r(t){this._=t}function kd(t,e){return t.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}$r.prototype=Vr.prototype={constructor:$r,on:function(t,e){var n=this._,i=kd(t+"",n),r,o=-1,s=i.length;if(arguments.length<2){for(;++o<s;)if((r=(t=i[o]).type)&&(r=Id(n[r],t.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<s;)if(r=(t=i[o]).type)n[r]=Sf(n[r],t.name,e);else if(e==null)for(r in n)n[r]=Sf(n[r],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new $r(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,o;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],i=0,r=o.length;i<r;++i)o[i].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,o=i.length;r<o;++r)i[r].value.apply(e,n)}};function Id(t,e){for(var n=0,i=t.length,r;n<i;++n)if((r=t[n]).name===e)return r.value}function Sf(t,e,n){for(var i=0,r=t.length;i<r;++i)if(t[i].name===e){t[i]=Pd,t=t.slice(0,i).concat(t.slice(i+1));break}return n!=null&&t.push({name:e,value:n}),t}var ki=0,ir=0,rr=0,Tf=1e3,Hr,or,Wr=0,ni=0,Xr=0,ar=typeof performance=="object"&&performance.now?performance:Date,wf=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ba(){return ni||(wf(Ld),ni=ar.now()+Xr)}function Ld(){ni=0}function jr(){this._call=this._time=this._next=null}jr.prototype=Af.prototype={constructor:jr,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?ba():+n)+(e==null?0:+e),!this._next&&or!==this&&(or?or._next=this:Hr=this,or=this),this._call=t,this._time=n,_a()},stop:function(){this._call&&(this._call=null,this._time=1/0,_a())}};function Af(t,e,n){var i=new jr;return i.restart(t,e,n),i}function Dd(){ba(),++ki;for(var t=Hr,e;t;)(e=ni-t._time)>=0&&t._call.call(null,e),t=t._next;--ki}function Ef(){ni=(Wr=ar.now())+Xr,ki=ir=0;try{Dd()}finally{ki=0,zd(),ni=0}}function Fd(){var t=ar.now(),e=t-Wr;e>Tf&&(Xr-=e,Wr=t)}function zd(){for(var t,e=Hr,n,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Hr=n);or=t,_a(i)}function _a(t){if(!ki){ir&&(ir=clearTimeout(ir));var e=t-ni;e>24?(t<1/0&&(ir=setTimeout(Ef,t-ar.now()-Xr)),rr&&(rr=clearInterval(rr))):(rr||(Wr=ar.now(),rr=setInterval(Fd,Tf)),ki=1,wf(Ef))}}function Cf(t,e,n){var i=new jr;return e=e==null?0:+e,i.restart(r=>{i.stop(),t(r+e)},e,n),i}var Rd=Vr("start","end","cancel","interrupt"),Md=[],Pf=0,kf=1,Sa=2,qr=3,If=4,Ta=5,Yr=6;function Zr(t,e,n,i,r,o){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;Od(t,n,{name:e,index:i,group:r,on:Rd,tween:Md,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Pf})}function wa(t,e){var n=cn(t,e);if(n.state>Pf)throw new Error("too late; already scheduled");return n}function bn(t,e){var n=cn(t,e);if(n.state>qr)throw new Error("too late; already running");return n}function cn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Od(t,e,n){var i=t.__transition,r;i[e]=n,n.timer=Af(o,0,n.time);function o(u){n.state=kf,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var d,y,S,D;if(n.state!==kf)return l();for(d in i)if(D=i[d],D.name===n.name){if(D.state===qr)return Cf(s);D.state===If?(D.state=Yr,D.timer.stop(),D.on.call("interrupt",t,t.__data__,D.index,D.group),delete i[d]):+d<e&&(D.state=Yr,D.timer.stop(),D.on.call("cancel",t,t.__data__,D.index,D.group),delete i[d])}if(Cf(function(){n.state===qr&&(n.state=If,n.timer.restart(f,n.delay,n.time),f(u))}),n.state=Sa,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Sa){for(n.state=qr,r=new Array(S=n.tween.length),d=0,y=-1;d<S;++d)(D=n.tween[d].value.call(t,t.__data__,n.index,n.group))&&(r[++y]=D);r.length=y+1}}function f(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=Ta,1),y=-1,S=r.length;++y<S;)r[y].call(t,d);n.state===Ta&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Yr,n.timer.stop(),delete i[e];for(var u in i)return;delete t.__transition}}function Qr(t,e){var n=t.__transition,i,r,o=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((i=n[s]).name!==e){o=!1;continue}r=i.state>Sa&&i.state<Ta,i.state=Yr,i.timer.stop(),i.on.call(r?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete n[s]}o&&delete t.__transition}}function Nd(t){return this.each(function(){Qr(this,t)})}function Aa(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Lf(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function sr(){}var fr=.7,Kr=1/fr,Ii="\\s*([+-]?\\d+)\\s*",lr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_n="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gd=/^#([0-9a-f]{3,8})$/,Bd=new RegExp(`^rgb\\(${Ii},${Ii},${Ii}\\)$`),Ud=new RegExp(`^rgb\\(${_n},${_n},${_n}\\)$`),Vd=new RegExp(`^rgba\\(${Ii},${Ii},${Ii},${lr}\\)$`),$d=new RegExp(`^rgba\\(${_n},${_n},${_n},${lr}\\)$`),Hd=new RegExp(`^hsl\\(${lr},${_n},${_n}\\)$`),Wd=new RegExp(`^hsla\\(${lr},${_n},${_n},${lr}\\)$`),Df={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};Aa(sr,Vn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ff,formatHex:Ff,formatHex8:Xd,formatHsl:jd,formatRgb:zf,toString:zf});function Ff(){return this.rgb().formatHex()}function Xd(){return this.rgb().formatHex8()}function jd(){return Gf(this).formatHsl()}function zf(){return this.rgb().formatRgb()}function Vn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Gd.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Rf(e):n===3?new Zt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Jr(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Jr(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=Bd.exec(t))?new Zt(e[1],e[2],e[3],1):(e=Ud.exec(t))?new Zt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Vd.exec(t))?Jr(e[1],e[2],e[3],e[4]):(e=$d.exec(t))?Jr(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Hd.exec(t))?Nf(e[1],e[2]/100,e[3]/100,1):(e=Wd.exec(t))?Nf(e[1],e[2]/100,e[3]/100,e[4]):Df.hasOwnProperty(t)?Rf(Df[t]):t==="transparent"?new Zt(NaN,NaN,NaN,0):null}function Rf(t){return new Zt(t>>16&255,t>>8&255,t&255,1)}function Jr(t,e,n,i){return i<=0&&(t=e=n=NaN),new Zt(t,e,n,i)}function qd(t){return t instanceof sr||(t=Vn(t)),t?(t=t.rgb(),new Zt(t.r,t.g,t.b,t.opacity)):new Zt}function Ea(t,e,n,i){return arguments.length===1?qd(t):new Zt(t,e,n,i??1)}function Zt(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}Aa(Zt,Ea,Lf(sr,{brighter(t){return t=t==null?Kr:Math.pow(Kr,t),new Zt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?fr:Math.pow(fr,t),new Zt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Zt(ii(this.r),ii(this.g),ii(this.b),eo(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:Mf,formatHex:Mf,formatHex8:Yd,formatRgb:Of,toString:Of}));function Mf(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}`}function Yd(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}${ri((isNaN(this.opacity)?1:this.opacity)*255)}`}function Of(){const t=eo(this.opacity);return`${t===1?"rgb(":"rgba("}${ii(this.r)}, ${ii(this.g)}, ${ii(this.b)}${t===1?")":`, ${t})`}`}function eo(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ii(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ri(t){return t=ii(t),(t<16?"0":"")+t.toString(16)}function Nf(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new hn(t,e,n,i)}function Gf(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof sr||(t=Vn(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var e=t.r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),o=Math.max(e,n,i),s=NaN,f=o-r,l=(o+r)/2;return f?(e===o?s=(n-i)/f+(n<i)*6:n===o?s=(i-e)/f+2:s=(e-n)/f+4,f/=l<.5?o+r:2-o-r,s*=60):f=l>0&&l<1?0:s,new hn(s,f,l,t.opacity)}function Zd(t,e,n,i){return arguments.length===1?Gf(t):new hn(t,e,n,i??1)}function hn(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}Aa(hn,Zd,Lf(sr,{brighter(t){return t=t==null?Kr:Math.pow(Kr,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?fr:Math.pow(fr,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Zt(Ca(t>=240?t-240:t+120,r,i),Ca(t,r,i),Ca(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new hn(Bf(this.h),to(this.s),to(this.l),eo(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 t=eo(this.opacity);return`${t===1?"hsl(":"hsla("}${Bf(this.h)}, ${to(this.s)*100}%, ${to(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Bf(t){return t=(t||0)%360,t<0?t+360:t}function to(t){return Math.max(0,Math.min(1,t||0))}function Ca(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Pa=t=>()=>t;function Qd(t,e){return function(n){return t+n*e}}function Kd(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}function Jd(t){return(t=+t)==1?Uf:function(e,n){return n-e?Kd(e,n,t):Pa(isNaN(e)?n:e)}}function Uf(t,e){var n=e-t;return n?Qd(t,n):Pa(isNaN(t)?e:t)}const no=function t(e){var n=Jd(e);function i(r,o){var s=n((r=Ea(r)).r,(o=Ea(o)).r),f=n(r.g,o.g),l=n(r.b,o.b),u=Uf(r.opacity,o.opacity);return function(d){return r.r=s(d),r.g=f(d),r.b=l(d),r.opacity=u(d),r+""}}return i.gamma=t,i}(1);function em(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,i=e.slice(),r;return function(o){for(r=0;r<n;++r)i[r]=t[r]*(1-o)+e[r]*o;return i}}function tm(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function nm(t,e){var n=e?e.length:0,i=t?Math.min(n,t.length):0,r=new Array(i),o=new Array(n),s;for(s=0;s<i;++s)r[s]=La(t[s],e[s]);for(;s<n;++s)o[s]=e[s];return function(f){for(s=0;s<i;++s)o[s]=r[s](f);return o}}function im(t,e){var n=new Date;return t=+t,e=+e,function(i){return n.setTime(t*(1-i)+e*i),n}}function dn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function rm(t,e){var n={},i={},r;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in t?n[r]=La(t[r],e[r]):i[r]=e[r];return function(o){for(r in n)i[r]=n[r](o);return i}}var ka=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ia=new RegExp(ka.source,"g");function om(t){return function(){return t}}function am(t){return function(e){return t(e)+""}}function Vf(t,e){var n=ka.lastIndex=Ia.lastIndex=0,i,r,o,s=-1,f=[],l=[];for(t=t+"",e=e+"";(i=ka.exec(t))&&(r=Ia.exec(e));)(o=r.index)>n&&(o=e.slice(n,o),f[s]?f[s]+=o:f[++s]=o),(i=i[0])===(r=r[0])?f[s]?f[s]+=r:f[++s]=r:(f[++s]=null,l.push({i:s,x:dn(i,r)})),n=Ia.lastIndex;return n<e.length&&(o=e.slice(n),f[s]?f[s]+=o:f[++s]=o),f.length<2?l[0]?am(l[0].x):om(e):(e=l.length,function(u){for(var d=0,y;d<e;++d)f[(y=l[d]).i]=y.x(u);return f.join("")})}function La(t,e){var n=typeof e,i;return e==null||n==="boolean"?Pa(e):(n==="number"?dn:n==="string"?(i=Vn(e))?(e=i,no):Vf:e instanceof Vn?no:e instanceof Date?im:tm(e)?em:Array.isArray(e)?nm:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?rm:dn)(t,e)}function sm(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var $f=180/Math.PI,Da={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Hf(t,e,n,i,r,o){var s,f,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*i)&&(n-=t*l,i-=e*l),(f=Math.sqrt(n*n+i*i))&&(n/=f,i/=f,l/=f),t*i<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:r,translateY:o,rotate:Math.atan2(e,t)*$f,skewX:Math.atan(l)*$f,scaleX:s,scaleY:f}}var io;function fm(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Da:Hf(e.a,e.b,e.c,e.d,e.e,e.f)}function lm(t){return t==null||(io||(io=document.createElementNS("http://www.w3.org/2000/svg","g")),io.setAttribute("transform",t),!(t=io.transform.baseVal.consolidate()))?Da:(t=t.matrix,Hf(t.a,t.b,t.c,t.d,t.e,t.f))}function Wf(t,e,n,i){function r(u){return u.length?u.pop()+" ":""}function o(u,d,y,S,D,q){if(u!==y||d!==S){var Te=D.push("translate(",null,e,null,n);q.push({i:Te-4,x:dn(u,y)},{i:Te-2,x:dn(d,S)})}else(y||S)&&D.push("translate("+y+e+S+n)}function s(u,d,y,S){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),S.push({i:y.push(r(y)+"rotate(",null,i)-2,x:dn(u,d)})):d&&y.push(r(y)+"rotate("+d+i)}function f(u,d,y,S){u!==d?S.push({i:y.push(r(y)+"skewX(",null,i)-2,x:dn(u,d)}):d&&y.push(r(y)+"skewX("+d+i)}function l(u,d,y,S,D,q){if(u!==y||d!==S){var Te=D.push(r(D)+"scale(",null,",",null,")");q.push({i:Te-4,x:dn(u,y)},{i:Te-2,x:dn(d,S)})}else(y!==1||S!==1)&&D.push(r(D)+"scale("+y+","+S+")")}return function(u,d){var y=[],S=[];return u=t(u),d=t(d),o(u.translateX,u.translateY,d.translateX,d.translateY,y,S),s(u.rotate,d.rotate,y,S),f(u.skewX,d.skewX,y,S),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,y,S),u=d=null,function(D){for(var q=-1,Te=S.length,we;++q<Te;)y[(we=S[q]).i]=we.x(D);return y.join("")}}}var um=Wf(fm,"px, ","px)","deg)"),cm=Wf(lm,", ",")",")"),hm=1e-12;function Xf(t){return((t=Math.exp(t))+1/t)/2}function dm(t){return((t=Math.exp(t))-1/t)/2}function mm(t){return((t=Math.exp(2*t))-1)/(t+1)}const pm=function t(e,n,i){function r(o,s){var f=o[0],l=o[1],u=o[2],d=s[0],y=s[1],S=s[2],D=d-f,q=y-l,Te=D*D+q*q,we,fe;if(Te<hm)fe=Math.log(S/u)/e,we=function(Be){return[f+Be*D,l+Be*q,u*Math.exp(e*Be*fe)]};else{var Ne=Math.sqrt(Te),Ve=(S*S-u*u+i*Te)/(2*u*n*Ne),V=(S*S-u*u-i*Te)/(2*S*n*Ne),ae=Math.log(Math.sqrt(Ve*Ve+1)-Ve),Ie=Math.log(Math.sqrt(V*V+1)-V);fe=(Ie-ae)/e,we=function(Be){var Xe=Be*fe,nt=Xf(ae),lt=u/(n*Ne)*(nt*mm(e*Xe+ae)-dm(ae));return[f+lt*D,l+lt*q,u*nt/Xf(e*Xe+ae)]}}return we.duration=fe*1e3*e/Math.SQRT2,we}return r.rho=function(o){var s=Math.max(.001,+o),f=s*s,l=f*f;return t(s,f,l)},r}(Math.SQRT2,2,4);function vm(t,e){var n,i;return function(){var r=bn(this,t),o=r.tween;if(o!==n){i=n=o;for(var s=0,f=i.length;s<f;++s)if(i[s].name===e){i=i.slice(),i.splice(s,1);break}}r.tween=i}}function gm(t,e,n){var i,r;if(typeof n!="function")throw new Error;return function(){var o=bn(this,t),s=o.tween;if(s!==i){r=(i=s).slice();for(var f={name:e,value:n},l=0,u=r.length;l<u;++l)if(r[l].name===e){r[l]=f;break}l===u&&r.push(f)}o.tween=r}}function ym(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i=cn(this.node(),n).tween,r=0,o=i.length,s;r<o;++r)if((s=i[r]).name===t)return s.value;return null}return this.each((e==null?vm:gm)(n,t,e))}function Fa(t,e,n){var i=t._id;return t.each(function(){var r=bn(this,i);(r.value||(r.value={}))[e]=n.apply(this,arguments)}),function(r){return cn(r,i).value[e]}}function jf(t,e){var n;return(typeof e=="number"?dn:e instanceof Vn?no:(n=Vn(e))?(e=n,no):Vf)(t,e)}function xm(t){return function(){this.removeAttribute(t)}}function bm(t){return function(){this.removeAttributeNS(t.space,t.local)}}function _m(t,e,n){var i,r=n+"",o;return function(){var s=this.getAttribute(t);return s===r?null:s===i?o:o=e(i=s,n)}}function Sm(t,e,n){var i,r=n+"",o;return function(){var s=this.getAttributeNS(t.space,t.local);return s===r?null:s===i?o:o=e(i=s,n)}}function Tm(t,e,n){var i,r,o;return function(){var s,f=n(this),l;return f==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=f+"",s===l?null:s===i&&l===r?o:(r=l,o=e(i=s,f)))}}function wm(t,e,n){var i,r,o;return function(){var s,f=n(this),l;return f==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=f+"",s===l?null:s===i&&l===r?o:(r=l,o=e(i=s,f)))}}function Am(t,e){var n=Br(t),i=n==="transform"?cm:jf;return this.attrTween(t,typeof e=="function"?(n.local?wm:Tm)(n,i,Fa(this,"attr."+t,e)):e==null?(n.local?bm:xm)(n):(n.local?Sm:_m)(n,i,e))}function Em(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Cm(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Pm(t,e){var n,i;function r(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&Cm(t,o)),n}return r._value=e,r}function km(t,e){var n,i;function r(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&Em(t,o)),n}return r._value=e,r}function Im(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var i=Br(t);return this.tween(n,(i.local?Pm:km)(i,e))}function Lm(t,e){return function(){wa(this,t).delay=+e.apply(this,arguments)}}function Dm(t,e){return e=+e,function(){wa(this,t).delay=e}}function Fm(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Lm:Dm)(e,t)):cn(this.node(),e).delay}function zm(t,e){return function(){bn(this,t).duration=+e.apply(this,arguments)}}function Rm(t,e){return e=+e,function(){bn(this,t).duration=e}}function Mm(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?zm:Rm)(e,t)):cn(this.node(),e).duration}function Om(t,e){if(typeof e!="function")throw new Error;return function(){bn(this,t).ease=e}}function Nm(t){var e=this._id;return arguments.length?this.each(Om(e,t)):cn(this.node(),e).ease}function Gm(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;bn(this,t).ease=n}}function Bm(t){if(typeof t!="function")throw new Error;return this.each(Gm(this._id,t))}function Um(t){typeof t!="function"&&(t=hf(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var o=e[r],s=o.length,f=i[r]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&f.push(l);return new In(i,this._parents,this._name,this._id)}function Vm(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,i=e.length,r=n.length,o=Math.min(i,r),s=new Array(i),f=0;f<o;++f)for(var l=e[f],u=n[f],d=l.length,y=s[f]=new Array(d),S,D=0;D<d;++D)(S=l[D]||u[D])&&(y[D]=S);for(;f<i;++f)s[f]=e[f];return new In(s,this._parents,this._name,this._id)}function $m(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function Hm(t,e,n){var i,r,o=$m(e)?wa:bn;return function(){var s=o(this,t),f=s.on;f!==i&&(r=(i=f).copy()).on(e,n),s.on=r}}function Wm(t,e){var n=this._id;return arguments.length<2?cn(this.node(),n).on.on(t):this.each(Hm(n,t,e))}function Xm(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function jm(){return this.on("end.remove",Xm(this._id))}function qm(t){var e=this._name,n=this._id;typeof t!="function"&&(t=ya(t));for(var i=this._groups,r=i.length,o=new Array(r),s=0;s<r;++s)for(var f=i[s],l=f.length,u=o[s]=new Array(l),d,y,S=0;S<l;++S)(d=f[S])&&(y=t.call(d,d.__data__,S,f))&&("__data__"in d&&(y.__data__=d.__data__),u[S]=y,Zr(u[S],e,n,S,u,cn(d,n)));return new In(o,this._parents,e,n)}function Ym(t){var e=this._name,n=this._id;typeof t!="function"&&(t=cf(t));for(var i=this._groups,r=i.length,o=[],s=[],f=0;f<r;++f)for(var l=i[f],u=l.length,d,y=0;y<u;++y)if(d=l[y]){for(var S=t.call(d,d.__data__,y,l),D,q=cn(d,n),Te=0,we=S.length;Te<we;++Te)(D=S[Te])&&Zr(D,e,n,Te,S,q);o.push(S),s.push(d)}return new In(o,s,e,n)}var Zm=nr.prototype.constructor;function Qm(){return new Zm(this._groups,this._parents)}function Km(t,e){var n,i,r;return function(){var o=Pi(this,t),s=(this.style.removeProperty(t),Pi(this,t));return o===s?null:o===n&&s===i?r:r=e(n=o,i=s)}}function qf(t){return function(){this.style.removeProperty(t)}}function Jm(t,e,n){var i,r=n+"",o;return function(){var s=Pi(this,t);return s===r?null:s===i?o:o=e(i=s,n)}}function ep(t,e,n){var i,r,o;return function(){var s=Pi(this,t),f=n(this),l=f+"";return f==null&&(l=f=(this.style.removeProperty(t),Pi(this,t))),s===l?null:s===i&&l===r?o:(r=l,o=e(i=s,f))}}function tp(t,e){var n,i,r,o="style."+e,s="end."+o,f;return function(){var l=bn(this,t),u=l.on,d=l.value[o]==null?f||(f=qf(e)):void 0;(u!==n||r!==d)&&(i=(n=u).copy()).on(s,r=d),l.on=i}}function np(t,e,n){var i=(t+="")=="transform"?um:jf;return e==null?this.styleTween(t,Km(t,i)).on("end.style."+t,qf(t)):typeof e=="function"?this.styleTween(t,ep(t,i,Fa(this,"style."+t,e))).each(tp(this._id,t)):this.styleTween(t,Jm(t,i,e),n).on("end.style."+t,null)}function ip(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}function rp(t,e,n){var i,r;function o(){var s=e.apply(this,arguments);return s!==r&&(i=(r=s)&&ip(t,s,n)),i}return o._value=e,o}function op(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,rp(t,e,n??""))}function ap(t){return function(){this.textContent=t}}function sp(t){return function(){var e=t(this);this.textContent=e??""}}function fp(t){return this.tween("text",typeof t=="function"?sp(Fa(this,"text",t)):ap(t==null?"":t+""))}function lp(t){return function(e){this.textContent=t.call(this,e)}}function up(t){var e,n;function i(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&lp(r)),e}return i._value=t,i}function cp(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,up(t))}function hp(){for(var t=this._name,e=this._id,n=Yf(),i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],f=s.length,l,u=0;u<f;++u)if(l=s[u]){var d=cn(l,e);Zr(l,t,n,u,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new In(i,this._parents,t,n)}function dp(){var t,e,n=this,i=n._id,r=n.size();return new Promise(function(o,s){var f={value:s},l={value:function(){--r===0&&o()}};n.each(function(){var u=bn(this,i),d=u.on;d!==t&&(e=(t=d).copy(),e._.cancel.push(f),e._.interrupt.push(f),e._.end.push(l)),u.on=e}),r===0&&o()})}var mp=0;function In(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function Yf(){return++mp}var Ln=nr.prototype;In.prototype={constructor:In,select:qm,selectAll:Ym,selectChild:Ln.selectChild,selectChildren:Ln.selectChildren,filter:Um,merge:Vm,selection:Qm,transition:hp,call:Ln.call,nodes:Ln.nodes,node:Ln.node,size:Ln.size,empty:Ln.empty,each:Ln.each,on:Wm,attr:Am,attrTween:Im,style:np,styleTween:op,text:fp,textTween:cp,remove:jm,tween:ym,delay:Fm,duration:Mm,ease:Nm,easeVarying:Bm,end:dp,[Symbol.iterator]:Ln[Symbol.iterator]};function pp(t){return t*t}function vp(t){return t*(2-t)}function gp(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function yp(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var xp={time:null,delay:0,duration:250,ease:yp};function bp(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function _p(t){var e,n;t instanceof In?(e=t._id,t=t._name):(e=Yf(),(n=xp).time=ba(),t=t==null?null:t+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],f=s.length,l,u=0;u<f;++u)(l=s[u])&&Zr(l,t,e,u,s,n||bp(l,e));return new In(i,this._parents,t,e)}nr.prototype.interrupt=Nd,nr.prototype.transition=_p;function za(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Sp(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}var ro={exports:{}},Tp=ro.exports,Zf;function wp(){return Zf||(Zf=1,function(t,e){(function(n,i){t.exports=i()})(Tp,function(){var n=function(a){return a instanceof Uint8Array||a instanceof Uint16Array||a instanceof Uint32Array||a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array||a instanceof Float32Array||a instanceof Float64Array||a instanceof Uint8ClampedArray},i=function(a,h){for(var _=Object.keys(h),M=0;M<_.length;++M)a[_[M]]=h[_[M]];return a},r=`
2
+ `;function o(a){return typeof atob<"u"?atob(a):"base64:"+a}function s(a){var h=new Error("(regl) "+a);throw console.error(h),h}function f(a,h){a||s(h)}function l(a){return a?": "+a:""}function u(a,h,_){a in h||s("unknown parameter ("+a+")"+l(_)+". possible values: "+Object.keys(h).join())}function d(a,h){n(a)||s("invalid parameter type"+l(h)+". must be a typed array")}function y(a,h){switch(h){case"number":return typeof a=="number";case"object":return typeof a=="object";case"string":return typeof a=="string";case"boolean":return typeof a=="boolean";case"function":return typeof a=="function";case"undefined":return typeof a>"u";case"symbol":return typeof a=="symbol"}}function S(a,h,_){y(a,h)||s("invalid parameter type"+l(_)+". expected "+h+", got "+typeof a)}function D(a,h){a>=0&&(a|0)===a||s("invalid parameter type, ("+a+")"+l(h)+". must be a nonnegative integer")}function q(a,h,_){h.indexOf(a)<0&&s("invalid value"+l(_)+". must be one of: "+h)}var Te=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function we(a){Object.keys(a).forEach(function(h){Te.indexOf(h)<0&&s('invalid regl constructor argument "'+h+'". must be one of '+Te)})}function fe(a,h){for(a=a+"";a.length<h;)a=" "+a;return a}function Ne(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function Ve(a,h){this.number=a,this.line=h,this.errors=[]}function V(a,h,_){this.file=a,this.line=h,this.message=_}function ae(){var a=new Error,h=(a.stack||a).toString(),_=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(h);if(_)return _[1];var M=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(h);return M?M[1]:"unknown"}function Ie(){var a=new Error,h=(a.stack||a).toString(),_=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(h);if(_)return _[1];var M=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(h);return M?M[1]:"unknown"}function Be(a,h){var _=a.split(`
3
+ `),M=1,W=0,R={unknown:new Ne,0:new Ne};R.unknown.name=R[0].name=h||ae(),R.unknown.lines.push(new Ve(0,""));for(var B=0;B<_.length;++B){var K=_[B],Q=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(K);if(Q)switch(Q[1]){case"line":var ie=/(\d+)(\s+\d+)?/.exec(Q[2]);ie&&(M=ie[1]|0,ie[2]&&(W=ie[2]|0,W in R||(R[W]=new Ne)));break;case"define":var oe=/SHADER_NAME(_B64)?\s+(.*)$/.exec(Q[2]);oe&&(R[W].name=oe[1]?o(oe[2]):oe[2]);break}R[W].lines.push(new Ve(M++,K))}return Object.keys(R).forEach(function(re){var ue=R[re];ue.lines.forEach(function(J){ue.index[J.number]=J})}),R}function Xe(a){var h=[];return a.split(`
4
+ `).forEach(function(_){if(!(_.length<5)){var M=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(_);M?h.push(new V(M[1]|0,M[2]|0,M[3].trim())):_.length>0&&h.push(new V("unknown",0,_))}}),h}function nt(a,h){h.forEach(function(_){var M=a[_.file];if(M){var W=M.index[_.line];if(W){W.errors.push(_),M.hasErrors=!0;return}}a.unknown.hasErrors=!0,a.unknown.lines[0].errors.push(_)})}function lt(a,h,_,M,W){if(!a.getShaderParameter(h,a.COMPILE_STATUS)){var R=a.getShaderInfoLog(h),B=M===a.FRAGMENT_SHADER?"fragment":"vertex";De(_,"string",B+" shader source must be a string",W);var K=Be(_,W),Q=Xe(R);nt(K,Q),Object.keys(K).forEach(function(ie){var oe=K[ie];if(!oe.hasErrors)return;var re=[""],ue=[""];function J(ne,k){re.push(ne),ue.push(k||"")}J("file number "+ie+": "+oe.name+`
5
+ `,"color:red;text-decoration:underline;font-weight:bold"),oe.lines.forEach(function(ne){if(ne.errors.length>0){J(fe(ne.number,4)+"| ","background-color:yellow; font-weight:bold"),J(ne.line+r,"color:red; background-color:yellow; font-weight:bold");var k=0;ne.errors.forEach(function(N){var te=N.message,xe=/^\s*'(.*)'\s*:\s*(.*)$/.exec(te);if(xe){var Z=xe[1];switch(te=xe[2],Z){case"assign":Z="=";break}k=Math.max(ne.line.indexOf(Z,k),0)}else k=0;J(fe("| ",6)),J(fe("^^^",k+3)+r,"font-weight:bold"),J(fe("| ",6)),J(te+r,"font-weight:bold")}),J(fe("| ",6)+r)}else J(fe(ne.number,4)+"| "),J(ne.line+r,"color:red")}),typeof document<"u"&&!window.chrome?(ue[0]=re.join("%c"),console.log.apply(console,ue)):console.log(re.join(""))}),f.raise("Error compiling "+B+" shader, "+K[0].name)}}function Ee(a,h,_,M,W){if(!a.getProgramParameter(h,a.LINK_STATUS)){var R=a.getProgramInfoLog(h),B=Be(_,W),K=Be(M,W),Q='Error linking program with vertex shader, "'+K[0].name+'", and fragment shader "'+B[0].name+'"';typeof document<"u"?console.log("%c"+Q+r+"%c"+R,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(Q+r+R),f.raise(Q)}}function ct(a){a._commandRef=ae()}function ft(a,h,_,M){ct(a);function W(Q){return Q?M.id(Q):0}a._fragId=W(a.static.frag),a._vertId=W(a.static.vert);function R(Q,ie){Object.keys(ie).forEach(function(oe){Q[M.id(oe)]=!0})}var B=a._uniformSet={};R(B,h.static),R(B,h.dynamic);var K=a._attributeSet={};R(K,_.static),R(K,_.dynamic),a._hasCount="count"in a.static||"count"in a.dynamic||"elements"in a.static||"elements"in a.dynamic}function G(a,h){var _=Ie();s(a+" in command "+(h||ae())+(_==="unknown"?"":" called from "+_))}function Pe(a,h,_){a||G(h,_||ae())}function se(a,h,_,M){a in h||G("unknown parameter ("+a+")"+l(_)+". possible values: "+Object.keys(h).join(),M||ae())}function De(a,h,_,M){y(a,h)||G("invalid parameter type"+l(_)+". expected "+h+", got "+typeof a,M||ae())}function qe(a){a()}function je(a,h,_){a.texture?q(a.texture._texture.internalformat,h,"unsupported texture format for attachment"):q(a.renderbuffer._renderbuffer.format,_,"unsupported renderbuffer format for attachment")}var Qe=33071,Ze=9728,dt=9984,ut=9985,_t=9986,at=9987,$t=5120,Ht=5121,Kt=5122,Mn=5123,wo=5124,Ao=5125,On=5126,si=32819,Tn=32820,Fi=33635,zi=34042,$n=36193,Mt={};Mt[$t]=Mt[Ht]=1,Mt[Kt]=Mt[Mn]=Mt[$n]=Mt[Fi]=Mt[si]=Mt[Tn]=2,Mt[wo]=Mt[Ao]=Mt[On]=Mt[zi]=4;function fi(a,h){return a===Tn||a===si||a===Fi?2:a===zi?4:Mt[a]*h}function li(a){return!(a&a-1)&&!!a}function Eo(a,h,_){var M,W=h.width,R=h.height,B=h.channels;f(W>0&&W<=_.maxTextureSize&&R>0&&R<=_.maxTextureSize,"invalid texture shape"),(a.wrapS!==Qe||a.wrapT!==Qe)&&f(li(W)&&li(R),"incompatible wrap mode for texture, both width and height must be power of 2"),h.mipmask===1?W!==1&&R!==1&&f(a.minFilter!==dt&&a.minFilter!==_t&&a.minFilter!==ut&&a.minFilter!==at,"min filter requires mipmap"):(f(li(W)&&li(R),"texture must be a square power of 2 to support mipmapping"),f(h.mipmask===(W<<1)-1,"missing or incomplete mipmap data")),h.type===On&&(_.extensions.indexOf("oes_texture_float_linear")<0&&f(a.minFilter===Ze&&a.magFilter===Ze,"filter not supported, must enable oes_texture_float_linear"),f(!a.genMipmaps,"mipmap generation not supported with float textures"));var K=h.images;for(M=0;M<16;++M)if(K[M]){var Q=W>>M,ie=R>>M;f(h.mipmask&1<<M,"missing mipmap data");var oe=K[M];if(f(oe.width===Q&&oe.height===ie,"invalid shape for mip images"),f(oe.format===h.format&&oe.internalformat===h.internalformat&&oe.type===h.type,"incompatible type for mip image"),!oe.compressed)if(oe.data){var re=Math.ceil(fi(oe.type,B)*Q/oe.unpackAlignment)*oe.unpackAlignment;f(oe.data.byteLength===re*ie,"invalid data for image, buffer size is inconsistent with image format")}else oe.element||oe.copy}else a.genMipmaps||f((h.mipmask&1<<M)===0,"extra mipmap data");h.compressed&&f(!a.genMipmaps,"mipmap generation for compressed images not supported")}function ss(a,h,_,M){var W=a.width,R=a.height,B=a.channels;f(W>0&&W<=M.maxTextureSize&&R>0&&R<=M.maxTextureSize,"invalid texture shape"),f(W===R,"cube map must be square"),f(h.wrapS===Qe&&h.wrapT===Qe,"wrap mode not supported by cube map");for(var K=0;K<_.length;++K){var Q=_[K];f(Q.width===W&&Q.height===R,"inconsistent cube map face shape"),h.genMipmaps&&(f(!Q.compressed,"can not generate mipmap for compressed textures"),f(Q.mipmask===1,"can not specify mipmaps and generate mipmaps"));for(var ie=Q.images,oe=0;oe<16;++oe){var re=ie[oe];if(re){var ue=W>>oe,J=R>>oe;f(Q.mipmask&1<<oe,"missing mipmap data"),f(re.width===ue&&re.height===J,"invalid shape for mip images"),f(re.format===a.format&&re.internalformat===a.internalformat&&re.type===a.type,"incompatible type for mip image"),re.compressed||(re.data?f(re.data.byteLength===ue*J*Math.max(fi(re.type,B),re.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):re.element||re.copy)}}}}var m=i(f,{optional:qe,raise:s,commandRaise:G,command:Pe,parameter:u,commandParameter:se,constructor:we,type:S,commandType:De,isTypedArray:d,nni:D,oneOf:q,shaderError:lt,linkError:Ee,callSite:Ie,saveCommandRef:ct,saveDrawInfo:ft,framebufferFormat:je,guessCommand:ae,texture2D:Eo,textureCube:ss}),ui=0,Hn=0,Wn=5,Co=6;function wn(a,h){this.id=ui++,this.type=a,this.data=h}function yr(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function Nn(a){if(a.length===0)return[];var h=a.charAt(0),_=a.charAt(a.length-1);if(a.length>1&&h===_&&(h==='"'||h==="'"))return['"'+yr(a.substr(1,a.length-2))+'"'];var M=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(a);if(M)return Nn(a.substr(0,M.index)).concat(Nn(M[1])).concat(Nn(a.substr(M.index+M[0].length)));var W=a.split(".");if(W.length===1)return['"'+yr(a)+'"'];for(var R=[],B=0;B<W.length;++B)R=R.concat(Nn(W[B]));return R}function xr(a){return"["+Nn(a).join("][")+"]"}function Ri(a,h){return new wn(a,xr(h+""))}function Mi(a){return typeof a=="function"&&!a._reglType||a instanceof wn}function sn(a,h){if(typeof a=="function")return new wn(Hn,a);if(typeof a=="number"||typeof a=="boolean")return new wn(Wn,a);if(Array.isArray(a))return new wn(Co,a.map(function(_,M){return sn(_,h+"["+M+"]")}));if(a instanceof wn)return a;m(!1,"invalid option type in uniform "+h)}var It={DynamicVariable:wn,define:Ri,isDynamic:Mi,unbox:sn,accessor:xr},ci={next:typeof requestAnimationFrame=="function"?function(a){return requestAnimationFrame(a)}:function(a){return setTimeout(a,16)},cancel:typeof cancelAnimationFrame=="function"?function(a){return cancelAnimationFrame(a)}:clearTimeout},Oi=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return+new Date};function fs(){var a={"":0},h=[""];return{id:function(_){var M=a[_];return M||(M=a[_]=h.length,h.push(_),M)},str:function(_){return h[_]}}}function Ni(a,h,_){var M=document.createElement("canvas");i(M.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),a.appendChild(M),a===document.body&&(M.style.position="absolute",i(a.style,{margin:0,padding:0}));function W(){var K=window.innerWidth,Q=window.innerHeight;if(a!==document.body){var ie=M.getBoundingClientRect();K=ie.right-ie.left,Q=ie.bottom-ie.top}M.width=_*K,M.height=_*Q}var R;a!==document.body&&typeof ResizeObserver=="function"?(R=new ResizeObserver(function(){setTimeout(W)}),R.observe(a)):window.addEventListener("resize",W,!1);function B(){R?R.disconnect():window.removeEventListener("resize",W),a.removeChild(M)}return W(),{canvas:M,onDestroy:B}}function Gi(a,h){function _(M){try{return a.getContext(M,h)}catch{return null}}return _("webgl")||_("experimental-webgl")||_("webgl-experimental")}function ls(a){return typeof a.nodeName=="string"&&typeof a.appendChild=="function"&&typeof a.getBoundingClientRect=="function"}function hi(a){return typeof a.drawArrays=="function"||typeof a.drawElements=="function"}function Po(a){return typeof a=="string"?a.split():(m(Array.isArray(a),"invalid extension array"),a)}function ko(a){return typeof a=="string"?(m(typeof document<"u","not supported outside of DOM"),document.querySelector(a)):a}function Lt(a){var h=a||{},_,M,W,R,B={},K=[],Q=[],ie=typeof window>"u"?1:window.devicePixelRatio,oe=!1,re=function(ne){ne&&m.raise(ne)},ue=function(){};if(typeof h=="string"?(m(typeof document<"u","selector queries only supported in DOM enviroments"),_=document.querySelector(h),m(_,"invalid query string for element")):typeof h=="object"?ls(h)?_=h:hi(h)?(R=h,W=R.canvas):(m.constructor(h),"gl"in h?R=h.gl:"canvas"in h?W=ko(h.canvas):"container"in h&&(M=ko(h.container)),"attributes"in h&&(B=h.attributes,m.type(B,"object","invalid context attributes")),"extensions"in h&&(K=Po(h.extensions)),"optionalExtensions"in h&&(Q=Po(h.optionalExtensions)),"onDone"in h&&(m.type(h.onDone,"function","invalid or missing onDone callback"),re=h.onDone),"profile"in h&&(oe=!!h.profile),"pixelRatio"in h&&(ie=+h.pixelRatio,m(ie>0,"invalid pixel ratio"))):m.raise("invalid arguments to regl"),_&&(_.nodeName.toLowerCase()==="canvas"?W=_:M=_),!R){if(!W){m(typeof document<"u","must manually specify webgl context outside of DOM environments");var J=Ni(M||document.body,re,ie);if(!J)return null;W=J.canvas,ue=J.onDestroy}B.premultipliedAlpha===void 0&&(B.premultipliedAlpha=!0),R=Gi(W,B)}return R?{gl:R,canvas:W,container:M,extensions:K,optionalExtensions:Q,pixelRatio:ie,profile:oe,onDone:re,onDestroy:ue}:(ue(),re("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Xn(a,h){var _={};function M(B){m.type(B,"string","extension name must be string");var K=B.toLowerCase(),Q;try{Q=_[K]=a.getExtension(K)}catch{}return!!Q}for(var W=0;W<h.extensions.length;++W){var R=h.extensions[W];if(!M(R))return h.onDestroy(),h.onDone('"'+R+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return h.optionalExtensions.forEach(M),{extensions:_,restore:function(){Object.keys(_).forEach(function(B){if(_[B]&&!M(B))throw new Error("(regl): error restoring extension "+B)})}}}function Yt(a,h){for(var _=Array(a),M=0;M<a;++M)_[M]=h(M);return _}var Io=5120,br=5121,Lo=5122,Do=5123,us=5124,fn=5125,jn=5126;function Fo(a){for(var h=16;h<=1<<28;h*=16)if(a<=h)return h;return 0}function _r(a){var h,_;return h=(a>65535)<<4,a>>>=h,_=(a>255)<<3,a>>>=_,h|=_,_=(a>15)<<2,a>>>=_,h|=_,_=(a>3)<<1,a>>>=_,h|=_,h|a>>1}function Bi(){var a=Yt(8,function(){return[]});function h(R){var B=Fo(R),K=a[_r(B)>>2];return K.length>0?K.pop():new ArrayBuffer(B)}function _(R){a[_r(R.byteLength)>>2].push(R)}function M(R,B){var K=null;switch(R){case Io:K=new Int8Array(h(B),0,B);break;case br:K=new Uint8Array(h(B),0,B);break;case Lo:K=new Int16Array(h(2*B),0,B);break;case Do:K=new Uint16Array(h(2*B),0,B);break;case us:K=new Int32Array(h(4*B),0,B);break;case fn:K=new Uint32Array(h(4*B),0,B);break;case jn:K=new Float32Array(h(4*B),0,B);break;default:return null}return K.length!==B?K.subarray(0,B):K}function W(R){_(R.buffer)}return{alloc:h,free:_,allocType:M,freeType:W}}var gt=Bi();gt.zero=Bi();var vn=3408,zo=3410,Ro=3411,Mo=3412,Oo=3413,cs=3414,$e=3415,P=33901,ve=33902,ze=3379,mt=3386,Ot=34921,At=36347,Wt=36348,gn=35661,di=35660,Sr=34930,Nt=36349,No=34076,Go=34024,Dg=7936,Fg=7937,zg=7938,Rg=35724,Mg=34047,Og=36063,Ng=34852,Bo=3553,ou=34067,Gg=34069,Bg=33984,Tr=6408,hs=5126,au=5121,ds=36160,Ug=36053,Vg=36064,$g=16384,Hg=function(a,h){var _=1;h.ext_texture_filter_anisotropic&&(_=a.getParameter(Mg));var M=1,W=1;h.webgl_draw_buffers&&(M=a.getParameter(Ng),W=a.getParameter(Og));var R=!!h.oes_texture_float;if(R){var B=a.createTexture();a.bindTexture(Bo,B),a.texImage2D(Bo,0,Tr,1,1,0,Tr,hs,null);var K=a.createFramebuffer();if(a.bindFramebuffer(ds,K),a.framebufferTexture2D(ds,Vg,Bo,B,0),a.bindTexture(Bo,null),a.checkFramebufferStatus(ds)!==Ug)R=!1;else{a.viewport(0,0,1,1),a.clearColor(1,0,0,1),a.clear($g);var Q=gt.allocType(hs,4);a.readPixels(0,0,1,1,Tr,hs,Q),a.getError()?R=!1:(a.deleteFramebuffer(K),a.deleteTexture(B),R=Q[0]===1),gt.freeType(Q)}}var ie=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),oe=!0;if(!ie){var re=a.createTexture(),ue=gt.allocType(au,36);a.activeTexture(Bg),a.bindTexture(ou,re),a.texImage2D(Gg,0,Tr,3,3,0,Tr,au,ue),gt.freeType(ue),a.bindTexture(ou,null),a.deleteTexture(re),oe=!a.getError()}return{colorBits:[a.getParameter(zo),a.getParameter(Ro),a.getParameter(Mo),a.getParameter(Oo)],depthBits:a.getParameter(cs),stencilBits:a.getParameter($e),subpixelBits:a.getParameter(vn),extensions:Object.keys(h).filter(function(J){return!!h[J]}),maxAnisotropic:_,maxDrawbuffers:M,maxColorAttachments:W,pointSizeDims:a.getParameter(P),lineWidthDims:a.getParameter(ve),maxViewportDims:a.getParameter(mt),maxCombinedTextureUnits:a.getParameter(gn),maxCubeMapSize:a.getParameter(No),maxRenderbufferSize:a.getParameter(Go),maxTextureUnits:a.getParameter(Sr),maxTextureSize:a.getParameter(ze),maxAttributes:a.getParameter(Ot),maxVertexUniforms:a.getParameter(At),maxVertexTextureUnits:a.getParameter(di),maxVaryingVectors:a.getParameter(Wt),maxFragmentUniforms:a.getParameter(Nt),glsl:a.getParameter(Rg),renderer:a.getParameter(Fg),vendor:a.getParameter(Dg),version:a.getParameter(zg),readFloat:R,npotTextureCube:oe}};function yn(a){return!!a&&typeof a=="object"&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&typeof a.offset=="number"&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||n(a.data))}var rn=function(a){return Object.keys(a).map(function(h){return a[h]})},Uo={shape:qg,flatten:jg};function Wg(a,h,_){for(var M=0;M<h;++M)_[M]=a[M]}function Xg(a,h,_,M){for(var W=0,R=0;R<h;++R)for(var B=a[R],K=0;K<_;++K)M[W++]=B[K]}function su(a,h,_,M,W,R){for(var B=R,K=0;K<h;++K)for(var Q=a[K],ie=0;ie<_;++ie)for(var oe=Q[ie],re=0;re<M;++re)W[B++]=oe[re]}function fu(a,h,_,M,W){for(var R=1,B=_+1;B<h.length;++B)R*=h[B];var K=h[_];if(h.length-_===4){var Q=h[_+1],ie=h[_+2],oe=h[_+3];for(B=0;B<K;++B)su(a[B],Q,ie,oe,M,W),W+=R}else for(B=0;B<K;++B)fu(a[B],h,_+1,M,W),W+=R}function jg(a,h,_,M){var W=1;if(h.length)for(var R=0;R<h.length;++R)W*=h[R];else W=0;var B=M||gt.allocType(_,W);switch(h.length){case 0:break;case 1:Wg(a,h[0],B);break;case 2:Xg(a,h[0],h[1],B);break;case 3:su(a,h[0],h[1],h[2],B,0);break;default:fu(a,h,0,B,0)}return B}function qg(a){for(var h=[],_=a;_.length;_=_[0])h.push(_.length);return h}var ms={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Yg=5120,Zg=5122,Qg=5124,Kg=5121,Jg=5123,ey=5125,ty=5126,ny=5126,mi={int8:Yg,int16:Zg,int32:Qg,uint8:Kg,uint16:Jg,uint32:ey,float:ty,float32:ny},iy=35048,ry=35040,Vo={dynamic:iy,stream:ry,static:35044},ps=Uo.flatten,lu=Uo.shape,uu=35044,oy=35040,vs=5121,gs=5126,qn=[];qn[5120]=1,qn[5122]=2,qn[5124]=4,qn[5121]=1,qn[5123]=2,qn[5125]=4,qn[5126]=4;function $o(a){return ms[Object.prototype.toString.call(a)]|0}function cu(a,h){for(var _=0;_<h.length;++_)a[_]=h[_]}function hu(a,h,_,M,W,R,B){for(var K=0,Q=0;Q<_;++Q)for(var ie=0;ie<M;++ie)a[K++]=h[W*Q+R*ie+B]}function ay(a,h,_,M){var W=0,R={};function B(k){this.id=W++,this.buffer=a.createBuffer(),this.type=k,this.usage=uu,this.byteLength=0,this.dimension=1,this.dtype=vs,this.persistentData=null,_.profile&&(this.stats={size:0})}B.prototype.bind=function(){a.bindBuffer(this.type,this.buffer)},B.prototype.destroy=function(){ue(this)};var K=[];function Q(k,N){var te=K.pop();return te||(te=new B(k)),te.bind(),re(te,N,oy,0,1,!1),te}function ie(k){K.push(k)}function oe(k,N,te){k.byteLength=N.byteLength,a.bufferData(k.type,N,te)}function re(k,N,te,xe,Z,ge){var me;if(k.usage=te,Array.isArray(N)){if(k.dtype=xe||gs,N.length>0){var Le;if(Array.isArray(N[0])){me=lu(N);for(var X=1,H=1;H<me.length;++H)X*=me[H];k.dimension=X,Le=ps(N,me,k.dtype),oe(k,Le,te),ge?k.persistentData=Le:gt.freeType(Le)}else if(typeof N[0]=="number"){k.dimension=Z;var Se=gt.allocType(k.dtype,N.length);cu(Se,N),oe(k,Se,te),ge?k.persistentData=Se:gt.freeType(Se)}else n(N[0])?(k.dimension=N[0].length,k.dtype=xe||$o(N[0])||gs,Le=ps(N,[N.length,N[0].length],k.dtype),oe(k,Le,te),ge?k.persistentData=Le:gt.freeType(Le)):m.raise("invalid buffer data")}}else if(n(N))k.dtype=xe||$o(N),k.dimension=Z,oe(k,N,te),ge&&(k.persistentData=new Uint8Array(new Uint8Array(N.buffer)));else if(yn(N)){me=N.shape;var ce=N.stride,ee=N.offset,he=0,de=0,He=0,Ue=0;me.length===1?(he=me[0],de=1,He=ce[0],Ue=0):me.length===2?(he=me[0],de=me[1],He=ce[0],Ue=ce[1]):m.raise("invalid shape"),k.dtype=xe||$o(N.data)||gs,k.dimension=de;var pe=gt.allocType(k.dtype,he*de);hu(pe,N.data,he,de,He,Ue,ee),oe(k,pe,te),ge?k.persistentData=pe:gt.freeType(pe)}else N instanceof ArrayBuffer?(k.dtype=vs,k.dimension=Z,oe(k,N,te),ge&&(k.persistentData=new Uint8Array(new Uint8Array(N)))):m.raise("invalid buffer data")}function ue(k){h.bufferCount--,M(k);var N=k.buffer;m(N,"buffer must not be deleted already"),a.deleteBuffer(N),k.buffer=null,delete R[k.id]}function J(k,N,te,xe){h.bufferCount++;var Z=new B(N);R[Z.id]=Z;function ge(X){var H=uu,Se=null,ce=0,ee=0,he=1;return Array.isArray(X)||n(X)||yn(X)||X instanceof ArrayBuffer?Se=X:typeof X=="number"?ce=X|0:X&&(m.type(X,"object","buffer arguments must be an object, a number or an array"),"data"in X&&(m(Se===null||Array.isArray(Se)||n(Se)||yn(Se),"invalid data for buffer"),Se=X.data),"usage"in X&&(m.parameter(X.usage,Vo,"invalid buffer usage"),H=Vo[X.usage]),"type"in X&&(m.parameter(X.type,mi,"invalid buffer type"),ee=mi[X.type]),"dimension"in X&&(m.type(X.dimension,"number","invalid dimension"),he=X.dimension|0),"length"in X&&(m.nni(ce,"buffer length must be a nonnegative integer"),ce=X.length|0)),Z.bind(),Se?re(Z,Se,H,ee,he,xe):(ce&&a.bufferData(Z.type,ce,H),Z.dtype=ee||vs,Z.usage=H,Z.dimension=he,Z.byteLength=ce),_.profile&&(Z.stats.size=Z.byteLength*qn[Z.dtype]),ge}function me(X,H){m(H+X.byteLength<=Z.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+X.byteLength+" starting from offset "+H+" to a buffer of size "+Z.byteLength),a.bufferSubData(Z.type,H,X)}function Le(X,H){var Se=(H||0)|0,ce;if(Z.bind(),n(X)||X instanceof ArrayBuffer)me(X,Se);else if(Array.isArray(X)){if(X.length>0)if(typeof X[0]=="number"){var ee=gt.allocType(Z.dtype,X.length);cu(ee,X),me(ee,Se),gt.freeType(ee)}else if(Array.isArray(X[0])||n(X[0])){ce=lu(X);var he=ps(X,ce,Z.dtype);me(he,Se),gt.freeType(he)}else m.raise("invalid buffer data")}else if(yn(X)){ce=X.shape;var de=X.stride,He=0,Ue=0,pe=0,ye=0;ce.length===1?(He=ce[0],Ue=1,pe=de[0],ye=0):ce.length===2?(He=ce[0],Ue=ce[1],pe=de[0],ye=de[1]):m.raise("invalid shape");var Re=Array.isArray(X.data)?Z.dtype:$o(X.data),We=gt.allocType(Re,He*Ue);hu(We,X.data,He,Ue,pe,ye,X.offset),me(We,Se),gt.freeType(We)}else m.raise("invalid data for buffer subdata");return ge}return te||ge(k),ge._reglType="buffer",ge._buffer=Z,ge.subdata=Le,_.profile&&(ge.stats=Z.stats),ge.destroy=function(){ue(Z)},ge}function ne(){rn(R).forEach(function(k){k.buffer=a.createBuffer(),a.bindBuffer(k.type,k.buffer),a.bufferData(k.type,k.persistentData||k.byteLength,k.usage)})}return _.profile&&(h.getTotalBufferSize=function(){var k=0;return Object.keys(R).forEach(function(N){k+=R[N].stats.size}),k}),{create:J,createStream:Q,destroyStream:ie,clear:function(){rn(R).forEach(ue),K.forEach(ue)},getBuffer:function(k){return k&&k._buffer instanceof B?k._buffer:null},restore:ne,_initBuffer:re}}var sy=0,fy=0,ly=1,uy=1,cy=4,hy=4,Yn={points:sy,point:fy,lines:ly,line:uy,triangles:cy,triangle:hy,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},dy=0,my=1,wr=4,py=5120,Ui=5121,du=5122,Vi=5123,mu=5124,pi=5125,ys=34963,vy=35040,gy=35044;function yy(a,h,_,M){var W={},R=0,B={uint8:Ui,uint16:Vi};h.oes_element_index_uint&&(B.uint32=pi);function K(ne){this.id=R++,W[this.id]=this,this.buffer=ne,this.primType=wr,this.vertCount=0,this.type=0}K.prototype.bind=function(){this.buffer.bind()};var Q=[];function ie(ne){var k=Q.pop();return k||(k=new K(_.create(null,ys,!0,!1)._buffer)),re(k,ne,vy,-1,-1,0,0),k}function oe(ne){Q.push(ne)}function re(ne,k,N,te,xe,Z,ge){ne.buffer.bind();var me;if(k){var Le=ge;!ge&&(!n(k)||yn(k)&&!n(k.data))&&(Le=h.oes_element_index_uint?pi:Vi),_._initBuffer(ne.buffer,k,N,Le,3)}else a.bufferData(ys,Z,N),ne.buffer.dtype=me||Ui,ne.buffer.usage=N,ne.buffer.dimension=3,ne.buffer.byteLength=Z;if(me=ge,!ge){switch(ne.buffer.dtype){case Ui:case py:me=Ui;break;case Vi:case du:me=Vi;break;case pi:case mu:me=pi;break;default:m.raise("unsupported type for element array")}ne.buffer.dtype=me}ne.type=me,m(me!==pi||!!h.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var X=xe;X<0&&(X=ne.buffer.byteLength,me===Vi?X>>=1:me===pi&&(X>>=2)),ne.vertCount=X;var H=te;if(te<0){H=wr;var Se=ne.buffer.dimension;Se===1&&(H=dy),Se===2&&(H=my),Se===3&&(H=wr)}ne.primType=H}function ue(ne){M.elementsCount--,m(ne.buffer!==null,"must not double destroy elements"),delete W[ne.id],ne.buffer.destroy(),ne.buffer=null}function J(ne,k){var N=_.create(null,ys,!0),te=new K(N._buffer);M.elementsCount++;function xe(Z){if(!Z)N(),te.primType=wr,te.vertCount=0,te.type=Ui;else if(typeof Z=="number")N(Z),te.primType=wr,te.vertCount=Z|0,te.type=Ui;else{var ge=null,me=gy,Le=-1,X=-1,H=0,Se=0;Array.isArray(Z)||n(Z)||yn(Z)?ge=Z:(m.type(Z,"object","invalid arguments for elements"),"data"in Z&&(ge=Z.data,m(Array.isArray(ge)||n(ge)||yn(ge),"invalid data for element buffer")),"usage"in Z&&(m.parameter(Z.usage,Vo,"invalid element buffer usage"),me=Vo[Z.usage]),"primitive"in Z&&(m.parameter(Z.primitive,Yn,"invalid element buffer primitive"),Le=Yn[Z.primitive]),"count"in Z&&(m(typeof Z.count=="number"&&Z.count>=0,"invalid vertex count for elements"),X=Z.count|0),"type"in Z&&(m.parameter(Z.type,B,"invalid buffer type"),Se=B[Z.type]),"length"in Z?H=Z.length|0:(H=X,Se===Vi||Se===du?H*=2:(Se===pi||Se===mu)&&(H*=4))),re(te,ge,me,Le,X,H,Se)}return xe}return xe(ne),xe._reglType="elements",xe._elements=te,xe.subdata=function(Z,ge){return N.subdata(Z,ge),xe},xe.destroy=function(){ue(te)},xe}return{create:J,createStream:ie,destroyStream:oe,getElements:function(ne){return typeof ne=="function"&&ne._elements instanceof K?ne._elements:null},clear:function(){rn(W).forEach(ue)}}}var pu=new Float32Array(1),xy=new Uint32Array(pu.buffer),by=5123;function vu(a){for(var h=gt.allocType(by,a.length),_=0;_<a.length;++_)if(isNaN(a[_]))h[_]=65535;else if(a[_]===1/0)h[_]=31744;else if(a[_]===-1/0)h[_]=64512;else{pu[0]=a[_];var M=xy[0],W=M>>>31<<15,R=(M<<1>>>24)-127,B=M>>13&1023;if(R<-24)h[_]=W;else if(R<-14){var K=-14-R;h[_]=W+(B+1024>>K)}else R>15?h[_]=W+31744:h[_]=W+(R+15<<10)+B}return h}function pt(a){return Array.isArray(a)||n(a)}var gu=function(a){return!(a&a-1)&&!!a},_y=34467,An=3553,xs=34067,Ho=34069,vi=6408,bs=6406,Wo=6407,Ar=6409,Xo=6410,yu=32854,_s=32855,xu=36194,Sy=32819,Ty=32820,wy=33635,Ay=34042,Ss=6402,jo=34041,Ts=35904,ws=35906,$i=36193,As=33776,Es=33777,Cs=33778,Ps=33779,bu=35986,_u=35987,Su=34798,Tu=35840,wu=35841,Au=35842,Eu=35843,Cu=36196,Hi=5121,ks=5123,Is=5125,Er=5126,Ey=10242,Cy=10243,Py=10497,Ls=33071,ky=33648,Iy=10240,Ly=10241,Ds=9728,Dy=9729,Fs=9984,Pu=9985,ku=9986,zs=9987,Fy=33170,qo=4352,zy=4353,Ry=4354,My=34046,Oy=3317,Ny=37440,Gy=37441,By=37443,Iu=37444,Cr=33984,Uy=[Fs,ku,Pu,zs],Yo=[0,Ar,Xo,Wo,vi],ln={};ln[Ar]=ln[bs]=ln[Ss]=1,ln[jo]=ln[Xo]=2,ln[Wo]=ln[Ts]=3,ln[vi]=ln[ws]=4;function Wi(a){return"[object "+a+"]"}var Lu=Wi("HTMLCanvasElement"),Du=Wi("OffscreenCanvas"),Fu=Wi("CanvasRenderingContext2D"),zu=Wi("ImageBitmap"),Ru=Wi("HTMLImageElement"),Mu=Wi("HTMLVideoElement"),Vy=Object.keys(ms).concat([Lu,Du,Fu,zu,Ru,Mu]),Xi=[];Xi[Hi]=1,Xi[Er]=4,Xi[$i]=2,Xi[ks]=2,Xi[Is]=4;var Gt=[];Gt[yu]=2,Gt[_s]=2,Gt[xu]=2,Gt[jo]=4,Gt[As]=.5,Gt[Es]=.5,Gt[Cs]=1,Gt[Ps]=1,Gt[bu]=.5,Gt[_u]=1,Gt[Su]=1,Gt[Tu]=.5,Gt[wu]=.25,Gt[Au]=.5,Gt[Eu]=.25,Gt[Cu]=.5;function Ou(a){return Array.isArray(a)&&(a.length===0||typeof a[0]=="number")}function Nu(a){if(!Array.isArray(a))return!1;var h=a.length;return!(h===0||!pt(a[0]))}function gi(a){return Object.prototype.toString.call(a)}function Gu(a){return gi(a)===Lu}function Bu(a){return gi(a)===Du}function $y(a){return gi(a)===Fu}function Hy(a){return gi(a)===zu}function Wy(a){return gi(a)===Ru}function Xy(a){return gi(a)===Mu}function Rs(a){if(!a)return!1;var h=gi(a);return Vy.indexOf(h)>=0?!0:Ou(a)||Nu(a)||yn(a)}function Uu(a){return ms[Object.prototype.toString.call(a)]|0}function jy(a,h){var _=h.length;switch(a.type){case Hi:case ks:case Is:case Er:var M=gt.allocType(a.type,_);M.set(h),a.data=M;break;case $i:a.data=vu(h);break;default:m.raise("unsupported texture type, must specify a typed array")}}function Vu(a,h){return gt.allocType(a.type===$i?Er:a.type,h)}function $u(a,h){a.type===$i?(a.data=vu(h),gt.freeType(h)):a.data=h}function qy(a,h,_,M,W,R){for(var B=a.width,K=a.height,Q=a.channels,ie=B*K*Q,oe=Vu(a,ie),re=0,ue=0;ue<K;++ue)for(var J=0;J<B;++J)for(var ne=0;ne<Q;++ne)oe[re++]=h[_*J+M*ue+W*ne+R];$u(a,oe)}function Zo(a,h,_,M,W,R){var B;if(typeof Gt[a]<"u"?B=Gt[a]:B=ln[a]*Xi[h],R&&(B*=6),W){for(var K=0,Q=_;Q>=1;)K+=B*Q*Q,Q/=2;return K}else return B*_*M}function Yy(a,h,_,M,W,R,B){var K={"don't care":qo,"dont care":qo,nice:Ry,fast:zy},Q={repeat:Py,clamp:Ls,mirror:ky},ie={nearest:Ds,linear:Dy},oe=i({mipmap:zs,"nearest mipmap nearest":Fs,"linear mipmap nearest":Pu,"nearest mipmap linear":ku,"linear mipmap linear":zs},ie),re={none:0,browser:Iu},ue={uint8:Hi,rgba4:Sy,rgb565:wy,"rgb5 a1":Ty},J={alpha:bs,luminance:Ar,"luminance alpha":Xo,rgb:Wo,rgba:vi,rgba4:yu,"rgb5 a1":_s,rgb565:xu},ne={};h.ext_srgb&&(J.srgb=Ts,J.srgba=ws),h.oes_texture_float&&(ue.float32=ue.float=Er),h.oes_texture_half_float&&(ue.float16=ue["half float"]=$i),h.webgl_depth_texture&&(i(J,{depth:Ss,"depth stencil":jo}),i(ue,{uint16:ks,uint32:Is,"depth stencil":Ay})),h.webgl_compressed_texture_s3tc&&i(ne,{"rgb s3tc dxt1":As,"rgba s3tc dxt1":Es,"rgba s3tc dxt3":Cs,"rgba s3tc dxt5":Ps}),h.webgl_compressed_texture_atc&&i(ne,{"rgb atc":bu,"rgba atc explicit alpha":_u,"rgba atc interpolated alpha":Su}),h.webgl_compressed_texture_pvrtc&&i(ne,{"rgb pvrtc 4bppv1":Tu,"rgb pvrtc 2bppv1":wu,"rgba pvrtc 4bppv1":Au,"rgba pvrtc 2bppv1":Eu}),h.webgl_compressed_texture_etc1&&(ne["rgb etc1"]=Cu);var k=Array.prototype.slice.call(a.getParameter(_y));Object.keys(ne).forEach(function(x){var O=ne[x];k.indexOf(O)>=0&&(J[x]=O)});var N=Object.keys(J);_.textureFormats=N;var te=[];Object.keys(J).forEach(function(x){var O=J[x];te[O]=x});var xe=[];Object.keys(ue).forEach(function(x){var O=ue[x];xe[O]=x});var Z=[];Object.keys(ie).forEach(function(x){var O=ie[x];Z[O]=x});var ge=[];Object.keys(oe).forEach(function(x){var O=oe[x];ge[O]=x});var me=[];Object.keys(Q).forEach(function(x){var O=Q[x];me[O]=x});var Le=N.reduce(function(x,O){var z=J[O];return z===Ar||z===bs||z===Ar||z===Xo||z===Ss||z===jo||h.ext_srgb&&(z===Ts||z===ws)?x[z]=z:z===_s||O.indexOf("rgba")>=0?x[z]=vi:x[z]=Wo,x},{});function X(){this.internalformat=vi,this.format=vi,this.type=Hi,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Iu,this.width=0,this.height=0,this.channels=0}function H(x,O){x.internalformat=O.internalformat,x.format=O.format,x.type=O.type,x.compressed=O.compressed,x.premultiplyAlpha=O.premultiplyAlpha,x.flipY=O.flipY,x.unpackAlignment=O.unpackAlignment,x.colorSpace=O.colorSpace,x.width=O.width,x.height=O.height,x.channels=O.channels}function Se(x,O){if(!(typeof O!="object"||!O)){if("premultiplyAlpha"in O&&(m.type(O.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),x.premultiplyAlpha=O.premultiplyAlpha),"flipY"in O&&(m.type(O.flipY,"boolean","invalid texture flip"),x.flipY=O.flipY),"alignment"in O&&(m.oneOf(O.alignment,[1,2,4,8],"invalid texture unpack alignment"),x.unpackAlignment=O.alignment),"colorSpace"in O&&(m.parameter(O.colorSpace,re,"invalid colorSpace"),x.colorSpace=re[O.colorSpace]),"type"in O){var z=O.type;m(h.oes_texture_float||!(z==="float"||z==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),m(h.oes_texture_half_float||!(z==="half float"||z==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),m(h.webgl_depth_texture||!(z==="uint16"||z==="uint32"||z==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),m.parameter(z,ue,"invalid texture type"),x.type=ue[z]}var _e=x.width,Ke=x.height,p=x.channels,c=!1;"shape"in O?(m(Array.isArray(O.shape)&&O.shape.length>=2,"shape must be an array"),_e=O.shape[0],Ke=O.shape[1],O.shape.length===3&&(p=O.shape[2],m(p>0&&p<=4,"invalid number of channels"),c=!0),m(_e>=0&&_e<=_.maxTextureSize,"invalid width"),m(Ke>=0&&Ke<=_.maxTextureSize,"invalid height")):("radius"in O&&(_e=Ke=O.radius,m(_e>=0&&_e<=_.maxTextureSize,"invalid radius")),"width"in O&&(_e=O.width,m(_e>=0&&_e<=_.maxTextureSize,"invalid width")),"height"in O&&(Ke=O.height,m(Ke>=0&&Ke<=_.maxTextureSize,"invalid height")),"channels"in O&&(p=O.channels,m(p>0&&p<=4,"invalid number of channels"),c=!0)),x.width=_e|0,x.height=Ke|0,x.channels=p|0;var T=!1;if("format"in O){var C=O.format;m(h.webgl_depth_texture||!(C==="depth"||C==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),m.parameter(C,J,"invalid texture format");var I=x.internalformat=J[C];x.format=Le[I],C in ue&&("type"in O||(x.type=ue[C])),C in ne&&(x.compressed=!0),T=!0}!c&&T?x.channels=ln[x.format]:c&&!T?x.channels!==Yo[x.format]&&(x.format=x.internalformat=Yo[x.channels]):T&&c&&m(x.channels===ln[x.format],"number of channels inconsistent with specified format")}}function ce(x){a.pixelStorei(Ny,x.flipY),a.pixelStorei(Gy,x.premultiplyAlpha),a.pixelStorei(By,x.colorSpace),a.pixelStorei(Oy,x.unpackAlignment)}function ee(){X.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function he(x,O){var z=null;if(Rs(O)?z=O:O&&(m.type(O,"object","invalid pixel data type"),Se(x,O),"x"in O&&(x.xOffset=O.x|0),"y"in O&&(x.yOffset=O.y|0),Rs(O.data)&&(z=O.data)),m(!x.compressed||z instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),O.copy){m(!z,"can not specify copy and data field for the same texture");var _e=W.viewportWidth,Ke=W.viewportHeight;x.width=x.width||_e-x.xOffset,x.height=x.height||Ke-x.yOffset,x.needsCopy=!0,m(x.xOffset>=0&&x.xOffset<_e&&x.yOffset>=0&&x.yOffset<Ke&&x.width>0&&x.width<=_e&&x.height>0&&x.height<=Ke,"copy texture read out of bounds")}else if(!z)x.width=x.width||1,x.height=x.height||1,x.channels=x.channels||4;else if(n(z))x.channels=x.channels||4,x.data=z,!("type"in O)&&x.type===Hi&&(x.type=Uu(z));else if(Ou(z))x.channels=x.channels||4,jy(x,z),x.alignment=1,x.needsFree=!0;else if(yn(z)){var p=z.data;!Array.isArray(p)&&x.type===Hi&&(x.type=Uu(p));var c=z.shape,T=z.stride,C,I,A,w,E,v;c.length===3?(A=c[2],v=T[2]):(m(c.length===2,"invalid ndarray pixel data, must be 2 or 3D"),A=1,v=1),C=c[0],I=c[1],w=T[0],E=T[1],x.alignment=1,x.width=C,x.height=I,x.channels=A,x.format=x.internalformat=Yo[A],x.needsFree=!0,qy(x,p,w,E,v,z.offset)}else if(Gu(z)||Bu(z)||$y(z))Gu(z)||Bu(z)?x.element=z:x.element=z.canvas,x.width=x.element.width,x.height=x.element.height,x.channels=4;else if(Hy(z))x.element=z,x.width=z.width,x.height=z.height,x.channels=4;else if(Wy(z))x.element=z,x.width=z.naturalWidth,x.height=z.naturalHeight,x.channels=4;else if(Xy(z))x.element=z,x.width=z.videoWidth,x.height=z.videoHeight,x.channels=4;else if(Nu(z)){var b=x.width||z[0].length,g=x.height||z.length,F=x.channels;pt(z[0][0])?F=F||z[0][0].length:F=F||1;for(var L=Uo.shape(z),$=1,j=0;j<L.length;++j)$*=L[j];var le=Vu(x,$);Uo.flatten(z,L,"",le),$u(x,le),x.alignment=1,x.width=b,x.height=g,x.channels=F,x.format=x.internalformat=Yo[F],x.needsFree=!0}x.type===Er?m(_.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):x.type===$i&&m(_.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function de(x,O,z){var _e=x.element,Ke=x.data,p=x.internalformat,c=x.format,T=x.type,C=x.width,I=x.height;ce(x),_e?a.texImage2D(O,z,c,c,T,_e):x.compressed?a.compressedTexImage2D(O,z,p,C,I,0,Ke):x.needsCopy?(M(),a.copyTexImage2D(O,z,c,x.xOffset,x.yOffset,C,I,0)):a.texImage2D(O,z,c,C,I,0,c,T,Ke||null)}function He(x,O,z,_e,Ke){var p=x.element,c=x.data,T=x.internalformat,C=x.format,I=x.type,A=x.width,w=x.height;ce(x),p?a.texSubImage2D(O,Ke,z,_e,C,I,p):x.compressed?a.compressedTexSubImage2D(O,Ke,z,_e,T,A,w,c):x.needsCopy?(M(),a.copyTexSubImage2D(O,Ke,z,_e,x.xOffset,x.yOffset,A,w)):a.texSubImage2D(O,Ke,z,_e,A,w,C,I,c)}var Ue=[];function pe(){return Ue.pop()||new ee}function ye(x){x.needsFree&&gt.freeType(x.data),ee.call(x),Ue.push(x)}function Re(){X.call(this),this.genMipmaps=!1,this.mipmapHint=qo,this.mipmask=0,this.images=Array(16)}function We(x,O,z){var _e=x.images[0]=pe();x.mipmask=1,_e.width=x.width=O,_e.height=x.height=z,_e.channels=x.channels=4}function Je(x,O){var z=null;if(Rs(O))z=x.images[0]=pe(),H(z,x),he(z,O),x.mipmask=1;else if(Se(x,O),Array.isArray(O.mipmap))for(var _e=O.mipmap,Ke=0;Ke<_e.length;++Ke)z=x.images[Ke]=pe(),H(z,x),z.width>>=Ke,z.height>>=Ke,he(z,_e[Ke]),x.mipmask|=1<<Ke;else z=x.images[0]=pe(),H(z,x),he(z,O),x.mipmask=1;H(x,x.images[0]),x.compressed&&(x.internalformat===As||x.internalformat===Es||x.internalformat===Cs||x.internalformat===Ps)&&m(x.width%4===0&&x.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function vt(x,O){for(var z=x.images,_e=0;_e<z.length;++_e){if(!z[_e])return;de(z[_e],O,_e)}}var yt=[];function tt(){var x=yt.pop()||new Re;X.call(x),x.mipmask=0;for(var O=0;O<16;++O)x.images[O]=null;return x}function Et(x){for(var O=x.images,z=0;z<O.length;++z)O[z]&&ye(O[z]),O[z]=null;yt.push(x)}function ht(){this.minFilter=Ds,this.magFilter=Ds,this.wrapS=Ls,this.wrapT=Ls,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=qo}function Tt(x,O){if("min"in O){var z=O.min;m.parameter(z,oe),x.minFilter=oe[z],Uy.indexOf(x.minFilter)>=0&&!("faces"in O)&&(x.genMipmaps=!0)}if("mag"in O){var _e=O.mag;m.parameter(_e,ie),x.magFilter=ie[_e]}var Ke=x.wrapS,p=x.wrapT;if("wrap"in O){var c=O.wrap;typeof c=="string"?(m.parameter(c,Q),Ke=p=Q[c]):Array.isArray(c)&&(m.parameter(c[0],Q),m.parameter(c[1],Q),Ke=Q[c[0]],p=Q[c[1]])}else{if("wrapS"in O){var T=O.wrapS;m.parameter(T,Q),Ke=Q[T]}if("wrapT"in O){var C=O.wrapT;m.parameter(C,Q),p=Q[C]}}if(x.wrapS=Ke,x.wrapT=p,"anisotropic"in O){var I=O.anisotropic;m(typeof I=="number"&&I>=1&&I<=_.maxAnisotropic,"aniso samples must be between 1 and "),x.anisotropic=O.anisotropic}if("mipmap"in O){var A=!1;switch(typeof O.mipmap){case"string":m.parameter(O.mipmap,K,"invalid mipmap hint"),x.mipmapHint=K[O.mipmap],x.genMipmaps=!0,A=!0;break;case"boolean":A=x.genMipmaps=O.mipmap;break;case"object":m(Array.isArray(O.mipmap),"invalid mipmap type"),x.genMipmaps=!1,A=!0;break;default:m.raise("invalid mipmap type")}A&&!("min"in O)&&(x.minFilter=Fs)}}function Ct(x,O){a.texParameteri(O,Ly,x.minFilter),a.texParameteri(O,Iy,x.magFilter),a.texParameteri(O,Ey,x.wrapS),a.texParameteri(O,Cy,x.wrapT),h.ext_texture_filter_anisotropic&&a.texParameteri(O,My,x.anisotropic),x.genMipmaps&&(a.hint(Fy,x.mipmapHint),a.generateMipmap(O))}var Pt=0,zt={},Bt=_.maxTextureUnits,xt=Array(Bt).map(function(){return null});function Ye(x){X.call(this),this.mipmask=0,this.internalformat=vi,this.id=Pt++,this.refCount=1,this.target=x,this.texture=a.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new ht,B.profile&&(this.stats={size:0})}function Ut(x){a.activeTexture(Cr),a.bindTexture(x.target,x.texture)}function ot(){var x=xt[0];x?a.bindTexture(x.target,x.texture):a.bindTexture(An,null)}function Fe(x){var O=x.texture;m(O,"must not double destroy texture");var z=x.unit,_e=x.target;z>=0&&(a.activeTexture(Cr+z),a.bindTexture(_e,null),xt[z]=null),a.deleteTexture(O),x.texture=null,x.params=null,x.pixels=null,x.refCount=0,delete zt[x.id],R.textureCount--}i(Ye.prototype,{bind:function(){var x=this;x.bindCount+=1;var O=x.unit;if(O<0){for(var z=0;z<Bt;++z){var _e=xt[z];if(_e){if(_e.bindCount>0)continue;_e.unit=-1}xt[z]=x,O=z;break}O>=Bt&&m.raise("insufficient number of texture units"),B.profile&&R.maxTextureUnits<O+1&&(R.maxTextureUnits=O+1),x.unit=O,a.activeTexture(Cr+O),a.bindTexture(x.target,x.texture)}return O},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&Fe(this)}});function et(x,O){var z=new Ye(An);zt[z.id]=z,R.textureCount++;function _e(c,T){var C=z.texInfo;ht.call(C);var I=tt();return typeof c=="number"?typeof T=="number"?We(I,c|0,T|0):We(I,c|0,c|0):c?(m.type(c,"object","invalid arguments to regl.texture"),Tt(C,c),Je(I,c)):We(I,1,1),C.genMipmaps&&(I.mipmask=(I.width<<1)-1),z.mipmask=I.mipmask,H(z,I),m.texture2D(C,I,_),z.internalformat=I.internalformat,_e.width=I.width,_e.height=I.height,Ut(z),vt(I,An),Ct(C,An),ot(),Et(I),B.profile&&(z.stats.size=Zo(z.internalformat,z.type,I.width,I.height,C.genMipmaps,!1)),_e.format=te[z.internalformat],_e.type=xe[z.type],_e.mag=Z[C.magFilter],_e.min=ge[C.minFilter],_e.wrapS=me[C.wrapS],_e.wrapT=me[C.wrapT],_e}function Ke(c,T,C,I){m(!!c,"must specify image data");var A=T|0,w=C|0,E=I|0,v=pe();return H(v,z),v.width=0,v.height=0,he(v,c),v.width=v.width||(z.width>>E)-A,v.height=v.height||(z.height>>E)-w,m(z.type===v.type&&z.format===v.format&&z.internalformat===v.internalformat,"incompatible format for texture.subimage"),m(A>=0&&w>=0&&A+v.width<=z.width&&w+v.height<=z.height,"texture.subimage write out of bounds"),m(z.mipmask&1<<E,"missing mipmap data"),m(v.data||v.element||v.needsCopy,"missing image data"),Ut(z),He(v,An,A,w,E),ot(),ye(v),_e}function p(c,T){var C=c|0,I=T|0||C;if(C===z.width&&I===z.height)return _e;_e.width=z.width=C,_e.height=z.height=I,Ut(z);for(var A=0;z.mipmask>>A;++A){var w=C>>A,E=I>>A;if(!w||!E)break;a.texImage2D(An,A,z.format,w,E,0,z.format,z.type,null)}return ot(),B.profile&&(z.stats.size=Zo(z.internalformat,z.type,C,I,!1,!1)),_e}return _e(x,O),_e.subimage=Ke,_e.resize=p,_e._reglType="texture2d",_e._texture=z,B.profile&&(_e.stats=z.stats),_e.destroy=function(){z.decRef()},_e}function it(x,O,z,_e,Ke,p){var c=new Ye(xs);zt[c.id]=c,R.cubeCount++;var T=new Array(6);function C(w,E,v,b,g,F){var L,$=c.texInfo;for(ht.call($),L=0;L<6;++L)T[L]=tt();if(typeof w=="number"||!w){var j=w|0||1;for(L=0;L<6;++L)We(T[L],j,j)}else if(typeof w=="object")if(E)Je(T[0],w),Je(T[1],E),Je(T[2],v),Je(T[3],b),Je(T[4],g),Je(T[5],F);else if(Tt($,w),Se(c,w),"faces"in w){var le=w.faces;for(m(Array.isArray(le)&&le.length===6,"cube faces must be a length 6 array"),L=0;L<6;++L)m(typeof le[L]=="object"&&!!le[L],"invalid input for cube map face"),H(T[L],c),Je(T[L],le[L])}else for(L=0;L<6;++L)Je(T[L],w);else m.raise("invalid arguments to cube map");for(H(c,T[0]),m.optional(function(){_.npotTextureCube||m(gu(c.width)&&gu(c.height),"your browser does not support non power or two texture dimensions")}),$.genMipmaps?c.mipmask=(T[0].width<<1)-1:c.mipmask=T[0].mipmask,m.textureCube(c,$,T,_),c.internalformat=T[0].internalformat,C.width=T[0].width,C.height=T[0].height,Ut(c),L=0;L<6;++L)vt(T[L],Ho+L);for(Ct($,xs),ot(),B.profile&&(c.stats.size=Zo(c.internalformat,c.type,C.width,C.height,$.genMipmaps,!0)),C.format=te[c.internalformat],C.type=xe[c.type],C.mag=Z[$.magFilter],C.min=ge[$.minFilter],C.wrapS=me[$.wrapS],C.wrapT=me[$.wrapT],L=0;L<6;++L)Et(T[L]);return C}function I(w,E,v,b,g){m(!!E,"must specify image data"),m(typeof w=="number"&&w===(w|0)&&w>=0&&w<6,"invalid face");var F=v|0,L=b|0,$=g|0,j=pe();return H(j,c),j.width=0,j.height=0,he(j,E),j.width=j.width||(c.width>>$)-F,j.height=j.height||(c.height>>$)-L,m(c.type===j.type&&c.format===j.format&&c.internalformat===j.internalformat,"incompatible format for texture.subimage"),m(F>=0&&L>=0&&F+j.width<=c.width&&L+j.height<=c.height,"texture.subimage write out of bounds"),m(c.mipmask&1<<$,"missing mipmap data"),m(j.data||j.element||j.needsCopy,"missing image data"),Ut(c),He(j,Ho+w,F,L,$),ot(),ye(j),C}function A(w){var E=w|0;if(E!==c.width){C.width=c.width=E,C.height=c.height=E,Ut(c);for(var v=0;v<6;++v)for(var b=0;c.mipmask>>b;++b)a.texImage2D(Ho+v,b,c.format,E>>b,E>>b,0,c.format,c.type,null);return ot(),B.profile&&(c.stats.size=Zo(c.internalformat,c.type,C.width,C.height,!1,!0)),C}}return C(x,O,z,_e,Ke,p),C.subimage=I,C.resize=A,C._reglType="textureCube",C._texture=c,B.profile&&(C.stats=c.stats),C.destroy=function(){c.decRef()},C}function bt(){for(var x=0;x<Bt;++x)a.activeTexture(Cr+x),a.bindTexture(An,null),xt[x]=null;rn(zt).forEach(Fe),R.cubeCount=0,R.textureCount=0}B.profile&&(R.getTotalTextureSize=function(){var x=0;return Object.keys(zt).forEach(function(O){x+=zt[O].stats.size}),x});function Cn(){for(var x=0;x<Bt;++x){var O=xt[x];O&&(O.bindCount=0,O.unit=-1,xt[x]=null)}rn(zt).forEach(function(z){z.texture=a.createTexture(),a.bindTexture(z.target,z.texture);for(var _e=0;_e<32;++_e)if((z.mipmask&1<<_e)!==0)if(z.target===An)a.texImage2D(An,_e,z.internalformat,z.width>>_e,z.height>>_e,0,z.internalformat,z.type,null);else for(var Ke=0;Ke<6;++Ke)a.texImage2D(Ho+Ke,_e,z.internalformat,z.width>>_e,z.height>>_e,0,z.internalformat,z.type,null);Ct(z.texInfo,z.target)})}function wi(){for(var x=0;x<Bt;++x){var O=xt[x];O&&(O.bindCount=0,O.unit=-1,xt[x]=null),a.activeTexture(Cr+x),a.bindTexture(An,null),a.bindTexture(xs,null)}}return{create2D:et,createCube:it,clear:bt,getTexture:function(x){return null},restore:Cn,refresh:wi}}var Zn=36161,Qo=32854,Hu=32855,Wu=36194,Xu=33189,ju=36168,qu=34041,Yu=35907,Zu=34836,Qu=34842,Ku=34843,xn=[];xn[Qo]=2,xn[Hu]=2,xn[Wu]=2,xn[Xu]=2,xn[ju]=1,xn[qu]=4,xn[Yu]=4,xn[Zu]=16,xn[Qu]=8,xn[Ku]=6;function Ju(a,h,_){return xn[a]*h*_}var Zy=function(a,h,_,M,W){var R={rgba4:Qo,rgb565:Wu,"rgb5 a1":Hu,depth:Xu,stencil:ju,"depth stencil":qu};h.ext_srgb&&(R.srgba=Yu),h.ext_color_buffer_half_float&&(R.rgba16f=Qu,R.rgb16f=Ku),h.webgl_color_buffer_float&&(R.rgba32f=Zu);var B=[];Object.keys(R).forEach(function(J){var ne=R[J];B[ne]=J});var K=0,Q={};function ie(J){this.id=K++,this.refCount=1,this.renderbuffer=J,this.format=Qo,this.width=0,this.height=0,W.profile&&(this.stats={size:0})}ie.prototype.decRef=function(){--this.refCount<=0&&oe(this)};function oe(J){var ne=J.renderbuffer;m(ne,"must not double destroy renderbuffer"),a.bindRenderbuffer(Zn,null),a.deleteRenderbuffer(ne),J.renderbuffer=null,J.refCount=0,delete Q[J.id],M.renderbufferCount--}function re(J,ne){var k=new ie(a.createRenderbuffer());Q[k.id]=k,M.renderbufferCount++;function N(xe,Z){var ge=0,me=0,Le=Qo;if(typeof xe=="object"&&xe){var X=xe;if("shape"in X){var H=X.shape;m(Array.isArray(H)&&H.length>=2,"invalid renderbuffer shape"),ge=H[0]|0,me=H[1]|0}else"radius"in X&&(ge=me=X.radius|0),"width"in X&&(ge=X.width|0),"height"in X&&(me=X.height|0);"format"in X&&(m.parameter(X.format,R,"invalid renderbuffer format"),Le=R[X.format])}else typeof xe=="number"?(ge=xe|0,typeof Z=="number"?me=Z|0:me=ge):xe?m.raise("invalid arguments to renderbuffer constructor"):ge=me=1;if(m(ge>0&&me>0&&ge<=_.maxRenderbufferSize&&me<=_.maxRenderbufferSize,"invalid renderbuffer size"),!(ge===k.width&&me===k.height&&Le===k.format))return N.width=k.width=ge,N.height=k.height=me,k.format=Le,a.bindRenderbuffer(Zn,k.renderbuffer),a.renderbufferStorage(Zn,Le,ge,me),m(a.getError()===0,"invalid render buffer format"),W.profile&&(k.stats.size=Ju(k.format,k.width,k.height)),N.format=B[k.format],N}function te(xe,Z){var ge=xe|0,me=Z|0||ge;return ge===k.width&&me===k.height||(m(ge>0&&me>0&&ge<=_.maxRenderbufferSize&&me<=_.maxRenderbufferSize,"invalid renderbuffer size"),N.width=k.width=ge,N.height=k.height=me,a.bindRenderbuffer(Zn,k.renderbuffer),a.renderbufferStorage(Zn,k.format,ge,me),m(a.getError()===0,"invalid render buffer format"),W.profile&&(k.stats.size=Ju(k.format,k.width,k.height))),N}return N(J,ne),N.resize=te,N._reglType="renderbuffer",N._renderbuffer=k,W.profile&&(N.stats=k.stats),N.destroy=function(){k.decRef()},N}W.profile&&(M.getTotalRenderbufferSize=function(){var J=0;return Object.keys(Q).forEach(function(ne){J+=Q[ne].stats.size}),J});function ue(){rn(Q).forEach(function(J){J.renderbuffer=a.createRenderbuffer(),a.bindRenderbuffer(Zn,J.renderbuffer),a.renderbufferStorage(Zn,J.format,J.width,J.height)}),a.bindRenderbuffer(Zn,null)}return{create:re,clear:function(){rn(Q).forEach(oe)},restore:ue}},Gn=36160,Ms=36161,yi=3553,Ko=34069,ec=36064,tc=36096,nc=36128,ic=33306,rc=36053,Qy=36054,Ky=36055,Jy=36057,ex=36061,tx=36193,nx=5121,ix=5126,oc=6407,ac=6408,rx=6402,ox=[oc,ac],Os=[];Os[ac]=4,Os[oc]=3;var Jo=[];Jo[nx]=1,Jo[ix]=4,Jo[tx]=2;var ax=32854,sx=32855,fx=36194,lx=33189,ux=36168,sc=34041,cx=35907,hx=34836,dx=34842,mx=34843,px=[ax,sx,fx,cx,dx,mx,hx],ji={};ji[rc]="complete",ji[Qy]="incomplete attachment",ji[Jy]="incomplete dimensions",ji[Ky]="incomplete, missing attachment",ji[ex]="unsupported";function vx(a,h,_,M,W,R){var B={cur:null,next:null,dirty:!1,setFBO:null},K=["rgba"],Q=["rgba4","rgb565","rgb5 a1"];h.ext_srgb&&Q.push("srgba"),h.ext_color_buffer_half_float&&Q.push("rgba16f","rgb16f"),h.webgl_color_buffer_float&&Q.push("rgba32f");var ie=["uint8"];h.oes_texture_half_float&&ie.push("half float","float16"),h.oes_texture_float&&ie.push("float","float32");function oe(ee,he,de){this.target=ee,this.texture=he,this.renderbuffer=de;var He=0,Ue=0;he?(He=he.width,Ue=he.height):de&&(He=de.width,Ue=de.height),this.width=He,this.height=Ue}function re(ee){ee&&(ee.texture&&ee.texture._texture.decRef(),ee.renderbuffer&&ee.renderbuffer._renderbuffer.decRef())}function ue(ee,he,de){if(ee)if(ee.texture){var He=ee.texture._texture,Ue=Math.max(1,He.width),pe=Math.max(1,He.height);m(Ue===he&&pe===de,"inconsistent width/height for supplied texture"),He.refCount+=1}else{var ye=ee.renderbuffer._renderbuffer;m(ye.width===he&&ye.height===de,"inconsistent width/height for renderbuffer"),ye.refCount+=1}}function J(ee,he){he&&(he.texture?a.framebufferTexture2D(Gn,ee,he.target,he.texture._texture.texture,0):a.framebufferRenderbuffer(Gn,ee,Ms,he.renderbuffer._renderbuffer.renderbuffer))}function ne(ee){var he=yi,de=null,He=null,Ue=ee;typeof ee=="object"&&(Ue=ee.data,"target"in ee&&(he=ee.target|0)),m.type(Ue,"function","invalid attachment data");var pe=Ue._reglType;return pe==="texture2d"?(de=Ue,m(he===yi)):pe==="textureCube"?(de=Ue,m(he>=Ko&&he<Ko+6,"invalid cube map target")):pe==="renderbuffer"?(He=Ue,he=Ms):m.raise("invalid regl object for attachment"),new oe(he,de,He)}function k(ee,he,de,He,Ue){if(de){var pe=M.create2D({width:ee,height:he,format:He,type:Ue});return pe._texture.refCount=0,new oe(yi,pe,null)}else{var ye=W.create({width:ee,height:he,format:He});return ye._renderbuffer.refCount=0,new oe(Ms,null,ye)}}function N(ee){return ee&&(ee.texture||ee.renderbuffer)}function te(ee,he,de){ee&&(ee.texture?ee.texture.resize(he,de):ee.renderbuffer&&ee.renderbuffer.resize(he,de),ee.width=he,ee.height=de)}var xe=0,Z={};function ge(){this.id=xe++,Z[this.id]=this,this.framebuffer=a.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function me(ee){ee.colorAttachments.forEach(re),re(ee.depthAttachment),re(ee.stencilAttachment),re(ee.depthStencilAttachment)}function Le(ee){var he=ee.framebuffer;m(he,"must not double destroy framebuffer"),a.deleteFramebuffer(he),ee.framebuffer=null,R.framebufferCount--,delete Z[ee.id]}function X(ee){var he;a.bindFramebuffer(Gn,ee.framebuffer);var de=ee.colorAttachments;for(he=0;he<de.length;++he)J(ec+he,de[he]);for(he=de.length;he<_.maxColorAttachments;++he)a.framebufferTexture2D(Gn,ec+he,yi,null,0);a.framebufferTexture2D(Gn,ic,yi,null,0),a.framebufferTexture2D(Gn,tc,yi,null,0),a.framebufferTexture2D(Gn,nc,yi,null,0),J(tc,ee.depthAttachment),J(nc,ee.stencilAttachment),J(ic,ee.depthStencilAttachment);var He=a.checkFramebufferStatus(Gn);!a.isContextLost()&&He!==rc&&m.raise("framebuffer configuration not supported, status = "+ji[He]),a.bindFramebuffer(Gn,B.next?B.next.framebuffer:null),B.cur=B.next,a.getError()}function H(ee,he){var de=new ge;R.framebufferCount++;function He(pe,ye){var Re;m(B.next!==de,"can not update framebuffer which is currently in use");var We=0,Je=0,vt=!0,yt=!0,tt=null,Et=!0,ht="rgba",Tt="uint8",Ct=1,Pt=null,zt=null,Bt=null,xt=!1;if(typeof pe=="number")We=pe|0,Je=ye|0||We;else if(!pe)We=Je=1;else{m.type(pe,"object","invalid arguments for framebuffer");var Ye=pe;if("shape"in Ye){var Ut=Ye.shape;m(Array.isArray(Ut)&&Ut.length>=2,"invalid shape for framebuffer"),We=Ut[0],Je=Ut[1]}else"radius"in Ye&&(We=Je=Ye.radius),"width"in Ye&&(We=Ye.width),"height"in Ye&&(Je=Ye.height);("color"in Ye||"colors"in Ye)&&(tt=Ye.color||Ye.colors,Array.isArray(tt)&&m(tt.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),tt||("colorCount"in Ye&&(Ct=Ye.colorCount|0,m(Ct>0,"invalid color buffer count")),"colorTexture"in Ye&&(Et=!!Ye.colorTexture,ht="rgba4"),"colorType"in Ye&&(Tt=Ye.colorType,Et?(m(h.oes_texture_float||!(Tt==="float"||Tt==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),m(h.oes_texture_half_float||!(Tt==="half float"||Tt==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):Tt==="half float"||Tt==="float16"?(m(h.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),ht="rgba16f"):(Tt==="float"||Tt==="float32")&&(m(h.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),ht="rgba32f"),m.oneOf(Tt,ie,"invalid color type")),"colorFormat"in Ye&&(ht=Ye.colorFormat,K.indexOf(ht)>=0?Et=!0:Q.indexOf(ht)>=0?Et=!1:m.optional(function(){Et?m.oneOf(Ye.colorFormat,K,"invalid color format for texture"):m.oneOf(Ye.colorFormat,Q,"invalid color format for renderbuffer")}))),("depthTexture"in Ye||"depthStencilTexture"in Ye)&&(xt=!!(Ye.depthTexture||Ye.depthStencilTexture),m(!xt||h.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in Ye&&(typeof Ye.depth=="boolean"?vt=Ye.depth:(Pt=Ye.depth,yt=!1)),"stencil"in Ye&&(typeof Ye.stencil=="boolean"?yt=Ye.stencil:(zt=Ye.stencil,vt=!1)),"depthStencil"in Ye&&(typeof Ye.depthStencil=="boolean"?vt=yt=Ye.depthStencil:(Bt=Ye.depthStencil,vt=!1,yt=!1))}var ot=null,Fe=null,et=null,it=null;if(Array.isArray(tt))ot=tt.map(ne);else if(tt)ot=[ne(tt)];else for(ot=new Array(Ct),Re=0;Re<Ct;++Re)ot[Re]=k(We,Je,Et,ht,Tt);m(h.webgl_draw_buffers||ot.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),m(ot.length<=_.maxColorAttachments,"too many color attachments, not supported"),We=We||ot[0].width,Je=Je||ot[0].height,Pt?Fe=ne(Pt):vt&&!yt&&(Fe=k(We,Je,xt,"depth","uint32")),zt?et=ne(zt):yt&&!vt&&(et=k(We,Je,!1,"stencil","uint8")),Bt?it=ne(Bt):!Pt&&!zt&&yt&&vt&&(it=k(We,Je,xt,"depth stencil","depth stencil")),m(!!Pt+!!zt+!!Bt<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var bt=null;for(Re=0;Re<ot.length;++Re)if(ue(ot[Re],We,Je),m(!ot[Re]||ot[Re].texture&&ox.indexOf(ot[Re].texture._texture.format)>=0||ot[Re].renderbuffer&&px.indexOf(ot[Re].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+Re+" is invalid"),ot[Re]&&ot[Re].texture){var Cn=Os[ot[Re].texture._texture.format]*Jo[ot[Re].texture._texture.type];bt===null?bt=Cn:m(bt===Cn,"all color attachments much have the same number of bits per pixel.")}return ue(Fe,We,Je),m(!Fe||Fe.texture&&Fe.texture._texture.format===rx||Fe.renderbuffer&&Fe.renderbuffer._renderbuffer.format===lx,"invalid depth attachment for framebuffer object"),ue(et,We,Je),m(!et||et.renderbuffer&&et.renderbuffer._renderbuffer.format===ux,"invalid stencil attachment for framebuffer object"),ue(it,We,Je),m(!it||it.texture&&it.texture._texture.format===sc||it.renderbuffer&&it.renderbuffer._renderbuffer.format===sc,"invalid depth-stencil attachment for framebuffer object"),me(de),de.width=We,de.height=Je,de.colorAttachments=ot,de.depthAttachment=Fe,de.stencilAttachment=et,de.depthStencilAttachment=it,He.color=ot.map(N),He.depth=N(Fe),He.stencil=N(et),He.depthStencil=N(it),He.width=de.width,He.height=de.height,X(de),He}function Ue(pe,ye){m(B.next!==de,"can not resize a framebuffer which is currently in use");var Re=Math.max(pe|0,1),We=Math.max(ye|0||Re,1);if(Re===de.width&&We===de.height)return He;for(var Je=de.colorAttachments,vt=0;vt<Je.length;++vt)te(Je[vt],Re,We);return te(de.depthAttachment,Re,We),te(de.stencilAttachment,Re,We),te(de.depthStencilAttachment,Re,We),de.width=He.width=Re,de.height=He.height=We,X(de),He}return He(ee,he),i(He,{resize:Ue,_reglType:"framebuffer",_framebuffer:de,destroy:function(){Le(de),me(de)},use:function(pe){B.setFBO({framebuffer:He},pe)}})}function Se(ee){var he=Array(6);function de(Ue){var pe;m(he.indexOf(B.next)<0,"can not update framebuffer which is currently in use");var ye={color:null},Re=0,We=null,Je="rgba",vt="uint8",yt=1;if(typeof Ue=="number")Re=Ue|0;else if(!Ue)Re=1;else{m.type(Ue,"object","invalid arguments for framebuffer");var tt=Ue;if("shape"in tt){var Et=tt.shape;m(Array.isArray(Et)&&Et.length>=2,"invalid shape for framebuffer"),m(Et[0]===Et[1],"cube framebuffer must be square"),Re=Et[0]}else"radius"in tt&&(Re=tt.radius|0),"width"in tt?(Re=tt.width|0,"height"in tt&&m(tt.height===Re,"must be square")):"height"in tt&&(Re=tt.height|0);("color"in tt||"colors"in tt)&&(We=tt.color||tt.colors,Array.isArray(We)&&m(We.length===1||h.webgl_draw_buffers,"multiple render targets not supported")),We||("colorCount"in tt&&(yt=tt.colorCount|0,m(yt>0,"invalid color buffer count")),"colorType"in tt&&(m.oneOf(tt.colorType,ie,"invalid color type"),vt=tt.colorType),"colorFormat"in tt&&(Je=tt.colorFormat,m.oneOf(tt.colorFormat,K,"invalid color format for texture"))),"depth"in tt&&(ye.depth=tt.depth),"stencil"in tt&&(ye.stencil=tt.stencil),"depthStencil"in tt&&(ye.depthStencil=tt.depthStencil)}var ht;if(We)if(Array.isArray(We))for(ht=[],pe=0;pe<We.length;++pe)ht[pe]=We[pe];else ht=[We];else{ht=Array(yt);var Tt={radius:Re,format:Je,type:vt};for(pe=0;pe<yt;++pe)ht[pe]=M.createCube(Tt)}for(ye.color=Array(ht.length),pe=0;pe<ht.length;++pe){var Ct=ht[pe];m(typeof Ct=="function"&&Ct._reglType==="textureCube","invalid cube map"),Re=Re||Ct.width,m(Ct.width===Re&&Ct.height===Re,"invalid cube map shape"),ye.color[pe]={target:Ko,data:ht[pe]}}for(pe=0;pe<6;++pe){for(var Pt=0;Pt<ht.length;++Pt)ye.color[Pt].target=Ko+pe;pe>0&&(ye.depth=he[0].depth,ye.stencil=he[0].stencil,ye.depthStencil=he[0].depthStencil),he[pe]?he[pe](ye):he[pe]=H(ye)}return i(de,{width:Re,height:Re,color:ht})}function He(Ue){var pe,ye=Ue|0;if(m(ye>0&&ye<=_.maxCubeMapSize,"invalid radius for cube fbo"),ye===de.width)return de;var Re=de.color;for(pe=0;pe<Re.length;++pe)Re[pe].resize(ye);for(pe=0;pe<6;++pe)he[pe].resize(ye);return de.width=de.height=ye,de}return de(ee),i(de,{faces:he,resize:He,_reglType:"framebufferCube",destroy:function(){he.forEach(function(Ue){Ue.destroy()})}})}function ce(){B.cur=null,B.next=null,B.dirty=!0,rn(Z).forEach(function(ee){ee.framebuffer=a.createFramebuffer(),X(ee)})}return i(B,{getFramebuffer:function(ee){if(typeof ee=="function"&&ee._reglType==="framebuffer"){var he=ee._framebuffer;if(he instanceof ge)return he}return null},create:H,createCube:Se,clear:function(){rn(Z).forEach(Le)},restore:ce})}var gx=5126,fc=34962,ea=34963,lc=["attributes","elements","offset","count","primitive","instances"];function Ns(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=gx,this.offset=0,this.stride=0,this.divisor=0}function yx(a,h,_,M,W,R,B){for(var K=_.maxAttributes,Q=new Array(K),ie=0;ie<K;++ie)Q[ie]=new Ns;var oe=0,re={},ue={Record:Ns,scope:{},state:Q,currentVAO:null,targetVAO:null,restore:ne()?me:function(){},createVAO:Le,getVAO:N,destroyBuffer:J,setVAO:ne()?te:xe,clear:ne()?Z:function(){}};function J(X){for(var H=0;H<Q.length;++H){var Se=Q[H];Se.buffer===X&&(a.disableVertexAttribArray(H),Se.buffer=null)}}function ne(){return h.oes_vertex_array_object}function k(){return h.angle_instanced_arrays}function N(X){return typeof X=="function"&&X._vao?X._vao:null}function te(X){if(X!==ue.currentVAO){var H=ne();X?H.bindVertexArrayOES(X.vao):H.bindVertexArrayOES(null),ue.currentVAO=X}}function xe(X){if(X!==ue.currentVAO){if(X)X.bindAttrs();else{for(var H=k(),Se=0;Se<Q.length;++Se){var ce=Q[Se];ce.buffer?(a.enableVertexAttribArray(Se),ce.buffer.bind(),a.vertexAttribPointer(Se,ce.size,ce.type,ce.normalized,ce.stride,ce.offfset),H&&ce.divisor&&H.vertexAttribDivisorANGLE(Se,ce.divisor)):(a.disableVertexAttribArray(Se),a.vertexAttrib4f(Se,ce.x,ce.y,ce.z,ce.w))}B.elements?a.bindBuffer(ea,B.elements.buffer.buffer):a.bindBuffer(ea,null)}ue.currentVAO=X}}function Z(){rn(re).forEach(function(X){X.destroy()})}function ge(){this.id=++oe,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var X=ne();X?this.vao=X.createVertexArrayOES():this.vao=null,re[this.id]=this,this.buffers=[]}ge.prototype.bindAttrs=function(){for(var X=k(),H=this.attributes,Se=0;Se<H.length;++Se){var ce=H[Se];ce.buffer?(a.enableVertexAttribArray(Se),a.bindBuffer(fc,ce.buffer.buffer),a.vertexAttribPointer(Se,ce.size,ce.type,ce.normalized,ce.stride,ce.offset),X&&ce.divisor&&X.vertexAttribDivisorANGLE(Se,ce.divisor)):(a.disableVertexAttribArray(Se),a.vertexAttrib4f(Se,ce.x,ce.y,ce.z,ce.w))}for(var ee=H.length;ee<K;++ee)a.disableVertexAttribArray(ee);var he=R.getElements(this.elements);he?a.bindBuffer(ea,he.buffer.buffer):a.bindBuffer(ea,null)},ge.prototype.refresh=function(){var X=ne();X&&(X.bindVertexArrayOES(this.vao),this.bindAttrs(),ue.currentVAO=null,X.bindVertexArrayOES(null))},ge.prototype.destroy=function(){if(this.vao){var X=ne();this===ue.currentVAO&&(ue.currentVAO=null,X.bindVertexArrayOES(null)),X.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),re[this.id]&&(delete re[this.id],M.vaoCount-=1)};function me(){var X=ne();X&&rn(re).forEach(function(H){H.refresh()})}function Le(X){var H=new ge;M.vaoCount+=1;function Se(ce){var ee;if(Array.isArray(ce))ee=ce,H.elements&&H.ownsElements&&H.elements.destroy(),H.elements=null,H.ownsElements=!1,H.offset=0,H.count=0,H.instances=-1,H.primitive=4;else{if(m(typeof ce=="object","invalid arguments for create vao"),m("attributes"in ce,"must specify attributes for vao"),ce.elements){var he=ce.elements;H.ownsElements?typeof he=="function"&&he._reglType==="elements"?(H.elements.destroy(),H.ownsElements=!1):(H.elements(he),H.ownsElements=!1):R.getElements(ce.elements)?(H.elements=ce.elements,H.ownsElements=!1):(H.elements=R.create(ce.elements),H.ownsElements=!0)}else H.elements=null,H.ownsElements=!1;ee=ce.attributes,H.offset=0,H.count=-1,H.instances=-1,H.primitive=4,H.elements&&(H.count=H.elements._elements.vertCount,H.primitive=H.elements._elements.primType),"offset"in ce&&(H.offset=ce.offset|0),"count"in ce&&(H.count=ce.count|0),"instances"in ce&&(H.instances=ce.instances|0),"primitive"in ce&&(m(ce.primitive in Yn,"bad primitive type: "+ce.primitive),H.primitive=Yn[ce.primitive]),m.optional(()=>{for(var vt=Object.keys(ce),yt=0;yt<vt.length;++yt)m(lc.indexOf(vt[yt])>=0,'invalid option for vao: "'+vt[yt]+'" valid options are '+lc)}),m(Array.isArray(ee),"attributes must be an array")}m(ee.length<K,"too many attributes"),m(ee.length>0,"must specify at least one attribute");var de={},He=H.attributes;He.length=ee.length;for(var Ue=0;Ue<ee.length;++Ue){var pe=ee[Ue],ye=He[Ue]=new Ns,Re=pe.data||pe;if(Array.isArray(Re)||n(Re)||yn(Re)){var We;H.buffers[Ue]&&(We=H.buffers[Ue],n(Re)&&We._buffer.byteLength>=Re.byteLength?We.subdata(Re):(We.destroy(),H.buffers[Ue]=null)),H.buffers[Ue]||(We=H.buffers[Ue]=W.create(pe,fc,!1,!0)),ye.buffer=W.getBuffer(We),ye.size=ye.buffer.dimension|0,ye.normalized=!1,ye.type=ye.buffer.dtype,ye.offset=0,ye.stride=0,ye.divisor=0,ye.state=1,de[Ue]=1}else W.getBuffer(pe)?(ye.buffer=W.getBuffer(pe),ye.size=ye.buffer.dimension|0,ye.normalized=!1,ye.type=ye.buffer.dtype,ye.offset=0,ye.stride=0,ye.divisor=0,ye.state=1):W.getBuffer(pe.buffer)?(ye.buffer=W.getBuffer(pe.buffer),ye.size=(+pe.size||ye.buffer.dimension)|0,ye.normalized=!!pe.normalized||!1,"type"in pe?(m.parameter(pe.type,mi,"invalid buffer type"),ye.type=mi[pe.type]):ye.type=ye.buffer.dtype,ye.offset=(pe.offset||0)|0,ye.stride=(pe.stride||0)|0,ye.divisor=(pe.divisor||0)|0,ye.state=1,m(ye.size>=1&&ye.size<=4,"size must be between 1 and 4"),m(ye.offset>=0,"invalid offset"),m(ye.stride>=0&&ye.stride<=255,"stride must be between 0 and 255"),m(ye.divisor>=0,"divisor must be positive"),m(!ye.divisor||!!h.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in pe?(m(Ue>0,"first attribute must not be a constant"),ye.x=+pe.x||0,ye.y=+pe.y||0,ye.z=+pe.z||0,ye.w=+pe.w||0,ye.state=2):m(!1,"invalid attribute spec for location "+Ue)}for(var Je=0;Je<H.buffers.length;++Je)!de[Je]&&H.buffers[Je]&&(H.buffers[Je].destroy(),H.buffers[Je]=null);return H.refresh(),Se}return Se.destroy=function(){for(var ce=0;ce<H.buffers.length;++ce)H.buffers[ce]&&H.buffers[ce].destroy();H.buffers.length=0,H.ownsElements&&(H.elements.destroy(),H.elements=null,H.ownsElements=!1),H.destroy()},Se._vao=H,Se._reglType="vao",Se(X)}return ue}var uc=35632,xx=35633,bx=35718,_x=35721;function Sx(a,h,_,M){var W={},R={};function B(k,N,te,xe){this.name=k,this.id=N,this.location=te,this.info=xe}function K(k,N){for(var te=0;te<k.length;++te)if(k[te].id===N.id){k[te].location=N.location;return}k.push(N)}function Q(k,N,te){var xe=k===uc?W:R,Z=xe[N];if(!Z){var ge=h.str(N);Z=a.createShader(k),a.shaderSource(Z,ge),a.compileShader(Z),m.shaderError(a,Z,ge,k,te),xe[N]=Z}return Z}var ie={},oe=[],re=0;function ue(k,N){this.id=re++,this.fragId=k,this.vertId=N,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,M.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function J(k,N,te){var xe,Z,ge=Q(uc,k.fragId),me=Q(xx,k.vertId),Le=k.program=a.createProgram();if(a.attachShader(Le,ge),a.attachShader(Le,me),te)for(xe=0;xe<te.length;++xe){var X=te[xe];a.bindAttribLocation(Le,X[0],X[1])}a.linkProgram(Le),m.linkError(a,Le,h.str(k.fragId),h.str(k.vertId),N);var H=a.getProgramParameter(Le,bx);M.profile&&(k.stats.uniformsCount=H);var Se=k.uniforms;for(xe=0;xe<H;++xe)if(Z=a.getActiveUniform(Le,xe),Z){if(Z.size>1)for(var ce=0;ce<Z.size;++ce){var ee=Z.name.replace("[0]","["+ce+"]");K(Se,new B(ee,h.id(ee),a.getUniformLocation(Le,ee),Z))}var he=Z.name;Z.size>1&&(he=he.replace("[0]","")),K(Se,new B(he,h.id(he),a.getUniformLocation(Le,he),Z))}var de=a.getProgramParameter(Le,_x);M.profile&&(k.stats.attributesCount=de);var He=k.attributes;for(xe=0;xe<de;++xe)Z=a.getActiveAttrib(Le,xe),Z&&K(He,new B(Z.name,h.id(Z.name),a.getAttribLocation(Le,Z.name),Z))}M.profile&&(_.getMaxUniformsCount=function(){var k=0;return oe.forEach(function(N){N.stats.uniformsCount>k&&(k=N.stats.uniformsCount)}),k},_.getMaxAttributesCount=function(){var k=0;return oe.forEach(function(N){N.stats.attributesCount>k&&(k=N.stats.attributesCount)}),k});function ne(){W={},R={};for(var k=0;k<oe.length;++k)J(oe[k],null,oe[k].attributes.map(function(N){return[N.location,N.name]}))}return{clear:function(){var k=a.deleteShader.bind(a);rn(W).forEach(k),W={},rn(R).forEach(k),R={},oe.forEach(function(N){a.deleteProgram(N.program)}),oe.length=0,ie={},_.shaderCount=0},program:function(k,N,te,xe){m.command(k>=0,"missing vertex shader",te),m.command(N>=0,"missing fragment shader",te);var Z=ie[N];Z||(Z=ie[N]={});var ge=Z[k];if(ge&&(ge.refCount++,!xe))return ge;var me=new ue(N,k);return _.shaderCount++,J(me,te,xe),ge||(Z[k]=me),oe.push(me),i(me,{destroy:function(){if(me.refCount--,me.refCount<=0){a.deleteProgram(me.program);var Le=oe.indexOf(me);oe.splice(Le,1),_.shaderCount--}Z[me.vertId].refCount<=0&&(a.deleteShader(R[me.vertId]),delete R[me.vertId],delete ie[me.fragId][me.vertId]),Object.keys(ie[me.fragId]).length||(a.deleteShader(W[me.fragId]),delete W[me.fragId],delete ie[me.fragId])}})},restore:ne,shader:Q,frag:-1,vert:-1}}var Tx=6408,Pr=5121,wx=3333,ta=5126;function Ax(a,h,_,M,W,R,B){function K(oe){var re;h.next===null?(m(W.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),re=Pr):(m(h.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),re=h.next.colorAttachments[0].texture._texture.type,m.optional(function(){R.oes_texture_float?(m(re===Pr||re===ta,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),re===ta&&m(B.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):m(re===Pr,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var ue=0,J=0,ne=M.framebufferWidth,k=M.framebufferHeight,N=null;n(oe)?N=oe:oe&&(m.type(oe,"object","invalid arguments to regl.read()"),ue=oe.x|0,J=oe.y|0,m(ue>=0&&ue<M.framebufferWidth,"invalid x offset for regl.read"),m(J>=0&&J<M.framebufferHeight,"invalid y offset for regl.read"),ne=(oe.width||M.framebufferWidth-ue)|0,k=(oe.height||M.framebufferHeight-J)|0,N=oe.data||null),N&&(re===Pr?m(N instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):re===ta&&m(N instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),m(ne>0&&ne+ue<=M.framebufferWidth,"invalid width for read pixels"),m(k>0&&k+J<=M.framebufferHeight,"invalid height for read pixels"),_();var te=ne*k*4;return N||(re===Pr?N=new Uint8Array(te):re===ta&&(N=N||new Float32Array(te))),m.isTypedArray(N,"data buffer for regl.read() must be a typedarray"),m(N.byteLength>=te,"data buffer for regl.read() too small"),a.pixelStorei(wx,4),a.readPixels(ue,J,ne,k,Tx,re,N),N}function Q(oe){var re;return h.setFBO({framebuffer:oe.framebuffer},function(){re=K(oe)}),re}function ie(oe){return!oe||!("framebuffer"in oe)?K(oe):Q(oe)}return ie}function qi(a){return Array.prototype.slice.call(a)}function Yi(a){return qi(a).join("")}function Ex(){var a=0,h=[],_=[];function M(re){for(var ue=0;ue<_.length;++ue)if(_[ue]===re)return h[ue];var J="g"+a++;return h.push(J),_.push(re),J}function W(){var re=[];function ue(){re.push.apply(re,qi(arguments))}var J=[];function ne(){var k="v"+a++;return J.push(k),arguments.length>0&&(re.push(k,"="),re.push.apply(re,qi(arguments)),re.push(";")),k}return i(ue,{def:ne,toString:function(){return Yi([J.length>0?"var "+J.join(",")+";":"",Yi(re)])}})}function R(){var re=W(),ue=W(),J=re.toString,ne=ue.toString;function k(N,te){ue(N,te,"=",re.def(N,te),";")}return i(function(){re.apply(re,qi(arguments))},{def:re.def,entry:re,exit:ue,save:k,set:function(N,te,xe){k(N,te),re(N,te,"=",xe,";")},toString:function(){return J()+ne()}})}function B(){var re=Yi(arguments),ue=R(),J=R(),ne=ue.toString,k=J.toString;return i(ue,{then:function(){return ue.apply(ue,qi(arguments)),this},else:function(){return J.apply(J,qi(arguments)),this},toString:function(){var N=k();return N&&(N="else{"+N+"}"),Yi(["if(",re,"){",ne(),"}",N])}})}var K=W(),Q={};function ie(re,ue){var J=[];function ne(){var Z="a"+J.length;return J.push(Z),Z}ue=ue||0;for(var k=0;k<ue;++k)ne();var N=R(),te=N.toString,xe=Q[re]=i(N,{arg:ne,toString:function(){return Yi(["function(",J.join(),"){",te(),"}"])}});return xe}function oe(){var re=['"use strict";',K,"return {"];Object.keys(Q).forEach(function(ne){re.push('"',ne,'":',Q[ne].toString(),",")}),re.push("}");var ue=Yi(re).replace(/;/g,`;
6
+ `).replace(/}/g,`}
7
+ `).replace(/{/g,`{
8
+ `),J=Function.apply(null,h.concat(ue));return J.apply(null,_)}return{global:K,link:M,block:W,proc:ie,scope:R,cond:B,compile:oe}}var Zi="xyzw".split(""),cc=5121,Qi=1,Gs=2,Bs=0,Us=1,Vs=2,$s=3,na=4,hc=5,dc=6,mc="dither",pc="blend.enable",vc="blend.color",Hs="blend.equation",Ws="blend.func",gc="depth.enable",yc="depth.func",xc="depth.range",bc="depth.mask",Xs="colorMask",_c="cull.enable",Sc="cull.face",js="frontFace",qs="lineWidth",Tc="polygonOffset.enable",Ys="polygonOffset.offset",wc="sample.alpha",Ac="sample.enable",Zs="sample.coverage",Ec="stencil.enable",Cc="stencil.mask",Qs="stencil.func",Ks="stencil.opFront",kr="stencil.opBack",Pc="scissor.enable",ia="scissor.box",Bn="viewport",Ir="profile",xi="framebuffer",Lr="vert",Dr="frag",bi="elements",_i="primitive",Si="count",ra="offset",oa="instances",Fr="vao",Js="Width",ef="Height",Ki=xi+Js,Ji=xi+ef,Cx=Bn+Js,Px=Bn+ef,kc="drawingBuffer",Ic=kc+Js,Lc=kc+ef,kx=[Ws,Hs,Qs,Ks,kr,Zs,Bn,ia,Ys],er=34962,tf=34963,Ix=35632,Lx=35633,Dc=3553,Dx=34067,Fx=2884,zx=3042,Rx=3024,Mx=2960,Ox=2929,Nx=3089,Gx=32823,Bx=32926,Ux=32928,nf=5126,aa=35664,sa=35665,fa=35666,rf=5124,la=35667,ua=35668,ca=35669,of=35670,ha=35671,da=35672,ma=35673,zr=35674,Rr=35675,Mr=35676,Or=35678,Nr=35680,af=4,Gr=1028,Ti=1029,Fc=2304,sf=2305,Vx=32775,$x=32776,Hx=519,Qn=7680,zc=0,Rc=1,Mc=32774,Wx=513,Oc=36160,Xx=36064,En={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Nc=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],tr={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Kn={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Gc={frag:Ix,vert:Lx},ff={cw:Fc,ccw:sf};function pa(a){return Array.isArray(a)||n(a)||yn(a)}function Bc(a){return a.sort(function(h,_){return h===Bn?-1:_===Bn?1:h<_?-1:1})}function Dt(a,h,_,M){this.thisDep=a,this.contextDep=h,this.propDep=_,this.append=M}function Jn(a){return a&&!(a.thisDep||a.contextDep||a.propDep)}function St(a){return new Dt(!1,!1,!1,a)}function Jt(a,h){var _=a.type;if(_===Bs){var M=a.data.length;return new Dt(!0,M>=1,M>=2,h)}else if(_===na){var W=a.data;return new Dt(W.thisDep,W.contextDep,W.propDep,h)}else{if(_===hc)return new Dt(!1,!1,!1,h);if(_===dc){for(var R=!1,B=!1,K=!1,Q=0;Q<a.data.length;++Q){var ie=a.data[Q];if(ie.type===Us)K=!0;else if(ie.type===Vs)B=!0;else if(ie.type===$s)R=!0;else if(ie.type===Bs){R=!0;var oe=ie.data;oe>=1&&(B=!0),oe>=2&&(K=!0)}else ie.type===na&&(R=R||ie.data.thisDep,B=B||ie.data.contextDep,K=K||ie.data.propDep)}return new Dt(R,B,K,h)}else return new Dt(_===$s,_===Vs,_===Us,h)}}var Uc=new Dt(!1,!1,!1,function(){});function jx(a,h,_,M,W,R,B,K,Q,ie,oe,re,ue,J,ne){var k=ie.Record,N={add:32774,subtract:32778,"reverse subtract":32779};_.ext_blend_minmax&&(N.min=Vx,N.max=$x);var te=_.angle_instanced_arrays,xe=_.webgl_draw_buffers,Z=_.oes_vertex_array_object,ge={dirty:!0,profile:ne.profile},me={},Le=[],X={},H={};function Se(p){return p.replace(".","_")}function ce(p,c,T){var C=Se(p);Le.push(p),me[C]=ge[C]=!!T,X[C]=c}function ee(p,c,T){var C=Se(p);Le.push(p),Array.isArray(T)?(ge[C]=T.slice(),me[C]=T.slice()):ge[C]=me[C]=T,H[C]=c}ce(mc,Rx),ce(pc,zx),ee(vc,"blendColor",[0,0,0,0]),ee(Hs,"blendEquationSeparate",[Mc,Mc]),ee(Ws,"blendFuncSeparate",[Rc,zc,Rc,zc]),ce(gc,Ox,!0),ee(yc,"depthFunc",Wx),ee(xc,"depthRange",[0,1]),ee(bc,"depthMask",!0),ee(Xs,Xs,[!0,!0,!0,!0]),ce(_c,Fx),ee(Sc,"cullFace",Ti),ee(js,js,sf),ee(qs,qs,1),ce(Tc,Gx),ee(Ys,"polygonOffset",[0,0]),ce(wc,Bx),ce(Ac,Ux),ee(Zs,"sampleCoverage",[1,!1]),ce(Ec,Mx),ee(Cc,"stencilMask",-1),ee(Qs,"stencilFunc",[Hx,0,-1]),ee(Ks,"stencilOpSeparate",[Gr,Qn,Qn,Qn]),ee(kr,"stencilOpSeparate",[Ti,Qn,Qn,Qn]),ce(Pc,Nx),ee(ia,"scissor",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]),ee(Bn,Bn,[0,0,a.drawingBufferWidth,a.drawingBufferHeight]);var he={gl:a,context:ue,strings:h,next:me,current:ge,draw:re,elements:R,buffer:W,shader:oe,attributes:ie.state,vao:ie,uniforms:Q,framebuffer:K,extensions:_,timer:J,isBufferArgs:pa},de={primTypes:Yn,compareFuncs:tr,blendFuncs:En,blendEquations:N,stencilOps:Kn,glTypes:mi,orientationType:ff};m.optional(function(){he.isArrayLike=pt}),xe&&(de.backBuffer=[Ti],de.drawBuffer=Yt(M.maxDrawbuffers,function(p){return p===0?[0]:Yt(p,function(c){return Xx+c})}));var He=0;function Ue(){var p=Ex(),c=p.link,T=p.global;p.id=He++,p.batchId="0";var C=c(he),I=p.shared={props:"a0"};Object.keys(he).forEach(function(b){I[b]=T.def(C,".",b)}),m.optional(function(){p.CHECK=c(m),p.commandStr=m.guessCommand(),p.command=c(p.commandStr),p.assert=function(b,g,F){b("if(!(",g,"))",this.CHECK,".commandRaise(",c(F),",",this.command,");")},de.invalidBlendCombinations=Nc});var A=p.next={},w=p.current={};Object.keys(H).forEach(function(b){Array.isArray(ge[b])&&(A[b]=T.def(I.next,".",b),w[b]=T.def(I.current,".",b))});var E=p.constants={};Object.keys(de).forEach(function(b){E[b]=T.def(JSON.stringify(de[b]))}),p.invoke=function(b,g){switch(g.type){case Bs:var F=["this",I.context,I.props,p.batchId];return b.def(c(g.data),".call(",F.slice(0,Math.max(g.data.length+1,4)),")");case Us:return b.def(I.props,g.data);case Vs:return b.def(I.context,g.data);case $s:return b.def("this",g.data);case na:return g.data.append(p,b),g.data.ref;case hc:return g.data.toString();case dc:return g.data.map(function(L){return p.invoke(b,L)})}},p.attribCache={};var v={};return p.scopeAttrib=function(b){var g=h.id(b);if(g in v)return v[g];var F=ie.scope[g];F||(F=ie.scope[g]=new k);var L=v[g]=c(F);return L},p}function pe(p){var c=p.static,T=p.dynamic,C;if(Ir in c){var I=!!c[Ir];C=St(function(w,E){return I}),C.enable=I}else if(Ir in T){var A=T[Ir];C=Jt(A,function(w,E){return w.invoke(E,A)})}return C}function ye(p,c){var T=p.static,C=p.dynamic;if(xi in T){var I=T[xi];return I?(I=K.getFramebuffer(I),m.command(I,"invalid framebuffer object"),St(function(w,E){var v=w.link(I),b=w.shared;E.set(b.framebuffer,".next",v);var g=b.context;return E.set(g,"."+Ki,v+".width"),E.set(g,"."+Ji,v+".height"),v})):St(function(w,E){var v=w.shared;E.set(v.framebuffer,".next","null");var b=v.context;return E.set(b,"."+Ki,b+"."+Ic),E.set(b,"."+Ji,b+"."+Lc),"null"})}else if(xi in C){var A=C[xi];return Jt(A,function(w,E){var v=w.invoke(E,A),b=w.shared,g=b.framebuffer,F=E.def(g,".getFramebuffer(",v,")");m.optional(function(){w.assert(E,"!"+v+"||"+F,"invalid framebuffer object")}),E.set(g,".next",F);var L=b.context;return E.set(L,"."+Ki,F+"?"+F+".width:"+L+"."+Ic),E.set(L,"."+Ji,F+"?"+F+".height:"+L+"."+Lc),F})}else return null}function Re(p,c,T){var C=p.static,I=p.dynamic;function A(v){if(v in C){var b=C[v];m.commandType(b,"object","invalid "+v,T.commandStr);var g=!0,F=b.x|0,L=b.y|0,$,j;return"width"in b?($=b.width|0,m.command($>=0,"invalid "+v,T.commandStr)):g=!1,"height"in b?(j=b.height|0,m.command(j>=0,"invalid "+v,T.commandStr)):g=!1,new Dt(!g&&c&&c.thisDep,!g&&c&&c.contextDep,!g&&c&&c.propDep,function(ke,be){var Y=ke.shared.context,U=$;"width"in b||(U=be.def(Y,".",Ki,"-",F));var Ce=j;return"height"in b||(Ce=be.def(Y,".",Ji,"-",L)),[F,L,U,Ce]})}else if(v in I){var le=I[v],Ge=Jt(le,function(ke,be){var Y=ke.invoke(be,le);m.optional(function(){ke.assert(be,Y+"&&typeof "+Y+'==="object"',"invalid "+v)});var U=ke.shared.context,Ce=be.def(Y,".x|0"),Ae=be.def(Y,".y|0"),Me=be.def('"width" in ',Y,"?",Y,".width|0:","(",U,".",Ki,"-",Ce,")"),st=be.def('"height" in ',Y,"?",Y,".height|0:","(",U,".",Ji,"-",Ae,")");return m.optional(function(){ke.assert(be,Me+">=0&&"+st+">=0","invalid "+v)}),[Ce,Ae,Me,st]});return c&&(Ge.thisDep=Ge.thisDep||c.thisDep,Ge.contextDep=Ge.contextDep||c.contextDep,Ge.propDep=Ge.propDep||c.propDep),Ge}else return c?new Dt(c.thisDep,c.contextDep,c.propDep,function(ke,be){var Y=ke.shared.context;return[0,0,be.def(Y,".",Ki),be.def(Y,".",Ji)]}):null}var w=A(Bn);if(w){var E=w;w=new Dt(w.thisDep,w.contextDep,w.propDep,function(v,b){var g=E.append(v,b),F=v.shared.context;return b.set(F,"."+Cx,g[2]),b.set(F,"."+Px,g[3]),g})}return{viewport:w,scissor_box:A(ia)}}function We(p,c){var T=p.static,C=typeof T[Dr]=="string"&&typeof T[Lr]=="string";if(C){if(Object.keys(c.dynamic).length>0)return null;var I=c.static,A=Object.keys(I);if(A.length>0&&typeof I[A[0]]=="number"){for(var w=[],E=0;E<A.length;++E)m(typeof I[A[E]]=="number","must specify all vertex attribute locations when using vaos"),w.push([I[A[E]]|0,A[E]]);return w}}return null}function Je(p,c,T){var C=p.static,I=p.dynamic;function A(g){if(g in C){var F=h.id(C[g]);m.optional(function(){oe.shader(Gc[g],F,m.guessCommand())});var L=St(function(){return F});return L.id=F,L}else if(g in I){var $=I[g];return Jt($,function(j,le){var Ge=j.invoke(le,$),ke=le.def(j.shared.strings,".id(",Ge,")");return m.optional(function(){le(j.shared.shader,".shader(",Gc[g],",",ke,",",j.command,");")}),ke})}return null}var w=A(Dr),E=A(Lr),v=null,b;return Jn(w)&&Jn(E)?(v=oe.program(E.id,w.id,null,T),b=St(function(g,F){return g.link(v)})):b=new Dt(w&&w.thisDep||E&&E.thisDep,w&&w.contextDep||E&&E.contextDep,w&&w.propDep||E&&E.propDep,function(g,F){var L=g.shared.shader,$;w?$=w.append(g,F):$=F.def(L,".",Dr);var j;E?j=E.append(g,F):j=F.def(L,".",Lr);var le=L+".program("+j+","+$;return m.optional(function(){le+=","+g.command}),F.def(le+")")}),{frag:w,vert:E,progVar:b,program:v}}function vt(p,c){var T=p.static,C=p.dynamic,I={},A=!1;function w(){if(Fr in T){var be=T[Fr];return be!==null&&ie.getVAO(be)===null&&(be=ie.createVAO(be)),A=!0,I.vao=be,St(function(U){var Ce=ie.getVAO(be);return Ce?U.link(Ce):"null"})}else if(Fr in C){A=!0;var Y=C[Fr];return Jt(Y,function(U,Ce){var Ae=U.invoke(Ce,Y);return Ce.def(U.shared.vao+".getVAO("+Ae+")")})}return null}var E=w(),v=!1;function b(){if(bi in T){var be=T[bi];if(I.elements=be,pa(be)){var Y=I.elements=R.create(be,!0);be=R.getElements(Y),v=!0}else be&&(be=R.getElements(be),v=!0,m.command(be,"invalid elements",c.commandStr));var U=St(function(Ae,Me){if(be){var st=Ae.link(be);return Ae.ELEMENTS=st,st}return Ae.ELEMENTS=null,null});return U.value=be,U}else if(bi in C){v=!0;var Ce=C[bi];return Jt(Ce,function(Ae,Me){var st=Ae.shared,Vt=st.isBufferArgs,Ai=st.elements,Un=Ae.invoke(Me,Ce),Pn=Me.def("null"),ei=Me.def(Vt,"(",Un,")"),Ei=Ae.cond(ei).then(Pn,"=",Ai,".createStream(",Un,");").else(Pn,"=",Ai,".getElements(",Un,");");return m.optional(function(){Ae.assert(Ei.else,"!"+Un+"||"+Pn,"invalid elements")}),Me.entry(Ei),Me.exit(Ae.cond(ei).then(Ai,".destroyStream(",Pn,");")),Ae.ELEMENTS=Pn,Pn})}else if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.elements+".getElements("+Ae.shared.vao+".currentVAO.elements):null")});return null}var g=b();function F(){if(_i in T){var be=T[_i];return I.primitive=be,m.commandParameter(be,Yn,"invalid primitve",c.commandStr),St(function(U,Ce){return Yn[be]})}else if(_i in C){var Y=C[_i];return Jt(Y,function(U,Ce){var Ae=U.constants.primTypes,Me=U.invoke(Ce,Y);return m.optional(function(){U.assert(Ce,Me+" in "+Ae,"invalid primitive, must be one of "+Object.keys(Yn))}),Ce.def(Ae,"[",Me,"]")})}else{if(v)return Jn(g)?g.value?St(function(U,Ce){return Ce.def(U.ELEMENTS,".primType")}):St(function(){return af}):new Dt(g.thisDep,g.contextDep,g.propDep,function(U,Ce){var Ae=U.ELEMENTS;return Ce.def(Ae,"?",Ae,".primType:",af)});if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(U,Ce){return Ce.def(U.shared.vao+".currentVAO?"+U.shared.vao+".currentVAO.primitive:"+af)})}return null}function L(be,Y){if(be in T){var U=T[be]|0;return Y?I.offset=U:I.instances=U,m.command(!Y||U>=0,"invalid "+be,c.commandStr),St(function(Ae,Me){return Y&&(Ae.OFFSET=U),U})}else if(be in C){var Ce=C[be];return Jt(Ce,function(Ae,Me){var st=Ae.invoke(Me,Ce);return Y&&(Ae.OFFSET=st,m.optional(function(){Ae.assert(Me,st+">=0","invalid "+be)})),st})}else if(Y){if(v)return St(function(Ae,Me){return Ae.OFFSET=0,0});if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.vao+".currentVAO.offset:0")})}else if(A)return new Dt(E.thisDep,E.contextDep,E.propDep,function(Ae,Me){return Me.def(Ae.shared.vao+".currentVAO?"+Ae.shared.vao+".currentVAO.instances:-1")});return null}var $=L(ra,!0);function j(){if(Si in T){var be=T[Si]|0;return I.count=be,m.command(typeof be=="number"&&be>=0,"invalid vertex count",c.commandStr),St(function(){return be})}else if(Si in C){var Y=C[Si];return Jt(Y,function(Me,st){var Vt=Me.invoke(st,Y);return m.optional(function(){Me.assert(st,"typeof "+Vt+'==="number"&&'+Vt+">=0&&"+Vt+"===("+Vt+"|0)","invalid vertex count")}),Vt})}else if(v)if(Jn(g)){if(g)return $?new Dt($.thisDep,$.contextDep,$.propDep,function(Me,st){var Vt=st.def(Me.ELEMENTS,".vertCount-",Me.OFFSET);return m.optional(function(){Me.assert(st,Vt+">=0","invalid vertex offset/element buffer too small")}),Vt}):St(function(Me,st){return st.def(Me.ELEMENTS,".vertCount")});var U=St(function(){return-1});return m.optional(function(){U.MISSING=!0}),U}else{var Ce=new Dt(g.thisDep||$.thisDep,g.contextDep||$.contextDep,g.propDep||$.propDep,function(Me,st){var Vt=Me.ELEMENTS;return Me.OFFSET?st.def(Vt,"?",Vt,".vertCount-",Me.OFFSET,":-1"):st.def(Vt,"?",Vt,".vertCount:-1")});return m.optional(function(){Ce.DYNAMIC=!0}),Ce}else if(A){var Ae=new Dt(E.thisDep,E.contextDep,E.propDep,function(Me,st){return st.def(Me.shared.vao,".currentVAO?",Me.shared.vao,".currentVAO.count:-1")});return Ae}return null}var le=F(),Ge=j(),ke=L(oa,!1);return{elements:g,primitive:le,count:Ge,instances:ke,offset:$,vao:E,vaoActive:A,elementsActive:v,static:I}}function yt(p,c){var T=p.static,C=p.dynamic,I={};return Le.forEach(function(A){var w=Se(A);function E(v,b){if(A in T){var g=v(T[A]);I[w]=St(function(){return g})}else if(A in C){var F=C[A];I[w]=Jt(F,function(L,$){return b(L,$,L.invoke($,F))})}}switch(A){case _c:case pc:case mc:case Ec:case gc:case Pc:case Tc:case wc:case Ac:case bc:return E(function(v){return m.commandType(v,"boolean",A,c.commandStr),v},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="boolean"',"invalid flag "+A,v.commandStr)}),g});case yc:return E(function(v){return m.commandParameter(v,tr,"invalid "+A,c.commandStr),tr[v]},function(v,b,g){var F=v.constants.compareFuncs;return m.optional(function(){v.assert(b,g+" in "+F,"invalid "+A+", must be one of "+Object.keys(tr))}),b.def(F,"[",g,"]")});case xc:return E(function(v){return m.command(pt(v)&&v.length===2&&typeof v[0]=="number"&&typeof v[1]=="number"&&v[0]<=v[1],"depth range is 2d array",c.commandStr),v},function(v,b,g){m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===2&&typeof "+g+'[0]==="number"&&typeof '+g+'[1]==="number"&&'+g+"[0]<="+g+"[1]","depth range must be a 2d array")});var F=b.def("+",g,"[0]"),L=b.def("+",g,"[1]");return[F,L]});case Ws:return E(function(v){m.commandType(v,"object","blend.func",c.commandStr);var b="srcRGB"in v?v.srcRGB:v.src,g="srcAlpha"in v?v.srcAlpha:v.src,F="dstRGB"in v?v.dstRGB:v.dst,L="dstAlpha"in v?v.dstAlpha:v.dst;return m.commandParameter(b,En,w+".srcRGB",c.commandStr),m.commandParameter(g,En,w+".srcAlpha",c.commandStr),m.commandParameter(F,En,w+".dstRGB",c.commandStr),m.commandParameter(L,En,w+".dstAlpha",c.commandStr),m.command(Nc.indexOf(b+", "+F)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+b+", "+F+")",c.commandStr),[En[b],En[F],En[g],En[L]]},function(v,b,g){var F=v.constants.blendFuncs;m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid blend func, must be an object")});function L(Y,U){var Ce=b.def('"',Y,U,'" in ',g,"?",g,".",Y,U,":",g,".",Y);return m.optional(function(){v.assert(b,Ce+" in "+F,"invalid "+A+"."+Y+U+", must be one of "+Object.keys(En))}),Ce}var $=L("src","RGB"),j=L("dst","RGB");m.optional(function(){var Y=v.constants.invalidBlendCombinations;v.assert(b,Y+".indexOf("+$+'+", "+'+j+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var le=b.def(F,"[",$,"]"),Ge=b.def(F,"[",L("src","Alpha"),"]"),ke=b.def(F,"[",j,"]"),be=b.def(F,"[",L("dst","Alpha"),"]");return[le,ke,Ge,be]});case Hs:return E(function(v){if(typeof v=="string")return m.commandParameter(v,N,"invalid "+A,c.commandStr),[N[v],N[v]];if(typeof v=="object")return m.commandParameter(v.rgb,N,A+".rgb",c.commandStr),m.commandParameter(v.alpha,N,A+".alpha",c.commandStr),[N[v.rgb],N[v.alpha]];m.commandRaise("invalid blend.equation",c.commandStr)},function(v,b,g){var F=v.constants.blendEquations,L=b.def(),$=b.def(),j=v.cond("typeof ",g,'==="string"');return m.optional(function(){function le(Ge,ke,be){v.assert(Ge,be+" in "+F,"invalid "+ke+", must be one of "+Object.keys(N))}le(j.then,A,g),v.assert(j.else,g+"&&typeof "+g+'==="object"',"invalid "+A),le(j.else,A+".rgb",g+".rgb"),le(j.else,A+".alpha",g+".alpha")}),j.then(L,"=",$,"=",F,"[",g,"];"),j.else(L,"=",F,"[",g,".rgb];",$,"=",F,"[",g,".alpha];"),b(j),[L,$]});case vc:return E(function(v){return m.command(pt(v)&&v.length===4,"blend.color must be a 4d array",c.commandStr),Yt(4,function(b){return+v[b]})},function(v,b,g){return m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===4","blend.color must be a 4d array")}),Yt(4,function(F){return b.def("+",g,"[",F,"]")})});case Cc:return E(function(v){return m.commandType(v,"number",w,c.commandStr),v|0},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="number"',"invalid stencil.mask")}),b.def(g,"|0")});case Qs:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.cmp||"keep",g=v.ref||0,F="mask"in v?v.mask:-1;return m.commandParameter(b,tr,A+".cmp",c.commandStr),m.commandType(g,"number",A+".ref",c.commandStr),m.commandType(F,"number",A+".mask",c.commandStr),[tr[b],g,F]},function(v,b,g){var F=v.constants.compareFuncs;m.optional(function(){function le(){v.assert(b,Array.prototype.join.call(arguments,""),"invalid stencil.func")}le(g+"&&typeof ",g,'==="object"'),le('!("cmp" in ',g,")||(",g,".cmp in ",F,")")});var L=b.def('"cmp" in ',g,"?",F,"[",g,".cmp]",":",Qn),$=b.def(g,".ref|0"),j=b.def('"mask" in ',g,"?",g,".mask|0:-1");return[L,$,j]});case Ks:case kr:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.fail||"keep",g=v.zfail||"keep",F=v.zpass||"keep";return m.commandParameter(b,Kn,A+".fail",c.commandStr),m.commandParameter(g,Kn,A+".zfail",c.commandStr),m.commandParameter(F,Kn,A+".zpass",c.commandStr),[A===kr?Ti:Gr,Kn[b],Kn[g],Kn[F]]},function(v,b,g){var F=v.constants.stencilOps;m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid "+A)});function L($){return m.optional(function(){v.assert(b,'!("'+$+'" in '+g+")||("+g+"."+$+" in "+F+")","invalid "+A+"."+$+", must be one of "+Object.keys(Kn))}),b.def('"',$,'" in ',g,"?",F,"[",g,".",$,"]:",Qn)}return[A===kr?Ti:Gr,L("fail"),L("zfail"),L("zpass")]});case Ys:return E(function(v){m.commandType(v,"object",w,c.commandStr);var b=v.factor|0,g=v.units|0;return m.commandType(b,"number",w+".factor",c.commandStr),m.commandType(g,"number",w+".units",c.commandStr),[b,g]},function(v,b,g){m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid "+A)});var F=b.def(g,".factor|0"),L=b.def(g,".units|0");return[F,L]});case Sc:return E(function(v){var b=0;return v==="front"?b=Gr:v==="back"&&(b=Ti),m.command(!!b,w,c.commandStr),b},function(v,b,g){return m.optional(function(){v.assert(b,g+'==="front"||'+g+'==="back"',"invalid cull.face")}),b.def(g,'==="front"?',Gr,":",Ti)});case qs:return E(function(v){return m.command(typeof v=="number"&&v>=M.lineWidthDims[0]&&v<=M.lineWidthDims[1],"invalid line width, must be a positive number between "+M.lineWidthDims[0]+" and "+M.lineWidthDims[1],c.commandStr),v},function(v,b,g){return m.optional(function(){v.assert(b,"typeof "+g+'==="number"&&'+g+">="+M.lineWidthDims[0]+"&&"+g+"<="+M.lineWidthDims[1],"invalid line width")}),g});case js:return E(function(v){return m.commandParameter(v,ff,w,c.commandStr),ff[v]},function(v,b,g){return m.optional(function(){v.assert(b,g+'==="cw"||'+g+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),b.def(g+'==="cw"?'+Fc+":"+sf)});case Xs:return E(function(v){return m.command(pt(v)&&v.length===4,"color.mask must be length 4 array",c.commandStr),v.map(function(b){return!!b})},function(v,b,g){return m.optional(function(){v.assert(b,v.shared.isArrayLike+"("+g+")&&"+g+".length===4","invalid color.mask")}),Yt(4,function(F){return"!!"+g+"["+F+"]"})});case Zs:return E(function(v){m.command(typeof v=="object"&&v,w,c.commandStr);var b="value"in v?v.value:1,g=!!v.invert;return m.command(typeof b=="number"&&b>=0&&b<=1,"sample.coverage.value must be a number between 0 and 1",c.commandStr),[b,g]},function(v,b,g){m.optional(function(){v.assert(b,g+"&&typeof "+g+'==="object"',"invalid sample.coverage")});var F=b.def('"value" in ',g,"?+",g,".value:1"),L=b.def("!!",g,".invert");return[F,L]})}}),I}function tt(p,c){var T=p.static,C=p.dynamic,I={};return Object.keys(T).forEach(function(A){var w=T[A],E;if(typeof w=="number"||typeof w=="boolean")E=St(function(){return w});else if(typeof w=="function"){var v=w._reglType;v==="texture2d"||v==="textureCube"?E=St(function(b){return b.link(w)}):v==="framebuffer"||v==="framebufferCube"?(m.command(w.color.length>0,'missing color attachment for framebuffer sent to uniform "'+A+'"',c.commandStr),E=St(function(b){return b.link(w.color[0])})):m.commandRaise('invalid data for uniform "'+A+'"',c.commandStr)}else pt(w)?E=St(function(b){var g=b.global.def("[",Yt(w.length,function(F){return m.command(typeof w[F]=="number"||typeof w[F]=="boolean","invalid uniform "+A,b.commandStr),w[F]}),"]");return g}):m.commandRaise('invalid or missing data for uniform "'+A+'"',c.commandStr);E.value=w,I[A]=E}),Object.keys(C).forEach(function(A){var w=C[A];I[A]=Jt(w,function(E,v){return E.invoke(v,w)})}),I}function Et(p,c){var T=p.static,C=p.dynamic,I={};return Object.keys(T).forEach(function(A){var w=T[A],E=h.id(A),v=new k;if(pa(w))v.state=Qi,v.buffer=W.getBuffer(W.create(w,er,!1,!0)),v.type=0;else{var b=W.getBuffer(w);if(b)v.state=Qi,v.buffer=b,v.type=0;else if(m.command(typeof w=="object"&&w,"invalid data for attribute "+A,c.commandStr),"constant"in w){var g=w.constant;v.buffer="null",v.state=Gs,typeof g=="number"?v.x=g:(m.command(pt(g)&&g.length>0&&g.length<=4,"invalid constant for attribute "+A,c.commandStr),Zi.forEach(function(ke,be){be<g.length&&(v[ke]=g[be])}))}else{pa(w.buffer)?b=W.getBuffer(W.create(w.buffer,er,!1,!0)):b=W.getBuffer(w.buffer),m.command(!!b,'missing buffer for attribute "'+A+'"',c.commandStr);var F=w.offset|0;m.command(F>=0,'invalid offset for attribute "'+A+'"',c.commandStr);var L=w.stride|0;m.command(L>=0&&L<256,'invalid stride for attribute "'+A+'", must be integer betweeen [0, 255]',c.commandStr);var $=w.size|0;m.command(!("size"in w)||$>0&&$<=4,'invalid size for attribute "'+A+'", must be 1,2,3,4',c.commandStr);var j=!!w.normalized,le=0;"type"in w&&(m.commandParameter(w.type,mi,"invalid type for attribute "+A,c.commandStr),le=mi[w.type]);var Ge=w.divisor|0;m.optional(function(){"divisor"in w&&(m.command(Ge===0||te,'cannot specify divisor for attribute "'+A+'", instancing not supported',c.commandStr),m.command(Ge>=0,'invalid divisor for attribute "'+A+'"',c.commandStr));var ke=c.commandStr,be=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(w).forEach(function(Y){m.command(be.indexOf(Y)>=0,'unknown parameter "'+Y+'" for attribute pointer "'+A+'" (valid parameters are '+be+")",ke)})}),v.buffer=b,v.state=Qi,v.size=$,v.normalized=j,v.type=le||b.dtype,v.offset=F,v.stride=L,v.divisor=Ge}}I[A]=St(function(ke,be){var Y=ke.attribCache;if(E in Y)return Y[E];var U={isStream:!1};return Object.keys(v).forEach(function(Ce){U[Ce]=v[Ce]}),v.buffer&&(U.buffer=ke.link(v.buffer),U.type=U.type||U.buffer+".dtype"),Y[E]=U,U})}),Object.keys(C).forEach(function(A){var w=C[A];function E(v,b){var g=v.invoke(b,w),F=v.shared,L=v.constants,$=F.isBufferArgs,j=F.buffer;m.optional(function(){v.assert(b,g+"&&(typeof "+g+'==="object"||typeof '+g+'==="function")&&('+$+"("+g+")||"+j+".getBuffer("+g+")||"+j+".getBuffer("+g+".buffer)||"+$+"("+g+'.buffer)||("constant" in '+g+"&&(typeof "+g+'.constant==="number"||'+F.isArrayLike+"("+g+".constant))))",'invalid dynamic attribute "'+A+'"')});var le={isStream:b.def(!1)},Ge=new k;Ge.state=Qi,Object.keys(Ge).forEach(function(U){le[U]=b.def(""+Ge[U])});var ke=le.buffer,be=le.type;b("if(",$,"(",g,")){",le.isStream,"=true;",ke,"=",j,".createStream(",er,",",g,");",be,"=",ke,".dtype;","}else{",ke,"=",j,".getBuffer(",g,");","if(",ke,"){",be,"=",ke,".dtype;",'}else if("constant" in ',g,"){",le.state,"=",Gs,";","if(typeof "+g+'.constant === "number"){',le[Zi[0]],"=",g,".constant;",Zi.slice(1).map(function(U){return le[U]}).join("="),"=0;","}else{",Zi.map(function(U,Ce){return le[U]+"="+g+".constant.length>"+Ce+"?"+g+".constant["+Ce+"]:0;"}).join(""),"}}else{","if(",$,"(",g,".buffer)){",ke,"=",j,".createStream(",er,",",g,".buffer);","}else{",ke,"=",j,".getBuffer(",g,".buffer);","}",be,'="type" in ',g,"?",L.glTypes,"[",g,".type]:",ke,".dtype;",le.normalized,"=!!",g,".normalized;");function Y(U){b(le[U],"=",g,".",U,"|0;")}return Y("size"),Y("offset"),Y("stride"),Y("divisor"),b("}}"),b.exit("if(",le.isStream,"){",j,".destroyStream(",ke,");","}"),le}I[A]=Jt(w,E)}),I}function ht(p){var c=p.static,T=p.dynamic,C={};return Object.keys(c).forEach(function(I){var A=c[I];C[I]=St(function(w,E){return typeof A=="number"||typeof A=="boolean"?""+A:w.link(A)})}),Object.keys(T).forEach(function(I){var A=T[I];C[I]=Jt(A,function(w,E){return w.invoke(E,A)})}),C}function Tt(p,c,T,C,I){var A=p.static,w=p.dynamic;m.optional(function(){var Y=[xi,Lr,Dr,bi,_i,ra,Si,oa,Ir,Fr].concat(Le);function U(Ce){Object.keys(Ce).forEach(function(Ae){m.command(Y.indexOf(Ae)>=0,'unknown parameter "'+Ae+'"',I.commandStr)})}U(A),U(w)});var E=We(p,c),v=ye(p),b=Re(p,v,I),g=vt(p,I),F=yt(p,I),L=Je(p,I,E);function $(Y){var U=b[Y];U&&(F[Y]=U)}$(Bn),$(Se(ia));var j=Object.keys(F).length>0,le={framebuffer:v,draw:g,shader:L,state:F,dirty:j,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(le.profile=pe(p),le.uniforms=tt(T,I),le.drawVAO=le.scopeVAO=g.vao,!le.drawVAO&&L.program&&!E&&_.angle_instanced_arrays&&g.static.elements){var Ge=!0,ke=L.program.attributes.map(function(Y){var U=c.static[Y];return Ge=Ge&&!!U,U});if(Ge&&ke.length>0){var be=ie.getVAO(ie.createVAO({attributes:ke,elements:g.static.elements}));le.drawVAO=new Dt(null,null,null,function(Y,U){return Y.link(be)}),le.useVAO=!0}}return E?le.useVAO=!0:le.attributes=Et(c,I),le.context=ht(C),le}function Ct(p,c,T){var C=p.shared,I=C.context,A=p.scope();Object.keys(T).forEach(function(w){c.save(I,"."+w);var E=T[w],v=E.append(p,c);Array.isArray(v)?A(I,".",w,"=[",v.join(),"];"):A(I,".",w,"=",v,";")}),c(A)}function Pt(p,c,T,C){var I=p.shared,A=I.gl,w=I.framebuffer,E;xe&&(E=c.def(I.extensions,".webgl_draw_buffers"));var v=p.constants,b=v.drawBuffer,g=v.backBuffer,F;T?F=T.append(p,c):F=c.def(w,".next"),C||c("if(",F,"!==",w,".cur){"),c("if(",F,"){",A,".bindFramebuffer(",Oc,",",F,".framebuffer);"),xe&&c(E,".drawBuffersWEBGL(",b,"[",F,".colorAttachments.length]);"),c("}else{",A,".bindFramebuffer(",Oc,",null);"),xe&&c(E,".drawBuffersWEBGL(",g,");"),c("}",w,".cur=",F,";"),C||c("}")}function zt(p,c,T){var C=p.shared,I=C.gl,A=p.current,w=p.next,E=C.current,v=C.next,b=p.cond(E,".dirty");Le.forEach(function(g){var F=Se(g);if(!(F in T.state)){var L,$;if(F in w){L=w[F],$=A[F];var j=Yt(ge[F].length,function(Ge){return b.def(L,"[",Ge,"]")});b(p.cond(j.map(function(Ge,ke){return Ge+"!=="+$+"["+ke+"]"}).join("||")).then(I,".",H[F],"(",j,");",j.map(function(Ge,ke){return $+"["+ke+"]="+Ge}).join(";"),";"))}else{L=b.def(v,".",F);var le=p.cond(L,"!==",E,".",F);b(le),F in X?le(p.cond(L).then(I,".enable(",X[F],");").else(I,".disable(",X[F],");"),E,".",F,"=",L,";"):le(I,".",H[F],"(",L,");",E,".",F,"=",L,";")}}}),Object.keys(T.state).length===0&&b(E,".dirty=false;"),c(b)}function Bt(p,c,T,C){var I=p.shared,A=p.current,w=I.current,E=I.gl;Bc(Object.keys(T)).forEach(function(v){var b=T[v];if(!(C&&!C(b))){var g=b.append(p,c);if(X[v]){var F=X[v];Jn(b)?g?c(E,".enable(",F,");"):c(E,".disable(",F,");"):c(p.cond(g).then(E,".enable(",F,");").else(E,".disable(",F,");")),c(w,".",v,"=",g,";")}else if(pt(g)){var L=A[v];c(E,".",H[v],"(",g,");",g.map(function($,j){return L+"["+j+"]="+$}).join(";"),";")}else c(E,".",H[v],"(",g,");",w,".",v,"=",g,";")}})}function xt(p,c){te&&(p.instancing=c.def(p.shared.extensions,".angle_instanced_arrays"))}function Ye(p,c,T,C,I){var A=p.shared,w=p.stats,E=A.current,v=A.timer,b=T.profile;function g(){return typeof performance>"u"?"Date.now()":"performance.now()"}var F,L;function $(Y){F=c.def(),Y(F,"=",g(),";"),typeof I=="string"?Y(w,".count+=",I,";"):Y(w,".count++;"),J&&(C?(L=c.def(),Y(L,"=",v,".getNumPendingQueries();")):Y(v,".beginQuery(",w,");"))}function j(Y){Y(w,".cpuTime+=",g(),"-",F,";"),J&&(C?Y(v,".pushScopeStats(",L,",",v,".getNumPendingQueries(),",w,");"):Y(v,".endQuery();"))}function le(Y){var U=c.def(E,".profile");c(E,".profile=",Y,";"),c.exit(E,".profile=",U,";")}var Ge;if(b){if(Jn(b)){b.enable?($(c),j(c.exit),le("true")):le("false");return}Ge=b.append(p,c),le(Ge)}else Ge=c.def(E,".profile");var ke=p.block();$(ke),c("if(",Ge,"){",ke,"}");var be=p.block();j(be),c.exit("if(",Ge,"){",be,"}")}function Ut(p,c,T,C,I){var A=p.shared;function w(v){switch(v){case aa:case la:case ha:return 2;case sa:case ua:case da:return 3;case fa:case ca:case ma:return 4;default:return 1}}function E(v,b,g){var F=A.gl,L=c.def(v,".location"),$=c.def(A.attributes,"[",L,"]"),j=g.state,le=g.buffer,Ge=[g.x,g.y,g.z,g.w],ke=["buffer","normalized","offset","stride"];function be(){c("if(!",$,".buffer){",F,".enableVertexAttribArray(",L,");}");var U=g.type,Ce;if(g.size?Ce=c.def(g.size,"||",b):Ce=b,c("if(",$,".type!==",U,"||",$,".size!==",Ce,"||",ke.map(function(Me){return $+"."+Me+"!=="+g[Me]}).join("||"),"){",F,".bindBuffer(",er,",",le,".buffer);",F,".vertexAttribPointer(",[L,Ce,U,g.normalized,g.stride,g.offset],");",$,".type=",U,";",$,".size=",Ce,";",ke.map(function(Me){return $+"."+Me+"="+g[Me]+";"}).join(""),"}"),te){var Ae=g.divisor;c("if(",$,".divisor!==",Ae,"){",p.instancing,".vertexAttribDivisorANGLE(",[L,Ae],");",$,".divisor=",Ae,";}")}}function Y(){c("if(",$,".buffer){",F,".disableVertexAttribArray(",L,");",$,".buffer=null;","}if(",Zi.map(function(U,Ce){return $+"."+U+"!=="+Ge[Ce]}).join("||"),"){",F,".vertexAttrib4f(",L,",",Ge,");",Zi.map(function(U,Ce){return $+"."+U+"="+Ge[Ce]+";"}).join(""),"}")}j===Qi?be():j===Gs?Y():(c("if(",j,"===",Qi,"){"),be(),c("}else{"),Y(),c("}"))}C.forEach(function(v){var b=v.name,g=T.attributes[b],F;if(g){if(!I(g))return;F=g.append(p,c)}else{if(!I(Uc))return;var L=p.scopeAttrib(b);m.optional(function(){p.assert(c,L+".state","missing attribute "+b)}),F={},Object.keys(new k).forEach(function($){F[$]=c.def(L,".",$)})}E(p.link(v),w(v.info.type),F)})}function ot(p,c,T,C,I,A){for(var w=p.shared,E=w.gl,v={},b,g=0;g<C.length;++g){var F=C[g],L=F.name,$=F.info.type,j=F.info.size,le=T.uniforms[L];if(j>1){if(!le)continue;var Ge=L.replace("[0]","");if(v[Ge])continue;v[Ge]=1}var ke=p.link(F),be=ke+".location",Y;if(le){if(!I(le))continue;if(Jn(le)){var U=le.value;if(m.command(U!==null&&typeof U<"u",'missing uniform "'+L+'"',p.commandStr),$===Or||$===Nr){m.command(typeof U=="function"&&($===Or&&(U._reglType==="texture2d"||U._reglType==="framebuffer")||$===Nr&&(U._reglType==="textureCube"||U._reglType==="framebufferCube")),"invalid texture for uniform "+L,p.commandStr);var Ce=p.link(U._texture||U.color[0]._texture);c(E,".uniform1i(",be,",",Ce+".bind());"),c.exit(Ce,".unbind();")}else if($===zr||$===Rr||$===Mr){m.optional(function(){m.command(pt(U),"invalid matrix for uniform "+L,p.commandStr),m.command($===zr&&U.length===4||$===Rr&&U.length===9||$===Mr&&U.length===16,"invalid length for matrix uniform "+L,p.commandStr)});var Ae=p.global.def("new Float32Array(["+Array.prototype.slice.call(U)+"])"),Me=2;$===Rr?Me=3:$===Mr&&(Me=4),c(E,".uniformMatrix",Me,"fv(",be,",false,",Ae,");")}else{switch($){case nf:j===1?m.commandType(U,"number","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1f";break;case aa:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2f";break;case sa:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3f";break;case fa:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4f";break;case of:j===1?m.commandType(U,"boolean","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1i";break;case rf:j===1?m.commandType(U,"number","uniform "+L,p.commandStr):m.command(pt(U)&&U.length===j,"uniform "+L,p.commandStr),b="1i";break;case ha:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2i";break;case la:m.command(pt(U)&&U.length&&U.length%2===0&&U.length<=j*2,"uniform "+L,p.commandStr),b="2i";break;case da:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3i";break;case ua:m.command(pt(U)&&U.length&&U.length%3===0&&U.length<=j*3,"uniform "+L,p.commandStr),b="3i";break;case ma:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4i";break;case ca:m.command(pt(U)&&U.length&&U.length%4===0&&U.length<=j*4,"uniform "+L,p.commandStr),b="4i";break}j>1?(b+="v",U=p.global.def("["+Array.prototype.slice.call(U)+"]")):U=pt(U)?Array.prototype.slice.call(U):U,c(E,".uniform",b,"(",be,",",U,");")}continue}else Y=le.append(p,c)}else{if(!I(Uc))continue;Y=c.def(w.uniforms,"[",h.id(L),"]")}$===Or?(m(!Array.isArray(Y),"must specify a scalar prop for textures"),c("if(",Y,"&&",Y,'._reglType==="framebuffer"){',Y,"=",Y,".color[0];","}")):$===Nr&&(m(!Array.isArray(Y),"must specify a scalar prop for cube maps"),c("if(",Y,"&&",Y,'._reglType==="framebufferCube"){',Y,"=",Y,".color[0];","}")),m.optional(function(){function on(en,va){p.assert(c,en,'bad data or missing for uniform "'+L+'". '+va)}function Ci(en,va){va===1&&m(!Array.isArray(Y),"must not specify an array type for uniform"),on("Array.isArray("+Y+") && typeof "+Y+'[0]===" '+en+'" || typeof '+Y+'==="'+en+'"',"invalid type, expected "+en)}function un(en,va,ga){Array.isArray(Y)?m(Y.length&&Y.length%en===0&&Y.length<=en*ga,"must have length of "+(ga===1?"":"n * ")+en):on(w.isArrayLike+"("+Y+")&&"+Y+".length && "+Y+".length % "+en+" === 0 && "+Y+".length<="+en*ga,"invalid vector, should have length of "+(ga===1?"":"n * ")+en,p.commandStr)}function qc(en){m(!Array.isArray(Y),"must not specify a value type"),on("typeof "+Y+'==="function"&&'+Y+'._reglType==="texture'+(en===Dc?"2d":"Cube")+'"',"invalid texture type",p.commandStr)}switch($){case rf:Ci("number",j);break;case la:un(2,"number",j);break;case ua:un(3,"number",j);break;case ca:un(4,"number",j);break;case nf:Ci("number",j);break;case aa:un(2,"number",j);break;case sa:un(3,"number",j);break;case fa:un(4,"number",j);break;case of:Ci("boolean",j);break;case ha:un(2,"boolean",j);break;case da:un(3,"boolean",j);break;case ma:un(4,"boolean",j);break;case zr:un(4,"number",j);break;case Rr:un(9,"number",j);break;case Mr:un(16,"number",j);break;case Or:qc(Dc);break;case Nr:qc(Dx);break}});var st=1;switch($){case Or:case Nr:var Vt=c.def(Y,"._texture");c(E,".uniform1i(",be,",",Vt,".bind());"),c.exit(Vt,".unbind();");continue;case rf:case of:b="1i";break;case la:case ha:b="2i",st=2;break;case ua:case da:b="3i",st=3;break;case ca:case ma:b="4i",st=4;break;case nf:b="1f";break;case aa:b="2f",st=2;break;case sa:b="3f",st=3;break;case fa:b="4f",st=4;break;case zr:b="Matrix2fv";break;case Rr:b="Matrix3fv";break;case Mr:b="Matrix4fv";break}if(b.indexOf("Matrix")===-1&&j>1&&(b+="v",st=1),b.charAt(0)==="M"){c(E,".uniform",b,"(",be,",");var Ai=Math.pow($-zr+2,2),Un=p.global.def("new Float32Array(",Ai,")");Array.isArray(Y)?c("false,(",Yt(Ai,function(on){return Un+"["+on+"]="+Y[on]}),",",Un,")"):c("false,(Array.isArray(",Y,")||",Y," instanceof Float32Array)?",Y,":(",Yt(Ai,function(on){return Un+"["+on+"]="+Y+"["+on+"]"}),",",Un,")"),c(");")}else if(st>1){for(var Pn=[],ei=[],Ei=0;Ei<st;++Ei)Array.isArray(Y)?ei.push(Y[Ei]):ei.push(c.def(Y+"["+Ei+"]")),A&&Pn.push(c.def());A&&c("if(!",p.batchId,"||",Pn.map(function(on,Ci){return on+"!=="+ei[Ci]}).join("||"),"){",Pn.map(function(on,Ci){return on+"="+ei[Ci]+";"}).join("")),c(E,".uniform",b,"(",be,",",ei.join(","),");"),A&&c("}")}else{if(m(!Array.isArray(Y),"uniform value must not be an array"),A){var jc=c.def();c("if(!",p.batchId,"||",jc,"!==",Y,"){",jc,"=",Y,";")}c(E,".uniform",b,"(",be,",",Y,");"),A&&c("}")}}}function Fe(p,c,T,C){var I=p.shared,A=I.gl,w=I.draw,E=C.draw;function v(){var Ce=E.elements,Ae,Me=c;return Ce?((Ce.contextDep&&C.contextDynamic||Ce.propDep)&&(Me=T),Ae=Ce.append(p,Me),E.elementsActive&&Me("if("+Ae+")"+A+".bindBuffer("+tf+","+Ae+".buffer.buffer);")):(Ae=Me.def(),Me(Ae,"=",w,".",bi,";","if(",Ae,"){",A,".bindBuffer(",tf,",",Ae,".buffer.buffer);}","else if(",I.vao,".currentVAO){",Ae,"=",p.shared.elements+".getElements("+I.vao,".currentVAO.elements);",Z?"":"if("+Ae+")"+A+".bindBuffer("+tf+","+Ae+".buffer.buffer);","}")),Ae}function b(){var Ce=E.count,Ae,Me=c;return Ce?((Ce.contextDep&&C.contextDynamic||Ce.propDep)&&(Me=T),Ae=Ce.append(p,Me),m.optional(function(){Ce.MISSING&&p.assert(c,"false","missing vertex count"),Ce.DYNAMIC&&p.assert(Me,Ae+">=0","missing vertex count")})):(Ae=Me.def(w,".",Si),m.optional(function(){p.assert(Me,Ae+">=0","missing vertex count")})),Ae}var g=v();function F(Ce){var Ae=E[Ce];return Ae?Ae.contextDep&&C.contextDynamic||Ae.propDep?Ae.append(p,T):Ae.append(p,c):c.def(w,".",Ce)}var L=F(_i),$=F(ra),j=b();if(typeof j=="number"){if(j===0)return}else T("if(",j,"){"),T.exit("}");var le,Ge;te&&(le=F(oa),Ge=p.instancing);var ke=g+".type",be=E.elements&&Jn(E.elements)&&!E.vaoActive;function Y(){function Ce(){T(Ge,".drawElementsInstancedANGLE(",[L,j,ke,$+"<<(("+ke+"-"+cc+")>>1)",le],");")}function Ae(){T(Ge,".drawArraysInstancedANGLE(",[L,$,j,le],");")}g&&g!=="null"?be?Ce():(T("if(",g,"){"),Ce(),T("}else{"),Ae(),T("}")):Ae()}function U(){function Ce(){T(A+".drawElements("+[L,j,ke,$+"<<(("+ke+"-"+cc+")>>1)"]+");")}function Ae(){T(A+".drawArrays("+[L,$,j]+");")}g&&g!=="null"?be?Ce():(T("if(",g,"){"),Ce(),T("}else{"),Ae(),T("}")):Ae()}te&&(typeof le!="number"||le>=0)?typeof le=="string"?(T("if(",le,">0){"),Y(),T("}else if(",le,"<0){"),U(),T("}")):Y():U()}function et(p,c,T,C,I){var A=Ue(),w=A.proc("body",I);return m.optional(function(){A.commandStr=c.commandStr,A.command=A.link(c.commandStr)}),te&&(A.instancing=w.def(A.shared.extensions,".angle_instanced_arrays")),p(A,w,T,C),A.compile().body}function it(p,c,T,C){xt(p,c),T.useVAO?T.drawVAO?c(p.shared.vao,".setVAO(",T.drawVAO.append(p,c),");"):c(p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"):(c(p.shared.vao,".setVAO(null);"),Ut(p,c,T,C.attributes,function(){return!0})),ot(p,c,T,C.uniforms,function(){return!0},!1),Fe(p,c,c,T)}function bt(p,c){var T=p.proc("draw",1);xt(p,T),Ct(p,T,c.context),Pt(p,T,c.framebuffer),zt(p,T,c),Bt(p,T,c.state),Ye(p,T,c,!1,!0);var C=c.shader.progVar.append(p,T);if(T(p.shared.gl,".useProgram(",C,".program);"),c.shader.program)it(p,T,c,c.shader.program);else{T(p.shared.vao,".setVAO(null);");var I=p.global.def("{}"),A=T.def(C,".id"),w=T.def(I,"[",A,"]");T(p.cond(w).then(w,".call(this,a0);").else(w,"=",I,"[",A,"]=",p.link(function(E){return et(it,p,c,E,1)}),"(",C,");",w,".call(this,a0);"))}Object.keys(c.state).length>0&&T(p.shared.current,".dirty=true;"),p.shared.vao&&T(p.shared.vao,".setVAO(null);")}function Cn(p,c,T,C){p.batchId="a1",xt(p,c);function I(){return!0}Ut(p,c,T,C.attributes,I),ot(p,c,T,C.uniforms,I,!1),Fe(p,c,c,T)}function wi(p,c,T,C){xt(p,c);var I=T.contextDep,A=c.def(),w="a0",E="a1",v=c.def();p.shared.props=v,p.batchId=A;var b=p.scope(),g=p.scope();c(b.entry,"for(",A,"=0;",A,"<",E,";++",A,"){",v,"=",w,"[",A,"];",g,"}",b.exit);function F(ke){return ke.contextDep&&I||ke.propDep}function L(ke){return!F(ke)}if(T.needsContext&&Ct(p,g,T.context),T.needsFramebuffer&&Pt(p,g,T.framebuffer),Bt(p,g,T.state,F),T.profile&&F(T.profile)&&Ye(p,g,T,!1,!0),C)T.useVAO?T.drawVAO?F(T.drawVAO)?g(p.shared.vao,".setVAO(",T.drawVAO.append(p,g),");"):b(p.shared.vao,".setVAO(",T.drawVAO.append(p,b),");"):b(p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"):(b(p.shared.vao,".setVAO(null);"),Ut(p,b,T,C.attributes,L),Ut(p,g,T,C.attributes,F)),ot(p,b,T,C.uniforms,L,!1),ot(p,g,T,C.uniforms,F,!0),Fe(p,b,g,T);else{var $=p.global.def("{}"),j=T.shader.progVar.append(p,g),le=g.def(j,".id"),Ge=g.def($,"[",le,"]");g(p.shared.gl,".useProgram(",j,".program);","if(!",Ge,"){",Ge,"=",$,"[",le,"]=",p.link(function(ke){return et(Cn,p,T,ke,2)}),"(",j,");}",Ge,".call(this,a0[",A,"],",A,");")}}function x(p,c){var T=p.proc("batch",2);p.batchId="0",xt(p,T);var C=!1,I=!0;Object.keys(c.context).forEach(function($){C=C||c.context[$].propDep}),C||(Ct(p,T,c.context),I=!1);var A=c.framebuffer,w=!1;A?(A.propDep?C=w=!0:A.contextDep&&C&&(w=!0),w||Pt(p,T,A)):Pt(p,T,null),c.state.viewport&&c.state.viewport.propDep&&(C=!0);function E($){return $.contextDep&&C||$.propDep}zt(p,T,c),Bt(p,T,c.state,function($){return!E($)}),(!c.profile||!E(c.profile))&&Ye(p,T,c,!1,"a1"),c.contextDep=C,c.needsContext=I,c.needsFramebuffer=w;var v=c.shader.progVar;if(v.contextDep&&C||v.propDep)wi(p,T,c,null);else{var b=v.append(p,T);if(T(p.shared.gl,".useProgram(",b,".program);"),c.shader.program)wi(p,T,c,c.shader.program);else{T(p.shared.vao,".setVAO(null);");var g=p.global.def("{}"),F=T.def(b,".id"),L=T.def(g,"[",F,"]");T(p.cond(L).then(L,".call(this,a0,a1);").else(L,"=",g,"[",F,"]=",p.link(function($){return et(wi,p,c,$,2)}),"(",b,");",L,".call(this,a0,a1);"))}}Object.keys(c.state).length>0&&T(p.shared.current,".dirty=true;"),p.shared.vao&&T(p.shared.vao,".setVAO(null);")}function O(p,c){var T=p.proc("scope",3);p.batchId="a2";var C=p.shared,I=C.current;Ct(p,T,c.context),c.framebuffer&&c.framebuffer.append(p,T),Bc(Object.keys(c.state)).forEach(function(w){var E=c.state[w],v=E.append(p,T);pt(v)?v.forEach(function(b,g){T.set(p.next[w],"["+g+"]",b)}):T.set(C.next,"."+w,v)}),Ye(p,T,c,!0,!0),[bi,ra,Si,oa,_i].forEach(function(w){var E=c.draw[w];E&&T.set(C.draw,"."+w,""+E.append(p,T))}),Object.keys(c.uniforms).forEach(function(w){var E=c.uniforms[w].append(p,T);Array.isArray(E)&&(E="["+E.join()+"]"),T.set(C.uniforms,"["+h.id(w)+"]",E)}),Object.keys(c.attributes).forEach(function(w){var E=c.attributes[w].append(p,T),v=p.scopeAttrib(w);Object.keys(new k).forEach(function(b){T.set(v,"."+b,E[b])})}),c.scopeVAO&&T.set(C.vao,".targetVAO",c.scopeVAO.append(p,T));function A(w){var E=c.shader[w];E&&T.set(C.shader,"."+w,E.append(p,T))}A(Lr),A(Dr),Object.keys(c.state).length>0&&(T(I,".dirty=true;"),T.exit(I,".dirty=true;")),T("a1(",p.shared.context,",a0,",p.batchId,");")}function z(p){if(!(typeof p!="object"||pt(p))){for(var c=Object.keys(p),T=0;T<c.length;++T)if(It.isDynamic(p[c[T]]))return!0;return!1}}function _e(p,c,T){var C=c.static[T];if(!C||!z(C))return;var I=p.global,A=Object.keys(C),w=!1,E=!1,v=!1,b=p.global.def("{}");A.forEach(function(F){var L=C[F];if(It.isDynamic(L)){typeof L=="function"&&(L=C[F]=It.unbox(L));var $=Jt(L,null);w=w||$.thisDep,v=v||$.propDep,E=E||$.contextDep}else{switch(I(b,".",F,"="),typeof L){case"number":I(L);break;case"string":I('"',L,'"');break;case"object":Array.isArray(L)&&I("[",L.join(),"]");break;default:I(p.link(L));break}I(";")}});function g(F,L){A.forEach(function($){var j=C[$];if(It.isDynamic(j)){var le=F.invoke(L,j);L(b,".",$,"=",le,";")}})}c.dynamic[T]=new It.DynamicVariable(na,{thisDep:w,contextDep:E,propDep:v,ref:b,append:g}),delete c.static[T]}function Ke(p,c,T,C,I){var A=Ue();A.stats=A.link(I),Object.keys(c.static).forEach(function(E){_e(A,c,E)}),kx.forEach(function(E){_e(A,p,E)});var w=Tt(p,c,T,C,A);return bt(A,w),O(A,w),x(A,w),i(A.compile(),{destroy:function(){w.shader.program.destroy()}})}return{next:me,current:ge,procs:function(){var p=Ue(),c=p.proc("poll"),T=p.proc("refresh"),C=p.block();c(C),T(C);var I=p.shared,A=I.gl,w=I.next,E=I.current;C(E,".dirty=false;"),Pt(p,c),Pt(p,T,null,!0);var v;te&&(v=p.link(te)),_.oes_vertex_array_object&&T(p.link(_.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var b=0;b<M.maxAttributes;++b){var g=T.def(I.attributes,"[",b,"]"),F=p.cond(g,".buffer");F.then(A,".enableVertexAttribArray(",b,");",A,".bindBuffer(",er,",",g,".buffer.buffer);",A,".vertexAttribPointer(",b,",",g,".size,",g,".type,",g,".normalized,",g,".stride,",g,".offset);").else(A,".disableVertexAttribArray(",b,");",A,".vertexAttrib4f(",b,",",g,".x,",g,".y,",g,".z,",g,".w);",g,".buffer=null;"),T(F),te&&T(v,".vertexAttribDivisorANGLE(",b,",",g,".divisor);")}return T(p.shared.vao,".currentVAO=null;",p.shared.vao,".setVAO(",p.shared.vao,".targetVAO);"),Object.keys(X).forEach(function(L){var $=X[L],j=C.def(w,".",L),le=p.block();le("if(",j,"){",A,".enable(",$,")}else{",A,".disable(",$,")}",E,".",L,"=",j,";"),T(le),c("if(",j,"!==",E,".",L,"){",le,"}")}),Object.keys(H).forEach(function(L){var $=H[L],j=ge[L],le,Ge,ke=p.block();if(ke(A,".",$,"("),pt(j)){var be=j.length;le=p.global.def(w,".",L),Ge=p.global.def(E,".",L),ke(Yt(be,function(Y){return le+"["+Y+"]"}),");",Yt(be,function(Y){return Ge+"["+Y+"]="+le+"["+Y+"];"}).join("")),c("if(",Yt(be,function(Y){return le+"["+Y+"]!=="+Ge+"["+Y+"]"}).join("||"),"){",ke,"}")}else le=C.def(w,".",L),Ge=C.def(E,".",L),ke(le,");",E,".",L,"=",le,";"),c("if(",le,"!==",Ge,"){",ke,"}");T(ke)}),p.compile()}(),compile:Ke}}function qx(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var Yx=34918,Zx=34919,Vc=35007,Qx=function(a,h){if(!h.ext_disjoint_timer_query)return null;var _=[];function M(){return _.pop()||h.ext_disjoint_timer_query.createQueryEXT()}function W(te){_.push(te)}var R=[];function B(te){var xe=M();h.ext_disjoint_timer_query.beginQueryEXT(Vc,xe),R.push(xe),J(R.length-1,R.length,te)}function K(){h.ext_disjoint_timer_query.endQueryEXT(Vc)}function Q(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var ie=[];function oe(){return ie.pop()||new Q}function re(te){ie.push(te)}var ue=[];function J(te,xe,Z){var ge=oe();ge.startQueryIndex=te,ge.endQueryIndex=xe,ge.sum=0,ge.stats=Z,ue.push(ge)}var ne=[],k=[];function N(){var te,xe,Z=R.length;if(Z!==0){k.length=Math.max(k.length,Z+1),ne.length=Math.max(ne.length,Z+1),ne[0]=0,k[0]=0;var ge=0;for(te=0,xe=0;xe<R.length;++xe){var me=R[xe];h.ext_disjoint_timer_query.getQueryObjectEXT(me,Zx)?(ge+=h.ext_disjoint_timer_query.getQueryObjectEXT(me,Yx),W(me)):R[te++]=me,ne[xe+1]=ge,k[xe+1]=te}for(R.length=te,te=0,xe=0;xe<ue.length;++xe){var Le=ue[xe],X=Le.startQueryIndex,H=Le.endQueryIndex;Le.sum+=ne[H]-ne[X];var Se=k[X],ce=k[H];ce===Se?(Le.stats.gpuTime+=Le.sum/1e6,re(Le)):(Le.startQueryIndex=Se,Le.endQueryIndex=ce,ue[te++]=Le)}ue.length=te}}return{beginQuery:B,endQuery:K,pushScopeStats:J,update:N,getNumPendingQueries:function(){return R.length},clear:function(){_.push.apply(_,R);for(var te=0;te<_.length;te++)h.ext_disjoint_timer_query.deleteQueryEXT(_[te]);R.length=0,_.length=0},restore:function(){R.length=0,_.length=0}}},Kx=16384,Jx=256,eb=1024,tb=34962,$c="webglcontextlost",Hc="webglcontextrestored",Wc=1,nb=2,ib=3;function Xc(a,h){for(var _=0;_<a.length;++_)if(a[_]===h)return _;return-1}function rb(a){var h=Lt(a);if(!h)return null;var _=h.gl,M=_.getContextAttributes(),W=_.isContextLost(),R=Xn(_,h);if(!R)return null;var B=fs(),K=qx(),Q=R.extensions,ie=Qx(_,Q),oe=Oi(),re=_.drawingBufferWidth,ue=_.drawingBufferHeight,J={tick:0,time:0,viewportWidth:re,viewportHeight:ue,framebufferWidth:re,framebufferHeight:ue,drawingBufferWidth:re,drawingBufferHeight:ue,pixelRatio:h.pixelRatio},ne={},k={elements:null,primitive:4,count:-1,offset:0,instances:-1},N=Hg(_,Q),te=ay(_,K,h,ge),xe=yy(_,Q,te,K),Z=yx(_,Q,N,K,te,xe,k);function ge(Fe){return Z.destroyBuffer(Fe)}var me=Sx(_,B,K,h),Le=Yy(_,Q,N,function(){Se.procs.poll()},J,K,h),X=Zy(_,Q,N,K,h),H=vx(_,Q,N,Le,X,K),Se=jx(_,B,Q,N,te,xe,Le,H,ne,Z,me,k,J,ie,h),ce=Ax(_,H,Se.procs.poll,J,M,Q,N),ee=Se.next,he=_.canvas,de=[],He=[],Ue=[],pe=[h.onDestroy],ye=null;function Re(){if(de.length===0){ie&&ie.update(),ye=null;return}ye=ci.next(Re),Bt();for(var Fe=de.length-1;Fe>=0;--Fe){var et=de[Fe];et&&et(J,null,0)}_.flush(),ie&&ie.update()}function We(){!ye&&de.length>0&&(ye=ci.next(Re))}function Je(){ye&&(ci.cancel(Re),ye=null)}function vt(Fe){Fe.preventDefault(),W=!0,Je(),He.forEach(function(et){et()})}function yt(Fe){_.getError(),W=!1,R.restore(),me.restore(),te.restore(),Le.restore(),X.restore(),H.restore(),Z.restore(),ie&&ie.restore(),Se.procs.refresh(),We(),Ue.forEach(function(et){et()})}he&&(he.addEventListener($c,vt,!1),he.addEventListener(Hc,yt,!1));function tt(){de.length=0,Je(),he&&(he.removeEventListener($c,vt),he.removeEventListener(Hc,yt)),me.clear(),H.clear(),X.clear(),Z.clear(),Le.clear(),xe.clear(),te.clear(),ie&&ie.clear(),pe.forEach(function(Fe){Fe()})}function Et(Fe){m(!!Fe,"invalid args to regl({...})"),m.type(Fe,"object","invalid args to regl({...})");function et(I){var A=i({},I);delete A.uniforms,delete A.attributes,delete A.context,delete A.vao,"stencil"in A&&A.stencil.op&&(A.stencil.opBack=A.stencil.opFront=A.stencil.op,delete A.stencil.op);function w(E){if(E in A){var v=A[E];delete A[E],Object.keys(v).forEach(function(b){A[E+"."+b]=v[b]})}}return w("blend"),w("depth"),w("cull"),w("stencil"),w("polygonOffset"),w("scissor"),w("sample"),"vao"in I&&(A.vao=I.vao),A}function it(I,A){var w={},E={};return Object.keys(I).forEach(function(v){var b=I[v];if(It.isDynamic(b)){E[v]=It.unbox(b,v);return}else if(A&&Array.isArray(b)){for(var g=0;g<b.length;++g)if(It.isDynamic(b[g])){E[v]=It.unbox(b,v);return}}w[v]=b}),{dynamic:E,static:w}}var bt=it(Fe.context||{},!0),Cn=it(Fe.uniforms||{},!0),wi=it(Fe.attributes||{},!1),x=it(et(Fe),!1),O={gpuTime:0,cpuTime:0,count:0},z=Se.compile(x,wi,Cn,bt,O),_e=z.draw,Ke=z.batch,p=z.scope,c=[];function T(I){for(;c.length<I;)c.push(null);return c}function C(I,A){var w;if(W&&m.raise("context lost"),typeof I=="function")return p.call(this,null,I,0);if(typeof A=="function")if(typeof I=="number")for(w=0;w<I;++w)p.call(this,null,A,w);else if(Array.isArray(I))for(w=0;w<I.length;++w)p.call(this,I[w],A,w);else return p.call(this,I,A,0);else if(typeof I=="number"){if(I>0)return Ke.call(this,T(I|0),I|0)}else if(Array.isArray(I)){if(I.length)return Ke.call(this,I,I.length)}else return _e.call(this,I)}return i(C,{stats:O,destroy:function(){z.destroy()}})}var ht=H.setFBO=Et({framebuffer:It.define.call(null,Wc,"framebuffer")});function Tt(Fe,et){var it=0;Se.procs.poll();var bt=et.color;bt&&(_.clearColor(+bt[0]||0,+bt[1]||0,+bt[2]||0,+bt[3]||0),it|=Kx),"depth"in et&&(_.clearDepth(+et.depth),it|=Jx),"stencil"in et&&(_.clearStencil(et.stencil|0),it|=eb),m(!!it,"called regl.clear with no buffer specified"),_.clear(it)}function Ct(Fe){if(m(typeof Fe=="object"&&Fe,"regl.clear() takes an object as input"),"framebuffer"in Fe)if(Fe.framebuffer&&Fe.framebuffer_reglType==="framebufferCube")for(var et=0;et<6;++et)ht(i({framebuffer:Fe.framebuffer.faces[et]},Fe),Tt);else ht(Fe,Tt);else Tt(null,Fe)}function Pt(Fe){m.type(Fe,"function","regl.frame() callback must be a function"),de.push(Fe);function et(){var it=Xc(de,Fe);m(it>=0,"cannot cancel a frame twice");function bt(){var Cn=Xc(de,bt);de[Cn]=de[de.length-1],de.length-=1,de.length<=0&&Je()}de[it]=bt}return We(),{cancel:et}}function zt(){var Fe=ee.viewport,et=ee.scissor_box;Fe[0]=Fe[1]=et[0]=et[1]=0,J.viewportWidth=J.framebufferWidth=J.drawingBufferWidth=Fe[2]=et[2]=_.drawingBufferWidth,J.viewportHeight=J.framebufferHeight=J.drawingBufferHeight=Fe[3]=et[3]=_.drawingBufferHeight}function Bt(){J.tick+=1,J.time=Ye(),zt(),Se.procs.poll()}function xt(){Le.refresh(),zt(),Se.procs.refresh(),ie&&ie.update()}function Ye(){return(Oi()-oe)/1e3}xt();function Ut(Fe,et){m.type(et,"function","listener callback must be a function");var it;switch(Fe){case"frame":return Pt(et);case"lost":it=He;break;case"restore":it=Ue;break;case"destroy":it=pe;break;default:m.raise("invalid event, must be one of frame,lost,restore,destroy")}return it.push(et),{cancel:function(){for(var bt=0;bt<it.length;++bt)if(it[bt]===et){it[bt]=it[it.length-1],it.pop();return}}}}var ot=i(Et,{clear:Ct,prop:It.define.bind(null,Wc),context:It.define.bind(null,nb),this:It.define.bind(null,ib),draw:Et({}),buffer:function(Fe){return te.create(Fe,tb,!1,!1)},elements:function(Fe){return xe.create(Fe,!1)},texture:Le.create2D,cube:Le.createCube,renderbuffer:X.create,framebuffer:H.create,framebufferCube:H.createCube,vao:Z.createVAO,attributes:M,frame:Pt,on:Ut,limits:N,hasExtension:function(Fe){return N.extensions.indexOf(Fe.toLowerCase())>=0},read:ce,destroy:tt,_gl:_,_refresh:xt,poll:function(){Bt(),ie&&ie.update()},now:Ye,stats:K});return h.onDone(null,ot),ot}return rb})}(ro)),ro.exports}var Ap=wp();const Ep=za(Ap),Cp="#b3b3b3",Pp=void 0,Ra=void 0,kp=1,Ip=4,Lp="#666666",Dp=.1,Fp=1,zp=1,Qf="#222222",Oe={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: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},Rp=.7,Mp=.95,Op=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:Kf,setPrototypeOf:Jf,isFrozen:Np,getPrototypeOf:Gp,getOwnPropertyDescriptor:Bp}=Object;let{freeze:Xt,seal:an,create:el}=Object,{apply:Ma,construct:Oa}=typeof Reflect<"u"&&Reflect;Xt||(Xt=function(e){return e}),an||(an=function(e){return e}),Ma||(Ma=function(e,n,i){return e.apply(n,i)}),Oa||(Oa=function(e,n){return new e(...n)});const oo=qt(Array.prototype.forEach),Up=qt(Array.prototype.lastIndexOf),tl=qt(Array.prototype.pop),ur=qt(Array.prototype.push),Vp=qt(Array.prototype.splice),ao=qt(String.prototype.toLowerCase),Na=qt(String.prototype.toString),nl=qt(String.prototype.match),cr=qt(String.prototype.replace),$p=qt(String.prototype.indexOf),Hp=qt(String.prototype.trim),mn=qt(Object.prototype.hasOwnProperty),jt=qt(RegExp.prototype.test),hr=Wp(TypeError);function qt(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Ma(t,e,i)}}function Wp(t){return function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return Oa(t,n)}}function rt(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ao;Jf&&Jf(t,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const o=n(r);o!==r&&(Np(e)||(e[i]=o),r=o)}t[r]=!0}return t}function Xp(t){for(let e=0;e<t.length;e++)mn(t,e)||(t[e]=null);return t}function Dn(t){const e=el(null);for(const[n,i]of Kf(t))mn(t,n)&&(Array.isArray(i)?e[n]=Xp(i):i&&typeof i=="object"&&i.constructor===Object?e[n]=Dn(i):e[n]=i);return e}function dr(t,e){for(;t!==null;){const i=Bp(t,e);if(i){if(i.get)return qt(i.get);if(typeof i.value=="function")return qt(i.value)}t=Gp(t)}function n(){return null}return n}const il=Xt(["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"]),Ga=Xt(["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"]),Ba=Xt(["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"]),jp=Xt(["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"]),Ua=Xt(["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"]),qp=Xt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rl=Xt(["#text"]),ol=Xt(["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"]),Va=Xt(["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"]),al=Xt(["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"]),so=Xt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yp=an(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Zp=an(/<%[\w\W]*|[\w\W]*%>/gm),Qp=an(/\$\{[\w\W]*/gm),Kp=an(/^data-[\-\w.\u00B7-\uFFFF]+$/),Jp=an(/^aria-[\-\w]+$/),sl=an(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),e0=an(/^(?:\w+script|data):/i),t0=an(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fl=an(/^html$/i),n0=an(/^[a-z][.\w]*(-[.\w]+)+$/i);var ll=Object.freeze({__proto__:null,ARIA_ATTR:Jp,ATTR_WHITESPACE:t0,CUSTOM_ELEMENT:n0,DATA_ATTR:Kp,DOCTYPE_NAME:fl,ERB_EXPR:Zp,IS_ALLOWED_URI:sl,IS_SCRIPT_OR_DATA:e0,MUSTACHE_EXPR:Yp,TMPLIT_EXPR:Qp});const mr={element:1,text:3,progressingInstruction:7,comment:8,document:9},i0=function(){return typeof window>"u"?null:window},r0=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));const o="dompurify"+(i?"#"+i:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},ul=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function cl(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:i0();const e=$e=>cl($e);if(e.version="3.2.6",e.removed=[],!t||!t.document||t.document.nodeType!==mr.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const i=n,r=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:s,Node:f,Element:l,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:y,DOMParser:S,trustedTypes:D}=t,q=l.prototype,Te=dr(q,"cloneNode"),we=dr(q,"remove"),fe=dr(q,"nextSibling"),Ne=dr(q,"childNodes"),Ve=dr(q,"parentNode");if(typeof s=="function"){const $e=n.createElement("template");$e.content&&$e.content.ownerDocument&&(n=$e.content.ownerDocument)}let V,ae="";const{implementation:Ie,createNodeIterator:Be,createDocumentFragment:Xe,getElementsByTagName:nt}=n,{importNode:lt}=i;let Ee=ul();e.isSupported=typeof Kf=="function"&&typeof Ve=="function"&&Ie&&Ie.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ct,ERB_EXPR:ft,TMPLIT_EXPR:G,DATA_ATTR:Pe,ARIA_ATTR:se,IS_SCRIPT_OR_DATA:De,ATTR_WHITESPACE:qe,CUSTOM_ELEMENT:je}=ll;let{IS_ALLOWED_URI:Qe}=ll,Ze=null;const dt=rt({},[...il,...Ga,...Ba,...Ua,...rl]);let ut=null;const _t=rt({},[...ol,...Va,...al,...so]);let at=Object.seal(el(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}})),$t=null,Ht=null,Kt=!0,Mn=!0,wo=!1,Ao=!0,On=!1,si=!0,Tn=!1,Fi=!1,zi=!1,$n=!1,Mt=!1,fi=!1,li=!0,Eo=!1;const ss="user-content-";let m=!0,ui=!1,Hn={},Wn=null;const Co=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let wn=null;const yr=rt({},["audio","video","img","source","image","track"]);let Nn=null;const xr=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ri="http://www.w3.org/1998/Math/MathML",Mi="http://www.w3.org/2000/svg",sn="http://www.w3.org/1999/xhtml";let It=sn,ci=!1,Oi=null;const fs=rt({},[Ri,Mi,sn],Na);let Ni=rt({},["mi","mo","mn","ms","mtext"]),Gi=rt({},["annotation-xml"]);const ls=rt({},["title","style","font","a","script"]);let hi=null;const Po=["application/xhtml+xml","text/html"],ko="text/html";let Lt=null,Xn=null;const Yt=n.createElement("form"),Io=function(P){return P instanceof RegExp||P instanceof Function},br=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Xn&&Xn===P)){if((!P||typeof P!="object")&&(P={}),P=Dn(P),hi=Po.indexOf(P.PARSER_MEDIA_TYPE)===-1?ko:P.PARSER_MEDIA_TYPE,Lt=hi==="application/xhtml+xml"?Na:ao,Ze=mn(P,"ALLOWED_TAGS")?rt({},P.ALLOWED_TAGS,Lt):dt,ut=mn(P,"ALLOWED_ATTR")?rt({},P.ALLOWED_ATTR,Lt):_t,Oi=mn(P,"ALLOWED_NAMESPACES")?rt({},P.ALLOWED_NAMESPACES,Na):fs,Nn=mn(P,"ADD_URI_SAFE_ATTR")?rt(Dn(xr),P.ADD_URI_SAFE_ATTR,Lt):xr,wn=mn(P,"ADD_DATA_URI_TAGS")?rt(Dn(yr),P.ADD_DATA_URI_TAGS,Lt):yr,Wn=mn(P,"FORBID_CONTENTS")?rt({},P.FORBID_CONTENTS,Lt):Co,$t=mn(P,"FORBID_TAGS")?rt({},P.FORBID_TAGS,Lt):Dn({}),Ht=mn(P,"FORBID_ATTR")?rt({},P.FORBID_ATTR,Lt):Dn({}),Hn=mn(P,"USE_PROFILES")?P.USE_PROFILES:!1,Kt=P.ALLOW_ARIA_ATTR!==!1,Mn=P.ALLOW_DATA_ATTR!==!1,wo=P.ALLOW_UNKNOWN_PROTOCOLS||!1,Ao=P.ALLOW_SELF_CLOSE_IN_ATTR!==!1,On=P.SAFE_FOR_TEMPLATES||!1,si=P.SAFE_FOR_XML!==!1,Tn=P.WHOLE_DOCUMENT||!1,$n=P.RETURN_DOM||!1,Mt=P.RETURN_DOM_FRAGMENT||!1,fi=P.RETURN_TRUSTED_TYPE||!1,zi=P.FORCE_BODY||!1,li=P.SANITIZE_DOM!==!1,Eo=P.SANITIZE_NAMED_PROPS||!1,m=P.KEEP_CONTENT!==!1,ui=P.IN_PLACE||!1,Qe=P.ALLOWED_URI_REGEXP||sl,It=P.NAMESPACE||sn,Ni=P.MATHML_TEXT_INTEGRATION_POINTS||Ni,Gi=P.HTML_INTEGRATION_POINTS||Gi,at=P.CUSTOM_ELEMENT_HANDLING||{},P.CUSTOM_ELEMENT_HANDLING&&Io(P.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(at.tagNameCheck=P.CUSTOM_ELEMENT_HANDLING.tagNameCheck),P.CUSTOM_ELEMENT_HANDLING&&Io(P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(at.attributeNameCheck=P.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),P.CUSTOM_ELEMENT_HANDLING&&typeof P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(at.allowCustomizedBuiltInElements=P.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),On&&(Mn=!1),Mt&&($n=!0),Hn&&(Ze=rt({},rl),ut=[],Hn.html===!0&&(rt(Ze,il),rt(ut,ol)),Hn.svg===!0&&(rt(Ze,Ga),rt(ut,Va),rt(ut,so)),Hn.svgFilters===!0&&(rt(Ze,Ba),rt(ut,Va),rt(ut,so)),Hn.mathMl===!0&&(rt(Ze,Ua),rt(ut,al),rt(ut,so))),P.ADD_TAGS&&(Ze===dt&&(Ze=Dn(Ze)),rt(Ze,P.ADD_TAGS,Lt)),P.ADD_ATTR&&(ut===_t&&(ut=Dn(ut)),rt(ut,P.ADD_ATTR,Lt)),P.ADD_URI_SAFE_ATTR&&rt(Nn,P.ADD_URI_SAFE_ATTR,Lt),P.FORBID_CONTENTS&&(Wn===Co&&(Wn=Dn(Wn)),rt(Wn,P.FORBID_CONTENTS,Lt)),m&&(Ze["#text"]=!0),Tn&&rt(Ze,["html","head","body"]),Ze.table&&(rt(Ze,["tbody"]),delete $t.tbody),P.TRUSTED_TYPES_POLICY){if(typeof P.TRUSTED_TYPES_POLICY.createHTML!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof P.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');V=P.TRUSTED_TYPES_POLICY,ae=V.createHTML("")}else V===void 0&&(V=r0(D,r)),V!==null&&typeof ae=="string"&&(ae=V.createHTML(""));Xt&&Xt(P),Xn=P}},Lo=rt({},[...Ga,...Ba,...jp]),Do=rt({},[...Ua,...qp]),us=function(P){let ve=Ve(P);(!ve||!ve.tagName)&&(ve={namespaceURI:It,tagName:"template"});const ze=ao(P.tagName),mt=ao(ve.tagName);return Oi[P.namespaceURI]?P.namespaceURI===Mi?ve.namespaceURI===sn?ze==="svg":ve.namespaceURI===Ri?ze==="svg"&&(mt==="annotation-xml"||Ni[mt]):!!Lo[ze]:P.namespaceURI===Ri?ve.namespaceURI===sn?ze==="math":ve.namespaceURI===Mi?ze==="math"&&Gi[mt]:!!Do[ze]:P.namespaceURI===sn?ve.namespaceURI===Mi&&!Gi[mt]||ve.namespaceURI===Ri&&!Ni[mt]?!1:!Do[ze]&&(ls[ze]||!Lo[ze]):!!(hi==="application/xhtml+xml"&&Oi[P.namespaceURI]):!1},fn=function(P){ur(e.removed,{element:P});try{Ve(P).removeChild(P)}catch{we(P)}},jn=function(P,ve){try{ur(e.removed,{attribute:ve.getAttributeNode(P),from:ve})}catch{ur(e.removed,{attribute:null,from:ve})}if(ve.removeAttribute(P),P==="is")if($n||Mt)try{fn(ve)}catch{}else try{ve.setAttribute(P,"")}catch{}},Fo=function(P){let ve=null,ze=null;if(zi)P="<remove></remove>"+P;else{const At=nl(P,/^[\r\n\t ]+/);ze=At&&At[0]}hi==="application/xhtml+xml"&&It===sn&&(P='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+P+"</body></html>");const mt=V?V.createHTML(P):P;if(It===sn)try{ve=new S().parseFromString(mt,hi)}catch{}if(!ve||!ve.documentElement){ve=Ie.createDocument(It,"template",null);try{ve.documentElement.innerHTML=ci?ae:mt}catch{}}const Ot=ve.body||ve.documentElement;return P&&ze&&Ot.insertBefore(n.createTextNode(ze),Ot.childNodes[0]||null),It===sn?nt.call(ve,Tn?"html":"body")[0]:Tn?ve.documentElement:Ot},_r=function(P){return Be.call(P.ownerDocument||P,P,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Bi=function(P){return P instanceof y&&(typeof P.nodeName!="string"||typeof P.textContent!="string"||typeof P.removeChild!="function"||!(P.attributes instanceof d)||typeof P.removeAttribute!="function"||typeof P.setAttribute!="function"||typeof P.namespaceURI!="string"||typeof P.insertBefore!="function"||typeof P.hasChildNodes!="function")},gt=function(P){return typeof f=="function"&&P instanceof f};function vn($e,P,ve){oo($e,ze=>{ze.call(e,P,ve,Xn)})}const zo=function(P){let ve=null;if(vn(Ee.beforeSanitizeElements,P,null),Bi(P))return fn(P),!0;const ze=Lt(P.nodeName);if(vn(Ee.uponSanitizeElement,P,{tagName:ze,allowedTags:Ze}),si&&P.hasChildNodes()&&!gt(P.firstElementChild)&&jt(/<[/\w!]/g,P.innerHTML)&&jt(/<[/\w!]/g,P.textContent)||P.nodeType===mr.progressingInstruction||si&&P.nodeType===mr.comment&&jt(/<[/\w]/g,P.data))return fn(P),!0;if(!Ze[ze]||$t[ze]){if(!$t[ze]&&Mo(ze)&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,ze)||at.tagNameCheck instanceof Function&&at.tagNameCheck(ze)))return!1;if(m&&!Wn[ze]){const mt=Ve(P)||P.parentNode,Ot=Ne(P)||P.childNodes;if(Ot&&mt){const At=Ot.length;for(let Wt=At-1;Wt>=0;--Wt){const gn=Te(Ot[Wt],!0);gn.__removalCount=(P.__removalCount||0)+1,mt.insertBefore(gn,fe(P))}}}return fn(P),!0}return P instanceof l&&!us(P)||(ze==="noscript"||ze==="noembed"||ze==="noframes")&&jt(/<\/no(script|embed|frames)/i,P.innerHTML)?(fn(P),!0):(On&&P.nodeType===mr.text&&(ve=P.textContent,oo([ct,ft,G],mt=>{ve=cr(ve,mt," ")}),P.textContent!==ve&&(ur(e.removed,{element:P.cloneNode()}),P.textContent=ve)),vn(Ee.afterSanitizeElements,P,null),!1)},Ro=function(P,ve,ze){if(li&&(ve==="id"||ve==="name")&&(ze in n||ze in Yt))return!1;if(!(Mn&&!Ht[ve]&&jt(Pe,ve))){if(!(Kt&&jt(se,ve))){if(!ut[ve]||Ht[ve]){if(!(Mo(P)&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,P)||at.tagNameCheck instanceof Function&&at.tagNameCheck(P))&&(at.attributeNameCheck instanceof RegExp&&jt(at.attributeNameCheck,ve)||at.attributeNameCheck instanceof Function&&at.attributeNameCheck(ve))||ve==="is"&&at.allowCustomizedBuiltInElements&&(at.tagNameCheck instanceof RegExp&&jt(at.tagNameCheck,ze)||at.tagNameCheck instanceof Function&&at.tagNameCheck(ze))))return!1}else if(!Nn[ve]){if(!jt(Qe,cr(ze,qe,""))){if(!((ve==="src"||ve==="xlink:href"||ve==="href")&&P!=="script"&&$p(ze,"data:")===0&&wn[P])){if(!(wo&&!jt(De,cr(ze,qe,"")))){if(ze)return!1}}}}}}return!0},Mo=function(P){return P!=="annotation-xml"&&nl(P,je)},Oo=function(P){vn(Ee.beforeSanitizeAttributes,P,null);const{attributes:ve}=P;if(!ve||Bi(P))return;const ze={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ut,forceKeepAttr:void 0};let mt=ve.length;for(;mt--;){const Ot=ve[mt],{name:At,namespaceURI:Wt,value:gn}=Ot,di=Lt(At),Sr=gn;let Nt=At==="value"?Sr:Hp(Sr);if(ze.attrName=di,ze.attrValue=Nt,ze.keepAttr=!0,ze.forceKeepAttr=void 0,vn(Ee.uponSanitizeAttribute,P,ze),Nt=ze.attrValue,Eo&&(di==="id"||di==="name")&&(jn(At,P),Nt=ss+Nt),si&&jt(/((--!?|])>)|<\/(style|title)/i,Nt)){jn(At,P);continue}if(ze.forceKeepAttr)continue;if(!ze.keepAttr){jn(At,P);continue}if(!Ao&&jt(/\/>/i,Nt)){jn(At,P);continue}On&&oo([ct,ft,G],Go=>{Nt=cr(Nt,Go," ")});const No=Lt(P.nodeName);if(!Ro(No,di,Nt)){jn(At,P);continue}if(V&&typeof D=="object"&&typeof D.getAttributeType=="function"&&!Wt)switch(D.getAttributeType(No,di)){case"TrustedHTML":{Nt=V.createHTML(Nt);break}case"TrustedScriptURL":{Nt=V.createScriptURL(Nt);break}}if(Nt!==Sr)try{Wt?P.setAttributeNS(Wt,At,Nt):P.setAttribute(At,Nt),Bi(P)?fn(P):tl(e.removed)}catch{jn(At,P)}}vn(Ee.afterSanitizeAttributes,P,null)},cs=function $e(P){let ve=null;const ze=_r(P);for(vn(Ee.beforeSanitizeShadowDOM,P,null);ve=ze.nextNode();)vn(Ee.uponSanitizeShadowNode,ve,null),zo(ve),Oo(ve),ve.content instanceof o&&$e(ve.content);vn(Ee.afterSanitizeShadowDOM,P,null)};return e.sanitize=function($e){let P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=null,ze=null,mt=null,Ot=null;if(ci=!$e,ci&&($e="<!-->"),typeof $e!="string"&&!gt($e))if(typeof $e.toString=="function"){if($e=$e.toString(),typeof $e!="string")throw hr("dirty is not a string, aborting")}else throw hr("toString is not a function");if(!e.isSupported)return $e;if(Fi||br(P),e.removed=[],typeof $e=="string"&&(ui=!1),ui){if($e.nodeName){const gn=Lt($e.nodeName);if(!Ze[gn]||$t[gn])throw hr("root node is forbidden and cannot be sanitized in-place")}}else if($e instanceof f)ve=Fo("<!---->"),ze=ve.ownerDocument.importNode($e,!0),ze.nodeType===mr.element&&ze.nodeName==="BODY"||ze.nodeName==="HTML"?ve=ze:ve.appendChild(ze);else{if(!$n&&!On&&!Tn&&$e.indexOf("<")===-1)return V&&fi?V.createHTML($e):$e;if(ve=Fo($e),!ve)return $n?null:fi?ae:""}ve&&zi&&fn(ve.firstChild);const At=_r(ui?$e:ve);for(;mt=At.nextNode();)zo(mt),Oo(mt),mt.content instanceof o&&cs(mt.content);if(ui)return $e;if($n){if(Mt)for(Ot=Xe.call(ve.ownerDocument);ve.firstChild;)Ot.appendChild(ve.firstChild);else Ot=ve;return(ut.shadowroot||ut.shadowrootmode)&&(Ot=lt.call(i,Ot,!0)),Ot}let Wt=Tn?ve.outerHTML:ve.innerHTML;return Tn&&Ze["!doctype"]&&ve.ownerDocument&&ve.ownerDocument.doctype&&ve.ownerDocument.doctype.name&&jt(fl,ve.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+ve.ownerDocument.doctype.name+`>
9
+ `+Wt),On&&oo([ct,ft,G],gn=>{Wt=cr(Wt,gn," ")}),V&&fi?V.createHTML(Wt):Wt},e.setConfig=function(){let $e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};br($e),Fi=!0},e.clearConfig=function(){Xn=null,Fi=!1},e.isValidAttribute=function($e,P,ve){Xn||br({});const ze=Lt($e),mt=Lt(P);return Ro(ze,mt,ve)},e.addHook=function($e,P){typeof P=="function"&&ur(Ee[$e],P)},e.removeHook=function($e,P){if(P!==void 0){const ve=Up(Ee[$e],P);return ve===-1?void 0:Vp(Ee[$e],ve,1)[0]}return tl(Ee[$e])},e.removeHooks=function($e){Ee[$e]=[]},e.removeAllHooks=function(){Ee=ul()},e}var o0=cl();const hl=t=>typeof t=="function",$a=t=>Array.isArray(t),dl=t=>t instanceof Object,ml=t=>t instanceof Object?t.constructor.name!=="Function"&&t.constructor.name!=="Object":!1,Ha=t=>dl(t)&&!$a(t)&&!hl(t)&&!ml(t);function Fn(t){let e;if($a(t))e=t;else{const n=Vn(t),i=n==null?void 0:n.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(n==null?void 0:n.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function pl(t,e,n){return .2126*t+.7152*e+.0722*n}function Qt(t,e){let n=new Float32Array;return t({framebuffer:e})(()=>{n=t.read()}),n}function vl(t,e,n){return Math.min(Math.max(t,e),n)}function nn(t){return t!=null&&!Number.isNaN(t)}function gl(t,e){return o0.sanitize(t,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class a0{constructor(){this.enableSimulation=Oe.enableSimulation,this.backgroundColor=Qf,this.spaceSize=Oe.spaceSize,this.pointColor=Cp,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=Pp,this.pointGreyoutColor=Ra,this.pointSize=Ip,this.pointOpacity=kp,this.pointSizeScale=Oe.pointSizeScale,this.hoveredPointCursor=Oe.hoveredPointCursor,this.hoveredLinkCursor=Oe.hoveredLinkCursor,this.renderHoveredPointRing=Oe.renderHoveredPointRing,this.hoveredPointRingColor=Oe.hoveredPointRingColor,this.focusedPointRingColor=Oe.focusedPointRingColor,this.focusedPointIndex=Oe.focusedPointIndex,this.linkColor=Lp,this.linkDefaultColor=void 0,this.linkOpacity=Fp,this.linkGreyoutOpacity=Dp,this.linkWidth=zp,this.linkWidthScale=Oe.linkWidthScale,this.hoveredLinkColor=Oe.hoveredLinkColor,this.hoveredLinkWidthIncrease=Oe.hoveredLinkWidthIncrease,this.renderLinks=Oe.renderLinks,this.curvedLinks=Oe.curvedLinks,this.curvedLinkSegments=Oe.curvedLinkSegments,this.curvedLinkWeight=Oe.curvedLinkWeight,this.curvedLinkControlPointDistance=Oe.curvedLinkControlPointDistance,this.linkArrows=Oe.linkArrows,this.linkArrowsSizeScale=Oe.linkArrowsSizeScale,this.scaleLinksOnZoom=Oe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=Oe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=Oe.linkVisibilityMinTransparency,this.useClassicQuadtree=Oe.useClassicQuadtree,this.simulationDecay=Oe.simulation.decay,this.simulationGravity=Oe.simulation.gravity,this.simulationCenter=Oe.simulation.center,this.simulationRepulsion=Oe.simulation.repulsion,this.simulationRepulsionTheta=Oe.simulation.repulsionTheta,this.simulationRepulsionQuadtreeLevels=Oe.simulation.repulsionQuadtreeLevels,this.simulationLinkSpring=Oe.simulation.linkSpring,this.simulationLinkDistance=Oe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=Oe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=Oe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=Oe.enableRightClickRepulsion,this.simulationFriction=Oe.simulation.friction,this.simulationCluster=Oe.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=Oe.showFPSMonitor,this.pixelRatio=Oe.pixelRatio,this.scalePointsOnZoom=Oe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=Oe.enableZoom,this.enableSimulationDuringZoom=Oe.enableSimulationDuringZoom,this.enableDrag=Oe.enableDrag,this.fitViewOnInit=Oe.fitViewOnInit,this.fitViewDelay=Oe.fitViewDelay,this.fitViewPadding=Oe.fitViewPadding,this.fitViewDuration=Oe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=Oe.pointSamplingDistance,this.attribution=Oe.attribution,this.rescalePositions=Oe.rescalePositions}init(e){Object.keys(e).forEach(n=>{this.deepMergeConfig(this.getConfig(),e,n)})}deepMergeConfig(e,n,i){Ha(e[i])&&Ha(n[i])?Object.keys(n[i]).forEach(r=>{this.deepMergeConfig(e[i],n[i],r)}):e[i]=n[i]}getConfig(){return this}}class zn{constructor(e,n,i,r,o){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.reglInstance=e,this.config=n,this.store=i,this.data=r,o&&(this.points=o)}}var s0=`#ifdef GL_ES
10
+ precision highp float;
11
+ #endif
12
+
13
+ varying vec4 rgba;
14
+
15
+ void main() {
16
+ gl_FragColor = rgba;
17
+ }`,f0=`#ifdef GL_ES
18
+ precision highp float;
19
+ #endif
20
+
21
+ uniform sampler2D positionsTexture;
22
+ uniform float pointsTextureSize;
23
+
24
+ attribute vec2 pointIndices;
25
+
26
+ varying vec4 rgba;
27
+
28
+ void main() {
29
+ vec4 pointPosition = texture2D(positionsTexture, pointIndices / pointsTextureSize);
30
+ rgba = vec4(pointPosition.xy, 1.0, 0.0);
31
+
32
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
33
+ gl_PointSize = 1.0;
34
+ }`,l0=`#ifdef GL_ES
35
+ precision highp float;
36
+ #endif
37
+
38
+ uniform sampler2D positionsTexture;
39
+ uniform sampler2D centermassTexture;
40
+ uniform float centerForce;
41
+ uniform float alpha;
42
+
43
+ varying vec2 textureCoords;
44
+
45
+ void main() {
46
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
47
+ vec4 velocity = vec4(0.0);
48
+ vec4 centermassValues = texture2D(centermassTexture, vec2(0.0));
49
+ vec2 centermassPosition = centermassValues.xy / centermassValues.b;
50
+ vec2 distVector = centermassPosition - pointPosition.xy;
51
+ float dist = sqrt(dot(distVector, distVector));
52
+ if (dist > 0.0) {
53
+ float angle = atan(distVector.y, distVector.x);
54
+ float addV = alpha * centerForce * dist * 0.01;
55
+ velocity.rg += addV * vec2(cos(angle), sin(angle));
56
+ }
57
+
58
+ gl_FragColor = velocity;
59
+ }`;function wt(t){return{buffer:t.buffer(new Float32Array([-1,-1,1,-1,-1,1,1,1])),size:2}}function oi(t){const e=new Float32Array(t*t*2);for(let n=0;n<t;n++)for(let i=0;i<t;i++){const r=n*t*2+i*2;e[r+0]=i,e[r+1]=n}return e}var ai=`#ifdef GL_ES
60
+ precision highp float;
61
+ #endif
62
+
63
+ void main() {
64
+ gl_FragColor = vec4(0.0);
65
+ }`,kt=`#ifdef GL_ES
66
+ precision highp float;
67
+ #endif
68
+
69
+ attribute vec2 vertexCoord;
70
+ varying vec2 textureCoords;
71
+
72
+ void main() {
73
+
74
+ textureCoords = (vertexCoord + 1.0) / 2.0;
75
+ gl_Position = vec4(vertexCoord, 0, 1);
76
+ }`;class u0 extends zn{create(){const{reglInstance:e,store:n}=this;this.centermassTexture||(this.centermassTexture=e.texture()),this.centermassTexture({data:new Float32Array(4).fill(0),shape:[1,1,4],type:"float"}),this.centermassFbo||(this.centermassFbo=e.framebuffer()),this.centermassFbo({color:this.centermassTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(oi(n.pointsTextureSize))}initPrograms(){const{reglInstance:e,config:n,store:i,data:r,points:o}=this;this.clearCentermassCommand||(this.clearCentermassCommand=e({frag:ai,vert:kt,framebuffer:()=>this.centermassFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=e({frag:s0,vert:f0,framebuffer:()=>this.centermassFbo,primitive:"points",count:()=>r.pointsNumber??0,attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,pointsTextureSize:()=>i.pointsTextureSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.runCommand||(this.runCommand=e({frag:l0,vert:kt,framebuffer:()=>o==null?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,centermassTexture:()=>this.centermassFbo,centerForce:()=>n.simulationCenter,alpha:()=>i.alpha}}))}run(){var e,n,i;(e=this.clearCentermassCommand)==null||e.call(this),(n=this.calculateCentermassCommand)==null||n.call(this),(i=this.runCommand)==null||i.call(this)}}var c0=`#ifdef GL_ES
77
+ precision highp float;
78
+ #endif
79
+
80
+ uniform sampler2D positionsTexture;
81
+ uniform float gravity;
82
+ uniform float spaceSize;
83
+ uniform float alpha;
84
+
85
+ varying vec2 textureCoords;
86
+
87
+ void main() {
88
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
89
+
90
+ vec4 velocity = vec4(0.0);
91
+
92
+ vec2 centerPosition = vec2(spaceSize / 2.0);
93
+ vec2 distVector = centerPosition - pointPosition.rg;
94
+ float dist = sqrt(dot(distVector, distVector));
95
+ if (dist > 0.0) {
96
+ float angle = atan(distVector.y, distVector.x);
97
+ float additionalVelocity = alpha * gravity * dist * 0.1;
98
+ velocity.rg += additionalVelocity * vec2(cos(angle), sin(angle));
99
+ }
100
+
101
+ gl_FragColor = velocity;
102
+ }`;class h0 extends zn{initPrograms(){const{reglInstance:e,config:n,store:i,points:r}=this;this.runCommand||(this.runCommand=e({frag:c0,vert:kt,framebuffer:()=>r==null?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>r==null?void 0:r.previousPositionFbo,gravity:()=>n.simulationGravity,spaceSize:()=>i.adjustedSpaceSize,alpha:()=>i.alpha}}))}run(){var e;(e=this.runCommand)==null||e.call(this)}}function d0(t){return`
103
+ #ifdef GL_ES
104
+ precision highp float;
105
+ #endif
106
+
107
+ uniform sampler2D positionsTexture;
108
+ uniform float linkSpring;
109
+ uniform float linkDistance;
110
+ uniform vec2 linkDistRandomVariationRange;
111
+
112
+ uniform sampler2D linkInfoTexture; // Texture storing first link indices and amount
113
+ uniform sampler2D linkIndicesTexture;
114
+ uniform sampler2D linkPropertiesTexture; // Texture storing link bias and strength
115
+ uniform sampler2D linkRandomDistanceTexture;
116
+
117
+ uniform float pointsTextureSize;
118
+ uniform float linksTextureSize;
119
+ uniform float alpha;
120
+
121
+ varying vec2 textureCoords;
122
+
123
+ const float MAX_LINKS = ${t}.0;
124
+
125
+ void main() {
126
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
127
+ vec4 velocity = vec4(0.0);
128
+
129
+ vec4 linkInfo = texture2D(linkInfoTexture, textureCoords);
130
+ float iCount = linkInfo.r;
131
+ float jCount = linkInfo.g;
132
+ float linkAmount = linkInfo.b;
133
+ if (linkAmount > 0.0) {
134
+ for (float i = 0.0; i < MAX_LINKS; i += 1.0) {
135
+ if (i < linkAmount) {
136
+ if (iCount >= linksTextureSize) {
137
+ iCount = 0.0;
138
+ jCount += 1.0;
139
+ }
140
+ vec2 linkTextureIndex = (vec2(iCount, jCount) + 0.5) / linksTextureSize;
141
+ vec4 connectedPointIndex = texture2D(linkIndicesTexture, linkTextureIndex);
142
+ vec4 biasAndStrength = texture2D(linkPropertiesTexture, linkTextureIndex);
143
+ vec4 randomMinDistance = texture2D(linkRandomDistanceTexture, linkTextureIndex);
144
+ float bias = biasAndStrength.r;
145
+ float strength = biasAndStrength.g;
146
+ float randomMinLinkDist = randomMinDistance.r * (linkDistRandomVariationRange.g - linkDistRandomVariationRange.r) + linkDistRandomVariationRange.r;
147
+ randomMinLinkDist *= linkDistance;
148
+
149
+ iCount += 1.0;
150
+
151
+ vec4 connectedPointPosition = texture2D(positionsTexture, (connectedPointIndex.rg + 0.5) / pointsTextureSize);
152
+ float x = connectedPointPosition.x - (pointPosition.x + velocity.x);
153
+ float y = connectedPointPosition.y - (pointPosition.y + velocity.y);
154
+ float l = sqrt(x * x + y * y);
155
+
156
+ // Apply the link force
157
+ l = max(l, randomMinLinkDist * 0.99);
158
+ l = (l - randomMinLinkDist) / l;
159
+ l *= linkSpring * alpha;
160
+ l *= strength;
161
+ l *= bias;
162
+ x *= l;
163
+ y *= l;
164
+ velocity.x += x;
165
+ velocity.y += y;
166
+ }
167
+ }
168
+ }
169
+
170
+ gl_FragColor = vec4(velocity.rg, 0.0, 0.0);
171
+ }
172
+ `}var Wa=(t=>(t.OUTGOING="outgoing",t.INCOMING="incoming",t))(Wa||{});class yl extends zn{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){const{reglInstance:n,store:{pointsTextureSize:i,linksTextureSize:r},data:o}=this;if(!i||!r)return;this.linkFirstIndicesAndAmount=new Float32Array(i*i*4),this.indices=new Float32Array(r*r*4);const s=new Float32Array(r*r*4),f=new Float32Array(r*r*4),l=e==="incoming"?o.sourceIndexToTargetIndices:o.targetIndexToSourceIndices;this.maxPointDegree=0;let u=0;l==null||l.forEach((d,y)=>{d&&(this.linkFirstIndicesAndAmount[y*4+0]=u%r,this.linkFirstIndicesAndAmount[y*4+1]=Math.floor(u/r),this.linkFirstIndicesAndAmount[y*4+2]=d.length??0,d.forEach(([S,D])=>{var V,ae,Ie;this.indices[u*4+0]=S%i,this.indices[u*4+1]=Math.floor(S/i);const q=((V=o.degree)==null?void 0:V[S])??0,Te=((ae=o.degree)==null?void 0:ae[y])??0,we=q+Te,fe=we!==0?q/we:.5,Ne=Math.min(q,Te);let Ve=((Ie=o.linkStrength)==null?void 0:Ie[D])??1/Math.max(Ne,1);Ve=Math.sqrt(Ve),s[u*4+0]=fe,s[u*4+1]=Ve,f[u*4]=this.store.getRandomFloat(0,1),u+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,d.length??0))}),this.linkFirstIndicesAndAmountTexture||(this.linkFirstIndicesAndAmountTexture=n.texture()),this.linkFirstIndicesAndAmountTexture({data:this.linkFirstIndicesAndAmount,shape:[i,i,4],type:"float"}),this.linkFirstIndicesAndAmountFbo||(this.linkFirstIndicesAndAmountFbo=n.framebuffer()),this.linkFirstIndicesAndAmountFbo({color:this.linkFirstIndicesAndAmountTexture,depth:!1,stencil:!1}),this.indicesTexture||(this.indicesTexture=n.texture()),this.indicesTexture({data:this.indices,shape:[r,r,4],type:"float"}),this.indicesFbo||(this.indicesFbo=n.framebuffer()),this.indicesFbo({color:this.indicesTexture,depth:!1,stencil:!1}),this.biasAndStrengthTexture||(this.biasAndStrengthTexture=n.texture()),this.biasAndStrengthTexture({data:s,shape:[r,r,4],type:"float"}),this.biasAndStrengthFbo||(this.biasAndStrengthFbo=n.framebuffer()),this.biasAndStrengthFbo({color:this.biasAndStrengthTexture,depth:!1,stencil:!1}),this.randomDistanceTexture||(this.randomDistanceTexture=n.texture()),this.randomDistanceTexture({data:f,shape:[r,r,4],type:"float"}),this.randomDistanceFbo||(this.randomDistanceFbo=n.framebuffer()),this.randomDistanceFbo({color:this.randomDistanceTexture,depth:!1,stencil:!1})}initPrograms(){const{reglInstance:e,config:n,store:i,points:r}=this;this.runCommand||(this.runCommand=e({frag:()=>d0(this.maxPointDegree),vert:kt,framebuffer:()=>r==null?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>r==null?void 0:r.previousPositionFbo,linkSpring:()=>n.simulationLinkSpring,linkDistance:()=>n.simulationLinkDistance,linkDistRandomVariationRange:()=>n.simulationLinkDistRandomVariationRange,linkInfoTexture:()=>this.linkFirstIndicesAndAmountFbo,linkIndicesTexture:()=>this.indicesFbo,linkPropertiesTexture:()=>this.biasAndStrengthFbo,linkRandomDistanceTexture:()=>this.randomDistanceFbo,pointsTextureSize:()=>i.pointsTextureSize,linksTextureSize:()=>i.linksTextureSize,alpha:()=>i.alpha}}))}run(){var e;(e=this.runCommand)==null||e.call(this)}}var xl=`#ifdef GL_ES
173
+ precision highp float;
174
+ #endif
175
+
176
+ varying vec4 rgba;
177
+
178
+ void main() {
179
+ gl_FragColor = rgba;
180
+ }`,bl=`#ifdef GL_ES
181
+ precision highp float;
182
+ #endif
183
+
184
+ uniform sampler2D positionsTexture;
185
+ uniform float pointsTextureSize;
186
+ uniform float levelTextureSize;
187
+ uniform float cellSize;
188
+
189
+ attribute vec2 pointIndices;
190
+
191
+ varying vec4 rgba;
192
+
193
+ void main() {
194
+ vec4 pointPosition = texture2D(positionsTexture, pointIndices / pointsTextureSize);
195
+ rgba = vec4(pointPosition.rg, 1.0, 0.0);
196
+
197
+ float n = floor(pointPosition.x / cellSize);
198
+ float m = floor(pointPosition.y / cellSize);
199
+
200
+ vec2 levelPosition = 2.0 * (vec2(n, m) + 0.5) / levelTextureSize - 1.0;
201
+
202
+ gl_Position = vec4(levelPosition, 0.0, 1.0);
203
+ gl_PointSize = 1.0;
204
+ }`,m0=`#ifdef GL_ES
205
+ precision highp float;
206
+ #endif
207
+
208
+ uniform sampler2D positionsTexture;
209
+ uniform sampler2D levelFbo;
210
+
211
+ uniform float level;
212
+ uniform float levels;
213
+ uniform float levelTextureSize;
214
+ uniform float repulsion;
215
+ uniform float alpha;
216
+ uniform float spaceSize;
217
+ uniform float theta;
218
+
219
+ varying vec2 textureCoords;
220
+
221
+ const float MAX_LEVELS_NUM = 14.0;
222
+
223
+ vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) {
224
+ vec2 add = vec2(0.0);
225
+ vec4 centermass = texture2D(levelFbo, ij);
226
+ if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {
227
+ vec2 centermassPosition = vec2(centermass.rg / centermass.b);
228
+ vec2 distVector = pp - centermassPosition;
229
+ float l = dot(distVector, distVector);
230
+ float dist = sqrt(l);
231
+ if (l > 0.0) {
232
+ float c = alpha * repulsion * centermass.b;
233
+
234
+ float distanceMin2 = 1.0;
235
+ if (l < distanceMin2) l = sqrt(distanceMin2 * l);
236
+ float addV = c / sqrt(l);
237
+ add = addV * normalize(distVector);
238
+ }
239
+ }
240
+ return add;
241
+ }
242
+
243
+ void main() {
244
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
245
+ float x = pointPosition.x;
246
+ float y = pointPosition.y;
247
+
248
+ float left = 0.0;
249
+ float top = 0.0;
250
+ float right = spaceSize;
251
+ float bottom = spaceSize;
252
+
253
+ float n_left = 0.0;
254
+ float n_top = 0.0;
255
+ float n_right = 0.0;
256
+ float n_bottom = 0.0;
257
+
258
+ float cellSize = 0.0;
259
+
260
+
261
+ for (float i = 0.0; i < MAX_LEVELS_NUM; i += 1.0) {
262
+ if (i <= level) {
263
+ left += cellSize * n_left;
264
+ top += cellSize * n_top;
265
+ right -= cellSize * n_right;
266
+ bottom -= cellSize * n_bottom;
267
+
268
+ cellSize = pow(2.0 , levels - i - 1.0);
269
+
270
+ float dist_left = x - left;
271
+ n_left = max(0.0, floor(dist_left / cellSize - theta));
272
+
273
+ float dist_top = y - top;
274
+ n_top = max(0.0, floor(dist_top / cellSize - theta));
275
+
276
+ float dist_right = right - x;
277
+ n_right = max(0.0, floor(dist_right / cellSize - theta));
278
+
279
+ float dist_bottom = bottom - y;
280
+ n_bottom = max(0.0, floor(dist_bottom / cellSize - theta));
281
+
282
+ }
283
+ }
284
+
285
+ vec4 velocity = vec4(vec2(0.0), 1.0, 0.0);
286
+
287
+
288
+ for (float i = 0.0; i < 12.0; i += 1.0) {
289
+ for (float j = 0.0; j < 4.0; j += 1.0) {
290
+ float n = left + cellSize * j;
291
+ float m = top + cellSize * n_top + cellSize * i;
292
+
293
+ if (n < (left + n_left * cellSize) && m < bottom) {
294
+ velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
295
+ }
296
+
297
+ n = left + cellSize * i;
298
+ m = top + cellSize * j;
299
+
300
+ if (n < (right - n_right * cellSize) && m < (top + n_top * cellSize)) {
301
+ velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
302
+ }
303
+
304
+ n = right - n_right * cellSize + cellSize * j;
305
+ m = top + cellSize * i;
306
+
307
+ if (n < right && m < (bottom - n_bottom * cellSize)) {
308
+ velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
309
+ }
310
+
311
+ n = left + n_left * cellSize + cellSize * i;
312
+ m = bottom - n_bottom * cellSize + cellSize * j;
313
+
314
+ if (n < right && m < bottom) {
315
+ velocity.xy += calculateAdditionalVelocity(vec2(n / cellSize, m / cellSize) / levelTextureSize, pointPosition.xy);
316
+ }
317
+ }
318
+ }
319
+
320
+ gl_FragColor = velocity;
321
+ }`,p0=`#ifdef GL_ES
322
+ precision highp float;
323
+ #endif
324
+
325
+ uniform sampler2D positionsTexture;
326
+ uniform sampler2D levelFbo;
327
+ uniform sampler2D randomValues;
328
+
329
+ uniform float levelTextureSize;
330
+ uniform float repulsion;
331
+ uniform float alpha;
332
+
333
+ varying vec2 textureCoords;
334
+
335
+ vec2 calculateAdditionalVelocity (vec2 ij, vec2 pp) {
336
+ vec2 add = vec2(0.0);
337
+ vec4 centermass = texture2D(levelFbo, ij);
338
+ if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {
339
+ vec2 centermassPosition = vec2(centermass.rg / centermass.b);
340
+ vec2 distVector = pp - centermassPosition;
341
+ float l = dot(distVector, distVector);
342
+ float dist = sqrt(l);
343
+ if (l > 0.0) {
344
+ float angle = atan(distVector.y, distVector.x);
345
+ float c = alpha * repulsion * centermass.b;
346
+
347
+ float distanceMin2 = 1.0;
348
+ if (l < distanceMin2) l = sqrt(distanceMin2 * l);
349
+ float addV = c / sqrt(l);
350
+ add = addV * vec2(cos(angle), sin(angle));
351
+ }
352
+ }
353
+ return add;
354
+ }
355
+
356
+ void main() {
357
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
358
+ vec4 random = texture2D(randomValues, textureCoords);
359
+
360
+ vec4 velocity = vec4(0.0);
361
+
362
+
363
+ velocity.xy += calculateAdditionalVelocity(pointPosition.xy / levelTextureSize, pointPosition.xy);
364
+
365
+ velocity.xy += velocity.xy * random.rg;
366
+
367
+ gl_FragColor = velocity;
368
+ }`;class v0 extends zn{constructor(){super(...arguments),this.levelsFbos=new Map,this.quadtreeLevels=0}create(){const{reglInstance:e,store:n}=this;if(!n.pointsTextureSize)return;this.quadtreeLevels=Math.log2(n.adjustedSpaceSize);for(let r=0;r<this.quadtreeLevels;r+=1){const o=Math.pow(2,r+1);this.levelsFbos.has(`level[${r}]`)||this.levelsFbos.set(`level[${r}]`,e.framebuffer());const s=this.levelsFbos.get(`level[${r}]`);s&&s({shape:[o,o],colorType:"float",depth:!1,stencil:!1})}const i=new Float32Array(n.pointsTextureSize*n.pointsTextureSize*4);for(let r=0;r<n.pointsTextureSize*n.pointsTextureSize;++r)i[r*4]=n.getRandomFloat(-1,1)*1e-5,i[r*4+1]=n.getRandomFloat(-1,1)*1e-5;this.randomValuesTexture||(this.randomValuesTexture=e.texture()),this.randomValuesTexture({data:i,shape:[n.pointsTextureSize,n.pointsTextureSize,4],type:"float"}),this.randomValuesFbo||(this.randomValuesFbo=e.framebuffer()),this.randomValuesFbo({color:this.randomValuesTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(oi(n.pointsTextureSize))}initPrograms(){const{reglInstance:e,config:n,store:i,data:r,points:o}=this;this.clearLevelsCommand||(this.clearLevelsCommand=e({frag:ai,vert:kt,framebuffer:(s,f)=>f.levelFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=e({frag:xl,vert:bl,framebuffer:(s,f)=>f.levelFbo,primitive:"points",count:()=>r.pointsNumber??0,attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,pointsTextureSize:()=>i.pointsTextureSize,levelTextureSize:(s,f)=>f.levelTextureSize,cellSize:(s,f)=>f.cellSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.forceCommand||(this.forceCommand=e({frag:m0,vert:kt,framebuffer:()=>o==null?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,level:(s,f)=>f.level,levels:this.quadtreeLevels,levelFbo:(s,f)=>f.levelFbo,levelTextureSize:(s,f)=>f.levelTextureSize,alpha:()=>i.alpha,repulsion:()=>n.simulationRepulsion,spaceSize:()=>i.adjustedSpaceSize,theta:()=>n.simulationRepulsionTheta},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.forceFromItsOwnCentermassCommand||(this.forceFromItsOwnCentermassCommand=e({frag:p0,vert:kt,framebuffer:()=>o==null?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,randomValues:()=>this.randomValuesFbo,levelFbo:(s,f)=>f.levelFbo,levelTextureSize:(s,f)=>f.levelTextureSize,alpha:()=>i.alpha,repulsion:()=>n.simulationRepulsion,spaceSize:()=>i.adjustedSpaceSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.clearVelocityCommand||(this.clearVelocityCommand=e({frag:ai,vert:kt,framebuffer:()=>o==null?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}}))}run(){var n,i,r,o,s;const{store:e}=this;for(let f=0;f<this.quadtreeLevels;f+=1){(n=this.clearLevelsCommand)==null||n.call(this,{levelFbo:this.levelsFbos.get(`level[${f}]`)});const l=Math.pow(2,f+1),u=e.adjustedSpaceSize/l;(i=this.calculateLevelsCommand)==null||i.call(this,{levelFbo:this.levelsFbos.get(`level[${f}]`),levelTextureSize:l,cellSize:u})}(r=this.clearVelocityCommand)==null||r.call(this);for(let f=0;f<this.quadtreeLevels;f+=1){const l=Math.pow(2,f+1);(o=this.forceCommand)==null||o.call(this,{levelFbo:this.levelsFbos.get(`level[${f}]`),levelTextureSize:l,level:f}),f===this.quadtreeLevels-1&&((s=this.forceFromItsOwnCentermassCommand)==null||s.call(this,{levelFbo:this.levelsFbos.get(`level[${f}]`),levelTextureSize:l,level:f}))}}}function g0(t,e){t=Math.min(t,e);const n=e-t,i=`
369
+ float dist = sqrt(l);
370
+ if (dist > 0.0) {
371
+ float c = alpha * repulsion * centermass.b;
372
+ addVelocity += calcAdd(vec2(x, y), l, c);
373
+ addVelocity += addVelocity * random.rg;
374
+ }
375
+ `;function r(o){if(o>=e)return i;{const s=Math.pow(2,o+1),f=new Array(o+1-n).fill(0).map((u,d)=>`pow(2.0, ${o-(d+n)}.0) * i${d+n}`).join("+"),l=new Array(o+1-n).fill(0).map((u,d)=>`pow(2.0, ${o-(d+n)}.0) * j${d+n}`).join("+");return`
376
+ for (float ij${o} = 0.0; ij${o} < 4.0; ij${o} += 1.0) {
377
+ float i${o} = 0.0;
378
+ float j${o} = 0.0;
379
+ if (ij${o} == 1.0 || ij${o} == 3.0) i${o} = 1.0;
380
+ if (ij${o} == 2.0 || ij${o} == 3.0) j${o} = 1.0;
381
+ float i = pow(2.0, ${t}.0) * n / width${o+1} + ${f};
382
+ float j = pow(2.0, ${t}.0) * m / width${o+1} + ${l};
383
+ float groupPosX = (i + 0.5) / ${s}.0;
384
+ float groupPosY = (j + 0.5) / ${s}.0;
385
+
386
+ vec4 centermass = texture2D(level[${o}], vec2(groupPosX, groupPosY));
387
+ if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {
388
+ float x = centermass.r / centermass.b - pointPosition.r;
389
+ float y = centermass.g / centermass.b - pointPosition.g;
390
+ float l = x * x + y * y;
391
+ if ((width${o+1} * width${o+1}) / theta < l) {
392
+ ${i}
393
+ } else {
394
+ ${r(o+1)}
395
+ }
396
+ }
397
+ }
398
+ `}}return`
399
+ #ifdef GL_ES
400
+ precision highp float;
401
+ #endif
402
+
403
+ uniform sampler2D positionsTexture;
404
+ uniform sampler2D randomValues;
405
+ uniform float spaceSize;
406
+ uniform float repulsion;
407
+ uniform float theta;
408
+ uniform float alpha;
409
+ uniform sampler2D level[${e}];
410
+ varying vec2 textureCoords;
411
+
412
+ vec2 calcAdd(vec2 xy, float l, float c) {
413
+ float distanceMin2 = 1.0;
414
+ if (l < distanceMin2) l = sqrt(distanceMin2 * l);
415
+ float add = c / l;
416
+ return add * xy;
417
+ }
418
+
419
+ void main() {
420
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
421
+ vec4 random = texture2D(randomValues, textureCoords);
422
+
423
+ float width0 = spaceSize;
424
+
425
+ vec2 velocity = vec2(0.0);
426
+ vec2 addVelocity = vec2(0.0);
427
+
428
+ ${new Array(e).fill(0).map((o,s)=>`float width${s+1} = width${s} / 2.0;`).join(`
429
+ `)}
430
+
431
+ for (float n = 0.0; n < pow(2.0, ${n}.0); n += 1.0) {
432
+ for (float m = 0.0; m < pow(2.0, ${n}.0); m += 1.0) {
433
+ ${r(n)}
434
+ }
435
+ }
436
+
437
+ velocity -= addVelocity;
438
+
439
+ gl_FragColor = vec4(velocity, 0.0, 0.0);
440
+ }
441
+ `}class y0 extends zn{constructor(){super(...arguments),this.levelsTextures=new Map,this.levelsFbos=new Map,this.quadtreeLevels=0}create(){const{reglInstance:e,store:n}=this;if(!n.pointsTextureSize)return;this.quadtreeLevels=Math.log2(n.adjustedSpaceSize);for(let r=0;r<this.quadtreeLevels;r+=1){const o=Math.pow(2,r+1),s=`level[${r}]`;this.levelsTextures.has(s)||this.levelsTextures.set(s,e.texture());const f=this.levelsTextures.get(s);f&&f({data:new Float32Array(o*o*4),shape:[o,o,4],type:"float"}),this.levelsFbos.has(s)||this.levelsFbos.set(s,e.framebuffer());const l=this.levelsFbos.get(s);l&&l({color:this.levelsTextures.get(s),depth:!1,stencil:!1})}const i=new Float32Array(n.pointsTextureSize*n.pointsTextureSize*4);for(let r=0;r<n.pointsTextureSize*n.pointsTextureSize;++r)i[r*4]=n.getRandomFloat(-1,1)*1e-5,i[r*4+1]=n.getRandomFloat(-1,1)*1e-5;this.randomValuesTexture||(this.randomValuesTexture=e.texture()),this.randomValuesTexture({data:i,shape:[n.pointsTextureSize,n.pointsTextureSize,4],type:"float"}),this.randomValuesFbo||(this.randomValuesFbo=e.framebuffer()),this.randomValuesFbo({color:this.randomValuesTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(oi(n.pointsTextureSize))}initPrograms(){const{reglInstance:e,config:n,store:i,data:r,points:o}=this;this.clearLevelsCommand||(this.clearLevelsCommand=e({frag:ai,vert:kt,framebuffer:(s,f)=>f.levelFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=e({frag:xl,vert:bl,framebuffer:(s,f)=>f.levelFbo,primitive:"points",count:()=>r.pointsNumber??0,attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,pointsTextureSize:()=>i.pointsTextureSize,levelTextureSize:(s,f)=>f.levelTextureSize,cellSize:(s,f)=>f.cellSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.quadtreeCommand=e({frag:g0(n.simulationRepulsionQuadtreeLevels??this.quadtreeLevels,this.quadtreeLevels),vert:kt,framebuffer:()=>o==null?void 0:o.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>o==null?void 0:o.previousPositionFbo,randomValues:()=>this.randomValuesFbo,spaceSize:()=>i.adjustedSpaceSize,repulsion:()=>n.simulationRepulsion,theta:()=>n.simulationRepulsionTheta,alpha:()=>i.alpha,...Object.fromEntries(this.levelsFbos)}})}run(){var n,i,r;const{store:e}=this;for(let o=0;o<this.quadtreeLevels;o+=1){(n=this.clearLevelsCommand)==null||n.call(this,{levelFbo:this.levelsFbos.get(`level[${o}]`)});const s=Math.pow(2,o+1),f=e.adjustedSpaceSize/s;(i=this.calculateLevelsCommand)==null||i.call(this,{levelFbo:this.levelsFbos.get(`level[${o}]`),levelTextureSize:s,cellSize:f})}(r=this.quadtreeCommand)==null||r.call(this)}}var x0=`#ifdef GL_ES
442
+ precision highp float;
443
+ #endif
444
+
445
+ uniform sampler2D positionsTexture;
446
+ uniform float repulsion;
447
+ uniform vec2 mousePos;
448
+
449
+ varying vec2 textureCoords;
450
+
451
+ void main() {
452
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
453
+ vec4 velocity = vec4(0.0);
454
+ vec2 mouse = mousePos;
455
+
456
+ vec2 distVector = mouse - pointPosition.rg;
457
+ float dist = sqrt(dot(distVector, distVector));
458
+ dist = max(dist, 10.0);
459
+ float angle = atan(distVector.y, distVector.x);
460
+ float addV = 100.0 * repulsion / (dist * dist);
461
+ velocity.rg -= addV * vec2(cos(angle), sin(angle));
462
+
463
+ gl_FragColor = velocity;
464
+ }`;class b0 extends zn{initPrograms(){const{reglInstance:e,config:n,store:i,points:r}=this;this.runCommand||(this.runCommand=e({frag:x0,vert:kt,framebuffer:()=>r==null?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>r==null?void 0:r.previousPositionFbo,mousePos:()=>i.mousePosition,repulsion:()=>n.simulationRepulsionFromMouse}}))}run(){var e;(e=this.runCommand)==null||e.call(this)}}var _0=`#ifdef GL_ES
465
+ precision highp float;
466
+ #endif
467
+
468
+ varying vec4 rgba;
469
+
470
+ void main() {
471
+ gl_FragColor = rgba;
472
+ }`,S0=`#ifdef GL_ES
473
+ precision highp float;
474
+ #endif
475
+
476
+ uniform sampler2D positionsTexture;
477
+ uniform sampler2D clusterTexture;
478
+ uniform float pointsTextureSize;
479
+ uniform float clustersTextureSize;
480
+
481
+ attribute vec2 pointIndices;
482
+
483
+ varying vec4 rgba;
484
+
485
+ void main() {
486
+ vec4 pointPosition = texture2D(positionsTexture, pointIndices / pointsTextureSize);
487
+ rgba = vec4(pointPosition.xy, 1.0, 0.0);
488
+
489
+ vec4 pointClusterIndices = texture2D(clusterTexture, pointIndices / pointsTextureSize);
490
+ vec2 xy = vec2(0.0);
491
+ if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) {
492
+ xy = 2.0 * (pointClusterIndices.xy + 0.5) / clustersTextureSize - 1.0;
493
+ }
494
+
495
+ gl_Position = vec4(xy, 0.0, 1.0);
496
+ gl_PointSize = 1.0;
497
+ }`,T0=`#ifdef GL_ES
498
+ precision highp float;
499
+ #endif
500
+
501
+ uniform sampler2D positionsTexture;
502
+ uniform sampler2D centermassTexture;
503
+ uniform sampler2D clusterTexture;
504
+ uniform sampler2D clusterPositionsTexture;
505
+ uniform sampler2D clusterForceCoefficient;
506
+ uniform float alpha;
507
+ uniform float clustersTextureSize;
508
+ uniform float clusterCoefficient;
509
+
510
+ varying vec2 textureCoords;
511
+
512
+ void main() {
513
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
514
+ vec4 velocity = vec4(0.0);
515
+ vec4 pointClusterIndices = texture2D(clusterTexture, textureCoords);
516
+
517
+ if (pointClusterIndices.x >= 0.0 && pointClusterIndices.y >= 0.0) {
518
+
519
+ vec2 clusterPositions = texture2D(clusterPositionsTexture, pointClusterIndices.xy / clustersTextureSize).xy;
520
+ if (clusterPositions.x < 0.0 || clusterPositions.y < 0.0) {
521
+ vec4 centermassValues = texture2D(centermassTexture, pointClusterIndices.xy / clustersTextureSize);
522
+ clusterPositions = centermassValues.xy / centermassValues.b;
523
+ }
524
+ vec4 clusterCustomCoeff = texture2D(clusterForceCoefficient, textureCoords);
525
+ vec2 distVector = clusterPositions.xy - pointPosition.xy;
526
+ float dist = length(distVector);
527
+ if (dist > 0.0) {
528
+ float addV = alpha * dist * clusterCoefficient * clusterCustomCoeff.r;
529
+ velocity.rg += addV * normalize(distVector);
530
+ }
531
+ }
532
+
533
+ gl_FragColor = velocity;
534
+ }`;class w0 extends zn{create(){var l;const{reglInstance:e,store:n,data:i}=this,{pointsTextureSize:r}=n;if(i.pointsNumber===void 0||!i.pointClusters&&!i.clusterPositions)return;this.clusterCount=(i.pointClusters??[]).reduce((u,d)=>d===void 0||d<0?u:Math.max(u,d),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const o=new Float32Array(r*r*4),s=new Float32Array(this.clustersTextureSize*this.clustersTextureSize*4).fill(-1),f=new Float32Array(r*r*4).fill(1);if(i.clusterPositions)for(let u=0;u<this.clusterCount;++u)s[u*4+0]=i.clusterPositions[u*2+0]??-1,s[u*4+1]=i.clusterPositions[u*2+1]??-1;for(let u=0;u<i.pointsNumber;++u){const d=(l=i.pointClusters)==null?void 0:l[u];d===void 0?(o[u*4+0]=-1,o[u*4+1]=-1):(o[u*4+0]=d%this.clustersTextureSize,o[u*4+1]=Math.floor(d/this.clustersTextureSize)),i.clusterStrength&&(f[u*4+0]=i.clusterStrength[u]??1)}this.clusterTexture||(this.clusterTexture=e.texture()),this.clusterTexture({data:o,shape:[r,r,4],type:"float"}),this.clusterFbo||(this.clusterFbo=e.framebuffer()),this.clusterFbo({color:this.clusterTexture,depth:!1,stencil:!1}),this.clusterPositionsTexture||(this.clusterPositionsTexture=e.texture()),this.clusterPositionsTexture({data:s,shape:[this.clustersTextureSize,this.clustersTextureSize,4],type:"float"}),this.clusterPositionsFbo||(this.clusterPositionsFbo=e.framebuffer()),this.clusterPositionsFbo({color:this.clusterPositionsTexture,depth:!1,stencil:!1}),this.clusterForceCoefficientTexture||(this.clusterForceCoefficientTexture=e.texture()),this.clusterForceCoefficientTexture({data:f,shape:[r,r,4],type:"float"}),this.clusterForceCoefficientFbo||(this.clusterForceCoefficientFbo=e.framebuffer()),this.clusterForceCoefficientFbo({color:this.clusterForceCoefficientTexture,depth:!1,stencil:!1}),this.centermassTexture||(this.centermassTexture=e.texture()),this.centermassTexture({data:new Float32Array(this.clustersTextureSize*this.clustersTextureSize*4).fill(0),shape:[this.clustersTextureSize,this.clustersTextureSize,4],type:"float"}),this.centermassFbo||(this.centermassFbo=e.framebuffer()),this.centermassFbo({color:this.centermassTexture,depth:!1,stencil:!1}),this.pointIndices||(this.pointIndices=e.buffer(0)),this.pointIndices(oi(n.pointsTextureSize))}initPrograms(){const{reglInstance:e,store:n,data:i,points:r}=this;i.pointClusters!==void 0&&(this.clearCentermassCommand||(this.clearCentermassCommand=e({frag:ai,vert:kt,framebuffer:()=>this.centermassFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=e({frag:_0,vert:S0,framebuffer:()=>this.centermassFbo,primitive:"points",count:()=>i.pointsNumber??0,attributes:{pointIndices:{buffer:this.pointIndices,size:2}},uniforms:{positionsTexture:()=>r==null?void 0:r.previousPositionFbo,pointsTextureSize:()=>n.pointsTextureSize,clusterTexture:()=>this.clusterFbo,clustersTextureSize:()=>this.clustersTextureSize},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}})),this.applyForcesCommand||(this.applyForcesCommand=e({frag:T0,vert:kt,framebuffer:()=>r==null?void 0:r.velocityFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>r==null?void 0:r.previousPositionFbo,clusterTexture:()=>this.clusterFbo,centermassTexture:()=>this.centermassFbo,clusterPositionsTexture:()=>this.clusterPositionsFbo,clusterForceCoefficient:()=>this.clusterForceCoefficientFbo,alpha:()=>n.alpha,clustersTextureSize:()=>this.clustersTextureSize,clusterCoefficient:()=>this.config.simulationCluster}})))}calculateCentermass(){var e,n;(e=this.clearCentermassCommand)==null||e.call(this),(n=this.calculateCentermassCommand)==null||n.call(this)}run(){var e;!this.data.pointClusters&&!this.data.clusterPositions||(this.calculateCentermass(),(e=this.applyForcesCommand)==null||e.call(this))}}var fo={exports:{}},A0=fo.exports,_l;function E0(){return _l||(_l=1,function(t,e){(function(n,i){t.exports=i()})(A0,function(){var n=`<div class="gl-box">
535
+ <svg viewBox="0 0 55 60">
536
+ <text x="27" y="56" class="gl-fps">00 FPS</text>
537
+ <text x="28" y="8" class="gl-mem"></text>
538
+ <rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect>
539
+ <polyline class="gl-chart"></polyline>
540
+ </svg>
541
+ <svg viewBox="0 0 14 60" class="gl-cpu-svg">
542
+ <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
543
+ <line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/>
544
+ <path d="M5.35 43c-.464 0-.812.377-.812.812v1.16c-.783.1972-1.421.812-1.595 1.624h-1.16c-.435 0-.812.348-.812.812s.348.812.812.812h1.102v1.653H1.812c-.464 0-.812.377-.812.812 0 .464.377.812.812.812h1.131c.1943.783.812 1.392 1.595 1.595v1.131c0 .464.377.812.812.812.464 0 .812-.377.812-.812V53.15h1.653v1.073c0 .464.377.812.812.812.464 0 .812-.377.812-.812v-1.131c.783-.1943 1.392-.812 1.595-1.595h1.131c.464 0 .812-.377.812-.812 0-.464-.377-.812-.812-.812h-1.073V48.22h1.102c.435 0 .812-.348.812-.812s-.348-.812-.812-.812h-1.16c-.1885-.783-.812-1.421-1.595-1.624v-1.131c0-.464-.377-.812-.812-.812-.464 0-.812.377-.812.812v1.073H6.162v-1.073c0-.464-.377-.812-.812-.812zm.58 3.48h2.088c.754 0 1.363.609 1.363 1.363v2.088c0 .754-.609 1.363-1.363 1.363H5.93c-.754 0-1.363-.609-1.363-1.363v-2.088c0-.754.609-1.363 1.363-1.363z"/>
545
+ </svg>
546
+ <svg viewBox="0 0 14 60" class="gl-gpu-svg">
547
+ <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
548
+ <line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>
549
+ <path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z"/>
550
+ </svg>
551
+ </div>`,i=`#gl-bench {
552
+ position:absolute;
553
+ left:0;
554
+ top:0;
555
+ z-index:1000;
556
+ -webkit-user-select: none;
557
+ -moz-user-select: none;
558
+ user-select: none;
559
+ }
560
+
561
+ #gl-bench div {
562
+ position: relative;
563
+ display: block;
564
+ margin: 4px;
565
+ padding: 0 7px 0 10px;
566
+ background: #6c6;
567
+ border-radius: 15px;
568
+ cursor: pointer;
569
+ opacity: 0.9;
570
+ }
571
+
572
+ #gl-bench svg {
573
+ height: 60px;
574
+ margin: 0 -1px;
575
+ }
576
+
577
+ #gl-bench text {
578
+ font-size: 12px;
579
+ font-family: Helvetica,Arial,sans-serif;
580
+ font-weight: 700;
581
+ dominant-baseline: middle;
582
+ text-anchor: middle;
583
+ }
584
+
585
+ #gl-bench .gl-mem {
586
+ font-size: 9px;
587
+ }
588
+
589
+ #gl-bench line {
590
+ stroke-width: 5;
591
+ stroke: #112211;
592
+ stroke-linecap: round;
593
+ }
594
+
595
+ #gl-bench polyline {
596
+ fill: none;
597
+ stroke: #112211;
598
+ stroke-linecap: round;
599
+ stroke-linejoin: round;
600
+ stroke-width: 3.5;
601
+ }
602
+
603
+ #gl-bench rect {
604
+ fill: #448844;
605
+ }
606
+
607
+ #gl-bench .opacity {
608
+ stroke: #448844;
609
+ }
610
+ `;class r{constructor(s,f={}){this.css=i,this.svg=n,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"],S=>{S.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,f),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let l,u=0,d,y=S=>{++u<20?l=requestAnimationFrame(y):(this.detected=Math.ceil(1e3*u/(S-d)/70),cancelAnimationFrame(l)),d||(d=S)};if(requestAnimationFrame(y),s){const S=async(q,Te)=>Promise.resolve(setTimeout(()=>{s.getError();const we=this.now()-q;Te.forEach((fe,Ne)=>{fe&&(this.gpuAccums[Ne]+=we)})},0)),D=(q,Te,we)=>function(){const fe=Te.now();q.apply(we,arguments),Te.trackGPU&&Te.finished.push(S(fe,Te.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(q=>{s[q]&&(s[q]=D(s[q],this,s))}),s.getExtension=((q,Te)=>function(){let we=q.apply(s,arguments);return we&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(fe=>{we[fe]&&(we[fe]=D(we[fe],Te,we))}),we})(s.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let S=document.createElement("div");S.id="gl-bench",this.dom.appendChild(S),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=S,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((D,q,Te)=>{const we=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],fe=Object.assign({},we);return we.forEach(Ne=>fe[Ne]=q.getElementsByClassName(Ne)),this.nodes=fe,(Ne,Ve,V,ae,Ie,Be,Xe)=>{fe["gl-cpu"][Ne].style.strokeDasharray=(Ve*.27).toFixed(0)+" 100",fe["gl-gpu"][Ne].style.strokeDasharray=(V*.27).toFixed(0)+" 100",fe["gl-mem"][Ne].innerHTML=Te[Ne]?Te[Ne]:ae?"mem: "+ae.toFixed(0)+"mb":"",fe["gl-fps"][Ne].innerHTML=Ie.toFixed(0)+" FPS",D(Te[Ne],Ve,V,ae,Ie,Be,Xe)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((D,q)=>{let Te={"gl-chart":q.getElementsByClassName("gl-chart")};return(we,fe,Ne)=>{let Ve="",V=fe.length;for(let ae=0;ae<V;ae++){let Ie=(Ne+ae+1)%V;fe[Ie]!=null&&(Ve=Ve+" "+(55*ae/(V-1)).toFixed(1)+","+(45-fe[Ie]*22/60/this.detected).toFixed(1))}Te["gl-chart"][we].setAttribute("points",Ve),D(this.names[we],fe,Ne)}})(this.chartLogger,this.dom)}}addUI(s){this.names.indexOf(s)==-1&&(this.names.push(s),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(s){this.frameId++;const f=s||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=f;else{let l=f-this.paramTime;if(l>=1e3){const u=this.frameId-this.paramFrame,d=u/l*1e3;for(let y=0;y<this.names.length;y++){const S=this.cpuAccums[y]/l*100,D=this.gpuAccums[y]/l*100,q=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(y,S,D,q,d,l,u),this.cpuAccums[y]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[y]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=f}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=f,this.circularId=0;else{let l=f-this.chartTime,u=this.chartHz*l/1e3;for(;--u>0&&this.detected;){const y=(this.frameId-this.chartFrame)/l*1e3;this.chart[this.circularId%this.chartLen]=y;for(let S=0;S<this.names.length;S++)this.chartLogger(S,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=f}}}begin(s){this.updateAccums(s)}end(s){this.updateAccums(s)}updateAccums(s){let f=this.names.indexOf(s);f==-1&&(f=this.names.length,this.addUI(s));const l=this.now(),u=l-this.t0;for(let d=0;d<f+1;d++)this.activeAccums[d]&&(this.cpuAccums[d]+=u);this.activeAccums[f]=!this.activeAccums[f],this.t0=l}}return r})}(fo)),fo.exports}var C0=E0();const P0=za(C0),k0=`
611
+ #gl-bench {
612
+ position:absolute;
613
+ right:0;
614
+ top:0;
615
+ z-index:1000;
616
+ -webkit-user-select: none;
617
+ -moz-user-select: none;
618
+ user-select: none;
619
+ }
620
+ #gl-bench div {
621
+ position: relative;
622
+ display: block;
623
+ margin: 4px;
624
+ padding: 0 7px 0 10px;
625
+ background: #5f69de;
626
+ border-radius: 15px;
627
+ cursor: pointer;
628
+ opacity: 0.9;
629
+ }
630
+ #gl-bench svg {
631
+ height: 60px;
632
+ margin: 0 -1px;
633
+ }
634
+ #gl-bench text {
635
+ font-size: 12px;
636
+ font-family: Helvetica,Arial,sans-serif;
637
+ font-weight: 700;
638
+ dominant-baseline: middle;
639
+ text-anchor: middle;
640
+ }
641
+ #gl-bench .gl-mem {
642
+ font-size: 9px;
643
+ }
644
+ #gl-bench line {
645
+ stroke-width: 5;
646
+ stroke: #112211;
647
+ stroke-linecap: round;
648
+ }
649
+ #gl-bench polyline {
650
+ fill: none;
651
+ stroke: #112211;
652
+ stroke-linecap: round;
653
+ stroke-linejoin: round;
654
+ stroke-width: 3.5;
655
+ }
656
+ #gl-bench rect {
657
+ fill: #8288e4;
658
+ }
659
+ #gl-bench .opacity {
660
+ stroke: #8288e4;
661
+ }
662
+ `;class Sl{constructor(e){this.destroy();const n=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new P0(n,{css:k0})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var n,i;(n=this.bench)==null||n.end("frame"),(i=this.bench)==null||i.nextFrame(e)}destroy(){this.bench=void 0,Ft("#gl-bench").remove()}}var Tl=(t=>(t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Triangle=2]="Triangle",t[t.Diamond=3]="Diamond",t[t.Pentagon=4]="Pentagon",t[t.Hexagon=5]="Hexagon",t[t.Star=6]="Star",t[t.Cross=7]="Cross",t[t.None=8]="None",t))(Tl||{});class I0{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=Fn(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 n=0;n<this.pointColors.length/4;n++)this.pointColors[n*4]=e[0],this.pointColors[n*4+1]=e[1],this.pointColors[n*4+2]=e[2],this.pointColors[n*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let n=0;n<this.pointColors.length/4;n++)nn(this.pointColors[n*4])||(this.pointColors[n*4]=e[0]),nn(this.pointColors[n*4+1])||(this.pointColors[n*4+1]=e[1]),nn(this.pointColors[n*4+2])||(this.pointColors[n*4+2]=e[2]),nn(this.pointColors[n*4+3])||(this.pointColors[n*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointSizes=this.inputPointSizes;for(let e=0;e<this.pointSizes.length;e++)nn(this.pointSizes[e])||(this.pointSizes[e]=this._config.pointSize)}}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 n=this.pointShapes;for(let i=0;i<n.length;i++){const r=n[i];(r==null||!nn(r)||r<0||r>8)&&(n[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 n=0;n<e.length;n++){const i=e[n],r=i===void 0?NaN:i;!Number.isFinite(r)||r<0?e[n]=-1:e[n]=Math.trunc(r)}this.pointImageIndices=e}}updatePointImageSizes(){var e;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(this._config.pointSize);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let n=0;n<this.pointImageSizes.length;n++)nn(this.pointImageSizes[n])||(this.pointImageSizes[n]=((e=this.pointSizes)==null?void 0:e[n])??this._config.pointSize)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Fn(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 n=0;n<this.linkColors.length/4;n++)this.linkColors[n*4]=e[0],this.linkColors[n*4+1]=e[1],this.linkColors[n*4+2]=e[2],this.linkColors[n*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let n=0;n<this.linkColors.length/4;n++)nn(this.linkColors[n*4])||(this.linkColors[n*4]=e[0]),nn(this.linkColors[n*4+1])||(this.linkColors[n*4+1]=e[1]),nn(this.linkColors[n*4+2])||(this.linkColors[n*4+2]=e[2]),nn(this.linkColors[n*4+3])||(this.linkColors[n*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(this._config.linkWidth);else{this.linkWidths=this.inputLinkWidths;for(let e=0;e<this.linkWidths.length;e++)nn(this.linkWidths[e])||(this.linkWidths[e]=this._config.linkWidth)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+this._config.linkArrows):this.linkArrows=this.linkArrowsBoolean.map(e=>+e)}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 n,i,r,o;return[...((i=(n=this.sourceIndexToTargetIndices)==null?void 0:n[e])==null?void 0:i.map(s=>s[0]))||[],...((o=(r=this.targetIndexToSourceIndices)==null?void 0:r[e])==null?void 0:o.map(s=>s[0]))||[]]}_createAdjacencyLists(){var e,n;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],o=this.links[i*2+1];r!==void 0&&o!==void 0&&(this.sourceIndexToTargetIndices[r]===void 0&&(this.sourceIndexToTargetIndices[r]=[]),(e=this.sourceIndexToTargetIndices[r])==null||e.push([o,i]),this.targetIndexToSourceIndices[o]===void 0&&(this.targetIndexToSourceIndices[o]=[]),(n=this.targetIndexToSourceIndices[o])==null||n.push([r,i]))}}_calculateDegrees(){var e,n,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 o=0;o<this.pointsNumber;o++)this.inDegree[o]=((n=(e=this.targetIndexToSourceIndices)==null?void 0:e[o])==null?void 0:n.length)??0,this.outDegree[o]=((r=(i=this.sourceIndexToTargetIndices)==null?void 0:i[o])==null?void 0:r.length)??0,this.degree[o]=(this.inDegree[o]??0)+(this.outDegree[o]??0)}}var L0=`precision highp float;
663
+
664
+ varying vec4 rgbaColor;
665
+ varying vec2 pos;
666
+ varying float arrowLength;
667
+ varying float useArrow;
668
+ varying float smoothing;
669
+ varying float arrowWidthFactor;
670
+ varying float linkIndex;
671
+
672
+ uniform float renderMode;
673
+
674
+ float map(float value, float min1, float max1, float min2, float max2) {
675
+ return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
676
+ }
677
+
678
+ void main() {
679
+ float opacity = 1.0;
680
+ vec3 color = rgbaColor.rgb;
681
+
682
+ if (useArrow > 0.5) {
683
+ float end_arrow = 0.5 + arrowLength / 2.0;
684
+ float start_arrow = end_arrow - arrowLength;
685
+ float arrowWidthDelta = arrowWidthFactor / 2.0;
686
+ float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothing / 2.0, abs(pos.y));
687
+ float arrowOpacity = 1.0;
688
+ if (pos.x > start_arrow && pos.x < start_arrow + arrowLength) {
689
+ float xmapped = map(pos.x, start_arrow, end_arrow, 0.0, 1.0);
690
+ arrowOpacity = rgbaColor.a * smoothstep(xmapped - smoothing, xmapped, map(abs(pos.y), 0.5, 0.0, 0.0, 1.0));
691
+ if (linkOpacity != arrowOpacity) {
692
+ linkOpacity = max(linkOpacity, arrowOpacity);
693
+ }
694
+ }
695
+ opacity = linkOpacity;
696
+ } else opacity = rgbaColor.a * smoothstep(0.5, 0.5 - smoothing, abs(pos.y));
697
+
698
+ if (renderMode > 0.0) {
699
+ if (opacity > 0.0) {
700
+ gl_FragColor = vec4(linkIndex, 0.0, 0.0, 1.0);
701
+ } else {
702
+ gl_FragColor = vec4(-1.0, 0.0, 0.0, 0.0);
703
+ }
704
+ } else gl_FragColor = vec4(color, opacity);
705
+
706
+ }`,D0=`precision highp float;
707
+
708
+ attribute vec2 position, pointA, pointB;
709
+ attribute vec4 color;
710
+ attribute float width;
711
+ attribute float arrow;
712
+ attribute float linkIndices;
713
+
714
+ uniform sampler2D positionsTexture;
715
+ uniform sampler2D pointGreyoutStatus;
716
+ uniform mat3 transformationMatrix;
717
+ uniform float pointsTextureSize;
718
+ uniform float widthScale;
719
+ uniform float linkArrowsSizeScale;
720
+ uniform float spaceSize;
721
+ uniform vec2 screenSize;
722
+ uniform vec2 linkVisibilityDistanceRange;
723
+ uniform float linkVisibilityMinTransparency;
724
+ uniform float linkOpacity;
725
+ uniform float greyoutOpacity;
726
+ uniform float curvedWeight;
727
+ uniform float curvedLinkControlPointDistance;
728
+ uniform float curvedLinkSegments;
729
+ uniform bool scaleLinksOnZoom;
730
+ uniform float maxPointSize;
731
+
732
+ uniform float renderMode;
733
+ uniform float hoveredLinkIndex;
734
+ uniform vec4 hoveredLinkColor;
735
+ uniform float hoveredLinkWidthIncrease;
736
+
737
+ varying vec4 rgbaColor;
738
+ varying vec2 pos;
739
+ varying float arrowLength;
740
+ varying float useArrow;
741
+ varying float smoothing;
742
+ varying float arrowWidthFactor;
743
+ varying float linkIndex;
744
+
745
+ float map(float value, float min1, float max1, float min2, float max2) {
746
+ return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
747
+ }
748
+
749
+ vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) {
750
+ vec2 divident = (1.0 - t) * (1.0 - t) * A + 2.0 * (1.0 - t) * t * w * ControlPoint + t * t * B;
751
+ float divisor = (1.0 - t) * (1.0 - t) + 2.0 * (1.0 - t) * t * w + t * t;
752
+ return divident / divisor;
753
+ }
754
+
755
+ float calculateLinkWidth(float width) {
756
+ float linkWidth;
757
+ if (scaleLinksOnZoom) {
758
+
759
+ linkWidth = width;
760
+ } else {
761
+
762
+ linkWidth = width / transformationMatrix[0][0];
763
+
764
+ linkWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
765
+ }
766
+
767
+ if (useArrow > 0.5) {
768
+ return min(linkWidth, (maxPointSize * 2.0) / transformationMatrix[0][0]);
769
+ } else {
770
+ return min(linkWidth, maxPointSize / transformationMatrix[0][0]);
771
+ }
772
+ }
773
+
774
+ float calculateArrowWidth(float arrowWidth) {
775
+ if (scaleLinksOnZoom) {
776
+ return arrowWidth;
777
+ } else {
778
+
779
+ arrowWidth = arrowWidth / transformationMatrix[0][0];
780
+
781
+ arrowWidth *= min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
782
+ return arrowWidth;
783
+ }
784
+ }
785
+
786
+ void main() {
787
+ pos = position;
788
+ linkIndex = linkIndices;
789
+
790
+ vec2 pointTexturePosA = (pointA + 0.5) / pointsTextureSize;
791
+ vec2 pointTexturePosB = (pointB + 0.5) / pointsTextureSize;
792
+
793
+ vec4 greyoutStatusA = texture2D(pointGreyoutStatus, pointTexturePosA);
794
+ vec4 greyoutStatusB = texture2D(pointGreyoutStatus, pointTexturePosB);
795
+
796
+ vec4 pointPositionA = texture2D(positionsTexture, pointTexturePosA);
797
+ vec4 pointPositionB = texture2D(positionsTexture, pointTexturePosB);
798
+ vec2 a = pointPositionA.xy;
799
+ vec2 b = pointPositionB.xy;
800
+
801
+
802
+ vec2 xBasis = b - a;
803
+ vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
804
+
805
+
806
+ float linkDist = length(xBasis);
807
+ float h = curvedLinkControlPointDistance;
808
+ vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h;
809
+
810
+
811
+ float linkDistPx = linkDist * transformationMatrix[0][0];
812
+
813
+
814
+ float linkWidth = width * widthScale;
815
+ float k = 2.0;
816
+
817
+ float arrowWidth = linkWidth * k;
818
+ arrowWidth *= linkArrowsSizeScale;
819
+
820
+
821
+ float arrowWidthDifference = max(0.0, arrowWidth - linkWidth);
822
+
823
+
824
+ float arrowWidthPx = calculateArrowWidth(arrowWidth);
825
+
826
+
827
+
828
+
829
+ arrowLength = min(0.3, (0.866 * arrowWidthPx * 2.0) / linkDist);
830
+
831
+ useArrow = arrow;
832
+ if (useArrow > 0.5) {
833
+ linkWidth += arrowWidthDifference;
834
+ }
835
+
836
+ arrowWidthFactor = arrowWidthDifference / linkWidth;
837
+
838
+
839
+ float linkWidthPx = calculateLinkWidth(linkWidth);
840
+
841
+ if (renderMode > 0.0) {
842
+
843
+ linkWidthPx += 5.0 / transformationMatrix[0][0];
844
+ } else {
845
+
846
+ if (hoveredLinkIndex == linkIndex) {
847
+ linkWidthPx += hoveredLinkWidthIncrease / transformationMatrix[0][0];
848
+ }
849
+ }
850
+ float smoothingPx = 0.5 / transformationMatrix[0][0];
851
+ smoothing = smoothingPx / linkWidthPx;
852
+ linkWidthPx += smoothingPx;
853
+
854
+
855
+ vec3 rgbColor = color.rgb;
856
+
857
+ float opacity = color.a * linkOpacity * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0));
858
+
859
+
860
+ if (greyoutStatusA.r > 0.0 || greyoutStatusB.r > 0.0) {
861
+ opacity *= greyoutOpacity;
862
+ }
863
+
864
+
865
+ rgbaColor = vec4(rgbColor, opacity);
866
+
867
+
868
+ if (hoveredLinkIndex == linkIndex && hoveredLinkColor.a > -0.5) {
869
+
870
+ rgbaColor.rgb = hoveredLinkColor.rgb;
871
+ rgbaColor.a *= hoveredLinkColor.a;
872
+ }
873
+
874
+
875
+ float t = position.x;
876
+ float w = curvedWeight;
877
+
878
+ float tPrev = t - 1.0 / curvedLinkSegments;
879
+ float tNext = t + 1.0 / curvedLinkSegments;
880
+
881
+ vec2 pointCurr = conicParametricCurve(a, b, controlPoint, t, w);
882
+
883
+ vec2 pointPrev = conicParametricCurve(a, b, controlPoint, max(0.0, tPrev), w);
884
+ vec2 pointNext = conicParametricCurve(a, b, controlPoint, min(tNext, 1.0), w);
885
+
886
+ vec2 xBasisCurved = pointNext - pointPrev;
887
+ vec2 yBasisCurved = normalize(vec2(-xBasisCurved.y, xBasisCurved.x));
888
+
889
+ pointCurr += yBasisCurved * linkWidthPx * position.y;
890
+
891
+
892
+ vec2 p = 2.0 * pointCurr / spaceSize - 1.0;
893
+ p *= spaceSize / screenSize;
894
+ vec3 final = transformationMatrix * vec3(p, 1);
895
+
896
+ gl_Position = vec4(final.rg, 0, 1);
897
+ }`,F0=`precision highp float;
898
+
899
+ uniform sampler2D linkIndexTexture;
900
+ uniform vec2 mousePosition;
901
+ uniform vec2 screenSize;
902
+
903
+ varying vec2 vTexCoord;
904
+
905
+ void main() {
906
+
907
+ vec2 texCoord = mousePosition / screenSize;
908
+
909
+
910
+ vec4 linkIndexData = texture2D(linkIndexTexture, texCoord);
911
+
912
+
913
+ float linkIndex = linkIndexData.r;
914
+
915
+
916
+ if (linkIndexData.a > 0.0 && linkIndex >= 0.0) {
917
+
918
+ gl_FragColor = vec4(linkIndex, 0.0, 0.0, 1.0);
919
+ } else {
920
+
921
+ gl_FragColor = vec4(-1.0, 0.0, 0.0, 0.0);
922
+ }
923
+ }`,z0=`attribute vec2 position;
924
+
925
+ varying vec2 vTexCoord;
926
+
927
+ void main() {
928
+ vTexCoord = position * 0.5 + 0.5;
929
+ gl_Position = vec4(position, 0.0, 1.0);
930
+ }`;function lo(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function R0(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function wl(t){let e,n,i;t.length!==2?(e=lo,n=(f,l)=>lo(t(f),l),i=(f,l)=>t(f)-l):(e=t===lo||t===R0?t:M0,n=t,i=t);function r(f,l,u=0,d=f.length){if(u<d){if(e(l,l)!==0)return d;do{const y=u+d>>>1;n(f[y],l)<0?u=y+1:d=y}while(u<d)}return u}function o(f,l,u=0,d=f.length){if(u<d){if(e(l,l)!==0)return d;do{const y=u+d>>>1;n(f[y],l)<=0?u=y+1:d=y}while(u<d)}return u}function s(f,l,u=0,d=f.length){const y=r(f,l,u,d-1);return y>u&&i(f[y-1],l)>-i(f[y],l)?y-1:y}return{left:r,center:s,right:o}}function M0(){return 0}function O0(t){return t===null?NaN:+t}const N0=wl(lo).right;wl(O0).center;function Al(t,e){let n,i;for(const r of t)r!=null&&(n===void 0?r>=r&&(n=i=r):(n>r&&(n=r),i<r&&(i=r)));return[n,i]}var Xa=Math.sqrt(50),ja=Math.sqrt(10),qa=Math.sqrt(2);function G0(t,e,n){var i,r=-1,o,s,f;if(e=+e,t=+t,n=+n,t===e&&n>0)return[t];if((i=e<t)&&(o=t,t=e,e=o),(f=El(t,e,n))===0||!isFinite(f))return[];if(f>0){let l=Math.round(t/f),u=Math.round(e/f);for(l*f<t&&++l,u*f>e&&--u,s=new Array(o=u-l+1);++r<o;)s[r]=(l+r)*f}else{f=-f;let l=Math.round(t*f),u=Math.round(e*f);for(l/f<t&&++l,u/f>e&&--u,s=new Array(o=u-l+1);++r<o;)s[r]=(l+r)/f}return i&&s.reverse(),s}function El(t,e,n){var i=(e-t)/Math.max(0,n),r=Math.floor(Math.log(i)/Math.LN10),o=i/Math.pow(10,r);return r>=0?(o>=Xa?10:o>=ja?5:o>=qa?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=Xa?10:o>=ja?5:o>=qa?2:1)}function B0(t,e,n){var i=Math.abs(e-t)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=Xa?r*=10:o>=ja?r*=5:o>=qa&&(r*=2),e<t?-r:r}function U0(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=Math.max(0,Math.ceil((e-t)/n))|0,o=new Array(r);++i<r;)o[i]=t+i*n;return o}function Cl(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function V0(t){return function(){return t}}function $0(t){return+t}var Pl=[0,1];function Sn(t){return t}function Ya(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:V0(isNaN(e)?NaN:.5)}function H0(t,e){var n;return t>e&&(n=t,t=e,e=n),function(i){return Math.max(t,Math.min(e,i))}}function W0(t,e,n){var i=t[0],r=t[1],o=e[0],s=e[1];return r<i?(i=Ya(r,i),o=n(s,o)):(i=Ya(i,r),o=n(o,s)),function(f){return o(i(f))}}function X0(t,e,n){var i=Math.min(t.length,e.length)-1,r=new Array(i),o=new Array(i),s=-1;for(t[i]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<i;)r[s]=Ya(t[s],t[s+1]),o[s]=n(e[s],e[s+1]);return function(f){var l=N0(t,f,1,i)-1;return o[l](r[l](f))}}function kl(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Il(){var t=Pl,e=Pl,n=La,i,r,o,s=Sn,f,l,u;function d(){var S=Math.min(t.length,e.length);return s!==Sn&&(s=H0(t[0],t[S-1])),f=S>2?X0:W0,l=u=null,y}function y(S){return S==null||isNaN(S=+S)?o:(l||(l=f(t.map(i),e,n)))(i(s(S)))}return y.invert=function(S){return s(r((u||(u=f(e,t.map(i),dn)))(S)))},y.domain=function(S){return arguments.length?(t=Array.from(S,$0),d()):t.slice()},y.range=function(S){return arguments.length?(e=Array.from(S),d()):e.slice()},y.rangeRound=function(S){return e=Array.from(S),n=sm,d()},y.clamp=function(S){return arguments.length?(s=S?!0:Sn,d()):s!==Sn},y.interpolate=function(S){return arguments.length?(n=S,d()):n},y.unknown=function(S){return arguments.length?(o=S,y):o},function(S,D){return i=S,r=D,d()}}function j0(){return Il()(Sn,Sn)}function q0(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function uo(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function Li(t){return t=uo(Math.abs(t)),t?t[1]:NaN}function Y0(t,e){return function(n,i){for(var r=n.length,o=[],s=0,f=t[0],l=0;r>0&&f>0&&(l+f+1>i&&(f=Math.max(1,i-l)),o.push(n.substring(r-=f,r+f)),!((l+=f+1)>i));)f=t[s=(s+1)%t.length];return o.reverse().join(e)}}function Z0(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Q0=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function co(t){if(!(e=Q0.exec(t)))throw new Error("invalid format: "+t);var e;return new Za({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]})}co.prototype=Za.prototype;function Za(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Za.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 K0(t){e:for(var e=t.length,n=1,i=-1,r;n<e;++n)switch(t[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+t[n])break e;i>0&&(i=0);break}return i>0?t.slice(0,i)+t.slice(r+1):t}var Ll;function J0(t,e){var n=uo(t,e);if(!n)return t+"";var i=n[0],r=n[1],o=r-(Ll=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+uo(t,Math.max(0,e+o-1))[0]}function Dl(t,e){var n=uo(t,e);if(!n)return t+"";var i=n[0],r=n[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 Fl={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:q0,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Dl(t*100,e),r:Dl,s:J0,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function zl(t){return t}var Rl=Array.prototype.map,Ml=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ev(t){var e=t.grouping===void 0||t.thousands===void 0?zl:Y0(Rl.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",i=t.currency===void 0?"":t.currency[1]+"",r=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?zl:Z0(Rl.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",f=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function u(y){y=co(y);var S=y.fill,D=y.align,q=y.sign,Te=y.symbol,we=y.zero,fe=y.width,Ne=y.comma,Ve=y.precision,V=y.trim,ae=y.type;ae==="n"?(Ne=!0,ae="g"):Fl[ae]||(Ve===void 0&&(Ve=12),V=!0,ae="g"),(we||S==="0"&&D==="=")&&(we=!0,S="0",D="=");var Ie=Te==="$"?n:Te==="#"&&/[boxX]/.test(ae)?"0"+ae.toLowerCase():"",Be=Te==="$"?i:/[%p]/.test(ae)?s:"",Xe=Fl[ae],nt=/[defgprs%]/.test(ae);Ve=Ve===void 0?6:/[gprs]/.test(ae)?Math.max(1,Math.min(21,Ve)):Math.max(0,Math.min(20,Ve));function lt(Ee){var ct=Ie,ft=Be,G,Pe,se;if(ae==="c")ft=Xe(Ee)+ft,Ee="";else{Ee=+Ee;var De=Ee<0||1/Ee<0;if(Ee=isNaN(Ee)?l:Xe(Math.abs(Ee),Ve),V&&(Ee=K0(Ee)),De&&+Ee==0&&q!=="+"&&(De=!1),ct=(De?q==="("?q:f:q==="-"||q==="("?"":q)+ct,ft=(ae==="s"?Ml[8+Ll/3]:"")+ft+(De&&q==="("?")":""),nt){for(G=-1,Pe=Ee.length;++G<Pe;)if(se=Ee.charCodeAt(G),48>se||se>57){ft=(se===46?r+Ee.slice(G+1):Ee.slice(G))+ft,Ee=Ee.slice(0,G);break}}}Ne&&!we&&(Ee=e(Ee,1/0));var qe=ct.length+Ee.length+ft.length,je=qe<fe?new Array(fe-qe+1).join(S):"";switch(Ne&&we&&(Ee=e(je+Ee,je.length?fe-ft.length:1/0),je=""),D){case"<":Ee=ct+Ee+ft+je;break;case"=":Ee=ct+je+Ee+ft;break;case"^":Ee=je.slice(0,qe=je.length>>1)+ct+Ee+ft+je.slice(qe);break;default:Ee=je+ct+Ee+ft;break}return o(Ee)}return lt.toString=function(){return y+""},lt}function d(y,S){var D=u((y=co(y),y.type="f",y)),q=Math.max(-8,Math.min(8,Math.floor(Li(S)/3)))*3,Te=Math.pow(10,-q),we=Ml[8+q/3];return function(fe){return D(Te*fe)+we}}return{format:u,formatPrefix:d}}var ho,Ol,Nl;tv({thousands:",",grouping:[3],currency:["$",""]});function tv(t){return ho=ev(t),Ol=ho.format,Nl=ho.formatPrefix,ho}function nv(t){return Math.max(0,-Li(Math.abs(t)))}function iv(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Li(e)/3)))*3-Li(Math.abs(t)))}function rv(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Li(e)-Li(t))+1}function ov(t,e,n,i){var r=B0(t,e,n),o;switch(i=co(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return i.precision==null&&!isNaN(o=iv(r,s))&&(i.precision=o),Nl(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(o=rv(r,Math.max(Math.abs(t),Math.abs(e))))&&(i.precision=o-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(o=nv(r))&&(i.precision=o-(i.type==="%")*2);break}}return Ol(i)}function Gl(t){var e=t.domain;return t.ticks=function(n){var i=e();return G0(i[0],i[i.length-1],n??10)},t.tickFormat=function(n,i){var r=e();return ov(r[0],r[r.length-1],n??10,i)},t.nice=function(n){n==null&&(n=10);var i=e(),r=0,o=i.length-1,s=i[r],f=i[o],l,u,d=10;for(f<s&&(u=s,s=f,f=u,u=r,r=o,o=u);d-- >0;){if(u=El(s,f,n),u===l)return i[r]=s,i[o]=f,e(i);if(u>0)s=Math.floor(s/u)*u,f=Math.ceil(f/u)*u;else if(u<0)s=Math.ceil(s*u)/u,f=Math.floor(f*u)/u;else break;l=u}return t},t}function Qa(){var t=j0();return t.copy=function(){return kl(t,Qa())},Cl.apply(t,arguments),Gl(t)}function Bl(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function av(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function sv(t){return t<0?-t*t:t*t}function fv(t){var e=t(Sn,Sn),n=1;function i(){return n===1?t(Sn,Sn):n===.5?t(av,sv):t(Bl(n),Bl(1/n))}return e.exponent=function(r){return arguments.length?(n=+r,i()):n},Gl(e)}function Ul(){var t=fv(Il());return t.copy=function(){return kl(t,Ul()).exponent(t.exponent())},Cl.apply(t,arguments),t}const lv=t=>{const e=Ul().exponent(2).range([0,1]).domain([-1,1]),n=U0(0,t).map(r=>-.5+r/t);n.push(.5);const i=new Array(n.length*2);return n.forEach((r,o)=>{i[o*2]=[e(r*2),.5],i[o*2+1]=[e(r*2),-.5]}),i};class uv extends zn{initPrograms(){const{reglInstance:e,config:n,store:i}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=e.framebuffer({color:e.texture({width:1,height:1,format:"rgba",type:"float"}),depth:!1,stencil:!1})),this.drawCurveCommand||(this.drawCurveCommand=e({vert:D0,frag:L0,attributes:{position:{buffer:()=>this.curveLineBuffer,divisor:0},pointA:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},pointB:{buffer:()=>this.pointsBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*2,stride:Float32Array.BYTES_PER_ELEMENT*4},color:{buffer:()=>this.colorBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*4},width:{buffer:()=>this.widthBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1},arrow:{buffer:()=>this.arrowBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1},linkIndices:{buffer:()=>this.linkIndexBuffer,divisor:1,offset:Float32Array.BYTES_PER_ELEMENT*0,stride:Float32Array.BYTES_PER_ELEMENT*1}},uniforms:{positionsTexture:()=>{var r;return(r=this.points)==null?void 0:r.currentPositionFbo},pointGreyoutStatus:()=>{var r;return(r=this.points)==null?void 0:r.greyoutStatusFbo},transformationMatrix:()=>i.transform,pointsTextureSize:()=>i.pointsTextureSize,widthScale:()=>n.linkWidthScale,linkArrowsSizeScale:()=>n.linkArrowsSizeScale,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,linkVisibilityDistanceRange:()=>n.linkVisibilityDistanceRange,linkVisibilityMinTransparency:()=>n.linkVisibilityMinTransparency,linkOpacity:()=>n.linkOpacity,greyoutOpacity:()=>n.linkGreyoutOpacity,scaleLinksOnZoom:()=>n.scaleLinksOnZoom,maxPointSize:()=>i.maxPointSize,curvedWeight:()=>n.curvedLinkWeight,curvedLinkControlPointDistance:()=>n.curvedLinkControlPointDistance,curvedLinkSegments:()=>n.curvedLinks?n.curvedLinkSegments??Oe.curvedLinkSegments:1,hoveredLinkIndex:()=>i.hoveredLinkIndex??-1,hoveredLinkColor:()=>i.hoveredLinkColor,hoveredLinkWidthIncrease:()=>n.hoveredLinkWidthIncrease,renderMode:e.prop("renderMode")},cull:{enable:!0,face:"back"},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},framebuffer:e.prop("framebuffer"),count:()=>{var r;return((r=this.curveLineGeometry)==null?void 0:r.length)??0},instances:()=>this.data.linksNumber??0,primitive:"triangle strip"})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=e({vert:z0,frag:F0,attributes:{position:{buffer:()=>this.quadBuffer}},uniforms:{linkIndexTexture:()=>this.linkIndexFbo,mousePosition:()=>i.screenMousePosition,screenSize:()=>i.screenSize},framebuffer:this.hoveredLineIndexFbo,count:4,primitive:"triangle strip"})),this.quadBuffer||(this.quadBuffer=e.buffer([-1,-1,1,-1,-1,1,1,1]))}draw(){var e;this.pointsBuffer&&(this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),(e=this.drawCurveCommand)==null||e.call(this,{framebuffer:null,renderMode:0}))}updateLinkIndexFbo(){const{reglInstance:e,store:n}=this;this.store.isLinkHoveringEnabled&&(this.linkIndexFbo||(this.linkIndexFbo=e.framebuffer()),this.linkIndexFbo({color:e.texture({width:n.screenSize[0],height:n.screenSize[1],format:"rgba",type:"float"}),depth:!1,stencil:!1}))}updatePointsBuffer(){const{reglInstance:e,data:n,store:i}=this;if(n.linksNumber===void 0||n.links===void 0)return;const r=new Float32Array(n.linksNumber*4);for(let s=0;s<n.linksNumber;s++){const f=n.links[s*2],l=n.links[s*2+1],u=f%i.pointsTextureSize,d=Math.floor(f/i.pointsTextureSize),y=l%i.pointsTextureSize,S=Math.floor(l/i.pointsTextureSize),D=s*4;r[D]=u,r[D+1]=d,r[D+2]=y,r[D+3]=S}this.pointsBuffer||(this.pointsBuffer=e.buffer(0)),this.pointsBuffer(r);const o=new Float32Array(n.linksNumber);for(let s=0;s<n.linksNumber;s++)o[s]=s;this.linkIndexBuffer||(this.linkIndexBuffer=e.buffer(0)),this.linkIndexBuffer(o)}updateColor(){const{reglInstance:e,data:n}=this;this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(n.linkColors??new Float32Array)}updateWidth(){const{reglInstance:e,data:n}=this;this.widthBuffer||(this.widthBuffer=e.buffer(0)),this.widthBuffer(n.linkWidths??new Float32Array)}updateArrow(){const{reglInstance:e,data:n}=this;this.arrowBuffer||(this.arrowBuffer=e.buffer(0)),this.arrowBuffer(n.linkArrows??new Float32Array)}updateCurveLineGeometry(){const{reglInstance:e,config:{curvedLinks:n,curvedLinkSegments:i}}=this;this.curveLineGeometry=lv(n?i??Oe.curvedLinkSegments:1),this.curveLineBuffer||(this.curveLineBuffer=e.buffer(0)),this.curveLineBuffer(this.curveLineGeometry)}findHoveredLine(){var e,n;!this.data.linksNumber||!this.store.isLinkHoveringEnabled||(this.linkIndexFbo||this.updateLinkIndexFbo(),this.reglInstance.clear({framebuffer:this.linkIndexFbo,color:[0,0,0,0]}),(e=this.drawCurveCommand)==null||e.call(this,{framebuffer:this.linkIndexFbo,renderMode:1}),(n=this.hoveredLineIndexCommand)==null||n.call(this))}}var cv=`#ifdef GL_ES
931
+ precision highp float;
932
+ #endif
933
+
934
+ uniform float greyoutOpacity;
935
+ uniform float pointOpacity;
936
+ uniform sampler2D imageAtlasTexture;
937
+ uniform bool isDarkenGreyout;
938
+ uniform vec4 backgroundColor;
939
+
940
+ varying float pointShape;
941
+ varying float isGreyedOut;
942
+ varying vec4 shapeColor;
943
+ varying vec4 imageAtlasUV;
944
+ varying float shapeSize;
945
+ varying float imageSizeVarying;
946
+ varying float overallSize;
947
+
948
+ const float smoothing = 0.9;
949
+
950
+ const float CIRCLE = 0.0;
951
+ const float SQUARE = 1.0;
952
+ const float TRIANGLE = 2.0;
953
+ const float DIAMOND = 3.0;
954
+ const float PENTAGON = 4.0;
955
+ const float HEXAGON = 5.0;
956
+ const float STAR = 6.0;
957
+ const float CROSS = 7.0;
958
+ const float NONE = 8.0;
959
+
960
+ float circleDistance(vec2 p) {
961
+ return dot(p, p);
962
+ }
963
+
964
+ vec4 applyGreyoutToImage(vec4 imageColor) {
965
+ vec3 finalColor = imageColor.rgb;
966
+ float finalAlpha = imageColor.a;
967
+
968
+ if (isGreyedOut > 0.0) {
969
+ float blendFactor = 0.65;
970
+
971
+ if (isDarkenGreyout) {
972
+ finalColor = mix(finalColor, vec3(0.2), blendFactor);
973
+ } else {
974
+ finalColor = mix(finalColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
975
+ }
976
+ }
977
+
978
+ return vec4(finalColor, finalAlpha);
979
+ }
980
+
981
+ float squareDistance(vec2 p) {
982
+ vec2 d = abs(p) - vec2(0.8);
983
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
984
+ }
985
+
986
+ float triangleDistance(vec2 p) {
987
+ const float k = sqrt(3.0);
988
+ p.x = abs(p.x) - 0.9;
989
+ p.y = p.y + 0.55;
990
+
991
+
992
+ if (p.x + k * p.y > 0.0)
993
+ p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;
994
+
995
+ p.x -= clamp(p.x, -1.0, 0.0);
996
+
997
+
998
+ return -length(p) * sign(p.y);
999
+ }
1000
+
1001
+ float diamondDistance(vec2 p) {
1002
+
1003
+ const float aspect = 1.2;
1004
+ return abs(p.x) + abs(p.y) / aspect - 0.8;
1005
+ }
1006
+
1007
+ float pentagonDistance(vec2 p) {
1008
+
1009
+ const vec3 k = vec3(0.809016994, 0.587785252, 0.726542528);
1010
+ p.x = abs(p.x);
1011
+
1012
+
1013
+ p -= 2.0 * min(dot(vec2(-k.x, k.y), p), 0.0) * vec2(-k.x, k.y);
1014
+ p -= 2.0 * min(dot(vec2( k.x, k.y), p), 0.0) * vec2( k.x, k.y);
1015
+
1016
+
1017
+ p -= vec2(clamp(p.x, -k.z * k.x, k.z * k.x), k.z);
1018
+
1019
+
1020
+ return length(p) * sign(p.y);
1021
+ }
1022
+
1023
+ float hexagonDistance(vec2 p) {
1024
+ const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
1025
+ p = abs(p);
1026
+ p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy;
1027
+ p -= vec2(clamp(p.x, -k.z * 0.8, k.z * 0.8), 0.8);
1028
+ return length(p) * sign(p.y);
1029
+ }
1030
+
1031
+ float starDistance(vec2 p) {
1032
+
1033
+
1034
+ const float r = 0.9;
1035
+ const float rf = 0.45;
1036
+
1037
+
1038
+ const vec2 k1 = vec2(0.809016994, -0.587785252);
1039
+ const vec2 k2 = vec2(-k1.x, k1.y);
1040
+
1041
+
1042
+ p.x = abs(p.x);
1043
+ p -= 2.0 * max(dot(k1, p), 0.0) * k1;
1044
+ p -= 2.0 * max(dot(k2, p), 0.0) * k2;
1045
+ p.x = abs(p.x);
1046
+
1047
+
1048
+ p.y -= r;
1049
+
1050
+
1051
+ vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0);
1052
+
1053
+ float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);
1054
+
1055
+
1056
+ return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);
1057
+ }
1058
+
1059
+ float crossDistance(vec2 p) {
1060
+
1061
+
1062
+
1063
+ p = abs(p);
1064
+ if (p.y > p.x) p = p.yx;
1065
+
1066
+ vec2 q = p - vec2(0.8, 0.3);
1067
+
1068
+
1069
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
1070
+ }
1071
+
1072
+ float getShapeDistance(vec2 p, float shape) {
1073
+ if (shape == SQUARE) return squareDistance(p);
1074
+ else if (shape == TRIANGLE) return triangleDistance(p);
1075
+ else if (shape == DIAMOND) return diamondDistance(p);
1076
+ else if (shape == PENTAGON) return pentagonDistance(p);
1077
+ else if (shape == HEXAGON) return hexagonDistance(p);
1078
+ else if (shape == STAR) return starDistance(p);
1079
+ else if (shape == CROSS) return crossDistance(p);
1080
+ else return circleDistance(p);
1081
+ }
1082
+
1083
+ void main() {
1084
+
1085
+ if (shapeColor.a == 0.0 && imageAtlasUV.x == -1.0) {
1086
+ discard;
1087
+ }
1088
+
1089
+
1090
+ if (pointShape == NONE && imageAtlasUV.x == -1.0) {
1091
+ discard;
1092
+ }
1093
+
1094
+
1095
+ vec2 pointCoord = 2.0 * gl_PointCoord - 1.0;
1096
+
1097
+ vec4 finalShapeColor = vec4(0.0);
1098
+ vec4 finalImageColor = vec4(0.0);
1099
+
1100
+
1101
+ if (pointShape != NONE) {
1102
+
1103
+ vec2 shapeCoord = pointCoord;
1104
+ if (overallSize > shapeSize && shapeSize > 0.0) {
1105
+
1106
+ float scale = shapeSize / overallSize;
1107
+ shapeCoord = pointCoord / scale;
1108
+ }
1109
+
1110
+ float opacity;
1111
+ if (pointShape == CIRCLE) {
1112
+
1113
+ float pointCenterDistance = dot(shapeCoord, shapeCoord);
1114
+ opacity = 1.0 - smoothstep(smoothing, 1.0, pointCenterDistance);
1115
+ } else {
1116
+
1117
+ float shapeDistance = getShapeDistance(shapeCoord, pointShape);
1118
+ opacity = 1.0 - smoothstep(-0.01, 0.01, shapeDistance);
1119
+ }
1120
+ opacity *= shapeColor.a;
1121
+
1122
+ finalShapeColor = vec4(shapeColor.rgb, opacity);
1123
+ }
1124
+
1125
+
1126
+ if (imageAtlasUV.x != -1.0) {
1127
+
1128
+ vec2 imageCoord = pointCoord;
1129
+ if (overallSize > imageSizeVarying && imageSizeVarying > 0.0) {
1130
+
1131
+ float scale = imageSizeVarying / overallSize;
1132
+ imageCoord = pointCoord / scale;
1133
+
1134
+
1135
+ if (abs(imageCoord.x) > 1.0 || abs(imageCoord.y) > 1.0) {
1136
+
1137
+ finalImageColor = vec4(0.0);
1138
+ } else {
1139
+
1140
+ vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
1141
+ vec4 imageColor = texture2D(imageAtlasTexture, atlasUV);
1142
+ finalImageColor = applyGreyoutToImage(imageColor);
1143
+ }
1144
+ } else {
1145
+
1146
+
1147
+ vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
1148
+ vec4 imageColor = texture2D(imageAtlasTexture, atlasUV);
1149
+ finalImageColor = applyGreyoutToImage(imageColor);
1150
+ }
1151
+ }
1152
+
1153
+ float finalPointAlpha = max(finalShapeColor.a, finalImageColor.a);
1154
+ if (isGreyedOut > 0.0 && greyoutOpacity != -1.0) {
1155
+ finalPointAlpha *= greyoutOpacity;
1156
+ } else {
1157
+ finalPointAlpha *= pointOpacity;
1158
+ }
1159
+
1160
+
1161
+ gl_FragColor = vec4(
1162
+ mix(finalShapeColor.rgb, finalImageColor.rgb, finalImageColor.a),
1163
+ finalPointAlpha
1164
+ );
1165
+ }`,hv=`#ifdef GL_ES
1166
+ precision highp float;
1167
+ #endif
1168
+
1169
+ attribute vec2 pointIndices;
1170
+ attribute float size;
1171
+ attribute vec4 color;
1172
+ attribute float shape;
1173
+ attribute float imageIndex;
1174
+ attribute float imageSize;
1175
+
1176
+ uniform sampler2D positionsTexture;
1177
+ uniform sampler2D pointGreyoutStatus;
1178
+ uniform sampler2D imageAtlasCoords;
1179
+ uniform float ratio;
1180
+ uniform mat3 transformationMatrix;
1181
+ uniform float pointsTextureSize;
1182
+ uniform float sizeScale;
1183
+ uniform float spaceSize;
1184
+ uniform vec2 screenSize;
1185
+
1186
+ uniform vec4 greyoutColor;
1187
+ uniform vec4 backgroundColor;
1188
+ uniform bool scalePointsOnZoom;
1189
+ uniform float maxPointSize;
1190
+ uniform bool isDarkenGreyout;
1191
+ uniform bool skipSelected;
1192
+ uniform bool skipUnselected;
1193
+ uniform bool hasImages;
1194
+ uniform float imageCount;
1195
+ uniform float imageAtlasCoordsTextureSize;
1196
+
1197
+ varying float pointShape;
1198
+ varying float isGreyedOut;
1199
+ varying vec4 shapeColor;
1200
+ varying vec4 imageAtlasUV;
1201
+ varying float shapeSize;
1202
+ varying float imageSizeVarying;
1203
+ varying float overallSize;
1204
+
1205
+ float calculatePointSize(float size) {
1206
+ float pSize;
1207
+ if (scalePointsOnZoom) {
1208
+ pSize = size * ratio * transformationMatrix[0][0];
1209
+ } else {
1210
+ pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
1211
+ }
1212
+
1213
+ return min(pSize, maxPointSize * ratio);
1214
+ }
1215
+
1216
+ void main() {
1217
+
1218
+ vec4 greyoutStatus = texture2D(pointGreyoutStatus, (pointIndices + 0.5) / pointsTextureSize);
1219
+ isGreyedOut = greyoutStatus.r;
1220
+ bool isSelected = greyoutStatus.r == 0.0;
1221
+
1222
+
1223
+ if (skipSelected && isSelected) {
1224
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
1225
+ gl_PointSize = 0.0;
1226
+ return;
1227
+ }
1228
+ if (skipUnselected && !isSelected) {
1229
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
1230
+ gl_PointSize = 0.0;
1231
+ return;
1232
+ }
1233
+
1234
+
1235
+ vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
1236
+ vec2 point = pointPosition.rg;
1237
+
1238
+
1239
+ vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0;
1240
+ normalizedPosition *= spaceSize / screenSize;
1241
+ vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1);
1242
+ gl_Position = vec4(finalPosition.rg, 0, 1);
1243
+
1244
+
1245
+ float shapeSizeValue = calculatePointSize(size * sizeScale);
1246
+ float imageSizeValue = calculatePointSize(imageSize * sizeScale);
1247
+
1248
+
1249
+ float overallSizeValue = max(shapeSizeValue, imageSizeValue);
1250
+ gl_PointSize = overallSizeValue;
1251
+
1252
+
1253
+ shapeSize = shapeSizeValue;
1254
+ imageSizeVarying = imageSizeValue;
1255
+ overallSize = overallSizeValue;
1256
+
1257
+ shapeColor = color;
1258
+ pointShape = shape;
1259
+
1260
+
1261
+ if (isGreyedOut > 0.0) {
1262
+ if (greyoutColor[0] != -1.0) {
1263
+ shapeColor = greyoutColor;
1264
+ } else {
1265
+
1266
+ float blendFactor = 0.65;
1267
+
1268
+ if (isDarkenGreyout) {
1269
+
1270
+ shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor);
1271
+ } else {
1272
+
1273
+ shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
1274
+ }
1275
+ }
1276
+ }
1277
+
1278
+ if (!hasImages || imageIndex < 0.0 || imageIndex >= imageCount) {
1279
+ imageAtlasUV = vec4(-1.0);
1280
+ return;
1281
+ }
1282
+
1283
+ float atlasCoordIndex = imageIndex;
1284
+
1285
+ float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize);
1286
+ float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize);
1287
+
1288
+ vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize;
1289
+ vec4 atlasCoords = texture2D(imageAtlasCoords, atlasCoordTexCoord);
1290
+ imageAtlasUV = atlasCoords;
1291
+ }`,dv=`#ifdef GL_ES
1292
+ precision highp float;
1293
+ #endif
1294
+
1295
+ uniform sampler2D positionsTexture;
1296
+ uniform sampler2D pointSize;
1297
+ uniform float sizeScale;
1298
+ uniform float spaceSize;
1299
+ uniform vec2 screenSize;
1300
+ uniform float ratio;
1301
+ uniform mat3 transformationMatrix;
1302
+ uniform vec2 selection0;
1303
+ uniform vec2 selection1;
1304
+ uniform bool scalePointsOnZoom;
1305
+ uniform float maxPointSize;
1306
+
1307
+ varying vec2 textureCoords;
1308
+
1309
+ float pointSizeF(float size) {
1310
+ float pSize;
1311
+ if (scalePointsOnZoom) {
1312
+ pSize = size * ratio * transformationMatrix[0][0];
1313
+ } else {
1314
+ pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
1315
+ }
1316
+ return min(pSize, maxPointSize * ratio);
1317
+ }
1318
+
1319
+ void main() {
1320
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
1321
+ vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
1322
+ p *= spaceSize / screenSize;
1323
+ vec3 final = transformationMatrix * vec3(p, 1);
1324
+
1325
+ vec4 pSize = texture2D(pointSize, textureCoords);
1326
+ float size = pSize.r * sizeScale;
1327
+
1328
+ float left = 2.0 * (selection0.x - 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
1329
+ float right = 2.0 * (selection1.x + 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
1330
+ float top = 2.0 * (selection0.y - 0.5 * pointSizeF(size)) / screenSize.y - 1.0;
1331
+ float bottom = 2.0 * (selection1.y + 0.5 * pointSizeF(size)) / screenSize.y - 1.0;
1332
+
1333
+ gl_FragColor = vec4(0.0, 0.0, pointPosition.rg);
1334
+ if (final.x >= left && final.x <= right && final.y >= top && final.y <= bottom) {
1335
+ gl_FragColor.r = 1.0;
1336
+ }
1337
+ }`,mv=`#ifdef GL_ES
1338
+ precision highp float;
1339
+ #endif
1340
+
1341
+ uniform sampler2D positionsTexture;
1342
+ uniform sampler2D polygonPathTexture;
1343
+ uniform int polygonPathLength;
1344
+ uniform float spaceSize;
1345
+ uniform vec2 screenSize;
1346
+ uniform mat3 transformationMatrix;
1347
+
1348
+ varying vec2 textureCoords;
1349
+
1350
+ vec2 getPolygonPoint(sampler2D pathTexture, int index, int pathLength) {
1351
+ if (index >= pathLength) return vec2(0.0);
1352
+
1353
+
1354
+ int textureSize = int(ceil(sqrt(float(pathLength))));
1355
+ int x = index - (index / textureSize) * textureSize;
1356
+ int y = index / textureSize;
1357
+
1358
+ vec2 texCoord = (vec2(float(x), float(y)) + 0.5) / float(textureSize);
1359
+ vec4 pathData = texture2D(pathTexture, texCoord);
1360
+
1361
+ return pathData.xy;
1362
+ }
1363
+
1364
+ bool pointInPolygon(vec2 point, sampler2D pathTexture, int pathLength) {
1365
+ bool inside = false;
1366
+
1367
+ for (int i = 0; i < 2048; i++) {
1368
+ if (i >= pathLength) break;
1369
+
1370
+ int j = int(mod(float(i + 1), float(pathLength)));
1371
+
1372
+ vec2 pi = getPolygonPoint(pathTexture, i, pathLength);
1373
+ vec2 pj = getPolygonPoint(pathTexture, j, pathLength);
1374
+
1375
+ if (((pi.y > point.y) != (pj.y > point.y)) &&
1376
+ (point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x)) {
1377
+ inside = !inside;
1378
+ }
1379
+ }
1380
+
1381
+ return inside;
1382
+ }
1383
+
1384
+ void main() {
1385
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
1386
+ vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
1387
+ p *= spaceSize / screenSize;
1388
+ vec3 final = transformationMatrix * vec3(p, 1);
1389
+
1390
+
1391
+ vec2 screenPos = (final.xy + 1.0) * screenSize / 2.0;
1392
+
1393
+ gl_FragColor = vec4(0.0, 0.0, pointPosition.rg);
1394
+
1395
+
1396
+ if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) {
1397
+ gl_FragColor.r = 1.0;
1398
+ }
1399
+ }`,pv=`precision mediump float;
1400
+
1401
+ uniform float width;
1402
+
1403
+ varying vec2 vertexPosition;
1404
+ varying float pointOpacity;
1405
+ varying vec3 rgbColor;
1406
+
1407
+ const float smoothing = 1.05;
1408
+
1409
+ void main () {
1410
+ float r = dot(vertexPosition, vertexPosition);
1411
+ float opacity = smoothstep(r, r * smoothing, 1.0);
1412
+ float stroke = smoothstep(width, width * smoothing, r);
1413
+ gl_FragColor = vec4(rgbColor, opacity * stroke * pointOpacity);
1414
+ }`,vv=`precision mediump float;
1415
+
1416
+ attribute vec2 vertexCoord;
1417
+
1418
+ uniform sampler2D positionsTexture;
1419
+ uniform sampler2D pointGreyoutStatusTexture;
1420
+ uniform float size;
1421
+ uniform mat3 transformationMatrix;
1422
+ uniform float pointsTextureSize;
1423
+ uniform float sizeScale;
1424
+ uniform float spaceSize;
1425
+ uniform vec2 screenSize;
1426
+ uniform bool scalePointsOnZoom;
1427
+ uniform float pointIndex;
1428
+ uniform float maxPointSize;
1429
+ uniform vec4 color;
1430
+ uniform float universalPointOpacity;
1431
+ uniform float greyoutOpacity;
1432
+ uniform bool isDarkenGreyout;
1433
+ uniform vec4 backgroundColor;
1434
+ uniform vec4 greyoutColor;
1435
+ varying vec2 vertexPosition;
1436
+ varying float pointOpacity;
1437
+ varying vec3 rgbColor;
1438
+
1439
+ float calculatePointSize(float size) {
1440
+ float pSize;
1441
+ if (scalePointsOnZoom) {
1442
+ pSize = size * transformationMatrix[0][0];
1443
+ } else {
1444
+ pSize = size * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
1445
+ }
1446
+ return min(pSize, maxPointSize);
1447
+ }
1448
+
1449
+ const float relativeRingRadius = 1.3;
1450
+
1451
+ void main () {
1452
+ vertexPosition = vertexCoord;
1453
+
1454
+ vec2 textureCoordinates = vec2(mod(pointIndex, pointsTextureSize), floor(pointIndex / pointsTextureSize)) + 0.5;
1455
+ vec4 pointPosition = texture2D(positionsTexture, textureCoordinates / pointsTextureSize);
1456
+
1457
+ rgbColor = color.rgb;
1458
+ pointOpacity = color.a * universalPointOpacity;
1459
+ vec4 greyoutStatus = texture2D(pointGreyoutStatusTexture, textureCoordinates / pointsTextureSize);
1460
+ if (greyoutStatus.r > 0.0) {
1461
+ if (greyoutColor[0] != -1.0) {
1462
+ rgbColor = greyoutColor.rgb;
1463
+ pointOpacity = greyoutColor.a;
1464
+ } else {
1465
+
1466
+ float blendFactor = 0.65;
1467
+
1468
+ if (isDarkenGreyout) {
1469
+
1470
+ rgbColor = mix(rgbColor, vec3(0.2), blendFactor);
1471
+ } else {
1472
+
1473
+ rgbColor = mix(rgbColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
1474
+ }
1475
+ }
1476
+
1477
+ if (greyoutOpacity != -1.0) {
1478
+ pointOpacity *= greyoutOpacity;
1479
+ }
1480
+ }
1481
+
1482
+
1483
+ float pointSize = (calculatePointSize(size * sizeScale) * relativeRingRadius) / transformationMatrix[0][0];
1484
+ float radius = pointSize * 0.5;
1485
+
1486
+
1487
+ vec2 a = pointPosition.xy;
1488
+ vec2 b = pointPosition.xy + vec2(0.0, radius);
1489
+ vec2 xBasis = b - a;
1490
+ vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
1491
+ vec2 pointPositionInScreenSpace = a + xBasis * vertexCoord.x + yBasis * radius * vertexCoord.y;
1492
+
1493
+
1494
+ vec2 p = 2.0 * pointPositionInScreenSpace / spaceSize - 1.0;
1495
+ p *= spaceSize / screenSize;
1496
+ vec3 final = transformationMatrix * vec3(p, 1);
1497
+
1498
+ gl_Position = vec4(final.rg, 0, 1);
1499
+ }`,gv=`#ifdef GL_ES
1500
+ precision highp float;
1501
+ #endif
1502
+
1503
+ varying vec4 rgba;
1504
+
1505
+ void main() {
1506
+ gl_FragColor = rgba;
1507
+ }`,yv=`#ifdef GL_ES
1508
+ precision highp float;
1509
+ #endif
1510
+
1511
+ attribute float size;
1512
+
1513
+ uniform sampler2D positionsTexture;
1514
+ uniform float pointsTextureSize;
1515
+ uniform float sizeScale;
1516
+ uniform float spaceSize;
1517
+ uniform vec2 screenSize;
1518
+ uniform float ratio;
1519
+ uniform mat3 transformationMatrix;
1520
+ uniform vec2 mousePosition;
1521
+ uniform bool scalePointsOnZoom;
1522
+ uniform float maxPointSize;
1523
+
1524
+ attribute vec2 pointIndices;
1525
+
1526
+ varying vec4 rgba;
1527
+
1528
+ float calculatePointSize(float size) {
1529
+ float pSize;
1530
+ if (scalePointsOnZoom) {
1531
+ pSize = size * ratio * transformationMatrix[0][0];
1532
+ } else {
1533
+ pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
1534
+ }
1535
+ return min(pSize, maxPointSize * ratio);
1536
+ }
1537
+
1538
+ float euclideanDistance (float x1, float x2, float y1, float y2) {
1539
+ return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
1540
+ }
1541
+
1542
+ void main() {
1543
+ vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
1544
+
1545
+
1546
+ vec2 normalizedPoint = 2.0 * pointPosition.rg / spaceSize - 1.0;
1547
+ normalizedPoint *= spaceSize / screenSize;
1548
+ vec3 finalPosition = transformationMatrix * vec3(normalizedPoint, 1);
1549
+
1550
+ float pointRadius = 0.5 * calculatePointSize(size * sizeScale);
1551
+
1552
+ vec2 pointScreenPosition = (finalPosition.xy + 1.0) * screenSize / 2.0;
1553
+ rgba = vec4(0.0);
1554
+ gl_Position = vec4(0.5, 0.5, 0.0, 1.0);
1555
+
1556
+ if (euclideanDistance(pointScreenPosition.x, mousePosition.x, pointScreenPosition.y, mousePosition.y) < pointRadius / ratio) {
1557
+ float index = pointIndices.g * pointsTextureSize + pointIndices.r;
1558
+ rgba = vec4(index, size, pointPosition.xy);
1559
+ gl_Position = vec4(-0.5, -0.5, 0.0, 1.0);
1560
+ }
1561
+
1562
+ gl_PointSize = 1.0;
1563
+ }`,xv=`#ifdef GL_ES
1564
+ precision highp float;
1565
+ #endif
1566
+
1567
+ varying vec4 rgba;
1568
+
1569
+ void main() {
1570
+ gl_FragColor = rgba;
1571
+ }`,bv=`#ifdef GL_ES
1572
+ precision highp float;
1573
+ #endif
1574
+
1575
+ uniform sampler2D positionsTexture;
1576
+ uniform float pointsTextureSize;
1577
+ uniform float spaceSize;
1578
+ uniform vec2 screenSize;
1579
+ uniform mat3 transformationMatrix;
1580
+
1581
+ attribute vec2 pointIndices;
1582
+
1583
+ varying vec4 rgba;
1584
+
1585
+ void main() {
1586
+ vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
1587
+ vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
1588
+ p *= spaceSize / screenSize;
1589
+ vec3 final = transformationMatrix * vec3(p, 1);
1590
+
1591
+ vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0;
1592
+ float index = pointIndices.g * pointsTextureSize + pointIndices.r;
1593
+ rgba = vec4(index, 1.0, pointPosition.xy);
1594
+ float i = (pointScreenPosition.x + 0.5) / screenSize.x;
1595
+ float j = (pointScreenPosition.y + 0.5) / screenSize.y;
1596
+ gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0);
1597
+
1598
+ gl_PointSize = 1.0;
1599
+ }`,_v=`#ifdef GL_ES
1600
+ precision highp float;
1601
+ #endif
1602
+
1603
+ uniform sampler2D positionsTexture;
1604
+ uniform sampler2D velocity;
1605
+ uniform sampler2D pinnedStatusTexture;
1606
+ uniform float friction;
1607
+ uniform float spaceSize;
1608
+
1609
+ varying vec2 textureCoords;
1610
+
1611
+ void main() {
1612
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
1613
+ vec4 pointVelocity = texture2D(velocity, textureCoords);
1614
+
1615
+
1616
+
1617
+
1618
+ vec4 pinnedStatus = texture2D(pinnedStatusTexture, textureCoords);
1619
+
1620
+
1621
+ if (pinnedStatus.r > 0.5) {
1622
+ gl_FragColor = pointPosition;
1623
+ return;
1624
+ }
1625
+
1626
+
1627
+ pointVelocity.rg *= friction;
1628
+
1629
+ pointPosition.rg += pointVelocity.rg;
1630
+
1631
+ pointPosition.r = clamp(pointPosition.r, 0.0, spaceSize);
1632
+ pointPosition.g = clamp(pointPosition.g, 0.0, spaceSize);
1633
+
1634
+ gl_FragColor = pointPosition;
1635
+ }`,Sv=`#ifdef GL_ES
1636
+ precision highp float;
1637
+ #endif
1638
+
1639
+ uniform sampler2D positionsTexture;
1640
+ uniform sampler2D trackedIndices;
1641
+ uniform float pointsTextureSize;
1642
+
1643
+ varying vec2 textureCoords;
1644
+
1645
+ void main() {
1646
+ vec4 trackedPointIndices = texture2D(trackedIndices, textureCoords);
1647
+ if (trackedPointIndices.r < 0.0) discard;
1648
+ vec4 pointPosition = texture2D(positionsTexture, (trackedPointIndices.rg + 0.5) / pointsTextureSize);
1649
+
1650
+ gl_FragColor = vec4(pointPosition.rg, 1.0, 1.0);
1651
+ }`,Tv=`#ifdef GL_ES
1652
+ precision highp float;
1653
+ #endif
1654
+
1655
+ uniform sampler2D positionsTexture;
1656
+ uniform vec2 mousePos;
1657
+ uniform float index;
1658
+
1659
+ varying vec2 textureCoords;
1660
+
1661
+ void main() {
1662
+ vec4 pointPosition = texture2D(positionsTexture, textureCoords);
1663
+
1664
+
1665
+ if (index >= 0.0 && index == pointPosition.b) {
1666
+ pointPosition.rg = mousePos.rg;
1667
+ }
1668
+
1669
+ gl_FragColor = pointPosition;
1670
+ }`;function wv(t,e=16384){if(!(t!=null&&t.length))return null;let n=0;for(const u of t){const d=Math.max(u.width,u.height);d>n&&(n=d)}if(n===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const i=n,r=Math.ceil(Math.sqrt(t.length));let o=r*n,s=1;o>e&&(s=e/o,n=Math.max(1,Math.floor(n*s)),o=Math.max(1,Math.floor(o*s)),console.warn(`🖼️ Atlas scaling required: Original size ${(i*r).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${o.toLocaleString()}px (${Math.round(s*100)}% of original quality)`));const f=new Uint8Array(o*o*4).fill(0),l=new Float32Array(r*r*4).fill(-1);for(const[u,d]of t.entries()){const y=d.width,S=d.height;if(y===0||S===0)continue;const D=Math.min(1,n/Math.max(y,S)),q=Math.floor(y*D),Te=Math.floor(S*D),we=Math.floor(u/r),Ne=u%r*n,Ve=we*n;l[u*4]=Ne/o,l[u*4+1]=Ve/o,l[u*4+2]=(Ne+q)/o,l[u*4+3]=(Ve+Te)/o;for(let V=0;V<Te;V++)for(let ae=0;ae<q;ae++){const Ie=Math.floor(ae*(y/q)),Xe=(Math.floor(V*(S/Te))*y+Ie)*4,nt=((Ve+V)*o+(Ne+ae))*4;f[nt]=d.data[Xe]??0,f[nt+1]=d.data[Xe+1]??0,f[nt+2]=d.data[Xe+2]??0,f[nt+3]=d.data[Xe+3]??255}}return{atlasData:f,atlasSize:o,atlasCoords:l,atlasCoordsSize:r}}class Av extends zn{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){const{reglInstance:e,store:n,data:i,config:{rescalePositions:r,enableSimulation:o}}=this,{pointsTextureSize:s}=n;if(!s||!i.pointPositions||i.pointsNumber===void 0)return;const f=new Float32Array(s*s*4);let l=r;r===void 0&&!o&&(l=!0),this.shouldSkipRescale&&(l=!1),l?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let u=0;u<i.pointsNumber;++u)f[u*4+0]=i.pointPositions[u*2+0],f[u*4+1]=i.pointPositions[u*2+1],f[u*4+2]=u;this.currentPositionFbo||(this.currentPositionFbo=e.framebuffer()),this.currentPositionFbo({color:e.texture({data:f,shape:[s,s,4],type:"float"}),depth:!1,stencil:!1}),this.previousPositionFbo||(this.previousPositionFbo=e.framebuffer()),this.previousPositionFbo({color:e.texture({data:f,shape:[s,s,4],type:"float"}),depth:!1,stencil:!1}),this.config.enableSimulation&&(this.velocityFbo||(this.velocityFbo=e.framebuffer()),this.velocityFbo({color:e.texture({data:new Float32Array(s*s*4).fill(0),shape:[s,s,4],type:"float"}),depth:!1,stencil:!1})),this.selectedTexture||(this.selectedTexture=e.texture()),this.selectedTexture({data:f,shape:[s,s,4],type:"float"}),this.selectedFbo||(this.selectedFbo=e.framebuffer()),this.selectedFbo({color:this.selectedTexture,depth:!1,stencil:!1}),this.hoveredFbo||(this.hoveredFbo=e.framebuffer()),this.hoveredFbo({shape:[2,2],colorType:"float",depth:!1,stencil:!1}),this.drawPointIndices||(this.drawPointIndices=e.buffer(0)),this.drawPointIndices(oi(n.pointsTextureSize)),this.hoveredPointIndices||(this.hoveredPointIndices=e.buffer(0)),this.hoveredPointIndices(oi(n.pointsTextureSize)),this.sampledPointIndices||(this.sampledPointIndices=e.buffer(0)),this.sampledPointIndices(oi(n.pointsTextureSize)),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){const{reglInstance:e,config:n,store:i,data:r}=this;n.enableSimulation&&(this.updatePositionCommand||(this.updatePositionCommand=e({frag:_v,vert:kt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,velocity:()=>this.velocityFbo,friction:()=>n.simulationFriction,spaceSize:()=>i.adjustedSpaceSize,pinnedStatusTexture:()=>this.pinnedStatusFbo}}))),this.dragPointCommand||(this.dragPointCommand=e({frag:Tv,vert:kt,framebuffer:()=>this.currentPositionFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>this.previousPositionFbo,mousePos:()=>i.mousePosition,index:()=>{var o;return((o=i.hoveredPoint)==null?void 0:o.index)??-1}}})),this.drawCommand||(this.drawCommand=e({frag:cv,vert:hv,primitive:"points",count:()=>r.pointsNumber??0,attributes:{pointIndices:{buffer:this.drawPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1},color:{buffer:()=>this.colorBuffer,size:4},shape:{buffer:()=>this.shapeBuffer,size:1},imageIndex:{buffer:()=>this.imageIndicesBuffer,size:1},imageSize:{buffer:()=>this.imageSizesBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointGreyoutStatus:()=>this.greyoutStatusFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>i.pointsTextureSize,transformationMatrix:()=>i.transform,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,pointOpacity:()=>n.pointOpacity,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,greyoutColor:()=>i.greyoutPointColor,backgroundColor:()=>i.backgroundColor,isDarkenGreyout:()=>i.isDarkenGreyout,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>i.maxPointSize,skipSelected:e.prop("skipSelected"),skipUnselected:e.prop("skipUnselected"),imageAtlasTexture:()=>this.imageAtlasTexture,imageAtlasCoords:()=>this.imageAtlasCoordsTexture,hasImages:()=>this.imageCount>0,imageCount:()=>this.imageCount,imageAtlasCoordsTextureSize:()=>this.imageAtlasCoordsTextureSize},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=e({frag:dv,vert:kt,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointSize:()=>this.sizeFbo,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,sizeScale:()=>n.pointSizeScale,transformationMatrix:()=>i.transform,ratio:()=>n.pixelRatio,selection0:()=>i.selectedArea[0],selection1:()=>i.selectedArea[1],scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>i.maxPointSize}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionCommand=e({frag:mv,vert:kt,framebuffer:()=>this.selectedFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,transformationMatrix:()=>i.transform,polygonPathTexture:()=>this.polygonPathTexture,polygonPathLength:()=>this.polygonPathLength}})),this.clearHoveredFboCommand||(this.clearHoveredFboCommand=e({frag:ai,vert:kt,framebuffer:this.hoveredFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=e({frag:gv,vert:yv,primitive:"points",count:()=>r.pointsNumber??0,framebuffer:()=>this.hoveredFbo,attributes:{pointIndices:{buffer:this.hoveredPointIndices,size:2},size:{buffer:()=>this.sizeBuffer,size:1}},uniforms:{positionsTexture:()=>this.currentPositionFbo,ratio:()=>n.pixelRatio,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>i.pointsTextureSize,transformationMatrix:()=>i.transform,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,mousePosition:()=>i.screenMousePosition,maxPointSize:()=>i.maxPointSize},depth:{enable:!1,mask:!1}})),this.clearSampledPointsFboCommand||(this.clearSampledPointsFboCommand=e({frag:ai,vert:kt,framebuffer:()=>this.sampledPointsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=e({frag:xv,vert:bv,primitive:"points",count:()=>r.pointsNumber??0,framebuffer:()=>this.sampledPointsFbo,attributes:{pointIndices:{buffer:this.sampledPointIndices,size:2}},uniforms:{positionsTexture:()=>this.currentPositionFbo,pointsTextureSize:()=>i.pointsTextureSize,transformationMatrix:()=>i.transform,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize},depth:{enable:!1,mask:!1}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=e({frag:pv,vert:vv,attributes:{vertexCoord:wt(e)},primitive:"triangle strip",count:4,uniforms:{color:e.prop("color"),width:e.prop("width"),pointIndex:e.prop("pointIndex"),size:e.prop("size"),positionsTexture:()=>this.currentPositionFbo,sizeScale:()=>n.pointSizeScale,pointsTextureSize:()=>i.pointsTextureSize,transformationMatrix:()=>i.transform,spaceSize:()=>i.adjustedSpaceSize,screenSize:()=>i.screenSize,scalePointsOnZoom:()=>n.scalePointsOnZoom,maxPointSize:()=>i.maxPointSize,pointGreyoutStatusTexture:()=>this.greyoutStatusFbo,universalPointOpacity:()=>n.pointOpacity,greyoutOpacity:()=>n.pointGreyoutOpacity??-1,isDarkenGreyout:()=>i.isDarkenGreyout,backgroundColor:()=>i.backgroundColor,greyoutColor:()=>i.greyoutPointColor},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}})),this.trackPointsCommand||(this.trackPointsCommand=e({frag:Sv,vert:kt,framebuffer:()=>this.trackedPositionsFbo,primitive:"triangle strip",count:4,attributes:{vertexCoord:wt(e)},uniforms:{positionsTexture:()=>this.currentPositionFbo,trackedIndices:()=>this.trackedIndicesFbo,pointsTextureSize:()=>i.pointsTextureSize}}))}updateColor(){const{reglInstance:e,store:{pointsTextureSize:n},data:i}=this;n&&(this.colorBuffer||(this.colorBuffer=e.buffer(0)),this.colorBuffer(i.pointColors))}updateGreyoutStatus(){const{reglInstance:e,store:{selectedIndices:n,pointsTextureSize:i}}=this;if(!i)return;const r=new Float32Array(i*i*4).fill(n?1:0);if(n)for(const o of n)r[o*4]=0;this.greyoutStatusTexture||(this.greyoutStatusTexture=e.texture()),this.greyoutStatusTexture({data:r,width:i,height:i,type:"float"}),this.greyoutStatusFbo||(this.greyoutStatusFbo=e.framebuffer()),this.greyoutStatusFbo({color:this.greyoutStatusTexture,depth:!1,stencil:!1})}updatePinnedStatus(){const{reglInstance:e,store:{pointsTextureSize:n},data:i}=this;if(!n)return;const r=new Float32Array(n*n*4).fill(0);if(i.inputPinnedPoints&&i.pointsNumber!==void 0)for(const o of i.inputPinnedPoints)o>=0&&o<i.pointsNumber&&(r[o*4]=1);this.pinnedStatusTexture||(this.pinnedStatusTexture=e.texture()),this.pinnedStatusTexture({data:r,width:n,height:n,type:"float"}),this.pinnedStatusFbo||(this.pinnedStatusFbo=e.framebuffer()),this.pinnedStatusFbo({color:this.pinnedStatusTexture,depth:!1,stencil:!1})}updateSize(){const{reglInstance:e,store:{pointsTextureSize:n},data:i}=this;if(!n||i.pointsNumber===void 0||i.pointSizes===void 0)return;this.sizeBuffer||(this.sizeBuffer=e.buffer(0)),this.sizeBuffer(i.pointSizes);const r=new Float32Array(n*n*4);for(let o=0;o<i.pointsNumber;o++)r[o*4]=i.pointSizes[o];this.sizeTexture||(this.sizeTexture=e.texture()),this.sizeTexture({data:r,width:n,height:n,type:"float"}),this.sizeFbo||(this.sizeFbo=e.framebuffer()),this.sizeFbo({color:this.sizeTexture,depth:!1,stencil:!1})}updateShape(){const{reglInstance:e,data:n}=this;n.pointsNumber===void 0||n.pointShapes===void 0||(this.shapeBuffer||(this.shapeBuffer=e.buffer(0)),this.shapeBuffer(n.pointShapes))}updateImageIndices(){const{reglInstance:e,data:n}=this;n.pointsNumber===void 0||n.pointImageIndices===void 0||(this.imageIndicesBuffer||(this.imageIndicesBuffer=e.buffer(0)),this.imageIndicesBuffer(n.pointImageIndices))}updateImageSizes(){const{reglInstance:e,data:n}=this;n.pointsNumber===void 0||n.pointImageSizes===void 0||(this.imageSizesBuffer||(this.imageSizesBuffer=e.buffer(0)),this.imageSizesBuffer(n.pointImageSizes))}createAtlas(){var u;const{reglInstance:e,data:n,store:i}=this;if(this.imageAtlasTexture||(this.imageAtlasTexture=e.texture()),this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=e.texture()),!((u=n.inputImageData)!=null&&u.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0;return}const r=wv(n.inputImageData,i.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=n.inputImageData.length;const{atlasData:o,atlasSize:s,atlasCoords:f,atlasCoordsSize:l}=r;this.imageAtlasCoordsTextureSize=l,this.imageAtlasTexture({data:o,shape:[s,s,4],type:"uint8"}),this.imageAtlasCoordsTexture({data:f,shape:[l,l,4],type:"float"})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:n},reglInstance:i}=this;let r=n??Math.min(...e)/2;r===0&&(r=Oe.pointSamplingDistance);const o=Math.ceil(e[0]/r),s=Math.ceil(e[1]/r);this.sampledPointsFbo||(this.sampledPointsFbo=i.framebuffer()),this.sampledPointsFbo({shape:[o,s],depth:!1,stencil:!1,colorType:"float"})}trackPoints(){var e,n;(e=this.trackedIndices)!=null&&e.length&&((n=this.trackPointsCommand)==null||n.call(this))}draw(){var o,s,f,l,u,d,y;const{config:{renderHoveredPointRing:e,pointSize:n},store:i,data:r}=this;this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),i.selectedIndices&&i.selectedIndices.length>0?((o=this.drawCommand)==null||o.call(this,{skipSelected:!0,skipUnselected:!1}),(s=this.drawCommand)==null||s.call(this,{skipSelected:!1,skipUnselected:!0})):(f=this.drawCommand)==null||f.call(this,{skipSelected:!1,skipUnselected:!1}),e&&i.hoveredPoint&&((u=this.drawHighlightedCommand)==null||u.call(this,{width:.85,color:i.hoveredPointRingColor,pointIndex:i.hoveredPoint.index,size:((l=r.pointSizes)==null?void 0:l[i.hoveredPoint.index])??n})),i.focusedPoint&&((y=this.drawHighlightedCommand)==null||y.call(this,{width:.75,color:i.focusedPointRingColor,pointIndex:i.focusedPoint.index,size:((d=r.pointSizes)==null?void 0:d[i.focusedPoint.index])??n}))}updatePosition(){var e;(e=this.updatePositionCommand)==null||e.call(this),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var e;(e=this.dragPointCommand)==null||e.call(this),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var e;(e=this.findPointsOnAreaSelectionCommand)==null||e.call(this)}findPointsOnPolygonSelection(){var e;(e=this.findPointsOnPolygonSelectionCommand)==null||e.call(this)}updatePolygonPath(e){const{reglInstance:n}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture=void 0,this.polygonPathFbo=void 0;return}const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4);for(const[o,s]of e.entries()){const[f,l]=s;r[o*4]=f,r[o*4+1]=l,r[o*4+2]=0,r[o*4+3]=0}this.polygonPathTexture||(this.polygonPathTexture=n.texture()),this.polygonPathTexture({data:r,width:i,height:i,type:"float"}),this.polygonPathFbo||(this.polygonPathFbo=n.framebuffer()),this.polygonPathFbo({color:this.polygonPathTexture,depth:!1,stencil:!1})}findHoveredPoint(){var e,n;(e=this.clearHoveredFboCommand)==null||e.call(this),(n=this.findHoveredPointCommand)==null||n.call(this)}trackPointsByIndices(e){const{store:{pointsTextureSize:n},reglInstance:i}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!n)return;const r=Math.ceil(Math.sqrt(e.length)),o=new Float32Array(r*r*4).fill(-1);for(const[s,f]of e.entries())f!==void 0&&(o[s*4]=f%n,o[s*4+1]=Math.floor(f/n),o[s*4+2]=0,o[s*4+3]=0);this.trackedIndicesTexture||(this.trackedIndicesTexture=i.texture()),this.trackedIndicesTexture({data:o,width:r,height:r,type:"float"}),this.trackedIndicesFbo||(this.trackedIndicesFbo=i.framebuffer()),this.trackedIndicesFbo({color:this.trackedIndicesTexture,depth:!1,stencil:!1}),this.trackedPositionsFbo||(this.trackedPositionsFbo=i.framebuffer()),this.trackedPositionsFbo({shape:[r,r],depth:!1,stencil:!1,colorType:"float"}),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:n}}=this;if((!e||!n)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;const i=Qt(this.reglInstance,this.trackedPositionsFbo),r=new Map;for(let o=0;o<i.length/4;o+=1){const s=i[o*4],f=i[o*4+1],l=this.trackedIndices[o];s!==void 0&&f!==void 0&&l!==void 0&&r.set(l,[s,f])}return(!e||!n)&&(this.trackedPositions=r,this.isPositionsUpToDate=!0),r}getSampledPointPositionsMap(){var i,r;const e=new Map;if(!this.sampledPointsFbo)return e;(i=this.clearSampledPointsFboCommand)==null||i.call(this),(r=this.fillSampledPointsFboCommand)==null||r.call(this);const n=Qt(this.reglInstance,this.sampledPointsFbo);for(let o=0;o<n.length/4;o++){const s=n[o*4],f=!!n[o*4+1],l=n[o*4+2],u=n[o*4+3];f&&s!==void 0&&l!==void 0&&u!==void 0&&e.set(s,[l,u])}return e}getSampledPoints(){var r,o;const e=[],n=[];if(!this.sampledPointsFbo)return{indices:e,positions:n};(r=this.clearSampledPointsFboCommand)==null||r.call(this),(o=this.fillSampledPointsFboCommand)==null||o.call(this);const i=Qt(this.reglInstance,this.sampledPointsFbo);for(let s=0;s<i.length/4;s++){const f=i[s*4],l=!!i[s*4+1],u=i[s*4+2],d=i[s*4+3];l&&f!==void 0&&u!==void 0&&d!==void 0&&(e.push(f),n.push(u,d))}return{indices:e,positions:n}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices)return e;e.length=this.trackedIndices.length*2;const n=Qt(this.reglInstance,this.trackedPositionsFbo);for(let i=0;i<n.length/4;i+=1){const r=n[i*4],o=n[i*4+1],s=this.trackedIndices[i];r!==void 0&&o!==void 0&&s!==void 0&&(e[i*2]=r,e[i*2+1]=o)}return e}swapFbo(){const e=this.previousPositionFbo;this.previousPositionFbo=this.currentPositionFbo,this.currentPositionFbo=e}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const n=this.data.pointPositions,i=n.length/2;let r=1/0,o=-1/0,s=1/0,f=-1/0;for(let we=0;we<n.length;we+=2){const fe=n[we],Ne=n[we+1];r=Math.min(r,fe),o=Math.max(o,fe),s=Math.min(s,Ne),f=Math.max(f,Ne)}const l=o-r,u=f-s,d=Math.max(l,u);if(d>e){this.scaleX=void 0,this.scaleY=void 0;return}const y=e*e*.001,D=(i>y?e*Math.max(1.2,Math.sqrt(i)/e):e*.1)/d,q=(d-l)/2*D,Te=(d-u)/2*D;this.scaleX=we=>(we-r)*D+q,this.scaleY=we=>(we-s)*D+Te;for(let we=0;we<i;we++)this.data.pointPositions[we*2]=this.scaleX(n[we*2]),this.data.pointPositions[we*2+1]=this.scaleY(n[we*2+1])}}var Vl=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function Ev(){var t=new Vl(9);return Vl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function $l(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],f=e[4],l=e[5],u=e[6],d=e[7],y=e[8],S=n[0],D=n[1];return t[0]=i,t[1]=r,t[2]=o,t[3]=s,t[4]=f,t[5]=l,t[6]=S*i+D*s+u,t[7]=S*r+D*f+d,t[8]=S*o+D*l+y,t}function Ka(t,e,n){var i=n[0],r=n[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=r*e[3],t[4]=r*e[4],t[5]=r*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function Cv(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}var mo={exports:{}},Pv=mo.exports,Hl;function kv(){return Hl||(Hl=1,function(t){(function(e,n,i){function r(l){var u=this,d=f();u.next=function(){var y=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=y-(u.c=y|0)},u.c=1,u.s0=d(" "),u.s1=d(" "),u.s2=d(" "),u.s0-=d(l),u.s0<0&&(u.s0+=1),u.s1-=d(l),u.s1<0&&(u.s1+=1),u.s2-=d(l),u.s2<0&&(u.s2+=1),d=null}function o(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function s(l,u){var d=new r(l),y=u&&u.state,S=d.next;return S.int32=function(){return d.next()*4294967296|0},S.double=function(){return S()+(S()*2097152|0)*11102230246251565e-32},S.quick=S,y&&(typeof y=="object"&&o(y,d),S.state=function(){return o(d,{})}),S}function f(){var l=4022871197,u=function(d){d=String(d);for(var y=0;y<d.length;y++){l+=d.charCodeAt(y);var S=.02519603282416938*l;l=S>>>0,S-=l,S*=l,l=S>>>0,S-=l,l+=S*4294967296}return(l>>>0)*23283064365386963e-26};return u}n&&n.exports?n.exports=s:this.alea=s})(Pv,t)}(mo)),mo.exports}var po={exports:{}},Iv=po.exports,Wl;function Lv(){return Wl||(Wl=1,function(t){(function(e,n,i){function r(f){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var y=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^y^y>>>8},f===(f|0)?l.x=f:u+=f;for(var d=0;d<u.length+64;d++)l.x^=u.charCodeAt(d)|0,l.next()}function o(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l}function s(f,l){var u=new r(f),d=l&&l.state,y=function(){return(u.next()>>>0)/4294967296};return y.double=function(){do var S=u.next()>>>11,D=(u.next()>>>0)/4294967296,q=(S+D)/(1<<21);while(q===0);return q},y.int32=u.next,y.quick=y,d&&(typeof d=="object"&&o(d,u),y.state=function(){return o(u,{})}),y}n&&n.exports?n.exports=s:this.xor128=s})(Iv,t)}(po)),po.exports}var vo={exports:{}},Dv=vo.exports,Xl;function Fv(){return Xl||(Xl=1,function(t){(function(e,n,i){function r(f){var l=this,u="";l.next=function(){var y=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^(y^y<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,f===(f|0)?l.x=f:u+=f;for(var d=0;d<u.length+64;d++)l.x^=u.charCodeAt(d)|0,d==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function o(f,l){return l.x=f.x,l.y=f.y,l.z=f.z,l.w=f.w,l.v=f.v,l.d=f.d,l}function s(f,l){var u=new r(f),d=l&&l.state,y=function(){return(u.next()>>>0)/4294967296};return y.double=function(){do var S=u.next()>>>11,D=(u.next()>>>0)/4294967296,q=(S+D)/(1<<21);while(q===0);return q},y.int32=u.next,y.quick=y,d&&(typeof d=="object"&&o(d,u),y.state=function(){return o(u,{})}),y}n&&n.exports?n.exports=s:this.xorwow=s})(Dv,t)}(vo)),vo.exports}var go={exports:{}},zv=go.exports,jl;function Rv(){return jl||(jl=1,function(t){(function(e,n,i){function r(f){var l=this;l.next=function(){var d=l.x,y=l.i,S,D;return S=d[y],S^=S>>>7,D=S^S<<24,S=d[y+1&7],D^=S^S>>>10,S=d[y+3&7],D^=S^S>>>3,S=d[y+4&7],D^=S^S<<7,S=d[y+7&7],S=S^S<<13,D^=S^S<<9,d[y]=D,l.i=y+1&7,D};function u(d,y){var S,D=[];if(y===(y|0))D[0]=y;else for(y=""+y,S=0;S<y.length;++S)D[S&7]=D[S&7]<<15^y.charCodeAt(S)+D[S+1&7]<<13;for(;D.length<8;)D.push(0);for(S=0;S<8&&D[S]===0;++S);for(S==8?D[7]=-1:D[S],d.x=D,d.i=0,S=256;S>0;--S)d.next()}u(l,f)}function o(f,l){return l.x=f.x.slice(),l.i=f.i,l}function s(f,l){f==null&&(f=+new Date);var u=new r(f),d=l&&l.state,y=function(){return(u.next()>>>0)/4294967296};return y.double=function(){do var S=u.next()>>>11,D=(u.next()>>>0)/4294967296,q=(S+D)/(1<<21);while(q===0);return q},y.int32=u.next,y.quick=y,d&&(d.x&&o(d,u),y.state=function(){return o(u,{})}),y}n&&n.exports?n.exports=s:this.xorshift7=s})(zv,t)}(go)),go.exports}var yo={exports:{}},Mv=yo.exports,ql;function Ov(){return ql||(ql=1,function(t){(function(e,n,i){function r(f){var l=this;l.next=function(){var d=l.w,y=l.X,S=l.i,D,q;return l.w=d=d+1640531527|0,q=y[S+34&127],D=y[S=S+1&127],q^=q<<13,D^=D<<17,q^=q>>>15,D^=D>>>12,q=y[S]=q^D,l.i=S,q+(d^d>>>16)|0};function u(d,y){var S,D,q,Te,we,fe=[],Ne=128;for(y===(y|0)?(D=y,y=null):(y=y+"\0",D=0,Ne=Math.max(Ne,y.length)),q=0,Te=-32;Te<Ne;++Te)y&&(D^=y.charCodeAt((Te+32)%y.length)),Te===0&&(we=D),D^=D<<10,D^=D>>>15,D^=D<<4,D^=D>>>13,Te>=0&&(we=we+1640531527|0,S=fe[Te&127]^=D+we,q=S==0?q+1:0);for(q>=128&&(fe[(y&&y.length||0)&127]=-1),q=127,Te=4*128;Te>0;--Te)D=fe[q+34&127],S=fe[q=q+1&127],D^=D<<13,S^=S<<17,D^=D>>>15,S^=S>>>12,fe[q]=D^S;d.w=we,d.X=fe,d.i=q}u(l,f)}function o(f,l){return l.i=f.i,l.w=f.w,l.X=f.X.slice(),l}function s(f,l){f==null&&(f=+new Date);var u=new r(f),d=l&&l.state,y=function(){return(u.next()>>>0)/4294967296};return y.double=function(){do var S=u.next()>>>11,D=(u.next()>>>0)/4294967296,q=(S+D)/(1<<21);while(q===0);return q},y.int32=u.next,y.quick=y,d&&(d.X&&o(d,u),y.state=function(){return o(u,{})}),y}n&&n.exports?n.exports=s:this.xor4096=s})(Mv,t)}(yo)),yo.exports}var xo={exports:{}},Nv=xo.exports,Yl;function Gv(){return Yl||(Yl=1,function(t){(function(e,n,i){function r(f){var l=this,u="";l.next=function(){var y=l.b,S=l.c,D=l.d,q=l.a;return y=y<<25^y>>>7^S,S=S-D|0,D=D<<24^D>>>8^q,q=q-y|0,l.b=y=y<<20^y>>>12^S,l.c=S=S-D|0,l.d=D<<16^S>>>16^q,l.a=q-y|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,f===Math.floor(f)?(l.a=f/4294967296|0,l.b=f|0):u+=f;for(var d=0;d<u.length+20;d++)l.b^=u.charCodeAt(d)|0,l.next()}function o(f,l){return l.a=f.a,l.b=f.b,l.c=f.c,l.d=f.d,l}function s(f,l){var u=new r(f),d=l&&l.state,y=function(){return(u.next()>>>0)/4294967296};return y.double=function(){do var S=u.next()>>>11,D=(u.next()>>>0)/4294967296,q=(S+D)/(1<<21);while(q===0);return q},y.int32=u.next,y.quick=y,d&&(typeof d=="object"&&o(d,u),y.state=function(){return o(u,{})}),y}n&&n.exports?n.exports=s:this.tychei=s})(Nv,t)}(xo)),xo.exports}var bo={exports:{}};const Bv=Sp(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Uv=bo.exports,Zl;function Vv(){return Zl||(Zl=1,function(t){(function(e,n,i){var r=256,o=6,s=52,f="random",l=i.pow(r,o),u=i.pow(2,s),d=u*2,y=r-1,S;function D(V,ae,Ie){var Be=[];ae=ae==!0?{entropy:!0}:ae||{};var Xe=fe(we(ae.entropy?[V,Ve(n)]:V??Ne(),3),Be),nt=new q(Be),lt=function(){for(var Ee=nt.g(o),ct=l,ft=0;Ee<u;)Ee=(Ee+ft)*r,ct*=r,ft=nt.g(1);for(;Ee>=d;)Ee/=2,ct/=2,ft>>>=1;return(Ee+ft)/ct};return lt.int32=function(){return nt.g(4)|0},lt.quick=function(){return nt.g(4)/4294967296},lt.double=lt,fe(Ve(nt.S),n),(ae.pass||Ie||function(Ee,ct,ft,G){return G&&(G.S&&Te(G,nt),Ee.state=function(){return Te(nt,{})}),ft?(i[f]=Ee,ct):Ee})(lt,Xe,"global"in ae?ae.global:this==i,ae.state)}function q(V){var ae,Ie=V.length,Be=this,Xe=0,nt=Be.i=Be.j=0,lt=Be.S=[];for(Ie||(V=[Ie++]);Xe<r;)lt[Xe]=Xe++;for(Xe=0;Xe<r;Xe++)lt[Xe]=lt[nt=y&nt+V[Xe%Ie]+(ae=lt[Xe])],lt[nt]=ae;(Be.g=function(Ee){for(var ct,ft=0,G=Be.i,Pe=Be.j,se=Be.S;Ee--;)ct=se[G=y&G+1],ft=ft*r+se[y&(se[G]=se[Pe=y&Pe+ct])+(se[Pe]=ct)];return Be.i=G,Be.j=Pe,ft})(r)}function Te(V,ae){return ae.i=V.i,ae.j=V.j,ae.S=V.S.slice(),ae}function we(V,ae){var Ie=[],Be=typeof V,Xe;if(ae&&Be=="object")for(Xe in V)try{Ie.push(we(V[Xe],ae-1))}catch{}return Ie.length?Ie:Be=="string"?V:V+"\0"}function fe(V,ae){for(var Ie=V+"",Be,Xe=0;Xe<Ie.length;)ae[y&Xe]=y&(Be^=ae[y&Xe]*19)+Ie.charCodeAt(Xe++);return Ve(ae)}function Ne(){try{var V;return S&&(V=S.randomBytes)?V=V(r):(V=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(V)),Ve(V)}catch{var ae=e.navigator,Ie=ae&&ae.plugins;return[+new Date,e,Ie,e.screen,Ve(n)]}}function Ve(V){return String.fromCharCode.apply(0,V)}if(fe(i.random(),n),t.exports){t.exports=D;try{S=Bv}catch{}}else i["seed"+f]=D})(typeof self<"u"?self:Uv,[],Math)}(bo)),bo.exports}var Ja,Ql;function $v(){if(Ql)return Ja;Ql=1;var t=kv(),e=Lv(),n=Fv(),i=Rv(),r=Ov(),o=Gv(),s=Vv();return s.alea=t,s.xor128=e,s.xorwow=n,s.xorshift7=i,s.xor4096=r,s.tychei=o,Ja=s,Ja}var Hv=$v();const Wv=za(Hv);function Xv(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,qv(i.key),i)}}function es(t,e,n){return e&&Xv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Kl(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,ts(t,e)}function ts(t,e){return ts=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},ts(t,e)}function jv(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function qv(t){var e=jv(t,"string");return typeof e=="symbol"?e:String(e)}var _o=function(){function t(){}var e=t.prototype;return e._seed=function(i,r){if(i===(i||0))return i;for(var o=""+i,s=0,f=0;f<o.length;++f)s^=o.charCodeAt(f)|0;return s},t}(),Jl=function(t){Kl(e,t);function e(i,r){var o;return o=t.call(this)||this,o._rng=void 0,o.seed(i,r),o}var n=e.prototype;return n.next=function(){return this._rng()},n.seed=function(r,o){this._rng=r},n.clone=function(r,o){return new e(this._rng,o)},es(e,[{key:"name",get:function(){return"function"}}]),e}(_o),eu=function(){var t=[].slice.call(arguments),e=t,n=e[0],i=n===void 0?"default":n;switch(typeof i){case"object":if(i instanceof _o)return i;break;case"function":return new Jl(i);case"number":case"string":default:return new Jl(Wv.apply(void 0,t))}throw new Error('invalid RNG "'+i+'"')},Yv=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){return t.next()*(n-e)+e}};function pn(t){return new Zv(t)}var Zv=function(e){var n=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(n.n))return n;throw new Error("Expected number to be an integer, got "+n.n)},this.isPositive=function(){if(n.n>0)return n;throw new Error("Expected number to be positive, got "+n.n)},this.lessThan=function(i){if(n.n<i)return n;throw new Error("Expected number to be less than "+i+", got "+n.n)},this.greaterThanOrEqual=function(i){if(n.n>=i)return n;throw new Error("Expected number to be greater than or equal to "+i+", got "+n.n)},this.greaterThan=function(i){if(n.n>i)return n;throw new Error("Expected number to be greater than "+i+", got "+n.n)},this.n=e},Qv=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),n===void 0&&(n=e===void 0?1:e,e=0),pn(e).isInt(),pn(n).isInt(),function(){return Math.floor(t.next()*(n-e+1)+e)}},Kv=function(t){return function(){return t.next()>=.5}},Jv=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),function(){var i,r,o;do i=t.next()*2-1,r=t.next()*2-1,o=i*i+r*r;while(!o||o>1);return e+n*r*Math.sqrt(-2*Math.log(o)/o)}},eg=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=1);var i=t.normal(e,n);return function(){return Math.exp(i())}},tg=function(t,e){return e===void 0&&(e=.5),pn(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(t.next()+e)}},ng=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=.5),pn(e).isInt().isPositive(),pn(n).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<e;)t.next()<n&&r++;return r}},ig=function(t,e){e===void 0&&(e=.5),pn(e).greaterThan(0).lessThan(1);var n=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(t.next())*n)}},rg=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],og=function(e){return rg[e]},ag=.9189385332046727,sg=function(t,e){if(e===void 0&&(e=1),pn(e).isPositive(),e<10){var n=Math.exp(-e);return function(){for(var l=n,u=0,d=t.next();d>l;)d=d-l,l=e*l/++u;return u}}else{var i=Math.sqrt(e),r=.931+2.53*i,o=-.059+.02483*r,s=1.1239+1.1328/(r-3.4),f=.9277-3.6224/(r-2);return function(){for(;;){var l=void 0,u=t.next();if(u<=.86*f)return l=u/f-.43,Math.floor((2*o/(.5-Math.abs(l))+r)*l+e+.445);u>=f?l=t.next()-.5:(l=u/f-.93,l=(l<0?-.5:.5)-l,u=t.next()*f);var d=.5-Math.abs(l);if(!(d<.013&&u>d)){var y=Math.floor((2*o/d+r)*l+e+.445);if(u=u*s/(o/(d*d)+r),y>=10){var S=(y+.5)*Math.log(e/y)-e-ag+y-(.08333333333333333-(.002777777777777778-1/(1260*y*y))/(y*y))/y;if(Math.log(u*i)<=S)return y}else if(y>=0){var D,q=(D=og(y))!=null?D:0;if(Math.log(u)<=y*Math.log(e)-e-q)return y}}}}}},fg=function(t,e){return e===void 0&&(e=1),pn(e).isPositive(),function(){return-Math.log(1-t.next())/e}},lg=function(t,e){return e===void 0&&(e=1),pn(e).isInt().greaterThanOrEqual(0),function(){for(var n=0,i=0;i<e;++i)n+=t.next();return n}},ug=function(t,e){e===void 0&&(e=1),pn(e).isInt().isPositive();var n=t.irwinHall(e);return function(){return n()/e}},cg=function(t,e){e===void 0&&(e=1),pn(e).greaterThanOrEqual(0);var n=1/e;return function(){return 1/Math.pow(1-t.next(),n)}},hg=function(t){Kl(e,t);function e(){return t.apply(this,arguments)||this}var n=e.prototype;return n.next=function(){return Math.random()},n.seed=function(r,o){},n.clone=function(){return new e},es(e,[{key:"name",get:function(){return"default"}}]),e}(_o),tu=function(){function t(n){var i=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return i._rng.next()},this.float=function(r,o){return i.uniform(r,o)()},this.int=function(r,o){return i.uniformInt(r,o)()},this.integer=function(r,o){return i.uniformInt(r,o)()},this.bool=function(){return i.uniformBoolean()()},this.boolean=function(){return i.uniformBoolean()()},this.uniform=function(r,o){return i._memoize("uniform",Yv,r,o)},this.uniformInt=function(r,o){return i._memoize("uniformInt",Qv,r,o)},this.uniformBoolean=function(){return i._memoize("uniformBoolean",Kv)},this.normal=function(r,o){return Jv(i,r,o)},this.logNormal=function(r,o){return eg(i,r,o)},this.bernoulli=function(r){return tg(i,r)},this.binomial=function(r,o){return ng(i,r,o)},this.geometric=function(r){return ig(i,r)},this.poisson=function(r){return sg(i,r)},this.exponential=function(r){return fg(i,r)},this.irwinHall=function(r){return lg(i,r)},this.bates=function(r){return ug(i,r)},this.pareto=function(r){return cg(i,r)},n&&n instanceof _o?this.use(n):this.use(new hg),this._cache={}}var e=t.prototype;return e.clone=function(){var i=[].slice.call(arguments);return i.length?new t(eu.apply(void 0,i)):new t(this.rng.clone())},e.use=function(){this._rng=eu.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 o=this.uniformInt(0,r-1)();return i[o]}else return},e._memoize=function(i,r){var o=[].slice.call(arguments,2),s=""+o.join(";"),f=this._cache[i];return(f===void 0||f.key!==s)&&(f={key:s,distribution:r.apply(void 0,[this].concat(o))},this._cache[i]=f),f.distribution},es(t,[{key:"rng",get:function(){return this._rng}}]),t}();new tu;const ns=.001,is=64,dg=4;class mg{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Ev(),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=is,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=Oe.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,Rp],this.focusedPointRingColor=[1,1,1,Mp],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=Qa(),this.scalePointY=Qa(),this.random=new tu,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(ns,1/e)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e;const n=pl(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",n>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",n>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=n<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,n){return this.random.float(e,n)}adjustSpaceSize(e,n){e>=n?(this.adjustedSpaceSize=n/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,n){const{adjustedSpaceSize:i}=this;this.screenSize=[e,n],this.scalePointX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scalePointY.domain([i,0]).range([(n-i)/2,(n+i)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const n=Fn(e);this.hoveredPointRingColor[0]=n[0],this.hoveredPointRingColor[1]=n[1],this.hoveredPointRingColor[2]=n[2]}setFocusedPointRingColor(e){const n=Fn(e);this.focusedPointRingColor[0]=n[0],this.focusedPointRingColor[1]=n[1],this.focusedPointRingColor[2]=n[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const n=Fn(e);this.greyoutPointColor[0]=n[0],this.greyoutPointColor[1]=n[1],this.greyoutPointColor[2]=n[2],this.greyoutPointColor[3]=n[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 n=Fn(e);this.hoveredLinkColor[0]=n[0],this.hoveredLinkColor[1]=n[1],this.hoveredLinkColor[2]=n[2],this.hoveredLinkColor[3]=n[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 pg={passive:!1},pr={capture:!0,passive:!1};function rs(t){t.stopImmediatePropagation()}function Di(t){t.preventDefault(),t.stopImmediatePropagation()}function nu(t){var e=t.document.documentElement,n=Ft(t).on("dragstart.drag",Di,pr);"onselectstart"in e?n.on("selectstart.drag",Di,pr):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function iu(t,e){var n=t.document.documentElement,i=Ft(t).on("dragstart.drag",null);e&&(i.on("click.drag",Di,pr),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const So=t=>()=>t;function os(t,{sourceEvent:e,subject:n,target:i,identifier:r,active:o,x:s,y:f,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:f,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}os.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function vg(t){return!t.ctrlKey&&!t.button}function gg(){return this.parentNode}function yg(t,e){return e??{x:t.x,y:t.y}}function xg(){return navigator.maxTouchPoints||"ontouchstart"in this}function bg(){var t=vg,e=gg,n=yg,i=xg,r={},o=Vr("start","drag","end"),s=0,f,l,u,d,y=0;function S(V){V.on("mousedown.drag",D).filter(i).on("touchstart.drag",we).on("touchmove.drag",fe,pg).on("touchend.drag touchcancel.drag",Ne).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function D(V,ae){if(!(d||!t.call(this,V,ae))){var Ie=Ve(this,e.call(this,V,ae),V,ae,"mouse");Ie&&(Ft(V.view).on("mousemove.drag",q,pr).on("mouseup.drag",Te,pr),nu(V.view),rs(V),u=!1,f=V.clientX,l=V.clientY,Ie("start",V))}}function q(V){if(Di(V),!u){var ae=V.clientX-f,Ie=V.clientY-l;u=ae*ae+Ie*Ie>y}r.mouse("drag",V)}function Te(V){Ft(V.view).on("mousemove.drag mouseup.drag",null),iu(V.view,u),Di(V),r.mouse("end",V)}function we(V,ae){if(t.call(this,V,ae)){var Ie=V.changedTouches,Be=e.call(this,V,ae),Xe=Ie.length,nt,lt;for(nt=0;nt<Xe;++nt)(lt=Ve(this,Be,V,ae,Ie[nt].identifier,Ie[nt]))&&(rs(V),lt("start",V,Ie[nt]))}}function fe(V){var ae=V.changedTouches,Ie=ae.length,Be,Xe;for(Be=0;Be<Ie;++Be)(Xe=r[ae[Be].identifier])&&(Di(V),Xe("drag",V,ae[Be]))}function Ne(V){var ae=V.changedTouches,Ie=ae.length,Be,Xe;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),Be=0;Be<Ie;++Be)(Xe=r[ae[Be].identifier])&&(rs(V),Xe("end",V,ae[Be]))}function Ve(V,ae,Ie,Be,Xe,nt){var lt=o.copy(),Ee=kn(nt||Ie,ae),ct,ft,G;if((G=n.call(V,new os("beforestart",{sourceEvent:Ie,target:S,identifier:Xe,active:s,x:Ee[0],y:Ee[1],dx:0,dy:0,dispatch:lt}),Be))!=null)return ct=G.x-Ee[0]||0,ft=G.y-Ee[1]||0,function Pe(se,De,qe){var je=Ee,Qe;switch(se){case"start":r[Xe]=Pe,Qe=s++;break;case"end":delete r[Xe],--s;case"drag":Ee=kn(qe||De,ae),Qe=s;break}lt.call(se,V,new os(se,{sourceEvent:De,subject:G,target:S,identifier:Xe,active:Qe,x:Ee[0]+ct,y:Ee[1]+ft,dx:Ee[0]-je[0],dy:Ee[1]-je[1],dispatch:lt}),Be)}}return S.filter=function(V){return arguments.length?(t=typeof V=="function"?V:So(!!V),S):t},S.container=function(V){return arguments.length?(e=typeof V=="function"?V:So(V),S):e},S.subject=function(V){return arguments.length?(n=typeof V=="function"?V:So(V),S):n},S.touchable=function(V){return arguments.length?(i=typeof V=="function"?V:So(!!V),S):i},S.on=function(){var V=o.on.apply(o,arguments);return V===o?S:V},S.clickDistance=function(V){return arguments.length?(y=(V=+V)*V,S):Math.sqrt(y)},S}const To=t=>()=>t;function _g(t,{sourceEvent:e,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Rn(t,e,n){this.k=t,this.x=e,this.y=n}Rn.prototype={constructor:Rn,scale:function(t){return t===1?this:new Rn(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Rn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var vr=new Rn(1,0,0);Rn.prototype;function as(t){t.stopImmediatePropagation()}function gr(t){t.preventDefault(),t.stopImmediatePropagation()}function Sg(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Tg(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function ru(){return this.__zoom||vr}function wg(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Ag(){return navigator.maxTouchPoints||"ontouchstart"in this}function Eg(t,e,n){var i=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function Cg(){var t=Sg,e=Tg,n=Eg,i=wg,r=Ag,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],f=250,l=pm,u=Vr("start","zoom","end"),d,y,S,D=500,q=150,Te=0,we=10;function fe(G){G.property("__zoom",ru).on("wheel.zoom",Xe,{passive:!1}).on("mousedown.zoom",nt).on("dblclick.zoom",lt).filter(r).on("touchstart.zoom",Ee).on("touchmove.zoom",ct).on("touchend.zoom touchcancel.zoom",ft).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}fe.transform=function(G,Pe,se,De){var qe=G.selection?G.selection():G;qe.property("__zoom",ru),G!==qe?ae(G,Pe,se,De):qe.interrupt().each(function(){Ie(this,arguments).event(De).start().zoom(null,typeof Pe=="function"?Pe.apply(this,arguments):Pe).end()})},fe.scaleBy=function(G,Pe,se,De){fe.scaleTo(G,function(){var qe=this.__zoom.k,je=typeof Pe=="function"?Pe.apply(this,arguments):Pe;return qe*je},se,De)},fe.scaleTo=function(G,Pe,se,De){fe.transform(G,function(){var qe=e.apply(this,arguments),je=this.__zoom,Qe=se==null?V(qe):typeof se=="function"?se.apply(this,arguments):se,Ze=je.invert(Qe),dt=typeof Pe=="function"?Pe.apply(this,arguments):Pe;return n(Ve(Ne(je,dt),Qe,Ze),qe,s)},se,De)},fe.translateBy=function(G,Pe,se,De){fe.transform(G,function(){return n(this.__zoom.translate(typeof Pe=="function"?Pe.apply(this,arguments):Pe,typeof se=="function"?se.apply(this,arguments):se),e.apply(this,arguments),s)},null,De)},fe.translateTo=function(G,Pe,se,De,qe){fe.transform(G,function(){var je=e.apply(this,arguments),Qe=this.__zoom,Ze=De==null?V(je):typeof De=="function"?De.apply(this,arguments):De;return n(vr.translate(Ze[0],Ze[1]).scale(Qe.k).translate(typeof Pe=="function"?-Pe.apply(this,arguments):-Pe,typeof se=="function"?-se.apply(this,arguments):-se),je,s)},De,qe)};function Ne(G,Pe){return Pe=Math.max(o[0],Math.min(o[1],Pe)),Pe===G.k?G:new Rn(Pe,G.x,G.y)}function Ve(G,Pe,se){var De=Pe[0]-se[0]*G.k,qe=Pe[1]-se[1]*G.k;return De===G.x&&qe===G.y?G:new Rn(G.k,De,qe)}function V(G){return[(+G[0][0]+ +G[1][0])/2,(+G[0][1]+ +G[1][1])/2]}function ae(G,Pe,se,De){G.on("start.zoom",function(){Ie(this,arguments).event(De).start()}).on("interrupt.zoom end.zoom",function(){Ie(this,arguments).event(De).end()}).tween("zoom",function(){var qe=this,je=arguments,Qe=Ie(qe,je).event(De),Ze=e.apply(qe,je),dt=se==null?V(Ze):typeof se=="function"?se.apply(qe,je):se,ut=Math.max(Ze[1][0]-Ze[0][0],Ze[1][1]-Ze[0][1]),_t=qe.__zoom,at=typeof Pe=="function"?Pe.apply(qe,je):Pe,$t=l(_t.invert(dt).concat(ut/_t.k),at.invert(dt).concat(ut/at.k));return function(Ht){if(Ht===1)Ht=at;else{var Kt=$t(Ht),Mn=ut/Kt[2];Ht=new Rn(Mn,dt[0]-Kt[0]*Mn,dt[1]-Kt[1]*Mn)}Qe.zoom(null,Ht)}})}function Ie(G,Pe,se){return!se&&G.__zooming||new Be(G,Pe)}function Be(G,Pe){this.that=G,this.args=Pe,this.active=0,this.sourceEvent=null,this.extent=e.apply(G,Pe),this.taps=0}Be.prototype={event:function(G){return G&&(this.sourceEvent=G),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(G,Pe){return this.mouse&&G!=="mouse"&&(this.mouse[1]=Pe.invert(this.mouse[0])),this.touch0&&G!=="touch"&&(this.touch0[1]=Pe.invert(this.touch0[0])),this.touch1&&G!=="touch"&&(this.touch1[1]=Pe.invert(this.touch1[0])),this.that.__zoom=Pe,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(G){var Pe=Ft(this.that).datum();u.call(G,this.that,new _g(G,{sourceEvent:this.sourceEvent,target:fe,transform:this.that.__zoom,dispatch:u}),Pe)}};function Xe(G,...Pe){if(!t.apply(this,arguments))return;var se=Ie(this,Pe).event(G),De=this.__zoom,qe=Math.max(o[0],Math.min(o[1],De.k*Math.pow(2,i.apply(this,arguments)))),je=kn(G);if(se.wheel)(se.mouse[0][0]!==je[0]||se.mouse[0][1]!==je[1])&&(se.mouse[1]=De.invert(se.mouse[0]=je)),clearTimeout(se.wheel);else{if(De.k===qe)return;se.mouse=[je,De.invert(je)],Qr(this),se.start()}gr(G),se.wheel=setTimeout(Qe,q),se.zoom("mouse",n(Ve(Ne(De,qe),se.mouse[0],se.mouse[1]),se.extent,s));function Qe(){se.wheel=null,se.end()}}function nt(G,...Pe){if(S||!t.apply(this,arguments))return;var se=G.currentTarget,De=Ie(this,Pe,!0).event(G),qe=Ft(G.view).on("mousemove.zoom",dt,!0).on("mouseup.zoom",ut,!0),je=kn(G,se),Qe=G.clientX,Ze=G.clientY;nu(G.view),as(G),De.mouse=[je,this.__zoom.invert(je)],Qr(this),De.start();function dt(_t){if(gr(_t),!De.moved){var at=_t.clientX-Qe,$t=_t.clientY-Ze;De.moved=at*at+$t*$t>Te}De.event(_t).zoom("mouse",n(Ve(De.that.__zoom,De.mouse[0]=kn(_t,se),De.mouse[1]),De.extent,s))}function ut(_t){qe.on("mousemove.zoom mouseup.zoom",null),iu(_t.view,De.moved),gr(_t),De.event(_t).end()}}function lt(G,...Pe){if(t.apply(this,arguments)){var se=this.__zoom,De=kn(G.changedTouches?G.changedTouches[0]:G,this),qe=se.invert(De),je=se.k*(G.shiftKey?.5:2),Qe=n(Ve(Ne(se,je),De,qe),e.apply(this,Pe),s);gr(G),f>0?Ft(this).transition().duration(f).call(ae,Qe,De,G):Ft(this).call(fe.transform,Qe,De,G)}}function Ee(G,...Pe){if(t.apply(this,arguments)){var se=G.touches,De=se.length,qe=Ie(this,Pe,G.changedTouches.length===De).event(G),je,Qe,Ze,dt;for(as(G),Qe=0;Qe<De;++Qe)Ze=se[Qe],dt=kn(Ze,this),dt=[dt,this.__zoom.invert(dt),Ze.identifier],qe.touch0?!qe.touch1&&qe.touch0[2]!==dt[2]&&(qe.touch1=dt,qe.taps=0):(qe.touch0=dt,je=!0,qe.taps=1+!!d);d&&(d=clearTimeout(d)),je&&(qe.taps<2&&(y=dt[0],d=setTimeout(function(){d=null},D)),Qr(this),qe.start())}}function ct(G,...Pe){if(this.__zooming){var se=Ie(this,Pe).event(G),De=G.changedTouches,qe=De.length,je,Qe,Ze,dt;for(gr(G),je=0;je<qe;++je)Qe=De[je],Ze=kn(Qe,this),se.touch0&&se.touch0[2]===Qe.identifier?se.touch0[0]=Ze:se.touch1&&se.touch1[2]===Qe.identifier&&(se.touch1[0]=Ze);if(Qe=se.that.__zoom,se.touch1){var ut=se.touch0[0],_t=se.touch0[1],at=se.touch1[0],$t=se.touch1[1],Ht=(Ht=at[0]-ut[0])*Ht+(Ht=at[1]-ut[1])*Ht,Kt=(Kt=$t[0]-_t[0])*Kt+(Kt=$t[1]-_t[1])*Kt;Qe=Ne(Qe,Math.sqrt(Ht/Kt)),Ze=[(ut[0]+at[0])/2,(ut[1]+at[1])/2],dt=[(_t[0]+$t[0])/2,(_t[1]+$t[1])/2]}else if(se.touch0)Ze=se.touch0[0],dt=se.touch0[1];else return;se.zoom("touch",n(Ve(Qe,Ze,dt),se.extent,s))}}function ft(G,...Pe){if(this.__zooming){var se=Ie(this,Pe).event(G),De=G.changedTouches,qe=De.length,je,Qe;for(as(G),S&&clearTimeout(S),S=setTimeout(function(){S=null},D),je=0;je<qe;++je)Qe=De[je],se.touch0&&se.touch0[2]===Qe.identifier?delete se.touch0:se.touch1&&se.touch1[2]===Qe.identifier&&delete se.touch1;if(se.touch1&&!se.touch0&&(se.touch0=se.touch1,delete se.touch1),se.touch0)se.touch0[1]=this.__zoom.invert(se.touch0[0]);else if(se.end(),se.taps===2&&(Qe=kn(Qe,this),Math.hypot(y[0]-Qe[0],y[1]-Qe[1])<we)){var Ze=Ft(this).on("dblclick.zoom");Ze&&Ze.apply(this,arguments)}}}return fe.wheelDelta=function(G){return arguments.length?(i=typeof G=="function"?G:To(+G),fe):i},fe.filter=function(G){return arguments.length?(t=typeof G=="function"?G:To(!!G),fe):t},fe.touchable=function(G){return arguments.length?(r=typeof G=="function"?G:To(!!G),fe):r},fe.extent=function(G){return arguments.length?(e=typeof G=="function"?G:To([[+G[0][0],+G[0][1]],[+G[1][0],+G[1][1]]]),fe):e},fe.scaleExtent=function(G){return arguments.length?(o[0]=+G[0],o[1]=+G[1],fe):[o[0],o[1]]},fe.translateExtent=function(G){return arguments.length?(s[0][0]=+G[0][0],s[1][0]=+G[1][0],s[0][1]=+G[0][1],s[1][1]=+G[1][1],fe):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},fe.constrain=function(G){return arguments.length?(n=G,fe):n},fe.duration=function(G){return arguments.length?(f=+G,fe):f},fe.interpolate=function(G){return arguments.length?(l=G,fe):l},fe.on=function(){var G=u.on.apply(u,arguments);return G===u?fe:G},fe.clickDistance=function(G){return arguments.length?(Te=(G=+G)*G,fe):Math.sqrt(Te)},fe.tapDistance=function(G){return arguments.length?(we=+G,fe):we},fe}class Pg{constructor(e,n){this.eventTransform=vr,this.behavior=Cg().scaleExtent([.001,1/0]).on("start",i=>{var o,s;this.isRunning=!0;const r=!!i.sourceEvent;(s=(o=this.config)==null?void 0:o.onZoomStart)==null||s.call(o,i,r)}).on("zoom",i=>{var S,D;this.eventTransform=i.transform;const{eventTransform:{x:r,y:o,k:s},store:{transform:f,screenSize:l}}=this,u=l[0],d=l[1];if(!u||!d)return;Cv(f,u,d),$l(f,f,[r,o]),Ka(f,f,[s,s]),$l(f,f,[u/2,d/2]),Ka(f,f,[u/2,d/2]),Ka(f,f,[1,-1]);const y=!!i.sourceEvent;(D=(S=this.config)==null?void 0:S.onZoom)==null||D.call(S,i,y)}).on("end",i=>{var o,s;this.isRunning=!1;const r=!!i.sourceEvent;(s=(o=this.config)==null?void 0:o.onZoomEnd)==null||s.call(o,i,r)}),this.isRunning=!1,this.store=e,this.config=n}getTransform(e,n,i=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:r}}=this,o=r[0],s=r[1],f=Al(e.map(fe=>fe[0])),l=Al(e.map(fe=>fe[1]));f[0]=this.store.scaleX(f[0]),f[1]=this.store.scaleX(f[1]),l[0]=this.store.scaleY(l[0]),l[1]=this.store.scaleY(l[1]),f[0]===f[1]&&(f[0]-=.5,f[1]+=.5),l[0]===l[1]&&(l[0]+=.5,l[1]-=.5);const u=o*(1-i*2)/(f[1]-f[0]),d=s*(1-i*2)/(l[0]-l[1]),y=vl(n??Math.min(u,d),...this.behavior.scaleExtent()),S=(f[1]+f[0])/2,D=(l[1]+l[0])/2,q=o/2-S*y,Te=s/2-D*y;return vr.translate(q,Te).scale(y)}getDistanceToPoint(e){const{x:n,y:i,k:r}=this.eventTransform,o=this.getTransform([e],r),s=n-o.x,f=i-o.y;return Math.sqrt(s*s+f*f)}getMiddlePointTransform(e){const{store:{screenSize:n},eventTransform:{x:i,y:r,k:o}}=this,s=n[0],f=n[1],l=(s/2-i)/o,u=(f/2-r)/o,d=this.store.scaleX(e[0]),y=this.store.scaleY(e[1]),S=(l+d)/2,D=(u+y)/2,q=1,Te=s/2-S*q,we=f/2-D*q;return vr.translate(Te,we).scale(q)}convertScreenToSpacePosition(e){const{eventTransform:{x:n,y:i,k:r},store:{screenSize:o}}=this,s=o[0],f=o[1],l=(e[0]-n)/r,u=(e[1]-i)/r,d=[l,f-u];return d[0]-=(s-this.store.adjustedSpaceSize)/2,d[1]-=(f-this.store.adjustedSpaceSize)/2,d}convertSpaceToScreenPosition(e){const n=this.eventTransform.applyX(this.store.scaleX(e[0])),i=this.eventTransform.applyY(this.store.scaleY(e[1]));return[n,i]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:n},store:{maxPointSize:i},eventTransform:{k:r}}=this;let o=e*2;return n?o*=r:o*=Math.min(5,Math.max(1,r*.01)),Math.min(o,i)/2}}class kg{constructor(e,n){this.isActive=!1,this.behavior=bg().subject(i=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:i.x,y:i.y}:void 0).on("start",i=>{var r,o;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(o=(r=this.config)==null?void 0:r.onDragStart)==null||o.call(r,i))}).on("drag",i=>{var r,o;(o=(r=this.config)==null?void 0:r.onDrag)==null||o.call(r,i)}).on("end",i=>{var r,o;this.isActive=!1,this.store.draggingPointIndex=void 0,(o=(r=this.config)==null?void 0:r.onDragEnd)==null||o.call(r,i)}),this.store=e,this.config=n}}function Ig(t){const e=document.createElement("div");return e.style.cssText=`
1671
+ color: var(--cosmosgl-error-message-color);
1672
+ padding: 0em 2em;
1673
+ position: absolute;
1674
+ top: 50%; left: 0; right: 0;
1675
+ transform: translateY(-50%);
1676
+ z-index: 1000;
1677
+ font-family: inherit;
1678
+ font-size: 1rem;
1679
+ text-align: center;
1680
+ user-select: none;
1681
+ `,e.textContent="Sorry, your device or browser does not support the required WebGL features for this visualization",t.appendChild(e),e}class Lg{constructor(e,n){this.config=new a0,this.graph=new I0(this.config),this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new mg,this.zoomInstance=new Pg(this.store,this.config),this.dragInstance=new kg(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,n&&this.config.init(n),this.store.div=e;const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",this.store.div.appendChild(i),this.addAttribution();const r=i.clientWidth,o=i.clientHeight;i.width=r*this.config.pixelRatio,i.height=o*this.config.pixelRatio,this.canvas=i;let s;try{s=Ep({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0},extensions:["OES_texture_float","ANGLE_instanced_arrays"]})}catch{Ig(this.store.div),this._isDestroyed=!0;return}this.reglInstance=s,this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.store.setWebGLMaxTextureSize(this.reglInstance.limits.maxTextureSize),this.store.updateScreenSize(r,o),this.canvasD3Selection=Ft(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mousemove.cosmos",()=>{this._isMouseOnCanvas=!0}).on("mouseleave.cosmos",f=>{this._isMouseOnCanvas=!1,this.currentEvent=f,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(f),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(f),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),Ft(document).on("keydown.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",f=>{f.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",f=>{this.currentEvent=f}).on("zoom.detect",f=>{!!f.sourceEvent&&this.updateMousePosition(f.sourceEvent),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f}),this.dragInstance.behavior.on("start.detect",f=>{this.currentEvent=f,this.updateCanvasCursor()}).on("drag.detect",f=>{this.dragInstance.isActive&&this.updateMousePosition(f),this.currentEvent=f}).on("end.detect",f=>{this.currentEvent=f,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),this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio,this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Av(this.reglInstance,this.config,this.store,this.graph),this.lines=new uv(this.reglInstance,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new h0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new u0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useClassicQuadtree?new y0(this.reglInstance,this.config,this.store,this.graph,this.points):new v0(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new yl(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new b0(this.reglInstance,this.config,this.store,this.graph,this.points)),this.clusters=new w0(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Fn(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Sl(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed)}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;if(this._isDestroyed||!this.reglInstance||!this.points||!this.lines||!this.clusters)return;const n={...this.config};this.config.init(e),(n.pointDefaultColor!==this.config.pointDefaultColor||n.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),this.points.updateColor()),n.pointSize!==this.config.pointSize&&(this.graph.updatePointSize(),this.points.updateSize()),(n.linkDefaultColor!==this.config.linkDefaultColor||n.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),this.lines.updateColor()),n.linkWidth!==this.config.linkWidth&&(this.graph.updateLinkWidth(),this.lines.updateWidth()),n.linkArrows!==this.config.linkArrows&&(this.graph.updateArrows(),this.lines.updateArrow()),(n.curvedLinkSegments!==this.config.curvedLinkSegments||n.curvedLinks!==this.config.curvedLinks)&&this.lines.updateCurveLineGeometry(),n.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Fn(this.config.backgroundColor??Qf)),n.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??Oe.hoveredPointRingColor),n.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??Oe.focusedPointRingColor),n.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ra),n.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??Oe.hoveredLinkColor),n.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),(n.spaceSize!==this.config.spaceSize||n.simulationRepulsionQuadtreeLevels!==this.config.simulationRepulsionQuadtreeLevels)&&(this.store.adjustSpaceSize(this.config.spaceSize,this.reglInstance.limits.maxTextureSize),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),n.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Sl(this.canvas):((i=this.fpsMonitor)==null||i.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(this.reglInstance.limits.pointSizeDims[1]??is)/this.config.pixelRatio),(n.enableZoom!==this.config.enableZoom||n.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(n.onLinkClick!==this.config.onLinkClick||n.onLinkMouseOver!==this.config.onLinkMouseOver||n.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,n){this._isDestroyed||!this.points||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=n,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.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){this._isDestroyed||!this.points||(this.graph.inputImageData=e,this.points.createAtlas())}setPointImageIndices(e){this._isDestroyed||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){this._isDestroyed||!this.points||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,this.points.updatePinnedStatus())}render(e){if(this._isDestroyed||!this.reglInstance)return;this.graph.update();const{fitViewOnInit:n,fitViewDelay:i,fitViewPadding:r,fitViewDuration:o,fitViewByPointsInRect:s,fitViewByPointIndices:f,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),Ft(this.canvas).style("cursor",null),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});return}this._isFirstRenderAfterInit&&n&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{f?this.fitViewByPointIndices(f,o,r):s?this.setZoomTransformByPointPositions(s,o,void 0,r):this.fitView(o,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,n=700,i=Op,r=!0){if(this._isDestroyed||!this.reglInstance||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:o}}=this,s=Qt(this.reglInstance,this.points.currentPositionFbo);if(e===void 0)return;const f=s[e*4+0],l=s[e*4+1];if(f===void 0||l===void 0)return;const u=this.zoomInstance.getDistanceToPoint([f,l]),d=r?i:Math.max(this.getZoomLevel(),i);if(u<Math.min(o[0],o[1]))this.setZoomTransformByPointPositions([f,l],n,d);else{const y=this.zoomInstance.getTransform([[f,l]],d),S=this.zoomInstance.getMiddlePointTransform([f,l]);this.canvasD3Selection.transition().ease(pp).duration(n/2).call(this.zoomInstance.behavior.transform,S).transition().ease(vp).duration(n/2).call(this.zoomInstance.behavior.transform,y)}}zoom(e,n=0){this._isDestroyed||this.setZoomLevel(e,n)}setZoomLevel(e,n=0){this._isDestroyed||!this.canvasD3Selection||(n===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(n).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.reglInstance||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],n=Qt(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=n[i*4+0],o=n[i*4+1];r!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=o)}return e}getClusterPositions(){if(this._isDestroyed||!this.reglInstance||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],n=Qt(this.reglInstance,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=n[i*4+0],o=n[i*4+1],s=n[i*4+2];r!==void 0&&o!==void 0&&s!==void 0&&(e[i*2]=r/s,e[i*2+1]=o/s)}return e}fitView(e=250,n=.1){this._isDestroyed||this.setZoomTransformByPointPositions(this.getPointPositions(),e,void 0,n)}fitViewByPointIndices(e,n=250,i=.1){if(this._isDestroyed)return;const r=this.getPointPositions(),o=new Array(e.length*2);for(const[s,f]of e.entries())o[s*2]=r[f*2],o[s*2+1]=r[f*2+1];this.setZoomTransformByPointPositions(o,n,void 0,i)}fitViewByPointPositions(e,n=250,i=.1){this._isDestroyed||this.setZoomTransformByPointPositions(e,n,void 0,i)}getPointsInRect(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;const n=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((r,o)=>o%4===0&&r!==0?o/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.reglInstance||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),Qt(this.reglInstance,this.points.selectedFbo).map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}selectPointsInRect(e){if(!(this._isDestroyed||!this.reglInstance||!this.points)){if(e){const n=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],n-e[1][1]],[e[1][0],n-e[0][1]]],this.points.findPointsOnAreaSelection();const i=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=i.map((r,o)=>o%4===0&&r!==0?o/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.reglInstance||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const n=this.store.screenSize[1],i=e.map(([o,s])=>[o,n-s]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=Qt(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=r.map((o,s)=>s%4===0&&o!==0?s/4:-1).filter(o=>o!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,n=!1){if(!this._isDestroyed)if(n){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||!this.points||(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(n=>n!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||!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 n;if(!this._isDestroyed)return(n=this.graph.pointSizes)==null?void 0:n[e]}trackPointPositionsByIndices(e){this._isDestroyed||!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 n,i;this._isDestroyed||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(n=this.config).onSimulationStart)==null||i.call(n))}stop(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(n=(e=this.config).onSimulationEnd)==null||n.call(e))}pause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!1,(n=(e=this.config).onSimulationPause)==null||n.call(e))}unpause(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationUnpause)==null||n.call(e))}restart(){var e,n;this._isDestroyed||(this.store.isSimulationRunning=!0,(n=(e=this.config).onSimulationRestart)==null||n.call(e))}step(){this._isDestroyed||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,n,i,r;this._isDestroyed||!this.reglInstance||(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),Ft(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),(n=this.dragInstance)!=null&&n.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),this.reglInstance.destroy(),this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0}),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.reglInstance=void 0,this.attributionDivElement=void 0,this._isDestroyed=!0)}create(){var e,n,i,r,o;this._isDestroyed||!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&&((n=this.forceLinkIncoming)==null||n.create(Wa.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(Wa.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((o=this.clusters)==null||o.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 n=new Array(e.length/2);for(let i=0;i<e.length/2;i++)n[i]=[e[i*2],e[i*2+1]];return n}update(e=this.store.alpha){const{graph:n}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(n.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((n.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var f,l,u,d,y,S,D,q,Te,we,fe,Ne,Ve,V,ae,Ie,Be,Xe,nt;const{config:{simulationGravity:n,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:o}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((f=this.forceMouse)==null||f.run(),(l=this.points)==null||l.updatePosition()),(e||o&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(n&&((u=this.forceGravity)==null||u.run(),(d=this.points)==null||d.updatePosition()),i&&((y=this.forceCenter)==null||y.run(),(S=this.points)==null||S.updatePosition()),(D=this.forceManyBody)==null||D.run(),(q=this.points)==null||q.updatePosition(),this.store.linksTextureSize&&((Te=this.forceLinkIncoming)==null||Te.run(),(we=this.points)==null||we.updatePosition(),(fe=this.forceLinkOutgoing)==null||fe.run(),(Ne=this.points)==null||Ne.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((Ve=this.clusters)==null||Ve.run(),(V=this.points)==null||V.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??Oe.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,ns/this.store.alpha)),(Xe=(Be=this.config).onSimulationTick)==null||Xe.call(Be,this.store.alpha,(ae=this.store.hoveredPoint)==null?void 0:ae.index,(Ie=this.store.hoveredPoint)==null?void 0:Ie.position)),(nt=this.points)==null||nt.trackPoints()}initPrograms(){var e,n,i,r,o,s;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(n=this.forceLinkIncoming)==null||n.initPrograms(),(i=this.forceLinkOutgoing)==null||i.initPrograms(),(r=this.forceMouse)==null||r.initPrograms(),(o=this.forceManyBody)==null||o.initPrograms(),(s=this.forceCenter)==null||s.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:n}}=this;e<ns&&n&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var i,r,o,s,f,l,u,d;if(this._isDestroyed||!this.store.pointsTextureSize)return;(i=this.fpsMonitor)==null||i.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),(r=this.reglInstance)==null||r.clear({color:this.store.backgroundColor,depth:1,stencil:0});const{config:{renderLinks:n}}=this;n&&this.store.linksTextureSize&&((o=this.lines)==null||o.draw()),(s=this.points)==null||s.draw(),this.dragInstance.isActive&&((f=this.points)==null||f.drag(),(l=this.points)==null||l.drag(),(u=this.points)==null||u.trackPoints()),(d=this.fpsMonitor)==null||d.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,n;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(n=(e=this.config).onSimulationEnd)==null||n.call(e)}onClick(e){var n,i,r,o,s,f,l,u,d,y;(o=(r=this.config).onClick)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(f=(s=this.config).onPointClick)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(u=(l=this.config).onLinkClick)==null||u.call(l,this.store.hoveredLinkIndex,e):(y=(d=this.config).onBackgroundClick)==null||y.call(d,e)}updateMousePosition(e){if(!e)return;const n=e.offsetX??e.x,i=e.offsetY??e.y;n===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([n,i]),this.store.screenMousePosition=[n,this.store.screenSize[1]-i])}onMouseMove(e){var n,i,r,o;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(o=(r=this.config).onMouseMove)==null||o.call(r,(n=this.store.hoveredPoint)==null?void 0:n.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onRightClickMouse(e){e.preventDefault()}resizeCanvas(e=!1){var s,f,l,u;if(this._isDestroyed)return;const n=this.canvas.width,i=this.canvas.height,r=this.canvas.clientWidth,o=this.canvas.clientHeight;if(e||n!==r*this.config.pixelRatio||i!==o*this.config.pixelRatio){const[d,y]=this.store.screenSize,{k:S}=this.zoomInstance.eventTransform,D=this.zoomInstance.convertScreenToSpacePosition([d/2,y/2]);this.store.updateScreenSize(r,o),this.canvas.width=r*this.config.pixelRatio,this.canvas.height=o*this.config.pixelRatio,(s=this.reglInstance)==null||s.poll(),(f=this.canvasD3Selection)==null||f.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform([D],S)),(l=this.points)==null||l.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((u=this.lines)==null||u.updateLinkIndexFbo())}}setZoomTransformByPointPositions(e,n=250,i,r){var s;this.resizeCanvas();const o=this.zoomInstance.getTransform(this.pair(e),i,r);(s=this.canvasD3Selection)==null||s.transition().ease(gp).duration(n).call(this.zoomInstance.behavior.transform,o)}updateZoomDragBehaviors(){var e,n,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(n=this.canvasD3Selection)==null||n.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||!this.reglInstance)){if(this._findHoveredItemExecutionCount<dg){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 o,s,f,l,u;if(this._isDestroyed||!this.reglInstance||!this.points)return;this.points.findHoveredPoint();let e=!1,n=!1;const i=Qt(this.reglInstance,this.points.hoveredFbo);if(i[1]){const d=i[0];((o=this.store.hoveredPoint)==null?void 0:o.index)!==d&&(e=!0);const y=i[2],S=i[3];this.store.hoveredPoint={index:d,position:[y,S]}}else this.store.hoveredPoint&&(n=!0),this.store.hoveredPoint=void 0;e&&this.store.hoveredPoint&&((f=(s=this.config).onPointMouseOver)==null||f.call(s,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent)),n&&((u=(l=this.config).onPointMouseOut)==null||u.call(l,this.currentEvent))}findHoveredLine(){var o,s,f,l,u,d;if(this._isDestroyed||!this.reglInstance||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(s=(o=this.config).onLinkMouseOut)==null||s.call(o,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,n=!1;const r=Qt(this.reglInstance,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(n=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(f=this.config).onLinkMouseOver)==null||l.call(f,this.store.hoveredLinkIndex)),n&&((d=(u=this.config).onLinkMouseOut)==null||d.call(u,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:n}=this.config;this.dragInstance.isActive?Ft(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?Ft(this.canvas).style("cursor",e):Ft(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?Ft(this.canvas).style("cursor",n):Ft(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
1682
+ user-select: none;
1683
+ position: absolute;
1684
+ bottom: 0;
1685
+ right: 0;
1686
+ color: var(--cosmosgl-attribution-color);
1687
+ margin: 0 0.6rem 0.6rem 0;
1688
+ font-size: 0.7rem;
1689
+ font-family: inherit;
1690
+ `,this.attributionDivElement.innerHTML=gl(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))}}Rt.Graph=Lg,Rt.PointShape=Tl,Rt.clamp=vl,Rt.getRgbaColor=Fn,Rt.isAClassInstance=ml,Rt.isArray=$a,Rt.isFunction=hl,Rt.isNumber=nn,Rt.isObject=dl,Rt.isPlainObject=Ha,Rt.readPixels=Qt,Rt.rgbToBrightness=pl,Rt.sanitizeHtml=gl,Object.defineProperty(Rt,Symbol.toStringTag,{value:"Module"})});
2
1691
  //# sourceMappingURL=index.min.js.map