diff --git a/dist/deepscatter.umd.js b/dist/deepscatter.umd.js new file mode 100644 index 000000000..1b4c5328d --- /dev/null +++ b/dist/deepscatter.umd.js @@ -0,0 +1,15 @@ +!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",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(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function c(){return[]}function f(t){return null==t?c:function(){return this.querySelectorAll(t)}}function l(t){return function(){return this.matches(t)}}function d(t){return function(e){return e.matches(t)}}var h=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){return function(){return t}}function v(t,e,n,r,i,o){for(var a,s=0,u=e.length,c=o.length;se?1:t>=e?0:NaN}function I(t){return function(){this.removeAttribute(t)}}function k(t){return function(){this.removeAttributeNS(t.space,t.local)}}function T(t,e){return function(){this.setAttribute(t,e)}}function E(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function O(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 M(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function D(t){return function(){this.style.removeProperty(t)}}function j(t,e,n){return function(){this.style.setProperty(t,e,n)}}function z(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function F(t,e){return t.style.getPropertyValue(e)||M(t).getComputedStyle(t,null).getPropertyValue(e)}function N(t){return function(){delete this[t]}}function L(t,e){return function(){this[t]=e}}function C(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function R(t){return t.trim().split(/^|\s+/)}function P(t){return t.classList||new U(t)}function U(t){this._node=t,this._names=R(t.getAttribute("class")||"")}function V(t,e){for(var n=P(t),r=-1,i=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function at(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=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 lt=[null];function dt(t,e){this._groups=t,this._parents=e}function ht(){return new dt([[document.documentElement]],lt)}function pt(t){return"string"==typeof t?new dt([[document.querySelector(t)]],[document.documentElement]):new dt([[t]],lt)}dt.prototype=ht.prototype={constructor:dt,select:function(t){"function"!=typeof t&&(t=s(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=k&&(k=I+1);!(S=m[k])&&++k=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=S);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?D:"function"==typeof e?z:j)(t,e,null==n?"":n)):F(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?N:"function"==typeof e?C:L)(t,e)):this.node()[t]},classed:function(t,e){var n=R(t+"");if(arguments.length<2){for(var r=P(this.node()),i=-1,o=n.length;++i0){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}}var mt=1e-6,bt=Math.PI,yt=2*bt,gt=180/bt,vt=bt/180,wt=Math.abs,xt=Math.cos,At=Math.sin,St=Math.sqrt;function It(){}function kt(t,e){t&&Et.hasOwnProperty(t.type)&&Et[t.type](t,e)}var Tt={Feature:function(t,e){kt(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r=0;--o)i.point((f=c[o])[0],f[1]);else r(d.x,d.p.x,-1,i);d=d.p}c=(d=d.o).z,h=!h}while(!d.v);i.lineEnd()}}}function zt(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r0)do{c.point(0===f||3===f?t:n,f>1?r:e)}while((f=(f+s+4)%4)!==l);else c.point(o[0],o[1])}function a(r,i){return wt(r[0]-t)0?0:3:wt(r[0]-n)0?2:1:wt(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,f,l,d,h,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:It,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(f=[]);b=!0,m=!1,p=_=NaN},lineEnd:function(){u&&(I(l,d),h&&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&&(d-o)*(r-a)>(h-a)*(t-o)&&++e:h<=r&&(d-o)*(r-a)<(h-a)*(t-o)&&--e;return e}(),n=y&&e,i=(l=u,u=Array.from(function*(t){for(const e of t)yield*e}(l))).length;var l;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&jt(u,s,e,o,a),a.polygonEnd());w=a,u=c=f=null}};function S(t,e){i(t,e)&&w.point(t,e)}function I(o,a){var s=i(o,a);if(c&&f.push([o,a]),b)l=o,d=a,h=s,b=!1,s&&(w.lineStart(),w.point(o,a));else if(s&&m)w.point(o,a);else{var u=[p=Math.max(Nt,Math.min(Ft,p)),_=Math.max(Nt,Math.min(Ft,_))],g=[o=Math.max(Nt,Math.min(Ft,o)),a=Math.max(Nt,Math.min(Ft,a))];!function(t,e,n,r,i,o){var a,s=t[0],u=t[1],c=0,f=1,l=e[0]-s,d=e[1]-u;if(a=n-s,l||!(a>0)){if(a/=l,l<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=i-s,l||!(a<0)){if(a/=l,l<0){if(a>f)return;a>c&&(c=a)}else if(l>0){if(a0)){if(a/=d,d<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=o-u,d||!(a<0)){if(a/=d,d<0){if(a>f)return;a>c&&(c=a)}else if(d>0){if(a0&&(t[0]=s+c*l,t[1]=u+c*d),f<1&&(e[0]=s+f*l,e[1]=u+f*d),!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}}var Ct,Rt,Pt,Ut,Vt=t=>t,$t=new _t,Gt=new _t,Ht={point:It,lineStart:It,lineEnd:It,polygonStart:function(){Ht.lineStart=Yt,Ht.lineEnd=Xt},polygonEnd:function(){Ht.lineStart=Ht.lineEnd=Ht.point=It,$t.add(wt(Gt)),Gt=new _t},result:function(){var t=$t/2;return $t=new _t,t}};function Yt(){Ht.point=Wt}function Wt(t,e){Ht.point=qt,Ct=Pt=t,Rt=Ut=e}function qt(t,e){Gt.add(Ut*t-Pt*e),Pt=t,Ut=e}function Xt(){qt(Ct,Rt)}var Zt=1/0,Jt=Zt,Kt=-Zt,Qt=Kt,te={point:function(t,e){tKt&&(Kt=t);eQt&&(Qt=e)},lineStart:It,lineEnd:It,polygonStart:It,polygonEnd:It,result:function(){var t=[[Zt,Jt],[Kt,Qt]];return Kt=Qt=-(Jt=Zt=1/0),t}};var ee,ne,re,ie,oe=0,ae=0,se=0,ue=0,ce=0,fe=0,le=0,de=0,he=0,pe={point:_e,lineStart:me,lineEnd:ge,polygonStart:function(){pe.lineStart=ve,pe.lineEnd=we},polygonEnd:function(){pe.point=_e,pe.lineStart=me,pe.lineEnd=ge},result:function(){var t=he?[le/he,de/he]:fe?[ue/fe,ce/fe]:se?[oe/se,ae/se]:[NaN,NaN];return oe=ae=se=ue=ce=fe=le=de=he=0,t}};function _e(t,e){oe+=t,ae+=e,++se}function me(){pe.point=be}function be(t,e){pe.point=ye,_e(re=t,ie=e)}function ye(t,e){var n=t-re,r=e-ie,i=St(n*n+r*r);ue+=i*(re+t)/2,ce+=i*(ie+e)/2,fe+=i,_e(re=t,ie=e)}function ge(){pe.point=_e}function ve(){pe.point=xe}function we(){Ae(ee,ne)}function xe(t,e){pe.point=Ae,_e(ee=re=t,ne=ie=e)}function Ae(t,e){var n=t-re,r=e-ie,i=St(n*n+r*r);ue+=i*(re+t)/2,ce+=i*(ie+e)/2,fe+=i,le+=(i=ie*t-re*e)*(re+t),de+=i*(ie+e),he+=3*i,_e(re=t,ie=e)}function Se(t){this._context=t}Se.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,yt)}},result:It};var Ie,ke,Te,Ee,Be,Oe=new _t,Me={point:It,lineStart:function(){Me.point=De},lineEnd:function(){Ie&&je(ke,Te),Me.point=It},polygonStart:function(){Ie=!0},polygonEnd:function(){Ie=null},result:function(){var t=+Oe;return Oe=new _t,t}};function De(t,e){Me.point=je,ke=Ee=t,Te=Be=e}function je(t,e){Ee-=t,Be-=e,Oe.add(St(Ee*Ee+Be*Be)),Ee=t,Be=e}function ze(){this._string=[]}function Fe(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Ne(t,e){var n,r,i=4.5;function o(t){return t&&("function"==typeof i&&r.pointRadius(+i.apply(this,arguments)),Mt(t,n(r))),r.result()}return o.area=function(t){return Mt(t,n(Ht)),Ht.result()},o.measure=function(t){return Mt(t,n(Me)),Me.result()},o.bounds=function(t){return Mt(t,n(te)),te.result()},o.centroid=function(t){return Mt(t,n(pe)),pe.result()},o.projection=function(e){return arguments.length?(n=null==e?(t=null,Vt):(t=e).stream,o):t},o.context=function(t){return arguments.length?(r=null==t?(e=null,new ze):new Se(e=t),"function"!=typeof i&&r.pointRadius(i),o):e},o.pointRadius=function(t){return arguments.length?(i="function"==typeof t?t:(r.pointRadius(+t),+t),o):i},o.projection(t).context(e)}function Le(){}function Ce(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Mt(n,t.stream(te)),e(te.result()),null!=r&&t.clipExtent(r),t}function Re(t,e,n){return Ce(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 Pe(){var t,e,n,r,i,o,a,s,u=1,c=0,f=0,l=1,d=1,h=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 Le;for(var n in s)e[n]=s[n];return e.stream=t,e}),y=Vt;function g(){return _=u*l,m=u*d,o=a=null,v}function v(n){var r=n[0]*_,i=n[1]*m;if(h){var o=i*t-r*e;r=r*t+i*e,i=o}return[r+c,i+f]}return v.invert=function(n){var r=n[0]-c,i=n[1]-f;if(h){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,Vt):Lt(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],f=+t[1],g()):[c,f]},v.angle=function(n){return arguments.length?(e=At(h=n%360*vt),t=xt(h),g()):h*gt},v.reflectX=function(t){return arguments.length?(l=t?-1:1,g()):l<0},v.reflectY=function(t){return arguments.length?(d=t?-1:1,g()):d<0},v.fitExtent=function(t,e){return Re(v,t,e)},v.fitSize=function(t,e){return function(t,e,n){return Re(t,[[0,0],e],n)}(v,t,e)},v.fitWidth=function(t,e){return function(t,e,n){return Ce(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 Ce(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}function Ue(t,e){return null==t||null==e?NaN:te?1:t>=e?0:NaN}function Ve(t){let e=t,n=t;function r(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r>>1;n(t[o],e)<0?r=o+1:i=o}return r}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>Ue(t(e),n)}(t)),{left:r,center:function(t,n,i,o){null==i&&(i=0),null==o&&(o=t.length);const a=r(t,n,i,o-1);return a>i&&e(t[a-1],n)>-e(t[a],n)?a-1:a},right:function(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r>>1;n(t[o],e)>0?i=o:r=o+1}return r}}}ze.prototype={_radius:4.5,_circle:Fe(4.5),pointRadius:function(t){return(t=+t)!==this._radius&&(this._radius=t,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(t,e){switch(this._point){case 0:this._string.push("M",t,",",e),this._point=1;break;case 1:this._string.push("L",t,",",e);break;default:null==this._circle&&(this._circle=Fe(this._radius)),this._string.push("M",t,",",e,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Le.prototype={constructor:Le,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()}};const $e=Ve(Ue).left;function Ge(t,e){let n,r;if(void 0===e)for(const i of t)null!=i&&(void 0===n?i>=i&&(n=r=i):(n>i&&(n=i),r=o&&(n=r=o):(n>o&&(n=o),r=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 Ye(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 We(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 qe(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=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 tn(t){return this instanceof tn?(this.v=t,this):new tn(t)}function en(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 tn?Promise.resolve(n.value.v).then(u,c):f(o[0][2],n)}catch(r){f(o[0][3],r)}var n}function u(t){s("next",t)}function c(t){s("throw",t)}function f(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function nn(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:tn(t[r](e)),done:"return"===r}:i?i(e):e}:i}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Qe(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)}))}}}var on={};function an(t,e,n){return e<=t&&t<=n}function sn(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}on.SIZEOF_SHORT=2,on.SIZEOF_INT=4,on.FILE_IDENTIFIER_LENGTH=4,on.SIZE_PREFIX_LENGTH=4,on.Encoding={UTF8_BYTES:1,UTF16_STRING:2},on.int32=new Int32Array(2),on.float32=new Float32Array(on.int32.buffer),on.float64=new Float64Array(on.int32.buffer),on.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],on.Long=function(t,e){this.low=0|t,this.high=0|e},on.Long.create=function(t,e){return 0==t&&0==e?on.Long.ZERO:new on.Long(t,e)},on.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},on.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},on.Long.ZERO=new on.Long(0,0),on.Builder=function(t){if(t)e=t;else var e=1024;this.bb=on.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},on.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},on.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},on.Builder.prototype.dataBuffer=function(){return this.bb},on.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},on.Builder.prototype.prep=function(t,e){t>this.minalign&&(this.minalign=t);for(var n=1+~(this.bb.capacity()-this.space+e)&t-1;this.space=0&&0==this.vtable[e];e--);for(var n=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=(n+2)*on.SIZEOF_SHORT;this.addInt16(r);var i=0,o=this.space;t:for(e=0;e=0;o--)this.writeInt8(i.charCodeAt(o))}this.prep(this.minalign,on.SIZEOF_INT+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},on.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},on.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,r=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(r+e)))throw new Error("FlatBuffers: field "+e+" must be set")},on.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(on.SIZEOF_INT,t*e),this.prep(n,t*e)},on.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},on.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n=56320)r=i;else r=(i<<10)+t.charCodeAt(n++)+-56613888;r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,a=this.bb.bytes();n>24},on.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},on.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},on.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},on.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},on.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},on.ByteBuffer.prototype.readInt64=function(t){return new on.Long(this.readInt32(t),this.readInt32(t+4))},on.ByteBuffer.prototype.readUint64=function(t){return new on.Long(this.readUint32(t),this.readUint32(t+4))},on.ByteBuffer.prototype.readFloat32=function(t){return on.int32[0]=this.readInt32(t),on.float32[0]},on.ByteBuffer.prototype.readFloat64=function(t){return on.int32[on.isLittleEndian?0:1]=this.readInt32(t),on.int32[on.isLittleEndian?1:0]=this.readInt32(t+4),on.float64[0]},on.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},on.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},on.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},on.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},on.ByteBuffer.prototype.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},on.ByteBuffer.prototype.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},on.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},on.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},on.ByteBuffer.prototype.writeFloat32=function(t,e){on.float32[0]=e,this.writeInt32(t,on.int32[0])},on.ByteBuffer.prototype.writeFloat64=function(t,e){on.float64[0]=e,this.writeInt32(t,on.int32[on.isLittleEndian?0:1]),this.writeInt32(t+4,on.int32[on.isLittleEndian?1:0])},on.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&o)))}return r},on.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},on.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+on.SIZEOF_INT},on.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},on.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=on.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+on.FILE_IDENTIFIER_LENGTH);for(var e=0;e>6*n)+r];n>0;){var o=e>>6*(n-1);i.push(128|63&o),n-=1}return i}}dn.prototype={decode:function(t,e){var n;n="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=sn(e),this._streaming||(this._decoder=new pn({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var r,i=new un(n),o=[];!i.endOfStream()&&(r=this._decoder.handler(i,i.read()))!==cn;)null!==r&&(Array.isArray(r)?o.push.apply(o,r):o.push(r));if(!this._streaming){do{if((r=this._decoder.handler(i,i.read()))===cn)break;null!==r&&(Array.isArray(r)?o.push.apply(o,r):o.push(r))}while(!i.endOfStream());this._decoder=null}return o.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===o[0]?(this._BOMseen=!0,o.shift()):this._BOMseen=!0)),function(t){for(var e="",n=0;n>10),56320+(1023&r)))}return e}(o)}},hn.prototype={encode:function(t,e){t=t?String(t):"",e=sn(e),this._streaming||(this._encoder=new _n(this._options)),this._streaming=Boolean(e.stream);for(var n,r=[],i=new un(function(t){for(var e=String(t),n=e.length,r=0,i=[];r57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(r===n-1)i.push(65533);else{var a=t.charCodeAt(r+1);if(56320<=a&&a<=57343){var s=1023&o,u=1023&a;i.push(65536+(s<<10)+u),r+=1}else i.push(65533)}r+=1}return i}(t));!i.endOfStream()&&(n=this._encoder.handler(i,i.read()))!==cn;)Array.isArray(n)?r.push.apply(r,n):r.push(n);if(!this._streaming){for(;(n=this._encoder.handler(i,i.read()))!==cn;)Array.isArray(n)?r.push.apply(r,n):r.push(n);this._encoder=null}return new Uint8Array(r)}};const mn=new("undefined"!=typeof TextDecoder?TextDecoder:dn)("utf-8"),bn=t=>mn.decode(t),yn=new("undefined"!=typeof TextEncoder?TextEncoder:hn),gn=t=>yn.encode(t),vn=Object.freeze({done:!0,value:void 0});class wn{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class xn{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class An extends xn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return Ke(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(vn);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Zn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Zn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Ke(this,void 0,void 0,(function*(){return yield this.abort(t),vn}))}return(t){return Ke(this,void 0,void 0,(function*(){return yield this.close(),vn}))}read(t){return Ke(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return Ke(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(vn)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error(`${this} is closed`)}}const[Sn,In]=(()=>{const t=()=>{throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=()=>{throw t()},e.asUintN=()=>{throw t()},"undefined"!=typeof BigInt?[BigInt,!0]:[e,!1]})(),kn=t=>"boolean"==typeof t,Tn=t=>"function"==typeof t,En=t=>null!=t&&Object(t)===t,Bn=t=>En(t)&&Tn(t.then),On=t=>En(t)&&Tn(t[Symbol.iterator]),Mn=t=>En(t)&&Tn(t[Symbol.asyncIterator]),Dn=t=>En(t)&&En(t.schema),jn=t=>En(t)&&"done"in t&&"value"in t,zn=t=>En(t)&&Tn(t.stat)&&(t=>"number"==typeof t)(t.fd),Fn=t=>En(t)&&Nn(t.body),Nn=t=>En(t)&&Tn(t.cancel)&&Tn(t.getReader)&&!(t instanceof xn),Ln=t=>En(t)&&Tn(t.read)&&Tn(t.pipe)&&kn(t.readable)&&!(t instanceof xn);var Cn=on.ByteBuffer;const Rn="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Pn(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 Un(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,f=t.length;++ut+e.byteLength),0);let i,o,a,s=0,u=-1;const c=Math.min(e||1/0,r);for(let f=n.length;++uVn(Int32Array,t),Gn=t=>Vn(Uint8Array,t),Hn=t=>(t.next(),t);const Yn=t=>function*(t,e){const n=function*(t){yield t},r="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Rn?n(e):On(e)?e:n(e);return yield*Hn(function*(e){let n=null;do{n=e.next(yield Vn(t,n))}while(!n.done)}(r[Symbol.iterator]())),new t}(Uint8Array,t);function Wn(t,e){return en(this,arguments,(function*(){if(Bn(e))return yield tn(yield tn(yield*nn(rn(Wn(t,yield tn(e))))));const n=function(t){return en(this,arguments,(function*(){yield yield tn(yield tn(t))}))},r="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Rn?n(e):On(e)?function(t){return en(this,arguments,(function*(){yield tn(yield*nn(rn(Hn(function*(t){let e=null;do{e=t.next(yield e&&e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):Mn(e)?e:n(e);return yield tn(yield*nn(rn(Hn(function(e){return en(this,arguments,(function*(){let n=null;do{n=yield tn(e.next(yield yield tn(Vn(t,n))))}while(!n.done)}))}(r[Symbol.asyncIterator]()))))),yield tn(new t)}))}const qn=t=>Wn(Uint8Array,t);function Xn(t,e,n){if(0!==t){n=n.slice(0,e+1);for(let r=-1;++r<=e;)n[r]+=t}return n}var Zn={fromIterable:t=>Jn(function*(t){let e,n,r,i,o=!1,a=[],s=0;function u(){return"peek"===r?Un(a,i)[0]:([n,a,s]=Un(a,i),n)}({cmd:r,size:i}=yield null);const c=Yn(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=isNaN(i-s)?c.next(void 0):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(iJn(function(t){return en(this,arguments,(function*(){let e,n,r,i,o=!1,a=[],s=0;function u(){return"peek"===r?Un(a,i)[0]:([n,a,s]=Un(a,i),n)}({cmd:r,size:i}=yield yield tn(null));const c=qn(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=isNaN(i-s)?yield tn(c.next(void 0)):yield tn(c.next(i-s))),!e&&n.byteLength>0&&(a.push(n),s+=n.byteLength),e||i<=s)do{({cmd:r,size:i}=yield yield tn(u()))}while(iJn(function(t){return en(this,arguments,(function*(){let e,n,r,i=!1,o=!1,a=[],s=0;function u(){return"peek"===n?Un(a,r)[0]:([e,a,s]=Un(a,r),e)}({cmd:n,size:r}=yield yield tn(null));const c=new Kn(t);try{do{if(({done:i,value:e}=isNaN(r-s)?yield tn(c.read(void 0)):yield tn(c.read(r-s))),!i&&e.byteLength>0&&(a.push(Gn(e)),s+=e.byteLength),i||r<=s)do{({cmd:n,size:r}=yield yield tn(u()))}while(rJn(function(t){return en(this,arguments,(function*(){const e=[];let n,r,i,o="error",a=!1,s=null,u=0,c=[];function f(){return"peek"===n?Un(c,r)[0]:([i,c,u]=Un(c,r),i)}if(({cmd:n,size:r}=yield yield tn(null)),t.isTTY)return yield yield tn(new Uint8Array(0)),yield tn(null);try{e[0]=tr(t,"end"),e[1]=tr(t,"error");do{if(e[2]=tr(t,"readable"),[o,s]=yield tn(Promise.race(e.map((t=>t[2])))),"error"===o)break;if((a="end"===o)||(isFinite(r-u)?(i=Gn(t.read(r-u)),i.byteLength0&&(c.push(i),u+=i.byteLength)),a||r<=u)do{({cmd:n,size:r}=yield yield tn(f()))}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')}};const Jn=t=>(t.next(),t);class Kn{constructor(t){this.source=t,this.byobReader=null,this.defaultReader=null;try{this.supportsBYOB=!!(this.reader=this.getBYOBReader())}catch(e){this.supportsBYOB=!(this.reader=this.getDefaultReader())}}get closed(){return this.reader?this.reader.closed.catch((()=>{})):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=this.byobReader=this.defaultReader=null}cancel(t){return Ke(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 Ke(this,void 0,void 0,(function*(){if(0===t)return{done:null==this.reader,value:new Uint8Array(0)};const e=this.supportsBYOB&&"number"==typeof t?yield this.readFromBYOBReader(t):yield this.getDefaultReader().read();return!e.done&&(e.value=Gn(e)),e}))}getDefaultReader(){return this.byobReader&&this.releaseLock(),this.defaultReader||(this.defaultReader=this.source.getReader(),this.defaultReader.closed.catch((()=>{}))),this.reader=this.defaultReader}getBYOBReader(){return this.defaultReader&&this.releaseLock(),this.byobReader||(this.byobReader=this.source.getReader({mode:"byob"}),this.byobReader.closed.catch((()=>{}))),this.reader=this.byobReader}readFromBYOBReader(t){return Ke(this,void 0,void 0,(function*(){return yield Qn(this.getBYOBReader(),new ArrayBuffer(t),0,t)}))}}function Qn(t,e,n,r){return Ke(this,void 0,void 0,(function*(){if(n>=r)return{done:!1,value:new Uint8Array(e,0,r)};const{done:i,value:o}=yield t.read(new Uint8Array(e,n,r-n));return(n+=o.byteLength){const n=t=>r([e,t]);let r;return[e,n,new Promise((i=>(r=i)&&t.once(e,n)))]};class er{}var nr,rr,ir,or,ar,sr,ur,cr,fr,lr,dr,hr,pr,_r,mr,br,yr,gr,vr,wr,xr,Ar,Sr,Ir,kr,Tr,Er,Br,Or,Mr;er.prototype.data=null,(rr=nr||(nr={}))[rr.V1=0]="V1",rr[rr.V2=1]="V2",rr[rr.V3=2]="V3",rr[rr.V4=3]="V4",rr[rr.V5=4]="V5",(or=ir||(ir={}))[or.UNUSED=0]="UNUSED",or[or.DICTIONARY_REPLACEMENT=1]="DICTIONARY_REPLACEMENT",or[or.COMPRESSED_BODY=2]="COMPRESSED_BODY",(sr=ar||(ar={}))[sr.Sparse=0]="Sparse",sr[sr.Dense=1]="Dense",(cr=ur||(ur={}))[cr.HALF=0]="HALF",cr[cr.SINGLE=1]="SINGLE",cr[cr.DOUBLE=2]="DOUBLE",(lr=fr||(fr={}))[lr.DAY=0]="DAY",lr[lr.MILLISECOND=1]="MILLISECOND",(hr=dr||(dr={}))[hr.SECOND=0]="SECOND",hr[hr.MILLISECOND=1]="MILLISECOND",hr[hr.MICROSECOND=2]="MICROSECOND",hr[hr.NANOSECOND=3]="NANOSECOND",(_r=pr||(pr={}))[_r.YEAR_MONTH=0]="YEAR_MONTH",_r[_r.DAY_TIME=1]="DAY_TIME",(br=mr||(mr={}))[br.NONE=0]="NONE",br[br.Null=1]="Null",br[br.Int=2]="Int",br[br.FloatingPoint=3]="FloatingPoint",br[br.Binary=4]="Binary",br[br.Utf8=5]="Utf8",br[br.Bool=6]="Bool",br[br.Decimal=7]="Decimal",br[br.Date=8]="Date",br[br.Time=9]="Time",br[br.Timestamp=10]="Timestamp",br[br.Interval=11]="Interval",br[br.List=12]="List",br[br.Struct_=13]="Struct_",br[br.Union=14]="Union",br[br.FixedSizeBinary=15]="FixedSizeBinary",br[br.FixedSizeList=16]="FixedSizeList",br[br.Map=17]="Map",br[br.Duration=18]="Duration",br[br.LargeBinary=19]="LargeBinary",br[br.LargeUtf8=20]="LargeUtf8",br[br.LargeList=21]="LargeList",(gr=yr||(yr={}))[gr.DenseArray=0]="DenseArray",(wr=vr||(vr={}))[wr.Little=0]="Little",wr[wr.Big=1]="Big";class Dr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new Dr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Dr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Dr.startNull(t),Dr.endNull(t)}}class jr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new jr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new jr).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return jr.startStruct_(t),jr.endStruct_(t)}}class zr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new zr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new zr).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return zr.startList(t),zr.endList(t)}}class Fr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new Fr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Fr).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return Fr.startFixedSizeList(t),Fr.addListSize(t,e),Fr.endFixedSizeList(t)}}class Nr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new Nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Nr).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return Nr.startMap(t),Nr.addKeysSorted(t,e),Nr.endMap(t)}}class Lr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new Lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Lr).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ar.Sparse}typeIds(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*t):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,ar.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=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 Lr.startUnion(t),Lr.addMode(t,e),Lr.addTypeIds(t,n),Lr.endUnion(t)}}class Cr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new Cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Cr).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return Cr.startInt(t),Cr.addBitWidth(t,e),Cr.addIsSigned(t,n),Cr.endInt(t)}}class Rr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new Rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Rr).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ur.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,ur.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Rr.startFloatingPoint(t),Rr.addPrecision(t,e),Rr.endFloatingPoint(t)}}class Pr{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 Pr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Pr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Pr.startUtf8(t),Pr.endUtf8(t)}}class Ur{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new Ur).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ur).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Ur.startBinary(t),Ur.endBinary(t)}}class Vr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new Vr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Vr).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return Vr.startFixedSizeBinary(t),Vr.addByteWidth(t,e),Vr.endFixedSizeBinary(t)}}class $r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new $r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new $r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return $r.startBool(t),$r.endBool(t)}}class Gr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new Gr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Gr).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,r){return Gr.startDecimal(t),Gr.addPrecision(t,e),Gr.addScale(t,n),Gr.addBitWidth(t,r),Gr.endDecimal(t)}}class Hr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new Hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Hr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):fr.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,fr.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Hr.startDate(t),Hr.addUnit(t,e),Hr.endDate(t)}}class Yr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new Yr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Yr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):dr.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,dr.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return Yr.startTime(t),Yr.addUnit(t,e),Yr.addBitWidth(t,n),Yr.endTime(t)}}class Wr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new Wr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Wr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):dr.SECOND}timezone(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,dr.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Wr.startTimestamp(t),Wr.addUnit(t,e),Wr.addTimezone(t,n),Wr.endTimestamp(t)}}class qr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new qr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new qr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):pr.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,pr.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return qr.startInterval(t),qr.addUnit(t,e),qr.endInterval(t)}}class Xr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new Xr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Xr).__init(t.readInt32(t.position())+t.position(),t)}key(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return Xr.startKeyValue(t),Xr.addKey(t,e),Xr.addValue(t,n),Xr.endKeyValue(t)}}class Zr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new Zr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Zr).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}indexType(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Cr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):yr.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,yr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}static createDictionaryEncoding(t,e,n,r,i){return Zr.startDictionaryEncoding(t),Zr.addId(t,e),Zr.addIndexType(t,n),Zr.addIsOrdered(t,r),Zr.addDictionaryKind(t,i),Zr.endDictionaryEncoding(t)}}class Jr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new Jr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Jr).__init(t.readInt32(t.position())+t.position(),t)}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):mr.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 Zr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const n=this.bb.__offset(this.bb_pos,14);return n?(e||new Jr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),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 Xr).__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,mr.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()}static createField(t,e,n,r,i,o,a,s){return Jr.startField(t),Jr.addName(t,e),Jr.addNullable(t,n),Jr.addTypeType(t,r),Jr.addType(t,i),Jr.addDictionary(t,o),Jr.addChildren(t,a),Jr.addCustomMetadata(t,s),Jr.endField(t)}}class Kr{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 createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}}class Qr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new Qr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Qr).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):vr.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Jr).__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 Xr).__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):this.bb.createLong(0,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,vr.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(t,e,n,r,i){return Qr.startSchema(t),Qr.addEndianness(t,e),Qr.addFields(t,n),Qr.addCustomMetadata(t,r),Qr.addFeatures(t,i),Qr.endSchema(t)}}(Ar=xr||(xr={}))[Ar.LZ4_FRAME=0]="LZ4_FRAME",Ar[Ar.ZSTD=1]="ZSTD",(Ir=Sr||(Sr={}))[Ir.BUFFER=0]="BUFFER",(Tr=kr||(kr={}))[Tr.NONE=0]="NONE",Tr[Tr.Schema=1]="Schema",Tr[Tr.DictionaryBatch=2]="DictionaryBatch",Tr[Tr.RecordBatch=3]="RecordBatch",Tr[Tr.Tensor=4]="Tensor",Tr[Tr.SparseTensor=5]="SparseTensor";class ti{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 createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}}class ei{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 ei).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ei).__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):xr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Sr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,xr.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Sr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return ei.startBodyCompression(t),ei.addCodec(t,e),ei.addMethod(t,n),ei.endBodyCompression(t)}}class ni{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new ni).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ni).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new ti).__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 Kr).__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 ei).__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,t.createLong(0,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()}static createRecordBatch(t,e,n,r,i){return ni.startRecordBatch(t),ni.addLength(t,e),ni.addNodes(t,n),ni.addBuffers(t,r),ni.addCompression(t,i),ni.endRecordBatch(t)}}class ri{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new ri).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ri).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new ni).__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,t.createLong(0,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()}static createDictionaryBatch(t,e,n,r){return ri.startDictionaryBatch(t),ri.addId(t,e),ri.addData(t,n),ri.addIsDelta(t,r),ri.endDictionaryBatch(t)}}class ii{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ii).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ii).__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):nr.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):kr.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):this.bb.createLong(0,0)}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new Xr).__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,nr.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,kr.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,t.createLong(0,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(t,e,n,r,i,o){return ii.startMessage(t),ii.addVersion(t,e),ii.addHeaderType(t,n),ii.addHeader(t,r),ii.addBodyLength(t,i),ii.addCustomMetadata(t,o),ii.endMessage(t)}}function oi(t,e,n,r){return 0!=(n&1<>r}function si(t,e,n){const r=n.byteLength+7&-8;if(t>0||n.byteLength>3):ui(new ci(n,t,e,null,oi)).subarray(0,r)),i}return n}function ui(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}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",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.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(Er||(Er={})),(Or=Br||(Br={}))[Or.OFFSET=0]="OFFSET",Or[Or.DATA=1]="DATA",Or[Or.VALIDITY=2]="VALIDITY",Or[Or.TYPE=3]="TYPE";class ci{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 fi(t,e,i)+fi(t,r,n)+function(t,e,n){let r=0,i=0|e;const o=new DataView(t.buffer,t.byteOffset,t.byteLength),a=void 0===n?t.byteLength:i+n;for(;a-i>=4;)r+=li(o.getUint32(i)),i+=4;for(;a-i>=2;)r+=li(o.getUint16(i)),i+=2;for(;a-i>=1;)r+=li(o.getUint8(i)),i+=1;return r}(t,i>>3,r-i>>3)}function li(t){let e=0|t;return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class di{static isNull(t){return t&&t.typeId===Er.Null}static isInt(t){return t&&t.typeId===Er.Int}static isFloat(t){return t&&t.typeId===Er.Float}static isBinary(t){return t&&t.typeId===Er.Binary}static isUtf8(t){return t&&t.typeId===Er.Utf8}static isBool(t){return t&&t.typeId===Er.Bool}static isDecimal(t){return t&&t.typeId===Er.Decimal}static isDate(t){return t&&t.typeId===Er.Date}static isTime(t){return t&&t.typeId===Er.Time}static isTimestamp(t){return t&&t.typeId===Er.Timestamp}static isInterval(t){return t&&t.typeId===Er.Interval}static isList(t){return t&&t.typeId===Er.List}static isStruct(t){return t&&t.typeId===Er.Struct}static isUnion(t){return t&&t.typeId===Er.Union}static isFixedSizeBinary(t){return t&&t.typeId===Er.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===Er.FixedSizeList}static isMap(t){return t&&t.typeId===Er.Map}static isDictionary(t){return t&&t.typeId===Er.Dictionary}get typeId(){return Er.NONE}}di[Symbol.toStringTag]=((Mr=di.prototype).children=null,Mr.ArrayType=Array,Mr[Symbol.toStringTag]="DataType");class hi extends di{toString(){return"Null"}get typeId(){return Er.Null}}hi[Symbol.toStringTag]=(t=>t[Symbol.toStringTag]="Null")(hi.prototype);class pi extends di{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return Er.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:case 64:return this.isSigned?Int32Array:Uint32Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}pi[Symbol.toStringTag]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(pi.prototype);class _i extends pi{constructor(){super(!0,32)}}Object.defineProperty(class extends pi{constructor(){super(!0,8)}}.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(class extends pi{constructor(){super(!0,16)}}.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(_i.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends pi{constructor(){super(!0,64)}}.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends pi{constructor(){super(!1,8)}}.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(class extends pi{constructor(){super(!1,16)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends pi{constructor(){super(!1,32)}}.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(class extends pi{constructor(){super(!1,64)}}.prototype,"ArrayType",{value:Uint32Array});class mi extends di{constructor(t){super(),this.precision=t}get typeId(){return Er.Float}get ArrayType(){switch(this.precision){case ur.HALF:return Uint16Array;case ur.SINGLE:return Float32Array;case ur.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}mi[Symbol.toStringTag]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(mi.prototype);Object.defineProperty(class extends mi{constructor(){super(ur.HALF)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends mi{constructor(){super(ur.SINGLE)}}.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(class extends mi{constructor(){super(ur.DOUBLE)}}.prototype,"ArrayType",{value:Float64Array});class bi extends di{constructor(){super()}get typeId(){return Er.Binary}toString(){return"Binary"}}bi[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(bi.prototype);class yi extends di{constructor(){super()}get typeId(){return Er.Utf8}toString(){return"Utf8"}}yi[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(yi.prototype);class gi extends di{constructor(){super()}get typeId(){return Er.Bool}toString(){return"Bool"}}gi[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(gi.prototype);class vi extends di{constructor(t,e){super(),this.scale=t,this.precision=e}get typeId(){return Er.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}vi[Symbol.toStringTag]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(vi.prototype);class wi extends di{constructor(t){super(),this.unit=t}get typeId(){return Er.Date}toString(){return`Date${32*(this.unit+1)}<${fr[this.unit]}>`}}wi[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(wi.prototype);class xi extends di{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return Er.Time}toString(){return`Time${this.bitWidth}<${dr[this.unit]}>`}}xi[Symbol.toStringTag]=(t=>(t.unit=null,t.bitWidth=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Time"))(xi.prototype);class Ai extends di{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return Er.Timestamp}toString(){return`Timestamp<${dr[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Ai[Symbol.toStringTag]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(Ai.prototype);class Si extends di{constructor(t){super(),this.unit=t}get typeId(){return Er.Interval}toString(){return`Interval<${pr[this.unit]}>`}}Si[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Si.prototype);class Ii extends di{constructor(t){super(),this.children=[t]}get typeId(){return Er.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}}Ii[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Ii.prototype);class ki extends di{constructor(t){super(),this.children=t}get typeId(){return Er.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}ki[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(ki.prototype);class Ti extends di{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 Er.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}Ti[Symbol.toStringTag]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Ti.prototype);class Ei extends di{constructor(t){super(),this.byteWidth=t}get typeId(){return Er.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Ei[Symbol.toStringTag]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(Ei.prototype);class Bi extends di{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return Er.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}>`}}Bi[Symbol.toStringTag]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Bi.prototype);class Oi extends di{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return Er.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}toString(){return`Map<{${this.children[0].type.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}Oi[Symbol.toStringTag]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Oi.prototype);const Mi=(Di=-1,()=>++Di);var Di;class ji extends di{constructor(t,e,n,r){super(),this.indices=e,this.dictionary=t,this.isOrdered=r||!1,this.id=null==n?Mi():"number"==typeof n?n:n.low}get typeId(){return Er.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}>`}}ji[Symbol.toStringTag]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(ji.prototype);class zi{constructor(t,e,n,r,i,o,a){let s;this.type=t,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)),this.childData=(o||[]).map((t=>t instanceof zi?t:t.data)),i instanceof zi?(this.stride=i.stride,this.values=i.values,this.typeIds=i.typeIds,this.nullBitmap=i.nullBitmap,this.valueOffsets=i.valueOffsets):(this.stride=function(t){const e=t;switch(t.typeId){case Er.Decimal:return 4;case Er.Timestamp:return 2;case Er.Date:case Er.Interval:return 1+e.unit;case Er.Int:case Er.Time:return+(e.bitWidth>32)+1;case Er.FixedSizeList:return e.listSize;case Er.FixedSizeBinary:return e.byteWidth;default:return 1}}(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)))}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.childData.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-fi(t,this.offset,this.offset+this.length)),e}clone(t,e=this.offset,n=this.length,r=this._nullCount,i=this,o=this.childData){return new zi(t,e,n,r,i,o,this.dictionary)}slice(t,e){const{stride:n,typeId:r,childData:i}=this,o=+(0===this._nullCount)-1,a=16===r?n:1,s=this._sliceBuffers(t,e,n,r);return this.clone(this.type,this.offset+t,e,o,s,!i.length||this.valueOffsets?i:this._sliceChildren(i,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===Er.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,r=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);r[e>>3]=(1<0&&r.set(si(this.offset,e,this.nullBitmap),0);const i=this.buffers;return i[Br.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[Br.TYPE])&&(o[Br.TYPE]=i.subarray(t,t+e)),(i=o[Br.OFFSET])&&(o[Br.OFFSET]=i.subarray(t,t+e+1))||(i=o[Br.DATA])&&(o[Br.DATA]=6===r?i:i.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}static new(t,e,n,r,i,o,a){switch(i instanceof zi?i=i.buffers:i||(i=[]),t.typeId){case Er.Null:return zi.Null(t,e,n);case Er.Int:return zi.Int(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Dictionary:return zi.Dictionary(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[],a);case Er.Float:return zi.Float(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Bool:return zi.Bool(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Decimal:return zi.Decimal(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Date:return zi.Date(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Time:return zi.Time(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Timestamp:return zi.Timestamp(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Interval:return zi.Interval(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.FixedSizeBinary:return zi.FixedSizeBinary(t,e,n,r||0,i[Br.VALIDITY],i[Br.DATA]||[]);case Er.Binary:return zi.Binary(t,e,n,r||0,i[Br.VALIDITY],i[Br.OFFSET]||[],i[Br.DATA]||[]);case Er.Utf8:return zi.Utf8(t,e,n,r||0,i[Br.VALIDITY],i[Br.OFFSET]||[],i[Br.DATA]||[]);case Er.List:return zi.List(t,e,n,r||0,i[Br.VALIDITY],i[Br.OFFSET]||[],(o||[])[0]);case Er.FixedSizeList:return zi.FixedSizeList(t,e,n,r||0,i[Br.VALIDITY],(o||[])[0]);case Er.Struct:return zi.Struct(t,e,n,r||0,i[Br.VALIDITY],o||[]);case Er.Map:return zi.Map(t,e,n,r||0,i[Br.VALIDITY],i[Br.OFFSET]||[],(o||[])[0]);case Er.Union:return zi.Union(t,e,n,r||0,i[Br.VALIDITY],i[Br.TYPE]||[],i[Br.OFFSET]||o,o)}throw new Error(`Unrecognized typeId ${t.typeId}`)}static Null(t,e,n){return new zi(t,e,n,0)}static Int(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Dictionary(t,e,n,r,i,o,a){return new zi(t,e,n,r,[void 0,Vn(t.indices.ArrayType,o),Gn(i)],[],a)}static Float(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Bool(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Decimal(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Date(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Time(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Timestamp(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Interval(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static FixedSizeBinary(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,Vn(t.ArrayType,o),Gn(i)])}static Binary(t,e,n,r,i,o,a){return new zi(t,e,n,r,[$n(o),Gn(a),Gn(i)])}static Utf8(t,e,n,r,i,o,a){return new zi(t,e,n,r,[$n(o),Gn(a),Gn(i)])}static List(t,e,n,r,i,o,a){return new zi(t,e,n,r,[$n(o),void 0,Gn(i)],a?[a]:[])}static FixedSizeList(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,void 0,Gn(i)],o?[o]:[])}static Struct(t,e,n,r,i,o){return new zi(t,e,n,r,[void 0,void 0,Gn(i)],o)}static Map(t,e,n,r,i,o,a){return new zi(t,e,n,r,[$n(o),void 0,Gn(i)],a?[a]:[])}static Union(t,e,n,r,i,o,a,s){const u=[void 0,void 0,Gn(i),Vn(t.ArrayType,o)];return t.mode===ar.Sparse?new zi(t,e,n,r,u,a):(u[Br.OFFSET]=$n(a),new zi(t,e,n,r,u,s))}}zi.prototype.childData=Object.freeze([]);function Fi(t){if(null===t)return"null";if(undefined===t)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}]`:JSON.stringify(t)}class Ni{constructor(t=[],e,n){this.fields=t||[],this.metadata=e||new Map,n||(n=Ri(t)),this.dictionaries=n}get[Symbol.toStringTag](){return"Schema"}toString(){return`Schema<{ ${this.fields.map(((t,e)=>`${e}: ${t}`)).join(", ")} }>`}select(...t){const e=t.reduce(((t,e)=>(t[e]=!0)&&t),Object.create(null));return new Ni(this.fields.filter((t=>e[t.name])),this.metadata)}selectAt(...t){return new Ni(t.map((t=>this.fields[t])).filter(Boolean),this.metadata)}assign(...t){const e=t[0]instanceof Ni?t[0]:Array.isArray(t[0])?new Ni(t[0]):new Ni(t),n=[...this.fields],r=Ci(Ci(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:Ci(Ci(new Map,n[e].metadata),t.metadata)}))&&!1})),o=Ri(i,new Map);return new Ni([...n,...i],r,new Map([...this.dictionaries,...o]))}}class Li{constructor(t,e,n=!1,r){this.name=t,this.type=e,this.nullable=n,this.metadata=r||new Map}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 Li(`${e}`,n,r,i)}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,Li.new(e,n,r,i)}}function Ci(t,e){return new Map([...t||new Map,...e||new Map])}function Ri(t,e=new Map){for(let n=-1,r=t.length;++n0&&Ri(r.children,e)}return e}Ni.prototype.fields=null,Ni.prototype.metadata=null,Ni.prototype.dictionaries=null,Li.prototype.type=null,Li.prototype.name=null,Li.prototype.nullable=null,Li.prototype.metadata=null;class Pi{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){let r=null,i=Er.NONE;e instanceof zi||e instanceof er?i=Ui(e.type):e instanceof di?i=Ui(e):"number"!=typeof(i=e)&&(i=Er[e]);switch(i){case Er.Null:r=t.visitNull;break;case Er.Bool:r=t.visitBool;break;case Er.Int:r=t.visitInt;break;case Er.Int8:r=t.visitInt8||t.visitInt;break;case Er.Int16:r=t.visitInt16||t.visitInt;break;case Er.Int32:r=t.visitInt32||t.visitInt;break;case Er.Int64:r=t.visitInt64||t.visitInt;break;case Er.Uint8:r=t.visitUint8||t.visitInt;break;case Er.Uint16:r=t.visitUint16||t.visitInt;break;case Er.Uint32:r=t.visitUint32||t.visitInt;break;case Er.Uint64:r=t.visitUint64||t.visitInt;break;case Er.Float:r=t.visitFloat;break;case Er.Float16:r=t.visitFloat16||t.visitFloat;break;case Er.Float32:r=t.visitFloat32||t.visitFloat;break;case Er.Float64:r=t.visitFloat64||t.visitFloat;break;case Er.Utf8:r=t.visitUtf8;break;case Er.Binary:r=t.visitBinary;break;case Er.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case Er.Date:r=t.visitDate;break;case Er.DateDay:r=t.visitDateDay||t.visitDate;break;case Er.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case Er.Timestamp:r=t.visitTimestamp;break;case Er.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case Er.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case Er.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case Er.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case Er.Time:r=t.visitTime;break;case Er.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case Er.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case Er.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case Er.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case Er.Decimal:r=t.visitDecimal;break;case Er.List:r=t.visitList;break;case Er.Struct:r=t.visitStruct;break;case Er.Union:r=t.visitUnion;break;case Er.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case Er.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case Er.Dictionary:r=t.visitDictionary;break;case Er.Interval:r=t.visitInterval;break;case Er.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case Er.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case Er.FixedSizeList:r=t.visitFixedSizeList;break;case Er.Map:r=t.visitMap}if("function"==typeof r)return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${Er[i]}'`)}(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 Ui(t){switch(t.typeId){case Er.Null:return Er.Null;case Er.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?Er.Int8:Er.Uint8;case 16:return n?Er.Int16:Er.Uint16;case 32:return n?Er.Int32:Er.Uint32;case 64:return n?Er.Int64:Er.Uint64}return Er.Int}case Er.Float:switch(t.precision){case ur.HALF:return Er.Float16;case ur.SINGLE:return Er.Float32;case ur.DOUBLE:return Er.Float64}return Er.Float;case Er.Binary:return Er.Binary;case Er.Utf8:return Er.Utf8;case Er.Bool:return Er.Bool;case Er.Decimal:return Er.Decimal;case Er.Time:switch(t.unit){case dr.SECOND:return Er.TimeSecond;case dr.MILLISECOND:return Er.TimeMillisecond;case dr.MICROSECOND:return Er.TimeMicrosecond;case dr.NANOSECOND:return Er.TimeNanosecond}return Er.Time;case Er.Timestamp:switch(t.unit){case dr.SECOND:return Er.TimestampSecond;case dr.MILLISECOND:return Er.TimestampMillisecond;case dr.MICROSECOND:return Er.TimestampMicrosecond;case dr.NANOSECOND:return Er.TimestampNanosecond}return Er.Timestamp;case Er.Date:switch(t.unit){case fr.DAY:return Er.DateDay;case fr.MILLISECOND:return Er.DateMillisecond}return Er.Date;case Er.Interval:switch(t.unit){case pr.DAY_TIME:return Er.IntervalDayTime;case pr.YEAR_MONTH:return Er.IntervalYearMonth}return Er.Interval;case Er.Map:return Er.Map;case Er.List:return Er.List;case Er.Struct:return Er.Struct;case Er.Union:switch(t.mode){case ar.Dense:return Er.DenseUnion;case ar.Sparse:return Er.SparseUnion}return Er.Union;case Er.FixedSizeBinary:return Er.FixedSizeBinary;case Er.FixedSizeList:return Er.FixedSizeList;case Er.Dictionary:return Er.Dictionary}throw new Error(`Unrecognized type '${Er[t.typeId]}'`)}Pi.prototype.visitInt8=null,Pi.prototype.visitInt16=null,Pi.prototype.visitInt32=null,Pi.prototype.visitInt64=null,Pi.prototype.visitUint8=null,Pi.prototype.visitUint16=null,Pi.prototype.visitUint32=null,Pi.prototype.visitUint64=null,Pi.prototype.visitFloat16=null,Pi.prototype.visitFloat32=null,Pi.prototype.visitFloat64=null,Pi.prototype.visitDateDay=null,Pi.prototype.visitDateMillisecond=null,Pi.prototype.visitTimestampSecond=null,Pi.prototype.visitTimestampMillisecond=null,Pi.prototype.visitTimestampMicrosecond=null,Pi.prototype.visitTimestampNanosecond=null,Pi.prototype.visitTimeSecond=null,Pi.prototype.visitTimeMillisecond=null,Pi.prototype.visitTimeMicrosecond=null,Pi.prototype.visitTimeNanosecond=null,Pi.prototype.visitDenseUnion=null,Pi.prototype.visitSparseUnion=null,Pi.prototype.visitIntervalDayTime=null,Pi.prototype.visitIntervalYearMonth=null;class Vi{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 Vi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Vi).__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):nr.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Qr).__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 $i).__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 $i).__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 Xr).__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,nr.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)}static createFooter(t,e,n,r,i,o){return Vi.startFooter(t),Vi.addVersion(t,e),Vi.addSchema(t,n),Vi.addDictionaries(t,r),Vi.addRecordBatches(t,i),Vi.addCustomMetadata(t,o),Vi.endFooter(t)}}class $i{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 createBlock(t,e,n,r){return t.prep(8,24),t.writeInt64(r),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()}}var Gi=on.Long,Hi=on.Builder,Yi=on.ByteBuffer;class Wi{constructor(t,e=nr.V4,n,r){this.schema=t,this.version=e,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}static decode(t){t=new Yi(Gn(t));const e=Vi.getRootAsFooter(t),n=Ni.decode(e.schema());return new qi(n,e)}static encode(t){const e=new Hi,n=Ni.encode(e,t.schema);Vi.startRecordBatchesVector(e,t.numRecordBatches),[...t.recordBatches()].slice().reverse().forEach((t=>Xi.encode(e,t)));const r=e.endVector();Vi.startDictionariesVector(e,t.numDictionaries),[...t.dictionaryBatches()].slice().reverse().forEach((t=>Xi.encode(e,t)));const i=e.endVector();return Vi.startFooter(e),Vi.addSchema(e,n),Vi.addVersion(e,nr.V4),Vi.addRecordBatches(e,r),Vi.addDictionaries(e,i),Vi.finishFooterBuffer(e,Vi.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&t0)return super.write(t)}toString(t=!1){return t?bn(this.toUint8Array(!0)):this.toUint8Array(!1).then(bn)}toUint8Array(t=!1){return t?Un(this._values)[0]:(()=>Ke(this,void 0,void 0,(function*(){var t,e;const n=[];let r=0;try{for(var i,o=rn(this);!(i=yield o.next()).done;){const t=i.value;n.push(t),r+=t.byteLength}}catch(a){t={error:a}}finally{try{i&&!i.done&&(e=o.return)&&(yield e.call(o))}finally{if(t)throw t.error}}return Un(n,r)[0]})))()}}class Ji{constructor(t){t&&(this.source=new Qi(Zn.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 Ki{constructor(t){t instanceof Ki?this.source=t.source:t instanceof Zi?this.source=new to(Zn.fromAsyncIterable(t)):Ln(t)?this.source=new to(Zn.fromNodeStream(t)):Nn(t)?this.source=new to(Zn.fromDOMStream(t)):Fn(t)?this.source=new to(Zn.fromDOMStream(t.body)):On(t)?this.source=new to(Zn.fromIterable(t)):(Bn(t)||Mn(t))&&(this.source=new to(Zn.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 Qi{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)||vn)}return(t){return Object.create(this.source.return&&this.source.return(t)||vn)}}class to{constructor(t){this.source=t,this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}cancel(t){return Ke(this,void 0,void 0,(function*(){yield this.return(t)}))}get closed(){return this._closedPromise}read(t){return Ke(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return Ke(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(t,e="read"){return Ke(this,void 0,void 0,(function*(){return yield this.source.next({cmd:e,size:t})}))}throw(t){return Ke(this,void 0,void 0,(function*(){const e=this.source.throw&&(yield this.source.throw(t))||vn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}return(t){return Ke(this,void 0,void 0,(function*(){const e=this.source.return&&(yield this.source.return(t))||vn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}}class eo extends Ji{constructor(t,e){super(),this.position=0,this.buffer=Gn(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),tKe(this,void 0,void 0,(function*(){this.size=(yield t.stat()).size,delete this._pending})))()}readInt32(t){return Ke(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 Ke(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`${ro(this.buffer[3])} ${ro(this.buffer[2])} ${ro(this.buffer[1])} ${ro(this.buffer[0])}`}static multiply(t,e){return new uo(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new uo(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return uo.fromString("string"==typeof t?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return uo.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),r=t.length,i=new uo(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 fo extends co{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):ui(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Vn(Uint8Array,Vn(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Vn(Uint8Array,Vn(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return di.isTimestamp(t)||(di.isInt(t)||di.isTime(t))&&64===t.bitWidth||di.isDate(t)&&t.unit===fr.MILLISECOND?Vn(Uint8Array,so.convertArray(n[e])):di.isDecimal(t)?Vn(Uint8Array,uo.convertArray(n[e])):di.isBinary(t)||di.isFixedSizeBinary(t)?function(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=parseInt(e.substr(r,2),16);return n}(n[e]):di.isBool(t)?ui(n[e]):di.isUtf8(t)?gn(n[e].join("")):Vn(Uint8Array,Vn(t.ArrayType,n[e].map((t=>+t))))}}const lo=Symbol.for("parent"),ho=Symbol.for("rowIndex"),po=Symbol.for("keyToIdx"),_o=Symbol.for("idxToVal"),mo=Symbol.for("nodejs.util.inspect.custom");class bo{constructor(t,e){this[lo]=t,this.size=e}entries(){return this[Symbol.iterator]()}has(t){return void 0!==this.get(t)}get(t){let e;if(null!=t){const n=this[po]||(this[po]=new Map);let r=n.get(t);if(void 0!==r){const t=this[_o]||(this[_o]=new Array(this.size));void 0!==(e=t[r])||(t[r]=e=this.getValue(r))}else if((r=this.getIndex(t))>-1){n.set(t,r);const i=this[_o]||(this[_o]=new Array(this.size));void 0!==(e=i[r])||(i[r]=e=this.getValue(r))}}return e}set(t,e){if(null!=t){const n=this[po]||(this[po]=new Map);let r=n.get(t);if(void 0===r&&n.set(t,r=this.getIndex(t)),r>-1){(this[_o]||(this[_o]=new Array(this.size)))[r]=this.setValue(r,e)}}return this}clear(){throw new Error(`Clearing ${this[Symbol.toStringTag]} not supported.`)}delete(t){throw new Error(`Deleting ${this[Symbol.toStringTag]} values not supported.`)}*[Symbol.iterator](){const t=this.keys(),e=this.values(),n=this[po]||(this[po]=new Map),r=this[_o]||(this[_o]=new Array(this.size));for(let i,o,a,s,u=0;!(a=t.next()).done&&!(s=e.next()).done;++u)i=a.value,o=s.value,r[u]=o,n.has(i)||n.set(i,u),yield[i,o]}forEach(t,e){const n=this.keys(),r=this.values(),i=void 0===e?t:(n,r,i)=>t.call(e,n,r,i),o=this[po]||(this[po]=new Map),a=this[_o]||(this[_o]=new Array(this.size));for(let s,u,c,f,l=0;!(c=n.next()).done&&!(f=r.next()).done;++l)s=c.value,u=f.value,a[l]=u,o.has(s)||o.set(s,l),i(u,s,this)}toArray(){return[...this.values()]}toJSON(){const t={};return this.forEach(((e,n)=>t[n]=e)),t}inspect(){return this.toString()}[mo](){return this.toString()}toString(){const t=[];return this.forEach(((e,n)=>{n=Fi(n),e=Fi(e),t.push(`${n}: ${e}`)})),`{ ${t.join(", ")} }`}}bo[Symbol.toStringTag]=(t=>(Object.defineProperties(t,{size:{writable:!0,enumerable:!1,configurable:!1,value:0},[lo]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ho]:{writable:!0,enumerable:!1,configurable:!1,value:-1}}),t[Symbol.toStringTag]="Row"))(bo.prototype);class yo extends bo{constructor(t){return super(t,t.type.children.length),go(this)}*keys(){for(const t of this[lo].type.children)yield t.name}*values(){for(const t of this[lo].type.children)yield this[t.name]}getKey(t){return this[lo].type.children[t].name}getIndex(t){return this[lo].type.children.findIndex((e=>e.name===t))}getValue(t){return this[lo].getChildAt(t).get(this[ho])}setValue(t,e){return this[lo].getChildAt(t).set(this[ho],e)}}Object.setPrototypeOf(bo.prototype,Map.prototype);const go=(()=>{const t={enumerable:!0,configurable:!1,get:null,set:null};return e=>{let n=-1;const r=e[po]||(e[po]=new Map),i=t=>function(){return this.get(t)},o=t=>function(e){return this.set(t,e)};for(const a of e.keys())r.set(a,++n),t.get=i(a),t.set=o(a),Object.prototype.hasOwnProperty.call(e,a)||(t.enumerable=!0,Object.defineProperty(e,a,t)),Object.prototype.hasOwnProperty.call(e,n)||(t.enumerable=!1,Object.defineProperty(e,n,t));return t.get=t.set=null,e}})();let vo;function wo(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]}(()=>{if("undefined"==typeof Proxy)return go;const t=bo.prototype.has,e=bo.prototype.get,n=bo.prototype.set,r=bo.prototype.getKey,i={isExtensible:()=>!1,deleteProperty:()=>!1,preventExtensions:()=>!0,ownKeys:t=>[...t.keys()].map((t=>`${t}`)),has(t,e){switch(e){case"getKey":case"getIndex":case"getValue":case"setValue":case"toArray":case"toJSON":case"inspect":case"constructor":case"isPrototypeOf":case"propertyIsEnumerable":case"toString":case"toLocaleString":case"valueOf":case"size":case"has":case"get":case"set":case"clear":case"delete":case"keys":case"values":case"entries":case"forEach":case"__proto__":case"__defineGetter__":case"__defineSetter__":case"hasOwnProperty":case"__lookupGetter__":case"__lookupSetter__":case Symbol.iterator:case Symbol.toStringTag:case lo:case ho:case _o:case po:case mo:return!0}return"number"!=typeof e||t.has(e)||(e=t.getKey(e)),t.has(e)},get(n,i,o){switch(i){case"getKey":case"getIndex":case"getValue":case"setValue":case"toArray":case"toJSON":case"inspect":case"constructor":case"isPrototypeOf":case"propertyIsEnumerable":case"toString":case"toLocaleString":case"valueOf":case"size":case"has":case"get":case"set":case"clear":case"delete":case"keys":case"values":case"entries":case"forEach":case"__proto__":case"__defineGetter__":case"__defineSetter__":case"hasOwnProperty":case"__lookupGetter__":case"__lookupSetter__":case Symbol.iterator:case Symbol.toStringTag:case lo:case ho:case _o:case po:case mo:return Reflect.get(n,i,o)}return"number"!=typeof i||t.call(o,i)||(i=r.call(o,i)),e.call(o,i)},set(e,i,o,a){switch(i){case lo:case ho:case _o:case po:return Reflect.set(e,i,o,a);case"getKey":case"getIndex":case"getValue":case"setValue":case"toArray":case"toJSON":case"inspect":case"constructor":case"isPrototypeOf":case"propertyIsEnumerable":case"toString":case"toLocaleString":case"valueOf":case"size":case"has":case"get":case"set":case"clear":case"delete":case"keys":case"values":case"entries":case"forEach":case"__proto__":case"__defineGetter__":case"__defineSetter__":case"hasOwnProperty":case"__lookupGetter__":case"__lookupSetter__":case Symbol.iterator:case Symbol.toStringTag:return!1}return"number"!=typeof i||t.call(a,i)||(i=r.call(a,i)),!!t.call(a,i)&&!!n.call(a,i,o)}}})(),In&&Sn(0);const xo=Array.isArray,Ao=(t,e)=>ko(t,e,[],0),So=(t,e)=>To(t,e,[],0);function Io(t,e,n,r){let i,o=r,a=-1;const s=e.length;for(;++ai.getChildAt(e))),n,o).length:i instanceof er&&(n[o++]=i);return n}const Eo=(t,[e,n],r)=>(t[0][r]=e,t[1][r]=n,t);function Bo(t,e){let n,r;switch(r=t.length){case 0:return e;case 1:if(n=e[0],!t[0])return e;if(xo(t[0]))return Bo(t[0],e);t[0]instanceof zi||t[0]instanceof er||t[0]instanceof di||([n,t]=Object.entries(t[0]).reduce(Eo,e));break;default:xo(n=t[r-1])?t=xo(t[0])?t[0]:t.slice(0,r-1):(t=xo(t[0])?t[0]:t,n=[])}let i=-1,o=-1,a=-1;const s=t.length;let u,c;const[f,l]=e;for(;++a`}get data(){return this._chunks[0]?this._chunks[0].data:null}get ArrayType(){return this._type.ArrayType}get numChildren(){return this._numChildren}get stride(){return this._chunks[0]?this._chunks[0].stride:1}get byteLength(){return this._chunks.reduce(((t,e)=>t+e.byteLength),0)}get nullCount(){let t=this._nullCount;return t<0&&(this._nullCount=t=this._chunks.reduce(((t,{nullCount:e})=>t+e),0)),t}get indices(){if(di.isDictionary(this._type)){if(!this._indices){const t=this._chunks;this._indices=1===t.length?t[0].indices:Mo.concat(...t.map((t=>t.indices)))}return this._indices}return null}get dictionary(){return di.isDictionary(this._type)?this._chunks[this._chunks.length-1].data.dictionary:null}[Symbol.iterator](){return new Oo(this._chunks)}clone(t=this._chunks){return new Mo(this._type,t)}concat(...t){return this.clone(Mo.flatten(this,...t))}slice(t,e){return wo(this,t,e,this._sliceInternal)}getChildAt(t){if(t<0||t>=this._numChildren)return null;const e=this._children||(this._children=[]);let n,r,i;return(n=e[t])?n:(r=(this._type.children||[])[t])&&(i=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),i.length>0)?e[t]=new Mo(r.type,i):null}search(t,e){const n=t,r=this._chunkOffsets;let i=r.length-1;if(n<0)return null;if(n>=r[i])return null;if(i<=1)return e?e(this,0,n):[0,n];let o=0,a=0,s=0;do{if(o+1===i)return e?e(this,o,n-a):[o,n-a];s=o+(i-o)/2|0,n>=r[s]?o=s:i=s}while(n=(a=r[o]));return null}isValid(t){return!!this.search(t,this.isValidInternal)}get(t){return this.search(t,this.getInternal)}set(t,e){this.search(t,(({chunks:t},n,r)=>t[n].set(r,e)))}indexOf(t,e){return e&&"number"==typeof e?this.search(e,((e,n,r)=>this.indexOfInternal(e,n,r,t))):this.indexOfInternal(this,0,Math.max(0,e||0),t)}toArray(){const{chunks:t}=this,e=t.length;let n=this._type.ArrayType;if(e<=0)return new n(0);if(e<=1)return t[0].toArray();let r=0;const i=new Array(e);for(let s=-1;++s=n)break;if(e>=u+s)continue;if(u>=e&&u+s<=n){r.push(t);continue}const c=Math.max(0,e-u),f=Math.min(n-u,s);r.push(t.slice(c,f))}return t.clone(r)}}const Do=(t,e,n)=>(e.set(t,n),n+t.length),jo=(t,e,n)=>{let r=n;for(let i=-1,o=t.length;++it>0))&&(e=e.clone({nullable:!0}));return new zo(e,i)}get field(){return this._field}get name(){return this._field.name}get nullable(){return this._field.nullable}get metadata(){return this._field.metadata}clone(t=this._chunks){return new zo(this._field,t)}getChildAt(t){if(t<0||t>=this.numChildren)return null;const e=this._children||(this._children=[]);let n,r,i;return(n=e[t])?n:(r=(this.type.children||[])[t])&&(i=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),i.length>0)?e[t]=new zo(r,i):null}}class Fo extends zo{constructor(t,e,n){super(t,[e],n),this._chunk=e}search(t,e){return e?e(this,0,t):[0,t]}isValid(t){return this._chunk.isValid(t)}get(t){return this._chunk.get(t)}set(t,e){this._chunk.set(t,e)}indexOf(t,e){return this._chunk.indexOf(t,e)}}var No=on.Long;const Lo=new class extends Pi{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return Dr.startNull(e),Dr.endNull(e)}visitInt(t,e){return Cr.startInt(e),Cr.addBitWidth(e,t.bitWidth),Cr.addIsSigned(e,t.isSigned),Cr.endInt(e)}visitFloat(t,e){return Rr.startFloatingPoint(e),Rr.addPrecision(e,t.precision),Rr.endFloatingPoint(e)}visitBinary(t,e){return Ur.startBinary(e),Ur.endBinary(e)}visitBool(t,e){return $r.startBool(e),$r.endBool(e)}visitUtf8(t,e){return Pr.startUtf8(e),Pr.endUtf8(e)}visitDecimal(t,e){return Gr.startDecimal(e),Gr.addScale(e,t.scale),Gr.addPrecision(e,t.precision),Gr.endDecimal(e)}visitDate(t,e){return Hr.startDate(e),Hr.addUnit(e,t.unit),Hr.endDate(e)}visitTime(t,e){return Yr.startTime(e),Yr.addUnit(e,t.unit),Yr.addBitWidth(e,t.bitWidth),Yr.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Wr.startTimestamp(e),Wr.addUnit(e,t.unit),void 0!==n&&Wr.addTimezone(e,n),Wr.endTimestamp(e)}visitInterval(t,e){return qr.startInterval(e),qr.addUnit(e,t.unit),qr.endInterval(e)}visitList(t,e){return zr.startList(e),zr.endList(e)}visitStruct(t,e){return jr.startStruct_(e),jr.endStruct_(e)}visitUnion(t,e){Lr.startTypeIdsVector(e,t.typeIds.length);const n=Lr.createTypeIdsVector(e,t.typeIds);return Lr.startUnion(e),Lr.addMode(e,t.mode),Lr.addTypeIds(e,n),Lr.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return Zr.startDictionaryEncoding(e),Zr.addId(e,new No(t.id,0)),Zr.addIsOrdered(e,t.isOrdered),void 0!==n&&Zr.addIndexType(e,n),Zr.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Vr.startFixedSizeBinary(e),Vr.addByteWidth(e,t.byteWidth),Vr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Fr.startFixedSizeList(e),Fr.addListSize(e,t.listSize),Fr.endFixedSizeList(e)}visitMap(t,e){return Nr.startMap(e),Nr.addKeysSorted(e,t.keysSorted),Nr.endMap(e)}};function Co(t){return new Xo(t.count,Po(t.columns),Uo(t.columns))}function Ro(t,e){return(t.children||[]).filter(Boolean).map((t=>Li.fromJSON(t,e)))}function Po(t){return(t||[]).reduce(((t,e)=>{return[...t,new Ko(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...Po(e.children)];var n}),[])}function Uo(t,e=[]){for(let n=-1,r=(t||[]).length;++nr),this._bodyLength="number"==typeof t?t:t.low}static fromJSON(t,e){const n=new qo(0,nr.V4,e);return n._createHeader=function(t,e){return()=>{switch(e){case kr.Schema:return Ni.fromJSON(t);case kr.RecordBatch:return Xo.fromJSON(t);case kr.DictionaryBatch:return Zo.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${kr[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new Wo(Gn(t));const e=ii.getRootAsMessage(t),n=e.bodyLength(),r=e.version(),i=e.headerType(),o=new qo(n,r,i);return o._createHeader=function(t,e){return()=>{switch(e){case kr.Schema:return Ni.decode(t.header(new Qr));case kr.RecordBatch:return Xo.decode(t.header(new ni),t.version());case kr.DictionaryBatch:return Zo.decode(t.header(new ri),t.version())}throw new Error(`Unrecognized Message type: { name: ${kr[e]}, type: ${e} }`)}}(e,i),o}static encode(t){const e=new Yo;let n=-1;return t.isSchema()?n=Ni.encode(e,t.header()):t.isRecordBatch()?n=Xo.encode(e,t.header()):t.isDictionaryBatch()&&(n=Zo.encode(e,t.header())),ii.startMessage(e),ii.addVersion(e,nr.V4),ii.addHeader(e,n),ii.addHeaderType(e,t.headerType),ii.addBodyLength(e,new Ho(t.bodyLength,0)),ii.finishMessageBuffer(e,ii.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Ni)return new qo(0,nr.V4,kr.Schema,t);if(t instanceof Xo)return new qo(e,nr.V4,kr.RecordBatch,t);if(t instanceof Zo)return new qo(e,nr.V4,kr.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===kr.Schema}isRecordBatch(){return this.headerType===kr.RecordBatch}isDictionaryBatch(){return this.headerType===kr.DictionaryBatch}}class Xo{constructor(t,e,n){this._nodes=e,this._buffers=n,this._length="number"==typeof t?t:t.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}}class Zo{constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id="number"==typeof e?e:e.low}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}}class Jo{constructor(t,e){this.offset="number"==typeof t?t:t.low,this.length="number"==typeof e?e:e.low}}class Ko{constructor(t,e){this.length="number"==typeof t?t:t.low,this.nullCount="number"==typeof e?e:e.low}}function Qo(t,e){const n=[];for(let r,i=-1,o=-1,a=t.childrenLength();++iLi.encode(t,e))),u=Jr.createChildrenVector(t,s),c=e.metadata&&e.metadata.size>0?Jr.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const r=t.createString(`${e}`),i=t.createString(`${n}`);return Xr.startKeyValue(t),Xr.addKey(t,r),Xr.addValue(t,i),Xr.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Jr.startField(t),Jr.addType(t,r),Jr.addTypeType(t,a),Jr.addChildren(t,u),Jr.addNullable(t,!!e.nullable),-1!==n&&Jr.addName(t,n);-1!==i&&Jr.addDictionary(t,i);-1!==c&&Jr.addCustomMetadata(t,c);return Jr.endField(t)},Li.decode=function(t,e){let n,r,i,o,a,s;e&&(s=t.dictionary())?e.has(n=s.id().low)?(o=(o=s.indexType())?ea(o):new _i,a=new ji(e.get(n),o,n,s.isOrdered()),r=new Li(t.name(),a,t.nullable(),ta(t))):(o=(o=s.indexType())?ea(o):new _i,e.set(n,i=na(t,Qo(t,e))),a=new ji(i,o,n,s.isOrdered()),r=new Li(t.name(),a,t.nullable(),ta(t))):(i=na(t,Qo(t,e)),r=new Li(t.name(),i,t.nullable(),ta(t)));return r||null},Li.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)?$o(r):new _i,s=new ji(e.get(n),r,n,o.isOrdered),i=new Li(t.name,s,t.nullable,Vo(t.customMetadata))):(r=(r=o.indexType)?$o(r):new _i,e.set(n,a=Go(t,Ro(t,e))),s=new ji(a,r,n,o.isOrdered),i=new Li(t.name,s,t.nullable,Vo(t.customMetadata))):(a=Go(t,Ro(t,e)),i=new Li(t.name,a,t.nullable,Vo(t.customMetadata))),i||null},Ni.encode=function(t,e){const n=e.fields.map((e=>Li.encode(t,e)));Qr.startFieldsVector(t,n.length);const r=Qr.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?Qr.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const r=t.createString(`${e}`),i=t.createString(`${n}`);return Xr.startKeyValue(t),Xr.addKey(t,r),Xr.addValue(t,i),Xr.endKeyValue(t)}))):-1;Qr.startSchema(t),Qr.addFields(t,r),Qr.addEndianness(t,ra?vr.Little:vr.Big),-1!==i&&Qr.addCustomMetadata(t,i);return Qr.endSchema(t)},Ni.decode=function(t,e=new Map){const n=function(t,e){const n=[];for(let r,i=-1,o=-1,a=t.fieldsLength();++iLi.fromJSON(t,e)))}(t,e),Vo(t.customMetadata),e)},Xo.encode=function(t,e){const n=e.nodes||[],r=e.buffers||[];ni.startNodesVector(t,n.length),n.slice().reverse().forEach((e=>Ko.encode(t,e)));const i=t.endVector();ni.startBuffersVector(t,r.length),r.slice().reverse().forEach((e=>Jo.encode(t,e)));const o=t.endVector();return ni.startRecordBatch(t),ni.addLength(t,new Ho(e.length,0)),ni.addNodes(t,i),ni.addBuffers(t,o),ni.endRecordBatch(t)},Xo.decode=function(t,e=nr.V4){return new Xo(t.length(),function(t){const e=[];for(let n,r=-1,i=-1,o=t.nodesLength();++r`Expected ${kr[t]} Message in stream, but was null or length 0.`,aa=t=>`Header pointer of flatbuffer-encoded ${kr[t]} Message is null or length 0.`,sa=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,ua=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class ca{constructor(t){this.source=t instanceof Ji?t:new Ji(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?vn: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(oa(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=Gn(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(oa(t));return e.value}readSchema(){const t=kr.Schema,e=this.readMessage(t),n=e&&e.header();if(!e||!n)throw new Error(aa(t));return n}}const da=4,ha="ARROW1",pa=new Uint8Array(ha.length);for(let um=0;umthis.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 va(t,e){return e instanceof t.constructor}function wa(t,e){return t===e||va(t,e)}function xa(t,e){return t===e||va(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Aa(t,e){return t===e||va(t,e)&&t.precision===e.precision}function Sa(t,e){return t===e||va(t,e)&&t.unit===e.unit}function Ia(t,e){return t===e||va(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function ka(t,e){return t===e||va(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function Ta(t,e){return t===e||va(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&Ba.compareManyFields(t.children,e.children)}function Ea(t,e){return t===e||va(t,e)&&t.unit===e.unit}ga.prototype.visitNull=wa,ga.prototype.visitBool=wa,ga.prototype.visitInt=xa,ga.prototype.visitInt8=xa,ga.prototype.visitInt16=xa,ga.prototype.visitInt32=xa,ga.prototype.visitInt64=xa,ga.prototype.visitUint8=xa,ga.prototype.visitUint16=xa,ga.prototype.visitUint32=xa,ga.prototype.visitUint64=xa,ga.prototype.visitFloat=Aa,ga.prototype.visitFloat16=Aa,ga.prototype.visitFloat32=Aa,ga.prototype.visitFloat64=Aa,ga.prototype.visitUtf8=wa,ga.prototype.visitBinary=wa,ga.prototype.visitFixedSizeBinary=function(t,e){return t===e||va(t,e)&&t.byteWidth===e.byteWidth},ga.prototype.visitDate=Sa,ga.prototype.visitDateDay=Sa,ga.prototype.visitDateMillisecond=Sa,ga.prototype.visitTimestamp=Ia,ga.prototype.visitTimestampSecond=Ia,ga.prototype.visitTimestampMillisecond=Ia,ga.prototype.visitTimestampMicrosecond=Ia,ga.prototype.visitTimestampNanosecond=Ia,ga.prototype.visitTime=ka,ga.prototype.visitTimeSecond=ka,ga.prototype.visitTimeMillisecond=ka,ga.prototype.visitTimeMicrosecond=ka,ga.prototype.visitTimeNanosecond=ka,ga.prototype.visitDecimal=wa,ga.prototype.visitList=function(t,e){return t===e||va(t,e)&&t.children.length===e.children.length&&Ba.compareManyFields(t.children,e.children)},ga.prototype.visitStruct=function(t,e){return t===e||va(t,e)&&t.children.length===e.children.length&&Ba.compareManyFields(t.children,e.children)},ga.prototype.visitUnion=Ta,ga.prototype.visitDenseUnion=Ta,ga.prototype.visitSparseUnion=Ta,ga.prototype.visitDictionary=function(t,e){return t===e||va(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Ba.visit(t.indices,e.indices)&&Ba.visit(t.dictionary,e.dictionary)},ga.prototype.visitInterval=Ea,ga.prototype.visitIntervalDayTime=Ea,ga.prototype.visitIntervalYearMonth=Ea,ga.prototype.visitFixedSizeList=function(t,e){return t===e||va(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Ba.compareManyFields(t.children,e.children)},ga.prototype.visitMap=function(t,e){return t===e||va(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Ba.compareManyFields(t.children,e.children)};const Ba=new ga;function Oa(t,e){return Ba.compareSchemas(t,e)}class Ma extends Pi{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...t){const e=new Ma,n=So(Za,t),[r=e]=e.visitMany(n);return r}visit(t){if(!di.isDictionary(t.type)){const{data:e,length:n,nullCount:r}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");di.isNull(t.type)||Da.call(this,r<=0?new Uint8Array(0):si(e.offset,n,e.nullBitmap)),this.nodes.push(new Ko(n,r))}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.indices)}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Da(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new Jo(this._byteLength,e)),this._byteLength+=e,this}function ja(t){return Da.call(this,t.values.subarray(0,t.length*t.stride))}function za(t){const{length:e,values:n,valueOffsets:r}=t,i=r[0],o=r[e],a=Math.min(o-i,n.byteLength-i);return Da.call(this,Xn(-r[0],e,r)),Da.call(this,n.subarray(i,i+a)),this}function Fa(t){const{length:e,valueOffsets:n}=t;return n&&Da.call(this,Xn(n[0],e,n)),this.visit(t.getChildAt(0))}function Na(t){return this.visitMany(t.type.children.map(((e,n)=>t.getChildAt(n))).filter(Boolean))[0]}Ma.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?Da.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Da.call(this,si(t.offset,t.length,e)):Da.call(this,ui(t))},Ma.prototype.visitInt=ja,Ma.prototype.visitFloat=ja,Ma.prototype.visitUtf8=za,Ma.prototype.visitBinary=za,Ma.prototype.visitFixedSizeBinary=ja,Ma.prototype.visitDate=ja,Ma.prototype.visitTimestamp=ja,Ma.prototype.visitTime=ja,Ma.prototype.visitDecimal=ja,Ma.prototype.visitList=Fa,Ma.prototype.visitStruct=Na,Ma.prototype.visitUnion=function(t){const{type:e,length:n,typeIds:r,valueOffsets:i}=t;if(Da.call(this,r),e.mode===ar.Sparse)return Na.call(this,t);if(e.mode===ar.Dense){if(t.offset<=0)return Da.call(this,i),Na.call(this,t);{const o=r.reduce(((t,e)=>Math.max(t,e)),r[0]),a=new Int32Array(o+1),s=new Int32Array(o+1).fill(-1),u=new Int32Array(n),c=Xn(-i[0],n,i);for(let t,e,i=-1;++ithis.writeAll(t))):Mn(t)?Ua(this,t):Pa(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){var n;return t===this._sink||t instanceof Zi?this._sink=t:(this._sink=new Zi,t&&(En(n=t)&&Tn(n.abort)&&Tn(n.getWriter)&&!(n instanceof xn))?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>En(t)&&Tn(t.end)&&Tn(t.write)&&kn(t.writable)&&!(t instanceof xn))(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,e&&Oa(e,this._schema)||(null===e?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(!this._sink)throw new Error("RecordBatchWriter is closed");if(null==t)return this.finish()&&void 0;if(t instanceof Xa&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Za&&!(e=t.schema))return this.finish()&&void 0;if(e&&!Oa(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Za?t instanceof Ja||this._writeRecordBatch(t):t instanceof Xa?this.writeAll(t.chunks):On(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,r=qo.encode(t),i=r.byteLength,o=this._writeLegacyIpcFormat?4:8,a=i+o+n&~n,s=a-i-o;return t.headerType===kr.RecordBatch?this._recordBatchBlocks.push(new Xi(a,t.bodyLength,this._position)):t.headerType===kr.DictionaryBatch&&this._dictionaryBlocks.push(new Xi(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),i>0&&this._write(r),this._writePadding(s)}_write(t){if(this._started){const e=Gn(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(qo.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(pa)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:r,buffers:i}=Ma.assemble(t),o=new Xo(t.length,n,r),a=qo.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(i)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:r,nodes:i,bufferRegions:o,buffers:a}=Ma.assemble(t),s=new Xo(t.length,i,o),u=new Zo(s,e,n),c=qo.from(u,r);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,r;for(let i=-1,o=t.length;++i0&&(this._write(e),(r=(n+7&-8)-n)>0&&this._writePadding(r));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let t=this._dictionaryDeltaOffsets.get(e)||0;if(0===t||(n=n.slice(t)).length>0){const r="chunks"in n?n.chunks:[n];for(const n of r)this._writeDictionaryBatch(n,e,t>0),t+=n.length}}return this}}class Ca extends La{static writeAll(t,e){const n=new Ca(e);return Bn(t)?t.then((t=>n.writeAll(t))):Mn(t)?Ua(n,t):Pa(n,t)}}class Ra extends La{static writeAll(t){const e=new Ra;return Bn(t)?t.then((t=>e.writeAll(t))):Mn(t)?Ua(e,t):Pa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const e=Wi.encode(new Wi(t,nr.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function Pa(t,e){let n=e;e instanceof Xa&&(n=e.chunks,t.reset(void 0,e.schema));for(const r of n)t.write(r);return t.finish()}function Ua(t,e){var n,r,i,o;return Ke(this,void 0,void 0,(function*(){try{for(n=rn(e);!(r=yield n.next()).done;){const e=r.value;t.write(e)}}catch(a){i={error:a}}finally{try{r&&!r.done&&(o=n.return)&&(yield o.call(n))}finally{if(i)throw i.error}}return t.finish()}))}const Va=new Uint8Array(0),$a=t=>[Va,Va,new Uint8Array(t),Va];function Ga(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,f=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,s=-1;++s0&&(r[o++]=[a,f.slice()]))}return[t=new Ni(n,t.metadata),r.map((e=>new Za(t,...e)))]}(t,e.map((t=>t instanceof Mo?t.chunks.map((t=>t.data)):[t.data])))}function Ha(t,e,n,r,i){let o,a,s=0,u=-1;const c=r.length,f=(e+63&-64)>>3;for(;++u=e?s===e?n[u]=o:(n[u]=o.slice(0,e),o=o.slice(e,s-e),i.numBatches=Math.max(i.numBatches,r[u].unshift(o))):((a=t[u]).nullable||(t[u]=a.clone({nullable:!0})),n[u]=o?o._changeLengthAndBackfillNullBitmap(e):zi.new(a.type,0,e,e,$a(f)));return n}class Ya extends er{constructor(t,e){super(),this._children=e,this.numChildren=t.childData.length,this._bindDataAccessors(this.data=t)}get type(){return this.data.type}get typeId(){return this.data.typeId}get length(){return this.data.length}get offset(){return this.data.offset}get stride(){return this.data.stride}get nullCount(){return this.data.nullCount}get byteLength(){return this.data.byteLength}get VectorName(){return`${Er[this.typeId]}Vector`}get ArrayType(){return this.type.ArrayType}get values(){return this.data.values}get typeIds(){return this.data.typeIds}get nullBitmap(){return this.data.nullBitmap}get valueOffsets(){return this.data.valueOffsets}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}clone(t,e=this._children){return er.new(t,e)}concat(...t){return Mo.concat(this,...t)}slice(t,e){return wo(this,t,e,this._sliceInternal)}isValid(t){if(this.nullCount>0){const e=this.offset+t;return 0!==(this.nullBitmap[e>>3]&1<=this.numChildren?null:(this._children||(this._children=[]))[t]||(this._children[t]=er.new(this.data.childData[t]))}toJSON(){return[...this]}_sliceInternal(t,e,n){return t.clone(t.data.slice(e,n-e),null)}_bindDataAccessors(t){}}Ya.prototype[Symbol.isConcatSpreadable]=!0;const Wa=Symbol.for("rowIndex");class qa extends Ya{bind(t){const e=this._row||(this._row=new yo(this)),n=Object.create(e);return n[Wa]=t,n}}class Xa extends Mo{constructor(...t){let e=null;t[0]instanceof Ni&&(e=t.shift());const n=Io(Za,t,[],0);if(!e&&!(e=n[0]&&n[0].schema))throw new TypeError("Table must be initialized with a Schema or at least one RecordBatch");n[0]||(n[0]=new Ja(e)),super(new ki(e.fields),n),this._schema=e,this._chunks=n}static empty(t=new Ni([])){return new Xa(t,[])}static from(t){if(!t)return Xa.empty();if("object"==typeof t){const e=On(t.values)?function(t){const{type:e}=t;if(e instanceof ki)return Xa.fromStruct(qa.from(t));return null}(t):Mn(t.values)?function(t){const{type:e}=t;if(e instanceof ki)return qa.from(t).then((t=>Xa.fromStruct(t)));return null}(t):null;if(null!==e)return e}let e=Qa.from(t);return Bn(e)?(()=>Ke(this,void 0,void 0,(function*(){return yield Xa.from(yield e)})))():e.isSync()&&(e=e.open())?e.schema?new Xa(e.schema,[...e]):Xa.empty():(t=>Ke(this,void 0,void 0,(function*(){var e,n;const r=yield t,i=r.schema,o=[];if(i){try{for(var a,s=rn(r);!(a=yield s.next()).done;){const t=a.value;o.push(t)}}catch(u){e={error:u}}finally{try{a&&!a.done&&(n=s.return)&&(yield n.call(s))}finally{if(e)throw e.error}}return new Xa(i,o)}return Xa.empty()})))(e.open())}static fromAsync(t){return Ke(this,void 0,void 0,(function*(){return yield Xa.from(t)}))}static fromStruct(t){return Xa.new(t.data.childData,t.type.children)}static new(...t){return new Xa(...(e=(t=>{const[e,n]=Bo(t,[[],[]]);return n.map(((t,n)=>t instanceof zo?zo.new(t.field.clone(e[n]),t):t instanceof er?zo.new(e[n],t):zo.new(e[n],[])))})(t),Ga(new Ni(e.map((({field:t})=>t))),e)));var e}get schema(){return this._schema}get length(){return this._length}get chunks(){return this._chunks}get numCols(){return this._numChildren}clone(t=this._chunks){return new Xa(this._schema,t)}getColumn(t){return this.getColumnAt(this.getColumnIndex(t))}getColumnAt(t){return this.getChildAt(t)}getColumnIndex(t){return this._schema.fields.findIndex((e=>e.name===t))}getChildAt(t){if(t<0||t>=this.numChildren)return null;let e,n;const r=this._schema.fields,i=this._children||(this._children=[]);if(n=i[t])return n;if(e=r[t]){const n=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t));if(n.length>0)return i[t]=new zo(e,n)}return null}serialize(t="binary",e=!0){return(e?Ca:Ra).writeAll(this).toUint8Array(!0)}count(){return this._length}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);return new Xa(e,this._chunks.map((({length:n,data:{childData:r}})=>new Za(e,n,t.map((t=>r[t])).filter(Boolean)))))}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(((e,n,i,o=r[n])=>void 0===o?this.getColumnAt(n):t.getColumnAt(o))),...n.map((e=>t.getColumnAt(e)))].filter(Boolean);return new Xa(...Ga(i,o))}}class Za extends qa{constructor(...t){let e;const n=t[0];let r;if(t[1]instanceof zi)[,e,r]=t;else{const r=n.fields,[,i,o]=t;e=zi.Struct(new ki(r),0,i,0,null,o)}super(e,r),this._schema=n}static from(t){return On(t.values),Xa.from(t)}static new(...t){const[e,n]=(t=>Bo(t,[[],[]]))(t),r=n.filter((t=>t instanceof er));return new Za(...function(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){let r,i,o=-1;const a=e.length,s=[...t.fields],u=[],c=(n+63&-64)>>3;for(;++ot.data))))}clone(t,e=this._children){return new Za(this._schema,t,e)}concat(...t){const e=this._schema,n=Mo.flatten(this,...t);return new Xa(e,n.map((({data:t})=>new Za(e,t))))}get schema(){return this._schema}get numCols(){return this._schema.fields.length}get dictionaries(){return this._dictionaries||(this._dictionaries=Ka.collect(this))}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=t.map((t=>this.data.childData[t])).filter(Boolean);return new Za(e,this.length,n)}}class Ja extends Za{constructor(t){super(t,0,t.fields.map((t=>zi.new(t.type,0,0,0))))}}class Ka extends Pi{constructor(){super(...arguments),this.dictionaries=new Map}static collect(t){return(new Ka).visit(t.data,new ki(t.schema.fields)).dictionaries}visit(t,e){return di.isDictionary(e)?this.visitDictionary(t,e):(t.childData.forEach(((t,n)=>this.visit(t,e.children[n].type))),this)}visitDictionary(t,e){const n=t.dictionary;return n&&n.length>0&&this.dictionaries.set(e.id,n),this}}class Qa extends xn{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const e=this._impl.open(t);return Bn(e)?e.then((()=>this)):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 Zn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Zn.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 Qa?t:Dn(t)?function(t){return new ts(new cs(t))}(t):zn(t)?function(t){return Ke(this,void 0,void 0,(function*(){const{size:e}=yield t.stat(),n=new no(t,e);return e>=ya&&_a(yield n.readAt(0,ma+7&-8))?new rs(new us(n)):new es(new as(n))}))}(t):Bn(t)?(()=>Ke(this,void 0,void 0,(function*(){return yield Qa.from(yield t)})))():Fn(t)||Nn(t)||Ln(t)||Mn(t)?function(t){return Ke(this,void 0,void 0,(function*(){const e=yield t.peek(ma+7&-8);return e&&e.byteLength>=4?_a(e)?new ns(new ss(yield t.read())):new es(new as(t)):new es(new as(function(){return en(this,arguments,(function*(){}))}()))}))}(new Ki(t)):function(t){const e=t.peek(ma+7&-8);return e&&e.byteLength>=4?_a(e)?new ns(new ss(t.read())):new ts(new os(t)):new ts(new os(function*(){}()))}(new Ji(t))}static readAll(t){return t instanceof Qa?t.isSync()?ls(t):ds(t):Dn(t)||ArrayBuffer.isView(t)||On(t)||jn(t)?ls(t):ds(t)}}class ts extends Qa{constructor(t){super(t),this._impl=t}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return en(this,arguments,(function*(){yield tn(yield*nn(rn(this[Symbol.iterator]())))}))}}class es extends Qa{constructor(t){super(t),this._impl=t}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class ns extends ts{constructor(t){super(t),this._impl=t}}class rs extends es{constructor(t){super(t),this._impl=t}}class is{constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}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){return new Za(this.schema,t.length,this._loadVectors(t,e,this.schema.fields))}_loadDictionaryBatch(t,e){const{id:n,isDelta:r,data:i}=t,{dictionaries:o,schema:a}=this,s=o.get(n);if(r||!s){const t=a.dictionaries.get(n);return s&&r?s.concat(er.new(this._loadVectors(i,e,[t])[0])):er.new(this._loadVectors(i,e,[t])[0])}return s}_loadVectors(t,e,n){return new co(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}}class os extends is{constructor(t,e){super(e),this._reader=Dn(t)?new la(this._handle=t):new ca(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=fs(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):vn}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):vn}next(){if(this.closed)return vn;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 Ja(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class as extends is{constructor(t,e){super(e),this._reader=new fa(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Ke(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 Ke(this,void 0,void 0,(function*(){return this.closed||(this.autoDestroy=fs(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this}))}throw(t){return Ke(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):vn}))}return(t){return Ke(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):vn}))}next(){return Ke(this,void 0,void 0,(function*(){if(this.closed)return vn;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 Ja(this.schema)}):yield this.return()}))}_readNextMessageAndValidate(t){return Ke(this,void 0,void 0,(function*(){return yield this._reader.readMessage(t)}))}}class ss extends os{constructor(t,e){super(t instanceof eo?t:new eo(t),e)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}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){if(this.closed)return null;this._footer||this.open();const e=this._footer&&this._footer.getRecordBatch(t);if(e&&this._handle.seek(e.offset)){const t=this._reader.readMessage(kr.RecordBatch);if(t&&t.isRecordBatch()){const e=t.header(),n=this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,n)}}return null}_readDictionaryBatch(t){const e=this._footer&&this._footer.getDictionaryBatch(t);if(e&&this._handle.seek(e.offset)){const t=this._reader.readMessage(kr.DictionaryBatch);if(t&&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-ba,n=t.readInt32(e),r=t.readAt(e-n,n);return Wi.decode(r)}_readNextMessageAndValidate(t){if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Ke(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){return Ke(this,void 0,void 0,(function*(){if(this.closed)return null;this._footer||(yield this.open());const e=this._footer&&this._footer.getRecordBatch(t);if(e&&(yield this._handle.seek(e.offset))){const t=yield this._reader.readMessage(kr.RecordBatch);if(t&&t.isRecordBatch()){const e=t.header(),n=yield this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,n)}}return null}))}_readDictionaryBatch(t){return Ke(this,void 0,void 0,(function*(){const e=this._footer&&this._footer.getDictionaryBatch(t);if(e&&(yield this._handle.seek(e.offset))){const t=yield this._reader.readMessage(kr.DictionaryBatch);if(t&&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 Ke(this,void 0,void 0,(function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-ba,n=yield t.readInt32(e),r=yield t.readAt(e-n,n);return Wi.decode(r)}))}_readNextMessageAndValidate(t){return Ke(this,void 0,void 0,(function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex-1},Z.prototype.set=function(t,e){var n=this.__data__,r=nt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},J.prototype.clear=function(){this.size=0,this.__data__={hash:new X,map:new(Y||Z),string:new X}},J.prototype.delete=function(t){var e=dt(this,t).delete(t);return this.size-=e?1:0,e},J.prototype.get=function(t){return dt(this,t).get(t)},J.prototype.has=function(t){return dt(this,t).has(t)},J.prototype.set=function(t,e){var n=dt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},K.prototype.clear=function(){this.__data__=new Z,this.size=0},K.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},K.prototype.get=function(t){return this.__data__.get(t)},K.prototype.has=function(t){return this.__data__.has(t)},K.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Z){var r=n.__data__;if(!Y||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new J(r)}return n.set(t,e),this.size=n.size,this};var it,ot=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var s=o[it?a:++r];if(!1===e(i[s],s,i))break}return t};function at(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":U&&U in Object(t)?function(t){var e=E.call(t,U),n=t[U];try{t[U]=void 0;var r=!0}catch(o){}var i=O.call(t);r&&(e?t[U]=n:delete t[U]);return i}(t):function(t){return O.call(t)}(t)}function st(t){return kt(t)&&at(t)==i}function ut(t){return!(!It(t)||function(t){return!!B&&B in t}(t))&&(At(t)?D:s).test(function(t){if(null!=t){try{return T.call(t)}catch(e){}try{return t+""}catch(e){}}return""}(t))}function ct(t){if(!It(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=_t(t),n=[];for(var r in t)("constructor"!=r||!e&&E.call(t,r))&&n.push(r);return n}function ft(t,e,n,r,i){t!==e&&ot(e,(function(o,s){if(i||(i=new K),It(o))!function(t,e,n,r,i,o,s){var u=mt(t,n),c=mt(e,n),f=s.get(c);if(f)return void tt(t,n,f);var l=o?o(u,c,n+"",t,e,s):void 0,d=void 0===l;if(d){var h=vt(c),p=!h&&xt(c),_=!h&&!p&&Tt(c);l=c,h||p||_?vt(u)?l=u:kt(v=u)&&wt(v)?l=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n-1&&t%1==0&&t0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(V?function(t,e){return V(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Mt);function yt(t,e){return t===e||t!=t&&e!=e}var gt=st(function(){return arguments}())?st:function(t){return kt(t)&&E.call(t,"callee")&&!R.call(t,"callee")},vt=Array.isArray;function wt(t){return null!=t&&St(t.length)&&!At(t)}var xt=$||function(){return!1};function At(t){if(!It(t))return!1;var e=at(t);return e==o||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function St(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}function It(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function kt(t){return null!=t&&"object"==typeof t}var Tt=y?function(t){return function(e){return t(e)}}(y):function(t){return kt(t)&&St(t.length)&&!!c[at(t)]};function Et(t){return wt(t)?Q(t,!0):ct(t)}var Bt,Ot=(Bt=function(t,e,n){ft(t,e,n)},lt((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=Bt.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!It(n))return!1;var r=typeof e;return!!("number"==r?wt(n)&&pt(e,n.length):"string"==r&&e in n)&&yt(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;--ys}()}finally{ys=0,function(){var t,e,n=_s,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:_s=e);ms=t,Ds(r)}(),xs=0}}function Ms(){var t=Ss.now(),e=t-ws;e>1e3&&(As-=e,ws=t)}function Ds(t){ys||(gs&&(gs=clearTimeout(gs)),t-xs>24?(t<1/0&&(gs=setTimeout(Os,t-Ss.now()-As)),vs&&(vs=clearInterval(vs))):(vs||(ws=Ss.now(),vs=setInterval(Ms,1e3)),ys=1,Is(Os)))}function js(t,e,n){var r=new Es;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Es.prototype=Bs.prototype={constructor:Es,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ks():+n)+(null==e?0:+e),this._next||ms===this||(ms?ms._next=this:_s=this,ms=this),this._call=t,this._time=n,Ds()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ds())}};var zs={value:()=>{}};function Fs(){for(var t,e=0,n=arguments.length,r={};e=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Cs(t,e){for(var n,r=0,i=t.length;r0)for(var n,r,i=new Array(n),o=0;o=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Us.hasOwnProperty(e)?{space:Us[e],local:t}:t}function $s(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ps&&e.documentElement.namespaceURI===Ps?e.createElement(t):e.createElementNS(n,t)}}function Gs(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Hs(t){var e=Vs(t);return(e.local?Gs:$s)(e)}function Ys(){}function Ws(t){return null==t?Ys:function(){return this.querySelector(t)}}function qs(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Xs(){return[]}function Zs(t){return function(e){return e.matches(t)}}var Js=Array.prototype.find;function Ks(){return this.firstElementChild}var Qs=Array.prototype.filter;function tu(){return this.children}function eu(t){return new Array(t.length)}function nu(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ru(t){return function(){return t}}function iu(t,e,n,r,i,o){for(var a,s=0,u=e.length,c=o.length;se?1:t>=e?0:NaN}function uu(t){return function(){this.removeAttribute(t)}}function cu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function fu(t,e){return function(){this.setAttribute(t,e)}}function lu(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function du(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function hu(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 pu(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function _u(t){return function(){this.style.removeProperty(t)}}function mu(t,e,n){return function(){this.style.setProperty(t,e,n)}}function bu(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function yu(t,e){return t.style.getPropertyValue(e)||pu(t).getComputedStyle(t,null).getPropertyValue(e)}function gu(t){return function(){delete this[t]}}function vu(t,e){return function(){this[t]=e}}function wu(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function xu(t){return t.trim().split(/^|\s+/)}function Au(t){return t.classList||new Su(t)}function Su(t){this._node=t,this._names=xu(t.getAttribute("class")||"")}function Iu(t,e){for(var n=Au(t),r=-1,i=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function $u(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=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 qu=[null];function Xu(t,e){this._groups=t,this._parents=e}function Zu(t){return"string"==typeof t?new Xu([[document.querySelector(t)]],[document.documentElement]):new Xu([[t]],qu)}function Ju(t){t.preventDefault(),t.stopImmediatePropagation()}function Ku(t){var e=t.document.documentElement,n=Zu(t).on("dragstart.drag",Ju,!0);"onselectstart"in e?n.on("selectstart.drag",Ju,!0):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Qu(t,e){var n=t.document.documentElement,r=Zu(t).on("dragstart.drag",null);e&&(r.on("click.drag",Ju,!0),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}Xu.prototype={constructor:Xu,select:function(t){"function"!=typeof t&&(t=Ws(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=w&&(w=v+1);!(g=m[w])&&++w=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=su);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?_u:"function"==typeof e?bu:mu)(t,e,null==n?"":n)):yu(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?gu:"function"==typeof e?wu:vu)(t,e)):this.node()[t]},classed:function(t,e){var n=xu(t+"");if(arguments.length<2){for(var r=Au(this.node()),i=-1,o=n.length;++i=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),rc.hasOwnProperty(e)?{space:rc[e],local:t}:t}function oc(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===nc&&e.documentElement.namespaceURI===nc?e.createElement(t):e.createElementNS(n,t)}}function ac(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function sc(t){var e=ic(t);return(e.local?ac:oc)(e)}function uc(){}function cc(t){return null==t?uc:function(){return this.querySelector(t)}}function fc(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function lc(){return[]}function dc(t){return function(e){return e.matches(t)}}var hc=Array.prototype.find;function pc(){return this.firstElementChild}var _c=Array.prototype.filter;function mc(){return this.children}function bc(t){return new Array(t.length)}function yc(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function gc(t){return function(){return t}}function vc(t,e,n,r,i,o){for(var a,s=0,u=e.length,c=o.length;se?1:t>=e?0:NaN}function Sc(t){return function(){this.removeAttribute(t)}}function Ic(t){return function(){this.removeAttributeNS(t.space,t.local)}}function kc(t,e){return function(){this.setAttribute(t,e)}}function Tc(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Ec(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Bc(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 Oc(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Mc(t){return function(){this.style.removeProperty(t)}}function Dc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function jc(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function zc(t,e){return t.style.getPropertyValue(e)||Oc(t).getComputedStyle(t,null).getPropertyValue(e)}function Fc(t){return function(){delete this[t]}}function Nc(t,e){return function(){this[t]=e}}function Lc(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Cc(t){return t.trim().split(/^|\s+/)}function Rc(t){return t.classList||new Pc(t)}function Pc(t){this._node=t,this._names=Cc(t.getAttribute("class")||"")}function Uc(t,e){for(var n=Rc(t),r=-1,i=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function af(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=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 lf=[null];function df(t,e){this._groups=t,this._parents=e}function hf(t){return"string"==typeof t?new df([[document.querySelector(t)]],[document.documentElement]):new df([[t]],lf)}function pf(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]}df.prototype={constructor:df,select:function(t){"function"!=typeof t&&(t=cc(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=w&&(w=v+1);!(g=m[w])&&++w=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=Ac);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?Mc:"function"==typeof e?jc:Dc)(t,e,null==n?"":n)):zc(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Fc:"function"==typeof e?Lc:Nc)(t,e)):this.node()[t]},classed:function(t,e){var n=Cc(t+"");if(arguments.length<2){for(var r=Rc(this.node()),i=-1,o=n.length;++i0)throw new Error("too late; already scheduled");return n}function gf(t,e){var n=vf(t,e);if(n.state>3)throw new Error("too late; already running");return n}function vf(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function wf(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>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}function xf(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Af(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Sf(){}var If=.7,kf=1/If,Tf="\\s*([+-]?\\d+)\\s*",Ef="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Bf="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Of=/^#([0-9a-f]{3,8})$/,Mf=new RegExp("^rgb\\("+[Tf,Tf,Tf]+"\\)$"),Df=new RegExp("^rgb\\("+[Bf,Bf,Bf]+"\\)$"),jf=new RegExp("^rgba\\("+[Tf,Tf,Tf,Ef]+"\\)$"),zf=new RegExp("^rgba\\("+[Bf,Bf,Bf,Ef]+"\\)$"),Ff=new RegExp("^hsl\\("+[Ef,Bf,Bf]+"\\)$"),Nf=new RegExp("^hsla\\("+[Ef,Bf,Bf,Ef]+"\\)$"),Lf={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 Cf(){return this.rgb().formatHex()}function Rf(){return this.rgb().formatRgb()}function Pf(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Of.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Uf(e):3===n?new Hf(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Vf(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Vf(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=Mf.exec(t))?new Hf(e[1],e[2],e[3],1):(e=Df.exec(t))?new Hf(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=jf.exec(t))?Vf(e[1],e[2],e[3],e[4]):(e=zf.exec(t))?Vf(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Ff.exec(t))?Xf(e[1],e[2]/100,e[3]/100,1):(e=Nf.exec(t))?Xf(e[1],e[2]/100,e[3]/100,e[4]):Lf.hasOwnProperty(t)?Uf(Lf[t]):"transparent"===t?new Hf(NaN,NaN,NaN,0):null}function Uf(t){return new Hf(t>>16&255,t>>8&255,255&t,1)}function Vf(t,e,n,r){return r<=0&&(t=e=n=NaN),new Hf(t,e,n,r)}function $f(t){return t instanceof Sf||(t=Pf(t)),t?new Hf((t=t.rgb()).r,t.g,t.b,t.opacity):new Hf}function Gf(t,e,n,r){return 1===arguments.length?$f(t):new Hf(t,e,n,null==r?1:r)}function Hf(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Yf(){return"#"+qf(this.r)+qf(this.g)+qf(this.b)}function Wf(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function qf(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Xf(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Jf(t,e,n,r)}function Zf(t){if(t instanceof Jf)return new Jf(t.h,t.s,t.l,t.opacity);if(t instanceof Sf||(t=Pf(t)),!t)return new Jf;if(t instanceof Jf)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 Jf(a,s,u,t.opacity)}function Jf(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Kf(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}xf(Sf,Pf,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:Cf,formatHex:Cf,formatHsl:function(){return Zf(this).formatHsl()},formatRgb:Rf,toString:Rf}),xf(Hf,Gf,Af(Sf,{brighter:function(t){return t=null==t?kf:Math.pow(kf,t),new Hf(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?If:Math.pow(If,t),new Hf(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){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:Yf,formatHex:Yf,formatRgb:Wf,toString:Wf})),xf(Jf,(function(t,e,n,r){return 1===arguments.length?Zf(t):new Jf(t,e,n,null==r?1:r)}),Af(Sf,{brighter:function(t){return t=null==t?kf:Math.pow(kf,t),new Jf(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?If:Math.pow(If,t),new Jf(this.h,this.s,this.l*t,this.opacity)},rgb:function(){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 Hf(Kf(t>=240?t-240:t+120,i,r),Kf(t,i,r),Kf(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));const Qf=Math.PI/180,tl=180/Math.PI;var el=-.14861,nl=1.78277,rl=-.29227,il=-.90649,ol=1.97294,al=ol*il,sl=ol*nl,ul=nl*rl-il*el;function cl(t){if(t instanceof ll)return new ll(t.h,t.s,t.l,t.opacity);t instanceof Hf||(t=$f(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(ul*r+al*e-sl*n)/(ul+al-sl),o=r-i,a=(ol*(n-i)-rl*o)/il,s=Math.sqrt(a*a+o*o)/(ol*i*(1-i)),u=s?Math.atan2(a,o)*tl-120:NaN;return new ll(u<0?u+360:u,s,i,t.opacity)}function fl(t,e,n,r){return 1===arguments.length?cl(t):new ll(t,e,n,null==r?1:r)}function ll(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}xf(ll,fl,Af(Sf,{brighter:function(t){return t=null==t?kf:Math.pow(kf,t),new ll(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?If:Math.pow(If,t),new ll(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*Qf,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new Hf(255*(e+n*(el*r+nl*i)),255*(e+n*(rl*r+il*i)),255*(e+n*(ol*r)),this.opacity)}}));var dl=t=>()=>t;function hl(t,e){return function(n){return t+n*e}}function pl(t){return 1==(t=+t)?_l: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):dl(isNaN(e)?n:e)}}function _l(t,e){var n=e-t;return n?hl(t,n):dl(isNaN(t)?e:t)}var ml=function t(e){var n=pl(e);function r(t,e){var r=n((t=Gf(t)).r,(e=Gf(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=_l(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 bl,yl=(bl=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:xl(n,r)})),o=Il.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:xl(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:xl(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:xl(t,n)},{i:s-2,x:xl(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):dl(isNaN(t)?e:t)}));var Ll=Nl(_l);function Cl(t,e){var n,r;return function(){var i=gf(this,t),o=i.tween;if(o!==n)for(var a=0,s=(r=n=o).length;a=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?yf:gf;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}var id=ht.prototype.constructor;function od(t){return function(){this.style.removeProperty(t)}}function ad(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function sd(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&ad(t,o,n)),r}return o._value=e,o}function ud(t){return function(e){this.textContent=t.call(this,e)}}function cd(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&ud(r)),e}return r._value=t,r}var fd=0;function ld(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function dd(){return++fd}var hd=ht.prototype;ld.prototype={constructor:ld,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=s(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>t;function bd(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 yd(t,e,n){this.k=t,this.x=e,this.y=n}yd.prototype={constructor:yd,scale:function(t){return 1===t?this:new yd(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new yd(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 gd=new yd(1,0,0);function vd(t){t.stopImmediatePropagation()}function wd(t){t.preventDefault(),t.stopImmediatePropagation()}function xd(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Ad(){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 Sd(){return this.__zoom||gd}function Id(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function kd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Td(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 Ed(t,e){return te?1:t>=e?0:NaN}function Bd(t){let e=t,n=t;function r(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r>>1;n(t[o],e)<0?r=o+1:i=o}return r}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>Ed(t(e),n)}(t)),{left:r,center:function(t,n,i,o){null==i&&(i=0),null==o&&(o=t.length);const a=r(t,n,i,o-1);return a>i&&e(t[a-1],n)>-e(t[a],n)?a-1:a},right:function(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r>>1;n(t[o],e)>0?i=o:r=o+1}return r}}}const Od=Bd(Ed).right;Bd((function(t){return null===t?NaN:+t})).center;var Md=Math.sqrt(50),Dd=Math.sqrt(10),jd=Math.sqrt(2);function zd(t,e,n){var r,i,o,a,s=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((r=e0){let n=Math.round(t/a),r=Math.round(e/a);for(n*ae&&--r,o=new Array(i=r-n+1);++se&&--r,o=new Array(i=r-n+1);++s=0?(o>=Md?10:o>=Dd?5:o>=jd?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=Md?10:o>=Dd?5:o>=jd?2:1)}function Nd(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Ld(t){return+t}var Cd=[0,1];function Rd(t){return t}function Pd(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:(n=isNaN(e)?NaN:.5,function(){return n});var n}function Ud(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?Vd:Ud,i=o=null,l}function l(e){return null==e||isNaN(e=+e)?n:(i||(i=r(a.map(t),s,u)))(t(c(e)))}return l.invert=function(n){return c(e((o||(o=r(s,a.map(t),xl)))(n)))},l.domain=function(t){return arguments.length?(a=Array.from(t,Ld),f()):a.slice()},l.range=function(t){return arguments.length?(s=Array.from(t),f()):s.slice()},l.rangeRound=function(t){return s=Array.from(t),u=El,f()},l.clamp=function(t){return arguments.length?(c=!!t||Rd,f()):c!==Rd},l.interpolate=function(t){return arguments.length?(u=t,f()):u},l.unknown=function(t){return arguments.length?(n=t,l):n},function(n,r){return t=n,e=r,f()}}function Hd(){return Gd()(Rd,Rd)}function Yd(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 Wd(t){return(t=Yd(Math.abs(t)))?t[1]:NaN}var qd,Xd=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zd(t){if(!(e=Xd.exec(t)))throw new Error("invalid format: "+t);var e;return new Jd({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 Jd(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 Kd(t,e){var n=Yd(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")}Zd.prototype=Jd.prototype,Jd.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Qd={"%":(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)=>Kd(100*t,e),r:Kd,s:function(t,e){var n=Yd(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(qd=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")+Yd(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function th(t){return t}var eh,nh,rh,ih=Array.prototype.map,oh=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ah(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?th:(e=ih.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?th:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(ih.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",f=void 0===t.nan?"NaN":t.nan+"";function l(t){var e=(t=Zd(t)).fill,n=t.align,l=t.sign,d=t.symbol,h=t.zero,p=t.width,_=t.comma,m=t.precision,b=t.trim,y=t.type;"n"===y?(_=!0,y="g"):Qd[y]||(void 0===m&&(m=12),b=!0,y="g"),(h||"0"===e&&"="===n)&&(h=!0,e="0",n="=");var g="$"===d?i:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",v="$"===d?o:/[%p]/.test(y)?u:"",w=Qd[y],x=/[defgprs%]/.test(y);function A(t){var i,o,u,d=g,A=v;if("c"===y)A=w(t)+A,t="";else{var S=(t=+t)<0||1/t<0;if(t=isNaN(t)?f: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&&"+"!==l&&(S=!1),d=(S?"("===l?l:c:"-"===l||"("===l?"":l)+d,A=("s"===y?oh[8+qd/3]:"")+A+(S&&"("===l?")":""),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}}_&&!h&&(t=r(t,1/0));var I=d.length+t.length+A.length,k=I>1)+d+t+A+k.slice(I);break;default:t=k+d+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:l,formatPrefix:function(t,e){var n=l(((t=Zd(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Wd(e)/3))),i=Math.pow(10,-r),o=oh[8+r/3];return function(t){return n(i*t)+o}}}}function sh(t,e,n,r){var i,o=function(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=Md?i*=10:o>=Dd?i*=5:o>=jd&&(i*=2),e0;){if((i=Fd(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 ch(){var t=Hd();return t.copy=function(){return $d(t,ch())},Nd.apply(t,arguments),uh(t)}function fh(t){return Math.log(t)}function lh(t){return Math.exp(t)}function dh(t){return-Math.log(-t)}function hh(t){return-Math.exp(-t)}function ph(t){return isFinite(t)?+("1e"+t):t<0?0:t}function _h(t){return function(e){return-t(-e)}}function mh(t){var e,n,r=t(fh,lh),i=r.domain,o=10;function a(){return e=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),function(e){return Math.log(e)/t})}(o),n=function(t){return 10===t?ph:t===Math.E?Math.exp:function(e){return Math.pow(t,e)}}(o),i()[0]<0?(e=_h(e),n=_h(n),t(dh,hh)):t(fh,lh),r}return r.base=function(t){return arguments.length?(o=+t,a()):o},r.domain=function(t){return arguments.length?(i(t),a()):i()},r.ticks=function(t){var r,a=i(),s=a[0],u=a[a.length-1];(r=u0){for(;d<=h;++d)for(f=1,c=n(d);fu)break;_.push(l)}}else for(;d<=h;++d)for(f=o-1,c=n(d);f>=1;--f)if(!((l=c*f)u)break;_.push(l)}2*_.lengtht.append("div").attr("class","note").style("top",0).style("left",0).style("position","fixed").style("z-index",100).style("border-radius","15px").style("padding","10px").style("background","rgba(255, 220, 225, 0.8)")),(t=>t),(t=>t.html((t=>Sh(t.data))))).html((t=>Sh(t.data))).style("transform",(t=>`translate(${+t.x+t.dx}px, ${+t.y+t.dy}px)`))}zoom_to_bbox(t,e=4){const n=this.scales(),[r,i]=t.x.map(n.x),[o,a]=t.y.map(n.y),{canvas:s,zoomer:u,width:c,height:f}=this,l=gd.translate(c/2,f/2).scale(.9/Math.max((i-r)/c,(a-o)/f)).translate(-(r+i)/2,-(o+a)/2);s.transition().duration(1e3*e).call(u.transform,l)}initialize_zoom(){const{width:t,height:e,canvas:n}=this;this.transform=gd;const r=function(){var t,e,n,r=xd,i=Ad,o=Td,a=Id,s=kd,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],f=250,l=ec,d=Fs("start","zoom","end"),h=500,p=0,_=10;function m(t){t.property("__zoom",Sd).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",k).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new yd(e,t.x,t.y)}function y(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new yd(t.k,r,i)}function g(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function v(t,e,n,r){t.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var t=this,o=arguments,a=w(t,o).event(r),s=i.apply(t,o),u=null==n?g(s):"function"==typeof n?n.apply(t,o):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),f=t.__zoom,d="function"==typeof e?e.apply(t,o):e,h=l(f.invert(u).concat(c/f.k),d.invert(u).concat(c/d.k));return function(t){if(1===t)t=d;else{var e=h(t),n=c/e[2];t=new yd(n,u[0]-e[0]*n,u[1]-e[1]*n)}a.zoom(null,t)}}))}function w(t,e,n){return!n&&t.__zooming||new x(t,e)}function x(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function A(t,...e){if(r.apply(this,arguments)){var n=w(this,e).event(t),i=this.__zoom,s=Math.max(u[0],Math.min(u[1],i.k*Math.pow(2,a.apply(this,arguments)))),f=pf(t);if(n.wheel)n.mouse[0][0]===f[0]&&n.mouse[0][1]===f[1]||(n.mouse[1]=i.invert(n.mouse[0]=f)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[f,i.invert(f)],wf(this),n.start()}wd(t),n.wheel=setTimeout(l,150),n.zoom("mouse",o(y(b(i,s),n.mouse[0],n.mouse[1]),n.extent,c))}function l(){n.wheel=null,n.end()}}function S(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,a=w(this,e,!0).event(t),s=hf(t.view).on("mousemove.zoom",d,!0).on("mouseup.zoom",h,!0),u=pf(t,i),f=t.clientX,l=t.clientY;Ku(t.view),vd(t),a.mouse=[u,this.__zoom.invert(u)],wf(this),a.start()}function d(t){if(wd(t),!a.moved){var e=t.clientX-f,n=t.clientY-l;a.moved=e*e+n*n>p}a.event(t).zoom("mouse",o(y(a.that.__zoom,a.mouse[0]=pf(t,i),a.mouse[1]),a.extent,c))}function h(t){s.on("mousemove.zoom mouseup.zoom",null),Qu(t.view,a.moved),wd(t),a.event(t).end()}}function I(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=pf(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),l=o(y(b(n,u),a,s),i.apply(this,e),c);wd(t),f>0?hf(this).transition().duration(f).call(v,l,a,t):hf(this).call(m.transform,l,a,t)}}function k(n,...i){if(r.apply(this,arguments)){var o,a,s,u,c=n.touches,f=c.length,l=w(this,i,n.changedTouches.length===f).event(n);for(vd(n),a=0;a{this.transform=t.transform,this.restart_timer(1e4)}));n.call(r),this.add_mouseover(),this.zoomer=r}add_mouseover(){let t=0;const e=pt("#deepscatter-svg").append("g").attr("class","label"),n=this.renderers.get("regl"),r=n.aes.x.current,i=n.aes.y.current;this.canvas.on("mousemove",(o=>{if(Date.now()-t<1e3/30)return;t=Date.now();const a=n.color_pick(o.x,o.y),s=a?[a]:[],u=s[0],c=u?[{x:o.x,y:o.y,data:u,dx:0,dy:30}]:[],{x_:f,y_:l}=this.scales();c.length&&this.html_annotation(c);e.selectAll("g").data(s).join("g").attr("transform",(t=>`translate(\n ${f(r.value_for(t))},\n ${l(i.value_for(t))}\n )`)).on("click",((t,e)=>{console.log(e),this.renderers.get("regl").click_function(e)})).selectAll("circle").data((t=>[t])).join("circle").attr("r",6).style("fill","pink")}))}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)]}}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=Bs(this.tick.bind(this));return this._timer=n,this._timer.stop_at=e,this._timer}data(t){return void 0===data?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,tileSet:r}=this,{extent:i}=this.tileSet,o={};if(void 0===i)return;const a={x:{},y:{}};for(const[d,h]of[["x",e],["y",n]]){const t=i[d];a[d].limits=t,a[d].size_range=t[1]-t[0],a[d].pixels_per_unit=h/a[d].size_range}const s=a.x.pixels_per_unit/a.y.pixels_per_unit;let u=0,c=0,f=e,l=n;return s>1?(f=e/s,u=(e-f)/2):(l=n*s,c=(n-l)/2),o.x=ch().domain(a.x.limits).range([u,e-u]),o.y=ch().domain(a.y.limits).range([c,n-c]),o.x_=this.transform.rescaleX(o.x),o.y_=this.transform.rescaleY(o.y),this._scales=o,o}webgl_scale(t=!0){const{x:e,y:n}=this.scales();return Ah(e,n).flat()}tick(t=!1){if(this._start=this._start||Date.now(),!0!==t&&this._timer&&this._timer.stop_at<=Date.now())return console.log("Timer ending"),void this._timer.stop()}}function Ah(t,e){function n(t){return t[1]-t[0]}const r=We(t.domain()),i=We(e.domain()),o=n(t.range())/n(t.domain()),a=n(e.range())/n(e.domain());return[[o,0,-o*r+We(t.range())],[0,a,-a*i+We(e.range())],[0,0,1]]}function Sh(t,e){let n="";const r=new Set(["x","y","ix","bookstack",null,"tile_key"]);for(const[i,o]of t.entries()){if(e){if(!e.has(i))continue}else{if(r.has(i))continue;if(i.match(/_dict_index/))continue;if(null===o)continue;if(""===o)continue}n+=`${i}: ${o}
`}return n}var Ih={exports:{}};Ih.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 d(t,e,n){e.indexOf(t)<0&&i("invalid value"+a(n)+". must be one of: "+e)}var h=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(t){Object.keys(t).forEach((function(t){h.indexOf(t)<0&&i('invalid regl constructor argument "'+t+'". must be one of '+h)}))}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";M(r,"string",u+" shader source must be a string",a);var c=w(r,a),f=x(s);A(c,f),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];switch(i=a[2],s){case"assign":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 k(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}))}k(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 E(t,e){var n=v();i(t+" in command "+(e||g())+("unknown"===n?"":" called from "+n))}function B(t,e,n){t||E(e,n||g())}function O(t,e,n,r){t in e||E("unknown parameter ("+t+")"+a(n)+". possible values: "+Object.keys(e).join(),r||g())}function M(t,e,n,r){c(t,e)||E("invalid parameter type"+a(n)+". expected "+e+", got "+typeof t,r||g())}function D(t){t()}function j(t,e,n){t.texture?d(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):d(t.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}var z=33071,F=9728,N=9984,L=9985,C=9986,R=9987,P=5121,U=5122,V=5123,$=5124,G=5125,H=5126,Y=32819,W=32820,q=33635,X=34042,Z=36193,J={};function K(t,e){return t===W||t===Y||t===q?2:t===X?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!==N&&t.minFilter!==C&&t.minFilter!==L&&t.minFilter!==R,"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===H&&(n.extensions.indexOf("oes_texture_float_linear")<0&&o(t.minFilter===F&&t.magFilter===F,"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,f=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>l,p=a>>l;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 h=yt(n||document.body,l,c);if(!h)return null;r=h.canvas,d=h.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:f,onDone:l,onDestroy:d}:(d(),l("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 Nt(){var t=kt(8,(function(){return[]}));function e(e){var n=zt(e),r=t[Ft(n)>>2];return r.length>0?r.pop():new ArrayBuffer(n)}function n(e){t[Ft(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 Et:r=new Uint8Array(e(n),0,n);break;case Bt:r=new Int16Array(e(2*n),0,n);break;case Ot:r=new Uint16Array(e(2*n),0,n);break;case Mt:r=new Int32Array(e(4*n),0,n);break;case Dt:r=new Uint32Array(e(4*n),0,n);break;case jt: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 Lt=Nt();Lt.zero=Nt();var Ct=3408,Rt=3410,Pt=3411,Ut=3412,Vt=3413,$t=3414,Gt=3415,Ht=33901,Yt=33902,Wt=3379,qt=3386,Xt=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,fe=34852,le=3553,de=34067,he=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(fe),i=t.getParameter(ce));var o=!!e.oes_texture_float;if(o){var a=t.createTexture();t.bindTexture(le,a),t.texImage2D(le,0,_e,1,1,0,_e,me,null);var s=t.createFramebuffer();if(t.bindFramebuffer(ye,s),t.framebufferTexture2D(ye,ve,le,a,0),t.bindTexture(le,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=Lt.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]),Lt.freeType(u)}}var c=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var f=t.createTexture(),l=Lt.allocType(be,36);t.activeTexture(pe),t.bindTexture(de,f),t.texImage2D(he,0,_e,3,3,0,_e,be,l),Lt.freeType(l),t.bindTexture(de,null),t.deleteTexture(f),c=!t.getError()}return{colorBits:[t.getParameter(Rt),t.getParameter(Pt),t.getParameter(Ut),t.getParameter(Vt)],depthBits:t.getParameter($t),stencilBits:t.getParameter(Gt),subpixelBits:t.getParameter(Ct),extensions:Object.keys(e).filter((function(t){return!!e[t]})),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:t.getParameter(Ht),lineWidthDims:t.getParameter(Yt),maxViewportDims:t.getParameter(qt),maxCombinedTextureUnits:t.getParameter(Kt),maxCubeMapSize:t.getParameter(ne),maxRenderbufferSize:t.getParameter(re),maxTextureUnits:t.getParameter(te),maxTextureSize:t.getParameter(Wt),maxAttributes:t.getParameter(Xt),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:Me,flatten:Oe};function ke(t,e,n){for(var r=0;r0)if(Array.isArray(n[0])){s=Ne(n);for(var c=1,f=1;f0)if("number"==typeof e[0]){var o=Lt.allocType(f.dtype,e.length);$e(o,e),p(o,i),Lt.freeType(o)}else if(Array.isArray(e[0])||t(e[0])){r=Ne(e);var a=Fe(e,r,f.dtype);p(a,i),Lt.freeType(a)}else nt.raise("invalid buffer data")}else if(Ae(e)){r=e.shape;var s=e.stride,u=0,c=0,d=0,h=0;1===r.length?(u=r[0],c=1,d=s[0],h=0):2===r.length?(u=r[0],c=r[1],d=s[0],h=s[1]):nt.raise("invalid shape");var _=Array.isArray(e.data)?f.dtype:Ve(e.data),m=Lt.allocType(_,u*c);Ge(m,e.data,u,c,d,h,e.offset),p(m,i),Lt.freeType(m)}else nt.raise("invalid data for buffer subdata");return l}return a[f.id]=f,u||l(i),l._reglType="buffer",l._buffer=f,l.subdata=_,r.profile&&(l.stats=f.stats),l.destroy=function(){h(f)},l}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:f,clear:function(){Se(a).forEach(h),u.forEach(h)},getBuffer:function(t){return t&&t._buffer instanceof s?t._buffer:null},restore:_,_initBuffer:d}}Ue[5120]=1,Ue[5122]=2,Ue[5124]=4,Ue[5121]=1,Ue[5123]=2,Ue[5125]=4,Ue[5126]=4;var Ye={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},We=0,qe=1,Xe=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=Xe,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(s.uint32=en),u.prototype.bind=function(){this.buffer.bind()};var c=[];function f(t){var e=c.pop();return e||(e=new u(r.create(null,nn,!0,!1)._buffer)),d(e,t,rn,-1,-1,0,0),e}function l(t){c.push(t)}function d(i,o,a,s,u,c,f){var l;if(i.buffer.bind(),o){var d=f;f||t(o)&&(!Ae(o)||t(o.data))||(d=n.oes_element_index_uint?en:Qe),r._initBuffer(i.buffer,o,a,d,3)}else e.bufferData(nn,c,a),i.buffer.dtype=l||Je,i.buffer.usage=a,i.buffer.dimension=3,i.buffer.byteLength=c;if(l=f,!f){switch(i.buffer.dtype){case Je:case Ze:l=Je;break;case Qe:case Ke:l=Qe;break;case en:case tn:l=en;break;default:nt.raise("unsupported type for element array")}i.buffer.dtype=l}i.type=l,nt(l!==en||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var h=u;h<0&&(h=i.buffer.byteLength,l===Qe?h>>=1:l===en&&(h>>=2)),i.vertCount=h;var p=s;if(s<0){p=Xe;var _=i.buffer.dimension;1===_&&(p=We),2===_&&(p=qe),3===_&&(p=Xe)}i.primType=p}function h(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=Xe,a.vertCount=0|e,a.type=Je;else{var n=null,r=on,i=-1,u=-1,f=0,l=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,Ye,"invalid element buffer primitive"),i=Ye[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"),l=s[e.type]),"length"in e?f=0|e.length:(f=u,l===Qe||l===Ke?f*=2:l!==en&&l!==tn||(f*=4))),d(a,n,r,i,u,f,l)}else o(),a.primType=Xe,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(){h(a)},c}return{create:p,createStream:f,destroyStream:l,getElements:function(t){return"function"==typeof t&&t._elements instanceof u?t._elements:null},clear:function(){Se(o).forEach(h)}}}var sn=new Float32Array(1),un=new Uint32Array(sn.buffer),cn=5123;function fn(t){for(var e=Lt.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 ln(e){return Array.isArray(e)||t(e)}var dn=function(t){return!(t&t-1||!t)},hn=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,kn=32820,Tn=33635,En=34042,Bn=6402,On=34041,Mn=35904,Dn=35906,jn=36193,zn=33776,Fn=33777,Nn=33778,Ln=33779,Cn=35986,Rn=35987,Pn=34798,Un=35840,Vn=35841,$n=35842,Gn=35843,Hn=36196,Yn=5121,Wn=5123,qn=5125,Xn=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,fr=4352,lr=4353,dr=4354,hr=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[Bn]=1,xr[On]=xr[wn]=2,xr[gn]=xr[Mn]=3,xr[bn]=xr[Dn]=4;var Sr=Ar("HTMLCanvasElement"),Ir=Ar("OffscreenCanvas"),kr=Ar("CanvasRenderingContext2D"),Tr=Ar("ImageBitmap"),Er=Ar("HTMLImageElement"),Br=Ar("HTMLVideoElement"),Or=Object.keys(De).concat([Sr,Ir,kr,Tr,Er,Br]),Mr=[];Mr[Yn]=1,Mr[Xn]=4,Mr[jn]=2,Mr[Wn]=2,Mr[qn]=4;var Dr=[];function jr(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function zr(t){return!!Array.isArray(t)&&!(0===t.length||!ln(t[0]))}function Fr(t){return Object.prototype.toString.call(t)}function Nr(t){return Fr(t)===Sr}function Lr(t){return Fr(t)===Ir}function Cr(t){return Fr(t)===kr}function Rr(t){return Fr(t)===Tr}function Pr(t){return Fr(t)===Er}function Ur(t){return Fr(t)===Br}function Vr(t){if(!t)return!1;var e=Fr(t);return Or.indexOf(e)>=0||jr(t)||zr(t)||Ae(t)}function $r(t){return 0|De[Object.prototype.toString.call(t)]}function Gr(t,e){var n=e.length;switch(t.type){case Yn:case Wn:case qn:case Xn:var r=Lt.allocType(t.type,n);r.set(e),t.data=r;break;case jn:t.data=fn(e);break;default:nt.raise("unsupported texture type, must specify a typed array")}}function Hr(t,e){return Lt.allocType(t.type===jn?Xn:t.type,e)}function Yr(t,e){t.type===jn?(t.data=fn(e),Lt.freeType(e)):t.data=e}function Wr(t,e,n,r,i,o){for(var a=t.width,s=t.height,u=t.channels,c=Hr(t,a*s*u),f=0,l=0;l=1;)s+=a*u*u,u/=2;return s}return a*n*r}function Xr(n,r,i,o,a,s,u){var c={"don't care":fr,"dont care":fr,nice:dr,fast:lr},f={repeat:Kn,clamp:Qn,mirror:tr},l={nearest:rr,linear:ir},d=e({mipmap:ur,"nearest mipmap nearest":or,"linear mipmap nearest":ar,"nearest mipmap linear":sr,"linear mipmap linear":ur},l),h={none:0,browser:yr},p={uint8:Yn,rgba4:In,rgb565:Tn,"rgb5 a1":kn},_={alpha:yn,luminance:vn,"luminance alpha":wn,rgb:gn,rgba:bn,rgba4:xn,"rgb5 a1":An,rgb565:Sn},m={};r.ext_srgb&&(_.srgb=Mn,_.srgba=Dn),r.oes_texture_float&&(p.float32=p.float=Xn),r.oes_texture_half_float&&(p.float16=p["half float"]=jn),r.webgl_depth_texture&&(e(_,{depth:Bn,"depth stencil":On}),e(p,{uint16:Wn,uint32:qn,"depth stencil":En})),r.webgl_compressed_texture_s3tc&&e(m,{"rgb s3tc dxt1":zn,"rgba s3tc dxt1":Fn,"rgba s3tc dxt3":Nn,"rgba s3tc dxt5":Ln}),r.webgl_compressed_texture_atc&&e(m,{"rgb atc":Cn,"rgba atc explicit alpha":Rn,"rgba atc interpolated alpha":Pn}),r.webgl_compressed_texture_pvrtc&&e(m,{"rgb pvrtc 4bppv1":Un,"rgb pvrtc 2bppv1":Vn,"rgba pvrtc 4bppv1":$n,"rgba pvrtc 2bppv1":Gn}),r.webgl_compressed_texture_etc1&&(m["rgb etc1"]=Hn);var b=Array.prototype.slice.call(n.getParameter(hn));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(l).forEach((function(t){var e=l[t];w[e]=t}));var x=[];Object.keys(d).forEach((function(t){var e=d[t];x[e]=t}));var A=[];Object.keys(f).forEach((function(t){var e=f[t];A[e]=t}));var S=y.reduce((function(t,e){var n=_[e];return n===vn||n===yn||n===vn||n===wn||n===Bn||n===On||r.ext_srgb&&(n===Mn||n===Dn)?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=Yn,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 k(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,h,"invalid colorSpace"),t.colorSpace=h[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 f=e.format;nt(r.webgl_depth_texture||!("depth"===f||"depth stencil"===f),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(f,_,"invalid texture format");var l=t.internalformat=_[f];t.format=S[l],f in p&&("type"in e||(t.type=p[f])),f 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 E(t){n.pixelStorei(_r,t.flipY),n.pixelStorei(mr,t.premultiplyAlpha),n.pixelStorei(br,t.colorSpace),n.pixelStorei(pr,t.unpackAlignment)}function B(){I.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function O(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!==Yn||(e.type=$r(r));else if(jr(r))e.channels=e.channels||4,Gr(e,r),e.alignment=1,e.needsFree=!0;else if(Ae(r)){var u=r.data;Array.isArray(u)||e.type!==Yn||(e.type=$r(u));var c,f,l,d,h,p,_=r.shape,m=r.stride;3===_.length?(l=_[2],p=m[2]):(nt(2===_.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,p=1),c=_[0],f=_[1],d=m[0],h=m[1],e.alignment=1,e.width=c,e.height=f,e.channels=l,e.format=e.internalformat=wr[l],e.needsFree=!0,Wr(e,u,d,h,p,r.offset)}else if(Nr(r)||Lr(r)||Cr(r))Nr(r)||Lr(r)?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(Rr(r))e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(Pr(r))e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(Ur(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=ln(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===jn&&nt(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function M(t,e,r){var i=t.element,a=t.data,s=t.internalformat,u=t.format,c=t.type,f=t.width,l=t.height;E(t),i?n.texImage2D(e,r,u,u,c,i):t.compressed?n.compressedTexImage2D(e,r,s,f,l,0,a):t.needsCopy?(o(),n.copyTexImage2D(e,r,u,t.xOffset,t.yOffset,f,l,0)):n.texImage2D(e,r,u,f,l,0,u,c,a||null)}function D(t,e,r,i,a){var s=t.element,u=t.data,c=t.internalformat,f=t.format,l=t.type,d=t.width,h=t.height;E(t),s?n.texSubImage2D(e,a,r,i,f,l,s):t.compressed?n.compressedTexSubImage2D(e,a,r,i,c,d,h,u):t.needsCopy?(o(),n.copyTexSubImage2D(e,a,r,i,t.xOffset,t.yOffset,d,h)):n.texSubImage2D(e,a,r,i,d,h,f,l,u)}var j=[];function z(){return j.pop()||new B}function F(t){t.needsFree&&Lt.freeType(t.data),B.call(t),j.push(t)}function N(){I.call(this),this.genMipmaps=!1,this.mipmapHint=fr,this.mipmask=0,this.images=Array(16)}function L(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 C(t,e){var n=null;if(Vr(e))k(n=t.images[0]=z(),t),O(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,O(n,r[i]),t.mipmask|=1<=0&&!("faces"in e)&&(t.genMipmaps=!0)}if("mag"in e){var r=e.mag;nt.parameter(r,l),t.magFilter=l[r]}var o=t.wrapS,a=t.wrapT;if("wrap"in e){var s=e.wrap;"string"==typeof s?(nt.parameter(s,f),o=a=f[s]):Array.isArray(s)&&(nt.parameter(s[0],f),nt.parameter(s[1],f),o=f[s[0]],a=f[s[1]])}else{if("wrapS"in e){var u=e.wrapS;nt.parameter(u,f),o=f[u]}if("wrapT"in e){var h=e.wrapT;nt.parameter(h,f),a=f[h]}}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 H(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,hr,t.anisotropic),t.genMipmaps&&(n.hint(cr,t.mipmapHint),n.generateMipmap(e))}var Y=0,W={},q=i.maxTextureUnits,X=Array(q).map((function(){return null}));function Z(t){I.call(this),this.mipmask=0,this.internalformat=bn,this.id=Y++,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=X[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),X[r]=null),n.deleteTexture(e),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete W[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=U();return"number"==typeof t?L(a,0|t,"number"==typeof e?0|e:0|t):t?(nt.type(t,"object","invalid arguments to regl.texture"),G(n,t),C(a,t)):L(a,1,1),n.genMipmaps&&(a.mipmask=(a.width<<1)-1),r.mipmask=a.mipmask,k(r,a),nt.texture2D(n,a,i),r.internalformat=a.internalformat,o.width=a.width,o.height=a.height,J(r),R(a,pn),H(n,pn),K(),V(a),u.profile&&(r.stats.size=qr(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 k(c,r),c.width=0,c.height=0,O(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,f=a>>s;if(!c||!f)break;n.texImage2D(pn,s,r.format,c,f,0,r.format,r.type,null)}return K(),u.profile&&(r.stats.size=qr(r.internalformat,r.type,i,a,!1,!1)),o}return W[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 f=new Z(_n);W[f.id]=f,s.cubeCount++;var l=new Array(6);function d(t,e,n,r,o,a){var s,c=f.texInfo;for($.call(c),s=0;s<6;++s)l[s]=U();if("number"!=typeof t&&t)if("object"==typeof t)if(e)C(l[0],t),C(l[1],e),C(l[2],n),C(l[3],r),C(l[4],o),C(l[5],a);else if(G(c,t),T(f,t),"faces"in t){var h=t.faces;for(nt(Array.isArray(h)&&6===h.length,"cube faces must be a length 6 array"),s=0;s<6;++s)nt("object"==typeof h[s]&&!!h[s],"invalid input for cube map face"),k(l[s],f),C(l[s],h[s])}else for(s=0;s<6;++s)C(l[s],t);else nt.raise("invalid arguments to cube map");else{var p=0|t||1;for(s=0;s<6;++s)L(l[s],p,p)}for(k(f,l[0]),nt.optional((function(){i.npotTextureCube||nt(dn(f.width)&&dn(f.height),"your browser does not support non power or two texture dimensions")})),c.genMipmaps?f.mipmask=(l[0].width<<1)-1:f.mipmask=l[0].mipmask,nt.textureCube(f,c,l,i),f.internalformat=l[0].internalformat,d.width=l[0].width,d.height=l[0].height,J(f),s=0;s<6;++s)R(l[s],mn+s);for(H(c,_n),K(),u.profile&&(f.stats.size=qr(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!0)),d.format=g[f.internalformat],d.type=v[f.type],d.mag=w[c.magFilter],d.min=x[c.minFilter],d.wrapS=A[c.wrapS],d.wrapT=A[c.wrapT],s=0;s<6;++s)V(l[s]);return d}function h(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 k(u,f),u.width=0,u.height=0,O(u,e),u.width=u.width||(f.width>>s)-o,u.height=u.height||(f.height>>s)-a,nt(f.type===u.type&&f.format===u.format&&f.internalformat===u.internalformat,"incompatible format for texture.subimage"),nt(o>=0&&a>=0&&o+u.width<=f.width&&a+u.height<=f.height,"texture.subimage write out of bounds"),nt(f.mipmask&1<>i;++i)n.texImage2D(mn+r,i,f.format,e>>i,e>>i,0,f.format,f.type,null);return K(),u.profile&&(f.stats.size=qr(f.internalformat,f.type,d.width,d.height,!1,!0)),d}}return d(t,e,r,o,a,c),d.subimage=h,d.resize=p,d._reglType="textureCube",d._texture=f,u.profile&&(d.stats=f.stats),d.destroy=function(){f.decRef()},d}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);H(t.texInfo,t.target)}))}function ot(){for(var t=0;t0)continue;i.unit=-1}X[r]=t,e=r;break}e>=q&&nt.raise("insufficient number of texture units"),u.profile&&s.maxTextureUnits=2,"invalid renderbuffer shape"),s=0|h[0],u=0|h[1]}else"radius"in d&&(s=u=0|d.radius),"width"in d&&(s=0|d.width),"height"in d&&(u=0|d.height);"format"in d&&(nt.parameter(d.format,o,"invalid renderbuffer format"),c=o[d.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!==f.width||u!==f.height||c!==f.format)return l.width=f.width=s,l.height=f.height=u,f.format=c,t.bindRenderbuffer(Zr,f.renderbuffer),t.renderbufferStorage(Zr,c,s,u),nt(0===t.getError(),"invalid render buffer format"),i.profile&&(f.stats.size=ui(f.format,f.width,f.height)),l.format=a[f.format],l}function d(e,r){var o=0|e,a=0|r||o;return o===f.width&&a===f.height||(nt(o>0&&a>0&&o<=n.maxRenderbufferSize&&a<=n.maxRenderbufferSize,"invalid renderbuffer size"),l.width=f.width=o,l.height=f.height=a,t.bindRenderbuffer(Zr,f.renderbuffer),t.renderbufferStorage(Zr,f.format,o,a),nt(0===t.getError(),"invalid render buffer format"),i.profile&&(f.stats.size=ui(f.format,f.width,f.height))),l}return u[f.id]=f,r.renderbufferCount++,l(e,s),l.resize=d,l._reglType="renderbuffer",l._renderbuffer=f,i.profile&&(l.stats=f.stats),l.destroy=function(){f.decRef()},l}function d(){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&&f(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var t=0;return Object.keys(u).forEach((function(e){t+=u[e].stats.size})),t}),{create:l,clear:function(){Se(u).forEach(f)},restore:d}},fi=36160,li=36161,di=3553,hi=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,ki=6407,Ti=6408,Ei=6402,Bi=[ki,Ti],Oi=[];Oi[Ti]=4,Oi[ki]=3;var Mi=[];Mi[Si]=1,Mi[Ii]=4,Mi[Ai]=2;var Di=33189,ji=36168,zi=34041,Fi=[32854,32855,36194,35907,34842,34843,34836],Ni={};function Li(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 f=["uint8"];function l(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 d(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function h(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(fi,e,n.target,n.texture._texture.texture,0):t.framebufferRenderbuffer(fi,e,li,n.renderbuffer._renderbuffer.renderbuffer))}function _(t){var e=di,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===di)):"textureCube"===o?(n=i,nt(e>=hi&&e=2,"invalid shape for framebuffer"),a=M[0],d=M[1]}else"radius"in O&&(a=d=O.radius),"width"in O&&(a=O.width),"height"in O&&(d=O.height);("color"in O||"colors"in O)&&(g=O.color||O.colors,Array.isArray(g)&&nt(1===g.length||n.webgl_draw_buffers,"multiple render targets not supported")),g||("colorCount"in O&&(I=0|O.colorCount,nt(I>0,"invalid color buffer count")),"colorTexture"in O&&(v=!!O.colorTexture,w="rgba4"),"colorType"in O&&(A=O.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,f,"invalid color type")),"colorFormat"in O&&(w=O.colorFormat,u.indexOf(w)>=0?v=!0:c.indexOf(w)>=0?v=!1:nt.optional((function(){v?nt.oneOf(O.colorFormat,u,"invalid color format for texture"):nt.oneOf(O.colorFormat,c,"invalid color format for renderbuffer")})))),("depthTexture"in O||"depthStencilTexture"in O)&&(B=!(!O.depthTexture&&!O.depthStencilTexture),nt(!B||n.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in O&&("boolean"==typeof O.depth?p=O.depth:(k=O.depth,y=!1)),"stencil"in O&&("boolean"==typeof O.stencil?y=O.stencil:(T=O.stencil,p=!1)),"depthStencil"in O&&("boolean"==typeof O.depthStencil?p=y=O.depthStencil:(E=O.depthStencil,p=!1,y=!1))}else a=d=1;var D=null,j=null,z=null,F=null;if(Array.isArray(g))D=g.map(_);else if(g)D=[_(g)];else for(D=new Array(I),i=0;i=0||D[i].renderbuffer&&Fi.indexOf(D[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),D[i]&&D[i].texture){var L=Oi[D[i].texture._texture.format]*Mi[D[i].texture._texture.type];null===N?N=L:nt(N===L,"all color attachments much have the same number of bits per pixel.")}return h(j,a,d),nt(!j||j.texture&&j.texture._texture.format===Ei||j.renderbuffer&&j.renderbuffer._renderbuffer.format===Di,"invalid depth attachment for framebuffer object"),h(z,a,d),nt(!z||z.renderbuffer&&z.renderbuffer._renderbuffer.format===ji,"invalid stencil attachment for framebuffer object"),h(F,a,d),nt(!F||F.texture&&F.texture._texture.format===zi||F.renderbuffer&&F.renderbuffer._renderbuffer.format===zi,"invalid depth-stencil attachment for framebuffer object"),x(o),o.width=a,o.height=d,o.colorAttachments=D,o.depthAttachment=j,o.stencilAttachment=z,o.depthStencilAttachment=F,l.color=D.map(b),l.depth=b(j),l.stencil=b(z),l.depthStencil=b(F),l.width=o.width,l.height=o.height,S(o),l}function d(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 l;for(var i=o.colorAttachments,a=0;a=2,"invalid shape for framebuffer"),nt(y[0]===y[1],"cube framebuffer must be square"),d=y[0]}else"radius"in b&&(d=0|b.radius),"width"in b?(d=0|b.width,"height"in b&&nt(b.height===d,"must be square")):"height"in b&&(d=0|b.height);("color"in b||"colors"in b)&&(h=b.color||b.colors,Array.isArray(h)&&nt(1===h.length||n.webgl_draw_buffers,"multiple render targets not supported")),h||("colorCount"in b&&(m=0|b.colorCount,nt(m>0,"invalid color buffer count")),"colorType"in b&&(nt.oneOf(b.colorType,f,"invalid color type"),_=b.colorType),"colorFormat"in b&&(p=b.colorFormat,nt.oneOf(b.colorFormat,u,"invalid color format for texture"))),"depth"in b&&(l.depth=b.depth),"stencil"in b&&(l.stencil=b.stencil),"depthStencil"in b&&(l.depthStencil=b.depthStencil)}else d=1;if(h)if(Array.isArray(h))for(c=[],r=0;r0&&(l.depth=o[0].depth,l.stencil=o[0].stencil,l.depthStencil=o[0].depthStencil),o[r]?o[r](l):o[r]=I(l)}return e(a,{width:d,height:d,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 '+Ui)})),nt(Array.isArray(i),"attributes must be an array")}nt(i.length0,"must specify at least one attribute");var f={},l=r.attributes;l.length=i.length;for(var d=0;d=m.byteLength?h.subdata(m):(h.destroy(),r.buffers[d]=null)),r.buffers[d]||(h=r.buffers[d]=o.create(p,Ri,!1,!0)),_.buffer=o.getBuffer(h),_.size=0|_.buffer.dimension,_.normalized=!1,_.type=_.buffer.dtype,_.offset=0,_.stride=0,_.divisor=0,_.state=1,f[d]=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,je,"invalid buffer type"),_.type=je[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(d>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 "+d)}for(var b=0;b1)for(var b=0;b1&&(g=g.replace("[0]","")),u(m,new s(g,n.id(g),t.getUniformLocation(h,g),f))}var v=t.getProgramParameter(h,Wi);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 l.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={},l.forEach((function(e){t.deleteProgram(e.program)})),l.length=0,f={},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=f[i];c||(c=f[i]={});var d=c[n];if(d&&(d.refCount++,!u))return d;var _=new h(i,n);return r.shaderCount++,p(_,s,u),d||(c[n]=_),l.push(_),e(_,{destroy:function(){if(_.refCount--,_.refCount<=0){t.deleteProgram(_.program);var e=l.indexOf(_);l.splice(e,1),r.shaderCount--}c[_.vertId].refCount<=0&&(t.deleteShader(a[_.vertId]),delete a[_.vertId],delete f[_.fragId][_.vertId]),Object.keys(f[_.fragId]).length||(t.deleteShader(o[_.fragId]),delete o[_.fragId],delete f[_.fragId])}})},restore:_,shader:c,frag:-1,vert:-1}}var Xi=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 f=0,l=0,d=i.framebufferWidth,h=i.framebufferHeight,p=null;t(u)?p=u:u&&(nt.type(u,"object","invalid arguments to regl.read()"),f=0|u.x,l=0|u.y,nt(f>=0&&f=0&&l0&&d+f<=i.framebufferWidth,"invalid width for read pixels"),nt(h>0&&h+l<=i.framebufferHeight,"invalid height for read pixels"),r();var _=d*h*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(f,l,d,h,Xi,c,p),p}function c(t){var e;return n.setFBO({framebuffer:t.framebuffer},(function(){e=u(t)})),e}function f(t){return t&&"framebuffer"in t?c(t):u(t)}return f}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 f(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:Ua,ccw:Va};function os(e){return Array.isArray(e)||t(e)||Ae(e)}function as(t){return t.sort((function(t,e){return t===Uo?-1:e===Uo?1:t=1,r>=2,e)}if(n===lo){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),f>=2&&(s=!0)}else c.type===lo&&(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===fo,n===co,n===uo,e)}var ls=new ss(!1,!1,!1,(function(){}));function ds(t,n,r,i,o,a,s,u,c,f,l,d,h,p,_){var m=f.Record,b={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(b.min=$a,b.max=Ga);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 k(t){return t.replace(".","_")}function T(t,e,n){var r=k(t);A.push(t),x[r]=w[r]=!!n,S[r]=e}function E(t,e,n){var r=k(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,ha),E(bo,"blendColor",[0,0,0,0]),E(yo,"blendEquationSeparate",[Xa,Xa]),E(go,"blendFuncSeparate",[qa,Wa,qa,Wa]),T(vo,ma,!0),E(wo,"depthFunc",Za),E(xo,"depthRange",[0,1]),E(Ao,"depthMask",!0),E(So,So,[!0,!0,!0,!0]),T(Io,da),E(ko,"cullFace",Pa),E(To,To,Va),E(Eo,Eo,1),T(Bo,ya),E(Oo,"polygonOffset",[0,0]),T(Mo,ga),T(Do,va),E(jo,"sampleCoverage",[1,!1]),T(zo,_a),E(Fo,"stencilMask",-1),E(No,"stencilFunc",[Ha,0,-1]),E(Lo,"stencilOpSeparate",[Ra,Ya,Ya,Ya]),E(Co,"stencilOpSeparate",[Pa,Ya,Ya,Ya]),T(Ro,ba),E(Po,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),E(Uo,Uo,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var B={gl:t,context:h,strings:n,next:x,current:w,draw:d,elements:a,buffer:o,shader:l,attributes:f.state,vao:f,uniforms:c,framebuffer:u,extensions:r,timer:p,isBufferArgs:os},O={primTypes:Ye,compareFuncs:es,blendFuncs:Qa,blendEquations:b,stencilOps:ns,glTypes:je,orientationType:is};nt.optional((function(){B.isArrayLike=ln})),g&&(O.backBuffer=[Pa],O.drawBuffer=kt(i.maxDrawbuffers,(function(t){return 0===t?[0]:kt(t,(function(t){return Ka+t}))})));var M=0;function D(){var t=no(),e=t.link,r=t.global;t.id=M++,t.batchId="0";var i=e(B),o=t.shared={props:"a0"};Object.keys(B).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,");")},O.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(O).forEach((function(t){u[t]=r.def(JSON.stringify(O[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 fo:return n.def("this",r.data);case lo: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=f.scope[r];return i||(i=f.scope[r]=new m),c[r]=e(i)},t}function j(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=fs(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 fs(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 F(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,f=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,"-",f)),[c,f,r,i]}))}if(t in i){var l=i[t],d=fs(l,(function(e,n){var r=e.invoke(n,l);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&&(d.thisDep=d.thisDep||e.thisDep,d.contextDep=d.contextDep||e.contextDep,d.propDep=d.propDep||e.propDep),d}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(Uo);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(Po)}}function N(t,e){var n=t.static;if("string"==typeof n[Ho]&&"string"==typeof n[Go]){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 f=r[t];return fs(f,(function(e,n){var r=e.invoke(n,f);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(Xo,!0);function m(){if(qo in n){var t=0|n[qo];return i.count=t,nt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),cs((function(){return t}))}if(qo in r){var a=r[qo];return fs(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(d)){if(d)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 f=new ss(d.thisDep||_.thisDep,d.contextDep||_.contextDep,d.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(){f.DYNAMIC=!0})),f}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=h(),y=m(),g=p(Zo,!1);return{elements:d,primitive:b,count:y,instances:g,offset:_,vao:u,vaoActive:o,elementsActive:c,static:i}}function R(t,e){var n=t.static,r=t.dynamic,o={};return A.forEach((function(t){var a=k(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]=fs(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 Ro:case Bo:case Mo:case Do: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(ln(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(ln(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),kt(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")})),kt(4,(function(t){return e.def("+",n,"[",t,"]")}))}));case Fo: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 No: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]",":",Ya),e.def(n,".ref|0"),e.def('"mask" in ',n,"?",n,".mask|0:-1")]}));case Lo:case Co: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===Co?Pa:Ra,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,"]:",Ya)}return nt.optional((function(){e.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+t)})),[t===Co?Pa:Ra,o("fail"),o("zfail"),o("zpass")]}));case Oo: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 ko:return s((function(t){var n=0;return"front"===t?n=Ra:"back"===t&&(n=Pa),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"?',Ra,":",Pa)}));case Eo: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"?'+Ua+":"+Va)}));case So:return s((function(t){return nt.command(ln(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")})),kt(4,(function(t){return"!!"+n+"["+t+"]"}))}));case jo: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 P(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 ln(o)?r=cs((function(e){return e.global.def("[",kt(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]=fs(e,(function(t,n){return t.invoke(n,e)}))})),i}function U(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 f=i.constant;u.buffer="null",u.state=ao,"number"==typeof f?u.x=f:(nt.command(ln(f)&&f.length>0&&f.length<=4,"invalid constant for attribute "+t,e.commandStr),ro.forEach((function(t,e){e=0,'invalid offset for attribute "'+t+'"',e.commandStr);var d=0|i.stride;nt.command(d>=0&&d<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',e.commandStr);var h=0|i.size;nt.command(!("size"in i)||h>0&&h<=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,je,"invalid type for attribute "+t,e.commandStr),_=je[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=h,u.normalized=p,u.type=_||c.dtype,u.offset=l,u.stride=d,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)},f=new m;f.state=oo,Object.keys(f).forEach((function(t){c[t]=r.def(""+f[t])}));var l=c.buffer,d=c.type;function h(t){r(c[t],"=",i,".",t,"|0;")}return r("if(",s,"(",i,")){",c.isStream,"=true;",l,"=",u,".createStream(",ua,",",i,");",d,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",i,");","if(",l,"){",d,"=",l,".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)){",l,"=",u,".createStream(",ua,",",i,".buffer);","}else{",l,"=",u,".getBuffer(",i,".buffer);","}",d,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",l,".dtype;",c.normalized,"=!!",i,".normalized;"),h("size"),h("offset"),h("stride"),h("divisor"),r("}}"),r.exit("if(",c.isStream,"){",u,".destroyStream(",l,");","}"),c}a[t]=fs(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]=fs(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,Go,Ho,Yo,Wo,Xo,qo,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=N(t,e),c=z(t),l=F(t,c,o),d=C(t,o),h=R(t,o),p=L(t,o,u);function _(t){var e=l[t];e&&(h[t]=e)}_(Uo),_(k(Po));var m=Object.keys(h).length>0,b={framebuffer:c,draw:d,shader:p,state:h,dirty:m,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(b.profile=j(t),b.uniforms=P(n,o),b.drawVAO=b.scopeVAO=d.vao,!b.drawVAO&&p.program&&!u&&r.angle_instanced_arrays&&d.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=f.getVAO(f.createVAO({attributes:g,elements:d.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=U(e,o),b.context=V(i),b}function G(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 H(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,f=c.drawBuffer,l=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(",f,"[",u,".colorAttachments.length]);"),e("}else{",a,".bindFramebuffer(",Ja,",null);"),g&&e(i,".drawBuffersWEBGL(",l,");"),e("}",s,".cur=",u,";"),r||e("}")}function Y(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,f,l=k(e);if(!(l in n.state))if(l in a){r=a[l],f=o[l];var d=kt(w[l].length,(function(t){return c.def(r,"[",t,"]")}));c(t.cond(d.map((function(t,e){return t+"!=="+f+"["+e+"]"})).join("||")).then(i,".",I[l],"(",d,");",d.map((function(t,e){return f+"["+e+"]="+t})).join(";"),";"))}else{r=c.def(u,".",l);var h=t.cond(r,"!==",s,".",l);c(h),l in S?h(t.cond(r).then(i,".enable(",S[l],");").else(i,".disable(",S[l],");"),s,".",l,"=",r,";"):h(i,".",I[l],"(",r,");",s,".",l,"=",r,";")}})),0===Object.keys(n.state).length&&c(s,".dirty=false;"),e(c)}function W(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 f=S[i];us(u)?e(s,c?".enable(":".disable(",f,");"):e(t.cond(c).then(s,".enable(",f,");").else(s,".disable(",f,");")),e(a,".",i,"=",c,";")}else if(ln(c)){var l=o[i];e(s,".",I[i],"(",c,");",c.map((function(t,e){return l+"["+e+"]="+t})).join(";"),";")}else e(s,".",I[i],"(",c,");",a,".",i,"=",c,";")}}))}function q(t,e){y&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function X(t,e,n,r,i){var o,a,s,u=t.shared,c=t.stats,f=u.current,l=u.timer,d=n.profile;function h(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function _(t){t(o=e.def(),"=",h(),";"),"string"==typeof i?t(c,".count+=",i,";"):t(c,".count++;"),p&&(r?t(a=e.def(),"=",l,".getNumPendingQueries();"):t(l,".beginQuery(",c,");"))}function m(t){t(c,".cpuTime+=",h(),"-",o,";"),p&&(r?t(l,".pushScopeStats(",a,",",l,".getNumPendingQueries(),",c,");"):t(l,".endQuery();"))}function b(t){var n=e.def(f,".profile");e(f,".profile=",t,";"),e.exit(f,".profile=",n,";")}if(d){if(us(d))return void(d.enable?(_(e),m(e.exit),b("true")):b("false"));b(s=d.append(t,e))}else s=e.def(f,".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 ka:case Oa:return 2;case Aa:case Ta:case Ma:return 3;case Sa:case Ea:case Da: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,f=i.buffer,l=[i.x,i.y,i.z,i.w],d=["buffer","normalized","offset","stride"];function h(){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,"||",d.map((function(t){return u+"."+t+"!=="+i[t]})).join("||"),"){",a,".bindBuffer(",ua,",",f,".buffer);",a,".vertexAttribPointer(",[s,n,o,i.normalized,i.stride,i.offset],");",u,".type=",o,";",u,".size=",n,";",d.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+"!=="+l[e]})).join("||"),"){",a,".vertexAttrib4f(",s,",",l,");",ro.map((function(t,e){return u+"."+t+"="+l[e]+";"})).join(""),"}")}c===oo?h():c===ao?p():(e("if(",c,"===",oo,"){"),h(),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(ls))return;var f=t.scopeAttrib(u);nt.optional((function(){t.assert(e,f+".state","missing attribute "+u)})),o={},Object.keys(new m).forEach((function(t){o[t]=e.def(f,".",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,f={},l=0;l1){if(!m)continue;var b=h.replace("[0]","");if(f[b])continue;f[b]=1}var y,g=t.link(d)+".location";if(m){if(!o(m))continue;if(us(m)){var v=m.value;if(nt.command(null!=v,'missing uniform "'+h+'"',t.commandStr),p===Na||p===La){nt.command("function"==typeof v&&(p===Na&&("texture2d"===v._reglType||"framebuffer"===v._reglType)||p===La&&("textureCube"===v._reglType||"framebufferCube"===v._reglType)),"invalid texture for uniform "+h,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===ja||p===za||p===Fa){nt.optional((function(){nt.command(ln(v),"invalid matrix for uniform "+h,t.commandStr),nt.command(p===ja&&4===v.length||p===za&&9===v.length||p===Fa&&16===v.length,"invalid length for matrix uniform "+h,t.commandStr)}));var x=t.global.def("new Float32Array(["+Array.prototype.slice.call(v)+"])"),A=2;p===za?A=3:p===Fa&&(A=4),e(c,".uniformMatrix",A,"fv(",g,",false,",x,");")}else{switch(p){case wa:1===_?nt.commandType(v,"number","uniform "+h,t.commandStr):nt.command(ln(v)&&v.length===_,"uniform "+h,t.commandStr),s="1f";break;case xa:nt.command(ln(v)&&v.length&&v.length%2==0&&v.length<=2*_,"uniform "+h,t.commandStr),s="2f";break;case Aa:nt.command(ln(v)&&v.length&&v.length%3==0&&v.length<=3*_,"uniform "+h,t.commandStr),s="3f";break;case Sa:nt.command(ln(v)&&v.length&&v.length%4==0&&v.length<=4*_,"uniform "+h,t.commandStr),s="4f";break;case Ba:1===_?nt.commandType(v,"boolean","uniform "+h,t.commandStr):nt.command(ln(v)&&v.length===_,"uniform "+h,t.commandStr),s="1i";break;case Ia:1===_?nt.commandType(v,"number","uniform "+h,t.commandStr):nt.command(ln(v)&&v.length===_,"uniform "+h,t.commandStr),s="1i";break;case Oa:case ka:nt.command(ln(v)&&v.length&&v.length%2==0&&v.length<=2*_,"uniform "+h,t.commandStr),s="2i";break;case Ma:case Ta:nt.command(ln(v)&&v.length&&v.length%3==0&&v.length<=3*_,"uniform "+h,t.commandStr),s="3i";break;case Da:case Ea:nt.command(ln(v)&&v.length&&v.length%4==0&&v.length<=4*_,"uniform "+h,t.commandStr),s="4i"}_>1?(s+="v",v=t.global.def("["+Array.prototype.slice.call(v)+"]")):v=ln(v)?Array.prototype.slice.call(v):v,e(c,".uniform",s,"(",g,",",v,");")}continue}y=m.append(t,e)}else{if(!o(ls))continue;y=e.def(u.uniforms,"[",n.id(h),"]")}p===Na?(nt(!Array.isArray(y),"must specify a scalar prop for textures"),e("if(",y,"&&",y,'._reglType==="framebuffer"){',y,"=",y,".color[0];","}")):p===La&&(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 "'+h+'". '+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===fa?"2d":"Cube")+'"',"invalid texture type",t.commandStr)}switch(p){case Ia:r("number",_);break;case ka:i(2,"number",_);break;case Ta:i(3,"number",_);break;case Ea: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 Ba:r("boolean",_);break;case Oa:i(2,"boolean",_);break;case Ma:i(3,"boolean",_);break;case Da:i(4,"boolean",_);break;case ja:i(4,"number",_);break;case za:i(9,"number",_);break;case Fa:i(16,"number",_);break;case Na:o(fa);break;case La:o(la)}}));var S=1;switch(p){case Na:case La:var I=e.def(y,"._texture");e(c,".uniform1i(",g,",",I,".bind());"),e.exit(I,".unbind();");continue;case Ia:case Ba:s="1i";break;case ka:case Oa:s="2i",S=2;break;case Ta:case Ma:s="3i",S=3;break;case Ea:case Da: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 ja:s="Matrix2fv";break;case za:s="Matrix3fv";break;case Fa:s="Matrix4fv"}if(-1===s.indexOf("Matrix")&&_>1&&(s+="v",S=1),"M"===s.charAt(0)){e(c,".uniform",s,"(",g,",");var k=Math.pow(p-ja+2,2),T=t.global.def("new Float32Array(",k,")");Array.isArray(y)?e("false,(",kt(k,(function(t){return T+"["+t+"]="+y[t]})),",",T,")"):e("false,(Array.isArray(",y,")||",y," instanceof Float32Array)?",y,":(",kt(k,(function(t){return T+"["+t+"]="+y+"["+t+"]"})),",",T,")"),e(");")}else if(S>1){for(var E=[],B=[],O=0;O=0","missing vertex count")}))):(i=u.def(a,".",qo),nt.optional((function(){t.assert(u,i+">=0","missing vertex count")}))),i}var f=u();function l(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 d,h,p=l(Wo),_=l(Xo),m=c();if("number"==typeof m){if(0===m)return}else n("if(",m,"){"),n.exit("}");y&&(d=l(Zo),h=t.instancing);var b=f+".type",g=s.elements&&us(s.elements)&&!s.vaoActive;function w(){function t(){n(h,".drawElementsInstancedANGLE(",[p,m,b,_+"<<(("+b+"-"+io+")>>1)",d],");")}function e(){n(h,".drawArraysInstancedANGLE(",[p,_,m,d],");")}f&&"null"!==f?g?t():(n("if(",f,"){"),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]+");")}f&&"null"!==f?g?t():(n("if(",f,"){"),t(),n("}else{"),e(),n("}")):e()}y&&("number"!=typeof d||d>=0)?"string"==typeof d?(n("if(",d,">0){"),w(),n("}else if(",d,"<0){"),x(),n("}")):w():x()}function Q(t,e,n,r,i){var o=D(),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){q(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);q(t,n),G(t,n,e.context),H(t,n,e.framebuffer),Y(t,n,e),W(t,n,e.state),X(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",q(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){q(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(),f=t.scope();function l(t){return t.contextDep&&i||t.propDep}function d(t){return!l(t)}if(e(c.entry,"for(",o,"=0;",o,"<",s,";++",o,"){",u,"=",a,"[",o,"];",f,"}",c.exit),n.needsContext&&G(t,f,n.context),n.needsFramebuffer&&H(t,f,n.framebuffer),W(t,f,n.state,l),n.profile&&l(n.profile)&&X(t,f,n,!1,!0),r)n.useVAO?n.drawVAO?l(n.drawVAO)?f(t.shared.vao,".setVAO(",n.drawVAO.append(t,f),");"):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,d),Z(t,f,n,r.attributes,l)),J(t,c,n,r.uniforms,d,!1),J(t,f,n,r.uniforms,l,!0),K(t,c,f,n);else{var h=t.global.def("{}"),p=n.shader.progVar.append(t,f),_=f.def(p,".id"),m=f.def(h,"[",_,"]");f(t.shared.gl,".useProgram(",p,".program);","if(!",m,"){",m,"=",h,"[",_,"]=",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",q(t,n);var r=!1,i=!0;Object.keys(e.context).forEach((function(t){r=r||e.context[t].propDep})),r||(G(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||H(t,n,o)):H(t,n,null),e.state.viewport&&e.state.viewport.propDep&&(r=!0),Y(t,n,e),W(t,n,e.state,(function(t){return!s(t)})),e.profile&&s(e.profile)||X(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 f=t.global.def("{}"),l=n.def(c,".id"),d=n.def(f,"[",l,"]");n(t.cond(d).then(d,".call(this,a0,a1);").else(d,"=",f,"[",l,"]=",t.link((function(n){return Q(it,t,e,n,2)})),"(",c,");",d,".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))}G(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);ln(o)?o.forEach((function(e,i){r.set(t.next[n],"["+i+"]",e)})):r.set(i.next,"."+n,o)})),X(t,r,e,!0,!0),[Yo,Xo,qo,Zo,Wo].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(Go),a(Ho),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&&!ln(t)){for(var e=Object.keys(t),n=0;n=0;--t){var e=O[t];e&&e(p,null,0)}r.flush(),f&&f.update()}function N(){!z&&O.length>0&&(z=_t.next(F))}function L(){z&&(_t.cancel(F),z=null)}function C(t){t.preventDefault(),o=!0,L(),M.forEach((function(t){t()}))}function R(t){r.getError(),o=!1,a.restore(),x.restore(),y.restore(),A.restore(),S.restore(),I.restore(),v.restore(),f&&f.restore(),k.procs.refresh(),N(),D.forEach((function(t){t()}))}function P(){O.length=0,L(),B&&(B.removeEventListener(xs,C),B.removeEventListener(As,R)),x.clear(),I.clear(),S.clear(),v.clear(),A.clear(),g.clear(),y.clear(),f&&f.clear(),j.forEach((function(t){t()}))}function U(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 d.call(this,_(0|t),0|t)}else{if(!Array.isArray(t))return l.call(this,t);if(t.length)return d.call(this,t,t.length)}}return e(m,{stats:c,destroy:function(){f.destroy()}})}B&&(B.addEventListener(xs,C,!1),B.addEventListener(As,R,!1));var V=I.setFBO=U({framebuffer:pt.define.call(null,Ss,"framebuffer")});function $(t,e){var n=0;k.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 G(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 H(t){function e(){var e=Ts(O,t);function n(){var t=Ts(O,n);O[t]=O[O.length-1],O.length-=1,O.length<=0&&L()}nt(e>=0,"cannot cancel a frame twice"),O[e]=n}return nt.type(t,"function","regl.frame() callback must be a function"),O.push(t),N(),{cancel:e}}function Y(){var t=E.viewport,e=E.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 W(){p.tick+=1,p.time=X(),Y(),k.procs.poll()}function q(){A.refresh(),Y(),k.procs.refresh(),f&&f.update()}function X(){return(mt()-l)/1e3}function Z(t,e){var n;switch(nt.type(e,"function","listener callback must be a function"),t){case"frame":return H(e);case"lost":n=M;break;case"restore":n=D;break;case"destroy":n=j;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:P,_gl:r,_refresh:q,poll:function(){W(),f&&f.update()},now:X,stats:u});return n.onDone(null,J),J}return Es}();var kh=Ih.exports;var Th=Math.sqrt(50),Eh=Math.sqrt(10),Bh=Math.sqrt(2);function Oh(t,e,n){var r,i,o,a,s=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((r=e=0?(o>=Th?10:o>=Eh?5:o>=Bh?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=Th?10:o>=Eh?5:o>=Bh?2:1)}(t,e,n))||!isFinite(a))return[];if(a>0){let n=Math.round(t/a),r=Math.round(e/a);for(n*ae&&--r,o=new Array(i=r-n+1);++se&&--r,o=new Array(i=r-n+1);++s=r&&++n;else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(i=+i)>=i&&++n}return n}(t))/Math.LN2)+1}var Dh=Array.prototype.slice;function jh(t,e){return t-e}var zh=t=>()=>t;function Fh(t,e){for(var n,r=-1,i=e.length;++rr!=h>r&&n<(d-c)*(r-f)/(h-f)+c&&(i=-i)}return i}function Lh(t,e,n){var r,i,o,a;return function(t,e,n){return(e[0]-t[0])*(n[1]-t[1])==(n[0]-t[0])*(e[1]-t[1])}(t,e,n)&&(i=t[r=+(t[0]===e[0])],o=n[r],a=e[r],i<=o&&o<=a||a<=o&&o<=i)}function Ch(){}var Rh=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ph(){var t=1,e=1,n=Mh,r=s;function i(t){var e,r,i,a,s,u,c=n(t);if(Array.isArray(c))c=c.slice().sort(jh);else{const n=function(t,e){let n,r;if(void 0===e)for(const i of t)null!=i&&(void 0===n?i>=i&&(n=r=i):(n>i&&(n=i),r=o&&(n=r=o):(n>o&&(n=o),r=Th?s*=10:u>=Eh?s*=5:u>=Bh&&(s*=2),ro(t,e)))}function o(n,i){var o=[],s=[];return function(n,r,i){var o,s,u,c,f,l,d=new Array,h=new Array;o=s=-1,c=n[0]>=r,Rh[c<<1].forEach(p);for(;++o=r,Rh[u|c<<1].forEach(p);Rh[c<<0].forEach(p);for(;++s=r,f=n[s*t]>=r,Rh[c<<1|f<<2].forEach(p);++o=r,l=f,f=n[s*t+o+1]>=r,Rh[u|c<<1|f<<2|l<<3].forEach(p);Rh[c|f<<3].forEach(p)}o=-1,f=n[s*t]>=r,Rh[f<<2].forEach(p);for(;++o=r,Rh[f<<2|l<<3].forEach(p);function p(t){var e,n,r=[t[0][0]+o,t[0][1]+s],u=[t[1][0]+o,t[1][1]+s],c=a(r),f=a(u);(e=h[c])?(n=d[f])?(delete h[e.end],delete d[n.start],e===n?(e.ring.push(u),i(e.ring)):d[e.start]=h[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[e.end],e.ring.push(u),h[e.end=f]=e):(e=d[f])?(n=h[c])?(delete d[e.start],delete h[n.end],e===n?(e.ring.push(u),i(e.ring)):d[n.start]=h[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[e.start],e.ring.unshift(r),d[e.start=c]=e):d[c]=h[f]={start:c,end:f,ring:[r,u]}}Rh[f<<3].forEach(p)}(n,i,(function(t){r(t,n,i),function(t){for(var e=0,n=t.length,r=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e0?o.push([t]):s.push(t)})),s.forEach((function(t){for(var e,n=0,r=o.length;n0&&a0&&s=0&&o>=0))throw new Error("invalid size");return t=r,e=o,i},i.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?zh(Dh.call(t)):zh(t),i):n},i.smooth=function(t){return arguments.length?(r=t?s:Ch,i):r===s},i}var Uh=function(t,e,n,r){return Vh[0]=r,Vh[1]=n,Vh[2]=e,Vh[3]=t,$h[0]},Vh=new Uint8Array(4),$h=new Float32Array(Vh.buffer);function Gh(t){for(var e=t.length/6|0,n=new Array(e),r=0;ryl(t[t.length-1]),np=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Gh),rp=ep(np),ip=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Gh),op=ep(ip),ap=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Gh),sp=ep(ap),up=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Gh),cp=ep(up),fp=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Gh),lp=ep(fp),dp=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Gh),hp=ep(dp),pp=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Gh),_p=ep(pp),mp=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Gh),bp=ep(mp),yp=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Gh),gp=ep(yp),vp=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Gh),wp=ep(vp),xp=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Gh),Ap=ep(xp),Sp=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Gh),Ip=ep(Sp),kp=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Gh),Tp=ep(kp),Ep=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Gh),Bp=ep(Ep),Op=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Gh),Mp=ep(Op),Dp=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Gh),jp=ep(Dp),zp=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Gh),Fp=ep(zp),Np=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Gh),Lp=ep(Np),Cp=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Gh),Rp=ep(Cp),Pp=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Gh),Up=ep(Pp),Vp=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Gh),$p=ep(Vp),Gp=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Gh),Hp=ep(Gp),Yp=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Gh),Wp=ep(Yp),qp=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Gh),Xp=ep(qp),Zp=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Gh),Jp=ep(Zp),Kp=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Gh),Qp=ep(Kp),t_=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Gh),e_=ep(t_);var n_=Ll(fl(300,.5,0),fl(-240,.5,1)),r_=Ll(fl(-100,.75,.35),fl(80,1.5,.8)),i_=Ll(fl(260,.75,.35),fl(80,1.5,.8)),o_=fl();var a_=Gf(),s_=Math.PI/3,u_=2*Math.PI/3;function c_(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var f_=c_(Gh("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),l_=c_(Gh("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),d_=c_(Gh("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),h_=c_(Gh("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")),p_=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",schemeCategory10:Hh,schemeAccent:Yh,schemeDark2:Wh,schemePaired:qh,schemePastel1:Xh,schemePastel2:Zh,schemeSet1:Jh,schemeSet2:Kh,schemeSet3:Qh,schemeTableau10:tp,interpolateBrBG:rp,schemeBrBG:np,interpolatePRGn:op,schemePRGn:ip,interpolatePiYG:sp,schemePiYG:ap,interpolatePuOr:cp,schemePuOr:up,interpolateRdBu:lp,schemeRdBu:fp,interpolateRdGy:hp,schemeRdGy:dp,interpolateRdYlBu:_p,schemeRdYlBu:pp,interpolateRdYlGn:bp,schemeRdYlGn:mp,interpolateSpectral:gp,schemeSpectral:yp,interpolateBuGn:wp,schemeBuGn:vp,interpolateBuPu:Ap,schemeBuPu:xp,interpolateGnBu:Ip,schemeGnBu:Sp,interpolateOrRd:Tp,schemeOrRd:kp,interpolatePuBuGn:Bp,schemePuBuGn:Ep,interpolatePuBu:Mp,schemePuBu:Op,interpolatePuRd:jp,schemePuRd:Dp,interpolateRdPu:Fp,schemeRdPu:zp,interpolateYlGnBu:Lp,schemeYlGnBu:Np,interpolateYlGn:Rp,schemeYlGn:Cp,interpolateYlOrBr:Up,schemeYlOrBr:Pp,interpolateYlOrRd:$p,schemeYlOrRd:Vp,interpolateBlues:Hp,schemeBlues:Gp,interpolateGreens:Wp,schemeGreens:Yp,interpolateGreys:Xp,schemeGreys:qp,interpolatePurples:Jp,schemePurples:Zp,interpolateReds:Qp,schemeReds:Kp,interpolateOranges:e_,schemeOranges:t_,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)))))))+")"},interpolateCubehelixDefault:n_,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return o_.h=360*t-100,o_.s=1.5-1.5*e,o_.l=.8-.9*e,o_+""},interpolateWarm:r_,interpolateCool:i_,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,a_.r=255*(e=Math.sin(t))*e,a_.g=255*(e=Math.sin(t+s_))*e,a_.b=255*(e=Math.sin(t+u_))*e,a_+""},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:f_,interpolateMagma:l_,interpolateInferno:d_,interpolatePlasma:h_});function __(t,e){t=t.flat();const[n,r]=Ge(t);null==e&&(e=new Uint32Array(t.length));const i=2**32/(r-n);let o=0;for(let a of t)e[o]=(a-n)*i,o+=1;return console.log(Je(t),r,n,(t[100]-n)*i),{extent:[n,r],array:new Uint8Array(e.buffer)}}const m_={sqrt:function(){return wh.apply(null,arguments).exponent(.5)},log:function t(){var e=mh(Gd()).domain([1,10]);return e.copy=function(){return $d(e,t()).base(e.base())},Nd.apply(e,arguments),e},linear:ch,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,Ld),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,Ld):[0,1],uh(r)}},b_=4095;function y_(t){const e=new Uint8Array(16380);return e.set(t.flat()),e}function g_(t){return y_(qe(b_).map((e=>{const n=Gf(t(e/b_));return[n.r,n.g,n.b,255]})))}const v_={white:qe(b_).map((t=>[255,255,255,255]))};for(const[um,cm]of Object.entries(p_)){if(um.startsWith("scheme")&&"string"==typeof cm[0]){const t=new Array(b_),e=cm.map((t=>{const e=Gf(t);return[e.r,e.g,e.b,255]}));for(const r of qe(b_))t[r]=e[r%cm.length];const n=um.replace("scheme","").toLowerCase();v_[n]=y_(t)}if(um.startsWith("interpolate")){const t=um.replace("interpolate","").toLowerCase();v_[t]=g_(cm),"rainbow"==t&&(v_.shufbow=Ze(v_[t]))}}const w_={x:{field:"x",constant:1,range:[0,500],transform:"literal"},y:{field:"y",constant:1,range:[0,500],transform:"literal"},x0:{constant:0,range:[0,500],transform:"literal"},y0:{constant:0,range:[0,500],transform:"literal"},color:{constant:[1,1,1],range:v_.white,transform:"linear"},jitter_radius:{constant:0,range:[0,.05],transform:"sqrt"},jitter_speed:{constant:0,range:[.05,1],transform:"linear"},size:{constant:1.5,range:[.5,5],transform:"sqrt"},filter:{constant:1,range:[0,1],transform:"linear"}};class x_{constructor(t,e,n,r){this.label=t,this.scatterplot=e,this.regl=n,this._domain=this.default_domain,this._range=this.default_range,this._transform=w_[t].transform,this.tileSet=r,this.needs_transitions=!0,this._domains={}}get default_val(){return 1}get texture_size(){return 4095}get transform(){return this._transform?this._transform:w_[this.label].transform}get default_range(){return w_[this.label].range}get scale(){return m_[this.transform]().domain(this.domain).range(this.range)}get column(){return this.tileSet.table.getColumn(this.field)}get default_domain(){if(null==this.field)return[1,1];if(this._domains[this.field])return this._domains[this.field];if(!this.tileSet.table)return[1,1];const{column:t}=this;return t.type.dictionary?this._domains[this.field]=[0,this.texture_size-1]:this._domains[this.field]=Ge(t.toArray()),this._domains[this.field]}default_data(){return Array(this.texture_size).fill(this.default_val)}get domain(){return this._domain||this.default_domain}get range(){return this._range||this.default_range}get scale(){return m_[this.transform]().domain(this.domain).range(this.range)}value_for(t){return t[this.field||this.partner.field]}create_lookup_texture(t,e,n){}get texture_buffer(){return this._texture_buffer||(this._texture_buffer=new Float32Array(this.texture_size),this._texture_buffer.set(this.default_data())),this._texture_buffer}get textures(){if(this._textures)return this._textures;this.texture_type=this.regl.hasExtension("OES_texture_float")?"float":this.regl.hasExtension("OES_texture_half_float")?"half float":"uint8",this.texture_format="uint8"===this.texture_type?"rgba":"alpha";const t={width:1,height:this.texture_size,type:this.texture_type,format:this.texture_format,data:this.default_data()};return this._textures={one_d:this.regl.texture(t)},this._textures}key(){return this.field+this.domain+this.range+this.transform}post_to_regl_buffer(t){console.log("Posting to buffer from ",t,this.field),this.textures[t].subimage({data:this.texture_buffer,width:1,height:this.texture_size})}clear(){console.log("Clearing",this.field),this.texture_buffer.set(this.default_data()),this.post_to_regl_buffer("one_d"),this.lookup=void 0,this.field=void 0,this._domain=void 0,this._range=void 0,this._transform=void 0}get use_lookup(){const{lookup:t}=this;return t?1:0}get lookup_texture(){const{lookup:t}=this;if(void 0===t)return{texture:this.textures.one_d,y_domain:[-1,1],x_domain:[-1,1],z_domain:[-1,1],y_constant:0};const{field:e}=this,{table:n,value:r,y:i,z:o}=t;if(!i.constant)throw"Only constant lookups for the secondary dimension are currently supported.";const a={x:e,y:i.field,z:o.field},s=this.scatterplot.lookup_tables.get(n),u=()=>this.arrow_column().data.dictionary.toArray();let c;void 0===s?(console.log("Using temporary null lookup."),c={texture:this.textures.one_d,y_domain:[-1,1],z_domain:[-1,1],x_domain:[-1,1]}):c=s.get_cached_crosstab_texture(a,{x:u},this.regl);const{texture:f,z_domain:l,y_domain:d,x_domain:h,shape:p,crosstabs:_}=c;return{value:i.constant||0,crosstabs:_,texture:f,shape:p,x_domain:h,y_domain:d,z_domain:l}}update(t){if(null===t)return void this.clear();if(void 0===t)throw"This should have been removed earlier";if("x"!==t.field&&"y"!==t.field||!t.range||console.warn("Asked for an x or y range, but it will be automatically\n set to the window scale."),this.stringversion=JSON.parse(JSON.stringify(t)),t.field===this.field&&t.op&&void 0!==this.field)return;"string"==typeof t&&(t=E_(t,!1),"filter"===this.label&&(t.domain=[-2047,2047])),("number"==typeof t||t.length)&&(t={constant:t,transform:"literal"}),t.lambda&&"string"==typeof t.lambda&&Object.assign(t,E_(t.lambda,!1)),this.lookup=t.lookup,this.field=t.field,this._domain=I_(t.domain),this._range=I_(t.range),this._constant=t.constant;const{lambda:e,field:n}=t;this._transform=t.transform||this.default_transform,e?this.apply_function_to_textures(n,this.domain,e):t.range&&(this.encode_for_textures(this.range),this.post_to_regl_buffer("one_d"))}encode_for_textures(t){const e=new Array(this.texture_size);this.scaleFunc=m_[this.transform]().range(t).domain([0,this.texture_size-1]);for(let n=0;n").map((t=>t.trim()));r=null==e?Function("x",n):Function(t,e)}else r=n;this.scaleFunc=ch().range(e).domain([0,this.texture_size-1]);let i=qe(this.texture_size);if(void 0===t||null==this.tileSet.table)return void this.texture_buffer.set(qe(this.texture_size).map((t=>1)));console.log(i);const{column:o}=this;if(!o)throw`Column ${t} does not exist on table.`;if(o.type.dictionary){i.fill("");o.data.dictionary.toArray().forEach(((t,e)=>i[e]=t))}else i=i.map((t=>this.scaleFunc(t)));const a=i.map((t=>+r(t)));console.log(a),console.log(__(a)),this.texture_buffer.set(__(a).array)}}class A_ extends x_{constructor(...t){super(...t),this._transform="literal"}get range(){return this.tileSet.extent?this.tileSet.extent.x:[-20,20]}get previous_range(){return this.range}get default_val(){return 1}}class S_ extends A_{get range(){const[t,e]=this.tileSet.extent?this.tileSet.extent.y:[-20,20];return[e,t]}get previous_range(){return this.range}}function I_(t){if("string"==typeof t)return t;if("numeric"==typeof t)return[t,t];if(void 0===t)return[1,1];try{return[...t]}catch(e){return console.warn("No list for range",t),[1,1]}}const k_={Size:class extends x_{get default_val(){return 1}},Jitter_speed:class extends x_{get default_val(){return.1}},Jitter_radius:class extends x_{constructor(...t){super(...t),this.method="None"}get default_val(){return.05}update(t){"number"==typeof t&&(t={constant:t}),t.method?this.method=t.method:this.partner.method&&(this.method=this.partner.method),null===t.method&&(this.method="None"),console.log(t,"ENCODING"),super.update(t)}get jitter_int_format(){return"spiral"==(t=this.method)?1:"uniform"==t?2:"normal"==t?3:"circle"==t?4:"time"==t?5:0;var t}},Color:class extends x_{get default_val(){return[128,150,213,255]}default_data(){return v_.viridis}get texture_buffer(){return this._texture_buffer||(this._texture_buffer=new Uint8Array(4*this.texture_size),this._texture_buffer.set(this.default_data())),this._texture_buffer}get textures(){if(this._textures)return this._textures;const t={width:1,height:this.texture_size,type:"uint8",format:"rgba",data:this.default_data()};return this._textures={one_d:this.regl.texture(t)},this.post_to_regl_buffer("one_d"),this._textures}get constant(){if(void 0!==this._constant){if("string"==typeof this._constant){const{r:t,g:e,b:n}=Gf(this._constant);return this._constant=[t/255,e/255,n/255],this._constant}return this._constant}}encode_for_textures(t){if(v_[t])this.texture_buffer.set(v_[t]);else if(t.length==4*this.texture_size)this.texture_buffer.set(t);else if(t.length&&t[0].length&&3==t[0].length){console.log("Setting color palette manually.");const e=qe(b_).map((e=>{const[n,r,i]=t[e%t.length];return[n,r,i,255]}));this.texture_buffer.set(y_(e))}else console.warn(`request range of ${t} for color ${this.field} unknown`)}},Filter:class extends x_{get default_val(){return 1}get domain(){return this.is_dictionary()?[-2047,2047]:[0,1]}get_function(){const t=this.stringversion;if(t&&t.op){if("gt"==t.op)return e=>e>t.a;if("lt"==t.op)return e=>ee==t.a;if("within"==t.op)return e=>Math.abs(e-t.a)<=t.b}if(!this.encoding)return()=>!0;const{lambda:e,field:n}=this.encoding;return e?t=>e(t[n]):t=>!0}ops_to_array(){const t=this.stringversion;if(!t||!t.op)return[0,0,0];return[[null,"lt","gt","eq","within"].indexOf(t.op),t.a||0,t.b||0]}},X:A_,Y:S_,X0:class extends A_{},Y0:class extends S_{}};class T_{constructor(t,e,n,r){this.states=[];const i=t.toLowerCase(),o=k_[t];for(const a of[1,2])this.states.push(new o(i,e,n,r));this.states[0].partner=this.states[1],this.states[1].partner=this.states[0];for(const a of this.states)a.update({constant:w_[i].constant});this.current_encoding=JSON.stringify({constant:w_[i].constant})}get current(){return this.states[0]}get last(){return this.states[1]}update(t){const e=JSON.stringify(t);if(e==this.current_encoding||void 0===t)return this.needs_transitions&&this.states[1].update(JSON.parse(this.current_encoding)),void(this.needs_transitions=!1);this.states.reverse(),this.states[0].update(t),this.needs_transitions=!0,this.current_encoding=e}}function E_(t,e=!1){console.log(t);let[n,r]=t.split("=>").map((t=>t.trim()));if(void 0===r)throw`Couldn't parse ${t} into a function`;"{"!=r.slice(0,1)&&"return"!=r.slice(0,6)&&(r=`return ${r}`);const i=`${n} => ${r}`;return e?Function(n,r):{field:n,lambda:i}}const B_=Array.from(Object.keys(k_)).map((t=>t.toLowerCase()));class O_{constructor(t,e,n,r=null){if(this.is_aesthetic_set=!0,this.scatterplot=t,this.regl=e,this.tileSet=n,null===r)for(const o of Array.from(Object.keys(k_))){const t=o,e=[t,this.scatterplot,this.regl,n];this[t.toLowerCase()]=new T_(...e)}const i={};for(const[o,a]of Object.entries(w_))i[o]=a.constant||a;this.encoding=JSON.parse(JSON.stringify(i)),this.apply_encoding(this.encoding)}interpret_position(t){if(t){t.x0||t.position0?this.position_interpolation=!0:(t.x||t.position)&&(this.position_interpolation=!1);for(const e of["position","position0"]){const n=e.replace("position","");if(t[e]){if("literal"===t[e])t[`x${n}`]={field:"x",transform:"literal"},t[`y${n}`]={field:"y",transform:"literal"};else{const r=t[e];t[`x${n}`]={field:`${r}.x`,transform:"literal"},t[`y${n}`]={field:`${r}.y`,transform:"literal"}}delete t[e]}}}delete t.position,delete t.position0}apply_encoding(t){null==t&&(t={}),this.interpret_position(t),t.x0&&this.x.update(t.x0),t.y0&&this.y.update(t.y0);for(const e of B_)this[e].update(t[e])}}class M_ extends class{constructor(t,e,n){this.scatterplot=n,this.holder=pt(t),this.canvas=pt(this.holder.node().firstElementChild),this.tileSet=e,this.prefs=n.prefs,this.width=+this.canvas.attr("width"),this.height=+this.canvas.attr("height"),this.deferred_functions=[],this._use_scale_to_download_tiles=!0}get discard_share(){return 0}get optimal_alpha(){let{zoom_balance:t,alpha:e,point_size:n}=this.prefs;const{max_ix:r,width:i,discard_share:o,height:a}=this,{k:s}=this.zoom.transform;e=void 0===e?.25:e;const u=1/s**2,c=e*(i*a)/(Ye([r,this.tileSet.highest_known_ix])*(1-o)*u*(Math.PI*Math.exp(Math.log(1*s)*t)*n)**2);return c>1?1:c<1/255?1/255:c}get max_ix(){const{prefs:t}=this;if(!this._use_scale_to_download_tiles)return t.max_points;const{k:e}=this.zoom.transform,n=Math.exp(Math.log(e)*t.zoom_balance);return t.max_points*e*e/n/n}is_visible(t){return p_in_rect(t,this._zoom.current_corners)&&t.ixt)).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}get click_function(){return console.log(this._click_function),this._current_click_function_string=this._current_click_function_string,this._current_click_function_string&&this._current_click_function_string===this.scatterplot.prefs.click_function||(this._current_click_function_string=this.scatterplot.prefs.click_function,this._click_function=Function("datum",this.scatterplot.prefs.click_function)),this._click_function}*initialize(){return Promise.all(this._initializations).then((t=>{this.zoom.restart_timer(5e5)}))}}{constructor(t,e,n){super(t,e,n),this.regl=kh({optionalExtensions:["OES_element_index_uint","OES_texture_float","OES_texture_half_float"],canvas:this.canvas.node()}),this.aes=new O_(n,this.regl,e),this.buffer_size=67108864,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()}get buffers(){return this._buffers=this._buffers||new j_(this.regl,this.buffer_size),this._buffers}data(t){return void 0===data?this.tileSet:(this.tileSet=t,this)}apply_webgl_scale(){if(this._use_scale_to_download_tiles=!0,this.aes.encoding.x.transform&&"literal"!==this.aes.encoding.x.transform||this.aes.encoding.y.transform&&"literal"!==this.aes.encoding.y.transform){const t=Ah(this.aes.x.scale,this.aes.y.scale).flat();this._webgl_scale_history.unshift(t),this._use_scale_to_download_tiles=!1}else this._webgl_scale_history||(this._webgl_scale_history=[]),this._webgl_scale_history.unshift(this.default_webgl_scale)}get props(){const{prefs:t}=this,{transform:e}=this.zoom,{aes_to_buffer_num:n,buffer_num_to_variable:r,variable_to_buffer_num:i}=this.allocate_aesthetic_buffers(),o={aes:{encoding:this.aes.encoding},colors_as_grid:0,corners:this.zoom.current_corners(),zoom_balance:t.zoom_balance,transform:e,max_ix:this.max_ix,time:(Date.now()-this.zoom._start)/1e3,update_time:(Date.now()-this.most_recent_restart)/1e3,string_index:0,prefs:JSON.parse(JSON.stringify(t)),color_type:void 0,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:r,aes_to_buffer_num:n,variable_to_buffer_num:i,color_picker_mode:0};return o.zoom_matrix=[[o.transform.k,0,o.transform.x],[0,o.transform.k,o.transform.y],[0,0,1]].flat(),JSON.parse(JSON.stringify(o))}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=[];for(const r of this.visible_tiles()){const i=new D_(this.regl,r,this);try{if(!i.ready(t.prefs,t.block_for_buffers))continue}catch(n){continue}const o={manager:i,image_locations:i.image_locations,sprites:this.sprites};Object.assign(o,t),e.push(o)}void 0!==this._renderer?(e.reverse(),this._renderer(e)):this._zoom&&this._zoom._timer&&this._zoom._timer.stop()}tick(t="No message",e=!1){const{prefs:n}=this,{regl:r,tileSet:i}=this,{props:o}=this;this.tick_num=this.tick_num||0,this.tick_num++,this._use_scale_to_download_tiles?i.download_most_needed_tiles(this.zoom.current_corners(),this.props.max_ix):i.download_to_depth(n.max_points),r.clear({color:[.9,.9,.93,0],depth:1});const a=Date.now();let s=()=>{};for(;Date.now()-a<10&&this.deferred_functions.length;){s=this.deferred_functions.shift();try{s()}catch(u){console.warn(u,s)}}this.render_all(o)}render_jpeg(t){}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)})),this.geolines&&this.fbos.lines.use((()=>{e.clear({color:[0,0,0,0]}),this.geolines.render(t)})),this.geo_polygons&&this.geo_polygons.length&&this.fbos.lines.use((()=>{e.clear({color:[0,0,0,0]});for(const e of this.geo_polygons)e.render(t)})),e.clear({color:[0,0,0,0]});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}})()}set_image_data(t,e){this.initialize_sprites(t);const{current_position:n}=sprites;if(n[1]>4060)return console.error(`First spritesheet overflow on ${t.key}`),void(sprites.current_position=[0,0]);t.table.get(e)._jpeg}spritesheet_setter(t){let e=0;if(this.spritesheet)e=this.spritesheet;else{e=(n="canvas",pt(o(n).call(document.documentElement))).attr("width",4096).attr("width",4096).style("display","none").node().getContext("2d");const t=32;e.font=`${t}px Times New Roman`,e.fillStyle="black",e.lookups=new Map,e.position=[0,t-t/4],this.spritesheet=e}var n;let[r,i]=e.position;if(e.lookups.get(t))return e.lookups.get(t);const a=e.measureText(t).width;return a>4096?void 0:(r+a>4096&&(r=0,i+=font_size),e.fillText(t,r,i),lookups.set(t,{x:r,y:i,width:a}),r+=a,e.position=[r,i],lookups.get(t))}initialize_textures(){const{regl:t}=this;this.fbos=this.fbos||{},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})}counter(t){}plot_as_grid(t,e,n=this.fbos.minicounter){console.log("plotting as grid");const{scatterplot:r,regl:i,tileSet:o}=this.aes,a=this.aes;void 0===n&&(n={width:this.width,height:this.height,use:t=>t()});const{width:s,height:u}=n;this.aes=new O_(r,i,o);const c=map._root.table.getColumn(t).data.dictionary.length;let f=1;for(;f{this.regl.clear({color:[0,0,0,0]}),this.render_points(d),i.read({data:h})})),this.aes=a}count_colors(t){console.log("Counting colors");const{regl:e,props:n}=this;n.prefs.jitter=null,void 0!==t?(console.warn("PROBABLY BROKEN BECAUSE OF THE NEW AES",t,n.prefs,t),n.aes.encoding.color={field:t,domain:[-2047,2047]}):t=this.aes.color.field,n.only_color=-1,n.colors_as_grid=1,n.block_for_buffers=!0;const{width:r,height:i}=this.fbos.minicounter,o=new Uint8Array(r*i*4),a=new Map;this.fbos.minicounter.use((()=>{e.clear({color:[0,0,0,0]}),this.render_points(n),e.read({data:o})})),console.log(o);for(const[s,u]of this.tileSet.dictionary_lookups[t]){if("string"==typeof s)continue;const t=Math.floor(s/64),e=s%64,n=r/64;let i=0,c=!1;for(const a of qe(n))for(const s of qe(n)){const u=o[t*n*4+4*s+e*n*4*r+a*r*4+3];u>=128?c=!0:i+=u}c?(console.log(s,u,"overflown, performing manually"),a.set(u,this.n_visible(s))):a.set(u,i)}return a}n_visible(t=-1){let{width:e,height:n}=this;e=Math.floor(e),n=Math.floor(n),this.contour_vals=this.contour_vals||new Uint8Array(4*e*n);const{props:r}=this;let i;return r.only_color=t,console.log("Counting visible points"),this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(r),this.regl.read(this.contour_vals),i=Je(this.contour_vals)})),i}calculate_contours(t="lc0"){const{width:e,height:n}=this;let r=[];const i=Ph().size([parseInt(e),parseInt(n)]).thresholds(d3.range(-1,9).map((t=>Math.pow(2,2*t))));for(const o of qe(this.tileSet.dictionary_lookups[t].size/2)){this.draw_contour_buffer(t,o);const e=i(this.contour_alpha_vals);e.forEach((e=>{e.label=this.tileSet.dictionary_lookups[t].get(o)})),r=r.concat(e)}return r}color_pick(t,e){const{props:n,height:r}=this;let i;n.color_picker_mode=1,this.fbos.colorpicker.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(n);try{i=this.regl.read({x:t,y:r-e,width:1,height:1})}catch(o){console.warn("Read bad data from",{x:t,y:e,height:r})}}));const o=Uh(...i),a=this.tileSet.findPoint(o);if(0!==a.length)return a[0]}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),console.log(this.contour_vals.filter((t=>0!==t)).map((t=>t/6)).reduce(((t,e)=>t+e),0))})),this.blur(this.fbos.contour,this.fbos.ping,3),this.fbos.contour.use((()=>{this.regl.read(this.contour_vals),console.log(this.contour_vals.filter((t=>0!=t)).map((t=>t/6)).reduce(((t,e)=>t+e),0))}));let o=0;for(;oe<.5,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},primitive:"points",frag:"precision mediump float;\n#define GLSLIFY 1\n\nvarying float pic_mode;\nvarying vec4 fill;\nvarying vec4 stroke;\nvarying float point_size;\nuniform float u_only_color;\nuniform float u_color_picker_mode;\nuniform sampler2D u_sprites;\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.0) {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.0) {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\n if (u_only_color >= -1.5) {\n gl_FragColor = vec4(0., 0., 0., 1./255.);\n return;\n }\n\n // Drop parts of the rectangle outside the unit circle.\n // I took this from observable.\n if (out_of_circle(gl_PointCoord)) {\n discard;\n return;\n }\n if (u_color_picker_mode > 0.5) {\n gl_FragColor = fill;\n } else {\n // Pre-blend the alpha channel.\n gl_FragColor = vec4(fill.rgb * fill.a, fill.a);\n }\n}\n",vert:'precision mediump float;\n#define GLSLIFY 1\n\nuniform float u_zoom_balance;\n\nuniform float u_update_time;\nuniform float u_transition_duration;\n\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_filter_last_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;\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_current_alpha;\nuniform float u_last_alpha;\n\n// The same set of items for a variety of aesthetics.\n\n// whether to continuously interpolate between\n// lastx and x, lasty and y.\nuniform float u_position_interpolation_mode;\n\n/*\npython code to generate what follows.\nks = ["x", "y", "jitter_radius", "jitter_speed", "size", "filter", "x0", "y0"]\ntimes = ["", "last_"]\nfor k in ks:\n for time in times:\n timek = time + k\n print(f"""\nuniform float u_{timek}_buffer_num;\nuniform float u_{timek}_constant;\nuniform float u_{timek}_transform;\nuniform vec2 u_{timek}_domain;\nuniform vec2 u_{timek}_range;\nuniform sampler2D u_{timek}_map;\nuniform float u_{timek}_needs_map;\nfloat a_{timek};\n """)\n\nfor i in range(1, 15):\n print(f"attribute float buffer_{i};")\n\nfor 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 }} else {{\n a_{timek} = u_{timek}_constant;\n }}"""\n*/\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\nuniform float u_x_buffer_num;\nuniform float u_x_constant;\nuniform float u_x_transform;\nuniform vec2 u_x_domain;\nuniform vec2 u_x_range;\nuniform sampler2D u_x_map;\nuniform float u_x_needs_map;\nfloat a_x;\n \n\nuniform float u_last_x_buffer_num;\nuniform float u_last_x_constant;\nuniform float u_last_x_transform;\nuniform vec2 u_last_x_domain;\nuniform vec2 u_last_x_range;\nuniform sampler2D u_last_x_map;\nuniform float u_last_x_needs_map;\nfloat a_last_x;\n \n\nuniform float u_y_buffer_num;\nuniform float u_y_constant;\nuniform float u_y_transform;\nuniform vec2 u_y_domain;\nuniform vec2 u_y_range;\nuniform sampler2D u_y_map;\nuniform float u_y_needs_map;\nfloat a_y;\n \n\nuniform float u_last_y_buffer_num;\nuniform float u_last_y_constant;\nuniform float u_last_y_transform;\nuniform vec2 u_last_y_domain;\nuniform vec2 u_last_y_range;\nuniform sampler2D u_last_y_map;\nuniform float u_last_y_needs_map;\nfloat a_last_y;\n \n\nuniform float u_jitter_radius_buffer_num;\nuniform float u_jitter_radius_constant;\nuniform float u_jitter_radius_transform;\nuniform vec2 u_jitter_radius_domain;\nuniform vec2 u_jitter_radius_range;\nuniform sampler2D u_jitter_radius_map;\nuniform float u_jitter_radius_needs_map;\nfloat a_jitter_radius;\n \n\nuniform float u_last_jitter_radius_buffer_num;\nuniform float u_last_jitter_radius_constant;\nuniform float u_last_jitter_radius_transform;\nuniform vec2 u_last_jitter_radius_domain;\nuniform vec2 u_last_jitter_radius_range;\nuniform sampler2D u_last_jitter_radius_map;\nuniform float u_last_jitter_radius_needs_map;\nfloat a_last_jitter_radius;\n \n\nuniform float u_jitter_speed_buffer_num;\nuniform float u_jitter_speed_constant;\nuniform float u_jitter_speed_transform;\nuniform vec2 u_jitter_speed_domain;\nuniform vec2 u_jitter_speed_range;\nuniform sampler2D u_jitter_speed_map;\nuniform float u_jitter_speed_needs_map;\nfloat a_jitter_speed;\n \n\nuniform float u_last_jitter_speed_buffer_num;\nuniform float u_last_jitter_speed_constant;\nuniform float u_last_jitter_speed_transform;\nuniform vec2 u_last_jitter_speed_domain;\nuniform vec2 u_last_jitter_speed_range;\nuniform sampler2D u_last_jitter_speed_map;\nuniform float u_last_jitter_speed_needs_map;\nfloat a_last_jitter_speed;\n \n\nuniform float u_size_buffer_num;\nuniform float u_size_constant;\nuniform float u_size_transform;\nuniform vec2 u_size_domain;\nuniform vec2 u_size_range;\nuniform sampler2D u_size_map;\nuniform float u_size_needs_map;\nfloat a_size;\n\nuniform float u_last_size_buffer_num;\nuniform float u_last_size_constant;\nuniform float u_last_size_transform;\nuniform vec2 u_last_size_domain;\nuniform vec2 u_last_size_range;\nuniform sampler2D u_last_size_map;\nuniform float u_last_size_needs_map;\nfloat a_last_size;\n \n\nuniform float u_filter_buffer_num;\nuniform float u_filter_constant;\nuniform float u_filter_transform;\nuniform vec2 u_filter_domain;\nuniform vec2 u_filter_range;\nuniform sampler2D u_filter_map;\nuniform float u_filter_needs_map;\nfloat a_filter;\n \n\nuniform float u_last_filter_buffer_num;\nuniform float u_last_filter_constant;\nuniform float u_last_filter_transform;\nuniform vec2 u_last_filter_domain;\nuniform vec2 u_last_filter_range;\nuniform sampler2D u_last_filter_map;\nuniform float u_last_filter_needs_map;\nfloat a_last_filter;\n \n\nuniform float u_x0_buffer_num;\nuniform float u_x0_constant;\nuniform float u_x0_transform;\nuniform vec2 u_x0_domain;\nuniform vec2 u_x0_range;\nuniform sampler2D u_x0_map;\nuniform float u_x0_needs_map;\nfloat a_x0;\n \n\nuniform float u_last_x0_buffer_num;\nuniform float u_last_x0_constant;\nuniform float u_last_x0_transform;\nuniform vec2 u_last_x0_domain;\nuniform vec2 u_last_x0_range;\nuniform sampler2D u_last_x0_map;\nuniform float u_last_x0_needs_map;\nfloat a_last_x0;\n \n\nuniform float u_y0_buffer_num;\nuniform float u_y0_constant;\nuniform float u_y0_transform;\nuniform vec2 u_y0_domain;\nuniform vec2 u_y0_range;\nuniform sampler2D u_y0_map;\nuniform float u_y0_needs_map;\nfloat a_y0;\n \n\nuniform float u_last_y0_buffer_num;\nuniform float u_last_y0_constant;\nuniform float u_last_y0_transform;\nuniform vec2 u_last_y0_domain;\nuniform vec2 u_last_y0_range;\nuniform sampler2D u_last_y0_map;\nuniform float u_last_y0_needs_map;\nfloat a_last_y0;\n \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 sampler2D u_color_map;\nuniform sampler2D u_last_color_map;\nuniform float u_last_color_needs_map;\nuniform float u_color_needs_map;\nuniform vec3 u_constant_color;\nuniform vec3 u_constant_last_color;\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 sampler2D u_jitter_radius_lookup_map;\nuniform vec2 u_jitter_radius_lookup_x_domain;\nuniform vec2 u_jitter_radius_lookup_y_domain;\nuniform vec2 u_jitter_radius_lookup_z_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\n// uniform vec4 corners;\n\n/*************** COLOR SCALES *******************************/\n\n// Ha! A gazillion version of this function:\n// https://gist.github.com/kylemcdonald/f8df3bc2f8d38ca2b7cb\n/*vec3 hsv2rgb(in vec3 c) {\n vec3 rgb = clamp(abs(mod(c.x * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0,\n 0.0, 1.0);\n rgb = rgb * rgb * (3.0 - 2.0 * rgb);\n return c.z * mix(vec3(1.0), rgb, c.y);\n}*/\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\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) + 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\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 bool clamped) {\n\n // Clamp an attribute into a domain, with an option 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 (clamped) {\n return linstep(domain, attr);\n } else {\n return linscale(domain, attr);\n }\n}\n\nmat3 pixelspace_to_glspace;\n\nfloat run_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\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\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 //return 0.05;\n // Scale values up by 256.\n return dot(floater, decoder);\n}\n\nfloat texture_float_lookup(in sampler2D texture,\n in vec2 domain,\n in vec2 range,\n in float transform,\n in float attr,\n in float use_texture,\n in float y_attr,\n in vec2 y_range) {\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, true);\n if (use_texture > 0.) {\n float y_pos = linstep(y_range, y_attr);\n vec4 encoded = texture2D(texture, vec2(y_pos, inrange));\n return RGBAtoFloat(encoded);\n } else {\n return mix(range.x, range.y, inrange);\n }\n}\n\nfloat texture_float_lookup(in sampler2D texture,\n in vec2 domain,\n in vec2 range,\n in float transform,\n in float attr,\n in float use_texture) {\n return texture_float_lookup(texture,\n domain,\n range,\n transform,\n attr,use_texture,\n 1., vec2(0., 2.));\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 sampler2D x_map, in float x_needs_map,\n in sampler2D y_map, in float y_needs_map\n ) {\n float x;\n float y;\n\n if (x_scale_type < 4.0) {\n x = texture_float_lookup(x_map, x_domain, x_range,\n x_scale_type,\n position.x, x_needs_map, 1., vec2(0., 2.)\n );\n } else {\n x = position.x;\n }\n\n if (x_scale_type < 4.0) {\n y = texture_float_lookup(y_map, y_domain, y_range, y_scale_type,\n position.y, y_needs_map, 1., vec2(0., 2.)\n );\n } else {\n y = position.y;\n }\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 * radius * tau / 2.;\n float units_per_second = speed / 100.;\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\n float r_mult = (sqrt(ix_to_random(ix, 7.)));\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 sampler2D jitter_radius_map,\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 sampler2D jitter_speed_map, 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_radius_needs_map,\n in float jitter_speed_needs_map\n) {\n if (jitter_type == 0.) {\n // No jitter\n return vec2(0., 0.);\n }\n\n if (jitter_type == 5.) {\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\n float jitter_r = texture_float_lookup(\n jitter_radius_map, jitter_radius_domain,\n jitter_radius_range,\n jitter_radius_transform, jitter_radius,\n jitter_radius_needs_map,\n 1.,\n vec2(0., 2.));\n\nif (jitter_type == 3.) {\n // normally distributed on x and y.\n return jitter_r * box_muller(ix, 1.) * vec2(1., u_width/u_height);\n }\n if (jitter_type == 2.) {\n // uniform in the circle.\n float theta = ix_to_random(ix, 15.) * tau;\n // Rescale.\n float r = jitter_r * sqrt(ix_to_random(ix, 145.));\n return vec2(cos(theta) * r, sin(theta)*r * u_width / u_height);\n }\n /* Jittering that includes motion) */\n\n float p_jitter_speed =\n texture_float_lookup(jitter_speed_map, jitter_speed_domain,\n jitter_speed_range,\n jitter_speed_transform, jitter_speed,\n jitter_speed_needs_map, 1., vec2(0., 2.));\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 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 (u_constant_color.r > -1.) {\n fill = vec4(u_constant_color.rgb, u_current_alpha);\n } else {\n float fractional_color = linstep(u_color_domain, a_color);\n fill = texture2D(u_color_map, vec2(0., fractional_color));\n fill = vec4(fill.rgb, u_current_alpha);\n }\n if (ease < 1.) {\n vec4 last_fill;\n if (u_constant_last_color.r > 0.) {\n last_fill = vec4(u_constant_last_color.rgb, u_last_alpha);\n } else {\n float last_fractional = linstep(u_last_color_domain, a_last_color);\n last_fill = texture2D(u_last_color_map, vec2(0., last_fractional));\n // Alpha channel interpolation already happened.\n last_fill = vec4(last_fill.rgb, u_last_alpha);\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\nvoid main() {\n\n float ix = buffer_0;\n\n if (ix > u_maxix) {\n // throwaway points that are too low.\n gl_Position = discard_me;\n return;\n }\n\n if (u_x_buffer_num > -0.5) {\n a_x = get_buffer(u_x_buffer_num);\n } else {\n a_x = u_x_constant;\n }\n\n if (u_last_x_buffer_num > -0.5) {\n a_last_x = get_buffer(u_last_x_buffer_num);\n } else {\n a_last_x = u_last_x_constant;\n }\n\n if (u_y_buffer_num > -0.5) {\n a_y = get_buffer(u_y_buffer_num);\n } else {\n a_y = u_y_constant;\n }\n\n if (u_last_y_buffer_num > -0.5) {\n a_last_y = get_buffer(u_last_y_buffer_num);\n } else {\n a_last_y = u_last_y_constant;\n }\n\n if (u_jitter_radius_buffer_num > -0.5) {\n a_jitter_radius = get_buffer(u_jitter_radius_buffer_num);\n } else {\n a_jitter_radius = u_jitter_radius_constant;\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 } else {\n a_last_jitter_radius = u_last_jitter_radius_constant;\n }\n\n if (u_jitter_speed_buffer_num > -0.5) {\n a_jitter_speed = get_buffer(u_jitter_speed_buffer_num);\n } else {\n a_jitter_speed = u_jitter_speed_constant;\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 } else {\n a_last_jitter_speed = u_last_jitter_speed_constant;\n }\n\n if (u_size_buffer_num > -0.5) {\n a_size = get_buffer(u_size_buffer_num);\n } else {\n a_size = u_size_constant;\n }\n\n if (u_last_size_buffer_num > -0.5) {\n a_last_size = get_buffer(u_last_size_buffer_num);\n } else {\n a_last_size = u_last_size_constant;\n }\n\n if (u_filter_buffer_num > -0.5) {\n a_filter = get_buffer(u_filter_buffer_num);\n } else {\n a_filter = u_filter_constant;\n }\n\n if (u_last_filter_buffer_num > -0.5) {\n a_last_filter = get_buffer(u_last_filter_buffer_num);\n } else {\n a_last_filter = u_last_filter_constant;\n }\n\n if (u_x0_buffer_num > -0.5) {\n a_x0 = get_buffer(u_x0_buffer_num);\n } else {\n a_x0 = u_x0_constant;\n }\n\n if (u_last_x0_buffer_num > -0.5) {\n a_last_x0 = get_buffer(u_last_x0_buffer_num);\n } else {\n a_last_x0 = u_last_x0_constant;\n }\n\n if (u_y0_buffer_num > -0.5) {\n a_y0 = get_buffer(u_y0_buffer_num);\n } else {\n a_y0 = u_y0_constant;\n }\n\n if (u_last_y0_buffer_num > -0.5) {\n a_last_y0 = get_buffer(u_last_y0_buffer_num);\n } else {\n a_last_y0 = u_last_y0_constant;\n }\n\n if (u_color_buffer_num > -0.5) {\n a_color = get_buffer(u_color_buffer_num);\n } else {\n a_color = ix;\n }\n\n if (u_last_color_buffer_num > -0.5) {\n a_last_color = get_buffer(u_last_color_buffer_num);\n } else {\n a_last_color = ix;\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// float ease = easeCubic(interpolation);\n// from_coord_to_gl = u_window_scale * u_zoom * pixelspace_to_glspace;\n\n float debug_mode = 0.;\n\n vec2 position = vec2(a_x, a_y);\n\n vec2 old_position = vec2(a_last_x, a_last_y);\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, u_last_x_needs_map, u_last_y_map,\n u_last_y_needs_map);\n\n bool plot_actual_position = u_grid_mode < .5;\n\n if (plot_actual_position) {\n position = calculate_position(position, u_x_transform,\n u_x_domain, u_x_range,\n u_y_transform, u_y_domain, u_y_range, u_window_scale, u_zoom, u_x_map,\n u_x_needs_map, u_y_map, u_y_needs_map);\n\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\n delay = delay * 3.;\n // delay = 0.;\n float frac = interpolate(\n u_update_time,\n delay,\n u_transition_duration + delay\n );\n\n if (u_position_interpolation_mode > 0.) {\n // If it\'s a continuous loop, just choose a random point along that loop.\n frac = fract(u_update_time/u_transition_duration);\n frac = fract(frac + randy);\n }\n\n frac = sineInOut_0(frac);\n\n if (frac <= 0.) {\n position = old_position;\n } else if (frac < 1.) {\n // position = mix(old_position, position, u_interpolation);\n frac = fract(frac);\n vec2 midpoint = box_muller(ix, 3.) * .05 *\n dot(old_position - position, old_position - position)\n + old_position / 2. + position / 2.;\n\n position = mix(\n mix(old_position, midpoint, frac),\n mix(midpoint, position, frac),\n frac);\n //position = mix(old_position, position, frac);\n } // else position just is what it is.\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\n position = position + jitterspec;\n }\n\n if (debug_mode > 0.) {\n // Just plot every point.\n gl_PointSize = 1.;\n fill = vec4(1., 1., 1., 1.);\n gl_Position = vec4(position, 1., 1.);\n return;\n }\n\n float my_filter;\n float last_filter;\n\n if (u_filter_numeric.r < 0.5) {\n my_filter = texture_float_lookup(u_filter_map, vec2(-2047., 2047.),\n vec2(0., 1.),\n 0., a_filter,\n 1., 1., vec2(0., 2.));\n } else {\n my_filter = run_filter(a_filter,\n u_filter_numeric.r, u_filter_numeric.g, u_filter_numeric.b);\n }\n if (u_filter_last_numeric.r < 0.5) {\n last_filter = texture_float_lookup(\n u_last_filter_map, u_last_filter_domain, vec2(0., 1.),\n u_last_filter_transform, a_last_filter, 0., 1., vec2(0., 2.));\n } else {\n last_filter = run_filter(a_last_filter,\n u_filter_last_numeric.r, u_filter_last_numeric.g, u_filter_last_numeric.b);\n }\n // Progress through the filters at different rates.\n if (ix_to_random(ix, 13.5) > ease) {\n my_filter = last_filter;\n }\n\n if (my_filter < 0.5) {\n gl_Position = discard_me;\n return;\n }\n\n \n float size_multiplier = texture_float_lookup(\n u_size_map, u_size_domain, u_size_range,\n u_size_transform, a_size, u_size_needs_map);\n\n float last_size_multiplier = texture_float_lookup(\n u_last_size_map, u_last_size_domain, u_last_size_range,\n u_last_size_transform, a_last_size,\n u_last_size_needs_map);\n\n size_multiplier = u_base_size * \n mix(last_size_multiplier, size_multiplier, ease);\n float depth_size_adjust = (1.0 - ix / (u_maxix));\n\n point_size_adjust = exp(log(u_k) * u_zoom_balance);\n\n gl_PointSize = point_size_adjust * size_multiplier;\n\n if (plot_actual_position && (u_jitter > 0. || u_last_jitter > 0.)) {\n\n /* JITTER */\n\n float jitter_radius_value = a_jitter_radius;\n\n float jitter_radius_fraction;\n\n // removed\n if (u_jitter_radius_lookup == -10.) {\n\n float y_frac =\n linstep(u_jitter_radius_lookup_y_domain,\n u_jitter_radius_lookup_y_constant);\n float x_frac = linstep(u_jitter_radius_lookup_x_domain, a_jitter_radius);\n\n //x_frac = 0.;\n //y_frac = .8;\n\n vec4 jitter_radius_texel = texture2D(\n u_jitter_radius_lookup_map,\n vec2(\n // Reversed \'cause of the way it\'s fed in.\n y_frac, x_frac\n ));\n\n jitter_radius_fraction = RGBAtoFloat(jitter_radius_texel);\n\n jitter_radius_value = mix(\n u_jitter_radius_lookup_z_domain.x,\n u_jitter_radius_lookup_z_domain.y,\n jitter_radius_fraction\n );\n } else {\n if (u_jitter == 0.) {\n jitter_radius_value = 0.;\n }\n }\n jitter_radius_value = 0.1;\n\n vec2 jitter = calculate_jitter(\n u_jitter, ix, u_jitter_radius_map,\n u_jitter_radius_domain,\n u_jitter_radius_range,\n u_jitter_radius_transform,\n jitter_radius_value,\n u_jitter_speed_map, u_jitter_speed_domain,\n u_jitter_speed_range,\n u_jitter_speed_transform, a_jitter_speed,\n u_jitter_radius_needs_map,\n u_jitter_speed_needs_map\n );\n\n if (ease < 1.) {\n\n vec2 last_jitter = calculate_jitter(\n //u_jitter,\n u_last_jitter,\n ix,\n u_last_jitter_radius_map,\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_speed_map, u_last_jitter_speed_domain,\n u_last_jitter_speed_range,\n u_last_jitter_speed_transform, a_last_jitter_speed,\n u_last_jitter_radius_needs_map,\n u_last_jitter_speed_needs_map\n );\n\n }\n\n if (u_jitter == 5.) {\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 + 0. * a_jitter_radius * jitter * point_size_adjust, 0., 1.);\n } else {\n gl_Position = vec4(position, 0., 1.);\n } \n if (u_color_picker_mode > 0.) {\n fill = encode_float_1604150559(ix);\n } else {\n run_color_fill(ease);\n// fill = packFloat(ix);\n }\n point_size = gl_PointSize;\n}\n',count:(t,e)=>e.manager.count,attributes:{buffer_0:(t,e)=>e.manager.regl_elements.get("ix")},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_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_constant_color:()=>void 0!==this.aes.color.current.constant?this.aes.color.current.constant:[-1,-1,-1],u_constant_last_color:()=>null!=this.aes.color.last.constant?this.aes.color.last.constant:[-1,-1,-1],u_width:({viewportWidth:t})=>t,u_height:({viewportHeight:t})=>t,u_aspect_ratio:({viewportWidth:t,viewportHeight:e})=>t/e,u_sprites(t,e){return e.sprites?e.sprites:this.fbos.dummy},u_zoom_balance:t.prop("zoom_balance"),u_base_size:(t,{prefs:e})=>e.point_size,u_maxix:(t,e)=>e.max_ix,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.filter.current.ops_to_array()},u_filter_last_numeric(){return this.aes.filter.last.ops_to_array()},u_current_alpha:()=>this.optimal_alpha,u_last_alpha:()=>this.optimal_alpha,u_jitter:()=>this.aes.jitter_radius.current.jitter_int_format,u_last_jitter:()=>this.aes.jitter_radius.last.jitter_int_format,u_zoom:(t,e)=>e.zoom_matrix}};for(const n of qe(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","jitter_speed","size","filter","character","x0","y0"])for(const t of["current","last"]){const r="current"===t?"":"last_";if(e.uniforms[`u_${r}${n}_map`]=()=>this.aes[n][t].textures.one_d,e.uniforms[`u_${r}${n}_needs_map`]=()=>this.aes[n][t].use_map_on_regl,"jitter_radius"==n&&""==r){const i=`u_${r}${n}_lookup`;e.uniforms[i]=()=>this.aes[n][t].use_lookup?1:0,e.uniforms[`${i}_map`]=()=>this.aes[n][t].lookup_texture.texture,e.uniforms[`${i}_y_constant`]=()=>+this.aes[n][t].lookup_texture.value||.5,e.uniforms[`${i}_y_domain`]=()=>this.aes[n][t].lookup_texture.y_domain,e.uniforms[`${i}_z_domain`]=()=>this.aes[n][t].lookup_texture.z_domain,e.uniforms[`${i}_x_domain`]=()=>this.aes[n][t].lookup_texture.x_domain}e.uniforms[`u_${r}${n}_domain`]=()=>this.aes[n][t].domain,"filter"!=n&&"color"!=n&&(e.uniforms[`u_${r}${n}_range`]=()=>this.aes[n][t].range),e.uniforms[`u_${r}${n}_transform`]=()=>{const e=this.aes[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`]=()=>void 0!==this.aes[n][t].constant?this.aes[n][t].constant:this.aes[n][t].default_val,e.uniforms[`u_${r}${n}_buffer_num`]=(e,{aes_to_buffer_num:r})=>{const i=r[`${n}--${t}`];return null==i?-1:i}}return this._renderer=t(e),this._renderer}allocate_aesthetic_buffers(){const t=[],e=["x","y","color","size","jitter_radius","jitter_speed","character","x0","y0","filter"];for(const o of e)for(const e of["current","last"])this.aes[o]&&this.aes[o][e].field&&t.push({aesthetic:o,time:e,field:this.aes[o][e].field});t.sort(((t,n)=>t.time{if(-1===B_.indexOf(t))return[];const n=[];for(const r of[e.current,e.last])r.field&&n.push(r.field);return n})).flat();for(const a of o.concat(["ix"])){const t=this.regl_elements.get(a);if(null===t)return!1;if(void 0===t){if(!this.tile.ready)return!1;if(r.set(a,null),!e)return n.deferred_functions.push((()=>this.create_regl_buffer(a))),!1;this.create_regl_buffer(a)}}return!0}get count(){const{tile:t,regl_elements:e}=this;return e.has("_count")?e.get("_count"):t.ready?(e.set("_count",t.table.length),e.get("_count")):void 0}create_buffer_data(t){const{tile:e}=this;if(!e.ready)throw"Tile table not present.";const n=e.table.getColumn(`${t}_dict_index`)||e.table.getColumn(t);if(!n){throw`Requested ${t} but table has columns ${e.table.schema.fields.map((t=>t.name)).join(", ")}`}if(n.dictionary){const r=new Float32Array(e.table.length);let i=0;for(const o of n.data.values){const n=e.local_dictionary_lookups[t].get(o);r[i]=e.dictionary_lookups[t].get(n),i+=1}return r}if(n.data.values.constructor!==Float32Array){const t=new Float32Array(e.table.length);for(let r=0;rthis.buffer_size&&this.generate_new_buffer();const n={buffer:this.buffers[0],offset:this.pointer,stride:e};return this.pointer+=t*e,n}}const z_=Symbol("Comlink.proxy"),F_=Symbol("Comlink.endpoint"),N_=Symbol("Comlink.releaseProxy"),L_=Symbol("Comlink.thrown"),C_=t=>"object"==typeof t&&null!==t||"function"==typeof t,R_=new Map([["proxy",{canHandle:t=>C_(t)&&t[z_],serialize(t){const{port1:e,port2:n}=new MessageChannel;return P_(t,e),[n,[n]]},deserialize:t=>(t.start(),V_(t))}],["throw",{canHandle:t=>C_(t)&&L_ in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function P_(t,e=self){e.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:i,type:o,path:a}=Object.assign({path:[]},r.data),s=(r.data.argumentList||[]).map(X_);let u;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(o){case"GET":u=n;break;case"SET":e[a.slice(-1)[0]]=X_(r.data.value),u=!0;break;case"APPLY":u=n.apply(e,s);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[z_]:!0})}(new n(...s));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;P_(t,n),u=W_(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(c){u={value:c,[L_]:0}}Promise.resolve(u).catch((t=>({value:t,[L_]:0}))).then((t=>{const[r,a]=q_(t);e.postMessage(Object.assign(Object.assign({},r),{id:i}),a),"RELEASE"===o&&(e.removeEventListener("message",n),U_(e))}))})),e.start&&e.start()}function U_(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function V_(t,e){return G_(t,[],e)}function $_(t){if(t)throw new Error("Proxy has been released and is not useable")}function G_(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if($_(r),o===N_)return()=>Z_(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{U_(t),r=!0}));if("then"===o){if(0===e.length)return{then:()=>i};const n=Z_(t,{type:"GET",path:e.map((t=>t.toString()))}).then(X_);return n.then.bind(n)}return G_(t,[...e,o])},set(n,i,o){$_(r);const[a,s]=q_(o);return Z_(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(X_)},apply(n,i,o){$_(r);const a=e[e.length-1];if(a===F_)return Z_(t,{type:"ENDPOINT"}).then(X_);if("bind"===a)return G_(t,e.slice(0,-1));const[s,u]=H_(o);return Z_(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(X_)},construct(n,i){$_(r);const[o,a]=H_(i);return Z_(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(X_)}});return i}function H_(t){const e=t.map(q_);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Y_=new WeakMap;function W_(t,e){return Y_.set(t,e),t}function q_(t){for(const[e,n]of R_)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Y_.get(t)||[]]}function X_(t){switch(t.type){case"HANDLER":return R_.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Z_(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}class J_ extends Map{get_count(t){return super.get(t)||0}get_counter(t){const e=super.get(t);return e||(super.set(t,new J_),super.get(t))}merge(t){for(let e of t.value_iter())this.add(...e)}inc(...t){this.add(1,...t)}add(t,...e){if(1===e.length)this.set(e[0],this.get_count(e[0])+t);else{this.get_counter(e[0]).add(t,...e.slice(1))}}is_counter(){}values(){return Array.from(this.value_iter())}*value_iter(){for(let[t,e]of this.entries())if(e.is_counter)for(let n of e.value_iter())yield[n[0],t,...n.slice(1)];else yield[e,t]}}class K_ extends class{}{constructor(t,e,n,r){super(),this.url=t,this.parent=n,void 0===n&&(this._mutations=r.mutate),this.key=e,this.codes=this.key.split("/").map((t=>+t)),this.max_ix=void 0,this.promise=Promise.resolve(1),this.download_state="Unattempted",this.class=new.target}get dictionary_lookups(){return this.parent.dictionary_lookups}is_visible(t,e){if(this.min_ix>t)return!1;if(void 0===e)return!1;const n=this.extent;return!(n.x[0]>e.x[1]||n.x[1]e.y[1]||n.y[1]t.download()));if(this._children)for(const r of this._children)n.concat(r.download_to_depth(t,e,!1));return Promise.all(n)}return this.download().then((r=>{if(this.max_ixn.download_to_depth(t,e)));return Promise.all(n).then((t=>this))}return this}))}get tileWorker(){return this.parent.tileWorker}get needed_mutations(){this._current_mutations=this._current_mutations||{};const t={};for(const[e,n]of Object.entries(this.mutations)){n!=this._current_mutations[e]&&(t[e]=n)}return t}apply_mutations_once(){const{needed_mutations:t}=this;return 0===Object.keys(t).length?Promise.resolve("complete"):void 0===t?Promise.resolve("deferred"):this.extend_promise((()=>(this._table=void 0,this.tileWorker.run_transforms(t,W_(this._table_buffer,[this._table_buffer])).then((([e,n])=>(this._table_buffer=e,Object.assign(this._current_mutations,t),this.local_dictionary_lookups=n,this.update_master_dictionary_lookups(),"changed"))))))}*points(t,e=!1){if(this.is_visible(1e100,t)){for(const e of this)tm([e.x,e.y],t)&&(yield e);if(0==e){for(const n of this.children)if(n.ready)for(const r of n.points(t,e))tm([r.x,r.y],t)&&(yield r)}else{let n=this.children.map((n=>{const r={t:n,iterator:n.points(t,e)};return r.next=r.iterator.next(),r}));for(n=n.filter((t=>t.next.value));n.length>0;){let t=0;for(let e=1;e0?this._table=Xa.from(this._table_buffer):void 0}get min_ix(){return void 0!==this._min_ix?this._min_ix:this.parent?this.parent.max_ix+1:void 0}download(){if(this._download)return this._download;if(this._already_called)throw"Illegally attempting to download twice";this._already_called=!0;const t=`${window.location.origin}/${this.url}/${this.key}.feather`;return this.download_state="In progress",this._download=this.tileWorker.fetch(t,this.needed_mutations).catch((t=>{throw this.download_state="Errored",t})).then((([t,e,n])=>(this.download_state="Complete",this._current_mutations=JSON.parse(JSON.stringify(this.needed_mutations)),this._table_buffer=t,this._extent=JSON.parse(e.get("extent")),this.child_locations=JSON.parse(e.get("children")),this._min_ix=this.table.getColumn("ix").get(0),this.max_ix=this.table.getColumn("ix").get(this.table.length-1),this.highest_known_ix=this.max_ix,this._current_mutations=JSON.parse(JSON.stringify(this.needed_mutations)),this.local_dictionary_lookups=n,this.update_master_dictionary_lookups(),this.table))),this._download}get schema(){return this.download().then((t=>this._schema))}extend_promise(t){return this.promise=this.promise.then((()=>t())),this.promise}get ready(){return this._table_buffer&&this._table_buffer.byteLength>0}find_closest(t,e=1/0,n){let r,i=e;return this.visit((e=>{if(!(function(t,e,n){if(void 0===t)return parseFloat("inf");const r=Math.max(t.x[0]-e,0,e-t.x[1]),i=Math.max(t.y[0]-n,0,n-t.y[1]);return Math.sqrt(r*r+i*i)}(e.extent,t[0],t[1])>i)&&(e._kdtree||e.kdtree(),e._kdtree)){const o=e._kdtree.find(t[0],t[1],i,n);if(o){const e=Math.sqrt((o.x-t[0])**2+(o.y-t[1])**2);r=o,i=e}}})),r}get _schema(){if(this.__schema)return this.__schema;const t=[];for(const e of this.table.schema.fields){const{name:n,type:r,nullable:i}=e;r&&5==r.typeId&&t.push({name:n,type:"string"}),r&&r.dictionary&&t.push({name:n,type:"dictionary",keys:this.table.getColumn(n).data.dictionary.toArray(),extent:[-2047,this.table.getColumn(n).data.dictionary.length-2047]}),r&&8==r.typeId&&t.push({name:n,type:"date",extent:Ge(this.table.getColumn(n).data.values)}),r&&3==r.typeId&&t.push({name:n,type:"float",extent:Ge(this.table.getColumn(n).data.values)})}return this.__schema=t,t}*yielder(){for(const t of this.table)t&&(yield t)}update_master_dictionary_lookups(){const t=this.local_dictionary_lookups;for(const[e,n]of Object.entries(t)){this.dictionary_lookups[e]=this.dictionary_lookups[e]||new Map;const t=this.dictionary_lookups[e];let r=0;for(const[i,o]of n.entries())t.has(o)||(r=t.size/2,t.set(r,o),t.set(o,r)),this.dictionary_lookups[e]}this.dictionary_lookups}get theoretical_extent(){const t=this.root_extent,[e,n,r]=this.codes,i=(t.x[1]-t.x[0])/2**e,o=(t.y[1]-t.y[0])/2**e;return{x:[t.x[0]+n*i,t.x[0]+(n+1)*i],y:[t.y[0]+r*o,t.y[0]+(r+1)*o]}}get extent(){return this._extent?this._extent:this.theoretical_extent}get mutations(){return this.parent.mutations}[Symbol.iterator](){return this.yielder()}count(...t){const e=[];for(const r of t)e.push(this.table.getColumn(r));const n=new J_;for(let r=0;rt.get(r)));n.inc(...t)}return n}get root_extent(){return this.parent.root_extent}}class Q_ extends K_{constructor(t,e={}){let n;if(t.match(/(\/[0-9]+){3}/)){const e=t.split("/");t=e.slice(0,-3).join("/"),n=e.slice(-3).join("/")}else n="0/0/0";super(t,n,void 0,e),this.extend_promise((()=>this.download())),this._min_ix=1}get root_extent(){if(this._extent)return this._extent}log_tiles(t=1,e=(t=>`${t.children.length}`)){const n=[],r=qe(2**t);for(const i of r){n[i]=[];for(const t of r)n[i][t]=" ";n[i][2**t]="|"}n[2**t]=Array(2**t+1).fill("-"),this.visit((r=>{const[i,o,a]=r.key.split("/").map((t=>+t));i==t&&(n[a][o]="_",n[a][o]=e(r))})),n.map((t=>t.join("")))}download_most_needed_tiles(t,e,n=4){this._download_queue||(this._download_queue=new Set);const r=this._download_queue;if(r.size>=n)return;const i=[];this.visit((e=>{const n=function(t,e){const n=t.extent;nm(n),nm(e),n.x[0]>e.x[1]||n.x[1]e.y[1]||(n.y[1],e.y[0]);const r={x:[He([e.x[0],n.x[0]]),Ye([e.x[1],n.x[1]])],y:[He([e.y[0],n.y[0]]),Ye([e.y[1],n.y[1]])]},{x:i,y:o}=r;let a=0;i[0]>i[1]&&(a-=1);o[0]>o[1]&&(a-=2);if(a<0)return a;return em(r)/em(e)}(e,t);i.push([n,e,t,e.download_state])})),i.sort(((t,e)=>t[0]-e[0]));for(const[o,a,s,u]of i);for(;i.length&&r.sizee||t<0||"Unattempted"===n.download_state&&(r.add(n.key),n.download().catch((t=>{throw console.warn("Error on",n.key),r.delete(n.key),t})).then((()=>r.delete(n.key))))}}get children(){if(void 0!==this._children)return this._children;if("Complete"!==this.download_state)return[];this._children=[];for(const t of this.child_locations)this._children.push(new K_(this.url,t,this));return this._children}get mutations(){return this._mutations?this._mutations:this._mutations={}}findPoint(t){return this.map((t=>t)).filter((e=>e.table&&e.min_ixt)).map((e=>{const n=$e(e.table.getColumn("ix").data.values,t);return e.table.get(n)&&e.table.get(n).ix===t?e.table.get(n):null})).filter((t=>t))}apply_mutations(t,e=!1){Object.assign(this.mutations,t);const n=this.map((e=>e.apply_mutations_once(t)));return e?n:Promise.all(n)}get dictionary_lookups(){return this._dictionary_lookups?this._dictionary_lookups:this._dictionary_lookups={}}get tileWorker(){if(void 0!==this._tileWorkers)return this._tileWorkers.unshift(this._tileWorkers.pop()),this._tileWorkers[0];this._tileWorkers=[];for(const t of qe(8))console.log(`Allocating worker ${t}`),this._tileWorkers.push(V_(new Worker("worker.js")));return this._tileWorkers[0]}map(t,e=!1){const n=[];return this.visit((e=>{n.push(t(e))}),e=e),n}visit(t,e=!1,n=(()=>!0)){const r=[this],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)}}function tm(t,e){return void 0===e||t[0]e.x[0]&&t[1]e.y[0]}function em(t){return(t.x[1]-t.x[0])*(t.y[1]-t.y[0])}const nm=function(t){if(t.x[1]t.arrayBuffer())).then((t=>{const e=Xa.from(t);return this.table=e,"complete"}))),this._promise}get_cached_crosstab_texture(t,e,n){const{x:r,y:i,z:o}=t,a=`${r}-${i}-${o}`;if(this.textures.get(a))return this.textures.get(a);const{crosstabs:s,y_domain:u,x_domain:c,shape:f}=this.crosstab_array(t,e),l=__(s);return this.textures.set(a,{texture:n.texture({type:"uint8",format:"rgba",data:l.array,height:f[0],width:s[0].length}),x_domain:c,y_domain:u,z_domain:l.extent,shape:f}),console.log(l.extent,l.array),this.textures.get(a)}crosstab_array(t,e={}){const n=new im,r=new im,{x:i,y:o,z:a}=t,s=this.table,u=s.getColumn(o).data.values,c=s.getColumn(i).toArray(),f=s.getColumn(a).toArray();e.x?n.prepopulate(e.x(),!1):n.prepopulate(c),e.y?r.prepopulate(e.y(),!0):r.prepopulate(u);const l=qe(n.size).map((t=>new Array(r.size).fill(0)));for(let d=0;dt-2047)),y_domain:Ge(u)}}}class im extends Map{get(t){return void 0!==super.get(t)?super.get(t):this.fixed?super.get("Other"):(super.set(t,this.size),super.get(t))}prepopulate(t,e=!0){const n=[...new Set(t)];e&&n.sort();for(const r of n)this.get(r);this.fixed=!0}}class om{constructor(t,e){console.log({regl:t}),this.feature_set=e,this.element_handler=new Map,this.coord_handler=new am(t),this.props=new Map,this.regl=t,this.prepare_features(),this.prepare_regl()}prepare_regl(){const{line_buffer:t,meta:e,regl:n}=this,r={depth:{enable:!1},stencil:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]},primitive:"triangle",frag:"\nprecision mediump float;\n#define GLSLIFY 1\nuniform vec4 u_color;\nvoid main() {\n gl_FragColor = u_color;\n}\n",vert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a_position;\n\nuniform mat3 u_window_scale;\nuniform mat3 u_zoom;\nuniform float u_height;\nuniform float u_width;\n\nmat3 pixelspace_to_glspace;\n\nvec2 calculate_position(in vec2 position,\n in mat3 window_scale,\n in mat3 zoom) {\n vec3 pos2d = vec3(position, 1.0) * window_scale * zoom;\n pos2d = pos2d * pixelspace_to_glspace;\n return pos2d.xy;\n}\n\nvoid main() {\n pixelspace_to_glspace = mat3(\n 2. / u_width, 0., -1.,\n 0., - 2. / u_height, 1.,\n 0., 0., 1.\n );\n\n vec2 position = calculate_position(a_position,\n u_window_scale, u_zoom);\n gl_Position = vec4(position, 1., 1.);\n}\n",elements:function(t,e){return e.elements},attributes:{a_position:(t,{position:e})=>e},uniforms:{u_centroid:n.prop("centroid"),u_theta:(t,{angle:e})=>e,u_scale:(t,{scale:e})=>e,u_incidence:(t,{radial_jitter_type:e})=>"distortion"==e?1:0,u_color:(t,{color:e,alpha:n})=>[...e,n],u_width:({viewportWidth:t})=>t,u_height:({viewportHeight:t})=>t,u_aspect_ratio:({viewportWidth:t,viewportHeight:e})=>t/e,u_zoom_balance:n.prop("zoom_balance"),u_window_scale:n.prop("webgl_scale"),u_zoom:function(t,e){return[[e.transform.k,0,e.transform.x],[0,e.transform.k,e.transform.y],[0,0,1]].flat()}}};this._render=this.regl(r)}render(t){const e=[];for(let n of this.features){n.alpha=1,n.color=[.2,.2,.2];const r={centroid:[n.properties.centroid_x,n.properties.centroid_y],color:n.color?n.color:[.5,.5,.5],angle:n.angle?n.angle:0,scale:n.scale?n.scale:1,alpha:n.alpha?n.alpha:1,position:n.coords,elements:n.vertices,radial_jitter_type:"distortion",translate:n.translate?n.translate:[0,0]};Object.assign(r,t),e.push(r)}this._render(e)}prepare_features(){this.features=[];const{feature_set:t,features:e,element_handler:n,coord_handler:r}=this;for(let i=0;ithis.size&&(this.current_buffer+=1,this.buffers[this.current_buffer]=this.regl.buffer({length:this.size,type:"float",usage:"static"}),this.current_position=0);const r=this.buffers[this.current_buffer];r.subdata(e,this.current_position);const i={buffer:r,stride:n||8,offset:this.current_position};return this.lookup.set(t,i),this.current_position+=4*e.length,i}}const sm=[{id:"canvas-2d-background",nodetype:"canvas"},{id:"webgl-canvas",nodetype:"canvas"},{id:"canvas-2d",nodetype:"canvas"},{id:"deepscatter-svg",nodetype:"svg"}];return class{constructor(t,e,n){this.bound=!1,void 0===t?(console.log(t),console.warn("Must bind to selector manually")):this.bind(t,e,n),this.d3={select:pt}}bind(t,e,n){if(this.width=e,this.height=n,this.div=pt(t),this.div.empty())throw console.error(t),"Must pass a valid div selector";console.log(this.div),this.elements=[],this.prefs={zoom_balance:.35,duration:2,point_size:1,alpha:.4,click_function:"alert(`You clicked on a point with data ${JSON.stringify(datum)}`)"};for(const r of sm){const t=this.div.append("div").attr("id",`container-for-${r.id}`).style("position","fixed").style("top",0).style("left",0).style("pointer-events","deepscatter-svg"==r.id?"auto":"none");t.append(r.nodetype).attr("id",r.id).attr("width",e||window.innerWidth).attr("height",n||window.innerHeight),this.elements.push(t)}this.bound=!0}async reinitialize(){const{prefs:t}=this;this._root=new Q_(this.source_url,t),await this._root.download(),this._renderer=new M_("#container-for-webgl-canvas",this._root,this),this._zoom=new xh("#deepscatter-svg",this.prefs),this._zoom.attach_tiles(this._root),this._zoom.attach_renderer("regl",this._renderer),this._zoom.initialize_zoom();const e=pt("#container-for-canvas-2d-background").select("canvas").node().getContext("2d");return e.fillStyle=t.background_color||"rgba(133, 133, 111, .8)",e.fillRect(0,0,2*window.innerWidth,2*window.innerHeight),this._renderer.initialize(),this._root.promise}registerPolygonMap(t){const{file:e,color:n}=t;this.feather_features||(this.feather_features={},this._renderer.geo_polygons=[]),this.feather_features[e]||(this.feather_features[e]="in progress",fetch(e).then((t=>t.arrayBuffer())).then((t=>{const e=Xa.from(t),n=new om(this._renderer.regl,e);this._renderer.geo_polygons.push(n)})))}visualize_tiles(){const t=this,e=t.elements[2].selectAll("canvas").node().getContext("2d");e.clearRect(0,0,1e4,1e4);const{x_:n,y_:r}=t._zoom.scales();e.strokeStyle="#888888";const i=t._root.map((t=>t));for(const o of qe(13))setTimeout((()=>{for(const t of i){if(t.codes[0]!=o)continue;if(!t.extent)continue;const[i,a]=t.extent.x.map((t=>n(t))),[s,u]=t.extent.y.map((t=>r(t))),c=t.codes[0];e.lineWidth=8/Math.sqrt(c),e.globalAlpha=.33,e.strokeRect(i,s,a-i,u-s),"Unattempted"!==t.download_state&&e.fillRect(i,s,a-i,u-s),e.globalAlpha=1}}),400*o)}update_prefs(t){t.encoding&&t.encoding.alpha&&(console.warn("Setting alpha through encoding--deprecated."),t.alpha=t.encoding.alpha),t.jitter&&(console.warn("Setting jitter type through base argument--deprectated"),"number"==typeof t.encoding.jitter_radius&&(t.encoding.jitter_radius={constant:t.encoding.jitter_radius}),t.encoding.jitter_radius.method=t.jitter);for(const e in["jitter","alpha","max_points"])t[`last_${e}`]=this.prefs[e]||void 0;if(this.prefs.encoding&&t.encoding)for(const e of Object.keys(this.prefs.encoding))t.encoding[e]&&(this.prefs.encoding[e]=t.encoding[e]);bs(this.prefs,t)}load_lookup_table(t){if(this.lookup_tables=this.lookup_tables||new Map,this.lookup_promises.get(t))return this.lookup_promises.get(t);if(null===this.lookup_promises.get(t))return;this.lookup_promises.set(t,null);const e=new rm(this.prefs,t);e.load().then((()=>this.lookup_tables.set(t,e))),this.lookup_promises.set(t,e.load())}async plotAPI(t={}){if(null==t)return Promise.resolve(1);if(this.update_prefs(t),t.lookup_tables){const e=[];this.lookup_promises=this.lookup_promises||new Map;for(const n of t.lookup_tables)this.lookup_promises.get(n)||e.push(this.load_lookup_table(n));await Promise.all(e)}if(t.source_url&&t.source_url!==this.source_url&&(this.source_url=t.source_url,await this.reinitialize()),t.basemap_gleofeather&&(t.polygons=[{file:t.basemap_gleofeather}]),t.polygons)for(const r of t.polygons)this.registerPolygonMap(r);await this._root.promise,t.mutate&&this._root.apply_mutations(t.mutate);const{width:e,height:n}=this;this.update_prefs(t),void 0!==t.zoom&&(null===t.zoom?(this._zoom.zoom_to(1,e/2,n/2),t.zoom=void 0):t.zoom.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=this._renderer.regl.frame((()=>{this._renderer.tick("Basic")})),this._zoom.restart_timer(6e4)}async root_table(){return!!this._root&&this._root.table}get query(){const t=JSON.parse(JSON.stringify(this.prefs));return t.zoom={bbox:this._renderer.zoom.current_corners()},t}top_n_points(t=20){const{_root:e,_renderer:n}=this,r=n.zoom.current_corners(),i=[],o=n.aes.filter.current.get_function();for(const a of e.points(r,!0))if(o(a)&&i.push(a),i.length>=t)return i;return i}drawContours(t,e){const n=(e||pt("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=He([.45,.25*Math.exp(Math.log(this._zoom.transform.k/2))]);const t=Ne(Pe().scale(this._zoom.transform.k).translate([this._zoom.transform.x,this._zoom.transform.y]),n);n.beginPath(),t(r),n.fill()}}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(e.length){if(e[0].length)return e.map(t);e[0]=n(i.invert(e[0])),e[1]=r(o.invert(e[1]))}}}(e),this.drawContours(e)}}}));