!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Deepscatter=e()}(this,(function(){"use strict";var t="http://www.w3.org/1999/xhtml";const e={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 n(t){var n=t+="",r=n.indexOf(":");return r>=0&&"xmlns"!==(n=t.slice(0,r))&&(t=t.slice(r+1)),e.hasOwnProperty(n)?{space:e[n],local:t}:t}function r(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===t&&n.documentElement.namespaceURI===t?n.createElement(e):n.createElementNS(r,e)}}function i(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var e=n(t);return(e.local?i:r)(e)}function a(){}function s(t){return null==t?a:function(){return this.querySelector(t)}}function u(){return[]}function c(t){return null==t?u:function(){return this.querySelectorAll(t)}}function l(t){return function(){return null==(e=t.apply(this,arguments))?[]:Array.isArray(e)?e:Array.from(e);var e}}function f(t){return function(){return this.matches(t)}}function h(t){return function(e){return e.matches(t)}}var d=Array.prototype.find;function p(){return this.firstElementChild}var _=Array.prototype.filter;function m(){return Array.from(this.children)}function b(t){return new Array(t.length)}function y(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function g(t,e,n,r,i,o){for(var a,s=0,u=e.length,c=o.length;se?1:t>=e?0:NaN}function S(t){return function(){this.removeAttribute(t)}}function I(t){return function(){this.removeAttributeNS(t.space,t.local)}}function O(t,e){return function(){this.setAttribute(t,e)}}function T(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function k(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function M(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function E(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function B(t){return function(){this.style.removeProperty(t)}}function j(t,e,n){return function(){this.style.setProperty(t,e,n)}}function D(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function z(t,e){return t.style.getPropertyValue(e)||E(t).getComputedStyle(t,null).getPropertyValue(e)}function N(t){return function(){delete this[t]}}function C(t,e){return function(){this[t]=e}}function F(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function L(t){return t.trim().split(/^|\s+/)}function U(t){return t.classList||new R(t)}function R(t){this._node=t,this._names=L(t.getAttribute("class")||"")}function P(t,e){for(var n=U(t),r=-1,i=e.length;++r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ct=[null];function lt(t,e){this._groups=t,this._parents=e}function ft(){return new lt([[document.documentElement]],ct)}function ht(t){return"string"==typeof t?new lt([[document.querySelector(t)]],[document.documentElement]):new lt([[t]],ct)}function dt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}function pt(t,e){return null==t||null==e?NaN:te?1:t>=e?0:NaN}function _t(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function mt(t){let e,n,r;function i(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<0?i=e+1:o=e}while(ipt(t(e),n),r=(e,n)=>t(e)-n):(e=t===pt||t===_t?t:bt,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const a=i(t,e,n,o-1);return a>n&&r(t[a-1],e)>-r(t[a],e)?a-1:a},right:function(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<=0?i=e+1:o=e}while(i=I&&(I=S+1);!(A=b[I])&&++I<_;);y._next=A||null}}return(s=new lt(s,i))._enter=u,s._exit=c,s},enter:function(){return new lt(this._enter||this._groups.map(b),this._parents)},exit:function(){return new lt(this._exit||this._groups.map(b),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,a=Math.min(i,o),s=new Array(i),u=0;u=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=A);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?B:"function"==typeof e?D:j)(t,e,null==n?"":n)):z(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?N:"function"==typeof e?F:C)(t,e)):this.node()[t]},classed:function(t,e){var n=L(t+"");if(arguments.length<2){for(var r=U(this.node()),i=-1,o=n.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?ot:it,r=0;r=i&&(n=r=i):(n>i&&(n=i),r=o&&(n=r=o):(n>o&&(n=o),r0){for(o=t[--i];i>0&&(e=o,n=t[--i],o=e+n,r=n-(o-e),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r,e=o+n,n==e-o&&(o=e))}return o}}class At extends Map{constructor(t,e=It){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[n,r]of t)this.set(n,r)}get(t){return super.get(St(this,t))}has(t){return super.has(St(this,t))}set(t,e){return super.set(function({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}(this,t),e)}delete(t){return super.delete(function({_intern:t,_key:e},n){const r=e(n);t.has(r)&&(n=t.get(n),t.delete(r));return n}(this,t))}}function St({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function It(t){return null!==t&&"object"==typeof t?t.valueOf():t}const Ot=Math.sqrt(50),Tt=Math.sqrt(10),kt=Math.sqrt(2);function Mt(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=Ot?10:o>=Tt?5:o>=kt?2:1;let s,u,c;return i<0?(c=Math.pow(10,-i)/a,s=Math.round(t*c),u=Math.round(e*c),s/ce&&--u,c=-c):(c=Math.pow(10,i)*a,s=Math.round(t/c),u=Math.round(e/c),s*ce&&--u),u0))return[];if((t=+t)===(e=+e))return[t];const r=e=i))return[];const s=o-i+1,u=new Array(s);if(r)if(a<0)for(let c=0;c=r)&&(n=r);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n=i)&&(n=i)}return n}function Dt(t,e){let n;if(void 0===e)for(const r of t)null!=r&&(n>r||void 0===n&&r>=r)&&(n=r);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function zt(t,e){let n=0,r=0;if(void 0===e)for(let i of t)null!=i&&(i=+i)>=i&&(++n,r+=i);else{let i=-1;for(let o of t)null!=(o=e(o,++i,t))&&(o=+o)>=o&&(++n,r+=o)}if(n)return r/n}function Nt(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(i);++r=0;--o)i.point((l=c[o])[0],l[1]);else r(h.x,h.p.x,-1,i);h=h.p}c=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function ee(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r0)do{c.point(0===l||3===l?t:n,l>1?r:e)}while((l=(l+s+4)%4)!==f);else c.point(o[0],o[1])}function a(r,i){return Vt(r[0]-t)0?0:3:Vt(r[0]-n)0?2:1:Vt(r[1]-e)0?1:0:i>0?3:2}function s(t,e){return u(t.x,e.x)}function u(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(a){var u,c,l,f,h,d,p,_,m,b,y,g,v,w=a,x=(v=[],{point:function(t,e,n){g.push([t,e,n])},lineStart:function(){v.push(g=[])},lineEnd:Gt,rejoin:function(){v.length>1&&v.push(v.pop().concat(v.shift()))},result:function(){var t=v;return v=[],g=null,t}}),A={point:S,lineStart:function(){A.point=I,c&&c.push(l=[]);b=!0,m=!1,p=_=NaN},lineEnd:function(){u&&(I(f,h),d&&m&&x.rejoin(),u.push(x.result()));A.point=S,m&&w.lineEnd()},polygonStart:function(){w=x,u=[],c=[],y=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=c.length;nr&&(h-o)*(r-a)>(d-a)*(t-o)&&++e:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--e;return e}(),n=y&&e,i=(f=u,u=Array.from(function*(t){for(const e of t)yield*e}(f))).length;var f;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&te(u,s,e,o,a),a.polygonEnd());w=a,u=c=l=null}};function S(t,e){i(t,e)&&w.point(t,e)}function I(o,a){var s=i(o,a);if(c&&l.push([o,a]),b)f=o,h=a,d=s,b=!1,s&&(w.lineStart(),w.point(o,a));else if(s&&m)w.point(o,a);else{var u=[p=Math.max(re,Math.min(ne,p)),_=Math.max(re,Math.min(ne,_))],g=[o=Math.max(re,Math.min(ne,o)),a=Math.max(re,Math.min(ne,a))];!function(t,e,n,r,i,o){var a,s=t[0],u=t[1],c=0,l=1,f=e[0]-s,h=e[1]-u;if(a=n-s,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>l)return;a>c&&(c=a)}if(a=i-s,f||!(a<0)){if(a/=f,f<0){if(a>l)return;a>c&&(c=a)}else if(f>0){if(a0)){if(a/=h,h<0){if(a0){if(a>l)return;a>c&&(c=a)}if(a=o-u,h||!(a<0)){if(a/=h,h<0){if(a>l)return;a>c&&(c=a)}else if(h>0){if(a0&&(t[0]=s+c*f,t[1]=u+c*h),l<1&&(e[0]=s+l*f,e[1]=u+l*h),!0}}}}}(u,g,t,e,n,r)?s&&(w.lineStart(),w.point(o,a),y=!1):(m||(w.lineStart(),w.point(u[0],u[1])),w.point(g[0],g[1]),s||w.lineEnd(),y=!1)}p=o,_=a,m=s}return A}}const oe=t=>t;var ae,se,ue,ce,le=new xt,fe=new xt,he={point:Gt,lineStart:Gt,lineEnd:Gt,polygonStart:function(){he.lineStart=de,he.lineEnd=me},polygonEnd:function(){he.lineStart=he.lineEnd=he.point=Gt,le.add(Vt(fe)),fe=new xt},result:function(){var t=le/2;return le=new xt,t}};function de(){he.point=pe}function pe(t,e){he.point=_e,ae=ue=t,se=ce=e}function _e(t,e){fe.add(ce*t-ue*e),ue=t,ce=e}function me(){_e(ae,se)}const be=he;var ye=1/0,ge=ye,ve=-ye,we=ve;const xe={point:function(t,e){tve&&(ve=t);ewe&&(we=e)},lineStart:Gt,lineEnd:Gt,polygonStart:Gt,polygonEnd:Gt,result:function(){var t=[[ye,ge],[ve,we]];return ve=we=-(ge=ye=1/0),t}};var Ae,Se,Ie,Oe,Te=0,ke=0,Me=0,Ee=0,Be=0,je=0,De=0,ze=0,Ne=0,Ce={point:Fe,lineStart:Le,lineEnd:Pe,polygonStart:function(){Ce.lineStart=Ve,Ce.lineEnd=$e},polygonEnd:function(){Ce.point=Fe,Ce.lineStart=Le,Ce.lineEnd=Pe},result:function(){var t=Ne?[De/Ne,ze/Ne]:je?[Ee/je,Be/je]:Me?[Te/Me,ke/Me]:[NaN,NaN];return Te=ke=Me=Ee=Be=je=De=ze=Ne=0,t}};function Fe(t,e){Te+=t,ke+=e,++Me}function Le(){Ce.point=Ue}function Ue(t,e){Ce.point=Re,Fe(Ie=t,Oe=e)}function Re(t,e){var n=t-Ie,r=e-Oe,i=Wt(n*n+r*r);Ee+=i*(Ie+t)/2,Be+=i*(Oe+e)/2,je+=i,Fe(Ie=t,Oe=e)}function Pe(){Ce.point=Fe}function Ve(){Ce.point=Ye}function $e(){We(Ae,Se)}function Ye(t,e){Ce.point=We,Fe(Ae=Ie=t,Se=Oe=e)}function We(t,e){var n=t-Ie,r=e-Oe,i=Wt(n*n+r*r);Ee+=i*(Ie+t)/2,Be+=i*(Oe+e)/2,je+=i,De+=(i=Oe*t-Ie*e)*(Ie+t),ze+=i*(Oe+e),Ne+=3*i,Fe(Ie=t,Oe=e)}const Ge=Ce;function qe(t){this._context=t}qe.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,Ut)}},result:Gt};var Xe,He,Ze,Je,Ke,Qe=new xt,tn={point:Gt,lineStart:function(){tn.point=en},lineEnd:function(){Xe&&nn(He,Ze),tn.point=Gt},polygonStart:function(){Xe=!0},polygonEnd:function(){Xe=null},result:function(){var t=+Qe;return Qe=new xt,t}};function en(t,e){tn.point=nn,He=Je=t,Ze=Ke=e}function nn(t,e){Je-=t,Ke-=e,Qe.add(Wt(Je*Je+Ke*Ke)),Je=t,Ke=e}const rn=tn;let on,an,sn,un;class cn{constructor(t){this._append=null==t?ln:function(t){const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);if(e>15)return ln;if(e!==on){const t=10**e;on=e,an=function(e){let n=1;this._+=e[0];for(const r=e.length;n=0))throw new RangeError(`invalid digits: ${t}`);i=e}return null===e&&(r=new cn(i)),a},a.projection(t).digits(i).context(e)}function hn(){}function dn(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Kt(n,t.stream(xe)),e(xe.result()),null!=r&&t.clipExtent(r),t}function pn(t,e,n){return dn(t,(function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],o=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),a=+e[0][0]+(r-o*(n[1][0]+n[0][0]))/2,s=+e[0][1]+(i-o*(n[1][1]+n[0][1]))/2;t.scale(150*o).translate([a,s])}),n)}function _n(){var t,e,n,r,i,o,a,s,u=1,c=0,l=0,f=1,h=1,d=0,p=null,_=1,m=1,b=(s={point:function(t,e){var n=v([t,e]);this.stream.point(n[0],n[1])}},function(t){var e=new hn;for(var n in s)e[n]=s[n];return e.stream=t,e}),y=oe;function g(){return _=u*f,m=u*h,o=a=null,v}function v(n){var r=n[0]*_,i=n[1]*m;if(d){var o=i*t-r*e;r=r*t+i*e,i=o}return[r+c,i+l]}return v.invert=function(n){var r=n[0]-c,i=n[1]-l;if(d){var o=i*t+r*e;r=r*t-i*e,i=o}return[r/_,i/m]},v.stream=function(t){return o&&a===t?o:o=b(y(a=t))},v.postclip=function(t){return arguments.length?(y=t,p=n=r=i=null,g()):y},v.clipExtent=function(t){return arguments.length?(y=null==t?(p=n=r=i=null,oe):ie(p=+t[0][0],n=+t[0][1],r=+t[1][0],i=+t[1][1]),g()):null==p?null:[[p,n],[r,i]]},v.scale=function(t){return arguments.length?(u=+t,g()):u},v.translate=function(t){return arguments.length?(c=+t[0],l=+t[1],g()):[c,l]},v.angle=function(n){return arguments.length?(e=Yt(d=n%360*Pt),t=$t(d),g()):d*Rt},v.reflectX=function(t){return arguments.length?(f=t?-1:1,g()):f<0},v.reflectY=function(t){return arguments.length?(h=t?-1:1,g()):h<0},v.fitExtent=function(t,e){return pn(v,t,e)},v.fitSize=function(t,e){return function(t,e,n){return pn(t,[[0,0],e],n)}(v,t,e)},v.fitWidth=function(t,e){return function(t,e,n){return dn(t,(function(n){var r=+e,i=r/(n[1][0]-n[0][0]),o=(r-i*(n[1][0]+n[0][0]))/2,a=-i*n[0][1];t.scale(150*i).translate([o,a])}),n)}(v,t,e)},v.fitHeight=function(t,e){return function(t,e,n){return dn(t,(function(n){var r=+e,i=r/(n[1][1]-n[0][1]),o=-i*n[0][0],a=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([o,a])}),n)}(v,t,e)},v}hn.prototype={constructor:hn,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var mn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},bn={};!function(t,e){var n=200,r="__lodash_hash_undefined__",i=800,o=16,a=9007199254740991,s="[object Arguments]",u="[object AsyncFunction]",c="[object Function]",l="[object GeneratorFunction]",f="[object Null]",h="[object Object]",d="[object Proxy]",p="[object Undefined]",_=/^\[object .+?Constructor\]$/,m=/^(?:0|[1-9]\d*)$/,b={};b["[object Float32Array]"]=b["[object Float64Array]"]=b["[object Int8Array]"]=b["[object Int16Array]"]=b["[object Int32Array]"]=b["[object Uint8Array]"]=b["[object Uint8ClampedArray]"]=b["[object Uint16Array]"]=b["[object Uint32Array]"]=!0,b[s]=b["[object Array]"]=b["[object ArrayBuffer]"]=b["[object Boolean]"]=b["[object DataView]"]=b["[object Date]"]=b["[object Error]"]=b[c]=b["[object Map]"]=b["[object Number]"]=b[h]=b["[object RegExp]"]=b["[object Set]"]=b["[object String]"]=b["[object WeakMap]"]=!1;var y="object"==typeof mn&&mn&&mn.Object===Object&&mn,g="object"==typeof self&&self&&self.Object===Object&&self,v=y||g||Function("return this")(),w=e&&!e.nodeType&&e,x=w&&t&&!t.nodeType&&t,A=x&&x.exports===w,S=A&&y.process,I=function(){try{var t=x&&x.require&&x.require("util").types;return t||S&&S.binding&&S.binding("util")}catch(e){}}(),O=I&&I.isTypedArray;var T,k,M,E=Array.prototype,B=Function.prototype,j=Object.prototype,D=v["__core-js_shared__"],z=B.toString,N=j.hasOwnProperty,C=(T=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",F=j.toString,L=z.call(Object),U=RegExp("^"+z.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),R=A?v.Buffer:void 0,P=v.Symbol,V=v.Uint8Array,$=R?R.allocUnsafe:void 0,Y=(k=Object.getPrototypeOf,M=Object,function(t){return k(M(t))}),W=Object.create,G=j.propertyIsEnumerable,q=E.splice,X=P?P.toStringTag:void 0,H=function(){try{var t=wt(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),Z=R?R.isBuffer:void 0,J=Math.max,K=Date.now,Q=wt(v,"Map"),tt=wt(Object,"create"),et=function(){function t(){}return function(e){if(!Dt(e))return{};if(W)return W(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function nt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1},rt.prototype.set=function(t,e){var n=this.__data__,r=ct(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},it.prototype.clear=function(){this.size=0,this.__data__={hash:new nt,map:new(Q||rt),string:new nt}},it.prototype.delete=function(t){var e=vt(this,t).delete(t);return this.size-=e?1:0,e},it.prototype.get=function(t){return vt(this,t).get(t)},it.prototype.has=function(t){return vt(this,t).has(t)},it.prototype.set=function(t,e){var n=vt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},ot.prototype.clear=function(){this.__data__=new rt,this.size=0},ot.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ot.prototype.get=function(t){return this.__data__.get(t)},ot.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.set=function(t,e){var r=this.__data__;if(r instanceof rt){var i=r.__data__;if(!Q||i.length-1&&t%1==0&&t0){if(++e>=i)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(gt);function Ot(t,e){return t===e||t!=t&&e!=e}var Tt=pt(function(){return arguments}())?pt:function(t){return zt(t)&&N.call(t,"callee")&&!G.call(t,"callee")},kt=Array.isArray;function Mt(t){return null!=t&&jt(t.length)&&!Bt(t)}var Et=Z||function(){return!1};function Bt(t){if(!Dt(t))return!1;var e=dt(t);return e==c||e==l||e==u||e==d}function jt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Dt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function zt(t){return null!=t&&"object"==typeof t}var Nt=O?function(t){return function(e){return t(e)}}(O):function(t){return zt(t)&&jt(t.length)&&!!b[dt(t)]};function Ct(t){return Mt(t)?at(t,!0):mt(t)}var Ft,Lt=(Ft=function(t,e,n){bt(t,e,n)},yt((function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=Ft.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!Dt(n))return!1;var r=typeof e;return!!("number"==r?Mt(n)&&xt(e,n.length):"string"==r&&e in n)&&Ot(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n=0&&e._call.call(void 0,t),e=e._next;--vn}()}finally{vn=0,function(){var t,e,n=yn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:yn=e);gn=t,Nn(r)}(),In=0}}function zn(){var t=Tn.now(),e=t-Sn;e>An&&(On-=e,Sn=t)}function Nn(t){vn||(wn&&(wn=clearTimeout(wn)),t-In>24?(t<1/0&&(wn=setTimeout(Dn,t-Tn.now()-On)),xn&&(xn=clearInterval(xn))):(xn||(Sn=Tn.now(),xn=setInterval(zn,An)),vn=1,kn(Dn)))}function Cn(t,e,n){var r=new Bn;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Bn.prototype=jn.prototype={constructor:Bn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Mn():+n)+(null==e?0:+e),this._next||gn===this||(gn?gn._next=this:yn=this,gn=this),this._call=t,this._time=n,Nn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Nn())}};var Fn={value:()=>{}};function Ln(){for(var t,e=0,n=arguments.length,r={};e=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a0)for(var n,r,i=new Array(n),o=0;o()=>t;function Hn(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:u,dy:c,dispatch:l}){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:r,enumerable:!0,configurable:!0},identifier:{value:i,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:c,enumerable:!0,configurable:!0},_:{value:l}})}function Zn(t){return!t.ctrlKey&&!t.button}function Jn(){return this.parentNode}function Kn(t,e){return null==e?{x:t.x,y:t.y}:e}function Qn(){return navigator.maxTouchPoints||"ontouchstart"in this}function tr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function er(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function nr(){}Hn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var rr=.7,ir=1/rr,or="\\s*([+-]?\\d+)\\s*",ar="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",sr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ur=/^#([0-9a-f]{3,8})$/,cr=new RegExp(`^rgb\\(${or},${or},${or}\\)$`),lr=new RegExp(`^rgb\\(${sr},${sr},${sr}\\)$`),fr=new RegExp(`^rgba\\(${or},${or},${or},${ar}\\)$`),hr=new RegExp(`^rgba\\(${sr},${sr},${sr},${ar}\\)$`),dr=new RegExp(`^hsl\\(${ar},${sr},${sr}\\)$`),pr=new RegExp(`^hsla\\(${ar},${sr},${sr},${ar}\\)$`),_r={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 mr(){return this.rgb().formatHex()}function br(){return this.rgb().formatRgb()}function yr(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ur.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?gr(e):3===n?new Ar(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?vr(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?vr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=cr.exec(t))?new Ar(e[1],e[2],e[3],1):(e=lr.exec(t))?new Ar(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=fr.exec(t))?vr(e[1],e[2],e[3],e[4]):(e=hr.exec(t))?vr(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=dr.exec(t))?Mr(e[1],e[2]/100,e[3]/100,1):(e=pr.exec(t))?Mr(e[1],e[2]/100,e[3]/100,e[4]):_r.hasOwnProperty(t)?gr(_r[t]):"transparent"===t?new Ar(NaN,NaN,NaN,0):null}function gr(t){return new Ar(t>>16&255,t>>8&255,255&t,1)}function vr(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ar(t,e,n,r)}function wr(t){return t instanceof nr||(t=yr(t)),t?new Ar((t=t.rgb()).r,t.g,t.b,t.opacity):new Ar}function xr(t,e,n,r){return 1===arguments.length?wr(t):new Ar(t,e,n,null==r?1:r)}function Ar(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Sr(){return`#${kr(this.r)}${kr(this.g)}${kr(this.b)}`}function Ir(){const t=Or(this.opacity);return`${1===t?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${1===t?")":`, ${t})`}`}function Or(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Tr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function kr(t){return((t=Tr(t))<16?"0":"")+t.toString(16)}function Mr(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Br(t,e,n,r)}function Er(t){if(t instanceof Br)return new Br(t.h,t.s,t.l,t.opacity);if(t instanceof nr||(t=yr(t)),!t)return new Br;if(t instanceof Br)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n0&&u<1?0:a,new Br(a,s,u,t.opacity)}function Br(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function jr(t){return(t=(t||0)%360)<0?t+360:t}function Dr(t){return Math.max(0,Math.min(1,t||0))}function zr(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}tr(nr,yr,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:mr,formatHex:mr,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Er(this).formatHsl()},formatRgb:br,toString:br}),tr(Ar,xr,er(nr,{brighter(t){return t=null==t?ir:Math.pow(ir,t),new Ar(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?rr:Math.pow(rr,t),new Ar(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ar(Tr(this.r),Tr(this.g),Tr(this.b),Or(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:Sr,formatHex:Sr,formatHex8:function(){return`#${kr(this.r)}${kr(this.g)}${kr(this.b)}${kr(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ir,toString:Ir})),tr(Br,(function(t,e,n,r){return 1===arguments.length?Er(t):new Br(t,e,n,null==r?1:r)}),er(nr,{brighter(t){return t=null==t?ir:Math.pow(ir,t),new Br(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?rr:Math.pow(rr,t),new Br(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Ar(zr(t>=240?t-240:t+120,i,r),zr(t,i,r),zr(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Br(jr(this.h),Dr(this.s),Dr(this.l),Or(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=Or(this.opacity);return`${1===t?"hsl(":"hsla("}${jr(this.h)}, ${100*Dr(this.s)}%, ${100*Dr(this.l)}%${1===t?")":`, ${t})`}`}}));const Nr=Math.PI/180,Cr=180/Math.PI;var Fr=-.14861,Lr=1.78277,Ur=-.29227,Rr=-.90649,Pr=1.97294,Vr=Pr*Rr,$r=Pr*Lr,Yr=Lr*Ur-Rr*Fr;function Wr(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof Gr)return new Gr(t.h,t.s,t.l,t.opacity);t instanceof Ar||(t=wr(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(Yr*r+Vr*e-$r*n)/(Yr+Vr-$r),o=r-i,a=(Pr*(n-i)-Ur*o)/Rr,s=Math.sqrt(a*a+o*o)/(Pr*i*(1-i)),u=s?Math.atan2(a,o)*Cr-120:NaN;return new Gr(u<0?u+360:u,s,i,t.opacity)}(t):new Gr(t,e,n,null==r?1:r)}function Gr(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}tr(Gr,Wr,er(nr,{brighter(t){return t=null==t?ir:Math.pow(ir,t),new Gr(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?rr:Math.pow(rr,t),new Gr(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Nr,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new Ar(255*(e+n*(Fr*r+Lr*i)),255*(e+n*(Ur*r+Rr*i)),255*(e+n*(Pr*r)),this.opacity)}}));const qr=t=>()=>t;function Xr(t,e){return function(n){return t+n*e}}function Hr(t){return 1==(t=+t)?Zr:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):qr(isNaN(e)?n:e)}}function Zr(t,e){var n=e-t;return n?Xr(t,n):qr(isNaN(t)?e:t)}const Jr=function t(e){var n=Hr(e);function r(t,e){var r=n((t=xr(t)).r,(e=xr(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=Zr(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);var Kr,Qr=(Kr=function(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,s=ro&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:ri(n,r)})),o=ai.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:ri(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:ri(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,u),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:ri(t,n)},{i:s-2,x:ri(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var e,n=-1,r=u.length;++n180||n<-180?n-360*Math.round(n/360):n):qr(isNaN(t)?e:t)}));var vi=gi(Zr),wi=Ln("start","end","cancel","interrupt"),xi=[],Ai=0,Si=1,Ii=2,Oi=3,Ti=4,ki=5,Mi=6;function Ei(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=Si,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(o){var c,l,f,h;if(n.state!==Si)return u();for(c in i)if((h=i[c]).name===n.name){if(h.state===Oi)return Cn(a);h.state===Ti?(h.state=Mi,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[c]):+cAi)throw new Error("too late; already scheduled");return n}function ji(t,e){var n=Di(t,e);if(n.state>Oi)throw new Error("too late; already running");return n}function Di(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function zi(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>Ii&&n.state=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?Bi:ji;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}(n,t,e))},attr:function(t,e){var r=n(t),i="transform"===r?mi:Li;return this.attrTween(t,"function"==typeof e?(r.local?Yi:$i)(r,i,Fi(this,"attr."+t,e)):null==e?(r.local?Ri:Ui)(r):(r.local?Vi:Pi)(r,i,e))},attrTween:function(t,e){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;var i=n(t);return this.tween(r,(i.local?Wi:Gi)(i,e))},style:function(t,e,n){var r="transform"==(t+="")?_i:Li;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=z(this,t),a=(this.style.removeProperty(t),z(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}(t,r)).on("end.style."+t,Ki(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var a=z(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=z(this,t)),a===u?null:a===r&&u===i?o:(i=u,o=e(r=a,s))}}(t,r,Fi(this,"style."+t,e))).each(function(t,e){var n,r,i,o,a="style."+e,s="end."+a;return function(){var u=ji(this,t),c=u.on,l=null==u.value[a]?o||(o=Ki(e)):void 0;c===n&&i===l||(r=(n=c).copy()).on(s,i=l),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var a=z(this,t);return a===o?null:a===r?i:i=e(r=a,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Fi(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",(t=this._id,function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}));var t},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=Di(this.node(),n).tween,o=0,a=i.length;o()=>t;function ao(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){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:r,enumerable:!0,configurable:!0},_:{value:i}})}function so(t,e,n){this.k=t,this.x=e,this.y=n}so.prototype={constructor:so,scale:function(t){return 1===t?this:new so(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new so(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 uo=new so(1,0,0);function co(t){t.stopImmediatePropagation()}function lo(t){t.preventDefault(),t.stopImmediatePropagation()}function fo(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function ho(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).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 po(){return this.__zoom||uo}function _o(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function mo(){return navigator.maxTouchPoints||"ontouchstart"in this}function bo(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function yo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function go(t,e){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof e?this.interpolator(e):this.range(e)}return this}so.prototype;const vo=Symbol("implicit");function wo(){var t=new At,e=[],n=[],r=vo;function i(i){let o=t.get(i);if(void 0===o){if(r!==vo)return r;t.set(i,o=e.push(i)-1)}return n[o%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new At;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return wo(e,n).unknown(r)},yo.apply(i,arguments),i}function xo(t){return+t}var Ao=[0,1];function So(t){return t}function Io(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:(n=isNaN(e)?NaN:.5,function(){return n});var n}function Oo(t,e,n){var r=t[0],i=t[1],o=e[0],a=e[1];return ie&&(n=t,t=e,e=n),c=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?To:Oo,i=o=null,f}function f(e){return null==e||isNaN(e=+e)?n:(i||(i=r(a.map(t),s,u)))(t(c(e)))}return f.invert=function(n){return c(e((o||(o=r(s,a.map(t),ri)))(n)))},f.domain=function(t){return arguments.length?(a=Array.from(t,xo),l()):a.slice()},f.range=function(t){return arguments.length?(s=Array.from(t),l()):s.slice()},f.rangeRound=function(t){return s=Array.from(t),u=ci,l()},f.clamp=function(t){return arguments.length?(c=!!t||So,l()):c!==So},f.interpolate=function(t){return arguments.length?(u=t,l()):u},f.unknown=function(t){return arguments.length?(n=t,f):n},function(n,r){return t=n,e=r,l()}}function Eo(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Bo(t){return(t=Eo(Math.abs(t)))?t[1]:NaN}var jo,Do=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zo(t){if(!(e=Do.exec(t)))throw new Error("invalid format: "+t);var e;return new No({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]})}function No(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Co(t,e){var n=Eo(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}zo.prototype=No.prototype,No.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};const Fo={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},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)=>Co(100*t,e),r:Co,s:function(t,e){var n=Eo(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(jo=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Eo(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Lo(t){return t}var Uo,Ro,Po,Vo=Array.prototype.map,$o=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Yo(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Lo:(e=Vo.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,s=e[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(t.substring(i-=s,i+s)),!((u+=s+1)>r));)s=e[a=(a+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Lo:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Vo.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",l=void 0===t.nan?"NaN":t.nan+"";function f(t){var e=(t=zo(t)).fill,n=t.align,f=t.sign,h=t.symbol,d=t.zero,p=t.width,_=t.comma,m=t.precision,b=t.trim,y=t.type;"n"===y?(_=!0,y="g"):Fo[y]||(void 0===m&&(m=12),b=!0,y="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var g="$"===h?i:"#"===h&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",v="$"===h?o:/[%p]/.test(y)?u:"",w=Fo[y],x=/[defgprs%]/.test(y);function A(t){var i,o,u,h=g,A=v;if("c"===y)A=w(t)+A,t="";else{var S=(t=+t)<0||1/t<0;if(t=isNaN(t)?l:w(Math.abs(t),m),b&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),S&&0==+t&&"+"!==f&&(S=!1),h=(S?"("===f?f:c:"-"===f||"("===f?"":f)+h,A=("s"===y?$o[8+jo/3]:"")+A+(S&&"("===f?")":""),x)for(i=-1,o=t.length;++i(u=t.charCodeAt(i))||u>57){A=(46===u?a+t.slice(i+1):t.slice(i))+A,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var I=h.length+t.length+A.length,O=I>1)+h+t+A+O.slice(I);break;default:t=O+h+t+A}return s(t)}return m=void 0===m?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),A.toString=function(){return t+""},A}return{format:f,formatPrefix:function(t,e){var n=f(((t=zo(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Bo(e)/3))),i=Math.pow(10,-r),o=$o[8+r/3];return function(t){return n(i*t)+o}}}}function Wo(t,e,n,r){var i,o=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?Bt(e,t,n):Bt(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=zo(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Bo(e)/3)))-Bo(Math.abs(t)))}(o,a))||(r.precision=i),Po(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Bo(e)-Bo(t))+1}(o,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Bo(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return Ro(r)}function Go(t){var e=t.domain;return t.ticks=function(t){var n=e();return Et(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return Wo(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),a=0,s=o.length-1,u=o[a],c=o[s],l=10;for(c0;){if((i=Bt(u,c,n))===r)return o[a]=u,o[s]=c,e(o);if(i>0)u=Math.floor(u/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;u=Math.ceil(u*i)/i,c=Math.floor(c*i)/i}r=i}return t},t}function qo(){var t=Mo()(So,So);return t.copy=function(){return ko(t,qo())},yo.apply(t,arguments),Go(t)}function Xo(t){return Math.log(t)}function Ho(t){return Math.exp(t)}function Zo(t){return-Math.log(-t)}function Jo(t){return-Math.exp(-t)}function Ko(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Qo(t){return(e,n)=>-t(-e,n)}function ta(t){const e=t(Xo,Ho),n=e.domain;let r,i,o=10;function a(){return r=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}(o),i=function(t){return 10===t?Ko:t===Math.E?Math.exp:e=>Math.pow(t,e)}(o),n()[0]<0?(r=Qo(r),i=Qo(i),t(Zo,Jo)):t(Xo,Ho),e}return e.base=function(t){return arguments.length?(o=+t,a()):o},e.domain=function(t){return arguments.length?(n(t),a()):n()},e.ticks=t=>{const e=n();let a=e[0],s=e[e.length-1];const u=s0){for(;f<=h;++f)for(c=1;cs)break;p.push(l)}}else for(;f<=h;++f)for(c=o-1;c>=1;--c)if(l=f>0?c/i(-f):c*i(f),!(ls)break;p.push(l)}2*p.length{if(null==t&&(t=10),null==n&&(n=10===o?"s":","),"function"!=typeof n&&(o%1||null!=(n=zo(n)).precision||(n.trim=!0),n=Ro(n)),t===1/0)return n;const a=Math.max(1,o*t/e.ticks().length);return t=>{let e=t/i(Math.round(r(t)));return e*on(function(t,e){var n,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return ai(Math.floor(r(t))),ceil:t=>i(Math.ceil(r(t)))})),e}function ea(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function na(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function ra(t){return t<0?-t*t:t*t}function ia(t){var e=t(So,So),n=1;return e.exponent=function(e){return arguments.length?1===(n=+e)?t(So,So):.5===n?t(na,ra):t(ea(n),ea(1/n)):n},Go(e)}function oa(){var t=ia(Mo());return t.copy=function(){return ko(t,oa()).exponent(t.exponent())},yo.apply(t,arguments),t}function aa(){var t,e,n,r,i,o=0,a=1,s=So,u=!1;function c(e){return null==e||isNaN(e=+e)?i:s(0===n?.5:(e=(r(e)-t)*n,u?Math.max(0,Math.min(1,e)):e))}function l(t){return function(e){var n,r;return arguments.length?([n,r]=e,s=t(n,r),c):[s(0),s(1)]}}return c.domain=function(i){return arguments.length?([o,a]=i,t=r(o=+o),e=r(a=+a),n=t===e?0:1/(e-t),c):[o,a]},c.clamp=function(t){return arguments.length?(u=!!t,c):u},c.interpolator=function(t){return arguments.length?(s=t,c):s},c.range=l(ui),c.rangeRound=l(ci),c.unknown=function(t){return arguments.length?(i=t,c):i},function(i){return r=i,t=i(o),e=i(a),n=t===e?0:1/(e-t),c}}function sa(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function ua(){var t=Go(aa()(So));return t.copy=function(){return sa(t,ua())},go.apply(t,arguments)}function ca(){var t=ta(aa()).domain([1,10]);return t.copy=function(){return sa(t,ca()).base(t.base())},go.apply(t,arguments)}function la(){var t=ia(aa());return t.copy=function(){return sa(t,la()).exponent(t.exponent())},go.apply(t,arguments)}Uo=Yo({thousands:",",grouping:[3],currency:["$",""]}),Ro=Uo.format,Po=Uo.formatPrefix;class fa{constructor(t,e,n){this.prefs=e,this.svg_element_selection=ht(t),this.width=+this.svg_element_selection.attr("width"),this.height=+this.svg_element_selection.attr("height"),this.renderers=new Map,this.scatterplot=n,this.renderers=new Map}attach_tiles(t){return this.tileSet=t,this.tileSet._zoom=this,this}attach_renderer(t,e){return this.renderers.set(t,e),e.bind_zoom(this),e.zoom.initialize_zoom(),this}zoom_to(t,e,n,r=4e3){const i=this.scales(),{svg_element_selection:o,zoomer:a,width:s,height:u}=this,c=uo.translate(s/2,u/2).scale(t).translate(-i.x(e),-i.y(n));o.transition().duration(r).call(a.transform,c)}html_annotation(t){const e=this.svg_element_selection.node().parentNode.parentNode;let n=.75;void 0!==this.scatterplot.prefs.tooltip_opacity&&(n=this.scatterplot.prefs.tooltip_opacity);ht(e).selectAll("div.tooltip").data(t).join((t=>t.append("div").attr("class","tooltip").style("top",0).style("left",0).style("position","absolute").style("z-index",100).style("border-radius","8px").style("padding","10px").style("background","ivory").style("opacity",n)),(t=>t.html((t=>this.scatterplot.tooltip_html(t.data,this.scatterplot)))),(t=>t.call((t=>t.remove())))).html((t=>this.scatterplot.tooltip_html(t.data,this))).style("transform",(t=>`translate(${+t.x+t.dx}px, ${+t.y+t.dy}px)`))}zoom_to_bbox(t,e=4e3,n=1.111){const r=this.scales();let[i,o]=t.x.map(r.x);const[a,s]=t.y.map(r.y);if("right"===this.scatterplot.prefs.zoom_align){const t=this.width/this.height,e=(o-i)/(s-a);if(e_}a.event(t).zoom("mouse",o(g(a.that.__zoom,a.mouse[0]=dt(t,i),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(t){s.on("mousemove.zoom mouseup.zoom",null),qn(t.view,a.moved),lo(t),a.event(t).end()}),!0),u=dt(t,i),l=t.clientX,f=t.clientY;Gn(t.view),co(t),a.mouse=[u,this.__zoom.invert(u)],zi(this),a.start()}}function O(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=dt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),f=o(g(y(n,u),a,s),i.apply(this,e),c);lo(t),l>0?ht(this).transition().duration(l).call(w,f,a,t):ht(this).call(b.transform,f,a,t)}}function T(n,...i){if(r.apply(this,arguments)){var o,a,s,u,c=n.touches,l=c.length,f=x(this,i,n.changedTouches.length===l).event(n);for(co(n),a=0;a{var e,n,r;try{document.getElementById("tooltipcircle").remove()}catch(i){}this.transform=t.transform,this.restart_timer(1e4),null==(n=(e=this.scatterplot).on_zoom)||n.call(e,t.transform),null==(r=null==t?void 0:t.sourceEvent)||r.stopPropagation()}));n.call(r),this.add_mouseover(),this.zoomer=r}set_highlit_points(t){const{x_:e,y_:n}=this.scales(),r=this.scatterplot.dim("x"),i=this.scatterplot.dim("y");this.scatterplot.highlit_point_change(t);const o=t.map((t=>({x:e(r.apply(t)),y:n(i.apply(t)),data:t,dx:0,dy:30})));this.html_annotation(o);this.svg_element_selection.select("#mousepoints").selectAll("circle.label").data(t,(t=>t.ix)).join((t=>t.append("circle").attr("id","tooltipcircle").attr("class","label").attr("stroke","#110022").attr("r",12).attr("fill",(t=>this.scatterplot.dim("color").apply(t))).attr("cx",(t=>e(r.apply(t)))).attr("cy",(t=>n(i.apply(t))))),(t=>t.attr("fill",(t=>this.scatterplot.dim("color").apply(t)))),(t=>t.call((t=>{t.remove()})))).on("click",((t,e)=>{this.scatterplot.click_function(e,this.scatterplot)}))}set_highlit_point(t){this.set_highlit_points([t])}add_mouseover(){let t=0;const e=this.renderers.get("regl");this.svg_element_selection.on("mousemove",(n=>{if(Date.now()-t<75)return;t=Date.now();const r=e.color_pick(n.offsetX,n.offsetY);null===r?this.set_highlit_points([]):this.set_highlit_points([r])}))}current_corners(){const{width:t,height:e}=this,n=this.scales();if(void 0===n)return;const{x_:r,y_:i}=n;return{x:[r.invert(0),r.invert(t)],y:[i.invert(0),i.invert(e)]}}current_center(){const{x:t,y:e}=this.current_corners();return[(t[0]+t[1])/2,(e[0]+e[1])/2]}restart_timer(t=1e4){let e=Date.now()+t;this._timer&&(this._timer.stop_at>e&&(e=this._timer.stop_at),this._timer.stop());const n=jn(this.tick.bind(this));return this._timer=n,this._timer.stop_at=e,this._timer}data(t){return void 0===t?this.tileSet:(this.tileSet=t,this)}scales(t=!0){if(this._scales)return this._scales.x_=this.transform.rescaleX(this._scales.x),this._scales.y_=this.transform.rescaleY(this._scales.y),this._scales;const{width:e,height:n}=this;if(void 0===this.tileSet)throw new Error("Error--scales created before tileSet present.");const{extent:r}=this.tileSet,i={};if(void 0===r)throw new Error("Error--scales created before extent present.");const o={};for(const[f,h]of[["x",e],["y",n]]){const t=r[f],e=t[1]-t[0];o[f]={limits:t,size_range:e,pixels_per_unit:h/e}}const a=o.x.pixels_per_unit/o.y.pixels_per_unit;let s=0,u=0,c=e,l=n;return a>1?(c=e/a,s=(e-c)/2):(l=n*a,u=(n-l)/2),i.x=qo().domain(o.x.limits).range([s,e-s]),i.y=qo().domain(o.y.limits).range([u,n-u]),i.x_=this.transform.rescaleX(i.x),i.y_=this.transform.rescaleY(i.y),this._scales=i,i}webgl_scale(t=!0){const{x:e,y:n}=this.scales();return function(t,e){function n(t){return t[1]-t[0]}const r=zt(t.domain()),i=zt(e.domain()),o=n(t.range())/n(t.domain()),a=n(e.range())/n(e.domain());return[[o,0,-o*r+zt(t.range())],[0,a,-a*i+zt(e.range())],[0,0,1]]}(e,n).flat()}tick(t=!1){this._start=this._start||Date.now(),!0!==t&&this._timer&&this._timer.stop_at<=Date.now()&&this._timer.stop()}}var ha={};({get exports(){return ha},set exports(t){ha=t}}).exports=function(){var t=function(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array||t instanceof Uint8ClampedArray},e=function(t,e){for(var n=Object.keys(e),r=0;r=0&&(0|t)===t||i("invalid parameter type, ("+t+")"+a(e)+". must be a nonnegative integer")}function h(t,e,n){e.indexOf(t)<0&&i("invalid value"+a(n)+". must be one of: "+e)}var d=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(t){Object.keys(t).forEach((function(t){d.indexOf(t)<0&&i('invalid regl constructor argument "'+t+'". must be one of '+d)}))}function _(t,e){for(t+="";t.length0&&e.push(new y("unknown",0,t))}})),e}function A(t,e){e.forEach((function(e){var n=t[e.file];if(n){var r=n.index[e.line];if(r)return r.errors.push(e),void(n.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(e)}))}function S(t,e,r,i,a){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var s=t.getShaderInfoLog(e),u=i===t.FRAGMENT_SHADER?"fragment":"vertex";B(r,"string",u+" shader source must be a string",a);var c=w(r,a),l=x(s);A(c,l),Object.keys(c).forEach((function(t){var e=c[t];if(e.hasErrors){var r=[""],i=[""];o("file number "+t+": "+e.name+"\n","color:red;text-decoration:underline;font-weight:bold"),e.lines.forEach((function(t){if(t.errors.length>0){o(_(t.number,4)+"| ","background-color:yellow; font-weight:bold"),o(t.line+n,"color:red; background-color:yellow; font-weight:bold");var e=0;t.errors.forEach((function(r){var i=r.message,a=/^\s*'(.*)'\s*:\s*(.*)$/.exec(i);if(a){var s=a[1];i=a[2],"assign"===s&&(s="="),e=Math.max(t.line.indexOf(s,e),0)}else e=0;o(_("| ",6)),o(_("^^^",e+3)+n,"font-weight:bold"),o(_("| ",6)),o(i+n,"font-weight:bold")})),o(_("| ",6)+n)}else o(_(t.number,4)+"| "),o(t.line+n,"color:red")})),"undefined"==typeof document||window.chrome?console.log(r.join("")):(i[0]=r.join("%c"),console.log.apply(console,i))}function o(t,e){r.push(t),i.push(e||"")}})),o.raise("Error compiling "+u+" shader, "+c[0].name)}}function I(t,e,r,i,a){if(!t.getProgramParameter(e,t.LINK_STATUS)){var s=t.getProgramInfoLog(e),u=w(r,a),c='Error linking program with vertex shader, "'+w(i,a)[0].name+'", and fragment shader "'+u[0].name+'"';"undefined"!=typeof document?console.log("%c"+c+n+"%c"+s,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(c+n+s),o.raise(c)}}function O(t){t._commandRef=g()}function T(t,e,n,r){function i(t){return t?r.id(t):0}function o(t,e){Object.keys(e).forEach((function(e){t[r.id(e)]=!0}))}O(t),t._fragId=i(t.static.frag),t._vertId=i(t.static.vert);var a=t._uniformSet={};o(a,e.static),o(a,e.dynamic);var s=t._attributeSet={};o(s,n.static),o(s,n.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic}function k(t,e){var n=v();i(t+" in command "+(e||g())+("unknown"===n?"":" called from "+n))}function M(t,e,n){t||k(e,n||g())}function E(t,e,n,r){t in e||k("unknown parameter ("+t+")"+a(n)+". possible values: "+Object.keys(e).join(),r||g())}function B(t,e,n,r){c(t,e)||k("invalid parameter type"+a(n)+". expected "+e+", got "+typeof t,r||g())}function j(t){t()}function D(t,e,n){t.texture?h(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):h(t.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}var z=33071,N=9728,C=9984,F=9985,L=9986,U=9987,R=5121,P=5122,V=5123,$=5124,Y=5125,W=5126,G=32819,q=32820,X=33635,H=34042,Z=36193,J={};function K(t,e){return t===q||t===G||t===X?2:t===H?4:J[t]*e}function Q(t){return!(t&t-1||!t)}function tt(t,e,n){var r,i=e.width,a=e.height,s=e.channels;o(i>0&&i<=n.maxTextureSize&&a>0&&a<=n.maxTextureSize,"invalid texture shape"),t.wrapS===z&&t.wrapT===z||o(Q(i)&&Q(a),"incompatible wrap mode for texture, both width and height must be power of 2"),1===e.mipmask?1!==i&&1!==a&&o(t.minFilter!==C&&t.minFilter!==L&&t.minFilter!==F&&t.minFilter!==U,"min filter requires mipmap"):(o(Q(i)&&Q(a),"texture must be a square power of 2 to support mipmapping"),o(e.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),e.type===W&&(n.extensions.indexOf("oes_texture_float_linear")<0&&o(t.minFilter===N&&t.magFilter===N,"filter not supported, must enable oes_texture_float_linear"),o(!t.genMipmaps,"mipmap generation not supported with float textures"));var u=e.images;for(r=0;r<16;++r)if(u[r]){var c=i>>r,l=a>>r;o(e.mipmask&1<0&&i<=r.maxTextureSize&&a>0&&a<=r.maxTextureSize,"invalid texture shape"),o(i===a,"cube map must be square"),o(e.wrapS===z&&e.wrapT===z,"wrap mode not supported by cube map");for(var u=0;u>f,p=a>>f;o(c.mipmask&1<1&&e===n&&('"'===e||"'"===e))return['"'+ut(t.substr(1,t.length-2))+'"'];var r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(r)return ct(t.substr(0,r.index)).concat(ct(r[1])).concat(ct(t.substr(r.index+r[0].length)));var i=t.split(".");if(1===i.length)return['"'+ut(t)+'"'];for(var o=[],a=0;a0,"invalid pixel ratio"))):nt.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?r=e:n=e),!i){if(!r){nt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var d=yt(n||document.body,f,c);if(!d)return null;r=d.canvas,h=d.onDestroy}void 0===a.premultipliedAlpha&&(a.premultipliedAlpha=!0),i=gt(r,a)}return i?{gl:i,canvas:r,container:n,extensions:s,optionalExtensions:u,pixelRatio:c,profile:l,onDone:f,onDestroy:h}:(h(),f("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function It(t,e){var n={};function r(e){nt.type(e,"string","extension name must be string");var r,i=e.toLowerCase();try{r=n[i]=t.getExtension(i)}catch(o){}return!!r}for(var i=0;i65535)<<4,e|=n=((t>>>=e)>255)<<3,e|=n=((t>>>=n)>15)<<2,(e|=n=((t>>>=n)>3)<<1)|(t>>>=n)>>1}function Ct(){var t=Ot(8,(function(){return[]}));function e(e){var n=zt(e),r=t[Nt(n)>>2];return r.length>0?r.pop():new ArrayBuffer(n)}function n(e){t[Nt(e.byteLength)>>2].push(e)}function r(t,n){var r=null;switch(t){case Tt:r=new Int8Array(e(n),0,n);break;case kt:r=new Uint8Array(e(n),0,n);break;case Mt:r=new Int16Array(e(2*n),0,n);break;case Et:r=new Uint16Array(e(2*n),0,n);break;case Bt:r=new Int32Array(e(4*n),0,n);break;case jt:r=new Uint32Array(e(4*n),0,n);break;case Dt:r=new Float32Array(e(4*n),0,n);break;default:return null}return r.length!==n?r.subarray(0,n):r}function i(t){n(t.buffer)}return{alloc:e,free:n,allocType:r,freeType:i}}var Ft=Ct();Ft.zero=Ct();var Lt=3408,Ut=3410,Rt=3411,Pt=3412,Vt=3413,$t=3414,Yt=3415,Wt=33901,Gt=33902,qt=3379,Xt=3386,Ht=34921,Zt=36347,Jt=36348,Kt=35661,Qt=35660,te=34930,ee=36349,ne=34076,re=34024,ie=7936,oe=7937,ae=7938,se=35724,ue=34047,ce=36063,le=34852,fe=3553,he=34067,de=34069,pe=33984,_e=6408,me=5126,be=5121,ye=36160,ge=36053,ve=36064,we=16384,xe=function(t,e){var n=1;e.ext_texture_filter_anisotropic&&(n=t.getParameter(ue));var r=1,i=1;e.webgl_draw_buffers&&(r=t.getParameter(le),i=t.getParameter(ce));var o=!!e.oes_texture_float;if(o){var a=t.createTexture();t.bindTexture(fe,a),t.texImage2D(fe,0,_e,1,1,0,_e,me,null);var s=t.createFramebuffer();if(t.bindFramebuffer(ye,s),t.framebufferTexture2D(ye,ve,fe,a,0),t.bindTexture(fe,null),t.checkFramebufferStatus(ye)!==ge)o=!1;else{t.viewport(0,0,1,1),t.clearColor(1,0,0,1),t.clear(we);var u=Ft.allocType(me,4);t.readPixels(0,0,1,1,_e,me,u),t.getError()?o=!1:(t.deleteFramebuffer(s),t.deleteTexture(a),o=1===u[0]),Ft.freeType(u)}}var c=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var l=t.createTexture(),f=Ft.allocType(be,36);t.activeTexture(pe),t.bindTexture(he,l),t.texImage2D(de,0,_e,3,3,0,_e,be,f),Ft.freeType(f),t.bindTexture(he,null),t.deleteTexture(l),c=!t.getError()}return{colorBits:[t.getParameter(Ut),t.getParameter(Rt),t.getParameter(Pt),t.getParameter(Vt)],depthBits:t.getParameter($t),stencilBits:t.getParameter(Yt),subpixelBits:t.getParameter(Lt),extensions:Object.keys(e).filter((function(t){return!!e[t]})),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:t.getParameter(Wt),lineWidthDims:t.getParameter(Gt),maxViewportDims:t.getParameter(Xt),maxCombinedTextureUnits:t.getParameter(Kt),maxCubeMapSize:t.getParameter(ne),maxRenderbufferSize:t.getParameter(re),maxTextureUnits:t.getParameter(te),maxTextureSize:t.getParameter(qt),maxAttributes:t.getParameter(Ht),maxVertexUniforms:t.getParameter(Zt),maxVertexTextureUnits:t.getParameter(Qt),maxVaryingVectors:t.getParameter(Jt),maxFragmentUniforms:t.getParameter(ee),glsl:t.getParameter(se),renderer:t.getParameter(oe),vendor:t.getParameter(ie),version:t.getParameter(ae),readFloat:o,npotTextureCube:c}};function Ae(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||t(e.data))}var Se=function(t){return Object.keys(t).map((function(e){return t[e]}))},Ie={shape:Be,flatten:Ee};function Oe(t,e,n){for(var r=0;r0)if(Array.isArray(n[0])){s=Ce(n);for(var c=1,l=1;l0)if("number"==typeof e[0]){var o=Ft.allocType(l.dtype,e.length);$e(o,e),p(o,i),Ft.freeType(o)}else if(Array.isArray(e[0])||t(e[0])){r=Ce(e);var a=Ne(e,r,l.dtype);p(a,i),Ft.freeType(a)}else nt.raise("invalid buffer data")}else if(Ae(e)){r=e.shape;var s=e.stride,u=0,c=0,h=0,d=0;1===r.length?(u=r[0],c=1,h=s[0],d=0):2===r.length?(u=r[0],c=r[1],h=s[0],d=s[1]):nt.raise("invalid shape");var _=Array.isArray(e.data)?l.dtype:Ve(e.data),m=Ft.allocType(_,u*c);Ye(m,e.data,u,c,h,d,e.offset),p(m,i),Ft.freeType(m)}else nt.raise("invalid data for buffer subdata");return f}return a[l.id]=l,u||f(i),f._reglType="buffer",f._buffer=l,f.subdata=_,r.profile&&(f.stats=l.stats),f.destroy=function(){d(l)},f}function _(){Se(a).forEach((function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)}))}return r.profile&&(n.getTotalBufferSize=function(){var t=0;return Object.keys(a).forEach((function(e){t+=a[e].stats.size})),t}),{create:p,createStream:c,destroyStream:l,clear:function(){Se(a).forEach(d),u.forEach(d)},getBuffer:function(t){return t&&t._buffer instanceof s?t._buffer:null},restore:_,_initBuffer:h}}Pe[5120]=1,Pe[5122]=2,Pe[5124]=4,Pe[5121]=1,Pe[5123]=2,Pe[5125]=4,Pe[5126]=4;var Ge={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},qe=0,Xe=1,He=4,Ze=5120,Je=5121,Ke=5122,Qe=5123,tn=5124,en=5125,nn=34963,rn=35040,on=35044;function an(e,n,r,i){var o={},a=0,s={uint8:Je,uint16:Qe};function u(t){this.id=a++,o[this.id]=this,this.buffer=t,this.primType=He,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(s.uint32=en),u.prototype.bind=function(){this.buffer.bind()};var c=[];function l(t){var e=c.pop();return e||(e=new u(r.create(null,nn,!0,!1)._buffer)),h(e,t,rn,-1,-1,0,0),e}function f(t){c.push(t)}function h(i,o,a,s,u,c,l){var f;if(i.buffer.bind(),o){var h=l;l||t(o)&&(!Ae(o)||t(o.data))||(h=n.oes_element_index_uint?en:Qe),r._initBuffer(i.buffer,o,a,h,3)}else e.bufferData(nn,c,a),i.buffer.dtype=f||Je,i.buffer.usage=a,i.buffer.dimension=3,i.buffer.byteLength=c;if(f=l,!l){switch(i.buffer.dtype){case Je:case Ze:f=Je;break;case Qe:case Ke:f=Qe;break;case en:case tn:f=en;break;default:nt.raise("unsupported type for element array")}i.buffer.dtype=f}i.type=f,nt(f!==en||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=u;d<0&&(d=i.buffer.byteLength,f===Qe?d>>=1:f===en&&(d>>=2)),i.vertCount=d;var p=s;if(s<0){p=He;var _=i.buffer.dimension;1===_&&(p=qe),2===_&&(p=Xe),3===_&&(p=He)}i.primType=p}function d(t){i.elementsCount--,nt(null!==t.buffer,"must not double destroy elements"),delete o[t.id],t.buffer.destroy(),t.buffer=null}function p(e,n){var o=r.create(null,nn,!0),a=new u(o._buffer);function c(e){if(e)if("number"==typeof e)o(e),a.primType=He,a.vertCount=0|e,a.type=Je;else{var n=null,r=on,i=-1,u=-1,l=0,f=0;Array.isArray(e)||t(e)||Ae(e)?n=e:(nt.type(e,"object","invalid arguments for elements"),"data"in e&&(n=e.data,nt(Array.isArray(n)||t(n)||Ae(n),"invalid data for element buffer")),"usage"in e&&(nt.parameter(e.usage,ze,"invalid element buffer usage"),r=ze[e.usage]),"primitive"in e&&(nt.parameter(e.primitive,Ge,"invalid element buffer primitive"),i=Ge[e.primitive]),"count"in e&&(nt("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),u=0|e.count),"type"in e&&(nt.parameter(e.type,s,"invalid buffer type"),f=s[e.type]),"length"in e?l=0|e.length:(l=u,f===Qe||f===Ke?l*=2:f!==en&&f!==tn||(l*=4))),h(a,n,r,i,u,l,f)}else o(),a.primType=He,a.vertCount=0,a.type=Je;return c}return i.elementsCount++,c(e),c._reglType="elements",c._elements=a,c.subdata=function(t,e){return o.subdata(t,e),c},c.destroy=function(){d(a)},c}return{create:p,createStream:l,destroyStream:f,getElements:function(t){return"function"==typeof t&&t._elements instanceof u?t._elements:null},clear:function(){Se(o).forEach(d)}}}var sn=new Float32Array(1),un=new Uint32Array(sn.buffer),cn=5123;function ln(t){for(var e=Ft.allocType(cn,t.length),n=0;n>>31<<15,o=(r<<1>>>24)-127,a=r>>13&1023;if(o<-24)e[n]=i;else if(o<-14){var s=-14-o;e[n]=i+(a+1024>>s)}else e[n]=o>15?i+31744:i+(o+15<<10)+a}return e}function fn(e){return Array.isArray(e)||t(e)}var hn=function(t){return!(t&t-1||!t)},dn=34467,pn=3553,_n=34067,mn=34069,bn=6408,yn=6406,gn=6407,vn=6409,wn=6410,xn=32854,An=32855,Sn=36194,In=32819,On=32820,Tn=33635,kn=34042,Mn=6402,En=34041,Bn=35904,jn=35906,Dn=36193,zn=33776,Nn=33777,Cn=33778,Fn=33779,Ln=35986,Un=35987,Rn=34798,Pn=35840,Vn=35841,$n=35842,Yn=35843,Wn=36196,Gn=5121,qn=5123,Xn=5125,Hn=5126,Zn=10242,Jn=10243,Kn=10497,Qn=33071,tr=33648,er=10240,nr=10241,rr=9728,ir=9729,or=9984,ar=9985,sr=9986,ur=9987,cr=33170,lr=4352,fr=4353,hr=4354,dr=34046,pr=3317,_r=37440,mr=37441,br=37443,yr=37444,gr=33984,vr=[or,sr,ar,ur],wr=[0,vn,wn,gn,bn],xr={};function Ar(t){return"[object "+t+"]"}xr[vn]=xr[yn]=xr[Mn]=1,xr[En]=xr[wn]=2,xr[gn]=xr[Bn]=3,xr[bn]=xr[jn]=4;var Sr=Ar("HTMLCanvasElement"),Ir=Ar("OffscreenCanvas"),Or=Ar("CanvasRenderingContext2D"),Tr=Ar("ImageBitmap"),kr=Ar("HTMLImageElement"),Mr=Ar("HTMLVideoElement"),Er=Object.keys(je).concat([Sr,Ir,Or,Tr,kr,Mr]),Br=[];Br[Gn]=1,Br[Hn]=4,Br[Dn]=2,Br[qn]=2,Br[Xn]=4;var jr=[];function Dr(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function zr(t){return!!Array.isArray(t)&&!(0===t.length||!fn(t[0]))}function Nr(t){return Object.prototype.toString.call(t)}function Cr(t){return Nr(t)===Sr}function Fr(t){return Nr(t)===Ir}function Lr(t){return Nr(t)===Or}function Ur(t){return Nr(t)===Tr}function Rr(t){return Nr(t)===kr}function Pr(t){return Nr(t)===Mr}function Vr(t){if(!t)return!1;var e=Nr(t);return Er.indexOf(e)>=0||Dr(t)||zr(t)||Ae(t)}function $r(t){return 0|je[Object.prototype.toString.call(t)]}function Yr(t,e){var n=e.length;switch(t.type){case Gn:case qn:case Xn:case Hn:var r=Ft.allocType(t.type,n);r.set(e),t.data=r;break;case Dn:t.data=ln(e);break;default:nt.raise("unsupported texture type, must specify a typed array")}}function Wr(t,e){return Ft.allocType(t.type===Dn?Hn:t.type,e)}function Gr(t,e){t.type===Dn?(t.data=ln(e),Ft.freeType(e)):t.data=e}function qr(t,e,n,r,i,o){for(var a=t.width,s=t.height,u=t.channels,c=Wr(t,a*s*u),l=0,f=0;f=1;)s+=a*u*u,u/=2;return s}return a*n*r}function Hr(n,r,i,o,a,s,u){var c={"don't care":lr,"dont care":lr,nice:hr,fast:fr},l={repeat:Kn,clamp:Qn,mirror:tr},f={nearest:rr,linear:ir},h=e({mipmap:ur,"nearest mipmap nearest":or,"linear mipmap nearest":ar,"nearest mipmap linear":sr,"linear mipmap linear":ur},f),d={none:0,browser:yr},p={uint8:Gn,rgba4:In,rgb565:Tn,"rgb5 a1":On},_={alpha:yn,luminance:vn,"luminance alpha":wn,rgb:gn,rgba:bn,rgba4:xn,"rgb5 a1":An,rgb565:Sn},m={};r.ext_srgb&&(_.srgb=Bn,_.srgba=jn),r.oes_texture_float&&(p.float32=p.float=Hn),r.oes_texture_half_float&&(p.float16=p["half float"]=Dn),r.webgl_depth_texture&&(e(_,{depth:Mn,"depth stencil":En}),e(p,{uint16:qn,uint32:Xn,"depth stencil":kn})),r.webgl_compressed_texture_s3tc&&e(m,{"rgb s3tc dxt1":zn,"rgba s3tc dxt1":Nn,"rgba s3tc dxt3":Cn,"rgba s3tc dxt5":Fn}),r.webgl_compressed_texture_atc&&e(m,{"rgb atc":Ln,"rgba atc explicit alpha":Un,"rgba atc interpolated alpha":Rn}),r.webgl_compressed_texture_pvrtc&&e(m,{"rgb pvrtc 4bppv1":Pn,"rgb pvrtc 2bppv1":Vn,"rgba pvrtc 4bppv1":$n,"rgba pvrtc 2bppv1":Yn}),r.webgl_compressed_texture_etc1&&(m["rgb etc1"]=Wn);var b=Array.prototype.slice.call(n.getParameter(dn));Object.keys(m).forEach((function(t){var e=m[t];b.indexOf(e)>=0&&(_[t]=e)}));var y=Object.keys(_);i.textureFormats=y;var g=[];Object.keys(_).forEach((function(t){var e=_[t];g[e]=t}));var v=[];Object.keys(p).forEach((function(t){var e=p[t];v[e]=t}));var w=[];Object.keys(f).forEach((function(t){var e=f[t];w[e]=t}));var x=[];Object.keys(h).forEach((function(t){var e=h[t];x[e]=t}));var A=[];Object.keys(l).forEach((function(t){var e=l[t];A[e]=t}));var S=y.reduce((function(t,e){var n=_[e];return n===vn||n===yn||n===vn||n===wn||n===Mn||n===En||r.ext_srgb&&(n===Bn||n===jn)?t[n]=n:n===An||e.indexOf("rgba")>=0?t[n]=bn:t[n]=gn,t}),{});function I(){this.internalformat=bn,this.format=bn,this.type=Gn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=yr,this.width=0,this.height=0,this.channels=0}function O(t,e){t.internalformat=e.internalformat,t.format=e.format,t.type=e.type,t.compressed=e.compressed,t.premultiplyAlpha=e.premultiplyAlpha,t.flipY=e.flipY,t.unpackAlignment=e.unpackAlignment,t.colorSpace=e.colorSpace,t.width=e.width,t.height=e.height,t.channels=e.channels}function T(t,e){if("object"==typeof e&&e){if("premultiplyAlpha"in e&&(nt.type(e.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),t.premultiplyAlpha=e.premultiplyAlpha),"flipY"in e&&(nt.type(e.flipY,"boolean","invalid texture flip"),t.flipY=e.flipY),"alignment"in e&&(nt.oneOf(e.alignment,[1,2,4,8],"invalid texture unpack alignment"),t.unpackAlignment=e.alignment),"colorSpace"in e&&(nt.parameter(e.colorSpace,d,"invalid colorSpace"),t.colorSpace=d[e.colorSpace]),"type"in e){var n=e.type;nt(r.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),nt(r.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."),nt(r.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."),nt.parameter(n,p,"invalid texture type"),t.type=p[n]}var o=t.width,a=t.height,s=t.channels,u=!1;"shape"in e?(nt(Array.isArray(e.shape)&&e.shape.length>=2,"shape must be an array"),o=e.shape[0],a=e.shape[1],3===e.shape.length&&(s=e.shape[2],nt(s>0&&s<=4,"invalid number of channels"),u=!0),nt(o>=0&&o<=i.maxTextureSize,"invalid width"),nt(a>=0&&a<=i.maxTextureSize,"invalid height")):("radius"in e&&(o=a=e.radius,nt(o>=0&&o<=i.maxTextureSize,"invalid radius")),"width"in e&&(o=e.width,nt(o>=0&&o<=i.maxTextureSize,"invalid width")),"height"in e&&(a=e.height,nt(a>=0&&a<=i.maxTextureSize,"invalid height")),"channels"in e&&(s=e.channels,nt(s>0&&s<=4,"invalid number of channels"),u=!0)),t.width=0|o,t.height=0|a,t.channels=0|s;var c=!1;if("format"in e){var l=e.format;nt(r.webgl_depth_texture||!("depth"===l||"depth stencil"===l),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(l,_,"invalid texture format");var f=t.internalformat=_[l];t.format=S[f],l in p&&("type"in e||(t.type=p[l])),l in m&&(t.compressed=!0),c=!0}!u&&c?t.channels=xr[t.format]:u&&!c?t.channels!==wr[t.format]&&(t.format=t.internalformat=wr[t.channels]):c&&u&&nt(t.channels===xr[t.format],"number of channels inconsistent with specified format")}}function k(t){n.pixelStorei(_r,t.flipY),n.pixelStorei(mr,t.premultiplyAlpha),n.pixelStorei(br,t.colorSpace),n.pixelStorei(pr,t.unpackAlignment)}function M(){I.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function E(e,n){var r=null;if(Vr(n)?r=n:n&&(nt.type(n,"object","invalid pixel data type"),T(e,n),"x"in n&&(e.xOffset=0|n.x),"y"in n&&(e.yOffset=0|n.y),Vr(n.data)&&(r=n.data)),nt(!e.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){nt(!r,"can not specify copy and data field for the same texture");var o=a.viewportWidth,s=a.viewportHeight;e.width=e.width||o-e.xOffset,e.height=e.height||s-e.yOffset,e.needsCopy=!0,nt(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=o&&e.height>0&&e.height<=s,"copy texture read out of bounds")}else if(r){if(t(r))e.channels=e.channels||4,e.data=r,"type"in n||e.type!==Gn||(e.type=$r(r));else if(Dr(r))e.channels=e.channels||4,Yr(e,r),e.alignment=1,e.needsFree=!0;else if(Ae(r)){var u=r.data;Array.isArray(u)||e.type!==Gn||(e.type=$r(u));var c,l,f,h,d,p,_=r.shape,m=r.stride;3===_.length?(f=_[2],p=m[2]):(nt(2===_.length,"invalid ndarray pixel data, must be 2 or 3D"),f=1,p=1),c=_[0],l=_[1],h=m[0],d=m[1],e.alignment=1,e.width=c,e.height=l,e.channels=f,e.format=e.internalformat=wr[f],e.needsFree=!0,qr(e,u,h,d,p,r.offset)}else if(Cr(r)||Fr(r)||Lr(r))Cr(r)||Fr(r)?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(Ur(r))e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(Rr(r))e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(Pr(r))e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(zr(r)){var b=e.width||r[0].length,y=e.height||r.length,g=e.channels;g=fn(r[0][0])?g||r[0][0].length:g||1;for(var v=Ie.shape(r),w=1,x=0;x=0,"oes_texture_float extension not enabled"):e.type===Dn&&nt(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function B(t,e,r){var i=t.element,a=t.data,s=t.internalformat,u=t.format,c=t.type,l=t.width,f=t.height;k(t),i?n.texImage2D(e,r,u,u,c,i):t.compressed?n.compressedTexImage2D(e,r,s,l,f,0,a):t.needsCopy?(o(),n.copyTexImage2D(e,r,u,t.xOffset,t.yOffset,l,f,0)):n.texImage2D(e,r,u,l,f,0,u,c,a||null)}function j(t,e,r,i,a){var s=t.element,u=t.data,c=t.internalformat,l=t.format,f=t.type,h=t.width,d=t.height;k(t),s?n.texSubImage2D(e,a,r,i,l,f,s):t.compressed?n.compressedTexSubImage2D(e,a,r,i,c,h,d,u):t.needsCopy?(o(),n.copyTexSubImage2D(e,a,r,i,t.xOffset,t.yOffset,h,d)):n.texSubImage2D(e,a,r,i,h,d,l,f,u)}var D=[];function z(){return D.pop()||new M}function N(t){t.needsFree&&Ft.freeType(t.data),M.call(t),D.push(t)}function C(){I.call(this),this.genMipmaps=!1,this.mipmapHint=lr,this.mipmask=0,this.images=Array(16)}function F(t,e,n){var r=t.images[0]=z();t.mipmask=1,r.width=t.width=e,r.height=t.height=n,r.channels=t.channels=4}function L(t,e){var n=null;if(Vr(e))O(n=t.images[0]=z(),t),E(n,e),t.mipmask=1;else if(T(t,e),Array.isArray(e.mipmap))for(var r=e.mipmap,i=0;i>=i,n.height>>=i,E(n,r[i]),t.mipmask|=1<=0&&!("faces"in e)&&(t.genMipmaps=!0)}if("mag"in e){var r=e.mag;nt.parameter(r,f),t.magFilter=f[r]}var o=t.wrapS,a=t.wrapT;if("wrap"in e){var s=e.wrap;"string"==typeof s?(nt.parameter(s,l),o=a=l[s]):Array.isArray(s)&&(nt.parameter(s[0],l),nt.parameter(s[1],l),o=l[s[0]],a=l[s[1]])}else{if("wrapS"in e){var u=e.wrapS;nt.parameter(u,l),o=l[u]}if("wrapT"in e){var d=e.wrapT;nt.parameter(d,l),a=l[d]}}if(t.wrapS=o,t.wrapT=a,"anisotropic"in e){var p=e.anisotropic;nt("number"==typeof p&&p>=1&&p<=i.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=e.anisotropic}if("mipmap"in e){var _=!1;switch(typeof e.mipmap){case"string":nt.parameter(e.mipmap,c,"invalid mipmap hint"),t.mipmapHint=c[e.mipmap],t.genMipmaps=!0,_=!0;break;case"boolean":_=t.genMipmaps=e.mipmap;break;case"object":nt(Array.isArray(e.mipmap),"invalid mipmap type"),t.genMipmaps=!1,_=!0;break;default:nt.raise("invalid mipmap type")}_&&!("min"in e)&&(t.minFilter=or)}}function W(t,e){n.texParameteri(e,nr,t.minFilter),n.texParameteri(e,er,t.magFilter),n.texParameteri(e,Zn,t.wrapS),n.texParameteri(e,Jn,t.wrapT),r.ext_texture_filter_anisotropic&&n.texParameteri(e,dr,t.anisotropic),t.genMipmaps&&(n.hint(cr,t.mipmapHint),n.generateMipmap(e))}var G=0,q={},X=i.maxTextureUnits,H=Array(X).map((function(){return null}));function Z(t){I.call(this),this.mipmask=0,this.internalformat=bn,this.id=G++,this.refCount=1,this.target=t,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new $,u.profile&&(this.stats={size:0})}function J(t){n.activeTexture(gr),n.bindTexture(t.target,t.texture)}function K(){var t=H[0];t?n.bindTexture(t.target,t.texture):n.bindTexture(pn,null)}function Q(t){var e=t.texture;nt(e,"must not double destroy texture");var r=t.unit,i=t.target;r>=0&&(n.activeTexture(gr+r),n.bindTexture(i,null),H[r]=null),n.deleteTexture(e),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete q[t.id],s.textureCount--}function tt(t,e){var r=new Z(pn);function o(t,e){var n=r.texInfo;$.call(n);var a=P();return"number"==typeof t?F(a,0|t,"number"==typeof e?0|e:0|t):t?(nt.type(t,"object","invalid arguments to regl.texture"),Y(n,t),L(a,t)):F(a,1,1),n.genMipmaps&&(a.mipmask=(a.width<<1)-1),r.mipmask=a.mipmask,O(r,a),nt.texture2D(n,a,i),r.internalformat=a.internalformat,o.width=a.width,o.height=a.height,J(r),U(a,pn),W(n,pn),K(),V(a),u.profile&&(r.stats.size=Xr(r.internalformat,r.type,a.width,a.height,n.genMipmaps,!1)),o.format=g[r.internalformat],o.type=v[r.type],o.mag=w[n.magFilter],o.min=x[n.minFilter],o.wrapS=A[n.wrapS],o.wrapT=A[n.wrapT],o}function a(t,e,n,i){nt(!!t,"must specify image data");var a=0|e,s=0|n,u=0|i,c=z();return O(c,r),c.width=0,c.height=0,E(c,t),c.width=c.width||(r.width>>u)-a,c.height=c.height||(r.height>>u)-s,nt(r.type===c.type&&r.format===c.format&&r.internalformat===c.internalformat,"incompatible format for texture.subimage"),nt(a>=0&&s>=0&&a+c.width<=r.width&&s+c.height<=r.height,"texture.subimage write out of bounds"),nt(r.mipmask&1<>s;++s){var c=i>>s,l=a>>s;if(!c||!l)break;n.texImage2D(pn,s,r.format,c,l,0,r.format,r.type,null)}return K(),u.profile&&(r.stats.size=Xr(r.internalformat,r.type,i,a,!1,!1)),o}return q[r.id]=r,s.textureCount++,o(t,e),o.subimage=a,o.resize=c,o._reglType="texture2d",o._texture=r,u.profile&&(o.stats=r.stats),o.destroy=function(){r.decRef()},o}function et(t,e,r,o,a,c){var l=new Z(_n);q[l.id]=l,s.cubeCount++;var f=new Array(6);function h(t,e,n,r,o,a){var s,c=l.texInfo;for($.call(c),s=0;s<6;++s)f[s]=P();if("number"!=typeof t&&t)if("object"==typeof t)if(e)L(f[0],t),L(f[1],e),L(f[2],n),L(f[3],r),L(f[4],o),L(f[5],a);else if(Y(c,t),T(l,t),"faces"in t){var d=t.faces;for(nt(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),s=0;s<6;++s)nt("object"==typeof d[s]&&!!d[s],"invalid input for cube map face"),O(f[s],l),L(f[s],d[s])}else for(s=0;s<6;++s)L(f[s],t);else nt.raise("invalid arguments to cube map");else{var p=0|t||1;for(s=0;s<6;++s)F(f[s],p,p)}for(O(l,f[0]),nt.optional((function(){i.npotTextureCube||nt(hn(l.width)&&hn(l.height),"your browser does not support non power or two texture dimensions")})),c.genMipmaps?l.mipmask=(f[0].width<<1)-1:l.mipmask=f[0].mipmask,nt.textureCube(l,c,f,i),l.internalformat=f[0].internalformat,h.width=f[0].width,h.height=f[0].height,J(l),s=0;s<6;++s)U(f[s],mn+s);for(W(c,_n),K(),u.profile&&(l.stats.size=Xr(l.internalformat,l.type,h.width,h.height,c.genMipmaps,!0)),h.format=g[l.internalformat],h.type=v[l.type],h.mag=w[c.magFilter],h.min=x[c.minFilter],h.wrapS=A[c.wrapS],h.wrapT=A[c.wrapT],s=0;s<6;++s)V(f[s]);return h}function d(t,e,n,r,i){nt(!!e,"must specify image data"),nt("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var o=0|n,a=0|r,s=0|i,u=z();return O(u,l),u.width=0,u.height=0,E(u,e),u.width=u.width||(l.width>>s)-o,u.height=u.height||(l.height>>s)-a,nt(l.type===u.type&&l.format===u.format&&l.internalformat===u.internalformat,"incompatible format for texture.subimage"),nt(o>=0&&a>=0&&o+u.width<=l.width&&a+u.height<=l.height,"texture.subimage write out of bounds"),nt(l.mipmask&1<>i;++i)n.texImage2D(mn+r,i,l.format,e>>i,e>>i,0,l.format,l.type,null);return K(),u.profile&&(l.stats.size=Xr(l.internalformat,l.type,h.width,h.height,!1,!0)),h}}return h(t,e,r,o,a,c),h.subimage=d,h.resize=p,h._reglType="textureCube",h._texture=l,u.profile&&(h.stats=l.stats),h.destroy=function(){l.decRef()},h}function rt(){for(var t=0;t>e,t.height>>e,0,t.internalformat,t.type,null);else for(var r=0;r<6;++r)n.texImage2D(mn+r,e,t.internalformat,t.width>>e,t.height>>e,0,t.internalformat,t.type,null);W(t.texInfo,t.target)}))}function ot(){for(var t=0;t0)continue;i.unit=-1}H[r]=t,e=r;break}e>=X&&nt.raise("insufficient number of texture units"),u.profile&&s.maxTextureUnits=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&&(nt.parameter(h.format,o,"invalid renderbuffer format"),c=o[h.format])}else"number"==typeof e?(s=0|e,u="number"==typeof r?0|r:s):e?nt.raise("invalid arguments to renderbuffer constructor"):s=u=1;if(nt(s>0&&u>0&&s<=n.maxRenderbufferSize&&u<=n.maxRenderbufferSize,"invalid renderbuffer size"),s!==l.width||u!==l.height||c!==l.format)return f.width=l.width=s,f.height=l.height=u,l.format=c,t.bindRenderbuffer(Zr,l.renderbuffer),t.renderbufferStorage(Zr,c,s,u),nt(0===t.getError(),"invalid render buffer format"),i.profile&&(l.stats.size=ui(l.format,l.width,l.height)),f.format=a[l.format],f}function h(e,r){var o=0|e,a=0|r||o;return o===l.width&&a===l.height||(nt(o>0&&a>0&&o<=n.maxRenderbufferSize&&a<=n.maxRenderbufferSize,"invalid renderbuffer size"),f.width=l.width=o,f.height=l.height=a,t.bindRenderbuffer(Zr,l.renderbuffer),t.renderbufferStorage(Zr,l.format,o,a),nt(0===t.getError(),"invalid render buffer format"),i.profile&&(l.stats.size=ui(l.format,l.width,l.height))),f}return u[l.id]=l,r.renderbufferCount++,f(e,s),f.resize=h,f._reglType="renderbuffer",f._renderbuffer=l,i.profile&&(f.stats=l.stats),f.destroy=function(){l.decRef()},f}function h(){Se(u).forEach((function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(Zr,e.renderbuffer),t.renderbufferStorage(Zr,e.format,e.width,e.height)})),t.bindRenderbuffer(Zr,null)}return c.prototype.decRef=function(){--this.refCount<=0&&l(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var t=0;return Object.keys(u).forEach((function(e){t+=u[e].stats.size})),t}),{create:f,clear:function(){Se(u).forEach(l)},restore:h}},li=36160,fi=36161,hi=3553,di=34069,pi=36064,_i=36096,mi=36128,bi=33306,yi=36053,gi=36054,vi=36055,wi=36057,xi=36061,Ai=36193,Si=5121,Ii=5126,Oi=6407,Ti=6408,ki=6402,Mi=[Oi,Ti],Ei=[];Ei[Ti]=4,Ei[Oi]=3;var Bi=[];Bi[Si]=1,Bi[Ii]=4,Bi[Ai]=2;var ji=33189,Di=36168,zi=34041,Ni=[32854,32855,36194,35907,34842,34843,34836],Ci={};function Fi(t,n,r,i,o,a){var s={cur:null,next:null,dirty:!1,setFBO:null},u=["rgba"],c=["rgba4","rgb565","rgb5 a1"];n.ext_srgb&&c.push("srgba"),n.ext_color_buffer_half_float&&c.push("rgba16f","rgb16f"),n.webgl_color_buffer_float&&c.push("rgba32f");var l=["uint8"];function f(t,e,n){this.target=t,this.texture=e,this.renderbuffer=n;var r=0,i=0;e?(r=e.width,i=e.height):n&&(r=n.width,i=n.height),this.width=r,this.height=i}function h(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function d(t,e,n){if(t)if(t.texture){var r=t.texture._texture,i=Math.max(1,r.width),o=Math.max(1,r.height);nt(i===e&&o===n,"inconsistent width/height for supplied texture"),r.refCount+=1}else{var a=t.renderbuffer._renderbuffer;nt(a.width===e&&a.height===n,"inconsistent width/height for renderbuffer"),a.refCount+=1}}function p(e,n){n&&(n.texture?t.framebufferTexture2D(li,e,n.target,n.texture._texture.texture,0):t.framebufferRenderbuffer(li,e,fi,n.renderbuffer._renderbuffer.renderbuffer))}function _(t){var e=hi,n=null,r=null,i=t;"object"==typeof t&&(i=t.data,"target"in t&&(e=0|t.target)),nt.type(i,"function","invalid attachment data");var o=i._reglType;return"texture2d"===o?(n=i,nt(e===hi)):"textureCube"===o?(n=i,nt(e>=di&&e=2,"invalid shape for framebuffer"),a=B[0],h=B[1]}else"radius"in E&&(a=h=E.radius),"width"in E&&(a=E.width),"height"in E&&(h=E.height);("color"in E||"colors"in E)&&(g=E.color||E.colors,Array.isArray(g)&&nt(1===g.length||n.webgl_draw_buffers,"multiple render targets not supported")),g||("colorCount"in E&&(I=0|E.colorCount,nt(I>0,"invalid color buffer count")),"colorTexture"in E&&(v=!!E.colorTexture,w="rgba4"),"colorType"in E&&(A=E.colorType,v?(nt(n.oes_texture_float||!("float"===A||"float32"===A),"you must enable OES_texture_float in order to use floating point framebuffer objects"),nt(n.oes_texture_half_float||!("half float"===A||"float16"===A),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===A||"float16"===A?(nt(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),w="rgba16f"):"float"!==A&&"float32"!==A||(nt(n.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),w="rgba32f"),nt.oneOf(A,l,"invalid color type")),"colorFormat"in E&&(w=E.colorFormat,u.indexOf(w)>=0?v=!0:c.indexOf(w)>=0?v=!1:nt.optional((function(){v?nt.oneOf(E.colorFormat,u,"invalid color format for texture"):nt.oneOf(E.colorFormat,c,"invalid color format for renderbuffer")})))),("depthTexture"in E||"depthStencilTexture"in E)&&(M=!(!E.depthTexture&&!E.depthStencilTexture),nt(!M||n.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in E&&("boolean"==typeof E.depth?p=E.depth:(O=E.depth,y=!1)),"stencil"in E&&("boolean"==typeof E.stencil?y=E.stencil:(T=E.stencil,p=!1)),"depthStencil"in E&&("boolean"==typeof E.depthStencil?p=y=E.depthStencil:(k=E.depthStencil,p=!1,y=!1))}else a=h=1;var j=null,D=null,z=null,N=null;if(Array.isArray(g))j=g.map(_);else if(g)j=[_(g)];else for(j=new Array(I),i=0;i=0||j[i].renderbuffer&&Ni.indexOf(j[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),j[i]&&j[i].texture){var F=Ei[j[i].texture._texture.format]*Bi[j[i].texture._texture.type];null===C?C=F:nt(C===F,"all color attachments much have the same number of bits per pixel.")}return d(D,a,h),nt(!D||D.texture&&D.texture._texture.format===ki||D.renderbuffer&&D.renderbuffer._renderbuffer.format===ji,"invalid depth attachment for framebuffer object"),d(z,a,h),nt(!z||z.renderbuffer&&z.renderbuffer._renderbuffer.format===Di,"invalid stencil attachment for framebuffer object"),d(N,a,h),nt(!N||N.texture&&N.texture._texture.format===zi||N.renderbuffer&&N.renderbuffer._renderbuffer.format===zi,"invalid depth-stencil attachment for framebuffer object"),x(o),o.width=a,o.height=h,o.colorAttachments=j,o.depthAttachment=D,o.stencilAttachment=z,o.depthStencilAttachment=N,f.color=j.map(b),f.depth=b(D),f.stencil=b(z),f.depthStencil=b(N),f.width=o.width,f.height=o.height,S(o),f}function h(t,e){nt(s.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|t,1),r=Math.max(0|e||n,1);if(n===o.width&&r===o.height)return f;for(var i=o.colorAttachments,a=0;a=2,"invalid shape for framebuffer"),nt(y[0]===y[1],"cube framebuffer must be square"),h=y[0]}else"radius"in b&&(h=0|b.radius),"width"in b?(h=0|b.width,"height"in b&&nt(b.height===h,"must be square")):"height"in b&&(h=0|b.height);("color"in b||"colors"in b)&&(d=b.color||b.colors,Array.isArray(d)&&nt(1===d.length||n.webgl_draw_buffers,"multiple render targets not supported")),d||("colorCount"in b&&(m=0|b.colorCount,nt(m>0,"invalid color buffer count")),"colorType"in b&&(nt.oneOf(b.colorType,l,"invalid color type"),_=b.colorType),"colorFormat"in b&&(p=b.colorFormat,nt.oneOf(b.colorFormat,u,"invalid color format for texture"))),"depth"in b&&(f.depth=b.depth),"stencil"in b&&(f.stencil=b.stencil),"depthStencil"in b&&(f.depthStencil=b.depthStencil)}else h=1;if(d)if(Array.isArray(d))for(c=[],r=0;r0&&(f.depth=o[0].depth,f.stencil=o[0].stencil,f.depthStencil=o[0].depthStencil),o[r]?o[r](f):o[r]=I(f)}return e(a,{width:h,height:h,color:c})}function c(t){var e,n=0|t;if(nt(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var i=a.color;for(e=0;e{for(var t=Object.keys(e),n=0;n=0,'invalid option for vao: "'+t[n]+'" valid options are '+Pi)})),nt(Array.isArray(i),"attributes must be an array")}nt(i.length0,"must specify at least one attribute");var l={},f=r.attributes;f.length=i.length;for(var h=0;h=m.byteLength?d.subdata(m):(d.destroy(),r.buffers[h]=null)),r.buffers[h]||(d=r.buffers[h]=o.create(p,Ui,!1,!0)),_.buffer=o.getBuffer(d),_.size=0|_.buffer.dimension,_.normalized=!1,_.type=_.buffer.dtype,_.offset=0,_.stride=0,_.divisor=0,_.state=1,l[h]=1):o.getBuffer(p)?(_.buffer=o.getBuffer(p),_.size=0|_.buffer.dimension,_.normalized=!1,_.type=_.buffer.dtype,_.offset=0,_.stride=0,_.divisor=0,_.state=1):o.getBuffer(p.buffer)?(_.buffer=o.getBuffer(p.buffer),_.size=0|(+p.size||_.buffer.dimension),_.normalized=!!p.normalized||!1,"type"in p?(nt.parameter(p.type,De,"invalid buffer type"),_.type=De[p.type]):_.type=_.buffer.dtype,_.offset=0|(p.offset||0),_.stride=0|(p.stride||0),_.divisor=0|(p.divisor||0),_.state=1,nt(_.size>=1&&_.size<=4,"size must be between 1 and 4"),nt(_.offset>=0,"invalid offset"),nt(_.stride>=0&&_.stride<=255,"stride must be between 0 and 255"),nt(_.divisor>=0,"divisor must be positive"),nt(!_.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(nt(h>0,"first attribute must not be a constant"),_.x=+p.x||0,_.y=+p.y||0,_.z=+p.z||0,_.w=+p.w||0,_.state=2):nt(!1,"invalid attribute spec for location "+h)}for(var b=0;b1)for(var b=0;b1&&(g=g.replace("[0]","")),u(m,new s(g,n.id(g),t.getUniformLocation(d,g),l))}var v=t.getProgramParameter(d,qi);i.profile&&(e.stats.attributesCount=v);var w=e.attributes;for(a=0;at&&(t=e.stats.uniformsCount)})),t},r.getMaxAttributesCount=function(){var t=0;return f.forEach((function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)})),t}),{clear:function(){var e=t.deleteShader.bind(t);Se(o).forEach(e),o={},Se(a).forEach(e),a={},f.forEach((function(e){t.deleteProgram(e.program)})),f.length=0,l={},r.shaderCount=0},program:function(n,i,s,u){nt.command(n>=0,"missing vertex shader",s),nt.command(i>=0,"missing fragment shader",s);var c=l[i];c||(c=l[i]={});var h=c[n];if(h&&(h.refCount++,!u))return h;var _=new d(i,n);return r.shaderCount++,p(_,s,u),h||(c[n]=_),f.push(_),e(_,{destroy:function(){if(_.refCount--,_.refCount<=0){t.deleteProgram(_.program);var e=f.indexOf(_);f.splice(e,1),r.shaderCount--}c[_.vertId].refCount<=0&&(t.deleteShader(a[_.vertId]),delete a[_.vertId],delete l[_.fragId][_.vertId]),Object.keys(l[_.fragId]).length||(t.deleteShader(o[_.fragId]),delete o[_.fragId],delete l[_.fragId])}})},restore:_,shader:c,frag:-1,vert:-1}}var Hi=6408,Zi=5121,Ji=3333,Ki=5126;function Qi(e,n,r,i,o,a,s){function u(u){var c;null===n.next?(nt(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),c=Zi):(nt(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),c=n.next.colorAttachments[0].texture._texture.type,nt.optional((function(){a.oes_texture_float?(nt(c===Zi||c===Ki,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),c===Ki&&nt(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):nt(c===Zi,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var l=0,f=0,h=i.framebufferWidth,d=i.framebufferHeight,p=null;t(u)?p=u:u&&(nt.type(u,"object","invalid arguments to regl.read()"),l=0|u.x,f=0|u.y,nt(l>=0&&l=0&&f0&&h+l<=i.framebufferWidth,"invalid width for read pixels"),nt(d>0&&d+f<=i.framebufferHeight,"invalid height for read pixels"),r();var _=h*d*4;return p||(c===Zi?p=new Uint8Array(_):c===Ki&&(p=p||new Float32Array(_))),nt.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),nt(p.byteLength>=_,"data buffer for regl.read() too small"),e.pixelStorei(Ji,4),e.readPixels(l,f,h,d,Hi,c,p),p}function c(t){var e;return n.setFBO({framebuffer:t.framebuffer},(function(){e=u(t)})),e}function l(t){return t&&"framebuffer"in t?c(t):u(t)}return l}function to(t){return Array.prototype.slice.call(t)}function eo(t){return to(t).join("")}function no(){var t=0,n=[],r=[];function i(e){for(var i=0;i0&&(n.push(e,"="),n.push.apply(n,to(arguments)),n.push(";")),e}return e(r,{def:o,toString:function(){return eo([i.length>0?"var "+i.join(",")+";":"",eo(n)])}})}function a(){var t=o(),n=o(),r=t.toString,i=n.toString;function a(e,r){n(e,r,"=",t.def(e,r),";")}return e((function(){t.apply(t,to(arguments))}),{def:t.def,entry:t,exit:n,save:a,set:function(e,n,r){a(e,n),t(e,n,"=",r,";")},toString:function(){return r()+i()}})}function s(){var t=eo(arguments),n=a(),r=a(),i=n.toString,o=r.toString;return e(n,{then:function(){return n.apply(n,to(arguments)),this},else:function(){return r.apply(r,to(arguments)),this},toString:function(){var e=o();return e&&(e="else{"+e+"}"),eo(["if(",t,"){",i(),"}",e])}})}var u=o(),c={};function l(t,n){var r=[];function i(){var t="a"+r.length;return r.push(t),t}n=n||0;for(var o=0;o":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},rs={frag:35632,vert:35633},is={cw:Pa,ccw:Va};function os(e){return Array.isArray(e)||t(e)||Ae(e)}function as(t){return t.sort((function(t,e){return t===Po?-1:e===Po?1:t=1,r>=2,e)}if(n===fo){var i=t.data;return new ss(i.thisDep,i.contextDep,i.propDep,e)}if(n===ho)return new ss(!1,!1,!1,e);if(n===po){for(var o=!1,a=!1,s=!1,u=0;u=1&&(a=!0),l>=2&&(s=!0)}else c.type===fo&&(o=o||c.data.thisDep,a=a||c.data.contextDep,s=s||c.data.propDep)}return new ss(o,a,s,e)}return new ss(n===lo,n===co,n===uo,e)}var fs=new ss(!1,!1,!1,(function(){}));function hs(t,n,r,i,o,a,s,u,c,l,f,h,d,p,_){var m=l.Record,b={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(b.min=$a,b.max=Ya);var y=r.angle_instanced_arrays,g=r.webgl_draw_buffers,v=r.oes_vertex_array_object,w={dirty:!0,profile:_.profile},x={},A=[],S={},I={};function O(t){return t.replace(".","_")}function T(t,e,n){var r=O(t);A.push(t),x[r]=w[r]=!!n,S[r]=e}function k(t,e,n){var r=O(t);A.push(t),Array.isArray(n)?(w[r]=n.slice(),x[r]=n.slice()):w[r]=x[r]=n,I[r]=e}T(_o,pa),T(mo,da),k(bo,"blendColor",[0,0,0,0]),k(yo,"blendEquationSeparate",[Ha,Ha]),k(go,"blendFuncSeparate",[Xa,qa,Xa,qa]),T(vo,ma,!0),k(wo,"depthFunc",Za),k(xo,"depthRange",[0,1]),k(Ao,"depthMask",!0),k(So,So,[!0,!0,!0,!0]),T(Io,ha),k(Oo,"cullFace",Ra),k(To,To,Va),k(ko,ko,1),T(Mo,ya),k(Eo,"polygonOffset",[0,0]),T(Bo,ga),T(jo,va),k(Do,"sampleCoverage",[1,!1]),T(zo,_a),k(No,"stencilMask",-1),k(Co,"stencilFunc",[Wa,0,-1]),k(Fo,"stencilOpSeparate",[Ua,Ga,Ga,Ga]),k(Lo,"stencilOpSeparate",[Ra,Ga,Ga,Ga]),T(Uo,ba),k(Ro,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),k(Po,Po,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var M={gl:t,context:d,strings:n,next:x,current:w,draw:h,elements:a,buffer:o,shader:f,attributes:l.state,vao:l,uniforms:c,framebuffer:u,extensions:r,timer:p,isBufferArgs:os},E={primTypes:Ge,compareFuncs:es,blendFuncs:Qa,blendEquations:b,stencilOps:ns,glTypes:De,orientationType:is};nt.optional((function(){M.isArrayLike=fn})),g&&(E.backBuffer=[Ra],E.drawBuffer=Ot(i.maxDrawbuffers,(function(t){return 0===t?[0]:Ot(t,(function(t){return Ka+t}))})));var B=0;function j(){var t=no(),e=t.link,r=t.global;t.id=B++,t.batchId="0";var i=e(M),o=t.shared={props:"a0"};Object.keys(M).forEach((function(t){o[t]=r.def(i,".",t)})),nt.optional((function(){t.CHECK=e(nt),t.commandStr=nt.guessCommand(),t.command=e(t.commandStr),t.assert=function(t,n,r){t("if(!(",n,"))",this.CHECK,".commandRaise(",e(r),",",this.command,");")},E.invalidBlendCombinations=ts}));var a=t.next={},s=t.current={};Object.keys(I).forEach((function(t){Array.isArray(w[t])&&(a[t]=r.def(o.next,".",t),s[t]=r.def(o.current,".",t))}));var u=t.constants={};Object.keys(E).forEach((function(t){u[t]=r.def(JSON.stringify(E[t]))})),t.invoke=function(n,r){switch(r.type){case so:var i=["this",o.context,o.props,t.batchId];return n.def(e(r.data),".call(",i.slice(0,Math.max(r.data.length+1,4)),")");case uo:return n.def(o.props,r.data);case co:return n.def(o.context,r.data);case lo:return n.def("this",r.data);case fo:return r.data.append(t,n),r.data.ref;case ho:return r.data.toString();case po:return r.data.map((function(e){return t.invoke(n,e)}))}},t.attribCache={};var c={};return t.scopeAttrib=function(t){var r=n.id(t);if(r in c)return c[r];var i=l.scope[r];return i||(i=l.scope[r]=new m),c[r]=e(i)},t}function D(t){var e,n=t.static,r=t.dynamic;if(Vo in n){var i=!!n[Vo];(e=cs((function(t,e){return i}))).enable=i}else if(Vo in r){var o=r[Vo];e=ls(o,(function(t,e){return t.invoke(e,o)}))}return e}function z(t,e){var n=t.static,r=t.dynamic;if($o in n){var i=n[$o];return i?(i=u.getFramebuffer(i),nt.command(i,"invalid framebuffer object"),cs((function(t,e){var n=t.link(i),r=t.shared;e.set(r.framebuffer,".next",n);var o=r.context;return e.set(o,"."+ta,n+".width"),e.set(o,"."+ea,n+".height"),n}))):cs((function(t,e){var n=t.shared;e.set(n.framebuffer,".next","null");var r=n.context;return e.set(r,"."+ta,r+"."+oa),e.set(r,"."+ea,r+"."+aa),"null"}))}if($o in r){var o=r[$o];return ls(o,(function(t,e){var n=t.invoke(e,o),r=t.shared,i=r.framebuffer,a=e.def(i,".getFramebuffer(",n,")");nt.optional((function(){t.assert(e,"!"+n+"||"+a,"invalid framebuffer object")})),e.set(i,".next",a);var s=r.context;return e.set(s,"."+ta,a+"?"+a+".width:"+s+"."+oa),e.set(s,"."+ea,a+"?"+a+".height:"+s+"."+aa),a}))}return null}function N(t,e,n){var r=t.static,i=t.dynamic;function o(t){if(t in r){var o=r[t];nt.commandType(o,"object","invalid "+t,n.commandStr);var a,s,u=!0,c=0|o.x,l=0|o.y;return"width"in o?(a=0|o.width,nt.command(a>=0,"invalid "+t,n.commandStr)):u=!1,"height"in o?(s=0|o.height,nt.command(s>=0,"invalid "+t,n.commandStr)):u=!1,new ss(!u&&e&&e.thisDep,!u&&e&&e.contextDep,!u&&e&&e.propDep,(function(t,e){var n=t.shared.context,r=a;"width"in o||(r=e.def(n,".",ta,"-",c));var i=s;return"height"in o||(i=e.def(n,".",ea,"-",l)),[c,l,r,i]}))}if(t in i){var f=i[t],h=ls(f,(function(e,n){var r=e.invoke(n,f);nt.optional((function(){e.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+t)}));var i=e.shared.context,o=n.def(r,".x|0"),a=n.def(r,".y|0"),s=n.def('"width" in ',r,"?",r,".width|0:","(",i,".",ta,"-",o,")"),u=n.def('"height" in ',r,"?",r,".height|0:","(",i,".",ea,"-",a,")");return nt.optional((function(){e.assert(n,s+">=0&&"+u+">=0","invalid "+t)})),[o,a,s,u]}));return e&&(h.thisDep=h.thisDep||e.thisDep,h.contextDep=h.contextDep||e.contextDep,h.propDep=h.propDep||e.propDep),h}return e?new ss(e.thisDep,e.contextDep,e.propDep,(function(t,e){var n=t.shared.context;return[0,0,e.def(n,".",ta),e.def(n,".",ea)]})):null}var a=o(Po);if(a){var s=a;a=new ss(a.thisDep,a.contextDep,a.propDep,(function(t,e){var n=s.append(t,e),r=t.shared.context;return e.set(r,"."+na,n[2]),e.set(r,"."+ra,n[3]),n}))}return{viewport:a,scissor_box:o(Ro)}}function C(t,e){var n=t.static;if("string"==typeof n[Wo]&&"string"==typeof n[Yo]){if(Object.keys(e.dynamic).length>0)return null;var r=e.static,i=Object.keys(r);if(i.length>0&&"number"==typeof r[i[0]]){for(var o=[],a=0;a=0,"invalid "+t,e.commandStr),cs((function(t,e){return a&&(t.OFFSET=s),s}))}if(t in r){var l=r[t];return ls(l,(function(e,n){var r=e.invoke(n,l);return a&&(e.OFFSET=r,nt.optional((function(){e.assert(n,r+">=0","invalid "+t)}))),r}))}if(a){if(c)return cs((function(t,e){return t.OFFSET=0,0}));if(o)return new ss(u.thisDep,u.contextDep,u.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.offset:0")}))}else if(o)return new ss(u.thisDep,u.contextDep,u.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.instances:-1")}));return null}var _=p(Ho,!0);function m(){if(Xo in n){var t=0|n[Xo];return i.count=t,nt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),cs((function(){return t}))}if(Xo in r){var a=r[Xo];return ls(a,(function(t,e){var n=t.invoke(e,a);return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")})),n}))}if(c){if(us(h)){if(h)return _?new ss(_.thisDep,_.contextDep,_.propDep,(function(t,e){var n=e.def(t.ELEMENTS,".vertCount-",t.OFFSET);return nt.optional((function(){t.assert(e,n+">=0","invalid vertex offset/element buffer too small")})),n})):cs((function(t,e){return e.def(t.ELEMENTS,".vertCount")}));var s=cs((function(){return-1}));return nt.optional((function(){s.MISSING=!0})),s}var l=new ss(h.thisDep||_.thisDep,h.contextDep||_.contextDep,h.propDep||_.propDep,(function(t,e){var n=t.ELEMENTS;return t.OFFSET?e.def(n,"?",n,".vertCount-",t.OFFSET,":-1"):e.def(n,"?",n,".vertCount:-1")}));return nt.optional((function(){l.DYNAMIC=!0})),l}return o?new ss(u.thisDep,u.contextDep,u.propDep,(function(t,e){return e.def(t.shared.vao,".currentVAO?",t.shared.vao,".currentVAO.count:-1")})):null}var b=d(),y=m(),g=p(Zo,!1);return{elements:h,primitive:b,count:y,instances:g,offset:_,vao:u,vaoActive:o,elementsActive:c,static:i}}function U(t,e){var n=t.static,r=t.dynamic,o={};return A.forEach((function(t){var a=O(t);function s(e,i){if(t in n){var s=e(n[t]);o[a]=cs((function(){return s}))}else if(t in r){var u=r[t];o[a]=ls(u,(function(t,e){return i(t,e,t.invoke(e,u))}))}}switch(t){case Io:case mo:case _o:case zo:case vo:case Uo:case Mo:case Bo:case jo:case Ao:return s((function(n){return nt.commandType(n,"boolean",t,e.commandStr),n}),(function(e,n,r){return nt.optional((function(){e.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+t,e.commandStr)})),r}));case wo:return s((function(n){return nt.commandParameter(n,es,"invalid "+t,e.commandStr),es[n]}),(function(e,n,r){var i=e.constants.compareFuncs;return nt.optional((function(){e.assert(n,r+" in "+i,"invalid "+t+", must be one of "+Object.keys(es))})),n.def(i,"[",r,"]")}));case xo:return s((function(t){return nt.command(fn(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&t[0]<=t[1],"depth range is 2d array",e.commandStr),t}),(function(t,e,n){return nt.optional((function(){t.assert(e,t.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")})),[e.def("+",n,"[0]"),e.def("+",n,"[1]")]}));case go:return s((function(t){nt.commandType(t,"object","blend.func",e.commandStr);var n="srcRGB"in t?t.srcRGB:t.src,r="srcAlpha"in t?t.srcAlpha:t.src,i="dstRGB"in t?t.dstRGB:t.dst,o="dstAlpha"in t?t.dstAlpha:t.dst;return nt.commandParameter(n,Qa,a+".srcRGB",e.commandStr),nt.commandParameter(r,Qa,a+".srcAlpha",e.commandStr),nt.commandParameter(i,Qa,a+".dstRGB",e.commandStr),nt.commandParameter(o,Qa,a+".dstAlpha",e.commandStr),nt.command(-1===ts.indexOf(n+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+i+")",e.commandStr),[Qa[n],Qa[i],Qa[r],Qa[o]]}),(function(e,n,r){var i=e.constants.blendFuncs;function o(o,a){var s=n.def('"',o,a,'" in ',r,"?",r,".",o,a,":",r,".",o);return nt.optional((function(){e.assert(n,s+" in "+i,"invalid "+t+"."+o+a+", must be one of "+Object.keys(Qa))})),s}nt.optional((function(){e.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")}));var a=o("src","RGB"),s=o("dst","RGB");nt.optional((function(){var t=e.constants.invalidBlendCombinations;e.assert(n,t+".indexOf("+a+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var u=n.def(i,"[",a,"]"),c=n.def(i,"[",o("src","Alpha"),"]");return[u,n.def(i,"[",s,"]"),c,n.def(i,"[",o("dst","Alpha"),"]")]}));case yo:return s((function(n){return"string"==typeof n?(nt.commandParameter(n,b,"invalid "+t,e.commandStr),[b[n],b[n]]):"object"==typeof n?(nt.commandParameter(n.rgb,b,t+".rgb",e.commandStr),nt.commandParameter(n.alpha,b,t+".alpha",e.commandStr),[b[n.rgb],b[n.alpha]]):void nt.commandRaise("invalid blend.equation",e.commandStr)}),(function(e,n,r){var i=e.constants.blendEquations,o=n.def(),a=n.def(),s=e.cond("typeof ",r,'==="string"');return nt.optional((function(){function n(t,n,r){e.assert(t,r+" in "+i,"invalid "+n+", must be one of "+Object.keys(b))}n(s.then,t,r),e.assert(s.else,r+"&&typeof "+r+'==="object"',"invalid "+t),n(s.else,t+".rgb",r+".rgb"),n(s.else,t+".alpha",r+".alpha")})),s.then(o,"=",a,"=",i,"[",r,"];"),s.else(o,"=",i,"[",r,".rgb];",a,"=",i,"[",r,".alpha];"),n(s),[o,a]}));case bo:return s((function(t){return nt.command(fn(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),Ot(4,(function(e){return+t[e]}))}),(function(t,e,n){return nt.optional((function(){t.assert(e,t.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")})),Ot(4,(function(t){return e.def("+",n,"[",t,"]")}))}));case No:return s((function(t){return nt.commandType(t,"number",a,e.commandStr),0|t}),(function(t,e,n){return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"',"invalid stencil.mask")})),e.def(n,"|0")}));case Co:return s((function(n){nt.commandType(n,"object",a,e.commandStr);var r=n.cmp||"keep",i=n.ref||0,o="mask"in n?n.mask:-1;return nt.commandParameter(r,es,t+".cmp",e.commandStr),nt.commandType(i,"number",t+".ref",e.commandStr),nt.commandType(o,"number",t+".mask",e.commandStr),[es[r],i,o]}),(function(t,e,n){var r=t.constants.compareFuncs;return nt.optional((function(){function i(){t.assert(e,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(n+"&&typeof ",n,'==="object"'),i('!("cmp" in ',n,")||(",n,".cmp in ",r,")")})),[e.def('"cmp" in ',n,"?",r,"[",n,".cmp]",":",Ga),e.def(n,".ref|0"),e.def('"mask" in ',n,"?",n,".mask|0:-1")]}));case Fo:case Lo:return s((function(n){nt.commandType(n,"object",a,e.commandStr);var r=n.fail||"keep",i=n.zfail||"keep",o=n.zpass||"keep";return nt.commandParameter(r,ns,t+".fail",e.commandStr),nt.commandParameter(i,ns,t+".zfail",e.commandStr),nt.commandParameter(o,ns,t+".zpass",e.commandStr),[t===Lo?Ra:Ua,ns[r],ns[i],ns[o]]}),(function(e,n,r){var i=e.constants.stencilOps;function o(o){return nt.optional((function(){e.assert(n,'!("'+o+'" in '+r+")||("+r+"."+o+" in "+i+")","invalid "+t+"."+o+", must be one of "+Object.keys(ns))})),n.def('"',o,'" in ',r,"?",i,"[",r,".",o,"]:",Ga)}return nt.optional((function(){e.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+t)})),[t===Lo?Ra:Ua,o("fail"),o("zfail"),o("zpass")]}));case Eo:return s((function(t){nt.commandType(t,"object",a,e.commandStr);var n=0|t.factor,r=0|t.units;return nt.commandType(n,"number",a+".factor",e.commandStr),nt.commandType(r,"number",a+".units",e.commandStr),[n,r]}),(function(e,n,r){return nt.optional((function(){e.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+t)})),[n.def(r,".factor|0"),n.def(r,".units|0")]}));case Oo:return s((function(t){var n=0;return"front"===t?n=Ua:"back"===t&&(n=Ra),nt.command(!!n,a,e.commandStr),n}),(function(t,e,n){return nt.optional((function(){t.assert(e,n+'==="front"||'+n+'==="back"',"invalid cull.face")})),e.def(n,'==="front"?',Ua,":",Ra)}));case ko:return s((function(t){return nt.command("number"==typeof t&&t>=i.lineWidthDims[0]&&t<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],e.commandStr),t}),(function(t,e,n){return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">="+i.lineWidthDims[0]+"&&"+n+"<="+i.lineWidthDims[1],"invalid line width")})),n}));case To:return s((function(t){return nt.commandParameter(t,is,a,e.commandStr),is[t]}),(function(t,e,n){return nt.optional((function(){t.assert(e,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),e.def(n+'==="cw"?'+Pa+":"+Va)}));case So:return s((function(t){return nt.command(fn(t)&&4===t.length,"color.mask must be length 4 array",e.commandStr),t.map((function(t){return!!t}))}),(function(t,e,n){return nt.optional((function(){t.assert(e,t.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")})),Ot(4,(function(t){return"!!"+n+"["+t+"]"}))}));case Do:return s((function(t){nt.command("object"==typeof t&&t,a,e.commandStr);var n="value"in t?t.value:1,r=!!t.invert;return nt.command("number"==typeof n&&n>=0&&n<=1,"sample.coverage.value must be a number between 0 and 1",e.commandStr),[n,r]}),(function(t,e,n){return nt.optional((function(){t.assert(e,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")})),[e.def('"value" in ',n,"?+",n,".value:1"),e.def("!!",n,".invert")]}))}})),o}function R(t,e){var n=t.static,r=t.dynamic,i={};return Object.keys(n).forEach((function(t){var r,o=n[t];if("number"==typeof o||"boolean"==typeof o)r=cs((function(){return o}));else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?r=cs((function(t){return t.link(o)})):"framebuffer"===a||"framebufferCube"===a?(nt.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',e.commandStr),r=cs((function(t){return t.link(o.color[0])}))):nt.commandRaise('invalid data for uniform "'+t+'"',e.commandStr)}else fn(o)?r=cs((function(e){return e.global.def("[",Ot(o.length,(function(n){return nt.command("number"==typeof o[n]||"boolean"==typeof o[n],"invalid uniform "+t,e.commandStr),o[n]})),"]")})):nt.commandRaise('invalid or missing data for uniform "'+t+'"',e.commandStr);r.value=o,i[t]=r})),Object.keys(r).forEach((function(t){var e=r[t];i[t]=ls(e,(function(t,n){return t.invoke(n,e)}))})),i}function P(t,e){var r=t.static,i=t.dynamic,a={};return Object.keys(r).forEach((function(t){var i=r[t],s=n.id(t),u=new m;if(os(i))u.state=oo,u.buffer=o.getBuffer(o.create(i,ua,!1,!0)),u.type=0;else{var c=o.getBuffer(i);if(c)u.state=oo,u.buffer=c,u.type=0;else if(nt.command("object"==typeof i&&i,"invalid data for attribute "+t,e.commandStr),"constant"in i){var l=i.constant;u.buffer="null",u.state=ao,"number"==typeof l?u.x=l:(nt.command(fn(l)&&l.length>0&&l.length<=4,"invalid constant for attribute "+t,e.commandStr),ro.forEach((function(t,e){e=0,'invalid offset for attribute "'+t+'"',e.commandStr);var h=0|i.stride;nt.command(h>=0&&h<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',e.commandStr);var d=0|i.size;nt.command(!("size"in i)||d>0&&d<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',e.commandStr);var p=!!i.normalized,_=0;"type"in i&&(nt.commandParameter(i.type,De,"invalid type for attribute "+t,e.commandStr),_=De[i.type]);var b=0|i.divisor;nt.optional((function(){"divisor"in i&&(nt.command(0===b||y,'cannot specify divisor for attribute "'+t+'", instancing not supported',e.commandStr),nt.command(b>=0,'invalid divisor for attribute "'+t+'"',e.commandStr));var n=e.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach((function(e){nt.command(r.indexOf(e)>=0,'unknown parameter "'+e+'" for attribute pointer "'+t+'" (valid parameters are '+r+")",n)}))})),u.buffer=c,u.state=oo,u.size=d,u.normalized=p,u.type=_||c.dtype,u.offset=f,u.stride=h,u.divisor=b}}a[t]=cs((function(t,e){var n=t.attribCache;if(s in n)return n[s];var r={isStream:!1};return Object.keys(u).forEach((function(t){r[t]=u[t]})),u.buffer&&(r.buffer=t.link(u.buffer),r.type=r.type||r.buffer+".dtype"),n[s]=r,r}))})),Object.keys(i).forEach((function(t){var e=i[t];function n(n,r){var i=n.invoke(r,e),o=n.shared,a=n.constants,s=o.isBufferArgs,u=o.buffer;nt.optional((function(){n.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+s+"("+i+")||"+u+".getBuffer("+i+")||"+u+".getBuffer("+i+".buffer)||"+s+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+t+'"')}));var c={isStream:r.def(!1)},l=new m;l.state=oo,Object.keys(l).forEach((function(t){c[t]=r.def(""+l[t])}));var f=c.buffer,h=c.type;function d(t){r(c[t],"=",i,".",t,"|0;")}return r("if(",s,"(",i,")){",c.isStream,"=true;",f,"=",u,".createStream(",ua,",",i,");",h,"=",f,".dtype;","}else{",f,"=",u,".getBuffer(",i,");","if(",f,"){",h,"=",f,".dtype;",'}else if("constant" in ',i,"){",c.state,"=",ao,";","if(typeof "+i+'.constant === "number"){',c[ro[0]],"=",i,".constant;",ro.slice(1).map((function(t){return c[t]})).join("="),"=0;","}else{",ro.map((function(t,e){return c[t]+"="+i+".constant.length>"+e+"?"+i+".constant["+e+"]:0;"})).join(""),"}}else{","if(",s,"(",i,".buffer)){",f,"=",u,".createStream(",ua,",",i,".buffer);","}else{",f,"=",u,".getBuffer(",i,".buffer);","}",h,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",f,".dtype;",c.normalized,"=!!",i,".normalized;"),d("size"),d("offset"),d("stride"),d("divisor"),r("}}"),r.exit("if(",c.isStream,"){",u,".destroyStream(",f,");","}"),c}a[t]=ls(e,n)})),a}function V(t){var e=t.static,n=t.dynamic,r={};return Object.keys(e).forEach((function(t){var n=e[t];r[t]=cs((function(t,e){return"number"==typeof n||"boolean"==typeof n?""+n:t.link(n)}))})),Object.keys(n).forEach((function(t){var e=n[t];r[t]=ls(e,(function(t,n){return t.invoke(n,e)}))})),r}function $(t,e,n,i,o){var a=t.static,s=t.dynamic;nt.optional((function(){var t=[$o,Yo,Wo,Go,qo,Ho,Xo,Zo,Vo,Jo].concat(A);function e(e){Object.keys(e).forEach((function(e){nt.command(t.indexOf(e)>=0,'unknown parameter "'+e+'"',o.commandStr)}))}e(a),e(s)}));var u=C(t,e),c=z(t),f=N(t,c,o),h=L(t,o),d=U(t,o),p=F(t,o,u);function _(t){var e=f[t];e&&(d[t]=e)}_(Po),_(O(Ro));var m=Object.keys(d).length>0,b={framebuffer:c,draw:h,shader:p,state:d,dirty:m,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(b.profile=D(t),b.uniforms=R(n,o),b.drawVAO=b.scopeVAO=h.vao,!b.drawVAO&&p.program&&!u&&r.angle_instanced_arrays&&h.static.elements){var y=!0,g=p.program.attributes.map((function(t){var n=e.static[t];return y=y&&!!n,n}));if(y&&g.length>0){var v=l.getVAO(l.createVAO({attributes:g,elements:h.static.elements}));b.drawVAO=new ss(null,null,null,(function(t,e){return t.link(v)})),b.useVAO=!0}}return u?b.useVAO=!0:b.attributes=P(e,o),b.context=V(i),b}function Y(t,e,n){var r=t.shared.context,i=t.scope();Object.keys(n).forEach((function(o){e.save(r,"."+o);var a=n[o].append(t,e);Array.isArray(a)?i(r,".",o,"=[",a.join(),"];"):i(r,".",o,"=",a,";")})),e(i)}function W(t,e,n,r){var i,o=t.shared,a=o.gl,s=o.framebuffer;g&&(i=e.def(o.extensions,".webgl_draw_buffers"));var u,c=t.constants,l=c.drawBuffer,f=c.backBuffer;u=n?n.append(t,e):e.def(s,".next"),r||e("if(",u,"!==",s,".cur){"),e("if(",u,"){",a,".bindFramebuffer(",Ja,",",u,".framebuffer);"),g&&e(i,".drawBuffersWEBGL(",l,"[",u,".colorAttachments.length]);"),e("}else{",a,".bindFramebuffer(",Ja,",null);"),g&&e(i,".drawBuffersWEBGL(",f,");"),e("}",s,".cur=",u,";"),r||e("}")}function G(t,e,n){var r=t.shared,i=r.gl,o=t.current,a=t.next,s=r.current,u=r.next,c=t.cond(s,".dirty");A.forEach((function(e){var r,l,f=O(e);if(!(f in n.state))if(f in a){r=a[f],l=o[f];var h=Ot(w[f].length,(function(t){return c.def(r,"[",t,"]")}));c(t.cond(h.map((function(t,e){return t+"!=="+l+"["+e+"]"})).join("||")).then(i,".",I[f],"(",h,");",h.map((function(t,e){return l+"["+e+"]="+t})).join(";"),";"))}else{r=c.def(u,".",f);var d=t.cond(r,"!==",s,".",f);c(d),f in S?d(t.cond(r).then(i,".enable(",S[f],");").else(i,".disable(",S[f],");"),s,".",f,"=",r,";"):d(i,".",I[f],"(",r,");",s,".",f,"=",r,";")}})),0===Object.keys(n.state).length&&c(s,".dirty=false;"),e(c)}function q(t,e,n,r){var i=t.shared,o=t.current,a=i.current,s=i.gl;as(Object.keys(n)).forEach((function(i){var u=n[i];if(!r||r(u)){var c=u.append(t,e);if(S[i]){var l=S[i];us(u)?e(s,c?".enable(":".disable(",l,");"):e(t.cond(c).then(s,".enable(",l,");").else(s,".disable(",l,");")),e(a,".",i,"=",c,";")}else if(fn(c)){var f=o[i];e(s,".",I[i],"(",c,");",c.map((function(t,e){return f+"["+e+"]="+t})).join(";"),";")}else e(s,".",I[i],"(",c,");",a,".",i,"=",c,";")}}))}function X(t,e){y&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function H(t,e,n,r,i){var o,a,s,u=t.shared,c=t.stats,l=u.current,f=u.timer,h=n.profile;function d(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function _(t){t(o=e.def(),"=",d(),";"),"string"==typeof i?t(c,".count+=",i,";"):t(c,".count++;"),p&&(r?t(a=e.def(),"=",f,".getNumPendingQueries();"):t(f,".beginQuery(",c,");"))}function m(t){t(c,".cpuTime+=",d(),"-",o,";"),p&&(r?t(f,".pushScopeStats(",a,",",f,".getNumPendingQueries(),",c,");"):t(f,".endQuery();"))}function b(t){var n=e.def(l,".profile");e(l,".profile=",t,";"),e.exit(l,".profile=",n,";")}if(h){if(us(h))return void(h.enable?(_(e),m(e.exit),b("true")):b("false"));b(s=h.append(t,e))}else s=e.def(l,".profile");var y=t.block();_(y),e("if(",s,"){",y,"}");var g=t.block();m(g),e.exit("if(",s,"){",g,"}")}function Z(t,e,n,r,i){var o=t.shared;function a(t){switch(t){case xa:case Oa:case Ea:return 2;case Aa:case Ta:case Ba:return 3;case Sa:case ka:case ja:return 4;default:return 1}}function s(n,r,i){var a=o.gl,s=e.def(n,".location"),u=e.def(o.attributes,"[",s,"]"),c=i.state,l=i.buffer,f=[i.x,i.y,i.z,i.w],h=["buffer","normalized","offset","stride"];function d(){e("if(!",u,".buffer){",a,".enableVertexAttribArray(",s,");}");var n,o=i.type;if(n=i.size?e.def(i.size,"||",r):r,e("if(",u,".type!==",o,"||",u,".size!==",n,"||",h.map((function(t){return u+"."+t+"!=="+i[t]})).join("||"),"){",a,".bindBuffer(",ua,",",l,".buffer);",a,".vertexAttribPointer(",[s,n,o,i.normalized,i.stride,i.offset],");",u,".type=",o,";",u,".size=",n,";",h.map((function(t){return u+"."+t+"="+i[t]+";"})).join(""),"}"),y){var c=i.divisor;e("if(",u,".divisor!==",c,"){",t.instancing,".vertexAttribDivisorANGLE(",[s,c],");",u,".divisor=",c,";}")}}function p(){e("if(",u,".buffer){",a,".disableVertexAttribArray(",s,");",u,".buffer=null;","}if(",ro.map((function(t,e){return u+"."+t+"!=="+f[e]})).join("||"),"){",a,".vertexAttrib4f(",s,",",f,");",ro.map((function(t,e){return u+"."+t+"="+f[e]+";"})).join(""),"}")}c===oo?d():c===ao?p():(e("if(",c,"===",oo,"){"),d(),e("}else{"),p(),e("}"))}r.forEach((function(r){var o,u=r.name,c=n.attributes[u];if(c){if(!i(c))return;o=c.append(t,e)}else{if(!i(fs))return;var l=t.scopeAttrib(u);nt.optional((function(){t.assert(e,l+".state","missing attribute "+u)})),o={},Object.keys(new m).forEach((function(t){o[t]=e.def(l,".",t)}))}s(t.link(r),a(r.info.type),o)}))}function J(t,e,r,i,o,a){for(var s,u=t.shared,c=u.gl,l={},f=0;f1){if(!m)continue;var b=d.replace("[0]","");if(l[b])continue;l[b]=1}var y,g=t.link(h)+".location";if(m){if(!o(m))continue;if(us(m)){var v=m.value;if(nt.command(null!=v,'missing uniform "'+d+'"',t.commandStr),p===Ca||p===Fa){nt.command("function"==typeof v&&(p===Ca&&("texture2d"===v._reglType||"framebuffer"===v._reglType)||p===Fa&&("textureCube"===v._reglType||"framebufferCube"===v._reglType)),"invalid texture for uniform "+d,t.commandStr);var w=t.link(v._texture||v.color[0]._texture);e(c,".uniform1i(",g,",",w+".bind());"),e.exit(w,".unbind();")}else if(p===Da||p===za||p===Na){nt.optional((function(){nt.command(fn(v),"invalid matrix for uniform "+d,t.commandStr),nt.command(p===Da&&4===v.length||p===za&&9===v.length||p===Na&&16===v.length,"invalid length for matrix uniform "+d,t.commandStr)}));var x=t.global.def("new Float32Array(["+Array.prototype.slice.call(v)+"])"),A=2;p===za?A=3:p===Na&&(A=4),e(c,".uniformMatrix",A,"fv(",g,",false,",x,");")}else{switch(p){case wa:1===_?nt.commandType(v,"number","uniform "+d,t.commandStr):nt.command(fn(v)&&v.length===_,"uniform "+d,t.commandStr),s="1f";break;case xa:nt.command(fn(v)&&v.length&&v.length%2==0&&v.length<=2*_,"uniform "+d,t.commandStr),s="2f";break;case Aa:nt.command(fn(v)&&v.length&&v.length%3==0&&v.length<=3*_,"uniform "+d,t.commandStr),s="3f";break;case Sa:nt.command(fn(v)&&v.length&&v.length%4==0&&v.length<=4*_,"uniform "+d,t.commandStr),s="4f";break;case Ma:1===_?nt.commandType(v,"boolean","uniform "+d,t.commandStr):nt.command(fn(v)&&v.length===_,"uniform "+d,t.commandStr),s="1i";break;case Ia:1===_?nt.commandType(v,"number","uniform "+d,t.commandStr):nt.command(fn(v)&&v.length===_,"uniform "+d,t.commandStr),s="1i";break;case Ea:case Oa:nt.command(fn(v)&&v.length&&v.length%2==0&&v.length<=2*_,"uniform "+d,t.commandStr),s="2i";break;case Ba:case Ta:nt.command(fn(v)&&v.length&&v.length%3==0&&v.length<=3*_,"uniform "+d,t.commandStr),s="3i";break;case ja:case ka:nt.command(fn(v)&&v.length&&v.length%4==0&&v.length<=4*_,"uniform "+d,t.commandStr),s="4i"}_>1?(s+="v",v=t.global.def("["+Array.prototype.slice.call(v)+"]")):v=fn(v)?Array.prototype.slice.call(v):v,e(c,".uniform",s,"(",g,",",v,");")}continue}y=m.append(t,e)}else{if(!o(fs))continue;y=e.def(u.uniforms,"[",n.id(d),"]")}p===Ca?(nt(!Array.isArray(y),"must specify a scalar prop for textures"),e("if(",y,"&&",y,'._reglType==="framebuffer"){',y,"=",y,".color[0];","}")):p===Fa&&(nt(!Array.isArray(y),"must specify a scalar prop for cube maps"),e("if(",y,"&&",y,'._reglType==="framebufferCube"){',y,"=",y,".color[0];","}")),nt.optional((function(){function n(n,r){t.assert(e,n,'bad data or missing for uniform "'+d+'". '+r)}function r(t,e){1===e&&nt(!Array.isArray(y),"must not specify an array type for uniform"),n("Array.isArray("+y+") && typeof "+y+'[0]===" '+t+'" || typeof '+y+'==="'+t+'"',"invalid type, expected "+t)}function i(e,r,i){Array.isArray(y)?nt(y.length&&y.length%e==0&&y.length<=e*i,"must have length of "+(1===i?"":"n * ")+e):n(u.isArrayLike+"("+y+")&&"+y+".length && "+y+".length % "+e+" === 0 && "+y+".length<="+e*i,"invalid vector, should have length of "+(1===i?"":"n * ")+e,t.commandStr)}function o(e){nt(!Array.isArray(y),"must not specify a value type"),n("typeof "+y+'==="function"&&'+y+'._reglType==="texture'+(e===la?"2d":"Cube")+'"',"invalid texture type",t.commandStr)}switch(p){case Ia:r("number",_);break;case Oa:i(2,"number",_);break;case Ta:i(3,"number",_);break;case ka:i(4,"number",_);break;case wa:r("number",_);break;case xa:i(2,"number",_);break;case Aa:i(3,"number",_);break;case Sa:i(4,"number",_);break;case Ma:r("boolean",_);break;case Ea:i(2,"boolean",_);break;case Ba:i(3,"boolean",_);break;case ja:i(4,"boolean",_);break;case Da:i(4,"number",_);break;case za:i(9,"number",_);break;case Na:i(16,"number",_);break;case Ca:o(la);break;case Fa:o(fa)}}));var S=1;switch(p){case Ca:case Fa:var I=e.def(y,"._texture");e(c,".uniform1i(",g,",",I,".bind());"),e.exit(I,".unbind();");continue;case Ia:case Ma:s="1i";break;case Oa:case Ea:s="2i",S=2;break;case Ta:case Ba:s="3i",S=3;break;case ka:case ja:s="4i",S=4;break;case wa:s="1f";break;case xa:s="2f",S=2;break;case Aa:s="3f",S=3;break;case Sa:s="4f",S=4;break;case Da:s="Matrix2fv";break;case za:s="Matrix3fv";break;case Na:s="Matrix4fv"}if(-1===s.indexOf("Matrix")&&_>1&&(s+="v",S=1),"M"===s.charAt(0)){e(c,".uniform",s,"(",g,",");var O=Math.pow(p-Da+2,2),T=t.global.def("new Float32Array(",O,")");Array.isArray(y)?e("false,(",Ot(O,(function(t){return T+"["+t+"]="+y[t]})),",",T,")"):e("false,(Array.isArray(",y,")||",y," instanceof Float32Array)?",y,":(",Ot(O,(function(t){return T+"["+t+"]="+y+"["+t+"]"})),",",T,")"),e(");")}else if(S>1){for(var k=[],M=[],E=0;E=0","missing vertex count")}))):(i=u.def(a,".",Xo),nt.optional((function(){t.assert(u,i+">=0","missing vertex count")}))),i}var l=u();function f(i){var o=s[i];return o?o.contextDep&&r.contextDynamic||o.propDep?o.append(t,n):o.append(t,e):e.def(a,".",i)}var h,d,p=f(qo),_=f(Ho),m=c();if("number"==typeof m){if(0===m)return}else n("if(",m,"){"),n.exit("}");y&&(h=f(Zo),d=t.instancing);var b=l+".type",g=s.elements&&us(s.elements)&&!s.vaoActive;function w(){function t(){n(d,".drawElementsInstancedANGLE(",[p,m,b,_+"<<(("+b+"-"+io+")>>1)",h],");")}function e(){n(d,".drawArraysInstancedANGLE(",[p,_,m,h],");")}l&&"null"!==l?g?t():(n("if(",l,"){"),t(),n("}else{"),e(),n("}")):e()}function x(){function t(){n(o+".drawElements("+[p,m,b,_+"<<(("+b+"-"+io+")>>1)"]+");")}function e(){n(o+".drawArrays("+[p,_,m]+");")}l&&"null"!==l?g?t():(n("if(",l,"){"),t(),n("}else{"),e(),n("}")):e()}y&&("number"!=typeof h||h>=0)?"string"==typeof h?(n("if(",h,">0){"),w(),n("}else if(",h,"<0){"),x(),n("}")):w():x()}function Q(t,e,n,r,i){var o=j(),a=o.proc("body",i);return nt.optional((function(){o.commandStr=e.commandStr,o.command=o.link(e.commandStr)})),y&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),t(o,a,n,r),o.compile().body}function tt(t,e,n,r){X(t,e),n.useVAO?n.drawVAO?e(t.shared.vao,".setVAO(",n.drawVAO.append(t,e),");"):e(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(e(t.shared.vao,".setVAO(null);"),Z(t,e,n,r.attributes,(function(){return!0}))),J(t,e,n,r.uniforms,(function(){return!0}),!1),K(t,e,e,n)}function et(t,e){var n=t.proc("draw",1);X(t,n),Y(t,n,e.context),W(t,n,e.framebuffer),G(t,n,e),q(t,n,e.state),H(t,n,e,!1,!0);var r=e.shader.progVar.append(t,n);if(n(t.shared.gl,".useProgram(",r,".program);"),e.shader.program)tt(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var i=t.global.def("{}"),o=n.def(r,".id"),a=n.def(i,"[",o,"]");n(t.cond(a).then(a,".call(this,a0);").else(a,"=",i,"[",o,"]=",t.link((function(n){return Q(tt,t,e,n,1)})),"(",r,");",a,".call(this,a0);"))}Object.keys(e.state).length>0&&n(t.shared.current,".dirty=true;"),t.shared.vao&&n(t.shared.vao,".setVAO(null);")}function rt(t,e,n,r){function i(){return!0}t.batchId="a1",X(t,e),Z(t,e,n,r.attributes,i),J(t,e,n,r.uniforms,i,!1),K(t,e,e,n)}function it(t,e,n,r){X(t,e);var i=n.contextDep,o=e.def(),a="a0",s="a1",u=e.def();t.shared.props=u,t.batchId=o;var c=t.scope(),l=t.scope();function f(t){return t.contextDep&&i||t.propDep}function h(t){return!f(t)}if(e(c.entry,"for(",o,"=0;",o,"<",s,";++",o,"){",u,"=",a,"[",o,"];",l,"}",c.exit),n.needsContext&&Y(t,l,n.context),n.needsFramebuffer&&W(t,l,n.framebuffer),q(t,l,n.state,f),n.profile&&f(n.profile)&&H(t,l,n,!1,!0),r)n.useVAO?n.drawVAO?f(n.drawVAO)?l(t.shared.vao,".setVAO(",n.drawVAO.append(t,l),");"):c(t.shared.vao,".setVAO(",n.drawVAO.append(t,c),");"):c(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(c(t.shared.vao,".setVAO(null);"),Z(t,c,n,r.attributes,h),Z(t,l,n,r.attributes,f)),J(t,c,n,r.uniforms,h,!1),J(t,l,n,r.uniforms,f,!0),K(t,c,l,n);else{var d=t.global.def("{}"),p=n.shader.progVar.append(t,l),_=l.def(p,".id"),m=l.def(d,"[",_,"]");l(t.shared.gl,".useProgram(",p,".program);","if(!",m,"){",m,"=",d,"[",_,"]=",t.link((function(e){return Q(rt,t,n,e,2)})),"(",p,");}",m,".call(this,a0[",o,"],",o,");")}}function ot(t,e){var n=t.proc("batch",2);t.batchId="0",X(t,n);var r=!1,i=!0;Object.keys(e.context).forEach((function(t){r=r||e.context[t].propDep})),r||(Y(t,n,e.context),i=!1);var o=e.framebuffer,a=!1;function s(t){return t.contextDep&&r||t.propDep}o?(o.propDep?r=a=!0:o.contextDep&&r&&(a=!0),a||W(t,n,o)):W(t,n,null),e.state.viewport&&e.state.viewport.propDep&&(r=!0),G(t,n,e),q(t,n,e.state,(function(t){return!s(t)})),e.profile&&s(e.profile)||H(t,n,e,!1,"a1"),e.contextDep=r,e.needsContext=i,e.needsFramebuffer=a;var u=e.shader.progVar;if(u.contextDep&&r||u.propDep)it(t,n,e,null);else{var c=u.append(t,n);if(n(t.shared.gl,".useProgram(",c,".program);"),e.shader.program)it(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var l=t.global.def("{}"),f=n.def(c,".id"),h=n.def(l,"[",f,"]");n(t.cond(h).then(h,".call(this,a0,a1);").else(h,"=",l,"[",f,"]=",t.link((function(n){return Q(it,t,e,n,2)})),"(",c,");",h,".call(this,a0,a1);"))}}Object.keys(e.state).length>0&&n(t.shared.current,".dirty=true;"),t.shared.vao&&n(t.shared.vao,".setVAO(null);")}function at(t,e){var r=t.proc("scope",3);t.batchId="a2";var i=t.shared,o=i.current;function a(n){var o=e.shader[n];o&&r.set(i.shader,"."+n,o.append(t,r))}Y(t,r,e.context),e.framebuffer&&e.framebuffer.append(t,r),as(Object.keys(e.state)).forEach((function(n){var o=e.state[n].append(t,r);fn(o)?o.forEach((function(e,i){r.set(t.next[n],"["+i+"]",e)})):r.set(i.next,"."+n,o)})),H(t,r,e,!0,!0),[Go,Ho,Xo,Zo,qo].forEach((function(n){var o=e.draw[n];o&&r.set(i.draw,"."+n,""+o.append(t,r))})),Object.keys(e.uniforms).forEach((function(o){var a=e.uniforms[o].append(t,r);Array.isArray(a)&&(a="["+a.join()+"]"),r.set(i.uniforms,"["+n.id(o)+"]",a)})),Object.keys(e.attributes).forEach((function(n){var i=e.attributes[n].append(t,r),o=t.scopeAttrib(n);Object.keys(new m).forEach((function(t){r.set(o,"."+t,i[t])}))})),e.scopeVAO&&r.set(i.vao,".targetVAO",e.scopeVAO.append(t,r)),a(Yo),a(Wo),Object.keys(e.state).length>0&&(r(o,".dirty=true;"),r.exit(o,".dirty=true;")),r("a1(",t.shared.context,",a0,",t.batchId,");")}function st(t){if("object"==typeof t&&!fn(t)){for(var e=Object.keys(t),n=0;n=0;--t){var e=E[t];e&&e(p,null,0)}r.flush(),l&&l.update()}function C(){!z&&E.length>0&&(z=_t.next(N))}function F(){z&&(_t.cancel(N),z=null)}function L(t){t.preventDefault(),o=!0,F(),B.forEach((function(t){t()}))}function U(t){r.getError(),o=!1,a.restore(),x.restore(),y.restore(),A.restore(),S.restore(),I.restore(),v.restore(),l&&l.restore(),O.procs.refresh(),C(),j.forEach((function(t){t()}))}function R(){E.length=0,F(),M&&(M.removeEventListener(xs,L),M.removeEventListener(As,U)),x.clear(),I.clear(),S.clear(),v.clear(),A.clear(),g.clear(),y.clear(),l&&l.clear(),D.forEach((function(t){t()}))}function P(t){function n(t){var n=e({},t);function r(t){if(t in n){var e=n[t];delete n[t],Object.keys(e).forEach((function(r){n[t+"."+r]=e[r]}))}}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),r("blend"),r("depth"),r("cull"),r("stencil"),r("polygonOffset"),r("scissor"),r("sample"),"vao"in t&&(n.vao=t.vao),n}function r(t,e){var n={},r={};return Object.keys(t).forEach((function(i){var o=t[i];if(pt.isDynamic(o))r[i]=pt.unbox(o,i);else{if(e&&Array.isArray(o))for(var a=0;a0)return h.call(this,_(0|t),0|t)}else{if(!Array.isArray(t))return f.call(this,t);if(t.length)return h.call(this,t,t.length)}}return e(m,{stats:c,destroy:function(){l.destroy()}})}M&&(M.addEventListener(xs,L,!1),M.addEventListener(As,U,!1));var V=I.setFBO=P({framebuffer:pt.define.call(null,Ss,"framebuffer")});function $(t,e){var n=0;O.procs.poll();var i=e.color;i&&(r.clearColor(+i[0]||0,+i[1]||0,+i[2]||0,+i[3]||0),n|=ys),"depth"in e&&(r.clearDepth(+e.depth),n|=gs),"stencil"in e&&(r.clearStencil(0|e.stencil),n|=vs),nt(!!n,"called regl.clear with no buffer specified"),r.clear(n)}function Y(t){if(nt("object"==typeof t&&t,"regl.clear() takes an object as input"),"framebuffer"in t)if(t.framebuffer&&"framebufferCube"===t.framebuffer_reglType)for(var n=0;n<6;++n)V(e({framebuffer:t.framebuffer.faces[n]},t),$);else V(t,$);else $(null,t)}function W(t){function e(){var e=Ts(E,t);function n(){var t=Ts(E,n);E[t]=E[E.length-1],E.length-=1,E.length<=0&&F()}nt(e>=0,"cannot cancel a frame twice"),E[e]=n}return nt.type(t,"function","regl.frame() callback must be a function"),E.push(t),C(),{cancel:e}}function G(){var t=k.viewport,e=k.scissor_box;t[0]=t[1]=e[0]=e[1]=0,p.viewportWidth=p.framebufferWidth=p.drawingBufferWidth=t[2]=e[2]=r.drawingBufferWidth,p.viewportHeight=p.framebufferHeight=p.drawingBufferHeight=t[3]=e[3]=r.drawingBufferHeight}function q(){p.tick+=1,p.time=H(),G(),O.procs.poll()}function X(){A.refresh(),G(),O.procs.refresh(),l&&l.update()}function H(){return(mt()-f)/1e3}function Z(t,e){var n;switch(nt.type(e,"function","listener callback must be a function"),t){case"frame":return W(e);case"lost":n=B;break;case"restore":n=j;break;case"destroy":n=D;break;default:nt.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(e),{cancel:function(){for(var t=0;t=0},read:T,destroy:R,_gl:r,_refresh:X,poll:function(){q(),l&&l.update()},now:H,stats:u});return n.onDone(null,J),J}return ks}();var da=function(t,e,n,r){return pa[0]=r,pa[1]=n,pa[2]=e,pa[3]=t,_a[0]},pa=new Uint8Array(4),_a=new Float32Array(pa.buffer);class ma{constructor(t,e="arithmetic"){this.transform="arithmetic",this.transform=e,this.start=t,this.value=t,this.target=t}update(t,e){if(0===e)return this.value=t,void(void 0!==this.timer&&this.timer.stop());this.start=this.value,this.target=t,this.start_timer(e)}start_timer(t){void 0!==this.timer&&this.timer.stop();const e=jn((n=>{const r=n/t;if(r>=1)return this.value=this.target,void e.stop();const i=1-r,o=r;this.value="geometric"===this.transform?this.start**i*this.target**o:this.start*i+this.target*o}));this.timer=e}}class ba{constructor(){this.maxPoints=new ma(1e4,"geometric"),this.pointSize=new ma(1,"geometric"),this.targetOpacity=new ma(50),this.foregroundOpacity=new ma(1),this.backgroundOpacity=new ma(.5),this.foregroundSize=new ma(1,"geometric"),this.backgroundSize=new ma(1,"geometric")}apply_prefs(t){const{duration:e}=t;this.maxPoints.update(t.max_points,e),this.targetOpacity.update(t.alpha,e),this.pointSize.update(t.point_size,e),this.foregroundOpacity.update(t.background_options.opacity[1],e),this.backgroundOpacity.update(t.background_options.opacity[0],e),this.foregroundSize.update(t.background_options.size[1],e),this.backgroundSize.update(t.background_options.size[0],e)}get max_points(){return this.maxPoints.value}get alpha(){return this.targetOpacity.value}get point_size(){return this.pointSize.value}get foreground_opacity(){return this.foregroundOpacity.value}get background_opacity(){return this.backgroundOpacity.value}get foreground_size(){return this.foregroundSize.value}get background_size(){return this.backgroundSize.value}}class ya{constructor(t,e,n){this._use_scale_to_download_tiles=!0,this._initializations=[],this.render_props=new ba,this.scatterplot=n,this.holder=ht(t),this.canvas=ht(this.holder.node().firstElementChild).node(),this.dataset=e,this.width=+ht(this.canvas).attr("width"),this.height=+ht(this.canvas).attr("height"),this.deferred_functions=[],this._use_scale_to_download_tiles=!0}get discard_share(){return 0}get prefs(){const t={...this.scatterplot.prefs};return t.arrow_table=void 0,t.arrow_buffer=void 0,t}get alpha(){return this.render_props.alpha}get optimal_alpha(){var t,e,n,r;const i=null!=(t=this.prefs.zoom_balance)?t:1,{alpha:o,point_size:a,max_ix:s,width:u,discard_share:c,height:l}=this,f=null!=(r=null==(n=null==(e=this.zoom)?void 0:e.transform)?void 0:n.k)?r:1,h=o/100,d=1/f**2,p=window.devicePixelRatio||1,_=u*l/p,m=Dt([s,this.dataset.highest_known_ix||1e10])*(1-c),b=Math.exp(Math.log(f)*i),y=h*_/(m*d*(Math.PI*(b*a/p/2)**2));return y<1/255?1/255:y}get point_size(){return this.render_props.point_size}get max_ix(){const{prefs:t}=this,{max_points:e}=this.render_props;if(!this._use_scale_to_download_tiles)return e;const{k:n}=this.zoom.transform,r=Math.exp(Math.log(n)*t.zoom_balance);return e*n*n/r/r}visible_tiles(){const{max_ix:t}=this,{dataset:e}=this;this.aes.dim("x");const n="x"==this.aes.dim("x").current.field&&"y"==this.aes.dim("y").current.field&&"x"==this.aes.dim("x").last.field&&"y"==this.aes.dim("y").last.field?e.map((t=>t)).filter((e=>e.is_visible(t,this.zoom.current_corners()))):e.map((t=>t)).filter((t=>t.min_ixt.min_ix-e.min_ix)),n}bind_zoom(t){return this.zoom=t,this}async initialize(){}}function ga(t){return void 0!==t.op}function va(t){return void 0!==t.lambda}function wa(t){return void 0!==t.constant}var xa={}; /** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ !function(t,e){(function(){var n,r="Expected a function",i="__lodash_hash_undefined__",o="__lodash_placeholder__",a=16,s=32,u=64,c=128,l=256,f=1/0,h=9007199254740991,d=NaN,p=4294967295,_=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",a],["flip",512],["partial",s],["partialRight",u],["rearg",l]],m="[object Arguments]",b="[object Array]",y="[object Boolean]",g="[object Date]",v="[object Error]",w="[object Function]",x="[object GeneratorFunction]",A="[object Map]",S="[object Number]",I="[object Object]",O="[object Promise]",T="[object RegExp]",k="[object Set]",M="[object String]",E="[object Symbol]",B="[object WeakMap]",j="[object ArrayBuffer]",D="[object DataView]",z="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",F="[object Int16Array]",L="[object Int32Array]",U="[object Uint8Array]",R="[object Uint8ClampedArray]",P="[object Uint16Array]",V="[object Uint32Array]",$=/\b__p \+= '';/g,Y=/\b(__p \+=) '' \+/g,W=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,q=/[&<>"']/g,X=RegExp(G.source),H=RegExp(q.source),Z=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tt=/^\w*$/,et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nt=/[\\^$.*+?()[\]{}|]/g,rt=RegExp(nt.source),it=/^\s+/,ot=/\s/,at=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,st=/\{\n\/\* \[wrapped with (.+)\] \*/,ut=/,? & /,ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,lt=/[()=,{}\[\]\/\s]/,ft=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,pt=/^[-+]0x[0-9a-f]+$/i,_t=/^0b[01]+$/i,mt=/^\[object .+?Constructor\]$/,bt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,gt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,xt="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",St="\\u2700-\\u27bf",It="a-z\\xdf-\\xf6\\xf8-\\xff",Ot="A-Z\\xc0-\\xd6\\xd8-\\xde",Tt="\\ufe0e\\ufe0f",kt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Mt="['’]",Et="["+xt+"]",Bt="["+kt+"]",jt="["+At+"]",Dt="\\d+",zt="["+St+"]",Nt="["+It+"]",Ct="[^"+xt+kt+Dt+St+It+Ot+"]",Ft="\\ud83c[\\udffb-\\udfff]",Lt="[^"+xt+"]",Ut="(?:\\ud83c[\\udde6-\\uddff]){2}",Rt="[\\ud800-\\udbff][\\udc00-\\udfff]",Pt="["+Ot+"]",Vt="\\u200d",$t="(?:"+Nt+"|"+Ct+")",Yt="(?:"+Pt+"|"+Ct+")",Wt="(?:['’](?:d|ll|m|re|s|t|ve))?",Gt="(?:['’](?:D|LL|M|RE|S|T|VE))?",qt="(?:"+jt+"|"+Ft+")"+"?",Xt="["+Tt+"]?",Ht=Xt+qt+("(?:"+Vt+"(?:"+[Lt,Ut,Rt].join("|")+")"+Xt+qt+")*"),Zt="(?:"+[zt,Ut,Rt].join("|")+")"+Ht,Jt="(?:"+[Lt+jt+"?",jt,Ut,Rt,Et].join("|")+")",Kt=RegExp(Mt,"g"),Qt=RegExp(jt,"g"),te=RegExp(Ft+"(?="+Ft+")|"+Jt+Ht,"g"),ee=RegExp([Pt+"?"+Nt+"+"+Wt+"(?="+[Bt,Pt,"$"].join("|")+")",Yt+"+"+Gt+"(?="+[Bt,Pt+$t,"$"].join("|")+")",Pt+"?"+$t+"+"+Wt,Pt+"+"+Gt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Dt,Zt].join("|"),"g"),ne=RegExp("["+Vt+xt+At+Tt+"]"),re=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ie=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],oe=-1,ae={};ae[z]=ae[N]=ae[C]=ae[F]=ae[L]=ae[U]=ae[R]=ae[P]=ae[V]=!0,ae[m]=ae[b]=ae[j]=ae[y]=ae[D]=ae[g]=ae[v]=ae[w]=ae[A]=ae[S]=ae[I]=ae[T]=ae[k]=ae[M]=ae[B]=!1;var se={};se[m]=se[b]=se[j]=se[D]=se[y]=se[g]=se[z]=se[N]=se[C]=se[F]=se[L]=se[A]=se[S]=se[I]=se[T]=se[k]=se[M]=se[E]=se[U]=se[R]=se[P]=se[V]=!0,se[v]=se[w]=se[B]=!1;var ue={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ce=parseFloat,le=parseInt,fe="object"==typeof mn&&mn&&mn.Object===Object&&mn,he="object"==typeof self&&self&&self.Object===Object&&self,de=fe||he||Function("return this")(),pe=e&&!e.nodeType&&e,_e=pe&&t&&!t.nodeType&&t,me=_e&&_e.exports===pe,be=me&&fe.process,ye=function(){try{var t=_e&&_e.require&&_e.require("util").types;return t||be&&be.binding&&be.binding("util")}catch(e){}}(),ge=ye&&ye.isArrayBuffer,ve=ye&&ye.isDate,we=ye&&ye.isMap,xe=ye&&ye.isRegExp,Ae=ye&&ye.isSet,Se=ye&&ye.isTypedArray;function Ie(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Oe(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i-1}function je(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function en(t,e){for(var n=t.length;n--&&Pe(e,t[n],0)>-1;);return n}var nn=Ge({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),rn=Ge({"&":"&","<":"<",">":">",'"':""","'":"'"});function on(t){return"\\"+ue[t]}function an(t){return ne.test(t)}function sn(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function un(t,e){return function(n){return t(e(n))}}function cn(t,e){for(var n=-1,r=t.length,i=0,a=[];++n",""":'"',"'":"'"});var _n=function t(e){var ot,xt=(e=null==e?de:_n.defaults(de.Object(),e,_n.pick(de,ie))).Array,At=e.Date,St=e.Error,It=e.Function,Ot=e.Math,Tt=e.Object,kt=e.RegExp,Mt=e.String,Et=e.TypeError,Bt=xt.prototype,jt=It.prototype,Dt=Tt.prototype,zt=e["__core-js_shared__"],Nt=jt.toString,Ct=Dt.hasOwnProperty,Ft=0,Lt=(ot=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||""))?"Symbol(src)_1."+ot:"",Ut=Dt.toString,Rt=Nt.call(Tt),Pt=de._,Vt=kt("^"+Nt.call(Ct).replace(nt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$t=me?e.Buffer:n,Yt=e.Symbol,Wt=e.Uint8Array,Gt=$t?$t.allocUnsafe:n,qt=un(Tt.getPrototypeOf,Tt),Xt=Tt.create,Ht=Dt.propertyIsEnumerable,Zt=Bt.splice,Jt=Yt?Yt.isConcatSpreadable:n,te=Yt?Yt.iterator:n,ne=Yt?Yt.toStringTag:n,ue=function(){try{var t=fo(Tt,"defineProperty");return t({},"",{}),t}catch(e){}}(),fe=e.clearTimeout!==de.clearTimeout&&e.clearTimeout,he=At&&At.now!==de.Date.now&&At.now,pe=e.setTimeout!==de.setTimeout&&e.setTimeout,_e=Ot.ceil,be=Ot.floor,ye=Tt.getOwnPropertySymbols,Le=$t?$t.isBuffer:n,Ge=e.isFinite,mn=Bt.join,bn=un(Tt.keys,Tt),yn=Ot.max,gn=Ot.min,vn=At.now,wn=e.parseInt,xn=Ot.random,An=Bt.reverse,Sn=fo(e,"DataView"),In=fo(e,"Map"),On=fo(e,"Promise"),Tn=fo(e,"Set"),kn=fo(e,"WeakMap"),Mn=fo(Tt,"create"),En=kn&&new kn,Bn={},jn=Po(Sn),Dn=Po(In),zn=Po(On),Nn=Po(Tn),Cn=Po(kn),Fn=Yt?Yt.prototype:n,Ln=Fn?Fn.valueOf:n,Un=Fn?Fn.toString:n;function Rn(t){if(is(t)&&!qa(t)&&!(t instanceof Yn)){if(t instanceof $n)return t;if(Ct.call(t,"__wrapped__"))return Vo(t)}return new $n(t)}var Pn=function(){function t(){}return function(e){if(!rs(e))return{};if(Xt)return Xt(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function Vn(){}function $n(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function Yn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Wn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function ur(t,e,r,i,o,a){var s,u=1&e,c=2&e,l=4&e;if(r&&(s=o?r(t,i,o,a):r(t)),s!==n)return s;if(!rs(t))return t;var f=qa(t);if(f){if(s=function(t){var e=t.length,n=new t.constructor(e);e&&"string"==typeof t[0]&&Ct.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!u)return Mi(t,s)}else{var h=_o(t),d=h==w||h==x;if(Ja(t))return Ai(t,u);if(h==I||h==m||d&&!o){if(s=c||d?{}:bo(t),!u)return c?function(t,e){return Ei(t,po(t),e)}(t,function(t,e){return t&&Ei(e,Ns(e),t)}(s,t)):function(t,e){return Ei(t,ho(t),e)}(t,ir(s,t))}else{if(!se[h])return o?t:{};s=function(t,e,n){var r=t.constructor;switch(e){case j:return Si(t);case y:case g:return new r(+t);case D:return function(t,e){var n=e?Si(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case z:case N:case C:case F:case L:case U:case R:case P:case V:return Ii(t,n);case A:return new r;case S:case M:return new r(t);case T:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case k:return new r;case E:return i=t,Ln?Tt(Ln.call(i)):{}}var i}(t,h,u)}}a||(a=new Hn);var p=a.get(t);if(p)return p;a.set(t,s),cs(t)?t.forEach((function(n){s.add(ur(n,e,r,n,t,a))})):os(t)&&t.forEach((function(n,i){s.set(i,ur(n,e,r,i,t,a))}));var _=f?n:(l?c?io:ro:c?Ns:zs)(t);return Te(_||t,(function(n,i){_&&(n=t[i=n]),er(s,i,ur(n,e,r,i,t,a))})),s}function cr(t,e,r){var i=r.length;if(null==t)return!i;for(t=Tt(t);i--;){var o=r[i],a=e[o],s=t[o];if(s===n&&!(o in t)||!a(s))return!1}return!0}function lr(t,e,i){if("function"!=typeof t)throw new Et(r);return Bo((function(){t.apply(n,i)}),e)}function fr(t,e,n,r){var i=-1,o=Be,a=!0,s=t.length,u=[],c=e.length;if(!s)return u;n&&(e=De(e,Je(n))),r?(o=je,a=!1):e.length>=200&&(o=Qe,a=!1,e=new Xn(e));t:for(;++i-1},Gn.prototype.set=function(t,e){var n=this.__data__,r=nr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Wn,map:new(In||Gn),string:new Wn}},qn.prototype.delete=function(t){var e=co(this,t).delete(t);return this.size-=e?1:0,e},qn.prototype.get=function(t){return co(this,t).get(t)},qn.prototype.has=function(t){return co(this,t).has(t)},qn.prototype.set=function(t,e){var n=co(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Xn.prototype.add=Xn.prototype.push=function(t){return this.__data__.set(t,i),this},Xn.prototype.has=function(t){return this.__data__.has(t)},Hn.prototype.clear=function(){this.__data__=new Gn,this.size=0},Hn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Hn.prototype.get=function(t){return this.__data__.get(t)},Hn.prototype.has=function(t){return this.__data__.has(t)},Hn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Gn){var r=n.__data__;if(!In||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new qn(r)}return n.set(t,e),this.size=n.size,this};var hr=Di(vr),dr=Di(wr,!0);function pr(t,e){var n=!0;return hr(t,(function(t,r,i){return n=!!e(t,r,i)})),n}function _r(t,e,r){for(var i=-1,o=t.length;++i0&&n(s)?e>1?br(s,e-1,n,r,i):ze(i,s):r||(i[i.length]=s)}return i}var yr=zi(),gr=zi(!0);function vr(t,e){return t&&yr(t,e,zs)}function wr(t,e){return t&&gr(t,e,zs)}function xr(t,e){return Ee(e,(function(e){return ts(t[e])}))}function Ar(t,e){for(var r=0,i=(e=gi(e,t)).length;null!=t&&re}function Tr(t,e){return null!=t&&Ct.call(t,e)}function kr(t,e){return null!=t&&e in Tt(t)}function Mr(t,e,r){for(var i=r?je:Be,o=t[0].length,a=t.length,s=a,u=xt(a),c=1/0,l=[];s--;){var f=t[s];s&&e&&(f=De(f,Je(e))),c=gn(f.length,c),u[s]=!r&&(e||o>=120&&f.length>=120)?new Xn(s&&f):n}f=t[0];var h=-1,d=u[0];t:for(;++h=s?u:u*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)}))}function Wr(t,e,n){for(var r=-1,i=e.length,o={};++r-1;)s!==t&&Zt.call(s,u,1),Zt.call(t,u,1);return t}function qr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;go(i)?Zt.call(t,i,1):fi(t,i)}}return t}function Xr(t,e){return t+be(xn()*(e-t+1))}function Hr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=be(e/2))&&(t+=t)}while(e);return n}function Zr(t,e){return jo(To(t,e,au),t+"")}function Jr(t){return Jn($s(t))}function Kr(t,e){var n=$s(t);return No(n,sr(e,0,n.length))}function Qr(t,e,r,i){if(!rs(t))return t;for(var o=-1,a=(e=gi(e,t)).length,s=a-1,u=t;null!=u&&++oi?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=xt(i);++r>>1,a=t[o];null!==a&&!fs(a)&&(n?a<=e:a=200){var c=e?null:Hi(t);if(c)return ln(c);a=!1,i=Qe,u=new Xn}else u=e?[]:s;t:for(;++r=i?t:ri(t,e,r)}var xi=fe||function(t){return de.clearTimeout(t)};function Ai(t,e){if(e)return t.slice();var n=t.length,r=Gt?Gt(n):new t.constructor(n);return t.copy(r),r}function Si(t){var e=new t.constructor(t.byteLength);return new Wt(e).set(new Wt(t)),e}function Ii(t,e){var n=e?Si(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Oi(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,a=fs(t),s=e!==n,u=null===e,c=e==e,l=fs(e);if(!u&&!l&&!a&&t>e||a&&s&&c&&!u&&!l||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!l&&t1?r[o-1]:n,s=o>2?r[2]:n;for(a=t.length>3&&"function"==typeof a?(o--,a):n,s&&vo(r[0],r[1],s)&&(a=o<3?n:a,o=1),e=Tt(e);++i-1?o[a?e[s]:s]:n}}function Ui(t){return no((function(e){var i=e.length,o=i,a=$n.prototype.thru;for(t&&e.reverse();o--;){var s=e[o];if("function"!=typeof s)throw new Et(r);if(a&&!u&&"wrapper"==ao(s))var u=new $n([],!0)}for(o=u?o:i;++o1&&g.reverse(),h&&lu))return!1;var l=a.get(t),f=a.get(e);if(l&&f)return l==e&&f==t;var h=-1,d=!0,p=2&r?new Xn:n;for(a.set(t,e),a.set(e,t);++h-1&&t%1==0&&t1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(at,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Te(_,(function(n){var r="_."+n[0];e&n[1]&&!Be(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(ut):[]}(r),n)))}function zo(t){var e=0,r=0;return function(){var i=vn(),o=16-(i-r);if(r=i,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(n,arguments)}}function No(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return r="function"==typeof r?(t.pop(),r):n,ua(t,r)}));function _a(t){var e=Rn(t);return e.__chain__=!0,e}function ma(t,e){return e(t)}var ba=no((function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return ar(e,t)};return!(e>1||this.__actions__.length)&&i instanceof Yn&&go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:ma,args:[o],thisArg:n}),new $n(i,this.__chain__).thru((function(t){return e&&!t.length&&t.push(n),t}))):this.thru(o)}));var ya=Bi((function(t,e,n){Ct.call(t,n)?++t[n]:or(t,n,1)}));var ga=Li(Go),va=Li(qo);function wa(t,e){return(qa(t)?Te:hr)(t,uo(e,3))}function xa(t,e){return(qa(t)?ke:dr)(t,uo(e,3))}var Aa=Bi((function(t,e,n){Ct.call(t,n)?t[n].push(e):or(t,n,[e])}));var Sa=Zr((function(t,e,n){var r=-1,i="function"==typeof e,o=Ha(t)?xt(t.length):[];return hr(t,(function(t){o[++r]=i?Ie(e,t,n):Er(t,e,n)})),o})),Ia=Bi((function(t,e,n){or(t,n,e)}));function Oa(t,e){return(qa(t)?De:Ur)(t,uo(e,3))}var Ta=Bi((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]}));var ka=Zr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&vo(t,e[0],e[1])?e=[]:n>2&&vo(e[0],e[1],e[2])&&(e=[e[0]]),Yr(t,br(e,1),[])})),Ma=he||function(){return de.Date.now()};function Ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,Ji(t,c,n,n,n,n,e)}function Ba(t,e){var i;if("function"!=typeof e)throw new Et(r);return t=bs(t),function(){return--t>0&&(i=e.apply(this,arguments)),t<=1&&(e=n),i}}var ja=Zr((function(t,e,n){var r=1;if(n.length){var i=cn(n,so(ja));r|=s}return Ji(t,r,e,n,i)})),Da=Zr((function(t,e,n){var r=3;if(n.length){var i=cn(n,so(Da));r|=s}return Ji(e,r,t,n,i)}));function za(t,e,i){var o,a,s,u,c,l,f=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new Et(r);function _(e){var r=o,i=a;return o=a=n,f=e,u=t.apply(i,r)}function m(t){var r=t-l;return l===n||r>=e||r<0||d&&t-f>=s}function b(){var t=Ma();if(m(t))return y(t);c=Bo(b,function(t){var n=e-(t-l);return d?gn(n,s-(t-f)):n}(t))}function y(t){return c=n,p&&o?_(t):(o=a=n,u)}function g(){var t=Ma(),r=m(t);if(o=arguments,a=this,l=t,r){if(c===n)return function(t){return f=t,c=Bo(b,e),h?_(t):u}(l);if(d)return xi(c),c=Bo(b,e),_(l)}return c===n&&(c=Bo(b,e)),u}return e=gs(e)||0,rs(i)&&(h=!!i.leading,s=(d="maxWait"in i)?yn(gs(i.maxWait)||0,e):s,p="trailing"in i?!!i.trailing:p),g.cancel=function(){c!==n&&xi(c),f=0,o=l=a=c=n},g.flush=function(){return c===n?u:y(Ma())},g}var Na=Zr((function(t,e){return lr(t,1,e)})),Ca=Zr((function(t,e,n){return lr(t,gs(e)||0,n)}));function Fa(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Et(r);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=t.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Fa.Cache||qn),n}function La(t){if("function"!=typeof t)throw new Et(r);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Fa.Cache=qn;var Ua=vi((function(t,e){var n=(e=1==e.length&&qa(e[0])?De(e[0],Je(uo())):De(br(e,1),Je(uo()))).length;return Zr((function(r){for(var i=-1,o=gn(r.length,n);++i=e})),Ga=Br(function(){return arguments}())?Br:function(t){return is(t)&&Ct.call(t,"callee")&&!Ht.call(t,"callee")},qa=xt.isArray,Xa=ge?Je(ge):function(t){return is(t)&&Ir(t)==j};function Ha(t){return null!=t&&ns(t.length)&&!ts(t)}function Za(t){return is(t)&&Ha(t)}var Ja=Le||gu,Ka=ve?Je(ve):function(t){return is(t)&&Ir(t)==g};function Qa(t){if(!is(t))return!1;var e=Ir(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ss(t)}function ts(t){if(!rs(t))return!1;var e=Ir(t);return e==w||e==x||"[object AsyncFunction]"==e||"[object Proxy]"==e}function es(t){return"number"==typeof t&&t==bs(t)}function ns(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=h}function rs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function is(t){return null!=t&&"object"==typeof t}var os=we?Je(we):function(t){return is(t)&&_o(t)==A};function as(t){return"number"==typeof t||is(t)&&Ir(t)==S}function ss(t){if(!is(t)||Ir(t)!=I)return!1;var e=qt(t);if(null===e)return!0;var n=Ct.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Nt.call(n)==Rt}var us=xe?Je(xe):function(t){return is(t)&&Ir(t)==T};var cs=Ae?Je(Ae):function(t){return is(t)&&_o(t)==k};function ls(t){return"string"==typeof t||!qa(t)&&is(t)&&Ir(t)==M}function fs(t){return"symbol"==typeof t||is(t)&&Ir(t)==E}var hs=Se?Je(Se):function(t){return is(t)&&ns(t.length)&&!!ae[Ir(t)]};var ds=Gi(Lr),ps=Gi((function(t,e){return t<=e}));function _s(t){if(!t)return[];if(Ha(t))return ls(t)?hn(t):Mi(t);if(te&&t[te])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[te]());var e=_o(t);return(e==A?sn:e==k?ln:$s)(t)}function ms(t){return t?(t=gs(t))===f||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function bs(t){var e=ms(t),n=e%1;return e==e?n?e-n:e:0}function ys(t){return t?sr(bs(t),0,p):0}function gs(t){if("number"==typeof t)return t;if(fs(t))return d;if(rs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=rs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ze(t);var n=_t.test(t);return n||bt.test(t)?le(t.slice(2),n?2:8):pt.test(t)?d:+t}function vs(t){return Ei(t,Ns(t))}function ws(t){return null==t?"":ci(t)}var xs=ji((function(t,e){if(So(e)||Ha(e))Ei(e,zs(e),t);else for(var n in e)Ct.call(e,n)&&er(t,n,e[n])})),As=ji((function(t,e){Ei(e,Ns(e),t)})),Ss=ji((function(t,e,n,r){Ei(e,Ns(e),t,r)})),Is=ji((function(t,e,n,r){Ei(e,zs(e),t,r)})),Os=no(ar);var Ts=Zr((function(t,e){t=Tt(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&vo(e[0],e[1],o)&&(i=1);++r1),e})),Ei(t,io(t),n),r&&(n=ur(n,7,to));for(var i=e.length;i--;)fi(n,e[i]);return n}));var Us=no((function(t,e){return null==t?{}:function(t,e){return Wr(t,e,(function(e,n){return Es(t,n)}))}(t,e)}));function Rs(t,e){if(null==t)return{};var n=De(io(t),(function(t){return[t]}));return e=uo(e),Wr(t,n,(function(t,n){return e(t,n[0])}))}var Ps=Zi(zs),Vs=Zi(Ns);function $s(t){return null==t?[]:Ke(t,zs(t))}var Ys=Ci((function(t,e,n){return e=e.toLowerCase(),t+(n?Ws(e):e)}));function Ws(t){return Qs(ws(t).toLowerCase())}function Gs(t){return(t=ws(t))&&t.replace(gt,nn).replace(Qt,"")}var qs=Ci((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),Xs=Ci((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Hs=Ni("toLowerCase");var Zs=Ci((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}));var Js=Ci((function(t,e,n){return t+(n?" ":"")+Qs(e)}));var Ks=Ci((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Qs=Ni("toUpperCase");function tu(t,e,r){return t=ws(t),(e=r?n:e)===n?function(t){return re.test(t)}(t)?function(t){return t.match(ee)||[]}(t):function(t){return t.match(ct)||[]}(t):t.match(e)||[]}var eu=Zr((function(t,e){try{return Ie(t,n,e)}catch(r){return Qa(r)?r:new St(r)}})),nu=no((function(t,e){return Te(e,(function(e){e=Ro(e),or(t,e,ja(t[e],t))})),t}));function ru(t){return function(){return t}}var iu=Ui(),ou=Ui(!0);function au(t){return t}function su(t){return Nr("function"==typeof t?t:ur(t,1))}var uu=Zr((function(t,e){return function(n){return Er(n,t,e)}})),cu=Zr((function(t,e){return function(n){return Er(t,n,e)}}));function lu(t,e,n){var r=zs(e),i=xr(e,r);null!=n||rs(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=xr(e,zs(e)));var o=!(rs(n)&&"chain"in n&&!n.chain),a=ts(t);return Te(i,(function(n){var r=e[n];t[n]=r,a&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__);return(n.__actions__=Mi(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,ze([this.value()],arguments))})})),t}function fu(){}var hu=$i(De),du=$i(Me),pu=$i(Fe);function _u(t){return wo(t)?We(Ro(t)):function(t){return function(e){return Ar(e,t)}}(t)}var mu=Wi(),bu=Wi(!0);function yu(){return[]}function gu(){return!1}var vu=Vi((function(t,e){return t+e}),0),wu=Xi("ceil"),xu=Vi((function(t,e){return t/e}),1),Au=Xi("floor");var Su,Iu=Vi((function(t,e){return t*e}),1),Ou=Xi("round"),Tu=Vi((function(t,e){return t-e}),0);return Rn.after=function(t,e){if("function"!=typeof e)throw new Et(r);return t=bs(t),function(){if(--t<1)return e.apply(this,arguments)}},Rn.ary=Ea,Rn.assign=xs,Rn.assignIn=As,Rn.assignInWith=Ss,Rn.assignWith=Is,Rn.at=Os,Rn.before=Ba,Rn.bind=ja,Rn.bindAll=nu,Rn.bindKey=Da,Rn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return qa(t)?t:[t]},Rn.chain=_a,Rn.chunk=function(t,e,r){e=(r?vo(t,e,r):e===n)?1:yn(bs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,a=0,s=xt(_e(i/e));oo?0:o+r),(i=i===n||i>o?o:bs(i))<0&&(i+=o),i=r>i?0:ys(i);r>>0)?(t=ws(t))&&("string"==typeof e||null!=e&&!us(e))&&!(e=ci(e))&&an(t)?wi(hn(t),0,r):t.split(e,r):[]},Rn.spread=function(t,e){if("function"!=typeof t)throw new Et(r);return e=null==e?0:yn(bs(e),0),Zr((function(n){var r=n[e],i=wi(n,0,e);return r&&ze(i,r),Ie(t,this,i)}))},Rn.tail=function(t){var e=null==t?0:t.length;return e?ri(t,1,e):[]},Rn.take=function(t,e,r){return t&&t.length?ri(t,0,(e=r||e===n?1:bs(e))<0?0:e):[]},Rn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?ri(t,(e=i-(e=r||e===n?1:bs(e)))<0?0:e,i):[]},Rn.takeRightWhile=function(t,e){return t&&t.length?di(t,uo(e,3),!1,!0):[]},Rn.takeWhile=function(t,e){return t&&t.length?di(t,uo(e,3)):[]},Rn.tap=function(t,e){return e(t),t},Rn.throttle=function(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new Et(r);return rs(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),za(t,e,{leading:i,maxWait:e,trailing:o})},Rn.thru=ma,Rn.toArray=_s,Rn.toPairs=Ps,Rn.toPairsIn=Vs,Rn.toPath=function(t){return qa(t)?De(t,Ro):fs(t)?[t]:Mi(Uo(ws(t)))},Rn.toPlainObject=vs,Rn.transform=function(t,e,n){var r=qa(t),i=r||Ja(t)||hs(t);if(e=uo(e,4),null==n){var o=t&&t.constructor;n=i?r?new o:[]:rs(t)&&ts(o)?Pn(qt(t)):{}}return(i?Te:vr)(t,(function(t,r,i){return e(n,t,r,i)})),n},Rn.unary=function(t){return Ea(t,1)},Rn.union=ia,Rn.unionBy=oa,Rn.unionWith=aa,Rn.uniq=function(t){return t&&t.length?li(t):[]},Rn.uniqBy=function(t,e){return t&&t.length?li(t,uo(e,2)):[]},Rn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?li(t,n,e):[]},Rn.unset=function(t,e){return null==t||fi(t,e)},Rn.unzip=sa,Rn.unzipWith=ua,Rn.update=function(t,e,n){return null==t?t:hi(t,e,yi(n))},Rn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:hi(t,e,yi(r),i)},Rn.values=$s,Rn.valuesIn=function(t){return null==t?[]:Ke(t,Ns(t))},Rn.without=ca,Rn.words=tu,Rn.wrap=function(t,e){return Ra(yi(e),t)},Rn.xor=la,Rn.xorBy=fa,Rn.xorWith=ha,Rn.zip=da,Rn.zipObject=function(t,e){return mi(t||[],e||[],er)},Rn.zipObjectDeep=function(t,e){return mi(t||[],e||[],Qr)},Rn.zipWith=pa,Rn.entries=Ps,Rn.entriesIn=Vs,Rn.extend=As,Rn.extendWith=Ss,lu(Rn,Rn),Rn.add=vu,Rn.attempt=eu,Rn.camelCase=Ys,Rn.capitalize=Ws,Rn.ceil=wu,Rn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=gs(r))==r?r:0),e!==n&&(e=(e=gs(e))==e?e:0),sr(gs(t),e,r)},Rn.clone=function(t){return ur(t,4)},Rn.cloneDeep=function(t){return ur(t,5)},Rn.cloneDeepWith=function(t,e){return ur(t,5,e="function"==typeof e?e:n)},Rn.cloneWith=function(t,e){return ur(t,4,e="function"==typeof e?e:n)},Rn.conformsTo=function(t,e){return null==e||cr(t,e,zs(e))},Rn.deburr=Gs,Rn.defaultTo=function(t,e){return null==t||t!=t?e:t},Rn.divide=xu,Rn.endsWith=function(t,e,r){t=ws(t),e=ci(e);var i=t.length,o=r=r===n?i:sr(bs(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},Rn.eq=$a,Rn.escape=function(t){return(t=ws(t))&&H.test(t)?t.replace(q,rn):t},Rn.escapeRegExp=function(t){return(t=ws(t))&&rt.test(t)?t.replace(nt,"\\$&"):t},Rn.every=function(t,e,r){var i=qa(t)?Me:pr;return r&&vo(t,e,r)&&(e=n),i(t,uo(e,3))},Rn.find=ga,Rn.findIndex=Go,Rn.findKey=function(t,e){return Ue(t,uo(e,3),vr)},Rn.findLast=va,Rn.findLastIndex=qo,Rn.findLastKey=function(t,e){return Ue(t,uo(e,3),wr)},Rn.floor=Au,Rn.forEach=wa,Rn.forEachRight=xa,Rn.forIn=function(t,e){return null==t?t:yr(t,uo(e,3),Ns)},Rn.forInRight=function(t,e){return null==t?t:gr(t,uo(e,3),Ns)},Rn.forOwn=function(t,e){return t&&vr(t,uo(e,3))},Rn.forOwnRight=function(t,e){return t&&wr(t,uo(e,3))},Rn.get=Ms,Rn.gt=Ya,Rn.gte=Wa,Rn.has=function(t,e){return null!=t&&mo(t,e,Tr)},Rn.hasIn=Es,Rn.head=Ho,Rn.identity=au,Rn.includes=function(t,e,n,r){t=Ha(t)?t:$s(t),n=n&&!r?bs(n):0;var i=t.length;return n<0&&(n=yn(i+n,0)),ls(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&Pe(t,e,n)>-1},Rn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:bs(n);return i<0&&(i=yn(r+i,0)),Pe(t,e,i)},Rn.inRange=function(t,e,r){return e=ms(e),r===n?(r=e,e=0):r=ms(r),function(t,e,n){return t>=gn(e,n)&&t=-9007199254740991&&t<=h},Rn.isSet=cs,Rn.isString=ls,Rn.isSymbol=fs,Rn.isTypedArray=hs,Rn.isUndefined=function(t){return t===n},Rn.isWeakMap=function(t){return is(t)&&_o(t)==B},Rn.isWeakSet=function(t){return is(t)&&"[object WeakSet]"==Ir(t)},Rn.join=function(t,e){return null==t?"":mn.call(t,e)},Rn.kebabCase=qs,Rn.last=Qo,Rn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=bs(r))<0?yn(i+o,0):gn(o,i-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,o):Re(t,$e,o,!0)},Rn.lowerCase=Xs,Rn.lowerFirst=Hs,Rn.lt=ds,Rn.lte=ps,Rn.max=function(t){return t&&t.length?_r(t,au,Or):n},Rn.maxBy=function(t,e){return t&&t.length?_r(t,uo(e,2),Or):n},Rn.mean=function(t){return Ye(t,au)},Rn.meanBy=function(t,e){return Ye(t,uo(e,2))},Rn.min=function(t){return t&&t.length?_r(t,au,Lr):n},Rn.minBy=function(t,e){return t&&t.length?_r(t,uo(e,2),Lr):n},Rn.stubArray=yu,Rn.stubFalse=gu,Rn.stubObject=function(){return{}},Rn.stubString=function(){return""},Rn.stubTrue=function(){return!0},Rn.multiply=Iu,Rn.nth=function(t,e){return t&&t.length?$r(t,bs(e)):n},Rn.noConflict=function(){return de._===this&&(de._=Pt),this},Rn.noop=fu,Rn.now=Ma,Rn.pad=function(t,e,n){t=ws(t);var r=(e=bs(e))?fn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return Yi(be(i),n)+t+Yi(_e(i),n)},Rn.padEnd=function(t,e,n){t=ws(t);var r=(e=bs(e))?fn(t):0;return e&&re){var i=t;t=e,e=i}if(r||t%1||e%1){var o=xn();return gn(t+o*(e-t+ce("1e-"+((o+"").length-1))),e)}return Xr(t,e)},Rn.reduce=function(t,e,n){var r=qa(t)?Ne:qe,i=arguments.length<3;return r(t,uo(e,4),n,i,hr)},Rn.reduceRight=function(t,e,n){var r=qa(t)?Ce:qe,i=arguments.length<3;return r(t,uo(e,4),n,i,dr)},Rn.repeat=function(t,e,r){return e=(r?vo(t,e,r):e===n)?1:bs(e),Hr(ws(t),e)},Rn.replace=function(){var t=arguments,e=ws(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Rn.result=function(t,e,r){var i=-1,o=(e=gi(e,t)).length;for(o||(o=1,t=n);++ih)return[];var n=p,r=gn(t,p);e=uo(e),t-=p;for(var i=He(r,e);++n=a)return t;var u=r-fn(i);if(u<1)return i;var c=s?wi(s,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(s&&(u+=c.length-u),us(o)){if(t.slice(u).search(o)){var l,f=c;for(o.global||(o=kt(o.source,ws(dt.exec(o))+"g")),o.lastIndex=0;l=o.exec(f);)var h=l.index;c=c.slice(0,h===n?u:h)}}else if(t.indexOf(ci(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},Rn.unescape=function(t){return(t=ws(t))&&X.test(t)?t.replace(G,pn):t},Rn.uniqueId=function(t){var e=++Ft;return ws(t)+e},Rn.upperCase=Ks,Rn.upperFirst=Qs,Rn.each=wa,Rn.eachRight=xa,Rn.first=Ho,lu(Rn,(Su={},vr(Rn,(function(t,e){Ct.call(Rn.prototype,e)||(Su[e]=t)})),Su),{chain:!1}),Rn.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Rn[t].placeholder=Rn})),Te(["drop","take"],(function(t,e){Yn.prototype[t]=function(r){r=r===n?1:yn(bs(r),0);var i=this.__filtered__&&!e?new Yn(this):this.clone();return i.__filtered__?i.__takeCount__=gn(r,i.__takeCount__):i.__views__.push({size:gn(r,p),type:t+(i.__dir__<0?"Right":"")}),i},Yn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;Yn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:uo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Yn.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Yn.prototype[t]=function(){return this.__filtered__?new Yn(this):this[n](1)}})),Yn.prototype.compact=function(){return this.filter(au)},Yn.prototype.find=function(t){return this.filter(t).head()},Yn.prototype.findLast=function(t){return this.reverse().find(t)},Yn.prototype.invokeMap=Zr((function(t,e){return"function"==typeof t?new Yn(this):this.map((function(n){return Er(n,t,e)}))})),Yn.prototype.reject=function(t){return this.filter(La(uo(t)))},Yn.prototype.slice=function(t,e){t=bs(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Yn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=bs(e))<0?r.dropRight(-e):r.take(e-t)),r)},Yn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Yn.prototype.toArray=function(){return this.take(p)},vr(Yn.prototype,(function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=Rn[i?"take"+("last"==e?"Right":""):e],a=i||/^find/.test(e);o&&(Rn.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,u=e instanceof Yn,c=s[0],l=u||qa(e),f=function(t){var e=o.apply(Rn,ze([t],s));return i&&h?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(u=l=!1);var h=this.__chain__,d=!!this.__actions__.length,p=a&&!h,_=u&&!d;if(!a&&l){e=_?e:new Yn(this);var m=t.apply(e,s);return m.__actions__.push({func:ma,args:[f],thisArg:n}),new $n(m,h)}return p&&_?t.apply(this,s):(m=this.thru(f),p?i?m.value()[0]:m.value():m)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Bt[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);Rn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(qa(i)?i:[],t)}return this[n]((function(n){return e.apply(qa(n)?n:[],t)}))}})),vr(Yn.prototype,(function(t,e){var n=Rn[e];if(n){var r=n.name+"";Ct.call(Bn,r)||(Bn[r]=[]),Bn[r].push({name:e,func:n})}})),Bn[Ri(n,2).name]=[{name:"wrapper",func:n}],Yn.prototype.clone=function(){var t=new Yn(this.__wrapped__);return t.__actions__=Mi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Mi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Mi(this.__views__),t},Yn.prototype.reverse=function(){if(this.__filtered__){var t=new Yn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Yn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=qa(t),r=e<0,i=n?t.length:0,o=function(t,e,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},Rn.prototype.plant=function(t){for(var e,r=this;r instanceof Vn;){var i=Vo(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},Rn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Yn){var e=t;return this.__actions__.length&&(e=new Yn(this)),(e=e.reverse()).__actions__.push({func:ma,args:[ra],thisArg:n}),new $n(e,this.__chain__)}return this.thru(ra)},Rn.prototype.toJSON=Rn.prototype.valueOf=Rn.prototype.value=function(){return pi(this.__wrapped__,this.__actions__)},Rn.prototype.first=Rn.prototype.head,te&&(Rn.prototype[te]=function(){return this}),Rn}();_e?((_e.exports=_n)._=_n,pe._=_n):de._=_n}).call(mn)}({get exports(){return xa},set exports(t){xa=t}},xa);const Aa={sqrt:function(){return oa.apply(null,arguments).exponent(.5)},log:function t(){const e=ta(Mo()).domain([1,10]);return e.copy=()=>ko(e,t()).base(e.base()),yo.apply(e,arguments),e},linear:qo,literal:function t(e){var n;function r(t){return null==t||isNaN(t=+t)?n:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(e=Array.from(t,xo),r):e.slice()},r.unknown=function(t){return arguments.length?(n=t,r):n},r.copy=function(){return t(e).unknown(n)},e=arguments.length?Array.from(e,xo):[0,1],Go(r)}};class Sa{constructor(t,e,n,r){if(this._transform="linear",this.field=null,this._texture_buffer=null,this.partner=null,this._textures={},this.current_encoding=null,this.aesthetic_map=r,void 0===this.aesthetic_map)throw new Error("Aesthetic map is undefined");this.scatterplot=t,this.regl=e,this._range=[0,1],this.dataset=n,this.id=Math.random().toString()}apply(t){return void 0===this.scale?this.default_constant:this.scale(this.value_for(t))}get transform(){return this._transform?this._transform:this.default_transform}set transform(t){this._transform=t}get scale(){if(this._scale)return this._scale;if(this.is_dictionary())throw new Error("Dictionary scales only supported for colors");const t=Aa[this.transform]();return t.domain(this.domain).range(this.range),this._scale=t}get column(){var t,e;if(null===this.field)throw new Error("Can't retrieve column for aesthetic without a field");if(null==(e=null==(t=this.dataset)?void 0:t.root_tile)?void 0:e.record_batch){const t=this.dataset.root_tile.record_batch.getChild(this.field);if(null==t)throw new Error("Can't find column "+this.field);return t}throw new Error("Table is null")}get default_domain(){var t;if(null==this.field)return[1,1];if(!this.scatterplot._root._schema)return[1,1];const{column:e}=this;return e?void 0!==(null==(t=e.type)?void 0:t.dictionary)?[0,this.aesthetic_map.texture_size]:(this.dataset.domain(this.field),this.dataset.domain(this.field)):[1,1]}default_data(){const t=this.toGLType(this.default_constant);return Array(this.aesthetic_map.texture_size).fill(t)}get webGLDomain(){return this.is_dictionary()?[0,4096]:this.domain}get domain(){return void 0===this._domain&&(this._domain=this.default_domain),this._domain||this.default_domain}get range(){return this._range||this.default_range}value_for(t){return this.field&&t[this.field]?t[this.field]:null}get map_position(){return 0===this.use_map_on_regl?0:this.aesthetic_map.get_position(this.id)}get texture_buffer(){return this._texture_buffer||(this._texture_buffer=new Float32Array(this.aesthetic_map.texture_size),this._texture_buffer.set(this.default_data())),this._texture_buffer}post_to_regl_buffer(){this.aesthetic_map.set_one_d(this.id,this.texture_buffer)}convert_string_encoding(t){return{field:t,domain:this.default_domain,range:this.default_range}}complete_domain(t){return t.domain=t.domain||this.default_domain,t}reset_to_defaults(){this._domain=this.default_domain,this._range=[0,1],this._transform=void 0,this._constant=this.default_constant,this.field=null,this.current_encoding=null,this._scale=void 0}update(t){var e;if(void 0!==t){if(null===t||"null"===t)return this.current_encoding=null,void this.reset_to_defaults();if(this._scale=void 0,"string"==typeof t&&(t=this.convert_string_encoding(t)),xa.isNumber(t)){const e={constant:t};this.current_encoding=e}else{if(0===Object.keys(t).length)return console.warn("Resetting parameters with an empty object is deprecated: use 'null'"),void this.reset_to_defaults();if(this.current_encoding=t,!wa(t)&&(this.field=t.field,!ga(t)))if(va(t)){const{lambda:e,field:n}=t;e&&(this.apply_function_for_textures(n,this.domain,e),this.post_to_regl_buffer())}else void 0===t.domain&&(t.domain=this.default_domain),t.range&&(this._domain=t.domain,this._range=t.range),this._transform=null!=(e=t.transform)?e:void 0}}else console.warn("Should never be calling update with undefined.")}encode_for_textures(t){const{texture_size:e}=this.aesthetic_map,n=Array(e),r=Aa[this.transform]().range(t).domain([0,e-1]);for(let i=0;i",2).map((t=>t.trim())),a=new Function(i,o);return a}(Ba(t)):t;return this._func=e,e}apply_function_for_textures(t,e,n){var r;const{texture_size:i}=this.aesthetic_map,o=this.materialize_function(n);let a=Nt(i);if(void 0===t||void 0===this.dataset.root_tile.record_batch)return void 0===t&&console.warn("SETTING EMPTY FIELD"),void 0===this.dataset.root_tile.record_batch&&console.warn("SETTING EMPTY TABLE"),void this.texture_buffer.set(Nt(i).map((t=>1)));const{column:s}=this;if(!s)throw new Error(`Column ${t} does not exist on table.`);if(null==(r=null==s?void 0:s.type)?void 0:r.dictionary){a.fill("");const t=s.data[0].dictionary.toArray();for(const[e,n]of t.entries())a[e]=n}else a=a.map((t=>this.scale(t)));const u=a.map((t=>o(t)));this.texture_buffer.set(u)}}class Ia extends Sa{constructor(t,e,n,r){super(t,e,n,r),this.current_encoding=null}toGLType(t){return t}static get_default_domain(){return[0,1]}get default_domain(){return[0,1]}}class Oa extends Ia{constructor(t,e,n,r){super(t,e,n,r),this.default_range=[-1,1],this.default_constant=0,this.default_transform="literal",this._constant=0,this._transform="literal"}get range(){return this._range?this._range:this.dataset.extent&&this.field&&this.dataset.extent[this.field]?this.dataset.extent[this.field]:this.default_range}static get default_constant(){return 0}}class Ta extends Oa{constructor(){super(...arguments),this.field="x"}}class ka extends Oa{constructor(){super(...arguments),this.field="y"}}class Ma extends Sa{constructor(t,e,n,r){super(t,e,n,r)}toGLType(t){return t?1:0}update(t){super.update(t),null!==this.current_encoding&&0===Object.keys(this.current_encoding).length&&(this.current_encoding=null)}ops_to_array(){const t=this.current_encoding;if(null===t)return[0,0,0];if(void 0===t)return[0,0,0];if(!ga(t))return[0,0,0];if("within"===t.op)return[4,t.a,t.b];if("between"===t.op)return[4,(t.b-t.a)/2,(t.b+t.a)/2];return[[null,"lt","gt","eq"].indexOf(t.op),t.a,0]}apply(t){const e=this.current_encoding;if(null==e)return!0;if(ga(e))return this.apply_op(t,e);if(wa(e))return 0===e.constant?(console.warn("Deprecated: pass `true` or `false` to boolean fields, not numbers"),!1):1===e.constant?(console.warn("Deprecated: pass `true` or `false` to boolean fields, not numbers"),!0):e.constant;if(va(e)){if(void 0===this._func)throw new Error("_func should have been bound"+JSON.stringify(this.current_encoding));const e=this.value_for(t);return null!==e&&!!this._func(e)}return!0}apply_op(t,e){const{op:n,a:r}=e,i=this.value_for(t);if(null===i)return!1;if("eq"===n)return i==r;if("gt"===n)return i>r;if("lt"===n)return i").map((t=>t.trim()));if(void 0===n)throw new Error(`Couldn't parse ${t} into a function`);"{"!==n.slice(0,1)&&"return"!==n.slice(0,6)&&(n=`return ${n}`);return{field:e,lambda:`${e} => ${n}`}}function ja(t){for(var e=t.length/6|0,n=new Array(e),r=0;rQr(t[t.length-1]);var Ya=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(ja);const Wa=$a(Ya);var Ga=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(ja);const qa=$a(Ga);var Xa=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(ja);const Ha=$a(Xa);var Za=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(ja);const Ja=$a(Za);var Ka=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(ja);const Qa=$a(Ka);var ts=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(ja);const es=$a(ts);var ns=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(ja);const rs=$a(ns);var is=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(ja);const os=$a(is);var as=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(ja);const ss=$a(as);var us=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(ja);const cs=$a(us);var ls=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(ja);const fs=$a(ls);var hs=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(ja);const ds=$a(hs);var ps=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(ja);const _s=$a(ps);var ms=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(ja);const bs=$a(ms);var ys=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(ja);const gs=$a(ys);var vs=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(ja);const ws=$a(vs);var xs=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(ja);const As=$a(xs);var Ss=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(ja);const Is=$a(Ss);var Os=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(ja);const Ts=$a(Os);var ks=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(ja);const Ms=$a(ks);var Es=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(ja);const Bs=$a(Es);var js=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(ja);const Ds=$a(js);var zs=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(ja);const Ns=$a(zs);var Cs=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(ja);const Fs=$a(Cs);var Ls=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(ja);const Us=$a(Ls);var Rs=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(ja);const Ps=$a(Rs);var Vs=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(ja);const $s=$a(Vs);const Ys=vi(Wr(300,.5,0),Wr(-240,.5,1));var Ws=vi(Wr(-100,.75,.35),Wr(80,1.5,.8)),Gs=vi(Wr(260,.75,.35),Wr(80,1.5,.8)),qs=Wr();var Xs=xr(),Hs=Math.PI/3,Zs=2*Math.PI/3;function Js(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}const Ks=Js(ja("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var Qs=Js(ja("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),tu=Js(ja("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),eu=Js(ja("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));const nu=Object.freeze(Object.defineProperty({__proto__:null,interpolateBlues:Ds,interpolateBrBG:Wa,interpolateBuGn:cs,interpolateBuPu:fs,interpolateCividis:function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},interpolateCool:Gs,interpolateCubehelixDefault:Ys,interpolateGnBu:ds,interpolateGreens:Ns,interpolateGreys:Fs,interpolateInferno:tu,interpolateMagma:Qs,interpolateOrRd:_s,interpolateOranges:$s,interpolatePRGn:qa,interpolatePiYG:Ha,interpolatePlasma:eu,interpolatePuBu:gs,interpolatePuBuGn:bs,interpolatePuOr:Ja,interpolatePuRd:ws,interpolatePurples:Us,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return qs.h=360*t-100,qs.s=1.5-1.5*e,qs.l=.8-.9*e,qs+""},interpolateRdBu:Qa,interpolateRdGy:es,interpolateRdPu:As,interpolateRdYlBu:rs,interpolateRdYlGn:os,interpolateReds:Ps,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,Xs.r=255*(e=Math.sin(t))*e,Xs.g=255*(e=Math.sin(t+Hs))*e,Xs.b=255*(e=Math.sin(t+Zs))*e,Xs+""},interpolateSpectral:ss,interpolateTurbo:function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},interpolateViridis:Ks,interpolateWarm:Ws,interpolateYlGn:Ts,interpolateYlGnBu:Is,interpolateYlOrBr:Ms,interpolateYlOrRd:Bs,schemeAccent:za,schemeBlues:js,schemeBrBG:Ya,schemeBuGn:us,schemeBuPu:ls,schemeCategory10:Da,schemeDark2:Na,schemeGnBu:hs,schemeGreens:zs,schemeGreys:Cs,schemeOrRd:ps,schemeOranges:Vs,schemePRGn:Ga,schemePaired:Ca,schemePastel1:Fa,schemePastel2:La,schemePiYG:Xa,schemePuBu:ys,schemePuBuGn:ms,schemePuOr:Za,schemePuRd:vs,schemePurples:Ls,schemeRdBu:Ka,schemeRdGy:ts,schemeRdPu:xs,schemeRdYlBu:ns,schemeRdYlGn:is,schemeReds:Rs,schemeSet1:Ua,schemeSet2:Ra,schemeSet3:Pa,schemeSpectral:as,schemeTableau10:Va,schemeYlGn:Os,schemeYlGnBu:Ss,schemeYlOrBr:ks,schemeYlOrRd:Es},Symbol.toStringTag,{value:"Module"})),ru=1664525,iu=1013904223,ou=1/4294967296;function au(t=Math.random()){let e=0|(0<=t&&t<1?t/ou:Math.abs(t));return()=>(e=ru*e+iu|0,ou*(e>>>0))}const su=4096;function uu(t){const e=new Uint8Array(4*su);return Nt(su).forEach((n=>{const r=xr(t(n/su));e.set([r.r,r.g,r.b,255],4*n)})),e}const cu={white:new Uint8Array(4*su).fill(255)},lu={};function fu(t){const e=t.map((t=>{const e=xr(t);return[e.r,e.g,e.b,255]})),n=new Uint8Array(4*su),r=Math.floor(su/t.length);for(let i=0;i[t,e]))),i=[];for(let e=0;e=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function yu(t){return this instanceof yu?(this.v=t,this):new yu(t)}function gu(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),o=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){o.push([t,e,n,r])>1||s(t,e)}))})}function s(t,e){try{(n=i[t](e)).value instanceof yu?Promise.resolve(n.value.v).then(u,c):l(o[0][2],n)}catch(r){l(o[0][3],r)}var n}function u(t){s("next",t)}function c(t){s("throw",t)}function l(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function vu(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:yu(t[r](e)),done:!1}:i?i(e):e}:i}}function wu(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=bu(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;const xu=new TextDecoder("utf-8"),Au=t=>xu.decode(t),Su=new TextEncoder,Iu=t=>Su.encode(t),Ou=t=>"function"==typeof t,Tu=t=>null!=t&&Object(t)===t,ku=t=>Tu(t)&&Ou(t.then),Mu=t=>Tu(t)&&Ou(t[Symbol.iterator]),Eu=t=>Tu(t)&&Ou(t[Symbol.asyncIterator]),Bu=t=>Tu(t)&&Tu(t.schema),ju=t=>Tu(t)&&"done"in t&&"value"in t,Du=t=>Tu(t)&&Ou(t.stat)&&(t=>"number"==typeof t)(t.fd),zu=t=>Tu(t)&&Cu(t.body),Nu=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Cu=t=>Tu(t)&&Ou(t.cancel)&&Ou(t.getReader)&&!Nu(t),Fu=t=>Tu(t)&&Ou(t.read)&&Ou(t.pipe)&&(t=>"boolean"==typeof t)(t.readable)&&!Nu(t),Lu=t=>Tu(t)&&Ou(t.clear)&&Ou(t.bytes)&&Ou(t.position)&&Ou(t.setPosition)&&Ou(t.capacity)&&Ou(t.getBufferIdentifier)&&Ou(t.createLong),Uu="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Ru(t,e,n=0,r=e.byteLength){const i=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,i),a=new Uint8Array(e.buffer,e.byteOffset,Math.min(r,i));return o.set(a,n),t}function Pu(t,e){const n=function(t){const e=t[0]?[t[0]]:[];let n,r,i,o;for(let a,s,u=0,c=0,l=t.length;++ut+e.byteLength),0);let i,o,a,s=0,u=-1;const c=Math.min(e||Number.POSITIVE_INFINITY,r);for(const l=n.length;++uVu(Int32Array,t),Yu=t=>Vu(Uint8Array,t),Wu=t=>(t.next(),t);const Gu=t=>function*(t,e){const n=function*(t){yield t},r="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Uu?n(e):Mu(e)?e:n(e);return yield*Wu(function*(e){let n=null;do{n=e.next(yield Vu(t,n))}while(!n.done)}(r[Symbol.iterator]())),new t}(Uint8Array,t);function qu(t,e){return gu(this,arguments,(function*(){if(ku(e))return yield yu(yield yu(yield*vu(wu(qu(t,yield yu(e))))));const n=function(t){return gu(this,arguments,(function*(){yield yield yu(yield yu(t))}))},r="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Uu?n(e):Mu(e)?function(t){return gu(this,arguments,(function*(){yield yu(yield*vu(wu(Wu(function*(t){let e=null;do{e=t.next(yield null==e?void 0:e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):Eu(e)?e:n(e);return yield yu(yield*vu(wu(Wu(function(e){return gu(this,arguments,(function*(){let n=null;do{n=yield yu(e.next(yield yield yu(Vu(t,n))))}while(!n.done)}))}(r[Symbol.asyncIterator]()))))),yield yu(new t)}))}const Xu=t=>qu(Uint8Array,t);const Hu={fromIterable:t=>Zu(function*(t){let e,n,r,i,o=!1,a=[],s=0;function u(){return"peek"===r?Pu(a,i)[0]:([n,a,s]=Pu(a,i),n)}({cmd:r,size:i}=yield null);const c=Gu(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=Number.isNaN(i-s)?c.next():c.next(i-s)),!e&&n.byteLength>0&&(a.push(n),s+=n.byteLength),e||i<=s)do{({cmd:r,size:i}=yield u())}while(iZu(function(t){return gu(this,arguments,(function*(){let e,n,r,i,o=!1,a=[],s=0;function u(){return"peek"===r?Pu(a,i)[0]:([n,a,s]=Pu(a,i),n)}({cmd:r,size:i}=yield yield yu(null));const c=Xu(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=Number.isNaN(i-s)?yield yu(c.next()):yield yu(c.next(i-s))),!e&&n.byteLength>0&&(a.push(n),s+=n.byteLength),e||i<=s)do{({cmd:r,size:i}=yield yield yu(u()))}while(iZu(function(t){return gu(this,arguments,(function*(){let e,n,r,i=!1,o=!1,a=[],s=0;function u(){return"peek"===n?Pu(a,r)[0]:([e,a,s]=Pu(a,r),e)}({cmd:n,size:r}=yield yield yu(null));const c=new Ju(t);try{do{if(({done:i,value:e}=Number.isNaN(r-s)?yield yu(c.read()):yield yu(c.read(r-s))),!i&&e.byteLength>0&&(a.push(Yu(e)),s+=e.byteLength),i||r<=s)do{({cmd:n,size:r}=yield yield yu(u()))}while(rZu(function(t){return gu(this,arguments,(function*(){const e=[];let n,r,i,o="error",a=!1,s=null,u=0,c=[];function l(){return"peek"===n?Pu(c,r)[0]:([i,c,u]=Pu(c,r),i)}if(({cmd:n,size:r}=yield yield yu(null)),t.isTTY)return yield yield yu(new Uint8Array(0)),yield yu(null);try{e[0]=Ku(t,"end"),e[1]=Ku(t,"error");do{if(e[2]=Ku(t,"readable"),[o,s]=yield yu(Promise.race(e.map((t=>t[2])))),"error"===o)break;if((a="end"===o)||(Number.isFinite(r-u)?(i=Yu(t.read(r-u)),i.byteLength0&&(c.push(i),u+=i.byteLength)),a||r<=u)do{({cmd:n,size:r}=yield yield yu(l()))}while(r{for(const[n,a]of e)t.off(n,a);try{const e=t.destroy;e&&e.call(t,n),n=void 0}catch(o){n=o||n}finally{null!=n?i(n):r()}}))}}))}(t)),toDOMStream(t,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(t,e){throw new Error('"toNodeStream" not available in this environment')}},Zu=t=>(t.next(),t);class Ju{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch((()=>{}))}get closed(){return this.reader?this.reader.closed.catch((()=>{})):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return mu(this,void 0,void 0,(function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch((()=>{}))),n&&n.locked&&this.releaseLock()}))}read(t){return mu(this,void 0,void 0,(function*(){if(0===t)return{done:null==this.reader,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=Yu(e)),e}))}}const Ku=(t,e)=>{const n=t=>r([e,t]);let r;return[e,n,new Promise((i=>(r=i)&&t.once(e,n)))]};var Qu,tc,ec,nc,rc,ic,oc,ac,sc,uc,cc,lc,fc,hc,dc,pc,_c,mc;(tc=Qu||(Qu={}))[tc.V1=0]="V1",tc[tc.V2=1]="V2",tc[tc.V3=2]="V3",tc[tc.V4=3]="V4",tc[tc.V5=4]="V5",(nc=ec||(ec={}))[nc.Sparse=0]="Sparse",nc[nc.Dense=1]="Dense",(ic=rc||(rc={}))[ic.HALF=0]="HALF",ic[ic.SINGLE=1]="SINGLE",ic[ic.DOUBLE=2]="DOUBLE",(ac=oc||(oc={}))[ac.DAY=0]="DAY",ac[ac.MILLISECOND=1]="MILLISECOND",(uc=sc||(sc={}))[uc.SECOND=0]="SECOND",uc[uc.MILLISECOND=1]="MILLISECOND",uc[uc.MICROSECOND=2]="MICROSECOND",uc[uc.NANOSECOND=3]="NANOSECOND",(lc=cc||(cc={}))[lc.YEAR_MONTH=0]="YEAR_MONTH",lc[lc.DAY_TIME=1]="DAY_TIME",lc[lc.MONTH_DAY_NANO=2]="MONTH_DAY_NANO",(hc=fc||(fc={}))[hc.NONE=0]="NONE",hc[hc.Schema=1]="Schema",hc[hc.DictionaryBatch=2]="DictionaryBatch",hc[hc.RecordBatch=3]="RecordBatch",hc[hc.Tensor=4]="Tensor",hc[hc.SparseTensor=5]="SparseTensor",(pc=dc||(dc={}))[pc.NONE=0]="NONE",pc[pc.Null=1]="Null",pc[pc.Int=2]="Int",pc[pc.Float=3]="Float",pc[pc.Binary=4]="Binary",pc[pc.Utf8=5]="Utf8",pc[pc.Bool=6]="Bool",pc[pc.Decimal=7]="Decimal",pc[pc.Date=8]="Date",pc[pc.Time=9]="Time",pc[pc.Timestamp=10]="Timestamp",pc[pc.Interval=11]="Interval",pc[pc.List=12]="List",pc[pc.Struct=13]="Struct",pc[pc.Union=14]="Union",pc[pc.FixedSizeBinary=15]="FixedSizeBinary",pc[pc.FixedSizeList=16]="FixedSizeList",pc[pc.Map=17]="Map",pc[pc.Dictionary=-1]="Dictionary",pc[pc.Int8=-2]="Int8",pc[pc.Int16=-3]="Int16",pc[pc.Int32=-4]="Int32",pc[pc.Int64=-5]="Int64",pc[pc.Uint8=-6]="Uint8",pc[pc.Uint16=-7]="Uint16",pc[pc.Uint32=-8]="Uint32",pc[pc.Uint64=-9]="Uint64",pc[pc.Float16=-10]="Float16",pc[pc.Float32=-11]="Float32",pc[pc.Float64=-12]="Float64",pc[pc.DateDay=-13]="DateDay",pc[pc.DateMillisecond=-14]="DateMillisecond",pc[pc.TimestampSecond=-15]="TimestampSecond",pc[pc.TimestampMillisecond=-16]="TimestampMillisecond",pc[pc.TimestampMicrosecond=-17]="TimestampMicrosecond",pc[pc.TimestampNanosecond=-18]="TimestampNanosecond",pc[pc.TimeSecond=-19]="TimeSecond",pc[pc.TimeMillisecond=-20]="TimeMillisecond",pc[pc.TimeMicrosecond=-21]="TimeMicrosecond",pc[pc.TimeNanosecond=-22]="TimeNanosecond",pc[pc.DenseUnion=-23]="DenseUnion",pc[pc.SparseUnion=-24]="SparseUnion",pc[pc.IntervalDayTime=-25]="IntervalDayTime",pc[pc.IntervalYearMonth=-26]="IntervalYearMonth",(mc=_c||(_c={}))[mc.OFFSET=0]="OFFSET",mc[mc.DATA=1]="DATA",mc[mc.VALIDITY=2]="VALIDITY",mc[mc.TYPE=3]="TYPE";const bc=void 0;function yc(t){if(null===t)return"null";if(t===bc)return"undefined";switch(typeof t){case"number":case"bigint":return`${t}`;case"string":return`"${t}"`}return"function"==typeof t[Symbol.toPrimitive]?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map((t=>yc(t)))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,((t,e)=>"bigint"==typeof e?`${e}`:e))}const gc=Symbol.for("isArrowBigNum");function vc(t,...e){return 0===e.length?Object.setPrototypeOf(Vu(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}function wc(...t){return vc.apply(this,t)}function xc(...t){return vc.apply(this,t)}function Ac(...t){return vc.apply(this,t)}function Sc(t){const{buffer:e,byteOffset:n,length:r,signed:i}=t,o=new BigUint64Array(e,n,r),a=i&&o.at(-1)&BigInt(1)<{if(8===t.byteLength){return`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`}if(!t.signed)return Tc(t);let e=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);if(new Int16Array([e.at(-1)])[0]>=0)return Tc(t);e=e.slice();let n=1;for(let r=0;r{if(8===t.byteLength){return new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}return Ic(t)};function Tc(t){let e="";const n=new Uint32Array(2);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let o=-1;const a=r.length-1;do{for(n[0]=r[o=0];oNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}var Ec,Bc,jc,Dc,zc,Nc,Cc,Fc,Lc,Uc,Rc,Pc,Vc,$c,Yc,Wc,Gc,qc,Xc,Hc;class Zc{static isNull(t){return(null==t?void 0:t.typeId)===dc.Null}static isInt(t){return(null==t?void 0:t.typeId)===dc.Int}static isFloat(t){return(null==t?void 0:t.typeId)===dc.Float}static isBinary(t){return(null==t?void 0:t.typeId)===dc.Binary}static isUtf8(t){return(null==t?void 0:t.typeId)===dc.Utf8}static isBool(t){return(null==t?void 0:t.typeId)===dc.Bool}static isDecimal(t){return(null==t?void 0:t.typeId)===dc.Decimal}static isDate(t){return(null==t?void 0:t.typeId)===dc.Date}static isTime(t){return(null==t?void 0:t.typeId)===dc.Time}static isTimestamp(t){return(null==t?void 0:t.typeId)===dc.Timestamp}static isInterval(t){return(null==t?void 0:t.typeId)===dc.Interval}static isList(t){return(null==t?void 0:t.typeId)===dc.List}static isStruct(t){return(null==t?void 0:t.typeId)===dc.Struct}static isUnion(t){return(null==t?void 0:t.typeId)===dc.Union}static isFixedSizeBinary(t){return(null==t?void 0:t.typeId)===dc.FixedSizeBinary}static isFixedSizeList(t){return(null==t?void 0:t.typeId)===dc.FixedSizeList}static isMap(t){return(null==t?void 0:t.typeId)===dc.Map}static isDictionary(t){return(null==t?void 0:t.typeId)===dc.Dictionary}static isDenseUnion(t){return Zc.isUnion(t)&&t.mode===ec.Dense}static isSparseUnion(t){return Zc.isUnion(t)&&t.mode===ec.Sparse}get typeId(){return dc.NONE}}Ec=Symbol.toStringTag,Zc[Ec]=((Hc=Zc.prototype).children=null,Hc.ArrayType=Array,Hc[Symbol.toStringTag]="DataType");let Jc=class extends Zc{toString(){return"Null"}get typeId(){return dc.Null}};Bc=Symbol.toStringTag,Jc[Bc]=(t=>t[Symbol.toStringTag]="Null")(Jc.prototype);class Kc extends Zc{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return dc.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}jc=Symbol.toStringTag,Kc[jc]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Kc.prototype);class Qc extends Kc{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class tl extends Kc{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class el extends Kc{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}let nl=class extends Kc{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}};class rl extends Kc{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}class il extends Kc{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class ol extends Kc{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}let al=class extends Kc{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Qc.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(tl.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(el.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(nl.prototype,"ArrayType",{value:BigInt64Array}),Object.defineProperty(rl.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(il.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(ol.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(al.prototype,"ArrayType",{value:BigUint64Array});class sl extends Zc{constructor(t){super(),this.precision=t}get typeId(){return dc.Float}get ArrayType(){switch(this.precision){case rc.HALF:return Uint16Array;case rc.SINGLE:return Float32Array;case rc.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Dc=Symbol.toStringTag,sl[Dc]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(sl.prototype);class ul extends sl{constructor(){super(rc.SINGLE)}}class cl extends sl{constructor(){super(rc.DOUBLE)}}Object.defineProperty(ul.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(cl.prototype,"ArrayType",{value:Float64Array});let ll=class extends Zc{constructor(){super()}get typeId(){return dc.Binary}toString(){return"Binary"}};zc=Symbol.toStringTag,ll[zc]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(ll.prototype);let fl=class extends Zc{constructor(){super()}get typeId(){return dc.Utf8}toString(){return"Utf8"}};Nc=Symbol.toStringTag,fl[Nc]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(fl.prototype);let hl=class extends Zc{constructor(){super()}get typeId(){return dc.Bool}toString(){return"Bool"}};Cc=Symbol.toStringTag,hl[Cc]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(hl.prototype);let dl=class extends Zc{constructor(t,e,n=128){super(),this.scale=t,this.precision=e,this.bitWidth=n}get typeId(){return dc.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Fc=Symbol.toStringTag,dl[Fc]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(dl.prototype);class pl extends Zc{constructor(t){super(),this.unit=t}get typeId(){return dc.Date}toString(){return`Date${32*(this.unit+1)}<${oc[this.unit]}>`}}Lc=Symbol.toStringTag,pl[Lc]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(pl.prototype);class _l extends pl{constructor(){super(oc.MILLISECOND)}}class ml extends Zc{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return dc.Time}toString(){return`Time${this.bitWidth}<${sc[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Uc=Symbol.toStringTag,ml[Uc]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(ml.prototype);class bl extends Zc{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return dc.Timestamp}toString(){return`Timestamp<${sc[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Rc=Symbol.toStringTag,bl[Rc]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(bl.prototype);class yl extends Zc{constructor(t){super(),this.unit=t}get typeId(){return dc.Interval}toString(){return`Interval<${cc[this.unit]}>`}}Pc=Symbol.toStringTag,yl[Pc]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(yl.prototype);let gl=class extends Zc{constructor(t){super(),this.children=[t]}get typeId(){return dc.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Vc=Symbol.toStringTag,gl[Vc]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(gl.prototype);class vl extends Zc{constructor(t){super(),this.children=t}get typeId(){return dc.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}$c=Symbol.toStringTag,vl[$c]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(vl.prototype);class wl extends Zc{constructor(t,e,n){super(),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce(((t,e,n)=>(t[e]=n)&&t||t),Object.create(null))}get typeId(){return dc.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}Yc=Symbol.toStringTag,wl[Yc]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(wl.prototype);let xl=class extends Zc{constructor(t){super(),this.byteWidth=t}get typeId(){return dc.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Wc=Symbol.toStringTag,xl[Wc]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(xl.prototype);let Al=class extends Zc{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return dc.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};Gc=Symbol.toStringTag,Al[Gc]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Al.prototype);class Sl extends Zc{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return dc.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}qc=Symbol.toStringTag,Sl[qc]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Sl.prototype);const Il=(Ol=-1,()=>++Ol);var Ol;class Tl extends Zc{constructor(t,e,n,r){super(),this.indices=e,this.dictionary=t,this.isOrdered=r||!1,this.id=null==n?Il():Mc(n)}get typeId(){return dc.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}function kl(t){const e=t;switch(t.typeId){case dc.Decimal:return t.bitWidth/32;case dc.Timestamp:return 2;case dc.Date:case dc.Interval:return 1+e.unit;case dc.FixedSizeList:return e.listSize;case dc.FixedSizeBinary:return e.byteWidth;default:return 1}}Xc=Symbol.toStringTag,Tl[Xc]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Tl.prototype);class Ml{visitMany(t,...e){return t.map(((t,n)=>this.visit(t,...e.map((t=>t[n])))))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return function(t,e,n=!0){if("number"==typeof e)return El(t,e,n);if("string"==typeof e&&e in dc)return El(t,dc[e],n);if(e&&e instanceof Zc)return El(t,Bl(e),n);if((null==e?void 0:e.type)&&e.type instanceof Zc)return El(t,Bl(e.type),n);return El(t,dc.NONE,n)}(this,t,e)}getVisitFnByTypeId(t,e=!0){return El(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function El(t,e,n=!0){let r=null;switch(e){case dc.Null:r=t.visitNull;break;case dc.Bool:r=t.visitBool;break;case dc.Int:r=t.visitInt;break;case dc.Int8:r=t.visitInt8||t.visitInt;break;case dc.Int16:r=t.visitInt16||t.visitInt;break;case dc.Int32:r=t.visitInt32||t.visitInt;break;case dc.Int64:r=t.visitInt64||t.visitInt;break;case dc.Uint8:r=t.visitUint8||t.visitInt;break;case dc.Uint16:r=t.visitUint16||t.visitInt;break;case dc.Uint32:r=t.visitUint32||t.visitInt;break;case dc.Uint64:r=t.visitUint64||t.visitInt;break;case dc.Float:r=t.visitFloat;break;case dc.Float16:r=t.visitFloat16||t.visitFloat;break;case dc.Float32:r=t.visitFloat32||t.visitFloat;break;case dc.Float64:r=t.visitFloat64||t.visitFloat;break;case dc.Utf8:r=t.visitUtf8;break;case dc.Binary:r=t.visitBinary;break;case dc.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case dc.Date:r=t.visitDate;break;case dc.DateDay:r=t.visitDateDay||t.visitDate;break;case dc.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case dc.Timestamp:r=t.visitTimestamp;break;case dc.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case dc.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case dc.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case dc.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case dc.Time:r=t.visitTime;break;case dc.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case dc.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case dc.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case dc.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case dc.Decimal:r=t.visitDecimal;break;case dc.List:r=t.visitList;break;case dc.Struct:r=t.visitStruct;break;case dc.Union:r=t.visitUnion;break;case dc.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case dc.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case dc.Dictionary:r=t.visitDictionary;break;case dc.Interval:r=t.visitInterval;break;case dc.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case dc.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case dc.FixedSizeList:r=t.visitFixedSizeList;break;case dc.Map:r=t.visitMap}if("function"==typeof r)return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${dc[e]}'`)}function Bl(t){switch(t.typeId){case dc.Null:return dc.Null;case dc.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?dc.Int8:dc.Uint8;case 16:return n?dc.Int16:dc.Uint16;case 32:return n?dc.Int32:dc.Uint32;case 64:return n?dc.Int64:dc.Uint64}return dc.Int}case dc.Float:switch(t.precision){case rc.HALF:return dc.Float16;case rc.SINGLE:return dc.Float32;case rc.DOUBLE:return dc.Float64}return dc.Float;case dc.Binary:return dc.Binary;case dc.Utf8:return dc.Utf8;case dc.Bool:return dc.Bool;case dc.Decimal:return dc.Decimal;case dc.Time:switch(t.unit){case sc.SECOND:return dc.TimeSecond;case sc.MILLISECOND:return dc.TimeMillisecond;case sc.MICROSECOND:return dc.TimeMicrosecond;case sc.NANOSECOND:return dc.TimeNanosecond}return dc.Time;case dc.Timestamp:switch(t.unit){case sc.SECOND:return dc.TimestampSecond;case sc.MILLISECOND:return dc.TimestampMillisecond;case sc.MICROSECOND:return dc.TimestampMicrosecond;case sc.NANOSECOND:return dc.TimestampNanosecond}return dc.Timestamp;case dc.Date:switch(t.unit){case oc.DAY:return dc.DateDay;case oc.MILLISECOND:return dc.DateMillisecond}return dc.Date;case dc.Interval:switch(t.unit){case cc.DAY_TIME:return dc.IntervalDayTime;case cc.YEAR_MONTH:return dc.IntervalYearMonth}return dc.Interval;case dc.Map:return dc.Map;case dc.List:return dc.List;case dc.Struct:return dc.Struct;case dc.Union:switch(t.mode){case ec.Dense:return dc.DenseUnion;case ec.Sparse:return dc.SparseUnion}return dc.Union;case dc.FixedSizeBinary:return dc.FixedSizeBinary;case dc.FixedSizeList:return dc.FixedSizeList;case dc.Dictionary:return dc.Dictionary}throw new Error(`Unrecognized type '${dc[t.typeId]}'`)}Ml.prototype.visitInt8=null,Ml.prototype.visitInt16=null,Ml.prototype.visitInt32=null,Ml.prototype.visitInt64=null,Ml.prototype.visitUint8=null,Ml.prototype.visitUint16=null,Ml.prototype.visitUint32=null,Ml.prototype.visitUint64=null,Ml.prototype.visitFloat16=null,Ml.prototype.visitFloat32=null,Ml.prototype.visitFloat64=null,Ml.prototype.visitDateDay=null,Ml.prototype.visitDateMillisecond=null,Ml.prototype.visitTimestampSecond=null,Ml.prototype.visitTimestampMillisecond=null,Ml.prototype.visitTimestampMicrosecond=null,Ml.prototype.visitTimestampNanosecond=null,Ml.prototype.visitTimeSecond=null,Ml.prototype.visitTimeMillisecond=null,Ml.prototype.visitTimeMicrosecond=null,Ml.prototype.visitTimeNanosecond=null,Ml.prototype.visitDenseUnion=null,Ml.prototype.visitSparseUnion=null,Ml.prototype.visitIntervalDayTime=null,Ml.prototype.visitIntervalYearMonth=null;const jl=new Float64Array(1),Dl=new Uint32Array(jl.buffer);function zl(t){const e=(31744&t)>>10,n=(1023&t)/1024,r=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Nl(t){if(t!=t)return 32256;jl[0]=t;const e=(2147483648&Dl[1])>>16&65535;let n=2146435072&Dl[1],r=0;return n>=1089470464?Dl[0]>0?n=31744:(n=(2080374784&n)>>16,r=(1048575&Dl[1])>>10):n<=1056964608?(r=1048576+(1048575&Dl[1]),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=512+(1048575&Dl[1])>>10),e|n|65535&r}class Cl extends Ml{}function Fl(t){return(e,n,r)=>{if(e.setValid(n,null!=r))return t(e,n,r)}}const Ll=(t,e,n)=>{t[e]=Math.trunc(n%4294967296),t[e+1]=Math.trunc(n/4294967296)},Ul=(t,e,n,r)=>{if(n+1{t[e]=n},Pl=({values:t},e,n)=>{t[e]=n},Vl=({values:t},e,n)=>{t[e]=Nl(n)},$l=({values:t},e,n)=>{((t,e,n)=>{t[e]=Math.trunc(n/864e5)})(t,e,n.valueOf())},Yl=({values:t},e,n)=>{Ll(t,2*e,n.valueOf())},Wl=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Gl=(t,e,n)=>{t.type.unit===oc.DAY?$l(t,e,n):Yl(t,e,n)},ql=({values:t},e,n)=>Ll(t,2*e,n/1e3),Xl=({values:t},e,n)=>Ll(t,2*e,n),Hl=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e3*n%4294967296),t[e+1]=Math.trunc(1e3*n/4294967296)})(t,2*e,n),Zl=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e6*n%4294967296),t[e+1]=Math.trunc(1e6*n/4294967296)})(t,2*e,n),Jl=(t,e,n)=>{switch(t.type.unit){case sc.SECOND:return ql(t,e,n);case sc.MILLISECOND:return Xl(t,e,n);case sc.MICROSECOND:return Hl(t,e,n);case sc.NANOSECOND:return Zl(t,e,n)}},Kl=({values:t},e,n)=>{t[e]=n},Ql=({values:t},e,n)=>{t[e]=n},tf=({values:t},e,n)=>{t[e]=n},ef=({values:t},e,n)=>{t[e]=n},nf=(t,e,n)=>{switch(t.type.unit){case sc.SECOND:return Kl(t,e,n);case sc.MILLISECOND:return Ql(t,e,n);case sc.MICROSECOND:return tf(t,e,n);case sc.NANOSECOND:return ef(t,e,n)}},rf=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},of=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];lf.visit(i,t.valueOffsets[e],n)},af=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];lf.visit(i,e,n)},sf=(t,e,n)=>{t.type.unit===cc.DAY_TIME?uf(t,e,n):cf(t,e,n)},uf=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},cf=({values:t},e,n)=>{t[e]=12*n[0]+n[1]%12};Cl.prototype.visitBool=Fl((({offset:t,values:e},n,r)=>{const i=t+n;r?e[i>>3]|=1<>3]&=~(1<{switch(t.type.precision){case rc.HALF:return Vl(t,e,n);case rc.SINGLE:case rc.DOUBLE:return Pl(t,e,n)}})),Cl.prototype.visitFloat16=Fl(Vl),Cl.prototype.visitFloat32=Fl(Pl),Cl.prototype.visitFloat64=Fl(Pl),Cl.prototype.visitUtf8=Fl((({values:t,valueOffsets:e},n,r)=>{Ul(t,e,n,Iu(r))})),Cl.prototype.visitBinary=Fl((({values:t,valueOffsets:e},n,r)=>Ul(t,e,n,r))),Cl.prototype.visitFixedSizeBinary=Fl(Wl),Cl.prototype.visitDate=Fl(Gl),Cl.prototype.visitDateDay=Fl($l),Cl.prototype.visitDateMillisecond=Fl(Yl),Cl.prototype.visitTimestamp=Fl(Jl),Cl.prototype.visitTimestampSecond=Fl(ql),Cl.prototype.visitTimestampMillisecond=Fl(Xl),Cl.prototype.visitTimestampMicrosecond=Fl(Hl),Cl.prototype.visitTimestampNanosecond=Fl(Zl),Cl.prototype.visitTime=Fl(nf),Cl.prototype.visitTimeSecond=Fl(Kl),Cl.prototype.visitTimeMillisecond=Fl(Ql),Cl.prototype.visitTimeMicrosecond=Fl(tf),Cl.prototype.visitTimeNanosecond=Fl(ef),Cl.prototype.visitDecimal=Fl(rf),Cl.prototype.visitList=Fl(((t,e,n)=>{const r=t.children[0],i=t.valueOffsets,o=lf.getVisitFn(r);if(Array.isArray(n))for(let a=-1,s=i[e],u=i[e+1];s{const r=t.type.children.map((t=>lf.getVisitFn(t.type))),i=n instanceof Map?(o=e,a=n,(t,e,n,r)=>e&&t(e,o,a.get(n.name))):n instanceof Mh?((t,e)=>(n,r,i,o)=>r&&n(r,t,e.get(o)))(e,n):Array.isArray(n)?((t,e)=>(n,r,i,o)=>r&&n(r,t,e[o]))(e,n):((t,e)=>(n,r,i,o)=>r&&n(r,t,e[i.name]))(e,n);var o,a;t.type.children.forEach(((e,n)=>i(r[n],t.children[n],e,n)))})),Cl.prototype.visitUnion=Fl(((t,e,n)=>{t.type.mode===ec.Dense?of(t,e,n):af(t,e,n)})),Cl.prototype.visitDenseUnion=Fl(of),Cl.prototype.visitSparseUnion=Fl(af),Cl.prototype.visitDictionary=Fl(((t,e,n)=>{var r;null===(r=t.dictionary)||void 0===r||r.set(t.values[e],n)})),Cl.prototype.visitInterval=Fl(sf),Cl.prototype.visitIntervalDayTime=Fl(uf),Cl.prototype.visitIntervalYearMonth=Fl(cf),Cl.prototype.visitFixedSizeList=Fl(((t,e,n)=>{const{stride:r}=t,i=t.children[0],o=lf.getVisitFn(i);if(Array.isArray(n))for(let a=-1,s=e*r;++a{const r=t.children[0],{valueOffsets:i}=t,o=lf.getVisitFn(r);let{[e]:a,[e+1]:s}=i;const u=n instanceof Map?n.entries():Object.entries(n);for(const c of u)if(o(r,a,c),++a>=s)break}));const lf=new Cl,ff=Symbol.for("parent"),hf=Symbol.for("rowIndex");class df{constructor(t,e){return this[ff]=t,this[hf]=e,new Proxy(this,new _f)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[hf],e=this[ff],n=e.type.children,r={};for(let i=-1,o=n.length;++i`${yc(t)}: ${yc(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new pf(this[ff],this[hf])}}class pf{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return tt.name))}has(t,e){return-1!==t[ff].type.children.findIndex((t=>t.name===e))}getOwnPropertyDescriptor(t,e){if(-1!==t[ff].type.children.findIndex((t=>t.name===e)))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[ff].type.children.findIndex((t=>t.name===e));if(-1!==n){const r=Ff.visit(t[ff].children[n],t[hf]);return Reflect.set(t,e,r),r}}set(t,e,n){const r=t[ff].type.children.findIndex((t=>t.name===e));return-1!==r?(lf.visit(t[ff].children[r],t[hf],n),Reflect.set(t,e,n)):!(!Reflect.has(t,e)&&"symbol"!=typeof e)&&Reflect.set(t,e,n)}}class mf extends Ml{}function bf(t){return(e,n)=>e.getValid(n)?t(e,n):null}const yf=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),gf=t=>new Date(t),vf=(t,e,n)=>{if(n+1>=e.length)return null;const r=e[n],i=e[n+1];return t.subarray(r,i)},wf=({values:t},e)=>((t,e)=>gf(((t,e)=>864e5*t[e])(t,e)))(t,e),xf=({values:t},e)=>((t,e)=>gf(yf(t,e)))(t,2*e),Af=({stride:t,values:e},n)=>e[t*n],Sf=({values:t},e)=>t[e],If=({values:t},e)=>1e3*yf(t,2*e),Of=({values:t},e)=>yf(t,2*e),Tf=({values:t},e)=>((t,e)=>t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3)(t,2*e),kf=({values:t},e)=>((t,e)=>t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6)(t,2*e),Mf=({values:t},e)=>t[e],Ef=({values:t},e)=>t[e],Bf=({values:t},e)=>t[e],jf=({values:t},e)=>t[e],Df=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Ff.visit(r,t.valueOffsets[e])},zf=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Ff.visit(r,e)},Nf=({values:t},e)=>t.subarray(2*e,2*(e+1)),Cf=({values:t},e)=>{const n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r};mf.prototype.visitNull=bf(((t,e)=>null)),mf.prototype.visitBool=bf((({offset:t,values:e},n)=>{const r=t+n;return 0!=(e[r>>3]&1<t[e])),mf.prototype.visitInt8=bf(Af),mf.prototype.visitInt16=bf(Af),mf.prototype.visitInt32=bf(Af),mf.prototype.visitInt64=bf(Sf),mf.prototype.visitUint8=bf(Af),mf.prototype.visitUint16=bf(Af),mf.prototype.visitUint32=bf(Af),mf.prototype.visitUint64=bf(Sf),mf.prototype.visitFloat=bf((({type:t,values:e},n)=>t.precision!==rc.HALF?e[n]:zl(e[n]))),mf.prototype.visitFloat16=bf((({stride:t,values:e},n)=>zl(e[t*n]))),mf.prototype.visitFloat32=bf(Af),mf.prototype.visitFloat64=bf(Af),mf.prototype.visitUtf8=bf((({values:t,valueOffsets:e},n)=>{const r=vf(t,e,n);return null!==r?Au(r):null})),mf.prototype.visitBinary=bf((({values:t,valueOffsets:e},n)=>vf(t,e,n))),mf.prototype.visitFixedSizeBinary=bf((({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)))),mf.prototype.visitDate=bf(((t,e)=>t.type.unit===oc.DAY?wf(t,e):xf(t,e))),mf.prototype.visitDateDay=bf(wf),mf.prototype.visitDateMillisecond=bf(xf),mf.prototype.visitTimestamp=bf(((t,e)=>{switch(t.type.unit){case sc.SECOND:return If(t,e);case sc.MILLISECOND:return Of(t,e);case sc.MICROSECOND:return Tf(t,e);case sc.NANOSECOND:return kf(t,e)}})),mf.prototype.visitTimestampSecond=bf(If),mf.prototype.visitTimestampMillisecond=bf(Of),mf.prototype.visitTimestampMicrosecond=bf(Tf),mf.prototype.visitTimestampNanosecond=bf(kf),mf.prototype.visitTime=bf(((t,e)=>{switch(t.type.unit){case sc.SECOND:return Mf(t,e);case sc.MILLISECOND:return Ef(t,e);case sc.MICROSECOND:return Bf(t,e);case sc.NANOSECOND:return jf(t,e)}})),mf.prototype.visitTimeSecond=bf(Mf),mf.prototype.visitTimeMillisecond=bf(Ef),mf.prototype.visitTimeMicrosecond=bf(Bf),mf.prototype.visitTimeNanosecond=bf(jf),mf.prototype.visitDecimal=bf((({values:t,stride:e},n)=>kc.decimal(t.subarray(e*n,e*(n+1))))),mf.prototype.visitList=bf(((t,e)=>{const{valueOffsets:n,stride:r,children:i}=t,{[e*r]:o,[e*r+1]:a}=n,s=i[0].slice(o,a-o);return new Mh([s])})),mf.prototype.visitStruct=bf(((t,e)=>new df(t,e))),mf.prototype.visitUnion=bf(((t,e)=>t.type.mode===ec.Dense?Df(t,e):zf(t,e))),mf.prototype.visitDenseUnion=bf(Df),mf.prototype.visitSparseUnion=bf(zf),mf.prototype.visitDictionary=bf(((t,e)=>{var n;return null===(n=t.dictionary)||void 0===n?void 0:n.get(t.values[e])})),mf.prototype.visitInterval=bf(((t,e)=>t.type.unit===cc.DAY_TIME?Nf(t,e):Cf(t,e))),mf.prototype.visitIntervalDayTime=bf(Nf),mf.prototype.visitIntervalYearMonth=bf(Cf),mf.prototype.visitFixedSizeList=bf(((t,e)=>{const{stride:n,children:r}=t,i=r[0].slice(e*n,n);return new Mh([i])})),mf.prototype.visitMap=bf(((t,e)=>{const{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:o}=n,a=r[0];return new Rf(a.slice(i,o-i))}));const Ff=new mf,Lf=Symbol.for("keys"),Uf=Symbol.for("vals");class Rf{constructor(t){return this[Lf]=new Mh([t.children[0]]).memoize(),this[Uf]=t.children[1],new Proxy(this,new Vf)}[Symbol.iterator](){return new Pf(this[Lf],this[Uf])}get size(){return this[Lf].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Lf],e=this[Uf],n={};for(let r=-1,i=t.length;++r`${yc(t)}: ${yc(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Pf{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Ff.visit(this.vals,t)]})}}class Vf{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Lf].toArray().map(String)}has(t,e){return t[Lf].includes(e)}getOwnPropertyDescriptor(t,e){if(-1!==t[Lf].indexOf(e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[Lf].indexOf(e);if(-1!==n){const r=Ff.visit(Reflect.get(t,Uf),n);return Reflect.set(t,e,r),r}}set(t,e,n){const r=t[Lf].indexOf(e);return-1!==r?(lf.visit(Reflect.get(t,Uf),r,n),Reflect.set(t,e,n)):!!Reflect.has(t,e)&&Reflect.set(t,e,n)}}let $f;function Yf(t,e,n,r){const{length:i=0}=t;let o="number"!=typeof e?0:e,a="number"!=typeof n?i:n;return o<0&&(o=(o%i+i)%i),a<0&&(a=(a%i+i)%i),ai&&(a=i),r?r(t,o,a):[o,a]}Object.defineProperties(Rf.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Uf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});const Wf=t=>t!=t;function Gf(t){if("object"!==typeof t||null===t)return Wf(t)?Wf:e=>e===t;if(t instanceof Date){const e=t.valueOf();return t=>t instanceof Date&&t.valueOf()===e}return ArrayBuffer.isView(t)?e=>!!e&&function(t,e){let n=0;const r=t.length;if(r!==e.length)return!1;if(r>0)do{if(t[n]!==e[n])return!1}while(++n!1;const r=[];for(let i=-1,o=n.length;++i{if(!n||"object"!=typeof n)return!1;switch(n.constructor){case Array:return function(t,e){const n=t.length;if(e.length!==n)return!1;for(let r=-1;++r>r}function Jf(t){const e=[];let n=0,r=0,i=0;for(const a of t)a&&(i|=1<0)&&(e[n++]=i);const o=new Uint8Array(e.length+7&-8);return o.set(e),o}class Kf{constructor(t,e,n,r,i){this.bytes=t,this.length=n,this.context=r,this.get=i,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8==0?0:8-e%8);return Qf(t,e,i)+Qf(t,r,n)+function(t,e,n){let r=0,i=Math.trunc(e);const o=new DataView(t.buffer,t.byteOffset,t.byteLength),a=void 0===n?t.byteLength:i+n;for(;a-i>=4;)r+=th(o.getUint32(i)),i+=4;for(;a-i>=2;)r+=th(o.getUint16(i)),i+=2;for(;a-i>=1;)r+=th(o.getUint8(i)),i+=1;return r}(t,i>>3,r-i>>3)}function th(t){let e=Math.trunc(t);return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class eh{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:r,typeIds:i}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),this.children.reduce(((t,e)=>t+e.byteLength),t)}get nullCount(){let t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-Qf(t,this.offset,this.offset+this.length)),e}constructor(t,e,n,r,i,o=[],a){let s;this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(r||0,-1)),i instanceof eh?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets):(this.stride=kl(t),i&&((s=i[0])&&(this.valueOffsets=s),(s=i[1])&&(this.values=s),(s=i[2])&&(this.nullBitmap=s),(s=i[3])&&(this.typeIds=s))),this.nullable=0!==this._nullCount&&this.nullBitmap&&this.nullBitmap.byteLength>0}getValid(t){if(this.nullable&&this.nullCount>0){const e=this.offset+t;return 0!=(this.nullBitmap[e>>3]&1<>3){const{nullBitmap:t}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:t,_nullCount:0})}const{nullBitmap:n,offset:r}=this,i=r+t>>3,o=(r+t)%8,a=n[i]>>o&1;return e?0===a&&(n[i]|=1<>3).fill(255,0,e>>3);r[e>>3]=(1<0&&r.set(function(t,e,n){const r=n.byteLength+7&-8;if(t>0||n.byteLength>3):Jf(new Kf(n,t,e,null,Hf)).subarray(0,r)),i}return n}(this.offset,e,this.nullBitmap),0);const i=this.buffers;return i[_c.VALIDITY]=r,this.clone(this.type,0,t,n+(t-e),i)}_sliceBuffers(t,e,n,r){let i;const{buffers:o}=this;return(i=o[_c.TYPE])&&(o[_c.TYPE]=i.subarray(t,t+e)),(i=o[_c.OFFSET])&&(o[_c.OFFSET]=i.subarray(t,t+e+1))||(i=o[_c.DATA])&&(o[_c.DATA]=6===r?i:i.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}}eh.prototype.children=Object.freeze([]);class nh extends Ml{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{type:e,offset:n=0,length:r=0}=t;return new eh(e,n,r,0)}visitBool(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length>>3,nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitInt(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitFloat(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitUtf8(t){const{type:e,offset:n=0}=t,r=Yu(t.data),i=Yu(t.nullBitmap),o=$u(t.valueOffsets),{length:a=o.length-1,nullCount:s=(t.nullBitmap?-1:0)}=t;return new eh(e,n,a,s,[o,r,i])}visitBinary(t){const{type:e,offset:n=0}=t,r=Yu(t.data),i=Yu(t.nullBitmap),o=$u(t.valueOffsets),{length:a=o.length-1,nullCount:s=(t.nullBitmap?-1:0)}=t;return new eh(e,n,a,s,[o,r,i])}visitFixedSizeBinary(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitDate(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitTimestamp(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitTime(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitDecimal(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitList(t){const{type:e,offset:n=0,child:r}=t,i=Yu(t.nullBitmap),o=$u(t.valueOffsets),{length:a=o.length-1,nullCount:s=(t.nullBitmap?-1:0)}=t;return new eh(e,n,a,s,[o,void 0,i],[r])}visitStruct(t){const{type:e,offset:n=0,children:r=[]}=t,i=Yu(t.nullBitmap),{length:o=r.reduce(((t,{length:e})=>Math.max(t,e)),0),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,void 0,i],r)}visitUnion(t){const{type:e,offset:n=0,children:r=[]}=t,i=Yu(t.nullBitmap),o=Vu(e.ArrayType,t.typeIds),{length:a=o.length,nullCount:s=(t.nullBitmap?-1:0)}=t;if(Zc.isSparseUnion(e))return new eh(e,n,a,s,[void 0,void 0,i,o],r);const u=$u(t.valueOffsets);return new eh(e,n,a,s,[u,void 0,i,o],r)}visitDictionary(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.indices.ArrayType,t.data),{dictionary:o=new Mh([(new nh).visit({type:e.dictionary})])}=t,{length:a=i.length,nullCount:s=(t.nullBitmap?-1:0)}=t;return new eh(e,n,a,s,[void 0,i,r],[],o)}visitInterval(t){const{type:e,offset:n=0}=t,r=Yu(t.nullBitmap),i=Vu(e.ArrayType,t.data),{length:o=i.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,i,r])}visitFixedSizeList(t){const{type:e,offset:n=0,child:r=(new nh).visit({type:e.valueType})}=t,i=Yu(t.nullBitmap),{length:o=r.length/kl(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new eh(e,n,o,a,[void 0,void 0,i],[r])}visitMap(t){const{type:e,offset:n=0,child:r=(new nh).visit({type:e.childType})}=t,i=Yu(t.nullBitmap),o=$u(t.valueOffsets),{length:a=o.length-1,nullCount:s=(t.nullBitmap?-1:0)}=t;return new eh(e,n,a,s,[o,void 0,i],[r])}}function rh(t){return(new nh).visit(t)}class ih{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext+e.nullCount),0)}function ah(t){return t.reduce(((t,e,n)=>(t[n+1]=t[n]+e.length,t)),new Uint32Array(t.length+1))}function sh(t,e,n,r){const i=[];for(let o=-1,a=t.length;++o=r)break;if(n>=s+u)continue;if(s>=n&&s+u<=r){i.push(a);continue}const c=Math.max(0,n-s),l=Math.min(r-s,u);i.push(a.slice(c,l-c))}return 0===i.length&&i.push(t[0].slice(0,0)),i}function uh(t,e,n,r){let i=0,o=0,a=e.length-1;do{if(i>=a-1)return n0?0:-1},dh.prototype.visitBool=ph,dh.prototype.visitInt=ph,dh.prototype.visitInt8=ph,dh.prototype.visitInt16=ph,dh.prototype.visitInt32=ph,dh.prototype.visitInt64=ph,dh.prototype.visitUint8=ph,dh.prototype.visitUint16=ph,dh.prototype.visitUint32=ph,dh.prototype.visitUint64=ph,dh.prototype.visitFloat=ph,dh.prototype.visitFloat16=ph,dh.prototype.visitFloat32=ph,dh.prototype.visitFloat64=ph,dh.prototype.visitUtf8=ph,dh.prototype.visitBinary=ph,dh.prototype.visitFixedSizeBinary=ph,dh.prototype.visitDate=ph,dh.prototype.visitDateDay=ph,dh.prototype.visitDateMillisecond=ph,dh.prototype.visitTimestamp=ph,dh.prototype.visitTimestampSecond=ph,dh.prototype.visitTimestampMillisecond=ph,dh.prototype.visitTimestampMicrosecond=ph,dh.prototype.visitTimestampNanosecond=ph,dh.prototype.visitTime=ph,dh.prototype.visitTimeSecond=ph,dh.prototype.visitTimeMillisecond=ph,dh.prototype.visitTimeMicrosecond=ph,dh.prototype.visitTimeNanosecond=ph,dh.prototype.visitDecimal=ph,dh.prototype.visitList=ph,dh.prototype.visitStruct=ph,dh.prototype.visitUnion=ph,dh.prototype.visitDenseUnion=_h,dh.prototype.visitSparseUnion=_h,dh.prototype.visitDictionary=ph,dh.prototype.visitInterval=ph,dh.prototype.visitIntervalDayTime=ph,dh.prototype.visitIntervalYearMonth=ph,dh.prototype.visitFixedSizeList=ph,dh.prototype.visitMap=ph;const mh=new dh;class bh extends Ml{}function yh(t){const{type:e}=t;if(0===t.nullCount&&1===t.stride&&(e.typeId===dc.Timestamp||e instanceof Kc&&64!==e.bitWidth||e instanceof ml&&64!==e.bitWidth||e instanceof sl&&e.precision!==rc.HALF))return new ih(t.data.length,(e=>{const n=t.data[e];return n.values.subarray(0,n.length)[Symbol.iterator]()}));let n=0;return new ih(t.data.length,(e=>{const r=t.data[e].length,i=t.slice(n,n+r);return n+=r,new gh(i)}))}class gh{constructor(t){this.vector=t,this.index=0}next(){return this.indext+e;class xh extends Ml{visitNull(t,e){return 0}visitInt(t,e){return t.type.bitWidth/8}visitFloat(t,e){return t.type.ArrayType.BYTES_PER_ELEMENT}visitBool(t,e){return 1/8}visitDecimal(t,e){return t.type.bitWidth/8}visitDate(t,e){return 4*(t.type.unit+1)}visitTime(t,e){return t.type.bitWidth/8}visitTimestamp(t,e){return t.type.unit===sc.SECOND?4:8}visitInterval(t,e){return 4*(t.type.unit+1)}visitStruct(t,e){return t.children.reduce(((t,n)=>t+Ih.visit(n,e)),0)}visitFixedSizeBinary(t,e){return t.type.byteWidth}visitMap(t,e){return 8+t.children.reduce(((t,n)=>t+Ih.visit(n,e)),0)}visitDictionary(t,e){var n;return t.type.indices.bitWidth/8+((null===(n=t.dictionary)||void 0===n?void 0:n.getByteLength(t.values[e]))||0)}}const Ah=({type:t,children:e,typeIds:n,valueOffsets:r},i)=>{const o=t.typeIdToChildIndex[n[i]];return 8+Ih.visit(e[o],r[i])},Sh=({children:t},e)=>4+Ih.visitMany(t,t.map((()=>e))).reduce(wh,0);xh.prototype.visitUtf8=({valueOffsets:t},e)=>t[e+1]-t[e]+8,xh.prototype.visitBinary=({valueOffsets:t},e)=>t[e+1]-t[e]+8,xh.prototype.visitList=({valueOffsets:t,stride:e,children:n},r)=>{const i=n[0],{[r*e]:o}=t,{[r*e+1]:a}=t,s=Ih.getVisitFn(i.type),u=i.slice(o,a-o);let c=8;for(let l=-1,f=a-o;++l{const r=e[0],i=r.slice(n*t,t),o=Ih.getVisitFn(r.type);let a=0;for(let s=-1,u=i.length;++st.type.mode===ec.Dense?Ah(t,e):Sh(t,e),xh.prototype.visitDenseUnion=Ah,xh.prototype.visitSparseUnion=Sh;const Ih=new xh;var Oh;const Th={},kh={};class Mh{constructor(t){var e,n,r;const i=t[0]instanceof Mh?t.flatMap((t=>t.data)):t;if(0===i.length||i.some((t=>!(t instanceof eh))))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=null===(e=i[0])||void 0===e?void 0:e.type;switch(i.length){case 0:this._offsets=[0];break;case 1:{const{get:t,set:e,indexOf:n,byteLength:r}=Th[o.typeId],a=i[0];this.isValid=t=>ch(a,t),this.get=e=>t(a,e),this.set=(t,n)=>e(a,t,n),this.indexOf=t=>n(a,t),this.getByteLength=t=>r(a,t),this._offsets=[0,a.length];break}default:Object.setPrototypeOf(this,kh[o.typeId]),this._offsets=ah(i)}this.data=i,this.type=o,this.stride=kl(o),this.numChildren=null!==(r=null===(n=o.children)||void 0===n?void 0:n.length)&&void 0!==r?r:0,this.length=this._offsets.at(-1)}get byteLength(){return-1===this._byteLength&&(this._byteLength=this.data.reduce(((t,e)=>t+e.byteLength),0)),this._byteLength}get nullCount(){return-1===this._nullCount&&(this._nullCount=oh(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${dc[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>0}getByteLength(t){return 0}[Symbol.iterator](){return vh.visit(this)}concat(...t){return new Mh(this.data.concat(t.flatMap((t=>t.data)).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Mh(Yf(this,t,e,(({data:t,_offsets:e},n,r)=>sh(t,e,n,r))))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:r,ArrayType:i}=this;switch(t.typeId){case dc.Int:case dc.Float:case dc.Decimal:case dc.Time:case dc.Timestamp:switch(e.length){case 0:return new i;case 1:return e[0].values.subarray(0,n*r);default:return e.reduce(((t,{values:e,length:n})=>(t.array.set(e.subarray(0,n*r),t.offset),t.offset+=n*r,t)),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt(null===(e=this.type.children)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te[t]))):null}get isMemoized(){return!!Zc.isDictionary(this.type)&&this.data[0].dictionary.isMemoized}memoize(){if(Zc.isDictionary(this.type)){const t=new Eh(this.data[0].dictionary),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new Mh(e)}return new Eh(this)}unmemoize(){if(Zc.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new Mh(e)}return this}}Oh=Symbol.toStringTag,Mh[Oh]=(t=>{t.type=Zc.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._nullCount=-1,t._byteLength=-1,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(dc).map((t=>dc[t])).filter((t=>"number"==typeof t&&t!==dc.NONE));for(const n of e){const e=Ff.getVisitFnByTypeId(n),r=lf.getVisitFnByTypeId(n),i=mh.getVisitFnByTypeId(n),o=Ih.getVisitFnByTypeId(n);Th[n]={get:e,set:r,indexOf:i,byteLength:o},kh[n]=Object.create(t,{isValid:{value:lh(ch)},get:{value:lh(Ff.getVisitFnByTypeId(n))},set:{value:fh(lf.getVisitFnByTypeId(n))},indexOf:{value:hh(mh.getVisitFnByTypeId(n))},getByteLength:{value:lh(Ih.getVisitFnByTypeId(n))}})}return"Vector"})(Mh.prototype);class Eh extends Mh{constructor(t){super(t.data);const e=this.get,n=this.set,r=this.slice,i=new Array(this.length);Object.defineProperty(this,"get",{value(t){const n=i[t];if(void 0!==n)return n;const r=e.call(this,t);return i[t]=r,r}}),Object.defineProperty(this,"set",{value(t,e){n.call(this,t,e),i[t]=e}}),Object.defineProperty(this,"slice",{value:(t,e)=>new Eh(r.call(this,t,e))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Mh(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}function Bh(t){if(t){if(t instanceof eh)return new Mh([t]);if(t instanceof Mh)return new Mh(t.data);if(t.type instanceof Zc)return new Mh([rh(t)]);if(Array.isArray(t))return new Mh(t.flatMap((t=>{return(e=t)instanceof eh?[e]:e instanceof Mh?e.data:Bh(e).data;var e})));if(ArrayBuffer.isView(t)){t instanceof DataView&&(t=new Uint8Array(t.buffer));const e={offset:0,length:t.length,nullCount:0,data:t};if(t instanceof Int8Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new Qc}))]);if(t instanceof Int16Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new tl}))]);if(t instanceof Int32Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new el}))]);if(t instanceof BigInt64Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new nl}))]);if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)return new Mh([rh(Object.assign(Object.assign({},e),{type:new rl}))]);if(t instanceof Uint16Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new il}))]);if(t instanceof Uint32Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new ol}))]);if(t instanceof BigUint64Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new al}))]);if(t instanceof Float32Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new ul}))]);if(t instanceof Float64Array)return new Mh([rh(Object.assign(Object.assign({},e),{type:new cl}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function jh(t){if(!t||t.length<=0)return function(t){return!0};let e="";const n=t.filter((t=>t==t));return n.length>0&&(e=`\n switch (x) {${n.map((t=>`\n case ${function(t){if("bigint"!=typeof t)return yc(t);return`${yc(t)}n`}(t)}:`)).join("")}\n return false;\n }`),t.length!==n.length&&(e=`if (x !== x) return false;\n${e}`),new Function("x",`${e}\nreturn true;`)}const Dh=(t,e)=>(Math.ceil(t)*e+63&-64||64)/e;class zh{constructor(t,e=1){this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=Math.ceil(t.length/e))}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;const e=this.stride,n=this.length*e,r=this.buffer.length;n>=r&&this._resize(Dh(0===r?1*n:2*n,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Dh(t*this.stride,this.BYTES_PER_ELEMENT);const e=((t,e=0)=>t.length>=e?t.subarray(0,e):Ru(new t.constructor(e),t,0))(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this._resize(0),this}_resize(t){return this.buffer=Ru(new this.ArrayType(t),this.buffer)}}zh.prototype.offset=0;class Nh extends zh{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}}class Ch extends Nh{constructor(t=new Uint8Array(0)){super(t,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){const{buffer:n}=this.reserve(t-this.length+1),r=t>>3,i=t%8,o=n[r]>>i&1;return e?0===o&&(n[r]|=1<this.length&&this.set(t-1,0),super.flush(t+1)}}let Lh=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=kl(t),this._nulls=new Ch,e&&e.length>0&&(this._isValid=jh(e))}toVector(){return new Mh([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0;const{_offsets:e,_values:n,_nulls:r,_typeIds:i,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),o.reduce(((t,e)=>t+e.byteLength),t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce(((t,e)=>t+e.reservedByteLength),t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,r;const{type:i,length:o,nullCount:a,_typeIds:s,_offsets:u,_values:c,_nulls:l}=this;(e=null==s?void 0:s.flush(o))?r=null==u?void 0:u.flush(o):t=(r=null==u?void 0:u.flush(o))?null==c?void 0:c.flush(u.last()):null==c?void 0:c.flush(o),a>0&&(n=null==l?void 0:l.flush(o));const f=this.children.map((t=>t.flush()));return this.clear(),rh({type:i,length:o,nullCount:a,children:f,child:f[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:r})}finish(){this.finished=!0;for(const t of this.children)t.finish();return this}clear(){var t,e,n,r;this.length=0,null===(t=this._nulls)||void 0===t||t.clear(),null===(e=this._values)||void 0===e||e.clear(),null===(n=this._offsets)||void 0===n||n.clear(),null===(r=this._typeIds)||void 0===r||r.clear();for(const i of this.children)i.clear();return this}};Lh.prototype.length=1,Lh.prototype.stride=1,Lh.prototype.children=null,Lh.prototype.finished=!1,Lh.prototype.nullValues=null,Lh.prototype._isValid=()=>!0;class Uh extends Lh{constructor(t){super(t),this._values=new Nh(new this.ArrayType(0),this.stride)}setValue(t,e){const n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}}class Rh extends Lh{constructor(t){super(t),this._pendingLength=0,this._offsets=new Fh}setValue(t,e){const n=this._pending||(this._pending=new Map),r=n.get(t);r&&(this._pendingLength-=r.length),this._pendingLength+=e instanceof Rf?e[Lf].length:e.length,n.set(t,e)}setValid(t,e){return!!super.setValid(t,e)||((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){const t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}class Ph{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,r){return t.prep(8,24),t.writeInt64(BigInt(null!=r?r:0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}}const Vh=new Int32Array(2),$h=new Float32Array(Vh.buffer),Yh=new Float64Array(Vh.buffer),Wh=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];var Gh,qh;(qh=Gh||(Gh={}))[qh.UTF8_BYTES=1]="UTF8_BYTES",qh[qh.UTF16_STRING=2]="UTF16_STRING";let Xh=class t{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){$h[0]=e,this.writeInt32(t,Vh[0])}writeFloat64(t,e){Yh[0]=e,this.writeInt32(t,Vh[Wh?0:1]),this.writeInt32(t+4,Vh[Wh?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const r=1+~(this.bb.capacity()-this.space+n)&e-1;for(;this.space=0&&0==this.vtable[e];e--);const n=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const r=2*(n+2);this.addInt16(r);let i=0;const o=this.space;t:for(e=0;e=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,r=n-this.bb.readInt32(n);if(!(e=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return Sd.startUnion(t),Sd.addMode(t,e),Sd.addTypeIds(t,n),Sd.endUnion(t)}}class Id{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Id).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Id).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Id.startUtf8(t),Id.endUtf8(t)}}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"}(Ad||(Ad={}));let Od=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Ad.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new id).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(e,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*e),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new Zh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Ad.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},Td=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Kh.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Od).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new Zh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,Kh.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(e,n,r,i,o){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,o),t.endSchema(e)}};class kd{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new kd).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new kd).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Jh.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Td).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new Ph).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new Ph).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new Zh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,Jh.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}class Md{constructor(t=[],e,n){this.fields=t||[],this.metadata=e||new Map,n||(n=jd(t)),this.dictionaries=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map((t=>t.name))}toString(){return`Schema<{ ${this.fields.map(((t,e)=>`${e}: ${t}`)).join(", ")} }>`}select(t){const e=new Set(t),n=this.fields.filter((t=>e.has(t.name)));return new Md(n,this.metadata)}selectAt(t){const e=t.map((t=>this.fields[t])).filter(Boolean);return new Md(e,this.metadata)}assign(...t){const e=t[0]instanceof Md?t[0]:Array.isArray(t[0])?new Md(t[0]):new Md(t),n=[...this.fields],r=Bd(Bd(new Map,this.metadata),e.metadata),i=e.fields.filter((t=>{const e=n.findIndex((e=>e.name===t.name));return!~e||(n[e]=t.clone({metadata:Bd(Bd(new Map,n[e].metadata),t.metadata)}))&&!1})),o=jd(i,new Map);return new Md([...n,...i],r,new Map([...this.dictionaries,...o]))}}Md.prototype.fields=null,Md.prototype.metadata=null,Md.prototype.dictionaries=null;class Ed{static new(...t){let[e,n,r,i]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===n&&(n=t[0].type),void 0===r&&(r=t[0].nullable),void 0===i&&(i=t[0].metadata)),new Ed(`${e}`,n,r,i)}constructor(t,e,n=!1,r){this.name=t,this.type=e,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,r,i]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:n=this.type,nullable:r=this.nullable,metadata:i=this.metadata}=t[0]):[e=this.name,n=this.type,r=this.nullable,i=this.metadata]=t,Ed.new(e,n,r,i)}}function Bd(t,e){return new Map([...t||new Map,...e||new Map])}function jd(t,e=new Map){for(let n=-1,r=t.length;++n0&&jd(r.children,e)}return e}Ed.prototype.type=null,Ed.prototype.name=null,Ed.prototype.nullable=null,Ed.prototype.metadata=null;var Dd=Hh,zd=Xh;class Nd{static decode(t){t=new zd(Yu(t));const e=kd.getRootAsFooter(t),n=Md.decode(e.schema());return new Cd(n,e)}static encode(t){const e=new Dd,n=Md.encode(e,t.schema);kd.startRecordBatchesVector(e,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())Fd.encode(e,o);const r=e.endVector();kd.startDictionariesVector(e,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())Fd.encode(e,o);const i=e.endVector();return kd.startFooter(e),kd.addSchema(e,n),kd.addVersion(e,Qu.V4),kd.addRecordBatches(e,r),kd.addDictionaries(e,i),kd.finishFooterBuffer(e,kd.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=Qu.V4,n,r){this.schema=t,this.version=e,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return mu(this,void 0,void 0,(function*(){yield this.return(t)}))}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Ld);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Hu.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Hu.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return mu(this,void 0,void 0,(function*(){return yield this.abort(t),Ld}))}return(t){return mu(this,void 0,void 0,(function*(){return yield this.close(),Ld}))}read(t){return mu(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return mu(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise(((t,e)=>{this.resolvers.push({resolve:t,reject:e})})):Promise.resolve(Ld)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Vd extends Pd{write(t){if((t=Yu(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Au(this.toUint8Array(!0)):this.toUint8Array(!1).then(Au)}toUint8Array(t=!1){return t?Pu(this._values)[0]:(()=>mu(this,void 0,void 0,(function*(){var t,e,n,r;const i=[];let o=0;try{for(var a,s=!0,u=wu(this);!(t=(a=yield u.next()).done);s=!0){r=a.value,s=!1;const t=r;i.push(t),o+=t.byteLength}}catch(c){e={error:c}}finally{try{s||t||!(n=u.return)||(yield n.call(u))}finally{if(e)throw e.error}}return Pu(i,o)[0]})))()}}class $d{constructor(t){t&&(this.source=new Wd(Hu.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Yd{constructor(t){t instanceof Yd?this.source=t.source:t instanceof Vd?this.source=new Gd(Hu.fromAsyncIterable(t)):Fu(t)?this.source=new Gd(Hu.fromNodeStream(t)):Cu(t)?this.source=new Gd(Hu.fromDOMStream(t)):zu(t)?this.source=new Gd(Hu.fromDOMStream(t.body)):Mu(t)?this.source=new Gd(Hu.fromIterable(t)):(ku(t)||Eu(t))&&(this.source=new Gd(Hu.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Wd{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Ld)}return(t){return Object.create(this.source.return&&this.source.return(t)||Ld)}}class Gd{constructor(t){this.source=t,this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}cancel(t){return mu(this,void 0,void 0,(function*(){yield this.return(t)}))}get closed(){return this._closedPromise}read(t){return mu(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return mu(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(t,e="read"){return mu(this,void 0,void 0,(function*(){return yield this.source.next({cmd:e,size:t})}))}throw(t){return mu(this,void 0,void 0,(function*(){const e=this.source.throw&&(yield this.source.throw(t))||Ld;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}return(t){return mu(this,void 0,void 0,(function*(){const e=this.source.return&&(yield this.source.return(t))||Ld;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}}class qd extends $d{constructor(t,e){super(),this.position=0,this.buffer=Yu(t),this.size=void 0===e?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),tmu(this,void 0,void 0,(function*(){this.size=(yield t.stat()).size,delete this._pending})))()}readInt32(t){return mu(this,void 0,void 0,(function*(){const{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}))}seek(t){return mu(this,void 0,void 0,(function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t>>16,65535&this.buffer[1],this.buffer[0]>>>16,65535&this.buffer[0]]),n=new Uint32Array([t.buffer[1]>>>16,65535&t.buffer[1],t.buffer[0]>>>16,65535&t.buffer[0]]);let r=e[3]*n[3];this.buffer[0]=65535&r;let i=r>>>16;return r=e[2]*n[3],i+=r,r=e[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Hd(this.buffer[3])} ${Hd(this.buffer[2])} ${Hd(this.buffer[1])} ${Hd(this.buffer[0])}`}static multiply(t,e){return new tp(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new tp(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return tp.fromString("string"==typeof t?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return tp.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),r=t.length,i=new tp(e);for(let o=n?1:0;o0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class np extends ep{constructor(t,e,n,r){super(new Uint8Array(0),e,n,r),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Jf(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Vu(Uint8Array,Vu(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Vu(Uint8Array,Vu(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return Zc.isTimestamp(t)||(Zc.isInt(t)||Zc.isTime(t))&&64===t.bitWidth||Zc.isDate(t)&&t.unit===oc.MILLISECOND?Vu(Uint8Array,Qd.convertArray(n[e])):Zc.isDecimal(t)?Vu(Uint8Array,tp.convertArray(n[e])):Zc.isBinary(t)||Zc.isFixedSizeBinary(t)?function(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}(n[e]):Zc.isBool(t)?Jf(n[e]):Zc.isUtf8(t)?Iu(n[e].join("")):Vu(Uint8Array,Vu(t.ArrayType,n[e].map((t=>+t))))}}class rp extends Rh{constructor(t){super(t),this._values=new zh(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Yu(e))}_flushPending(t,e){const n=this._offsets,r=this._values.reserve(e).buffer;let i=0;for(const[o,a]of t)if(void 0===a)n.set(o,0);else{const t=a.length;r.set(a,i),n.set(o,t),i+=t}}}class ip extends Lh{constructor(t){super(t),this._values=new Ch}setValue(t,e){this._values.set(t,+e)}}class op extends Uh{}op.prototype._setValue=Gl;class ap extends op{}ap.prototype._setValue=$l;class sp extends op{}sp.prototype._setValue=Yl;class up extends Uh{}up.prototype._setValue=rf;class cp extends Lh{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Tl(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=o_({type:this.type.indices,nullValues:e}),this.dictionary=o_({type:this.type.dictionary,nullValues:null}),"function"==typeof n&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){const n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){const n=this._keysToIndices,r=this.valueToKey(e);let i=n[r];return void 0===i&&(n[r]=i=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,i)}flush(){const t=this.type,e=this._dictionary,n=this.dictionary.toVector(),r=this.indices.flush().clone(t);return r.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=r.dictionary,this.clear(),r}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return"string"==typeof t?t:`${t}`}}class lp extends Uh{}lp.prototype._setValue=Wl;class fp extends Lh{setValue(t,e){const[n]=this.children,r=t*this.stride;for(let i=-1,o=e.length;++i0)throw new Error("FixedSizeListBuilder can only have one child.");const n=this.children.push(t);return this.type=new Al(this.type.listSize,new Ed(e,t.type,!0)),n}}class hp extends Uh{setValue(t,e){this._values.set(t,e)}}class dp extends hp{setValue(t,e){super.setValue(t,Nl(e))}}class pp extends hp{}class _p extends hp{}class mp extends Uh{}mp.prototype._setValue=sf;class bp extends mp{}bp.prototype._setValue=uf;class yp extends mp{}yp.prototype._setValue=cf;class gp extends Uh{setValue(t,e){this._values.set(t,e)}}class vp extends gp{}class wp extends gp{}class xp extends gp{}class Ap extends gp{}class Sp extends gp{}class Ip extends gp{}class Op extends gp{}class Tp extends gp{}class kp extends Rh{constructor(t){super(t),this._offsets=new Fh}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new gl(new Ed(e,t.type,!0)),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[r,i]of t)if(void 0===i)e.set(r,0);else{const t=i,o=t.length,a=e.set(r,o).buffer[r];for(let e=-1;++e0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Sl(new Ed(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[r,i]of t)if(void 0===i)e.set(r,0);else{let{[r]:t,[r+1]:o}=e.set(r,i.size).buffer;for(const e of i.entries())if(n.set(t,e),++t>=o)break}}}class Ep extends Lh{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}class Bp extends Lh{setValue(t,e){const{children:n,type:r}=this;switch(Array.isArray(e)||e.constructor){case!0:return r.children.forEach(((r,i)=>n[i].set(t,e[i])));case Map:return r.children.forEach(((r,i)=>n[i].set(t,e.get(r.name))));default:return r.children.forEach(((r,i)=>n[i].set(t,e[r.name])))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach((n=>n.setValid(t,e))),e}addChild(t,e=`${this.numChildren}`){const n=this.children.push(t);return this.type=new vl([...this.type.children,new Ed(e,t.type,!0)]),n}}class jp extends Uh{}jp.prototype._setValue=Jl;class Dp extends jp{}Dp.prototype._setValue=ql;class zp extends jp{}zp.prototype._setValue=Xl;class Np extends jp{}Np.prototype._setValue=Hl;class Cp extends jp{}Cp.prototype._setValue=Zl;class Fp extends Uh{}Fp.prototype._setValue=nf;class Lp extends Fp{}Lp.prototype._setValue=Kl;class Up extends Fp{}Up.prototype._setValue=Ql;class Rp extends Fp{}Rp.prototype._setValue=tf;class Pp extends Fp{}Pp.prototype._setValue=ef;class Vp extends Lh{constructor(t){super(t),this._typeIds=new Nh(new Int8Array(0),1),"function"==typeof t.valueToChildTypeId&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return void 0===n&&(n=this._valueToChildTypeId(this,e,t)),this.setValid(t,this.isValid(e))&&this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);const r=this.type.typeIdToChildIndex[n],i=this.children[r];null==i||i.set(t,e)}addChild(t,e=`${this.children.length}`){const n=this.children.push(t),{type:{children:r,mode:i,typeIds:o}}=this,a=[...r,new Ed(e,t.type)];return this.type=new wl(i,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}}class $p extends Vp{}class Yp extends Vp{constructor(t){super(t),this._offsets=new Nh(new Int32Array(0))}setValue(t,e,n){const r=this._typeIds.set(t,n).buffer[t],i=this.getChildAt(this.type.typeIdToChildIndex[r]),o=this._offsets.set(t,i.length).buffer[t];null==i||i.set(o,e)}}class Wp extends Rh{constructor(t){super(t),this._values=new zh(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Iu(e))}_flushPending(t,e){}}Wp.prototype._flushPending=rp.prototype._flushPending;const Gp=new class extends Ml{visitNull(){return Ep}visitBool(){return ip}visitInt(){return gp}visitInt8(){return vp}visitInt16(){return wp}visitInt32(){return xp}visitInt64(){return Ap}visitUint8(){return Sp}visitUint16(){return Ip}visitUint32(){return Op}visitUint64(){return Tp}visitFloat(){return hp}visitFloat16(){return dp}visitFloat32(){return pp}visitFloat64(){return _p}visitUtf8(){return Wp}visitBinary(){return rp}visitFixedSizeBinary(){return lp}visitDate(){return op}visitDateDay(){return ap}visitDateMillisecond(){return sp}visitTimestamp(){return jp}visitTimestampSecond(){return Dp}visitTimestampMillisecond(){return zp}visitTimestampMicrosecond(){return Np}visitTimestampNanosecond(){return Cp}visitTime(){return Fp}visitTimeSecond(){return Lp}visitTimeMillisecond(){return Up}visitTimeMicrosecond(){return Rp}visitTimeNanosecond(){return Pp}visitDecimal(){return up}visitList(){return kp}visitStruct(){return Bp}visitUnion(){return Vp}visitDenseUnion(){return Yp}visitSparseUnion(){return $p}visitDictionary(){return cp}visitInterval(){return mp}visitIntervalDayTime(){return bp}visitIntervalYearMonth(){return yp}visitFixedSizeList(){return fp}visitMap(){return Mp}};class qp extends Ml{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every(((t,n)=>this.compareFields(t,e[n])))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function Xp(t,e){return e instanceof t.constructor}function Hp(t,e){return t===e||Xp(t,e)}function Zp(t,e){return t===e||Xp(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Jp(t,e){return t===e||Xp(t,e)&&t.precision===e.precision}function Kp(t,e){return t===e||Xp(t,e)&&t.unit===e.unit}function Qp(t,e){return t===e||Xp(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function t_(t,e){return t===e||Xp(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function e_(t,e){return t===e||Xp(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&r_.compareManyFields(t.children,e.children)}function n_(t,e){return t===e||Xp(t,e)&&t.unit===e.unit}qp.prototype.visitNull=Hp,qp.prototype.visitBool=Hp,qp.prototype.visitInt=Zp,qp.prototype.visitInt8=Zp,qp.prototype.visitInt16=Zp,qp.prototype.visitInt32=Zp,qp.prototype.visitInt64=Zp,qp.prototype.visitUint8=Zp,qp.prototype.visitUint16=Zp,qp.prototype.visitUint32=Zp,qp.prototype.visitUint64=Zp,qp.prototype.visitFloat=Jp,qp.prototype.visitFloat16=Jp,qp.prototype.visitFloat32=Jp,qp.prototype.visitFloat64=Jp,qp.prototype.visitUtf8=Hp,qp.prototype.visitBinary=Hp,qp.prototype.visitFixedSizeBinary=function(t,e){return t===e||Xp(t,e)&&t.byteWidth===e.byteWidth},qp.prototype.visitDate=Kp,qp.prototype.visitDateDay=Kp,qp.prototype.visitDateMillisecond=Kp,qp.prototype.visitTimestamp=Qp,qp.prototype.visitTimestampSecond=Qp,qp.prototype.visitTimestampMillisecond=Qp,qp.prototype.visitTimestampMicrosecond=Qp,qp.prototype.visitTimestampNanosecond=Qp,qp.prototype.visitTime=t_,qp.prototype.visitTimeSecond=t_,qp.prototype.visitTimeMillisecond=t_,qp.prototype.visitTimeMicrosecond=t_,qp.prototype.visitTimeNanosecond=t_,qp.prototype.visitDecimal=Hp,qp.prototype.visitList=function(t,e){return t===e||Xp(t,e)&&t.children.length===e.children.length&&r_.compareManyFields(t.children,e.children)},qp.prototype.visitStruct=function(t,e){return t===e||Xp(t,e)&&t.children.length===e.children.length&&r_.compareManyFields(t.children,e.children)},qp.prototype.visitUnion=e_,qp.prototype.visitDenseUnion=e_,qp.prototype.visitSparseUnion=e_,qp.prototype.visitDictionary=function(t,e){return t===e||Xp(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&r_.visit(t.indices,e.indices)&&r_.visit(t.dictionary,e.dictionary)},qp.prototype.visitInterval=n_,qp.prototype.visitIntervalDayTime=n_,qp.prototype.visitIntervalYearMonth=n_,qp.prototype.visitFixedSizeList=function(t,e){return t===e||Xp(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&r_.compareManyFields(t.children,e.children)},qp.prototype.visitMap=function(t,e){return t===e||Xp(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&r_.compareManyFields(t.children,e.children)};const r_=new qp;function i_(t,e){return r_.compareSchemas(t,e)}function o_(t){const e=t.type,n=new(Gp.getVisitFn(e)())(t);if(e.children&&e.children.length>0){const r=t.children||[],i={nullValues:t.nullValues},o=Array.isArray(r)?(t,e)=>r[e]||i:({name:t})=>r[t]||i;for(const[t,a]of e.children.entries()){const{type:e}=a,r=o(a,t);n.children.push(o_(Object.assign(Object.assign({},r),{type:e})))}}return n}function a_(t,e){if(t instanceof eh||t instanceof Mh||t.type instanceof Zc||ArrayBuffer.isView(t))return Bh(t);const n=[...u_({type:null!=e?e:s_(t),nullValues:[null]})(t)],r=1===n.length?n[0]:n.reduce(((t,e)=>t.concat(e)));return Zc.isDictionary(r.type)?r.memoize():r}function s_(t){if(0===t.length)return new Jc;let e=0,n=0,r=0,i=0,o=0,a=0,s=0,u=0;for(const c of t){if(null!=c){switch(typeof c){case"bigint":++a;continue;case"boolean":++s;continue;case"number":++i;continue;case"string":++o;continue;case"object":Array.isArray(c)?++n:"[object Date]"===Object.prototype.toString.call(c)?++u:++r;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}++e}if(i+e===t.length)return new cl;if(o+e===t.length)return new Tl(new fl,new el);if(a+e===t.length)return new nl;if(s+e===t.length)return new hl;if(u+e===t.length)return new _l;if(n+e===t.length){const e=t,n=s_(e[e.findIndex((t=>null!=t))]);if(e.every((t=>{return null==t||(e=n,r=s_(t),r_.visit(e,r));var e,r})))return new gl(new Ed("",n,!0))}else if(r+e===t.length){const e=new Map;for(const n of t)for(const t of Object.keys(n))e.has(t)||null==n[t]||e.set(t,new Ed(t,s_([n[t]]),!0));return new vl([...e.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function u_(t){const{queueingStrategy:e="count"}=t,{highWaterMark:n=("bytes"!==e?Number.POSITIVE_INFINITY:Math.pow(2,14))}=t,r="bytes"!==e?"length":"byteLength";return function*(e){let i=0;const o=o_(t);for(const t of e)o.append(t)[r]>=n&&++i&&(yield o.toVector());(o.finish().length>0||0===i)&&(yield o.toVector())}}function c_(t,e){return function(t,e){const n=[...t.fields],r=[],i={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let o=0,a=0,s=-1;const u=e.length;let c,l=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,s=-1;++s0&&(r[o++]=rh({type:new vl(n),length:a,nullCount:0,children:l.slice()})))}return[t=t.assign(n),r.map((e=>new p_(t,e)))]}(t,e.map((t=>t.data.concat())))}function l_(t,e,n,r,i){var o;const a=(e+63&-64)>>3;for(let s=-1,u=r.length;++s=e)c===e?n[s]=u:(n[s]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[s].unshift(u.slice(e,c-e))));else{const r=t[s];t[s]=r.clone({nullable:!0}),n[s]=null!==(o=null==u?void 0:u._changeLengthAndBackfillNullBitmap(e))&&void 0!==o?o:rh({type:r.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)})}}return n}var f_,h_;class d_{constructor(...t){var e,n;if(0===t.length)return this.batches=[],this.schema=new Md([]),this._offsets=[0],this;let r,i;t[0]instanceof Md&&(r=t.shift()),t.at(-1)instanceof Uint32Array&&(i=t.pop());const o=t=>{if(t){if(t instanceof p_)return[t];if(t instanceof d_)return t.batches;if(t instanceof eh){if(t.type instanceof vl)return[new p_(new Md(t.type.children),t)]}else{if(Array.isArray(t))return t.flatMap((t=>o(t)));if("function"==typeof t[Symbol.iterator])return[...t].flatMap((t=>o(t)));if("object"==typeof t){const e=Object.keys(t),n=e.map((e=>new Mh([t[e]]))),r=new Md(e.map(((t,e)=>new Ed(String(t),n[e].type)))),[,i]=c_(r,n);return 0===i.length?[new p_(t)]:i}}}return[]},a=t.flatMap((t=>o(t)));if(r=null!==(n=null!=r?r:null===(e=a[0])||void 0===e?void 0:e.schema)&&void 0!==n?n:new Md([]),!(r instanceof Md))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const s of a){if(!(s instanceof p_))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!i_(r,s.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=r,this.batches=a,this._offsets=null!=i?i:ah(this.data)}get data(){return this.batches.map((({data:t})=>t))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce(((t,e)=>t+e.length),0)}get nullCount(){return-1===this._nullCount&&(this._nullCount=oh(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?vh.visit(new Mh(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(",\n ")}\n]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap((({data:t})=>t)));return new d_(e,n.map((t=>new p_(e,t))))}slice(t,e){const n=this.schema;[t,e]=Yf({length:this.numRows},t,e);const r=sh(this.data,this._offsets,t,e);return new d_(n,r.map((t=>new p_(n,t))))}getChild(t){return this.getChildAt(this.schema.fields.findIndex((e=>e.name===t)))}getChildAt(t){if(t>-1&&te.children[t]));if(0===e.length){const{type:n}=this.schema.fields[t],r=rh({type:n,length:0,nullCount:0});e.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new Mh(e)}return null}setChild(t,e){var n;return this.setChildAt(null===(n=this.schema.fields)||void 0===n?void 0:n.findIndex((e=>e.name===t)),e)}setChildAt(t,e){let n=this.schema,r=[...this.batches];if(t>-1&&tthis.getChildAt(e)));[i[t],a[t]]=[o,e],[n,r]=c_(n,a)}return new d_(n,r)}select(t){const e=this.schema.fields.reduce(((t,e,n)=>t.set(e.name,n)),new Map);return this.selectAt(t.map((t=>e.get(t))).filter((t=>t>-1)))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map((e=>e.selectAt(t)));return new d_(e,n)}assign(t){const e=this.schema.fields,[n,r]=t.schema.fields.reduce(((t,n,r)=>{const[i,o]=t,a=e.findIndex((t=>t.name===n.name));return~a?o[a]=r:i.push(r),t}),[[],[]]),i=this.schema.assign(t.schema),o=[...e.map(((t,e)=>[e,r[e]])).map((([e,n])=>void 0===n?this.getChildAt(e):t.getChildAt(n))),...n.map((e=>t.getChildAt(e)))].filter(Boolean);return new d_(...c_(i,o))}}f_=Symbol.toStringTag,d_[f_]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=lh(ch),t.get=lh(Ff.getVisitFn(dc.Struct)),t.set=fh(lf.getVisitFn(dc.Struct)),t.indexOf=hh(mh.getVisitFn(dc.Struct)),t.getByteLength=lh(Ih.getVisitFn(dc.Struct)),"Table"))(d_.prototype);let p_=class t{constructor(...t){switch(t.length){case 2:if([this.schema]=t,!(this.schema instanceof Md))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=rh({nullCount:0,type:new vl(this.schema.fields),children:this.schema.fields.map((t=>rh({type:t.type,nullCount:0})))})]=t,!(this.data instanceof eh))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=__(this.schema,this.data.children);break;case 1:{const[e]=t,{fields:n,children:r,length:i}=Object.keys(e).reduce(((t,n,r)=>(t.children[r]=e[n],t.length=Math.max(t.length,e[n].length),t.fields[r]=Ed.new({name:n,type:e[n].type,nullable:!0}),t)),{length:0,fields:new Array,children:new Array}),o=new Md(n),a=rh({type:new vl(n),length:i,children:r,nullCount:0});[this.schema,this.data]=__(o,a.children,i);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=m_(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Ff.visit(this.data,t)}set(t,e){return lf.visit(this.data,t,e)}indexOf(t,e){return mh.visit(this.data,t,e)}getByteLength(t){return Ih.visit(this.data,t)}[Symbol.iterator](){return vh.visit(new Mh([this.data]))}toArray(){return[...this]}concat(...t){return new d_(this.schema,[this,...t])}slice(e,n){const[r]=new Mh([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(t){var e;return this.getChildAt(null===(e=this.schema.fields)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te.name===t)),e)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ee.name===t));~e&&(i[e]=this.data.children[e])}return new t(n,rh({type:r,length:this.numRows,children:i}))}selectAt(e){const n=this.schema.selectAt(e),r=e.map((t=>this.data.children[t])).filter(Boolean),i=rh({type:new vl(n.fields),length:this.numRows,children:r});return new t(n,i)}};function __(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){var r;const i=[...t.fields],o=[...e],a=(n+63&-64)>>3;for(const[s,u]of t.fields.entries()){const t=e[s];t&&t.length===n||(i[s]=u.clone({nullable:!0}),o[s]=null!==(r=null==t?void 0:t._changeLengthAndBackfillNullBitmap(n))&&void 0!==r?r:rh({type:u.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[t.assign(i),rh({type:new vl(i),length:n,children:o})]}function m_(t,e,n=new Map){for(let r=-1,i=t.length;++r0&&m_(i.children,o.children,n)}return n}h_=Symbol.toStringTag,p_[h_]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(p_.prototype);class b_ extends p_{constructor(t){const e=t.fields.map((t=>rh({type:t.type})));super(t,rh({type:new vl(t.fields),nullCount:0,children:e}))}}var y_,g_,v_,w_;(g_=y_||(y_={}))[g_.BUFFER=0]="BUFFER",(w_=v_||(v_={}))[w_.LZ4_FRAME=0]="LZ4_FRAME",w_[w_.ZSTD=1]="ZSTD";class x_{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new x_).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new x_).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):v_.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):y_.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,v_.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,y_.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return x_.startBodyCompression(t),x_.addCodec(t,e),x_.addMethod(t,n),x_.endBodyCompression(t)}}class A_{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(null!=n?n:0)),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}}let S_=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(null!=n?n:0)),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}},I_=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new S_).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new A_).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new x_).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}},O_=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new I_).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var T_;!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(T_||(T_={}));let k_=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Jh.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):T_.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new Zh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,Jh.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,T_.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(e,n,r,i,o,a){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,o),t.addCustomMetadata(e,a),t.endMessage(e)}};const M_=new class extends Ml{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return yd.startNull(e),yd.endNull(e)}visitInt(t,e){return rd.startInt(e),rd.addBitWidth(e,t.bitWidth),rd.addIsSigned(e,t.isSigned),rd.endInt(e)}visitFloat(t,e){return pd.startFloatingPoint(e),pd.addPrecision(e,t.precision),pd.endFloatingPoint(e)}visitBinary(t,e){return od.startBinary(e),od.endBinary(e)}visitBool(t,e){return ad.startBool(e),ad.endBool(e)}visitUtf8(t,e){return Id.startUtf8(e),Id.endUtf8(e)}visitDecimal(t,e){return ud.startDecimal(e),ud.addScale(e,t.scale),ud.addPrecision(e,t.precision),ud.addBitWidth(e,t.bitWidth),ud.endDecimal(e)}visitDate(t,e){return sd.startDate(e),sd.addUnit(e,t.unit),sd.endDate(e)}visitTime(t,e){return vd.startTime(e),vd.addUnit(e,t.unit),vd.addBitWidth(e,t.bitWidth),vd.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return wd.startTimestamp(e),wd.addUnit(e,t.unit),void 0!==n&&wd.addTimezone(e,n),wd.endTimestamp(e)}visitInterval(t,e){return _d.startInterval(e),_d.addUnit(e,t.unit),_d.endInterval(e)}visitList(t,e){return md.startList(e),md.endList(e)}visitStruct(t,e){return gd.startStruct_(e),gd.endStruct_(e)}visitUnion(t,e){Sd.startTypeIdsVector(e,t.typeIds.length);const n=Sd.createTypeIdsVector(e,t.typeIds);return Sd.startUnion(e),Sd.addMode(e,t.mode),Sd.addTypeIds(e,n),Sd.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return id.startDictionaryEncoding(e),id.addId(e,BigInt(t.id)),id.addIsOrdered(e,t.isOrdered),void 0!==n&&id.addIndexType(e,n),id.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return hd.startFixedSizeBinary(e),hd.addByteWidth(e,t.byteWidth),hd.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return dd.startFixedSizeList(e),dd.addListSize(e,t.listSize),dd.endFixedSizeList(e)}visitMap(t,e){return bd.startMap(e),bd.addKeysSorted(e,t.keysSorted),bd.endMap(e)}};function E_(t){return new R_(t.count,j_(t.columns),D_(t.columns))}function B_(t,e){return(t.children||[]).filter(Boolean).map((t=>Ed.fromJSON(t,e)))}function j_(t){return(t||[]).reduce(((t,e)=>{return[...t,new $_(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...j_(e.children)];var n}),[])}function D_(t,e=[]){for(let n=-1,r=(t||[]).length;++n{switch(e){case fc.Schema:return Md.fromJSON(t);case fc.RecordBatch:return R_.fromJSON(t);case fc.DictionaryBatch:return P_.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${fc[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new L_(Yu(t));const e=k_.getRootAsMessage(t),n=e.bodyLength(),r=e.version(),i=e.headerType(),o=new U_(n,r,i);return o._createHeader=function(t,e){return()=>{switch(e){case fc.Schema:return Md.decode(t.header(new Td));case fc.RecordBatch:return R_.decode(t.header(new I_),t.version());case fc.DictionaryBatch:return P_.decode(t.header(new O_),t.version())}throw new Error(`Unrecognized Message type: { name: ${fc[e]}, type: ${e} }`)}}(e,i),o}static encode(t){const e=new F_;let n=-1;return t.isSchema()?n=Md.encode(e,t.header()):t.isRecordBatch()?n=R_.encode(e,t.header()):t.isDictionaryBatch()&&(n=P_.encode(e,t.header())),k_.startMessage(e),k_.addVersion(e,Qu.V4),k_.addHeader(e,n),k_.addHeaderType(e,t.headerType),k_.addBodyLength(e,BigInt(t.bodyLength)),k_.finishMessageBuffer(e,k_.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Md)return new U_(0,Qu.V4,fc.Schema,t);if(t instanceof R_)return new U_(e,Qu.V4,fc.RecordBatch,t);if(t instanceof P_)return new U_(e,Qu.V4,fc.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===fc.Schema}isRecordBatch(){return this.headerType===fc.RecordBatch}isDictionaryBatch(){return this.headerType===fc.DictionaryBatch}constructor(t,e,n,r){this._version=e,this._headerType=n,this.body=new Uint8Array(0),r&&(this._createHeader=()=>r),this._bodyLength=Mc(t)}}class R_{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=Mc(t)}}class P_{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=Mc(e)}}class V_{constructor(t,e){this.offset=Mc(t),this.length=Mc(e)}}class $_{constructor(t,e){this.length=Mc(t),this.nullCount=Mc(e)}}function Y_(t,e){const n=[];for(let r,i=-1,o=-1,a=t.childrenLength();++iEd.encode(t,e))),u=Od.createChildrenVector(t,s),c=e.metadata&&e.metadata.size>0?Od.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const r=t.createString(`${e}`),i=t.createString(`${n}`);return Zh.startKeyValue(t),Zh.addKey(t,r),Zh.addValue(t,i),Zh.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Od.startField(t),Od.addType(t,r),Od.addTypeType(t,a),Od.addChildren(t,u),Od.addNullable(t,!!e.nullable),-1!==n&&Od.addName(t,n);-1!==i&&Od.addDictionary(t,i);-1!==c&&Od.addCustomMetadata(t,c);return Od.endField(t)},Ed.decode=function(t,e){let n,r,i,o,a,s;e&&(s=t.dictionary())?e.has(n=Mc(s.id()))?(o=(o=s.indexType())?G_(o):new el,a=new Tl(e.get(n),o,n,s.isOrdered()),r=new Ed(t.name(),a,t.nullable(),W_(t))):(o=(o=s.indexType())?G_(o):new el,e.set(n,i=q_(t,Y_(t,e))),a=new Tl(i,o,n,s.isOrdered()),r=new Ed(t.name(),a,t.nullable(),W_(t))):(i=q_(t,Y_(t,e)),r=new Ed(t.name(),i,t.nullable(),W_(t)));return r||null},Ed.fromJSON=function(t,e){let n,r,i,o,a,s;return e&&(o=t.dictionary)?e.has(n=o.id)?(r=(r=o.indexType)?N_(r):new el,s=new Tl(e.get(n),r,n,o.isOrdered),i=new Ed(t.name,s,t.nullable,z_(t.customMetadata))):(r=(r=o.indexType)?N_(r):new el,e.set(n,a=C_(t,B_(t,e))),s=new Tl(a,r,n,o.isOrdered),i=new Ed(t.name,s,t.nullable,z_(t.customMetadata))):(a=C_(t,B_(t,e)),i=new Ed(t.name,a,t.nullable,z_(t.customMetadata))),i||null},Md.encode=function(t,e){const n=e.fields.map((e=>Ed.encode(t,e)));Td.startFieldsVector(t,n.length);const r=Td.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?Td.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const r=t.createString(`${e}`),i=t.createString(`${n}`);return Zh.startKeyValue(t),Zh.addKey(t,r),Zh.addValue(t,i),Zh.endKeyValue(t)}))):-1;Td.startSchema(t),Td.addFields(t,r),Td.addEndianness(t,X_?Kh.Little:Kh.Big),-1!==i&&Td.addCustomMetadata(t,i);return Td.endSchema(t)},Md.decode=function(t,e=new Map){const n=function(t,e){const n=[];for(let r,i=-1,o=-1,a=t.fieldsLength();++iEd.fromJSON(t,e)))}(t,e),z_(t.customMetadata),e)},R_.encode=function(t,e){const n=e.nodes||[],r=e.buffers||[];I_.startNodesVector(t,n.length);for(const a of n.slice().reverse())$_.encode(t,a);const i=t.endVector();I_.startBuffersVector(t,r.length);for(const a of r.slice().reverse())V_.encode(t,a);const o=t.endVector();return I_.startRecordBatch(t),I_.addLength(t,BigInt(e.length)),I_.addNodes(t,i),I_.addBuffers(t,o),I_.endRecordBatch(t)},R_.decode=function(t,e=Qu.V4){if(null!==t.compression())throw new Error("Record batch compression not implemented");return new R_(t.length(),function(t){const e=[];for(let n,r=-1,i=-1,o=t.nodesLength();++r{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0]})(),H_=t=>`Expected ${fc[t]} Message in stream, but was null or length 0.`,Z_=t=>`Header pointer of flatbuffer-encoded ${fc[t]} Message is null or length 0.`,J_=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,K_=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class Q_{constructor(t){this.source=t instanceof $d?t:new $d(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||-1===t.value&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Ld:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(null!=t&&e.value.headerType!==t)throw new Error(H_(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=Yu(this.source.read(t));if(e.byteLength[...e,...n.VALIDITY&&[n.VALIDITY]||[],...n.TYPE&&[n.TYPE]||[],...n.OFFSET&&[n.OFFSET]||[],...n.DATA&&[n.DATA]||[],...t(n.children)]),[])}(this._body)}readMessage(t){let e;if((e=this.next()).done)return null;if(null!=t&&e.value.headerType!==t)throw new Error(H_(t));return e.value}readSchema(){const t=fc.Schema,e=this.readMessage(t),n=null==e?void 0:e.header();if(!e||!n)throw new Error(Z_(t));return n}}const nm=4,rm="ARROW1",im=new Uint8Array(rm.length);for(let cb=0;cbthis)):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Hu.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Hu.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof cm?t:Bu(t)?function(t){return new lm(new gm(t))}(t):Du(t)?function(t){return mu(this,void 0,void 0,(function*(){const{size:e}=yield t.stat(),n=new Xd(t,e);return e>=um&&om(yield n.readAt(0,am+7&-8))?new dm(new ym(n)):new fm(new mm(n))}))}(t):ku(t)?(()=>mu(this,void 0,void 0,(function*(){return yield cm.from(yield t)})))():zu(t)||Cu(t)||Fu(t)||Eu(t)?function(t){return mu(this,void 0,void 0,(function*(){const e=yield t.peek(am+7&-8);return e&&e.byteLength>=4?om(e)?new hm(new bm(yield t.read())):new fm(new mm(t)):new fm(new mm(function(){return gu(this,arguments,(function*(){}))}()))}))}(new Yd(t)):function(t){const e=t.peek(am+7&-8);return e&&e.byteLength>=4?om(e)?new hm(new bm(t.read())):new lm(new _m(t)):new lm(new _m(function*(){}()))}(new $d(t))}static readAll(t){return t instanceof cm?t.isSync()?wm(t):xm(t):Bu(t)||ArrayBuffer.isView(t)||Mu(t)||ju(t)?wm(t):xm(t)}}class lm extends cm{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return gu(this,arguments,(function*(){yield yu(yield*vu(wu(this[Symbol.iterator]())))}))}}class fm extends cm{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,r;return mu(this,void 0,void 0,(function*(){const i=new Array;try{for(var o,a=!0,s=wu(this);o=yield s.next(),!(t=o.done);a=!0){r=o.value,a=!1;const t=r;i.push(t)}}catch(u){e={error:u}}finally{try{a||t||!(n=s.return)||(yield n.call(s))}finally{if(e)throw e.error}}return i}))}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class hm extends lm{constructor(t){super(t),this._impl=t}}class dm extends fm{constructor(t){super(t),this._impl=t}}class pm{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){const n=this._loadVectors(t,e,this.schema.fields),r=rh({type:new vl(this.schema.fields),length:t.length,children:n});return new p_(this.schema,r)}_loadDictionaryBatch(t,e){const{id:n,isDelta:r}=t,{dictionaries:i,schema:o}=this,a=i.get(n);if(r||!a){const i=o.dictionaries.get(n),s=this._loadVectors(t.data,e,[i]);return(a&&r?a.concat(new Mh(s)):new Mh(s)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new ep(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}}class _m extends pm{constructor(t,e){super(e),this._reader=Bu(t)?new em(this._handle=t):new Q_(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=vm(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Ld}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Ld}next(){if(this.closed)return Ld;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),r=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),r=e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new b_(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class mm extends pm{constructor(t,e){super(e),this._reader=new tm(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return mu(this,void 0,void 0,(function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}))}open(t){return mu(this,void 0,void 0,(function*(){return this.closed||(this.autoDestroy=vm(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this}))}throw(t){return mu(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Ld}))}return(t){return mu(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Ld}))}next(){return mu(this,void 0,void 0,(function*(){if(this.closed)return Ld;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;const n=t.header(),r=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),r=yield e.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new b_(this.schema)}):yield this.return()}))}_readNextMessageAndValidate(t){return mu(this,void 0,void 0,(function*(){return yield this._reader.readMessage(t)}))}}class bm extends _m{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof qd?t:new qd(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const n=null===(e=this._footer)||void 0===e?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){const t=this._reader.readMessage(fc.RecordBatch);if(null==t?void 0:t.isRecordBatch()){const e=t.header(),n=this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,n)}}return null}_readDictionaryBatch(t){var e;const n=null===(e=this._footer)||void 0===e?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){const t=this._reader.readMessage(fc.DictionaryBatch);if(null==t?void 0:t.isDictionaryBatch()){const e=t.header(),n=this._reader.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,r)}}}_readFooter(){const{_handle:t}=this,e=t.size-sm,n=t.readInt32(e),r=t.readAt(e-n,n);return Nd.decode(r)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return mu(this,void 0,void 0,(function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)}))}readRecordBatch(t){var e;return mu(this,void 0,void 0,(function*(){if(this.closed)return null;this._footer||(yield this.open());const n=null===(e=this._footer)||void 0===e?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){const t=yield this._reader.readMessage(fc.RecordBatch);if(null==t?void 0:t.isRecordBatch()){const e=t.header(),n=yield this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,n)}}return null}))}_readDictionaryBatch(t){var e;return mu(this,void 0,void 0,(function*(){const n=null===(e=this._footer)||void 0===e?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){const t=yield this._reader.readMessage(fc.DictionaryBatch);if(null==t?void 0:t.isDictionaryBatch()){const e=t.header(),n=yield this._reader.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,r)}}}))}_readFooter(){return mu(this,void 0,void 0,(function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-sm,n=yield t.readInt32(e),r=yield t.readAt(e-n,n);return Nd.decode(r)}))}_readNextMessageAndValidate(t){return mu(this,void 0,void 0,(function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndexAm(t))):e.isAsync()?e.readAll().then((t=>new d_(t))):new d_(e.readAll())}class Sm extends ya{constructor(t,e,n){super(t,e,n),this.buffer_size=67108864,this._use_scale_to_download_tiles=!0,this.fbos={},this.textures={};const r=this.canvas;if(void 0===this.canvas)throw new Error("No canvas found");this.regl=ha({optionalExtensions:["OES_standard_derivatives","OES_element_index_uint","OES_texture_float","OES_texture_half_float"],canvas:r}),this.tileSet=e,this.aes=new pu(n,this.regl,e),this.initialize_textures(),this._initializations=[this.tileSet.promise.then((()=>{this.remake_renderer(),this._webgl_scale_history=[this.default_webgl_scale,this.default_webgl_scale]}))],this.initialize(),this._buffers=new Om(this.regl,this.buffer_size)}get buffers(){return this._buffers=this._buffers||new Om(this.regl,this.buffer_size),this._buffers}data(t){return void 0===t?this.tileSet:(this.tileSet=t,this)}get props(){this.allocate_aesthetic_buffers();const{prefs:t,aes_to_buffer_num:e,buffer_num_to_variable:n,variable_to_buffer_num:r}=this,{transform:i}=this.zoom,o=this.aes.dim("color"),[a,s]=[o.current,o.last],u=[s.colorscheme_size,a.colorscheme_size],c={aes:{encoding:this.aes.encoding},colors_as_grid:0,corners:this.zoom.current_corners(),zoom_balance:t.zoom_balance,transform:i,max_ix:this.max_ix,point_size:this.point_size,alpha:this.optimal_alpha,time:Date.now()-this.zoom._start,update_time:Date.now()-this.most_recent_restart,relative_time:(Date.now()-this.most_recent_restart)/t.duration,string_index:0,prefs:JSON.parse(JSON.stringify(t)),color_type:void 0,wrap_colors_after:u,start_time:this.most_recent_restart,webgl_scale:this._webgl_scale_history[0],last_webgl_scale:this._webgl_scale_history[1],use_scale_for_tiles:this._use_scale_to_download_tiles,grid_mode:0,buffer_num_to_variable:n,aes_to_buffer_num:e,variable_to_buffer_num:r,color_picker_mode:0,zoom_matrix:[[i.k,0,i.x],[0,i.k,i.y],[0,0,1]].flat()};return JSON.parse(JSON.stringify(c))}get default_webgl_scale(){return this._default_webgl_scale||(this._default_webgl_scale=this.zoom.webgl_scale()),this._default_webgl_scale}render_points(t){const e=[];let n=0;const r=this.aes.store.foreground.states[0].active||this.aes.store.foreground.states[1].active;for(const i of this.visible_tiles()){if(i._buffer_manager=i._buffer_manager||new Im(this.regl,i,this),!i._buffer_manager.ready(t.block_for_buffers))continue;const o={manager:i._buffer_manager,number:n++,foreground:r?1:-1,tile_id:i.numeric_id,sprites:this.sprites};if(Object.assign(o,t),e.push(o),r){const t={...o,foreground:0};e.push(t)}}e.sort(((t,e)=>1e3*(3+t.foreground)-1e3*(3+e.foreground)+e.number-t.number)),this._renderer(e)}tick(){const{prefs:t}=this,{regl:e,tileSet:n}=this,{props:r}=this;this.tick_num=this.tick_num||0,this.tick_num++,this._use_scale_to_download_tiles?n.download_most_needed_tiles(this.zoom.current_corners(),this.props.max_ix,5):n.download_most_needed_tiles(t.max_points,this.max_ix,5),e.clear({color:[.9,.9,.93,0],depth:1});const i=Date.now();!async function(t){for(;Date.now()-i<10&&t.length>0;){const n=t.shift();if(void 0!==n)try{await n()}catch(e){console.warn(e,n)}}}(this.deferred_functions);try{this.render_all(r)}catch(o){throw console.warn("ERROR NOTED"),this.reglframe.cancel(),o}}single_blur_pass(t,e,n){const{regl:r}=this;e.use((()=>{r.clear({color:[0,0,0,0]}),r({frag:"precision mediump float;\n#define GLSLIFY 1\n\nvec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {\n vec4 color = vec4(0.0);\n vec2 off1 = vec2(1.411764705882353) * direction;\n vec2 off2 = vec2(3.2941176470588234) * direction;\n vec2 off3 = vec2(5.176470588235294) * direction;\n color += texture2D(image, uv) * 0.1964825501511404;\n color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;\n color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;\n color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;\n color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;\n color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;\n color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;\n return color;\n}\n\nuniform vec2 iResolution;\nuniform sampler2D iChannel0;\nuniform vec2 direction;\n\nvoid main() {\n vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);\n gl_FragColor = blur13(iChannel0, uv, iResolution.xy, direction);\n}\n",uniforms:{iResolution:({viewportWidth:t,viewportHeight:e})=>[t,e],iChannel0:t,direction:n},vert:"\n precision mediump float;\n attribute vec2 position;\n varying vec2 uv;\n void main() {\n uv = 0.5 * (position + 1.0);\n gl_Position = vec4(position, 0, 1);\n }",attributes:{position:[-4,-4,4,-4,0,4]},depth:{enable:!1},count:3})()}))}blur(t,e,n=3){let r=n-1;for(;r>-1;)this.single_blur_pass(t,e,[2**r,0]),this.single_blur_pass(e,t,[0,2**r]),r-=1}render_all(t){const{regl:e}=this;this.fbos.points.use((()=>{e.clear({color:[0,0,0,0]}),this.render_points(t)})),e.clear({color:[0,0,0,0]}),this.fbos.lines.use((()=>e.clear({color:[0,0,0,0]}))),this.scatterplot.trimap&&this.fbos.lines.use((()=>{this.scatterplot.trimap.zoom=this.zoom,this.scatterplot.trimap.tick("polygon")}));for(const n of[this.fbos.lines,this.fbos.points])e({profile:!0,blend:{enable:!0,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D tex;\n uniform float wRcp, hRcp;\n void main() {\n gl_FragColor = texture2D(tex, uv);\n }\n ",vert:"\n precision mediump float;\n attribute vec2 position;\n varying vec2 uv;\n void main() {\n uv = 0.5 * (position + 1.0);\n gl_Position = vec4(position, 0., 1.);\n }\n ",attributes:{position:this.fill_buffer},depth:{enable:!1},count:3,uniforms:{tex:()=>n,wRcp:({viewportWidth:t})=>1/t,hRcp:({viewportHeight:t})=>1/t}})()}initialize_textures(){const{regl:t}=this;this.fbos=this.fbos||{},this.textures=this.textures||{},this.textures.empty_texture=t.texture(Nt(128).map((t=>Nt(128).map((t=>[0,0,0]))))),this.fbos.minicounter=t.framebuffer({width:512,height:512,depth:!1}),this.fbos.lines=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.points=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.ping=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.pong=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.contour=this.fbos.contour||t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.colorpicker=this.fbos.colorpicker||t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.dummy=this.fbos.dummy||t.framebuffer({width:1,height:1,depth:!1})}get_image_texture(t){const{regl:e}=this;if(this.textures=this.textures||{},this.textures[t])return this.textures[t];const n=new Image;return n.src=t,n.addEventListener("load",(()=>{this.textures[t]=e.texture(n)})),this.textures[t]}n_visible(t=-1){let{width:e,height:n}=this;e=Math.floor(e),n=Math.floor(n),void 0===this.contour_vals&&(this.contour_vals=new Uint8Array(e*n*4));const{props:r}=this;let i;return r.only_color=t,this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(r),this.regl.read(this.contour_vals),i=function(t,e){let n=0;if(void 0===e)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}(this.contour_vals)})),i}get integer_buffer(){if(void 0===this._integer_buffer){const t=new Float32Array(65536);for(let e=0;e<65536;e++)t[e]=e;this._integer_buffer=this.regl.buffer(t)}return this._integer_buffer}color_pick(t,e){if(0===e)return null;const n=this.color_pick_single(t,e,"tile_id");if(-1==n)return null;const r=this.color_pick_single(t,e,"ix_in_tile");if(-1===r)return null;for(const i of this.visible_tiles())if(i.numeric_id===n)return i.record_batch.get(r);return null}color_pick_single(t,e,n="tile_id"){const{props:r,height:i}=this;r.color_picker_mode=["ix","tile_id","ix_in_tile"].indexOf(n)+1;let o=[0,0,0,0];this.fbos.colorpicker.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(r);try{o=this.regl.read({x:t,y:i-e,width:1,height:1})}catch{console.warn("Read bad data from",{x:t,y:e,height:i,attempted:i-e})}}));const a=da(...o)-1;return Math.round(a)}get fill_buffer(){if(!this._fill_buffer){const{regl:t}=this;this._fill_buffer=t.buffer({data:[-4,-4,4,-4,0,4]})}return this._fill_buffer}draw_contour_buffer(t,e){let{width:n,height:r}=this;n=Math.floor(n),r=Math.floor(r),this.contour_vals=this.contour_vals||new Uint8Array(4*n*r),this.contour_alpha_vals=this.contour_alpha_vals||new Uint16Array(n*r);const{props:i}=this;i.aes.encoding.color={field:t},i.only_color=e,this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(i),this.regl.read(this.contour_vals)})),this.blur(this.fbos.contour,this.fbos.ping,3),this.fbos.contour.use((()=>{this.regl.read(this.contour_vals)}));let o=0;for(;oe<.5,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},primitive:"points",frag:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n\nprecision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fill;\nvarying vec2 letter_pos;\nvarying float point_size;\n\nuniform float u_only_color;\nuniform float u_color_picker_mode;\n//uniform float u_use_glyphset;\n//uniform sampler2D u_glyphset;\n\nfloat delta = 0.0, alpha = 1.0;\n\nbool out_of_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.03) {return true;}\n return false;\n}\n\nbool out_of_hollow_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.01) {return true;}\n float distance_from_edge = (1.0 - r_sq) * point_size;\n if (distance_from_edge > 4.0) {return true;}\n return false;\n}\n\nbool out_of_triangle(in vec2 coord) {\n if (coord.y > (2. * abs(coord.x - .5))) {\n return false;\n }\n return true;\n}\n\nvoid main() {\n if (u_only_color >= -1.5) {\n gl_FragColor = vec4(0., 0., 0., 1./255.);\n return;\n }\n\n float alpha = fill.a;\n// if (u_use_glyphset == 0. || point_size < 5.0) {\n if (out_of_circle(gl_PointCoord)) {\n discard;\n return;\n }\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n float r = dot(cxy, cxy);\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha *= (1.0 - smoothstep(1.0 - delta, 1.0 + delta, r));\n #endif\n/* } else {\n vec2 coords = letter_pos + gl_PointCoord/8.;\n// vec2 coords = vec2(.2, .2);\n vec4 sprite = texture2D(u_glyphset, coords);\n alpha *= (sprite.a); \n// fill = vec4(1.0, 1.0, 1.0, alpha); \n if (alpha <= 0.03) discard;\n }*/\n // Pre-blend the alpha channel.\n if (u_color_picker_mode >= 1.) {\n // no alpha when color picking; we use all four channels for that.\n gl_FragColor = fill;\n } else {\n gl_FragColor = vec4(fill.rgb * alpha, alpha);\n }\n\n}\n",vert:'precision mediump float;\n#define GLSLIFY 1\n\nuniform float u_zoom_balance;\nuniform float u_tile_id;\nuniform float u_update_time;\nuniform float u_transition_duration;\nuniform vec2 u_wrap_colors_after;\n// Type of jitter.\nuniform float u_jitter;\nuniform float u_last_jitter;\n\n// Whether to plot only a single category.\nuniform float u_only_color;\nuniform float u_grid_mode;\n\nuniform vec3 u_filter_numeric; // An override for simple numeric operations.\nuniform vec3 u_last_filter_numeric; // An override for simple numeric operations.\n\nuniform vec3 u_filter2_numeric; // An override for simple numeric operations.\nuniform vec3 u_last_filter2_numeric; // An override for simple numeric operations.\n\nuniform vec3 u_foreground_numeric; // An override for simple numeric operations.\nuniform vec3 u_last_foreground_numeric; // An override for simple numeric operations.\n\n// Transform from data space to the open window.\nuniform mat3 u_window_scale;\nuniform mat3 u_last_window_scale;\n// Transform from the open window to the d3-zoom.\nuniform mat3 u_zoom;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_use_glyphset;\nvarying vec2 letter_pos; // store which letter to use.\n\nuniform float u_maxix; // The maximum index to plot.\nuniform float u_time; // The current time.\nuniform float u_k; // The d3-scale factor.\nuniform float u_color_picker_mode;\nuniform float u_base_size;\nuniform float u_alpha;\nuniform float u_foreground_number; // -1 -- everything is foreground; 0 -- background; 1 -- foreground.\nuniform vec4 u_background_rgba;\nuniform float u_foreground_alpha;\nuniform float u_background_mouseover;\nuniform float u_foreground_size;\nuniform float u_background_size;\n\nuniform sampler2D u_one_d_aesthetic_map;\nuniform sampler2D u_color_aesthetic_map;\n\n// The same set of items for a variety of aesthetics.\n\n// whether to continuously interpolate between\n// x0 and x, y0 and y.\nuniform float u_position_interpolation_mode;\n\nfloat a_color;\nfloat a_last_color;\n\nuniform float u_color_buffer_num;\nuniform float u_last_color_buffer_num;\n\nuniform vec3 u_color_constant;\nuniform vec3 u_last_color_constant;\n\nuniform float u_color_transform;\nuniform float u_last_color_transform;\nuniform vec2 u_color_domain;\nuniform vec2 u_last_color_domain;\nuniform float u_last_color_map_position;\nuniform float u_color_map_position;\n\nbool a_color_is_constant;\nbool a_last_color_is_constant;\n\n/*\npython code to generate what follows.\ndef autogenerate_code():\n ks = ["x", "y", "jitter_radius", "jitter_speed", "size", "filter", "filter2", "x0", "y0", "foreground"]\n times = ["", "last_"]\n print("""\n // BEGIN AUTOGENERATED. DO NOT EDIT. \n // ------------------------------------------------ \n """)\n for k in ks:\n for time in times:\n timek = time + k\n print(f"""\n uniform float u_{timek}_buffer_num;\n uniform float u_{timek}_constant;\n uniform float u_{timek}_transform;\n uniform vec2 u_{timek}_domain;\n uniform vec2 u_{timek}_range;\n uniform float u_{timek}_map_position;\n float a_{timek};\n bool a_{timek}_is_constant;\n """)\n for i in range(0, 16):\n print(f"attribute float buffer_{i};")\n for k in ks:\n for time in times:\n timek = time + k\n print(f"""\n if (u_{timek}_buffer_num > -0.5) {{\n a_{timek} = get_buffer(u_{timek}_buffer_num);\n a_{timek}_is_constant = false;\n }} else {{\n a_{timek} = u_{timek}_constant;\n a_{timek}_is_constant = true;\n }}""")\n print("""\n// END AUTOGENERATED. DO NOT EDIT ABOVE. \n// ------------------------------------------------ \n """)\n\nautogenerate_code()\n*/\n\n // BEGIN AUTOGENERATED. DO NOT EDIT. \n // ------------------------------------------------ \n \n\n uniform float u_x_buffer_num;\n uniform float u_x_constant;\n uniform float u_x_transform;\n uniform vec2 u_x_domain;\n uniform vec2 u_x_range;\n uniform float u_x_map_position;\n float a_x;\n bool a_x_is_constant;\n \n\n uniform float u_last_x_buffer_num;\n uniform float u_last_x_constant;\n uniform float u_last_x_transform;\n uniform vec2 u_last_x_domain;\n uniform vec2 u_last_x_range;\n uniform float u_last_x_map_position;\n float a_last_x;\n bool a_last_x_is_constant;\n \n\n uniform float u_y_buffer_num;\n uniform float u_y_constant;\n uniform float u_y_transform;\n uniform vec2 u_y_domain;\n uniform vec2 u_y_range;\n uniform float u_y_map_position;\n float a_y;\n bool a_y_is_constant;\n \n\n uniform float u_last_y_buffer_num;\n uniform float u_last_y_constant;\n uniform float u_last_y_transform;\n uniform vec2 u_last_y_domain;\n uniform vec2 u_last_y_range;\n uniform float u_last_y_map_position;\n float a_last_y;\n bool a_last_y_is_constant;\n \n\n uniform float u_jitter_radius_buffer_num;\n uniform float u_jitter_radius_constant;\n uniform float u_jitter_radius_transform;\n uniform vec2 u_jitter_radius_domain;\n uniform vec2 u_jitter_radius_range;\n uniform float u_jitter_radius_map_position;\n float a_jitter_radius;\n bool a_jitter_radius_is_constant;\n \n\n uniform float u_last_jitter_radius_buffer_num;\n uniform float u_last_jitter_radius_constant;\n uniform float u_last_jitter_radius_transform;\n uniform vec2 u_last_jitter_radius_domain;\n uniform vec2 u_last_jitter_radius_range;\n uniform float u_last_jitter_radius_map_position;\n float a_last_jitter_radius;\n bool a_last_jitter_radius_is_constant;\n \n\n uniform float u_jitter_speed_buffer_num;\n uniform float u_jitter_speed_constant;\n uniform float u_jitter_speed_transform;\n uniform vec2 u_jitter_speed_domain;\n uniform vec2 u_jitter_speed_range;\n uniform float u_jitter_speed_map_position;\n float a_jitter_speed;\n bool a_jitter_speed_is_constant;\n \n\n uniform float u_last_jitter_speed_buffer_num;\n uniform float u_last_jitter_speed_constant;\n uniform float u_last_jitter_speed_transform;\n uniform vec2 u_last_jitter_speed_domain;\n uniform vec2 u_last_jitter_speed_range;\n uniform float u_last_jitter_speed_map_position;\n float a_last_jitter_speed;\n bool a_last_jitter_speed_is_constant;\n \n\n uniform float u_size_buffer_num;\n uniform float u_size_constant;\n uniform float u_size_transform;\n uniform vec2 u_size_domain;\n uniform vec2 u_size_range;\n uniform float u_size_map_position;\n float a_size;\n bool a_size_is_constant;\n \n\n uniform float u_last_size_buffer_num;\n uniform float u_last_size_constant;\n uniform float u_last_size_transform;\n uniform vec2 u_last_size_domain;\n uniform vec2 u_last_size_range;\n uniform float u_last_size_map_position;\n float a_last_size;\n bool a_last_size_is_constant;\n \n\n uniform float u_filter_buffer_num;\n uniform float u_filter_constant;\n uniform float u_filter_transform;\n uniform vec2 u_filter_domain;\n uniform vec2 u_filter_range;\n uniform float u_filter_map_position;\n float a_filter;\n bool a_filter_is_constant;\n \n\n uniform float u_last_filter_buffer_num;\n uniform float u_last_filter_constant;\n uniform float u_last_filter_transform;\n uniform vec2 u_last_filter_domain;\n uniform vec2 u_last_filter_range;\n uniform float u_last_filter_map_position;\n float a_last_filter;\n bool a_last_filter_is_constant;\n \n\n uniform float u_filter2_buffer_num;\n uniform float u_filter2_constant;\n uniform float u_filter2_transform;\n uniform vec2 u_filter2_domain;\n uniform vec2 u_filter2_range;\n uniform float u_filter2_map_position;\n float a_filter2;\n bool a_filter2_is_constant;\n \n\n uniform float u_last_filter2_buffer_num;\n uniform float u_last_filter2_constant;\n uniform float u_last_filter2_transform;\n uniform vec2 u_last_filter2_domain;\n uniform vec2 u_last_filter2_range;\n uniform float u_last_filter2_map_position;\n float a_last_filter2;\n bool a_last_filter2_is_constant;\n \n\n uniform float u_x0_buffer_num;\n uniform float u_x0_constant;\n uniform float u_x0_transform;\n uniform vec2 u_x0_domain;\n uniform vec2 u_x0_range;\n uniform float u_x0_map_position;\n float a_x0;\n bool a_x0_is_constant;\n \n\n uniform float u_last_x0_buffer_num;\n uniform float u_last_x0_constant;\n uniform float u_last_x0_transform;\n uniform vec2 u_last_x0_domain;\n uniform vec2 u_last_x0_range;\n uniform float u_last_x0_map_position;\n float a_last_x0;\n bool a_last_x0_is_constant;\n \n\n uniform float u_y0_buffer_num;\n uniform float u_y0_constant;\n uniform float u_y0_transform;\n uniform vec2 u_y0_domain;\n uniform vec2 u_y0_range;\n uniform float u_y0_map_position;\n float a_y0;\n bool a_y0_is_constant;\n \n\n uniform float u_last_y0_buffer_num;\n uniform float u_last_y0_constant;\n uniform float u_last_y0_transform;\n uniform vec2 u_last_y0_domain;\n uniform vec2 u_last_y0_range;\n uniform float u_last_y0_map_position;\n float a_last_y0;\n bool a_last_y0_is_constant;\n \n\n uniform float u_foreground_buffer_num;\n uniform float u_foreground_constant;\n uniform float u_foreground_transform;\n uniform vec2 u_foreground_domain;\n uniform vec2 u_foreground_range;\n uniform float u_foreground_map_position;\n float a_foreground;\n bool a_foreground_is_constant;\n \n\n uniform float u_last_foreground_buffer_num;\n uniform float u_last_foreground_constant;\n uniform float u_last_foreground_transform;\n uniform vec2 u_last_foreground_domain;\n uniform vec2 u_last_foreground_range;\n uniform float u_last_foreground_map_position;\n float a_last_foreground;\n bool a_last_foreground_is_constant;\n \nattribute float buffer_0;\nattribute float buffer_1;\nattribute float buffer_2;\nattribute float buffer_3;\nattribute float buffer_4;\nattribute float buffer_5;\nattribute float buffer_6;\nattribute float buffer_7;\nattribute float buffer_8;\nattribute float buffer_9;\nattribute float buffer_10;\nattribute float buffer_11;\nattribute float buffer_12;\nattribute float buffer_13;\nattribute float buffer_14;\nattribute float buffer_15;\n\n// END AUTOGENERATED. DO NOT EDIT ABOVE. \n// ------------------------------------------------ \n\nhighp float ix_to_random(in float ix, in float seed) {\n // For high numbers, taking the log avoids coincidence.\n highp float seed2 = log(ix + 2.) + 1.;\n vec2 co = vec2(seed2, seed);\n highp float a = 12.9898;\n highp float b = 78.233;\n highp float c = 43758.5453;\n highp float dt = dot(co.xy, vec2(a, b));\n highp float sn = mod(dt, 3.14);\n return fract(sin(sn) * c);\n}\n\n// The fill color.\nvarying vec4 fill;\nvarying float point_size;\n\nuniform float u_jitter_radius_lookup;\nuniform float u_jitter_radius_lookup_y_constant;\nuniform vec2 u_jitter_radius_lookup_x_domain;\nuniform vec2 u_jitter_radius_lookup_y_domain;\n\nfloat point_size_adjust;\n\n// A coordinate to throw away a vertex point.\nvec4 discard_me = vec4(100.0, 100.0, 1.0, 1.0);\n\n// Initialized in the main loop\n// mat3 from_coord_to_gl;\n\nconst float e = 1.618282;\n// I\'ve been convinced.\nconst float tau = 2. * 3.14159265359;\n\nfloat interpolate_raw(in float x, in float min, in float max) {\n if (x < min) {return 0.;}\n if (x > max) {return 1.;}\n return (x - min)/(max - min);\n}\n\nfloat interpolate(in float x, in float min, in float max) {\n if (max < min) {\n return 1. - interpolate_raw(x, max, min);\n } else {\n return interpolate_raw(x, min, max);\n }\n}\n\n/*\n\nThe following glsl code was written in python.\n\nbuffers = [*range(16)]\n\ndef write_buffs(buffs):\n if len(buffs) == 1:\n return[f"return buffer_{buffs[0]}"]\n condition_1 = [" " + line for line in write_buffs(buffs[:len(buffs)//2])]\n condition_2 = ["" + line for line in write_buffs(buffs[len(buffs)//2:])]\n\n args = [\n f"if (i < {buffs[len(buffs) // 2 - 1]}.5) {{",\n *condition_1,\n "}",\n *condition_2\n ]\n return args\n\nprint("\\n".join(write_buffs(buffers)))\n*/\n\nfloat get_buffer(in float i) {\n //given an index, returns the appropriate buffer.\n if (i < 7.5) {\n if (i < 3.5) {\n if (i < 1.5) {\n if (i < 0.5) {\n return buffer_0;\n }\n return buffer_1;\n }\n if (i < 2.5) {\n return buffer_2;\n }\n return buffer_3;\n }\n if (i < 5.5) {\n if (i < 4.5) {\n return buffer_4;\n }\n return buffer_5;\n }\n if (i < 6.5) {\n return buffer_6;\n }\n return buffer_7;\n }\n if (i < 11.5) {\n if (i < 9.5) {\n if (i < 8.5) {\n return buffer_8;\n }\n return buffer_9;\n }\n if (i < 10.5) {\n return buffer_10;\n }\n return buffer_11;\n }\n if (i < 13.5) {\n if (i < 12.5) {\n return buffer_12;\n }\n return buffer_13;\n }\n if (i < 14.5) {\n return buffer_14;\n }\n return buffer_15;\n}\n\nfloat linstep(in vec2 range, in float x) {\n return interpolate(x, range.x, range.y);\n float scale_size = range.y - range.x;\n float from_left = x - range.x;\n return clamp(from_left / scale_size, 0.0, 1.0);\n}\n\nfloat linscale(in vec2 range, in float x) {\n float scale_size = range.y - range.x;\n float from_left = x - range.x;\n return from_left / scale_size;\n}\n\nvec2 box_muller(in float ix, in float seed) {\n // Box-Muller transform gives you two gaussian randoms for two uniforms.\n highp float U = ix_to_random(ix, seed);\n highp float V = ix_to_random(ix, seed + 17.123123);\n return vec2(sqrt(-2. * log(U)) * cos(tau * V),\n sqrt(-2. * log(U)) * sin(tau * V));\n}\n\n/*************** END COLOR SCALES *******************************/\n\nfloat domainify(in vec2 domain, in float transform, in float attr, in float overflow_behavior) {\n\n // Clamp an attribute into a domain, with an optional log or sqrt transform.\n if (transform == 2.) {\n domain = sqrt(domain);\n attr = sqrt(attr);\n }\n if (transform == 3.) {\n domain = log(domain);\n attr = log(attr);\n }\n if (overflow_behavior == 1.) {\n // clamp\n return linstep(domain, attr);\n }\n if (overflow_behavior == 2.) {\n //wrap\n\n return fract(linscale(domain, attr));\n }\n return linscale(domain, attr);\n}\n\nmat3 pixelspace_to_glspace;\n\nfloat run_numeric_filter (in float a_filter,\n in float u_filter_op, in float u_filter_param_1,\n in float u_filter_param_2) {\n bool truthy;\n if (u_filter_op < 1.5) {\n truthy = a_filter < u_filter_param_1;\n } else if (u_filter_op < 2.5) {\n truthy = a_filter > u_filter_param_1;\n } else if (u_filter_op < 3.5) {\n truthy = a_filter == u_filter_param_1;\n } else if (u_filter_op < 4.5) {\n truthy = abs(a_filter - u_filter_param_2) < u_filter_param_1;\n }\n if (truthy) {return 1.;} else {return 0.;}\n}\n\nfloat choose_and_run_filter(\n in vec3 u_filter_numeric,\n in float a_filter,\n in float map_location,\n in bool filter_is_constant\n ) {\n if (filter_is_constant) {\n return 1.;\n }\n if (u_filter_numeric.r < 0.5) {\n // Must be on a dictionary. Unreasonable assumption, maybe?\n float frac_filter = linstep(vec2(-0., 4096.), a_filter);\n float map_coords = (map_location + .5) / 32.;\n return texture2D(u_one_d_aesthetic_map, vec2(map_coords, frac_filter)).a;\n } else {\n return run_numeric_filter(a_filter,\n u_filter_numeric.r, u_filter_numeric.g, u_filter_numeric.b);\n }\n}\n\nconst float tau_0 = 2. * 3.14159265359;\n\nhighp float ix_to_random_1540259130(in float ix, in float seed) {\n // For high numbers, taking the log avoids coincidence.\n highp float seed2 = log(ix) + 1.;\n vec2 co = vec2(seed2, seed);\n highp float a = 12.9898;\n highp float b = 78.233;\n highp float c = 43758.5453;\n highp float dt= dot(co.xy ,vec2(a,b));\n highp float sn= mod(dt,3.14);\n return fract(sin(sn) * c);\n}\n\nhighp vec2 box_muller_1540259130(in float ix, in float seed) {\n // Box-Muller transform gives you two gaussian randoms for two uniforms.\n highp float U = ix_to_random_1540259130(ix, seed);\n highp float V = ix_to_random_1540259130(ix, seed + 17.123123);\n return vec2(\n sqrt(-2.*log(U))*cos(tau_0*V),\n sqrt(-2.*log(U))*sin(tau_0*V)\n );\n}\n\nvec2 logarithmic_spiral_jitter_1540259130(\n in float ix, // a random seed.\n in float a, // offset\n in float angle_parameter_1540259130, // angle parameter\n in float randomize_angle_1540259130, // sd radians\n in float max_r_1540259130, // Maximum radius of spiral.\n in float randomize_rotation_max_radians_1540259130, // in standard deviations to the log-multiplier.\n in float randomize_radius_1540259130, // in standard deviation percentage points.\n in float hole, // donut hole size.\n in float speed_0, // webgl units per second.\n in float time_0,// The time, in seconds, to plot at. Generally passed as a uniform or something.\n in float acceleration,\n in float n_spirals_1540259130,\n in float shear,\n in float aspect_ratio_1540259130\n ) {\n // Each point starts at a different place on the spiral.\n vec2 two_gaussians_1540259130 = box_muller_1540259130(ix, 55.1);\n\n highp float calculated_angle = angle_parameter_1540259130 + two_gaussians_1540259130.x * randomize_angle_1540259130;\n float k = 1. / tan(calculated_angle);\n if (k > 100000.) {\n k = 0.;\n }\n\n // The length of the segment to be traversed.\n float arc_length = sqrt((1. + k*k)/k) * (max_r_1540259130 - a);\n float period = arc_length / speed_0;\n\n // Every point needs to start at a different place along the curve.\n float stagger_time = ix_to_random_1540259130(ix, 3.);\n\n // How long does a circuit take? Add some random noise.\n float time_period = period * exp(box_muller_1540259130(ix, 0.031).x / 6.);\n\n // Adjust u_time from the clock to our current spot.\n float varying_time = time_0 + stagger_time * time_period;\n\n // Adjust that time by raising to a power to set the speed along the curve.\n // Not sure if this is the soundest way to parametrize.\n float relative_time = pow(1. - mod(varying_time, time_period)/time_period, acceleration);\n\n // Calculate the radius at this time point.\n float radius = max_r_1540259130 * relative_time + a;\n\n // The angle implied by that radius.\n float theta = 1./k * log(radius / a);\n\n /* A different way to calculate radius from the theta. Not used\n float max_theta = 1. / k * log(max_r / a);\n float theta2 = max_theta * relative_time;\n vec2 pos_theta_style = vec2(a * exp(k * theta2), theta2);\n radius = pos_theta_style.x;\n theta = pos_theta_style.y;\n */\n\n // If multiple spirals, the theta needs to be rotated for which spiral we\'re in.\n // Choose it based on a new random seed.\n float which_spiral = floor(ix_to_random_1540259130(ix, 13.13) * n_spirals_1540259130);\n float which_spiral_adjust = which_spiral / n_spirals_1540259130 * tau_0;\n theta = theta + which_spiral_adjust;\n\n // Add some gaussian jitter to the polar coordinates.\n vec2 polar_jitter = box_muller_1540259130(ix, 24.);\n\n highp float radius_adjust = 1. + polar_jitter.x * randomize_radius_1540259130;\n highp float theta_adjust = polar_jitter.y * randomize_rotation_max_radians_1540259130;\n\n vec2 shear_adjust = box_muller_1540259130(ix, 59.1) * shear;\n\n mat3 shear_mat = mat3(\n 1., shear_adjust.x, 0.,\n shear_adjust.y, 1., 0.,\n 0., 0., 1.);\n // into euclidean space.\n vec3 pos_spiral = vec3(\n cos(theta + theta_adjust)*(radius * radius_adjust + hole),\n sin(theta + theta_adjust)*(radius * radius_adjust + hole),\n 0.\n );\n mat3 adjust_to_viewport =\n mat3(\n 1./aspect_ratio_1540259130, 0., 0.,\n 0., 1., 0.,\n 0., 0., 1.);\n\n pos_spiral = pos_spiral * shear_mat * \n adjust_to_viewport;\n return pos_spiral.xy;\n}\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1604150559(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\n#ifndef PI\n#define PI 3.141592653589793\n#endif\n\nfloat sineInOut_0(float t) {\n return -0.5 * (cos(PI * t) - 1.0);\n}\n\n#ifndef PI\n#define PI 3.141592653589793\n#endif\n\nvec2 bezier_interpolate(vec2 p1, vec2 p2, float frac, float ix) {\n // Interpolates between two points on a Bezier curve around a jittered middle.\n // Makes animations look cooler.\n vec2 midpoint = box_muller(ix, 3.) * .05 *\n dot(p2 - p1, p2 - p1)\n + p2 / 2. + p1 / 2.;\n\n return mix(\n mix(p2, midpoint, frac),\n mix(midpoint, p1, frac),\n frac);\n}\n\nfloat sineInOut(float t) {\n return -0.5 * (cos(PI * t) - 1.0);\n}\n\nconst vec4 decoder = vec4(1./256./256./256., 1. / 256. / 256., 1. / 256., 1.);\n\nfloat RGBAtoFloat(in vec4 floater) {\n // Scale values up by 256.\n return dot(floater, decoder);\n}\n\nfloat texture_float_lookup(in vec2 domain,\n in vec2 range,\n in float transform,\n in float attr,\n in float texture_position) {\n if (transform == 4.0) {\n // Literal transforms aren\'t looked up, just returned as is.\n return attr;\n }\n float inrange = domainify(domain, transform, attr, 1.);\n if (texture_position > 0.5) {\n float y_pos = texture_position / 32. - 0.5 / 32.;\n vec4 encoded = texture2D(u_one_d_aesthetic_map, vec2(y_pos, inrange));\n return encoded.a;\n return RGBAtoFloat(encoded); // unreachable.\n } else {\n return mix(range.x, range.y, inrange);\n }\n}\n\nvec2 calculate_position(in vec2 position, in float x_scale_type,\n in vec2 x_domain, in vec2 x_range, in float y_scale_type,\n in vec2 y_domain, in vec2 y_range, in mat3 window_scale,\n in mat3 zoom, in float x_map_position,\n in float y_map_position\n ) {\n float x;\n float y;\n\n if (x_scale_type < 4.0) {\n float x_ = linscale(u_color_domain, a_color);\n x = texture_float_lookup(x_domain, x_range,\n x_scale_type,\n position.x, 0. // ymap position 0 means never use a texture lookup.\n );\n } else {\n x = position.x;\n }\n\n if (y_scale_type < 4.0) {\n y = texture_float_lookup(y_domain, y_range, y_scale_type,\n position.y, 0. // ymap position 0 means never use a texture lookup.\n );\n } else {\n y = position.y;\n }\n vec3 pos2d = vec3(x, y, 1.0) * window_scale * zoom * pixelspace_to_glspace;\n return pos2d.xy;\n}\n\nfloat cubicInOut(float t) {\n return t < 0.5\n ? 4.0 * t * t * t\n : 1. - 4.0 * pow(1. - t, 3.0);\n}\n\nvec4 ixToRGBA(in float ix) {\n float min = fract(ix / 256.);\n float mid = fract((ix - min) / 256.);\n float high = fract((ix - min - mid * 256.) / (256.) / 256.);\n return vec4(min, mid, high, 1.);\n}\n\nvec2 circle_jitter(in float ix, in float aspect_ratio, in float time,\n in float radius, in float speed) {\n vec2 two_gaussians = box_muller(ix, 12.);\n\n float stagger_time = two_gaussians.y * tau;\n\n // How long does a circuit take?\n\n float units_per_period = radius * tau;\n float units_per_second = speed;\n float seconds_per_period = units_per_period / units_per_second;\n float time_period = seconds_per_period;\n if (time_period > 1e4) {\n return vec2(0., 0.);\n }\n\n // Adjust time from the clock to our current spot.\n float varying_time = time + stagger_time * time_period;\n // Where are we from 0 to 1 relative to the time period\n\n float relative_time = 1. - mod(varying_time, time_period) / time_period;\n\n float theta = relative_time * tau;\n // Problem--should it lie on a disk, or on a circle?\n float r_mult = 1.;//(sqrt(ix_to_random(ix, 7.)));\n\n return vec2(cos(theta) * r_mult, aspect_ratio * sin(theta) * r_mult) *\n radius;\n}\n\nvec2 calculate_jitter(\n in float jitter_type,\n in float ix, // distinguishing index\n in vec2 jitter_radius_domain,\n in vec2 jitter_radius_range,\n in float jitter_radius_transform,\n in float jitter_radius,\n in float jitter_radius_map_position,\n in bool jitter_radius_is_constant,\n in vec2 jitter_speed_domain,\n in vec2 jitter_speed_range,\n in float jitter_speed_transform,\n in float jitter_speed,\n in float jitter_speed_map_position,\n in bool jitter_speed_is_constant\n) {\n\n // Jitter is calculated based on speed, so requires two full maps in.\n if (jitter_type == 0.) {\n // No jitter\n return vec2(0., 0.);\n }\n\n if (jitter_type == 5.) {\n // Temporal jitter--should be broken out into a separate channel/channels.\n float time_period = 60.;\n float share = 1./4.;\n float offset = ix_to_random(ix, 12.);\n float fractional = fract((offset * time_period + u_time)/time_period);\n if (fractional > share) {\n return vec2(0., 0.);\n }\n float size = 0.5 * (1. - cos(2. * 3.1415926 * min(fractional/share, 1. - fractional/share)));\n size = clamp(size, 0., 1.);\n return vec2(size, 0.);\n }\n float jitter_r; \n if (jitter_radius_is_constant) {\n jitter_r = jitter_radius;\n } else {\n jitter_r = texture_float_lookup(\n jitter_radius_domain,\n jitter_radius_range,\n jitter_radius_transform,\n jitter_radius,\n 0.);\n }\n if (jitter_type == 3.) {\n float r = box_muller(ix, 1.).r * jitter_r;\n r = r * point_size_adjust;\n float theta = ix_to_random(ix, 15.) * tau;\n return vec2(cos(theta) * r, sin(theta) * r * u_width / u_height);\n }\n\n if (jitter_type == 2.) {\n // uniform in the circle.\n float theta = ix_to_random(ix, 15.) * tau;\n float r = jitter_r * sqrt(ix_to_random(ix, 115.));\n r = r * point_size_adjust;\n return vec2(cos(theta) * r, sin(theta) * r * u_width / u_height);\n }\n\n /* Jittering that includes motion) */\n\n float p_jitter_speed =\n texture_float_lookup(jitter_speed_domain,\n jitter_speed_range,\n jitter_speed_transform, jitter_speed,\n jitter_speed_map_position);\n\n if (jitter_type == 1.) {\n return logarithmic_spiral_jitter_1540259130(\n ix,\n 0.005 * jitter_r, // a\n 1.3302036, // angle parameter\n 0.005, // angle random\n jitter_r, // max radius\n 0.03, // random_rotation\n 0.06, // random radius\n 0.003 * point_size_adjust * jitter_r, // donut.\n .5 * p_jitter_speed * jitter_r / point_size_adjust, // speed\n u_time, // time\n 0.8, // acceleration\n 2.0, // n_spirals\n .09, //shear\n u_width/u_height // shear\n );\n }\n\n if (jitter_type == 4.) {\n // circle\n return circle_jitter(ix, u_width/u_height, u_time, jitter_r, p_jitter_speed);\n }\n}\n\nvoid run_color_fill(in float ease) {\n float alpha = min(u_alpha, 1.0);\n if (u_only_color >= -1.5) {\n if (u_only_color > -.5 && a_color != u_only_color) {\n gl_Position = discard_me;\n return;\n } else {\n // -1 is a special value meaning \'plot everything\'.\n fill = vec4(0., 0., 0., 1. / 255.);\n gl_PointSize = 1.;\n }\n } else {\n if (a_color_is_constant) {\n fill = vec4(u_color_constant.rgb, alpha);\n } else {\n float color_pos = (u_color_map_position * -1. - 1.) / 32. + 0.5 / 32.;\n float overflow_behavior = 1.; // means--clamp\n float fractional_color;\n if (u_wrap_colors_after.y > 0.) {\n fractional_color = fract(a_color / u_wrap_colors_after.y);\n } else {\n fractional_color = domainify(u_color_domain, u_color_transform, a_color, overflow_behavior);\n }\n fill = texture2D(u_color_aesthetic_map , vec2(color_pos, fractional_color));\n fill = vec4(fill.rgb, alpha);\n }\n if (ease < 1.) {\n vec4 last_fill;\n if (a_last_color_is_constant) {\n last_fill = vec4(u_last_color_constant.rgb, alpha);\n } else {\n float color_pos = (u_last_color_map_position * -1. - 1.) / 32. + 0.5 / 32.;\n float overflow_behavior = 1.; // means--clamp\n float last_fractional;\n if (u_wrap_colors_after.x > 0.) {\n last_fractional = fract(a_last_color / u_wrap_colors_after.x);\n } else {\n last_fractional = domainify(u_last_color_domain, u_last_color_transform, a_last_color, overflow_behavior);\n }\n last_fill = texture2D(u_color_aesthetic_map , vec2(color_pos, last_fractional));\n last_fill = vec4(last_fill.rgb, alpha);\n // last_fill = vec4(0.8, 0.1, 0.1, 1.0);\n }\n // RGB blending is bad--maybe use https://www.shadertoy.com/view/lsdGzN\n // instead?\n fill = mix(last_fill, fill, ease);\n }\n }\n}\n\nvec2 calc_and_interpolate_positions(\n inout vec2 old_position,\n in float u_last_x_transform,\n in vec2 u_last_x_domain,\n in vec2 u_last_x_range,\n in float u_last_y_transform,\n in vec2 u_last_y_domain,\n in vec2 u_last_y_range,\n in mat3 u_last_window_scale,\n in mat3 u_zoom,\n in float u_last_x_map_position,\n in float u_last_y_map_position,\n inout vec2 position,\n in float u_x_transform,\n in vec2 u_x_domain,\n in vec2 u_x_range,\n in float u_y_transform,\n in vec2 u_y_domain,\n in vec2 u_y_range,\n in mat3 u_window_scale,\n in float u_x_map_position,\n in float u_y_map_position,\n in float interpolation,\n in float u_grid_mode, \n in float ix) {\n\n old_position = calculate_position(old_position, u_last_x_transform,\n u_last_x_domain, u_last_x_range,\n u_last_y_transform, u_last_y_domain, u_last_y_range,\n u_last_window_scale,\n u_zoom, u_last_x_map_position, \n u_last_y_map_position);\n \n bool plot_actual_position = u_grid_mode < .5;\n\n if (plot_actual_position) {\n position = calculate_position(position, \n u_x_transform,\n u_x_domain, u_x_range,\n u_y_transform, u_y_domain, \n u_y_range, u_window_scale, u_zoom, \n u_x_map_position, u_y_map_position);\n float xpos = clamp((1. + position.x) / 2., 0., 1.);\n float randy = ix_to_random(ix, 13.76);\n float delay = xpos + randy * .1;\n delay = delay * 3.;\n\n float frac = interpolate(\n u_update_time,\n delay,\n u_transition_duration + delay\n );\n\n frac = sineInOut_0(frac);\n\n if (frac <= 0.) {\n position = old_position;\n } else if (frac < 1.) {\n frac = fract(frac);\n position = bezier_interpolate(position, old_position, frac, ix);\n }\n } else {\n position.x = -1. + 2. * linscale(u_x_domain, position.x);\n //position.y = -1.0;\n vec2 jitterspec = vec2(\n (ix_to_random(ix, 3.) * a_jitter_radius ) * 2.,\n (ix_to_random(ix, 1.5) * a_jitter_speed ) * 2.\n );\n position = position + jitterspec;\n }\n return position;\n}\n\nvoid main() {\n float debug_mode = 0.;\n float ix = buffer_0;\n float ix_in_tile = buffer_1;\n if (ix > u_maxix) {\n // throw away points that are too low.\n gl_Position = discard_me;\n return;\n }\n\n if (debug_mode > 1.5) {\n // Debug mode.\n gl_PointSize = 2.;\n gl_Position = vec4(box_muller(ix, 2.).xy * .33, 0., 1.);\n return;\n }\n\n // Autogenerated below this point\n\n if (u_x_buffer_num > -0.5) {\n a_x = get_buffer(u_x_buffer_num);\n a_x_is_constant = false;\n } else {\n a_x = u_x_constant;\n a_x_is_constant = true;\n }\n\n if (u_last_x_buffer_num > -0.5) {\n a_last_x = get_buffer(u_last_x_buffer_num);\n a_last_x_is_constant = false;\n } else {\n a_last_x = u_last_x_constant;\n a_last_x_is_constant = true;\n }\n\n if (u_y_buffer_num > -0.5) {\n a_y = get_buffer(u_y_buffer_num);\n a_y_is_constant = false;\n } else {\n a_y = u_y_constant;\n a_y_is_constant = true;\n }\n\n if (u_last_y_buffer_num > -0.5) {\n a_last_y = get_buffer(u_last_y_buffer_num);\n a_last_y_is_constant = false;\n } else {\n a_last_y = u_last_y_constant;\n a_last_y_is_constant = true;\n }\n\n if (u_jitter_radius_buffer_num > -0.5) {\n a_jitter_radius = get_buffer(u_jitter_radius_buffer_num);\n a_jitter_radius_is_constant = false;\n } else {\n a_jitter_radius = u_jitter_radius_constant;\n a_jitter_radius_is_constant = true;\n }\n\n if (u_last_jitter_radius_buffer_num > -0.5) {\n a_last_jitter_radius = get_buffer(u_last_jitter_radius_buffer_num);\n a_last_jitter_radius_is_constant = false;\n } else {\n a_last_jitter_radius = u_last_jitter_radius_constant;\n a_last_jitter_radius_is_constant = true;\n }\n\n if (u_jitter_speed_buffer_num > -0.5) {\n a_jitter_speed = get_buffer(u_jitter_speed_buffer_num);\n a_jitter_speed_is_constant = false;\n } else {\n a_jitter_speed = u_jitter_speed_constant;\n a_jitter_speed_is_constant = true;\n }\n\n if (u_last_jitter_speed_buffer_num > -0.5) {\n a_last_jitter_speed = get_buffer(u_last_jitter_speed_buffer_num);\n a_last_jitter_speed_is_constant = false;\n } else {\n a_last_jitter_speed = u_last_jitter_speed_constant;\n a_last_jitter_speed_is_constant = true;\n }\n\n if (u_size_buffer_num > -0.5) {\n a_size = get_buffer(u_size_buffer_num);\n a_size_is_constant = false;\n } else {\n a_size = u_size_constant;\n a_size_is_constant = true;\n }\n\n if (u_last_size_buffer_num > -0.5) {\n a_last_size = get_buffer(u_last_size_buffer_num);\n a_last_size_is_constant = false;\n } else {\n a_last_size = u_last_size_constant;\n a_last_size_is_constant = true;\n }\n\n if (u_filter_buffer_num > -0.5) {\n a_filter = get_buffer(u_filter_buffer_num);\n a_filter_is_constant = false;\n } else {\n a_filter = u_filter_constant;\n a_filter_is_constant = true;\n }\n\n if (u_last_filter_buffer_num > -0.5) {\n a_last_filter = get_buffer(u_last_filter_buffer_num);\n a_last_filter_is_constant = false;\n } else {\n a_last_filter = u_last_filter_constant;\n a_last_filter_is_constant = true;\n }\n\n if (u_filter2_buffer_num > -0.5) {\n a_filter2 = get_buffer(u_filter2_buffer_num);\n a_filter2_is_constant = false;\n } else {\n a_filter2 = u_filter2_constant;\n a_filter2_is_constant = true;\n }\n\n if (u_last_filter2_buffer_num > -0.5) {\n a_last_filter2 = get_buffer(u_last_filter2_buffer_num);\n a_last_filter2_is_constant = false;\n } else {\n a_last_filter2 = u_last_filter2_constant;\n a_last_filter2_is_constant = true;\n }\n\n if (u_x0_buffer_num > -0.5) {\n a_x0 = get_buffer(u_x0_buffer_num);\n a_x0_is_constant = false;\n } else {\n a_x0 = u_x0_constant;\n a_x0_is_constant = true;\n }\n\n if (u_last_x0_buffer_num > -0.5) {\n a_last_x0 = get_buffer(u_last_x0_buffer_num);\n a_last_x0_is_constant = false;\n } else {\n a_last_x0 = u_last_x0_constant;\n a_last_x0_is_constant = true;\n }\n\n if (u_y0_buffer_num > -0.5) {\n a_y0 = get_buffer(u_y0_buffer_num);\n a_y0_is_constant = false;\n } else {\n a_y0 = u_y0_constant;\n a_y0_is_constant = true;\n }\n\n if (u_last_y0_buffer_num > -0.5) {\n a_last_y0 = get_buffer(u_last_y0_buffer_num);\n a_last_y0_is_constant = false;\n } else {\n a_last_y0 = u_last_y0_constant;\n a_last_y0_is_constant = true;\n }\n\n if (u_foreground_buffer_num > -0.5) {\n a_foreground = get_buffer(u_foreground_buffer_num);\n a_foreground_is_constant = false;\n } else {\n a_foreground = u_foreground_constant;\n a_foreground_is_constant = true;\n }\n\n if (u_last_foreground_buffer_num > -0.5) {\n a_last_foreground = get_buffer(u_last_foreground_buffer_num);\n a_last_foreground_is_constant = false;\n } else {\n a_last_foreground = u_last_foreground_constant;\n a_last_foreground_is_constant = true;\n }\n\n// END AUTOGENERATED. DO NOT EDIT ABOVE. \n// ------------------------------------------------ \n gl_PointSize = 1.;\n\n if (u_color_buffer_num > -0.5) {\n a_color = get_buffer(u_color_buffer_num);\n a_color_is_constant = false;\n } else {\n a_color = ix;\n a_color_is_constant = true;\n }\n\n if (u_last_color_buffer_num > -0.5) {\n a_last_color = get_buffer(u_last_color_buffer_num);\n a_last_color_is_constant = false;\n } else {\n a_last_color = ix;\n a_last_color_is_constant = true;\n }\n\n pixelspace_to_glspace = mat3(\n 2. / u_width, 0., -1.,\n 0., - 2. / u_height, 1.,\n 0., 0., 1.\n );\n\n float interpolation =\n interpolate(u_update_time, 0., u_transition_duration);\n \n float ease = interpolation;\n\n // I set this sometimes.\n\n vec2 position = vec2(a_x, a_y);\n vec2 old_position = vec2(a_last_x, a_last_y);\n\n position = calc_and_interpolate_positions(\n old_position,\n u_last_x_transform,\n u_last_x_domain, u_last_x_range,\n u_last_y_transform,\n u_last_y_domain, u_last_y_range,\n u_last_window_scale,\n u_zoom,\n u_last_x_map_position,\n u_last_y_map_position,\n position,\n u_x_transform,\n u_x_domain, u_x_range,\n u_y_transform,\n u_y_domain, u_y_range,\n u_window_scale,\n u_x_map_position,\n u_y_map_position,\n interpolation,\n u_grid_mode,\n ix\n );\n\n if (u_x0_buffer_num > 0.) {\n vec2 position0 = vec2(a_x0, a_y0);\n vec2 old_position0 = vec2(a_last_x0, a_last_y0);\n\n position0 = calc_and_interpolate_positions(\n old_position0,\n u_last_x0_transform,\n u_last_x0_domain, u_last_x0_range,\n u_last_y0_transform,\n u_last_y0_domain, u_last_y0_range,\n u_last_window_scale,\n u_zoom,\n u_last_x0_map_position,\n u_last_y0_map_position,\n position0,\n u_x0_transform,\n u_x0_domain, u_x0_range,\n u_y0_transform,\n u_y0_domain, u_y0_range,\n u_window_scale,\n u_x0_map_position,\n u_y0_map_position,\n interpolation,\n u_grid_mode,\n ix\n );\n\n if (u_position_interpolation_mode > 0.) {\n float rand2 = ix_to_random(ix, 11.76);\n\n // If it\'s a continuous loop, just choose a random point along that loop.\n float rand_offset = fract(u_update_time/u_transition_duration / 10. + rand2);\n position = mix(position0, position, rand_offset);\n }\n }\n\n bool plot_actual_position = u_grid_mode < .5;\n\n if (u_position_interpolation_mode > 0.) {\n float rand2 = ix_to_random(ix, 11.76);\n\n // If it\'s a continuous loop, just choose a random point along that loop.\n float rand_offset = fract(u_update_time/u_transition_duration + rand2);\n \n }\n\n/* position = vec2(\n ix_to_random(ix, .1),\n ix_to_random(ix, .2)\n );*/\n /* FILTERING */\n\n float filter_status = choose_and_run_filter(\n u_filter_numeric,\n a_filter,\n u_filter_map_position,\n a_filter_is_constant\n );\n\n float last_filter_status = choose_and_run_filter(\n u_last_filter_numeric,\n a_last_filter,\n u_last_filter_map_position,\n a_last_filter_is_constant\n );\n\n float filter2_status = choose_and_run_filter(\n u_filter2_numeric,\n a_filter2,\n u_filter2_map_position,\n a_filter2_is_constant\n );\n\n float last_filter2_status = choose_and_run_filter(\n u_last_filter2_numeric,\n a_last_filter2,\n u_last_filter2_map_position,\n a_last_filter2_is_constant\n );\n\n float foreground_status = choose_and_run_filter(\n u_foreground_numeric,\n a_foreground,\n u_foreground_map_position,\n a_foreground_is_constant\n );\n\n float last_foreground_status = choose_and_run_filter(\n u_last_foreground_numeric,\n a_last_foreground,\n u_last_foreground_map_position,\n a_last_foreground_is_constant\n );\n float fg_ease = mix(last_foreground_status, foreground_status, ease);\n if (ease < ix_to_random(ix, 1.)) {\n foreground_status = last_foreground_status;\n }\n\n /*if (a_foreground_is_constant) {\n foreground_status = 1.;\n }*/\n\n bool was_filtered = last_filter2_status < .5 || last_filter_status < .5;\n bool will_be_filtered = filter2_status < .5 || filter_status < .5;\n\n bool overall_filter_status = will_be_filtered;\n\n if (ease < ix_to_random(ix, 1.)) {\n overall_filter_status = was_filtered;\n }\n\n if (overall_filter_status == true) {\n gl_Position = discard_me;\n return;\n }\n\n float size_multiplier = texture_float_lookup(\n u_size_domain,\n u_size_range,\n u_size_transform, a_size,\n u_size_map_position);\n\n float last_size_multiplier = texture_float_lookup(\n u_last_size_domain, u_last_size_range, u_last_size_transform, a_last_size,\n u_last_size_map_position);\n\n size_multiplier = u_base_size * \n mix(last_size_multiplier, size_multiplier, ease);\n \n float depth_size_adjust = (1.0 - ix / (u_maxix));\n\n point_size_adjust = exp(log(u_k) * u_zoom_balance) ;// * depth_size_adjust;\n// point_size_adjust = exp(log(u_k) * u_zoom_balance);\n gl_PointSize = point_size_adjust * size_multiplier;\n\n if (gl_PointSize <= 5.1) {\n // It\'s ugly on new macs when it jumps straight from one to two for a bunch of points at once.\n float size_fuzz = exp(ix_to_random(ix, 3.1) * .5 - .25);\n gl_PointSize *= size_fuzz;\n }\n\n if (gl_PointSize <= 0.01) {\n gl_Position = discard_me;\n return;\n }\n vec2 jitter = vec2(0., 0.);\n\n if (plot_actual_position && (u_jitter > 0. || u_last_jitter > 0.)) {\n /* JITTER */\n jitter = vec2(ix_to_random(ix, 2. + u_time), ix_to_random(ix, 3. + u_time)) * .01;\n float jitter_radius_fraction;\n jitter = calculate_jitter(\n u_jitter, ix,\n u_jitter_radius_domain, u_jitter_radius_range,\n u_jitter_radius_transform, a_jitter_radius,\n u_jitter_radius_map_position, a_jitter_radius_is_constant,\n u_jitter_speed_domain,\n u_jitter_speed_range,\n u_jitter_speed_transform, a_jitter_speed,\n u_jitter_speed_map_position, a_jitter_speed_is_constant\n );\n vec2 last_jitter;\n if (ease < 1.) {\n last_jitter = calculate_jitter(\n u_last_jitter, ix,\n u_last_jitter_radius_domain, \n u_last_jitter_radius_range,\n u_last_jitter_radius_transform, \n a_last_jitter_radius,\n u_last_jitter_radius_map_position,\n a_last_jitter_radius_is_constant,\n u_last_jitter_speed_domain,\n u_last_jitter_speed_range,\n u_last_jitter_speed_transform,\n a_last_jitter_speed,\n u_last_jitter_speed_map_position,\n a_last_jitter_speed_is_constant\n );\n jitter = mix(last_jitter, jitter, ease);\n }\n if (u_jitter == 5.) {\n // temporal jitter: rescale the point from the first dimension\n gl_PointSize *= jitter.x;\n jitter = vec2(0., 0.);\n if (gl_PointSize < 0.05) {\n gl_Position = discard_me;\n return;\n }\n }\n gl_Position = vec4(position + jitter, 0., 1.);\n } else {\n gl_Position = vec4(position + jitter, 0., 1.);\n } \n if (u_color_picker_mode == 1.) {\n // Add one so the first element is distinguishable.\n fill = encode_float_1604150559(ix + 1.);\n } else if (u_color_picker_mode == 2.) {\n fill = encode_float_1604150559(u_tile_id + 1.);\n } else if (u_color_picker_mode == 3.) {\n fill = encode_float_1604150559(ix_in_tile + 1.);\n } else {\n run_color_fill(ease);\n }\n\n // Are we in a mode where we need to plot foreground and background?\n if (u_foreground_number > -1.) {\n // In that case, throw away points from the other half of the set.\n if (u_foreground_number != foreground_status) {\n gl_Position = discard_me;\n return;\n }\n if (u_foreground_number == 1.) {\n gl_PointSize *= u_foreground_size;\n fill = vec4(fill.rgb, min(1., fill.a * u_foreground_alpha));\n }\n // If we\'re in background mode, got to change the points a bit.\n if (u_foreground_number == 0.) { \n gl_PointSize *= u_background_size;\n // Should the color piker run?\n if (u_color_picker_mode >= 1.) {\n if (u_background_mouseover == 1.) {\n // pass--keep the colors as are.\n } else {\n gl_Position = discard_me;\n return;\n }\n } else {\n float alpha = min(u_alpha * u_background_rgba.a, 1.);\n if (alpha < 1./255.) {\n // Very light alphas must be quantized. Only show an appropriate sample.\n float seed = ix_to_random(ix, 38.6);\n if (alpha * 255. < seed) {\n gl_Position = discard_me;\n return;\n } else {\n alpha = 1. / 255.;\n }\n }\n fill = vec4(u_background_rgba.rgb, alpha);\n }\n }\n }\n \n point_size = gl_PointSize;\n\n/* if (u_use_glyphset > 0. && point_size > 5.0) {\n float random_letter = floor(64. * ix_to_random(ix, 1.3));\n letter_pos = vec2(\n // start at a number between 0 and 7.\n mod(random_letter, 8.) / 8.,\n floor(random_letter / 8.) / 8.\n );\n gl_PointSize *= 3.0;\n }*/\n}\n',count:(t,e)=>e.manager.count,attributes:{},uniforms:{u_update_time:t.prop("update_time"),u_transition_duration:(t,e)=>e.prefs.duration,u_only_color:(t,e)=>void 0!==e.only_color?e.only_color:-2,u_wrap_colors_after:(t,{wrap_colors_after:e})=>{if(void 0===e)throw new Error("wrap_colors_after is undefined");return e},u_use_glyphset:(t,{prefs:e})=>e.glyph_set?1:0,u_glyphset:(t,{prefs:e})=>e.glyph_set?this.get_image_texture(e.glyph_set):this.textures.empty_texture,u_color_picker_mode:t.prop("color_picker_mode"),u_position_interpolation_mode(){return this.aes.position_interpolation?1:0},u_grid_mode:(t,{grid_mode:e})=>e,u_colors_as_grid:t.prop("colors_as_grid"),u_tile_id:(t,e)=>e.tile_id,u_width:({viewportWidth:t})=>t,u_height:({viewportHeight:t})=>t,u_one_d_aesthetic_map:this.aes.aesthetic_map.one_d_texture,u_color_aesthetic_map:this.aes.aesthetic_map.color_texture,u_aspect_ratio:({viewportWidth:t,viewportHeight:e})=>t/e,u_zoom_balance:t.prop("zoom_balance"),u_base_size:(t,{point_size:e})=>e,u_maxix:(t,{max_ix:e})=>e,u_alpha:(t,{alpha:e})=>e,u_foreground_number:(t,{foreground:e})=>e,u_foreground_alpha:()=>this.render_props.foreground_opacity,u_background_rgba:()=>{const t=this.prefs.background_options.color,{r:e,g:n,b:r}=xr(t);return[e/255,n/255,r/255,this.prefs.background_options.opacity[0]]},u_background_mouseover:()=>this.prefs.background_options.mouseover?1:0,u_background_size:()=>this.render_props.background_size,u_foreground_size:()=>this.render_props.foreground_size,u_k:(t,e)=>e.transform.k,u_window_scale:t.prop("webgl_scale"),u_last_window_scale:t.prop("last_webgl_scale"),u_time:({time:t})=>t,u_filter_numeric(){return this.aes.dim("filter").current.ops_to_array()},u_last_filter_numeric(){return this.aes.dim("filter").last.ops_to_array()},u_filter2_numeric(){return this.aes.dim("filter2").current.ops_to_array()},u_last_filter2_numeric(){return this.aes.dim("filter2").last.ops_to_array()},u_foreground_numeric(){return this.aes.dim("foreground").current.ops_to_array()},u_last_foreground_numeric(){return this.aes.dim("foreground").last.ops_to_array()},u_jitter:()=>this.aes.dim("jitter_radius").current.jitter_int_format,u_last_jitter:()=>this.aes.dim("jitter_radius").last.jitter_int_format,u_zoom:(t,e)=>e.zoom_matrix}};for(const n of Nt(0,16))e.attributes[`buffer_${n}`]=(t,{manager:e,buffer_num_to_variable:r})=>e.regl_elements.get(r[n])||{constant:0};for(const n of["x","y","color","jitter_radius","x0","y0","jitter_speed","size","filter","filter2","foreground"])for(const t of["current","last"]){const r="current"===t?"":"last_";e.uniforms[`u_${r}${n}_map_position`]=()=>this.aes.dim(n)[t].map_position,e.uniforms[`u_${r}${n}_buffer_num`]=(e,{aes_to_buffer_num:r})=>{const i=r[`${n}--${t}`];return void 0===i?-1:i},e.uniforms[`u_${r}${n}_domain`]=()=>this.aes.dim(n)[t].webGLDomain,e.uniforms[`u_${r}${n}_range`]=()=>this.aes.dim(n)[t].range,e.uniforms[`u_${r}${n}_transform`]=()=>{const e=this.aes.dim(n)[t].transform;if("linear"===e)return 1;if("sqrt"===e)return 2;if("log"===e)return 3;if("literal"===e)return 4;throw"Invalid transform"},e.uniforms[`u_${r}${n}_constant`]=()=>this.aes.dim(n)[t].constant}return this._renderer=t(e),this._renderer}allocate_aesthetic_buffers(){const t=[],e=["x","y","color","x0","y0","size","jitter_radius","jitter_speed","filter","filter2","foreground"];for(const s of e){const e=["current","last"];for(const n of e)try{this.aes.dim(s)[n].field&&t.push({aesthetic:s,time:n,field:this.aes.dim(s)[n].field})}catch(a){throw this.reglframe=void 0,a}}t.sort(((t,n)=>t.time{e.deferred_functions.push((async()=>{await this.create_regl_buffer(t),n()}))}))}}return{ready:!0,promise:Promise.resolve()}}release(t){let e;(e=this.regl_elements.get(t))&&this.renderer.buffers.free_block(e)}get count(){return this.tile.record_batch.numRows}async create_buffer_data(t){const{tile:e}=this;if(!e.ready)throw new Error("Tile table not present.");let n=e.record_batch.getChild(t);if(!n){if(void 0===e.dataset.transformations[t]){const n=e.record_batch.schema.fields.map((t=>t.name));throw new Error(`Requested ${t} but table only has columns ["${n.join('", "')}]"`)}if(await e.apply_transformation(t),n=e.record_batch.getChild(t),!n)throw new Error(`${t} was not created.`)}if(1!==n.data.length)throw new Error(`Column ${t} has ${n.data.length} buffers, not 1.`);if(!n.type||!n.type.typeId)throw new Error(`Column ${t} has no type.`);if(!n.type||n.type.typeId!==dc.Float32){const t=new Float32Array(e.record_batch.numRows),r=n.data[0];if(n.type.dictionary)for(let n=0;n128&&this.freed_buffers.push({buffer:this.buffers[0],offset:this.pointer,stride:4,byte_size:this.buffer_size-this.pointer}),this.pointer=0,this.buffers.unshift(this.regl.buffer({type:"float",length:this.buffer_size,usage:"dynamic"}))}free_block(t){this.freed_buffers.push(t)}allocate_block(t,e){const n=t*e;let r=0;for(const o of this.freed_buffers){if(o.byte_size===n)return this.freed_buffers.splice(r,1),{buffer:o.buffer,offset:o.offset,stride:e,byte_size:n};r+=1}this.pointer+t*e>this.buffer_size&&this.generate_new_buffer();const i={buffer:this.buffers[0],offset:this.pointer,stride:e,byte_size:t*e};return this.pointer+=t*e,i}}let Tm=0;class km{constructor(t){if(this.max_ix=-1,this._children=[],this.transformation_holder={},this.promise=Promise.resolve(),this.download_state="Unattempted",this.key=String(Math.random()),this.parent=null,this.dataset=t,this.ready=!1,void 0===t)throw new Error("No dataset provided");this.numeric_id=Tm++}get children(){return this._children}download(){throw new Error("Not implemented")}delete_column_if_exists(t){var e;this._batch&&(null==(e=this._buffer_manager)||e.release(t),this._batch=Rm(this.record_batch,t,null))}async get_column(t){void 0===this._batch&&await this.promise;const e=this.record_batch.getChild(t);if(e)return e;if(this.dataset.transformations[t])return await this.apply_transformation(t),this.record_batch.getChild(t);throw new Error(`Column ${t} not found`)}async apply_transformation(t){if(void 0!==this.transformation_holder[t])return this.transformation_holder[t];const e=this.dataset.transformations[t];if(void 0===e)throw new Error(`Transformation ${t} is not defined`);return this.transformation_holder[t]=Promise.resolve(e(this)).then((e=>{if(void 0===e)throw new Error(`Transformation ${t} failed`);this._batch=Rm(this.record_batch,t,e)})),this.transformation_holder[t]}add_column(t,e){return this._batch=Rm(this.record_batch,t,e),this._batch}is_visible(t,e){if(void 0===this.min_ix)return!1;if(this.min_ix>t)return!1;if(void 0===e)return!0;const n=this.extent;return!(n.x[0]>e.x[1]||n.x[1]e.y[1]||n.y[1]t())),this.promise}get _schema(){if(this.__schema)return this.__schema;const t=[];for(const e of this.record_batch.schema.fields){const{name:n,type:r}=e;if(5==(null==r?void 0:r.typeId)&&t.push({name:n,type:"string",extent:[]}),r&&r.dictionary&&t.push({name:n,type:"dictionary",keys:this.record_batch.getChild(n).data[0].dictionary.toArray(),extent:[0,this.record_batch.getChild(n).data[0].dictionary.length]}),r&&8==r.typeId&&t.push({name:n,type:"date",extent:wt(this.record_batch.getChild(n).data[0].values)}),10===(null==r?void 0:r.typeId))return[10,100];r&&3==r.typeId&&t.push({name:n,type:"float",extent:wt(this.record_batch.getChild(n).data[0].values)})}return this.__schema=t,t}*yielder(){for(const t of this.record_batch)t&&(yield t)}get extent(){return this._extent?this._extent:{x:[Number.MIN_VALUE,Number.MAX_VALUE],y:[Number.MIN_VALUE,Number.MAX_VALUE]}}[Symbol.iterator](){return this.yielder()}get root_extent(){return null===this.parent?{x:[Number.MIN_VALUE,Number.MAX_VALUE],y:[Number.MIN_VALUE,Number.MAX_VALUE]}:this.parent.root_extent}}class Mm extends km{constructor(t,e,n,r){super(r),this._children=[],this._already_called=!1,this.child_locations=[],this.url=t,this.parent=n,this.key=e;const[i,o,a]=e.split("/").map((t=>Number.parseInt(t)));this.codes=[i,o,a]}get extent(){return this._extent?this._extent:this.theoretical_extent}async download_to_depth(t){await this.download();let e=[];this.max_ixe.download_to_depth(t)))),await Promise.all(e)}async get_arrow(t=undefined){let e,n,r=`${this.url}/${this.key}.feather`;if(t&&(r=r.replace(".feather",`.${t}.feather`)),void 0!==this.dataset.tileProxy){const t=new URL(r).pathname;e=Am(await this.dataset.tileProxy.apiCall(t,"GET",null,null,{octetStreamAsUint8:!0}))}else{let t={};if("true"===window.localStorage.getItem("isLoggedIn")){r=r.replace("/public","");t={Authorization:`Bearer ${localStorage.getItem("access_token")}`}}const i={method:"GET",...t},o=await fetch(r,i);n=await o.arrayBuffer(),e=Am(n)}e.batches.length>1&&console.warn(`More than one record batch at ${r}; all but first batch will be ignored.`);const i=e.batches[0];return void 0===t&&(this.download_state="Complete",this._batch=e.batches[0]),i}async download(){if(void 0!==this._download)return this._download;if(this._already_called)throw"Illegally attempting to download twice";return this._already_called=!0,this.download_state="In progress",this._download=this.get_arrow().then((t=>{this.ready=!0;const e=t.schema.metadata,n=e.get("extent");n&&(this._extent=JSON.parse(n));const r=e.get("children");r&&(this.child_locations=JSON.parse(r));const i=t.getChild("ix");if(null===i)throw"No ix column in table";this._min_ix=Number(i.get(0)),this.max_ix=Number(i.get(i.length-1)),this._min_ix>this.max_ix&&(this.max_ix=this._min_ix+1e5,this._min_ix=0),this.highest_known_ix=this.max_ix})).catch((t=>{throw this.download_state="Failed",console.error(`Error: Remote Tile at ${this.url}/${this.key}.feather not found.\n `),console.warn(t),t}))}get macrotile(){return jm(this.key)}get macro_siblings(){return function(t,e=2,n=2){return function(t,e=2,n=2){if(Dm.has(t))return Dm.get(t);const r=[[t]];for(;r.lengthe.x[0]&&t[1]e.y[0]}function jm(t,e=2,n=2){let[r,i,o]=t.split("/").map((t=>parseInt(t))),a=0;for(;!(a>=n&&r%e==0);)i=Math.floor(i/2),o=Math.floor(o/2),r-=1,a++;return`${r}/${i}/${o}`}const Dm=new Map;function zm(t){const[e,n,r]=t.split("/").map((t=>parseInt(t))),i=[];for(let o=0;o<4;o++)i.push(`${e+1}/${2*n+o%2}/${2*r+Math.floor(o/2)}`);return i}class Nm{constructor(t){this.transformations={},this.extents={},this._ix_seed=0,this.plot=t}get highest_known_ix(){return this.root_tile.highest_known_ix}register_transformation(t,e,n=[]){this.transformations[t]=async t=>{await Promise.all(n.map((e=>t.get_column(e))));const r=new Float32Array(t.record_batch.numRows);let i=0;for(const n of t.record_batch)r[i]=e(n),i++;return r}}download_to_depth(t){return Promise.resolve()}get table(){return new d_(this.map((t=>t)).filter((t=>t.ready)).map((t=>t.record_batch)))}static from_quadfeather(t,e){const n={};return e.tileProxy&&(n.tileProxy=e.tileProxy),new Fm(t,e,n)}static from_arrow_table(t,e){return new Cm(t,e)}has_column(t){return this.root_tile.record_batch.schema.fields.some((e=>e.name==t))||t in this.transformations}delete_column_if_exists(t){this.map((e=>e.delete_column_if_exists(t))),delete this.transformations[t]}domain(t,e=1e6){var n;if(this.extents[t])return this.extents[t];const r=null==(n=this._schema)?void 0:n.fields.find((e=>e.name===t));if(void 0!==r){let e,n;const i=r.metadata.get("extent");i&&([e,n]=JSON.parse(i));const o=r.metadata.get("min");o&&(e=JSON.parse(o));const a=r.metadata.get("max");if(a&&(n=JSON.parse(a)),10===r.type.typeId&&"string"==typeof e&&(e=Number(new Date(e))),10===r.type.typeId&&"string"==typeof n&&(n=Number(new Date(n))),"string"==typeof n)throw new Error("Failed to parse min-max as numbers");if(void 0!==e)return this.extents[t]=[e,n]}return this.extents[t]=wt([...new Mh(this.map((t=>t)).filter((t=>t.ready)).map((e=>e.record_batch.getChild(t))).filter((t=>null!==t)))])}*points(t,e=1e99){const n=[this.root_tile];let r;for(;r=n.shift();)if("Complete"==r.download_state&&(void 0===t||r.is_visible(e,t))){for(const n of r)Bm([n.x,n.y],t)&&n.ix<=e&&(yield n);n.push(...r.children)}}map(t,e=!1){const n=[];return this.visit((e=>{n.push(t(e))}),e),n}visit(t,e=!1,n=(t=>!0)){const r=[this.root_tile],i=[];let o;for(;o=r.shift();)e?i.push(o):t(o),n(o)&&"Complete"==o.download_state&&r.push(...o.children);if(e)for(;o=i.pop();)t(o)}async visit_full(t,e=!1,n=null,r=(t=>!0),i){let o=0;const a=n||this.root_tile;await a.download();const s=JSON.parse(a.record_batch.schema.metadata.get("total_points"));await async function n(r){await r.download(),e?(await Promise.all(r.children.map(n)),await t(r),o+=r.record_batch.numRows,i(r,o,s)):(await t(r),o+=r.record_batch.numRows,i(r,o,s),await Promise.all(r.children.map(n)))}(a)}async schema(){return await this.ready,this._schema?this._schema:(this._schema=this.root_tile.record_batch.schema,this.root_tile.record_batch.schema)}add_tiled_column(t,e){const n=Am(e),r={};for(const i of n.batches){const t=i.getChild("data").data[0];if(null===t)throw new Error('tiled columns must contain "data" field.');const e=t.valueOffsets,n=t.children[0];for(let o=0;oc.charCodeAt(t)||"")).join("");a.add(t)}const s=o.data[0].valueOffsets,u=o.data[0].values;for(let c=0;ct))}findPointRaw(t){const e=[];return this.visit((n=>{if(!(n.ready&&n.record_batch&&n.min_ix<=t&&n.max_ix>=t))return;const r=n.record_batch.getChild("ix"),i=vt(r.toArray(),t),o=n.record_batch.get(i);null!==o&&o.ix===t&&e.push([n,o,i])})),e}}class Cm extends Nm{constructor(t,e){super(e),this.promise=Promise.resolve(),this.root_tile=new Em(t,this,0)}get extent(){return this.root_tile.extent}get ready(){return Promise.resolve()}download_most_needed_tiles(...t){}}class Fm extends Nm{constructor(t,e,n={}){super(e),this._download_queue=new Set,n.tileProxy&&(this.tileProxy=n.tileProxy),this.root_tile=new Mm(t,"0/0/0",null,this);const r=this.root_tile.download();this.promise=r.then((t=>{const e=this.root_tile.record_batch.schema;if(e.metadata.has("sidecars")){const t=e.metadata.get("sidecars"),n=JSON.parse(t);for(const[e,r]of Object.entries(n))this.transformations[e]=async function(t){const n=await t.get_arrow(r),i=n.getChild(e);if(null===i)throw new Error(`No column named ${e} in sidecar tile ${n.schema.fields.map((t=>t.name)).join(", ")}`);return i}}}))}get ready(){return this.root_tile.download()}get extent(){return this.root_tile.extent}async download_to_depth(t){await this.root_tile.download_to_depth(t)}download_most_needed_tiles(t,e,n=4){const r=this._download_queue;if(r.size>=n)return;const i=[];for(this.visit((function(e){if(void 0===t)return 1/e.codes[0];if("Unattempted"===e.download_state){const n=function(t,e){const n=t.extent;if(n.x[0]>e.x[1]||n.x[1]e.y[1]||n.y[1]i[1]&&(a-=1);o[0]>o[1]&&(a-=2);if(a<0)return a;return Lm(r)/Lm(e)}(e,t);i.push([n,e,t])}})),i.sort(((t,e)=>Number(t[0])-Number(e[0])));i.length>0&&r.sizee||n<=0||(r.add(o.key),o.download().then((()=>r.delete(o.key))).catch((t=>{throw console.warn("Error on",o.key),r.delete(o.key),t})))}}add_macrotiled_column(t,e){const n={},r={};this.transformations[t]=async function(t){await async function(t){const{macrotile:i}=t;return void 0!==n[i]?await n[i]:(n[i]=e(t.macro_siblings).then((t=>{const e=Am(t);for(const n of e.batches){const t=n.getChild("data");for(let e=0;e>r&1;e[8*n+r]=i}}return e}return i}}}function Lm(t){return(t.x[1]-t.x[0])*(t.y[1]-t.y[0])}let Um=4e4;function Rm(t,e,n){const r={};for(const o of t.schema.fields){if(o.name===e){if(null===n)continue;throw new Error(`Name ${o.name} already exists, can't add.`)}const i=t.getChild(o.name).data[0];r[o.name]=i}if(void 0===n)throw new Error("Must pass data to bind_column");if(null!==n)if(n instanceof Float32Array)r[e]=Bh({type:new ul,data:n,length:n.length}).data[0];else if(n instanceof BigInt64Array)r[e]=Bh({type:new nl,data:n,length:n.length}).data[0];else if(n instanceof Uint8Array)r[e]=Bh({type:new rl,data:n,length:n.length}).data[0];else if(n.data.length>0){let t=n.data[0];if(t.dictionary){const e=t;t=Bh({data:e.values,dictionary:e.dictionary,type:new Tl(e.type.dictionary,e.type.indices,Um++)}).data[0]}r[e]=t}else console.warn("Unknown data format object passed to add or remove columns--treating as Data, but this behavior is deprecated",n),r[e]=n;const i=new p_(r);for(const[o,a]of t.schema.metadata)i.schema.metadata.set(o,a);for(const o of t.schema.fields){const t=i.schema.fields.find((t=>t.name===o.name));if(void 0!==t)for(const[e,n]of o.metadata)t.metadata.set(e,n);else if(null!==n)throw new Error("Error!")}if(null!==n){const t=i.schema.fields.find((t=>t.name===e));null==t||t.metadata.set("created by deepscatter",(new Date).toISOString())}return i}var Pm={},Vm={};!function(t,e){t.exports=function(){function t(t,n,i,o,a){e(t,n,i||0,o||t.length-1,a||r)}function e(t,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,u=r-i+1,c=Math.log(s),l=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(t,r,Math.max(i,Math.floor(r-u*l/s+f)),Math.min(o,Math.floor(r+(s-u)*l/s+f)),a)}var h=t[r],d=i,p=o;for(n(t,i,r),a(t[o],h)>0&&n(t,i,o);d0;)p--}0===a(t[i],h)?n(t,i,p):n(t,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function n(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function r(t,e){return te?1:0}return t}()}({get exports(){return Vm},set exports(t){Vm=t}}),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vm,n=[],r=function(t){return n.push(t)},i=function(t){t&&(r(t),u(t)||t.children.forEach(i))},o=function(t){var e=n.pop();return e?(e.children=t,e.height=1,e.leaf=!0,e.minX=1/0,e.minY=1/0,e.minZ=1/0,e.maxX=-1/0,e.maxY=-1/0,e.maxZ=-1/0):e={children:t,height:1,leaf:!0,minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0},e},a=[],s=function(t,e){var n=a.pop();return n?(n.dist=t,n.node=e):n={dist:t,node:e},n},u=function(t){return t.leaf},c=function(t,e){return t.leaf},l=function(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY&&e.maxZ>=t.minZ},t.boxRayIntersects=function(t,e,n,r,i,o,a){var s=(t.minX-e)*i,u=(t.maxX-e)*i,c=(t.minY-n)*o,l=(t.maxY-n)*o,f=(t.minZ-r)*a,h=(t.maxZ-r)*a,d=Math.min(f,h),p=Math.max(f,h),_=Math.min(c,l),m=Math.max(c,l),b=Math.min(s,u),y=Math.max(s,u),g=Math.max(0,b,_,d);return Math.min(y,m,p)>=g?g:1/0};var b=function(t,n,r,i,o){for(var a,s=[n,r];s.length;)(r=s.pop())-(n=s.pop())<=i||(a=n+Math.ceil((r-n)/i/2)*i,e(t,a,n,r,o),s.push(n,a,a,r))},y=function(t,e){return t.minX-e.minX},g=function(t,e){return t.minY-e.minY},v=function(t,e){return t.minZ-e.minZ},w=function(){function e(t){void 0===t&&(t=16),this.maxEntries=Math.max(t,8),this.minEntries=Math.max(4,Math.ceil(.4*this.maxEntries)),this.clear()}return e.alloc=function(){return this.pool.pop()||new this},e.free=function(t){t.clear(),this.pool.push(t)},e.prototype.search=function(e){var n=this.data,r=[];if(!t.intersects(e,n))return r;for(var i=[];n;){for(var o=0,a=n.children.length;o=e)break;var i=r+1;if(i0;){var r=n-1>>1;if(d[r].dist<=d[n].dist)break;p(n,r),n=r}},b=l;d.length&&d[0].dist=e;s--){u=t.children[s];d(o,u),a+=_(o)}return a},e.prototype.adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)d(e[r],t)},e.prototype.condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?((n=t[e-1].children).splice(n.indexOf(t[e]),1),r(t[e])):this.clear():f(t[e])},e.prototype._insert=function(t,e,n){var r=[],i=this.chooseSubtree(t,this.data,e,r);for(i.children.push(t),d(i,t);e>=0&&r[e].children.length>this.maxEntries;)this.split(r,e),e--;this.adjustParentBBoxes(t,r,e)},e.pool=[],e}();t.RBush3D=w}(Pm);const $m=function(){var t,e,n,r,i=Zn,o=Jn,a=Kn,s=Qn,u={},c=Ln("start","drag","end"),l=0,f=0;function h(t){t.on("mousedown.drag",d).filter(s).on("touchstart.drag",m).on("touchmove.drag",b,Vn).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(!r&&i.call(this,a,s)){var u=g(this,o.call(this,a,s),a,s,"mouse");u&&(ht(a.view).on("mousemove.drag",p,$n).on("mouseup.drag",_,$n),Gn(a.view),Yn(a),n=!1,t=a.clientX,e=a.clientY,u("start",a))}}function p(r){if(Wn(r),!n){var i=r.clientX-t,o=r.clientY-e;n=i*i+o*o>f}u.mouse("drag",r)}function _(t){ht(t.view).on("mousemove.drag mouseup.drag",null),qn(t.view,n),Wn(t),u.mouse("end",t)}function m(t,e){if(i.call(this,t,e)){var n,r,a=t.changedTouches,s=o.call(this,t,e),u=a.length;for(n=0;n?@[\\\]^`{|}~]/g,"---"),o=r.querySelectorAll(`#${i}`);if(0===o.length?this.labelgroup=ht(r).select("#labelrects").append("g").attr("id",i).node():this.labelgroup=o[1],void 0===this.canvas)throw new Error("WTF?");this.ctx=this.canvas.getContext("2d"),this.tree=new qm(this.ctx,function(t){const[e,n]=t._zoom.scales().x.range(),[r,i]=t._zoom.scales().x.domain();return(n-e)/(i-r)}(t),.5,[.5,1e6],void 0===n.margin?30:n.margin),this.bind_zoom(t._renderer.zoom)}start(t=1e9){this.timer&&this.timer.stop(),ht(this.labelgroup).attr("display","inline"),this.timer=jn((()=>{this.render(),(t-=1)<=0&&this.stop()}))}delete(){ht(this.labelgroup).remove()}stop(){this.timer&&(this.timer.stop(),ht(this.labelgroup).attr("display","none"),this.ctx.clearRect(0,0,4096,4096),this.timer=void 0)}update(t,e,n){var r;this.label_key=e;for(const i of t.features){const{properties:t,geometry:o}=i;if(null!==t&&"Point"===o.type){const i=null!=(r=t[n])?r:16;let a="";void 0!==t[e]&&null!==t[e]&&(a=t[e]);const s={x:o.coordinates[0]+.1*Math.random(),y:o.coordinates[1]+.1*Math.random(),text:a,height:i,properties:t};this.tree.insert_point(s)}}}render(){const t=this.ctx,{x_:e,y_:n}=this.zoom.scales(),{transform:r}=this.zoom,{width:i,height:o}=this;t.clearRect(0,0,i,o),t.textAlign="center",t.textBaseline="middle",t.globalAlpha=1;const a=this.zoom.current_corners(),s=this.tree.search({minX:a.x[0],minY:a.y[0],minZ:r.k,maxX:a.x[1],maxY:a.y[1],maxZ:r.k});t.clearRect(0,0,4096,4096);const u=this.scatterplot.dim("color"),c=ht(this.labelgroup).selectAll("rect.labelbbox").data(s,(t=>""+t.minZ+t.minX)).join((t=>t.append("rect").attr("class","labellbox").style("opacity",0)));for(const l of s){const r=l.data,i=e(r.x),o=n(r.y);t.globalAlpha=1,t.fillStyle="white";let a=!1;for(const t of[this.scatterplot.dim("filter"),this.scatterplot.dim("filter2")])r.properties[t.field]&&(t.apply(r.properties)||(a=!0));if(a){r.properties.__display="none";continue}if(r.properties.__display="inline",!1===this.options.useColorScale||void 0===this.options.useColorScale)t.shadowColor="#71797E",t.strokeStyle="#71797E";else if(r.properties[u.field]){u.scale.domain().indexOf(r.properties[u.field])>-1?(t.shadowColor=u.scale(r.properties[u.field]),t.strokeStyle=u.scale(r.properties[u.field])):(t.shadowColor="gray",t.strokeStyle="gray")}else t.shadowColor="black";let s=0;this.hovered===""+l.minZ+l.minX&&(s+=2),t.font=`${1*r.height+s}pt verdana`,t.shadowBlur=12+3*s,t.lineWidth=3+s,t.strokeText(r.text,i,o),t.shadowBlur=0,t.lineWidth=4+s,t.fillStyle="white",t.fillText(r.text,i,o)}c.attr("class","labelbbox").attr("x",(t=>e(t.data.x)-t.data.pixel_width*this.tree.pixel_ratio/2)).attr("y",(t=>n(t.data.y)-t.data.pixel_height*this.tree.pixel_ratio/2-5)).attr("width",(t=>t.data.pixel_width*this.tree.pixel_ratio)).attr("stroke","red").attr("height",(t=>t.data.pixel_height*this.tree.pixel_ratio+10)).attr("display",(t=>t.data.properties.__display||"inline")).on("mouseover",((t,e)=>{ht(t.target).style("opacity",0),this.hovered=""+e.minZ+e.minX,t.stopPropagation()})).on("mousemove",(function(t,e){t.stopPropagation()})).on("click",((t,e)=>{this.scatterplot.label_click(e.data,this.scatterplot,this)})).on("mouseout",((t,e)=>{this.hovered=void 0,t.stopPropagation()})),this.options.draggable_labels&&($m.on("drag",((t,r)=>{r.data.x=e.invert(t.x),r.data.y=n.invert(t.y)})),$m.on("end",((t,e)=>{console.log({text:e.data.text,x:e.data.x,y:e.data.y})})),c.call($m)),t.shadowColor="black",t.strokeStyle="black"}}let Wm=null;function Gm(t,e,n){const r=function(){if(null!==Wm)return Wm;const t=document.createElement("canvas");return t.width=500,t.height=400,Wm=t.getContext("2d"),Wm}();if(r.font=`${t.height}pt verdana`,""===t.text)return null;const i=r.measureText(t.text);let{actualBoundingBoxLeft:o,actualBoundingBoxRight:a,actualBoundingBoxAscent:s,actualBoundingBoxDescent:u}=i;return(Number.isNaN(o)||void 0===o)&&(o=0,a=i.width,s=t.height,u=0),{pixel_height:(s-u)/e+n/e,pixel_width:(a-o)/e+n/e}}class qm extends Pm.RBush3D{constructor(t,e,n=.5,r=[.1,1e3],i=10){super(),this._accessor=t=>[t.x,t.y],this.scale_factor=n,this.mindepth=r[0],this.maxdepth=r[1],this.context=t,this.pixel_ratio=e,this.margin=i}max_collision_depth(t,e){const[n,r]=this._accessor(t),[i,o]=this._accessor(e),a=Math.abs(n-i),s=(t.pixel_width+e.pixel_width)/2/a,u=Math.abs(r-o),c=(t.pixel_height+e.pixel_height)/2/u;return Math.min(s,c)}set accessor(t){this._accessor=t}get accessor(){return this._accessor}to3d(t,e=1,n){const[r,i]=this.accessor(t),{pixel_height:o,pixel_width:a}=t,s={minX:r-a/e/2,maxX:r+a/e/2,minY:i-o/e/2,maxY:i+o/e/2,minZ:e,maxZ:n||this.maxdepth,data:t};if(Number.isNaN(r)||Number.isNaN(i))throw"Missing position"+JSON.stringify(t);if(Number.isNaN(a))throw"Missing Aspect Ratio"+JSON.stringify(t);return s}insert_point(t,e=1/4){if(void 0===t.text||""===t.text)return;let n;n=void 0===t.pixel_width?{...t,...Gm(t,this.pixel_ratio,this.margin)}:t;const r=this.to3d(n,e,this.maxdepth);this.collides(r)?this.insert_after_collisions(r):e<=this.mindepth?this.insert(r):this.insert_point(t,e/2)}insert_after_collisions(t){let e,n=-1;for(const r of this.search(t)){const i=this.max_collision_depth(t.data,r.data);i>n&&(n=i,e=r)}if(e&&nXm(t,e)))),i=r.slice(1).reduce(((t,e)=>{switch(n){case"ALL":return t.and(e);case"ANY":case"NONE":return t.or(e)}}),r[0]);return"NONE"===n?i.not():i}var n;throw console.error("UNABLE TO PARSE",e),new Error("UNABLE TO PARSE")}class Zm{constructor(t,e){this.length=t,this.mask=e||new Uint8Array(Math.ceil(t/8))}static from_arrow(t){const e=t.data[0].values;return new Zm(t.length,e)}to_arrow(){return new Mh([rh({type:new hl,data:this.mask,length:this.length})])}set(t){const e=Math.floor(t/8),n=t%8;this.mask[e]|=1<{n=t})),this.composition=null,function(t){return void 0!==t.ids}(e))this.add_identifier_column(e.name,e.ids,e.idField).then(n);else if(function(t){return void 0!==t.field}(e))this.add_boolean_column(e.name,e.field).then(n);else if(function(t){return void 0!==t.tileFunction}(e))this.add_function_column(e.name,e.tileFunction).then(n);else if(function(t){return void 0!==t.composition}(e)){const{name:t,composition:r}=e;this.composition=r,this.add_function_column(t,(async t=>(await Hm(t,r)).to_arrow())).then(n)}}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}dispatch(t,e){this.events[t]&&this.events[t].forEach((t=>t(e)))}applyToAllLoadedTiles(){return Promise.all(this.dataset.map((t=>{if(t.ready)return t.get_column(this.name)}))).then((()=>{}))}applyToAllTiles(){throw new Error("Method not implemented.")}union(t,e){return new Jm(this.plot,{name:e||this.name+" union "+t.name,composition:["OR",this,t]})}intersection(t,e){return new Jm(this.plot,{name:e||this.name+" intersection "+t.name,composition:["AND",this,t]})}moveCursor(t){return this.cursor+=t,this.cursor>=this.selectionSize&&(this.cursor=this.cursor%this.selectionSize),this.cursor<0&&(this.cursor=this.selectionSize+this.cursor),this}async removePoints(t,e){return this.add_or_remove_points(t,e,"remove")}async addPoints(t,e){return this.add_or_remove_points(t,e,"add")}async export(t,e="json"){const n=Object.fromEntries(t.map((t=>[t,[]])));for(let r of this)for(let e of t)n[e].push(r[e]);return n}moveCursorToPoint(t){const e=t.ix;if(void 0===t.ix)throw new Error("Unable to move cursor to point, because it has no `ix` property.");let n,r,i=0,o=0;for(let s of this.match_count){const a=this.tiles[o];if(a.min_ixe){const i=vt([...a.record_batch.getChild("ix").data[0].values],t.ix),o=a.record_batch.get(i);if(null!==o&&o.ix===e){n=a,r=i;break}}o+=1,i+=s}if(void 0===n||void 0===r)return null;const a=n.record_batch.getChild(this.name);for(let s=0;s{i=-1,await this.ready;let o=(await t.get_column(this.name)).toArray();const a=t.record_batch.getChild("ix").data[0].values;for(let s of e){const u=vt([...a],s),c=t.record_batch.get(u);if(null!==c&&c.ix===s)if(o=new Float32Array(o),"add"===n){if(o[u]=1,1===e.length){r=t.key;let e=0;for(let t=0;t0&&(e+=1);i=e}}else o[u]=0}return o}});o.on("tile loaded",(()=>{if(i>=0){o.cursor=i;for(let t=0;t{const n=await t(e),r=e.record_batch;let i=0;for(let t=0;tthis.selectionSize)throw new Error(`Index ${t} out of bounds for selection of size ${this.selectionSize}`);let e,n=0,r=0;for(let s of this.match_count){if(ttb(n,t):tb(n,e)}function tb(t,e){let n;if("Int8Array"===e[Symbol.toStringTag])n=new Qc;else if("Int16Array"===e[Symbol.toStringTag])n=new tl;else{if("Int32Array"!==e[Symbol.toStringTag])throw new Error("values must be an array of signed integers, 32 bit or smaller.");n=new el}return Bh({type:new Tl(t.type,n,Km++,!1),length:e.length,nullCount:0,data:e,dictionary:t})}const eb={zoom_balance:.35,duration:1e3,max_points:1e3,encoding:{},point_size:1,alpha:40,background_options:{color:"gray",opacity:[.2,1],size:[.66,1],mouseover:!1},zoom_align:"center"},nb=[{id:"canvas-2d-background",nodetype:"canvas"},{id:"webgl-canvas",nodetype:"canvas"},{id:"canvas-2d",nodetype:"canvas"},{id:"deepscatter-svg",nodetype:"svg"}];class rb{constructor(t,e,n,r={}){this.secondary_renderers={},this.selection_history=[],this.util={dictionaryFromArrays:Qm,vectorFromArray:a_},this.plot_queue=Promise.resolve(),this.hooks={},this.mark_ready=function(){},this.bound=!1,void 0!==t&&this.bind(t,e,n),this.width=e,this.height=n,this.ready=new Promise(((t,e)=>{this.mark_ready=t})),this.click_handler=new ab(this),this.tooltip_handler=new ub(this),this.label_click_handler=new ob(this),this.handle_highlit_point_change=new sb(this),r.tileProxy&&(this.tileProxy=r.tileProxy),r.dataset&&this.load_dataset(r.dataset),this.prefs={...eb}}bind(t,e,n){if(this.div=ht(t).selectAll("div.deepscatter_container").data([1]).join("div").attr("class","deepscatter_container").style("position","absolute"),this.div.empty())throw console.error(t),"Must pass a valid div selector";this.elements=[];for(const r of nb){const t=this.div.append("div").attr("id",`container-for-${r.id}`).style("position","absolute").style("top",0).style("left",0).style("pointer-events","deepscatter-svg"===r.id?"auto":"none"),i=t.append(r.nodetype).attr("id",r.id).attr("width",e||window.innerWidth).attr("height",n||window.innerHeight);"svg"===r.nodetype&&(i.append("g").attr("id","mousepoints"),i.append("g").attr("id","labelrects")),this.elements.push(t)}this.bound=!0}async select_and_plot(t,e=this.prefs.duration){const n=await this.select_data(t);return await n.ready,await this.plotAPI({duration:e,encoding:{foreground:{field:n.name,op:"eq",a:1}}}),n}async select_data(t){if(t.useNameCache&&t.name&&this.selection_history.length>0){const e=this.selection_history.find((e=>e.name===t.name));if(e)return this.selection_history=[...this.selection_history.filter((e=>e.name!==t.name)),e],e.selection}const e=new Jm(this,t);return this.selection_history.push({selection:e,name:e.name,flushed:!1}),await e.ready,e}add_identifier_column(t,e,n){const r=Array.isArray(e)?Object.fromEntries(e.map((t=>[t,1]))):e;this._root.add_label_identifiers(r,t,n)}async add_labels_from_url(t,e,n,r,i){return await this.ready,await this._root.promise,fetch(t).then((async t=>{const o=await t.json();this.add_labels(o,e,n,r,i)})).catch((t=>{console.warn(t),console.error("Broken addition of ",e)}))}add_labels(t,e,n,r,i={}){const o=new Ym(this,e,i);o.update(t,n,r),this.secondary_renderers[e]=o,this.secondary_renderers[e].start()}get dataset(){if(void 0===this._root)throw new Error("No dataset has been loaded");return this._root}add_api_label(t){const e={type:"FeatureCollection",features:t.labels.map((t=>({type:"Feature",geometry:{type:"Point",coordinates:[t.x,t.y]},properties:{text:t.text,size:t.size||void 0}})))};this.add_labels(e,t.name,"text","size",t.options||{})}async load_dataset(t){if(void 0!==t.source_url)this._root=Nm.from_quadfeather(t.source_url,this);else if(void 0!==t.arrow_table)this._root=Nm.from_arrow_table(t.arrow_table,this);else{if(void 0===t.arrow_buffer)throw new Error("No source_url or arrow_table specified");{const e=Am(t.arrow_buffer);this._root=Nm.from_arrow_table(e,this)}}return await this._root.ready,this._root}async reinitialize(){var t;const{prefs:e}=this;await this._root.ready,this._renderer=new Sm("#container-for-webgl-canvas",this._root,this),this._zoom=new fa("#deepscatter-svg",this.prefs,this),this._zoom.attach_tiles(this._root),this._zoom.attach_renderer("regl",this._renderer),this._zoom.initialize_zoom();const n=ht("#container-for-canvas-2d-background").select("canvas").node().getContext("2d");return n.fillStyle=null!=(t=e.background_color)?t:"rgba(133, 133, 111, .8)",n.fillRect(0,0,2*window.innerWidth,2*window.innerHeight),this._renderer.initialize(),this._root.promise.then((()=>this.mark_ready())),this.ready}visualize_tiles(){const t=this.elements[2].selectAll("canvas").node().getContext("2d");t.clearRect(0,0,1e4,1e4);const{x_:e,y_:n}=this._zoom.scales();t.strokeStyle="#888888";const r=this._root.map((t=>t));for(const i of Nt(20))setTimeout((()=>{for(const o of r){if(!o.codes||o.codes[0]!=i)continue;if(!o.extent)continue;const[r,a]=o.extent.x.map((t=>e(t))),[s,u]=o.extent.y.map((t=>n(t))),c=o.codes[0];t.lineWidth=8/Math.sqrt(c),t.globalAlpha=.33,t.strokeRect(r,s,a-r,u-s),"Unattempted"!==o.download_state&&t.fillRect(r,s,a-r,u-s),t.globalAlpha=1}}),400*i);setTimeout((()=>t.clearRect(0,0,1e4,1e4)),6800)}destroy(){var t,e,n;null==(e=null==(t=this._renderer)?void 0:t.regl)||e.destroy(),null==(n=this.div)||n.node().parentElement.replaceChildren()}update_prefs(t){if(this.prefs.encoding&&t.encoding)for(const e of Object.keys(this.prefs.encoding))void 0!==t.encoding[e]&&(this.prefs.encoding[e]=t.encoding[e]);bn(this.prefs,t)}add_hook(t,e,n=!1){if(void 0!==this.hooks[t]&&!n)throw new Error(`Hook ${t} already exists`);this.hooks[t]=e}remove_hook(t,e=!1){if(void 0===this.hooks[t]){if(e)return;throw new Error(`Hook ${t} does not exist`)}delete this.hooks[t]}stop_labellers(){console.log("Stopping labels");for(const[t,e]of Object.entries(this.secondary_renderers))e&&void 0!==e.label_key&&(this.secondary_renderers[t].stop(),this.secondary_renderers[t].delete(),this.secondary_renderers[t]=void 0)}dim(t){return this._renderer.aes.dim(t).current}set tooltip_html(t){this.tooltip_handler.f=t}get tooltip_html(){return this.tooltip_handler.f}set label_click(t){this.label_click_handler.f=t}get label_click(){return this.label_click_handler.f.bind(this.label_click_handler)}set highlit_point_change(t){this.handle_highlit_point_change.f=t}get highlit_point_change(){return this.handle_highlit_point_change.f.bind(this.handle_highlit_point_change)}set click_function(t){this.click_handler.f=t}get click_function(){return this.click_handler.f}async plotAPI(t){if(void 0!==t){await this.plot_queue,t&&await this.start_transformations(t),this.plot_queue=this.unsafe_plotAPI(t),await this.plot_queue;for(const[t,e]of Object.entries(this.hooks))e()}}async start_transformations(t,e=110){return new Promise((n=>{this.prefs.duration{const r=Date.now()-t;r{n()}),e-r):n()}))}}else n()}))}async unsafe_plotAPI(t){var e;if(null===t)return;if(t.click_function&&(this.click_function=Function("datum",t.click_function)),t.tooltip_html&&(this.tooltip_html=Function("datum",t.tooltip_html)),t.background_options&&(t.background_options.opacity&&"number"==typeof t.background_options.opacity&&(t.background_options.opacity=[t.background_options.opacity,1]),t.background_options.size&&"number"==typeof t.background_options.size&&(t.background_options.size=[t.background_options.size,1])),this.update_prefs(t),void 0===this._root){const{source_url:e,arrow_table:n,arrow_buffer:r}=t,i={source_url:e,arrow_table:n,arrow_buffer:r};if(1!==Object.values(i).filter((t=>void 0!==t)).length)throw new Error("The initial API call specify exactly one of source_url, arrow_table, or arrow_buffer");await this.load_dataset(i)}if(t.transformations)for(const[o,a]of Object.entries(t.transformations)){const t=Function("datum",a);this.dataset.transformations[o]?console.log("Already",o,a):this.dataset.register_transformation(o,t)}void 0===this._zoom&&await this.reinitialize(),t.basemap_gleofeather&&(t.polygons=[{file:t.basemap_gleofeather}]),this._renderer.render_props.apply_prefs(this.prefs);const{width:n,height:r}=this;if(this.update_prefs(t),void 0!==t.zoom&&(null===t.zoom?(this._zoom.zoom_to(1,n/2,r/2),t.zoom=void 0):(null==(e=t.zoom)?void 0:e.bbox)&&this._zoom.zoom_to_bbox(t.zoom.bbox,t.duration)),this._renderer.most_recent_restart=Date.now(),this._renderer.aes.apply_encoding(t.encoding),this._renderer.apply_webgl_scale&&this._renderer.apply_webgl_scale(t),this._renderer.reglframe&&(this._renderer.reglframe.cancel(),this._renderer.reglframe=void 0),this._renderer.reglframe=this._renderer.regl.frame((()=>{this._renderer.tick("Basic")})),void 0!==t.labels)if(null!==(i=t.labels)&&void 0!==i.url){const{url:e,label_field:n,size_field:r}=t.labels,i=t.labels.name||e;this.secondary_renderers[i]||(this.stop_labellers(),this.add_labels_from_url(e,i,n,r).catch((t=>{console.error("Label addition failed."),console.error(t)})))}else if(function(t){return null!==t&&void 0!==t.labels}(t.labels)){if(!t.labels.name)throw new Error("API field `labels` must have a name.");this.stop_labellers(),this.add_api_label(t.labels)}else{if(null!==t.labels)throw new Error("API field `labels` format not recognized.");this.stop_labellers()}var i;this._zoom.restart_timer(6e4)}get root_batch(){if(!this._root)throw new Error("No dataset has been loaded");return this.dataset.root_tile.record_batch}get query(){const t=JSON.parse(JSON.stringify(this.prefs));return t.zoom={bbox:this._renderer.zoom.current_corners()},t}drawContours(t,e){const n=(e||ht("body")).select("#canvas-2d").node().getContext("2d");for(const r of t){n.fillStyle="rgba(25, 25, 29, 1)",n.fillRect(0,0,2*window.innerWidth,2*window.innerHeight),n.strokeStyle="#8a0303",n.fillStyle="rgba(30, 30, 34, 1)",n.lineWidth=jt([.45,.25*Math.exp(Math.log(this._zoom.transform.k/2))]);const t=fn(_n().scale(this._zoom.transform.k).translate([this._zoom.transform.x,this._zoom.transform.y]),n);n.beginPath(),t(r),n.fill()}}sample_points(t=10){const e=[];for(const n of this._root.points(this._zoom.current_corners()))if(e.push({...n}),e.length>=3*t)break;return e.sort(((t,e)=>Number(t.ix)-Number(e.ix))),e.slice(0,t)}contours(t){const e=this._renderer.calculate_contours(t),{x:n,y:r,x_:i,y_:o}=this._zoom.scales();!function t(e){if(e){if(e.coordinates)return t(e.coordinates);if(0!==e.length){if(e[0].length>0)return e.map(t);e[0]=n(i.invert(e[0])),e[1]=r(o.invert(e[1]))}}}(e),this.drawContours(e)}}rb.Bitmask=Zm,rb.ArrowDataset=Cm,rb.QuadtileDataset=Fm,rb.DataSelection=Jm;class ib{constructor(t){this.string_rep="",this.plot=t}get f(){return void 0===this._f?(t,e)=>this.default(t,e):this._f}set f(t){"string"==typeof t?this.string_rep!==t&&(this.string_rep=t,this._f=Function("datum","plot",t)):this._f=t}}class ob extends ib{default(t,e=undefined,n=undefined){let r;null!==t&&(1==t.__activated?(r=null,t.__activated=void 0):(t.__activated=!0,r={field:n.label_key,lambda:`d => d === '${t.properties[n.label_key]}'`}),this.plot.plotAPI({encoding:{filter:r}}))}}class ab extends ib{default(t,e=undefined){console.log({...t})}}class sb extends ib{default(t,e=undefined){}}class ub extends ib{default(t,e=undefined){let n="
";const r=new Set(["x","y","ix",null,"tile_key"]);for(const[i,o]of t)null!==o&&(r.has(i)||""!==o&&(n+=`
${String(i)}
\n`,n+=`
${String(o)}
\n`));return`${n}
\n`}}return rb}));