diff --git a/dist/deepscatter.es.js b/dist/deepscatter.es.js new file mode 100644 index 000000000..b5afc9b4f --- /dev/null +++ b/dist/deepscatter.es.js @@ -0,0 +1,29 @@ +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+="",i=n.indexOf(":");return i>=0&&"xmlns"!==(n=t.slice(0,i))&&(t=t.slice(i+1)),e.hasOwnProperty(n)?{space:e[n],local:t}:t}function i(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===t&&n.documentElement.namespaceURI===t?n.createElement(e):n.createElementNS(i,e)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var e=n(t);return(e.local?r:i)(e)}function l(){}function a(t){return null==t?l:function(){return this.querySelector(t)}}function s(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function u(){return[]}function c(t){return null==t?u:function(){return this.querySelectorAll(t)}}function d(t){return function(){return this.matches(t)}}function h(t){return function(e){return e.matches(t)}}var b=Array.prototype.find;function p(){return this.firstElementChild}var m=Array.prototype.filter;function f(){return Array.from(this.children)}function y(t){return new Array(t.length)}function Z(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function X(t){return function(){return t}}function G(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function R(t){return function(){this.removeAttribute(t)}}function g(t){return function(){this.removeAttributeNS(t.space,t.local)}}function L(t,e){return function(){this.setAttribute(t,e)}}function x(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Y(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function K(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 H(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function J(t){return function(){this.style.removeProperty(t)}}function w(t,e,n){return function(){this.style.setProperty(t,e,n)}}function _(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function I(t,e){return t.style.getPropertyValue(e)||H(t).getComputedStyle(t,null).getPropertyValue(e)}function N(t){return function(){delete this[t]}}function C(t,e){return function(){this[t]=e}}function U(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function F(t){return t.trim().split(/^|\s+/)}function B(t){return t.classList||new k(t)}function k(t){this._node=t,this._names=F(t.getAttribute("class")||"")}function T(t,e){for(var n=B(t),i=-1,r=e.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function lt(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var dt=[null];function ht(t,e){this._groups=t,this._parents=e}function bt(){return new ht([[document.documentElement]],dt)}function pt(t){return"string"==typeof t?new ht([[document.querySelector(t)]],[document.documentElement]):new ht([[t]],dt)}ht.prototype=bt.prototype={constructor:ht,select:function(t){"function"!=typeof t&&(t=a(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=g&&(g=R+1);!(S=f[g])&&++g=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);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,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?J:"function"==typeof e?_:w)(t,e,null==n?"":n)):I(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?N:"function"==typeof e?U:C)(t,e)):this.node()[t]},classed:function(t,e){var n=F(t+"");if(arguments.length<2){for(var i=B(this.node()),r=-1,o=n.length;++r0){for(o=t[--r];r>0&&(e=o,n=t[--r],o=e+n,i=n-(o-e),!i););r>0&&(i<0&&t[r-1]<0||i>0&&t[r-1]>0)&&(n=2*i,e=o+n,n==e-o&&(o=e))}return o}}var ft=Math.PI,yt=2*ft,Zt=180/ft,Xt=ft/180,Gt=Math.abs,Wt=Math.cos,Vt=Math.sin,vt=Math.sqrt;function St(){}function Rt(t,e){t&&Lt.hasOwnProperty(t.type)&&Lt[t.type](t,e)}var gt={Feature:function(t,e){Rt(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i=0;--o)r.point((c=u[o])[0],c[1]);else i(h.x,h.p.x,-1,r);h=h.p}u=(h=h.o).z,b=!b}while(!h.v);r.lineEnd()}}}function wt(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i0)do{u.point(0===c||3===c?t:n,c>1?i:e)}while((c=(c+a+4)%4)!==d);else u.point(o[0],o[1])}function l(i,r){return Gt(i[0]-t)<1e-6?r>0?0:3:Gt(i[0]-n)<1e-6?r>0?2:1:Gt(i[1]-e)<1e-6?r>0?1:0:r>0?3:2}function a(t,e){return s(t.x,e.x)}function s(t,e){var n=l(t,1),i=l(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){var s,u,c,d,h,b,p,m,f,y,Z,X,G,W=l,V=(G=[],{point:function(t,e,n){X.push([t,e,n])},lineStart:function(){G.push(X=[])},lineEnd:St,rejoin:function(){G.length>1&&G.push(G.pop().concat(G.shift()))},result:function(){var t=G;return G=[],X=null,t}}),v={point:S,lineStart:function(){v.point=R,u&&u.push(c=[]);y=!0,f=!1,p=m=NaN},lineEnd:function(){s&&(R(d,h),b&&f&&V.rejoin(),s.push(V.result()));v.point=S,f&&W.lineEnd()},polygonStart:function(){W=V,s=[],u=[],Z=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=u.length;ni&&(h-o)*(i-l)>(b-l)*(t-o)&&++e:b<=i&&(h-o)*(i-l)<(b-l)*(t-o)&&--e;return e}(),n=Z&&e,r=(d=s,s=Array.from(function*(t){for(const e of t)yield*e}(d))).length;var d;(n||r)&&(l.polygonStart(),n&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),r&&Jt(s,a,e,o,l),l.polygonEnd());W=l,s=u=c=null}};function S(t,e){r(t,e)&&W.point(t,e)}function R(o,l){var a=r(o,l);if(u&&c.push([o,l]),y)d=o,h=l,b=a,y=!1,a&&(W.lineStart(),W.point(o,l));else if(a&&f)W.point(o,l);else{var s=[p=Math.max(-1e9,Math.min(1e9,p)),m=Math.max(-1e9,Math.min(1e9,m))],X=[o=Math.max(-1e9,Math.min(1e9,o)),l=Math.max(-1e9,Math.min(1e9,l))];!function(t,e,n,i,r,o){var l,a=t[0],s=t[1],u=0,c=1,d=e[0]-a,h=e[1]-s;if(l=n-a,d||!(l>0)){if(l/=d,d<0){if(l0){if(l>c)return;l>u&&(u=l)}if(l=r-a,d||!(l<0)){if(l/=d,d<0){if(l>c)return;l>u&&(u=l)}else if(d>0){if(l0)){if(l/=h,h<0){if(l0){if(l>c)return;l>u&&(u=l)}if(l=o-s,h||!(l<0)){if(l/=h,h<0){if(l>c)return;l>u&&(u=l)}else if(h>0){if(l0&&(t[0]=a+u*d,t[1]=s+u*h),c<1&&(e[0]=a+c*d,e[1]=s+c*h),!0}}}}}(s,X,t,e,n,i)?a&&(W.lineStart(),W.point(o,l),Z=!1):(f||(W.lineStart(),W.point(s[0],s[1])),W.point(X[0],X[1]),a||W.lineEnd(),Z=!1)}p=o,m=l,f=a}return v}}var It,Nt,Ct,Ut,Ft=t=>t,Bt=new mt,kt=new mt,Tt={point:St,lineStart:St,lineEnd:St,polygonStart:function(){Tt.lineStart=zt,Tt.lineEnd=Qt},polygonEnd:function(){Tt.lineStart=Tt.lineEnd=Tt.point=St,Bt.add(Gt(kt)),kt=new mt},result:function(){var t=Bt/2;return Bt=new mt,t}};function zt(){Tt.point=Mt}function Mt(t,e){Tt.point=jt,It=Ct=t,Nt=Ut=e}function jt(t,e){kt.add(Ut*t-Ct*e),Ct=t,Ut=e}function Qt(){jt(It,Nt)}var Pt=1/0,Et=Pt,Dt=-Pt,Ot=Dt,At={point:function(t,e){tDt&&(Dt=t);eOt&&(Ot=e)},lineStart:St,lineEnd:St,polygonStart:St,polygonEnd:St,result:function(){var t=[[Pt,Et],[Dt,Ot]];return Dt=Ot=-(Et=Pt=1/0),t}};var qt,$t,te,ee,ne=0,ie=0,re=0,oe=0,le=0,ae=0,se=0,ue=0,ce=0,de={point:he,lineStart:be,lineEnd:fe,polygonStart:function(){de.lineStart=ye,de.lineEnd=Ze},polygonEnd:function(){de.point=he,de.lineStart=be,de.lineEnd=fe},result:function(){var t=ce?[se/ce,ue/ce]:ae?[oe/ae,le/ae]:re?[ne/re,ie/re]:[NaN,NaN];return ne=ie=re=oe=le=ae=se=ue=ce=0,t}};function he(t,e){ne+=t,ie+=e,++re}function be(){de.point=pe}function pe(t,e){de.point=me,he(te=t,ee=e)}function me(t,e){var n=t-te,i=e-ee,r=vt(n*n+i*i);oe+=r*(te+t)/2,le+=r*(ee+e)/2,ae+=r,he(te=t,ee=e)}function fe(){de.point=he}function ye(){de.point=Xe}function Ze(){Ge(qt,$t)}function Xe(t,e){de.point=Ge,he(qt=te=t,$t=ee=e)}function Ge(t,e){var n=t-te,i=e-ee,r=vt(n*n+i*i);oe+=r*(te+t)/2,le+=r*(ee+e)/2,ae+=r,se+=(r=ee*t-te*e)*(te+t),ue+=r*(ee+e),ce+=3*r,he(te=t,ee=e)}function We(t){this._context=t}We.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:St};var Ve,ve,Se,Re,ge,Le=new mt,xe={point:St,lineStart:function(){xe.point=Ye},lineEnd:function(){Ve&&Ke(ve,Se),xe.point=St},polygonStart:function(){Ve=!0},polygonEnd:function(){Ve=null},result:function(){var t=+Le;return Le=new mt,t}};function Ye(t,e){xe.point=Ke,ve=Re=t,Se=ge=e}function Ke(t,e){Re-=t,ge-=e,Le.add(vt(Re*Re+ge*ge)),Re=t,ge=e}function He(){this._string=[]}function Je(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function we(t,e){var n,i,r=4.5;function o(t){return t&&("function"==typeof r&&i.pointRadius(+r.apply(this,arguments)),Kt(t,n(i))),i.result()}return o.area=function(t){return Kt(t,n(Tt)),Tt.result()},o.measure=function(t){return Kt(t,n(xe)),xe.result()},o.bounds=function(t){return Kt(t,n(At)),At.result()},o.centroid=function(t){return Kt(t,n(de)),de.result()},o.projection=function(e){return arguments.length?(n=null==e?(t=null,Ft):(t=e).stream,o):t},o.context=function(t){return arguments.length?(i=null==t?(e=null,new He):new We(e=t),"function"!=typeof r&&i.pointRadius(r),o):e},o.pointRadius=function(t){return arguments.length?(r="function"==typeof t?t:(i.pointRadius(+t),+t),o):r},o.projection(t).context(e)}function _e(){}function Ie(t,e,n){var i=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=i&&t.clipExtent(null),Kt(n,t.stream(At)),e(At.result()),null!=i&&t.clipExtent(i),t}function Ne(t,e,n){return Ie(t,(function(n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=Math.min(i/(n[1][0]-n[0][0]),r/(n[1][1]-n[0][1])),l=+e[0][0]+(i-o*(n[1][0]+n[0][0]))/2,a=+e[0][1]+(r-o*(n[1][1]+n[0][1]))/2;t.scale(150*o).translate([l,a])}),n)}function Ce(){var t,e,n,i,r,o,l,a,s=1,u=0,c=0,d=1,h=1,b=0,p=null,m=1,f=1,y=(a={point:function(t,e){var n=G([t,e]);this.stream.point(n[0],n[1])}},function(t){var e=new _e;for(var n in a)e[n]=a[n];return e.stream=t,e}),Z=Ft;function X(){return m=s*d,f=s*h,o=l=null,G}function G(n){var i=n[0]*m,r=n[1]*f;if(b){var o=r*t-i*e;i=i*t+r*e,r=o}return[i+u,r+c]}return G.invert=function(n){var i=n[0]-u,r=n[1]-c;if(b){var o=r*t+i*e;i=i*t-r*e,r=o}return[i/m,r/f]},G.stream=function(t){return o&&l===t?o:o=y(Z(l=t))},G.postclip=function(t){return arguments.length?(Z=t,p=n=i=r=null,X()):Z},G.clipExtent=function(t){return arguments.length?(Z=null==t?(p=n=i=r=null,Ft):_t(p=+t[0][0],n=+t[0][1],i=+t[1][0],r=+t[1][1]),X()):null==p?null:[[p,n],[i,r]]},G.scale=function(t){return arguments.length?(s=+t,X()):s},G.translate=function(t){return arguments.length?(u=+t[0],c=+t[1],X()):[u,c]},G.angle=function(n){return arguments.length?(e=Vt(b=n%360*Xt),t=Wt(b),X()):b*Zt},G.reflectX=function(t){return arguments.length?(d=t?-1:1,X()):d<0},G.reflectY=function(t){return arguments.length?(h=t?-1:1,X()):h<0},G.fitExtent=function(t,e){return Ne(G,t,e)},G.fitSize=function(t,e){return function(t,e,n){return Ne(t,[[0,0],e],n)}(G,t,e)},G.fitWidth=function(t,e){return function(t,e,n){return Ie(t,(function(n){var i=+e,r=i/(n[1][0]-n[0][0]),o=(i-r*(n[1][0]+n[0][0]))/2,l=-r*n[0][1];t.scale(150*r).translate([o,l])}),n)}(G,t,e)},G.fitHeight=function(t,e){return function(t,e,n){return Ie(t,(function(n){var i=+e,r=i/(n[1][1]-n[0][1]),o=-r*n[0][0],l=(i-r*(n[1][1]+n[0][1]))/2;t.scale(150*r).translate([o,l])}),n)}(G,t,e)},G}function Ue(t,e){return null==t||null==e?NaN:te?1:t>=e?0:NaN}function Fe(t){let e=t,n=t;function i(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)<0?i=o+1:r=o}return i}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>Ue(t(e),n)}(t)),{left:i,center:function(t,n,r,o){null==r&&(r=0),null==o&&(o=t.length);const l=i(t,n,r,o-1);return l>r&&e(t[l-1],n)>-e(t[l],n)?l-1:l},right:function(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)>0?r=o:i=o+1}return i}}}He.prototype={_radius:4.5,_circle:Je(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=Je(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}},_e.prototype={constructor:_e,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 Be=Fe(Ue).left;function ke(t,e){let n,i;if(void 0===e)for(const r of t)null!=r&&(void 0===n?r>=r&&(n=i=r):(n>r&&(n=r),i=o&&(n=i=o):(n>o&&(n=o),i=i)&&(n=i);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n=r)&&(n=r)}return n}function ze(t,e){let n;if(void 0===e)for(const i of t)null!=i&&(n>i||void 0===n&&i>=i)&&(n=i);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function Me(t,e){let n=0,i=0;if(void 0===e)for(let r of t)null!=r&&(r=+r)>=r&&(++n,i+=r);else{let r=-1;for(let o of t)null!=(o=e(o,++r,t))&&(o=+o)>=o&&(++n,i+=o)}if(n)return i/n}function je(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(r);++i=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(t){return this instanceof Ae?(this.v=t,this):new Ae(t)}function qe(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),o=[];return i={},l("next"),l("throw"),l("return"),i[Symbol.asyncIterator]=function(){return this},i;function l(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){o.push([t,e,n,i])>1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof Ae?Promise.resolve(n.value.v).then(s,u):c(o[0][2],n)}catch(i){c(o[0][3],i)}var n}function s(t){a("next",t)}function u(t){a("throw",t)}function c(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function $e(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:Ae(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function tn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Oe(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}var en={};function nn(t,e,n){return e<=t&&t<=n}function rn(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}en.SIZEOF_SHORT=2,en.SIZEOF_INT=4,en.FILE_IDENTIFIER_LENGTH=4,en.SIZE_PREFIX_LENGTH=4,en.Encoding={UTF8_BYTES:1,UTF16_STRING:2},en.int32=new Int32Array(2),en.float32=new Float32Array(en.int32.buffer),en.float64=new Float64Array(en.int32.buffer),en.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],en.Long=function(t,e){this.low=0|t,this.high=0|e},en.Long.create=function(t,e){return 0==t&&0==e?en.Long.ZERO:new en.Long(t,e)},en.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},en.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},en.Long.ZERO=new en.Long(0,0),en.Builder=function(t){if(t)e=t;else var e=1024;this.bb=en.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},en.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},en.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},en.Builder.prototype.dataBuffer=function(){return this.bb},en.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},en.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 i=(n+2)*en.SIZEOF_SHORT;this.addInt16(i);var r=0,o=this.space;t:for(e=0;e=0;o--)this.writeInt8(r.charCodeAt(o))}this.prep(this.minalign,en.SIZEOF_INT+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},en.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},en.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(i+e)))throw new Error("FlatBuffers: field "+e+" must be set")},en.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(en.SIZEOF_INT,t*e),this.prep(n,t*e)},en.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},en.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n=56320)i=r;else i=(r<<10)+t.charCodeAt(n++)+-56613888;i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,l=this.bb.bytes();n>24},en.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},en.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},en.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},en.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},en.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},en.ByteBuffer.prototype.readInt64=function(t){return new en.Long(this.readInt32(t),this.readInt32(t+4))},en.ByteBuffer.prototype.readUint64=function(t){return new en.Long(this.readUint32(t),this.readUint32(t+4))},en.ByteBuffer.prototype.readFloat32=function(t){return en.int32[0]=this.readInt32(t),en.float32[0]},en.ByteBuffer.prototype.readFloat64=function(t){return en.int32[en.isLittleEndian?0:1]=this.readInt32(t),en.int32[en.isLittleEndian?1:0]=this.readInt32(t+4),en.float64[0]},en.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},en.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},en.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},en.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},en.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},en.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},en.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},en.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},en.ByteBuffer.prototype.writeFloat32=function(t,e){en.float32[0]=e,this.writeInt32(t,en.int32[0])},en.ByteBuffer.prototype.writeFloat64=function(t,e){en.float64[0]=e,this.writeInt32(t,en.int32[en.isLittleEndian?0:1]),this.writeInt32(t+4,en.int32[en.isLittleEndian?1:0])},en.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&o)))}return i},en.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},en.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+en.SIZEOF_INT},en.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},en.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=en.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+en.FILE_IDENTIFIER_LENGTH);for(var e=0;e>6*n)+i];n>0;){var o=e>>6*(n-1);r.push(128|63&o),n-=1}return r}}an.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=rn(e),this._streaming||(this._decoder=new un({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var i,r=new on(n),o=[];!r.endOfStream()&&-1!==(i=this._decoder.handler(r,r.read()));)null!==i&&(Array.isArray(i)?o.push.apply(o,i):o.push(i));if(!this._streaming){do{if(-1===(i=this._decoder.handler(r,r.read())))break;null!==i&&(Array.isArray(i)?o.push.apply(o,i):o.push(i))}while(!r.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&i)))}return e}(o)}},sn.prototype={encode:function(t,e){t=t?String(t):"",e=rn(e),this._streaming||(this._encoder=new cn(this._options)),this._streaming=Boolean(e.stream);for(var n,i=[],r=new on(function(t){for(var e=String(t),n=e.length,i=0,r=[];i57343)r.push(o);else if(56320<=o&&o<=57343)r.push(65533);else if(55296<=o&&o<=56319)if(i===n-1)r.push(65533);else{var l=t.charCodeAt(i+1);if(56320<=l&&l<=57343){var a=1023&o,s=1023&l;r.push(65536+(a<<10)+s),i+=1}else r.push(65533)}i+=1}return r}(t));!r.endOfStream()&&-1!==(n=this._encoder.handler(r,r.read()));)Array.isArray(n)?i.push.apply(i,n):i.push(n);if(!this._streaming){for(;-1!==(n=this._encoder.handler(r,r.read()));)Array.isArray(n)?i.push.apply(i,n):i.push(n);this._encoder=null}return new Uint8Array(i)}};const dn=new("undefined"!=typeof TextDecoder?TextDecoder:an)("utf-8"),hn=t=>dn.decode(t),bn=new("undefined"!=typeof TextEncoder?TextEncoder:sn),pn=t=>bn.encode(t),mn=Object.freeze({done:!0,value:void 0});class fn{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class yn{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 Zn extends yn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return De(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(mn);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return jn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return jn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return De(this,void 0,void 0,(function*(){return yield this.abort(t),mn}))}return(t){return De(this,void 0,void 0,(function*(){return yield this.close(),mn}))}read(t){return De(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return De(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(mn)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error(`${this} is closed`)}}const[Xn,Gn]=(()=>{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]})(),Wn=t=>"boolean"==typeof t,Vn=t=>"function"==typeof t,vn=t=>null!=t&&Object(t)===t,Sn=t=>vn(t)&&Vn(t.then),Rn=t=>vn(t)&&Vn(t[Symbol.iterator]),gn=t=>vn(t)&&Vn(t[Symbol.asyncIterator]),Ln=t=>vn(t)&&vn(t.schema),xn=t=>vn(t)&&"done"in t&&"value"in t,Yn=t=>vn(t)&&Vn(t.stat)&&(t=>"number"==typeof t)(t.fd),Kn=t=>vn(t)&&Hn(t.body),Hn=t=>vn(t)&&Vn(t.cancel)&&Vn(t.getReader)&&!(t instanceof yn),Jn=t=>vn(t)&&Vn(t.read)&&Vn(t.pipe)&&Wn(t.readable)&&!(t instanceof yn);var wn=en.ByteBuffer;const _n="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function In(t,e,n=0,i=e.byteLength){const r=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,r),l=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return o.set(l,n),t}function Nn(t,e){const n=function(t){const e=t[0]?[t[0]]:[];let n,i,r,o;for(let l,a,s=0,u=0,c=t.length;++st+e.byteLength),0);let r,o,l,a=0,s=-1;const u=Math.min(e||1/0,i);for(let c=n.length;++sCn(Int32Array,t),Fn=t=>Cn(Uint8Array,t),Bn=t=>(t.next(),t);const kn=t=>function*(t,e){const n=function*(t){yield t},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof _n?n(e):Rn(e)?e:n(e);return yield*Bn(function*(e){let n=null;do{n=e.next(yield Cn(t,n))}while(!n.done)}(i[Symbol.iterator]())),new t}(Uint8Array,t);function Tn(t,e){return qe(this,arguments,(function*(){if(Sn(e))return yield Ae(yield Ae(yield*$e(tn(Tn(t,yield Ae(e))))));const n=function(t){return qe(this,arguments,(function*(){yield yield Ae(yield Ae(t))}))},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof _n?n(e):Rn(e)?function(t){return qe(this,arguments,(function*(){yield Ae(yield*$e(tn(Bn(function*(t){let e=null;do{e=t.next(yield e&&e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):gn(e)?e:n(e);return yield Ae(yield*$e(tn(Bn(function(e){return qe(this,arguments,(function*(){let n=null;do{n=yield Ae(e.next(yield yield Ae(Cn(t,n))))}while(!n.done)}))}(i[Symbol.asyncIterator]()))))),yield Ae(new t)}))}const zn=t=>Tn(Uint8Array,t);function Mn(t,e,n){if(0!==t){n=n.slice(0,e+1);for(let i=-1;++i<=e;)n[i]+=t}return n}var jn={fromIterable:t=>Qn(function*(t){let e,n,i,r,o=!1,l=[],a=0;function s(){return"peek"===i?Nn(l,r)[0]:([n,l,a]=Nn(l,r),n)}({cmd:i,size:r}=yield null);const u=kn(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=isNaN(r-a)?u.next(void 0):u.next(r-a)),!e&&n.byteLength>0&&(l.push(n),a+=n.byteLength),e||r<=a)do{({cmd:i,size:r}=yield s())}while(rQn(function(t){return qe(this,arguments,(function*(){let e,n,i,r,o=!1,l=[],a=0;function s(){return"peek"===i?Nn(l,r)[0]:([n,l,a]=Nn(l,r),n)}({cmd:i,size:r}=yield yield Ae(null));const u=zn(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=isNaN(r-a)?yield Ae(u.next(void 0)):yield Ae(u.next(r-a))),!e&&n.byteLength>0&&(l.push(n),a+=n.byteLength),e||r<=a)do{({cmd:i,size:r}=yield yield Ae(s()))}while(rQn(function(t){return qe(this,arguments,(function*(){let e,n,i,r=!1,o=!1,l=[],a=0;function s(){return"peek"===n?Nn(l,i)[0]:([e,l,a]=Nn(l,i),e)}({cmd:n,size:i}=yield yield Ae(null));const u=new Pn(t);try{do{if(({done:r,value:e}=isNaN(i-a)?yield Ae(u.read(void 0)):yield Ae(u.read(i-a))),!r&&e.byteLength>0&&(l.push(Fn(e)),a+=e.byteLength),r||i<=a)do{({cmd:n,size:i}=yield yield Ae(s()))}while(iQn(function(t){return qe(this,arguments,(function*(){const e=[];let n,i,r,o="error",l=!1,a=null,s=0,u=[];function c(){return"peek"===n?Nn(u,i)[0]:([r,u,s]=Nn(u,i),r)}if(({cmd:n,size:i}=yield yield Ae(null)),t.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{e[0]=Dn(t,"end"),e[1]=Dn(t,"error");do{if(e[2]=Dn(t,"readable"),[o,a]=yield Ae(Promise.race(e.map((t=>t[2])))),"error"===o)break;if((l="end"===o)||(isFinite(i-s)?(r=Fn(t.read(i-s)),r.byteLength0&&(u.push(r),s+=r.byteLength)),l||i<=s)do{({cmd:n,size:i}=yield yield Ae(c()))}while(i{for(const[n,l]of e)t.off(n,l);try{const e=t.destroy;e&&e.call(t,n),n=void 0}catch(o){n=o||n}finally{null!=n?r(n):i()}}))}}))}(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 Qn=t=>(t.next(),t);class Pn{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 De(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 De(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=Fn(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 De(this,void 0,void 0,(function*(){return yield En(this.getBYOBReader(),new ArrayBuffer(t),0,t)}))}}function En(t,e,n,i){return De(this,void 0,void 0,(function*(){if(n>=i)return{done:!1,value:new Uint8Array(e,0,i)};const{done:r,value:o}=yield t.read(new Uint8Array(e,n,i-n));return(n+=o.byteLength){const n=t=>i([e,t]);let i;return[e,n,new Promise((r=>(i=r)&&t.once(e,n)))]};class On{}var An,qn,$n,ti,ei,ni,ii,ri,oi,li,ai,si,ui,ci,di,hi,bi,pi,mi,fi,yi,Zi,Xi,Gi,Wi,Vi,vi,Si,Ri,gi;On.prototype.data=null,(qn=An||(An={}))[qn.V1=0]="V1",qn[qn.V2=1]="V2",qn[qn.V3=2]="V3",qn[qn.V4=3]="V4",qn[qn.V5=4]="V5",(ti=$n||($n={}))[ti.UNUSED=0]="UNUSED",ti[ti.DICTIONARY_REPLACEMENT=1]="DICTIONARY_REPLACEMENT",ti[ti.COMPRESSED_BODY=2]="COMPRESSED_BODY",(ni=ei||(ei={}))[ni.Sparse=0]="Sparse",ni[ni.Dense=1]="Dense",(ri=ii||(ii={}))[ri.HALF=0]="HALF",ri[ri.SINGLE=1]="SINGLE",ri[ri.DOUBLE=2]="DOUBLE",(li=oi||(oi={}))[li.DAY=0]="DAY",li[li.MILLISECOND=1]="MILLISECOND",(si=ai||(ai={}))[si.SECOND=0]="SECOND",si[si.MILLISECOND=1]="MILLISECOND",si[si.MICROSECOND=2]="MICROSECOND",si[si.NANOSECOND=3]="NANOSECOND",(ci=ui||(ui={}))[ci.YEAR_MONTH=0]="YEAR_MONTH",ci[ci.DAY_TIME=1]="DAY_TIME",(hi=di||(di={}))[hi.NONE=0]="NONE",hi[hi.Null=1]="Null",hi[hi.Int=2]="Int",hi[hi.FloatingPoint=3]="FloatingPoint",hi[hi.Binary=4]="Binary",hi[hi.Utf8=5]="Utf8",hi[hi.Bool=6]="Bool",hi[hi.Decimal=7]="Decimal",hi[hi.Date=8]="Date",hi[hi.Time=9]="Time",hi[hi.Timestamp=10]="Timestamp",hi[hi.Interval=11]="Interval",hi[hi.List=12]="List",hi[hi.Struct_=13]="Struct_",hi[hi.Union=14]="Union",hi[hi.FixedSizeBinary=15]="FixedSizeBinary",hi[hi.FixedSizeList=16]="FixedSizeList",hi[hi.Map=17]="Map",hi[hi.Duration=18]="Duration",hi[hi.LargeBinary=19]="LargeBinary",hi[hi.LargeUtf8=20]="LargeUtf8",hi[hi.LargeList=21]="LargeList",(pi=bi||(bi={}))[pi.DenseArray=0]="DenseArray",(fi=mi||(mi={}))[fi.Little=0]="Little",fi[fi.Big=1]="Big";class Li{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 Li).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Li).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Li.startNull(t),Li.endNull(t)}}class xi{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 xi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new xi).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return xi.startStruct_(t),xi.endStruct_(t)}}class Yi{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 Yi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Yi).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Yi.startList(t),Yi.endList(t)}}class Ki{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 Ki).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ki).__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 Ki.startFixedSizeList(t),Ki.addListSize(t,e),Ki.endFixedSizeList(t)}}class Hi{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 Hi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Hi).__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 Hi.startMap(t),Hi.addKeysSorted(t,e),Hi.endMap(t)}}class Ji{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 Ji).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ji).__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):ei.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,ei.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 Ji.startUnion(t),Ji.addMode(t,e),Ji.addTypeIds(t,n),Ji.endUnion(t)}}class wi{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 wi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new wi).__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 wi.startInt(t),wi.addBitWidth(t,e),wi.addIsSigned(t,n),wi.endInt(t)}}class _i{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 _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new _i).__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):ii.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,ii.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return _i.startFloatingPoint(t),_i.addPrecision(t,e),_i.endFloatingPoint(t)}}class Ii{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 Ii).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ii).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Ii.startUtf8(t),Ii.endUtf8(t)}}class Ni{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 Ni).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ni).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Ni.startBinary(t),Ni.endBinary(t)}}class Ci{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 Ci).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ci).__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 Ci.startFixedSizeBinary(t),Ci.addByteWidth(t,e),Ci.endFixedSizeBinary(t)}}class Ui{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 Ui).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ui).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Ui.startBool(t),Ui.endBool(t)}}class Fi{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 Fi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Fi).__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,i){return Fi.startDecimal(t),Fi.addPrecision(t,e),Fi.addScale(t,n),Fi.addBitWidth(t,i),Fi.endDecimal(t)}}class Bi{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 Bi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Bi).__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):oi.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,oi.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Bi.startDate(t),Bi.addUnit(t,e),Bi.endDate(t)}}class ki{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 ki).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new ki).__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):ai.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,ai.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return ki.startTime(t),ki.addUnit(t,e),ki.addBitWidth(t,n),ki.endTime(t)}}class Ti{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 Ti).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ti).__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):ai.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,ai.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Ti.startTimestamp(t),Ti.addUnit(t,e),Ti.addTimezone(t,n),Ti.endTimestamp(t)}}class zi{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 zi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new zi).__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):ui.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,ui.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return zi.startInterval(t),zi.addUnit(t,e),zi.endInterval(t)}}class Mi{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 Mi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Mi).__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 Mi.startKeyValue(t),Mi.addKey(t,e),Mi.addValue(t,n),Mi.endKeyValue(t)}}class ji{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 ji).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new ji).__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 wi).__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):bi.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,bi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}static createDictionaryEncoding(t,e,n,i,r){return ji.startDictionaryEncoding(t),ji.addId(t,e),ji.addIndexType(t,n),ji.addIsOrdered(t,i),ji.addDictionaryKind(t,r),ji.endDictionaryEncoding(t)}}class Qi{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 Qi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Qi).__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):di.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 ji).__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 Qi).__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 Mi).__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,di.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,i,r,o,l,a){return Qi.startField(t),Qi.addName(t,e),Qi.addNullable(t,n),Qi.addTypeType(t,i),Qi.addType(t,r),Qi.addDictionary(t,o),Qi.addChildren(t,l),Qi.addCustomMetadata(t,a),Qi.endField(t)}}class Pi{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 Ei{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 Ei).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ei).__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):mi.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Qi).__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 Mi).__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,mi.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,i,r){return Ei.startSchema(t),Ei.addEndianness(t,e),Ei.addFields(t,n),Ei.addCustomMetadata(t,i),Ei.addFeatures(t,r),Ei.endSchema(t)}}(Zi=yi||(yi={}))[Zi.LZ4_FRAME=0]="LZ4_FRAME",Zi[Zi.ZSTD=1]="ZSTD",(Gi=Xi||(Xi={}))[Gi.BUFFER=0]="BUFFER",(Vi=Wi||(Wi={}))[Vi.NONE=0]="NONE",Vi[Vi.Schema=1]="Schema",Vi[Vi.DictionaryBatch=2]="DictionaryBatch",Vi[Vi.RecordBatch=3]="RecordBatch",Vi[Vi.Tensor=4]="Tensor",Vi[Vi.SparseTensor=5]="SparseTensor";class Di{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 Oi{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 Oi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Oi).__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):yi.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Xi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,yi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Xi.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return Oi.startBodyCompression(t),Oi.addCodec(t,e),Oi.addMethod(t,n),Oi.endBodyCompression(t)}}class Ai{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 Ai).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Ai).__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 Di).__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 Pi).__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 Oi).__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,i,r){return Ai.startRecordBatch(t),Ai.addLength(t,e),Ai.addNodes(t,n),Ai.addBuffers(t,i),Ai.addCompression(t,r),Ai.endRecordBatch(t)}}class qi{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 qi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new qi).__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 Ai).__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,i){return qi.startDictionaryBatch(t),qi.addId(t,e),qi.addData(t,n),qi.addIsDelta(t,i),qi.endDictionaryBatch(t)}}class $i{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 $i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new $i).__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):An.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Wi.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 Mi).__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,An.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Wi.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,i,r,o){return $i.startMessage(t),$i.addVersion(t,e),$i.addHeaderType(t,n),$i.addHeader(t,i),$i.addBodyLength(t,r),$i.addCustomMetadata(t,o),$i.endMessage(t)}}function tr(t,e,n,i){return 0!=(n&1<>i}function nr(t,e,n){const i=n.byteLength+7&-8;if(t>0||n.byteLength>3):ir(new rr(n,t,e,null,tr)).subarray(0,i)),r}return n}function ir(t){const e=[];let n=0,i=0,r=0;for(const l of t)l&&(r|=1<0)&&(e[n++]=r);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"}(vi||(vi={})),(Ri=Si||(Si={}))[Ri.OFFSET=0]="OFFSET",Ri[Ri.DATA=1]="DATA",Ri[Ri.VALIDITY=2]="VALIDITY",Ri[Ri.TYPE=3]="TYPE";class rr{constructor(t,e,n,i,r){this.bytes=t,this.length=n,this.context=i,this.get=r,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=e+(e%8==0?0:8-e%8);return or(t,e,r)+or(t,i,n)+function(t,e,n){let i=0,r=0|e;const o=new DataView(t.buffer,t.byteOffset,t.byteLength),l=void 0===n?t.byteLength:r+n;for(;l-r>=4;)i+=lr(o.getUint32(r)),r+=4;for(;l-r>=2;)i+=lr(o.getUint16(r)),r+=2;for(;l-r>=1;)i+=lr(o.getUint8(r)),r+=1;return i}(t,r>>3,i-r>>3)}function lr(t){let e=0|t;return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class ar{static isNull(t){return t&&t.typeId===vi.Null}static isInt(t){return t&&t.typeId===vi.Int}static isFloat(t){return t&&t.typeId===vi.Float}static isBinary(t){return t&&t.typeId===vi.Binary}static isUtf8(t){return t&&t.typeId===vi.Utf8}static isBool(t){return t&&t.typeId===vi.Bool}static isDecimal(t){return t&&t.typeId===vi.Decimal}static isDate(t){return t&&t.typeId===vi.Date}static isTime(t){return t&&t.typeId===vi.Time}static isTimestamp(t){return t&&t.typeId===vi.Timestamp}static isInterval(t){return t&&t.typeId===vi.Interval}static isList(t){return t&&t.typeId===vi.List}static isStruct(t){return t&&t.typeId===vi.Struct}static isUnion(t){return t&&t.typeId===vi.Union}static isFixedSizeBinary(t){return t&&t.typeId===vi.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===vi.FixedSizeList}static isMap(t){return t&&t.typeId===vi.Map}static isDictionary(t){return t&&t.typeId===vi.Dictionary}get typeId(){return vi.NONE}}ar[Symbol.toStringTag]=((gi=ar.prototype).children=null,gi.ArrayType=Array,gi[Symbol.toStringTag]="DataType");class sr extends ar{toString(){return"Null"}get typeId(){return vi.Null}}sr[Symbol.toStringTag]=sr.prototype[Symbol.toStringTag]="Null";class ur extends ar{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return vi.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}`}}ur[Symbol.toStringTag]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(ur.prototype);class cr extends ur{constructor(){super(!0,32)}}Object.defineProperty(class extends ur{constructor(){super(!0,8)}}.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(class extends ur{constructor(){super(!0,16)}}.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(cr.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends ur{constructor(){super(!0,64)}}.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends ur{constructor(){super(!1,8)}}.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(class extends ur{constructor(){super(!1,16)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends ur{constructor(){super(!1,32)}}.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(class extends ur{constructor(){super(!1,64)}}.prototype,"ArrayType",{value:Uint32Array});class dr extends ar{constructor(t){super(),this.precision=t}get typeId(){return vi.Float}get ArrayType(){switch(this.precision){case ii.HALF:return Uint16Array;case ii.SINGLE:return Float32Array;case ii.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}dr[Symbol.toStringTag]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(dr.prototype);Object.defineProperty(class extends dr{constructor(){super(ii.HALF)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends dr{constructor(){super(ii.SINGLE)}}.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(class extends dr{constructor(){super(ii.DOUBLE)}}.prototype,"ArrayType",{value:Float64Array});class hr extends ar{constructor(){super()}get typeId(){return vi.Binary}toString(){return"Binary"}}hr[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(hr.prototype);class br extends ar{constructor(){super()}get typeId(){return vi.Utf8}toString(){return"Utf8"}}br[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(br.prototype);class pr extends ar{constructor(){super()}get typeId(){return vi.Bool}toString(){return"Bool"}}pr[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(pr.prototype);class mr extends ar{constructor(t,e){super(),this.scale=t,this.precision=e}get typeId(){return vi.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}mr[Symbol.toStringTag]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(mr.prototype);class fr extends ar{constructor(t){super(),this.unit=t}get typeId(){return vi.Date}toString(){return`Date${32*(this.unit+1)}<${oi[this.unit]}>`}}fr[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(fr.prototype);class yr extends ar{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return vi.Time}toString(){return`Time${this.bitWidth}<${ai[this.unit]}>`}}yr[Symbol.toStringTag]=(t=>(t.unit=null,t.bitWidth=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Time"))(yr.prototype);class Zr extends ar{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return vi.Timestamp}toString(){return`Timestamp<${ai[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Zr[Symbol.toStringTag]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(Zr.prototype);class Xr extends ar{constructor(t){super(),this.unit=t}get typeId(){return vi.Interval}toString(){return`Interval<${ui[this.unit]}>`}}Xr[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Xr.prototype);class Gr extends ar{constructor(t){super(),this.children=[t]}get typeId(){return vi.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}}Gr[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Gr.prototype);class Wr extends ar{constructor(t){super(),this.children=t}get typeId(){return vi.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}Wr[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(Wr.prototype);class Vr extends ar{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 vi.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}Vr[Symbol.toStringTag]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Vr.prototype);class vr extends ar{constructor(t){super(),this.byteWidth=t}get typeId(){return vi.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}vr[Symbol.toStringTag]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(vr.prototype);class Sr extends ar{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return vi.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}>`}}Sr[Symbol.toStringTag]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Sr.prototype);class Rr extends ar{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return vi.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(", ")}}>`}}Rr[Symbol.toStringTag]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Rr.prototype);const gr=(Lr=-1,()=>++Lr);var Lr;class xr extends ar{constructor(t,e,n,i){super(),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=null==n?gr():"number"==typeof n?n:n.low}get typeId(){return vi.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}>`}}xr[Symbol.toStringTag]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(xr.prototype);class Yr{constructor(t,e,n,i,r,o,l){let a;this.type=t,this.dictionary=l,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1)),this.childData=(o||[]).map((t=>t instanceof Yr?t:t.data)),r instanceof Yr?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=function(t){const e=t;switch(t.typeId){case vi.Decimal:return 4;case vi.Timestamp:return 2;case vi.Date:case vi.Interval:return 1+e.unit;case vi.Int:case vi.Time:return+(e.bitWidth>32)+1;case vi.FixedSizeList:return e.listSize;case vi.FixedSizeBinary:return e.byteWidth;default:return 1}}(t),r&&((a=r[0])&&(this.valueOffsets=a),(a=r[1])&&(this.values=a),(a=r[2])&&(this.nullBitmap=a),(a=r[3])&&(this.typeIds=a)))}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:i,typeIds:r}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.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-or(t,this.offset,this.offset+this.length)),e}clone(t,e=this.offset,n=this.length,i=this._nullCount,r=this,o=this.childData){return new Yr(t,e,n,i,r,o,this.dictionary)}slice(t,e){const{stride:n,typeId:i,childData:r}=this,o=+(0===this._nullCount)-1,l=16===i?n:1,a=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,a,!r.length||this.valueOffsets?r:this._sliceChildren(r,l*t,l*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===vi.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(nr(this.offset,e,this.nullBitmap),0);const r=this.buffers;return r[Si.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)}_sliceBuffers(t,e,n,i){let r;const{buffers:o}=this;return(r=o[Si.TYPE])&&(o[Si.TYPE]=r.subarray(t,t+e)),(r=o[Si.OFFSET])&&(o[Si.OFFSET]=r.subarray(t,t+e+1))||(r=o[Si.DATA])&&(o[Si.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}static new(t,e,n,i,r,o,l){switch(r instanceof Yr?r=r.buffers:r||(r=[]),t.typeId){case vi.Null:return Yr.Null(t,e,n);case vi.Int:return Yr.Int(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Dictionary:return Yr.Dictionary(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[],l);case vi.Float:return Yr.Float(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Bool:return Yr.Bool(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Decimal:return Yr.Decimal(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Date:return Yr.Date(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Time:return Yr.Time(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Timestamp:return Yr.Timestamp(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Interval:return Yr.Interval(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.FixedSizeBinary:return Yr.FixedSizeBinary(t,e,n,i||0,r[Si.VALIDITY],r[Si.DATA]||[]);case vi.Binary:return Yr.Binary(t,e,n,i||0,r[Si.VALIDITY],r[Si.OFFSET]||[],r[Si.DATA]||[]);case vi.Utf8:return Yr.Utf8(t,e,n,i||0,r[Si.VALIDITY],r[Si.OFFSET]||[],r[Si.DATA]||[]);case vi.List:return Yr.List(t,e,n,i||0,r[Si.VALIDITY],r[Si.OFFSET]||[],(o||[])[0]);case vi.FixedSizeList:return Yr.FixedSizeList(t,e,n,i||0,r[Si.VALIDITY],(o||[])[0]);case vi.Struct:return Yr.Struct(t,e,n,i||0,r[Si.VALIDITY],o||[]);case vi.Map:return Yr.Map(t,e,n,i||0,r[Si.VALIDITY],r[Si.OFFSET]||[],(o||[])[0]);case vi.Union:return Yr.Union(t,e,n,i||0,r[Si.VALIDITY],r[Si.TYPE]||[],r[Si.OFFSET]||o,o)}throw new Error(`Unrecognized typeId ${t.typeId}`)}static Null(t,e,n){return new Yr(t,e,n,0)}static Int(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Dictionary(t,e,n,i,r,o,l){return new Yr(t,e,n,i,[void 0,Cn(t.indices.ArrayType,o),Fn(r)],[],l)}static Float(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Bool(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Decimal(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Date(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Time(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Timestamp(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Interval(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static FixedSizeBinary(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,Cn(t.ArrayType,o),Fn(r)])}static Binary(t,e,n,i,r,o,l){return new Yr(t,e,n,i,[Un(o),Fn(l),Fn(r)])}static Utf8(t,e,n,i,r,o,l){return new Yr(t,e,n,i,[Un(o),Fn(l),Fn(r)])}static List(t,e,n,i,r,o,l){return new Yr(t,e,n,i,[Un(o),void 0,Fn(r)],l?[l]:[])}static FixedSizeList(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,void 0,Fn(r)],o?[o]:[])}static Struct(t,e,n,i,r,o){return new Yr(t,e,n,i,[void 0,void 0,Fn(r)],o)}static Map(t,e,n,i,r,o,l){return new Yr(t,e,n,i,[Un(o),void 0,Fn(r)],l?[l]:[])}static Union(t,e,n,i,r,o,l,a){const s=[void 0,void 0,Fn(r),Cn(t.ArrayType,o)];return t.mode===ei.Sparse?new Yr(t,e,n,i,s,l):(s[Si.OFFSET]=Un(l),new Yr(t,e,n,i,s,a))}}Yr.prototype.childData=Object.freeze([]);function Kr(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 Hr{constructor(t=[],e,n){this.fields=t||[],this.metadata=e||new Map,n||(n=_r(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 Hr(this.fields.filter((t=>e[t.name])),this.metadata)}selectAt(...t){return new Hr(t.map((t=>this.fields[t])).filter(Boolean),this.metadata)}assign(...t){const e=t[0]instanceof Hr?t[0]:Array.isArray(t[0])?new Hr(t[0]):new Hr(t),n=[...this.fields],i=wr(wr(new Map,this.metadata),e.metadata),r=e.fields.filter((t=>{const e=n.findIndex((e=>e.name===t.name));return!~e||(n[e]=t.clone({metadata:wr(wr(new Map,n[e].metadata),t.metadata)}))&&!1})),o=_r(r,new Map);return new Hr([...n,...r],i,new Map([...this.dictionaries,...o]))}}class Jr{constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}static new(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===n&&(n=t[0].type),void 0===i&&(i=t[0].nullable),void 0===r&&(r=t[0].metadata)),new Jr(`${e}`,n,i,r)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:r=this.metadata}=t[0]):[e=this.name,n=this.type,i=this.nullable,r=this.metadata]=t,Jr.new(e,n,i,r)}}function wr(t,e){return new Map([...t||new Map,...e||new Map])}function _r(t,e=new Map){for(let n=-1,i=t.length;++n0&&_r(i.children,e)}return e}Hr.prototype.fields=null,Hr.prototype.metadata=null,Hr.prototype.dictionaries=null,Jr.prototype.type=null,Jr.prototype.name=null,Jr.prototype.nullable=null,Jr.prototype.metadata=null;class Ir{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 i=null,r=vi.NONE;e instanceof Yr||e instanceof On?r=Nr(e.type):e instanceof ar?r=Nr(e):"number"!=typeof(r=e)&&(r=vi[e]);switch(r){case vi.Null:i=t.visitNull;break;case vi.Bool:i=t.visitBool;break;case vi.Int:i=t.visitInt;break;case vi.Int8:i=t.visitInt8||t.visitInt;break;case vi.Int16:i=t.visitInt16||t.visitInt;break;case vi.Int32:i=t.visitInt32||t.visitInt;break;case vi.Int64:i=t.visitInt64||t.visitInt;break;case vi.Uint8:i=t.visitUint8||t.visitInt;break;case vi.Uint16:i=t.visitUint16||t.visitInt;break;case vi.Uint32:i=t.visitUint32||t.visitInt;break;case vi.Uint64:i=t.visitUint64||t.visitInt;break;case vi.Float:i=t.visitFloat;break;case vi.Float16:i=t.visitFloat16||t.visitFloat;break;case vi.Float32:i=t.visitFloat32||t.visitFloat;break;case vi.Float64:i=t.visitFloat64||t.visitFloat;break;case vi.Utf8:i=t.visitUtf8;break;case vi.Binary:i=t.visitBinary;break;case vi.FixedSizeBinary:i=t.visitFixedSizeBinary;break;case vi.Date:i=t.visitDate;break;case vi.DateDay:i=t.visitDateDay||t.visitDate;break;case vi.DateMillisecond:i=t.visitDateMillisecond||t.visitDate;break;case vi.Timestamp:i=t.visitTimestamp;break;case vi.TimestampSecond:i=t.visitTimestampSecond||t.visitTimestamp;break;case vi.TimestampMillisecond:i=t.visitTimestampMillisecond||t.visitTimestamp;break;case vi.TimestampMicrosecond:i=t.visitTimestampMicrosecond||t.visitTimestamp;break;case vi.TimestampNanosecond:i=t.visitTimestampNanosecond||t.visitTimestamp;break;case vi.Time:i=t.visitTime;break;case vi.TimeSecond:i=t.visitTimeSecond||t.visitTime;break;case vi.TimeMillisecond:i=t.visitTimeMillisecond||t.visitTime;break;case vi.TimeMicrosecond:i=t.visitTimeMicrosecond||t.visitTime;break;case vi.TimeNanosecond:i=t.visitTimeNanosecond||t.visitTime;break;case vi.Decimal:i=t.visitDecimal;break;case vi.List:i=t.visitList;break;case vi.Struct:i=t.visitStruct;break;case vi.Union:i=t.visitUnion;break;case vi.DenseUnion:i=t.visitDenseUnion||t.visitUnion;break;case vi.SparseUnion:i=t.visitSparseUnion||t.visitUnion;break;case vi.Dictionary:i=t.visitDictionary;break;case vi.Interval:i=t.visitInterval;break;case vi.IntervalDayTime:i=t.visitIntervalDayTime||t.visitInterval;break;case vi.IntervalYearMonth:i=t.visitIntervalYearMonth||t.visitInterval;break;case vi.FixedSizeList:i=t.visitFixedSizeList;break;case vi.Map:i=t.visitMap}if("function"==typeof i)return i;if(!n)return()=>null;throw new Error(`Unrecognized type '${vi[r]}'`)}(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 Nr(t){switch(t.typeId){case vi.Null:return vi.Null;case vi.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?vi.Int8:vi.Uint8;case 16:return n?vi.Int16:vi.Uint16;case 32:return n?vi.Int32:vi.Uint32;case 64:return n?vi.Int64:vi.Uint64}return vi.Int}case vi.Float:switch(t.precision){case ii.HALF:return vi.Float16;case ii.SINGLE:return vi.Float32;case ii.DOUBLE:return vi.Float64}return vi.Float;case vi.Binary:return vi.Binary;case vi.Utf8:return vi.Utf8;case vi.Bool:return vi.Bool;case vi.Decimal:return vi.Decimal;case vi.Time:switch(t.unit){case ai.SECOND:return vi.TimeSecond;case ai.MILLISECOND:return vi.TimeMillisecond;case ai.MICROSECOND:return vi.TimeMicrosecond;case ai.NANOSECOND:return vi.TimeNanosecond}return vi.Time;case vi.Timestamp:switch(t.unit){case ai.SECOND:return vi.TimestampSecond;case ai.MILLISECOND:return vi.TimestampMillisecond;case ai.MICROSECOND:return vi.TimestampMicrosecond;case ai.NANOSECOND:return vi.TimestampNanosecond}return vi.Timestamp;case vi.Date:switch(t.unit){case oi.DAY:return vi.DateDay;case oi.MILLISECOND:return vi.DateMillisecond}return vi.Date;case vi.Interval:switch(t.unit){case ui.DAY_TIME:return vi.IntervalDayTime;case ui.YEAR_MONTH:return vi.IntervalYearMonth}return vi.Interval;case vi.Map:return vi.Map;case vi.List:return vi.List;case vi.Struct:return vi.Struct;case vi.Union:switch(t.mode){case ei.Dense:return vi.DenseUnion;case ei.Sparse:return vi.SparseUnion}return vi.Union;case vi.FixedSizeBinary:return vi.FixedSizeBinary;case vi.FixedSizeList:return vi.FixedSizeList;case vi.Dictionary:return vi.Dictionary}throw new Error(`Unrecognized type '${vi[t.typeId]}'`)}Ir.prototype.visitInt8=null,Ir.prototype.visitInt16=null,Ir.prototype.visitInt32=null,Ir.prototype.visitInt64=null,Ir.prototype.visitUint8=null,Ir.prototype.visitUint16=null,Ir.prototype.visitUint32=null,Ir.prototype.visitUint64=null,Ir.prototype.visitFloat16=null,Ir.prototype.visitFloat32=null,Ir.prototype.visitFloat64=null,Ir.prototype.visitDateDay=null,Ir.prototype.visitDateMillisecond=null,Ir.prototype.visitTimestampSecond=null,Ir.prototype.visitTimestampMillisecond=null,Ir.prototype.visitTimestampMicrosecond=null,Ir.prototype.visitTimestampNanosecond=null,Ir.prototype.visitTimeSecond=null,Ir.prototype.visitTimeMillisecond=null,Ir.prototype.visitTimeMicrosecond=null,Ir.prototype.visitTimeNanosecond=null,Ir.prototype.visitDenseUnion=null,Ir.prototype.visitSparseUnion=null,Ir.prototype.visitIntervalDayTime=null,Ir.prototype.visitIntervalYearMonth=null;class Cr{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 Cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+en.SIZE_PREFIX_LENGTH),(e||new Cr).__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):An.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ei).__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 Ur).__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 Ur).__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 Mi).__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,An.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,i,r,o){return Cr.startFooter(t),Cr.addVersion(t,e),Cr.addSchema(t,n),Cr.addDictionaries(t,i),Cr.addRecordBatches(t,r),Cr.addCustomMetadata(t,o),Cr.endFooter(t)}}class Ur{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,i){return t.prep(8,24),t.writeInt64(i),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()}}var Fr=en.Long,Br=en.Builder,kr=en.ByteBuffer;class Tr{constructor(t,e=An.V4,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}static decode(t){t=new kr(Fn(t));const e=Cr.getRootAsFooter(t),n=Hr.decode(e.schema());return new zr(n,e)}static encode(t){const e=new Br,n=Hr.encode(e,t.schema);Cr.startRecordBatchesVector(e,t.numRecordBatches),[...t.recordBatches()].slice().reverse().forEach((t=>Mr.encode(e,t)));const i=e.endVector();Cr.startDictionariesVector(e,t.numDictionaries),[...t.dictionaryBatches()].slice().reverse().forEach((t=>Mr.encode(e,t)));const r=e.endVector();return Cr.startFooter(e),Cr.addSchema(e,n),Cr.addVersion(e,An.V4),Cr.addRecordBatches(e,i),Cr.addDictionaries(e,r),Cr.finishFooterBuffer(e,Cr.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?hn(this.toUint8Array(!0)):this.toUint8Array(!1).then(hn)}toUint8Array(t=!1){return t?Nn(this._values)[0]:(()=>De(this,void 0,void 0,(function*(){var t,e;const n=[];let i=0;try{for(var r,o=tn(this);!(r=yield o.next()).done;){const t=r.value;n.push(t),i+=t.byteLength}}catch(l){t={error:l}}finally{try{r&&!r.done&&(e=o.return)&&(yield e.call(o))}finally{if(t)throw t.error}}return Nn(n,i)[0]})))()}}class Qr{constructor(t){t&&(this.source=new Er(jn.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 Pr{constructor(t){t instanceof Pr?this.source=t.source:t instanceof jr?this.source=new Dr(jn.fromAsyncIterable(t)):Jn(t)?this.source=new Dr(jn.fromNodeStream(t)):Hn(t)?this.source=new Dr(jn.fromDOMStream(t)):Kn(t)?this.source=new Dr(jn.fromDOMStream(t.body)):Rn(t)?this.source=new Dr(jn.fromIterable(t)):(Sn(t)||gn(t))&&(this.source=new Dr(jn.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 Er{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)||mn)}return(t){return Object.create(this.source.return&&this.source.return(t)||mn)}}class Dr{constructor(t){this.source=t,this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}cancel(t){return De(this,void 0,void 0,(function*(){yield this.return(t)}))}get closed(){return this._closedPromise}read(t){return De(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return De(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(t,e="read"){return De(this,void 0,void 0,(function*(){return yield this.source.next({cmd:e,size:t})}))}throw(t){return De(this,void 0,void 0,(function*(){const e=this.source.throw&&(yield this.source.throw(t))||mn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}return(t){return De(this,void 0,void 0,(function*(){const e=this.source.return&&(yield this.source.return(t))||mn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}}class Or extends Qr{constructor(t,e){super(),this.position=0,this.buffer=Fn(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),tDe(this,void 0,void 0,(function*(){this.size=(yield t.stat()).size,delete this._pending})))()}readInt32(t){return De(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 De(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 i=e[3]*n[3];this.buffer[0]=65535&i;let r=i>>>16;return i=e[2]*n[3],r+=i,i=e[3]*n[2]>>>0,r+=i,this.buffer[0]+=r<<16,this.buffer[1]=r>>>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`${qr(this.buffer[3])} ${qr(this.buffer[2])} ${qr(this.buffer[1])} ${qr(this.buffer[0])}`}static multiply(t,e){return new io(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new io(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return io.fromString("string"==typeof t?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return io.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),i=t.length,r=new io(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 oo extends ro{constructor(t,e,n,i){super(new Uint8Array(0),e,n,i),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):ir(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Cn(Uint8Array,Cn(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Cn(Uint8Array,Cn(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return ar.isTimestamp(t)||(ar.isInt(t)||ar.isTime(t))&&64===t.bitWidth||ar.isDate(t)&&t.unit===oi.MILLISECOND?Cn(Uint8Array,no.convertArray(n[e])):ar.isDecimal(t)?Cn(Uint8Array,io.convertArray(n[e])):ar.isBinary(t)||ar.isFixedSizeBinary(t)?function(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let i=0;i>1]=parseInt(e.substr(i,2),16);return n}(n[e]):ar.isBool(t)?ir(n[e]):ar.isUtf8(t)?pn(n[e].join("")):Cn(Uint8Array,Cn(t.ArrayType,n[e].map((t=>+t))))}}const lo=Symbol.for("parent"),ao=Symbol.for("rowIndex"),so=Symbol.for("keyToIdx"),uo=Symbol.for("idxToVal"),co=Symbol.for("nodejs.util.inspect.custom");class ho{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[so]||(this[so]=new Map);let i=n.get(t);if(void 0!==i){const t=this[uo]||(this[uo]=new Array(this.size));void 0!==(e=t[i])||(t[i]=e=this.getValue(i))}else if((i=this.getIndex(t))>-1){n.set(t,i);const r=this[uo]||(this[uo]=new Array(this.size));void 0!==(e=r[i])||(r[i]=e=this.getValue(i))}}return e}set(t,e){if(null!=t){const n=this[so]||(this[so]=new Map);let i=n.get(t);if(void 0===i&&n.set(t,i=this.getIndex(t)),i>-1){(this[uo]||(this[uo]=new Array(this.size)))[i]=this.setValue(i,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[so]||(this[so]=new Map),i=this[uo]||(this[uo]=new Array(this.size));for(let r,o,l,a,s=0;!(l=t.next()).done&&!(a=e.next()).done;++s)r=l.value,o=a.value,i[s]=o,n.has(r)||n.set(r,s),yield[r,o]}forEach(t,e){const n=this.keys(),i=this.values(),r=void 0===e?t:(n,i,r)=>t.call(e,n,i,r),o=this[so]||(this[so]=new Map),l=this[uo]||(this[uo]=new Array(this.size));for(let a,s,u,c,d=0;!(u=n.next()).done&&!(c=i.next()).done;++d)a=u.value,s=c.value,l[d]=s,o.has(a)||o.set(a,d),r(s,a,this)}toArray(){return[...this.values()]}toJSON(){const t={};return this.forEach(((e,n)=>t[n]=e)),t}inspect(){return this.toString()}[co](){return this.toString()}toString(){const t=[];return this.forEach(((e,n)=>{n=Kr(n),e=Kr(e),t.push(`${n}: ${e}`)})),`{ ${t.join(", ")} }`}}ho[Symbol.toStringTag]=(t=>(Object.defineProperties(t,{size:{writable:!0,enumerable:!1,configurable:!1,value:0},[lo]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ao]:{writable:!0,enumerable:!1,configurable:!1,value:-1}}),t[Symbol.toStringTag]="Row"))(ho.prototype);class bo extends ho{constructor(t){return super(t,t.type.children.length),po(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[ao])}setValue(t,e){return this[lo].getChildAt(t).set(this[ao],e)}}Object.setPrototypeOf(ho.prototype,Map.prototype);const po=(()=>{const t={enumerable:!0,configurable:!1,get:null,set:null};return e=>{let n=-1;const i=e[so]||(e[so]=new Map),r=t=>function(){return this.get(t)},o=t=>function(e){return this.set(t,e)};for(const l of e.keys())i.set(l,++n),t.get=r(l),t.set=o(l),Object.prototype.hasOwnProperty.call(e,l)||(t.enumerable=!0,Object.defineProperty(e,l,t)),Object.prototype.hasOwnProperty.call(e,n)||(t.enumerable=!1,Object.defineProperty(e,n,t));return t.get=t.set=null,e}})();let mo;function fo(t,e,n,i){const{length:r=0}=t;let o="number"!=typeof e?0:e,l="number"!=typeof n?r:n;return o<0&&(o=(o%r+r)%r),l<0&&(l=(l%r+r)%r),lr&&(l=r),i?i(t,o,l):[o,l]}(()=>{if("undefined"==typeof Proxy)return po;const t=ho.prototype.has,e=ho.prototype.get,n=ho.prototype.set,i=ho.prototype.getKey,r={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 ao:case uo:case so:case co:return!0}return"number"!=typeof e||t.has(e)||(e=t.getKey(e)),t.has(e)},get(n,r,o){switch(r){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 ao:case uo:case so:case co:return Reflect.get(n,r,o)}return"number"!=typeof r||t.call(o,r)||(r=i.call(o,r)),e.call(o,r)},set(e,r,o,l){switch(r){case lo:case ao:case uo:case so:return Reflect.set(e,r,o,l);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 r||t.call(l,r)||(r=i.call(l,r)),!!t.call(l,r)&&!!n.call(l,r,o)}}})(),Gn&&Xn(0);const yo=Array.isArray,Zo=(t,e)=>Wo(t,e,[],0),Xo=(t,e)=>Vo(t,e,[],0);function Go(t,e,n,i){let r,o=i,l=-1;const a=e.length;for(;++lr.getChildAt(e))),n,o).length:r instanceof On&&(n[o++]=r);return n}const vo=(t,[e,n],i)=>(t[0][i]=e,t[1][i]=n,t);function So(t,e){let n,i;switch(i=t.length){case 0:return e;case 1:if(n=e[0],!t[0])return e;if(yo(t[0]))return So(t[0],e);t[0]instanceof Yr||t[0]instanceof On||t[0]instanceof ar||([n,t]=Object.entries(t[0]).reduce(vo,e));break;default:yo(n=t[i-1])?t=yo(t[0])?t[0]:t.slice(0,i-1):(t=yo(t[0])?t[0]:t,n=[])}let r=-1,o=-1,l=-1;const a=t.length;let s,u;const[c,d]=e;for(;++l`}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(ar.isDictionary(this._type)){if(!this._indices){const t=this._chunks;this._indices=1===t.length?t[0].indices:go.concat(...t.map((t=>t.indices)))}return this._indices}return null}get dictionary(){return ar.isDictionary(this._type)?this._chunks[this._chunks.length-1].data.dictionary:null}[Symbol.iterator](){return new Ro(this._chunks)}clone(t=this._chunks){return new go(this._type,t)}concat(...t){return this.clone(go.flatten(this,...t))}slice(t,e){return fo(this,t,e,this._sliceInternal)}getChildAt(t){if(t<0||t>=this._numChildren)return null;const e=this._children||(this._children=[]);let n,i,r;return(n=e[t])?n:(i=(this._type.children||[])[t])&&(r=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),r.length>0)?e[t]=new go(i.type,r):null}search(t,e){const n=t,i=this._chunkOffsets;let r=i.length-1;if(n<0)return null;if(n>=i[r])return null;if(r<=1)return e?e(this,0,n):[0,n];let o=0,l=0,a=0;do{if(o+1===r)return e?e(this,o,n-l):[o,n-l];a=o+(r-o)/2|0,n>=i[a]?o=a:r=a}while(n=(l=i[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,i)=>t[n].set(i,e)))}indexOf(t,e){return e&&"number"==typeof e?this.search(e,((e,n,i)=>this.indexOfInternal(e,n,i,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 i=0;const r=new Array(e);for(let a=-1;++a=n)break;if(e>=s+a)continue;if(s>=e&&s+a<=n){i.push(t);continue}const u=Math.max(0,e-s),c=Math.min(n-s,a);i.push(t.slice(u,c))}return t.clone(i)}}const Lo=(t,e,n)=>(e.set(t,n),n+t.length),xo=(t,e,n)=>{let i=n;for(let r=-1,o=t.length;++rt>0))&&(e=e.clone({nullable:!0}));return new Yo(e,r)}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 Yo(this._field,t)}getChildAt(t){if(t<0||t>=this.numChildren)return null;const e=this._children||(this._children=[]);let n,i,r;return(n=e[t])?n:(i=(this.type.children||[])[t])&&(r=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),r.length>0)?e[t]=new Yo(i,r):null}}class Ko extends Yo{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 Ho=en.Long;const Jo=new class extends Ir{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return Li.startNull(e),Li.endNull(e)}visitInt(t,e){return wi.startInt(e),wi.addBitWidth(e,t.bitWidth),wi.addIsSigned(e,t.isSigned),wi.endInt(e)}visitFloat(t,e){return _i.startFloatingPoint(e),_i.addPrecision(e,t.precision),_i.endFloatingPoint(e)}visitBinary(t,e){return Ni.startBinary(e),Ni.endBinary(e)}visitBool(t,e){return Ui.startBool(e),Ui.endBool(e)}visitUtf8(t,e){return Ii.startUtf8(e),Ii.endUtf8(e)}visitDecimal(t,e){return Fi.startDecimal(e),Fi.addScale(e,t.scale),Fi.addPrecision(e,t.precision),Fi.endDecimal(e)}visitDate(t,e){return Bi.startDate(e),Bi.addUnit(e,t.unit),Bi.endDate(e)}visitTime(t,e){return ki.startTime(e),ki.addUnit(e,t.unit),ki.addBitWidth(e,t.bitWidth),ki.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Ti.startTimestamp(e),Ti.addUnit(e,t.unit),void 0!==n&&Ti.addTimezone(e,n),Ti.endTimestamp(e)}visitInterval(t,e){return zi.startInterval(e),zi.addUnit(e,t.unit),zi.endInterval(e)}visitList(t,e){return Yi.startList(e),Yi.endList(e)}visitStruct(t,e){return xi.startStruct_(e),xi.endStruct_(e)}visitUnion(t,e){Ji.startTypeIdsVector(e,t.typeIds.length);const n=Ji.createTypeIdsVector(e,t.typeIds);return Ji.startUnion(e),Ji.addMode(e,t.mode),Ji.addTypeIds(e,n),Ji.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return ji.startDictionaryEncoding(e),ji.addId(e,new Ho(t.id,0)),ji.addIsOrdered(e,t.isOrdered),void 0!==n&&ji.addIndexType(e,n),ji.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ci.startFixedSizeBinary(e),Ci.addByteWidth(e,t.byteWidth),Ci.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Ki.startFixedSizeList(e),Ki.addListSize(e,t.listSize),Ki.endFixedSizeList(e)}visitMap(t,e){return Hi.startMap(e),Hi.addKeysSorted(e,t.keysSorted),Hi.endMap(e)}};function wo(t){return new Mo(t.count,Io(t.columns),No(t.columns))}function _o(t,e){return(t.children||[]).filter(Boolean).map((t=>Jr.fromJSON(t,e)))}function Io(t){return(t||[]).reduce(((t,e)=>{return[...t,new Po(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...Io(e.children)];var n}),[])}function No(t,e=[]){for(let n=-1,i=(t||[]).length;++ni),this._bodyLength="number"==typeof t?t:t.low}static fromJSON(t,e){const n=new zo(0,An.V4,e);return n._createHeader=function(t,e){return()=>{switch(e){case Wi.Schema:return Hr.fromJSON(t);case Wi.RecordBatch:return Mo.fromJSON(t);case Wi.DictionaryBatch:return jo.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${Wi[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new To(Fn(t));const e=$i.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),r=e.headerType(),o=new zo(n,i,r);return o._createHeader=function(t,e){return()=>{switch(e){case Wi.Schema:return Hr.decode(t.header(new Ei));case Wi.RecordBatch:return Mo.decode(t.header(new Ai),t.version());case Wi.DictionaryBatch:return jo.decode(t.header(new qi),t.version())}throw new Error(`Unrecognized Message type: { name: ${Wi[e]}, type: ${e} }`)}}(e,r),o}static encode(t){const e=new ko;let n=-1;return t.isSchema()?n=Hr.encode(e,t.header()):t.isRecordBatch()?n=Mo.encode(e,t.header()):t.isDictionaryBatch()&&(n=jo.encode(e,t.header())),$i.startMessage(e),$i.addVersion(e,An.V4),$i.addHeader(e,n),$i.addHeaderType(e,t.headerType),$i.addBodyLength(e,new Bo(t.bodyLength,0)),$i.finishMessageBuffer(e,$i.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Hr)return new zo(0,An.V4,Wi.Schema,t);if(t instanceof Mo)return new zo(e,An.V4,Wi.RecordBatch,t);if(t instanceof jo)return new zo(e,An.V4,Wi.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===Wi.Schema}isRecordBatch(){return this.headerType===Wi.RecordBatch}isDictionaryBatch(){return this.headerType===Wi.DictionaryBatch}}class Mo{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 jo{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 Qo{constructor(t,e){this.offset="number"==typeof t?t:t.low,this.length="number"==typeof e?e:e.low}}class Po{constructor(t,e){this.length="number"==typeof t?t:t.low,this.nullCount="number"==typeof e?e:e.low}}function Eo(t,e){const n=[];for(let i,r=-1,o=-1,l=t.childrenLength();++rJr.encode(t,e))),s=Qi.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?Qi.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return Mi.startKeyValue(t),Mi.addKey(t,i),Mi.addValue(t,r),Mi.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Qi.startField(t),Qi.addType(t,i),Qi.addTypeType(t,l),Qi.addChildren(t,s),Qi.addNullable(t,!!e.nullable),-1!==n&&Qi.addName(t,n);-1!==r&&Qi.addDictionary(t,r);-1!==u&&Qi.addCustomMetadata(t,u);return Qi.endField(t)},Jr.decode=function(t,e){let n,i,r,o,l,a;e&&(a=t.dictionary())?e.has(n=a.id().low)?(o=(o=a.indexType())?Oo(o):new cr,l=new xr(e.get(n),o,n,a.isOrdered()),i=new Jr(t.name(),l,t.nullable(),Do(t))):(o=(o=a.indexType())?Oo(o):new cr,e.set(n,r=Ao(t,Eo(t,e))),l=new xr(r,o,n,a.isOrdered()),i=new Jr(t.name(),l,t.nullable(),Do(t))):(r=Ao(t,Eo(t,e)),i=new Jr(t.name(),r,t.nullable(),Do(t)));return i||null},Jr.fromJSON=function(t,e){let n,i,r,o,l,a;return e&&(o=t.dictionary)?e.has(n=o.id)?(i=(i=o.indexType)?Uo(i):new cr,a=new xr(e.get(n),i,n,o.isOrdered),r=new Jr(t.name,a,t.nullable,Co(t.customMetadata))):(i=(i=o.indexType)?Uo(i):new cr,e.set(n,l=Fo(t,_o(t,e))),a=new xr(l,i,n,o.isOrdered),r=new Jr(t.name,a,t.nullable,Co(t.customMetadata))):(l=Fo(t,_o(t,e)),r=new Jr(t.name,l,t.nullable,Co(t.customMetadata))),r||null},Hr.encode=function(t,e){const n=e.fields.map((e=>Jr.encode(t,e)));Ei.startFieldsVector(t,n.length);const i=Ei.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?Ei.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return Mi.startKeyValue(t),Mi.addKey(t,i),Mi.addValue(t,r),Mi.endKeyValue(t)}))):-1;Ei.startSchema(t),Ei.addFields(t,i),Ei.addEndianness(t,qo?mi.Little:mi.Big),-1!==r&&Ei.addCustomMetadata(t,r);return Ei.endSchema(t)},Hr.decode=function(t,e=new Map){const n=function(t,e){const n=[];for(let i,r=-1,o=-1,l=t.fieldsLength();++rJr.fromJSON(t,e)))}(t,e),Co(t.customMetadata),e)},Mo.encode=function(t,e){const n=e.nodes||[],i=e.buffers||[];Ai.startNodesVector(t,n.length),n.slice().reverse().forEach((e=>Po.encode(t,e)));const r=t.endVector();Ai.startBuffersVector(t,i.length),i.slice().reverse().forEach((e=>Qo.encode(t,e)));const o=t.endVector();return Ai.startRecordBatch(t),Ai.addLength(t,new Bo(e.length,0)),Ai.addNodes(t,r),Ai.addBuffers(t,o),Ai.endRecordBatch(t)},Mo.decode=function(t,e=An.V4){return new Mo(t.length(),function(t){const e=[];for(let n,i=-1,r=-1,o=t.nodesLength();++i`Expected ${Wi[t]} Message in stream, but was null or length 0.`,el=t=>`Header pointer of flatbuffer-encoded ${Wi[t]} Message is null or length 0.`,nl=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,il=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class rl{constructor(t){this.source=t instanceof Qr?t:new Qr(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?mn: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(tl(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=Fn(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(tl(t));return e.value}readSchema(){const t=Wi.Schema,e=this.readMessage(t),n=e&&e.header();if(!e||!n)throw new Error(el(t));return n}}const al=4,sl=new Uint8Array("ARROW1".length);for(let wR=0;wR<"ARROW1".length;wR+=1)sl[wR]="ARROW1".charCodeAt(wR);function ul(t,e=0){for(let n=-1,i=sl.length;++nthis.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 pl(t,e){return e instanceof t.constructor}function ml(t,e){return t===e||pl(t,e)}function fl(t,e){return t===e||pl(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function yl(t,e){return t===e||pl(t,e)&&t.precision===e.precision}function Zl(t,e){return t===e||pl(t,e)&&t.unit===e.unit}function Xl(t,e){return t===e||pl(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function Gl(t,e){return t===e||pl(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function Wl(t,e){return t===e||pl(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&vl.compareManyFields(t.children,e.children)}function Vl(t,e){return t===e||pl(t,e)&&t.unit===e.unit}bl.prototype.visitNull=ml,bl.prototype.visitBool=ml,bl.prototype.visitInt=fl,bl.prototype.visitInt8=fl,bl.prototype.visitInt16=fl,bl.prototype.visitInt32=fl,bl.prototype.visitInt64=fl,bl.prototype.visitUint8=fl,bl.prototype.visitUint16=fl,bl.prototype.visitUint32=fl,bl.prototype.visitUint64=fl,bl.prototype.visitFloat=yl,bl.prototype.visitFloat16=yl,bl.prototype.visitFloat32=yl,bl.prototype.visitFloat64=yl,bl.prototype.visitUtf8=ml,bl.prototype.visitBinary=ml,bl.prototype.visitFixedSizeBinary=function(t,e){return t===e||pl(t,e)&&t.byteWidth===e.byteWidth},bl.prototype.visitDate=Zl,bl.prototype.visitDateDay=Zl,bl.prototype.visitDateMillisecond=Zl,bl.prototype.visitTimestamp=Xl,bl.prototype.visitTimestampSecond=Xl,bl.prototype.visitTimestampMillisecond=Xl,bl.prototype.visitTimestampMicrosecond=Xl,bl.prototype.visitTimestampNanosecond=Xl,bl.prototype.visitTime=Gl,bl.prototype.visitTimeSecond=Gl,bl.prototype.visitTimeMillisecond=Gl,bl.prototype.visitTimeMicrosecond=Gl,bl.prototype.visitTimeNanosecond=Gl,bl.prototype.visitDecimal=ml,bl.prototype.visitList=function(t,e){return t===e||pl(t,e)&&t.children.length===e.children.length&&vl.compareManyFields(t.children,e.children)},bl.prototype.visitStruct=function(t,e){return t===e||pl(t,e)&&t.children.length===e.children.length&&vl.compareManyFields(t.children,e.children)},bl.prototype.visitUnion=Wl,bl.prototype.visitDenseUnion=Wl,bl.prototype.visitSparseUnion=Wl,bl.prototype.visitDictionary=function(t,e){return t===e||pl(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&vl.visit(t.indices,e.indices)&&vl.visit(t.dictionary,e.dictionary)},bl.prototype.visitInterval=Vl,bl.prototype.visitIntervalDayTime=Vl,bl.prototype.visitIntervalYearMonth=Vl,bl.prototype.visitFixedSizeList=function(t,e){return t===e||pl(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&vl.compareManyFields(t.children,e.children)},bl.prototype.visitMap=function(t,e){return t===e||pl(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&vl.compareManyFields(t.children,e.children)};const vl=new bl;function Sl(t,e){return vl.compareSchemas(t,e)}class Rl extends Ir{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...t){const e=new Rl,n=Xo(Ml,t),[i=e]=e.visitMany(n);return i}visit(t){if(!ar.isDictionary(t.type)){const{data:e,length:n,nullCount:i}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");ar.isNull(t.type)||gl.call(this,i<=0?new Uint8Array(0):nr(e.offset,n,e.nullBitmap)),this.nodes.push(new Po(n,i))}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 gl(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new Qo(this._byteLength,e)),this._byteLength+=e,this}function Ll(t){return gl.call(this,t.values.subarray(0,t.length*t.stride))}function xl(t){const{length:e,values:n,valueOffsets:i}=t,r=i[0],o=i[e],l=Math.min(o-r,n.byteLength-r);return gl.call(this,Mn(-i[0],e,i)),gl.call(this,n.subarray(r,r+l)),this}function Yl(t){const{length:e,valueOffsets:n}=t;return n&&gl.call(this,Mn(n[0],e,n)),this.visit(t.getChildAt(0))}function Kl(t){return this.visitMany(t.type.children.map(((e,n)=>t.getChildAt(n))).filter(Boolean))[0]}Rl.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?gl.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?gl.call(this,nr(t.offset,t.length,e)):gl.call(this,ir(t))},Rl.prototype.visitInt=Ll,Rl.prototype.visitFloat=Ll,Rl.prototype.visitUtf8=xl,Rl.prototype.visitBinary=xl,Rl.prototype.visitFixedSizeBinary=Ll,Rl.prototype.visitDate=Ll,Rl.prototype.visitTimestamp=Ll,Rl.prototype.visitTime=Ll,Rl.prototype.visitDecimal=Ll,Rl.prototype.visitList=Yl,Rl.prototype.visitStruct=Kl,Rl.prototype.visitUnion=function(t){const{type:e,length:n,typeIds:i,valueOffsets:r}=t;if(gl.call(this,i),e.mode===ei.Sparse)return Kl.call(this,t);if(e.mode===ei.Dense){if(t.offset<=0)return gl.call(this,r),Kl.call(this,t);{const o=i.reduce(((t,e)=>Math.max(t,e)),i[0]),l=new Int32Array(o+1),a=new Int32Array(o+1).fill(-1),s=new Int32Array(n),u=Mn(-r[0],n,r);for(let t,e,r=-1;++rthis.writeAll(t))):gn(t)?Il(this,t):_l(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 jr?this._sink=t:(this._sink=new jr,t&&(vn(n=t)&&Vn(n.abort)&&Vn(n.getWriter)&&!(n instanceof yn))?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>vn(t)&&Vn(t.end)&&Vn(t.write)&&Wn(t.writable)&&!(t instanceof yn))(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&&Sl(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 zl&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ml&&!(e=t.schema))return this.finish()&&void 0;if(e&&!Sl(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ml?t instanceof jl||this._writeRecordBatch(t):t instanceof zl?this.writeAll(t.chunks):Rn(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,i=zo.encode(t),r=i.byteLength,o=this._writeLegacyIpcFormat?4:8,l=r+o+n&~n,a=l-r-o;return t.headerType===Wi.RecordBatch?this._recordBatchBlocks.push(new Mr(l,t.bodyLength,this._position)):t.headerType===Wi.DictionaryBatch&&this._dictionaryBlocks.push(new Mr(l,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(l-o)),r>0&&this._write(i),this._writePadding(a)}_write(t){if(this._started){const e=Fn(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(zo.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(sl)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:i,buffers:r}=Rl.assemble(t),o=new Mo(t.length,n,i),l=zo.from(o,e);return this._writeDictionaries(t)._writeMessage(l)._writeBodyBuffers(r)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:i,nodes:r,bufferRegions:o,buffers:l}=Rl.assemble(t),a=new Mo(t.length,r,o),s=new jo(a,e,n),u=zo.from(s,i);return this._writeMessage(u)._writeBodyBuffers(l)}_writeBodyBuffers(t){let e,n,i;for(let r=-1,o=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));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 i="chunks"in n?n.chunks:[n];for(const n of i)this._writeDictionaryBatch(n,e,t>0),t+=n.length}}return this}}class Jl extends Hl{static writeAll(t,e){const n=new Jl(e);return Sn(t)?t.then((t=>n.writeAll(t))):gn(t)?Il(n,t):_l(n,t)}}class wl extends Hl{static writeAll(t){const e=new wl;return Sn(t)?t.then((t=>e.writeAll(t))):gn(t)?Il(e,t):_l(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const e=Tr.encode(new Tr(t,An.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function _l(t,e){let n=e;e instanceof zl&&(n=e.chunks,t.reset(void 0,e.schema));for(const i of n)t.write(i);return t.finish()}function Il(t,e){var n,i,r,o;return De(this,void 0,void 0,(function*(){try{for(n=tn(e);!(i=yield n.next()).done;){const e=i.value;t.write(e)}}catch(l){r={error:l}}finally{try{i&&!i.done&&(o=n.return)&&(yield o.call(n))}finally{if(r)throw r.error}}return t.finish()}))}const Nl=new Uint8Array(0),Cl=t=>[Nl,Nl,new Uint8Array(t),Nl];function Ul(t,e){return function(t,e){const n=[...t.fields],i=[],r={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let o=0,l=0,a=-1;const s=e.length;let u,c=[];for(;r.numBatches-- >0;){for(l=Number.POSITIVE_INFINITY,a=-1;++a0&&(i[o++]=[l,c.slice()]))}return[t=new Hr(n,t.metadata),i.map((e=>new Ml(t,...e)))]}(t,e.map((t=>t instanceof go?t.chunks.map((t=>t.data)):[t.data])))}function Fl(t,e,n,i,r){let o,l,a=0,s=-1;const u=i.length,c=(e+63&-64)>>3;for(;++s=e?a===e?n[s]=o:(n[s]=o.slice(0,e),o=o.slice(e,a-e),r.numBatches=Math.max(r.numBatches,i[s].unshift(o))):((l=t[s]).nullable||(t[s]=l.clone({nullable:!0})),n[s]=o?o._changeLengthAndBackfillNullBitmap(e):Yr.new(l.type,0,e,e,Cl(c)));return n}class Bl extends On{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`${vi[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 On.new(t,e)}concat(...t){return go.concat(this,...t)}slice(t,e){return fo(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]=On.new(this.data.childData[t]))}toJSON(){return[...this]}_sliceInternal(t,e,n){return t.clone(t.data.slice(e,n-e),null)}_bindDataAccessors(t){}}Bl.prototype[Symbol.isConcatSpreadable]=!0;const kl=Symbol.for("rowIndex");class Tl extends Bl{bind(t){const e=this._row||(this._row=new bo(this)),n=Object.create(e);return n[kl]=t,n}}class zl extends go{constructor(...t){let e=null;t[0]instanceof Hr&&(e=t.shift());const n=Go(Ml,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 jl(e)),super(new Wr(e.fields),n),this._schema=e,this._chunks=n}static empty(t=new Hr([])){return new zl(t,[])}static from(t){if(!t)return zl.empty();if("object"==typeof t){const e=Rn(t.values)?function(t){const{type:e}=t;if(e instanceof Wr)return zl.fromStruct(Tl.from(t));return null}(t):gn(t.values)?function(t){const{type:e}=t;if(e instanceof Wr)return Tl.from(t).then((t=>zl.fromStruct(t)));return null}(t):null;if(null!==e)return e}let e=Pl.from(t);return Sn(e)?(()=>De(this,void 0,void 0,(function*(){return yield zl.from(yield e)})))():e.isSync()&&(e=e.open())?e.schema?new zl(e.schema,[...e]):zl.empty():(t=>De(this,void 0,void 0,(function*(){var e,n;const i=yield t,r=i.schema,o=[];if(r){try{for(var l,a=tn(i);!(l=yield a.next()).done;){const t=l.value;o.push(t)}}catch(s){e={error:s}}finally{try{l&&!l.done&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return new zl(r,o)}return zl.empty()})))(e.open())}static fromAsync(t){return De(this,void 0,void 0,(function*(){return yield zl.from(t)}))}static fromStruct(t){return zl.new(t.data.childData,t.type.children)}static new(...t){return new zl(...(e=(t=>{const[e,n]=So(t,[[],[]]);return n.map(((t,n)=>t instanceof Yo?Yo.new(t.field.clone(e[n]),t):t instanceof On?Yo.new(e[n],t):Yo.new(e[n],[])))})(t),Ul(new Hr(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 zl(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 i=this._schema.fields,r=this._children||(this._children=[]);if(n=r[t])return n;if(e=i[t]){const n=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t));if(n.length>0)return r[t]=new Yo(e,n)}return null}serialize(t="binary",e=!0){return(e?Jl:wl).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 zl(e,this._chunks.map((({length:n,data:{childData:i}})=>new Ml(e,n,t.map((t=>i[t])).filter(Boolean)))))}assign(t){const e=this._schema.fields,[n,i]=t.schema.fields.reduce(((t,n,i)=>{const[r,o]=t,l=e.findIndex((t=>t.name===n.name));return~l?o[l]=i:r.push(i),t}),[[],[]]),r=this._schema.assign(t.schema),o=[...e.map(((e,n,r,o=i[n])=>void 0===o?this.getColumnAt(n):t.getColumnAt(o))),...n.map((e=>t.getColumnAt(e)))].filter(Boolean);return new zl(...Ul(r,o))}}class Ml extends Tl{constructor(...t){let e;const n=t[0];let i;if(t[1]instanceof Yr)[,e,i]=t;else{const i=n.fields,[,r,o]=t;e=Yr.Struct(new Wr(i),0,r,0,null,o)}super(e,i),this._schema=n}static from(t){return Rn(t.values),zl.from(t)}static new(...t){const[e,n]=(t=>So(t,[[],[]]))(t),i=n.filter((t=>t instanceof On));return new Ml(...function(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){let i,r,o=-1;const l=e.length,a=[...t.fields],s=[],u=(n+63&-64)>>3;for(;++ot.data))))}clone(t,e=this._children){return new Ml(this._schema,t,e)}concat(...t){const e=this._schema,n=go.flatten(this,...t);return new zl(e,n.map((({data:t})=>new Ml(e,t))))}get schema(){return this._schema}get numCols(){return this._schema.fields.length}get dictionaries(){return this._dictionaries||(this._dictionaries=Ql.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 Ml(e,this.length,n)}}class jl extends Ml{constructor(t){super(t,0,t.fields.map((t=>Yr.new(t.type,0,0,0))))}}class Ql extends Ir{constructor(){super(...arguments),this.dictionaries=new Map}static collect(t){return(new Ql).visit(t.data,new Wr(t.schema.fields)).dictionaries}visit(t,e){return ar.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 Pl extends yn{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 Sn(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 jn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return jn.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 Pl?t:Ln(t)?function(t){return new El(new ia(t))}(t):Yn(t)?function(t){return De(this,void 0,void 0,(function*(){const{size:e}=yield t.stat(),n=new Ar(t,e);return e>=hl&&ul(yield n.readAt(0,cl+7&-8))?new Al(new na(n)):new Dl(new ta(n))}))}(t):Sn(t)?(()=>De(this,void 0,void 0,(function*(){return yield Pl.from(yield t)})))():Kn(t)||Hn(t)||Jn(t)||gn(t)?function(t){return De(this,void 0,void 0,(function*(){const e=yield t.peek(cl+7&-8);return e&&e.byteLength>=4?ul(e)?new Ol(new ea(yield t.read())):new Dl(new ta(t)):new Dl(new ta(function(){return qe(this,arguments,(function*(){}))}()))}))}(new Pr(t)):function(t){const e=t.peek(cl+7&-8);return e&&e.byteLength>=4?ul(e)?new Ol(new ea(t.read())):new El(new $l(t)):new El(new $l(function*(){}()))}(new Qr(t))}static readAll(t){return t instanceof Pl?t.isSync()?oa(t):la(t):Ln(t)||ArrayBuffer.isView(t)||Rn(t)||xn(t)?oa(t):la(t)}}class El extends Pl{constructor(t){super(t),this._impl=t}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return qe(this,arguments,(function*(){yield Ae(yield*$e(tn(this[Symbol.iterator]())))}))}}class Dl extends Pl{constructor(t){super(t),this._impl=t}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Ol extends El{constructor(t){super(t),this._impl=t}}class Al extends Dl{constructor(t){super(t),this._impl=t}}class ql{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 Ml(this.schema,t.length,this._loadVectors(t,e,this.schema.fields))}_loadDictionaryBatch(t,e){const{id:n,isDelta:i,data:r}=t,{dictionaries:o,schema:l}=this,a=o.get(n);if(i||!a){const t=l.dictionaries.get(n);return a&&i?a.concat(On.new(this._loadVectors(r,e,[t])[0])):On.new(this._loadVectors(r,e,[t])[0])}return a}_loadVectors(t,e,n){return new ro(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}}class $l extends ql{constructor(t,e){super(e),this._reader=Ln(t)?new ll(this._handle=t):new rl(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=ra(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):mn}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):mn}next(){if(this.closed)return mn;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(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new jl(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class ta extends ql{constructor(t,e){super(e),this._reader=new ol(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return De(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 De(this,void 0,void 0,(function*(){return this.closed||(this.autoDestroy=ra(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this}))}throw(t){return De(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):mn}))}return(t){return De(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):mn}))}next(){return De(this,void 0,void 0,(function*(){if(this.closed)return mn;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(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=yield e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new jl(this.schema)}):yield this.return()}))}_readNextMessageAndValidate(t){return De(this,void 0,void 0,(function*(){return yield this._reader.readMessage(t)}))}}class ea extends $l{constructor(t,e){super(t instanceof Or?t:new Or(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(Wi.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(Wi.DictionaryBatch);if(t&&t.isDictionaryBatch()){const e=t.header(),n=this._reader.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,i)}}}_readFooter(){const{_handle:t}=this,e=t.size-dl,n=t.readInt32(e),i=t.readAt(e-n,n);return Tr.decode(i)}_readNextMessageAndValidate(t){if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return De(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 De(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(Wi.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 De(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(Wi.DictionaryBatch);if(t&&t.isDictionaryBatch()){const e=t.header(),n=yield this._reader.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,i)}}}))}_readFooter(){return De(this,void 0,void 0,(function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-dl,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Tr.decode(i)}))}_readNextMessageAndValidate(t){return De(this,void 0,void 0,(function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex-1},O.prototype.set=function(t,e){var n=this.__data__,i=nt(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this},A.prototype.clear=function(){this.size=0,this.__data__={hash:new D,map:new(Q||O),string:new D}},A.prototype.delete=function(t){var e=ht(this,t).delete(t);return this.size-=e?1:0,e},A.prototype.get=function(t){return ht(this,t).get(t)},A.prototype.has=function(t){return ht(this,t).has(t)},A.prototype.set=function(t,e){var n=ht(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this},q.prototype.clear=function(){this.__data__=new O,this.size=0},q.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},q.prototype.get=function(t){return this.__data__.get(t)},q.prototype.has=function(t){return this.__data__.has(t)},q.prototype.set=function(t,e){var n=this.__data__;if(n instanceof O){var i=n.__data__;if(!Q||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new A(i)}return n.set(t,e),this.size=n.size,this};var rt,ot=function(t,e,n){for(var i=-1,r=Object(t),o=n(t),l=o.length;l--;){var a=o[rt?l:++i];if(!1===e(r[a],a,r))break}return t};function lt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":k&&k in Object(t)?function(t){var e=x.call(t,k),n=t[k];try{t[k]=void 0;var i=!0}catch(o){}var r=K.call(t);i&&(e?t[k]=n:delete t[k]);return r}(t):function(t){return K.call(t)}(t)}function at(t){return gt(t)&<(t)==r}function st(t){return!(!Rt(t)||function(t){return!!Y&&Y in t}(t))&&(vt(t)?J:a).test(function(t){if(null!=t){try{return L.call(t)}catch(e){}try{return t+""}catch(e){}}return""}(t))}function ut(t){if(!Rt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=mt(t),n=[];for(var i in t)("constructor"!=i||!e&&x.call(t,i))&&n.push(i);return n}function ct(t,e,n,i,r){t!==e&&ot(e,(function(o,a){if(r||(r=new q),Rt(o))!function(t,e,n,i,r,o,a){var s=ft(t,n),u=ft(e,n),c=a.get(u);if(c)return void tt(t,n,c);var d=o?o(s,u,n+"",t,e,a):void 0,h=void 0===d;if(h){var b=Gt(u),p=!b&&Vt(u),m=!b&&!p&&Lt(u);d=u,b||p||m?Gt(s)?d=s:gt(G=s)&&Wt(G)?d=function(t,e){var n=-1,i=t.length;e||(e=Array(i));for(;++n-1&&t%1==0&&t0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(T?function(t,e){return T(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Ht);function Zt(t,e){return t===e||t!=t&&e!=e}var Xt=at(function(){return arguments}())?at:function(t){return gt(t)&&x.call(t,"callee")&&!F.call(t,"callee")},Gt=Array.isArray;function Wt(t){return null!=t&&St(t.length)&&!vt(t)}var Vt=z||function(){return!1};function vt(t){if(!Rt(t))return!1;var e=lt(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<=i}function Rt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function gt(t){return null!=t&&"object"==typeof t}var Lt=Z?function(t){return function(e){return t(e)}}(Z):function(t){return gt(t)&&St(t.length)&&!!u[lt(t)]};function xt(t){return Wt(t)?$(t,!0):ut(t)}var Yt,Kt=(Yt=function(t,e,n){ct(t,e,n)},dt((function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,o=i>2?e[2]:void 0;for(r=Yt.length>3&&"function"==typeof r?(i--,r):void 0,o&&function(t,e,n){if(!Rt(n))return!1;var i=typeof e;return!!("number"==i?Wt(n)&&pt(e,n.length):"string"==i&&e in n)&&Zt(n[e],t)}(e[0],e[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++n=0&&e._call.call(void 0,t),e=e._next;--ha}()}finally{ha=0,function(){var t,e,n=ua,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:ua=e);ca=t,ga(i)}(),fa=0}}function Ra(){var t=Za.now(),e=t-ma;e>1e3&&(ya-=e,ma=t)}function ga(t){ha||(ba&&(ba=clearTimeout(ba)),t-fa>24?(t<1/0&&(ba=setTimeout(Sa,t-Za.now()-ya)),pa&&(pa=clearInterval(pa))):(pa||(ma=Za.now(),pa=setInterval(Ra,1e3)),ha=1,Xa(Sa)))}function La(t,e,n){var i=new Va;return e=null==e?0:+e,i.restart((n=>{i.stop(),t(n+e)}),e,n),i}Va.prototype=va.prototype={constructor:Va,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Ga():+n)+(null==e?0:+e),this._next||ca===this||(ca?ca._next=this:ua=this,ca=this),this._call=t,this._time=n,ga()},stop:function(){this._call&&(this._call=null,this._time=1/0,ga())}};var xa={value:()=>{}};function Ya(){for(var t,e=0,n=arguments.length,i={};e=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Ja(t,e){for(var n,i=0,r=t.length;i0)for(var n,i,r=new Array(n),o=0;o=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Ia.hasOwnProperty(e)?{space:Ia[e],local:t}:t}function Ca(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===_a&&e.documentElement.namespaceURI===_a?e.createElement(t):e.createElementNS(n,t)}}function Ua(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Fa(t){var e=Na(t);return(e.local?Ua:Ca)(e)}function Ba(){}function ka(t){return null==t?Ba:function(){return this.querySelector(t)}}function Ta(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function za(){return[]}function Ma(t){return function(e){return e.matches(t)}}var ja=Array.prototype.find;function Qa(){return this.firstElementChild}var Pa=Array.prototype.filter;function Ea(){return this.children}function Da(t){return new Array(t.length)}function Oa(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function Aa(t){return function(){return t}}function qa(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function ns(t){return function(){this.removeAttribute(t)}}function is(t){return function(){this.removeAttributeNS(t.space,t.local)}}function rs(t,e){return function(){this.setAttribute(t,e)}}function os(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ls(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function as(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 ss(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function us(t){return function(){this.style.removeProperty(t)}}function cs(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ds(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function hs(t,e){return t.style.getPropertyValue(e)||ss(t).getComputedStyle(t,null).getPropertyValue(e)}function bs(t){return function(){delete this[t]}}function ps(t,e){return function(){this[t]=e}}function ms(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function fs(t){return t.trim().split(/^|\s+/)}function ys(t){return t.classList||new Zs(t)}function Zs(t){this._node=t,this._names=fs(t.getAttribute("class")||"")}function Xs(t,e){for(var n=ys(t),i=-1,r=e.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function Cs(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Ts=[null];function zs(t,e){this._groups=t,this._parents=e}function Ms(t){return"string"==typeof t?new zs([[document.querySelector(t)]],[document.documentElement]):new zs([[t]],Ts)}function js(t){t.preventDefault(),t.stopImmediatePropagation()}function Qs(t){var e=t.document.documentElement,n=Ms(t).on("dragstart.drag",js,!0);"onselectstart"in e?n.on("selectstart.drag",js,!0):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Ps(t,e){var n=t.document.documentElement,i=Ms(t).on("dragstart.drag",null);e&&(i.on("click.drag",js,!0),setTimeout((function(){i.on("click.drag",null)}),0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}zs.prototype={constructor:zs,select:function(t){"function"!=typeof t&&(t=ka(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=W&&(W=G+1);!(X=f[W])&&++W=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=es);for(var n=this._groups,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?us:"function"==typeof e?ds:cs)(t,e,null==n?"":n)):hs(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?bs:"function"==typeof e?ms:ps)(t,e)):this.node()[t]},classed:function(t,e){var n=fs(t+"");if(arguments.length<2){for(var i=ys(this.node()),r=-1,o=n.length;++r=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),As.hasOwnProperty(e)?{space:As[e],local:t}:t}function $s(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Os&&e.documentElement.namespaceURI===Os?e.createElement(t):e.createElementNS(n,t)}}function tu(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function eu(t){var e=qs(t);return(e.local?tu:$s)(e)}function nu(){}function iu(t){return null==t?nu:function(){return this.querySelector(t)}}function ru(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function ou(){return[]}function lu(t){return function(e){return e.matches(t)}}var au=Array.prototype.find;function su(){return this.firstElementChild}var uu=Array.prototype.filter;function cu(){return this.children}function du(t){return new Array(t.length)}function hu(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function bu(t){return function(){return t}}function pu(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function Zu(t){return function(){this.removeAttribute(t)}}function Xu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Gu(t,e){return function(){this.setAttribute(t,e)}}function Wu(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Vu(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function vu(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 Su(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Ru(t){return function(){this.style.removeProperty(t)}}function gu(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Lu(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function xu(t,e){return t.style.getPropertyValue(e)||Su(t).getComputedStyle(t,null).getPropertyValue(e)}function Yu(t){return function(){delete this[t]}}function Ku(t,e){return function(){this[t]=e}}function Hu(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Ju(t){return t.trim().split(/^|\s+/)}function wu(t){return t.classList||new _u(t)}function _u(t){this._node=t,this._names=Ju(t.getAttribute("class")||"")}function Iu(t,e){for(var n=wu(t),i=-1,r=e.length;++i=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,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var rc=[null];function oc(t,e){this._groups=t,this._parents=e}function lc(t){return"string"==typeof t?new oc([[document.querySelector(t)]],[document.documentElement]):new oc([[t]],rc)}function ac(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 i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(e.getScreenCTM().inverse())).x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}oc.prototype={constructor:oc,select:function(t){"function"!=typeof t&&(t=iu(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=W&&(W=G+1);!(X=f[W])&&++W=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=yu);for(var n=this._groups,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?Ru:"function"==typeof e?Lu:gu)(t,e,null==n?"":n)):xu(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Yu:"function"==typeof e?Hu:Ku)(t,e)):this.node()[t]},classed:function(t,e){var n=Ju(t+"");if(arguments.length<2){for(var i=wu(this.node()),r=-1,o=n.length;++r0)throw new Error("too late; already scheduled");return n}function hc(t,e){var n=bc(t,e);if(n.state>3)throw new Error("too late; already running");return n}function bc(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function pc(t,e){var n,i,r,o=t.__transition,l=!0;if(o){for(r in e=null==e?null:e+"",o)(n=o[r]).name===e?(i=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[r]):l=!1;l&&delete t.__transition}}function mc(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function fc(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function yc(){}var Zc=1/.7,Xc="\\s*([+-]?\\d+)\\s*",Gc="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wc="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vc=/^#([0-9a-f]{3,8})$/,vc=new RegExp("^rgb\\("+[Xc,Xc,Xc]+"\\)$"),Sc=new RegExp("^rgb\\("+[Wc,Wc,Wc]+"\\)$"),Rc=new RegExp("^rgba\\("+[Xc,Xc,Xc,Gc]+"\\)$"),gc=new RegExp("^rgba\\("+[Wc,Wc,Wc,Gc]+"\\)$"),Lc=new RegExp("^hsl\\("+[Gc,Wc,Wc]+"\\)$"),xc=new RegExp("^hsla\\("+[Gc,Wc,Wc,Gc]+"\\)$"),Yc={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 Kc(){return this.rgb().formatHex()}function Hc(){return this.rgb().formatRgb()}function Jc(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Vc.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?wc(e):3===n?new Cc(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?_c(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?_c(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=vc.exec(t))?new Cc(e[1],e[2],e[3],1):(e=Sc.exec(t))?new Cc(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Rc.exec(t))?_c(e[1],e[2],e[3],e[4]):(e=gc.exec(t))?_c(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Lc.exec(t))?kc(e[1],e[2]/100,e[3]/100,1):(e=xc.exec(t))?kc(e[1],e[2]/100,e[3]/100,e[4]):Yc.hasOwnProperty(t)?wc(Yc[t]):"transparent"===t?new Cc(NaN,NaN,NaN,0):null}function wc(t){return new Cc(t>>16&255,t>>8&255,255&t,1)}function _c(t,e,n,i){return i<=0&&(t=e=n=NaN),new Cc(t,e,n,i)}function Ic(t){return t instanceof yc||(t=Jc(t)),t?new Cc((t=t.rgb()).r,t.g,t.b,t.opacity):new Cc}function Nc(t,e,n,i){return 1===arguments.length?Ic(t):new Cc(t,e,n,null==i?1:i)}function Cc(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function Uc(){return"#"+Bc(this.r)+Bc(this.g)+Bc(this.b)}function Fc(){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 Bc(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function kc(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new zc(t,e,n,i)}function Tc(t){if(t instanceof zc)return new zc(t.h,t.s,t.l,t.opacity);if(t instanceof yc||(t=Jc(t)),!t)return new zc;if(t instanceof zc)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),o=Math.max(e,n,i),l=NaN,a=o-r,s=(o+r)/2;return a?(l=e===o?(n-i)/a+6*(n0&&s<1?0:l,new zc(l,a,s,t.opacity)}function zc(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Mc(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}mc(yc,Jc,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:Kc,formatHex:Kc,formatHsl:function(){return Tc(this).formatHsl()},formatRgb:Hc,toString:Hc}),mc(Cc,Nc,fc(yc,{brighter:function(t){return t=null==t?Zc:Math.pow(Zc,t),new Cc(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Cc(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:Uc,formatHex:Uc,formatRgb:Fc,toString:Fc})),mc(zc,(function(t,e,n,i){return 1===arguments.length?Tc(t):new zc(t,e,n,null==i?1:i)}),fc(yc,{brighter:function(t){return t=null==t?Zc:Math.pow(Zc,t),new zc(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new zc(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,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Cc(Mc(t>=240?t-240:t+120,r,i),Mc(t,r,i),Mc(t<120?t+240:t-120,r,i),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 jc=Math.PI/180,Qc=180/Math.PI;var Pc=-.14861,Ec=1.78277,Dc=-.29227,Oc=-.90649,Ac=1.97294,qc=Ac*Oc,$c=Ac*Ec,td=Ec*Dc-Oc*Pc;function ed(t){if(t instanceof id)return new id(t.h,t.s,t.l,t.opacity);t instanceof Cc||(t=Ic(t));var e=t.r/255,n=t.g/255,i=t.b/255,r=(td*i+qc*e-$c*n)/(td+qc-$c),o=i-r,l=(Ac*(n-r)-Dc*o)/Oc,a=Math.sqrt(l*l+o*o)/(Ac*r*(1-r)),s=a?Math.atan2(l,o)*Qc-120:NaN;return new id(s<0?s+360:s,a,r,t.opacity)}function nd(t,e,n,i){return 1===arguments.length?ed(t):new id(t,e,n,null==i?1:i)}function id(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}mc(id,nd,fc(yc,{brighter:function(t){return t=null==t?Zc:Math.pow(Zc,t),new id(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new id(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*jc,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),i=Math.cos(t),r=Math.sin(t);return new Cc(255*(e+n*(Pc*i+Ec*r)),255*(e+n*(Dc*i+Oc*r)),255*(e+n*(Ac*i)),this.opacity)}}));var rd=t=>()=>t;function od(t,e){return function(n){return t+n*e}}function ld(t){return 1==(t=+t)?ad: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(i){return Math.pow(t+i*e,n)}}(e,n,t):rd(isNaN(e)?n:e)}}function ad(t,e){var n=e-t;return n?od(t,n):rd(isNaN(t)?e:t)}var sd=function t(e){var n=ld(e);function i(t,e){var i=n((t=Nc(t)).r,(e=Nc(e)).r),r=n(t.g,e.g),o=n(t.b,e.b),l=ad(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=o(e),t.opacity=l(e),t+""}}return i.gamma=t,i}(1);var ud,cd=(ud=function(t){var e=t.length-1;return function(n){var i=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),r=t[i],o=t[i+1],l=i>0?t[i-1]:2*r-o,a=io&&(r=e.slice(o,r),a[l]?a[l]+=r:a[++l]=r),(n=n[0])===(i=i[0])?a[l]?a[l]+=i:a[++l]=i:(a[++l]=null,s.push({i:l,x:pd(n,i)})),o=yd.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(r(n)+"rotate(",null,i)-2,x:pd(t,e)})):e&&n.push(r(n)+"rotate("+e+i)}(o.rotate,l.rotate,a,s),function(t,e,n,o){t!==e?o.push({i:n.push(r(n)+"skewX(",null,i)-2,x:pd(t,e)}):e&&n.push(r(n)+"skewX("+e+i)}(o.skewX,l.skewX,a,s),function(t,e,n,i,o,l){if(t!==n||e!==i){var a=o.push(r(o)+"scale(",null,",",null,")");l.push({i:a-4,x:pd(t,n)},{i:a-2,x:pd(e,i)})}else 1===n&&1===i||o.push(r(o)+"scale("+n+","+i+")")}(o.scaleX,o.scaleY,l.scaleX,l.scaleY,a,s),o=l=null,function(t){for(var e,n=-1,i=s.length;++n180||n<-180?n-360*Math.round(n/360):n):rd(isNaN(t)?e:t)}));var Yd=xd(ad);function Kd(t,e){var n,i;return function(){var r=hc(this,t),o=r.tween;if(o!==n)for(var l=0,a=(i=n=o).length;l=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?dc:hc;return function(){var l=o(this,t),a=l.on;a!==i&&(r=(i=a).copy()).on(e,n),l.on=r}}var Od=bt.prototype.constructor;function Ad(t){return function(){this.style.removeProperty(t)}}function qd(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}function $d(t,e,n){var i,r;function o(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&qd(t,o,n)),i}return o._value=e,o}function th(t){return function(e){this.textContent=t.call(this,e)}}function eh(t){var e,n;function i(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&th(i)),e}return i._value=t,i}var nh=0;function ih(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function rh(){return++nh}var oh=bt.prototype;ih.prototype={constructor:ih,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=a(t));for(var i=this._groups,r=i.length,o=new Array(r),l=0;l()=>t;function uh(t,{sourceEvent:e,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function ch(t,e,n){this.k=t,this.x=e,this.y=n}ch.prototype={constructor:ch,scale:function(t){return 1===t?this:new ch(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new ch(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 dh=new ch(1,0,0);function hh(t){t.stopImmediatePropagation()}function bh(t){t.preventDefault(),t.stopImmediatePropagation()}function ph(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function mh(){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 fh(){return this.__zoom||dh}function yh(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Zh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xh(t,e,n){var i=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],l=t.invertY(e[1][1])-n[1][1];return t.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l))}function Gh(t,e){return te?1:t>=e?0:NaN}function Wh(t){let e=t,n=t;function i(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)<0?i=o+1:r=o}return i}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>Gh(t(e),n)}(t)),{left:i,center:function(t,n,r,o){null==r&&(r=0),null==o&&(o=t.length);const l=i(t,n,r,o-1);return l>r&&e(t[l-1],n)>-e(t[l],n)?l-1:l},right:function(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)>0?r=o:i=o+1}return i}}}const Vh=Wh(Gh).right;Wh((function(t){return null===t?NaN:+t})).center;var vh=Math.sqrt(50),Sh=Math.sqrt(10),Rh=Math.sqrt(2);function gh(t,e,n){var i,r,o,l,a=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((i=e0){let n=Math.round(t/l),i=Math.round(e/l);for(n*le&&--i,o=new Array(r=i-n+1);++ae&&--i,o=new Array(r=i-n+1);++a=0?(o>=vh?10:o>=Sh?5:o>=Rh?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=vh?10:o>=Sh?5:o>=Rh?2:1)}function xh(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Yh(t){return+t}var Kh=[0,1];function Hh(t){return t}function Jh(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:(n=isNaN(e)?NaN:.5,function(){return n});var n}function wh(t,e,n){var i=t[0],r=t[1],o=e[0],l=e[1];return re&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),i=s>2?_h:wh,r=o=null,d}function d(e){return null==e||isNaN(e=+e)?n:(r||(r=i(l.map(t),a,s)))(t(u(e)))}return d.invert=function(n){return u(e((o||(o=i(a,l.map(t),pd)))(n)))},d.domain=function(t){return arguments.length?(l=Array.from(t,Yh),c()):l.slice()},d.range=function(t){return arguments.length?(a=Array.from(t),c()):a.slice()},d.rangeRound=function(t){return a=Array.from(t),s=Gd,c()},d.clamp=function(t){return arguments.length?(u=!!t||Hh,c()):u!==Hh},d.interpolate=function(t){return arguments.length?(s=t,c()):s},d.unknown=function(t){return arguments.length?(n=t,d):n},function(n,i){return t=n,e=i,c()}}function Ch(){return Nh()(Hh,Hh)}function Uh(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function Fh(t){return(t=Uh(Math.abs(t)))?t[1]:NaN}var Bh,kh=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Th(t){if(!(e=kh.exec(t)))throw new Error("invalid format: "+t);var e;return new zh({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 zh(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 Mh(t,e){var n=Uh(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}Th.prototype=zh.prototype,zh.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 jh={"%":(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)=>Mh(100*t,e),r:Mh,s:function(t,e){var n=Uh(t,e);if(!n)return t+"";var i=n[0],r=n[1],o=r-(Bh=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,l=i.length;return o===l?i:o>l?i+new Array(o-l+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+Uh(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Qh(t){return t}var Ph,Eh,Dh,Oh=Array.prototype.map,Ah=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function qh(t){var e,n,i=void 0===t.grouping||void 0===t.thousands?Qh:(e=Oh.call(t.grouping,Number),n=t.thousands+"",function(t,i){for(var r=t.length,o=[],l=0,a=e[0],s=0;r>0&&a>0&&(s+a+1>i&&(a=Math.max(1,i-s)),o.push(t.substring(r-=a,r+a)),!((s+=a+1)>i));)a=e[l=(l+1)%e.length];return o.reverse().join(n)}),r=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",l=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Qh:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Oh.call(t.numerals,String)),s=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function d(t){var e=(t=Th(t)).fill,n=t.align,d=t.sign,h=t.symbol,b=t.zero,p=t.width,m=t.comma,f=t.precision,y=t.trim,Z=t.type;"n"===Z?(m=!0,Z="g"):jh[Z]||(void 0===f&&(f=12),y=!0,Z="g"),(b||"0"===e&&"="===n)&&(b=!0,e="0",n="=");var X="$"===h?r:"#"===h&&/[boxX]/.test(Z)?"0"+Z.toLowerCase():"",G="$"===h?o:/[%p]/.test(Z)?s:"",W=jh[Z],V=/[defgprs%]/.test(Z);function v(t){var r,o,s,h=X,v=G;if("c"===Z)v=W(t)+v,t="";else{var S=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:W(Math.abs(t),f),y&&(t=function(t){t:for(var e,n=t.length,i=1,r=-1;i0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),S&&0==+t&&"+"!==d&&(S=!1),h=(S?"("===d?d:u:"-"===d||"("===d?"":d)+h,v=("s"===Z?Ah[8+Bh/3]:"")+v+(S&&"("===d?")":""),V)for(r=-1,o=t.length;++r(s=t.charCodeAt(r))||s>57){v=(46===s?l+t.slice(r+1):t.slice(r))+v,t=t.slice(0,r);break}}m&&!b&&(t=i(t,1/0));var R=h.length+t.length+v.length,g=R>1)+h+t+v+g.slice(R);break;default:t=g+h+t+v}return a(t)}return f=void 0===f?6:/[gprs]/.test(Z)?Math.max(1,Math.min(21,f)):Math.max(0,Math.min(20,f)),v.toString=function(){return t+""},v}return{format:d,formatPrefix:function(t,e){var n=d(((t=Th(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(Fh(e)/3))),r=Math.pow(10,-i),o=Ah[8+i/3];return function(t){return n(r*t)+o}}}}function $h(t,e,n,i){var r,o=function(t,e,n){var i=Math.abs(e-t)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=vh?r*=10:o>=Sh?r*=5:o>=Rh&&(r*=2),e0;){if((r=Lh(s,u,n))===i)return o[l]=s,o[a]=u,e(o);if(r>0)s=Math.floor(s/r)*r,u=Math.ceil(u/r)*r;else{if(!(r<0))break;s=Math.ceil(s*r)/r,u=Math.floor(u*r)/r}i=r}return t},t}function eb(){var t=Ch();return t.copy=function(){return Ih(t,eb())},xh.apply(t,arguments),tb(t)}function nb(t){return Math.log(t)}function ib(t){return Math.exp(t)}function rb(t){return-Math.log(-t)}function ob(t){return-Math.exp(-t)}function lb(t){return isFinite(t)?+("1e"+t):t<0?0:t}function ab(t){return function(e){return-t(-e)}}function sb(t){var e,n,i=t(nb,ib),r=i.domain,o=10;function l(){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?lb:t===Math.E?Math.exp:function(e){return Math.pow(t,e)}}(o),r()[0]<0?(e=ab(e),n=ab(n),t(rb,ob)):t(nb,ib),i}return i.base=function(t){return arguments.length?(o=+t,l()):o},i.domain=function(t){return arguments.length?(r(t),l()):r()},i.ticks=function(t){var i,l=r(),a=l[0],s=l[l.length-1];(i=s0){for(;h<=b;++h)for(c=1,u=n(h);cs)break;m.push(d)}}else for(;h<=b;++h)for(c=o-1,u=n(h);c>=1;--c)if(!((d=u*c)s)break;m.push(d)}2*m.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=>fb(t.data))))).html((t=>fb(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(),[i,r]=t.x.map(n.x),[o,l]=t.y.map(n.y),{canvas:a,zoomer:s,width:u,height:c}=this,d=dh.translate(u/2,c/2).scale(.9/Math.max((r-i)/u,(l-o)/c)).translate(-(i+r)/2,-(o+l)/2);a.transition().duration(1e3*e).call(s.transform,d)}initialize_zoom(){const{width:t,height:e,canvas:n}=this;this.transform=dh;const i=function(){var t,e,n,i=ph,r=mh,o=Xh,l=yh,a=Zh,s=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,d=Ds,h=Ya("start","zoom","end"),b=500,p=0,m=10;function f(t){t.property("__zoom",fh).on("wheel.zoom",v,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",R).filter(a).on("touchstart.zoom",g).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",x).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,e){return(e=Math.max(s[0],Math.min(s[1],e)))===t.k?t:new ch(e,t.x,t.y)}function Z(t,e,n){var i=e[0]-n[0]*t.k,r=e[1]-n[1]*t.k;return i===t.x&&r===t.y?t:new ch(t.k,i,r)}function X(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function G(t,e,n,i){t.on("start.zoom",(function(){W(this,arguments).event(i).start()})).on("interrupt.zoom end.zoom",(function(){W(this,arguments).event(i).end()})).tween("zoom",(function(){var t=this,o=arguments,l=W(t,o).event(i),a=r.apply(t,o),s=null==n?X(a):"function"==typeof n?n.apply(t,o):n,u=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),c=t.__zoom,h="function"==typeof e?e.apply(t,o):e,b=d(c.invert(s).concat(u/c.k),h.invert(s).concat(u/h.k));return function(t){if(1===t)t=h;else{var e=b(t),n=u/e[2];t=new ch(n,s[0]-e[0]*n,s[1]-e[1]*n)}l.zoom(null,t)}}))}function W(t,e,n){return!n&&t.__zooming||new V(t,e)}function V(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=r.apply(t,e),this.taps=0}function v(t,...e){if(i.apply(this,arguments)){var n=W(this,e).event(t),r=this.__zoom,a=Math.max(s[0],Math.min(s[1],r.k*Math.pow(2,l.apply(this,arguments)))),c=ac(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=r.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(r.k===a)return;n.mouse=[c,r.invert(c)],pc(this),n.start()}bh(t),n.wheel=setTimeout(d,150),n.zoom("mouse",o(Z(y(r,a),n.mouse[0],n.mouse[1]),n.extent,u))}function d(){n.wheel=null,n.end()}}function S(t,...e){if(!n&&i.apply(this,arguments)){var r=t.currentTarget,l=W(this,e,!0).event(t),a=lc(t.view).on("mousemove.zoom",h,!0).on("mouseup.zoom",b,!0),s=ac(t,r),c=t.clientX,d=t.clientY;Qs(t.view),hh(t),l.mouse=[s,this.__zoom.invert(s)],pc(this),l.start()}function h(t){if(bh(t),!l.moved){var e=t.clientX-c,n=t.clientY-d;l.moved=e*e+n*n>p}l.event(t).zoom("mouse",o(Z(l.that.__zoom,l.mouse[0]=ac(t,r),l.mouse[1]),l.extent,u))}function b(t){a.on("mousemove.zoom mouseup.zoom",null),Ps(t.view,l.moved),bh(t),l.event(t).end()}}function R(t,...e){if(i.apply(this,arguments)){var n=this.__zoom,l=ac(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(l),s=n.k*(t.shiftKey?.5:2),d=o(Z(y(n,s),l,a),r.apply(this,e),u);bh(t),c>0?lc(this).transition().duration(c).call(G,d,l,t):lc(this).call(f.transform,d,l,t)}}function g(n,...r){if(i.apply(this,arguments)){var o,l,a,s,u=n.touches,c=u.length,d=W(this,r,n.changedTouches.length===c).event(n);for(hh(n),l=0;l{this.transform=t.transform,this.restart_timer(1e4)}));n.call(i),this.add_mouseover(),this.zoomer=i}add_mouseover(){let t=0;const e=pt("#deepscatter-svg").append("g").attr("class","label"),n=this.renderers.get("regl"),i=n.aes.x.current,r=n.aes.y.current;this.canvas.on("mousemove",(o=>{if(Date.now()-t<1e3/30)return;t=Date.now();const l=n.color_pick(o.x,o.y),a=l?[l]:[],s=a[0],u=s?[{x:o.x,y:o.y,data:s,dx:0,dy:30}]:[],{x_:c,y_:d}=this.scales();u.length&&this.html_annotation(u);e.selectAll("g").data(a).join("g").attr("transform",(t=>`translate(\n ${c(i.value_for(t))},\n ${d(r.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_:i,y_:r}=n;return{x:[i.invert(0),i.invert(t)],y:[r.invert(0),r.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=va(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:i}=this,{extent:r}=this.tileSet,o={};if(void 0===r)return;const l={x:{},y:{}};for(const[h,b]of[["x",e],["y",n]]){const t=r[h];l[h].limits=t,l[h].size_range=t[1]-t[0],l[h].pixels_per_unit=b/l[h].size_range}const a=l.x.pixels_per_unit/l.y.pixels_per_unit;let s=0,u=0,c=e,d=n;return a>1?(c=e/a,s=(e-c)/2):(d=n*a,u=(n-d)/2),o.x=eb().domain(l.x.limits).range([s,e-s]),o.y=eb().domain(l.y.limits).range([u,n-u]),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 mb(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 mb(t,e){function n(t){return t[1]-t[0]}const i=Me(t.domain()),r=Me(e.domain()),o=n(t.range())/n(t.domain()),l=n(e.range())/n(e.domain());return[[o,0,-o*i+Me(t.range())],[0,l,-l*r+Me(e.range())],[0,0,1]]}function fb(t,e){let n="";const i=new Set(["x","y","ix","bookstack",null,"tile_key"]);for(const[r,o]of t.entries()){if(e){if(!e.has(r))continue}else{if(i.has(r))continue;if(r.match(/_dict_index/))continue;if(null===o)continue;if(""===o)continue}n+=`${r}: ${o}
`}return n}var yb={exports:{}},Zb=yb.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),i=0;i=0&&(0|t)===t||r("invalid parameter type, ("+t+")"+l(e)+". must be a nonnegative integer")}function h(t,e,n){e.indexOf(t)<0&&r("invalid value"+l(n)+". must be one of: "+e)}var b=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(t){Object.keys(t).forEach((function(t){b.indexOf(t)<0&&r('invalid regl constructor argument "'+t+'". must be one of '+b)}))}function m(t,e){for(t+="";t.length0&&e.push(new Z("unknown",0,t))}})),e}function v(t,e){e.forEach((function(e){var n=t[e.file];if(n){var i=n.index[e.line];if(i)return i.errors.push(e),void(n.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(e)}))}function S(t,e,i,r,l){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var a=t.getShaderInfoLog(e),s=r===t.FRAGMENT_SHADER?"fragment":"vertex";H(i,"string",s+" shader source must be a string",l);var u=W(i,l),c=V(a);v(u,c),Object.keys(u).forEach((function(t){var e=u[t];if(e.hasErrors){var i=[""],r=[""];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(m(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(i){var r=i.message,l=/^\s*'(.*)'\s*:\s*(.*)$/.exec(r);if(l){var a=l[1];switch(r=l[2],a){case"assign":a="="}e=Math.max(t.line.indexOf(a,e),0)}else e=0;o(m("| ",6)),o(m("^^^",e+3)+n,"font-weight:bold"),o(m("| ",6)),o(r+n,"font-weight:bold")})),o(m("| ",6)+n)}else o(m(t.number,4)+"| "),o(t.line+n,"color:red")})),"undefined"==typeof document||window.chrome?console.log(i.join("")):(r[0]=i.join("%c"),console.log.apply(console,r))}function o(t,e){i.push(t),r.push(e||"")}})),o.raise("Error compiling "+s+" shader, "+u[0].name)}}function R(t,e,i,r,l){if(!t.getProgramParameter(e,t.LINK_STATUS)){var a=t.getProgramInfoLog(e),s=W(i,l),u='Error linking program with vertex shader, "'+W(r,l)[0].name+'", and fragment shader "'+s[0].name+'"';"undefined"!=typeof document?console.log("%c"+u+n+"%c"+a,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(u+n+a),o.raise(u)}}function g(t){t._commandRef=X()}function L(t,e,n,i){function r(t){return t?i.id(t):0}function o(t,e){Object.keys(e).forEach((function(e){t[i.id(e)]=!0}))}g(t),t._fragId=r(t.static.frag),t._vertId=r(t.static.vert);var l=t._uniformSet={};o(l,e.static),o(l,e.dynamic);var a=t._attributeSet={};o(a,n.static),o(a,n.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic}function x(t,e){var n=G();r(t+" in command "+(e||X())+("unknown"===n?"":" called from "+n))}function Y(t,e,n){t||x(e,n||X())}function K(t,e,n,i){t in e||x("unknown parameter ("+t+")"+l(n)+". possible values: "+Object.keys(e).join(),i||X())}function H(t,e,n,i){u(t,e)||x("invalid parameter type"+l(n)+". expected "+e+", got "+typeof t,i||X())}function J(t){t()}function w(t,e,n){t.texture?h(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):h(t.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}var _=33071,I=9728,N=9984,C=9985,U=9986,F=9987,B=5121,k=5122,T=5123,z=5124,M=5125,j=5126,Q=32819,P=32820,E=33635,D=34042,O=36193,A={};function q(t,e){return t===P||t===Q||t===E?2:t===D?4:A[t]*e}function $(t){return!(t&t-1||!t)}function tt(t,e,n){var i,r=e.width,l=e.height,a=e.channels;o(r>0&&r<=n.maxTextureSize&&l>0&&l<=n.maxTextureSize,"invalid texture shape"),t.wrapS===_&&t.wrapT===_||o($(r)&&$(l),"incompatible wrap mode for texture, both width and height must be power of 2"),1===e.mipmask?1!==r&&1!==l&&o(t.minFilter!==N&&t.minFilter!==U&&t.minFilter!==C&&t.minFilter!==F,"min filter requires mipmap"):(o($(r)&&$(l),"texture must be a square power of 2 to support mipmapping"),o(e.mipmask===(r<<1)-1,"missing or incomplete mipmap data")),e.type===j&&(n.extensions.indexOf("oes_texture_float_linear")<0&&o(t.minFilter===I&&t.magFilter===I,"filter not supported, must enable oes_texture_float_linear"),o(!t.genMipmaps,"mipmap generation not supported with float textures"));var s=e.images;for(i=0;i<16;++i)if(s[i]){var u=r>>i,c=l>>i;o(e.mipmask&1<0&&r<=i.maxTextureSize&&l>0&&l<=i.maxTextureSize,"invalid texture shape"),o(r===l,"cube map must be square"),o(e.wrapS===_&&e.wrapT===_,"wrap mode not supported by cube map");for(var s=0;s>d,p=l>>d;o(u.mipmask&1<1&&e===n&&('"'===e||"'"===e))return['"'+st(t.substr(1,t.length-2))+'"'];var i=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(i)return ut(t.substr(0,i.index)).concat(ut(i[1])).concat(ut(t.substr(i.index+i[0].length)));var r=t.split(".");if(1===r.length)return['"'+st(t)+'"'];for(var o=[],l=0;l0,"invalid pixel ratio"))):nt.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?i=e:n=e),!r){if(!i){nt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var b=Zt(n||document.body,d,u);if(!b)return null;i=b.canvas,h=b.onDestroy}void 0===l.premultipliedAlpha&&(l.premultipliedAlpha=!0),r=Xt(i,l)}return r?{gl:r,canvas:i,container:n,extensions:a,optionalExtensions:s,pixelRatio:u,profile:c,onDone:d,onDestroy:h}:(h(),d("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Rt(t,e){var n={};function i(e){nt.type(e,"string","extension name must be string");var i,r=e.toLowerCase();try{i=n[r]=t.getExtension(r)}catch(o){}return!!i}for(var r=0;r65535)<<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=gt(8,(function(){return[]}));function e(e){var n=_t(e),i=t[It(n)>>2];return i.length>0?i.pop():new ArrayBuffer(n)}function n(e){t[It(e.byteLength)>>2].push(e)}function i(t,n){var i=null;switch(t){case Lt:i=new Int8Array(e(n),0,n);break;case xt:i=new Uint8Array(e(n),0,n);break;case Yt:i=new Int16Array(e(2*n),0,n);break;case Kt:i=new Uint16Array(e(2*n),0,n);break;case Ht:i=new Int32Array(e(4*n),0,n);break;case Jt:i=new Uint32Array(e(4*n),0,n);break;case wt:i=new Float32Array(e(4*n),0,n);break;default:return null}return i.length!==n?i.subarray(0,n):i}function r(t){n(t.buffer)}return{alloc:e,free:n,allocType:i,freeType:r}}var Ct=Nt();Ct.zero=Nt();var Ut=3408,Ft=3410,Bt=3411,kt=3412,Tt=3413,zt=3414,Mt=3415,jt=33901,Qt=33902,Pt=3379,Et=3386,Dt=34921,Ot=36347,At=36348,qt=35661,$t=35660,te=34930,ee=36349,ne=34076,ie=34024,re=7936,oe=7937,le=7938,ae=35724,se=34047,ue=36063,ce=34852,de=3553,he=34067,be=34069,pe=33984,me=6408,fe=5126,ye=5121,Ze=36160,Xe=36053,Ge=36064,We=16384,Ve=function(t,e){var n=1;e.ext_texture_filter_anisotropic&&(n=t.getParameter(se));var i=1,r=1;e.webgl_draw_buffers&&(i=t.getParameter(ce),r=t.getParameter(ue));var o=!!e.oes_texture_float;if(o){var l=t.createTexture();t.bindTexture(de,l),t.texImage2D(de,0,me,1,1,0,me,fe,null);var a=t.createFramebuffer();if(t.bindFramebuffer(Ze,a),t.framebufferTexture2D(Ze,Ge,de,l,0),t.bindTexture(de,null),t.checkFramebufferStatus(Ze)!==Xe)o=!1;else{t.viewport(0,0,1,1),t.clearColor(1,0,0,1),t.clear(We);var s=Ct.allocType(fe,4);t.readPixels(0,0,1,1,me,fe,s),t.getError()?o=!1:(t.deleteFramebuffer(a),t.deleteTexture(l),o=1===s[0]),Ct.freeType(s)}}var u=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=t.createTexture(),d=Ct.allocType(ye,36);t.activeTexture(pe),t.bindTexture(he,c),t.texImage2D(be,0,me,3,3,0,me,ye,d),Ct.freeType(d),t.bindTexture(he,null),t.deleteTexture(c),u=!t.getError()}return{colorBits:[t.getParameter(Ft),t.getParameter(Bt),t.getParameter(kt),t.getParameter(Tt)],depthBits:t.getParameter(zt),stencilBits:t.getParameter(Mt),subpixelBits:t.getParameter(Ut),extensions:Object.keys(e).filter((function(t){return!!e[t]})),maxAnisotropic:n,maxDrawbuffers:i,maxColorAttachments:r,pointSizeDims:t.getParameter(jt),lineWidthDims:t.getParameter(Qt),maxViewportDims:t.getParameter(Et),maxCombinedTextureUnits:t.getParameter(qt),maxCubeMapSize:t.getParameter(ne),maxRenderbufferSize:t.getParameter(ie),maxTextureUnits:t.getParameter(te),maxTextureSize:t.getParameter(Pt),maxAttributes:t.getParameter(Dt),maxVertexUniforms:t.getParameter(Ot),maxVertexTextureUnits:t.getParameter($t),maxVaryingVectors:t.getParameter(At),maxFragmentUniforms:t.getParameter(ee),glsl:t.getParameter(ae),renderer:t.getParameter(oe),vendor:t.getParameter(re),version:t.getParameter(le),readFloat:o,npotTextureCube:u}};function ve(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]}))},Re={shape:He,flatten:Ke};function ge(t,e,n){for(var i=0;i0)if(Array.isArray(n[0])){a=Ne(n);for(var u=1,c=1;c0)if("number"==typeof e[0]){var o=Ct.allocType(c.dtype,e.length);ze(o,e),p(o,r),Ct.freeType(o)}else if(Array.isArray(e[0])||t(e[0])){i=Ne(e);var l=Ie(e,i,c.dtype);p(l,r),Ct.freeType(l)}else nt.raise("invalid buffer data")}else if(ve(e)){i=e.shape;var a=e.stride,s=0,u=0,h=0,b=0;1===i.length?(s=i[0],u=1,h=a[0],b=0):2===i.length?(s=i[0],u=i[1],h=a[0],b=a[1]):nt.raise("invalid shape");var m=Array.isArray(e.data)?c.dtype:Te(e.data),f=Ct.allocType(m,s*u);Me(f,e.data,s,u,h,b,e.offset),p(f,r),Ct.freeType(f)}else nt.raise("invalid data for buffer subdata");return d}return l[c.id]=c,s||d(r),d._reglType="buffer",d._buffer=c,d.subdata=m,i.profile&&(d.stats=c.stats),d.destroy=function(){b(c)},d}function m(){Se(l).forEach((function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)}))}return i.profile&&(n.getTotalBufferSize=function(){var t=0;return Object.keys(l).forEach((function(e){t+=l[e].stats.size})),t}),{create:p,createStream:u,destroyStream:c,clear:function(){Se(l).forEach(b),s.forEach(b)},getBuffer:function(t){return t&&t._buffer instanceof a?t._buffer:null},restore:m,_initBuffer:h}}ke[5120]=1,ke[5122]=2,ke[5124]=4,ke[5121]=1,ke[5123]=2,ke[5125]=4,ke[5126]=4;var Qe={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},Pe=0,Ee=1,De=4,Oe=5120,Ae=5121,qe=5122,$e=5123,tn=5124,en=5125,nn=34963,rn=35040,on=35044;function ln(e,n,i,r){var o={},l=0,a={uint8:Ae,uint16:$e};function s(t){this.id=l++,o[this.id]=this,this.buffer=t,this.primType=De,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(a.uint32=en),s.prototype.bind=function(){this.buffer.bind()};var u=[];function c(t){var e=u.pop();return e||(e=new s(i.create(null,nn,!0,!1)._buffer)),h(e,t,rn,-1,-1,0,0),e}function d(t){u.push(t)}function h(r,o,l,a,s,u,c){var d;if(r.buffer.bind(),o){var h=c;c||t(o)&&(!ve(o)||t(o.data))||(h=n.oes_element_index_uint?en:$e),i._initBuffer(r.buffer,o,l,h,3)}else e.bufferData(nn,u,l),r.buffer.dtype=d||Ae,r.buffer.usage=l,r.buffer.dimension=3,r.buffer.byteLength=u;if(d=c,!c){switch(r.buffer.dtype){case Ae:case Oe:d=Ae;break;case $e:case qe:d=$e;break;case en:case tn:d=en;break;default:nt.raise("unsupported type for element array")}r.buffer.dtype=d}r.type=d,nt(d!==en||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var b=s;b<0&&(b=r.buffer.byteLength,d===$e?b>>=1:d===en&&(b>>=2)),r.vertCount=b;var p=a;if(a<0){p=De;var m=r.buffer.dimension;1===m&&(p=Pe),2===m&&(p=Ee),3===m&&(p=De)}r.primType=p}function b(t){r.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=i.create(null,nn,!0),l=new s(o._buffer);function u(e){if(e)if("number"==typeof e)o(e),l.primType=De,l.vertCount=0|e,l.type=Ae;else{var n=null,i=on,r=-1,s=-1,c=0,d=0;Array.isArray(e)||t(e)||ve(e)?n=e:(nt.type(e,"object","invalid arguments for elements"),"data"in e&&(n=e.data,nt(Array.isArray(n)||t(n)||ve(n),"invalid data for element buffer")),"usage"in e&&(nt.parameter(e.usage,_e,"invalid element buffer usage"),i=_e[e.usage]),"primitive"in e&&(nt.parameter(e.primitive,Qe,"invalid element buffer primitive"),r=Qe[e.primitive]),"count"in e&&(nt("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),s=0|e.count),"type"in e&&(nt.parameter(e.type,a,"invalid buffer type"),d=a[e.type]),"length"in e?c=0|e.length:(c=s,d===$e||d===qe?c*=2:d!==en&&d!==tn||(c*=4))),h(l,n,i,r,s,c,d)}else o(),l.primType=De,l.vertCount=0,l.type=Ae;return u}return r.elementsCount++,u(e),u._reglType="elements",u._elements=l,u.subdata=function(t,e){return o.subdata(t,e),u},u.destroy=function(){b(l)},u}return{create:p,createStream:c,destroyStream:d,getElements:function(t){return"function"==typeof t&&t._elements instanceof s?t._elements:null},clear:function(){Se(o).forEach(b)}}}var an=new Float32Array(1),sn=new Uint32Array(an.buffer),un=5123;function cn(t){for(var e=Ct.allocType(un,t.length),n=0;n>>31<<15,o=(i<<1>>>24)-127,l=i>>13&1023;if(o<-24)e[n]=r;else if(o<-14){var a=-14-o;e[n]=r+(l+1024>>a)}else e[n]=o>15?r+31744:r+(o+15<<10)+l}return e}function dn(e){return Array.isArray(e)||t(e)}var hn=function(t){return!(t&t-1||!t)},bn=34467,pn=3553,mn=34067,fn=34069,yn=6408,Zn=6406,Xn=6407,Gn=6409,Wn=6410,Vn=32854,vn=32855,Sn=36194,Rn=32819,gn=32820,Ln=33635,xn=34042,Yn=6402,Kn=34041,Hn=35904,Jn=35906,wn=36193,_n=33776,In=33777,Nn=33778,Cn=33779,Un=35986,Fn=35987,Bn=34798,kn=35840,Tn=35841,zn=35842,Mn=35843,jn=36196,Qn=5121,Pn=5123,En=5125,Dn=5126,On=10242,An=10243,qn=10497,$n=33071,ti=33648,ei=10240,ni=10241,ii=9728,ri=9729,oi=9984,li=9985,ai=9986,si=9987,ui=33170,ci=4352,di=4353,hi=4354,bi=34046,pi=3317,mi=37440,fi=37441,yi=37443,Zi=37444,Xi=33984,Gi=[oi,ai,li,si],Wi=[0,Gn,Wn,Xn,yn],Vi={};function vi(t){return"[object "+t+"]"}Vi[Gn]=Vi[Zn]=Vi[Yn]=1,Vi[Kn]=Vi[Wn]=2,Vi[Xn]=Vi[Hn]=3,Vi[yn]=Vi[Jn]=4;var Si=vi("HTMLCanvasElement"),Ri=vi("OffscreenCanvas"),gi=vi("CanvasRenderingContext2D"),Li=vi("ImageBitmap"),xi=vi("HTMLImageElement"),Yi=vi("HTMLVideoElement"),Ki=Object.keys(Je).concat([Si,Ri,gi,Li,xi,Yi]),Hi=[];Hi[Qn]=1,Hi[Dn]=4,Hi[wn]=2,Hi[Pn]=2,Hi[En]=4;var Ji=[];function wi(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function _i(t){return!!Array.isArray(t)&&!(0===t.length||!dn(t[0]))}function Ii(t){return Object.prototype.toString.call(t)}function Ni(t){return Ii(t)===Si}function Ci(t){return Ii(t)===Ri}function Ui(t){return Ii(t)===gi}function Fi(t){return Ii(t)===Li}function Bi(t){return Ii(t)===xi}function ki(t){return Ii(t)===Yi}function Ti(t){if(!t)return!1;var e=Ii(t);return Ki.indexOf(e)>=0||wi(t)||_i(t)||ve(t)}function zi(t){return 0|Je[Object.prototype.toString.call(t)]}function Mi(t,e){var n=e.length;switch(t.type){case Qn:case Pn:case En:case Dn:var i=Ct.allocType(t.type,n);i.set(e),t.data=i;break;case wn:t.data=cn(e);break;default:nt.raise("unsupported texture type, must specify a typed array")}}function ji(t,e){return Ct.allocType(t.type===wn?Dn:t.type,e)}function Qi(t,e){t.type===wn?(t.data=cn(e),Ct.freeType(e)):t.data=e}function Pi(t,e,n,i,r,o){for(var l=t.width,a=t.height,s=t.channels,u=ji(t,l*a*s),c=0,d=0;d=1;)a+=l*s*s,s/=2;return a}return l*n*i}function Di(n,i,r,o,l,a,s){var u={"don't care":ci,"dont care":ci,nice:hi,fast:di},c={repeat:qn,clamp:$n,mirror:ti},d={nearest:ii,linear:ri},h=e({mipmap:si,"nearest mipmap nearest":oi,"linear mipmap nearest":li,"nearest mipmap linear":ai,"linear mipmap linear":si},d),b={none:0,browser:Zi},p={uint8:Qn,rgba4:Rn,rgb565:Ln,"rgb5 a1":gn},m={alpha:Zn,luminance:Gn,"luminance alpha":Wn,rgb:Xn,rgba:yn,rgba4:Vn,"rgb5 a1":vn,rgb565:Sn},f={};i.ext_srgb&&(m.srgb=Hn,m.srgba=Jn),i.oes_texture_float&&(p.float32=p.float=Dn),i.oes_texture_half_float&&(p.float16=p["half float"]=wn),i.webgl_depth_texture&&(e(m,{depth:Yn,"depth stencil":Kn}),e(p,{uint16:Pn,uint32:En,"depth stencil":xn})),i.webgl_compressed_texture_s3tc&&e(f,{"rgb s3tc dxt1":_n,"rgba s3tc dxt1":In,"rgba s3tc dxt3":Nn,"rgba s3tc dxt5":Cn}),i.webgl_compressed_texture_atc&&e(f,{"rgb atc":Un,"rgba atc explicit alpha":Fn,"rgba atc interpolated alpha":Bn}),i.webgl_compressed_texture_pvrtc&&e(f,{"rgb pvrtc 4bppv1":kn,"rgb pvrtc 2bppv1":Tn,"rgba pvrtc 4bppv1":zn,"rgba pvrtc 2bppv1":Mn}),i.webgl_compressed_texture_etc1&&(f["rgb etc1"]=jn);var y=Array.prototype.slice.call(n.getParameter(bn));Object.keys(f).forEach((function(t){var e=f[t];y.indexOf(e)>=0&&(m[t]=e)}));var Z=Object.keys(m);r.textureFormats=Z;var X=[];Object.keys(m).forEach((function(t){var e=m[t];X[e]=t}));var G=[];Object.keys(p).forEach((function(t){var e=p[t];G[e]=t}));var W=[];Object.keys(d).forEach((function(t){var e=d[t];W[e]=t}));var V=[];Object.keys(h).forEach((function(t){var e=h[t];V[e]=t}));var v=[];Object.keys(c).forEach((function(t){var e=c[t];v[e]=t}));var S=Z.reduce((function(t,e){var n=m[e];return n===Gn||n===Zn||n===Gn||n===Wn||n===Yn||n===Kn||i.ext_srgb&&(n===Hn||n===Jn)?t[n]=n:n===vn||e.indexOf("rgba")>=0?t[n]=yn:t[n]=Xn,t}),{});function R(){this.internalformat=yn,this.format=yn,this.type=Qn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Zi,this.width=0,this.height=0,this.channels=0}function g(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 L(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,b,"invalid colorSpace"),t.colorSpace=b[e.colorSpace]),"type"in e){var n=e.type;nt(i.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),nt(i.oes_texture_half_float||!("half float"===n||"float16"===n),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),nt(i.webgl_depth_texture||!("uint16"===n||"uint32"===n||"depth stencil"===n),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(n,p,"invalid texture type"),t.type=p[n]}var o=t.width,l=t.height,a=t.channels,s=!1;"shape"in e?(nt(Array.isArray(e.shape)&&e.shape.length>=2,"shape must be an array"),o=e.shape[0],l=e.shape[1],3===e.shape.length&&(a=e.shape[2],nt(a>0&&a<=4,"invalid number of channels"),s=!0),nt(o>=0&&o<=r.maxTextureSize,"invalid width"),nt(l>=0&&l<=r.maxTextureSize,"invalid height")):("radius"in e&&(o=l=e.radius,nt(o>=0&&o<=r.maxTextureSize,"invalid radius")),"width"in e&&(o=e.width,nt(o>=0&&o<=r.maxTextureSize,"invalid width")),"height"in e&&(l=e.height,nt(l>=0&&l<=r.maxTextureSize,"invalid height")),"channels"in e&&(a=e.channels,nt(a>0&&a<=4,"invalid number of channels"),s=!0)),t.width=0|o,t.height=0|l,t.channels=0|a;var u=!1;if("format"in e){var c=e.format;nt(i.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(c,m,"invalid texture format");var d=t.internalformat=m[c];t.format=S[d],c in p&&("type"in e||(t.type=p[c])),c in f&&(t.compressed=!0),u=!0}!s&&u?t.channels=Vi[t.format]:s&&!u?t.channels!==Wi[t.format]&&(t.format=t.internalformat=Wi[t.channels]):u&&s&&nt(t.channels===Vi[t.format],"number of channels inconsistent with specified format")}}function x(t){n.pixelStorei(mi,t.flipY),n.pixelStorei(fi,t.premultiplyAlpha),n.pixelStorei(yi,t.colorSpace),n.pixelStorei(pi,t.unpackAlignment)}function Y(){R.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function K(e,n){var i=null;if(Ti(n)?i=n:n&&(nt.type(n,"object","invalid pixel data type"),L(e,n),"x"in n&&(e.xOffset=0|n.x),"y"in n&&(e.yOffset=0|n.y),Ti(n.data)&&(i=n.data)),nt(!e.compressed||i instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){nt(!i,"can not specify copy and data field for the same texture");var o=l.viewportWidth,a=l.viewportHeight;e.width=e.width||o-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0,nt(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=o&&e.height>0&&e.height<=a,"copy texture read out of bounds")}else if(i){if(t(i))e.channels=e.channels||4,e.data=i,"type"in n||e.type!==Qn||(e.type=zi(i));else if(wi(i))e.channels=e.channels||4,Mi(e,i),e.alignment=1,e.needsFree=!0;else if(ve(i)){var s=i.data;Array.isArray(s)||e.type!==Qn||(e.type=zi(s));var u,c,d,h,b,p,m=i.shape,f=i.stride;3===m.length?(d=m[2],p=f[2]):(nt(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),d=1,p=1),u=m[0],c=m[1],h=f[0],b=f[1],e.alignment=1,e.width=u,e.height=c,e.channels=d,e.format=e.internalformat=Wi[d],e.needsFree=!0,Pi(e,s,h,b,p,i.offset)}else if(Ni(i)||Ci(i)||Ui(i))Ni(i)||Ci(i)?e.element=i:e.element=i.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(Fi(i))e.element=i,e.width=i.width,e.height=i.height,e.channels=4;else if(Bi(i))e.element=i,e.width=i.naturalWidth,e.height=i.naturalHeight,e.channels=4;else if(ki(i))e.element=i,e.width=i.videoWidth,e.height=i.videoHeight,e.channels=4;else if(_i(i)){var y=e.width||i[0].length,Z=e.height||i.length,X=e.channels;X=dn(i[0][0])?X||i[0][0].length:X||1;for(var G=Re.shape(i),W=1,V=0;V=0,"oes_texture_float extension not enabled"):e.type===wn&&nt(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function H(t,e,i){var r=t.element,l=t.data,a=t.internalformat,s=t.format,u=t.type,c=t.width,d=t.height;x(t),r?n.texImage2D(e,i,s,s,u,r):t.compressed?n.compressedTexImage2D(e,i,a,c,d,0,l):t.needsCopy?(o(),n.copyTexImage2D(e,i,s,t.xOffset,t.yOffset,c,d,0)):n.texImage2D(e,i,s,c,d,0,s,u,l||null)}function J(t,e,i,r,l){var a=t.element,s=t.data,u=t.internalformat,c=t.format,d=t.type,h=t.width,b=t.height;x(t),a?n.texSubImage2D(e,l,i,r,c,d,a):t.compressed?n.compressedTexSubImage2D(e,l,i,r,u,h,b,s):t.needsCopy?(o(),n.copyTexSubImage2D(e,l,i,r,t.xOffset,t.yOffset,h,b)):n.texSubImage2D(e,l,i,r,h,b,c,d,s)}var w=[];function _(){return w.pop()||new Y}function I(t){t.needsFree&&Ct.freeType(t.data),Y.call(t),w.push(t)}function N(){R.call(this),this.genMipmaps=!1,this.mipmapHint=ci,this.mipmask=0,this.images=Array(16)}function C(t,e,n){var i=t.images[0]=_();t.mipmask=1,i.width=t.width=e,i.height=t.height=n,i.channels=t.channels=4}function U(t,e){var n=null;if(Ti(e))g(n=t.images[0]=_(),t),K(n,e),t.mipmask=1;else if(L(t,e),Array.isArray(e.mipmap))for(var i=e.mipmap,r=0;r>=r,n.height>>=r,K(n,i[r]),t.mipmask|=1<=0&&!("faces"in e)&&(t.genMipmaps=!0)}if("mag"in e){var i=e.mag;nt.parameter(i,d),t.magFilter=d[i]}var o=t.wrapS,l=t.wrapT;if("wrap"in e){var a=e.wrap;"string"==typeof a?(nt.parameter(a,c),o=l=c[a]):Array.isArray(a)&&(nt.parameter(a[0],c),nt.parameter(a[1],c),o=c[a[0]],l=c[a[1]])}else{if("wrapS"in e){var s=e.wrapS;nt.parameter(s,c),o=c[s]}if("wrapT"in e){var b=e.wrapT;nt.parameter(b,c),l=c[b]}}if(t.wrapS=o,t.wrapT=l,"anisotropic"in e){var p=e.anisotropic;nt("number"==typeof p&&p>=1&&p<=r.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=e.anisotropic}if("mipmap"in e){var m=!1;switch(typeof e.mipmap){case"string":nt.parameter(e.mipmap,u,"invalid mipmap hint"),t.mipmapHint=u[e.mipmap],t.genMipmaps=!0,m=!0;break;case"boolean":m=t.genMipmaps=e.mipmap;break;case"object":nt(Array.isArray(e.mipmap),"invalid mipmap type"),t.genMipmaps=!1,m=!0;break;default:nt.raise("invalid mipmap type")}m&&!("min"in e)&&(t.minFilter=oi)}}function j(t,e){n.texParameteri(e,ni,t.minFilter),n.texParameteri(e,ei,t.magFilter),n.texParameteri(e,On,t.wrapS),n.texParameteri(e,An,t.wrapT),i.ext_texture_filter_anisotropic&&n.texParameteri(e,bi,t.anisotropic),t.genMipmaps&&(n.hint(ui,t.mipmapHint),n.generateMipmap(e))}var Q=0,P={},E=r.maxTextureUnits,D=Array(E).map((function(){return null}));function O(t){R.call(this),this.mipmask=0,this.internalformat=yn,this.id=Q++,this.refCount=1,this.target=t,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new z,s.profile&&(this.stats={size:0})}function A(t){n.activeTexture(Xi),n.bindTexture(t.target,t.texture)}function q(){var t=D[0];t?n.bindTexture(t.target,t.texture):n.bindTexture(pn,null)}function $(t){var e=t.texture;nt(e,"must not double destroy texture");var i=t.unit,r=t.target;i>=0&&(n.activeTexture(Xi+i),n.bindTexture(r,null),D[i]=null),n.deleteTexture(e),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete P[t.id],a.textureCount--}function tt(t,e){var i=new O(pn);function o(t,e){var n=i.texInfo;z.call(n);var l=k();return"number"==typeof t?C(l,0|t,"number"==typeof e?0|e:0|t):t?(nt.type(t,"object","invalid arguments to regl.texture"),M(n,t),U(l,t)):C(l,1,1),n.genMipmaps&&(l.mipmask=(l.width<<1)-1),i.mipmask=l.mipmask,g(i,l),nt.texture2D(n,l,r),i.internalformat=l.internalformat,o.width=l.width,o.height=l.height,A(i),F(l,pn),j(n,pn),q(),T(l),s.profile&&(i.stats.size=Ei(i.internalformat,i.type,l.width,l.height,n.genMipmaps,!1)),o.format=X[i.internalformat],o.type=G[i.type],o.mag=W[n.magFilter],o.min=V[n.minFilter],o.wrapS=v[n.wrapS],o.wrapT=v[n.wrapT],o}function l(t,e,n,r){nt(!!t,"must specify image data");var l=0|e,a=0|n,s=0|r,u=_();return g(u,i),u.width=0,u.height=0,K(u,t),u.width=u.width||(i.width>>s)-l,u.height=u.height||(i.height>>s)-a,nt(i.type===u.type&&i.format===u.format&&i.internalformat===u.internalformat,"incompatible format for texture.subimage"),nt(l>=0&&a>=0&&l+u.width<=i.width&&a+u.height<=i.height,"texture.subimage write out of bounds"),nt(i.mipmask&1<>a;++a){var u=r>>a,c=l>>a;if(!u||!c)break;n.texImage2D(pn,a,i.format,u,c,0,i.format,i.type,null)}return q(),s.profile&&(i.stats.size=Ei(i.internalformat,i.type,r,l,!1,!1)),o}return P[i.id]=i,a.textureCount++,o(t,e),o.subimage=l,o.resize=u,o._reglType="texture2d",o._texture=i,s.profile&&(o.stats=i.stats),o.destroy=function(){i.decRef()},o}function et(t,e,i,o,l,u){var c=new O(mn);P[c.id]=c,a.cubeCount++;var d=new Array(6);function h(t,e,n,i,o,l){var a,u=c.texInfo;for(z.call(u),a=0;a<6;++a)d[a]=k();if("number"!=typeof t&&t)if("object"==typeof t)if(e)U(d[0],t),U(d[1],e),U(d[2],n),U(d[3],i),U(d[4],o),U(d[5],l);else if(M(u,t),L(c,t),"faces"in t){var b=t.faces;for(nt(Array.isArray(b)&&6===b.length,"cube faces must be a length 6 array"),a=0;a<6;++a)nt("object"==typeof b[a]&&!!b[a],"invalid input for cube map face"),g(d[a],c),U(d[a],b[a])}else for(a=0;a<6;++a)U(d[a],t);else nt.raise("invalid arguments to cube map");else{var p=0|t||1;for(a=0;a<6;++a)C(d[a],p,p)}for(g(c,d[0]),nt.optional((function(){r.npotTextureCube||nt(hn(c.width)&&hn(c.height),"your browser does not support non power or two texture dimensions")})),u.genMipmaps?c.mipmask=(d[0].width<<1)-1:c.mipmask=d[0].mipmask,nt.textureCube(c,u,d,r),c.internalformat=d[0].internalformat,h.width=d[0].width,h.height=d[0].height,A(c),a=0;a<6;++a)F(d[a],fn+a);for(j(u,mn),q(),s.profile&&(c.stats.size=Ei(c.internalformat,c.type,h.width,h.height,u.genMipmaps,!0)),h.format=X[c.internalformat],h.type=G[c.type],h.mag=W[u.magFilter],h.min=V[u.minFilter],h.wrapS=v[u.wrapS],h.wrapT=v[u.wrapT],a=0;a<6;++a)T(d[a]);return h}function b(t,e,n,i,r){nt(!!e,"must specify image data"),nt("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var o=0|n,l=0|i,a=0|r,s=_();return g(s,c),s.width=0,s.height=0,K(s,e),s.width=s.width||(c.width>>a)-o,s.height=s.height||(c.height>>a)-l,nt(c.type===s.type&&c.format===s.format&&c.internalformat===s.internalformat,"incompatible format for texture.subimage"),nt(o>=0&&l>=0&&o+s.width<=c.width&&l+s.height<=c.height,"texture.subimage write out of bounds"),nt(c.mipmask&1<>r;++r)n.texImage2D(fn+i,r,c.format,e>>r,e>>r,0,c.format,c.type,null);return q(),s.profile&&(c.stats.size=Ei(c.internalformat,c.type,h.width,h.height,!1,!0)),h}}return h(t,e,i,o,l,u),h.subimage=b,h.resize=p,h._reglType="textureCube",h._texture=c,s.profile&&(h.stats=c.stats),h.destroy=function(){c.decRef()},h}function it(){for(var t=0;t>e,t.height>>e,0,t.internalformat,t.type,null);else for(var i=0;i<6;++i)n.texImage2D(fn+i,e,t.internalformat,t.width>>e,t.height>>e,0,t.internalformat,t.type,null);j(t.texInfo,t.target)}))}function ot(){for(var t=0;t0)continue;r.unit=-1}D[i]=t,e=i;break}e>=E&&nt.raise("insufficient number of texture units"),s.profile&&a.maxTextureUnits=2,"invalid renderbuffer shape"),a=0|b[0],s=0|b[1]}else"radius"in h&&(a=s=0|h.radius),"width"in h&&(a=0|h.width),"height"in h&&(s=0|h.height);"format"in h&&(nt.parameter(h.format,o,"invalid renderbuffer format"),u=o[h.format])}else"number"==typeof e?(a=0|e,s="number"==typeof i?0|i:a):e?nt.raise("invalid arguments to renderbuffer constructor"):a=s=1;if(nt(a>0&&s>0&&a<=n.maxRenderbufferSize&&s<=n.maxRenderbufferSize,"invalid renderbuffer size"),a!==c.width||s!==c.height||u!==c.format)return d.width=c.width=a,d.height=c.height=s,c.format=u,t.bindRenderbuffer(Oi,c.renderbuffer),t.renderbufferStorage(Oi,u,a,s),nt(0===t.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=sr(c.format,c.width,c.height)),d.format=l[c.format],d}function h(e,i){var o=0|e,l=0|i||o;return o===c.width&&l===c.height||(nt(o>0&&l>0&&o<=n.maxRenderbufferSize&&l<=n.maxRenderbufferSize,"invalid renderbuffer size"),d.width=c.width=o,d.height=c.height=l,t.bindRenderbuffer(Oi,c.renderbuffer),t.renderbufferStorage(Oi,c.format,o,l),nt(0===t.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=sr(c.format,c.width,c.height))),d}return s[c.id]=c,i.renderbufferCount++,d(e,a),d.resize=h,d._reglType="renderbuffer",d._renderbuffer=c,r.profile&&(d.stats=c.stats),d.destroy=function(){c.decRef()},d}function h(){Se(s).forEach((function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(Oi,e.renderbuffer),t.renderbufferStorage(Oi,e.format,e.width,e.height)})),t.bindRenderbuffer(Oi,null)}return u.prototype.decRef=function(){--this.refCount<=0&&c(this)},r.profile&&(i.getTotalRenderbufferSize=function(){var t=0;return Object.keys(s).forEach((function(e){t+=s[e].stats.size})),t}),{create:d,clear:function(){Se(s).forEach(c)},restore:h}},cr=36160,dr=36161,hr=3553,br=34069,pr=36064,mr=36096,fr=36128,yr=33306,Zr=36053,Xr=36054,Gr=36055,Wr=36057,Vr=36061,vr=36193,Sr=5121,Rr=5126,gr=6407,Lr=6408,xr=6402,Yr=[gr,Lr],Kr=[];Kr[Lr]=4,Kr[gr]=3;var Hr=[];Hr[Sr]=1,Hr[Rr]=4,Hr[vr]=2;var Jr=33189,wr=36168,_r=34041,Ir=[32854,32855,36194,35907,34842,34843,34836],Nr={};function Cr(t,n,i,r,o,l){var a={cur:null,next:null,dirty:!1,setFBO:null},s=["rgba"],u=["rgba4","rgb565","rgb5 a1"];n.ext_srgb&&u.push("srgba"),n.ext_color_buffer_half_float&&u.push("rgba16f","rgb16f"),n.webgl_color_buffer_float&&u.push("rgba32f");var c=["uint8"];function d(t,e,n){this.target=t,this.texture=e,this.renderbuffer=n;var i=0,r=0;e?(i=e.width,r=e.height):n&&(i=n.width,r=n.height),this.width=i,this.height=r}function h(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function b(t,e,n){if(t)if(t.texture){var i=t.texture._texture,r=Math.max(1,i.width),o=Math.max(1,i.height);nt(r===e&&o===n,"inconsistent width/height for supplied texture"),i.refCount+=1}else{var l=t.renderbuffer._renderbuffer;nt(l.width===e&&l.height===n,"inconsistent width/height for renderbuffer"),l.refCount+=1}}function p(e,n){n&&(n.texture?t.framebufferTexture2D(cr,e,n.target,n.texture._texture.texture,0):t.framebufferRenderbuffer(cr,e,dr,n.renderbuffer._renderbuffer.renderbuffer))}function m(t){var e=hr,n=null,i=null,r=t;"object"==typeof t&&(r=t.data,"target"in t&&(e=0|t.target)),nt.type(r,"function","invalid attachment data");var o=r._reglType;return"texture2d"===o?(n=r,nt(e===hr)):"textureCube"===o?(n=r,nt(e>=br&&e=2,"invalid shape for framebuffer"),l=H[0],h=H[1]}else"radius"in K&&(l=h=K.radius),"width"in K&&(l=K.width),"height"in K&&(h=K.height);("color"in K||"colors"in K)&&(X=K.color||K.colors,Array.isArray(X)&&nt(1===X.length||n.webgl_draw_buffers,"multiple render targets not supported")),X||("colorCount"in K&&(R=0|K.colorCount,nt(R>0,"invalid color buffer count")),"colorTexture"in K&&(G=!!K.colorTexture,W="rgba4"),"colorType"in K&&(v=K.colorType,G?(nt(n.oes_texture_float||!("float"===v||"float32"===v),"you must enable OES_texture_float in order to use floating point framebuffer objects"),nt(n.oes_texture_half_float||!("half float"===v||"float16"===v),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===v||"float16"===v?(nt(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),W="rgba16f"):"float"!==v&&"float32"!==v||(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(v,c,"invalid color type")),"colorFormat"in K&&(W=K.colorFormat,s.indexOf(W)>=0?G=!0:u.indexOf(W)>=0?G=!1:nt.optional((function(){G?nt.oneOf(K.colorFormat,s,"invalid color format for texture"):nt.oneOf(K.colorFormat,u,"invalid color format for renderbuffer")})))),("depthTexture"in K||"depthStencilTexture"in K)&&(Y=!(!K.depthTexture&&!K.depthStencilTexture),nt(!Y||n.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in K&&("boolean"==typeof K.depth?p=K.depth:(g=K.depth,Z=!1)),"stencil"in K&&("boolean"==typeof K.stencil?Z=K.stencil:(L=K.stencil,p=!1)),"depthStencil"in K&&("boolean"==typeof K.depthStencil?p=Z=K.depthStencil:(x=K.depthStencil,p=!1,Z=!1))}else l=h=1;var J=null,w=null,_=null,I=null;if(Array.isArray(X))J=X.map(m);else if(X)J=[m(X)];else for(J=new Array(R),r=0;r=0||J[r].renderbuffer&&Ir.indexOf(J[r].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+r+" is invalid"),J[r]&&J[r].texture){var C=Kr[J[r].texture._texture.format]*Hr[J[r].texture._texture.type];null===N?N=C:nt(N===C,"all color attachments much have the same number of bits per pixel.")}return b(w,l,h),nt(!w||w.texture&&w.texture._texture.format===xr||w.renderbuffer&&w.renderbuffer._renderbuffer.format===Jr,"invalid depth attachment for framebuffer object"),b(_,l,h),nt(!_||_.renderbuffer&&_.renderbuffer._renderbuffer.format===wr,"invalid stencil attachment for framebuffer object"),b(I,l,h),nt(!I||I.texture&&I.texture._texture.format===_r||I.renderbuffer&&I.renderbuffer._renderbuffer.format===_r,"invalid depth-stencil attachment for framebuffer object"),V(o),o.width=l,o.height=h,o.colorAttachments=J,o.depthAttachment=w,o.stencilAttachment=_,o.depthStencilAttachment=I,d.color=J.map(y),d.depth=y(w),d.stencil=y(_),d.depthStencil=y(I),d.width=o.width,d.height=o.height,S(o),d}function h(t,e){nt(a.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|t,1),i=Math.max(0|e||n,1);if(n===o.width&&i===o.height)return d;for(var r=o.colorAttachments,l=0;l=2,"invalid shape for framebuffer"),nt(Z[0]===Z[1],"cube framebuffer must be square"),h=Z[0]}else"radius"in y&&(h=0|y.radius),"width"in y?(h=0|y.width,"height"in y&&nt(y.height===h,"must be square")):"height"in y&&(h=0|y.height);("color"in y||"colors"in y)&&(b=y.color||y.colors,Array.isArray(b)&&nt(1===b.length||n.webgl_draw_buffers,"multiple render targets not supported")),b||("colorCount"in y&&(f=0|y.colorCount,nt(f>0,"invalid color buffer count")),"colorType"in y&&(nt.oneOf(y.colorType,c,"invalid color type"),m=y.colorType),"colorFormat"in y&&(p=y.colorFormat,nt.oneOf(y.colorFormat,s,"invalid color format for texture"))),"depth"in y&&(d.depth=y.depth),"stencil"in y&&(d.stencil=y.stencil),"depthStencil"in y&&(d.depthStencil=y.depthStencil)}else h=1;if(b)if(Array.isArray(b))for(u=[],i=0;i0&&(d.depth=o[0].depth,d.stencil=o[0].stencil,d.depthStencil=o[0].depthStencil),o[i]?o[i](d):o[i]=R(d)}return e(l,{width:h,height:h,color:u})}function u(t){var e,n=0|t;if(nt(n>0&&n<=i.maxCubeMapSize,"invalid radius for cube fbo"),n===l.width)return l;var r=l.color;for(e=0;e{for(var t=Object.keys(e),n=0;n=0,'invalid option for vao: "'+t[n]+'" valid options are '+kr)})),nt(Array.isArray(r),"attributes must be an array")}nt(r.length0,"must specify at least one attribute");var c={},d=i.attributes;d.length=r.length;for(var h=0;h=f.byteLength?b.subdata(f):(b.destroy(),i.buffers[h]=null)),i.buffers[h]||(b=i.buffers[h]=o.create(p,Fr,!1,!0)),m.buffer=o.getBuffer(b),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1,c[h]=1):o.getBuffer(p)?(m.buffer=o.getBuffer(p),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1):o.getBuffer(p.buffer)?(m.buffer=o.getBuffer(p.buffer),m.size=0|(+p.size||m.buffer.dimension),m.normalized=!!p.normalized||!1,"type"in p?(nt.parameter(p.type,we,"invalid buffer type"),m.type=we[p.type]):m.type=m.buffer.dtype,m.offset=0|(p.offset||0),m.stride=0|(p.stride||0),m.divisor=0|(p.divisor||0),m.state=1,nt(m.size>=1&&m.size<=4,"size must be between 1 and 4"),nt(m.offset>=0,"invalid offset"),nt(m.stride>=0&&m.stride<=255,"stride must be between 0 and 255"),nt(m.divisor>=0,"divisor must be positive"),nt(!m.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(nt(h>0,"first attribute must not be a constant"),m.x=+p.x||0,m.y=+p.y||0,m.z=+p.z||0,m.w=+p.w||0,m.state=2):nt(!1,"invalid attribute spec for location "+h)}for(var y=0;y1)for(var y=0;y1&&(X=X.replace("[0]","")),s(f,new a(X,n.id(X),t.getUniformLocation(b,X),c))}var G=t.getProgramParameter(b,Pr);r.profile&&(e.stats.attributesCount=G);var W=e.attributes;for(l=0;lt&&(t=e.stats.uniformsCount)})),t},i.getMaxAttributesCount=function(){var t=0;return d.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(l).forEach(e),l={},d.forEach((function(e){t.deleteProgram(e.program)})),d.length=0,c={},i.shaderCount=0},program:function(n,r,a,s){nt.command(n>=0,"missing vertex shader",a),nt.command(r>=0,"missing fragment shader",a);var u=c[r];u||(u=c[r]={});var h=u[n];if(h&&(h.refCount++,!s))return h;var m=new b(r,n);return i.shaderCount++,p(m,a,s),h||(u[n]=m),d.push(m),e(m,{destroy:function(){if(m.refCount--,m.refCount<=0){t.deleteProgram(m.program);var e=d.indexOf(m);d.splice(e,1),i.shaderCount--}u[m.vertId].refCount<=0&&(t.deleteShader(l[m.vertId]),delete l[m.vertId],delete c[m.fragId][m.vertId]),Object.keys(c[m.fragId]).length||(t.deleteShader(o[m.fragId]),delete o[m.fragId],delete c[m.fragId])}})},restore:m,shader:u,frag:-1,vert:-1}}var Dr=6408,Or=5121,Ar=3333,qr=5126;function $r(e,n,i,r,o,l,a){function s(s){var u;null===n.next?(nt(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),u=Or):(nt(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),u=n.next.colorAttachments[0].texture._texture.type,nt.optional((function(){l.oes_texture_float?(nt(u===Or||u===qr,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),u===qr&&nt(a.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):nt(u===Or,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var c=0,d=0,h=r.framebufferWidth,b=r.framebufferHeight,p=null;t(s)?p=s:s&&(nt.type(s,"object","invalid arguments to regl.read()"),c=0|s.x,d=0|s.y,nt(c>=0&&c=0&&d0&&h+c<=r.framebufferWidth,"invalid width for read pixels"),nt(b>0&&b+d<=r.framebufferHeight,"invalid height for read pixels"),i();var m=h*b*4;return p||(u===Or?p=new Uint8Array(m):u===qr&&(p=p||new Float32Array(m))),nt.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),nt(p.byteLength>=m,"data buffer for regl.read() too small"),e.pixelStorei(Ar,4),e.readPixels(c,d,h,b,Dr,u,p),p}function u(t){var e;return n.setFBO({framebuffer:t.framebuffer},(function(){e=s(t)})),e}function c(t){return t&&"framebuffer"in t?u(t):s(t)}return c}function to(t){return Array.prototype.slice.call(t)}function eo(t){return to(t).join("")}function no(){var t=0,n=[],i=[];function r(e){for(var r=0;r0&&(n.push(e,"="),n.push.apply(n,to(arguments)),n.push(";")),e}return e(i,{def:o,toString:function(){return eo([r.length>0?"var "+r.join(",")+";":"",eo(n)])}})}function l(){var t=o(),n=o(),i=t.toString,r=n.toString;function l(e,i){n(e,i,"=",t.def(e,i),";")}return e((function(){t.apply(t,to(arguments))}),{def:t.def,entry:t,exit:n,save:l,set:function(e,n,i){l(e,n),t(e,n,"=",i,";")},toString:function(){return i()+r()}})}function a(){var t=eo(arguments),n=l(),i=l(),r=n.toString,o=i.toString;return e(n,{then:function(){return n.apply(n,to(arguments)),this},else:function(){return i.apply(i,to(arguments)),this},toString:function(){var e=o();return e&&(e="else{"+e+"}"),eo(["if(",t,"){",r(),"}",e])}})}var s=o(),u={};function c(t,n){var i=[];function r(){var t="a"+i.length;return i.push(t),t}n=n||0;for(var o=0;o":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},na={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ia={frag:35632,vert:35633},ra={cw:kl,ccw:Tl};function oa(e){return Array.isArray(e)||t(e)||ve(e)}function la(t){return t.sort((function(t,e){return t===ko?-1:e===ko?1:t=1,i>=2,e)}if(n===ho){var r=t.data;return new aa(r.thisDep,r.contextDep,r.propDep,e)}if(n===bo)return new aa(!1,!1,!1,e);if(n===po){for(var o=!1,l=!1,a=!1,s=0;s=1&&(l=!0),c>=2&&(a=!0)}else u.type===ho&&(o=o||u.data.thisDep,l=l||u.data.contextDep,a=a||u.data.propDep)}return new aa(o,l,a,e)}return new aa(n===co,n===uo,n===so,e)}var da=new aa(!1,!1,!1,(function(){}));function ha(t,n,i,r,o,l,a,s,u,c,d,h,b,p,m){var f=c.Record,y={add:32774,subtract:32778,"reverse subtract":32779};i.ext_blend_minmax&&(y.min=zl,y.max=Ml);var Z=i.angle_instanced_arrays,X=i.webgl_draw_buffers,G=i.oes_vertex_array_object,W={dirty:!0,profile:m.profile},V={},v=[],S={},R={};function g(t){return t.replace(".","_")}function L(t,e,n){var i=g(t);v.push(t),V[i]=W[i]=!!n,S[i]=e}function x(t,e,n){var i=g(t);v.push(t),Array.isArray(n)?(W[i]=n.slice(),V[i]=n.slice()):W[i]=V[i]=n,R[i]=e}L(mo,pl),L(fo,bl),x(yo,"blendColor",[0,0,0,0]),x(Zo,"blendEquationSeparate",[Dl,Dl]),x(Xo,"blendFuncSeparate",[El,Pl,El,Pl]),L(Go,fl,!0),x(Wo,"depthFunc",Ol),x(Vo,"depthRange",[0,1]),x(vo,"depthMask",!0),x(So,So,[!0,!0,!0,!0]),L(Ro,hl),x(go,"cullFace",Bl),x(Lo,Lo,Tl),x(xo,xo,1),L(Yo,Zl),x(Ko,"polygonOffset",[0,0]),L(Ho,Xl),L(Jo,Gl),x(wo,"sampleCoverage",[1,!1]),L(_o,ml),x(Io,"stencilMask",-1),x(No,"stencilFunc",[jl,0,-1]),x(Co,"stencilOpSeparate",[Fl,Ql,Ql,Ql]),x(Uo,"stencilOpSeparate",[Bl,Ql,Ql,Ql]),L(Fo,yl),x(Bo,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),x(ko,ko,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var Y={gl:t,context:b,strings:n,next:V,current:W,draw:h,elements:l,buffer:o,shader:d,attributes:c.state,vao:c,uniforms:u,framebuffer:s,extensions:i,timer:p,isBufferArgs:oa},K={primTypes:Qe,compareFuncs:ea,blendFuncs:$l,blendEquations:y,stencilOps:na,glTypes:we,orientationType:ra};nt.optional((function(){Y.isArrayLike=dn})),X&&(K.backBuffer=[Bl],K.drawBuffer=gt(r.maxDrawbuffers,(function(t){return 0===t?[0]:gt(t,(function(t){return ql+t}))})));var H=0;function J(){var t=no(),e=t.link,i=t.global;t.id=H++,t.batchId="0";var r=e(Y),o=t.shared={props:"a0"};Object.keys(Y).forEach((function(t){o[t]=i.def(r,".",t)})),nt.optional((function(){t.CHECK=e(nt),t.commandStr=nt.guessCommand(),t.command=e(t.commandStr),t.assert=function(t,n,i){t("if(!(",n,"))",this.CHECK,".commandRaise(",e(i),",",this.command,");")},K.invalidBlendCombinations=ta}));var l=t.next={},a=t.current={};Object.keys(R).forEach((function(t){Array.isArray(W[t])&&(l[t]=i.def(o.next,".",t),a[t]=i.def(o.current,".",t))}));var s=t.constants={};Object.keys(K).forEach((function(t){s[t]=i.def(JSON.stringify(K[t]))})),t.invoke=function(n,i){switch(i.type){case ao:var r=["this",o.context,o.props,t.batchId];return n.def(e(i.data),".call(",r.slice(0,Math.max(i.data.length+1,4)),")");case so:return n.def(o.props,i.data);case uo:return n.def(o.context,i.data);case co:return n.def("this",i.data);case ho:return i.data.append(t,n),i.data.ref;case bo:return i.data.toString();case po:return i.data.map((function(e){return t.invoke(n,e)}))}},t.attribCache={};var u={};return t.scopeAttrib=function(t){var i=n.id(t);if(i in u)return u[i];var r=c.scope[i];return r||(r=c.scope[i]=new f),u[i]=e(r)},t}function w(t){var e,n=t.static,i=t.dynamic;if(To in n){var r=!!n[To];(e=ua((function(t,e){return r}))).enable=r}else if(To in i){var o=i[To];e=ca(o,(function(t,e){return t.invoke(e,o)}))}return e}function _(t,e){var n=t.static,i=t.dynamic;if(zo in n){var r=n[zo];return r?(r=s.getFramebuffer(r),nt.command(r,"invalid framebuffer object"),ua((function(t,e){var n=t.link(r),i=t.shared;e.set(i.framebuffer,".next",n);var o=i.context;return e.set(o,"."+tl,n+".width"),e.set(o,"."+el,n+".height"),n}))):ua((function(t,e){var n=t.shared;e.set(n.framebuffer,".next","null");var i=n.context;return e.set(i,"."+tl,i+"."+ol),e.set(i,"."+el,i+"."+ll),"null"}))}if(zo in i){var o=i[zo];return ca(o,(function(t,e){var n=t.invoke(e,o),i=t.shared,r=i.framebuffer,l=e.def(r,".getFramebuffer(",n,")");nt.optional((function(){t.assert(e,"!"+n+"||"+l,"invalid framebuffer object")})),e.set(r,".next",l);var a=i.context;return e.set(a,"."+tl,l+"?"+l+".width:"+a+"."+ol),e.set(a,"."+el,l+"?"+l+".height:"+a+"."+ll),l}))}return null}function I(t,e,n){var i=t.static,r=t.dynamic;function o(t){if(t in i){var o=i[t];nt.commandType(o,"object","invalid "+t,n.commandStr);var l,a,s=!0,u=0|o.x,c=0|o.y;return"width"in o?(l=0|o.width,nt.command(l>=0,"invalid "+t,n.commandStr)):s=!1,"height"in o?(a=0|o.height,nt.command(a>=0,"invalid "+t,n.commandStr)):s=!1,new aa(!s&&e&&e.thisDep,!s&&e&&e.contextDep,!s&&e&&e.propDep,(function(t,e){var n=t.shared.context,i=l;"width"in o||(i=e.def(n,".",tl,"-",u));var r=a;return"height"in o||(r=e.def(n,".",el,"-",c)),[u,c,i,r]}))}if(t in r){var d=r[t],h=ca(d,(function(e,n){var i=e.invoke(n,d);nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)}));var r=e.shared.context,o=n.def(i,".x|0"),l=n.def(i,".y|0"),a=n.def('"width" in ',i,"?",i,".width|0:","(",r,".",tl,"-",o,")"),s=n.def('"height" in ',i,"?",i,".height|0:","(",r,".",el,"-",l,")");return nt.optional((function(){e.assert(n,a+">=0&&"+s+">=0","invalid "+t)})),[o,l,a,s]}));return e&&(h.thisDep=h.thisDep||e.thisDep,h.contextDep=h.contextDep||e.contextDep,h.propDep=h.propDep||e.propDep),h}return e?new aa(e.thisDep,e.contextDep,e.propDep,(function(t,e){var n=t.shared.context;return[0,0,e.def(n,".",tl),e.def(n,".",el)]})):null}var l=o(ko);if(l){var a=l;l=new aa(l.thisDep,l.contextDep,l.propDep,(function(t,e){var n=a.append(t,e),i=t.shared.context;return e.set(i,"."+nl,n[2]),e.set(i,"."+il,n[3]),n}))}return{viewport:l,scissor_box:o(Bo)}}function N(t,e){var n=t.static;if("string"==typeof n[jo]&&"string"==typeof n[Mo]){if(Object.keys(e.dynamic).length>0)return null;var i=e.static,r=Object.keys(i);if(r.length>0&&"number"==typeof i[r[0]]){for(var o=[],l=0;l=0,"invalid "+t,e.commandStr),ua((function(t,e){return l&&(t.OFFSET=a),a}))}if(t in i){var c=i[t];return ca(c,(function(e,n){var i=e.invoke(n,c);return l&&(e.OFFSET=i,nt.optional((function(){e.assert(n,i+">=0","invalid "+t)}))),i}))}if(l){if(u)return ua((function(t,e){return t.OFFSET=0,0}));if(o)return new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.offset:0")}))}else if(o)return new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.instances:-1")}));return null}var m=p(Do,!0);function f(){if(Eo in n){var t=0|n[Eo];return r.count=t,nt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),ua((function(){return t}))}if(Eo in i){var l=i[Eo];return ca(l,(function(t,e){var n=t.invoke(e,l);return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")})),n}))}if(u){if(sa(h)){if(h)return m?new aa(m.thisDep,m.contextDep,m.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})):ua((function(t,e){return e.def(t.ELEMENTS,".vertCount")}));var a=ua((function(){return-1}));return nt.optional((function(){a.MISSING=!0})),a}var c=new aa(h.thisDep||m.thisDep,h.contextDep||m.contextDep,h.propDep||m.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(){c.DYNAMIC=!0})),c}return o?new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao,".currentVAO?",t.shared.vao,".currentVAO.count:-1")})):null}var y=b(),Z=f(),X=p(Oo,!1);return{elements:h,primitive:y,count:Z,instances:X,offset:m,vao:s,vaoActive:o,elementsActive:u,static:r}}function F(t,e){var n=t.static,i=t.dynamic,o={};return v.forEach((function(t){var l=g(t);function a(e,r){if(t in n){var a=e(n[t]);o[l]=ua((function(){return a}))}else if(t in i){var s=i[t];o[l]=ca(s,(function(t,e){return r(t,e,t.invoke(e,s))}))}}switch(t){case Ro:case fo:case mo:case _o:case Go:case Fo:case Yo:case Ho:case Jo:case vo:return a((function(n){return nt.commandType(n,"boolean",t,e.commandStr),n}),(function(e,n,i){return nt.optional((function(){e.assert(n,"typeof "+i+'==="boolean"',"invalid flag "+t,e.commandStr)})),i}));case Wo:return a((function(n){return nt.commandParameter(n,ea,"invalid "+t,e.commandStr),ea[n]}),(function(e,n,i){var r=e.constants.compareFuncs;return nt.optional((function(){e.assert(n,i+" in "+r,"invalid "+t+", must be one of "+Object.keys(ea))})),n.def(r,"[",i,"]")}));case Vo:return a((function(t){return nt.command(dn(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 Xo:return a((function(t){nt.commandType(t,"object","blend.func",e.commandStr);var n="srcRGB"in t?t.srcRGB:t.src,i="srcAlpha"in t?t.srcAlpha:t.src,r="dstRGB"in t?t.dstRGB:t.dst,o="dstAlpha"in t?t.dstAlpha:t.dst;return nt.commandParameter(n,$l,l+".srcRGB",e.commandStr),nt.commandParameter(i,$l,l+".srcAlpha",e.commandStr),nt.commandParameter(r,$l,l+".dstRGB",e.commandStr),nt.commandParameter(o,$l,l+".dstAlpha",e.commandStr),nt.command(-1===ta.indexOf(n+", "+r),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+r+")",e.commandStr),[$l[n],$l[r],$l[i],$l[o]]}),(function(e,n,i){var r=e.constants.blendFuncs;function o(o,l){var a=n.def('"',o,l,'" in ',i,"?",i,".",o,l,":",i,".",o);return nt.optional((function(){e.assert(n,a+" in "+r,"invalid "+t+"."+o+l+", must be one of "+Object.keys($l))})),a}nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid blend func, must be an object")}));var l=o("src","RGB"),a=o("dst","RGB");nt.optional((function(){var t=e.constants.invalidBlendCombinations;e.assert(n,t+".indexOf("+l+'+", "+'+a+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var s=n.def(r,"[",l,"]"),u=n.def(r,"[",o("src","Alpha"),"]");return[s,n.def(r,"[",a,"]"),u,n.def(r,"[",o("dst","Alpha"),"]")]}));case Zo:return a((function(n){return"string"==typeof n?(nt.commandParameter(n,y,"invalid "+t,e.commandStr),[y[n],y[n]]):"object"==typeof n?(nt.commandParameter(n.rgb,y,t+".rgb",e.commandStr),nt.commandParameter(n.alpha,y,t+".alpha",e.commandStr),[y[n.rgb],y[n.alpha]]):void nt.commandRaise("invalid blend.equation",e.commandStr)}),(function(e,n,i){var r=e.constants.blendEquations,o=n.def(),l=n.def(),a=e.cond("typeof ",i,'==="string"');return nt.optional((function(){function n(t,n,i){e.assert(t,i+" in "+r,"invalid "+n+", must be one of "+Object.keys(y))}n(a.then,t,i),e.assert(a.else,i+"&&typeof "+i+'==="object"',"invalid "+t),n(a.else,t+".rgb",i+".rgb"),n(a.else,t+".alpha",i+".alpha")})),a.then(o,"=",l,"=",r,"[",i,"];"),a.else(o,"=",r,"[",i,".rgb];",l,"=",r,"[",i,".alpha];"),n(a),[o,l]}));case yo:return a((function(t){return nt.command(dn(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),gt(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")})),gt(4,(function(t){return e.def("+",n,"[",t,"]")}))}));case Io:return a((function(t){return nt.commandType(t,"number",l,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 a((function(n){nt.commandType(n,"object",l,e.commandStr);var i=n.cmp||"keep",r=n.ref||0,o="mask"in n?n.mask:-1;return nt.commandParameter(i,ea,t+".cmp",e.commandStr),nt.commandType(r,"number",t+".ref",e.commandStr),nt.commandType(o,"number",t+".mask",e.commandStr),[ea[i],r,o]}),(function(t,e,n){var i=t.constants.compareFuncs;return nt.optional((function(){function r(){t.assert(e,Array.prototype.join.call(arguments,""),"invalid stencil.func")}r(n+"&&typeof ",n,'==="object"'),r('!("cmp" in ',n,")||(",n,".cmp in ",i,")")})),[e.def('"cmp" in ',n,"?",i,"[",n,".cmp]",":",Ql),e.def(n,".ref|0"),e.def('"mask" in ',n,"?",n,".mask|0:-1")]}));case Co:case Uo:return a((function(n){nt.commandType(n,"object",l,e.commandStr);var i=n.fail||"keep",r=n.zfail||"keep",o=n.zpass||"keep";return nt.commandParameter(i,na,t+".fail",e.commandStr),nt.commandParameter(r,na,t+".zfail",e.commandStr),nt.commandParameter(o,na,t+".zpass",e.commandStr),[t===Uo?Bl:Fl,na[i],na[r],na[o]]}),(function(e,n,i){var r=e.constants.stencilOps;function o(o){return nt.optional((function(){e.assert(n,'!("'+o+'" in '+i+")||("+i+"."+o+" in "+r+")","invalid "+t+"."+o+", must be one of "+Object.keys(na))})),n.def('"',o,'" in ',i,"?",r,"[",i,".",o,"]:",Ql)}return nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)})),[t===Uo?Bl:Fl,o("fail"),o("zfail"),o("zpass")]}));case Ko:return a((function(t){nt.commandType(t,"object",l,e.commandStr);var n=0|t.factor,i=0|t.units;return nt.commandType(n,"number",l+".factor",e.commandStr),nt.commandType(i,"number",l+".units",e.commandStr),[n,i]}),(function(e,n,i){return nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)})),[n.def(i,".factor|0"),n.def(i,".units|0")]}));case go:return a((function(t){var n=0;return"front"===t?n=Fl:"back"===t&&(n=Bl),nt.command(!!n,l,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"?',Fl,":",Bl)}));case xo:return a((function(t){return nt.command("number"==typeof t&&t>=r.lineWidthDims[0]&&t<=r.lineWidthDims[1],"invalid line width, must be a positive number between "+r.lineWidthDims[0]+" and "+r.lineWidthDims[1],e.commandStr),t}),(function(t,e,n){return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">="+r.lineWidthDims[0]+"&&"+n+"<="+r.lineWidthDims[1],"invalid line width")})),n}));case Lo:return a((function(t){return nt.commandParameter(t,ra,l,e.commandStr),ra[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"?'+kl+":"+Tl)}));case So:return a((function(t){return nt.command(dn(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")})),gt(4,(function(t){return"!!"+n+"["+t+"]"}))}));case wo:return a((function(t){nt.command("object"==typeof t&&t,l,e.commandStr);var n="value"in t?t.value:1,i=!!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,i]}),(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 B(t,e){var n=t.static,i=t.dynamic,r={};return Object.keys(n).forEach((function(t){var i,o=n[t];if("number"==typeof o||"boolean"==typeof o)i=ua((function(){return o}));else if("function"==typeof o){var l=o._reglType;"texture2d"===l||"textureCube"===l?i=ua((function(t){return t.link(o)})):"framebuffer"===l||"framebufferCube"===l?(nt.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',e.commandStr),i=ua((function(t){return t.link(o.color[0])}))):nt.commandRaise('invalid data for uniform "'+t+'"',e.commandStr)}else dn(o)?i=ua((function(e){return e.global.def("[",gt(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);i.value=o,r[t]=i})),Object.keys(i).forEach((function(t){var e=i[t];r[t]=ca(e,(function(t,n){return t.invoke(n,e)}))})),r}function k(t,e){var i=t.static,r=t.dynamic,l={};return Object.keys(i).forEach((function(t){var r=i[t],a=n.id(t),s=new f;if(oa(r))s.state=oo,s.buffer=o.getBuffer(o.create(r,sl,!1,!0)),s.type=0;else{var u=o.getBuffer(r);if(u)s.state=oo,s.buffer=u,s.type=0;else if(nt.command("object"==typeof r&&r,"invalid data for attribute "+t,e.commandStr),"constant"in r){var c=r.constant;s.buffer="null",s.state=lo,"number"==typeof c?s.x=c:(nt.command(dn(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+t,e.commandStr),io.forEach((function(t,e){e=0,'invalid offset for attribute "'+t+'"',e.commandStr);var h=0|r.stride;nt.command(h>=0&&h<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',e.commandStr);var b=0|r.size;nt.command(!("size"in r)||b>0&&b<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',e.commandStr);var p=!!r.normalized,m=0;"type"in r&&(nt.commandParameter(r.type,we,"invalid type for attribute "+t,e.commandStr),m=we[r.type]);var y=0|r.divisor;nt.optional((function(){"divisor"in r&&(nt.command(0===y||Z,'cannot specify divisor for attribute "'+t+'", instancing not supported',e.commandStr),nt.command(y>=0,'invalid divisor for attribute "'+t+'"',e.commandStr));var n=e.commandStr,i=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(r).forEach((function(e){nt.command(i.indexOf(e)>=0,'unknown parameter "'+e+'" for attribute pointer "'+t+'" (valid parameters are '+i+")",n)}))})),s.buffer=u,s.state=oo,s.size=b,s.normalized=p,s.type=m||u.dtype,s.offset=d,s.stride=h,s.divisor=y}}l[t]=ua((function(t,e){var n=t.attribCache;if(a in n)return n[a];var i={isStream:!1};return Object.keys(s).forEach((function(t){i[t]=s[t]})),s.buffer&&(i.buffer=t.link(s.buffer),i.type=i.type||i.buffer+".dtype"),n[a]=i,i}))})),Object.keys(r).forEach((function(t){var e=r[t];function n(n,i){var r=n.invoke(i,e),o=n.shared,l=n.constants,a=o.isBufferArgs,s=o.buffer;nt.optional((function(){n.assert(i,r+"&&(typeof "+r+'==="object"||typeof '+r+'==="function")&&('+a+"("+r+")||"+s+".getBuffer("+r+")||"+s+".getBuffer("+r+".buffer)||"+a+"("+r+'.buffer)||("constant" in '+r+"&&(typeof "+r+'.constant==="number"||'+o.isArrayLike+"("+r+".constant))))",'invalid dynamic attribute "'+t+'"')}));var u={isStream:i.def(!1)},c=new f;c.state=oo,Object.keys(c).forEach((function(t){u[t]=i.def(""+c[t])}));var d=u.buffer,h=u.type;function b(t){i(u[t],"=",r,".",t,"|0;")}return i("if(",a,"(",r,")){",u.isStream,"=true;",d,"=",s,".createStream(",sl,",",r,");",h,"=",d,".dtype;","}else{",d,"=",s,".getBuffer(",r,");","if(",d,"){",h,"=",d,".dtype;",'}else if("constant" in ',r,"){",u.state,"=",lo,";","if(typeof "+r+'.constant === "number"){',u[io[0]],"=",r,".constant;",io.slice(1).map((function(t){return u[t]})).join("="),"=0;","}else{",io.map((function(t,e){return u[t]+"="+r+".constant.length>"+e+"?"+r+".constant["+e+"]:0;"})).join(""),"}}else{","if(",a,"(",r,".buffer)){",d,"=",s,".createStream(",sl,",",r,".buffer);","}else{",d,"=",s,".getBuffer(",r,".buffer);","}",h,'="type" in ',r,"?",l.glTypes,"[",r,".type]:",d,".dtype;",u.normalized,"=!!",r,".normalized;"),b("size"),b("offset"),b("stride"),b("divisor"),i("}}"),i.exit("if(",u.isStream,"){",s,".destroyStream(",d,");","}"),u}l[t]=ca(e,n)})),l}function T(t){var e=t.static,n=t.dynamic,i={};return Object.keys(e).forEach((function(t){var n=e[t];i[t]=ua((function(t,e){return"number"==typeof n||"boolean"==typeof n?""+n:t.link(n)}))})),Object.keys(n).forEach((function(t){var e=n[t];i[t]=ca(e,(function(t,n){return t.invoke(n,e)}))})),i}function z(t,e,n,r,o){var l=t.static,a=t.dynamic;nt.optional((function(){var t=[zo,Mo,jo,Qo,Po,Do,Eo,Oo,To,Ao].concat(v);function e(e){Object.keys(e).forEach((function(e){nt.command(t.indexOf(e)>=0,'unknown parameter "'+e+'"',o.commandStr)}))}e(l),e(a)}));var s=N(t,e),u=_(t),d=I(t,u,o),h=U(t,o),b=F(t,o),p=C(t,o,s);function m(t){var e=d[t];e&&(b[t]=e)}m(ko),m(g(Bo));var f=Object.keys(b).length>0,y={framebuffer:u,draw:h,shader:p,state:b,dirty:f,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(y.profile=w(t),y.uniforms=B(n,o),y.drawVAO=y.scopeVAO=h.vao,!y.drawVAO&&p.program&&!s&&i.angle_instanced_arrays&&h.static.elements){var Z=!0,X=p.program.attributes.map((function(t){var n=e.static[t];return Z=Z&&!!n,n}));if(Z&&X.length>0){var G=c.getVAO(c.createVAO({attributes:X,elements:h.static.elements}));y.drawVAO=new aa(null,null,null,(function(t,e){return t.link(G)})),y.useVAO=!0}}return s?y.useVAO=!0:y.attributes=k(e,o),y.context=T(r),y}function M(t,e,n){var i=t.shared.context,r=t.scope();Object.keys(n).forEach((function(o){e.save(i,"."+o);var l=n[o].append(t,e);Array.isArray(l)?r(i,".",o,"=[",l.join(),"];"):r(i,".",o,"=",l,";")})),e(r)}function j(t,e,n,i){var r,o=t.shared,l=o.gl,a=o.framebuffer;X&&(r=e.def(o.extensions,".webgl_draw_buffers"));var s,u=t.constants,c=u.drawBuffer,d=u.backBuffer;s=n?n.append(t,e):e.def(a,".next"),i||e("if(",s,"!==",a,".cur){"),e("if(",s,"){",l,".bindFramebuffer(",Al,",",s,".framebuffer);"),X&&e(r,".drawBuffersWEBGL(",c,"[",s,".colorAttachments.length]);"),e("}else{",l,".bindFramebuffer(",Al,",null);"),X&&e(r,".drawBuffersWEBGL(",d,");"),e("}",a,".cur=",s,";"),i||e("}")}function Q(t,e,n){var i=t.shared,r=i.gl,o=t.current,l=t.next,a=i.current,s=i.next,u=t.cond(a,".dirty");v.forEach((function(e){var i,c,d=g(e);if(!(d in n.state))if(d in l){i=l[d],c=o[d];var h=gt(W[d].length,(function(t){return u.def(i,"[",t,"]")}));u(t.cond(h.map((function(t,e){return t+"!=="+c+"["+e+"]"})).join("||")).then(r,".",R[d],"(",h,");",h.map((function(t,e){return c+"["+e+"]="+t})).join(";"),";"))}else{i=u.def(s,".",d);var b=t.cond(i,"!==",a,".",d);u(b),d in S?b(t.cond(i).then(r,".enable(",S[d],");").else(r,".disable(",S[d],");"),a,".",d,"=",i,";"):b(r,".",R[d],"(",i,");",a,".",d,"=",i,";")}})),0===Object.keys(n.state).length&&u(a,".dirty=false;"),e(u)}function P(t,e,n,i){var r=t.shared,o=t.current,l=r.current,a=r.gl;la(Object.keys(n)).forEach((function(r){var s=n[r];if(!i||i(s)){var u=s.append(t,e);if(S[r]){var c=S[r];sa(s)?e(a,u?".enable(":".disable(",c,");"):e(t.cond(u).then(a,".enable(",c,");").else(a,".disable(",c,");")),e(l,".",r,"=",u,";")}else if(dn(u)){var d=o[r];e(a,".",R[r],"(",u,");",u.map((function(t,e){return d+"["+e+"]="+t})).join(";"),";")}else e(a,".",R[r],"(",u,");",l,".",r,"=",u,";")}}))}function E(t,e){Z&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function D(t,e,n,i,r){var o,l,a,s=t.shared,u=t.stats,c=s.current,d=s.timer,h=n.profile;function b(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(t){t(o=e.def(),"=",b(),";"),"string"==typeof r?t(u,".count+=",r,";"):t(u,".count++;"),p&&(i?t(l=e.def(),"=",d,".getNumPendingQueries();"):t(d,".beginQuery(",u,");"))}function f(t){t(u,".cpuTime+=",b(),"-",o,";"),p&&(i?t(d,".pushScopeStats(",l,",",d,".getNumPendingQueries(),",u,");"):t(d,".endQuery();"))}function y(t){var n=e.def(c,".profile");e(c,".profile=",t,";"),e.exit(c,".profile=",n,";")}if(h){if(sa(h))return void(h.enable?(m(e),f(e.exit),y("true")):y("false"));y(a=h.append(t,e))}else a=e.def(c,".profile");var Z=t.block();m(Z),e("if(",a,"){",Z,"}");var X=t.block();f(X),e.exit("if(",a,"){",X,"}")}function O(t,e,n,i,r){var o=t.shared;function l(t){switch(t){case Vl:case gl:case Kl:return 2;case vl:case Ll:case Hl:return 3;case Sl:case xl:case Jl:return 4;default:return 1}}function a(n,i,r){var l=o.gl,a=e.def(n,".location"),s=e.def(o.attributes,"[",a,"]"),u=r.state,c=r.buffer,d=[r.x,r.y,r.z,r.w],h=["buffer","normalized","offset","stride"];function b(){e("if(!",s,".buffer){",l,".enableVertexAttribArray(",a,");}");var n,o=r.type;if(n=r.size?e.def(r.size,"||",i):i,e("if(",s,".type!==",o,"||",s,".size!==",n,"||",h.map((function(t){return s+"."+t+"!=="+r[t]})).join("||"),"){",l,".bindBuffer(",sl,",",c,".buffer);",l,".vertexAttribPointer(",[a,n,o,r.normalized,r.stride,r.offset],");",s,".type=",o,";",s,".size=",n,";",h.map((function(t){return s+"."+t+"="+r[t]+";"})).join(""),"}"),Z){var u=r.divisor;e("if(",s,".divisor!==",u,"){",t.instancing,".vertexAttribDivisorANGLE(",[a,u],");",s,".divisor=",u,";}")}}function p(){e("if(",s,".buffer){",l,".disableVertexAttribArray(",a,");",s,".buffer=null;","}if(",io.map((function(t,e){return s+"."+t+"!=="+d[e]})).join("||"),"){",l,".vertexAttrib4f(",a,",",d,");",io.map((function(t,e){return s+"."+t+"="+d[e]+";"})).join(""),"}")}u===oo?b():u===lo?p():(e("if(",u,"===",oo,"){"),b(),e("}else{"),p(),e("}"))}i.forEach((function(i){var o,s=i.name,u=n.attributes[s];if(u){if(!r(u))return;o=u.append(t,e)}else{if(!r(da))return;var c=t.scopeAttrib(s);nt.optional((function(){t.assert(e,c+".state","missing attribute "+s)})),o={},Object.keys(new f).forEach((function(t){o[t]=e.def(c,".",t)}))}a(t.link(i),l(i.info.type),o)}))}function A(t,e,i,r,o,l){for(var a,s=t.shared,u=s.gl,c={},d=0;d1){if(!f)continue;var y=b.replace("[0]","");if(c[y])continue;c[y]=1}var Z,X=t.link(h)+".location";if(f){if(!o(f))continue;if(sa(f)){var G=f.value;if(nt.command(null!=G,'missing uniform "'+b+'"',t.commandStr),p===Nl||p===Cl){nt.command("function"==typeof G&&(p===Nl&&("texture2d"===G._reglType||"framebuffer"===G._reglType)||p===Cl&&("textureCube"===G._reglType||"framebufferCube"===G._reglType)),"invalid texture for uniform "+b,t.commandStr);var W=t.link(G._texture||G.color[0]._texture);e(u,".uniform1i(",X,",",W+".bind());"),e.exit(W,".unbind();")}else if(p===wl||p===_l||p===Il){nt.optional((function(){nt.command(dn(G),"invalid matrix for uniform "+b,t.commandStr),nt.command(p===wl&&4===G.length||p===_l&&9===G.length||p===Il&&16===G.length,"invalid length for matrix uniform "+b,t.commandStr)}));var V=t.global.def("new Float32Array(["+Array.prototype.slice.call(G)+"])"),v=2;p===_l?v=3:p===Il&&(v=4),e(u,".uniformMatrix",v,"fv(",X,",false,",V,");")}else{switch(p){case Wl:1===m?nt.commandType(G,"number","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1f";break;case Vl:nt.command(dn(G)&&G.length&&G.length%2==0&&G.length<=2*m,"uniform "+b,t.commandStr),a="2f";break;case vl:nt.command(dn(G)&&G.length&&G.length%3==0&&G.length<=3*m,"uniform "+b,t.commandStr),a="3f";break;case Sl:nt.command(dn(G)&&G.length&&G.length%4==0&&G.length<=4*m,"uniform "+b,t.commandStr),a="4f";break;case Yl:1===m?nt.commandType(G,"boolean","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1i";break;case Rl:1===m?nt.commandType(G,"number","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1i";break;case Kl:case gl:nt.command(dn(G)&&G.length&&G.length%2==0&&G.length<=2*m,"uniform "+b,t.commandStr),a="2i";break;case Hl:case Ll:nt.command(dn(G)&&G.length&&G.length%3==0&&G.length<=3*m,"uniform "+b,t.commandStr),a="3i";break;case Jl:case xl:nt.command(dn(G)&&G.length&&G.length%4==0&&G.length<=4*m,"uniform "+b,t.commandStr),a="4i"}m>1?(a+="v",G=t.global.def("["+Array.prototype.slice.call(G)+"]")):G=dn(G)?Array.prototype.slice.call(G):G,e(u,".uniform",a,"(",X,",",G,");")}continue}Z=f.append(t,e)}else{if(!o(da))continue;Z=e.def(s.uniforms,"[",n.id(b),"]")}p===Nl?(nt(!Array.isArray(Z),"must specify a scalar prop for textures"),e("if(",Z,"&&",Z,'._reglType==="framebuffer"){',Z,"=",Z,".color[0];","}")):p===Cl&&(nt(!Array.isArray(Z),"must specify a scalar prop for cube maps"),e("if(",Z,"&&",Z,'._reglType==="framebufferCube"){',Z,"=",Z,".color[0];","}")),nt.optional((function(){function n(n,i){t.assert(e,n,'bad data or missing for uniform "'+b+'". '+i)}function i(t,e){1===e&&nt(!Array.isArray(Z),"must not specify an array type for uniform"),n("Array.isArray("+Z+") && typeof "+Z+'[0]===" '+t+'" || typeof '+Z+'==="'+t+'"',"invalid type, expected "+t)}function r(e,i,r){Array.isArray(Z)?nt(Z.length&&Z.length%e==0&&Z.length<=e*r,"must have length of "+(1===r?"":"n * ")+e):n(s.isArrayLike+"("+Z+")&&"+Z+".length && "+Z+".length % "+e+" === 0 && "+Z+".length<="+e*r,"invalid vector, should have length of "+(1===r?"":"n * ")+e,t.commandStr)}function o(e){nt(!Array.isArray(Z),"must not specify a value type"),n("typeof "+Z+'==="function"&&'+Z+'._reglType==="texture'+(e===cl?"2d":"Cube")+'"',"invalid texture type",t.commandStr)}switch(p){case Rl:i("number",m);break;case gl:r(2,"number",m);break;case Ll:r(3,"number",m);break;case xl:r(4,"number",m);break;case Wl:i("number",m);break;case Vl:r(2,"number",m);break;case vl:r(3,"number",m);break;case Sl:r(4,"number",m);break;case Yl:i("boolean",m);break;case Kl:r(2,"boolean",m);break;case Hl:r(3,"boolean",m);break;case Jl:r(4,"boolean",m);break;case wl:r(4,"number",m);break;case _l:r(9,"number",m);break;case Il:r(16,"number",m);break;case Nl:o(cl);break;case Cl:o(dl)}}));var S=1;switch(p){case Nl:case Cl:var R=e.def(Z,"._texture");e(u,".uniform1i(",X,",",R,".bind());"),e.exit(R,".unbind();");continue;case Rl:case Yl:a="1i";break;case gl:case Kl:a="2i",S=2;break;case Ll:case Hl:a="3i",S=3;break;case xl:case Jl:a="4i",S=4;break;case Wl:a="1f";break;case Vl:a="2f",S=2;break;case vl:a="3f",S=3;break;case Sl:a="4f",S=4;break;case wl:a="Matrix2fv";break;case _l:a="Matrix3fv";break;case Il:a="Matrix4fv"}if(-1===a.indexOf("Matrix")&&m>1&&(a+="v",S=1),"M"===a.charAt(0)){e(u,".uniform",a,"(",X,",");var g=Math.pow(p-wl+2,2),L=t.global.def("new Float32Array(",g,")");Array.isArray(Z)?e("false,(",gt(g,(function(t){return L+"["+t+"]="+Z[t]})),",",L,")"):e("false,(Array.isArray(",Z,")||",Z," instanceof Float32Array)?",Z,":(",gt(g,(function(t){return L+"["+t+"]="+Z+"["+t+"]"})),",",L,")"),e(");")}else if(S>1){for(var x=[],Y=[],K=0;K=0","missing vertex count")}))):(r=s.def(l,".",Eo),nt.optional((function(){t.assert(s,r+">=0","missing vertex count")}))),r}var c=s();function d(r){var o=a[r];return o?o.contextDep&&i.contextDynamic||o.propDep?o.append(t,n):o.append(t,e):e.def(l,".",r)}var h,b,p=d(Po),m=d(Do),f=u();if("number"==typeof f){if(0===f)return}else n("if(",f,"){"),n.exit("}");Z&&(h=d(Oo),b=t.instancing);var y=c+".type",X=a.elements&&sa(a.elements)&&!a.vaoActive;function W(){function t(){n(b,".drawElementsInstancedANGLE(",[p,f,y,m+"<<(("+y+"-"+ro+")>>1)",h],");")}function e(){n(b,".drawArraysInstancedANGLE(",[p,m,f,h],");")}c&&"null"!==c?X?t():(n("if(",c,"){"),t(),n("}else{"),e(),n("}")):e()}function V(){function t(){n(o+".drawElements("+[p,f,y,m+"<<(("+y+"-"+ro+")>>1)"]+");")}function e(){n(o+".drawArrays("+[p,m,f]+");")}c&&"null"!==c?X?t():(n("if(",c,"){"),t(),n("}else{"),e(),n("}")):e()}Z&&("number"!=typeof h||h>=0)?"string"==typeof h?(n("if(",h,">0){"),W(),n("}else if(",h,"<0){"),V(),n("}")):W():V()}function $(t,e,n,i,r){var o=J(),l=o.proc("body",r);return nt.optional((function(){o.commandStr=e.commandStr,o.command=o.link(e.commandStr)})),Z&&(o.instancing=l.def(o.shared.extensions,".angle_instanced_arrays")),t(o,l,n,i),o.compile().body}function tt(t,e,n,i){E(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);"),O(t,e,n,i.attributes,(function(){return!0}))),A(t,e,n,i.uniforms,(function(){return!0}),!1),q(t,e,e,n)}function et(t,e){var n=t.proc("draw",1);E(t,n),M(t,n,e.context),j(t,n,e.framebuffer),Q(t,n,e),P(t,n,e.state),D(t,n,e,!1,!0);var i=e.shader.progVar.append(t,n);if(n(t.shared.gl,".useProgram(",i,".program);"),e.shader.program)tt(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var r=t.global.def("{}"),o=n.def(i,".id"),l=n.def(r,"[",o,"]");n(t.cond(l).then(l,".call(this,a0);").else(l,"=",r,"[",o,"]=",t.link((function(n){return $(tt,t,e,n,1)})),"(",i,");",l,".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 it(t,e,n,i){function r(){return!0}t.batchId="a1",E(t,e),O(t,e,n,i.attributes,r),A(t,e,n,i.uniforms,r,!1),q(t,e,e,n)}function rt(t,e,n,i){E(t,e);var r=n.contextDep,o=e.def(),l="a0",a="a1",s=e.def();t.shared.props=s,t.batchId=o;var u=t.scope(),c=t.scope();function d(t){return t.contextDep&&r||t.propDep}function h(t){return!d(t)}if(e(u.entry,"for(",o,"=0;",o,"<",a,";++",o,"){",s,"=",l,"[",o,"];",c,"}",u.exit),n.needsContext&&M(t,c,n.context),n.needsFramebuffer&&j(t,c,n.framebuffer),P(t,c,n.state,d),n.profile&&d(n.profile)&&D(t,c,n,!1,!0),i)n.useVAO?n.drawVAO?d(n.drawVAO)?c(t.shared.vao,".setVAO(",n.drawVAO.append(t,c),");"):u(t.shared.vao,".setVAO(",n.drawVAO.append(t,u),");"):u(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(u(t.shared.vao,".setVAO(null);"),O(t,u,n,i.attributes,h),O(t,c,n,i.attributes,d)),A(t,u,n,i.uniforms,h,!1),A(t,c,n,i.uniforms,d,!0),q(t,u,c,n);else{var b=t.global.def("{}"),p=n.shader.progVar.append(t,c),m=c.def(p,".id"),f=c.def(b,"[",m,"]");c(t.shared.gl,".useProgram(",p,".program);","if(!",f,"){",f,"=",b,"[",m,"]=",t.link((function(e){return $(it,t,n,e,2)})),"(",p,");}",f,".call(this,a0[",o,"],",o,");")}}function ot(t,e){var n=t.proc("batch",2);t.batchId="0",E(t,n);var i=!1,r=!0;Object.keys(e.context).forEach((function(t){i=i||e.context[t].propDep})),i||(M(t,n,e.context),r=!1);var o=e.framebuffer,l=!1;function a(t){return t.contextDep&&i||t.propDep}o?(o.propDep?i=l=!0:o.contextDep&&i&&(l=!0),l||j(t,n,o)):j(t,n,null),e.state.viewport&&e.state.viewport.propDep&&(i=!0),Q(t,n,e),P(t,n,e.state,(function(t){return!a(t)})),e.profile&&a(e.profile)||D(t,n,e,!1,"a1"),e.contextDep=i,e.needsContext=r,e.needsFramebuffer=l;var s=e.shader.progVar;if(s.contextDep&&i||s.propDep)rt(t,n,e,null);else{var u=s.append(t,n);if(n(t.shared.gl,".useProgram(",u,".program);"),e.shader.program)rt(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var c=t.global.def("{}"),d=n.def(u,".id"),h=n.def(c,"[",d,"]");n(t.cond(h).then(h,".call(this,a0,a1);").else(h,"=",c,"[",d,"]=",t.link((function(n){return $(rt,t,e,n,2)})),"(",u,");",h,".call(this,a0,a1);"))}}Object.keys(e.state).length>0&&n(t.shared.current,".dirty=true;"),t.shared.vao&&n(t.shared.vao,".setVAO(null);")}function lt(t,e){var i=t.proc("scope",3);t.batchId="a2";var r=t.shared,o=r.current;function l(n){var o=e.shader[n];o&&i.set(r.shader,"."+n,o.append(t,i))}M(t,i,e.context),e.framebuffer&&e.framebuffer.append(t,i),la(Object.keys(e.state)).forEach((function(n){var o=e.state[n].append(t,i);dn(o)?o.forEach((function(e,r){i.set(t.next[n],"["+r+"]",e)})):i.set(r.next,"."+n,o)})),D(t,i,e,!0,!0),[Qo,Do,Eo,Oo,Po].forEach((function(n){var o=e.draw[n];o&&i.set(r.draw,"."+n,""+o.append(t,i))})),Object.keys(e.uniforms).forEach((function(o){var l=e.uniforms[o].append(t,i);Array.isArray(l)&&(l="["+l.join()+"]"),i.set(r.uniforms,"["+n.id(o)+"]",l)})),Object.keys(e.attributes).forEach((function(n){var r=e.attributes[n].append(t,i),o=t.scopeAttrib(n);Object.keys(new f).forEach((function(t){i.set(o,"."+t,r[t])}))})),e.scopeVAO&&i.set(r.vao,".targetVAO",e.scopeVAO.append(t,i)),l(Mo),l(jo),Object.keys(e.state).length>0&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",t.shared.context,",a0,",t.batchId,");")}function at(t){if("object"==typeof t&&!dn(t)){for(var e=Object.keys(t),n=0;n=0;--t){var e=K[t];e&&e(p,null,0)}i.flush(),c&&c.update()}function N(){!_&&K.length>0&&(_=mt.next(I))}function C(){_&&(mt.cancel(I),_=null)}function U(t){t.preventDefault(),o=!0,C(),H.forEach((function(t){t()}))}function F(t){i.getError(),o=!1,l.restore(),V.restore(),Z.restore(),v.restore(),S.restore(),R.restore(),G.restore(),c&&c.restore(),g.procs.refresh(),N(),J.forEach((function(t){t()}))}function B(){K.length=0,C(),Y&&(Y.removeEventListener(Va,U),Y.removeEventListener(va,F)),V.clear(),R.clear(),S.clear(),G.clear(),v.clear(),X.clear(),Z.clear(),c&&c.clear(),w.forEach((function(t){t()}))}function k(t){function n(t){var n=e({},t);function i(t){if(t in n){var e=n[t];delete n[t],Object.keys(e).forEach((function(i){n[t+"."+i]=e[i]}))}}return delete n.uniforms,delete n.attributes,delete n.context,delete n.vao,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),i("blend"),i("depth"),i("cull"),i("stencil"),i("polygonOffset"),i("scissor"),i("sample"),"vao"in t&&(n.vao=t.vao),n}function i(t,e){var n={},i={};return Object.keys(t).forEach((function(r){var o=t[r];if(pt.isDynamic(o))i[r]=pt.unbox(o,r);else{if(e&&Array.isArray(o))for(var l=0;l0)return h.call(this,m(0|t),0|t)}else{if(!Array.isArray(t))return d.call(this,t);if(t.length)return h.call(this,t,t.length)}}return e(f,{stats:u,destroy:function(){c.destroy()}})}Y&&(Y.addEventListener(Va,U,!1),Y.addEventListener(va,F,!1));var T=R.setFBO=k({framebuffer:pt.define.call(null,Sa,"framebuffer")});function z(t,e){var n=0;g.procs.poll();var r=e.color;r&&(i.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=Za),"depth"in e&&(i.clearDepth(+e.depth),n|=Xa),"stencil"in e&&(i.clearStencil(0|e.stencil),n|=Ga),nt(!!n,"called regl.clear with no buffer specified"),i.clear(n)}function M(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)T(e({framebuffer:t.framebuffer.faces[n]},t),z);else T(t,z);else z(null,t)}function j(t){function e(){var e=La(K,t);function n(){var t=La(K,n);K[t]=K[K.length-1],K.length-=1,K.length<=0&&C()}nt(e>=0,"cannot cancel a frame twice"),K[e]=n}return nt.type(t,"function","regl.frame() callback must be a function"),K.push(t),N(),{cancel:e}}function Q(){var t=x.viewport,e=x.scissor_box;t[0]=t[1]=e[0]=e[1]=0,p.viewportWidth=p.framebufferWidth=p.drawingBufferWidth=t[2]=e[2]=i.drawingBufferWidth,p.viewportHeight=p.framebufferHeight=p.drawingBufferHeight=t[3]=e[3]=i.drawingBufferHeight}function P(){p.tick+=1,p.time=D(),Q(),g.procs.poll()}function E(){v.refresh(),Q(),g.procs.refresh(),c&&c.update()}function D(){return(ft()-d)/1e3}function O(t,e){var n;switch(nt.type(e,"function","listener callback must be a function"),t){case"frame":return j(e);case"lost":n=H;break;case"restore":n=J;break;case"destroy":n=w;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:L,destroy:B,_gl:i,_refresh:E,poll:function(){P(),c&&c.update()},now:D,stats:s});return n.onDone(null,A),A}return xa}();var Xb=Math.sqrt(50),Gb=Math.sqrt(10),Wb=Math.sqrt(2);function Vb(t,e,n){var i,r,o,l,a=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((i=e=0?(o>=Xb?10:o>=Gb?5:o>=Wb?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=Xb?10:o>=Gb?5:o>=Wb?2:1)}(t,e,n))||!isFinite(l))return[];if(l>0){let n=Math.round(t/l),i=Math.round(e/l);for(n*le&&--i,o=new Array(r=i-n+1);++ae&&--i,o=new Array(r=i-n+1);++a=i&&++n;else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(r=+r)>=r&&++n}return n}(t))/Math.LN2)+1}var Sb=Array.prototype.slice;function Rb(t,e){return t-e}var gb=t=>()=>t;function Lb(t,e){for(var n,i=-1,r=e.length;++ii!=b>i&&n<(h-u)*(i-c)/(b-c)+u&&(r=-r)}return r}function Yb(t,e,n){var i,r,o,l;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)&&(r=t[i=+(t[0]===e[0])],o=n[i],l=e[i],r<=o&&o<=l||l<=o&&o<=r)}function Kb(){}var Hb=[[],[[[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 Jb(){var t=1,e=1,n=vb,i=a;function r(t){var e,i,r,l,a,s,u=n(t);if(Array.isArray(u))u=u.slice().sort(Rb);else{const n=function(t,e){let n,i;if(void 0===e)for(const r of t)null!=r&&(void 0===n?r>=r&&(n=i=r):(n>r&&(n=r),i=o&&(n=i=o):(n>o&&(n=o),i=Xb?a*=10:s>=Gb?a*=5:s>=Wb&&(a*=2),io(t,e)))}function o(n,r){var o=[],a=[];return function(n,i,r){var o,a,s,u,c,d,h=new Array,b=new Array;o=a=-1,u=n[0]>=i,Hb[u<<1].forEach(p);for(;++o=i,Hb[s|u<<1].forEach(p);Hb[u<<0].forEach(p);for(;++a=i,c=n[a*t]>=i,Hb[u<<1|c<<2].forEach(p);++o=i,d=c,c=n[a*t+o+1]>=i,Hb[s|u<<1|c<<2|d<<3].forEach(p);Hb[u|c<<3].forEach(p)}o=-1,c=n[a*t]>=i,Hb[c<<2].forEach(p);for(;++o=i,Hb[c<<2|d<<3].forEach(p);function p(t){var e,n,i=[t[0][0]+o,t[0][1]+a],s=[t[1][0]+o,t[1][1]+a],u=l(i),c=l(s);(e=b[u])?(n=h[c])?(delete b[e.end],delete h[n.start],e===n?(e.ring.push(s),r(e.ring)):h[e.start]=b[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete b[e.end],e.ring.push(s),b[e.end=c]=e):(e=h[c])?(n=b[u])?(delete h[e.start],delete b[n.end],e===n?(e.ring.push(s),r(e.ring)):h[n.start]=b[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete h[e.start],e.ring.unshift(i),h[e.start=u]=e):h[u]=b[c]={start:u,end:c,ring:[i,s]}}Hb[c<<3].forEach(p)}(n,r,(function(t){i(t,n,r),function(t){for(var e=0,n=t.length,i=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e0?o.push([t]):a.push(t)})),a.forEach((function(t){for(var e,n=0,i=o.length;n0&&l0&&a=0&&o>=0))throw new Error("invalid size");return t=i,e=o,r},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?gb(Sb.call(t)):gb(t),r):n},r.smooth=function(t){return arguments.length?(i=t?a:Kb,r):i===a},r}var wb=function(t,e,n,i){return _b[0]=i,_b[1]=n,_b[2]=e,_b[3]=t,Ib[0]},_b=new Uint8Array(4),Ib=new Float32Array(_b.buffer);function Nb(t){for(var e=t.length/6|0,n=new Array(e),i=0;icd(t[t.length-1]),Eb=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Nb),Db=Pb(Eb),Ob=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Nb),Ab=Pb(Ob),qb=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Nb),$b=Pb(qb),tp=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Nb),ep=Pb(tp),np=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Nb),ip=Pb(np),rp=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Nb),op=Pb(rp),lp=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Nb),ap=Pb(lp),sp=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Nb),up=Pb(sp),cp=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Nb),dp=Pb(cp),hp=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Nb),bp=Pb(hp),pp=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Nb),mp=Pb(pp),fp=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Nb),yp=Pb(fp),Zp=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Nb),Xp=Pb(Zp),Gp=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Nb),Wp=Pb(Gp),Vp=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Nb),vp=Pb(Vp),Sp=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Nb),Rp=Pb(Sp),gp=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Nb),Lp=Pb(gp),xp=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Nb),Yp=Pb(xp),Kp=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Nb),Hp=Pb(Kp),Jp=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Nb),wp=Pb(Jp),_p=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Nb),Ip=Pb(_p),Np=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Nb),Cp=Pb(Np),Up=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Nb),Fp=Pb(Up),Bp=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Nb),kp=Pb(Bp),Tp=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Nb),zp=Pb(Tp),Mp=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Nb),jp=Pb(Mp),Qp=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Nb),Pp=Pb(Qp);var Ep=Yd(nd(300,.5,0),nd(-240,.5,1)),Dp=Yd(nd(-100,.75,.35),nd(80,1.5,.8)),Op=Yd(nd(260,.75,.35),nd(80,1.5,.8)),Ap=nd();var qp=Nc(),$p=Math.PI/3,tm=2*Math.PI/3;function em(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var nm=em(Nb("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),im=em(Nb("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),rm=em(Nb("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),om=em(Nb("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")),lm=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",schemeCategory10:Cb,schemeAccent:Ub,schemeDark2:Fb,schemePaired:Bb,schemePastel1:kb,schemePastel2:Tb,schemeSet1:zb,schemeSet2:Mb,schemeSet3:jb,schemeTableau10:Qb,interpolateBrBG:Db,schemeBrBG:Eb,interpolatePRGn:Ab,schemePRGn:Ob,interpolatePiYG:$b,schemePiYG:qb,interpolatePuOr:ep,schemePuOr:tp,interpolateRdBu:ip,schemeRdBu:np,interpolateRdGy:op,schemeRdGy:rp,interpolateRdYlBu:ap,schemeRdYlBu:lp,interpolateRdYlGn:up,schemeRdYlGn:sp,interpolateSpectral:dp,schemeSpectral:cp,interpolateBuGn:bp,schemeBuGn:hp,interpolateBuPu:mp,schemeBuPu:pp,interpolateGnBu:yp,schemeGnBu:fp,interpolateOrRd:Xp,schemeOrRd:Zp,interpolatePuBuGn:Wp,schemePuBuGn:Gp,interpolatePuBu:vp,schemePuBu:Vp,interpolatePuRd:Rp,schemePuRd:Sp,interpolateRdPu:Lp,schemeRdPu:gp,interpolateYlGnBu:Yp,schemeYlGnBu:xp,interpolateYlGn:Hp,schemeYlGn:Kp,interpolateYlOrBr:wp,schemeYlOrBr:Jp,interpolateYlOrRd:Ip,schemeYlOrRd:_p,interpolateBlues:Cp,schemeBlues:Np,interpolateGreens:Fp,schemeGreens:Up,interpolateGreys:kp,schemeGreys:Bp,interpolatePurples:zp,schemePurples:Tp,interpolateReds:jp,schemeReds:Mp,interpolateOranges:Pp,schemeOranges:Qp,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:Ep,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return Ap.h=360*t-100,Ap.s=1.5-1.5*e,Ap.l=.8-.9*e,Ap+""},interpolateWarm:Dp,interpolateCool:Op,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,qp.r=255*(e=Math.sin(t))*e,qp.g=255*(e=Math.sin(t+$p))*e,qp.b=255*(e=Math.sin(t+tm))*e,qp+""},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:nm,interpolateMagma:im,interpolateInferno:rm,interpolatePlasma:om});function am(t,e){t=t.flat();const[n,i]=ke(t);null==e&&(e=new Uint32Array(t.length));const r=2**32/(i-n);let o=0;for(let l of t)e[o]=(l-n)*r,o+=1;return console.log(Ee(t),i,n,(t[100]-n)*r),{extent:[n,i],array:new Uint8Array(e.buffer)}}const sm={sqrt:function(){return bb.apply(null,arguments).exponent(.5)},log:function t(){var e=sb(Nh()).domain([1,10]);return e.copy=function(){return Ih(e,t()).base(e.base())},xh.apply(e,arguments),e},linear:eb,literal:function t(e){var n;function i(t){return null==t||isNaN(t=+t)?n:t}return i.invert=i,i.domain=i.range=function(t){return arguments.length?(e=Array.from(t,Yh),i):e.slice()},i.unknown=function(t){return arguments.length?(n=t,i):n},i.copy=function(){return t(e).unknown(n)},e=arguments.length?Array.from(e,Yh):[0,1],tb(i)}};function um(t){const e=new Uint8Array(16380);return e.set(t.flat()),e}function cm(t){return um(je(4095).map((e=>{const n=Nc(t(e/4095));return[n.r,n.g,n.b,255]})))}const dm={white:je(4095).map((t=>[255,255,255,255]))};for(const[wR,_R]of Object.entries(lm)){if(wR.startsWith("scheme")&&"string"==typeof _R[0]){const t=new Array(4095),e=_R.map((t=>{const e=Nc(t);return[e.r,e.g,e.b,255]}));for(const i of je(4095))t[i]=e[i%_R.length];const n=wR.replace("scheme","").toLowerCase();dm[n]=um(t)}if(wR.startsWith("interpolate")){const t=wR.replace("interpolate","").toLowerCase();dm[t]=cm(_R),"rainbow"==t&&(dm.shufbow=Pe(dm[t]))}}const hm={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:dm.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 bm{constructor(t,e,n,i){this.label=t,this.scatterplot=e,this.regl=n,this._domain=this.default_domain,this._range=this.default_range,this._transform=hm[t].transform,this.tileSet=i,this.needs_transitions=!0,this._domains={}}get default_val(){return 1}get texture_size(){return 4095}get transform(){return this._transform?this._transform:hm[this.label].transform}get default_range(){return hm[this.label].range}get scale(){return sm[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]=ke(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 sm[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:i,y:r,z:o}=t;if(!r.constant)throw"Only constant lookups for the secondary dimension are currently supported.";const l={x:e,y:r.field,z:o.field},a=this.scatterplot.lookup_tables.get(n),s=()=>this.arrow_column().data.dictionary.toArray();let u;void 0===a?(console.log("Using temporary null lookup."),u={texture:this.textures.one_d,y_domain:[-1,1],z_domain:[-1,1],x_domain:[-1,1]}):u=a.get_cached_crosstab_texture(l,{x:s},this.regl);const{texture:c,z_domain:d,y_domain:h,x_domain:b,shape:p,crosstabs:m}=u;return{value:r.constant||0,crosstabs:m,texture:c,shape:p,x_domain:b,y_domain:h,z_domain:d}}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=Xm(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,Xm(t.lambda,!1)),this.lookup=t.lookup,this.field=t.field,this._domain=fm(t.domain),this._range=fm(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=sm[this.transform]().range(t).domain([0,this.texture_size-1]);for(let n=0;n").map((t=>t.trim()));i=null==e?Function("x",n):Function(t,e)}else i=n;this.scaleFunc=eb().range(e).domain([0,this.texture_size-1]);let r=je(this.texture_size);if(void 0===t||null==this.tileSet.table)return void this.texture_buffer.set(je(this.texture_size).map((t=>1)));console.log(r);const{column:o}=this;if(!o)throw`Column ${t} does not exist on table.`;if(o.type.dictionary){r.fill("");o.data.dictionary.toArray().forEach(((t,e)=>r[e]=t))}else r=r.map((t=>this.scaleFunc(t)));const l=r.map((t=>+i(t)));console.log(l),console.log(am(l)),this.texture_buffer.set(am(l).array)}}class pm extends bm{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 mm extends pm{get range(){const[t,e]=this.tileSet.extent?this.tileSet.extent.y:[-20,20];return[e,t]}get previous_range(){return this.range}}function fm(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 ym={Size:class extends bm{get default_val(){return 1}},Jitter_speed:class extends bm{get default_val(){return.1}},Jitter_radius:class extends bm{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 bm{get default_val(){return[128,150,213,255]}default_data(){return dm.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}=Nc(this._constant);return this._constant=[t/255,e/255,n/255],this._constant}return this._constant}}encode_for_textures(t){if(dm[t])this.texture_buffer.set(dm[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=je(4095).map((e=>{const[n,i,r]=t[e%t.length];return[n,i,r,255]}));this.texture_buffer.set(um(e))}else console.warn(`request range of ${t} for color ${this.field} unknown`)}},Filter:class extends bm{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:pm,Y:mm,X0:class extends pm{},Y0:class extends mm{}};class Zm{constructor(t,e,n,i){this.states=[];const r=t.toLowerCase(),o=ym[t];for(const l of[1,2])this.states.push(new o(r,e,n,i));this.states[0].partner=this.states[1],this.states[1].partner=this.states[0];for(const l of this.states)l.update({constant:hm[r].constant});this.current_encoding=JSON.stringify({constant:hm[r].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 Xm(t,e=!1){console.log(t);let[n,i]=t.split("=>").map((t=>t.trim()));if(void 0===i)throw`Couldn't parse ${t} into a function`;"{"!=i.slice(0,1)&&"return"!=i.slice(0,6)&&(i=`return ${i}`);const r=`${n} => ${i}`;return e?Function(n,i):{field:n,lambda:r}}const Gm=Array.from(Object.keys(ym)).map((t=>t.toLowerCase()));class Wm{constructor(t,e,n,i=null){if(this.is_aesthetic_set=!0,this.scatterplot=t,this.regl=e,this.tileSet=n,null===i)for(const o of Array.from(Object.keys(ym))){const t=o,e=[t,this.scatterplot,this.regl,n];this[t.toLowerCase()]=new Zm(...e)}const r={};for(const[o,l]of Object.entries(hm))r[o]=l.constant||l;this.encoding=JSON.parse(JSON.stringify(r)),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 i=t[e];t[`x${n}`]={field:`${i}.x`,transform:"literal"},t[`y${n}`]={field:`${i}.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 Gm)this[e].update(t[e])}}class Vm 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:i,width:r,discard_share:o,height:l}=this,{k:a}=this.zoom.transform;e=void 0===e?.25:e;const s=1/a**2,u=e*(r*l)/(ze([i,this.tileSet.highest_known_ix])*(1-o)*s*(Math.PI*Math.exp(Math.log(1*a)*t)*n)**2);return u>1?1:u<1/255?1/255:u}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=Zb({optionalExtensions:["OES_standard_derivatives","OES_element_index_uint","OES_texture_float","OES_texture_half_float"],canvas:this.canvas.node()}),this.aes=new Wm(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 Sm(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=mb(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:i,variable_to_buffer_num:r}=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:i,aes_to_buffer_num:n,variable_to_buffer_num:r,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 i of this.visible_tiles()){const r=new vm(this.regl,i,this);try{if(!r.ready(t.prefs,t.block_for_buffers))continue}catch(n){continue}const o={manager:r,image_locations:r.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:i,tileSet:r}=this,{props:o}=this;this.tick_num=this.tick_num||0,this.tick_num++,this._use_scale_to_download_tiles?r.download_most_needed_tiles(this.zoom.current_corners(),this.props.max_ix):r.download_to_depth(n.max_points),i.clear({color:[.9,.9,.93,0],depth:1});const l=Date.now();let a=()=>{};for(;Date.now()-l<10&&this.deferred_functions.length;){a=this.deferred_functions.shift();try{a()}catch(s){console.warn(s,a)}}this.render_all(o)}render_jpeg(t){}single_blur_pass(t,e,n){const{regl:i}=this;e.use((()=>{i.clear({color:[0,0,0,0]}),i({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 i=n-1;for(;i>-1;)this.single_blur_pass(t,e,[2**i,0]),this.single_blur_pass(e,t,[0,2**i]),i-=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[i,r]=e.position;if(e.lookups.get(t))return e.lookups.get(t);const l=e.measureText(t).width;return l>4096?void 0:(i+l>4096&&(i=0,r+=font_size),e.fillText(t,i,r),lookups.set(t,{x:i,y:r,width:l}),i+=l,e.position=[i,r],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:i,regl:r,tileSet:o}=this.aes,l=this.aes;void 0===n&&(n={width:this.width,height:this.height,use:t=>t()});const{width:a,height:s}=n;this.aes=new Wm(i,r,o);const u=map._root.table.getColumn(t).data.dictionary.length;let c=1;for(;c{this.regl.clear({color:[0,0,0,0]}),this.render_points(h),r.read({data:b})})),this.aes=l}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:i,height:r}=this.fbos.minicounter,o=new Uint8Array(i*r*4),l=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[a,s]of this.tileSet.dictionary_lookups[t]){if("string"==typeof a)continue;const t=Math.floor(a/64),e=a%64,n=i/64;let r=0,u=!1;for(const l of je(n))for(const a of je(n)){const s=o[t*n*4+4*a+e*n*4*i+l*i*4+3];s>=128?u=!0:r+=s}u?(console.log(a,s,"overflown, performing manually"),l.set(s,this.n_visible(a))):l.set(s,r)}return l}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:i}=this;let r;return i.only_color=t,console.log("Counting visible points"),this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(i),this.regl.read(this.contour_vals),r=Ee(this.contour_vals)})),r}calculate_contours(t="lc0"){const{width:e,height:n}=this;let i=[];const r=Jb().size([parseInt(e),parseInt(n)]).thresholds(d3.range(-1,9).map((t=>Math.pow(2,2*t))));for(const o of je(this.tileSet.dictionary_lookups[t].size/2)){this.draw_contour_buffer(t,o);const e=r(this.contour_alpha_vals);e.forEach((e=>{e.label=this.tileSet.dictionary_lookups[t].get(o)})),i=i.concat(e)}return i}color_pick(t,e){const{props:n,height:i}=this;let r;n.color_picker_mode=1,this.fbos.colorpicker.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(n);try{r=this.regl.read({x:t,y:i-e,width:1,height:1})}catch(o){console.warn("Read bad data from",{x:t,y:e,height:i})}}));const o=wb(...r),l=this.tileSet.findPoint(o);if(0!==l.length)return l[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:i}=this;n=Math.floor(n),i=Math.floor(i),this.contour_vals=this.contour_vals||new Uint8Array(4*n*i),this.contour_alpha_vals=this.contour_alpha_vals||new Uint16Array(n*i);const{props:r}=this;r.aes.encoding.color={field:t},r.only_color=e,this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(r),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:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n\nprecision 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\nfloat delta = 0.0, alpha = 1.0;\n\nbool out_of_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.03) {return true;}\n return false;\n}\n\nbool out_of_hollow_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.01) {return true;}\n float distance_from_edge = (1.0 - r_sq) * point_size;\n if (distance_from_edge > 4.0) {return true;}\n return false;\n}\n\nbool out_of_triangle(in vec2 coord) {\n if (coord.y > (2. * abs(coord.x - .5))) {\n return false;\n }\n return true;\n}\n\nvoid main() {\n\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 float alpha = fill.a;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n float r = dot(cxy, cxy);\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha *= (1.0 - smoothstep(1.0 - delta, 1.0 + delta, r));\n #endif\n\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 * alpha, alpha);\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 je(0,16))e.attributes[`buffer_${n}`]=(t,{manager:e,buffer_num_to_variable:i})=>e.regl_elements.get(i[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 i="current"===t?"":"last_";if(e.uniforms[`u_${i}${n}_map`]=()=>this.aes[n][t].textures.one_d,e.uniforms[`u_${i}${n}_needs_map`]=()=>this.aes[n][t].use_map_on_regl,"jitter_radius"==n&&""==i){const r=`u_${i}${n}_lookup`;e.uniforms[r]=()=>this.aes[n][t].use_lookup?1:0,e.uniforms[`${r}_map`]=()=>this.aes[n][t].lookup_texture.texture,e.uniforms[`${r}_y_constant`]=()=>+this.aes[n][t].lookup_texture.value||.5,e.uniforms[`${r}_y_domain`]=()=>this.aes[n][t].lookup_texture.y_domain,e.uniforms[`${r}_z_domain`]=()=>this.aes[n][t].lookup_texture.z_domain,e.uniforms[`${r}_x_domain`]=()=>this.aes[n][t].lookup_texture.x_domain}e.uniforms[`u_${i}${n}_domain`]=()=>this.aes[n][t].domain,"filter"!=n&&"color"!=n&&(e.uniforms[`u_${i}${n}_range`]=()=>this.aes[n][t].range),e.uniforms[`u_${i}${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_${i}${n}_constant`]=()=>void 0!==this.aes[n][t].constant?this.aes[n][t].constant:this.aes[n][t].default_val,e.uniforms[`u_${i}${n}_buffer_num`]=(e,{aes_to_buffer_num:i})=>{const r=i[`${n}--${t}`];return null==r?-1:r}}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===Gm.indexOf(t))return[];const n=[];for(const i of[e.current,e.last])i.field&&n.push(i.field);return n})).flat();for(const l of o.concat(["ix"])){const t=this.regl_elements.get(l);if(null===t)return!1;if(void 0===t){if(!this.tile.ready)return!1;if(i.set(l,null),!e)return n.deferred_functions.push((()=>this.create_regl_buffer(l))),!1;this.create_regl_buffer(l)}}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 i=new Float32Array(e.table.length);let r=0;for(const o of n.data.values){const n=e.local_dictionary_lookups[t].get(o);i[r]=e.dictionary_lookups[t].get(n),r+=1}return i}if(n.data.values.constructor!==Float32Array){const t=new Float32Array(e.table.length);for(let i=0;ithis.buffer_size&&this.generate_new_buffer();const n={buffer:this.buffers[0],offset:this.pointer,stride:e};return this.pointer+=t*e,n}} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var Rm=function(t,e){return(Rm=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function gm(t,e){function n(){this.constructor=t}Rm(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Lm=function(){return(Lm=Object.assign||function(t){for(var e,n=1,i=arguments.length;n0&&r[r.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Jm(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)l.push(i.value)}catch(a){r={error:a}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return l}function wm(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof _m?Promise.resolve(n.value.v).then(s,u):c(o[0][2],n)}catch(i){c(o[0][3],i)}var n}function s(t){a("next",t)}function u(t){a("throw",t)}function c(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function Nm(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:_m(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function Cm(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Hm(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}var Um={SIZEOF_SHORT:2,SIZEOF_INT:4,FILE_IDENTIFIER_LENGTH:4,Encoding:{UTF8_BYTES:1,UTF16_STRING:2}};Um.int32=new Int32Array(2),Um.float32=new Float32Array(Um.int32.buffer),Um.float64=new Float64Array(Um.int32.buffer),Um.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],Um.Long=function(t,e){this.low=0|t,this.high=0|e},Um.Long.create=function(t,e){return 0==t&&0==e?Um.Long.ZERO:new Um.Long(t,e)},Um.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},Um.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},Um.Long.ZERO=new Um.Long(0,0),Um.Builder=function(t){if(t)e=t;else var e=1024;this.bb=Um.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},Um.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},Um.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},Um.Builder.prototype.dataBuffer=function(){return this.bb},Um.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},Um.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 i=(n+2)*Um.SIZEOF_SHORT;this.addInt16(i);var r=0,o=this.space;t:for(e=0;e=0;i--)this.writeInt8(n.charCodeAt(i))}this.prep(this.minalign,Um.SIZEOF_INT),this.addOffset(t),this.bb.setPosition(this.space)},Um.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(i+e)))throw new Error("FlatBuffers: field "+e+" must be set")},Um.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(Um.SIZEOF_INT,t*e),this.prep(n,t*e)},Um.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},Um.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n=56320)i=r;else i=(r<<10)+t.charCodeAt(n++)+-56613888;i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,l=this.bb.bytes();n>24},Um.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},Um.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},Um.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},Um.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},Um.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},Um.ByteBuffer.prototype.readInt64=function(t){return new Um.Long(this.readInt32(t),this.readInt32(t+4))},Um.ByteBuffer.prototype.readUint64=function(t){return new Um.Long(this.readUint32(t),this.readUint32(t+4))},Um.ByteBuffer.prototype.readFloat32=function(t){return Um.int32[0]=this.readInt32(t),Um.float32[0]},Um.ByteBuffer.prototype.readFloat64=function(t){return Um.int32[Um.isLittleEndian?0:1]=this.readInt32(t),Um.int32[Um.isLittleEndian?1:0]=this.readInt32(t+4),Um.float64[0]},Um.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},Um.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},Um.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},Um.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},Um.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},Um.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},Um.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},Um.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},Um.ByteBuffer.prototype.writeFloat32=function(t,e){Um.float32[0]=e,this.writeInt32(t,Um.int32[0])},Um.ByteBuffer.prototype.writeFloat64=function(t,e){Um.float64[0]=e,this.writeInt32(t,Um.int32[Um.isLittleEndian?0:1]),this.writeInt32(t+4,Um.int32[Um.isLittleEndian?1:0])},Um.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&o)))}return i},Um.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},Um.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+Um.SIZEOF_INT},Um.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},Um.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=Um.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+Um.FILE_IDENTIFIER_LENGTH);for(var e=0;e0;)t.shift().resolve(jm);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}},e.prototype[Symbol.asyncIterator]=function(){return this},e.prototype.toDOMStream=function(t){return _f.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)},e.prototype.toNodeStream=function(t){return _f.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)},e.prototype.throw=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.abort(t)];case 1:return e.sent(),[2,jm]}}))}))},e.prototype.return=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(t){switch(t.label){case 0:return[4,this.close()];case 1:return t.sent(),[2,jm]}}))}))},e.prototype.read=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"read")];case 1:return[2,e.sent().value]}}))}))},e.prototype.peek=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"peek")];case 1:return[2,e.sent().value]}}))}))},e.prototype.next=function(){for(var t=this,e=[],n=0;n0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((function(e,n){t.resolvers.push({resolve:e,reject:n})})):Promise.resolve(jm)},e.prototype._ensureOpen=function(){if(this._closedPromiseResolve)return!0;throw new Error(this+" is closed")},e}(Pm),Dm=Jm(function(){var t=function(){throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=function(){throw t()},e.asUintN=function(){throw t()},"undefined"!=typeof BigInt?[BigInt,!0]:[e,!1]}(),2),Om=Dm[0],Am=Dm[1],qm=Jm((Fm=function(){throw new Error("BigInt64Array is not available in this environment")},Bm=function(){function t(){throw Fm()}return Object.defineProperty(t,"BYTES_PER_ELEMENT",{get:function(){return 8},enumerable:!1,configurable:!0}),t.of=function(){throw Fm()},t.from=function(){throw Fm()},t}(),"undefined"!=typeof BigInt64Array?[BigInt64Array,!0]:[Bm,!1]),2),$m=qm[0];qm[1];var tf,ef,nf=Jm((tf=function(){throw new Error("BigUint64Array is not available in this environment")},ef=function(){function t(){throw tf()}return Object.defineProperty(t,"BYTES_PER_ELEMENT",{get:function(){return 8},enumerable:!1,configurable:!0}),t.of=function(){throw tf()},t.from=function(){throw tf()},t}(),"undefined"!=typeof BigUint64Array?[BigUint64Array,!0]:[ef,!1]),2),rf=nf[0];nf[1];var of=function(t){return"boolean"==typeof t},lf=function(t){return"function"==typeof t},af=function(t){return null!=t&&Object(t)===t},sf=function(t){return af(t)&&lf(t.then)},uf=function(t){return af(t)&&lf(t[Symbol.iterator])},cf=function(t){return af(t)&&lf(t[Symbol.asyncIterator])},df=function(t){return af(t)&&af(t.schema)},hf=function(t){return af(t)&&"done"in t&&"value"in t},bf=function(t){return af(t)&&lf(t.stat)&&function(t){return"number"==typeof t}(t.fd)},pf=function(t){return af(t)&&mf(t.body)},mf=function(t){return af(t)&&lf(t.cancel)&&lf(t.getReader)&&!(t instanceof Pm)},ff=function(t){return af(t)&&lf(t.read)&&lf(t.pipe)&&of(t.readable)&&!(t instanceof Pm)},yf=Um.ByteBuffer,Zf="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Xf(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=e.byteLength);var r=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,r),l=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return o.set(l,n),t}function Gf(t,e){for(var n,i,r,o=function(t){for(var e,n,i,r,o=t[0]?[t[0]]:[],l=void 0,a=void 0,s=0,u=0,c=t.length;++s0)do{if(t[n]!==e[n])return!1}while(++n0&&(r.push(o),s+=o.byteLength),!(n||a<=s))return[3,7];p.label=4;case 4:return[4,e()];case 5:b=p.sent(),l=b.cmd,a=b.size,p.label=6;case 6:if(a0&&(r.push(o),s+=o.byteLength),!(n||a<=s))return[3,13];m.label=9;case 9:return[4,_m(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),l=p.cmd,a=p.size,m.label=12;case 12:if(a0&&(r.push(Sf(o)),s+=o.byteLength),!(n||a<=s))return[3,13];m.label=9;case 9:return[4,_m(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),l=p.cmd,a=p.size,m.label=12;case 12:if(a0&&(c.push(d),u+=d.byteLength)),!(o||s<=u))return[3,13];m.label=9;case 9:return[4,_m(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),a=p.cmd,s=p.size,m.label=12;case 12:if(s=i?[2,{done:!1,value:new Uint8Array(e,0,i)}]:[4,t.read(new Uint8Array(e,n,i-n))];case 1:return r=a.sent(),o=r.done,l=r.value,(n+=l.byteLength)=0;n--)t.addInt32(e[n]);return t.endVector()},e.startTypeIdsVector=function(t,e){t.startVector(4,e,4)},e.endUnion=function(t){return t.endObject()},e.createUnion=function(t,n,i){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,i),e.endUnion(t)},e}();e.Union=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsInt=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.bitWidth=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.prototype.isSigned=function(){var t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},t.startInt=function(t){t.startObject(2)},t.addBitWidth=function(t,e){t.addFieldInt32(0,e,0)},t.addIsSigned=function(t,e){t.addFieldInt8(1,+e,0)},t.endInt=function(t){return t.endObject()},t.createInt=function(e,n,i){return t.startInt(e),t.addBitWidth(e,n),t.addIsSigned(e,i),t.endInt(e)},t}();t.Int=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsFloatingPoint=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.precision=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.Precision.HALF},e.startFloatingPoint=function(t){t.startObject(1)},e.addPrecision=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.Precision.HALF)},e.endFloatingPoint=function(t){return t.endObject()},e.createFloatingPoint=function(t,n){return e.startFloatingPoint(t),e.addPrecision(t,n),e.endFloatingPoint(t)},e}();e.FloatingPoint=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsUtf8=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startUtf8=function(t){t.startObject(0)},t.endUtf8=function(t){return t.endObject()},t.createUtf8=function(e){return t.startUtf8(e),t.endUtf8(e)},t}();t.Utf8=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startBinary=function(t){t.startObject(0)},t.endBinary=function(t){return t.endObject()},t.createBinary=function(e){return t.startBinary(e),t.endBinary(e)},t}();t.Binary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsLargeUtf8=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startLargeUtf8=function(t){t.startObject(0)},t.endLargeUtf8=function(t){return t.endObject()},t.createLargeUtf8=function(e){return t.startLargeUtf8(e),t.endLargeUtf8(e)},t}();t.LargeUtf8=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsLargeBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startLargeBinary=function(t){t.startObject(0)},t.endLargeBinary=function(t){return t.endObject()},t.createLargeBinary=function(e){return t.startLargeBinary(e),t.endLargeBinary(e)},t}();t.LargeBinary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFixedSizeBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.byteWidth=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.startFixedSizeBinary=function(t){t.startObject(1)},t.addByteWidth=function(t,e){t.addFieldInt32(0,e,0)},t.endFixedSizeBinary=function(t){return t.endObject()},t.createFixedSizeBinary=function(e,n){return t.startFixedSizeBinary(e),t.addByteWidth(e,n),t.endFixedSizeBinary(e)},t}();t.FixedSizeBinary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBool=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startBool=function(t){t.startObject(0)},t.endBool=function(t){return t.endObject()},t.createBool=function(e){return t.startBool(e),t.endBool(e)},t}();t.Bool=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDecimal=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.precision=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.prototype.scale=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},t.startDecimal=function(t){t.startObject(2)},t.addPrecision=function(t,e){t.addFieldInt32(0,e,0)},t.addScale=function(t,e){t.addFieldInt32(1,e,0)},t.endDecimal=function(t){return t.endObject()},t.createDecimal=function(e,n,i){return t.startDecimal(e),t.addPrecision(e,n),t.addScale(e,i),t.endDecimal(e)},t}();t.Decimal=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDate=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.DateUnit.MILLISECOND},e.startDate=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.DateUnit.MILLISECOND)},e.endDate=function(t){return t.endObject()},e.createDate=function(t,n){return e.startDate(t),e.addUnit(t,n),e.endDate(t)},e}();e.Date=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsTime=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.MILLISECOND},e.prototype.bitWidth=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32},e.startTime=function(t){t.startObject(2)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.MILLISECOND)},e.addBitWidth=function(t,e){t.addFieldInt32(1,e,32)},e.endTime=function(t){return t.endObject()},e.createTime=function(t,n,i){return e.startTime(t),e.addUnit(t,n),e.addBitWidth(t,i),e.endTime(t)},e}();e.Time=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsTimestamp=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.SECOND},e.prototype.timezone=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},e.startTimestamp=function(t){t.startObject(2)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.SECOND)},e.addTimezone=function(t,e){t.addFieldOffset(1,e,0)},e.endTimestamp=function(t){return t.endObject()},e.createTimestamp=function(t,n,i){return e.startTimestamp(t),e.addUnit(t,n),e.addTimezone(t,i),e.endTimestamp(t)},e}();e.Timestamp=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsInterval=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH},e.startInterval=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH)},e.endInterval=function(t){return t.endObject()},e.createInterval=function(t,n){return e.startInterval(t),e.addUnit(t,n),e.endInterval(t)},e}();e.Interval=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDuration=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.MILLISECOND},e.startDuration=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.MILLISECOND)},e.endDuration=function(t){return t.endObject()},e.createDuration=function(t,n){return e.startDuration(t),e.addUnit(t,n),e.endDuration(t)},e}();e.Duration=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsKeyValue=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.key=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},t.prototype.value=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},t.startKeyValue=function(t){t.startObject(2)},t.addKey=function(t,e){t.addFieldOffset(0,e,0)},t.addValue=function(t,e){t.addFieldOffset(1,e,0)},t.endKeyValue=function(t){return t.endObject()},t.createKeyValue=function(e,n,i){return t.startKeyValue(e),t.addKey(e,n),t.addValue(e,i),t.endKeyValue(e)},t}();t.KeyValue=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDictionaryEncoding=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.id=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.indexType=function(e){var n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.apache.arrow.flatbuf.Int).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.isOrdered=function(){var t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.startDictionaryEncoding=function(t){t.startObject(3)},e.addId=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addIndexType=function(t,e){t.addFieldOffset(1,e,0)},e.addIsOrdered=function(t,e){t.addFieldInt8(2,+e,0)},e.endDictionaryEncoding=function(t){return t.endObject()},e.createDictionaryEncoding=function(t,n,i,r){return e.startDictionaryEncoding(t),e.addId(t,n),e.addIndexType(t,i),e.addIsOrdered(t,r),e.endDictionaryEncoding(t)},e}();e.DictionaryEncoding=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsField=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.name=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.prototype.nullable=function(){var t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.prototype.typeType=function(){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):t.apache.arrow.flatbuf.Type.NONE},e.prototype.type=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null},e.prototype.dictionary=function(e){var n=this.bb.__offset(this.bb_pos,12);return n?(e||new t.apache.arrow.flatbuf.DictionaryEncoding).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.children=function(e,n){var i=this.bb.__offset(this.bb_pos,14);return i?(n||new t.apache.arrow.flatbuf.Field).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.childrenLength=function(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.customMetadata=function(e,n){var i=this.bb.__offset(this.bb_pos,16);return i?(n||new t.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startField=function(t){t.startObject(7)},e.addName=function(t,e){t.addFieldOffset(0,e,0)},e.addNullable=function(t,e){t.addFieldInt8(1,+e,0)},e.addTypeType=function(e,n){e.addFieldInt8(2,n,t.apache.arrow.flatbuf.Type.NONE)},e.addType=function(t,e){t.addFieldOffset(3,e,0)},e.addDictionary=function(t,e){t.addFieldOffset(4,e,0)},e.addChildren=function(t,e){t.addFieldOffset(5,e,0)},e.createChildrenVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startChildrenVector=function(t,e){t.startVector(4,e,4)},e.addCustomMetadata=function(t,e){t.addFieldOffset(6,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endField=function(t){return t.endObject()},e.createField=function(t,n,i,r,o,l,a,s){return e.startField(t),e.addName(t,n),e.addNullable(t,i),e.addTypeType(t,r),e.addType(t,o),e.addDictionary(t,l),e.addChildren(t,a),e.addCustomMetadata(t,s),e.endField(t)},e}();e.Field=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.offset=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.length=function(){return this.bb.readInt64(this.bb_pos+8)},t.createBuffer=function(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()},t}();t.Buffer=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsSchema=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.endianness=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.Endianness.Little},e.prototype.fields=function(e,n){var i=this.bb.__offset(this.bb_pos,6);return i?(n||new t.apache.arrow.flatbuf.Field).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.fieldsLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.customMetadata=function(e,n){var i=this.bb.__offset(this.bb_pos,8);return i?(n||new t.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startSchema=function(t){t.startObject(3)},e.addEndianness=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.Endianness.Little)},e.addFields=function(t,e){t.addFieldOffset(1,e,0)},e.createFieldsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startFieldsVector=function(t,e){t.startVector(4,e,4)},e.addCustomMetadata=function(t,e){t.addFieldOffset(2,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endSchema=function(t){return t.endObject()},e.finishSchemaBuffer=function(t,e){t.finish(e)},e.createSchema=function(t,n,i,r){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,i),e.addCustomMetadata(t,r),e.endSchema(t)},e}();e.Schema=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Ff||(Ff={})),function(t){!function(t){!function(t){!function(t){t.Schema=Ff.apache.arrow.flatbuf.Schema}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={})),function(t){!function(t){!function(t){!function(t){!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(t.MessageHeader||(t.MessageHeader={}))}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.length=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.nullCount=function(){return this.bb.readInt64(this.bb_pos+8)},t.createFieldNode=function(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()},t}();t.FieldNode=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsRecordBatch=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.length=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.nodes=function(e,n){var i=this.bb.__offset(this.bb_pos,6);return i?(n||new t.apache.arrow.flatbuf.FieldNode).__init(this.bb.__vector(this.bb_pos+i)+16*e,this.bb):null},e.prototype.nodesLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.buffers=function(t,e){var n=this.bb.__offset(this.bb_pos,8);return n?(e||new Ff.apache.arrow.flatbuf.Buffer).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null},e.prototype.buffersLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startRecordBatch=function(t){t.startObject(3)},e.addLength=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addNodes=function(t,e){t.addFieldOffset(1,e,0)},e.startNodesVector=function(t,e){t.startVector(16,e,8)},e.addBuffers=function(t,e){t.addFieldOffset(2,e,0)},e.startBuffersVector=function(t,e){t.startVector(16,e,8)},e.endRecordBatch=function(t){return t.endObject()},e.createRecordBatch=function(t,n,i,r){return e.startRecordBatch(t),e.addLength(t,n),e.addNodes(t,i),e.addBuffers(t,r),e.endRecordBatch(t)},e}();e.RecordBatch=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDictionaryBatch=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.id=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.data=function(e){var n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.apache.arrow.flatbuf.RecordBatch).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.isDelta=function(){var t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.startDictionaryBatch=function(t){t.startObject(3)},e.addId=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addData=function(t,e){t.addFieldOffset(1,e,0)},e.addIsDelta=function(t,e){t.addFieldInt8(2,+e,0)},e.endDictionaryBatch=function(t){return t.endObject()},e.createDictionaryBatch=function(t,n,i,r){return e.startDictionaryBatch(t),e.addId(t,n),e.addData(t,i),e.addIsDelta(t,r),e.endDictionaryBatch(t)},e}();e.DictionaryBatch=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsMessage=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.version=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ff.apache.arrow.flatbuf.MetadataVersion.V1},e.prototype.headerType=function(){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):t.apache.arrow.flatbuf.MessageHeader.NONE},e.prototype.header=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null},e.prototype.bodyLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.customMetadata=function(t,e){var n=this.bb.__offset(this.bb_pos,12);return n?(e||new Ff.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startMessage=function(t){t.startObject(5)},e.addVersion=function(t,e){t.addFieldInt16(0,e,Ff.apache.arrow.flatbuf.MetadataVersion.V1)},e.addHeaderType=function(e,n){e.addFieldInt8(1,n,t.apache.arrow.flatbuf.MessageHeader.NONE)},e.addHeader=function(t,e){t.addFieldOffset(2,e,0)},e.addBodyLength=function(t,e){t.addFieldInt64(3,e,t.createLong(0,0))},e.addCustomMetadata=function(t,e){t.addFieldOffset(4,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endMessage=function(t){return t.endObject()},e.finishMessageBuffer=function(t,e){t.finish(e)},e.createMessage=function(t,n,i,r,o,l){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,i),e.addHeader(t,r),e.addBodyLength(t,o),e.addCustomMetadata(t,l),e.endMessage(t)},e}();e.Message=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Mf||(Mf={}));var Qf,Pf,Ef=Ff.apache.arrow.flatbuf.Type,Df=Ff.apache.arrow.flatbuf.DateUnit,Of=Ff.apache.arrow.flatbuf.TimeUnit,Af=Ff.apache.arrow.flatbuf.Precision,qf=Ff.apache.arrow.flatbuf.UnionMode,$f=Ff.apache.arrow.flatbuf.IntervalUnit,ty=Mf.apache.arrow.flatbuf.MessageHeader,ey=Ff.apache.arrow.flatbuf.MetadataVersion;function ny(t,e,n,i){return 0!=(n&1<>i}function ry(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):ly(ay(n,t,e,null,ny)).subarray(0,i)),r}return n}function ly(t){var e,n,i=[],r=0,o=0,l=0;try{for(var a=Hm(t),s=a.next();!s.done;s=a.next()){s.value&&(l|=1<0)&&(i[r++]=l);var u=new Uint8Array(i.length+7&-8);return u.set(i),u}function ay(t,e,n,i,r){var o,l,a,s,u;return Km(this,(function(c){switch(c.label){case 0:o=e%8,l=e>>3,a=0,s=n,c.label=1;case 1:if(!(s>0))return[3,6];u=t[l++],c.label=2;case 2:return[4,r(i,a++,u,o)];case 3:c.sent(),c.label=4;case 4:if(--s>0&&++o<8)return[3,2];c.label=5;case 5:return o=0,[3,1];case 6:return[2]}}))}function sy(t,e,n){var i,r;if(n-e<=0)return 0;if(n-e<8){var o=0;try{for(var l=Hm(ay(t,e,n-e,t,iy)),a=l.next();!a.done;a=l.next()){o+=a.value}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(i)throw i.error}}return o}var s=n>>3<<3,u=e+(e%8==0?0:8-e%8);return sy(t,e,u)+sy(t,s,n)+uy(t,u>>3,s-u>>3)}function uy(t,e,n){for(var i=0,r=0|e,o=new DataView(t.buffer,t.byteOffset,t.byteLength),l=void 0===n?t.byteLength:r+n;l-r>=4;)i+=cy(o.getUint32(r)),r+=4;for(;l-r>=2;)i+=cy(o.getUint16(r)),r+=2;for(;l-r>=1;)i+=cy(o.getUint8(r)),r+=1;return i}function cy(t){var e=0|t;return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24}!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"}(Qf||(Qf={})),function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"}(Pf||(Pf={}));var dy=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",getBool:ny,getBit:iy,setBool:ry,truncateBitmap:oy,packBools:ly,iterateBits:ay,popcnt_bit_range:sy,popcnt_array:uy,popcnt_uint32:cy}),hy=function(){function t(){}return t.prototype.visitMany=function(t){for(var e=this,n=[],i=1;i0?"+":"")+this.scale+"]"},e[Symbol.toStringTag]=function(t){return t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"}(e.prototype),e}(Ry),My=function(t){function e(e){var n=t.call(this)||this;return n.unit=e,n}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Date},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Date"+32*(this.unit+1)+"<"+Df[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"}(e.prototype),e}(Ry),jy=function(t){function e(){return t.call(this,Df.DAY)||this}return gm(e,t),e}(My),Qy=function(t){function e(){return t.call(this,Df.MILLISECOND)||this}return gm(e,t),e}(My),Py=function(t){function e(e,n){var i=t.call(this)||this;return i.unit=e,i.bitWidth=n,i}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Time},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Time"+this.bitWidth+"<"+Of[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.bitWidth=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Time"}(e.prototype),e}(Ry);!function(t){function e(){return t.call(this,Of.SECOND,32)||this}gm(e,t)}(Py),function(t){function e(){return t.call(this,Of.MILLISECOND,32)||this}gm(e,t)}(Py),function(t){function e(){return t.call(this,Of.MICROSECOND,64)||this}gm(e,t)}(Py),function(t){function e(){return t.call(this,Of.NANOSECOND,64)||this}gm(e,t)}(Py);var Ey=function(t){function e(e,n){var i=t.call(this)||this;return i.unit=e,i.timezone=n,i}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Timestamp},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Timestamp<"+Of[this.unit]+(this.timezone?", "+this.timezone:"")+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"}(e.prototype),e}(Ry);!function(t){function e(e){return t.call(this,Of.SECOND,e)||this}gm(e,t)}(Ey),function(t){function e(e){return t.call(this,Of.MILLISECOND,e)||this}gm(e,t)}(Ey),function(t){function e(e){return t.call(this,Of.MICROSECOND,e)||this}gm(e,t)}(Ey),function(t){function e(e){return t.call(this,Of.NANOSECOND,e)||this}gm(e,t)}(Ey);var Dy=function(t){function e(e){var n=t.call(this)||this;return n.unit=e,n}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Interval},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Interval<"+$f[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"}(e.prototype),e}(Ry);!function(t){function e(){return t.call(this,$f.DAY_TIME)||this}gm(e,t)}(Dy),function(t){function e(){return t.call(this,$f.YEAR_MONTH)||this}gm(e,t)}(Dy);var Oy=function(t){function e(e){var n=t.call(this)||this;return n.children=[e],n}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.List},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"List<"+this.valueType+">"},Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueField",{get:function(){return this.children[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.valueType.ArrayType},enumerable:!1,configurable:!0}),e[Symbol.toStringTag]=function(t){return t.children=null,t[Symbol.toStringTag]="List"}(e.prototype),e}(Ry),Ay=function(t){function e(e){var n=t.call(this)||this;return n.children=e,n}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Struct},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Struct<{"+this.children.map((function(t){return t.name+":"+t.type})).join(", ")+"}>"},e[Symbol.toStringTag]=function(t){return t.children=null,t[Symbol.toStringTag]="Struct"}(e.prototype),e}(Ry),qy=function(t){function e(e,n,i){var r=t.call(this)||this;return r.mode=e,r.children=i,r.typeIds=n=Int32Array.from(n),r.typeIdToChildIndex=n.reduce((function(t,e,n){return(t[e]=n)&&t||t}),Object.create(null)),r}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Union},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this[Symbol.toStringTag]+"<"+this.children.map((function(t){return""+t.type})).join(" | ")+">"},e[Symbol.toStringTag]=function(t){return t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"}(e.prototype),e}(Ry);!function(t){function e(e,n){return t.call(this,qf.Dense,e,n)||this}gm(e,t)}(qy),function(t){function e(e,n){return t.call(this,qf.Sparse,e,n)||this}gm(e,t)}(qy);var $y=function(t){function e(e){var n=t.call(this)||this;return n.byteWidth=e,n}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.FixedSizeBinary},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"FixedSizeBinary["+this.byteWidth+"]"},e[Symbol.toStringTag]=function(t){return t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"}(e.prototype),e}(Ry),tZ=function(t){function e(e,n){var i=t.call(this)||this;return i.listSize=e,i.children=[n],i}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.FixedSizeList},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueField",{get:function(){return this.children[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.valueType.ArrayType},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"FixedSizeList["+this.listSize+"]<"+this.valueType+">"},e[Symbol.toStringTag]=function(t){return t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"}(e.prototype),e}(Ry),eZ=function(t){function e(e,n){void 0===n&&(n=!1);var i=t.call(this)||this;return i.children=[e],i.keysSorted=n,i}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Map},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"keyType",{get:function(){return this.children[0].type.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type.children[1].type},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Map<{"+this.children[0].type.children.map((function(t){return t.name+":"+t.type})).join(", ")+"}>"},e[Symbol.toStringTag]=function(t){return t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"}(e.prototype),e}(Ry),nZ=function(t){return function(){return++t}}(-1),iZ=function(t){function e(e,n,i,r){var o=t.call(this)||this;return o.indices=n,o.dictionary=e,o.isOrdered=r||!1,o.id=null==i?nZ():"number"==typeof i?i:i.low,o}return gm(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return Qf.Dictionary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.dictionary.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.dictionary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.dictionary.ArrayType},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Dictionary<"+this.indices+", "+this.dictionary+">"},e[Symbol.toStringTag]=function(t){return t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"}(e.prototype),e}(Ry);function rZ(t){var e=t;switch(t.typeId){case Qf.Decimal:return 4;case Qf.Timestamp:return 2;case Qf.Date:case Qf.Interval:return 1+e.unit;case Qf.Int:case Qf.Time:return+(e.bitWidth>32)+1;case Qf.FixedSizeList:return e.listSize;case Qf.FixedSizeBinary:return e.byteWidth;default:return 1}}var oZ=function(){function t(e,n,i,r,o,l,a){var s;this.type=e,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(r||0,-1)),this.childData=(l||[]).map((function(e){return e instanceof t?e:e.data})),o instanceof t?(this.stride=o.stride,this.values=o.values,this.typeIds=o.typeIds,this.nullBitmap=o.nullBitmap,this.valueOffsets=o.valueOffsets):(this.stride=rZ(e),o&&((s=o[0])&&(this.valueOffsets=s),(s=o[1])&&(this.values=s),(s=o[2])&&(this.nullBitmap=s),(s=o[3])&&(this.typeIds=s)))}return Object.defineProperty(t.prototype,"typeId",{get:function(){return this.type.typeId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"byteLength",{get:function(){var t=0,e=this,n=e.valueOffsets,i=e.values,r=e.nullBitmap,o=e.typeIds;return n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),o&&(t+=o.byteLength),this.childData.reduce((function(t,e){return t+e.byteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullCount",{get:function(){var t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-sy(t,this.offset,this.offset+this.length)),e},enumerable:!1,configurable:!0}),t.prototype.clone=function(e,n,i,r,o,l){return void 0===n&&(n=this.offset),void 0===i&&(i=this.length),void 0===r&&(r=this._nullCount),void 0===o&&(o=this),void 0===l&&(l=this.childData),new t(e,n,i,r,o,l,this.dictionary)},t.prototype.slice=function(t,e){var n=this,i=n.stride,r=n.typeId,o=n.childData,l=+(0===this._nullCount)-1,a=16===r?i:1,s=this._sliceBuffers(t,e,i,r);return this.clone(this.type,this.offset+t,e,l,s,!o.length||this.valueOffsets?o:this._sliceChildren(o,a*t,a*e))},t.prototype._changeLengthAndBackfillNullBitmap=function(t){if(this.typeId===Qf.Null)return this.clone(this.type,0,t,0);var e=this.length,n=this.nullCount,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(oy(this.offset,e,this.nullBitmap),0);var r=this.buffers;return r[Pf.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)},t.prototype._sliceBuffers=function(t,e,n,i){var r,o=this.buffers;return(r=o[Pf.TYPE])&&(o[Pf.TYPE]=r.subarray(t,t+e)),(r=o[Pf.OFFSET])&&(o[Pf.OFFSET]=r.subarray(t,t+e+1))||(r=o[Pf.DATA])&&(o[Pf.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),o},t.prototype._sliceChildren=function(t,e,n){return t.map((function(t){return t.slice(e,n)}))},t.new=function(e,n,i,r,o,l,a){switch(o instanceof t?o=o.buffers:o||(o=[]),e.typeId){case Qf.Null:return t.Null(e,n,i);case Qf.Int:return t.Int(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Dictionary:return t.Dictionary(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[],a);case Qf.Float:return t.Float(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Bool:return t.Bool(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Decimal:return t.Decimal(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Date:return t.Date(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Time:return t.Time(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Timestamp:return t.Timestamp(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Interval:return t.Interval(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.FixedSizeBinary:return t.FixedSizeBinary(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.DATA]||[]);case Qf.Binary:return t.Binary(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.OFFSET]||[],o[Pf.DATA]||[]);case Qf.Utf8:return t.Utf8(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.OFFSET]||[],o[Pf.DATA]||[]);case Qf.List:return t.List(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.OFFSET]||[],(l||[])[0]);case Qf.FixedSizeList:return t.FixedSizeList(e,n,i,r||0,o[Pf.VALIDITY],(l||[])[0]);case Qf.Struct:return t.Struct(e,n,i,r||0,o[Pf.VALIDITY],l||[]);case Qf.Map:return t.Map(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.OFFSET]||[],(l||[])[0]);case Qf.Union:return t.Union(e,n,i,r||0,o[Pf.VALIDITY],o[Pf.TYPE]||[],o[Pf.OFFSET]||l,l)}throw new Error("Unrecognized typeId "+e.typeId)},t.Null=function(e,n,i){return new t(e,n,i,0)},t.Int=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Dictionary=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[void 0,Wf(e.indices.ArrayType,l),Sf(o)],[],a)},t.Float=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Bool=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Decimal=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Date=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Time=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Timestamp=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Interval=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.FixedSizeBinary=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Wf(e.ArrayType,l),Sf(o)])},t.Binary=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Vf(l),Sf(a),Sf(o)])},t.Utf8=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Vf(l),Sf(a),Sf(o)])},t.List=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Vf(l),void 0,Sf(o)],a?[a]:[])},t.FixedSizeList=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,void 0,Sf(o)],l?[l]:[])},t.Struct=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,void 0,Sf(o)],l)},t.Map=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Vf(l),void 0,Sf(o)],a?[a]:[])},t.Union=function(e,n,i,r,o,l,a,s){var u=[void 0,void 0,Sf(o),Wf(e.ArrayType,l)];return e.mode===qf.Sparse?new t(e,n,i,r,u,a):(u[Pf.OFFSET]=Vf(a),new t(e,n,i,r,u,s))},t}();oZ.prototype.childData=Object.freeze([]);function lZ(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)}function aZ(t){if(!t||t.length<=0)return function(t){return!0};var e="",n=t.filter((function(t){return t==t}));return n.length>0&&(e="\n switch (x) {"+n.map((function(t){return"\n case "+function(t){if("bigint"!=typeof t)return lZ(t);if(Am)return lZ(t)+"n";return'"'+lZ(t)+'"'}(t)+":"})).join("")+"\n return false;\n }"),t.length!==n.length&&(e="if (x !== x) return false;\n"+e),new Function("x",e+"\nreturn true;")}var sZ=function(t,e){return(t*e+63&-64||64)/e},uZ=function(){function t(t,e){void 0===e&&(e=1),this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=t.length/e|0)}return Object.defineProperty(t.prototype,"byteLength",{get:function(){return this.length*this.stride*this.BYTES_PER_ELEMENT|0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedLength",{get:function(){return this.buffer.length/this.stride},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedByteLength",{get:function(){return this.buffer.byteLength},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){return this},t.prototype.append=function(t){return this.set(this.length,t)},t.prototype.reserve=function(t){if(t>0){this.length+=t;var e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(sZ(0===i?1*n:2*n,this.BYTES_PER_ELEMENT))}return this},t.prototype.flush=function(t){void 0===t&&(t=this.length),t=sZ(t*this.stride,this.BYTES_PER_ELEMENT);var e,n,i=(e=this.buffer,void 0===(n=t)&&(n=0),e.length>=n?e.subarray(0,n):Xf(new e.constructor(n),e,0));return this.clear(),i},t.prototype.clear=function(){return this.length=0,this._resize(0),this},t.prototype._resize=function(t){return this.buffer=Xf(new this.ArrayType(t),this.buffer)},t}();uZ.prototype.offset=0;var cZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.last=function(){return this.get(this.length-1)},e.prototype.get=function(t){return this.buffer[t]},e.prototype.set=function(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this},e}(uZ),dZ=function(t){function e(e){void 0===e&&(e=new Uint8Array(0));var n=t.call(this,e,1/8)||this;return n.numValid=0,n}return gm(e,t),Object.defineProperty(e.prototype,"numInvalid",{get:function(){return this.length-this.numValid},enumerable:!1,configurable:!0}),e.prototype.get=function(t){return this.buffer[t>>3]>>t%8&1},e.prototype.set=function(t,e){var n=this.reserve(t-this.length+1).buffer,i=t>>3,r=t%8,o=n[i]>>r&1;return e?0===o&&(n[i]|=1<this.length&&this.set(e-1,0),t.prototype.flush.call(this,e+1)},e}(cZ),bZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),Object.defineProperty(e.prototype,"ArrayType64",{get:function(){return this._ArrayType64||(this._ArrayType64=this.buffer instanceof Int32Array?$m:rf)},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e){switch(this.reserve(t-this.length+1),typeof e){case"bigint":this.buffer64[t]=e;break;case"number":this.buffer[t*this.stride]=e;break;default:this.buffer.set(e,t*this.stride)}return this},e.prototype._resize=function(e){var n=t.prototype._resize.call(this,e),i=n.byteLength/(this.BYTES_PER_ELEMENT*this.stride);return Am&&(this.buffer64=new this.ArrayType64(n.buffer,n.byteOffset,i)),n},e}(uZ),pZ=function(){function t(t){var e=t.type,n=t.nullValues;this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=rZ(e),this._nulls=new dZ,n&&n.length>0&&(this._isValid=aZ(n))}return t.new=function(t){},t.throughNode=function(t){throw new Error('"throughNode" not available in this environment')},t.throughDOM=function(t){throw new Error('"throughDOM" not available in this environment')},t.throughIterable=function(t){return function(t){var e=t.queueingStrategy,n=void 0===e?"count":e,i=t.highWaterMark,r=void 0===i?"bytes"!==n?1e3:Math.pow(2,14):i,o="bytes"!==n?"length":"byteLength";return function(e){var n,i,l,a,s,u,c,d;return Km(this,(function(h){switch(h.label){case 0:n=0,i=pZ.new(t),h.label=1;case 1:h.trys.push([1,7,8,9]),l=Hm(e),a=l.next(),h.label=2;case 2:return a.done?[3,6]:(s=a.value,i.append(s)[o]>=r?++n?[4,i.toVector()]:[3,4]:[3,5]);case 3:h.sent(),h.label=4;case 4:h.label=5;case 5:return a=l.next(),[3,2];case 6:return[3,9];case 7:return u=h.sent(),c={error:u},[3,9];case 8:try{a&&!a.done&&(d=l.return)&&d.call(l)}finally{if(c)throw c.error}return[7];case 9:return i.finish().length>0||0===n?[4,i.toVector()]:[3,11];case 10:h.sent(),h.label=11;case 11:return[2]}}))}}(t)},t.throughAsyncIterable=function(t){return function(t){var e=t.queueingStrategy,n=void 0===e?"count":e,i=t.highWaterMark,r=void 0===i?"bytes"!==n?1e3:Math.pow(2,14):i,o="bytes"!==n?"length":"byteLength";return function(e){return Im(this,arguments,(function(){var n,i,l,a,s,u,c,d;return Km(this,(function(h){switch(h.label){case 0:n=0,i=pZ.new(t),h.label=1;case 1:h.trys.push([1,9,10,15]),l=Cm(e),h.label=2;case 2:return[4,_m(l.next())];case 3:return(a=h.sent()).done?[3,8]:(s=a.value,i.append(s)[o]>=r?++n?[4,_m(i.toVector())]:[3,6]:[3,7]);case 4:return[4,h.sent()];case 5:h.sent(),h.label=6;case 6:h.label=7;case 7:return[3,2];case 8:return[3,15];case 9:return u=h.sent(),c={error:u},[3,15];case 10:return h.trys.push([10,,13,14]),a&&!a.done&&(d=l.return)?[4,_m(d.call(l))]:[3,12];case 11:h.sent(),h.label=12;case 12:return[3,14];case 13:if(c)throw c.error;return[7];case 14:return[7];case 15:return i.finish().length>0||0===n?[4,_m(i.toVector())]:[3,18];case 16:return[4,h.sent()];case 17:h.sent(),h.label=18;case 18:return[2]}}))}))}}(t)},t.prototype.toVector=function(){return jf.new(this.flush())},Object.defineProperty(t.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullCount",{get:function(){return this._nulls.numInvalid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numChildren",{get:function(){return this.children.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"byteLength",{get:function(){var t=0;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),this._typeIds&&(t+=this._typeIds.byteLength),this.children.reduce((function(t,e){return t+e.byteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedLength",{get:function(){return this._nulls.reservedLength},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedByteLength",{get:function(){var t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((function(t,e){return t+e.reservedByteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueOffsets",{get:function(){return this._offsets?this._offsets.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"values",{get:function(){return this._values?this._values.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullBitmap",{get:function(){return this._nulls?this._nulls.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeIds",{get:function(){return this._typeIds?this._typeIds.buffer:null},enumerable:!1,configurable:!0}),t.prototype.append=function(t){return this.set(this.length,t)},t.prototype.isValid=function(t){return this._isValid(t)},t.prototype.set=function(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this},t.prototype.setValue=function(t,e){this._setValue(this,t,e)},t.prototype.setValid=function(t,e){return this.length=this._nulls.set(t,+e).length,e},t.prototype.addChild=function(t,e){throw void 0===e&&(e=""+this.numChildren),new Error('Cannot append children to non-nested type "'+this.type+'"')},t.prototype.getChildAt=function(t){return this.children[t]||null},t.prototype.flush=function(){var t=[],e=this._values,n=this._offsets,i=this._typeIds,r=this.length,o=this.nullCount;i?(t[Pf.TYPE]=i.flush(r),n&&(t[Pf.OFFSET]=n.flush(r))):n?(e&&(t[Pf.DATA]=e.flush(n.last())),t[Pf.OFFSET]=n.flush(r)):e&&(t[Pf.DATA]=e.flush(r)),o>0&&(t[Pf.VALIDITY]=this._nulls.flush(r));var l=oZ.new(this.type,0,r,o,t,this.children.map((function(t){return t.flush()})));return this.clear(),l},t.prototype.finish=function(){return this.finished=!0,this.children.forEach((function(t){return t.finish()})),this},t.prototype.clear=function(){return this.length=0,this._offsets&&this._offsets.clear(),this._values&&this._values.clear(),this._nulls&&this._nulls.clear(),this._typeIds&&this._typeIds.clear(),this.children.forEach((function(t){return t.clear()})),this},t}();pZ.prototype.length=1,pZ.prototype.stride=1,pZ.prototype.children=null,pZ.prototype.finished=!1,pZ.prototype.nullValues=null,pZ.prototype._isValid=function(){return!0};var mZ=function(t){function e(e){var n=t.call(this,e)||this;return n._values=new cZ(new n.ArrayType(0),n.stride),n}return gm(e,t),e.prototype.setValue=function(e,n){var i=this._values;return i.reserve(e-i.length+1),t.prototype.setValue.call(this,e,n)},e}(pZ),fZ=function(t){function e(e){var n=t.call(this,e)||this;return n._pendingLength=0,n._offsets=new hZ,n}return gm(e,t),e.prototype.setValue=function(t,e){var n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e.length,n.set(t,e)},e.prototype.setValid=function(e,n){return!!t.prototype.setValid.call(this,e,n)||((this._pending||(this._pending=new Map)).set(e,void 0),!1)},e.prototype.clear=function(){return this._pendingLength=0,this._pending=void 0,t.prototype.clear.call(this)},e.prototype.flush=function(){return this._flush(),t.prototype.flush.call(this)},e.prototype.finish=function(){return this._flush(),t.prototype.finish.call(this)},e.prototype._flush=function(){var t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this},e}(pZ);var yZ=function(t){function e(e){var n=t.call(this,e)||this;return n._values=new dZ,n}return gm(e,t),e.prototype.setValue=function(t,e){this._values.set(t,+e)},e}(pZ),ZZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.setValue=function(t,e){},e.prototype.setValid=function(t,e){return this.length=Math.max(t+1,this.length),e},e}(pZ),XZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(mZ),GZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(XZ),WZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(XZ),VZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(mZ),vZ=function(t){function e(e){var n=e.type,i=e.nullValues,r=e.dictionaryHashFunction,o=t.call(this,{type:new iZ(n.dictionary,n.indices,n.id,n.isOrdered)})||this;return o._nulls=null,o._dictionaryOffset=0,o._keysToIndices=Object.create(null),o.indices=pZ.new({type:o.type.indices,nullValues:i}),o.dictionary=pZ.new({type:o.type.dictionary,nullValues:null}),"function"==typeof r&&(o.valueToKey=r),o}return gm(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.indices.values},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){return this.indices.nullCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullBitmap",{get:function(){return this.indices.nullBitmap},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this.indices.byteLength+this.dictionary.byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reservedLength",{get:function(){return this.indices.reservedLength+this.dictionary.reservedLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reservedByteLength",{get:function(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength},enumerable:!1,configurable:!0}),e.prototype.isValid=function(t){return this.indices.isValid(t)},e.prototype.setValid=function(t,e){var n=this.indices;return e=n.setValid(t,e),this.length=n.length,e},e.prototype.setValue=function(t,e){var n=this._keysToIndices,i=this.valueToKey(e),r=n[i];return void 0===r&&(n[i]=r=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,r)},e.prototype.flush=function(){var t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i},e.prototype.finish=function(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),t.prototype.finish.call(this)},e.prototype.clear=function(){return this.indices.clear(),this.dictionary.clear(),t.prototype.clear.call(this)},e.prototype.valueToKey=function(t){return"string"==typeof t?t:""+t},e}(pZ),SZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(mZ),RZ=new Float64Array(1),gZ=new Uint32Array(RZ.buffer);function LZ(t){var e=(31744&t)>>10,n=(1023&t)/1024,i=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return i*(n?NaN:1/0);case 0:return i*(n?6103515625e-14*n:0)}return i*Math.pow(2,e-15)*(1+n)}function xZ(t){if(t!=t)return 32256;RZ[0]=t;var e=(2147483648&gZ[1])>>16&65535,n=2146435072&gZ[1],i=0;return n>=1089470464?gZ[0]>0?n=31744:(n=(2080374784&n)>>16,i=(1048575&gZ[1])>>10):n<=1056964608?(i=1048576+((i=1048576+(1048575&gZ[1]))<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,i=512+(1048575&gZ[1])>>10),e|n|65535&i}var YZ,KZ,HZ=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",uint16ToFloat64:LZ,float64ToUint16:xZ}),JZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(mZ),wZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.setValue=function(t,e){this._values.set(t,xZ(e))},e}(JZ),_Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.setValue=function(t,e){this._values.set(t,e)},e}(JZ),IZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.setValue=function(t,e){this._values.set(t,e)},e}(JZ),NZ=Symbol.for("isArrowBigNum");function CZ(t){for(var e,n=[],i=1;i>>=0),s+=(n>>>0)+e*Math.pow(u,32);return s}function TZ(t){var e="",n=new Uint32Array(2),i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),r=new Uint32Array((i=new Uint16Array(i).reverse()).buffer),o=-1,l=i.length-1;do{for(n[0]=i[o=0];o-1){var r;n.set(t,i),void 0!==(e=(r=this[WX]||(this[WX]=new Array(this.size)))[i])||(r[i]=e=this.getValue(i))}}return e},t.prototype.set=function(t,e){if(null!=t){var n=this[GX]||(this[GX]=new Map),i=n.get(t);if(void 0===i&&n.set(t,i=this.getIndex(t)),i>-1)(this[WX]||(this[WX]=new Array(this.size)))[i]=this.setValue(i,e)}return this},t.prototype.clear=function(){throw new Error("Clearing "+this[Symbol.toStringTag]+" not supported.")},t.prototype.delete=function(t){throw new Error("Deleting "+this[Symbol.toStringTag]+" values not supported.")},t.prototype[Symbol.iterator]=function(){var t,e,n,i,r,o,l,a,s;return Km(this,(function(u){switch(u.label){case 0:t=this.keys(),e=this.values(),n=this[GX]||(this[GX]=new Map),i=this[WX]||(this[WX]=new Array(this.size)),r=void 0,o=void 0,l=0,a=void 0,s=void 0,u.label=1;case 1:return(a=t.next()).done||(s=e.next()).done?[3,4]:(r=a.value,o=s.value,i[l]=o,n.has(r)||n.set(r,l),[4,[r,o]]);case 2:u.sent(),u.label=3;case 3:return++l,[3,1];case 4:return[2]}}))},t.prototype.forEach=function(t,e){for(var n=this.keys(),i=this.values(),r=void 0===e?t:function(n,i,r){return t.call(e,n,i,r)},o=this[GX]||(this[GX]=new Map),l=this[WX]||(this[WX]=new Array(this.size)),a=void 0,s=void 0,u=0,c=void 0,d=void 0;!(c=n.next()).done&&!(d=i.next()).done;++u)a=c.value,s=d.value,l[u]=s,o.has(a)||o.set(a,u),r(s,a,this)},t.prototype.toArray=function(){return wm(this.values())},t.prototype.toJSON=function(){var t={};return this.forEach((function(e,n){return t[n]=e})),t},t.prototype.inspect=function(){return this.toString()},t.prototype[VX]=function(){return this.toString()},t.prototype.toString=function(){var t=[];return this.forEach((function(e,n){n=lZ(n),e=lZ(e),t.push(n+": "+e)})),"{ "+t.join(", ")+" }"},t[Symbol.toStringTag]=function(t){var e;return Object.defineProperties(t,((e={size:{writable:!0,enumerable:!1,configurable:!1,value:0}})[ZX]={writable:!0,enumerable:!1,configurable:!1,value:null},e[XX]={writable:!0,enumerable:!1,configurable:!1,value:-1},e)),t[Symbol.toStringTag]="Row"}(t.prototype),t}(),SX=function(t){function e(e){var n=t.call(this,e,e.length)||this;return YX(n)}return gm(e,t),e.prototype.keys=function(){return this[ZX].getChildAt(0)[Symbol.iterator]()},e.prototype.values=function(){return this[ZX].getChildAt(1)[Symbol.iterator]()},e.prototype.getKey=function(t){return this[ZX].getChildAt(0).get(t)},e.prototype.getIndex=function(t){return this[ZX].getChildAt(0).indexOf(t)},e.prototype.getValue=function(t){return this[ZX].getChildAt(1).get(t)},e.prototype.setValue=function(t,e){this[ZX].getChildAt(1).set(t,e)},e}(vX),RX=function(t){function e(e){var n=t.call(this,e,e.type.children.length)||this;return xX(n)}return gm(e,t),e.prototype.keys=function(){var t,e,n,i,r;return Km(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Hm(this[ZX].type.children),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[4,e.value.name];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.values=function(){var t,e,n,i,r;return Km(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Hm(this[ZX].type.children),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[4,this[e.value.name]];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.getKey=function(t){return this[ZX].type.children[t].name},e.prototype.getIndex=function(t){return this[ZX].type.children.findIndex((function(e){return e.name===t}))},e.prototype.getValue=function(t){return this[ZX].getChildAt(t).get(this[XX])},e.prototype.setValue=function(t,e){return this[ZX].getChildAt(t).set(this[XX],e)},e}(vX);Object.setPrototypeOf(vX.prototype,Map.prototype);var gX,LX,xX=(gX={enumerable:!0,configurable:!1,get:null,set:null},function(t){var e,n,i=-1,r=t[GX]||(t[GX]=new Map),o=function(t){return function(){return this.get(t)}},l=function(t){return function(e){return this.set(t,e)}};try{for(var a=Hm(t.keys()),s=a.next();!s.done;s=a.next()){var u=s.value;r.set(u,++i),gX.get=o(u),gX.set=l(u),t.hasOwnProperty(u)||(gX.enumerable=!0,Object.defineProperty(t,u,gX)),t.hasOwnProperty(i)||(gX.enumerable=!1,Object.defineProperty(t,i,gX))}}catch(c){e={error:c}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return gX.get=gX.set=null,t}),YX=function(){if("undefined"==typeof Proxy)return xX;var t=vX.prototype.has,e=vX.prototype.get,n=vX.prototype.set,i=vX.prototype.getKey,r={isExtensible:function(){return!1},deleteProperty:function(){return!1},preventExtensions:function(){return!0},ownKeys:function(t){return wm(t.keys()).map((function(t){return""+t}))},has:function(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 ZX:case XX:case WX:case GX:case VX:return!0}return"number"!=typeof e||t.has(e)||(e=t.getKey(e)),t.has(e)},get:function(n,r,o){switch(r){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 ZX:case XX:case WX:case GX:case VX:return Reflect.get(n,r,o)}return"number"!=typeof r||t.call(o,r)||(r=i.call(o,r)),e.call(o,r)},set:function(e,r,o,l){switch(r){case ZX:case XX:case WX:case GX:return Reflect.set(e,r,o,l);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 r||t.call(l,r)||(r=i.call(l,r)),!!t.call(l,r)&&!!n.call(l,r,o)}};return function(t){return new Proxy(t,r)}}();function KX(t,e,n,i){var r=t.length,o=void 0===r?0:r,l="number"!=typeof e?0:e,a="number"!=typeof n?o:n;return l<0&&(l=(l%o+o)%o),a<0&&(a=(a%o+o)%o),ao&&(a=o),i?i(t,l,a):[l,a]}var HX=Am?Om(0):0,JX=function(t){return t!=t};function wX(t){var e=typeof t;if("object"!==e||null===t)return JX(t)?JX:"bigint"!==e?function(e){return e===t}:function(e){return HX+e===t};if(t instanceof Date){var n=t.valueOf();return function(t){return t instanceof Date&&t.valueOf()===n}}return ArrayBuffer.isView(t)?function(e){return!!e&&Jf(t,e)}:t instanceof Map?function(t){var e=-1,n=[];return t.forEach((function(t){return n[++e]=wX(t)})),_X(n)}(t):Array.isArray(t)?function(t){for(var e=[],n=-1,i=t.length;++n-1?e:i+e%i;return n?n(t,r):r},clampRange:KX,createElementComparator:wX}),CX=function(t){function e(e,n,i){void 0===n&&(n=[]),void 0===i&&(i=function(t){for(var e=new Uint32Array((t||[]).length+1),n=e[0]=0,i=e.length,r=0;++r"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this._chunks[0]?this._chunks[0].data:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this._type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numChildren",{get:function(){return this._numChildren},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this._chunks[0]?this._chunks[0].stride:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this._chunks.reduce((function(t,e){return t+e.byteLength}),0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){var t=this._nullCount;return t<0&&(this._nullCount=t=this._chunks.reduce((function(t,e){return t+e.nullCount}),0)),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){if(Ry.isDictionary(this._type)){if(!this._indices){var t=this._chunks;this._indices=1===t.length?t[0].indices:e.concat.apply(e,wm(t.map((function(t){return t.indices}))))}return this._indices}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dictionary",{get:function(){return Ry.isDictionary(this._type)?this._chunks[this._chunks.length-1].data.dictionary:null},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var t,e,n,i,r;return Km(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Hm(this._chunks),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[5,Hm(e.value)];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.clone=function(t){return void 0===t&&(t=this._chunks),new e(this._type,t)},e.prototype.concat=function(){for(var t=[],n=0;n=this._numChildren)return null;var n,i,r,o=this._children||(this._children=[]);return(n=o[t])?n:(i=(this._type.children||[])[t])&&(r=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}))).length>0?o[t]=new e(i.type,r):null},e.prototype.search=function(t,e){var n=t,i=this._chunkOffsets,r=i.length-1;if(n<0)return null;if(n>=i[r])return null;if(r<=1)return e?e(this,0,n):[0,n];var o=0,l=0,a=0;do{if(o+1===r)return e?e(this,o,n-l):[o,n-l];n>=i[a=o+(r-o)/2|0]?o=a:r=a}while(n=(l=i[o]));return null},e.prototype.isValid=function(t){return!!this.search(t,this.isValidInternal)},e.prototype.get=function(t){return this.search(t,this.getInternal)},e.prototype.set=function(t,e){this.search(t,(function(t,n,i){return t.chunks[n].set(i,e)}))},e.prototype.indexOf=function(t,e){var n=this;return e&&"number"==typeof e?this.search(e,(function(e,i,r){return n.indexOfInternal(e,i,r,t)})):this.indexOfInternal(this,0,Math.max(0,e||0),t)},e.prototype.toArray=function(){var t=this.chunks,e=t.length,n=this._type.ArrayType;if(e<=0)return new n(0);if(e<=1)return t[0].toArray();for(var i=0,r=new Array(e),o=-1;++o=n)break;if(!(e>=c+u))if(c>=e&&c+u<=n)i.push(s);else{var d=Math.max(0,e-c),h=Math.min(n-c,u);i.push(s.slice(d,h))}}return t.clone(i)},e}(jf);var UX=function(t,e,n){return e.set(t,n),n+t.length},FX=function(t,e,n){for(var i=n,r=-1,o=t.length;++r0}))&&(r=r.clone({nullable:!0}));return new e(r,a)},Object.defineProperty(e.prototype,"field",{get:function(){return this._field},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._field.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullable",{get:function(){return this._field.nullable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this._field.metadata},enumerable:!1,configurable:!0}),e.prototype.clone=function(t){return void 0===t&&(t=this._chunks),new e(this._field,t)},e.prototype.getChildAt=function(t){if(t<0||t>=this.numChildren)return null;var n,i,r,o=this._children||(this._children=[]);return(n=o[t])?n:(i=(this.type.children||[])[t])&&(r=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}))).length>0?o[t]=new e(i,r):null},e}(CX),kX=function(t){function e(e,n,i){var r=t.call(this,e,[n],i)||this;return r._chunk=n,r}return gm(e,t),e.prototype.search=function(t,e){return e?e(this,0,t):[0,t]},e.prototype.isValid=function(t){return this._chunk.isValid(t)},e.prototype.get=function(t){return this._chunk.get(t)},e.prototype.set=function(t,e){this._chunk.set(t,e)},e.prototype.indexOf=function(t,e){return this._chunk.indexOf(t,e)},e}(BX),TX=Array.isArray,zX=function(t,e){return DX(t,e,[],0)},MX=function(t){var e=Jm(tG(t,[[],[]]),2),n=e[0];return e[1].map((function(t,e){return t instanceof BX?BX.new(t.field.clone(n[e]),t):t instanceof jf?BX.new(n[e],t):BX.new(n[e],[])}))},jX=function(t){return tG(t,[[],[]])},QX=function(t,e){return OX(t,e,[],0)},PX=function(t,e){return AX(t,e,[],0)},EX=function(t,e){return qX(t,e,[],0)};function DX(t,e,n,i){for(var r,o=i,l=-1,a=e.length;++l"},t.prototype.compareTo=function(t){return Sy.compareSchemas(this,t)},t.prototype.select=function(){for(var e=[],n=0;n0&&rG(r.children,e)}return e}eG.prototype.fields=null,eG.prototype.metadata=null,eG.prototype.dictionaries=null,nG.prototype.type=null,nG.prototype.name=null,nG.prototype.nullable=null,nG.prototype.metadata=null;var oG=function(t){function e(e){var n=t.call(this,e)||this;return n._run=new yX,n._offsets=new hZ,n}return gm(e,t),e.prototype.addChild=function(t,e){if(void 0===e&&(e="0"),this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Oy(new nG(e,t.type,!0)),this.numChildren-1},e.prototype.clear=function(){return this._run.clear(),t.prototype.clear.call(this)},e.prototype._flushPending=function(t){var e,n,i,r,o=this._run,l=this._offsets,a=this._setValue,s=0;try{for(var u=Hm(t),c=u.next();!c.done;c=u.next())s=(i=Jm(c.value,2))[0],void 0===(r=i[1])?l.set(s,0):(l.set(s,r.length),a(this,s,o.bind(r)))}catch(d){e={error:d}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e}(fZ),lG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._run=new yX,e}return gm(e,t),e.prototype.setValue=function(e,n){t.prototype.setValue.call(this,e,this._run.bind(n))},e.prototype.addChild=function(t,e){if(void 0===e&&(e="0"),this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");var n=this.children.push(t);return this.type=new tZ(this.type.listSize,new nG(e,t.type,!0)),n},e.prototype.clear=function(){return this._run.clear(),t.prototype.clear.call(this)},e}(pZ),aG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.set=function(e,n){return t.prototype.set.call(this,e,n)},e.prototype.setValue=function(t,e){e=e instanceof Map?e:new Map(Object.entries(e));var n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.size),this._pendingLength+=e.size,n.set(t,e)},e.prototype.addChild=function(t,e){if(void 0===e&&(e=""+this.numChildren),this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new eZ(new nG(e,t.type,!0),this.type.keysSorted),this.numChildren-1},e.prototype._flushPending=function(t){var e=this,n=this._offsets,i=this._setValue;t.forEach((function(t,r){void 0===t?n.set(r,0):(n.set(r,t.size),i(e,r,t))}))},e}(fZ),sG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.addChild=function(t,e){void 0===e&&(e=""+this.numChildren);var n=this.children.push(t);return this.type=new Ay(wm(this.type.children,[new nG(e,t.type,!0)])),n},e}(pZ),uG=function(t){function e(e){var n=t.call(this,e)||this;return n._typeIds=new cZ(new Int8Array(0),1),"function"==typeof e.valueToChildTypeId&&(n._valueToChildTypeId=e.valueToChildTypeId),n}return gm(e,t),Object.defineProperty(e.prototype,"typeIdToChildIndex",{get:function(){return this.type.typeIdToChildIndex},enumerable:!1,configurable:!0}),e.prototype.append=function(t,e){return this.set(this.length,t,e)},e.prototype.set=function(t,e,n){return void 0===n&&(n=this._valueToChildTypeId(this,e,t)),this.setValid(t,this.isValid(e))&&this.setValue(t,e,n),this},e.prototype.setValue=function(e,n,i){this._typeIds.set(e,i),t.prototype.setValue.call(this,e,n)},e.prototype.addChild=function(t,e){void 0===e&&(e=""+this.children.length);var n=this.children.push(t),i=this.type,r=i.children,o=i.mode,l=i.typeIds,a=wm(r,[new nG(e,t.type)]);return this.type=new qy(o,wm(l,[n]),a),n},e.prototype._valueToChildTypeId=function(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")},e}(pZ),cG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(uG),dG=function(t){function e(e){var n=t.call(this,e)||this;return n._offsets=new cZ(new Int32Array(0)),n}return gm(e,t),e.prototype.setValue=function(e,n,i){var r=this.type.typeIdToChildIndex[i];return this._offsets.set(e,this.getChildAt(r).length),t.prototype.setValue.call(this,e,n,i)},e}(uG),hG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(hy),bG=function(t,e,n){t[e]=n%4294967296|0,t[e+1]=n/4294967296|0},pG=function(t,e,n,i){var r=e,o=r[n],l=r[n+1];null!=o&&null!=l&&t.set(i.subarray(0,l-o),o)},mG=function(t,e,n){!function(t,e,n){t[e]=n/864e5|0}(t.values,e,n.valueOf())},fG=function(t,e,n){var i=t.values;bG(i,2*e,n.valueOf())},yG=function(t,e,n){var i=t.stride;t.values[i*e]=n},ZG=function(t,e,n){var i=t.stride;t.values[i*e]=xZ(n)},XG=function(t,e,n){switch(typeof n){case"bigint":t.values64[e]=n;break;case"number":t.values[e*t.stride]=n;break;default:var i=n,r=t.stride,o=Wf(t.ArrayType,i);t.values.set(o.subarray(0,r),r*e)}},GG=function(t,e,n){var i=t.values;return bG(i,2*e,n/1e3)},WG=function(t,e,n){var i=t.values;return bG(i,2*e,n)},VG=function(t,e,n){return function(t,e,n){t[e]=1e3*n%4294967296|0,t[e+1]=1e3*n/4294967296|0}(t.values,2*e,n)},vG=function(t,e,n){return function(t,e,n){t[e]=1e6*n%4294967296|0,t[e+1]=1e6*n/4294967296|0}(t.values,2*e,n)},SG=function(t,e,n){t.values[t.stride*e]=n},RG=function(t,e,n){t.values[t.stride*e]=n},gG=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},LG=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},xG=function(t,e,n){var i=t.typeIdToChildIndex[t.typeIds[e]],r=t.getChildAt(i);r&&r.set(t.valueOffsets[e],n)},YG=function(t,e,n){var i=t.typeIdToChildIndex[t.typeIds[e]],r=t.getChildAt(i);r&&r.set(e,n)},KG=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},HG=function(t,e,n){t.values[e]=12*n[0]+n[1]%12};hG.prototype.visitBool=function(t,e,n){var i=t.offset,r=t.values,o=i+e;n?r[o>>3]|=1<>3]&=~(1<0){var r=e.children||[],o={nullValues:e.nullValues},l=Array.isArray(r)?function(t,e){return r[e]||o}:function(t){var e=t.name;return r[e]||o};n.children.forEach((function(e,n){var r=e.type,o=l(e,n);i.children.push(t(Lm(Lm({},o),{type:r})))}))}return i},Object.keys(Qf).map((function(t){return Qf[t]})).filter((function(t){return"number"==typeof t&&t!==Qf.NONE})).forEach((function(t){_G.visit(t).prototype._setValue=wG.getVisitFn(t)})),fX.prototype._setValue=wG.visitBinary,function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsFooter=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.version=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ff.apache.arrow.flatbuf.MetadataVersion.V1},e.prototype.schema=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ff.apache.arrow.flatbuf.Schema).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},e.prototype.dictionaries=function(e,n){var i=this.bb.__offset(this.bb_pos,8);return i?(n||new t.apache.arrow.flatbuf.Block).__init(this.bb.__vector(this.bb_pos+i)+24*e,this.bb):null},e.prototype.dictionariesLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.recordBatches=function(e,n){var i=this.bb.__offset(this.bb_pos,10);return i?(n||new t.apache.arrow.flatbuf.Block).__init(this.bb.__vector(this.bb_pos+i)+24*e,this.bb):null},e.prototype.recordBatchesLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startFooter=function(t){t.startObject(4)},e.addVersion=function(t,e){t.addFieldInt16(0,e,Ff.apache.arrow.flatbuf.MetadataVersion.V1)},e.addSchema=function(t,e){t.addFieldOffset(1,e,0)},e.addDictionaries=function(t,e){t.addFieldOffset(2,e,0)},e.startDictionariesVector=function(t,e){t.startVector(24,e,8)},e.addRecordBatches=function(t,e){t.addFieldOffset(3,e,0)},e.startRecordBatchesVector=function(t,e){t.startVector(24,e,8)},e.endFooter=function(t){return t.endObject()},e.finishFooterBuffer=function(t,e){t.finish(e)},e.createFooter=function(t,n,i,r,o){return e.startFooter(t),e.addVersion(t,n),e.addSchema(t,i),e.addDictionaries(t,r),e.addRecordBatches(t,o),e.endFooter(t)},e}();e.Footer=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(JG||(JG={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.offset=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.metaDataLength=function(){return this.bb.readInt32(this.bb_pos+8)},t.prototype.bodyLength=function(){return this.bb.readInt64(this.bb_pos+16)},t.createBlock=function(t,e,n,i){return t.prep(8,24),t.writeInt64(i),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()},t}();t.Block=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(JG||(JG={}));var IG=Um.Long,NG=Um.Builder,CG=Um.ByteBuffer,UG=JG.apache.arrow.flatbuf.Block,FG=JG.apache.arrow.flatbuf.Footer,BG=function(){function t(t,e,n,i){void 0===e&&(e=ey.V4),this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}return t.decode=function(t){t=new CG(Sf(t));var e=FG.getRootAsFooter(t),n=eG.decode(e.schema());return new kG(n,e)},t.encode=function(t){var e=new NG,n=eG.encode(e,t.schema);FG.startRecordBatchesVector(e,t.numRecordBatches),wm(t.recordBatches()).slice().reverse().forEach((function(t){return TG.encode(e,t)}));var i=e.endVector();FG.startDictionariesVector(e,t.numDictionaries),wm(t.dictionaryBatches()).slice().reverse().forEach((function(t){return TG.encode(e,t)}));var r=e.endVector();return FG.startFooter(e),FG.addSchema(e,n),FG.addVersion(e,ey.V4),FG.addRecordBatches(e,i),FG.addDictionaries(e,r),FG.finishFooterBuffer(e,FG.endFooter(e)),e.asUint8Array()},Object.defineProperty(t.prototype,"numRecordBatches",{get:function(){return this._recordBatches.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numDictionaries",{get:function(){return this._dictionaryBatches.length},enumerable:!1,configurable:!0}),t.prototype.recordBatches=function(){var t,e,n;return Km(this,(function(i){switch(i.label){case 0:t=void 0,e=-1,n=this.numRecordBatches,i.label=1;case 1:return++e=0&&t=0&&t=0&&t=0&&t0)return t.prototype.write.call(this,e)},e.prototype.toString=function(t){return void 0===t&&(t=!1),t?zm(this.toUint8Array(!0)):this.toUint8Array(!1).then(zm)},e.prototype.toUint8Array=function(t){var e=this;return void 0===t&&(t=!1),t?Gf(this._values)[0]:Ym(e,void 0,void 0,(function(){var t,e,n,i,r,o,l,a;return Km(this,(function(s){switch(s.label){case 0:t=[],e=0,s.label=1;case 1:s.trys.push([1,6,7,12]),n=Cm(this),s.label=2;case 2:return[4,n.next()];case 3:if((i=s.sent()).done)return[3,5];r=i.value,t.push(r),e+=r.byteLength,s.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return o=s.sent(),l={error:o},[3,12];case 7:return s.trys.push([7,,10,11]),i&&!i.done&&(a=n.return)?[4,a.call(n)]:[3,9];case 8:s.sent(),s.label=9;case 9:return[3,11];case 10:if(l)throw l.error;return[7];case 11:return[7];case 12:return[2,Gf(t,e)[0]]}}))}))},e}(Em),MG=function(){function t(t){t&&(this.source=new QG(_f.fromIterable(t)))}return t.prototype[Symbol.iterator]=function(){return this},t.prototype.next=function(t){return this.source.next(t)},t.prototype.throw=function(t){return this.source.throw(t)},t.prototype.return=function(t){return this.source.return(t)},t.prototype.peek=function(t){return this.source.peek(t)},t.prototype.read=function(t){return this.source.read(t)},t}(),jG=function(){function t(e){e instanceof t?this.source=e.source:e instanceof zG?this.source=new PG(_f.fromAsyncIterable(e)):ff(e)?this.source=new PG(_f.fromNodeStream(e)):mf(e)?this.source=new PG(_f.fromDOMStream(e)):pf(e)?this.source=new PG(_f.fromDOMStream(e.body)):uf(e)?this.source=new PG(_f.fromIterable(e)):(sf(e)||cf(e))&&(this.source=new PG(_f.fromAsyncIterable(e)))}return t.prototype[Symbol.asyncIterator]=function(){return this},t.prototype.next=function(t){return this.source.next(t)},t.prototype.throw=function(t){return this.source.throw(t)},t.prototype.return=function(t){return this.source.return(t)},Object.defineProperty(t.prototype,"closed",{get:function(){return this.source.closed},enumerable:!1,configurable:!0}),t.prototype.cancel=function(t){return this.source.cancel(t)},t.prototype.peek=function(t){return this.source.peek(t)},t.prototype.read=function(t){return this.source.read(t)},t}(),QG=function(){function t(t){this.source=t}return t.prototype.cancel=function(t){this.return(t)},t.prototype.peek=function(t){return this.next(t,"peek").value},t.prototype.read=function(t){return this.next(t,"read").value},t.prototype.next=function(t,e){return void 0===e&&(e="read"),this.source.next({cmd:e,size:t})},t.prototype.throw=function(t){return Object.create(this.source.throw&&this.source.throw(t)||jm)},t.prototype.return=function(t){return Object.create(this.source.return&&this.source.return(t)||jm)},t}(),PG=function(){function t(t){var e=this;this.source=t,this._closedPromise=new Promise((function(t){return e._closedPromiseResolve=t}))}return t.prototype.cancel=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.return(t)];case 1:return e.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"closed",{get:function(){return this._closedPromise},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"read")];case 1:return[2,e.sent().value]}}))}))},t.prototype.peek=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"peek")];case 1:return[2,e.sent().value]}}))}))},t.prototype.next=function(t,e){return void 0===e&&(e="read"),Ym(this,void 0,void 0,(function(){return Km(this,(function(n){switch(n.label){case 0:return[4,this.source.next({cmd:e,size:t})];case 1:return[2,n.sent()]}}))}))},t.prototype.throw=function(t){return Ym(this,void 0,void 0,(function(){var e,n;return Km(this,(function(i){switch(i.label){case 0:return(n=this.source.throw)?[4,this.source.throw(t)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return e=n||jm,this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,[2,Object.create(e)]}}))}))},t.prototype.return=function(t){return Ym(this,void 0,void 0,(function(){var e,n;return Km(this,(function(i){switch(i.label){case 0:return(n=this.source.return)?[4,this.source.return(t)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return e=n||jm,this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,[2,Object.create(e)]}}))}))},t}(),EG=function(t){function e(e,n){var i=t.call(this)||this;return i.position=0,i.buffer=Sf(e),i.size=void 0===n?i.buffer.byteLength:n,i}return gm(e,t),e.prototype.readInt32=function(t){var e=this.readAt(t,4),n=e.buffer,i=e.byteOffset;return new DataView(n,i).getInt32(0,!0)},e.prototype.seek=function(t){return 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]]),i=e[3]*n[3];this.buffer[0]=65535&i;var r=i>>>16;return r+=i=e[2]*n[3],r+=i=e[3]*n[2]>>>0,this.buffer[0]+=r<<16,this.buffer[1]=r>>>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},t.prototype._plus=function(t){var e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e},t.prototype.lessThan=function(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},t.prototype.hex=function(){return OG(this.buffer[3])+" "+OG(this.buffer[2])+" "+OG(this.buffer[1])+" "+OG(this.buffer[0])},t.multiply=function(e,n){return new t(new Uint32Array(e.buffer)).times(n)},t.add=function(e,n){return new t(new Uint32Array(e.buffer)).plus(n)},t.from=function(e,n){return void 0===n&&(n=new Uint32Array(4)),t.fromString("string"==typeof e?e:e.toString(),n)},t.fromNumber=function(e,n){return void 0===n&&(n=new Uint32Array(4)),t.fromString(e.toString(),n)},t.fromString=function(e,n){void 0===n&&(n=new Uint32Array(4));for(var i=e.startsWith("-"),r=e.length,o=new t(n),l=i?1:0;l0&&this.readData(t,n)||new Uint8Array(0)},e.prototype.readOffsets=function(t,e){return this.readData(t,e)},e.prototype.readTypeIds=function(t,e){return this.readData(t,e)},e.prototype.readData=function(t,e){var n=void 0===e?this.nextBufferRange():e,i=n.length,r=n.offset;return this.bytes.subarray(r,r+i)},e.prototype.readDictionary=function(t){return this.dictionaries.get(t.id)},e}(hy),rW=function(t){function e(e,n,i,r){var o=t.call(this,new Uint8Array(0),n,i,r)||this;return o.sources=e,o}return gm(e,t),e.prototype.readNullBitmap=function(t,e,n){var i=(void 0===n?this.nextBufferRange():n).offset;return e<=0?new Uint8Array(0):ly(this.sources[i])},e.prototype.readOffsets=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset;return Wf(Uint8Array,Wf(Int32Array,this.sources[n]))},e.prototype.readTypeIds=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset;return Wf(Uint8Array,Wf(t.ArrayType,this.sources[n]))},e.prototype.readData=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset,i=this.sources;return Ry.isTimestamp(t)||(Ry.isInt(t)||Ry.isTime(t))&&64===t.bitWidth||Ry.isDate(t)&&t.unit===Df.MILLISECOND?Wf(Uint8Array,tW.convertArray(i[n])):Ry.isDecimal(t)?Wf(Uint8Array,eW.convertArray(i[n])):Ry.isBinary(t)||Ry.isFixedSizeBinary(t)?function(t){for(var e=t.join(""),n=new Uint8Array(e.length/2),i=0;i>1]=parseInt(e.substr(i,2),16);return n}(i[n]):Ry.isBool(t)?ly(i[n]):Ry.isUtf8(t)?Mm(i[n].join("")):Wf(Uint8Array,Wf(t.ArrayType,i[n].map((function(t){return+t}))))},e}(iW);var oW=Um.Long,lW=Ff.apache.arrow.flatbuf.Null,aW=Ff.apache.arrow.flatbuf.Int,sW=Ff.apache.arrow.flatbuf.FloatingPoint,uW=Ff.apache.arrow.flatbuf.Binary,cW=Ff.apache.arrow.flatbuf.Bool,dW=Ff.apache.arrow.flatbuf.Utf8,hW=Ff.apache.arrow.flatbuf.Decimal,bW=Ff.apache.arrow.flatbuf.Date,pW=Ff.apache.arrow.flatbuf.Time,mW=Ff.apache.arrow.flatbuf.Timestamp,fW=Ff.apache.arrow.flatbuf.Interval,yW=Ff.apache.arrow.flatbuf.List,ZW=Ff.apache.arrow.flatbuf.Struct_,XW=Ff.apache.arrow.flatbuf.Union,GW=Ff.apache.arrow.flatbuf.DictionaryEncoding,WW=Ff.apache.arrow.flatbuf.FixedSizeBinary,VW=Ff.apache.arrow.flatbuf.FixedSizeList,vW=Ff.apache.arrow.flatbuf.Map,SW=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.visit=function(e,n){return null==e||null==n?void 0:t.prototype.visit.call(this,e,n)},e.prototype.visitNull=function(t,e){return lW.startNull(e),lW.endNull(e)},e.prototype.visitInt=function(t,e){return aW.startInt(e),aW.addBitWidth(e,t.bitWidth),aW.addIsSigned(e,t.isSigned),aW.endInt(e)},e.prototype.visitFloat=function(t,e){return sW.startFloatingPoint(e),sW.addPrecision(e,t.precision),sW.endFloatingPoint(e)},e.prototype.visitBinary=function(t,e){return uW.startBinary(e),uW.endBinary(e)},e.prototype.visitBool=function(t,e){return cW.startBool(e),cW.endBool(e)},e.prototype.visitUtf8=function(t,e){return dW.startUtf8(e),dW.endUtf8(e)},e.prototype.visitDecimal=function(t,e){return hW.startDecimal(e),hW.addScale(e,t.scale),hW.addPrecision(e,t.precision),hW.endDecimal(e)},e.prototype.visitDate=function(t,e){return bW.startDate(e),bW.addUnit(e,t.unit),bW.endDate(e)},e.prototype.visitTime=function(t,e){return pW.startTime(e),pW.addUnit(e,t.unit),pW.addBitWidth(e,t.bitWidth),pW.endTime(e)},e.prototype.visitTimestamp=function(t,e){var n=t.timezone&&e.createString(t.timezone)||void 0;return mW.startTimestamp(e),mW.addUnit(e,t.unit),void 0!==n&&mW.addTimezone(e,n),mW.endTimestamp(e)},e.prototype.visitInterval=function(t,e){return fW.startInterval(e),fW.addUnit(e,t.unit),fW.endInterval(e)},e.prototype.visitList=function(t,e){return yW.startList(e),yW.endList(e)},e.prototype.visitStruct=function(t,e){return ZW.startStruct_(e),ZW.endStruct_(e)},e.prototype.visitUnion=function(t,e){XW.startTypeIdsVector(e,t.typeIds.length);var n=XW.createTypeIdsVector(e,t.typeIds);return XW.startUnion(e),XW.addMode(e,t.mode),XW.addTypeIds(e,n),XW.endUnion(e)},e.prototype.visitDictionary=function(t,e){var n=this.visit(t.indices,e);return GW.startDictionaryEncoding(e),GW.addId(e,new oW(t.id,0)),GW.addIsOrdered(e,t.isOrdered),void 0!==n&&GW.addIndexType(e,n),GW.endDictionaryEncoding(e)},e.prototype.visitFixedSizeBinary=function(t,e){return WW.startFixedSizeBinary(e),WW.addByteWidth(e,t.byteWidth),WW.endFixedSizeBinary(e)},e.prototype.visitFixedSizeList=function(t,e){return VW.startFixedSizeList(e),VW.addListSize(e,t.listSize),VW.endFixedSizeList(e)},e.prototype.visitMap=function(t,e){return vW.startMap(e),vW.addKeysSorted(e,t.keysSorted),vW.endMap(e)},e}(hy));function RW(t){return new QW(t.count,LW(t.columns),xW(t.columns))}function gW(t,e){return(t.children||[]).filter(Boolean).map((function(t){return nG.fromJSON(t,e)}))}function LW(t){return(t||[]).reduce((function(t,e){return wm(t,[new DW(e.count,(n=e.VALIDITY,(n||[]).reduce((function(t,e){return t+ +(0===e)}),0)))],LW(e.children));var n}),[])}function xW(t,e){void 0===e&&(e=[]);for(var n=-1,i=(t||[]).length;++n0?NW.createCustomMetadataVector(t,wm(e.metadata).map((function(e){var n=Jm(e,2),i=n[0],r=n[1],o=t.createString(""+i),l=t.createString(""+r);return BW.startKeyValue(t),BW.addKey(t,o),BW.addValue(t,l),BW.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));NW.startField(t),NW.addType(t,i),NW.addTypeType(t,l),NW.addChildren(t,s),NW.addNullable(t,!!e.nullable),-1!==n&&NW.addName(t,n);-1!==r&&NW.addDictionary(t,r);-1!==u&&NW.addCustomMetadata(t,u);return NW.endField(t)},nG.decode=function(t,e){var n,i,r,o,l,a;e&&(a=t.dictionary())?e.has(n=a.id().low)?(o=(o=a.indexType())?qW(o):new Ky,l=new iZ(e.get(n),o,n,a.isOrdered()),i=new nG(t.name(),l,t.nullable(),AW(t))):(o=(o=a.indexType())?qW(o):new Ky,e.set(n,r=$W(t,OW(t,e))),l=new iZ(r,o,n,a.isOrdered()),i=new nG(t.name(),l,t.nullable(),AW(t))):(r=$W(t,OW(t,e)),i=new nG(t.name(),r,t.nullable(),AW(t)));return i||null},nG.fromJSON=function(t,e){var n,i,r,o,l,a;return e&&(o=t.dictionary)?e.has(n=o.id)?(i=(i=o.indexType)?KW(i):new Ky,a=new iZ(e.get(n),i,n,o.isOrdered),r=new nG(t.name,a,t.nullable,YW(t.customMetadata))):(i=(i=o.indexType)?KW(i):new Ky,e.set(n,l=HW(t,gW(t,e))),a=new iZ(l,i,n,o.isOrdered),r=new nG(t.name,a,t.nullable,YW(t.customMetadata))):(l=HW(t,gW(t,e)),r=new nG(t.name,l,t.nullable,YW(t.customMetadata))),r||null},eG.encode=function(t,e){var n=e.fields.map((function(e){return nG.encode(t,e)}));CW.startFieldsVector(t,n.length);var i=CW.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?CW.createCustomMetadataVector(t,wm(e.metadata).map((function(e){var n=Jm(e,2),i=n[0],r=n[1],o=t.createString(""+i),l=t.createString(""+r);return BW.startKeyValue(t),BW.addKey(t,o),BW.addValue(t,l),BW.endKeyValue(t)}))):-1;CW.startSchema(t),CW.addFields(t,i),CW.addEndianness(t,eV?TW.Little:TW.Big),-1!==r&&CW.addCustomMetadata(t,r);return CW.endSchema(t)},eG.decode=function(t,e){void 0===e&&(e=new Map);var n=function(t,e){for(var n=[],i=void 0,r=-1,o=-1,l=t.fieldsLength();++r2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");Ry.isNull(e.type)||ZV.call(this,r<=0?new Uint8Array(0):oy(n.offset,i,n.nullBitmap)),this.nodes.push(new DW(i,r))}return t.prototype.visit.call(this,e)},e.prototype.visitNull=function(t){return this},e.prototype.visitDictionary=function(t){return this.visit(t.indices)},Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffers",{get:function(){return this._buffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this._byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferRegions",{get:function(){return this._bufferRegions},enumerable:!1,configurable:!0}),e}(hy);function ZV(t){var e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new EW(this._byteLength,e)),this._byteLength+=e,this}function XV(t){return ZV.call(this,t.values.subarray(0,t.length*t.stride))}function GV(t){var e=t.length,n=t.values,i=t.valueOffsets,r=i[0],o=i[e],l=Math.min(o-r,n.byteLength-r);return ZV.call(this,Hf(-i[0],e,i)),ZV.call(this,n.subarray(r,r+l)),this}function WV(t){var e=t.length,n=t.valueOffsets;return n&&ZV.call(this,Hf(n[0],e,n)),this.visit(t.getChildAt(0))}function VV(t){return this.visitMany(t.type.children.map((function(e,n){return t.getChildAt(n)})).filter(Boolean))[0]}yV.prototype.visitBool=function(t){var e;return t.nullCount>=t.length?ZV.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?ZV.call(this,oy(t.offset,t.length,e)):ZV.call(this,ly(t))},yV.prototype.visitInt=XV,yV.prototype.visitFloat=XV,yV.prototype.visitUtf8=GV,yV.prototype.visitBinary=GV,yV.prototype.visitFixedSizeBinary=XV,yV.prototype.visitDate=XV,yV.prototype.visitTimestamp=XV,yV.prototype.visitTime=XV,yV.prototype.visitDecimal=XV,yV.prototype.visitList=WV,yV.prototype.visitStruct=VV,yV.prototype.visitUnion=function(t){var e=t.type,n=t.length,i=t.typeIds,r=t.valueOffsets;if(ZV.call(this,i),e.mode===qf.Sparse)return VV.call(this,t);if(e.mode===qf.Dense){if(t.offset<=0)return ZV.call(this,r),VV.call(this,t);for(var o=i.reduce((function(t,e){return Math.max(t,e)}),i[0]),l=new Int32Array(o+1),a=new Int32Array(o+1).fill(-1),s=new Int32Array(n),u=Hf(-r[0],n,r),c=void 0,d=void 0,h=-1;++h0&&this._write(i),this._writePadding(a)},e.prototype._write=function(t){if(this._started){var e=Sf(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this},e.prototype._writeSchema=function(t){return this._writeMessage(jW.from(t))},e.prototype._writeFooter=function(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))},e.prototype._writeMagic=function(){return this._write(dV)},e.prototype._writePadding=function(t){return t>0?this._write(new Uint8Array(t)):this},e.prototype._writeRecordBatch=function(t){var e=yV.assemble(t),n=e.byteLength,i=e.nodes,r=e.bufferRegions,o=e.buffers,l=new QW(t.length,i,r),a=jW.from(l,n);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(o)},e.prototype._writeDictionaryBatch=function(t,e,n){void 0===n&&(n=!1),this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));var i=yV.assemble(t),r=i.byteLength,o=i.nodes,l=i.bufferRegions,a=i.buffers,s=new QW(t.length,o,l),u=new PW(s,e,n),c=jW.from(u,r);return this._writeMessage(c)._writeBodyBuffers(a)},e.prototype._writeBodyBuffers=function(t){for(var e,n,i,r=-1,o=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this},e.prototype._writeDictionaries=function(t){var e,n,i,r;try{for(var o=Hm(t.dictionaries),l=o.next();!l.done;l=o.next()){var a=Jm(l.value,2),s=a[0],u=a[1],c=this._dictionaryDeltaOffsets.get(s)||0;if(0===c||(u=u.slice(c)).length>0){var d="chunks"in u?u.chunks:[u];try{for(var h=(i=void 0,Hm(d)),b=h.next();!b.done;b=h.next()){var p=b.value;this._writeDictionaryBatch(p,s,c>0),c+=p.length}}catch(m){i={error:m}}finally{try{b&&!b.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}}}}catch(f){e={error:f}}finally{try{l&&!l.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this},e}(Pm),xV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.writeAll=function(t,n){var i=new e(n);return sf(t)?t.then((function(t){return i.writeAll(t)})):cf(t)?HV(i,t):KV(i,t)},e}(LV),YV=function(t){function e(){var e=t.call(this)||this;return e._autoDestroy=!0,e}return gm(e,t),e.writeAll=function(t){var n=new e;return sf(t)?t.then((function(t){return n.writeAll(t)})):cf(t)?HV(n,t):KV(n,t)},e.prototype._writeSchema=function(t){return this._writeMagic()._writePadding(2)},e.prototype._writeFooter=function(e){var n=BG.encode(new BG(e,ey.V4,this._recordBatchBlocks,this._dictionaryBlocks));return t.prototype._writeFooter.call(this,e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()},e}(LV);function KV(t,e){var n,i,r=e;e instanceof WS&&(r=e.chunks,t.reset(void 0,e.schema));try{for(var o=Hm(r),l=o.next();!l.done;l=o.next()){var a=l.value;t.write(a)}}catch(s){n={error:s}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return t.finish()}function HV(t,e){var n,i,r,o;return Ym(this,void 0,void 0,(function(){var l,a;return Km(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),n=Cm(e),s.label=1;case 1:return[4,n.next()];case 2:if((i=s.sent()).done)return[3,4];l=i.value,t.write(l),s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=s.sent(),r={error:a},[3,11];case 6:return s.trys.push([6,,9,10]),i&&!i.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return[2,t.finish()]}}))}))}function JV(t){var e=t.name,n=t.type,i=t.nullable,r=new vV;return{name:e,nullable:i,type:r.visit(n),children:(n.children||[]).map(JV),dictionary:Ry.isDictionary(n)?{id:n.id,isOrdered:n.isOrdered,indexType:r.visit(n.indices)}:void 0}}!function(t){function e(){var e=t.call(this)||this;return e._autoDestroy=!0,e._recordBatches=[],e._dictionaries=[],e}gm(e,t),e.writeAll=function(t){return(new e).writeAll(t)},e.prototype._writeMessage=function(){return this},e.prototype._writeFooter=function(t){return this},e.prototype._writeSchema=function(t){return this._write('{\n "schema": '+JSON.stringify({fields:t.fields.map(JV)},null,2))},e.prototype._writeDictionaries=function(t){return t.dictionaries.size>0&&this._dictionaries.push(t),this},e.prototype._writeDictionaryBatch=function(t,e,n){return void 0===n&&(n=!1),this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0)),this._write(0===this._dictionaryBlocks.length?" ":",\n "),this._write(""+function(t,e,n){void 0===n&&(n=!1);var i=new nG(""+e,t.type,t.nullCount>0),r=SV.assemble(new BX(i,[t]));return JSON.stringify({id:e,isDelta:n,data:{count:t.length,columns:r}},null,2)}(t,e,n)),this._dictionaryBlocks.push(new TG(0,0,0)),this},e.prototype._writeRecordBatch=function(t){return this._writeDictionaries(t),this._recordBatches.push(t),this},e.prototype.close=function(){var e,n,i;if(this._dictionaries.length>0){this._write(',\n "dictionaries": [\n');try{for(var r=Hm(this._dictionaries),o=r.next();!o.done;o=r.next()){var l=o.value;t.prototype._writeDictionaries.call(this,l)}}catch(u){e={error:u}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this._write("\n ]")}if(this._recordBatches.length>0){for(var a=-1,s=this._recordBatches.length;++a>3;++o0;){for(a=Number.POSITIVE_INFINITY,s=-1;++s0&&(r[l++]=[a,c.slice()]))}return[t=new eG(i,t.metadata),r.map((function(e){return new(VS.bind.apply(VS,wm([void 0,t],e)))}))]}(t,e.map((function(t){return t instanceof CX?t.chunks.map((function(t){return t.data})):[t.data]})))}function UV(t,e,n,i,r){for(var o,l,a=0,s=-1,u=i.length,c=(e+63&-64)>>3;++s=e?a===e?n[s]=o:(n[s]=o.slice(0,e),o=o.slice(e,a-e),r.numBatches=Math.max(r.numBatches,i[s].unshift(o))):((l=t[s]).nullable||(t[s]=l.clone({nullable:!0})),n[s]=o?o._changeLengthAndBackfillNullBitmap(e):oZ.new(l.type,0,e,e,_V(c)));return n}var FV=function(t){function e(e,n){var i=t.call(this)||this;return i._children=n,i.numChildren=e.childData.length,i._bindDataAccessors(i.data=e),i}return gm(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return this.data.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typeId",{get:function(){return this.data.typeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.data.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offset",{get:function(){return this.data.offset},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this.data.stride},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){return this.data.nullCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this.data.byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"VectorName",{get:function(){return Qf[this.typeId]+"Vector"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.data.values},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typeIds",{get:function(){return this.data.typeIds},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullBitmap",{get:function(){return this.data.nullBitmap},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueOffsets",{get:function(){return this.data.valueOffsets},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return this.VectorName+"<"+this.type[Symbol.toStringTag]+">"},enumerable:!1,configurable:!0}),e.prototype.clone=function(t,e){return void 0===e&&(e=this._children),jf.new(t,e)},e.prototype.concat=function(){for(var t=[],e=0;e0){var e=this.offset+t;return 0!==(this.nullBitmap[e>>3]&1<=this.numChildren?null:(this._children||(this._children=[]))[t]||(this._children[t]=jf.new(this.data.childData[t]))},e.prototype.toJSON=function(){return wm(this)},e.prototype._sliceInternal=function(t,e,n){return t.clone(t.data.slice(e,n-e),null)},e.prototype._bindDataAccessors=function(t){},e}(jf);FV.prototype[Symbol.isConcatSpreadable]=!0;var BV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.asUtf8=function(){return jf.new(this.data.clone(new ky))},e}(FV),kV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.from=function(t){return GS((function(){return new Ty}),t)},e}(FV),TV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.from=function(){for(var t=[],e=0;e>>0)},Bv=function(t){return new Date(t)},kv=function(t,e,n){var i=e,r=i[n],o=i[n+1];return null!=r&&null!=o?t.subarray(r,o):null},Tv=function(t,e){return function(t,e){return Bv(function(t,e){return 864e5*t[e]}(t,e))}(t.values,e)},zv=function(t,e){return function(t,e){return Bv(Fv(t,e))}(t.values,2*e)},Mv=function(t,e){var n=t.stride;return t.values[n*e]},jv=function(t,e){var n=t.stride;return LZ(t.values[n*e])},Qv=function(t,e){var n=t.stride,i=t.values,r=t.type;return MZ.new(i.subarray(n*e,n*(e+1)),r.isSigned)},Pv=function(t,e){var n=t.values;return 1e3*Fv(n,2*e)},Ev=function(t,e){var n=t.values;return Fv(n,2*e)},Dv=function(t,e){return function(t,e){return t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3}(t.values,2*e)},Ov=function(t,e){return function(t,e){return t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6}(t.values,2*e)},Av=function(t,e){return t.values[t.stride*e]},qv=function(t,e){return t.values[t.stride*e]},$v=function(t,e){var n=t.values;return MZ.signed(n.subarray(2*e,2*(e+1)))},tS=function(t,e){var n=t.values;return MZ.signed(n.subarray(2*e,2*(e+1)))},eS=function(t,e){var n=t.typeIdToChildIndex[t.typeIds[e]],i=t.getChildAt(n);return i?i.get(t.valueOffsets[e]):null},nS=function(t,e){var n=t.typeIdToChildIndex[t.typeIds[e]],i=t.getChildAt(n);return i?i.get(e):null},iS=function(t,e){return t.values.subarray(2*e,2*(e+1))},rS=function(t,e){var n=t.values[e],i=new Int32Array(2);return i[0]=n/12|0,i[1]=n%12|0,i};Uv.prototype.visitNull=function(t,e){return null},Uv.prototype.visitBool=function(t,e){var n=t.offset+e;return 0!=(t.values[n>>3]&1<0?0:-1},lS.prototype.visitBool=aS,lS.prototype.visitInt=aS,lS.prototype.visitInt8=aS,lS.prototype.visitInt16=aS,lS.prototype.visitInt32=aS,lS.prototype.visitInt64=aS,lS.prototype.visitUint8=aS,lS.prototype.visitUint16=aS,lS.prototype.visitUint32=aS,lS.prototype.visitUint64=aS,lS.prototype.visitFloat=aS,lS.prototype.visitFloat16=aS,lS.prototype.visitFloat32=aS,lS.prototype.visitFloat64=aS,lS.prototype.visitUtf8=aS,lS.prototype.visitBinary=aS,lS.prototype.visitFixedSizeBinary=aS,lS.prototype.visitDate=aS,lS.prototype.visitDateDay=aS,lS.prototype.visitDateMillisecond=aS,lS.prototype.visitTimestamp=aS,lS.prototype.visitTimestampSecond=aS,lS.prototype.visitTimestampMillisecond=aS,lS.prototype.visitTimestampMicrosecond=aS,lS.prototype.visitTimestampNanosecond=aS,lS.prototype.visitTime=aS,lS.prototype.visitTimeSecond=aS,lS.prototype.visitTimeMillisecond=aS,lS.prototype.visitTimeMicrosecond=aS,lS.prototype.visitTimeNanosecond=aS,lS.prototype.visitDecimal=aS,lS.prototype.visitList=aS,lS.prototype.visitStruct=aS,lS.prototype.visitUnion=aS,lS.prototype.visitDenseUnion=sS,lS.prototype.visitSparseUnion=sS,lS.prototype.visitDictionary=aS,lS.prototype.visitInterval=aS,lS.prototype.visitIntervalDayTime=aS,lS.prototype.visitIntervalYearMonth=aS,lS.prototype.visitFixedSizeList=aS,lS.prototype.visitMap=aS;var uS=new lS,cS=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e}(hy);function dS(t){if(t.nullCount>0)return function(t){var e=oS.getVisitFn(t);return ay(t.data.nullBitmap,t.data.offset,t.length,t,(function(t,n,i,r){return 0!=(i&1<0)?t.data.values.subarray(0,i)[Symbol.iterator]():function(e){var n;return Km(this,(function(r){switch(r.label){case 0:n=-1,r.label=1;case 1:return++n0&&(this.get=(e=this.get,function(t){return this.isValid(t)?e.call(this,t):null}),this.set=function(t){return function(e,n){ry(this.nullBitmap,this.offset+e,!(null==n))&&t.call(this,e,n)}}(this.set));var e},Object.keys(Qf).map((function(t){return Qf[t]})).filter((function(t){return"number"==typeof t})).filter((function(t){return t!==Qf.NONE})).forEach((function(t){var e,n=XS.visit(t);n.prototype.get=(e=oS.getVisitFn(t),function(t){return e(this,t)}),n.prototype.set=Cv(wG.getVisitFn(t)),n.prototype.indexOf=Cv(uS.getVisitFn(t)),n.prototype.toArray=Nv(mS.getVisitFn(t)),n.prototype.getByteWidth=function(t){return function(){return t(this.type)}}(ZS.getVisitFn(t)),n.prototype[Symbol.iterator]=Nv(hS.getVisitFn(t))}));var WS=function(t){function e(){for(var e=[],n=0;n=this.numChildren)return null;var e,n,i=this._schema.fields,r=this._children||(this._children=[]);if(n=r[t])return n;if(e=i[t]){var o=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}));if(o.length>0)return r[t]=new BX(e,o)}return null},e.prototype.serialize=function(t,e){return void 0===e&&(e=!0),(e?xV:YV).writeAll(this).toUint8Array(!0)},e.prototype.count=function(){return this._length},e.prototype.select=function(){for(var t=[],e=0;e-1}))))},e.prototype.selectAt=function(){for(var t,n=[],i=0;i-1}))))},e.prototype.selectAt=function(){for(var t,n=this,i=[],r=0;r0&&this.dictionaries.set(e.id,n),this},e}(hy),RS=function(t){function e(e){var n=t.call(this)||this;return n._impl=e,n}return gm(e,t),Object.defineProperty(e.prototype,"closed",{get:function(){return this._impl.closed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this._impl.schema},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoDestroy",{get:function(){return this._impl.autoDestroy},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dictionaries",{get:function(){return this._impl.dictionaries},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numDictionaries",{get:function(){return this._impl.numDictionaries},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRecordBatches",{get:function(){return this._impl.numRecordBatches},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"footer",{get:function(){return this._impl.isFile()?this._impl.footer:null},enumerable:!1,configurable:!0}),e.prototype.isSync=function(){return this._impl.isSync()},e.prototype.isAsync=function(){return this._impl.isAsync()},e.prototype.isFile=function(){return this._impl.isFile()},e.prototype.isStream=function(){return this._impl.isStream()},e.prototype.next=function(){return this._impl.next()},e.prototype.throw=function(t){return this._impl.throw(t)},e.prototype.return=function(t){return this._impl.return(t)},e.prototype.cancel=function(){return this._impl.cancel()},e.prototype.reset=function(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this},e.prototype.open=function(t){var e=this,n=this._impl.open(t);return sf(n)?n.then((function(){return e})):this},e.prototype.readRecordBatch=function(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null},e.prototype[Symbol.iterator]=function(){return this._impl[Symbol.iterator]()},e.prototype[Symbol.asyncIterator]=function(){return this._impl[Symbol.asyncIterator]()},e.prototype.toDOMStream=function(){var t,e,n=this;return _f.toDOMStream(this.isSync()?((t={})[Symbol.iterator]=function(){return n},t):((e={})[Symbol.asyncIterator]=function(){return n},e))},e.prototype.toNodeStream=function(){var t,e,n=this;return _f.toNodeStream(this.isSync()?((t={})[Symbol.iterator]=function(){return n},t):((e={})[Symbol.asyncIterator]=function(){return n},e),{objectMode:!0})},e.throughNode=function(t){throw new Error('"throughNode" not available in this environment')},e.throughDOM=function(t,e){throw new Error('"throughDOM" not available in this environment')},e.from=function(t){var n=this;return t instanceof e?t:df(t)?function(t){return new gS(new IS(t))}(t):bf(t)?function(t){return Ym(this,void 0,void 0,(function(){var e,n,i;return Km(this,(function(r){switch(r.label){case 0:return[4,t.stat()];case 1:return e=r.sent().size,n=new DG(t,e),e>=fV?(i=bV,[4,n.readAt(0,pV+7&-8)]):[3,3];case 2:if(i.apply(void 0,[r.sent()]))return[2,new YS(new _S(n))];r.label=3;case 3:return[2,new LS(new JS(n))]}}))}))}(t):sf(t)?Ym(n,void 0,void 0,(function(){var n,i;return Km(this,(function(r){switch(r.label){case 0:return i=(n=e).from,[4,t];case 1:return[4,i.apply(n,[r.sent()])];case 2:return[2,r.sent()]}}))})):pf(t)||mf(t)||ff(t)||cf(t)?function(t){return Ym(this,void 0,void 0,(function(){var e,n,i,r,o;return Km(this,(function(l){switch(l.label){case 0:return[4,t.peek(pV+7&-8)];case 1:return(e=l.sent())&&e.byteLength>=4?bV(e)?[3,2]:(i=new LS(new JS(t)),[3,4]):[3,5];case 2:return r=xS.bind,o=wS.bind,[4,t.read()];case 3:i=new(r.apply(xS,[void 0,new(o.apply(wS,[void 0,l.sent()]))])),l.label=4;case 4:return n=i,[3,6];case 5:n=new LS(new JS(function(){return Im(this,arguments,(function(){return Km(this,(function(t){return[2]}))}))}())),l.label=6;case 6:return[2,n]}}))}))}(new jG(t)):function(t){var e=t.peek(pV+7&-8);return e&&e.byteLength>=4?bV(e)?new xS(new wS(t.read())):new gS(new HS(t)):new gS(new HS(function(){return Km(this,(function(t){return[2]}))}()))}(new MG(t))},e.readAll=function(t){return t instanceof e?t.isSync()?CS(t):US(t):df(t)||ArrayBuffer.isView(t)||uf(t)||hf(t)?CS(t):US(t)},e}(Pm),gS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return gm(e,t),e.prototype[Symbol.iterator]=function(){return this._impl[Symbol.iterator]()},e.prototype[Symbol.asyncIterator]=function(){return Im(this,arguments,(function(){return Km(this,(function(t){switch(t.label){case 0:return[5,Hm(Nm(Cm(this[Symbol.iterator]())))];case 1:return[4,_m.apply(void 0,[t.sent()])];case 2:return t.sent(),[2]}}))}))},e}(RS),LS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return gm(e,t),e.prototype[Symbol.iterator]=function(){throw new Error("AsyncRecordBatchStreamReader is not Iterable")},e.prototype[Symbol.asyncIterator]=function(){return this._impl[Symbol.asyncIterator]()},e}(RS),xS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return gm(e,t),e}(gS),YS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return gm(e,t),e}(LS),KS=function(){function t(t){void 0===t&&(t=new Map),this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}return Object.defineProperty(t.prototype,"numDictionaries",{get:function(){return this._dictionaryIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numRecordBatches",{get:function(){return this._recordBatchIndex},enumerable:!1,configurable:!0}),t.prototype.isSync=function(){return!1},t.prototype.isAsync=function(){return!1},t.prototype.isFile=function(){return!1},t.prototype.isStream=function(){return!1},t.prototype.reset=function(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this},t.prototype._loadRecordBatch=function(t,e){return new VS(this.schema,t.length,this._loadVectors(t,e,this.schema.fields))},t.prototype._loadDictionaryBatch=function(t,e){var n=t.id,i=t.isDelta,r=t.data,o=this.dictionaries,l=this.schema,a=o.get(n);if(i||!a){var s=l.dictionaries.get(n);return a&&i?a.concat(jf.new(this._loadVectors(r,e,[s])[0])):jf.new(this._loadVectors(r,e,[s])[0])}return a},t.prototype._loadVectors=function(t,e,n){return new iW(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)},t}(),HS=function(t){function e(e,n){var i=t.call(this,n)||this;return i._reader=df(e)?new uV(i._handle=e):new aV(i._handle=e),i}return gm(e,t),e.prototype.isSync=function(){return!0},e.prototype.isStream=function(){return!0},e.prototype[Symbol.iterator]=function(){return this},e.prototype.cancel=function(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)},e.prototype.open=function(t){return this.closed||(this.autoDestroy=NS(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this},e.prototype.throw=function(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):jm},e.prototype.return=function(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):jm},e.prototype.next=function(){if(this.closed)return jm;for(var t,e=this._reader;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;var n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;n=t.header(),i=e.readMessageBody(t.bodyLength);var r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new vS(this.schema)}):this.return()},e.prototype._readNextMessageAndValidate=function(t){return this._reader.readMessage(t)},e}(KS),JS=function(t){function e(e,n){var i=t.call(this,n)||this;return i._reader=new sV(i._handle=e),i}return gm(e,t),e.prototype.isAsync=function(){return!0},e.prototype.isStream=function(){return!0},e.prototype[Symbol.asyncIterator]=function(){return this},e.prototype.cancel=function(){return Ym(this,void 0,void 0,(function(){return Km(this,(function(t){switch(t.label){case 0:return this.closed||!(this.closed=!0)?[3,2]:[4,this.reset()._reader.return()];case 1:t.sent(),this._reader=null,this.dictionaries=null,t.label=2;case 2:return[2]}}))}))},e.prototype.open=function(t){return Ym(this,void 0,void 0,(function(){var e,n;return Km(this,(function(i){switch(i.label){case 0:return this.closed?[3,4]:(this.autoDestroy=NS(this,t),(e=this.schema)?[3,2]:(n=this,[4,this._reader.readSchema()]));case 1:e=n.schema=i.sent(),i.label=2;case 2:return e?[3,4]:[4,this.cancel()];case 3:i.sent(),i.label=4;case 4:return[2,this]}}))}))},e.prototype.throw=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return!this.closed&&this.autoDestroy&&(this.closed=!0)?[4,this.reset()._reader.throw(t)]:[3,2];case 1:return[2,e.sent()];case 2:return[2,jm]}}))}))},e.prototype.return=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return!this.closed&&this.autoDestroy&&(this.closed=!0)?[4,this.reset()._reader.return(t)]:[3,2];case 1:return[2,e.sent()];case 2:return[2,jm]}}))}))},e.prototype.next=function(){return Ym(this,void 0,void 0,(function(){var t,e,n,i,r;return Km(this,(function(o){switch(o.label){case 0:if(this.closed)return[2,jm];e=this._reader,o.label=1;case 1:return[4,this._readNextMessageAndValidate()];case 2:return(t=o.sent())?t.isSchema()?[4,this.reset(t.header())]:[3,4]:[3,9];case 3:return o.sent(),[3,8];case 4:return t.isRecordBatch()?(this._recordBatchIndex++,n=t.header(),[4,e.readMessageBody(t.bodyLength)]):[3,6];case 5:return i=o.sent(),[2,{done:!1,value:this._loadRecordBatch(n,i)}];case 6:return t.isDictionaryBatch()?(this._dictionaryIndex++,n=t.header(),[4,e.readMessageBody(t.bodyLength)]):[3,8];case 7:i=o.sent(),r=this._loadDictionaryBatch(n,i),this.dictionaries.set(n.id,r),o.label=8;case 8:return[3,1];case 9:return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,[2,{done:!1,value:new vS(this.schema)}]):[4,this.return()];case 10:return[2,o.sent()]}}))}))},e.prototype._readNextMessageAndValidate=function(t){return Ym(this,void 0,void 0,(function(){return Km(this,(function(e){switch(e.label){case 0:return[4,this._reader.readMessage(t)];case 1:return[2,e.sent()]}}))}))},e}(KS),wS=function(t){function e(e,n){return t.call(this,e instanceof EG?e:new EG(e),n)||this}return gm(e,t),Object.defineProperty(e.prototype,"footer",{get:function(){return this._footer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numDictionaries",{get:function(){return this._footer?this._footer.numDictionaries:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRecordBatches",{get:function(){return this._footer?this._footer.numRecordBatches:0},enumerable:!1,configurable:!0}),e.prototype.isSync=function(){return!0},e.prototype.isFile=function(){return!0},e.prototype.open=function(e){var n,i;if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;try{for(var r=Hm(this._footer.dictionaryBatches()),o=r.next();!o.done;o=r.next()){o.value&&this._readDictionaryBatch(this._dictionaryIndex++)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}return t.prototype.open.call(this,e)},e.prototype.readRecordBatch=function(t){if(this.closed)return null;this._footer||this.open();var e=this._footer&&this._footer.getRecordBatch(t);if(e&&this._handle.seek(e.offset)){var n=this._reader.readMessage(ty.RecordBatch);if(n&&n.isRecordBatch()){var i=n.header(),r=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(i,r)}}return null},e.prototype._readDictionaryBatch=function(t){var e=this._footer&&this._footer.getDictionaryBatch(t);if(e&&this._handle.seek(e.offset)){var n=this._reader.readMessage(ty.DictionaryBatch);if(n&&n.isDictionaryBatch()){var i=n.header(),r=this._reader.readMessageBody(n.bodyLength),o=this._loadDictionaryBatch(i,r);this.dictionaries.set(i.id,o)}}},e.prototype._readFooter=function(){var t=this._handle,e=t.size-mV,n=t.readInt32(e),i=t.readAt(e-n,n);return BG.decode(i)},e.prototype._readNextMessageAndValidate=function(t){if(this._footer||this.open(),this._footer&&this._recordBatchIndex=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||0===this._numChunks)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))},t.prototype._enqueue=function(t,e){this._bufferedSize=0,this._controller=null,null===e?t.close():t.enqueue(e)},t}(),BS=function(t){return t.length},kS=function(t){return t.byteLength};var TS=function(){function t(){}return t.prototype.eq=function(e){return e instanceof t||(e=new zS(e)),new OS(this,e)},t.prototype.le=function(e){return e instanceof t||(e=new zS(e)),new AS(this,e)},t.prototype.ge=function(e){return e instanceof t||(e=new zS(e)),new qS(this,e)},t.prototype.lt=function(t){return new $S(this.ge(t))},t.prototype.gt=function(t){return new $S(this.le(t))},t.prototype.ne=function(t){return new $S(this.eq(t))},t}(),zS=function(t){function e(e){var n=t.call(this)||this;return n.v=e,n}return gm(e,t),e}(TS),MS=function(t){function e(e){var n=t.call(this)||this;return n.name=e,n}return gm(e,t),e.prototype.bind=function(t){if(!this.colidx){this.colidx=-1;for(var e=t.schema.fields,n=-1;++n=n.v;return function(){return i}},e.prototype._bindColCol=function(t,e,n){var i=e.bind(t),r=n.bind(t);return function(t,e){return i(t,e)>=r(t,e)}},e.prototype._bindColLit=function(t,e,n){var i=e.bind(t);return function(t,e){return i(t,e)>=n.v}},e.prototype._bindLitCol=function(t,e,n){var i=n.bind(t);return function(t,n){return e.v>=i(t,n)}},e}(QS),$S=function(t){function e(e){var n=t.call(this)||this;return n.child=e,n}return gm(e,t),e.prototype.bind=function(t){var e=this.child.bind(t);return function(t,n){return!e(t,n)}},e}(jS);!function(t){function e(e,n){var i=t.call(this)||this;return i.next=e,i.bind_=n,i}gm(e,t),e.prototype.bind=function(t){return this.bind_(t),this.next}}(jS),WS.prototype.countBy=function(t){return new tR(this.chunks).countBy(t)},WS.prototype.scan=function(t,e){return new tR(this.chunks).scan(t,e)},WS.prototype.scanReverse=function(t,e){return new tR(this.chunks).scanReverse(t,e)},WS.prototype.filter=function(t){return new tR(this.chunks).filter(t)};var tR=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gm(e,t),e.prototype.filter=function(t){return new nR(this.chunks,t)},e.prototype.scan=function(t,e){for(var n=this.chunks,i=n.length,r=-1;++r=0;){var r=n[i];e&&e(r);for(var o=r.length;--o>=0;)t(o,r)}},e.prototype.countBy=function(t){var e=this.chunks,n=e.length,i="string"==typeof t?new MS(t):t;i.bind(e[n-1]);var r=i.vector;if(!Ry.isDictionary(r.type))throw new Error("countBy currently only supports dictionary-encoded columns");for(var o=Math.ceil(Math.log(r.length)/Math.log(256)),l=new(4==o?Uint32Array:o>=2?Uint16Array:Uint8Array)(r.dictionary.length),a=-1;++a=0;)for(var r=n[i],o=this._predicate.bind(r),l=!1,a=r.length;--a>=0;)o(a,r)&&(e&&!l&&(e(r),l=!0),t(a,r))},e.prototype.count=function(){for(var t=0,e=this._chunks,n=e.length,i=-1;++i=2?Uint16Array:Uint8Array)(r.dictionary.length),a=-1;++a"object"==typeof t&&null!==t||"function"==typeof t,sR=new Map([["proxy",{canHandle:t=>aR(t)&&t[iR],serialize(t){const{port1:e,port2:n}=new MessageChannel;return uR(t,e),[n,[n]]},deserialize:t=>(t.start(),dR(t))}],["throw",{canHandle:t=>aR(t)&&lR 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 uR(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:r,type:o,path:l}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(ZR);let s;try{const e=l.slice(0,-1).reduce(((t,e)=>t[e]),t),n=l.reduce(((t,e)=>t[e]),t);switch(o){case"GET":s=n;break;case"SET":e[l.slice(-1)[0]]=ZR(i.data.value),s=!0;break;case"APPLY":s=n.apply(e,a);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[iR]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;uR(t,n),s=fR(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(u){s={value:u,[lR]:0}}Promise.resolve(s).catch((t=>({value:t,[lR]:0}))).then((t=>{const[i,l]=yR(t);e.postMessage(Object.assign(Object.assign({},i),{id:r}),l),"RELEASE"===o&&(e.removeEventListener("message",n),cR(e))}))})),e.start&&e.start()}function cR(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function dR(t,e){return bR(t,[],e)}function hR(t){if(t)throw new Error("Proxy has been released and is not useable")}function bR(t,e=[],n=function(){}){let i=!1;const r=new Proxy(n,{get(n,o){if(hR(i),o===oR)return()=>XR(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{cR(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>r};const n=XR(t,{type:"GET",path:e.map((t=>t.toString()))}).then(ZR);return n.then.bind(n)}return bR(t,[...e,o])},set(n,r,o){hR(i);const[l,a]=yR(o);return XR(t,{type:"SET",path:[...e,r].map((t=>t.toString())),value:l},a).then(ZR)},apply(n,r,o){hR(i);const l=e[e.length-1];if(l===rR)return XR(t,{type:"ENDPOINT"}).then(ZR);if("bind"===l)return bR(t,e.slice(0,-1));const[a,s]=pR(o);return XR(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:a},s).then(ZR)},construct(n,r){hR(i);const[o,l]=pR(r);return XR(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},l).then(ZR)}});return r}function pR(t){const e=t.map(yR);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const mR=new WeakMap;function fR(t,e){return mR.set(t,e),t}function yR(t){for(const[e,n]of sR)if(n.canHandle(t)){const[i,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},r]}return[{type:"RAW",value:t},mR.get(t)||[]]}function ZR(t){switch(t.type){case"HANDLER":return sR.get(t.name).deserialize(t.value);case"RAW":return t.value}}function XR(t,e,n){return new Promise((i=>{const r=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===r&&(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:r},e),n)}))}class GR extends Map{get_count(t){return super.get(t)||0}get_counter(t){const e=super.get(t);return e||(super.set(t,new GR),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]}}const WR=new Blob([atob("Y29uc3QgdD1TeW1ib2woIkNvbWxpbmsucHJveHkiKSxlPVN5bWJvbCgiQ29tbGluay5lbmRwb2ludCIpLG49U3ltYm9sKCJDb21saW5rLnJlbGVhc2VQcm94eSIpLHI9U3ltYm9sKCJDb21saW5rLnRocm93biIpLGk9dD0+Im9iamVjdCI9PXR5cGVvZiB0JiZudWxsIT09dHx8ImZ1bmN0aW9uIj09dHlwZW9mIHQsbz1uZXcgTWFwKFtbInByb3h5Iix7Y2FuSGFuZGxlOmU9PmkoZSkmJmVbdF0sc2VyaWFsaXplKHQpe2NvbnN0e3BvcnQxOmUscG9ydDI6bn09bmV3IE1lc3NhZ2VDaGFubmVsO3JldHVybiBzKHQsZSksW24sW25dXX0sZGVzZXJpYWxpemUodCl7cmV0dXJuIHQuc3RhcnQoKSxjKHQsW10sZSk7dmFyIGV9fV0sWyJ0aHJvdyIse2NhbkhhbmRsZTp0PT5pKHQpJiZyIGluIHQsc2VyaWFsaXplKHt2YWx1ZTp0fSl7bGV0IGU7cmV0dXJuIGU9dCBpbnN0YW5jZW9mIEVycm9yP3tpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOnQubWVzc2FnZSxuYW1lOnQubmFtZSxzdGFjazp0LnN0YWNrfX06e2lzRXJyb3I6ITEsdmFsdWU6dH0sW2UsW11dfSxkZXNlcmlhbGl6ZSh0KXtpZih0LmlzRXJyb3IpdGhyb3cgT2JqZWN0LmFzc2lnbihuZXcgRXJyb3IodC52YWx1ZS5tZXNzYWdlKSx0LnZhbHVlKTt0aHJvdyB0LnZhbHVlfX1dXSk7ZnVuY3Rpb24gcyhlLG49c2VsZil7bi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwoZnVuY3Rpb24gaShvKXtpZighb3x8IW8uZGF0YSlyZXR1cm47Y29uc3R7aWQ6YS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bl90cmFuc2Zvcm1zKHQsZSl7Y29uc29sZS5sb2coIjUgaGVyZSIpO2NvbnN0IG49ZmModCxlKSxyPWNjKG4pO3JldHVybiBjb25zb2xlLmxvZygiNiBoZXJlIiksW3Aobixbbl0pLHJdfX0pOwo=")],{type:"text/javascript;charset=utf-8"});function VR(){const t=(window.URL||window.webkitURL).createObjectURL(WR);try{return new Worker(t)}finally{(window.URL||window.webkitURL).revokeObjectURL(t)}}class vR extends class{}{constructor(t,e,n,i){super(),this.url=t,this.parent=n,void 0===n&&(this._mutations=i.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 i of this._children)n.concat(i.download_to_depth(t,e,!1));return Promise.all(n)}return this.download().then((i=>{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,fR(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)RR([e.x,e.y],t)&&(yield e);if(0==e){for(const n of this.children)if(n.ready)for(const i of n.points(t,e))RR([i.x,i.y],t)&&(yield i)}else{let n=this.children.map((n=>{const i={t:n,iterator:n.points(t,e)};return i.next=i.iterator.next(),i}));for(n=n.filter((t=>t.next.value));n.length>0;){let t=0;for(let e=1;e0?(console.log("BYTES",this._table_buffer.byteLength),this._table=WS.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=this.url.match("//")?`${this.url}/${this.key}.feather`:`${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,console.log("Got buffer"),this._table=WS.from(t),console.log("Into table"),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 i,r=e;return this.visit((e=>{if(!(function(t,e,n){if(void 0===t)return parseFloat("inf");const i=Math.max(t.x[0]-e,0,e-t.x[1]),r=Math.max(t.y[0]-n,0,n-t.y[1]);return Math.sqrt(i*i+r*r)}(e.extent,t[0],t[1])>r)&&(e._kdtree||e.kdtree(),e._kdtree)){const o=e._kdtree.find(t[0],t[1],r,n);if(o){const e=Math.sqrt((o.x-t[0])**2+(o.y-t[1])**2);i=o,r=e}}})),i}get _schema(){if(this.__schema)return this.__schema;const t=[];for(const e of this.table.schema.fields){const{name:n,type:i,nullable:r}=e;i&&5==i.typeId&&t.push({name:n,type:"string"}),i&&i.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]}),i&&8==i.typeId&&t.push({name:n,type:"date",extent:ke(this.table.getColumn(n).data.values)}),i&&3==i.typeId&&t.push({name:n,type:"float",extent:ke(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 i=0;for(const[r,o]of n.entries())t.has(o)||(i=t.size/2,t.set(i,o),t.set(o,i)),this.dictionary_lookups[e]}this.dictionary_lookups}get theoretical_extent(){const t=this.root_extent,[e,n,i]=this.codes,r=(t.x[1]-t.x[0])/2**e,o=(t.y[1]-t.y[0])/2**e;return{x:[t.x[0]+n*r,t.x[0]+(n+1)*r],y:[t.y[0]+i*o,t.y[0]+(i+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 i of t)e.push(this.table.getColumn(i));const n=new GR;for(let i=0;it.get(i)));n.inc(...t)}return n}get root_extent(){return this.parent.root_extent}}class SR extends vR{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=[],i=je(2**t);for(const r of i){n[r]=[];for(const t of i)n[r][t]=" ";n[r][2**t]="|"}n[2**t]=Array(2**t+1).fill("-"),this.visit((i=>{const[r,o,l]=i.key.split("/").map((t=>+t));r==t&&(n[l][o]="_",n[l][o]=e(i))})),n.map((t=>t.join("")))}download_most_needed_tiles(t,e,n=4){this._download_queue||(this._download_queue=new Set);const i=this._download_queue;if(i.size>=n)return;const r=[];this.visit((e=>{const n=function(t,e){const n=t.extent;LR(n),LR(e),n.x[0]>e.x[1]||n.x[1]e.y[1]||(n.y[1],e.y[0]);const i={x:[Te([e.x[0],n.x[0]]),ze([e.x[1],n.x[1]])],y:[Te([e.y[0],n.y[0]]),ze([e.y[1],n.y[1]])]},{x:r,y:o}=i;let l=0;r[0]>r[1]&&(l-=1);o[0]>o[1]&&(l-=2);if(l<0)return l;return gR(i)/gR(e)}(e,t);r.push([n,e,t,e.download_state])})),r.sort(((t,e)=>t[0]-e[0]));for(const[o,l,a,s]of r);for(;r.length&&i.sizee||t<0||"Unattempted"===n.download_state&&(i.add(n.key),n.download().catch((t=>{throw console.warn("Error on",n.key),i.delete(n.key),t})).then((()=>i.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 vR(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=Be(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 je(8))console.log(`Allocating worker ${t}`),this._tileWorkers.push(dR(new VR));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 i=[this],r=[];let o;for(;o=i.shift();)e?r.push(o):t(o),n(o)&&"Complete"==o.download_state&&i.push(...o.children);if(e)for(;o=r.pop();)t(o)}}function RR(t,e){return void 0===e||t[0]e.x[0]&&t[1]e.y[0]}function gR(t){return(t.x[1]-t.x[0])*(t.y[1]-t.y[0])}const LR=function(t){if(t.x[1]t.arrayBuffer())).then((t=>{const e=zl.from(t);return this.table=e,"complete"}))),this._promise}get_cached_crosstab_texture(t,e,n){const{x:i,y:r,z:o}=t,l=`${i}-${r}-${o}`;if(this.textures.get(l))return this.textures.get(l);const{crosstabs:a,y_domain:s,x_domain:u,shape:c}=this.crosstab_array(t,e),d=am(a);return this.textures.set(l,{texture:n.texture({type:"uint8",format:"rgba",data:d.array,height:c[0],width:a[0].length}),x_domain:u,y_domain:s,z_domain:d.extent,shape:c}),console.log(d.extent,d.array),this.textures.get(l)}crosstab_array(t,e={}){const n=new YR,i=new YR,{x:r,y:o,z:l}=t,a=this.table,s=a.getColumn(o).data.values,u=a.getColumn(r).toArray(),c=a.getColumn(l).toArray();e.x?n.prepopulate(e.x(),!1):n.prepopulate(u),e.y?i.prepopulate(e.y(),!0):i.prepopulate(s);const d=je(n.size).map((t=>new Array(i.size).fill(0)));for(let h=0;ht-2047)),y_domain:ke(s)}}}class YR 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 i of n)this.get(i);this.fixed=!0}}class KR{constructor(t,e){console.log({regl:t}),this.feature_set=e,this.element_handler=new Map,this.coord_handler=new HR(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,i={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(i)}render(t){const e=[];for(let n of this.features){n.alpha=1,n.color=[.2,.2,.2];const i={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(i,t),e.push(i)}this._render(e)}prepare_features(){this.features=[];const{feature_set:t,features:e,element_handler:n,coord_handler:i}=this;for(let r=0;rthis.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 i=this.buffers[this.current_buffer];i.subdata(e,this.current_position);const r={buffer:i,stride:n||8,offset:this.current_position};return this.lookup.set(t,r),this.current_position+=4*e.length,r}}const JR=[{id:"canvas-2d-background",nodetype:"canvas"},{id:"webgl-canvas",nodetype:"canvas"},{id:"canvas-2d",nodetype:"canvas"},{id:"deepscatter-svg",nodetype:"svg"}];export default 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 i of JR){const t=this.div.append("div").attr("id",`container-for-${i.id}`).style("position","fixed").style("top",0).style("left",0).style("pointer-events","deepscatter-svg"==i.id?"auto":"none");t.append(i.nodetype).attr("id",i.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 SR(this.source_url,t),await this._root.download(),this._renderer=new Vm("#container-for-webgl-canvas",this._root,this),this._zoom=new pb("#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=zl.from(t),n=new KR(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_:i}=t._zoom.scales();e.strokeStyle="#888888";const r=t._root.map((t=>t));for(const o of je(13))setTimeout((()=>{for(const t of r){if(t.codes[0]!=o)continue;if(!t.extent)continue;const[r,l]=t.extent.x.map((t=>n(t))),[a,s]=t.extent.y.map((t=>i(t))),u=t.codes[0];e.lineWidth=8/Math.sqrt(u),e.globalAlpha=.33,e.strokeRect(r,a,l-r,s-a),"Unattempted"!==t.download_state&&e.fillRect(r,a,l-r,s-a),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]);da(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 xR(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 i of t.polygons)this.registerPolygonMap(i);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,i=n.zoom.current_corners(),r=[],o=n.aes.filter.current.get_function();for(const l of e.points(i,!0))if(o(l)&&r.push(l),r.length>=t)return r;return r}drawContours(t,e){const n=(e||pt("body")).select("#canvas-2d").node().getContext("2d");for(const i 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=Te([.45,.25*Math.exp(Math.log(this._zoom.transform.k/2))]);const t=we(Ce().scale(this._zoom.transform.k).translate([this._zoom.transform.x,this._zoom.transform.y]),n);n.beginPath(),t(i),n.fill()}}contours(t){const e=this._renderer.calculate_contours(t),{x:n,y:i,x_:r,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(r.invert(e[0])),e[1]=i(o.invert(e[1]))}}}(e),this.drawContours(e)}} diff --git a/dist/deepscatter.umd.js b/dist/deepscatter.umd.js index 1b4c5328d..540d123f9 100644 --- a/dist/deepscatter.umd.js +++ b/dist/deepscatter.umd.js @@ -1,4 +1,4 @@ -!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=0&&"xmlns"!==(n=t.slice(0,i))&&(t=t.slice(i+1)),e.hasOwnProperty(n)?{space:e[n],local:t}:t}function i(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===t&&n.documentElement.namespaceURI===t?n.createElement(e):n.createElementNS(i,e)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var e=n(t);return(e.local?r:i)(e)}function l(){}function a(t){return null==t?l:function(){return this.querySelector(t)}}function s(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function u(){return[]}function c(t){return null==t?u:function(){return this.querySelectorAll(t)}}function d(t){return function(){return this.matches(t)}}function h(t){return function(e){return e.matches(t)}}var b=Array.prototype.find;function p(){return this.firstElementChild}var m=Array.prototype.filter;function f(){return Array.from(this.children)}function y(t){return new Array(t.length)}function Z(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function X(t){return function(){return t}}function G(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function R(t){return function(){this.removeAttribute(t)}}function g(t){return function(){this.removeAttributeNS(t.space,t.local)}}function L(t,e){return function(){this.setAttribute(t,e)}}function x(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Y(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function K(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 H(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function J(t){return function(){this.style.removeProperty(t)}}function w(t,e,n){return function(){this.style.setProperty(t,e,n)}}function _(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function I(t,e){return t.style.getPropertyValue(e)||H(t).getComputedStyle(t,null).getPropertyValue(e)}function N(t){return function(){delete this[t]}}function C(t,e){return function(){this[t]=e}}function U(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function F(t){return t.trim().split(/^|\s+/)}function B(t){return t.classList||new k(t)}function k(t){this._node=t,this._names=F(t.getAttribute("class")||"")}function T(t,e){for(var n=B(t),i=-1,r=e.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function lt(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var dt=[null];function ht(t,e){this._groups=t,this._parents=e}function bt(){return new ht([[document.documentElement]],dt)}function pt(t){return"string"==typeof t?new ht([[document.querySelector(t)]],[document.documentElement]):new ht([[t]],dt)}ht.prototype=bt.prototype={constructor:ht,select:function(t){"function"!=typeof t&&(t=a(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=g&&(g=R+1);!(S=f[g])&&++g=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);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,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?J:"function"==typeof e?_:w)(t,e,null==n?"":n)):I(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?N:"function"==typeof e?U:C)(t,e)):this.node()[t]},classed:function(t,e){var n=F(t+"");if(arguments.length<2){for(var i=B(this.node()),r=-1,o=n.length;++r0){for(o=t[--r];r>0&&(e=o,n=t[--r],o=e+n,i=n-(o-e),!i););r>0&&(i<0&&t[r-1]<0||i>0&&t[r-1]>0)&&(n=2*i,e=o+n,n==e-o&&(o=e))}return o}}var ft=1e-6,yt=Math.PI,Zt=2*yt,Xt=180/yt,Gt=yt/180,Wt=Math.abs,Vt=Math.cos,vt=Math.sin,St=Math.sqrt;function Rt(){}function gt(t,e){t&&xt.hasOwnProperty(t.type)&&xt[t.type](t,e)}var Lt={Feature:function(t,e){gt(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i=0;--o)r.point((c=u[o])[0],c[1]);else i(h.x,h.p.x,-1,r);h=h.p}u=(h=h.o).z,b=!b}while(!h.v);r.lineEnd()}}}function _t(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i0)do{u.point(0===c||3===c?t:n,c>1?i:e)}while((c=(c+a+4)%4)!==d);else u.point(o[0],o[1])}function l(i,r){return Wt(i[0]-t)0?0:3:Wt(i[0]-n)0?2:1:Wt(i[1]-e)0?1:0:r>0?3:2}function a(t,e){return s(t.x,e.x)}function s(t,e){var n=l(t,1),i=l(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){var s,u,c,d,h,b,p,m,f,y,Z,X,G,W=l,V=(G=[],{point:function(t,e,n){X.push([t,e,n])},lineStart:function(){G.push(X=[])},lineEnd:Rt,rejoin:function(){G.length>1&&G.push(G.pop().concat(G.shift()))},result:function(){var t=G;return G=[],X=null,t}}),v={point:S,lineStart:function(){v.point=R,u&&u.push(c=[]);y=!0,f=!1,p=m=NaN},lineEnd:function(){s&&(R(d,h),b&&f&&V.rejoin(),s.push(V.result()));v.point=S,f&&W.lineEnd()},polygonStart:function(){W=V,s=[],u=[],Z=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=u.length;ni&&(h-o)*(i-l)>(b-l)*(t-o)&&++e:b<=i&&(h-o)*(i-l)<(b-l)*(t-o)&&--e;return e}(),n=Z&&e,r=(d=s,s=Array.from(function*(t){for(const e of t)yield*e}(d))).length;var d;(n||r)&&(l.polygonStart(),n&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),r&&wt(s,a,e,o,l),l.polygonEnd());W=l,s=u=c=null}};function S(t,e){r(t,e)&&W.point(t,e)}function R(o,l){var a=r(o,l);if(u&&c.push([o,l]),y)d=o,h=l,b=a,y=!1,a&&(W.lineStart(),W.point(o,l));else if(a&&f)W.point(o,l);else{var s=[p=Math.max(Nt,Math.min(It,p)),m=Math.max(Nt,Math.min(It,m))],X=[o=Math.max(Nt,Math.min(It,o)),l=Math.max(Nt,Math.min(It,l))];!function(t,e,n,i,r,o){var l,a=t[0],s=t[1],u=0,c=1,d=e[0]-a,h=e[1]-s;if(l=n-a,d||!(l>0)){if(l/=d,d<0){if(l0){if(l>c)return;l>u&&(u=l)}if(l=r-a,d||!(l<0)){if(l/=d,d<0){if(l>c)return;l>u&&(u=l)}else if(d>0){if(l0)){if(l/=h,h<0){if(l0){if(l>c)return;l>u&&(u=l)}if(l=o-s,h||!(l<0)){if(l/=h,h<0){if(l>c)return;l>u&&(u=l)}else if(h>0){if(l0&&(t[0]=a+u*d,t[1]=s+u*h),c<1&&(e[0]=a+c*d,e[1]=s+c*h),!0}}}}}(s,X,t,e,n,i)?a&&(W.lineStart(),W.point(o,l),Z=!1):(f||(W.lineStart(),W.point(s[0],s[1])),W.point(X[0],X[1]),a||W.lineEnd(),Z=!1)}p=o,m=l,f=a}return v}}var Ut,Ft,Bt,kt,Tt=t=>t,zt=new mt,Mt=new mt,jt={point:Rt,lineStart:Rt,lineEnd:Rt,polygonStart:function(){jt.lineStart=Qt,jt.lineEnd=Dt},polygonEnd:function(){jt.lineStart=jt.lineEnd=jt.point=Rt,zt.add(Wt(Mt)),Mt=new mt},result:function(){var t=zt/2;return zt=new mt,t}};function Qt(){jt.point=Pt}function Pt(t,e){jt.point=Et,Ut=Bt=t,Ft=kt=e}function Et(t,e){Mt.add(kt*t-Bt*e),Bt=t,kt=e}function Dt(){Et(Ut,Ft)}var Ot=1/0,At=Ot,qt=-Ot,$t=qt,te={point:function(t,e){tqt&&(qt=t);e$t&&($t=e)},lineStart:Rt,lineEnd:Rt,polygonStart:Rt,polygonEnd:Rt,result:function(){var t=[[Ot,At],[qt,$t]];return qt=$t=-(At=Ot=1/0),t}};var ee,ne,ie,re,oe=0,le=0,ae=0,se=0,ue=0,ce=0,de=0,he=0,be=0,pe={point:me,lineStart:fe,lineEnd:Xe,polygonStart:function(){pe.lineStart=Ge,pe.lineEnd=We},polygonEnd:function(){pe.point=me,pe.lineStart=fe,pe.lineEnd=Xe},result:function(){var t=be?[de/be,he/be]:ce?[se/ce,ue/ce]:ae?[oe/ae,le/ae]:[NaN,NaN];return oe=le=ae=se=ue=ce=de=he=be=0,t}};function me(t,e){oe+=t,le+=e,++ae}function fe(){pe.point=ye}function ye(t,e){pe.point=Ze,me(ie=t,re=e)}function Ze(t,e){var n=t-ie,i=e-re,r=St(n*n+i*i);se+=r*(ie+t)/2,ue+=r*(re+e)/2,ce+=r,me(ie=t,re=e)}function Xe(){pe.point=me}function Ge(){pe.point=Ve}function We(){ve(ee,ne)}function Ve(t,e){pe.point=ve,me(ee=ie=t,ne=re=e)}function ve(t,e){var n=t-ie,i=e-re,r=St(n*n+i*i);se+=r*(ie+t)/2,ue+=r*(re+e)/2,ce+=r,de+=(r=re*t-ie*e)*(ie+t),he+=r*(re+e),be+=3*r,me(ie=t,re=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,Zt)}},result:Rt};var Re,ge,Le,xe,Ye,Ke=new mt,He={point:Rt,lineStart:function(){He.point=Je},lineEnd:function(){Re&&we(ge,Le),He.point=Rt},polygonStart:function(){Re=!0},polygonEnd:function(){Re=null},result:function(){var t=+Ke;return Ke=new mt,t}};function Je(t,e){He.point=we,ge=xe=t,Le=Ye=e}function we(t,e){xe-=t,Ye-=e,Ke.add(St(xe*xe+Ye*Ye)),xe=t,Ye=e}function _e(){this._string=[]}function Ie(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,i,r=4.5;function o(t){return t&&("function"==typeof r&&i.pointRadius(+r.apply(this,arguments)),Ht(t,n(i))),i.result()}return o.area=function(t){return Ht(t,n(jt)),jt.result()},o.measure=function(t){return Ht(t,n(He)),He.result()},o.bounds=function(t){return Ht(t,n(te)),te.result()},o.centroid=function(t){return Ht(t,n(pe)),pe.result()},o.projection=function(e){return arguments.length?(n=null==e?(t=null,Tt):(t=e).stream,o):t},o.context=function(t){return arguments.length?(i=null==t?(e=null,new _e):new Se(e=t),"function"!=typeof r&&i.pointRadius(r),o):e},o.pointRadius=function(t){return arguments.length?(r="function"==typeof t?t:(i.pointRadius(+t),+t),o):r},o.projection(t).context(e)}function Ce(){}function Ue(t,e,n){var i=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=i&&t.clipExtent(null),Ht(n,t.stream(te)),e(te.result()),null!=i&&t.clipExtent(i),t}function Fe(t,e,n){return Ue(t,(function(n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=Math.min(i/(n[1][0]-n[0][0]),r/(n[1][1]-n[0][1])),l=+e[0][0]+(i-o*(n[1][0]+n[0][0]))/2,a=+e[0][1]+(r-o*(n[1][1]+n[0][1]))/2;t.scale(150*o).translate([l,a])}),n)}function Be(){var t,e,n,i,r,o,l,a,s=1,u=0,c=0,d=1,h=1,b=0,p=null,m=1,f=1,y=(a={point:function(t,e){var n=G([t,e]);this.stream.point(n[0],n[1])}},function(t){var e=new Ce;for(var n in a)e[n]=a[n];return e.stream=t,e}),Z=Tt;function X(){return m=s*d,f=s*h,o=l=null,G}function G(n){var i=n[0]*m,r=n[1]*f;if(b){var o=r*t-i*e;i=i*t+r*e,r=o}return[i+u,r+c]}return G.invert=function(n){var i=n[0]-u,r=n[1]-c;if(b){var o=r*t+i*e;i=i*t-r*e,r=o}return[i/m,r/f]},G.stream=function(t){return o&&l===t?o:o=y(Z(l=t))},G.postclip=function(t){return arguments.length?(Z=t,p=n=i=r=null,X()):Z},G.clipExtent=function(t){return arguments.length?(Z=null==t?(p=n=i=r=null,Tt):Ct(p=+t[0][0],n=+t[0][1],i=+t[1][0],r=+t[1][1]),X()):null==p?null:[[p,n],[i,r]]},G.scale=function(t){return arguments.length?(s=+t,X()):s},G.translate=function(t){return arguments.length?(u=+t[0],c=+t[1],X()):[u,c]},G.angle=function(n){return arguments.length?(e=vt(b=n%360*Gt),t=Vt(b),X()):b*Xt},G.reflectX=function(t){return arguments.length?(d=t?-1:1,X()):d<0},G.reflectY=function(t){return arguments.length?(h=t?-1:1,X()):h<0},G.fitExtent=function(t,e){return Fe(G,t,e)},G.fitSize=function(t,e){return function(t,e,n){return Fe(t,[[0,0],e],n)}(G,t,e)},G.fitWidth=function(t,e){return function(t,e,n){return Ue(t,(function(n){var i=+e,r=i/(n[1][0]-n[0][0]),o=(i-r*(n[1][0]+n[0][0]))/2,l=-r*n[0][1];t.scale(150*r).translate([o,l])}),n)}(G,t,e)},G.fitHeight=function(t,e){return function(t,e,n){return Ue(t,(function(n){var i=+e,r=i/(n[1][1]-n[0][1]),o=-r*n[0][0],l=(i-r*(n[1][1]+n[0][1]))/2;t.scale(150*r).translate([o,l])}),n)}(G,t,e)},G}function ke(t,e){return null==t||null==e?NaN:te?1:t>=e?0:NaN}function Te(t){let e=t,n=t;function i(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)<0?i=o+1:r=o}return i}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>ke(t(e),n)}(t)),{left:i,center:function(t,n,r,o){null==r&&(r=0),null==o&&(o=t.length);const l=i(t,n,r,o-1);return l>r&&e(t[l-1],n)>-e(t[l],n)?l-1:l},right:function(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)>0?r=o:i=o+1}return i}}}_e.prototype={_radius:4.5,_circle:Ie(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=Ie(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}},Ce.prototype={constructor:Ce,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 ze=Te(ke).left;function Me(t,e){let n,i;if(void 0===e)for(const r of t)null!=r&&(void 0===n?r>=r&&(n=i=r):(n>r&&(n=r),i=o&&(n=i=o):(n>o&&(n=o),i=i)&&(n=i);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n=r)&&(n=r)}return n}function Qe(t,e){let n;if(void 0===e)for(const i of t)null!=i&&(n>i||void 0===n&&i>=i)&&(n=i);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function Pe(t,e){let n=0,i=0;if(void 0===e)for(let r of t)null!=r&&(r=+r)>=r&&(++n,i+=r);else{let r=-1;for(let o of t)null!=(o=e(o,++r,t))&&(o=+o)>=o&&(++n,i+=o)}if(n)return i/n}function Ee(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(r);++i=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)}}})); + ***************************************************************************** */function qe(t,e,n,i){return new(n||(n=Promise))((function(r,o){function l(t){try{s(i.next(t))}catch(e){o(e)}}function a(t){try{s(i.throw(t))}catch(e){o(e)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(l,a)}s((i=i.apply(t,e||[])).next())}))}function $e(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],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 i,r=n.apply(t,e||[]),o=[];return i={},l("next"),l("throw"),l("return"),i[Symbol.asyncIterator]=function(){return this},i;function l(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){o.push([t,e,n,i])>1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof tn?Promise.resolve(n.value.v).then(s,u):c(o[0][2],n)}catch(i){c(o[0][3],i)}var n}function s(t){a("next",t)}function u(t){a("throw",t)}function c(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function nn(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:tn(t[i](e)),done:"return"===i}:r?r(e):e}:r}}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=$e(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}var on={};function ln(t,e,n){return e<=t&&t<=n}function an(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 i=(n+2)*on.SIZEOF_SHORT;this.addInt16(i);var r=0,o=this.space;t:for(e=0;e=0;o--)this.writeInt8(r.charCodeAt(o))}this.prep(this.minalign,on.SIZEOF_INT+i),this.addOffset(t),i&&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,i=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(i+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)i=r;else i=(r<<10)+t.charCodeAt(n++)+-56613888;i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,l=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 i},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)+i];n>0;){var o=e>>6*(n-1);r.push(128|63&o),n-=1}return r}}hn.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=an(e),this._streaming||(this._decoder=new pn({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var i,r=new sn(n),o=[];!r.endOfStream()&&(i=this._decoder.handler(r,r.read()))!==un;)null!==i&&(Array.isArray(i)?o.push.apply(o,i):o.push(i));if(!this._streaming){do{if((i=this._decoder.handler(r,r.read()))===un)break;null!==i&&(Array.isArray(i)?o.push.apply(o,i):o.push(i))}while(!r.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&i)))}return e}(o)}},bn.prototype={encode:function(t,e){t=t?String(t):"",e=an(e),this._streaming||(this._encoder=new mn(this._options)),this._streaming=Boolean(e.stream);for(var n,i=[],r=new sn(function(t){for(var e=String(t),n=e.length,i=0,r=[];i57343)r.push(o);else if(56320<=o&&o<=57343)r.push(65533);else if(55296<=o&&o<=56319)if(i===n-1)r.push(65533);else{var l=t.charCodeAt(i+1);if(56320<=l&&l<=57343){var a=1023&o,s=1023&l;r.push(65536+(a<<10)+s),i+=1}else r.push(65533)}i+=1}return r}(t));!r.endOfStream()&&(n=this._encoder.handler(r,r.read()))!==un;)Array.isArray(n)?i.push.apply(i,n):i.push(n);if(!this._streaming){for(;(n=this._encoder.handler(r,r.read()))!==un;)Array.isArray(n)?i.push.apply(i,n):i.push(n);this._encoder=null}return new Uint8Array(i)}};const fn=new("undefined"!=typeof TextDecoder?TextDecoder:hn)("utf-8"),yn=t=>fn.decode(t),Zn=new("undefined"!=typeof TextEncoder?TextEncoder:bn),Xn=t=>Zn.encode(t),Gn=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 Vn{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 vn extends Vn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return qe(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(Gn);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return On.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return On.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return qe(this,void 0,void 0,(function*(){return yield this.abort(t),Gn}))}return(t){return qe(this,void 0,void 0,(function*(){return yield this.close(),Gn}))}read(t){return qe(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return qe(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(Gn)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error(`${this} is closed`)}}const[Sn,Rn]=(()=>{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]})(),gn=t=>"boolean"==typeof t,Ln=t=>"function"==typeof t,xn=t=>null!=t&&Object(t)===t,Yn=t=>xn(t)&&Ln(t.then),Kn=t=>xn(t)&&Ln(t[Symbol.iterator]),Hn=t=>xn(t)&&Ln(t[Symbol.asyncIterator]),Jn=t=>xn(t)&&xn(t.schema),wn=t=>xn(t)&&"done"in t&&"value"in t,_n=t=>xn(t)&&Ln(t.stat)&&(t=>"number"==typeof t)(t.fd),In=t=>xn(t)&&Nn(t.body),Nn=t=>xn(t)&&Ln(t.cancel)&&Ln(t.getReader)&&!(t instanceof Vn),Cn=t=>xn(t)&&Ln(t.read)&&Ln(t.pipe)&&gn(t.readable)&&!(t instanceof Vn);var Un=on.ByteBuffer;const Fn="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Bn(t,e,n=0,i=e.byteLength){const r=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,r),l=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return o.set(l,n),t}function kn(t,e){const n=function(t){const e=t[0]?[t[0]]:[];let n,i,r,o;for(let l,a,s=0,u=0,c=t.length;++st+e.byteLength),0);let r,o,l,a=0,s=-1;const u=Math.min(e||1/0,i);for(let c=n.length;++sTn(Int32Array,t),Mn=t=>Tn(Uint8Array,t),jn=t=>(t.next(),t);const Qn=t=>function*(t,e){const n=function*(t){yield t},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Fn?n(e):Kn(e)?e:n(e);return yield*jn(function*(e){let n=null;do{n=e.next(yield Tn(t,n))}while(!n.done)}(i[Symbol.iterator]())),new t}(Uint8Array,t);function Pn(t,e){return en(this,arguments,(function*(){if(Yn(e))return yield tn(yield tn(yield*nn(rn(Pn(t,yield tn(e))))));const n=function(t){return en(this,arguments,(function*(){yield yield tn(yield tn(t))}))},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Fn?n(e):Kn(e)?function(t){return en(this,arguments,(function*(){yield tn(yield*nn(rn(jn(function*(t){let e=null;do{e=t.next(yield e&&e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):Hn(e)?e:n(e);return yield tn(yield*nn(rn(jn(function(e){return en(this,arguments,(function*(){let n=null;do{n=yield tn(e.next(yield yield tn(Tn(t,n))))}while(!n.done)}))}(i[Symbol.asyncIterator]()))))),yield tn(new t)}))}const En=t=>Pn(Uint8Array,t);function Dn(t,e,n){if(0!==t){n=n.slice(0,e+1);for(let i=-1;++i<=e;)n[i]+=t}return n}var On={fromIterable:t=>An(function*(t){let e,n,i,r,o=!1,l=[],a=0;function s(){return"peek"===i?kn(l,r)[0]:([n,l,a]=kn(l,r),n)}({cmd:i,size:r}=yield null);const u=Qn(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=isNaN(r-a)?u.next(void 0):u.next(r-a)),!e&&n.byteLength>0&&(l.push(n),a+=n.byteLength),e||r<=a)do{({cmd:i,size:r}=yield s())}while(rAn(function(t){return en(this,arguments,(function*(){let e,n,i,r,o=!1,l=[],a=0;function s(){return"peek"===i?kn(l,r)[0]:([n,l,a]=kn(l,r),n)}({cmd:i,size:r}=yield yield tn(null));const u=En(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=isNaN(r-a)?yield tn(u.next(void 0)):yield tn(u.next(r-a))),!e&&n.byteLength>0&&(l.push(n),a+=n.byteLength),e||r<=a)do{({cmd:i,size:r}=yield yield tn(s()))}while(rAn(function(t){return en(this,arguments,(function*(){let e,n,i,r=!1,o=!1,l=[],a=0;function s(){return"peek"===n?kn(l,i)[0]:([e,l,a]=kn(l,i),e)}({cmd:n,size:i}=yield yield tn(null));const u=new qn(t);try{do{if(({done:r,value:e}=isNaN(i-a)?yield tn(u.read(void 0)):yield tn(u.read(i-a))),!r&&e.byteLength>0&&(l.push(Mn(e)),a+=e.byteLength),r||i<=a)do{({cmd:n,size:i}=yield yield tn(s()))}while(iAn(function(t){return en(this,arguments,(function*(){const e=[];let n,i,r,o="error",l=!1,a=null,s=0,u=[];function c(){return"peek"===n?kn(u,i)[0]:([r,u,s]=kn(u,i),r)}if(({cmd:n,size:i}=yield yield tn(null)),t.isTTY)return yield yield tn(new Uint8Array(0)),yield tn(null);try{e[0]=ti(t,"end"),e[1]=ti(t,"error");do{if(e[2]=ti(t,"readable"),[o,a]=yield tn(Promise.race(e.map((t=>t[2])))),"error"===o)break;if((l="end"===o)||(isFinite(i-s)?(r=Mn(t.read(i-s)),r.byteLength0&&(u.push(r),s+=r.byteLength)),l||i<=s)do{({cmd:n,size:i}=yield yield tn(c()))}while(i{for(const[n,l]of e)t.off(n,l);try{const e=t.destroy;e&&e.call(t,n),n=void 0}catch(o){n=o||n}finally{null!=n?r(n):i()}}))}}))}(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 An=t=>(t.next(),t);class qn{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 qe(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 qe(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=Mn(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 qe(this,void 0,void 0,(function*(){return yield $n(this.getBYOBReader(),new ArrayBuffer(t),0,t)}))}}function $n(t,e,n,i){return qe(this,void 0,void 0,(function*(){if(n>=i)return{done:!1,value:new Uint8Array(e,0,i)};const{done:r,value:o}=yield t.read(new Uint8Array(e,n,i-n));return(n+=o.byteLength){const n=t=>i([e,t]);let i;return[e,n,new Promise((r=>(i=r)&&t.once(e,n)))]};class ei{}var ni,ii,ri,oi,li,ai,si,ui,ci,di,hi,bi,pi,mi,fi,yi,Zi,Xi,Gi,Wi,Vi,vi,Si,Ri,gi,Li,xi,Yi,Ki,Hi;ei.prototype.data=null,(ii=ni||(ni={}))[ii.V1=0]="V1",ii[ii.V2=1]="V2",ii[ii.V3=2]="V3",ii[ii.V4=3]="V4",ii[ii.V5=4]="V5",(oi=ri||(ri={}))[oi.UNUSED=0]="UNUSED",oi[oi.DICTIONARY_REPLACEMENT=1]="DICTIONARY_REPLACEMENT",oi[oi.COMPRESSED_BODY=2]="COMPRESSED_BODY",(ai=li||(li={}))[ai.Sparse=0]="Sparse",ai[ai.Dense=1]="Dense",(ui=si||(si={}))[ui.HALF=0]="HALF",ui[ui.SINGLE=1]="SINGLE",ui[ui.DOUBLE=2]="DOUBLE",(di=ci||(ci={}))[di.DAY=0]="DAY",di[di.MILLISECOND=1]="MILLISECOND",(bi=hi||(hi={}))[bi.SECOND=0]="SECOND",bi[bi.MILLISECOND=1]="MILLISECOND",bi[bi.MICROSECOND=2]="MICROSECOND",bi[bi.NANOSECOND=3]="NANOSECOND",(mi=pi||(pi={}))[mi.YEAR_MONTH=0]="YEAR_MONTH",mi[mi.DAY_TIME=1]="DAY_TIME",(yi=fi||(fi={}))[yi.NONE=0]="NONE",yi[yi.Null=1]="Null",yi[yi.Int=2]="Int",yi[yi.FloatingPoint=3]="FloatingPoint",yi[yi.Binary=4]="Binary",yi[yi.Utf8=5]="Utf8",yi[yi.Bool=6]="Bool",yi[yi.Decimal=7]="Decimal",yi[yi.Date=8]="Date",yi[yi.Time=9]="Time",yi[yi.Timestamp=10]="Timestamp",yi[yi.Interval=11]="Interval",yi[yi.List=12]="List",yi[yi.Struct_=13]="Struct_",yi[yi.Union=14]="Union",yi[yi.FixedSizeBinary=15]="FixedSizeBinary",yi[yi.FixedSizeList=16]="FixedSizeList",yi[yi.Map=17]="Map",yi[yi.Duration=18]="Duration",yi[yi.LargeBinary=19]="LargeBinary",yi[yi.LargeUtf8=20]="LargeUtf8",yi[yi.LargeList=21]="LargeList",(Xi=Zi||(Zi={}))[Xi.DenseArray=0]="DenseArray",(Wi=Gi||(Gi={}))[Wi.Little=0]="Little",Wi[Wi.Big=1]="Big";class Ji{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 Ji).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ji).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Ji.startNull(t),Ji.endNull(t)}}class wi{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 wi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new wi).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return wi.startStruct_(t),wi.endStruct_(t)}}class _i{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 _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new _i).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return _i.startList(t),_i.endList(t)}}class Ii{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 Ii).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ii).__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 Ii.startFixedSizeList(t),Ii.addListSize(t,e),Ii.endFixedSizeList(t)}}class Ni{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 Ni).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ni).__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 Ni.startMap(t),Ni.addKeysSorted(t,e),Ni.endMap(t)}}class Ci{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 Ci).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ci).__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):li.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,li.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 Ci.startUnion(t),Ci.addMode(t,e),Ci.addTypeIds(t,n),Ci.endUnion(t)}}class Ui{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 Ui).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ui).__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 Ui.startInt(t),Ui.addBitWidth(t,e),Ui.addIsSigned(t,n),Ui.endInt(t)}}class Fi{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 Fi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Fi).__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):si.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,si.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Fi.startFloatingPoint(t),Fi.addPrecision(t,e),Fi.endFloatingPoint(t)}}class Bi{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 Bi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Bi).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Bi.startUtf8(t),Bi.endUtf8(t)}}class ki{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 ki).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ki).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return ki.startBinary(t),ki.endBinary(t)}}class Ti{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 Ti).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ti).__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 Ti.startFixedSizeBinary(t),Ti.addByteWidth(t,e),Ti.endFixedSizeBinary(t)}}class zi{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 zi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new zi).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return zi.startBool(t),zi.endBool(t)}}class Mi{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 Mi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Mi).__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,i){return Mi.startDecimal(t),Mi.addPrecision(t,e),Mi.addScale(t,n),Mi.addBitWidth(t,i),Mi.endDecimal(t)}}class ji{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 ji).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ji).__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):ci.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,ci.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return ji.startDate(t),ji.addUnit(t,e),ji.endDate(t)}}class Qi{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 Qi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Qi).__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):hi.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,hi.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return Qi.startTime(t),Qi.addUnit(t,e),Qi.addBitWidth(t,n),Qi.endTime(t)}}class Pi{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 Pi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Pi).__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):hi.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,hi.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Pi.startTimestamp(t),Pi.addUnit(t,e),Pi.addTimezone(t,n),Pi.endTimestamp(t)}}class Ei{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 Ei).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ei).__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):pi.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,pi.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return Ei.startInterval(t),Ei.addUnit(t,e),Ei.endInterval(t)}}class Di{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 Di).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Di).__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 Di.startKeyValue(t),Di.addKey(t,e),Di.addValue(t,n),Di.endKeyValue(t)}}class Oi{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 Oi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Oi).__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 Ui).__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):Zi.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,Zi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}static createDictionaryEncoding(t,e,n,i,r){return Oi.startDictionaryEncoding(t),Oi.addId(t,e),Oi.addIndexType(t,n),Oi.addIsOrdered(t,i),Oi.addDictionaryKind(t,r),Oi.endDictionaryEncoding(t)}}class Ai{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 Ai).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Ai).__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):fi.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 Oi).__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 Ai).__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 Di).__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,fi.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,i,r,o,l,a){return Ai.startField(t),Ai.addName(t,e),Ai.addNullable(t,n),Ai.addTypeType(t,i),Ai.addType(t,r),Ai.addDictionary(t,o),Ai.addChildren(t,l),Ai.addCustomMetadata(t,a),Ai.endField(t)}}class qi{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 $i{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 $i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new $i).__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):Gi.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Ai).__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 Di).__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,Gi.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,i,r){return $i.startSchema(t),$i.addEndianness(t,e),$i.addFields(t,n),$i.addCustomMetadata(t,i),$i.addFeatures(t,r),$i.endSchema(t)}}(vi=Vi||(Vi={}))[vi.LZ4_FRAME=0]="LZ4_FRAME",vi[vi.ZSTD=1]="ZSTD",(Ri=Si||(Si={}))[Ri.BUFFER=0]="BUFFER",(Li=gi||(gi={}))[Li.NONE=0]="NONE",Li[Li.Schema=1]="Schema",Li[Li.DictionaryBatch=2]="DictionaryBatch",Li[Li.RecordBatch=3]="RecordBatch",Li[Li.Tensor=4]="Tensor",Li[Li.SparseTensor=5]="SparseTensor";class tr{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 er{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 er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new er).__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):Vi.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Si.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Vi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Si.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return er.startBodyCompression(t),er.addCodec(t,e),er.addMethod(t,n),er.endBodyCompression(t)}}class nr{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 nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new nr).__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 tr).__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 qi).__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 er).__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,i,r){return nr.startRecordBatch(t),nr.addLength(t,e),nr.addNodes(t,n),nr.addBuffers(t,i),nr.addCompression(t,r),nr.endRecordBatch(t)}}class ir{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 ir).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new ir).__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 nr).__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,i){return ir.startDictionaryBatch(t),ir.addId(t,e),ir.addData(t,n),ir.addIsDelta(t,i),ir.endDictionaryBatch(t)}}class rr{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 rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new rr).__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):ni.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):gi.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 Di).__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,ni.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,gi.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,i,r,o){return rr.startMessage(t),rr.addVersion(t,e),rr.addHeaderType(t,n),rr.addHeader(t,i),rr.addBodyLength(t,r),rr.addCustomMetadata(t,o),rr.endMessage(t)}}function or(t,e,n,i){return 0!=(n&1<>i}function ar(t,e,n){const i=n.byteLength+7&-8;if(t>0||n.byteLength>3):sr(new ur(n,t,e,null,or)).subarray(0,i)),r}return n}function sr(t){const e=[];let n=0,i=0,r=0;for(const l of t)l&&(r|=1<0)&&(e[n++]=r);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"}(xi||(xi={})),(Ki=Yi||(Yi={}))[Ki.OFFSET=0]="OFFSET",Ki[Ki.DATA=1]="DATA",Ki[Ki.VALIDITY=2]="VALIDITY",Ki[Ki.TYPE=3]="TYPE";class ur{constructor(t,e,n,i,r){this.bytes=t,this.length=n,this.context=i,this.get=r,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=e+(e%8==0?0:8-e%8);return cr(t,e,r)+cr(t,i,n)+function(t,e,n){let i=0,r=0|e;const o=new DataView(t.buffer,t.byteOffset,t.byteLength),l=void 0===n?t.byteLength:r+n;for(;l-r>=4;)i+=dr(o.getUint32(r)),r+=4;for(;l-r>=2;)i+=dr(o.getUint16(r)),r+=2;for(;l-r>=1;)i+=dr(o.getUint8(r)),r+=1;return i}(t,r>>3,i-r>>3)}function dr(t){let e=0|t;return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class hr{static isNull(t){return t&&t.typeId===xi.Null}static isInt(t){return t&&t.typeId===xi.Int}static isFloat(t){return t&&t.typeId===xi.Float}static isBinary(t){return t&&t.typeId===xi.Binary}static isUtf8(t){return t&&t.typeId===xi.Utf8}static isBool(t){return t&&t.typeId===xi.Bool}static isDecimal(t){return t&&t.typeId===xi.Decimal}static isDate(t){return t&&t.typeId===xi.Date}static isTime(t){return t&&t.typeId===xi.Time}static isTimestamp(t){return t&&t.typeId===xi.Timestamp}static isInterval(t){return t&&t.typeId===xi.Interval}static isList(t){return t&&t.typeId===xi.List}static isStruct(t){return t&&t.typeId===xi.Struct}static isUnion(t){return t&&t.typeId===xi.Union}static isFixedSizeBinary(t){return t&&t.typeId===xi.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===xi.FixedSizeList}static isMap(t){return t&&t.typeId===xi.Map}static isDictionary(t){return t&&t.typeId===xi.Dictionary}get typeId(){return xi.NONE}}hr[Symbol.toStringTag]=((Hi=hr.prototype).children=null,Hi.ArrayType=Array,Hi[Symbol.toStringTag]="DataType");class br extends hr{toString(){return"Null"}get typeId(){return xi.Null}}br[Symbol.toStringTag]=(t=>t[Symbol.toStringTag]="Null")(br.prototype);class pr extends hr{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return xi.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}`}}pr[Symbol.toStringTag]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(pr.prototype);class mr extends pr{constructor(){super(!0,32)}}Object.defineProperty(class extends pr{constructor(){super(!0,8)}}.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(class extends pr{constructor(){super(!0,16)}}.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(mr.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends pr{constructor(){super(!0,64)}}.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends pr{constructor(){super(!1,8)}}.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(class extends pr{constructor(){super(!1,16)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends pr{constructor(){super(!1,32)}}.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(class extends pr{constructor(){super(!1,64)}}.prototype,"ArrayType",{value:Uint32Array});class fr extends hr{constructor(t){super(),this.precision=t}get typeId(){return xi.Float}get ArrayType(){switch(this.precision){case si.HALF:return Uint16Array;case si.SINGLE:return Float32Array;case si.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}fr[Symbol.toStringTag]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(fr.prototype);Object.defineProperty(class extends fr{constructor(){super(si.HALF)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends fr{constructor(){super(si.SINGLE)}}.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(class extends fr{constructor(){super(si.DOUBLE)}}.prototype,"ArrayType",{value:Float64Array});class yr extends hr{constructor(){super()}get typeId(){return xi.Binary}toString(){return"Binary"}}yr[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(yr.prototype);class Zr extends hr{constructor(){super()}get typeId(){return xi.Utf8}toString(){return"Utf8"}}Zr[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Zr.prototype);class Xr extends hr{constructor(){super()}get typeId(){return xi.Bool}toString(){return"Bool"}}Xr[Symbol.toStringTag]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Xr.prototype);class Gr extends hr{constructor(t,e){super(),this.scale=t,this.precision=e}get typeId(){return xi.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Gr[Symbol.toStringTag]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(Gr.prototype);class Wr extends hr{constructor(t){super(),this.unit=t}get typeId(){return xi.Date}toString(){return`Date${32*(this.unit+1)}<${ci[this.unit]}>`}}Wr[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(Wr.prototype);class Vr extends hr{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return xi.Time}toString(){return`Time${this.bitWidth}<${hi[this.unit]}>`}}Vr[Symbol.toStringTag]=(t=>(t.unit=null,t.bitWidth=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Time"))(Vr.prototype);class vr extends hr{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return xi.Timestamp}toString(){return`Timestamp<${hi[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}vr[Symbol.toStringTag]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(vr.prototype);class Sr extends hr{constructor(t){super(),this.unit=t}get typeId(){return xi.Interval}toString(){return`Interval<${pi[this.unit]}>`}}Sr[Symbol.toStringTag]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Sr.prototype);class Rr extends hr{constructor(t){super(),this.children=[t]}get typeId(){return xi.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}}Rr[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Rr.prototype);class gr extends hr{constructor(t){super(),this.children=t}get typeId(){return xi.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}gr[Symbol.toStringTag]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(gr.prototype);class Lr extends hr{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 xi.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}Lr[Symbol.toStringTag]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Lr.prototype);class xr extends hr{constructor(t){super(),this.byteWidth=t}get typeId(){return xi.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}xr[Symbol.toStringTag]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(xr.prototype);class Yr extends hr{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return xi.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}>`}}Yr[Symbol.toStringTag]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Yr.prototype);class Kr extends hr{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return xi.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(", ")}}>`}}Kr[Symbol.toStringTag]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Kr.prototype);const Hr=(Jr=-1,()=>++Jr);var Jr;class wr extends hr{constructor(t,e,n,i){super(),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=null==n?Hr():"number"==typeof n?n:n.low}get typeId(){return xi.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}>`}}wr[Symbol.toStringTag]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(wr.prototype);class _r{constructor(t,e,n,i,r,o,l){let a;this.type=t,this.dictionary=l,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1)),this.childData=(o||[]).map((t=>t instanceof _r?t:t.data)),r instanceof _r?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=function(t){const e=t;switch(t.typeId){case xi.Decimal:return 4;case xi.Timestamp:return 2;case xi.Date:case xi.Interval:return 1+e.unit;case xi.Int:case xi.Time:return+(e.bitWidth>32)+1;case xi.FixedSizeList:return e.listSize;case xi.FixedSizeBinary:return e.byteWidth;default:return 1}}(t),r&&((a=r[0])&&(this.valueOffsets=a),(a=r[1])&&(this.values=a),(a=r[2])&&(this.nullBitmap=a),(a=r[3])&&(this.typeIds=a)))}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:i,typeIds:r}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.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-cr(t,this.offset,this.offset+this.length)),e}clone(t,e=this.offset,n=this.length,i=this._nullCount,r=this,o=this.childData){return new _r(t,e,n,i,r,o,this.dictionary)}slice(t,e){const{stride:n,typeId:i,childData:r}=this,o=+(0===this._nullCount)-1,l=16===i?n:1,a=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,a,!r.length||this.valueOffsets?r:this._sliceChildren(r,l*t,l*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===xi.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(ar(this.offset,e,this.nullBitmap),0);const r=this.buffers;return r[Yi.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)}_sliceBuffers(t,e,n,i){let r;const{buffers:o}=this;return(r=o[Yi.TYPE])&&(o[Yi.TYPE]=r.subarray(t,t+e)),(r=o[Yi.OFFSET])&&(o[Yi.OFFSET]=r.subarray(t,t+e+1))||(r=o[Yi.DATA])&&(o[Yi.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}static new(t,e,n,i,r,o,l){switch(r instanceof _r?r=r.buffers:r||(r=[]),t.typeId){case xi.Null:return _r.Null(t,e,n);case xi.Int:return _r.Int(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Dictionary:return _r.Dictionary(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[],l);case xi.Float:return _r.Float(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Bool:return _r.Bool(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Decimal:return _r.Decimal(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Date:return _r.Date(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Time:return _r.Time(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Timestamp:return _r.Timestamp(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Interval:return _r.Interval(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.FixedSizeBinary:return _r.FixedSizeBinary(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.DATA]||[]);case xi.Binary:return _r.Binary(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.OFFSET]||[],r[Yi.DATA]||[]);case xi.Utf8:return _r.Utf8(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.OFFSET]||[],r[Yi.DATA]||[]);case xi.List:return _r.List(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.OFFSET]||[],(o||[])[0]);case xi.FixedSizeList:return _r.FixedSizeList(t,e,n,i||0,r[Yi.VALIDITY],(o||[])[0]);case xi.Struct:return _r.Struct(t,e,n,i||0,r[Yi.VALIDITY],o||[]);case xi.Map:return _r.Map(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.OFFSET]||[],(o||[])[0]);case xi.Union:return _r.Union(t,e,n,i||0,r[Yi.VALIDITY],r[Yi.TYPE]||[],r[Yi.OFFSET]||o,o)}throw new Error(`Unrecognized typeId ${t.typeId}`)}static Null(t,e,n){return new _r(t,e,n,0)}static Int(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Dictionary(t,e,n,i,r,o,l){return new _r(t,e,n,i,[void 0,Tn(t.indices.ArrayType,o),Mn(r)],[],l)}static Float(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Bool(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Decimal(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Date(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Time(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Timestamp(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Interval(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static FixedSizeBinary(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,Tn(t.ArrayType,o),Mn(r)])}static Binary(t,e,n,i,r,o,l){return new _r(t,e,n,i,[zn(o),Mn(l),Mn(r)])}static Utf8(t,e,n,i,r,o,l){return new _r(t,e,n,i,[zn(o),Mn(l),Mn(r)])}static List(t,e,n,i,r,o,l){return new _r(t,e,n,i,[zn(o),void 0,Mn(r)],l?[l]:[])}static FixedSizeList(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,void 0,Mn(r)],o?[o]:[])}static Struct(t,e,n,i,r,o){return new _r(t,e,n,i,[void 0,void 0,Mn(r)],o)}static Map(t,e,n,i,r,o,l){return new _r(t,e,n,i,[zn(o),void 0,Mn(r)],l?[l]:[])}static Union(t,e,n,i,r,o,l,a){const s=[void 0,void 0,Mn(r),Tn(t.ArrayType,o)];return t.mode===li.Sparse?new _r(t,e,n,i,s,l):(s[Yi.OFFSET]=zn(l),new _r(t,e,n,i,s,a))}}_r.prototype.childData=Object.freeze([]);function Ir(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 Nr{constructor(t=[],e,n){this.fields=t||[],this.metadata=e||new Map,n||(n=Fr(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 Nr(this.fields.filter((t=>e[t.name])),this.metadata)}selectAt(...t){return new Nr(t.map((t=>this.fields[t])).filter(Boolean),this.metadata)}assign(...t){const e=t[0]instanceof Nr?t[0]:Array.isArray(t[0])?new Nr(t[0]):new Nr(t),n=[...this.fields],i=Ur(Ur(new Map,this.metadata),e.metadata),r=e.fields.filter((t=>{const e=n.findIndex((e=>e.name===t.name));return!~e||(n[e]=t.clone({metadata:Ur(Ur(new Map,n[e].metadata),t.metadata)}))&&!1})),o=Fr(r,new Map);return new Nr([...n,...r],i,new Map([...this.dictionaries,...o]))}}class Cr{constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}static new(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===n&&(n=t[0].type),void 0===i&&(i=t[0].nullable),void 0===r&&(r=t[0].metadata)),new Cr(`${e}`,n,i,r)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:r=this.metadata}=t[0]):[e=this.name,n=this.type,i=this.nullable,r=this.metadata]=t,Cr.new(e,n,i,r)}}function Ur(t,e){return new Map([...t||new Map,...e||new Map])}function Fr(t,e=new Map){for(let n=-1,i=t.length;++n0&&Fr(i.children,e)}return e}Nr.prototype.fields=null,Nr.prototype.metadata=null,Nr.prototype.dictionaries=null,Cr.prototype.type=null,Cr.prototype.name=null,Cr.prototype.nullable=null,Cr.prototype.metadata=null;class Br{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 i=null,r=xi.NONE;e instanceof _r||e instanceof ei?r=kr(e.type):e instanceof hr?r=kr(e):"number"!=typeof(r=e)&&(r=xi[e]);switch(r){case xi.Null:i=t.visitNull;break;case xi.Bool:i=t.visitBool;break;case xi.Int:i=t.visitInt;break;case xi.Int8:i=t.visitInt8||t.visitInt;break;case xi.Int16:i=t.visitInt16||t.visitInt;break;case xi.Int32:i=t.visitInt32||t.visitInt;break;case xi.Int64:i=t.visitInt64||t.visitInt;break;case xi.Uint8:i=t.visitUint8||t.visitInt;break;case xi.Uint16:i=t.visitUint16||t.visitInt;break;case xi.Uint32:i=t.visitUint32||t.visitInt;break;case xi.Uint64:i=t.visitUint64||t.visitInt;break;case xi.Float:i=t.visitFloat;break;case xi.Float16:i=t.visitFloat16||t.visitFloat;break;case xi.Float32:i=t.visitFloat32||t.visitFloat;break;case xi.Float64:i=t.visitFloat64||t.visitFloat;break;case xi.Utf8:i=t.visitUtf8;break;case xi.Binary:i=t.visitBinary;break;case xi.FixedSizeBinary:i=t.visitFixedSizeBinary;break;case xi.Date:i=t.visitDate;break;case xi.DateDay:i=t.visitDateDay||t.visitDate;break;case xi.DateMillisecond:i=t.visitDateMillisecond||t.visitDate;break;case xi.Timestamp:i=t.visitTimestamp;break;case xi.TimestampSecond:i=t.visitTimestampSecond||t.visitTimestamp;break;case xi.TimestampMillisecond:i=t.visitTimestampMillisecond||t.visitTimestamp;break;case xi.TimestampMicrosecond:i=t.visitTimestampMicrosecond||t.visitTimestamp;break;case xi.TimestampNanosecond:i=t.visitTimestampNanosecond||t.visitTimestamp;break;case xi.Time:i=t.visitTime;break;case xi.TimeSecond:i=t.visitTimeSecond||t.visitTime;break;case xi.TimeMillisecond:i=t.visitTimeMillisecond||t.visitTime;break;case xi.TimeMicrosecond:i=t.visitTimeMicrosecond||t.visitTime;break;case xi.TimeNanosecond:i=t.visitTimeNanosecond||t.visitTime;break;case xi.Decimal:i=t.visitDecimal;break;case xi.List:i=t.visitList;break;case xi.Struct:i=t.visitStruct;break;case xi.Union:i=t.visitUnion;break;case xi.DenseUnion:i=t.visitDenseUnion||t.visitUnion;break;case xi.SparseUnion:i=t.visitSparseUnion||t.visitUnion;break;case xi.Dictionary:i=t.visitDictionary;break;case xi.Interval:i=t.visitInterval;break;case xi.IntervalDayTime:i=t.visitIntervalDayTime||t.visitInterval;break;case xi.IntervalYearMonth:i=t.visitIntervalYearMonth||t.visitInterval;break;case xi.FixedSizeList:i=t.visitFixedSizeList;break;case xi.Map:i=t.visitMap}if("function"==typeof i)return i;if(!n)return()=>null;throw new Error(`Unrecognized type '${xi[r]}'`)}(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 kr(t){switch(t.typeId){case xi.Null:return xi.Null;case xi.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?xi.Int8:xi.Uint8;case 16:return n?xi.Int16:xi.Uint16;case 32:return n?xi.Int32:xi.Uint32;case 64:return n?xi.Int64:xi.Uint64}return xi.Int}case xi.Float:switch(t.precision){case si.HALF:return xi.Float16;case si.SINGLE:return xi.Float32;case si.DOUBLE:return xi.Float64}return xi.Float;case xi.Binary:return xi.Binary;case xi.Utf8:return xi.Utf8;case xi.Bool:return xi.Bool;case xi.Decimal:return xi.Decimal;case xi.Time:switch(t.unit){case hi.SECOND:return xi.TimeSecond;case hi.MILLISECOND:return xi.TimeMillisecond;case hi.MICROSECOND:return xi.TimeMicrosecond;case hi.NANOSECOND:return xi.TimeNanosecond}return xi.Time;case xi.Timestamp:switch(t.unit){case hi.SECOND:return xi.TimestampSecond;case hi.MILLISECOND:return xi.TimestampMillisecond;case hi.MICROSECOND:return xi.TimestampMicrosecond;case hi.NANOSECOND:return xi.TimestampNanosecond}return xi.Timestamp;case xi.Date:switch(t.unit){case ci.DAY:return xi.DateDay;case ci.MILLISECOND:return xi.DateMillisecond}return xi.Date;case xi.Interval:switch(t.unit){case pi.DAY_TIME:return xi.IntervalDayTime;case pi.YEAR_MONTH:return xi.IntervalYearMonth}return xi.Interval;case xi.Map:return xi.Map;case xi.List:return xi.List;case xi.Struct:return xi.Struct;case xi.Union:switch(t.mode){case li.Dense:return xi.DenseUnion;case li.Sparse:return xi.SparseUnion}return xi.Union;case xi.FixedSizeBinary:return xi.FixedSizeBinary;case xi.FixedSizeList:return xi.FixedSizeList;case xi.Dictionary:return xi.Dictionary}throw new Error(`Unrecognized type '${xi[t.typeId]}'`)}Br.prototype.visitInt8=null,Br.prototype.visitInt16=null,Br.prototype.visitInt32=null,Br.prototype.visitInt64=null,Br.prototype.visitUint8=null,Br.prototype.visitUint16=null,Br.prototype.visitUint32=null,Br.prototype.visitUint64=null,Br.prototype.visitFloat16=null,Br.prototype.visitFloat32=null,Br.prototype.visitFloat64=null,Br.prototype.visitDateDay=null,Br.prototype.visitDateMillisecond=null,Br.prototype.visitTimestampSecond=null,Br.prototype.visitTimestampMillisecond=null,Br.prototype.visitTimestampMicrosecond=null,Br.prototype.visitTimestampNanosecond=null,Br.prototype.visitTimeSecond=null,Br.prototype.visitTimeMillisecond=null,Br.prototype.visitTimeMicrosecond=null,Br.prototype.visitTimeNanosecond=null,Br.prototype.visitDenseUnion=null,Br.prototype.visitSparseUnion=null,Br.prototype.visitIntervalDayTime=null,Br.prototype.visitIntervalYearMonth=null;class Tr{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 Tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+on.SIZE_PREFIX_LENGTH),(e||new Tr).__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):ni.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new $i).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new zr).__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 zr).__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 Di).__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,ni.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,i,r,o){return Tr.startFooter(t),Tr.addVersion(t,e),Tr.addSchema(t,n),Tr.addDictionaries(t,i),Tr.addRecordBatches(t,r),Tr.addCustomMetadata(t,o),Tr.endFooter(t)}}class zr{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,i){return t.prep(8,24),t.writeInt64(i),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()}}var Mr=on.Long,jr=on.Builder,Qr=on.ByteBuffer;class Pr{constructor(t,e=ni.V4,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}static decode(t){t=new Qr(Mn(t));const e=Tr.getRootAsFooter(t),n=Nr.decode(e.schema());return new Er(n,e)}static encode(t){const e=new jr,n=Nr.encode(e,t.schema);Tr.startRecordBatchesVector(e,t.numRecordBatches),[...t.recordBatches()].slice().reverse().forEach((t=>Dr.encode(e,t)));const i=e.endVector();Tr.startDictionariesVector(e,t.numDictionaries),[...t.dictionaryBatches()].slice().reverse().forEach((t=>Dr.encode(e,t)));const r=e.endVector();return Tr.startFooter(e),Tr.addSchema(e,n),Tr.addVersion(e,ni.V4),Tr.addRecordBatches(e,i),Tr.addDictionaries(e,r),Tr.finishFooterBuffer(e,Tr.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?yn(this.toUint8Array(!0)):this.toUint8Array(!1).then(yn)}toUint8Array(t=!1){return t?kn(this._values)[0]:(()=>qe(this,void 0,void 0,(function*(){var t,e;const n=[];let i=0;try{for(var r,o=rn(this);!(r=yield o.next()).done;){const t=r.value;n.push(t),i+=t.byteLength}}catch(l){t={error:l}}finally{try{r&&!r.done&&(e=o.return)&&(yield e.call(o))}finally{if(t)throw t.error}}return kn(n,i)[0]})))()}}class Ar{constructor(t){t&&(this.source=new $r(On.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 qr{constructor(t){t instanceof qr?this.source=t.source:t instanceof Or?this.source=new to(On.fromAsyncIterable(t)):Cn(t)?this.source=new to(On.fromNodeStream(t)):Nn(t)?this.source=new to(On.fromDOMStream(t)):In(t)?this.source=new to(On.fromDOMStream(t.body)):Kn(t)?this.source=new to(On.fromIterable(t)):(Yn(t)||Hn(t))&&(this.source=new to(On.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 $r{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)||Gn)}return(t){return Object.create(this.source.return&&this.source.return(t)||Gn)}}class to{constructor(t){this.source=t,this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}cancel(t){return qe(this,void 0,void 0,(function*(){yield this.return(t)}))}get closed(){return this._closedPromise}read(t){return qe(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return qe(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(t,e="read"){return qe(this,void 0,void 0,(function*(){return yield this.source.next({cmd:e,size:t})}))}throw(t){return qe(this,void 0,void 0,(function*(){const e=this.source.throw&&(yield this.source.throw(t))||Gn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}return(t){return qe(this,void 0,void 0,(function*(){const e=this.source.return&&(yield this.source.return(t))||Gn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}}class eo extends Ar{constructor(t,e){super(),this.position=0,this.buffer=Mn(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),tqe(this,void 0,void 0,(function*(){this.size=(yield t.stat()).size,delete this._pending})))()}readInt32(t){return qe(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 qe(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 i=e[3]*n[3];this.buffer[0]=65535&i;let r=i>>>16;return i=e[2]*n[3],r+=i,i=e[3]*n[2]>>>0,r+=i,this.buffer[0]+=r<<16,this.buffer[1]=r>>>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`${io(this.buffer[3])} ${io(this.buffer[2])} ${io(this.buffer[1])} ${io(this.buffer[0])}`}static multiply(t,e){return new so(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new so(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return so.fromString("string"==typeof t?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return so.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const n=t.startsWith("-"),i=t.length,r=new so(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 co extends uo{constructor(t,e,n,i){super(new Uint8Array(0),e,n,i),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):sr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Tn(Uint8Array,Tn(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Tn(Uint8Array,Tn(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:n}=this;return hr.isTimestamp(t)||(hr.isInt(t)||hr.isTime(t))&&64===t.bitWidth||hr.isDate(t)&&t.unit===ci.MILLISECOND?Tn(Uint8Array,ao.convertArray(n[e])):hr.isDecimal(t)?Tn(Uint8Array,so.convertArray(n[e])):hr.isBinary(t)||hr.isFixedSizeBinary(t)?function(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let i=0;i>1]=parseInt(e.substr(i,2),16);return n}(n[e]):hr.isBool(t)?sr(n[e]):hr.isUtf8(t)?Xn(n[e].join("")):Tn(Uint8Array,Tn(t.ArrayType,n[e].map((t=>+t))))}}const ho=Symbol.for("parent"),bo=Symbol.for("rowIndex"),po=Symbol.for("keyToIdx"),mo=Symbol.for("idxToVal"),fo=Symbol.for("nodejs.util.inspect.custom");class yo{constructor(t,e){this[ho]=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 i=n.get(t);if(void 0!==i){const t=this[mo]||(this[mo]=new Array(this.size));void 0!==(e=t[i])||(t[i]=e=this.getValue(i))}else if((i=this.getIndex(t))>-1){n.set(t,i);const r=this[mo]||(this[mo]=new Array(this.size));void 0!==(e=r[i])||(r[i]=e=this.getValue(i))}}return e}set(t,e){if(null!=t){const n=this[po]||(this[po]=new Map);let i=n.get(t);if(void 0===i&&n.set(t,i=this.getIndex(t)),i>-1){(this[mo]||(this[mo]=new Array(this.size)))[i]=this.setValue(i,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),i=this[mo]||(this[mo]=new Array(this.size));for(let r,o,l,a,s=0;!(l=t.next()).done&&!(a=e.next()).done;++s)r=l.value,o=a.value,i[s]=o,n.has(r)||n.set(r,s),yield[r,o]}forEach(t,e){const n=this.keys(),i=this.values(),r=void 0===e?t:(n,i,r)=>t.call(e,n,i,r),o=this[po]||(this[po]=new Map),l=this[mo]||(this[mo]=new Array(this.size));for(let a,s,u,c,d=0;!(u=n.next()).done&&!(c=i.next()).done;++d)a=u.value,s=c.value,l[d]=s,o.has(a)||o.set(a,d),r(s,a,this)}toArray(){return[...this.values()]}toJSON(){const t={};return this.forEach(((e,n)=>t[n]=e)),t}inspect(){return this.toString()}[fo](){return this.toString()}toString(){const t=[];return this.forEach(((e,n)=>{n=Ir(n),e=Ir(e),t.push(`${n}: ${e}`)})),`{ ${t.join(", ")} }`}}yo[Symbol.toStringTag]=(t=>(Object.defineProperties(t,{size:{writable:!0,enumerable:!1,configurable:!1,value:0},[ho]:{writable:!0,enumerable:!1,configurable:!1,value:null},[bo]:{writable:!0,enumerable:!1,configurable:!1,value:-1}}),t[Symbol.toStringTag]="Row"))(yo.prototype);class Zo extends yo{constructor(t){return super(t,t.type.children.length),Xo(this)}*keys(){for(const t of this[ho].type.children)yield t.name}*values(){for(const t of this[ho].type.children)yield this[t.name]}getKey(t){return this[ho].type.children[t].name}getIndex(t){return this[ho].type.children.findIndex((e=>e.name===t))}getValue(t){return this[ho].getChildAt(t).get(this[bo])}setValue(t,e){return this[ho].getChildAt(t).set(this[bo],e)}}Object.setPrototypeOf(yo.prototype,Map.prototype);const Xo=(()=>{const t={enumerable:!0,configurable:!1,get:null,set:null};return e=>{let n=-1;const i=e[po]||(e[po]=new Map),r=t=>function(){return this.get(t)},o=t=>function(e){return this.set(t,e)};for(const l of e.keys())i.set(l,++n),t.get=r(l),t.set=o(l),Object.prototype.hasOwnProperty.call(e,l)||(t.enumerable=!0,Object.defineProperty(e,l,t)),Object.prototype.hasOwnProperty.call(e,n)||(t.enumerable=!1,Object.defineProperty(e,n,t));return t.get=t.set=null,e}})();let Go;function Wo(t,e,n,i){const{length:r=0}=t;let o="number"!=typeof e?0:e,l="number"!=typeof n?r:n;return o<0&&(o=(o%r+r)%r),l<0&&(l=(l%r+r)%r),lr&&(l=r),i?i(t,o,l):[o,l]}(()=>{if("undefined"==typeof Proxy)return Xo;const t=yo.prototype.has,e=yo.prototype.get,n=yo.prototype.set,i=yo.prototype.getKey,r={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 ho:case bo:case mo:case po:case fo:return!0}return"number"!=typeof e||t.has(e)||(e=t.getKey(e)),t.has(e)},get(n,r,o){switch(r){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 ho:case bo:case mo:case po:case fo:return Reflect.get(n,r,o)}return"number"!=typeof r||t.call(o,r)||(r=i.call(o,r)),e.call(o,r)},set(e,r,o,l){switch(r){case ho:case bo:case mo:case po:return Reflect.set(e,r,o,l);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 r||t.call(l,r)||(r=i.call(l,r)),!!t.call(l,r)&&!!n.call(l,r,o)}}})(),Rn&&Sn(0);const Vo=Array.isArray,vo=(t,e)=>go(t,e,[],0),So=(t,e)=>Lo(t,e,[],0);function Ro(t,e,n,i){let r,o=i,l=-1;const a=e.length;for(;++lr.getChildAt(e))),n,o).length:r instanceof ei&&(n[o++]=r);return n}const xo=(t,[e,n],i)=>(t[0][i]=e,t[1][i]=n,t);function Yo(t,e){let n,i;switch(i=t.length){case 0:return e;case 1:if(n=e[0],!t[0])return e;if(Vo(t[0]))return Yo(t[0],e);t[0]instanceof _r||t[0]instanceof ei||t[0]instanceof hr||([n,t]=Object.entries(t[0]).reduce(xo,e));break;default:Vo(n=t[i-1])?t=Vo(t[0])?t[0]:t.slice(0,i-1):(t=Vo(t[0])?t[0]:t,n=[])}let r=-1,o=-1,l=-1;const a=t.length;let s,u;const[c,d]=e;for(;++l`}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(hr.isDictionary(this._type)){if(!this._indices){const t=this._chunks;this._indices=1===t.length?t[0].indices:Ho.concat(...t.map((t=>t.indices)))}return this._indices}return null}get dictionary(){return hr.isDictionary(this._type)?this._chunks[this._chunks.length-1].data.dictionary:null}[Symbol.iterator](){return new Ko(this._chunks)}clone(t=this._chunks){return new Ho(this._type,t)}concat(...t){return this.clone(Ho.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,i,r;return(n=e[t])?n:(i=(this._type.children||[])[t])&&(r=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),r.length>0)?e[t]=new Ho(i.type,r):null}search(t,e){const n=t,i=this._chunkOffsets;let r=i.length-1;if(n<0)return null;if(n>=i[r])return null;if(r<=1)return e?e(this,0,n):[0,n];let o=0,l=0,a=0;do{if(o+1===r)return e?e(this,o,n-l):[o,n-l];a=o+(r-o)/2|0,n>=i[a]?o=a:r=a}while(n=(l=i[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,i)=>t[n].set(i,e)))}indexOf(t,e){return e&&"number"==typeof e?this.search(e,((e,n,i)=>this.indexOfInternal(e,n,i,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 i=0;const r=new Array(e);for(let a=-1;++a=n)break;if(e>=s+a)continue;if(s>=e&&s+a<=n){i.push(t);continue}const u=Math.max(0,e-s),c=Math.min(n-s,a);i.push(t.slice(u,c))}return t.clone(i)}}const Jo=(t,e,n)=>(e.set(t,n),n+t.length),wo=(t,e,n)=>{let i=n;for(let r=-1,o=t.length;++rt>0))&&(e=e.clone({nullable:!0}));return new _o(e,r)}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 _o(this._field,t)}getChildAt(t){if(t<0||t>=this.numChildren)return null;const e=this._children||(this._children=[]);let n,i,r;return(n=e[t])?n:(i=(this.type.children||[])[t])&&(r=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t)),r.length>0)?e[t]=new _o(i,r):null}}class Io extends _o{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 Co=new class extends Br{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return Ji.startNull(e),Ji.endNull(e)}visitInt(t,e){return Ui.startInt(e),Ui.addBitWidth(e,t.bitWidth),Ui.addIsSigned(e,t.isSigned),Ui.endInt(e)}visitFloat(t,e){return Fi.startFloatingPoint(e),Fi.addPrecision(e,t.precision),Fi.endFloatingPoint(e)}visitBinary(t,e){return ki.startBinary(e),ki.endBinary(e)}visitBool(t,e){return zi.startBool(e),zi.endBool(e)}visitUtf8(t,e){return Bi.startUtf8(e),Bi.endUtf8(e)}visitDecimal(t,e){return Mi.startDecimal(e),Mi.addScale(e,t.scale),Mi.addPrecision(e,t.precision),Mi.endDecimal(e)}visitDate(t,e){return ji.startDate(e),ji.addUnit(e,t.unit),ji.endDate(e)}visitTime(t,e){return Qi.startTime(e),Qi.addUnit(e,t.unit),Qi.addBitWidth(e,t.bitWidth),Qi.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Pi.startTimestamp(e),Pi.addUnit(e,t.unit),void 0!==n&&Pi.addTimezone(e,n),Pi.endTimestamp(e)}visitInterval(t,e){return Ei.startInterval(e),Ei.addUnit(e,t.unit),Ei.endInterval(e)}visitList(t,e){return _i.startList(e),_i.endList(e)}visitStruct(t,e){return wi.startStruct_(e),wi.endStruct_(e)}visitUnion(t,e){Ci.startTypeIdsVector(e,t.typeIds.length);const n=Ci.createTypeIdsVector(e,t.typeIds);return Ci.startUnion(e),Ci.addMode(e,t.mode),Ci.addTypeIds(e,n),Ci.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return Oi.startDictionaryEncoding(e),Oi.addId(e,new No(t.id,0)),Oi.addIsOrdered(e,t.isOrdered),void 0!==n&&Oi.addIndexType(e,n),Oi.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ti.startFixedSizeBinary(e),Ti.addByteWidth(e,t.byteWidth),Ti.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Ii.startFixedSizeList(e),Ii.addListSize(e,t.listSize),Ii.endFixedSizeList(e)}visitMap(t,e){return Ni.startMap(e),Ni.addKeysSorted(e,t.keysSorted),Ni.endMap(e)}};function Uo(t){return new Do(t.count,Bo(t.columns),ko(t.columns))}function Fo(t,e){return(t.children||[]).filter(Boolean).map((t=>Cr.fromJSON(t,e)))}function Bo(t){return(t||[]).reduce(((t,e)=>{return[...t,new qo(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...Bo(e.children)];var n}),[])}function ko(t,e=[]){for(let n=-1,i=(t||[]).length;++ni),this._bodyLength="number"==typeof t?t:t.low}static fromJSON(t,e){const n=new Eo(0,ni.V4,e);return n._createHeader=function(t,e){return()=>{switch(e){case gi.Schema:return Nr.fromJSON(t);case gi.RecordBatch:return Do.fromJSON(t);case gi.DictionaryBatch:return Oo.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${gi[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new Po(Mn(t));const e=rr.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),r=e.headerType(),o=new Eo(n,i,r);return o._createHeader=function(t,e){return()=>{switch(e){case gi.Schema:return Nr.decode(t.header(new $i));case gi.RecordBatch:return Do.decode(t.header(new nr),t.version());case gi.DictionaryBatch:return Oo.decode(t.header(new ir),t.version())}throw new Error(`Unrecognized Message type: { name: ${gi[e]}, type: ${e} }`)}}(e,r),o}static encode(t){const e=new Qo;let n=-1;return t.isSchema()?n=Nr.encode(e,t.header()):t.isRecordBatch()?n=Do.encode(e,t.header()):t.isDictionaryBatch()&&(n=Oo.encode(e,t.header())),rr.startMessage(e),rr.addVersion(e,ni.V4),rr.addHeader(e,n),rr.addHeaderType(e,t.headerType),rr.addBodyLength(e,new jo(t.bodyLength,0)),rr.finishMessageBuffer(e,rr.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Nr)return new Eo(0,ni.V4,gi.Schema,t);if(t instanceof Do)return new Eo(e,ni.V4,gi.RecordBatch,t);if(t instanceof Oo)return new Eo(e,ni.V4,gi.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===gi.Schema}isRecordBatch(){return this.headerType===gi.RecordBatch}isDictionaryBatch(){return this.headerType===gi.DictionaryBatch}}class Do{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 Oo{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 Ao{constructor(t,e){this.offset="number"==typeof t?t:t.low,this.length="number"==typeof e?e:e.low}}class qo{constructor(t,e){this.length="number"==typeof t?t:t.low,this.nullCount="number"==typeof e?e:e.low}}function $o(t,e){const n=[];for(let i,r=-1,o=-1,l=t.childrenLength();++rCr.encode(t,e))),s=Ai.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?Ai.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return Di.startKeyValue(t),Di.addKey(t,i),Di.addValue(t,r),Di.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Ai.startField(t),Ai.addType(t,i),Ai.addTypeType(t,l),Ai.addChildren(t,s),Ai.addNullable(t,!!e.nullable),-1!==n&&Ai.addName(t,n);-1!==r&&Ai.addDictionary(t,r);-1!==u&&Ai.addCustomMetadata(t,u);return Ai.endField(t)},Cr.decode=function(t,e){let n,i,r,o,l,a;e&&(a=t.dictionary())?e.has(n=a.id().low)?(o=(o=a.indexType())?el(o):new mr,l=new wr(e.get(n),o,n,a.isOrdered()),i=new Cr(t.name(),l,t.nullable(),tl(t))):(o=(o=a.indexType())?el(o):new mr,e.set(n,r=nl(t,$o(t,e))),l=new wr(r,o,n,a.isOrdered()),i=new Cr(t.name(),l,t.nullable(),tl(t))):(r=nl(t,$o(t,e)),i=new Cr(t.name(),r,t.nullable(),tl(t)));return i||null},Cr.fromJSON=function(t,e){let n,i,r,o,l,a;return e&&(o=t.dictionary)?e.has(n=o.id)?(i=(i=o.indexType)?zo(i):new mr,a=new wr(e.get(n),i,n,o.isOrdered),r=new Cr(t.name,a,t.nullable,To(t.customMetadata))):(i=(i=o.indexType)?zo(i):new mr,e.set(n,l=Mo(t,Fo(t,e))),a=new wr(l,i,n,o.isOrdered),r=new Cr(t.name,a,t.nullable,To(t.customMetadata))):(l=Mo(t,Fo(t,e)),r=new Cr(t.name,l,t.nullable,To(t.customMetadata))),r||null},Nr.encode=function(t,e){const n=e.fields.map((e=>Cr.encode(t,e)));$i.startFieldsVector(t,n.length);const i=$i.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?$i.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return Di.startKeyValue(t),Di.addKey(t,i),Di.addValue(t,r),Di.endKeyValue(t)}))):-1;$i.startSchema(t),$i.addFields(t,i),$i.addEndianness(t,il?Gi.Little:Gi.Big),-1!==r&&$i.addCustomMetadata(t,r);return $i.endSchema(t)},Nr.decode=function(t,e=new Map){const n=function(t,e){const n=[];for(let i,r=-1,o=-1,l=t.fieldsLength();++rCr.fromJSON(t,e)))}(t,e),To(t.customMetadata),e)},Do.encode=function(t,e){const n=e.nodes||[],i=e.buffers||[];nr.startNodesVector(t,n.length),n.slice().reverse().forEach((e=>qo.encode(t,e)));const r=t.endVector();nr.startBuffersVector(t,i.length),i.slice().reverse().forEach((e=>Ao.encode(t,e)));const o=t.endVector();return nr.startRecordBatch(t),nr.addLength(t,new jo(e.length,0)),nr.addNodes(t,r),nr.addBuffers(t,o),nr.endRecordBatch(t)},Do.decode=function(t,e=ni.V4){return new Do(t.length(),function(t){const e=[];for(let n,i=-1,r=-1,o=t.nodesLength();++i`Expected ${gi[t]} Message in stream, but was null or length 0.`,ll=t=>`Header pointer of flatbuffer-encoded ${gi[t]} Message is null or length 0.`,al=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,sl=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class ul{constructor(t){this.source=t instanceof Ar?t:new Ar(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?Gn: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(ol(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=Mn(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(ol(t));return e.value}readSchema(){const t=gi.Schema,e=this.readMessage(t),n=e&&e.header();if(!e||!n)throw new Error(ll(t));return n}}const hl=4,bl="ARROW1",pl=new Uint8Array(bl.length);for(let TR=0;TRthis.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 Gl(t,e){return e instanceof t.constructor}function Wl(t,e){return t===e||Gl(t,e)}function Vl(t,e){return t===e||Gl(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function vl(t,e){return t===e||Gl(t,e)&&t.precision===e.precision}function Sl(t,e){return t===e||Gl(t,e)&&t.unit===e.unit}function Rl(t,e){return t===e||Gl(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function gl(t,e){return t===e||Gl(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function Ll(t,e){return t===e||Gl(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&Yl.compareManyFields(t.children,e.children)}function xl(t,e){return t===e||Gl(t,e)&&t.unit===e.unit}Xl.prototype.visitNull=Wl,Xl.prototype.visitBool=Wl,Xl.prototype.visitInt=Vl,Xl.prototype.visitInt8=Vl,Xl.prototype.visitInt16=Vl,Xl.prototype.visitInt32=Vl,Xl.prototype.visitInt64=Vl,Xl.prototype.visitUint8=Vl,Xl.prototype.visitUint16=Vl,Xl.prototype.visitUint32=Vl,Xl.prototype.visitUint64=Vl,Xl.prototype.visitFloat=vl,Xl.prototype.visitFloat16=vl,Xl.prototype.visitFloat32=vl,Xl.prototype.visitFloat64=vl,Xl.prototype.visitUtf8=Wl,Xl.prototype.visitBinary=Wl,Xl.prototype.visitFixedSizeBinary=function(t,e){return t===e||Gl(t,e)&&t.byteWidth===e.byteWidth},Xl.prototype.visitDate=Sl,Xl.prototype.visitDateDay=Sl,Xl.prototype.visitDateMillisecond=Sl,Xl.prototype.visitTimestamp=Rl,Xl.prototype.visitTimestampSecond=Rl,Xl.prototype.visitTimestampMillisecond=Rl,Xl.prototype.visitTimestampMicrosecond=Rl,Xl.prototype.visitTimestampNanosecond=Rl,Xl.prototype.visitTime=gl,Xl.prototype.visitTimeSecond=gl,Xl.prototype.visitTimeMillisecond=gl,Xl.prototype.visitTimeMicrosecond=gl,Xl.prototype.visitTimeNanosecond=gl,Xl.prototype.visitDecimal=Wl,Xl.prototype.visitList=function(t,e){return t===e||Gl(t,e)&&t.children.length===e.children.length&&Yl.compareManyFields(t.children,e.children)},Xl.prototype.visitStruct=function(t,e){return t===e||Gl(t,e)&&t.children.length===e.children.length&&Yl.compareManyFields(t.children,e.children)},Xl.prototype.visitUnion=Ll,Xl.prototype.visitDenseUnion=Ll,Xl.prototype.visitSparseUnion=Ll,Xl.prototype.visitDictionary=function(t,e){return t===e||Gl(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Yl.visit(t.indices,e.indices)&&Yl.visit(t.dictionary,e.dictionary)},Xl.prototype.visitInterval=xl,Xl.prototype.visitIntervalDayTime=xl,Xl.prototype.visitIntervalYearMonth=xl,Xl.prototype.visitFixedSizeList=function(t,e){return t===e||Gl(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Yl.compareManyFields(t.children,e.children)},Xl.prototype.visitMap=function(t,e){return t===e||Gl(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Yl.compareManyFields(t.children,e.children)};const Yl=new Xl;function Kl(t,e){return Yl.compareSchemas(t,e)}class Hl extends Br{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...t){const e=new Hl,n=So(Ol,t),[i=e]=e.visitMany(n);return i}visit(t){if(!hr.isDictionary(t.type)){const{data:e,length:n,nullCount:i}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");hr.isNull(t.type)||Jl.call(this,i<=0?new Uint8Array(0):ar(e.offset,n,e.nullBitmap)),this.nodes.push(new qo(n,i))}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 Jl(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new Ao(this._byteLength,e)),this._byteLength+=e,this}function wl(t){return Jl.call(this,t.values.subarray(0,t.length*t.stride))}function _l(t){const{length:e,values:n,valueOffsets:i}=t,r=i[0],o=i[e],l=Math.min(o-r,n.byteLength-r);return Jl.call(this,Dn(-i[0],e,i)),Jl.call(this,n.subarray(r,r+l)),this}function Il(t){const{length:e,valueOffsets:n}=t;return n&&Jl.call(this,Dn(n[0],e,n)),this.visit(t.getChildAt(0))}function Nl(t){return this.visitMany(t.type.children.map(((e,n)=>t.getChildAt(n))).filter(Boolean))[0]}Hl.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?Jl.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Jl.call(this,ar(t.offset,t.length,e)):Jl.call(this,sr(t))},Hl.prototype.visitInt=wl,Hl.prototype.visitFloat=wl,Hl.prototype.visitUtf8=_l,Hl.prototype.visitBinary=_l,Hl.prototype.visitFixedSizeBinary=wl,Hl.prototype.visitDate=wl,Hl.prototype.visitTimestamp=wl,Hl.prototype.visitTime=wl,Hl.prototype.visitDecimal=wl,Hl.prototype.visitList=Il,Hl.prototype.visitStruct=Nl,Hl.prototype.visitUnion=function(t){const{type:e,length:n,typeIds:i,valueOffsets:r}=t;if(Jl.call(this,i),e.mode===li.Sparse)return Nl.call(this,t);if(e.mode===li.Dense){if(t.offset<=0)return Jl.call(this,r),Nl.call(this,t);{const o=i.reduce(((t,e)=>Math.max(t,e)),i[0]),l=new Int32Array(o+1),a=new Int32Array(o+1).fill(-1),s=new Int32Array(n),u=Dn(-r[0],n,r);for(let t,e,r=-1;++rthis.writeAll(t))):Hn(t)?kl(this,t):Bl(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 Or?this._sink=t:(this._sink=new Or,t&&(xn(n=t)&&Ln(n.abort)&&Ln(n.getWriter)&&!(n instanceof Vn))?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>xn(t)&&Ln(t.end)&&Ln(t.write)&&gn(t.writable)&&!(t instanceof Vn))(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&&Kl(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 Dl&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ol&&!(e=t.schema))return this.finish()&&void 0;if(e&&!Kl(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ol?t instanceof Al||this._writeRecordBatch(t):t instanceof Dl?this.writeAll(t.chunks):Kn(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,i=Eo.encode(t),r=i.byteLength,o=this._writeLegacyIpcFormat?4:8,l=r+o+n&~n,a=l-r-o;return t.headerType===gi.RecordBatch?this._recordBatchBlocks.push(new Dr(l,t.bodyLength,this._position)):t.headerType===gi.DictionaryBatch&&this._dictionaryBlocks.push(new Dr(l,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(l-o)),r>0&&this._write(i),this._writePadding(a)}_write(t){if(this._started){const e=Mn(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Eo.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(pl)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:i,buffers:r}=Hl.assemble(t),o=new Do(t.length,n,i),l=Eo.from(o,e);return this._writeDictionaries(t)._writeMessage(l)._writeBodyBuffers(r)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:i,nodes:r,bufferRegions:o,buffers:l}=Hl.assemble(t),a=new Do(t.length,r,o),s=new Oo(a,e,n),u=Eo.from(s,i);return this._writeMessage(u)._writeBodyBuffers(l)}_writeBodyBuffers(t){let e,n,i;for(let r=-1,o=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));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 i="chunks"in n?n.chunks:[n];for(const n of i)this._writeDictionaryBatch(n,e,t>0),t+=n.length}}return this}}class Ul extends Cl{static writeAll(t,e){const n=new Ul(e);return Yn(t)?t.then((t=>n.writeAll(t))):Hn(t)?kl(n,t):Bl(n,t)}}class Fl extends Cl{static writeAll(t){const e=new Fl;return Yn(t)?t.then((t=>e.writeAll(t))):Hn(t)?kl(e,t):Bl(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const e=Pr.encode(new Pr(t,ni.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function Bl(t,e){let n=e;e instanceof Dl&&(n=e.chunks,t.reset(void 0,e.schema));for(const i of n)t.write(i);return t.finish()}function kl(t,e){var n,i,r,o;return qe(this,void 0,void 0,(function*(){try{for(n=rn(e);!(i=yield n.next()).done;){const e=i.value;t.write(e)}}catch(l){r={error:l}}finally{try{i&&!i.done&&(o=n.return)&&(yield o.call(n))}finally{if(r)throw r.error}}return t.finish()}))}const Tl=new Uint8Array(0),zl=t=>[Tl,Tl,new Uint8Array(t),Tl];function Ml(t,e){return function(t,e){const n=[...t.fields],i=[],r={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let o=0,l=0,a=-1;const s=e.length;let u,c=[];for(;r.numBatches-- >0;){for(l=Number.POSITIVE_INFINITY,a=-1;++a0&&(i[o++]=[l,c.slice()]))}return[t=new Nr(n,t.metadata),i.map((e=>new Ol(t,...e)))]}(t,e.map((t=>t instanceof Ho?t.chunks.map((t=>t.data)):[t.data])))}function jl(t,e,n,i,r){let o,l,a=0,s=-1;const u=i.length,c=(e+63&-64)>>3;for(;++s=e?a===e?n[s]=o:(n[s]=o.slice(0,e),o=o.slice(e,a-e),r.numBatches=Math.max(r.numBatches,i[s].unshift(o))):((l=t[s]).nullable||(t[s]=l.clone({nullable:!0})),n[s]=o?o._changeLengthAndBackfillNullBitmap(e):_r.new(l.type,0,e,e,zl(c)));return n}class Ql extends ei{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`${xi[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 ei.new(t,e)}concat(...t){return Ho.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]=ei.new(this.data.childData[t]))}toJSON(){return[...this]}_sliceInternal(t,e,n){return t.clone(t.data.slice(e,n-e),null)}_bindDataAccessors(t){}}Ql.prototype[Symbol.isConcatSpreadable]=!0;const Pl=Symbol.for("rowIndex");class El extends Ql{bind(t){const e=this._row||(this._row=new Zo(this)),n=Object.create(e);return n[Pl]=t,n}}class Dl extends Ho{constructor(...t){let e=null;t[0]instanceof Nr&&(e=t.shift());const n=Ro(Ol,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 Al(e)),super(new gr(e.fields),n),this._schema=e,this._chunks=n}static empty(t=new Nr([])){return new Dl(t,[])}static from(t){if(!t)return Dl.empty();if("object"==typeof t){const e=Kn(t.values)?function(t){const{type:e}=t;if(e instanceof gr)return Dl.fromStruct(El.from(t));return null}(t):Hn(t.values)?function(t){const{type:e}=t;if(e instanceof gr)return El.from(t).then((t=>Dl.fromStruct(t)));return null}(t):null;if(null!==e)return e}let e=$l.from(t);return Yn(e)?(()=>qe(this,void 0,void 0,(function*(){return yield Dl.from(yield e)})))():e.isSync()&&(e=e.open())?e.schema?new Dl(e.schema,[...e]):Dl.empty():(t=>qe(this,void 0,void 0,(function*(){var e,n;const i=yield t,r=i.schema,o=[];if(r){try{for(var l,a=rn(i);!(l=yield a.next()).done;){const t=l.value;o.push(t)}}catch(s){e={error:s}}finally{try{l&&!l.done&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return new Dl(r,o)}return Dl.empty()})))(e.open())}static fromAsync(t){return qe(this,void 0,void 0,(function*(){return yield Dl.from(t)}))}static fromStruct(t){return Dl.new(t.data.childData,t.type.children)}static new(...t){return new Dl(...(e=(t=>{const[e,n]=Yo(t,[[],[]]);return n.map(((t,n)=>t instanceof _o?_o.new(t.field.clone(e[n]),t):t instanceof ei?_o.new(e[n],t):_o.new(e[n],[])))})(t),Ml(new Nr(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 Dl(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 i=this._schema.fields,r=this._children||(this._children=[]);if(n=r[t])return n;if(e=i[t]){const n=this._chunks.map((e=>e.getChildAt(t))).filter((t=>null!=t));if(n.length>0)return r[t]=new _o(e,n)}return null}serialize(t="binary",e=!0){return(e?Ul:Fl).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 Dl(e,this._chunks.map((({length:n,data:{childData:i}})=>new Ol(e,n,t.map((t=>i[t])).filter(Boolean)))))}assign(t){const e=this._schema.fields,[n,i]=t.schema.fields.reduce(((t,n,i)=>{const[r,o]=t,l=e.findIndex((t=>t.name===n.name));return~l?o[l]=i:r.push(i),t}),[[],[]]),r=this._schema.assign(t.schema),o=[...e.map(((e,n,r,o=i[n])=>void 0===o?this.getColumnAt(n):t.getColumnAt(o))),...n.map((e=>t.getColumnAt(e)))].filter(Boolean);return new Dl(...Ml(r,o))}}class Ol extends El{constructor(...t){let e;const n=t[0];let i;if(t[1]instanceof _r)[,e,i]=t;else{const i=n.fields,[,r,o]=t;e=_r.Struct(new gr(i),0,r,0,null,o)}super(e,i),this._schema=n}static from(t){return Kn(t.values),Dl.from(t)}static new(...t){const[e,n]=(t=>Yo(t,[[],[]]))(t),i=n.filter((t=>t instanceof ei));return new Ol(...function(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){let i,r,o=-1;const l=e.length,a=[...t.fields],s=[],u=(n+63&-64)>>3;for(;++ot.data))))}clone(t,e=this._children){return new Ol(this._schema,t,e)}concat(...t){const e=this._schema,n=Ho.flatten(this,...t);return new Dl(e,n.map((({data:t})=>new Ol(e,t))))}get schema(){return this._schema}get numCols(){return this._schema.fields.length}get dictionaries(){return this._dictionaries||(this._dictionaries=ql.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 Ol(e,this.length,n)}}class Al extends Ol{constructor(t){super(t,0,t.fields.map((t=>_r.new(t.type,0,0,0))))}}class ql extends Br{constructor(){super(...arguments),this.dictionaries=new Map}static collect(t){return(new ql).visit(t.data,new gr(t.schema.fields)).dictionaries}visit(t,e){return hr.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 $l extends Vn{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 Yn(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 On.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return On.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 $l?t:Jn(t)?function(t){return new ta(new ua(t))}(t):_n(t)?function(t){return qe(this,void 0,void 0,(function*(){const{size:e}=yield t.stat(),n=new no(t,e);return e>=Zl&&ml(yield n.readAt(0,fl+7&-8))?new ia(new sa(n)):new ea(new la(n))}))}(t):Yn(t)?(()=>qe(this,void 0,void 0,(function*(){return yield $l.from(yield t)})))():In(t)||Nn(t)||Cn(t)||Hn(t)?function(t){return qe(this,void 0,void 0,(function*(){const e=yield t.peek(fl+7&-8);return e&&e.byteLength>=4?ml(e)?new na(new aa(yield t.read())):new ea(new la(t)):new ea(new la(function(){return en(this,arguments,(function*(){}))}()))}))}(new qr(t)):function(t){const e=t.peek(fl+7&-8);return e&&e.byteLength>=4?ml(e)?new na(new aa(t.read())):new ta(new oa(t)):new ta(new oa(function*(){}()))}(new Ar(t))}static readAll(t){return t instanceof $l?t.isSync()?da(t):ha(t):Jn(t)||ArrayBuffer.isView(t)||Kn(t)||wn(t)?da(t):ha(t)}}class ta extends $l{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 ea extends $l{constructor(t){super(t),this._impl=t}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class na extends ta{constructor(t){super(t),this._impl=t}}class ia extends ea{constructor(t){super(t),this._impl=t}}class ra{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 Ol(this.schema,t.length,this._loadVectors(t,e,this.schema.fields))}_loadDictionaryBatch(t,e){const{id:n,isDelta:i,data:r}=t,{dictionaries:o,schema:l}=this,a=o.get(n);if(i||!a){const t=l.dictionaries.get(n);return a&&i?a.concat(ei.new(this._loadVectors(r,e,[t])[0])):ei.new(this._loadVectors(r,e,[t])[0])}return a}_loadVectors(t,e,n){return new uo(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}}class oa extends ra{constructor(t,e){super(e),this._reader=Jn(t)?new dl(this._handle=t):new ul(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=ca(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):Gn}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Gn}next(){if(this.closed)return Gn;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(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new Al(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class la extends ra{constructor(t,e){super(e),this._reader=new cl(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return qe(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 qe(this,void 0,void 0,(function*(){return this.closed||(this.autoDestroy=ca(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this}))}throw(t){return qe(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Gn}))}return(t){return qe(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Gn}))}next(){return qe(this,void 0,void 0,(function*(){if(this.closed)return Gn;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(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const n=t.header(),i=yield e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new Al(this.schema)}):yield this.return()}))}_readNextMessageAndValidate(t){return qe(this,void 0,void 0,(function*(){return yield this._reader.readMessage(t)}))}}class aa extends oa{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(gi.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(gi.DictionaryBatch);if(t&&t.isDictionaryBatch()){const e=t.header(),n=this._reader.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,i)}}}_readFooter(){const{_handle:t}=this,e=t.size-yl,n=t.readInt32(e),i=t.readAt(e-n,n);return Pr.decode(i)}_readNextMessageAndValidate(t){if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return qe(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 qe(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(gi.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 qe(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(gi.DictionaryBatch);if(t&&t.isDictionaryBatch()){const e=t.header(),n=yield this._reader.readMessageBody(t.bodyLength),i=this._loadDictionaryBatch(e,n);this.dictionaries.set(e.id,i)}}}))}_readFooter(){return qe(this,void 0,void 0,(function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-yl,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Pr.decode(i)}))}_readNextMessageAndValidate(t){return qe(this,void 0,void 0,(function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex-1},O.prototype.set=function(t,e){var n=this.__data__,i=nt(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this},A.prototype.clear=function(){this.size=0,this.__data__={hash:new D,map:new(Q||O),string:new D}},A.prototype.delete=function(t){var e=ht(this,t).delete(t);return this.size-=e?1:0,e},A.prototype.get=function(t){return ht(this,t).get(t)},A.prototype.has=function(t){return ht(this,t).has(t)},A.prototype.set=function(t,e){var n=ht(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this},q.prototype.clear=function(){this.__data__=new O,this.size=0},q.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},q.prototype.get=function(t){return this.__data__.get(t)},q.prototype.has=function(t){return this.__data__.has(t)},q.prototype.set=function(t,e){var n=this.__data__;if(n instanceof O){var i=n.__data__;if(!Q||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new A(i)}return n.set(t,e),this.size=n.size,this};var rt,ot=function(t,e,n){for(var i=-1,r=Object(t),o=n(t),l=o.length;l--;){var a=o[rt?l:++i];if(!1===e(r[a],a,r))break}return t};function lt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":k&&k in Object(t)?function(t){var e=x.call(t,k),n=t[k];try{t[k]=void 0;var i=!0}catch(o){}var r=K.call(t);i&&(e?t[k]=n:delete t[k]);return r}(t):function(t){return K.call(t)}(t)}function at(t){return gt(t)&<(t)==r}function st(t){return!(!Rt(t)||function(t){return!!Y&&Y in t}(t))&&(vt(t)?J:a).test(function(t){if(null!=t){try{return L.call(t)}catch(e){}try{return t+""}catch(e){}}return""}(t))}function ut(t){if(!Rt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=mt(t),n=[];for(var i in t)("constructor"!=i||!e&&x.call(t,i))&&n.push(i);return n}function ct(t,e,n,i,r){t!==e&&ot(e,(function(o,a){if(r||(r=new q),Rt(o))!function(t,e,n,i,r,o,a){var s=ft(t,n),u=ft(e,n),c=a.get(u);if(c)return void tt(t,n,c);var d=o?o(s,u,n+"",t,e,a):void 0,h=void 0===d;if(h){var b=Gt(u),p=!b&&Vt(u),m=!b&&!p&&Lt(u);d=u,b||p||m?Gt(s)?d=s:gt(G=s)&&Wt(G)?d=function(t,e){var n=-1,i=t.length;e||(e=Array(i));for(;++n-1&&t%1==0&&t0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(T?function(t,e){return T(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Ht);function Zt(t,e){return t===e||t!=t&&e!=e}var Xt=at(function(){return arguments}())?at:function(t){return gt(t)&&x.call(t,"callee")&&!F.call(t,"callee")},Gt=Array.isArray;function Wt(t){return null!=t&&St(t.length)&&!vt(t)}var Vt=z||function(){return!1};function vt(t){if(!Rt(t))return!1;var e=lt(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<=i}function Rt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function gt(t){return null!=t&&"object"==typeof t}var Lt=Z?function(t){return function(e){return t(e)}}(Z):function(t){return gt(t)&&St(t.length)&&!!u[lt(t)]};function xt(t){return Wt(t)?$(t,!0):ut(t)}var Yt,Kt=(Yt=function(t,e,n){ct(t,e,n)},dt((function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,o=i>2?e[2]:void 0;for(r=Yt.length>3&&"function"==typeof r?(i--,r):void 0,o&&function(t,e,n){if(!Rt(n))return!1;var i=typeof e;return!!("number"==i?Wt(n)&&pt(e,n.length):"string"==i&&e in n)&&Zt(n[e],t)}(e[0],e[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++n=0&&e._call.call(void 0,t),e=e._next;--Za}()}finally{Za=0,function(){var t,e,n=ma,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:ma=e);fa=t,Ja(i)}(),Va=0}}function Ha(){var t=Sa.now(),e=t-Wa;e>1e3&&(va-=e,Wa=t)}function Ja(t){Za||(Xa&&(Xa=clearTimeout(Xa)),t-Va>24?(t<1/0&&(Xa=setTimeout(Ka,t-Sa.now()-va)),Ga&&(Ga=clearInterval(Ga))):(Ga||(Wa=Sa.now(),Ga=setInterval(Ha,1e3)),Za=1,Ra(Ka)))}function wa(t,e,n){var i=new xa;return e=null==e?0:+e,i.restart((n=>{i.stop(),t(n+e)}),e,n),i}xa.prototype=Ya.prototype={constructor:xa,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ga():+n)+(null==e?0:+e),this._next||fa===this||(fa?fa._next=this:ma=this,fa=this),this._call=t,this._time=n,Ja()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ja())}};var _a={value:()=>{}};function Ia(){for(var t,e=0,n=arguments.length,i={};e=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Ua(t,e){for(var n,i=0,r=t.length;i0)for(var n,i,r=new Array(n),o=0;o=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),ka.hasOwnProperty(e)?{space:ka[e],local:t}:t}function za(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ba&&e.documentElement.namespaceURI===Ba?e.createElement(t):e.createElementNS(n,t)}}function Ma(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function ja(t){var e=Ta(t);return(e.local?Ma:za)(e)}function Qa(){}function Pa(t){return null==t?Qa:function(){return this.querySelector(t)}}function Ea(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Da(){return[]}function Oa(t){return function(e){return e.matches(t)}}var Aa=Array.prototype.find;function qa(){return this.firstElementChild}var $a=Array.prototype.filter;function ts(){return this.children}function es(t){return new Array(t.length)}function ns(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function is(t){return function(){return t}}function rs(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function ss(t){return function(){this.removeAttribute(t)}}function us(t){return function(){this.removeAttributeNS(t.space,t.local)}}function cs(t,e){return function(){this.setAttribute(t,e)}}function ds(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function hs(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function bs(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 ps(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ms(t){return function(){this.style.removeProperty(t)}}function fs(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ys(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function Zs(t,e){return t.style.getPropertyValue(e)||ps(t).getComputedStyle(t,null).getPropertyValue(e)}function Xs(t){return function(){delete this[t]}}function Gs(t,e){return function(){this[t]=e}}function Ws(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Vs(t){return t.trim().split(/^|\s+/)}function vs(t){return t.classList||new Ss(t)}function Ss(t){this._node=t,this._names=Vs(t.getAttribute("class")||"")}function Rs(t,e){for(var n=vs(t),i=-1,r=e.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function zs(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Es=[null];function Ds(t,e){this._groups=t,this._parents=e}function Os(t){return"string"==typeof t?new Ds([[document.querySelector(t)]],[document.documentElement]):new Ds([[t]],Es)}function As(t){t.preventDefault(),t.stopImmediatePropagation()}function qs(t){var e=t.document.documentElement,n=Os(t).on("dragstart.drag",As,!0);"onselectstart"in e?n.on("selectstart.drag",As,!0):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function $s(t,e){var n=t.document.documentElement,i=Os(t).on("dragstart.drag",null);e&&(i.on("click.drag",As,!0),setTimeout((function(){i.on("click.drag",null)}),0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}Ds.prototype={constructor:Ds,select:function(t){"function"!=typeof t&&(t=Pa(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=W&&(W=G+1);!(X=f[W])&&++W=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=as);for(var n=this._groups,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?ms:"function"==typeof e?ys:fs)(t,e,null==n?"":n)):Zs(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Xs:"function"==typeof e?Ws:Gs)(t,e)):this.node()[t]},classed:function(t,e){var n=Vs(t+"");if(arguments.length<2){for(var i=vs(this.node()),r=-1,o=n.length;++r=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),iu.hasOwnProperty(e)?{space:iu[e],local:t}:t}function ou(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===nu&&e.documentElement.namespaceURI===nu?e.createElement(t):e.createElementNS(n,t)}}function lu(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function au(t){var e=ru(t);return(e.local?lu:ou)(e)}function su(){}function uu(t){return null==t?su:function(){return this.querySelector(t)}}function cu(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function du(){return[]}function hu(t){return function(e){return e.matches(t)}}var bu=Array.prototype.find;function pu(){return this.firstElementChild}var mu=Array.prototype.filter;function fu(){return this.children}function yu(t){return new Array(t.length)}function Zu(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function Xu(t){return function(){return t}}function Gu(t,e,n,i,r,o){for(var l,a=0,s=e.length,u=o.length;ae?1:t>=e?0:NaN}function Su(t){return function(){this.removeAttribute(t)}}function Ru(t){return function(){this.removeAttributeNS(t.space,t.local)}}function gu(t,e){return function(){this.setAttribute(t,e)}}function Lu(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function xu(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Yu(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 Ku(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Hu(t){return function(){this.style.removeProperty(t)}}function Ju(t,e,n){return function(){this.style.setProperty(t,e,n)}}function wu(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function _u(t,e){return t.style.getPropertyValue(e)||Ku(t).getComputedStyle(t,null).getPropertyValue(e)}function Iu(t){return function(){delete this[t]}}function Nu(t,e){return function(){this[t]=e}}function Cu(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Uu(t){return t.trim().split(/^|\s+/)}function Fu(t){return t.classList||new Bu(t)}function Bu(t){this._node=t,this._names=Uu(t.getAttribute("class")||"")}function ku(t,e){for(var n=Fu(t),i=-1,r=e.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function oc(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,o=e.length;i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var cc=[null];function dc(t,e){this._groups=t,this._parents=e}function hc(t){return"string"==typeof t?new dc([[document.querySelector(t)]],[document.documentElement]):new dc([[t]],cc)}function bc(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 i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(e.getScreenCTM().inverse())).x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}dc.prototype={constructor:dc,select:function(t){"function"!=typeof t&&(t=uu(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=W&&(W=G+1);!(X=f[W])&&++W=0;)(i=r[o])&&(l&&4^i.compareDocumentPosition(l)&&l.parentNode.insertBefore(i,l),l=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=vu);for(var n=this._groups,i=n.length,r=new Array(i),o=0;o1?this.each((null==e?Hu:"function"==typeof e?wu:Ju)(t,e,null==n?"":n)):_u(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Iu:"function"==typeof e?Cu:Nu)(t,e)):this.node()[t]},classed:function(t,e){var n=Uu(t+"");if(arguments.length<2){for(var i=Fu(this.node()),r=-1,o=n.length;++r0)throw new Error("too late; already scheduled");return n}function Zc(t,e){var n=Xc(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Xc(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Gc(t,e){var n,i,r,o=t.__transition,l=!0;if(o){for(r in e=null==e?null:e+"",o)(n=o[r]).name===e?(i=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[r]):l=!1;l&&delete t.__transition}}function Wc(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Vc(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function vc(){}var Sc=.7,Rc=1/Sc,gc="\\s*([+-]?\\d+)\\s*",Lc="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",xc="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Yc=/^#([0-9a-f]{3,8})$/,Kc=new RegExp("^rgb\\("+[gc,gc,gc]+"\\)$"),Hc=new RegExp("^rgb\\("+[xc,xc,xc]+"\\)$"),Jc=new RegExp("^rgba\\("+[gc,gc,gc,Lc]+"\\)$"),wc=new RegExp("^rgba\\("+[xc,xc,xc,Lc]+"\\)$"),_c=new RegExp("^hsl\\("+[Lc,xc,xc]+"\\)$"),Ic=new RegExp("^hsla\\("+[Lc,xc,xc,Lc]+"\\)$"),Nc={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 Cc(){return this.rgb().formatHex()}function Uc(){return this.rgb().formatRgb()}function Fc(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Yc.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Bc(e):3===n?new Mc(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?kc(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?kc(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=Kc.exec(t))?new Mc(e[1],e[2],e[3],1):(e=Hc.exec(t))?new Mc(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Jc.exec(t))?kc(e[1],e[2],e[3],e[4]):(e=wc.exec(t))?kc(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=_c.exec(t))?Ec(e[1],e[2]/100,e[3]/100,1):(e=Ic.exec(t))?Ec(e[1],e[2]/100,e[3]/100,e[4]):Nc.hasOwnProperty(t)?Bc(Nc[t]):"transparent"===t?new Mc(NaN,NaN,NaN,0):null}function Bc(t){return new Mc(t>>16&255,t>>8&255,255&t,1)}function kc(t,e,n,i){return i<=0&&(t=e=n=NaN),new Mc(t,e,n,i)}function Tc(t){return t instanceof vc||(t=Fc(t)),t?new Mc((t=t.rgb()).r,t.g,t.b,t.opacity):new Mc}function zc(t,e,n,i){return 1===arguments.length?Tc(t):new Mc(t,e,n,null==i?1:i)}function Mc(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function jc(){return"#"+Pc(this.r)+Pc(this.g)+Pc(this.b)}function Qc(){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 Pc(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Ec(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Oc(t,e,n,i)}function Dc(t){if(t instanceof Oc)return new Oc(t.h,t.s,t.l,t.opacity);if(t instanceof vc||(t=Fc(t)),!t)return new Oc;if(t instanceof Oc)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),o=Math.max(e,n,i),l=NaN,a=o-r,s=(o+r)/2;return a?(l=e===o?(n-i)/a+6*(n0&&s<1?0:l,new Oc(l,a,s,t.opacity)}function Oc(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Ac(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Wc(vc,Fc,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:Cc,formatHex:Cc,formatHsl:function(){return Dc(this).formatHsl()},formatRgb:Uc,toString:Uc}),Wc(Mc,zc,Vc(vc,{brighter:function(t){return t=null==t?Rc:Math.pow(Rc,t),new Mc(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Sc:Math.pow(Sc,t),new Mc(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:jc,formatHex:jc,formatRgb:Qc,toString:Qc})),Wc(Oc,(function(t,e,n,i){return 1===arguments.length?Dc(t):new Oc(t,e,n,null==i?1:i)}),Vc(vc,{brighter:function(t){return t=null==t?Rc:Math.pow(Rc,t),new Oc(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Sc:Math.pow(Sc,t),new Oc(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,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Mc(Ac(t>=240?t-240:t+120,r,i),Ac(t,r,i),Ac(t<120?t+240:t-120,r,i),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 qc=Math.PI/180,$c=180/Math.PI;var td=-.14861,ed=1.78277,nd=-.29227,id=-.90649,rd=1.97294,od=rd*id,ld=rd*ed,ad=ed*nd-id*td;function sd(t){if(t instanceof cd)return new cd(t.h,t.s,t.l,t.opacity);t instanceof Mc||(t=Tc(t));var e=t.r/255,n=t.g/255,i=t.b/255,r=(ad*i+od*e-ld*n)/(ad+od-ld),o=i-r,l=(rd*(n-r)-nd*o)/id,a=Math.sqrt(l*l+o*o)/(rd*r*(1-r)),s=a?Math.atan2(l,o)*$c-120:NaN;return new cd(s<0?s+360:s,a,r,t.opacity)}function ud(t,e,n,i){return 1===arguments.length?sd(t):new cd(t,e,n,null==i?1:i)}function cd(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}Wc(cd,ud,Vc(vc,{brighter:function(t){return t=null==t?Rc:Math.pow(Rc,t),new cd(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Sc:Math.pow(Sc,t),new cd(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*qc,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),i=Math.cos(t),r=Math.sin(t);return new Mc(255*(e+n*(td*i+ed*r)),255*(e+n*(nd*i+id*r)),255*(e+n*(rd*i)),this.opacity)}}));var dd=t=>()=>t;function hd(t,e){return function(n){return t+n*e}}function bd(t){return 1==(t=+t)?pd: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(i){return Math.pow(t+i*e,n)}}(e,n,t):dd(isNaN(e)?n:e)}}function pd(t,e){var n=e-t;return n?hd(t,n):dd(isNaN(t)?e:t)}var md=function t(e){var n=bd(e);function i(t,e){var i=n((t=zc(t)).r,(e=zc(e)).r),r=n(t.g,e.g),o=n(t.b,e.b),l=pd(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=o(e),t.opacity=l(e),t+""}}return i.gamma=t,i}(1);var fd,yd=(fd=function(t){var e=t.length-1;return function(n){var i=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),r=t[i],o=t[i+1],l=i>0?t[i-1]:2*r-o,a=io&&(r=e.slice(o,r),a[l]?a[l]+=r:a[++l]=r),(n=n[0])===(i=i[0])?a[l]?a[l]+=i:a[++l]=i:(a[++l]=null,s.push({i:l,x:Wd(n,i)})),o=Sd.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(r(n)+"rotate(",null,i)-2,x:Wd(t,e)})):e&&n.push(r(n)+"rotate("+e+i)}(o.rotate,l.rotate,a,s),function(t,e,n,o){t!==e?o.push({i:n.push(r(n)+"skewX(",null,i)-2,x:Wd(t,e)}):e&&n.push(r(n)+"skewX("+e+i)}(o.skewX,l.skewX,a,s),function(t,e,n,i,o,l){if(t!==n||e!==i){var a=o.push(r(o)+"scale(",null,",",null,")");l.push({i:a-4,x:Wd(t,n)},{i:a-2,x:Wd(e,i)})}else 1===n&&1===i||o.push(r(o)+"scale("+n+","+i+")")}(o.scaleX,o.scaleY,l.scaleX,l.scaleY,a,s),o=l=null,function(t){for(var e,n=-1,i=s.length;++n180||n<-180?n-360*Math.round(n/360):n):dd(isNaN(t)?e:t)}));var Nd=Id(pd);function Cd(t,e){var n,i;return function(){var r=Zc(this,t),o=r.tween;if(o!==n)for(var l=0,a=(i=n=o).length;l=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?yc:Zc;return function(){var l=o(this,t),a=l.on;a!==i&&(r=(i=a).copy()).on(e,n),l.on=r}}var ih=bt.prototype.constructor;function rh(t){return function(){this.style.removeProperty(t)}}function oh(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}function lh(t,e,n){var i,r;function o(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&oh(t,o,n)),i}return o._value=e,o}function ah(t){return function(e){this.textContent=t.call(this,e)}}function sh(t){var e,n;function i(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&ah(i)),e}return i._value=t,i}var uh=0;function ch(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function dh(){return++uh}var hh=bt.prototype;ch.prototype={constructor:ch,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=a(t));for(var i=this._groups,r=i.length,o=new Array(r),l=0;l()=>t;function fh(t,{sourceEvent:e,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function yh(t,e,n){this.k=t,this.x=e,this.y=n}yh.prototype={constructor:yh,scale:function(t){return 1===t?this:new yh(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new yh(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 Zh=new yh(1,0,0);function Xh(t){t.stopImmediatePropagation()}function Gh(t){t.preventDefault(),t.stopImmediatePropagation()}function Wh(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Vh(){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 vh(){return this.__zoom||Zh}function Sh(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Rh(){return navigator.maxTouchPoints||"ontouchstart"in this}function gh(t,e,n){var i=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],l=t.invertY(e[1][1])-n[1][1];return t.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l))}function Lh(t,e){return te?1:t>=e?0:NaN}function xh(t){let e=t,n=t;function i(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)<0?i=o+1:r=o}return i}return 1===t.length&&(e=(e,n)=>t(e)-n,n=function(t){return(e,n)=>Lh(t(e),n)}(t)),{left:i,center:function(t,n,r,o){null==r&&(r=0),null==o&&(o=t.length);const l=i(t,n,r,o-1);return l>r&&e(t[l-1],n)>-e(t[l],n)?l-1:l},right:function(t,e,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i>>1;n(t[o],e)>0?r=o:i=o+1}return i}}}const Yh=xh(Lh).right;xh((function(t){return null===t?NaN:+t})).center;var Kh=Math.sqrt(50),Hh=Math.sqrt(10),Jh=Math.sqrt(2);function wh(t,e,n){var i,r,o,l,a=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((i=e0){let n=Math.round(t/l),i=Math.round(e/l);for(n*le&&--i,o=new Array(r=i-n+1);++ae&&--i,o=new Array(r=i-n+1);++a=0?(o>=Kh?10:o>=Hh?5:o>=Jh?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=Kh?10:o>=Hh?5:o>=Jh?2:1)}function Ih(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Nh(t){return+t}var Ch=[0,1];function Uh(t){return t}function Fh(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:(n=isNaN(e)?NaN:.5,function(){return n});var n}function Bh(t,e,n){var i=t[0],r=t[1],o=e[0],l=e[1];return re&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),i=s>2?kh:Bh,r=o=null,d}function d(e){return null==e||isNaN(e=+e)?n:(r||(r=i(l.map(t),a,s)))(t(u(e)))}return d.invert=function(n){return u(e((o||(o=i(a,l.map(t),Wd)))(n)))},d.domain=function(t){return arguments.length?(l=Array.from(t,Nh),c()):l.slice()},d.range=function(t){return arguments.length?(a=Array.from(t),c()):a.slice()},d.rangeRound=function(t){return a=Array.from(t),s=Ld,c()},d.clamp=function(t){return arguments.length?(u=!!t||Uh,c()):u!==Uh},d.interpolate=function(t){return arguments.length?(s=t,c()):s},d.unknown=function(t){return arguments.length?(n=t,d):n},function(n,i){return t=n,e=i,c()}}function Mh(){return zh()(Uh,Uh)}function jh(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function Qh(t){return(t=jh(Math.abs(t)))?t[1]:NaN}var Ph,Eh=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Dh(t){if(!(e=Eh.exec(t)))throw new Error("invalid format: "+t);var e;return new Oh({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 Oh(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 Ah(t,e){var n=jh(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}Dh.prototype=Oh.prototype,Oh.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 qh={"%":(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)=>Ah(100*t,e),r:Ah,s:function(t,e){var n=jh(t,e);if(!n)return t+"";var i=n[0],r=n[1],o=r-(Ph=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,l=i.length;return o===l?i:o>l?i+new Array(o-l+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+jh(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function $h(t){return t}var tb,eb,nb,ib=Array.prototype.map,rb=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ob(t){var e,n,i=void 0===t.grouping||void 0===t.thousands?$h:(e=ib.call(t.grouping,Number),n=t.thousands+"",function(t,i){for(var r=t.length,o=[],l=0,a=e[0],s=0;r>0&&a>0&&(s+a+1>i&&(a=Math.max(1,i-s)),o.push(t.substring(r-=a,r+a)),!((s+=a+1)>i));)a=e[l=(l+1)%e.length];return o.reverse().join(n)}),r=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",l=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?$h:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(ib.call(t.numerals,String)),s=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function d(t){var e=(t=Dh(t)).fill,n=t.align,d=t.sign,h=t.symbol,b=t.zero,p=t.width,m=t.comma,f=t.precision,y=t.trim,Z=t.type;"n"===Z?(m=!0,Z="g"):qh[Z]||(void 0===f&&(f=12),y=!0,Z="g"),(b||"0"===e&&"="===n)&&(b=!0,e="0",n="=");var X="$"===h?r:"#"===h&&/[boxX]/.test(Z)?"0"+Z.toLowerCase():"",G="$"===h?o:/[%p]/.test(Z)?s:"",W=qh[Z],V=/[defgprs%]/.test(Z);function v(t){var r,o,s,h=X,v=G;if("c"===Z)v=W(t)+v,t="";else{var S=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:W(Math.abs(t),f),y&&(t=function(t){t:for(var e,n=t.length,i=1,r=-1;i0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),S&&0==+t&&"+"!==d&&(S=!1),h=(S?"("===d?d:u:"-"===d||"("===d?"":d)+h,v=("s"===Z?rb[8+Ph/3]:"")+v+(S&&"("===d?")":""),V)for(r=-1,o=t.length;++r(s=t.charCodeAt(r))||s>57){v=(46===s?l+t.slice(r+1):t.slice(r))+v,t=t.slice(0,r);break}}m&&!b&&(t=i(t,1/0));var R=h.length+t.length+v.length,g=R>1)+h+t+v+g.slice(R);break;default:t=g+h+t+v}return a(t)}return f=void 0===f?6:/[gprs]/.test(Z)?Math.max(1,Math.min(21,f)):Math.max(0,Math.min(20,f)),v.toString=function(){return t+""},v}return{format:d,formatPrefix:function(t,e){var n=d(((t=Dh(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(Qh(e)/3))),r=Math.pow(10,-i),o=rb[8+i/3];return function(t){return n(r*t)+o}}}}function lb(t,e,n,i){var r,o=function(t,e,n){var i=Math.abs(e-t)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=Kh?r*=10:o>=Hh?r*=5:o>=Jh&&(r*=2),e0;){if((r=_h(s,u,n))===i)return o[l]=s,o[a]=u,e(o);if(r>0)s=Math.floor(s/r)*r,u=Math.ceil(u/r)*r;else{if(!(r<0))break;s=Math.ceil(s*r)/r,u=Math.floor(u*r)/r}i=r}return t},t}function sb(){var t=Mh();return t.copy=function(){return Th(t,sb())},Ih.apply(t,arguments),ab(t)}function ub(t){return Math.log(t)}function cb(t){return Math.exp(t)}function db(t){return-Math.log(-t)}function hb(t){return-Math.exp(-t)}function bb(t){return isFinite(t)?+("1e"+t):t<0?0:t}function pb(t){return function(e){return-t(-e)}}function mb(t){var e,n,i=t(ub,cb),r=i.domain,o=10;function l(){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?bb:t===Math.E?Math.exp:function(e){return Math.pow(t,e)}}(o),r()[0]<0?(e=pb(e),n=pb(n),t(db,hb)):t(ub,cb),i}return i.base=function(t){return arguments.length?(o=+t,l()):o},i.domain=function(t){return arguments.length?(r(t),l()):r()},i.ticks=function(t){var i,l=r(),a=l[0],s=l[l.length-1];(i=s0){for(;h<=b;++h)for(c=1,u=n(h);cs)break;m.push(d)}}else for(;h<=b;++h)for(c=o-1,u=n(h);c>=1;--c)if(!((d=u*c)s)break;m.push(d)}2*m.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=>vb(t.data))))).html((t=>vb(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(),[i,r]=t.x.map(n.x),[o,l]=t.y.map(n.y),{canvas:a,zoomer:s,width:u,height:c}=this,d=Zh.translate(u/2,c/2).scale(.9/Math.max((r-i)/u,(l-o)/c)).translate(-(i+r)/2,-(o+l)/2);a.transition().duration(1e3*e).call(s.transform,d)}initialize_zoom(){const{width:t,height:e,canvas:n}=this;this.transform=Zh;const i=function(){var t,e,n,i=Wh,r=Vh,o=gh,l=Sh,a=Rh,s=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,d=eu,h=Ia("start","zoom","end"),b=500,p=0,m=10;function f(t){t.property("__zoom",vh).on("wheel.zoom",v,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",R).filter(a).on("touchstart.zoom",g).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",x).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,e){return(e=Math.max(s[0],Math.min(s[1],e)))===t.k?t:new yh(e,t.x,t.y)}function Z(t,e,n){var i=e[0]-n[0]*t.k,r=e[1]-n[1]*t.k;return i===t.x&&r===t.y?t:new yh(t.k,i,r)}function X(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function G(t,e,n,i){t.on("start.zoom",(function(){W(this,arguments).event(i).start()})).on("interrupt.zoom end.zoom",(function(){W(this,arguments).event(i).end()})).tween("zoom",(function(){var t=this,o=arguments,l=W(t,o).event(i),a=r.apply(t,o),s=null==n?X(a):"function"==typeof n?n.apply(t,o):n,u=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),c=t.__zoom,h="function"==typeof e?e.apply(t,o):e,b=d(c.invert(s).concat(u/c.k),h.invert(s).concat(u/h.k));return function(t){if(1===t)t=h;else{var e=b(t),n=u/e[2];t=new yh(n,s[0]-e[0]*n,s[1]-e[1]*n)}l.zoom(null,t)}}))}function W(t,e,n){return!n&&t.__zooming||new V(t,e)}function V(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=r.apply(t,e),this.taps=0}function v(t,...e){if(i.apply(this,arguments)){var n=W(this,e).event(t),r=this.__zoom,a=Math.max(s[0],Math.min(s[1],r.k*Math.pow(2,l.apply(this,arguments)))),c=bc(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=r.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(r.k===a)return;n.mouse=[c,r.invert(c)],Gc(this),n.start()}Gh(t),n.wheel=setTimeout(d,150),n.zoom("mouse",o(Z(y(r,a),n.mouse[0],n.mouse[1]),n.extent,u))}function d(){n.wheel=null,n.end()}}function S(t,...e){if(!n&&i.apply(this,arguments)){var r=t.currentTarget,l=W(this,e,!0).event(t),a=hc(t.view).on("mousemove.zoom",h,!0).on("mouseup.zoom",b,!0),s=bc(t,r),c=t.clientX,d=t.clientY;qs(t.view),Xh(t),l.mouse=[s,this.__zoom.invert(s)],Gc(this),l.start()}function h(t){if(Gh(t),!l.moved){var e=t.clientX-c,n=t.clientY-d;l.moved=e*e+n*n>p}l.event(t).zoom("mouse",o(Z(l.that.__zoom,l.mouse[0]=bc(t,r),l.mouse[1]),l.extent,u))}function b(t){a.on("mousemove.zoom mouseup.zoom",null),$s(t.view,l.moved),Gh(t),l.event(t).end()}}function R(t,...e){if(i.apply(this,arguments)){var n=this.__zoom,l=bc(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(l),s=n.k*(t.shiftKey?.5:2),d=o(Z(y(n,s),l,a),r.apply(this,e),u);Gh(t),c>0?hc(this).transition().duration(c).call(G,d,l,t):hc(this).call(f.transform,d,l,t)}}function g(n,...r){if(i.apply(this,arguments)){var o,l,a,s,u=n.touches,c=u.length,d=W(this,r,n.changedTouches.length===c).event(n);for(Xh(n),l=0;l{this.transform=t.transform,this.restart_timer(1e4)}));n.call(i),this.add_mouseover(),this.zoomer=i}add_mouseover(){let t=0;const e=pt("#deepscatter-svg").append("g").attr("class","label"),n=this.renderers.get("regl"),i=n.aes.x.current,r=n.aes.y.current;this.canvas.on("mousemove",(o=>{if(Date.now()-t<1e3/30)return;t=Date.now();const l=n.color_pick(o.x,o.y),a=l?[l]:[],s=a[0],u=s?[{x:o.x,y:o.y,data:s,dx:0,dy:30}]:[],{x_:c,y_:d}=this.scales();u.length&&this.html_annotation(u);e.selectAll("g").data(a).join("g").attr("transform",(t=>`translate(\n ${c(i.value_for(t))},\n ${d(r.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_:i,y_:r}=n;return{x:[i.invert(0),i.invert(t)],y:[r.invert(0),r.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=Ya(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:i}=this,{extent:r}=this.tileSet,o={};if(void 0===r)return;const l={x:{},y:{}};for(const[h,b]of[["x",e],["y",n]]){const t=r[h];l[h].limits=t,l[h].size_range=t[1]-t[0],l[h].pixels_per_unit=b/l[h].size_range}const a=l.x.pixels_per_unit/l.y.pixels_per_unit;let s=0,u=0,c=e,d=n;return a>1?(c=e/a,s=(e-c)/2):(d=n*a,u=(n-d)/2),o.x=sb().domain(l.x.limits).range([s,e-s]),o.y=sb().domain(l.y.limits).range([u,n-u]),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 Vb(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 Vb(t,e){function n(t){return t[1]-t[0]}const i=Pe(t.domain()),r=Pe(e.domain()),o=n(t.range())/n(t.domain()),l=n(e.range())/n(e.domain());return[[o,0,-o*i+Pe(t.range())],[0,l,-l*r+Pe(e.range())],[0,0,1]]}function vb(t,e){let n="";const i=new Set(["x","y","ix","bookstack",null,"tile_key"]);for(const[r,o]of t.entries()){if(e){if(!e.has(r))continue}else{if(i.has(r))continue;if(r.match(/_dict_index/))continue;if(null===o)continue;if(""===o)continue}n+=`${r}: ${o}
`}return n}var Sb={exports:{}};Sb.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),i=0;i=0&&(0|t)===t||r("invalid parameter type, ("+t+")"+l(e)+". must be a nonnegative integer")}function h(t,e,n){e.indexOf(t)<0&&r("invalid value"+l(n)+". must be one of: "+e)}var b=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(t){Object.keys(t).forEach((function(t){b.indexOf(t)<0&&r('invalid regl constructor argument "'+t+'". must be one of '+b)}))}function m(t,e){for(t+="";t.length0&&e.push(new Z("unknown",0,t))}})),e}function v(t,e){e.forEach((function(e){var n=t[e.file];if(n){var i=n.index[e.line];if(i)return i.errors.push(e),void(n.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(e)}))}function S(t,e,i,r,l){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var a=t.getShaderInfoLog(e),s=r===t.FRAGMENT_SHADER?"fragment":"vertex";H(i,"string",s+" shader source must be a string",l);var u=W(i,l),c=V(a);v(u,c),Object.keys(u).forEach((function(t){var e=u[t];if(e.hasErrors){var i=[""],r=[""];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(m(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(i){var r=i.message,l=/^\s*'(.*)'\s*:\s*(.*)$/.exec(r);if(l){var a=l[1];switch(r=l[2],a){case"assign":a="="}e=Math.max(t.line.indexOf(a,e),0)}else e=0;o(m("| ",6)),o(m("^^^",e+3)+n,"font-weight:bold"),o(m("| ",6)),o(r+n,"font-weight:bold")})),o(m("| ",6)+n)}else o(m(t.number,4)+"| "),o(t.line+n,"color:red")})),"undefined"==typeof document||window.chrome?console.log(i.join("")):(r[0]=i.join("%c"),console.log.apply(console,r))}function o(t,e){i.push(t),r.push(e||"")}})),o.raise("Error compiling "+s+" shader, "+u[0].name)}}function R(t,e,i,r,l){if(!t.getProgramParameter(e,t.LINK_STATUS)){var a=t.getProgramInfoLog(e),s=W(i,l),u='Error linking program with vertex shader, "'+W(r,l)[0].name+'", and fragment shader "'+s[0].name+'"';"undefined"!=typeof document?console.log("%c"+u+n+"%c"+a,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(u+n+a),o.raise(u)}}function g(t){t._commandRef=X()}function L(t,e,n,i){function r(t){return t?i.id(t):0}function o(t,e){Object.keys(e).forEach((function(e){t[i.id(e)]=!0}))}g(t),t._fragId=r(t.static.frag),t._vertId=r(t.static.vert);var l=t._uniformSet={};o(l,e.static),o(l,e.dynamic);var a=t._attributeSet={};o(a,n.static),o(a,n.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic}function x(t,e){var n=G();r(t+" in command "+(e||X())+("unknown"===n?"":" called from "+n))}function Y(t,e,n){t||x(e,n||X())}function K(t,e,n,i){t in e||x("unknown parameter ("+t+")"+l(n)+". possible values: "+Object.keys(e).join(),i||X())}function H(t,e,n,i){u(t,e)||x("invalid parameter type"+l(n)+". expected "+e+", got "+typeof t,i||X())}function J(t){t()}function w(t,e,n){t.texture?h(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):h(t.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}var _=33071,I=9728,N=9984,C=9985,U=9986,F=9987,B=5121,k=5122,T=5123,z=5124,M=5125,j=5126,Q=32819,P=32820,E=33635,D=34042,O=36193,A={};function q(t,e){return t===P||t===Q||t===E?2:t===D?4:A[t]*e}function $(t){return!(t&t-1||!t)}function tt(t,e,n){var i,r=e.width,l=e.height,a=e.channels;o(r>0&&r<=n.maxTextureSize&&l>0&&l<=n.maxTextureSize,"invalid texture shape"),t.wrapS===_&&t.wrapT===_||o($(r)&&$(l),"incompatible wrap mode for texture, both width and height must be power of 2"),1===e.mipmask?1!==r&&1!==l&&o(t.minFilter!==N&&t.minFilter!==U&&t.minFilter!==C&&t.minFilter!==F,"min filter requires mipmap"):(o($(r)&&$(l),"texture must be a square power of 2 to support mipmapping"),o(e.mipmask===(r<<1)-1,"missing or incomplete mipmap data")),e.type===j&&(n.extensions.indexOf("oes_texture_float_linear")<0&&o(t.minFilter===I&&t.magFilter===I,"filter not supported, must enable oes_texture_float_linear"),o(!t.genMipmaps,"mipmap generation not supported with float textures"));var s=e.images;for(i=0;i<16;++i)if(s[i]){var u=r>>i,c=l>>i;o(e.mipmask&1<0&&r<=i.maxTextureSize&&l>0&&l<=i.maxTextureSize,"invalid texture shape"),o(r===l,"cube map must be square"),o(e.wrapS===_&&e.wrapT===_,"wrap mode not supported by cube map");for(var s=0;s>d,p=l>>d;o(u.mipmask&1<1&&e===n&&('"'===e||"'"===e))return['"'+st(t.substr(1,t.length-2))+'"'];var i=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(i)return ut(t.substr(0,i.index)).concat(ut(i[1])).concat(ut(t.substr(i.index+i[0].length)));var r=t.split(".");if(1===r.length)return['"'+st(t)+'"'];for(var o=[],l=0;l0,"invalid pixel ratio"))):nt.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?i=e:n=e),!r){if(!i){nt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var b=Zt(n||document.body,d,u);if(!b)return null;i=b.canvas,h=b.onDestroy}void 0===l.premultipliedAlpha&&(l.premultipliedAlpha=!0),r=Xt(i,l)}return r?{gl:r,canvas:i,container:n,extensions:a,optionalExtensions:s,pixelRatio:u,profile:c,onDone:d,onDestroy:h}:(h(),d("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Rt(t,e){var n={};function i(e){nt.type(e,"string","extension name must be string");var i,r=e.toLowerCase();try{i=n[r]=t.getExtension(r)}catch(o){}return!!i}for(var r=0;r65535)<<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=gt(8,(function(){return[]}));function e(e){var n=_t(e),i=t[It(n)>>2];return i.length>0?i.pop():new ArrayBuffer(n)}function n(e){t[It(e.byteLength)>>2].push(e)}function i(t,n){var i=null;switch(t){case Lt:i=new Int8Array(e(n),0,n);break;case xt:i=new Uint8Array(e(n),0,n);break;case Yt:i=new Int16Array(e(2*n),0,n);break;case Kt:i=new Uint16Array(e(2*n),0,n);break;case Ht:i=new Int32Array(e(4*n),0,n);break;case Jt:i=new Uint32Array(e(4*n),0,n);break;case wt:i=new Float32Array(e(4*n),0,n);break;default:return null}return i.length!==n?i.subarray(0,n):i}function r(t){n(t.buffer)}return{alloc:e,free:n,allocType:i,freeType:r}}var Ct=Nt();Ct.zero=Nt();var Ut=3408,Ft=3410,Bt=3411,kt=3412,Tt=3413,zt=3414,Mt=3415,jt=33901,Qt=33902,Pt=3379,Et=3386,Dt=34921,Ot=36347,At=36348,qt=35661,$t=35660,te=34930,ee=36349,ne=34076,ie=34024,re=7936,oe=7937,le=7938,ae=35724,se=34047,ue=36063,ce=34852,de=3553,he=34067,be=34069,pe=33984,me=6408,fe=5126,ye=5121,Ze=36160,Xe=36053,Ge=36064,We=16384,Ve=function(t,e){var n=1;e.ext_texture_filter_anisotropic&&(n=t.getParameter(se));var i=1,r=1;e.webgl_draw_buffers&&(i=t.getParameter(ce),r=t.getParameter(ue));var o=!!e.oes_texture_float;if(o){var l=t.createTexture();t.bindTexture(de,l),t.texImage2D(de,0,me,1,1,0,me,fe,null);var a=t.createFramebuffer();if(t.bindFramebuffer(Ze,a),t.framebufferTexture2D(Ze,Ge,de,l,0),t.bindTexture(de,null),t.checkFramebufferStatus(Ze)!==Xe)o=!1;else{t.viewport(0,0,1,1),t.clearColor(1,0,0,1),t.clear(We);var s=Ct.allocType(fe,4);t.readPixels(0,0,1,1,me,fe,s),t.getError()?o=!1:(t.deleteFramebuffer(a),t.deleteTexture(l),o=1===s[0]),Ct.freeType(s)}}var u=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=t.createTexture(),d=Ct.allocType(ye,36);t.activeTexture(pe),t.bindTexture(he,c),t.texImage2D(be,0,me,3,3,0,me,ye,d),Ct.freeType(d),t.bindTexture(he,null),t.deleteTexture(c),u=!t.getError()}return{colorBits:[t.getParameter(Ft),t.getParameter(Bt),t.getParameter(kt),t.getParameter(Tt)],depthBits:t.getParameter(zt),stencilBits:t.getParameter(Mt),subpixelBits:t.getParameter(Ut),extensions:Object.keys(e).filter((function(t){return!!e[t]})),maxAnisotropic:n,maxDrawbuffers:i,maxColorAttachments:r,pointSizeDims:t.getParameter(jt),lineWidthDims:t.getParameter(Qt),maxViewportDims:t.getParameter(Et),maxCombinedTextureUnits:t.getParameter(qt),maxCubeMapSize:t.getParameter(ne),maxRenderbufferSize:t.getParameter(ie),maxTextureUnits:t.getParameter(te),maxTextureSize:t.getParameter(Pt),maxAttributes:t.getParameter(Dt),maxVertexUniforms:t.getParameter(Ot),maxVertexTextureUnits:t.getParameter($t),maxVaryingVectors:t.getParameter(At),maxFragmentUniforms:t.getParameter(ee),glsl:t.getParameter(ae),renderer:t.getParameter(oe),vendor:t.getParameter(re),version:t.getParameter(le),readFloat:o,npotTextureCube:u}};function ve(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]}))},Re={shape:He,flatten:Ke};function ge(t,e,n){for(var i=0;i0)if(Array.isArray(n[0])){a=Ne(n);for(var u=1,c=1;c0)if("number"==typeof e[0]){var o=Ct.allocType(c.dtype,e.length);ze(o,e),p(o,r),Ct.freeType(o)}else if(Array.isArray(e[0])||t(e[0])){i=Ne(e);var l=Ie(e,i,c.dtype);p(l,r),Ct.freeType(l)}else nt.raise("invalid buffer data")}else if(ve(e)){i=e.shape;var a=e.stride,s=0,u=0,h=0,b=0;1===i.length?(s=i[0],u=1,h=a[0],b=0):2===i.length?(s=i[0],u=i[1],h=a[0],b=a[1]):nt.raise("invalid shape");var m=Array.isArray(e.data)?c.dtype:Te(e.data),f=Ct.allocType(m,s*u);Me(f,e.data,s,u,h,b,e.offset),p(f,r),Ct.freeType(f)}else nt.raise("invalid data for buffer subdata");return d}return l[c.id]=c,s||d(r),d._reglType="buffer",d._buffer=c,d.subdata=m,i.profile&&(d.stats=c.stats),d.destroy=function(){b(c)},d}function m(){Se(l).forEach((function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)}))}return i.profile&&(n.getTotalBufferSize=function(){var t=0;return Object.keys(l).forEach((function(e){t+=l[e].stats.size})),t}),{create:p,createStream:u,destroyStream:c,clear:function(){Se(l).forEach(b),s.forEach(b)},getBuffer:function(t){return t&&t._buffer instanceof a?t._buffer:null},restore:m,_initBuffer:h}}ke[5120]=1,ke[5122]=2,ke[5124]=4,ke[5121]=1,ke[5123]=2,ke[5125]=4,ke[5126]=4;var Qe={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},Pe=0,Ee=1,De=4,Oe=5120,Ae=5121,qe=5122,$e=5123,tn=5124,en=5125,nn=34963,rn=35040,on=35044;function ln(e,n,i,r){var o={},l=0,a={uint8:Ae,uint16:$e};function s(t){this.id=l++,o[this.id]=this,this.buffer=t,this.primType=De,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(a.uint32=en),s.prototype.bind=function(){this.buffer.bind()};var u=[];function c(t){var e=u.pop();return e||(e=new s(i.create(null,nn,!0,!1)._buffer)),h(e,t,rn,-1,-1,0,0),e}function d(t){u.push(t)}function h(r,o,l,a,s,u,c){var d;if(r.buffer.bind(),o){var h=c;c||t(o)&&(!ve(o)||t(o.data))||(h=n.oes_element_index_uint?en:$e),i._initBuffer(r.buffer,o,l,h,3)}else e.bufferData(nn,u,l),r.buffer.dtype=d||Ae,r.buffer.usage=l,r.buffer.dimension=3,r.buffer.byteLength=u;if(d=c,!c){switch(r.buffer.dtype){case Ae:case Oe:d=Ae;break;case $e:case qe:d=$e;break;case en:case tn:d=en;break;default:nt.raise("unsupported type for element array")}r.buffer.dtype=d}r.type=d,nt(d!==en||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var b=s;b<0&&(b=r.buffer.byteLength,d===$e?b>>=1:d===en&&(b>>=2)),r.vertCount=b;var p=a;if(a<0){p=De;var m=r.buffer.dimension;1===m&&(p=Pe),2===m&&(p=Ee),3===m&&(p=De)}r.primType=p}function b(t){r.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=i.create(null,nn,!0),l=new s(o._buffer);function u(e){if(e)if("number"==typeof e)o(e),l.primType=De,l.vertCount=0|e,l.type=Ae;else{var n=null,i=on,r=-1,s=-1,c=0,d=0;Array.isArray(e)||t(e)||ve(e)?n=e:(nt.type(e,"object","invalid arguments for elements"),"data"in e&&(n=e.data,nt(Array.isArray(n)||t(n)||ve(n),"invalid data for element buffer")),"usage"in e&&(nt.parameter(e.usage,_e,"invalid element buffer usage"),i=_e[e.usage]),"primitive"in e&&(nt.parameter(e.primitive,Qe,"invalid element buffer primitive"),r=Qe[e.primitive]),"count"in e&&(nt("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),s=0|e.count),"type"in e&&(nt.parameter(e.type,a,"invalid buffer type"),d=a[e.type]),"length"in e?c=0|e.length:(c=s,d===$e||d===qe?c*=2:d!==en&&d!==tn||(c*=4))),h(l,n,i,r,s,c,d)}else o(),l.primType=De,l.vertCount=0,l.type=Ae;return u}return r.elementsCount++,u(e),u._reglType="elements",u._elements=l,u.subdata=function(t,e){return o.subdata(t,e),u},u.destroy=function(){b(l)},u}return{create:p,createStream:c,destroyStream:d,getElements:function(t){return"function"==typeof t&&t._elements instanceof s?t._elements:null},clear:function(){Se(o).forEach(b)}}}var an=new Float32Array(1),sn=new Uint32Array(an.buffer),un=5123;function cn(t){for(var e=Ct.allocType(un,t.length),n=0;n>>31<<15,o=(i<<1>>>24)-127,l=i>>13&1023;if(o<-24)e[n]=r;else if(o<-14){var a=-14-o;e[n]=r+(l+1024>>a)}else e[n]=o>15?r+31744:r+(o+15<<10)+l}return e}function dn(e){return Array.isArray(e)||t(e)}var hn=function(t){return!(t&t-1||!t)},bn=34467,pn=3553,mn=34067,fn=34069,yn=6408,Zn=6406,Xn=6407,Gn=6409,Wn=6410,Vn=32854,vn=32855,Sn=36194,Rn=32819,gn=32820,Ln=33635,xn=34042,Yn=6402,Kn=34041,Hn=35904,Jn=35906,wn=36193,_n=33776,In=33777,Nn=33778,Cn=33779,Un=35986,Fn=35987,Bn=34798,kn=35840,Tn=35841,zn=35842,Mn=35843,jn=36196,Qn=5121,Pn=5123,En=5125,Dn=5126,On=10242,An=10243,qn=10497,$n=33071,ti=33648,ei=10240,ni=10241,ii=9728,ri=9729,oi=9984,li=9985,ai=9986,si=9987,ui=33170,ci=4352,di=4353,hi=4354,bi=34046,pi=3317,mi=37440,fi=37441,yi=37443,Zi=37444,Xi=33984,Gi=[oi,ai,li,si],Wi=[0,Gn,Wn,Xn,yn],Vi={};function vi(t){return"[object "+t+"]"}Vi[Gn]=Vi[Zn]=Vi[Yn]=1,Vi[Kn]=Vi[Wn]=2,Vi[Xn]=Vi[Hn]=3,Vi[yn]=Vi[Jn]=4;var Si=vi("HTMLCanvasElement"),Ri=vi("OffscreenCanvas"),gi=vi("CanvasRenderingContext2D"),Li=vi("ImageBitmap"),xi=vi("HTMLImageElement"),Yi=vi("HTMLVideoElement"),Ki=Object.keys(Je).concat([Si,Ri,gi,Li,xi,Yi]),Hi=[];Hi[Qn]=1,Hi[Dn]=4,Hi[wn]=2,Hi[Pn]=2,Hi[En]=4;var Ji=[];function wi(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function _i(t){return!!Array.isArray(t)&&!(0===t.length||!dn(t[0]))}function Ii(t){return Object.prototype.toString.call(t)}function Ni(t){return Ii(t)===Si}function Ci(t){return Ii(t)===Ri}function Ui(t){return Ii(t)===gi}function Fi(t){return Ii(t)===Li}function Bi(t){return Ii(t)===xi}function ki(t){return Ii(t)===Yi}function Ti(t){if(!t)return!1;var e=Ii(t);return Ki.indexOf(e)>=0||wi(t)||_i(t)||ve(t)}function zi(t){return 0|Je[Object.prototype.toString.call(t)]}function Mi(t,e){var n=e.length;switch(t.type){case Qn:case Pn:case En:case Dn:var i=Ct.allocType(t.type,n);i.set(e),t.data=i;break;case wn:t.data=cn(e);break;default:nt.raise("unsupported texture type, must specify a typed array")}}function ji(t,e){return Ct.allocType(t.type===wn?Dn:t.type,e)}function Qi(t,e){t.type===wn?(t.data=cn(e),Ct.freeType(e)):t.data=e}function Pi(t,e,n,i,r,o){for(var l=t.width,a=t.height,s=t.channels,u=ji(t,l*a*s),c=0,d=0;d=1;)a+=l*s*s,s/=2;return a}return l*n*i}function Di(n,i,r,o,l,a,s){var u={"don't care":ci,"dont care":ci,nice:hi,fast:di},c={repeat:qn,clamp:$n,mirror:ti},d={nearest:ii,linear:ri},h=e({mipmap:si,"nearest mipmap nearest":oi,"linear mipmap nearest":li,"nearest mipmap linear":ai,"linear mipmap linear":si},d),b={none:0,browser:Zi},p={uint8:Qn,rgba4:Rn,rgb565:Ln,"rgb5 a1":gn},m={alpha:Zn,luminance:Gn,"luminance alpha":Wn,rgb:Xn,rgba:yn,rgba4:Vn,"rgb5 a1":vn,rgb565:Sn},f={};i.ext_srgb&&(m.srgb=Hn,m.srgba=Jn),i.oes_texture_float&&(p.float32=p.float=Dn),i.oes_texture_half_float&&(p.float16=p["half float"]=wn),i.webgl_depth_texture&&(e(m,{depth:Yn,"depth stencil":Kn}),e(p,{uint16:Pn,uint32:En,"depth stencil":xn})),i.webgl_compressed_texture_s3tc&&e(f,{"rgb s3tc dxt1":_n,"rgba s3tc dxt1":In,"rgba s3tc dxt3":Nn,"rgba s3tc dxt5":Cn}),i.webgl_compressed_texture_atc&&e(f,{"rgb atc":Un,"rgba atc explicit alpha":Fn,"rgba atc interpolated alpha":Bn}),i.webgl_compressed_texture_pvrtc&&e(f,{"rgb pvrtc 4bppv1":kn,"rgb pvrtc 2bppv1":Tn,"rgba pvrtc 4bppv1":zn,"rgba pvrtc 2bppv1":Mn}),i.webgl_compressed_texture_etc1&&(f["rgb etc1"]=jn);var y=Array.prototype.slice.call(n.getParameter(bn));Object.keys(f).forEach((function(t){var e=f[t];y.indexOf(e)>=0&&(m[t]=e)}));var Z=Object.keys(m);r.textureFormats=Z;var X=[];Object.keys(m).forEach((function(t){var e=m[t];X[e]=t}));var G=[];Object.keys(p).forEach((function(t){var e=p[t];G[e]=t}));var W=[];Object.keys(d).forEach((function(t){var e=d[t];W[e]=t}));var V=[];Object.keys(h).forEach((function(t){var e=h[t];V[e]=t}));var v=[];Object.keys(c).forEach((function(t){var e=c[t];v[e]=t}));var S=Z.reduce((function(t,e){var n=m[e];return n===Gn||n===Zn||n===Gn||n===Wn||n===Yn||n===Kn||i.ext_srgb&&(n===Hn||n===Jn)?t[n]=n:n===vn||e.indexOf("rgba")>=0?t[n]=yn:t[n]=Xn,t}),{});function R(){this.internalformat=yn,this.format=yn,this.type=Qn,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Zi,this.width=0,this.height=0,this.channels=0}function g(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 L(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,b,"invalid colorSpace"),t.colorSpace=b[e.colorSpace]),"type"in e){var n=e.type;nt(i.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),nt(i.oes_texture_half_float||!("half float"===n||"float16"===n),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),nt(i.webgl_depth_texture||!("uint16"===n||"uint32"===n||"depth stencil"===n),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(n,p,"invalid texture type"),t.type=p[n]}var o=t.width,l=t.height,a=t.channels,s=!1;"shape"in e?(nt(Array.isArray(e.shape)&&e.shape.length>=2,"shape must be an array"),o=e.shape[0],l=e.shape[1],3===e.shape.length&&(a=e.shape[2],nt(a>0&&a<=4,"invalid number of channels"),s=!0),nt(o>=0&&o<=r.maxTextureSize,"invalid width"),nt(l>=0&&l<=r.maxTextureSize,"invalid height")):("radius"in e&&(o=l=e.radius,nt(o>=0&&o<=r.maxTextureSize,"invalid radius")),"width"in e&&(o=e.width,nt(o>=0&&o<=r.maxTextureSize,"invalid width")),"height"in e&&(l=e.height,nt(l>=0&&l<=r.maxTextureSize,"invalid height")),"channels"in e&&(a=e.channels,nt(a>0&&a<=4,"invalid number of channels"),s=!0)),t.width=0|o,t.height=0|l,t.channels=0|a;var u=!1;if("format"in e){var c=e.format;nt(i.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),nt.parameter(c,m,"invalid texture format");var d=t.internalformat=m[c];t.format=S[d],c in p&&("type"in e||(t.type=p[c])),c in f&&(t.compressed=!0),u=!0}!s&&u?t.channels=Vi[t.format]:s&&!u?t.channels!==Wi[t.format]&&(t.format=t.internalformat=Wi[t.channels]):u&&s&&nt(t.channels===Vi[t.format],"number of channels inconsistent with specified format")}}function x(t){n.pixelStorei(mi,t.flipY),n.pixelStorei(fi,t.premultiplyAlpha),n.pixelStorei(yi,t.colorSpace),n.pixelStorei(pi,t.unpackAlignment)}function Y(){R.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function K(e,n){var i=null;if(Ti(n)?i=n:n&&(nt.type(n,"object","invalid pixel data type"),L(e,n),"x"in n&&(e.xOffset=0|n.x),"y"in n&&(e.yOffset=0|n.y),Ti(n.data)&&(i=n.data)),nt(!e.compressed||i instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){nt(!i,"can not specify copy and data field for the same texture");var o=l.viewportWidth,a=l.viewportHeight;e.width=e.width||o-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0,nt(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=o&&e.height>0&&e.height<=a,"copy texture read out of bounds")}else if(i){if(t(i))e.channels=e.channels||4,e.data=i,"type"in n||e.type!==Qn||(e.type=zi(i));else if(wi(i))e.channels=e.channels||4,Mi(e,i),e.alignment=1,e.needsFree=!0;else if(ve(i)){var s=i.data;Array.isArray(s)||e.type!==Qn||(e.type=zi(s));var u,c,d,h,b,p,m=i.shape,f=i.stride;3===m.length?(d=m[2],p=f[2]):(nt(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),d=1,p=1),u=m[0],c=m[1],h=f[0],b=f[1],e.alignment=1,e.width=u,e.height=c,e.channels=d,e.format=e.internalformat=Wi[d],e.needsFree=!0,Pi(e,s,h,b,p,i.offset)}else if(Ni(i)||Ci(i)||Ui(i))Ni(i)||Ci(i)?e.element=i:e.element=i.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(Fi(i))e.element=i,e.width=i.width,e.height=i.height,e.channels=4;else if(Bi(i))e.element=i,e.width=i.naturalWidth,e.height=i.naturalHeight,e.channels=4;else if(ki(i))e.element=i,e.width=i.videoWidth,e.height=i.videoHeight,e.channels=4;else if(_i(i)){var y=e.width||i[0].length,Z=e.height||i.length,X=e.channels;X=dn(i[0][0])?X||i[0][0].length:X||1;for(var G=Re.shape(i),W=1,V=0;V=0,"oes_texture_float extension not enabled"):e.type===wn&&nt(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function H(t,e,i){var r=t.element,l=t.data,a=t.internalformat,s=t.format,u=t.type,c=t.width,d=t.height;x(t),r?n.texImage2D(e,i,s,s,u,r):t.compressed?n.compressedTexImage2D(e,i,a,c,d,0,l):t.needsCopy?(o(),n.copyTexImage2D(e,i,s,t.xOffset,t.yOffset,c,d,0)):n.texImage2D(e,i,s,c,d,0,s,u,l||null)}function J(t,e,i,r,l){var a=t.element,s=t.data,u=t.internalformat,c=t.format,d=t.type,h=t.width,b=t.height;x(t),a?n.texSubImage2D(e,l,i,r,c,d,a):t.compressed?n.compressedTexSubImage2D(e,l,i,r,u,h,b,s):t.needsCopy?(o(),n.copyTexSubImage2D(e,l,i,r,t.xOffset,t.yOffset,h,b)):n.texSubImage2D(e,l,i,r,h,b,c,d,s)}var w=[];function _(){return w.pop()||new Y}function I(t){t.needsFree&&Ct.freeType(t.data),Y.call(t),w.push(t)}function N(){R.call(this),this.genMipmaps=!1,this.mipmapHint=ci,this.mipmask=0,this.images=Array(16)}function C(t,e,n){var i=t.images[0]=_();t.mipmask=1,i.width=t.width=e,i.height=t.height=n,i.channels=t.channels=4}function U(t,e){var n=null;if(Ti(e))g(n=t.images[0]=_(),t),K(n,e),t.mipmask=1;else if(L(t,e),Array.isArray(e.mipmap))for(var i=e.mipmap,r=0;r>=r,n.height>>=r,K(n,i[r]),t.mipmask|=1<=0&&!("faces"in e)&&(t.genMipmaps=!0)}if("mag"in e){var i=e.mag;nt.parameter(i,d),t.magFilter=d[i]}var o=t.wrapS,l=t.wrapT;if("wrap"in e){var a=e.wrap;"string"==typeof a?(nt.parameter(a,c),o=l=c[a]):Array.isArray(a)&&(nt.parameter(a[0],c),nt.parameter(a[1],c),o=c[a[0]],l=c[a[1]])}else{if("wrapS"in e){var s=e.wrapS;nt.parameter(s,c),o=c[s]}if("wrapT"in e){var b=e.wrapT;nt.parameter(b,c),l=c[b]}}if(t.wrapS=o,t.wrapT=l,"anisotropic"in e){var p=e.anisotropic;nt("number"==typeof p&&p>=1&&p<=r.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=e.anisotropic}if("mipmap"in e){var m=!1;switch(typeof e.mipmap){case"string":nt.parameter(e.mipmap,u,"invalid mipmap hint"),t.mipmapHint=u[e.mipmap],t.genMipmaps=!0,m=!0;break;case"boolean":m=t.genMipmaps=e.mipmap;break;case"object":nt(Array.isArray(e.mipmap),"invalid mipmap type"),t.genMipmaps=!1,m=!0;break;default:nt.raise("invalid mipmap type")}m&&!("min"in e)&&(t.minFilter=oi)}}function j(t,e){n.texParameteri(e,ni,t.minFilter),n.texParameteri(e,ei,t.magFilter),n.texParameteri(e,On,t.wrapS),n.texParameteri(e,An,t.wrapT),i.ext_texture_filter_anisotropic&&n.texParameteri(e,bi,t.anisotropic),t.genMipmaps&&(n.hint(ui,t.mipmapHint),n.generateMipmap(e))}var Q=0,P={},E=r.maxTextureUnits,D=Array(E).map((function(){return null}));function O(t){R.call(this),this.mipmask=0,this.internalformat=yn,this.id=Q++,this.refCount=1,this.target=t,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new z,s.profile&&(this.stats={size:0})}function A(t){n.activeTexture(Xi),n.bindTexture(t.target,t.texture)}function q(){var t=D[0];t?n.bindTexture(t.target,t.texture):n.bindTexture(pn,null)}function $(t){var e=t.texture;nt(e,"must not double destroy texture");var i=t.unit,r=t.target;i>=0&&(n.activeTexture(Xi+i),n.bindTexture(r,null),D[i]=null),n.deleteTexture(e),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete P[t.id],a.textureCount--}function tt(t,e){var i=new O(pn);function o(t,e){var n=i.texInfo;z.call(n);var l=k();return"number"==typeof t?C(l,0|t,"number"==typeof e?0|e:0|t):t?(nt.type(t,"object","invalid arguments to regl.texture"),M(n,t),U(l,t)):C(l,1,1),n.genMipmaps&&(l.mipmask=(l.width<<1)-1),i.mipmask=l.mipmask,g(i,l),nt.texture2D(n,l,r),i.internalformat=l.internalformat,o.width=l.width,o.height=l.height,A(i),F(l,pn),j(n,pn),q(),T(l),s.profile&&(i.stats.size=Ei(i.internalformat,i.type,l.width,l.height,n.genMipmaps,!1)),o.format=X[i.internalformat],o.type=G[i.type],o.mag=W[n.magFilter],o.min=V[n.minFilter],o.wrapS=v[n.wrapS],o.wrapT=v[n.wrapT],o}function l(t,e,n,r){nt(!!t,"must specify image data");var l=0|e,a=0|n,s=0|r,u=_();return g(u,i),u.width=0,u.height=0,K(u,t),u.width=u.width||(i.width>>s)-l,u.height=u.height||(i.height>>s)-a,nt(i.type===u.type&&i.format===u.format&&i.internalformat===u.internalformat,"incompatible format for texture.subimage"),nt(l>=0&&a>=0&&l+u.width<=i.width&&a+u.height<=i.height,"texture.subimage write out of bounds"),nt(i.mipmask&1<>a;++a){var u=r>>a,c=l>>a;if(!u||!c)break;n.texImage2D(pn,a,i.format,u,c,0,i.format,i.type,null)}return q(),s.profile&&(i.stats.size=Ei(i.internalformat,i.type,r,l,!1,!1)),o}return P[i.id]=i,a.textureCount++,o(t,e),o.subimage=l,o.resize=u,o._reglType="texture2d",o._texture=i,s.profile&&(o.stats=i.stats),o.destroy=function(){i.decRef()},o}function et(t,e,i,o,l,u){var c=new O(mn);P[c.id]=c,a.cubeCount++;var d=new Array(6);function h(t,e,n,i,o,l){var a,u=c.texInfo;for(z.call(u),a=0;a<6;++a)d[a]=k();if("number"!=typeof t&&t)if("object"==typeof t)if(e)U(d[0],t),U(d[1],e),U(d[2],n),U(d[3],i),U(d[4],o),U(d[5],l);else if(M(u,t),L(c,t),"faces"in t){var b=t.faces;for(nt(Array.isArray(b)&&6===b.length,"cube faces must be a length 6 array"),a=0;a<6;++a)nt("object"==typeof b[a]&&!!b[a],"invalid input for cube map face"),g(d[a],c),U(d[a],b[a])}else for(a=0;a<6;++a)U(d[a],t);else nt.raise("invalid arguments to cube map");else{var p=0|t||1;for(a=0;a<6;++a)C(d[a],p,p)}for(g(c,d[0]),nt.optional((function(){r.npotTextureCube||nt(hn(c.width)&&hn(c.height),"your browser does not support non power or two texture dimensions")})),u.genMipmaps?c.mipmask=(d[0].width<<1)-1:c.mipmask=d[0].mipmask,nt.textureCube(c,u,d,r),c.internalformat=d[0].internalformat,h.width=d[0].width,h.height=d[0].height,A(c),a=0;a<6;++a)F(d[a],fn+a);for(j(u,mn),q(),s.profile&&(c.stats.size=Ei(c.internalformat,c.type,h.width,h.height,u.genMipmaps,!0)),h.format=X[c.internalformat],h.type=G[c.type],h.mag=W[u.magFilter],h.min=V[u.minFilter],h.wrapS=v[u.wrapS],h.wrapT=v[u.wrapT],a=0;a<6;++a)T(d[a]);return h}function b(t,e,n,i,r){nt(!!e,"must specify image data"),nt("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var o=0|n,l=0|i,a=0|r,s=_();return g(s,c),s.width=0,s.height=0,K(s,e),s.width=s.width||(c.width>>a)-o,s.height=s.height||(c.height>>a)-l,nt(c.type===s.type&&c.format===s.format&&c.internalformat===s.internalformat,"incompatible format for texture.subimage"),nt(o>=0&&l>=0&&o+s.width<=c.width&&l+s.height<=c.height,"texture.subimage write out of bounds"),nt(c.mipmask&1<>r;++r)n.texImage2D(fn+i,r,c.format,e>>r,e>>r,0,c.format,c.type,null);return q(),s.profile&&(c.stats.size=Ei(c.internalformat,c.type,h.width,h.height,!1,!0)),h}}return h(t,e,i,o,l,u),h.subimage=b,h.resize=p,h._reglType="textureCube",h._texture=c,s.profile&&(h.stats=c.stats),h.destroy=function(){c.decRef()},h}function it(){for(var t=0;t>e,t.height>>e,0,t.internalformat,t.type,null);else for(var i=0;i<6;++i)n.texImage2D(fn+i,e,t.internalformat,t.width>>e,t.height>>e,0,t.internalformat,t.type,null);j(t.texInfo,t.target)}))}function ot(){for(var t=0;t0)continue;r.unit=-1}D[i]=t,e=i;break}e>=E&&nt.raise("insufficient number of texture units"),s.profile&&a.maxTextureUnits=2,"invalid renderbuffer shape"),a=0|b[0],s=0|b[1]}else"radius"in h&&(a=s=0|h.radius),"width"in h&&(a=0|h.width),"height"in h&&(s=0|h.height);"format"in h&&(nt.parameter(h.format,o,"invalid renderbuffer format"),u=o[h.format])}else"number"==typeof e?(a=0|e,s="number"==typeof i?0|i:a):e?nt.raise("invalid arguments to renderbuffer constructor"):a=s=1;if(nt(a>0&&s>0&&a<=n.maxRenderbufferSize&&s<=n.maxRenderbufferSize,"invalid renderbuffer size"),a!==c.width||s!==c.height||u!==c.format)return d.width=c.width=a,d.height=c.height=s,c.format=u,t.bindRenderbuffer(Oi,c.renderbuffer),t.renderbufferStorage(Oi,u,a,s),nt(0===t.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=sr(c.format,c.width,c.height)),d.format=l[c.format],d}function h(e,i){var o=0|e,l=0|i||o;return o===c.width&&l===c.height||(nt(o>0&&l>0&&o<=n.maxRenderbufferSize&&l<=n.maxRenderbufferSize,"invalid renderbuffer size"),d.width=c.width=o,d.height=c.height=l,t.bindRenderbuffer(Oi,c.renderbuffer),t.renderbufferStorage(Oi,c.format,o,l),nt(0===t.getError(),"invalid render buffer format"),r.profile&&(c.stats.size=sr(c.format,c.width,c.height))),d}return s[c.id]=c,i.renderbufferCount++,d(e,a),d.resize=h,d._reglType="renderbuffer",d._renderbuffer=c,r.profile&&(d.stats=c.stats),d.destroy=function(){c.decRef()},d}function h(){Se(s).forEach((function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(Oi,e.renderbuffer),t.renderbufferStorage(Oi,e.format,e.width,e.height)})),t.bindRenderbuffer(Oi,null)}return u.prototype.decRef=function(){--this.refCount<=0&&c(this)},r.profile&&(i.getTotalRenderbufferSize=function(){var t=0;return Object.keys(s).forEach((function(e){t+=s[e].stats.size})),t}),{create:d,clear:function(){Se(s).forEach(c)},restore:h}},cr=36160,dr=36161,hr=3553,br=34069,pr=36064,mr=36096,fr=36128,yr=33306,Zr=36053,Xr=36054,Gr=36055,Wr=36057,Vr=36061,vr=36193,Sr=5121,Rr=5126,gr=6407,Lr=6408,xr=6402,Yr=[gr,Lr],Kr=[];Kr[Lr]=4,Kr[gr]=3;var Hr=[];Hr[Sr]=1,Hr[Rr]=4,Hr[vr]=2;var Jr=33189,wr=36168,_r=34041,Ir=[32854,32855,36194,35907,34842,34843,34836],Nr={};function Cr(t,n,i,r,o,l){var a={cur:null,next:null,dirty:!1,setFBO:null},s=["rgba"],u=["rgba4","rgb565","rgb5 a1"];n.ext_srgb&&u.push("srgba"),n.ext_color_buffer_half_float&&u.push("rgba16f","rgb16f"),n.webgl_color_buffer_float&&u.push("rgba32f");var c=["uint8"];function d(t,e,n){this.target=t,this.texture=e,this.renderbuffer=n;var i=0,r=0;e?(i=e.width,r=e.height):n&&(i=n.width,r=n.height),this.width=i,this.height=r}function h(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function b(t,e,n){if(t)if(t.texture){var i=t.texture._texture,r=Math.max(1,i.width),o=Math.max(1,i.height);nt(r===e&&o===n,"inconsistent width/height for supplied texture"),i.refCount+=1}else{var l=t.renderbuffer._renderbuffer;nt(l.width===e&&l.height===n,"inconsistent width/height for renderbuffer"),l.refCount+=1}}function p(e,n){n&&(n.texture?t.framebufferTexture2D(cr,e,n.target,n.texture._texture.texture,0):t.framebufferRenderbuffer(cr,e,dr,n.renderbuffer._renderbuffer.renderbuffer))}function m(t){var e=hr,n=null,i=null,r=t;"object"==typeof t&&(r=t.data,"target"in t&&(e=0|t.target)),nt.type(r,"function","invalid attachment data");var o=r._reglType;return"texture2d"===o?(n=r,nt(e===hr)):"textureCube"===o?(n=r,nt(e>=br&&e=2,"invalid shape for framebuffer"),l=H[0],h=H[1]}else"radius"in K&&(l=h=K.radius),"width"in K&&(l=K.width),"height"in K&&(h=K.height);("color"in K||"colors"in K)&&(X=K.color||K.colors,Array.isArray(X)&&nt(1===X.length||n.webgl_draw_buffers,"multiple render targets not supported")),X||("colorCount"in K&&(R=0|K.colorCount,nt(R>0,"invalid color buffer count")),"colorTexture"in K&&(G=!!K.colorTexture,W="rgba4"),"colorType"in K&&(v=K.colorType,G?(nt(n.oes_texture_float||!("float"===v||"float32"===v),"you must enable OES_texture_float in order to use floating point framebuffer objects"),nt(n.oes_texture_half_float||!("half float"===v||"float16"===v),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===v||"float16"===v?(nt(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),W="rgba16f"):"float"!==v&&"float32"!==v||(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(v,c,"invalid color type")),"colorFormat"in K&&(W=K.colorFormat,s.indexOf(W)>=0?G=!0:u.indexOf(W)>=0?G=!1:nt.optional((function(){G?nt.oneOf(K.colorFormat,s,"invalid color format for texture"):nt.oneOf(K.colorFormat,u,"invalid color format for renderbuffer")})))),("depthTexture"in K||"depthStencilTexture"in K)&&(Y=!(!K.depthTexture&&!K.depthStencilTexture),nt(!Y||n.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in K&&("boolean"==typeof K.depth?p=K.depth:(g=K.depth,Z=!1)),"stencil"in K&&("boolean"==typeof K.stencil?Z=K.stencil:(L=K.stencil,p=!1)),"depthStencil"in K&&("boolean"==typeof K.depthStencil?p=Z=K.depthStencil:(x=K.depthStencil,p=!1,Z=!1))}else l=h=1;var J=null,w=null,_=null,I=null;if(Array.isArray(X))J=X.map(m);else if(X)J=[m(X)];else for(J=new Array(R),r=0;r=0||J[r].renderbuffer&&Ir.indexOf(J[r].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+r+" is invalid"),J[r]&&J[r].texture){var C=Kr[J[r].texture._texture.format]*Hr[J[r].texture._texture.type];null===N?N=C:nt(N===C,"all color attachments much have the same number of bits per pixel.")}return b(w,l,h),nt(!w||w.texture&&w.texture._texture.format===xr||w.renderbuffer&&w.renderbuffer._renderbuffer.format===Jr,"invalid depth attachment for framebuffer object"),b(_,l,h),nt(!_||_.renderbuffer&&_.renderbuffer._renderbuffer.format===wr,"invalid stencil attachment for framebuffer object"),b(I,l,h),nt(!I||I.texture&&I.texture._texture.format===_r||I.renderbuffer&&I.renderbuffer._renderbuffer.format===_r,"invalid depth-stencil attachment for framebuffer object"),V(o),o.width=l,o.height=h,o.colorAttachments=J,o.depthAttachment=w,o.stencilAttachment=_,o.depthStencilAttachment=I,d.color=J.map(y),d.depth=y(w),d.stencil=y(_),d.depthStencil=y(I),d.width=o.width,d.height=o.height,S(o),d}function h(t,e){nt(a.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|t,1),i=Math.max(0|e||n,1);if(n===o.width&&i===o.height)return d;for(var r=o.colorAttachments,l=0;l=2,"invalid shape for framebuffer"),nt(Z[0]===Z[1],"cube framebuffer must be square"),h=Z[0]}else"radius"in y&&(h=0|y.radius),"width"in y?(h=0|y.width,"height"in y&&nt(y.height===h,"must be square")):"height"in y&&(h=0|y.height);("color"in y||"colors"in y)&&(b=y.color||y.colors,Array.isArray(b)&&nt(1===b.length||n.webgl_draw_buffers,"multiple render targets not supported")),b||("colorCount"in y&&(f=0|y.colorCount,nt(f>0,"invalid color buffer count")),"colorType"in y&&(nt.oneOf(y.colorType,c,"invalid color type"),m=y.colorType),"colorFormat"in y&&(p=y.colorFormat,nt.oneOf(y.colorFormat,s,"invalid color format for texture"))),"depth"in y&&(d.depth=y.depth),"stencil"in y&&(d.stencil=y.stencil),"depthStencil"in y&&(d.depthStencil=y.depthStencil)}else h=1;if(b)if(Array.isArray(b))for(u=[],i=0;i0&&(d.depth=o[0].depth,d.stencil=o[0].stencil,d.depthStencil=o[0].depthStencil),o[i]?o[i](d):o[i]=R(d)}return e(l,{width:h,height:h,color:u})}function u(t){var e,n=0|t;if(nt(n>0&&n<=i.maxCubeMapSize,"invalid radius for cube fbo"),n===l.width)return l;var r=l.color;for(e=0;e{for(var t=Object.keys(e),n=0;n=0,'invalid option for vao: "'+t[n]+'" valid options are '+kr)})),nt(Array.isArray(r),"attributes must be an array")}nt(r.length0,"must specify at least one attribute");var c={},d=i.attributes;d.length=r.length;for(var h=0;h=f.byteLength?b.subdata(f):(b.destroy(),i.buffers[h]=null)),i.buffers[h]||(b=i.buffers[h]=o.create(p,Fr,!1,!0)),m.buffer=o.getBuffer(b),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1,c[h]=1):o.getBuffer(p)?(m.buffer=o.getBuffer(p),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1):o.getBuffer(p.buffer)?(m.buffer=o.getBuffer(p.buffer),m.size=0|(+p.size||m.buffer.dimension),m.normalized=!!p.normalized||!1,"type"in p?(nt.parameter(p.type,we,"invalid buffer type"),m.type=we[p.type]):m.type=m.buffer.dtype,m.offset=0|(p.offset||0),m.stride=0|(p.stride||0),m.divisor=0|(p.divisor||0),m.state=1,nt(m.size>=1&&m.size<=4,"size must be between 1 and 4"),nt(m.offset>=0,"invalid offset"),nt(m.stride>=0&&m.stride<=255,"stride must be between 0 and 255"),nt(m.divisor>=0,"divisor must be positive"),nt(!m.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(nt(h>0,"first attribute must not be a constant"),m.x=+p.x||0,m.y=+p.y||0,m.z=+p.z||0,m.w=+p.w||0,m.state=2):nt(!1,"invalid attribute spec for location "+h)}for(var y=0;y1)for(var y=0;y1&&(X=X.replace("[0]","")),s(f,new a(X,n.id(X),t.getUniformLocation(b,X),c))}var G=t.getProgramParameter(b,Pr);r.profile&&(e.stats.attributesCount=G);var W=e.attributes;for(l=0;lt&&(t=e.stats.uniformsCount)})),t},i.getMaxAttributesCount=function(){var t=0;return d.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(l).forEach(e),l={},d.forEach((function(e){t.deleteProgram(e.program)})),d.length=0,c={},i.shaderCount=0},program:function(n,r,a,s){nt.command(n>=0,"missing vertex shader",a),nt.command(r>=0,"missing fragment shader",a);var u=c[r];u||(u=c[r]={});var h=u[n];if(h&&(h.refCount++,!s))return h;var m=new b(r,n);return i.shaderCount++,p(m,a,s),h||(u[n]=m),d.push(m),e(m,{destroy:function(){if(m.refCount--,m.refCount<=0){t.deleteProgram(m.program);var e=d.indexOf(m);d.splice(e,1),i.shaderCount--}u[m.vertId].refCount<=0&&(t.deleteShader(l[m.vertId]),delete l[m.vertId],delete c[m.fragId][m.vertId]),Object.keys(c[m.fragId]).length||(t.deleteShader(o[m.fragId]),delete o[m.fragId],delete c[m.fragId])}})},restore:m,shader:u,frag:-1,vert:-1}}var Dr=6408,Or=5121,Ar=3333,qr=5126;function $r(e,n,i,r,o,l,a){function s(s){var u;null===n.next?(nt(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),u=Or):(nt(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),u=n.next.colorAttachments[0].texture._texture.type,nt.optional((function(){l.oes_texture_float?(nt(u===Or||u===qr,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),u===qr&&nt(a.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):nt(u===Or,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var c=0,d=0,h=r.framebufferWidth,b=r.framebufferHeight,p=null;t(s)?p=s:s&&(nt.type(s,"object","invalid arguments to regl.read()"),c=0|s.x,d=0|s.y,nt(c>=0&&c=0&&d0&&h+c<=r.framebufferWidth,"invalid width for read pixels"),nt(b>0&&b+d<=r.framebufferHeight,"invalid height for read pixels"),i();var m=h*b*4;return p||(u===Or?p=new Uint8Array(m):u===qr&&(p=p||new Float32Array(m))),nt.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),nt(p.byteLength>=m,"data buffer for regl.read() too small"),e.pixelStorei(Ar,4),e.readPixels(c,d,h,b,Dr,u,p),p}function u(t){var e;return n.setFBO({framebuffer:t.framebuffer},(function(){e=s(t)})),e}function c(t){return t&&"framebuffer"in t?u(t):s(t)}return c}function to(t){return Array.prototype.slice.call(t)}function eo(t){return to(t).join("")}function no(){var t=0,n=[],i=[];function r(e){for(var r=0;r0&&(n.push(e,"="),n.push.apply(n,to(arguments)),n.push(";")),e}return e(i,{def:o,toString:function(){return eo([r.length>0?"var "+r.join(",")+";":"",eo(n)])}})}function l(){var t=o(),n=o(),i=t.toString,r=n.toString;function l(e,i){n(e,i,"=",t.def(e,i),";")}return e((function(){t.apply(t,to(arguments))}),{def:t.def,entry:t,exit:n,save:l,set:function(e,n,i){l(e,n),t(e,n,"=",i,";")},toString:function(){return i()+r()}})}function a(){var t=eo(arguments),n=l(),i=l(),r=n.toString,o=i.toString;return e(n,{then:function(){return n.apply(n,to(arguments)),this},else:function(){return i.apply(i,to(arguments)),this},toString:function(){var e=o();return e&&(e="else{"+e+"}"),eo(["if(",t,"){",r(),"}",e])}})}var s=o(),u={};function c(t,n){var i=[];function r(){var t="a"+i.length;return i.push(t),t}n=n||0;for(var o=0;o":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},na={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ia={frag:35632,vert:35633},ra={cw:kl,ccw:Tl};function oa(e){return Array.isArray(e)||t(e)||ve(e)}function la(t){return t.sort((function(t,e){return t===ko?-1:e===ko?1:t=1,i>=2,e)}if(n===ho){var r=t.data;return new aa(r.thisDep,r.contextDep,r.propDep,e)}if(n===bo)return new aa(!1,!1,!1,e);if(n===po){for(var o=!1,l=!1,a=!1,s=0;s=1&&(l=!0),c>=2&&(a=!0)}else u.type===ho&&(o=o||u.data.thisDep,l=l||u.data.contextDep,a=a||u.data.propDep)}return new aa(o,l,a,e)}return new aa(n===co,n===uo,n===so,e)}var da=new aa(!1,!1,!1,(function(){}));function ha(t,n,i,r,o,l,a,s,u,c,d,h,b,p,m){var f=c.Record,y={add:32774,subtract:32778,"reverse subtract":32779};i.ext_blend_minmax&&(y.min=zl,y.max=Ml);var Z=i.angle_instanced_arrays,X=i.webgl_draw_buffers,G=i.oes_vertex_array_object,W={dirty:!0,profile:m.profile},V={},v=[],S={},R={};function g(t){return t.replace(".","_")}function L(t,e,n){var i=g(t);v.push(t),V[i]=W[i]=!!n,S[i]=e}function x(t,e,n){var i=g(t);v.push(t),Array.isArray(n)?(W[i]=n.slice(),V[i]=n.slice()):W[i]=V[i]=n,R[i]=e}L(mo,pl),L(fo,bl),x(yo,"blendColor",[0,0,0,0]),x(Zo,"blendEquationSeparate",[Dl,Dl]),x(Xo,"blendFuncSeparate",[El,Pl,El,Pl]),L(Go,fl,!0),x(Wo,"depthFunc",Ol),x(Vo,"depthRange",[0,1]),x(vo,"depthMask",!0),x(So,So,[!0,!0,!0,!0]),L(Ro,hl),x(go,"cullFace",Bl),x(Lo,Lo,Tl),x(xo,xo,1),L(Yo,Zl),x(Ko,"polygonOffset",[0,0]),L(Ho,Xl),L(Jo,Gl),x(wo,"sampleCoverage",[1,!1]),L(_o,ml),x(Io,"stencilMask",-1),x(No,"stencilFunc",[jl,0,-1]),x(Co,"stencilOpSeparate",[Fl,Ql,Ql,Ql]),x(Uo,"stencilOpSeparate",[Bl,Ql,Ql,Ql]),L(Fo,yl),x(Bo,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),x(ko,ko,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var Y={gl:t,context:b,strings:n,next:V,current:W,draw:h,elements:l,buffer:o,shader:d,attributes:c.state,vao:c,uniforms:u,framebuffer:s,extensions:i,timer:p,isBufferArgs:oa},K={primTypes:Qe,compareFuncs:ea,blendFuncs:$l,blendEquations:y,stencilOps:na,glTypes:we,orientationType:ra};nt.optional((function(){Y.isArrayLike=dn})),X&&(K.backBuffer=[Bl],K.drawBuffer=gt(r.maxDrawbuffers,(function(t){return 0===t?[0]:gt(t,(function(t){return ql+t}))})));var H=0;function J(){var t=no(),e=t.link,i=t.global;t.id=H++,t.batchId="0";var r=e(Y),o=t.shared={props:"a0"};Object.keys(Y).forEach((function(t){o[t]=i.def(r,".",t)})),nt.optional((function(){t.CHECK=e(nt),t.commandStr=nt.guessCommand(),t.command=e(t.commandStr),t.assert=function(t,n,i){t("if(!(",n,"))",this.CHECK,".commandRaise(",e(i),",",this.command,");")},K.invalidBlendCombinations=ta}));var l=t.next={},a=t.current={};Object.keys(R).forEach((function(t){Array.isArray(W[t])&&(l[t]=i.def(o.next,".",t),a[t]=i.def(o.current,".",t))}));var s=t.constants={};Object.keys(K).forEach((function(t){s[t]=i.def(JSON.stringify(K[t]))})),t.invoke=function(n,i){switch(i.type){case ao:var r=["this",o.context,o.props,t.batchId];return n.def(e(i.data),".call(",r.slice(0,Math.max(i.data.length+1,4)),")");case so:return n.def(o.props,i.data);case uo:return n.def(o.context,i.data);case co:return n.def("this",i.data);case ho:return i.data.append(t,n),i.data.ref;case bo:return i.data.toString();case po:return i.data.map((function(e){return t.invoke(n,e)}))}},t.attribCache={};var u={};return t.scopeAttrib=function(t){var i=n.id(t);if(i in u)return u[i];var r=c.scope[i];return r||(r=c.scope[i]=new f),u[i]=e(r)},t}function w(t){var e,n=t.static,i=t.dynamic;if(To in n){var r=!!n[To];(e=ua((function(t,e){return r}))).enable=r}else if(To in i){var o=i[To];e=ca(o,(function(t,e){return t.invoke(e,o)}))}return e}function _(t,e){var n=t.static,i=t.dynamic;if(zo in n){var r=n[zo];return r?(r=s.getFramebuffer(r),nt.command(r,"invalid framebuffer object"),ua((function(t,e){var n=t.link(r),i=t.shared;e.set(i.framebuffer,".next",n);var o=i.context;return e.set(o,"."+tl,n+".width"),e.set(o,"."+el,n+".height"),n}))):ua((function(t,e){var n=t.shared;e.set(n.framebuffer,".next","null");var i=n.context;return e.set(i,"."+tl,i+"."+ol),e.set(i,"."+el,i+"."+ll),"null"}))}if(zo in i){var o=i[zo];return ca(o,(function(t,e){var n=t.invoke(e,o),i=t.shared,r=i.framebuffer,l=e.def(r,".getFramebuffer(",n,")");nt.optional((function(){t.assert(e,"!"+n+"||"+l,"invalid framebuffer object")})),e.set(r,".next",l);var a=i.context;return e.set(a,"."+tl,l+"?"+l+".width:"+a+"."+ol),e.set(a,"."+el,l+"?"+l+".height:"+a+"."+ll),l}))}return null}function I(t,e,n){var i=t.static,r=t.dynamic;function o(t){if(t in i){var o=i[t];nt.commandType(o,"object","invalid "+t,n.commandStr);var l,a,s=!0,u=0|o.x,c=0|o.y;return"width"in o?(l=0|o.width,nt.command(l>=0,"invalid "+t,n.commandStr)):s=!1,"height"in o?(a=0|o.height,nt.command(a>=0,"invalid "+t,n.commandStr)):s=!1,new aa(!s&&e&&e.thisDep,!s&&e&&e.contextDep,!s&&e&&e.propDep,(function(t,e){var n=t.shared.context,i=l;"width"in o||(i=e.def(n,".",tl,"-",u));var r=a;return"height"in o||(r=e.def(n,".",el,"-",c)),[u,c,i,r]}))}if(t in r){var d=r[t],h=ca(d,(function(e,n){var i=e.invoke(n,d);nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)}));var r=e.shared.context,o=n.def(i,".x|0"),l=n.def(i,".y|0"),a=n.def('"width" in ',i,"?",i,".width|0:","(",r,".",tl,"-",o,")"),s=n.def('"height" in ',i,"?",i,".height|0:","(",r,".",el,"-",l,")");return nt.optional((function(){e.assert(n,a+">=0&&"+s+">=0","invalid "+t)})),[o,l,a,s]}));return e&&(h.thisDep=h.thisDep||e.thisDep,h.contextDep=h.contextDep||e.contextDep,h.propDep=h.propDep||e.propDep),h}return e?new aa(e.thisDep,e.contextDep,e.propDep,(function(t,e){var n=t.shared.context;return[0,0,e.def(n,".",tl),e.def(n,".",el)]})):null}var l=o(ko);if(l){var a=l;l=new aa(l.thisDep,l.contextDep,l.propDep,(function(t,e){var n=a.append(t,e),i=t.shared.context;return e.set(i,"."+nl,n[2]),e.set(i,"."+il,n[3]),n}))}return{viewport:l,scissor_box:o(Bo)}}function N(t,e){var n=t.static;if("string"==typeof n[jo]&&"string"==typeof n[Mo]){if(Object.keys(e.dynamic).length>0)return null;var i=e.static,r=Object.keys(i);if(r.length>0&&"number"==typeof i[r[0]]){for(var o=[],l=0;l=0,"invalid "+t,e.commandStr),ua((function(t,e){return l&&(t.OFFSET=a),a}))}if(t in i){var c=i[t];return ca(c,(function(e,n){var i=e.invoke(n,c);return l&&(e.OFFSET=i,nt.optional((function(){e.assert(n,i+">=0","invalid "+t)}))),i}))}if(l){if(u)return ua((function(t,e){return t.OFFSET=0,0}));if(o)return new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.offset:0")}))}else if(o)return new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.instances:-1")}));return null}var m=p(Do,!0);function f(){if(Eo in n){var t=0|n[Eo];return r.count=t,nt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),ua((function(){return t}))}if(Eo in i){var l=i[Eo];return ca(l,(function(t,e){var n=t.invoke(e,l);return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")})),n}))}if(u){if(sa(h)){if(h)return m?new aa(m.thisDep,m.contextDep,m.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})):ua((function(t,e){return e.def(t.ELEMENTS,".vertCount")}));var a=ua((function(){return-1}));return nt.optional((function(){a.MISSING=!0})),a}var c=new aa(h.thisDep||m.thisDep,h.contextDep||m.contextDep,h.propDep||m.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(){c.DYNAMIC=!0})),c}return o?new aa(s.thisDep,s.contextDep,s.propDep,(function(t,e){return e.def(t.shared.vao,".currentVAO?",t.shared.vao,".currentVAO.count:-1")})):null}var y=b(),Z=f(),X=p(Oo,!1);return{elements:h,primitive:y,count:Z,instances:X,offset:m,vao:s,vaoActive:o,elementsActive:u,static:r}}function F(t,e){var n=t.static,i=t.dynamic,o={};return v.forEach((function(t){var l=g(t);function a(e,r){if(t in n){var a=e(n[t]);o[l]=ua((function(){return a}))}else if(t in i){var s=i[t];o[l]=ca(s,(function(t,e){return r(t,e,t.invoke(e,s))}))}}switch(t){case Ro:case fo:case mo:case _o:case Go:case Fo:case Yo:case Ho:case Jo:case vo:return a((function(n){return nt.commandType(n,"boolean",t,e.commandStr),n}),(function(e,n,i){return nt.optional((function(){e.assert(n,"typeof "+i+'==="boolean"',"invalid flag "+t,e.commandStr)})),i}));case Wo:return a((function(n){return nt.commandParameter(n,ea,"invalid "+t,e.commandStr),ea[n]}),(function(e,n,i){var r=e.constants.compareFuncs;return nt.optional((function(){e.assert(n,i+" in "+r,"invalid "+t+", must be one of "+Object.keys(ea))})),n.def(r,"[",i,"]")}));case Vo:return a((function(t){return nt.command(dn(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 Xo:return a((function(t){nt.commandType(t,"object","blend.func",e.commandStr);var n="srcRGB"in t?t.srcRGB:t.src,i="srcAlpha"in t?t.srcAlpha:t.src,r="dstRGB"in t?t.dstRGB:t.dst,o="dstAlpha"in t?t.dstAlpha:t.dst;return nt.commandParameter(n,$l,l+".srcRGB",e.commandStr),nt.commandParameter(i,$l,l+".srcAlpha",e.commandStr),nt.commandParameter(r,$l,l+".dstRGB",e.commandStr),nt.commandParameter(o,$l,l+".dstAlpha",e.commandStr),nt.command(-1===ta.indexOf(n+", "+r),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+r+")",e.commandStr),[$l[n],$l[r],$l[i],$l[o]]}),(function(e,n,i){var r=e.constants.blendFuncs;function o(o,l){var a=n.def('"',o,l,'" in ',i,"?",i,".",o,l,":",i,".",o);return nt.optional((function(){e.assert(n,a+" in "+r,"invalid "+t+"."+o+l+", must be one of "+Object.keys($l))})),a}nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid blend func, must be an object")}));var l=o("src","RGB"),a=o("dst","RGB");nt.optional((function(){var t=e.constants.invalidBlendCombinations;e.assert(n,t+".indexOf("+l+'+", "+'+a+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var s=n.def(r,"[",l,"]"),u=n.def(r,"[",o("src","Alpha"),"]");return[s,n.def(r,"[",a,"]"),u,n.def(r,"[",o("dst","Alpha"),"]")]}));case Zo:return a((function(n){return"string"==typeof n?(nt.commandParameter(n,y,"invalid "+t,e.commandStr),[y[n],y[n]]):"object"==typeof n?(nt.commandParameter(n.rgb,y,t+".rgb",e.commandStr),nt.commandParameter(n.alpha,y,t+".alpha",e.commandStr),[y[n.rgb],y[n.alpha]]):void nt.commandRaise("invalid blend.equation",e.commandStr)}),(function(e,n,i){var r=e.constants.blendEquations,o=n.def(),l=n.def(),a=e.cond("typeof ",i,'==="string"');return nt.optional((function(){function n(t,n,i){e.assert(t,i+" in "+r,"invalid "+n+", must be one of "+Object.keys(y))}n(a.then,t,i),e.assert(a.else,i+"&&typeof "+i+'==="object"',"invalid "+t),n(a.else,t+".rgb",i+".rgb"),n(a.else,t+".alpha",i+".alpha")})),a.then(o,"=",l,"=",r,"[",i,"];"),a.else(o,"=",r,"[",i,".rgb];",l,"=",r,"[",i,".alpha];"),n(a),[o,l]}));case yo:return a((function(t){return nt.command(dn(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),gt(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")})),gt(4,(function(t){return e.def("+",n,"[",t,"]")}))}));case Io:return a((function(t){return nt.commandType(t,"number",l,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 a((function(n){nt.commandType(n,"object",l,e.commandStr);var i=n.cmp||"keep",r=n.ref||0,o="mask"in n?n.mask:-1;return nt.commandParameter(i,ea,t+".cmp",e.commandStr),nt.commandType(r,"number",t+".ref",e.commandStr),nt.commandType(o,"number",t+".mask",e.commandStr),[ea[i],r,o]}),(function(t,e,n){var i=t.constants.compareFuncs;return nt.optional((function(){function r(){t.assert(e,Array.prototype.join.call(arguments,""),"invalid stencil.func")}r(n+"&&typeof ",n,'==="object"'),r('!("cmp" in ',n,")||(",n,".cmp in ",i,")")})),[e.def('"cmp" in ',n,"?",i,"[",n,".cmp]",":",Ql),e.def(n,".ref|0"),e.def('"mask" in ',n,"?",n,".mask|0:-1")]}));case Co:case Uo:return a((function(n){nt.commandType(n,"object",l,e.commandStr);var i=n.fail||"keep",r=n.zfail||"keep",o=n.zpass||"keep";return nt.commandParameter(i,na,t+".fail",e.commandStr),nt.commandParameter(r,na,t+".zfail",e.commandStr),nt.commandParameter(o,na,t+".zpass",e.commandStr),[t===Uo?Bl:Fl,na[i],na[r],na[o]]}),(function(e,n,i){var r=e.constants.stencilOps;function o(o){return nt.optional((function(){e.assert(n,'!("'+o+'" in '+i+")||("+i+"."+o+" in "+r+")","invalid "+t+"."+o+", must be one of "+Object.keys(na))})),n.def('"',o,'" in ',i,"?",r,"[",i,".",o,"]:",Ql)}return nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)})),[t===Uo?Bl:Fl,o("fail"),o("zfail"),o("zpass")]}));case Ko:return a((function(t){nt.commandType(t,"object",l,e.commandStr);var n=0|t.factor,i=0|t.units;return nt.commandType(n,"number",l+".factor",e.commandStr),nt.commandType(i,"number",l+".units",e.commandStr),[n,i]}),(function(e,n,i){return nt.optional((function(){e.assert(n,i+"&&typeof "+i+'==="object"',"invalid "+t)})),[n.def(i,".factor|0"),n.def(i,".units|0")]}));case go:return a((function(t){var n=0;return"front"===t?n=Fl:"back"===t&&(n=Bl),nt.command(!!n,l,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"?',Fl,":",Bl)}));case xo:return a((function(t){return nt.command("number"==typeof t&&t>=r.lineWidthDims[0]&&t<=r.lineWidthDims[1],"invalid line width, must be a positive number between "+r.lineWidthDims[0]+" and "+r.lineWidthDims[1],e.commandStr),t}),(function(t,e,n){return nt.optional((function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">="+r.lineWidthDims[0]+"&&"+n+"<="+r.lineWidthDims[1],"invalid line width")})),n}));case Lo:return a((function(t){return nt.commandParameter(t,ra,l,e.commandStr),ra[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"?'+kl+":"+Tl)}));case So:return a((function(t){return nt.command(dn(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")})),gt(4,(function(t){return"!!"+n+"["+t+"]"}))}));case wo:return a((function(t){nt.command("object"==typeof t&&t,l,e.commandStr);var n="value"in t?t.value:1,i=!!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,i]}),(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 B(t,e){var n=t.static,i=t.dynamic,r={};return Object.keys(n).forEach((function(t){var i,o=n[t];if("number"==typeof o||"boolean"==typeof o)i=ua((function(){return o}));else if("function"==typeof o){var l=o._reglType;"texture2d"===l||"textureCube"===l?i=ua((function(t){return t.link(o)})):"framebuffer"===l||"framebufferCube"===l?(nt.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',e.commandStr),i=ua((function(t){return t.link(o.color[0])}))):nt.commandRaise('invalid data for uniform "'+t+'"',e.commandStr)}else dn(o)?i=ua((function(e){return e.global.def("[",gt(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);i.value=o,r[t]=i})),Object.keys(i).forEach((function(t){var e=i[t];r[t]=ca(e,(function(t,n){return t.invoke(n,e)}))})),r}function k(t,e){var i=t.static,r=t.dynamic,l={};return Object.keys(i).forEach((function(t){var r=i[t],a=n.id(t),s=new f;if(oa(r))s.state=oo,s.buffer=o.getBuffer(o.create(r,sl,!1,!0)),s.type=0;else{var u=o.getBuffer(r);if(u)s.state=oo,s.buffer=u,s.type=0;else if(nt.command("object"==typeof r&&r,"invalid data for attribute "+t,e.commandStr),"constant"in r){var c=r.constant;s.buffer="null",s.state=lo,"number"==typeof c?s.x=c:(nt.command(dn(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+t,e.commandStr),io.forEach((function(t,e){e=0,'invalid offset for attribute "'+t+'"',e.commandStr);var h=0|r.stride;nt.command(h>=0&&h<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',e.commandStr);var b=0|r.size;nt.command(!("size"in r)||b>0&&b<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',e.commandStr);var p=!!r.normalized,m=0;"type"in r&&(nt.commandParameter(r.type,we,"invalid type for attribute "+t,e.commandStr),m=we[r.type]);var y=0|r.divisor;nt.optional((function(){"divisor"in r&&(nt.command(0===y||Z,'cannot specify divisor for attribute "'+t+'", instancing not supported',e.commandStr),nt.command(y>=0,'invalid divisor for attribute "'+t+'"',e.commandStr));var n=e.commandStr,i=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(r).forEach((function(e){nt.command(i.indexOf(e)>=0,'unknown parameter "'+e+'" for attribute pointer "'+t+'" (valid parameters are '+i+")",n)}))})),s.buffer=u,s.state=oo,s.size=b,s.normalized=p,s.type=m||u.dtype,s.offset=d,s.stride=h,s.divisor=y}}l[t]=ua((function(t,e){var n=t.attribCache;if(a in n)return n[a];var i={isStream:!1};return Object.keys(s).forEach((function(t){i[t]=s[t]})),s.buffer&&(i.buffer=t.link(s.buffer),i.type=i.type||i.buffer+".dtype"),n[a]=i,i}))})),Object.keys(r).forEach((function(t){var e=r[t];function n(n,i){var r=n.invoke(i,e),o=n.shared,l=n.constants,a=o.isBufferArgs,s=o.buffer;nt.optional((function(){n.assert(i,r+"&&(typeof "+r+'==="object"||typeof '+r+'==="function")&&('+a+"("+r+")||"+s+".getBuffer("+r+")||"+s+".getBuffer("+r+".buffer)||"+a+"("+r+'.buffer)||("constant" in '+r+"&&(typeof "+r+'.constant==="number"||'+o.isArrayLike+"("+r+".constant))))",'invalid dynamic attribute "'+t+'"')}));var u={isStream:i.def(!1)},c=new f;c.state=oo,Object.keys(c).forEach((function(t){u[t]=i.def(""+c[t])}));var d=u.buffer,h=u.type;function b(t){i(u[t],"=",r,".",t,"|0;")}return i("if(",a,"(",r,")){",u.isStream,"=true;",d,"=",s,".createStream(",sl,",",r,");",h,"=",d,".dtype;","}else{",d,"=",s,".getBuffer(",r,");","if(",d,"){",h,"=",d,".dtype;",'}else if("constant" in ',r,"){",u.state,"=",lo,";","if(typeof "+r+'.constant === "number"){',u[io[0]],"=",r,".constant;",io.slice(1).map((function(t){return u[t]})).join("="),"=0;","}else{",io.map((function(t,e){return u[t]+"="+r+".constant.length>"+e+"?"+r+".constant["+e+"]:0;"})).join(""),"}}else{","if(",a,"(",r,".buffer)){",d,"=",s,".createStream(",sl,",",r,".buffer);","}else{",d,"=",s,".getBuffer(",r,".buffer);","}",h,'="type" in ',r,"?",l.glTypes,"[",r,".type]:",d,".dtype;",u.normalized,"=!!",r,".normalized;"),b("size"),b("offset"),b("stride"),b("divisor"),i("}}"),i.exit("if(",u.isStream,"){",s,".destroyStream(",d,");","}"),u}l[t]=ca(e,n)})),l}function T(t){var e=t.static,n=t.dynamic,i={};return Object.keys(e).forEach((function(t){var n=e[t];i[t]=ua((function(t,e){return"number"==typeof n||"boolean"==typeof n?""+n:t.link(n)}))})),Object.keys(n).forEach((function(t){var e=n[t];i[t]=ca(e,(function(t,n){return t.invoke(n,e)}))})),i}function z(t,e,n,r,o){var l=t.static,a=t.dynamic;nt.optional((function(){var t=[zo,Mo,jo,Qo,Po,Do,Eo,Oo,To,Ao].concat(v);function e(e){Object.keys(e).forEach((function(e){nt.command(t.indexOf(e)>=0,'unknown parameter "'+e+'"',o.commandStr)}))}e(l),e(a)}));var s=N(t,e),u=_(t),d=I(t,u,o),h=U(t,o),b=F(t,o),p=C(t,o,s);function m(t){var e=d[t];e&&(b[t]=e)}m(ko),m(g(Bo));var f=Object.keys(b).length>0,y={framebuffer:u,draw:h,shader:p,state:b,dirty:f,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(y.profile=w(t),y.uniforms=B(n,o),y.drawVAO=y.scopeVAO=h.vao,!y.drawVAO&&p.program&&!s&&i.angle_instanced_arrays&&h.static.elements){var Z=!0,X=p.program.attributes.map((function(t){var n=e.static[t];return Z=Z&&!!n,n}));if(Z&&X.length>0){var G=c.getVAO(c.createVAO({attributes:X,elements:h.static.elements}));y.drawVAO=new aa(null,null,null,(function(t,e){return t.link(G)})),y.useVAO=!0}}return s?y.useVAO=!0:y.attributes=k(e,o),y.context=T(r),y}function M(t,e,n){var i=t.shared.context,r=t.scope();Object.keys(n).forEach((function(o){e.save(i,"."+o);var l=n[o].append(t,e);Array.isArray(l)?r(i,".",o,"=[",l.join(),"];"):r(i,".",o,"=",l,";")})),e(r)}function j(t,e,n,i){var r,o=t.shared,l=o.gl,a=o.framebuffer;X&&(r=e.def(o.extensions,".webgl_draw_buffers"));var s,u=t.constants,c=u.drawBuffer,d=u.backBuffer;s=n?n.append(t,e):e.def(a,".next"),i||e("if(",s,"!==",a,".cur){"),e("if(",s,"){",l,".bindFramebuffer(",Al,",",s,".framebuffer);"),X&&e(r,".drawBuffersWEBGL(",c,"[",s,".colorAttachments.length]);"),e("}else{",l,".bindFramebuffer(",Al,",null);"),X&&e(r,".drawBuffersWEBGL(",d,");"),e("}",a,".cur=",s,";"),i||e("}")}function Q(t,e,n){var i=t.shared,r=i.gl,o=t.current,l=t.next,a=i.current,s=i.next,u=t.cond(a,".dirty");v.forEach((function(e){var i,c,d=g(e);if(!(d in n.state))if(d in l){i=l[d],c=o[d];var h=gt(W[d].length,(function(t){return u.def(i,"[",t,"]")}));u(t.cond(h.map((function(t,e){return t+"!=="+c+"["+e+"]"})).join("||")).then(r,".",R[d],"(",h,");",h.map((function(t,e){return c+"["+e+"]="+t})).join(";"),";"))}else{i=u.def(s,".",d);var b=t.cond(i,"!==",a,".",d);u(b),d in S?b(t.cond(i).then(r,".enable(",S[d],");").else(r,".disable(",S[d],");"),a,".",d,"=",i,";"):b(r,".",R[d],"(",i,");",a,".",d,"=",i,";")}})),0===Object.keys(n.state).length&&u(a,".dirty=false;"),e(u)}function P(t,e,n,i){var r=t.shared,o=t.current,l=r.current,a=r.gl;la(Object.keys(n)).forEach((function(r){var s=n[r];if(!i||i(s)){var u=s.append(t,e);if(S[r]){var c=S[r];sa(s)?e(a,u?".enable(":".disable(",c,");"):e(t.cond(u).then(a,".enable(",c,");").else(a,".disable(",c,");")),e(l,".",r,"=",u,";")}else if(dn(u)){var d=o[r];e(a,".",R[r],"(",u,");",u.map((function(t,e){return d+"["+e+"]="+t})).join(";"),";")}else e(a,".",R[r],"(",u,");",l,".",r,"=",u,";")}}))}function E(t,e){Z&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function D(t,e,n,i,r){var o,l,a,s=t.shared,u=t.stats,c=s.current,d=s.timer,h=n.profile;function b(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(t){t(o=e.def(),"=",b(),";"),"string"==typeof r?t(u,".count+=",r,";"):t(u,".count++;"),p&&(i?t(l=e.def(),"=",d,".getNumPendingQueries();"):t(d,".beginQuery(",u,");"))}function f(t){t(u,".cpuTime+=",b(),"-",o,";"),p&&(i?t(d,".pushScopeStats(",l,",",d,".getNumPendingQueries(),",u,");"):t(d,".endQuery();"))}function y(t){var n=e.def(c,".profile");e(c,".profile=",t,";"),e.exit(c,".profile=",n,";")}if(h){if(sa(h))return void(h.enable?(m(e),f(e.exit),y("true")):y("false"));y(a=h.append(t,e))}else a=e.def(c,".profile");var Z=t.block();m(Z),e("if(",a,"){",Z,"}");var X=t.block();f(X),e.exit("if(",a,"){",X,"}")}function O(t,e,n,i,r){var o=t.shared;function l(t){switch(t){case Vl:case gl:case Kl:return 2;case vl:case Ll:case Hl:return 3;case Sl:case xl:case Jl:return 4;default:return 1}}function a(n,i,r){var l=o.gl,a=e.def(n,".location"),s=e.def(o.attributes,"[",a,"]"),u=r.state,c=r.buffer,d=[r.x,r.y,r.z,r.w],h=["buffer","normalized","offset","stride"];function b(){e("if(!",s,".buffer){",l,".enableVertexAttribArray(",a,");}");var n,o=r.type;if(n=r.size?e.def(r.size,"||",i):i,e("if(",s,".type!==",o,"||",s,".size!==",n,"||",h.map((function(t){return s+"."+t+"!=="+r[t]})).join("||"),"){",l,".bindBuffer(",sl,",",c,".buffer);",l,".vertexAttribPointer(",[a,n,o,r.normalized,r.stride,r.offset],");",s,".type=",o,";",s,".size=",n,";",h.map((function(t){return s+"."+t+"="+r[t]+";"})).join(""),"}"),Z){var u=r.divisor;e("if(",s,".divisor!==",u,"){",t.instancing,".vertexAttribDivisorANGLE(",[a,u],");",s,".divisor=",u,";}")}}function p(){e("if(",s,".buffer){",l,".disableVertexAttribArray(",a,");",s,".buffer=null;","}if(",io.map((function(t,e){return s+"."+t+"!=="+d[e]})).join("||"),"){",l,".vertexAttrib4f(",a,",",d,");",io.map((function(t,e){return s+"."+t+"="+d[e]+";"})).join(""),"}")}u===oo?b():u===lo?p():(e("if(",u,"===",oo,"){"),b(),e("}else{"),p(),e("}"))}i.forEach((function(i){var o,s=i.name,u=n.attributes[s];if(u){if(!r(u))return;o=u.append(t,e)}else{if(!r(da))return;var c=t.scopeAttrib(s);nt.optional((function(){t.assert(e,c+".state","missing attribute "+s)})),o={},Object.keys(new f).forEach((function(t){o[t]=e.def(c,".",t)}))}a(t.link(i),l(i.info.type),o)}))}function A(t,e,i,r,o,l){for(var a,s=t.shared,u=s.gl,c={},d=0;d1){if(!f)continue;var y=b.replace("[0]","");if(c[y])continue;c[y]=1}var Z,X=t.link(h)+".location";if(f){if(!o(f))continue;if(sa(f)){var G=f.value;if(nt.command(null!=G,'missing uniform "'+b+'"',t.commandStr),p===Nl||p===Cl){nt.command("function"==typeof G&&(p===Nl&&("texture2d"===G._reglType||"framebuffer"===G._reglType)||p===Cl&&("textureCube"===G._reglType||"framebufferCube"===G._reglType)),"invalid texture for uniform "+b,t.commandStr);var W=t.link(G._texture||G.color[0]._texture);e(u,".uniform1i(",X,",",W+".bind());"),e.exit(W,".unbind();")}else if(p===wl||p===_l||p===Il){nt.optional((function(){nt.command(dn(G),"invalid matrix for uniform "+b,t.commandStr),nt.command(p===wl&&4===G.length||p===_l&&9===G.length||p===Il&&16===G.length,"invalid length for matrix uniform "+b,t.commandStr)}));var V=t.global.def("new Float32Array(["+Array.prototype.slice.call(G)+"])"),v=2;p===_l?v=3:p===Il&&(v=4),e(u,".uniformMatrix",v,"fv(",X,",false,",V,");")}else{switch(p){case Wl:1===m?nt.commandType(G,"number","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1f";break;case Vl:nt.command(dn(G)&&G.length&&G.length%2==0&&G.length<=2*m,"uniform "+b,t.commandStr),a="2f";break;case vl:nt.command(dn(G)&&G.length&&G.length%3==0&&G.length<=3*m,"uniform "+b,t.commandStr),a="3f";break;case Sl:nt.command(dn(G)&&G.length&&G.length%4==0&&G.length<=4*m,"uniform "+b,t.commandStr),a="4f";break;case Yl:1===m?nt.commandType(G,"boolean","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1i";break;case Rl:1===m?nt.commandType(G,"number","uniform "+b,t.commandStr):nt.command(dn(G)&&G.length===m,"uniform "+b,t.commandStr),a="1i";break;case Kl:case gl:nt.command(dn(G)&&G.length&&G.length%2==0&&G.length<=2*m,"uniform "+b,t.commandStr),a="2i";break;case Hl:case Ll:nt.command(dn(G)&&G.length&&G.length%3==0&&G.length<=3*m,"uniform "+b,t.commandStr),a="3i";break;case Jl:case xl:nt.command(dn(G)&&G.length&&G.length%4==0&&G.length<=4*m,"uniform "+b,t.commandStr),a="4i"}m>1?(a+="v",G=t.global.def("["+Array.prototype.slice.call(G)+"]")):G=dn(G)?Array.prototype.slice.call(G):G,e(u,".uniform",a,"(",X,",",G,");")}continue}Z=f.append(t,e)}else{if(!o(da))continue;Z=e.def(s.uniforms,"[",n.id(b),"]")}p===Nl?(nt(!Array.isArray(Z),"must specify a scalar prop for textures"),e("if(",Z,"&&",Z,'._reglType==="framebuffer"){',Z,"=",Z,".color[0];","}")):p===Cl&&(nt(!Array.isArray(Z),"must specify a scalar prop for cube maps"),e("if(",Z,"&&",Z,'._reglType==="framebufferCube"){',Z,"=",Z,".color[0];","}")),nt.optional((function(){function n(n,i){t.assert(e,n,'bad data or missing for uniform "'+b+'". '+i)}function i(t,e){1===e&&nt(!Array.isArray(Z),"must not specify an array type for uniform"),n("Array.isArray("+Z+") && typeof "+Z+'[0]===" '+t+'" || typeof '+Z+'==="'+t+'"',"invalid type, expected "+t)}function r(e,i,r){Array.isArray(Z)?nt(Z.length&&Z.length%e==0&&Z.length<=e*r,"must have length of "+(1===r?"":"n * ")+e):n(s.isArrayLike+"("+Z+")&&"+Z+".length && "+Z+".length % "+e+" === 0 && "+Z+".length<="+e*r,"invalid vector, should have length of "+(1===r?"":"n * ")+e,t.commandStr)}function o(e){nt(!Array.isArray(Z),"must not specify a value type"),n("typeof "+Z+'==="function"&&'+Z+'._reglType==="texture'+(e===cl?"2d":"Cube")+'"',"invalid texture type",t.commandStr)}switch(p){case Rl:i("number",m);break;case gl:r(2,"number",m);break;case Ll:r(3,"number",m);break;case xl:r(4,"number",m);break;case Wl:i("number",m);break;case Vl:r(2,"number",m);break;case vl:r(3,"number",m);break;case Sl:r(4,"number",m);break;case Yl:i("boolean",m);break;case Kl:r(2,"boolean",m);break;case Hl:r(3,"boolean",m);break;case Jl:r(4,"boolean",m);break;case wl:r(4,"number",m);break;case _l:r(9,"number",m);break;case Il:r(16,"number",m);break;case Nl:o(cl);break;case Cl:o(dl)}}));var S=1;switch(p){case Nl:case Cl:var R=e.def(Z,"._texture");e(u,".uniform1i(",X,",",R,".bind());"),e.exit(R,".unbind();");continue;case Rl:case Yl:a="1i";break;case gl:case Kl:a="2i",S=2;break;case Ll:case Hl:a="3i",S=3;break;case xl:case Jl:a="4i",S=4;break;case Wl:a="1f";break;case Vl:a="2f",S=2;break;case vl:a="3f",S=3;break;case Sl:a="4f",S=4;break;case wl:a="Matrix2fv";break;case _l:a="Matrix3fv";break;case Il:a="Matrix4fv"}if(-1===a.indexOf("Matrix")&&m>1&&(a+="v",S=1),"M"===a.charAt(0)){e(u,".uniform",a,"(",X,",");var g=Math.pow(p-wl+2,2),L=t.global.def("new Float32Array(",g,")");Array.isArray(Z)?e("false,(",gt(g,(function(t){return L+"["+t+"]="+Z[t]})),",",L,")"):e("false,(Array.isArray(",Z,")||",Z," instanceof Float32Array)?",Z,":(",gt(g,(function(t){return L+"["+t+"]="+Z+"["+t+"]"})),",",L,")"),e(");")}else if(S>1){for(var x=[],Y=[],K=0;K=0","missing vertex count")}))):(r=s.def(l,".",Eo),nt.optional((function(){t.assert(s,r+">=0","missing vertex count")}))),r}var c=s();function d(r){var o=a[r];return o?o.contextDep&&i.contextDynamic||o.propDep?o.append(t,n):o.append(t,e):e.def(l,".",r)}var h,b,p=d(Po),m=d(Do),f=u();if("number"==typeof f){if(0===f)return}else n("if(",f,"){"),n.exit("}");Z&&(h=d(Oo),b=t.instancing);var y=c+".type",X=a.elements&&sa(a.elements)&&!a.vaoActive;function W(){function t(){n(b,".drawElementsInstancedANGLE(",[p,f,y,m+"<<(("+y+"-"+ro+")>>1)",h],");")}function e(){n(b,".drawArraysInstancedANGLE(",[p,m,f,h],");")}c&&"null"!==c?X?t():(n("if(",c,"){"),t(),n("}else{"),e(),n("}")):e()}function V(){function t(){n(o+".drawElements("+[p,f,y,m+"<<(("+y+"-"+ro+")>>1)"]+");")}function e(){n(o+".drawArrays("+[p,m,f]+");")}c&&"null"!==c?X?t():(n("if(",c,"){"),t(),n("}else{"),e(),n("}")):e()}Z&&("number"!=typeof h||h>=0)?"string"==typeof h?(n("if(",h,">0){"),W(),n("}else if(",h,"<0){"),V(),n("}")):W():V()}function $(t,e,n,i,r){var o=J(),l=o.proc("body",r);return nt.optional((function(){o.commandStr=e.commandStr,o.command=o.link(e.commandStr)})),Z&&(o.instancing=l.def(o.shared.extensions,".angle_instanced_arrays")),t(o,l,n,i),o.compile().body}function tt(t,e,n,i){E(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);"),O(t,e,n,i.attributes,(function(){return!0}))),A(t,e,n,i.uniforms,(function(){return!0}),!1),q(t,e,e,n)}function et(t,e){var n=t.proc("draw",1);E(t,n),M(t,n,e.context),j(t,n,e.framebuffer),Q(t,n,e),P(t,n,e.state),D(t,n,e,!1,!0);var i=e.shader.progVar.append(t,n);if(n(t.shared.gl,".useProgram(",i,".program);"),e.shader.program)tt(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var r=t.global.def("{}"),o=n.def(i,".id"),l=n.def(r,"[",o,"]");n(t.cond(l).then(l,".call(this,a0);").else(l,"=",r,"[",o,"]=",t.link((function(n){return $(tt,t,e,n,1)})),"(",i,");",l,".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 it(t,e,n,i){function r(){return!0}t.batchId="a1",E(t,e),O(t,e,n,i.attributes,r),A(t,e,n,i.uniforms,r,!1),q(t,e,e,n)}function rt(t,e,n,i){E(t,e);var r=n.contextDep,o=e.def(),l="a0",a="a1",s=e.def();t.shared.props=s,t.batchId=o;var u=t.scope(),c=t.scope();function d(t){return t.contextDep&&r||t.propDep}function h(t){return!d(t)}if(e(u.entry,"for(",o,"=0;",o,"<",a,";++",o,"){",s,"=",l,"[",o,"];",c,"}",u.exit),n.needsContext&&M(t,c,n.context),n.needsFramebuffer&&j(t,c,n.framebuffer),P(t,c,n.state,d),n.profile&&d(n.profile)&&D(t,c,n,!1,!0),i)n.useVAO?n.drawVAO?d(n.drawVAO)?c(t.shared.vao,".setVAO(",n.drawVAO.append(t,c),");"):u(t.shared.vao,".setVAO(",n.drawVAO.append(t,u),");"):u(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(u(t.shared.vao,".setVAO(null);"),O(t,u,n,i.attributes,h),O(t,c,n,i.attributes,d)),A(t,u,n,i.uniforms,h,!1),A(t,c,n,i.uniforms,d,!0),q(t,u,c,n);else{var b=t.global.def("{}"),p=n.shader.progVar.append(t,c),m=c.def(p,".id"),f=c.def(b,"[",m,"]");c(t.shared.gl,".useProgram(",p,".program);","if(!",f,"){",f,"=",b,"[",m,"]=",t.link((function(e){return $(it,t,n,e,2)})),"(",p,");}",f,".call(this,a0[",o,"],",o,");")}}function ot(t,e){var n=t.proc("batch",2);t.batchId="0",E(t,n);var i=!1,r=!0;Object.keys(e.context).forEach((function(t){i=i||e.context[t].propDep})),i||(M(t,n,e.context),r=!1);var o=e.framebuffer,l=!1;function a(t){return t.contextDep&&i||t.propDep}o?(o.propDep?i=l=!0:o.contextDep&&i&&(l=!0),l||j(t,n,o)):j(t,n,null),e.state.viewport&&e.state.viewport.propDep&&(i=!0),Q(t,n,e),P(t,n,e.state,(function(t){return!a(t)})),e.profile&&a(e.profile)||D(t,n,e,!1,"a1"),e.contextDep=i,e.needsContext=r,e.needsFramebuffer=l;var s=e.shader.progVar;if(s.contextDep&&i||s.propDep)rt(t,n,e,null);else{var u=s.append(t,n);if(n(t.shared.gl,".useProgram(",u,".program);"),e.shader.program)rt(t,n,e,e.shader.program);else{n(t.shared.vao,".setVAO(null);");var c=t.global.def("{}"),d=n.def(u,".id"),h=n.def(c,"[",d,"]");n(t.cond(h).then(h,".call(this,a0,a1);").else(h,"=",c,"[",d,"]=",t.link((function(n){return $(rt,t,e,n,2)})),"(",u,");",h,".call(this,a0,a1);"))}}Object.keys(e.state).length>0&&n(t.shared.current,".dirty=true;"),t.shared.vao&&n(t.shared.vao,".setVAO(null);")}function lt(t,e){var i=t.proc("scope",3);t.batchId="a2";var r=t.shared,o=r.current;function l(n){var o=e.shader[n];o&&i.set(r.shader,"."+n,o.append(t,i))}M(t,i,e.context),e.framebuffer&&e.framebuffer.append(t,i),la(Object.keys(e.state)).forEach((function(n){var o=e.state[n].append(t,i);dn(o)?o.forEach((function(e,r){i.set(t.next[n],"["+r+"]",e)})):i.set(r.next,"."+n,o)})),D(t,i,e,!0,!0),[Qo,Do,Eo,Oo,Po].forEach((function(n){var o=e.draw[n];o&&i.set(r.draw,"."+n,""+o.append(t,i))})),Object.keys(e.uniforms).forEach((function(o){var l=e.uniforms[o].append(t,i);Array.isArray(l)&&(l="["+l.join()+"]"),i.set(r.uniforms,"["+n.id(o)+"]",l)})),Object.keys(e.attributes).forEach((function(n){var r=e.attributes[n].append(t,i),o=t.scopeAttrib(n);Object.keys(new f).forEach((function(t){i.set(o,"."+t,r[t])}))})),e.scopeVAO&&i.set(r.vao,".targetVAO",e.scopeVAO.append(t,i)),l(Mo),l(jo),Object.keys(e.state).length>0&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",t.shared.context,",a0,",t.batchId,");")}function at(t){if("object"==typeof t&&!dn(t)){for(var e=Object.keys(t),n=0;n=0;--t){var e=K[t];e&&e(p,null,0)}i.flush(),c&&c.update()}function N(){!_&&K.length>0&&(_=mt.next(I))}function C(){_&&(mt.cancel(I),_=null)}function U(t){t.preventDefault(),o=!0,C(),H.forEach((function(t){t()}))}function F(t){i.getError(),o=!1,l.restore(),V.restore(),Z.restore(),v.restore(),S.restore(),R.restore(),G.restore(),c&&c.restore(),g.procs.refresh(),N(),J.forEach((function(t){t()}))}function B(){K.length=0,C(),Y&&(Y.removeEventListener(Va,U),Y.removeEventListener(va,F)),V.clear(),R.clear(),S.clear(),G.clear(),v.clear(),X.clear(),Z.clear(),c&&c.clear(),w.forEach((function(t){t()}))}function k(t){function n(t){var n=e({},t);function i(t){if(t in n){var e=n[t];delete n[t],Object.keys(e).forEach((function(i){n[t+"."+i]=e[i]}))}}return delete n.uniforms,delete n.attributes,delete n.context,delete n.vao,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),i("blend"),i("depth"),i("cull"),i("stencil"),i("polygonOffset"),i("scissor"),i("sample"),"vao"in t&&(n.vao=t.vao),n}function i(t,e){var n={},i={};return Object.keys(t).forEach((function(r){var o=t[r];if(pt.isDynamic(o))i[r]=pt.unbox(o,r);else{if(e&&Array.isArray(o))for(var l=0;l0)return h.call(this,m(0|t),0|t)}else{if(!Array.isArray(t))return d.call(this,t);if(t.length)return h.call(this,t,t.length)}}return e(f,{stats:u,destroy:function(){c.destroy()}})}Y&&(Y.addEventListener(Va,U,!1),Y.addEventListener(va,F,!1));var T=R.setFBO=k({framebuffer:pt.define.call(null,Sa,"framebuffer")});function z(t,e){var n=0;g.procs.poll();var r=e.color;r&&(i.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=Za),"depth"in e&&(i.clearDepth(+e.depth),n|=Xa),"stencil"in e&&(i.clearStencil(0|e.stencil),n|=Ga),nt(!!n,"called regl.clear with no buffer specified"),i.clear(n)}function M(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)T(e({framebuffer:t.framebuffer.faces[n]},t),z);else T(t,z);else z(null,t)}function j(t){function e(){var e=La(K,t);function n(){var t=La(K,n);K[t]=K[K.length-1],K.length-=1,K.length<=0&&C()}nt(e>=0,"cannot cancel a frame twice"),K[e]=n}return nt.type(t,"function","regl.frame() callback must be a function"),K.push(t),N(),{cancel:e}}function Q(){var t=x.viewport,e=x.scissor_box;t[0]=t[1]=e[0]=e[1]=0,p.viewportWidth=p.framebufferWidth=p.drawingBufferWidth=t[2]=e[2]=i.drawingBufferWidth,p.viewportHeight=p.framebufferHeight=p.drawingBufferHeight=t[3]=e[3]=i.drawingBufferHeight}function P(){p.tick+=1,p.time=D(),Q(),g.procs.poll()}function E(){v.refresh(),Q(),g.procs.refresh(),c&&c.update()}function D(){return(ft()-d)/1e3}function O(t,e){var n;switch(nt.type(e,"function","listener callback must be a function"),t){case"frame":return j(e);case"lost":n=H;break;case"restore":n=J;break;case"destroy":n=w;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:L,destroy:B,_gl:i,_refresh:E,poll:function(){P(),c&&c.update()},now:D,stats:s});return n.onDone(null,A),A}return xa}();var Rb=Sb.exports;var gb=Math.sqrt(50),Lb=Math.sqrt(10),xb=Math.sqrt(2);function Yb(t,e,n){var i,r,o,l,a=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((i=e=0?(o>=gb?10:o>=Lb?5:o>=xb?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=gb?10:o>=Lb?5:o>=xb?2:1)}(t,e,n))||!isFinite(l))return[];if(l>0){let n=Math.round(t/l),i=Math.round(e/l);for(n*le&&--i,o=new Array(r=i-n+1);++ae&&--i,o=new Array(r=i-n+1);++a=i&&++n;else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(r=+r)>=r&&++n}return n}(t))/Math.LN2)+1}var Hb=Array.prototype.slice;function Jb(t,e){return t-e}var wb=t=>()=>t;function _b(t,e){for(var n,i=-1,r=e.length;++ii!=b>i&&n<(h-u)*(i-c)/(b-c)+u&&(r=-r)}return r}function Nb(t,e,n){var i,r,o,l;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)&&(r=t[i=+(t[0]===e[0])],o=n[i],l=e[i],r<=o&&o<=l||l<=o&&o<=r)}function Cb(){}var Ub=[[],[[[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 Fb(){var t=1,e=1,n=Kb,i=a;function r(t){var e,i,r,l,a,s,u=n(t);if(Array.isArray(u))u=u.slice().sort(Jb);else{const n=function(t,e){let n,i;if(void 0===e)for(const r of t)null!=r&&(void 0===n?r>=r&&(n=i=r):(n>r&&(n=r),i=o&&(n=i=o):(n>o&&(n=o),i=gb?a*=10:s>=Lb?a*=5:s>=xb&&(a*=2),io(t,e)))}function o(n,r){var o=[],a=[];return function(n,i,r){var o,a,s,u,c,d,h=new Array,b=new Array;o=a=-1,u=n[0]>=i,Ub[u<<1].forEach(p);for(;++o=i,Ub[s|u<<1].forEach(p);Ub[u<<0].forEach(p);for(;++a=i,c=n[a*t]>=i,Ub[u<<1|c<<2].forEach(p);++o=i,d=c,c=n[a*t+o+1]>=i,Ub[s|u<<1|c<<2|d<<3].forEach(p);Ub[u|c<<3].forEach(p)}o=-1,c=n[a*t]>=i,Ub[c<<2].forEach(p);for(;++o=i,Ub[c<<2|d<<3].forEach(p);function p(t){var e,n,i=[t[0][0]+o,t[0][1]+a],s=[t[1][0]+o,t[1][1]+a],u=l(i),c=l(s);(e=b[u])?(n=h[c])?(delete b[e.end],delete h[n.start],e===n?(e.ring.push(s),r(e.ring)):h[e.start]=b[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete b[e.end],e.ring.push(s),b[e.end=c]=e):(e=h[c])?(n=b[u])?(delete h[e.start],delete b[n.end],e===n?(e.ring.push(s),r(e.ring)):h[n.start]=b[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete h[e.start],e.ring.unshift(i),h[e.start=u]=e):h[u]=b[c]={start:u,end:c,ring:[i,s]}}Ub[c<<3].forEach(p)}(n,r,(function(t){i(t,n,r),function(t){for(var e=0,n=t.length,i=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e0?o.push([t]):a.push(t)})),a.forEach((function(t){for(var e,n=0,i=o.length;n0&&l0&&a=0&&o>=0))throw new Error("invalid size");return t=i,e=o,r},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?wb(Hb.call(t)):wb(t),r):n},r.smooth=function(t){return arguments.length?(i=t?a:Cb,r):i===a},r}var Bb=function(t,e,n,i){return kb[0]=i,kb[1]=n,kb[2]=e,kb[3]=t,Tb[0]},kb=new Uint8Array(4),Tb=new Float32Array(kb.buffer);function zb(t){for(var e=t.length/6|0,n=new Array(e),i=0;iyd(t[t.length-1]),ep=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(zb),np=tp(ep),ip=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(zb),rp=tp(ip),op=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(zb),lp=tp(op),ap=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(zb),sp=tp(ap),up=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(zb),cp=tp(up),dp=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(zb),hp=tp(dp),bp=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(zb),pp=tp(bp),mp=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(zb),fp=tp(mp),yp=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(zb),Zp=tp(yp),Xp=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(zb),Gp=tp(Xp),Wp=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(zb),Vp=tp(Wp),vp=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(zb),Sp=tp(vp),Rp=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(zb),gp=tp(Rp),Lp=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(zb),xp=tp(Lp),Yp=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(zb),Kp=tp(Yp),Hp=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(zb),Jp=tp(Hp),wp=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(zb),_p=tp(wp),Ip=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(zb),Np=tp(Ip),Cp=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(zb),Up=tp(Cp),Fp=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(zb),Bp=tp(Fp),kp=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(zb),Tp=tp(kp),zp=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(zb),Mp=tp(zp),jp=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(zb),Qp=tp(jp),Pp=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(zb),Ep=tp(Pp),Dp=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(zb),Op=tp(Dp),Ap=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(zb),qp=tp(Ap),$p=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(zb),tm=tp($p);var em=Nd(ud(300,.5,0),ud(-240,.5,1)),nm=Nd(ud(-100,.75,.35),ud(80,1.5,.8)),im=Nd(ud(260,.75,.35),ud(80,1.5,.8)),rm=ud();var om=zc(),lm=Math.PI/3,am=2*Math.PI/3;function sm(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var um=sm(zb("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),cm=sm(zb("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),dm=sm(zb("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),hm=sm(zb("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")),bm=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",schemeCategory10:Mb,schemeAccent:jb,schemeDark2:Qb,schemePaired:Pb,schemePastel1:Eb,schemePastel2:Db,schemeSet1:Ob,schemeSet2:Ab,schemeSet3:qb,schemeTableau10:$b,interpolateBrBG:np,schemeBrBG:ep,interpolatePRGn:rp,schemePRGn:ip,interpolatePiYG:lp,schemePiYG:op,interpolatePuOr:sp,schemePuOr:ap,interpolateRdBu:cp,schemeRdBu:up,interpolateRdGy:hp,schemeRdGy:dp,interpolateRdYlBu:pp,schemeRdYlBu:bp,interpolateRdYlGn:fp,schemeRdYlGn:mp,interpolateSpectral:Zp,schemeSpectral:yp,interpolateBuGn:Gp,schemeBuGn:Xp,interpolateBuPu:Vp,schemeBuPu:Wp,interpolateGnBu:Sp,schemeGnBu:vp,interpolateOrRd:gp,schemeOrRd:Rp,interpolatePuBuGn:xp,schemePuBuGn:Lp,interpolatePuBu:Kp,schemePuBu:Yp,interpolatePuRd:Jp,schemePuRd:Hp,interpolateRdPu:_p,schemeRdPu:wp,interpolateYlGnBu:Np,schemeYlGnBu:Ip,interpolateYlGn:Up,schemeYlGn:Cp,interpolateYlOrBr:Bp,schemeYlOrBr:Fp,interpolateYlOrRd:Tp,schemeYlOrRd:kp,interpolateBlues:Mp,schemeBlues:zp,interpolateGreens:Qp,schemeGreens:jp,interpolateGreys:Ep,schemeGreys:Pp,interpolatePurples:Op,schemePurples:Dp,interpolateReds:qp,schemeReds:Ap,interpolateOranges:tm,schemeOranges:$p,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:em,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return rm.h=360*t-100,rm.s=1.5-1.5*e,rm.l=.8-.9*e,rm+""},interpolateWarm:nm,interpolateCool:im,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,om.r=255*(e=Math.sin(t))*e,om.g=255*(e=Math.sin(t+lm))*e,om.b=255*(e=Math.sin(t+am))*e,om+""},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:um,interpolateMagma:cm,interpolateInferno:dm,interpolatePlasma:hm});function pm(t,e){t=t.flat();const[n,i]=Me(t);null==e&&(e=new Uint32Array(t.length));const r=2**32/(i-n);let o=0;for(let l of t)e[o]=(l-n)*r,o+=1;return console.log(Ae(t),i,n,(t[100]-n)*r),{extent:[n,i],array:new Uint8Array(e.buffer)}}const mm={sqrt:function(){return Gb.apply(null,arguments).exponent(.5)},log:function t(){var e=mb(zh()).domain([1,10]);return e.copy=function(){return Th(e,t()).base(e.base())},Ih.apply(e,arguments),e},linear:sb,literal:function t(e){var n;function i(t){return null==t||isNaN(t=+t)?n:t}return i.invert=i,i.domain=i.range=function(t){return arguments.length?(e=Array.from(t,Nh),i):e.slice()},i.unknown=function(t){return arguments.length?(n=t,i):n},i.copy=function(){return t(e).unknown(n)},e=arguments.length?Array.from(e,Nh):[0,1],ab(i)}},fm=4095;function ym(t){const e=new Uint8Array(16380);return e.set(t.flat()),e}function Zm(t){return ym(Ee(fm).map((e=>{const n=zc(t(e/fm));return[n.r,n.g,n.b,255]})))}const Xm={white:Ee(fm).map((t=>[255,255,255,255]))};for(const[TR,zR]of Object.entries(bm)){if(TR.startsWith("scheme")&&"string"==typeof zR[0]){const t=new Array(fm),e=zR.map((t=>{const e=zc(t);return[e.r,e.g,e.b,255]}));for(const i of Ee(fm))t[i]=e[i%zR.length];const n=TR.replace("scheme","").toLowerCase();Xm[n]=ym(t)}if(TR.startsWith("interpolate")){const t=TR.replace("interpolate","").toLowerCase();Xm[t]=Zm(zR),"rainbow"==t&&(Xm.shufbow=Oe(Xm[t]))}}const Gm={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:Xm.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 Wm{constructor(t,e,n,i){this.label=t,this.scatterplot=e,this.regl=n,this._domain=this.default_domain,this._range=this.default_range,this._transform=Gm[t].transform,this.tileSet=i,this.needs_transitions=!0,this._domains={}}get default_val(){return 1}get texture_size(){return 4095}get transform(){return this._transform?this._transform:Gm[this.label].transform}get default_range(){return Gm[this.label].range}get scale(){return mm[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]=Me(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 mm[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:i,y:r,z:o}=t;if(!r.constant)throw"Only constant lookups for the secondary dimension are currently supported.";const l={x:e,y:r.field,z:o.field},a=this.scatterplot.lookup_tables.get(n),s=()=>this.arrow_column().data.dictionary.toArray();let u;void 0===a?(console.log("Using temporary null lookup."),u={texture:this.textures.one_d,y_domain:[-1,1],z_domain:[-1,1],x_domain:[-1,1]}):u=a.get_cached_crosstab_texture(l,{x:s},this.regl);const{texture:c,z_domain:d,y_domain:h,x_domain:b,shape:p,crosstabs:m}=u;return{value:r.constant||0,crosstabs:m,texture:c,shape:p,x_domain:b,y_domain:h,z_domain:d}}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=Lm(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,Lm(t.lambda,!1)),this.lookup=t.lookup,this.field=t.field,this._domain=Sm(t.domain),this._range=Sm(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=mm[this.transform]().range(t).domain([0,this.texture_size-1]);for(let n=0;n").map((t=>t.trim()));i=null==e?Function("x",n):Function(t,e)}else i=n;this.scaleFunc=sb().range(e).domain([0,this.texture_size-1]);let r=Ee(this.texture_size);if(void 0===t||null==this.tileSet.table)return void this.texture_buffer.set(Ee(this.texture_size).map((t=>1)));console.log(r);const{column:o}=this;if(!o)throw`Column ${t} does not exist on table.`;if(o.type.dictionary){r.fill("");o.data.dictionary.toArray().forEach(((t,e)=>r[e]=t))}else r=r.map((t=>this.scaleFunc(t)));const l=r.map((t=>+i(t)));console.log(l),console.log(pm(l)),this.texture_buffer.set(pm(l).array)}}class Vm extends Wm{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 vm extends Vm{get range(){const[t,e]=this.tileSet.extent?this.tileSet.extent.y:[-20,20];return[e,t]}get previous_range(){return this.range}}function Sm(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 Rm={Size:class extends Wm{get default_val(){return 1}},Jitter_speed:class extends Wm{get default_val(){return.1}},Jitter_radius:class extends Wm{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 Wm{get default_val(){return[128,150,213,255]}default_data(){return Xm.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}=zc(this._constant);return this._constant=[t/255,e/255,n/255],this._constant}return this._constant}}encode_for_textures(t){if(Xm[t])this.texture_buffer.set(Xm[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=Ee(fm).map((e=>{const[n,i,r]=t[e%t.length];return[n,i,r,255]}));this.texture_buffer.set(ym(e))}else console.warn(`request range of ${t} for color ${this.field} unknown`)}},Filter:class extends Wm{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:Vm,Y:vm,X0:class extends Vm{},Y0:class extends vm{}};class gm{constructor(t,e,n,i){this.states=[];const r=t.toLowerCase(),o=Rm[t];for(const l of[1,2])this.states.push(new o(r,e,n,i));this.states[0].partner=this.states[1],this.states[1].partner=this.states[0];for(const l of this.states)l.update({constant:Gm[r].constant});this.current_encoding=JSON.stringify({constant:Gm[r].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 Lm(t,e=!1){console.log(t);let[n,i]=t.split("=>").map((t=>t.trim()));if(void 0===i)throw`Couldn't parse ${t} into a function`;"{"!=i.slice(0,1)&&"return"!=i.slice(0,6)&&(i=`return ${i}`);const r=`${n} => ${i}`;return e?Function(n,i):{field:n,lambda:r}}const xm=Array.from(Object.keys(Rm)).map((t=>t.toLowerCase()));class Ym{constructor(t,e,n,i=null){if(this.is_aesthetic_set=!0,this.scatterplot=t,this.regl=e,this.tileSet=n,null===i)for(const o of Array.from(Object.keys(Rm))){const t=o,e=[t,this.scatterplot,this.regl,n];this[t.toLowerCase()]=new gm(...e)}const r={};for(const[o,l]of Object.entries(Gm))r[o]=l.constant||l;this.encoding=JSON.parse(JSON.stringify(r)),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 i=t[e];t[`x${n}`]={field:`${i}.x`,transform:"literal"},t[`y${n}`]={field:`${i}.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 xm)this[e].update(t[e])}}class Km 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:i,width:r,discard_share:o,height:l}=this,{k:a}=this.zoom.transform;e=void 0===e?.25:e;const s=1/a**2,u=e*(r*l)/(Qe([i,this.tileSet.highest_known_ix])*(1-o)*s*(Math.PI*Math.exp(Math.log(1*a)*t)*n)**2);return u>1?1:u<1/255?1/255:u}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=Rb({optionalExtensions:["OES_standard_derivatives","OES_element_index_uint","OES_texture_float","OES_texture_half_float"],canvas:this.canvas.node()}),this.aes=new Ym(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 Jm(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=Vb(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:i,variable_to_buffer_num:r}=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:i,aes_to_buffer_num:n,variable_to_buffer_num:r,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 i of this.visible_tiles()){const r=new Hm(this.regl,i,this);try{if(!r.ready(t.prefs,t.block_for_buffers))continue}catch(n){continue}const o={manager:r,image_locations:r.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:i,tileSet:r}=this,{props:o}=this;this.tick_num=this.tick_num||0,this.tick_num++,this._use_scale_to_download_tiles?r.download_most_needed_tiles(this.zoom.current_corners(),this.props.max_ix):r.download_to_depth(n.max_points),i.clear({color:[.9,.9,.93,0],depth:1});const l=Date.now();let a=()=>{};for(;Date.now()-l<10&&this.deferred_functions.length;){a=this.deferred_functions.shift();try{a()}catch(s){console.warn(s,a)}}this.render_all(o)}render_jpeg(t){}single_blur_pass(t,e,n){const{regl:i}=this;e.use((()=>{i.clear({color:[0,0,0,0]}),i({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 i=n-1;for(;i>-1;)this.single_blur_pass(t,e,[2**i,0]),this.single_blur_pass(e,t,[0,2**i]),i-=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[i,r]=e.position;if(e.lookups.get(t))return e.lookups.get(t);const l=e.measureText(t).width;return l>4096?void 0:(i+l>4096&&(i=0,r+=font_size),e.fillText(t,i,r),lookups.set(t,{x:i,y:r,width:l}),i+=l,e.position=[i,r],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:i,regl:r,tileSet:o}=this.aes,l=this.aes;void 0===n&&(n={width:this.width,height:this.height,use:t=>t()});const{width:a,height:s}=n;this.aes=new Ym(i,r,o);const u=map._root.table.getColumn(t).data.dictionary.length;let c=1;for(;c{this.regl.clear({color:[0,0,0,0]}),this.render_points(h),r.read({data:b})})),this.aes=l}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:i,height:r}=this.fbos.minicounter,o=new Uint8Array(i*r*4),l=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[a,s]of this.tileSet.dictionary_lookups[t]){if("string"==typeof a)continue;const t=Math.floor(a/64),e=a%64,n=i/64;let r=0,u=!1;for(const l of Ee(n))for(const a of Ee(n)){const s=o[t*n*4+4*a+e*n*4*i+l*i*4+3];s>=128?u=!0:r+=s}u?(console.log(a,s,"overflown, performing manually"),l.set(s,this.n_visible(a))):l.set(s,r)}return l}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:i}=this;let r;return i.only_color=t,console.log("Counting visible points"),this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(i),this.regl.read(this.contour_vals),r=Ae(this.contour_vals)})),r}calculate_contours(t="lc0"){const{width:e,height:n}=this;let i=[];const r=Fb().size([parseInt(e),parseInt(n)]).thresholds(d3.range(-1,9).map((t=>Math.pow(2,2*t))));for(const o of Ee(this.tileSet.dictionary_lookups[t].size/2)){this.draw_contour_buffer(t,o);const e=r(this.contour_alpha_vals);e.forEach((e=>{e.label=this.tileSet.dictionary_lookups[t].get(o)})),i=i.concat(e)}return i}color_pick(t,e){const{props:n,height:i}=this;let r;n.color_picker_mode=1,this.fbos.colorpicker.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(n);try{r=this.regl.read({x:t,y:i-e,width:1,height:1})}catch(o){console.warn("Read bad data from",{x:t,y:e,height:i})}}));const o=Bb(...r),l=this.tileSet.findPoint(o);if(0!==l.length)return l[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:i}=this;n=Math.floor(n),i=Math.floor(i),this.contour_vals=this.contour_vals||new Uint8Array(4*n*i),this.contour_alpha_vals=this.contour_alpha_vals||new Uint16Array(n*i);const{props:r}=this;r.aes.encoding.color={field:t},r.only_color=e,this.fbos.contour.use((()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(r),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:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n\nprecision 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\nfloat delta = 0.0, alpha = 1.0;\n\nbool out_of_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.03) {return true;}\n return false;\n}\n\nbool out_of_hollow_circle(in vec2 coord) {\n vec2 cxy = 2.0 * coord - 1.0;\n float r_sq = dot(cxy, cxy);\n if (r_sq > 1.01) {return true;}\n float distance_from_edge = (1.0 - r_sq) * point_size;\n if (distance_from_edge > 4.0) {return true;}\n return false;\n}\n\nbool out_of_triangle(in vec2 coord) {\n if (coord.y > (2. * abs(coord.x - .5))) {\n return false;\n }\n return true;\n}\n\nvoid main() {\n\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 float alpha = fill.a;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n float r = dot(cxy, cxy);\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha *= (1.0 - smoothstep(1.0 - delta, 1.0 + delta, r));\n #endif\n\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 * alpha, alpha);\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 Ee(0,16))e.attributes[`buffer_${n}`]=(t,{manager:e,buffer_num_to_variable:i})=>e.regl_elements.get(i[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 i="current"===t?"":"last_";if(e.uniforms[`u_${i}${n}_map`]=()=>this.aes[n][t].textures.one_d,e.uniforms[`u_${i}${n}_needs_map`]=()=>this.aes[n][t].use_map_on_regl,"jitter_radius"==n&&""==i){const r=`u_${i}${n}_lookup`;e.uniforms[r]=()=>this.aes[n][t].use_lookup?1:0,e.uniforms[`${r}_map`]=()=>this.aes[n][t].lookup_texture.texture,e.uniforms[`${r}_y_constant`]=()=>+this.aes[n][t].lookup_texture.value||.5,e.uniforms[`${r}_y_domain`]=()=>this.aes[n][t].lookup_texture.y_domain,e.uniforms[`${r}_z_domain`]=()=>this.aes[n][t].lookup_texture.z_domain,e.uniforms[`${r}_x_domain`]=()=>this.aes[n][t].lookup_texture.x_domain}e.uniforms[`u_${i}${n}_domain`]=()=>this.aes[n][t].domain,"filter"!=n&&"color"!=n&&(e.uniforms[`u_${i}${n}_range`]=()=>this.aes[n][t].range),e.uniforms[`u_${i}${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_${i}${n}_constant`]=()=>void 0!==this.aes[n][t].constant?this.aes[n][t].constant:this.aes[n][t].default_val,e.uniforms[`u_${i}${n}_buffer_num`]=(e,{aes_to_buffer_num:i})=>{const r=i[`${n}--${t}`];return null==r?-1:r}}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===xm.indexOf(t))return[];const n=[];for(const i of[e.current,e.last])i.field&&n.push(i.field);return n})).flat();for(const l of o.concat(["ix"])){const t=this.regl_elements.get(l);if(null===t)return!1;if(void 0===t){if(!this.tile.ready)return!1;if(i.set(l,null),!e)return n.deferred_functions.push((()=>this.create_regl_buffer(l))),!1;this.create_regl_buffer(l)}}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 i=new Float32Array(e.table.length);let r=0;for(const o of n.data.values){const n=e.local_dictionary_lookups[t].get(o);i[r]=e.dictionary_lookups[t].get(n),r+=1}return i}if(n.data.values.constructor!==Float32Array){const t=new Float32Array(e.table.length);for(let i=0;ithis.buffer_size&&this.generate_new_buffer();const n={buffer:this.buffers[0],offset:this.pointer,stride:e};return this.pointer+=t*e,n}} +/*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */var wm=function(t,e){return(wm=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function _m(t,e){function n(){this.constructor=t}wm(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Im=function(){return(Im=Object.assign||function(t){for(var e,n=1,i=arguments.length;n0&&r[r.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Bm(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)l.push(i.value)}catch(a){r={error:a}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return l}function km(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof Tm?Promise.resolve(n.value.v).then(s,u):c(o[0][2],n)}catch(i){c(o[0][3],i)}var n}function s(t){a("next",t)}function u(t){a("throw",t)}function c(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function Mm(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:Tm(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function jm(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Fm(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}var Qm={SIZEOF_SHORT:2,SIZEOF_INT:4,FILE_IDENTIFIER_LENGTH:4,Encoding:{UTF8_BYTES:1,UTF16_STRING:2}};Qm.int32=new Int32Array(2),Qm.float32=new Float32Array(Qm.int32.buffer),Qm.float64=new Float64Array(Qm.int32.buffer),Qm.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],Qm.Long=function(t,e){this.low=0|t,this.high=0|e},Qm.Long.create=function(t,e){return 0==t&&0==e?Qm.Long.ZERO:new Qm.Long(t,e)},Qm.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},Qm.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},Qm.Long.ZERO=new Qm.Long(0,0),Qm.Builder=function(t){if(t)e=t;else var e=1024;this.bb=Qm.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},Qm.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},Qm.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},Qm.Builder.prototype.dataBuffer=function(){return this.bb},Qm.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},Qm.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 i=(n+2)*Qm.SIZEOF_SHORT;this.addInt16(i);var r=0,o=this.space;t:for(e=0;e=0;i--)this.writeInt8(n.charCodeAt(i))}this.prep(this.minalign,Qm.SIZEOF_INT),this.addOffset(t),this.bb.setPosition(this.space)},Qm.Builder.prototype.requiredField=function(t,e){var n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(i+e)))throw new Error("FlatBuffers: field "+e+" must be set")},Qm.Builder.prototype.startVector=function(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(Qm.SIZEOF_INT,t*e),this.prep(n,t*e)},Qm.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},Qm.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var n=0;n=56320)i=r;else i=(r<<10)+t.charCodeAt(n++)+-56613888;i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);n=0;for(var o=this.space,l=this.bb.bytes();n>24},Qm.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},Qm.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},Qm.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},Qm.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},Qm.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},Qm.ByteBuffer.prototype.readInt64=function(t){return new Qm.Long(this.readInt32(t),this.readInt32(t+4))},Qm.ByteBuffer.prototype.readUint64=function(t){return new Qm.Long(this.readUint32(t),this.readUint32(t+4))},Qm.ByteBuffer.prototype.readFloat32=function(t){return Qm.int32[0]=this.readInt32(t),Qm.float32[0]},Qm.ByteBuffer.prototype.readFloat64=function(t){return Qm.int32[Qm.isLittleEndian?0:1]=this.readInt32(t),Qm.int32[Qm.isLittleEndian?1:0]=this.readInt32(t+4),Qm.float64[0]},Qm.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},Qm.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},Qm.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},Qm.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},Qm.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},Qm.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},Qm.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},Qm.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},Qm.ByteBuffer.prototype.writeFloat32=function(t,e){Qm.float32[0]=e,this.writeInt32(t,Qm.int32[0])},Qm.ByteBuffer.prototype.writeFloat64=function(t,e){Qm.float64[0]=e,this.writeInt32(t,Qm.int32[Qm.isLittleEndian?0:1]),this.writeInt32(t+4,Qm.int32[Qm.isLittleEndian?1:0])},Qm.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&o)))}return i},Qm.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},Qm.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+Qm.SIZEOF_INT},Qm.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},Qm.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=Qm.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+Qm.FILE_IDENTIFIER_LENGTH);for(var e=0;e0;)t.shift().resolve($m);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}},e.prototype[Symbol.asyncIterator]=function(){return this},e.prototype.toDOMStream=function(t){return Tf.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)},e.prototype.toNodeStream=function(t){return Tf.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)},e.prototype.throw=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.abort(t)];case 1:return e.sent(),[2,$m]}}))}))},e.prototype.return=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(t){switch(t.label){case 0:return[4,this.close()];case 1:return t.sent(),[2,$m]}}))}))},e.prototype.read=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"read")];case 1:return[2,e.sent().value]}}))}))},e.prototype.peek=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"peek")];case 1:return[2,e.sent().value]}}))}))},e.prototype.next=function(){for(var t=this,e=[],n=0;n0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((function(e,n){t.resolvers.push({resolve:e,reject:n})})):Promise.resolve($m)},e.prototype._ensureOpen=function(){if(this._closedPromiseResolve)return!0;throw new Error(this+" is closed")},e}(ef),rf=Bm(function(){var t=function(){throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=function(){throw t()},e.asUintN=function(){throw t()},"undefined"!=typeof BigInt?[BigInt,!0]:[e,!1]}(),2),of=rf[0],lf=rf[1],af=Bm((Pm=function(){throw new Error("BigInt64Array is not available in this environment")},Em=function(){function t(){throw Pm()}return Object.defineProperty(t,"BYTES_PER_ELEMENT",{get:function(){return 8},enumerable:!1,configurable:!0}),t.of=function(){throw Pm()},t.from=function(){throw Pm()},t}(),"undefined"!=typeof BigInt64Array?[BigInt64Array,!0]:[Em,!1]),2),sf=af[0];af[1];var uf,cf,df=Bm((uf=function(){throw new Error("BigUint64Array is not available in this environment")},cf=function(){function t(){throw uf()}return Object.defineProperty(t,"BYTES_PER_ELEMENT",{get:function(){return 8},enumerable:!1,configurable:!0}),t.of=function(){throw uf()},t.from=function(){throw uf()},t}(),"undefined"!=typeof BigUint64Array?[BigUint64Array,!0]:[cf,!1]),2),hf=df[0];df[1];var bf=function(t){return"boolean"==typeof t},pf=function(t){return"function"==typeof t},mf=function(t){return null!=t&&Object(t)===t},ff=function(t){return mf(t)&&pf(t.then)},yf=function(t){return mf(t)&&pf(t[Symbol.iterator])},Zf=function(t){return mf(t)&&pf(t[Symbol.asyncIterator])},Xf=function(t){return mf(t)&&mf(t.schema)},Gf=function(t){return mf(t)&&"done"in t&&"value"in t},Wf=function(t){return mf(t)&&pf(t.stat)&&function(t){return"number"==typeof t}(t.fd)},Vf=function(t){return mf(t)&&vf(t.body)},vf=function(t){return mf(t)&&pf(t.cancel)&&pf(t.getReader)&&!(t instanceof ef)},Sf=function(t){return mf(t)&&pf(t.read)&&pf(t.pipe)&&bf(t.readable)&&!(t instanceof ef)},Rf=Qm.ByteBuffer,gf="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Lf(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=e.byteLength);var r=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,r),l=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return o.set(l,n),t}function xf(t,e){for(var n,i,r,o=function(t){for(var e,n,i,r,o=t[0]?[t[0]]:[],l=void 0,a=void 0,s=0,u=0,c=t.length;++s0)do{if(t[n]!==e[n])return!1}while(++n0&&(r.push(o),s+=o.byteLength),!(n||a<=s))return[3,7];p.label=4;case 4:return[4,e()];case 5:b=p.sent(),l=b.cmd,a=b.size,p.label=6;case 6:if(a0&&(r.push(o),s+=o.byteLength),!(n||a<=s))return[3,13];m.label=9;case 9:return[4,Tm(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),l=p.cmd,a=p.size,m.label=12;case 12:if(a0&&(r.push(Jf(o)),s+=o.byteLength),!(n||a<=s))return[3,13];m.label=9;case 9:return[4,Tm(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),l=p.cmd,a=p.size,m.label=12;case 12:if(a0&&(c.push(d),u+=d.byteLength)),!(o||s<=u))return[3,13];m.label=9;case 9:return[4,Tm(e())];case 10:return[4,m.sent()];case 11:p=m.sent(),a=p.cmd,s=p.size,m.label=12;case 12:if(s=i?[2,{done:!1,value:new Uint8Array(e,0,i)}]:[4,t.read(new Uint8Array(e,n,i-n))];case 1:return r=a.sent(),o=r.done,l=r.value,(n+=l.byteLength)=0;n--)t.addInt32(e[n]);return t.endVector()},e.startTypeIdsVector=function(t,e){t.startVector(4,e,4)},e.endUnion=function(t){return t.endObject()},e.createUnion=function(t,n,i){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,i),e.endUnion(t)},e}();e.Union=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsInt=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.bitWidth=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.prototype.isSigned=function(){var t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},t.startInt=function(t){t.startObject(2)},t.addBitWidth=function(t,e){t.addFieldInt32(0,e,0)},t.addIsSigned=function(t,e){t.addFieldInt8(1,+e,0)},t.endInt=function(t){return t.endObject()},t.createInt=function(e,n,i){return t.startInt(e),t.addBitWidth(e,n),t.addIsSigned(e,i),t.endInt(e)},t}();t.Int=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsFloatingPoint=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.precision=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.Precision.HALF},e.startFloatingPoint=function(t){t.startObject(1)},e.addPrecision=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.Precision.HALF)},e.endFloatingPoint=function(t){return t.endObject()},e.createFloatingPoint=function(t,n){return e.startFloatingPoint(t),e.addPrecision(t,n),e.endFloatingPoint(t)},e}();e.FloatingPoint=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsUtf8=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startUtf8=function(t){t.startObject(0)},t.endUtf8=function(t){return t.endObject()},t.createUtf8=function(e){return t.startUtf8(e),t.endUtf8(e)},t}();t.Utf8=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startBinary=function(t){t.startObject(0)},t.endBinary=function(t){return t.endObject()},t.createBinary=function(e){return t.startBinary(e),t.endBinary(e)},t}();t.Binary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsLargeUtf8=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startLargeUtf8=function(t){t.startObject(0)},t.endLargeUtf8=function(t){return t.endObject()},t.createLargeUtf8=function(e){return t.startLargeUtf8(e),t.endLargeUtf8(e)},t}();t.LargeUtf8=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsLargeBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startLargeBinary=function(t){t.startObject(0)},t.endLargeBinary=function(t){return t.endObject()},t.createLargeBinary=function(e){return t.startLargeBinary(e),t.endLargeBinary(e)},t}();t.LargeBinary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFixedSizeBinary=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.byteWidth=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.startFixedSizeBinary=function(t){t.startObject(1)},t.addByteWidth=function(t,e){t.addFieldInt32(0,e,0)},t.endFixedSizeBinary=function(t){return t.endObject()},t.createFixedSizeBinary=function(e,n){return t.startFixedSizeBinary(e),t.addByteWidth(e,n),t.endFixedSizeBinary(e)},t}();t.FixedSizeBinary=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBool=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startBool=function(t){t.startObject(0)},t.endBool=function(t){return t.endObject()},t.createBool=function(e){return t.startBool(e),t.endBool(e)},t}();t.Bool=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDecimal=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.precision=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},t.prototype.scale=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},t.startDecimal=function(t){t.startObject(2)},t.addPrecision=function(t,e){t.addFieldInt32(0,e,0)},t.addScale=function(t,e){t.addFieldInt32(1,e,0)},t.endDecimal=function(t){return t.endObject()},t.createDecimal=function(e,n,i){return t.startDecimal(e),t.addPrecision(e,n),t.addScale(e,i),t.endDecimal(e)},t}();t.Decimal=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDate=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.DateUnit.MILLISECOND},e.startDate=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.DateUnit.MILLISECOND)},e.endDate=function(t){return t.endObject()},e.createDate=function(t,n){return e.startDate(t),e.addUnit(t,n),e.endDate(t)},e}();e.Date=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsTime=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.MILLISECOND},e.prototype.bitWidth=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32},e.startTime=function(t){t.startObject(2)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.MILLISECOND)},e.addBitWidth=function(t,e){t.addFieldInt32(1,e,32)},e.endTime=function(t){return t.endObject()},e.createTime=function(t,n,i){return e.startTime(t),e.addUnit(t,n),e.addBitWidth(t,i),e.endTime(t)},e}();e.Time=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsTimestamp=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.SECOND},e.prototype.timezone=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},e.startTimestamp=function(t){t.startObject(2)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.SECOND)},e.addTimezone=function(t,e){t.addFieldOffset(1,e,0)},e.endTimestamp=function(t){return t.endObject()},e.createTimestamp=function(t,n,i){return e.startTimestamp(t),e.addUnit(t,n),e.addTimezone(t,i),e.endTimestamp(t)},e}();e.Timestamp=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsInterval=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH},e.startInterval=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH)},e.endInterval=function(t){return t.endObject()},e.createInterval=function(t,n){return e.startInterval(t),e.addUnit(t,n),e.endInterval(t)},e}();e.Interval=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDuration=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.unit=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.TimeUnit.MILLISECOND},e.startDuration=function(t){t.startObject(1)},e.addUnit=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.TimeUnit.MILLISECOND)},e.endDuration=function(t){return t.endObject()},e.createDuration=function(t,n){return e.startDuration(t),e.addUnit(t,n),e.endDuration(t)},e}();e.Duration=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsKeyValue=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.key=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},t.prototype.value=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},t.startKeyValue=function(t){t.startObject(2)},t.addKey=function(t,e){t.addFieldOffset(0,e,0)},t.addValue=function(t,e){t.addFieldOffset(1,e,0)},t.endKeyValue=function(t){return t.endObject()},t.createKeyValue=function(e,n,i){return t.startKeyValue(e),t.addKey(e,n),t.addValue(e,i),t.endKeyValue(e)},t}();t.KeyValue=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDictionaryEncoding=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.id=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.indexType=function(e){var n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.apache.arrow.flatbuf.Int).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.isOrdered=function(){var t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.startDictionaryEncoding=function(t){t.startObject(3)},e.addId=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addIndexType=function(t,e){t.addFieldOffset(1,e,0)},e.addIsOrdered=function(t,e){t.addFieldInt8(2,+e,0)},e.endDictionaryEncoding=function(t){return t.endObject()},e.createDictionaryEncoding=function(t,n,i,r){return e.startDictionaryEncoding(t),e.addId(t,n),e.addIndexType(t,i),e.addIsOrdered(t,r),e.endDictionaryEncoding(t)},e}();e.DictionaryEncoding=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsField=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.name=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.prototype.nullable=function(){var t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.prototype.typeType=function(){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):t.apache.arrow.flatbuf.Type.NONE},e.prototype.type=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null},e.prototype.dictionary=function(e){var n=this.bb.__offset(this.bb_pos,12);return n?(e||new t.apache.arrow.flatbuf.DictionaryEncoding).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.children=function(e,n){var i=this.bb.__offset(this.bb_pos,14);return i?(n||new t.apache.arrow.flatbuf.Field).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.childrenLength=function(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.customMetadata=function(e,n){var i=this.bb.__offset(this.bb_pos,16);return i?(n||new t.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startField=function(t){t.startObject(7)},e.addName=function(t,e){t.addFieldOffset(0,e,0)},e.addNullable=function(t,e){t.addFieldInt8(1,+e,0)},e.addTypeType=function(e,n){e.addFieldInt8(2,n,t.apache.arrow.flatbuf.Type.NONE)},e.addType=function(t,e){t.addFieldOffset(3,e,0)},e.addDictionary=function(t,e){t.addFieldOffset(4,e,0)},e.addChildren=function(t,e){t.addFieldOffset(5,e,0)},e.createChildrenVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startChildrenVector=function(t,e){t.startVector(4,e,4)},e.addCustomMetadata=function(t,e){t.addFieldOffset(6,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endField=function(t){return t.endObject()},e.createField=function(t,n,i,r,o,l,a,s){return e.startField(t),e.addName(t,n),e.addNullable(t,i),e.addTypeType(t,r),e.addType(t,o),e.addDictionary(t,l),e.addChildren(t,a),e.addCustomMetadata(t,s),e.endField(t)},e}();e.Field=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.offset=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.length=function(){return this.bb.readInt64(this.bb_pos+8)},t.createBuffer=function(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()},t}();t.Buffer=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsSchema=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.endianness=function(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):t.apache.arrow.flatbuf.Endianness.Little},e.prototype.fields=function(e,n){var i=this.bb.__offset(this.bb_pos,6);return i?(n||new t.apache.arrow.flatbuf.Field).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.fieldsLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.customMetadata=function(e,n){var i=this.bb.__offset(this.bb_pos,8);return i?(n||new t.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startSchema=function(t){t.startObject(3)},e.addEndianness=function(e,n){e.addFieldInt16(0,n,t.apache.arrow.flatbuf.Endianness.Little)},e.addFields=function(t,e){t.addFieldOffset(1,e,0)},e.createFieldsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startFieldsVector=function(t,e){t.startVector(4,e,4)},e.addCustomMetadata=function(t,e){t.addFieldOffset(2,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endSchema=function(t){return t.endObject()},e.finishSchemaBuffer=function(t,e){t.finish(e)},e.createSchema=function(t,n,i,r){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,i),e.addCustomMetadata(t,r),e.endSchema(t)},e}();e.Schema=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(Pf||(Pf={})),function(t){!function(t){!function(t){!function(t){t.Schema=Pf.apache.arrow.flatbuf.Schema}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={})),function(t){!function(t){!function(t){!function(t){!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(t.MessageHeader||(t.MessageHeader={}))}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.length=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.nullCount=function(){return this.bb.readInt64(this.bb_pos+8)},t.createFieldNode=function(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()},t}();t.FieldNode=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsRecordBatch=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.length=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.nodes=function(e,n){var i=this.bb.__offset(this.bb_pos,6);return i?(n||new t.apache.arrow.flatbuf.FieldNode).__init(this.bb.__vector(this.bb_pos+i)+16*e,this.bb):null},e.prototype.nodesLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.buffers=function(t,e){var n=this.bb.__offset(this.bb_pos,8);return n?(e||new Pf.apache.arrow.flatbuf.Buffer).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null},e.prototype.buffersLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startRecordBatch=function(t){t.startObject(3)},e.addLength=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addNodes=function(t,e){t.addFieldOffset(1,e,0)},e.startNodesVector=function(t,e){t.startVector(16,e,8)},e.addBuffers=function(t,e){t.addFieldOffset(2,e,0)},e.startBuffersVector=function(t,e){t.startVector(16,e,8)},e.endRecordBatch=function(t){return t.endObject()},e.createRecordBatch=function(t,n,i,r){return e.startRecordBatch(t),e.addLength(t,n),e.addNodes(t,i),e.addBuffers(t,r),e.endRecordBatch(t)},e}();e.RecordBatch=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsDictionaryBatch=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.id=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.data=function(e){var n=this.bb.__offset(this.bb_pos,6);return n?(e||new t.apache.arrow.flatbuf.RecordBatch).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null},e.prototype.isDelta=function(){var t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.startDictionaryBatch=function(t){t.startObject(3)},e.addId=function(t,e){t.addFieldInt64(0,e,t.createLong(0,0))},e.addData=function(t,e){t.addFieldOffset(1,e,0)},e.addIsDelta=function(t,e){t.addFieldInt8(2,+e,0)},e.endDictionaryBatch=function(t){return t.endObject()},e.createDictionaryBatch=function(t,n,i,r){return e.startDictionaryBatch(t),e.addId(t,n),e.addData(t,i),e.addIsDelta(t,r),e.endDictionaryBatch(t)},e}();e.DictionaryBatch=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={})),function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsMessage=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.version=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Pf.apache.arrow.flatbuf.MetadataVersion.V1},e.prototype.headerType=function(){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):t.apache.arrow.flatbuf.MessageHeader.NONE},e.prototype.header=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null},e.prototype.bodyLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)},e.prototype.customMetadata=function(t,e){var n=this.bb.__offset(this.bb_pos,12);return n?(e||new Pf.apache.arrow.flatbuf.KeyValue).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null},e.prototype.customMetadataLength=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startMessage=function(t){t.startObject(5)},e.addVersion=function(t,e){t.addFieldInt16(0,e,Pf.apache.arrow.flatbuf.MetadataVersion.V1)},e.addHeaderType=function(e,n){e.addFieldInt8(1,n,t.apache.arrow.flatbuf.MessageHeader.NONE)},e.addHeader=function(t,e){t.addFieldOffset(2,e,0)},e.addBodyLength=function(t,e){t.addFieldInt64(3,e,t.createLong(0,0))},e.addCustomMetadata=function(t,e){t.addFieldOffset(4,e,0)},e.createCustomMetadataVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},e.startCustomMetadataVector=function(t,e){t.startVector(4,e,4)},e.endMessage=function(t){return t.endObject()},e.finishMessageBuffer=function(t,e){t.finish(e)},e.createMessage=function(t,n,i,r,o,l){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,i),e.addHeader(t,r),e.addBodyLength(t,o),e.addCustomMetadata(t,l),e.endMessage(t)},e}();e.Message=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(qf||(qf={}));var ty,ey,ny=Pf.apache.arrow.flatbuf.Type,iy=Pf.apache.arrow.flatbuf.DateUnit,ry=Pf.apache.arrow.flatbuf.TimeUnit,oy=Pf.apache.arrow.flatbuf.Precision,ly=Pf.apache.arrow.flatbuf.UnionMode,ay=Pf.apache.arrow.flatbuf.IntervalUnit,sy=qf.apache.arrow.flatbuf.MessageHeader,uy=Pf.apache.arrow.flatbuf.MetadataVersion;function cy(t,e,n,i){return 0!=(n&1<>i}function hy(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):py(my(n,t,e,null,cy)).subarray(0,i)),r}return n}function py(t){var e,n,i=[],r=0,o=0,l=0;try{for(var a=Fm(t),s=a.next();!s.done;s=a.next()){s.value&&(l|=1<0)&&(i[r++]=l);var u=new Uint8Array(i.length+7&-8);return u.set(i),u}function my(t,e,n,i,r){var o,l,a,s,u;return Um(this,(function(c){switch(c.label){case 0:o=e%8,l=e>>3,a=0,s=n,c.label=1;case 1:if(!(s>0))return[3,6];u=t[l++],c.label=2;case 2:return[4,r(i,a++,u,o)];case 3:c.sent(),c.label=4;case 4:if(--s>0&&++o<8)return[3,2];c.label=5;case 5:return o=0,[3,1];case 6:return[2]}}))}function fy(t,e,n){var i,r;if(n-e<=0)return 0;if(n-e<8){var o=0;try{for(var l=Fm(my(t,e,n-e,t,dy)),a=l.next();!a.done;a=l.next()){o+=a.value}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=l.return)&&r.call(l)}finally{if(i)throw i.error}}return o}var s=n>>3<<3,u=e+(e%8==0?0:8-e%8);return fy(t,e,u)+fy(t,s,n)+yy(t,u>>3,s-u>>3)}function yy(t,e,n){for(var i=0,r=0|e,o=new DataView(t.buffer,t.byteOffset,t.byteLength),l=void 0===n?t.byteLength:r+n;l-r>=4;)i+=Zy(o.getUint32(r)),r+=4;for(;l-r>=2;)i+=Zy(o.getUint16(r)),r+=2;for(;l-r>=1;)i+=Zy(o.getUint8(r)),r+=1;return i}function Zy(t){var e=0|t;return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24}!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"}(ty||(ty={})),function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"}(ey||(ey={}));var Xy=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",getBool:cy,getBit:dy,setBool:hy,truncateBitmap:by,packBools:py,iterateBits:my,popcnt_bit_range:fy,popcnt_array:yy,popcnt_uint32:Zy}),Gy=function(){function t(){}return t.prototype.visitMany=function(t){for(var e=this,n=[],i=1;i0?"+":"")+this.scale+"]"},e[Symbol.toStringTag]=function(t){return t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"}(e.prototype),e}(wy),qy=function(t){function e(e){var n=t.call(this)||this;return n.unit=e,n}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Date},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Date"+32*(this.unit+1)+"<"+iy[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"}(e.prototype),e}(wy),$y=function(t){function e(){return t.call(this,iy.DAY)||this}return _m(e,t),e}(qy),tZ=function(t){function e(){return t.call(this,iy.MILLISECOND)||this}return _m(e,t),e}(qy),eZ=function(t){function e(e,n){var i=t.call(this)||this;return i.unit=e,i.bitWidth=n,i}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Time},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Time"+this.bitWidth+"<"+ry[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.bitWidth=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Time"}(e.prototype),e}(wy);!function(t){function e(){return t.call(this,ry.SECOND,32)||this}_m(e,t)}(eZ),function(t){function e(){return t.call(this,ry.MILLISECOND,32)||this}_m(e,t)}(eZ),function(t){function e(){return t.call(this,ry.MICROSECOND,64)||this}_m(e,t)}(eZ),function(t){function e(){return t.call(this,ry.NANOSECOND,64)||this}_m(e,t)}(eZ);var nZ=function(t){function e(e,n){var i=t.call(this)||this;return i.unit=e,i.timezone=n,i}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Timestamp},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Timestamp<"+ry[this.unit]+(this.timezone?", "+this.timezone:"")+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"}(e.prototype),e}(wy);!function(t){function e(e){return t.call(this,ry.SECOND,e)||this}_m(e,t)}(nZ),function(t){function e(e){return t.call(this,ry.MILLISECOND,e)||this}_m(e,t)}(nZ),function(t){function e(e){return t.call(this,ry.MICROSECOND,e)||this}_m(e,t)}(nZ),function(t){function e(e){return t.call(this,ry.NANOSECOND,e)||this}_m(e,t)}(nZ);var iZ=function(t){function e(e){var n=t.call(this)||this;return n.unit=e,n}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Interval},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Interval<"+ay[this.unit]+">"},e[Symbol.toStringTag]=function(t){return t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"}(e.prototype),e}(wy);!function(t){function e(){return t.call(this,ay.DAY_TIME)||this}_m(e,t)}(iZ),function(t){function e(){return t.call(this,ay.YEAR_MONTH)||this}_m(e,t)}(iZ);var rZ=function(t){function e(e){var n=t.call(this)||this;return n.children=[e],n}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.List},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"List<"+this.valueType+">"},Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueField",{get:function(){return this.children[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.valueType.ArrayType},enumerable:!1,configurable:!0}),e[Symbol.toStringTag]=function(t){return t.children=null,t[Symbol.toStringTag]="List"}(e.prototype),e}(wy),oZ=function(t){function e(e){var n=t.call(this)||this;return n.children=e,n}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Struct},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Struct<{"+this.children.map((function(t){return t.name+":"+t.type})).join(", ")+"}>"},e[Symbol.toStringTag]=function(t){return t.children=null,t[Symbol.toStringTag]="Struct"}(e.prototype),e}(wy),lZ=function(t){function e(e,n,i){var r=t.call(this)||this;return r.mode=e,r.children=i,r.typeIds=n=Int32Array.from(n),r.typeIdToChildIndex=n.reduce((function(t,e,n){return(t[e]=n)&&t||t}),Object.create(null)),r}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Union},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this[Symbol.toStringTag]+"<"+this.children.map((function(t){return""+t.type})).join(" | ")+">"},e[Symbol.toStringTag]=function(t){return t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"}(e.prototype),e}(wy);!function(t){function e(e,n){return t.call(this,ly.Dense,e,n)||this}_m(e,t)}(lZ),function(t){function e(e,n){return t.call(this,ly.Sparse,e,n)||this}_m(e,t)}(lZ);var aZ=function(t){function e(e){var n=t.call(this)||this;return n.byteWidth=e,n}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.FixedSizeBinary},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"FixedSizeBinary["+this.byteWidth+"]"},e[Symbol.toStringTag]=function(t){return t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"}(e.prototype),e}(wy),sZ=function(t){function e(e,n){var i=t.call(this)||this;return i.listSize=e,i.children=[n],i}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.FixedSizeList},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueField",{get:function(){return this.children[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.valueType.ArrayType},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"FixedSizeList["+this.listSize+"]<"+this.valueType+">"},e[Symbol.toStringTag]=function(t){return t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"}(e.prototype),e}(wy),uZ=function(t){function e(e,n){void 0===n&&(n=!1);var i=t.call(this)||this;return i.children=[e],i.keysSorted=n,i}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Map},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"keyType",{get:function(){return this.children[0].type.children[0].type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.children[0].type.children[1].type},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Map<{"+this.children[0].type.children.map((function(t){return t.name+":"+t.type})).join(", ")+"}>"},e[Symbol.toStringTag]=function(t){return t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"}(e.prototype),e}(wy),cZ=function(t){return function(){return++t}}(-1),dZ=function(t){function e(e,n,i,r){var o=t.call(this)||this;return o.indices=n,o.dictionary=e,o.isOrdered=r||!1,o.id=null==i?cZ():"number"==typeof i?i:i.low,o}return _m(e,t),Object.defineProperty(e.prototype,"typeId",{get:function(){return ty.Dictionary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.dictionary.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueType",{get:function(){return this.dictionary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.dictionary.ArrayType},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"Dictionary<"+this.indices+", "+this.dictionary+">"},e[Symbol.toStringTag]=function(t){return t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"}(e.prototype),e}(wy);function hZ(t){var e=t;switch(t.typeId){case ty.Decimal:return 4;case ty.Timestamp:return 2;case ty.Date:case ty.Interval:return 1+e.unit;case ty.Int:case ty.Time:return+(e.bitWidth>32)+1;case ty.FixedSizeList:return e.listSize;case ty.FixedSizeBinary:return e.byteWidth;default:return 1}}var bZ=function(){function t(e,n,i,r,o,l,a){var s;this.type=e,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(r||0,-1)),this.childData=(l||[]).map((function(e){return e instanceof t?e:e.data})),o instanceof t?(this.stride=o.stride,this.values=o.values,this.typeIds=o.typeIds,this.nullBitmap=o.nullBitmap,this.valueOffsets=o.valueOffsets):(this.stride=hZ(e),o&&((s=o[0])&&(this.valueOffsets=s),(s=o[1])&&(this.values=s),(s=o[2])&&(this.nullBitmap=s),(s=o[3])&&(this.typeIds=s)))}return Object.defineProperty(t.prototype,"typeId",{get:function(){return this.type.typeId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"byteLength",{get:function(){var t=0,e=this,n=e.valueOffsets,i=e.values,r=e.nullBitmap,o=e.typeIds;return n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),o&&(t+=o.byteLength),this.childData.reduce((function(t,e){return t+e.byteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullCount",{get:function(){var t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-fy(t,this.offset,this.offset+this.length)),e},enumerable:!1,configurable:!0}),t.prototype.clone=function(e,n,i,r,o,l){return void 0===n&&(n=this.offset),void 0===i&&(i=this.length),void 0===r&&(r=this._nullCount),void 0===o&&(o=this),void 0===l&&(l=this.childData),new t(e,n,i,r,o,l,this.dictionary)},t.prototype.slice=function(t,e){var n=this,i=n.stride,r=n.typeId,o=n.childData,l=+(0===this._nullCount)-1,a=16===r?i:1,s=this._sliceBuffers(t,e,i,r);return this.clone(this.type,this.offset+t,e,l,s,!o.length||this.valueOffsets?o:this._sliceChildren(o,a*t,a*e))},t.prototype._changeLengthAndBackfillNullBitmap=function(t){if(this.typeId===ty.Null)return this.clone(this.type,0,t,0);var e=this.length,n=this.nullCount,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(by(this.offset,e,this.nullBitmap),0);var r=this.buffers;return r[ey.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)},t.prototype._sliceBuffers=function(t,e,n,i){var r,o=this.buffers;return(r=o[ey.TYPE])&&(o[ey.TYPE]=r.subarray(t,t+e)),(r=o[ey.OFFSET])&&(o[ey.OFFSET]=r.subarray(t,t+e+1))||(r=o[ey.DATA])&&(o[ey.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),o},t.prototype._sliceChildren=function(t,e,n){return t.map((function(t){return t.slice(e,n)}))},t.new=function(e,n,i,r,o,l,a){switch(o instanceof t?o=o.buffers:o||(o=[]),e.typeId){case ty.Null:return t.Null(e,n,i);case ty.Int:return t.Int(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Dictionary:return t.Dictionary(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[],a);case ty.Float:return t.Float(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Bool:return t.Bool(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Decimal:return t.Decimal(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Date:return t.Date(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Time:return t.Time(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Timestamp:return t.Timestamp(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Interval:return t.Interval(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.FixedSizeBinary:return t.FixedSizeBinary(e,n,i,r||0,o[ey.VALIDITY],o[ey.DATA]||[]);case ty.Binary:return t.Binary(e,n,i,r||0,o[ey.VALIDITY],o[ey.OFFSET]||[],o[ey.DATA]||[]);case ty.Utf8:return t.Utf8(e,n,i,r||0,o[ey.VALIDITY],o[ey.OFFSET]||[],o[ey.DATA]||[]);case ty.List:return t.List(e,n,i,r||0,o[ey.VALIDITY],o[ey.OFFSET]||[],(l||[])[0]);case ty.FixedSizeList:return t.FixedSizeList(e,n,i,r||0,o[ey.VALIDITY],(l||[])[0]);case ty.Struct:return t.Struct(e,n,i,r||0,o[ey.VALIDITY],l||[]);case ty.Map:return t.Map(e,n,i,r||0,o[ey.VALIDITY],o[ey.OFFSET]||[],(l||[])[0]);case ty.Union:return t.Union(e,n,i,r||0,o[ey.VALIDITY],o[ey.TYPE]||[],o[ey.OFFSET]||l,l)}throw new Error("Unrecognized typeId "+e.typeId)},t.Null=function(e,n,i){return new t(e,n,i,0)},t.Int=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Dictionary=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[void 0,Yf(e.indices.ArrayType,l),Jf(o)],[],a)},t.Float=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Bool=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Decimal=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Date=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Time=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Timestamp=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Interval=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.FixedSizeBinary=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,Yf(e.ArrayType,l),Jf(o)])},t.Binary=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Kf(l),Jf(a),Jf(o)])},t.Utf8=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Kf(l),Jf(a),Jf(o)])},t.List=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Kf(l),void 0,Jf(o)],a?[a]:[])},t.FixedSizeList=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,void 0,Jf(o)],l?[l]:[])},t.Struct=function(e,n,i,r,o,l){return new t(e,n,i,r,[void 0,void 0,Jf(o)],l)},t.Map=function(e,n,i,r,o,l,a){return new t(e,n,i,r,[Kf(l),void 0,Jf(o)],a?[a]:[])},t.Union=function(e,n,i,r,o,l,a,s){var u=[void 0,void 0,Jf(o),Yf(e.ArrayType,l)];return e.mode===ly.Sparse?new t(e,n,i,r,u,a):(u[ey.OFFSET]=Kf(a),new t(e,n,i,r,u,s))},t}();bZ.prototype.childData=Object.freeze([]);function pZ(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)}function mZ(t){if(!t||t.length<=0)return function(t){return!0};var e="",n=t.filter((function(t){return t==t}));return n.length>0&&(e="\n switch (x) {"+n.map((function(t){return"\n case "+function(t){if("bigint"!=typeof t)return pZ(t);if(lf)return pZ(t)+"n";return'"'+pZ(t)+'"'}(t)+":"})).join("")+"\n return false;\n }"),t.length!==n.length&&(e="if (x !== x) return false;\n"+e),new Function("x",e+"\nreturn true;")}var fZ=function(t,e){return(t*e+63&-64||64)/e},yZ=function(){function t(t,e){void 0===e&&(e=1),this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=t.length/e|0)}return Object.defineProperty(t.prototype,"byteLength",{get:function(){return this.length*this.stride*this.BYTES_PER_ELEMENT|0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedLength",{get:function(){return this.buffer.length/this.stride},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedByteLength",{get:function(){return this.buffer.byteLength},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){return this},t.prototype.append=function(t){return this.set(this.length,t)},t.prototype.reserve=function(t){if(t>0){this.length+=t;var e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(fZ(0===i?1*n:2*n,this.BYTES_PER_ELEMENT))}return this},t.prototype.flush=function(t){void 0===t&&(t=this.length),t=fZ(t*this.stride,this.BYTES_PER_ELEMENT);var e,n,i=(e=this.buffer,void 0===(n=t)&&(n=0),e.length>=n?e.subarray(0,n):Lf(new e.constructor(n),e,0));return this.clear(),i},t.prototype.clear=function(){return this.length=0,this._resize(0),this},t.prototype._resize=function(t){return this.buffer=Lf(new this.ArrayType(t),this.buffer)},t}();yZ.prototype.offset=0;var ZZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.last=function(){return this.get(this.length-1)},e.prototype.get=function(t){return this.buffer[t]},e.prototype.set=function(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this},e}(yZ),XZ=function(t){function e(e){void 0===e&&(e=new Uint8Array(0));var n=t.call(this,e,1/8)||this;return n.numValid=0,n}return _m(e,t),Object.defineProperty(e.prototype,"numInvalid",{get:function(){return this.length-this.numValid},enumerable:!1,configurable:!0}),e.prototype.get=function(t){return this.buffer[t>>3]>>t%8&1},e.prototype.set=function(t,e){var n=this.reserve(t-this.length+1).buffer,i=t>>3,r=t%8,o=n[i]>>r&1;return e?0===o&&(n[i]|=1<this.length&&this.set(e-1,0),t.prototype.flush.call(this,e+1)},e}(ZZ),WZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),Object.defineProperty(e.prototype,"ArrayType64",{get:function(){return this._ArrayType64||(this._ArrayType64=this.buffer instanceof Int32Array?sf:hf)},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e){switch(this.reserve(t-this.length+1),typeof e){case"bigint":this.buffer64[t]=e;break;case"number":this.buffer[t*this.stride]=e;break;default:this.buffer.set(e,t*this.stride)}return this},e.prototype._resize=function(e){var n=t.prototype._resize.call(this,e),i=n.byteLength/(this.BYTES_PER_ELEMENT*this.stride);return lf&&(this.buffer64=new this.ArrayType64(n.buffer,n.byteOffset,i)),n},e}(yZ),VZ=function(){function t(t){var e=t.type,n=t.nullValues;this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=hZ(e),this._nulls=new XZ,n&&n.length>0&&(this._isValid=mZ(n))}return t.new=function(t){},t.throughNode=function(t){throw new Error('"throughNode" not available in this environment')},t.throughDOM=function(t){throw new Error('"throughDOM" not available in this environment')},t.throughIterable=function(t){return function(t){var e=t.queueingStrategy,n=void 0===e?"count":e,i=t.highWaterMark,r=void 0===i?"bytes"!==n?1e3:Math.pow(2,14):i,o="bytes"!==n?"length":"byteLength";return function(e){var n,i,l,a,s,u,c,d;return Um(this,(function(h){switch(h.label){case 0:n=0,i=VZ.new(t),h.label=1;case 1:h.trys.push([1,7,8,9]),l=Fm(e),a=l.next(),h.label=2;case 2:return a.done?[3,6]:(s=a.value,i.append(s)[o]>=r?++n?[4,i.toVector()]:[3,4]:[3,5]);case 3:h.sent(),h.label=4;case 4:h.label=5;case 5:return a=l.next(),[3,2];case 6:return[3,9];case 7:return u=h.sent(),c={error:u},[3,9];case 8:try{a&&!a.done&&(d=l.return)&&d.call(l)}finally{if(c)throw c.error}return[7];case 9:return i.finish().length>0||0===n?[4,i.toVector()]:[3,11];case 10:h.sent(),h.label=11;case 11:return[2]}}))}}(t)},t.throughAsyncIterable=function(t){return function(t){var e=t.queueingStrategy,n=void 0===e?"count":e,i=t.highWaterMark,r=void 0===i?"bytes"!==n?1e3:Math.pow(2,14):i,o="bytes"!==n?"length":"byteLength";return function(e){return zm(this,arguments,(function(){var n,i,l,a,s,u,c,d;return Um(this,(function(h){switch(h.label){case 0:n=0,i=VZ.new(t),h.label=1;case 1:h.trys.push([1,9,10,15]),l=jm(e),h.label=2;case 2:return[4,Tm(l.next())];case 3:return(a=h.sent()).done?[3,8]:(s=a.value,i.append(s)[o]>=r?++n?[4,Tm(i.toVector())]:[3,6]:[3,7]);case 4:return[4,h.sent()];case 5:h.sent(),h.label=6;case 6:h.label=7;case 7:return[3,2];case 8:return[3,15];case 9:return u=h.sent(),c={error:u},[3,15];case 10:return h.trys.push([10,,13,14]),a&&!a.done&&(d=l.return)?[4,Tm(d.call(l))]:[3,12];case 11:h.sent(),h.label=12;case 12:return[3,14];case 13:if(c)throw c.error;return[7];case 14:return[7];case 15:return i.finish().length>0||0===n?[4,Tm(i.toVector())]:[3,18];case 16:return[4,h.sent()];case 17:h.sent(),h.label=18;case 18:return[2]}}))}))}}(t)},t.prototype.toVector=function(){return $f.new(this.flush())},Object.defineProperty(t.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullCount",{get:function(){return this._nulls.numInvalid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numChildren",{get:function(){return this.children.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"byteLength",{get:function(){var t=0;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),this._typeIds&&(t+=this._typeIds.byteLength),this.children.reduce((function(t,e){return t+e.byteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedLength",{get:function(){return this._nulls.reservedLength},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reservedByteLength",{get:function(){var t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((function(t,e){return t+e.reservedByteLength}),t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueOffsets",{get:function(){return this._offsets?this._offsets.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"values",{get:function(){return this._values?this._values.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nullBitmap",{get:function(){return this._nulls?this._nulls.buffer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeIds",{get:function(){return this._typeIds?this._typeIds.buffer:null},enumerable:!1,configurable:!0}),t.prototype.append=function(t){return this.set(this.length,t)},t.prototype.isValid=function(t){return this._isValid(t)},t.prototype.set=function(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this},t.prototype.setValue=function(t,e){this._setValue(this,t,e)},t.prototype.setValid=function(t,e){return this.length=this._nulls.set(t,+e).length,e},t.prototype.addChild=function(t,e){throw void 0===e&&(e=""+this.numChildren),new Error('Cannot append children to non-nested type "'+this.type+'"')},t.prototype.getChildAt=function(t){return this.children[t]||null},t.prototype.flush=function(){var t=[],e=this._values,n=this._offsets,i=this._typeIds,r=this.length,o=this.nullCount;i?(t[ey.TYPE]=i.flush(r),n&&(t[ey.OFFSET]=n.flush(r))):n?(e&&(t[ey.DATA]=e.flush(n.last())),t[ey.OFFSET]=n.flush(r)):e&&(t[ey.DATA]=e.flush(r)),o>0&&(t[ey.VALIDITY]=this._nulls.flush(r));var l=bZ.new(this.type,0,r,o,t,this.children.map((function(t){return t.flush()})));return this.clear(),l},t.prototype.finish=function(){return this.finished=!0,this.children.forEach((function(t){return t.finish()})),this},t.prototype.clear=function(){return this.length=0,this._offsets&&this._offsets.clear(),this._values&&this._values.clear(),this._nulls&&this._nulls.clear(),this._typeIds&&this._typeIds.clear(),this.children.forEach((function(t){return t.clear()})),this},t}();VZ.prototype.length=1,VZ.prototype.stride=1,VZ.prototype.children=null,VZ.prototype.finished=!1,VZ.prototype.nullValues=null,VZ.prototype._isValid=function(){return!0};var vZ=function(t){function e(e){var n=t.call(this,e)||this;return n._values=new ZZ(new n.ArrayType(0),n.stride),n}return _m(e,t),e.prototype.setValue=function(e,n){var i=this._values;return i.reserve(e-i.length+1),t.prototype.setValue.call(this,e,n)},e}(VZ),SZ=function(t){function e(e){var n=t.call(this,e)||this;return n._pendingLength=0,n._offsets=new GZ,n}return _m(e,t),e.prototype.setValue=function(t,e){var n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e.length,n.set(t,e)},e.prototype.setValid=function(e,n){return!!t.prototype.setValid.call(this,e,n)||((this._pending||(this._pending=new Map)).set(e,void 0),!1)},e.prototype.clear=function(){return this._pendingLength=0,this._pending=void 0,t.prototype.clear.call(this)},e.prototype.flush=function(){return this._flush(),t.prototype.flush.call(this)},e.prototype.finish=function(){return this._flush(),t.prototype.finish.call(this)},e.prototype._flush=function(){var t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this},e}(VZ);var RZ=function(t){function e(e){var n=t.call(this,e)||this;return n._values=new XZ,n}return _m(e,t),e.prototype.setValue=function(t,e){this._values.set(t,+e)},e}(VZ),gZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.setValue=function(t,e){},e.prototype.setValid=function(t,e){return this.length=Math.max(t+1,this.length),e},e}(VZ),LZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(vZ),xZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(LZ),YZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(LZ),KZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(vZ),HZ=function(t){function e(e){var n=e.type,i=e.nullValues,r=e.dictionaryHashFunction,o=t.call(this,{type:new dZ(n.dictionary,n.indices,n.id,n.isOrdered)})||this;return o._nulls=null,o._dictionaryOffset=0,o._keysToIndices=Object.create(null),o.indices=VZ.new({type:o.type.indices,nullValues:i}),o.dictionary=VZ.new({type:o.type.dictionary,nullValues:null}),"function"==typeof r&&(o.valueToKey=r),o}return _m(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.indices.values},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){return this.indices.nullCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullBitmap",{get:function(){return this.indices.nullBitmap},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this.indices.byteLength+this.dictionary.byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reservedLength",{get:function(){return this.indices.reservedLength+this.dictionary.reservedLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reservedByteLength",{get:function(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength},enumerable:!1,configurable:!0}),e.prototype.isValid=function(t){return this.indices.isValid(t)},e.prototype.setValid=function(t,e){var n=this.indices;return e=n.setValid(t,e),this.length=n.length,e},e.prototype.setValue=function(t,e){var n=this._keysToIndices,i=this.valueToKey(e),r=n[i];return void 0===r&&(n[i]=r=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,r)},e.prototype.flush=function(){var t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i},e.prototype.finish=function(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),t.prototype.finish.call(this)},e.prototype.clear=function(){return this.indices.clear(),this.dictionary.clear(),t.prototype.clear.call(this)},e.prototype.valueToKey=function(t){return"string"==typeof t?t:""+t},e}(VZ),JZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(vZ),wZ=new Float64Array(1),_Z=new Uint32Array(wZ.buffer);function IZ(t){var e=(31744&t)>>10,n=(1023&t)/1024,i=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return i*(n?NaN:1/0);case 0:return i*(n?6103515625e-14*n:0)}return i*Math.pow(2,e-15)*(1+n)}function NZ(t){if(t!=t)return 32256;wZ[0]=t;var e=(2147483648&_Z[1])>>16&65535,n=2146435072&_Z[1],i=0;return n>=1089470464?_Z[0]>0?n=31744:(n=(2080374784&n)>>16,i=(1048575&_Z[1])>>10):n<=1056964608?(i=1048576+((i=1048576+(1048575&_Z[1]))<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,i=512+(1048575&_Z[1])>>10),e|n|65535&i}var CZ,UZ,FZ=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",uint16ToFloat64:IZ,float64ToUint16:NZ}),BZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(vZ),kZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.setValue=function(t,e){this._values.set(t,NZ(e))},e}(BZ),TZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.setValue=function(t,e){this._values.set(t,e)},e}(BZ),zZ=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.setValue=function(t,e){this._values.set(t,e)},e}(BZ),MZ=Symbol.for("isArrowBigNum");function jZ(t){for(var e,n=[],i=1;i>>=0),s+=(n>>>0)+e*Math.pow(u,32);return s}function OZ(t){var e="",n=new Uint32Array(2),i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),r=new Uint32Array((i=new Uint16Array(i).reverse()).buffer),o=-1,l=i.length-1;do{for(n[0]=i[o=0];o-1){var r;n.set(t,i),void 0!==(e=(r=this[YX]||(this[YX]=new Array(this.size)))[i])||(r[i]=e=this.getValue(i))}}return e},t.prototype.set=function(t,e){if(null!=t){var n=this[xX]||(this[xX]=new Map),i=n.get(t);if(void 0===i&&n.set(t,i=this.getIndex(t)),i>-1)(this[YX]||(this[YX]=new Array(this.size)))[i]=this.setValue(i,e)}return this},t.prototype.clear=function(){throw new Error("Clearing "+this[Symbol.toStringTag]+" not supported.")},t.prototype.delete=function(t){throw new Error("Deleting "+this[Symbol.toStringTag]+" values not supported.")},t.prototype[Symbol.iterator]=function(){var t,e,n,i,r,o,l,a,s;return Um(this,(function(u){switch(u.label){case 0:t=this.keys(),e=this.values(),n=this[xX]||(this[xX]=new Map),i=this[YX]||(this[YX]=new Array(this.size)),r=void 0,o=void 0,l=0,a=void 0,s=void 0,u.label=1;case 1:return(a=t.next()).done||(s=e.next()).done?[3,4]:(r=a.value,o=s.value,i[l]=o,n.has(r)||n.set(r,l),[4,[r,o]]);case 2:u.sent(),u.label=3;case 3:return++l,[3,1];case 4:return[2]}}))},t.prototype.forEach=function(t,e){for(var n=this.keys(),i=this.values(),r=void 0===e?t:function(n,i,r){return t.call(e,n,i,r)},o=this[xX]||(this[xX]=new Map),l=this[YX]||(this[YX]=new Array(this.size)),a=void 0,s=void 0,u=0,c=void 0,d=void 0;!(c=n.next()).done&&!(d=i.next()).done;++u)a=c.value,s=d.value,l[u]=s,o.has(a)||o.set(a,u),r(s,a,this)},t.prototype.toArray=function(){return km(this.values())},t.prototype.toJSON=function(){var t={};return this.forEach((function(e,n){return t[n]=e})),t},t.prototype.inspect=function(){return this.toString()},t.prototype[KX]=function(){return this.toString()},t.prototype.toString=function(){var t=[];return this.forEach((function(e,n){n=pZ(n),e=pZ(e),t.push(n+": "+e)})),"{ "+t.join(", ")+" }"},t[Symbol.toStringTag]=function(t){var e;return Object.defineProperties(t,((e={size:{writable:!0,enumerable:!1,configurable:!1,value:0}})[gX]={writable:!0,enumerable:!1,configurable:!1,value:null},e[LX]={writable:!0,enumerable:!1,configurable:!1,value:-1},e)),t[Symbol.toStringTag]="Row"}(t.prototype),t}(),JX=function(t){function e(e){var n=t.call(this,e,e.length)||this;return CX(n)}return _m(e,t),e.prototype.keys=function(){return this[gX].getChildAt(0)[Symbol.iterator]()},e.prototype.values=function(){return this[gX].getChildAt(1)[Symbol.iterator]()},e.prototype.getKey=function(t){return this[gX].getChildAt(0).get(t)},e.prototype.getIndex=function(t){return this[gX].getChildAt(0).indexOf(t)},e.prototype.getValue=function(t){return this[gX].getChildAt(1).get(t)},e.prototype.setValue=function(t,e){this[gX].getChildAt(1).set(t,e)},e}(HX),wX=function(t){function e(e){var n=t.call(this,e,e.type.children.length)||this;return NX(n)}return _m(e,t),e.prototype.keys=function(){var t,e,n,i,r;return Um(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Fm(this[gX].type.children),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[4,e.value.name];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.values=function(){var t,e,n,i,r;return Um(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Fm(this[gX].type.children),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[4,this[e.value.name]];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.getKey=function(t){return this[gX].type.children[t].name},e.prototype.getIndex=function(t){return this[gX].type.children.findIndex((function(e){return e.name===t}))},e.prototype.getValue=function(t){return this[gX].getChildAt(t).get(this[LX])},e.prototype.setValue=function(t,e){return this[gX].getChildAt(t).set(this[LX],e)},e}(HX);Object.setPrototypeOf(HX.prototype,Map.prototype);var _X,IX,NX=(_X={enumerable:!0,configurable:!1,get:null,set:null},function(t){var e,n,i=-1,r=t[xX]||(t[xX]=new Map),o=function(t){return function(){return this.get(t)}},l=function(t){return function(e){return this.set(t,e)}};try{for(var a=Fm(t.keys()),s=a.next();!s.done;s=a.next()){var u=s.value;r.set(u,++i),_X.get=o(u),_X.set=l(u),t.hasOwnProperty(u)||(_X.enumerable=!0,Object.defineProperty(t,u,_X)),t.hasOwnProperty(i)||(_X.enumerable=!1,Object.defineProperty(t,i,_X))}}catch(c){e={error:c}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return _X.get=_X.set=null,t}),CX=function(){if("undefined"==typeof Proxy)return NX;var t=HX.prototype.has,e=HX.prototype.get,n=HX.prototype.set,i=HX.prototype.getKey,r={isExtensible:function(){return!1},deleteProperty:function(){return!1},preventExtensions:function(){return!0},ownKeys:function(t){return km(t.keys()).map((function(t){return""+t}))},has:function(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 gX:case LX:case YX:case xX:case KX:return!0}return"number"!=typeof e||t.has(e)||(e=t.getKey(e)),t.has(e)},get:function(n,r,o){switch(r){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 gX:case LX:case YX:case xX:case KX:return Reflect.get(n,r,o)}return"number"!=typeof r||t.call(o,r)||(r=i.call(o,r)),e.call(o,r)},set:function(e,r,o,l){switch(r){case gX:case LX:case YX:case xX:return Reflect.set(e,r,o,l);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 r||t.call(l,r)||(r=i.call(l,r)),!!t.call(l,r)&&!!n.call(l,r,o)}};return function(t){return new Proxy(t,r)}}();function UX(t,e,n,i){var r=t.length,o=void 0===r?0:r,l="number"!=typeof e?0:e,a="number"!=typeof n?o:n;return l<0&&(l=(l%o+o)%o),a<0&&(a=(a%o+o)%o),ao&&(a=o),i?i(t,l,a):[l,a]}var FX=lf?of(0):0,BX=function(t){return t!=t};function kX(t){var e,n,i=typeof t;if("object"!==i||null===t)return BX(t)?BX:"bigint"!==i?function(e){return e===t}:function(e){return FX+e===t};if(t instanceof Date){var r=t.valueOf();return function(t){return t instanceof Date&&t.valueOf()===r}}return ArrayBuffer.isView(t)?function(e){return!!e&&Bf(t,e)}:t instanceof Map?(e=-1,n=[],t.forEach((function(t){return n[++e]=kX(t)})),TX(n)):Array.isArray(t)?function(t){for(var e=[],n=-1,i=t.length;++n-1?e:i+e%i;return n?n(t,r):r},clampRange:UX,createElementComparator:kX}),jX=function(t){function e(e,n,i){void 0===n&&(n=[]),void 0===i&&(i=function(t){for(var e=new Uint32Array((t||[]).length+1),n=e[0]=0,i=e.length,r=0;++r"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this._chunks[0]?this._chunks[0].data:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this._type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numChildren",{get:function(){return this._numChildren},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this._chunks[0]?this._chunks[0].stride:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this._chunks.reduce((function(t,e){return t+e.byteLength}),0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){var t=this._nullCount;return t<0&&(this._nullCount=t=this._chunks.reduce((function(t,e){return t+e.nullCount}),0)),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){if(wy.isDictionary(this._type)){if(!this._indices){var t=this._chunks;this._indices=1===t.length?t[0].indices:e.concat.apply(e,km(t.map((function(t){return t.indices}))))}return this._indices}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dictionary",{get:function(){return wy.isDictionary(this._type)?this._chunks[this._chunks.length-1].data.dictionary:null},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var t,e,n,i,r;return Um(this,(function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),t=Fm(this._chunks),e=t.next(),o.label=1;case 1:return e.done?[3,4]:[5,Fm(e.value)];case 2:o.sent(),o.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return n=o.sent(),i={error:n},[3,7];case 6:try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))},e.prototype.clone=function(t){return void 0===t&&(t=this._chunks),new e(this._type,t)},e.prototype.concat=function(){for(var t=[],n=0;n=this._numChildren)return null;var n,i,r,o=this._children||(this._children=[]);return(n=o[t])?n:(i=(this._type.children||[])[t])&&(r=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}))).length>0?o[t]=new e(i.type,r):null},e.prototype.search=function(t,e){var n=t,i=this._chunkOffsets,r=i.length-1;if(n<0)return null;if(n>=i[r])return null;if(r<=1)return e?e(this,0,n):[0,n];var o=0,l=0,a=0;do{if(o+1===r)return e?e(this,o,n-l):[o,n-l];n>=i[a=o+(r-o)/2|0]?o=a:r=a}while(n=(l=i[o]));return null},e.prototype.isValid=function(t){return!!this.search(t,this.isValidInternal)},e.prototype.get=function(t){return this.search(t,this.getInternal)},e.prototype.set=function(t,e){this.search(t,(function(t,n,i){return t.chunks[n].set(i,e)}))},e.prototype.indexOf=function(t,e){var n=this;return e&&"number"==typeof e?this.search(e,(function(e,i,r){return n.indexOfInternal(e,i,r,t)})):this.indexOfInternal(this,0,Math.max(0,e||0),t)},e.prototype.toArray=function(){var t=this.chunks,e=t.length,n=this._type.ArrayType;if(e<=0)return new n(0);if(e<=1)return t[0].toArray();for(var i=0,r=new Array(e),o=-1;++o=n)break;if(!(e>=c+u))if(c>=e&&c+u<=n)i.push(s);else{var d=Math.max(0,e-c),h=Math.min(n-c,u);i.push(s.slice(d,h))}}return t.clone(i)},e}($f);var QX=function(t,e,n){return e.set(t,n),n+t.length},PX=function(t,e,n){for(var i=n,r=-1,o=t.length;++r0}))&&(r=r.clone({nullable:!0}));return new e(r,a)},Object.defineProperty(e.prototype,"field",{get:function(){return this._field},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._field.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullable",{get:function(){return this._field.nullable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this._field.metadata},enumerable:!1,configurable:!0}),e.prototype.clone=function(t){return void 0===t&&(t=this._chunks),new e(this._field,t)},e.prototype.getChildAt=function(t){if(t<0||t>=this.numChildren)return null;var n,i,r,o=this._children||(this._children=[]);return(n=o[t])?n:(i=(this.type.children||[])[t])&&(r=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}))).length>0?o[t]=new e(i,r):null},e}(jX),DX=function(t){function e(e,n,i){var r=t.call(this,e,[n],i)||this;return r._chunk=n,r}return _m(e,t),e.prototype.search=function(t,e){return e?e(this,0,t):[0,t]},e.prototype.isValid=function(t){return this._chunk.isValid(t)},e.prototype.get=function(t){return this._chunk.get(t)},e.prototype.set=function(t,e){this._chunk.set(t,e)},e.prototype.indexOf=function(t,e){return this._chunk.indexOf(t,e)},e}(EX),OX=Array.isArray,AX=function(t,e){return iG(t,e,[],0)},qX=function(t){var e=Bm(sG(t,[[],[]]),2),n=e[0];return e[1].map((function(t,e){return t instanceof EX?EX.new(t.field.clone(n[e]),t):t instanceof $f?EX.new(n[e],t):EX.new(n[e],[])}))},$X=function(t){return sG(t,[[],[]])},tG=function(t,e){return rG(t,e,[],0)},eG=function(t,e){return oG(t,e,[],0)},nG=function(t,e){return lG(t,e,[],0)};function iG(t,e,n,i){for(var r,o=i,l=-1,a=e.length;++l"},t.prototype.compareTo=function(t){return Jy.compareSchemas(this,t)},t.prototype.select=function(){for(var e=[],n=0;n0&&hG(r.children,e)}return e}uG.prototype.fields=null,uG.prototype.metadata=null,uG.prototype.dictionaries=null,cG.prototype.type=null,cG.prototype.name=null,cG.prototype.nullable=null,cG.prototype.metadata=null;var bG=function(t){function e(e){var n=t.call(this,e)||this;return n._run=new RX,n._offsets=new GZ,n}return _m(e,t),e.prototype.addChild=function(t,e){if(void 0===e&&(e="0"),this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new rZ(new cG(e,t.type,!0)),this.numChildren-1},e.prototype.clear=function(){return this._run.clear(),t.prototype.clear.call(this)},e.prototype._flushPending=function(t){var e,n,i,r,o=this._run,l=this._offsets,a=this._setValue,s=0;try{for(var u=Fm(t),c=u.next();!c.done;c=u.next())s=(i=Bm(c.value,2))[0],void 0===(r=i[1])?l.set(s,0):(l.set(s,r.length),a(this,s,o.bind(r)))}catch(d){e={error:d}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e}(SZ),pG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._run=new RX,e}return _m(e,t),e.prototype.setValue=function(e,n){t.prototype.setValue.call(this,e,this._run.bind(n))},e.prototype.addChild=function(t,e){if(void 0===e&&(e="0"),this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");var n=this.children.push(t);return this.type=new sZ(this.type.listSize,new cG(e,t.type,!0)),n},e.prototype.clear=function(){return this._run.clear(),t.prototype.clear.call(this)},e}(VZ),mG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.set=function(e,n){return t.prototype.set.call(this,e,n)},e.prototype.setValue=function(t,e){e=e instanceof Map?e:new Map(Object.entries(e));var n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.size),this._pendingLength+=e.size,n.set(t,e)},e.prototype.addChild=function(t,e){if(void 0===e&&(e=""+this.numChildren),this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new uZ(new cG(e,t.type,!0),this.type.keysSorted),this.numChildren-1},e.prototype._flushPending=function(t){var e=this,n=this._offsets,i=this._setValue;t.forEach((function(t,r){void 0===t?n.set(r,0):(n.set(r,t.size),i(e,r,t))}))},e}(SZ),fG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.addChild=function(t,e){void 0===e&&(e=""+this.numChildren);var n=this.children.push(t);return this.type=new oZ(km(this.type.children,[new cG(e,t.type,!0)])),n},e}(VZ),yG=function(t){function e(e){var n=t.call(this,e)||this;return n._typeIds=new ZZ(new Int8Array(0),1),"function"==typeof e.valueToChildTypeId&&(n._valueToChildTypeId=e.valueToChildTypeId),n}return _m(e,t),Object.defineProperty(e.prototype,"typeIdToChildIndex",{get:function(){return this.type.typeIdToChildIndex},enumerable:!1,configurable:!0}),e.prototype.append=function(t,e){return this.set(this.length,t,e)},e.prototype.set=function(t,e,n){return void 0===n&&(n=this._valueToChildTypeId(this,e,t)),this.setValid(t,this.isValid(e))&&this.setValue(t,e,n),this},e.prototype.setValue=function(e,n,i){this._typeIds.set(e,i),t.prototype.setValue.call(this,e,n)},e.prototype.addChild=function(t,e){void 0===e&&(e=""+this.children.length);var n=this.children.push(t),i=this.type,r=i.children,o=i.mode,l=i.typeIds,a=km(r,[new cG(e,t.type)]);return this.type=new lZ(o,km(l,[n]),a),n},e.prototype._valueToChildTypeId=function(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")},e}(VZ),ZG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(yG),XG=function(t){function e(e){var n=t.call(this,e)||this;return n._offsets=new ZZ(new Int32Array(0)),n}return _m(e,t),e.prototype.setValue=function(e,n,i){var r=this.type.typeIdToChildIndex[i];return this._offsets.set(e,this.getChildAt(r).length),t.prototype.setValue.call(this,e,n,i)},e}(yG),GG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(Gy),WG=function(t,e,n){t[e]=n%4294967296|0,t[e+1]=n/4294967296|0},VG=function(t,e,n,i){var r=e,o=r[n],l=r[n+1];null!=o&&null!=l&&t.set(i.subarray(0,l-o),o)},vG=function(t,e,n){!function(t,e,n){t[e]=n/864e5|0}(t.values,e,n.valueOf())},SG=function(t,e,n){var i=t.values;WG(i,2*e,n.valueOf())},RG=function(t,e,n){var i=t.stride;t.values[i*e]=n},gG=function(t,e,n){var i=t.stride;t.values[i*e]=NZ(n)},LG=function(t,e,n){switch(typeof n){case"bigint":t.values64[e]=n;break;case"number":t.values[e*t.stride]=n;break;default:var i=n,r=t.stride,o=Yf(t.ArrayType,i);t.values.set(o.subarray(0,r),r*e)}},xG=function(t,e,n){var i=t.values;return WG(i,2*e,n/1e3)},YG=function(t,e,n){var i=t.values;return WG(i,2*e,n)},KG=function(t,e,n){return function(t,e,n){t[e]=1e3*n%4294967296|0,t[e+1]=1e3*n/4294967296|0}(t.values,2*e,n)},HG=function(t,e,n){return function(t,e,n){t[e]=1e6*n%4294967296|0,t[e+1]=1e6*n/4294967296|0}(t.values,2*e,n)},JG=function(t,e,n){t.values[t.stride*e]=n},wG=function(t,e,n){t.values[t.stride*e]=n},_G=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},IG=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},NG=function(t,e,n){var i=t.typeIdToChildIndex[t.typeIds[e]],r=t.getChildAt(i);r&&r.set(t.valueOffsets[e],n)},CG=function(t,e,n){var i=t.typeIdToChildIndex[t.typeIds[e]],r=t.getChildAt(i);r&&r.set(e,n)},UG=function(t,e,n){t.values.set(n.subarray(0,2),2*e)},FG=function(t,e,n){t.values[e]=12*n[0]+n[1]%12};GG.prototype.visitBool=function(t,e,n){var i=t.offset,r=t.values,o=i+e;n?r[o>>3]|=1<>3]&=~(1<0){var r=e.children||[],o={nullValues:e.nullValues},l=Array.isArray(r)?function(t,e){return r[e]||o}:function(t){var e=t.name;return r[e]||o};n.children.forEach((function(e,n){var r=e.type,o=l(e,n);i.children.push(t(Im(Im({},o),{type:r})))}))}return i},Object.keys(ty).map((function(t){return ty[t]})).filter((function(t){return"number"==typeof t&&t!==ty.NONE})).forEach((function(t){TG.visit(t).prototype._setValue=kG.getVisitFn(t)})),SX.prototype._setValue=kG.visitBinary,function(t){!function(e){!function(e){!function(e){var n=function(){function e(){this.bb=null,this.bb_pos=0}return e.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.getRootAsFooter=function(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)},e.prototype.version=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Pf.apache.arrow.flatbuf.MetadataVersion.V1},e.prototype.schema=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new Pf.apache.arrow.flatbuf.Schema).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},e.prototype.dictionaries=function(e,n){var i=this.bb.__offset(this.bb_pos,8);return i?(n||new t.apache.arrow.flatbuf.Block).__init(this.bb.__vector(this.bb_pos+i)+24*e,this.bb):null},e.prototype.dictionariesLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},e.prototype.recordBatches=function(e,n){var i=this.bb.__offset(this.bb_pos,10);return i?(n||new t.apache.arrow.flatbuf.Block).__init(this.bb.__vector(this.bb_pos+i)+24*e,this.bb):null},e.prototype.recordBatchesLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},e.startFooter=function(t){t.startObject(4)},e.addVersion=function(t,e){t.addFieldInt16(0,e,Pf.apache.arrow.flatbuf.MetadataVersion.V1)},e.addSchema=function(t,e){t.addFieldOffset(1,e,0)},e.addDictionaries=function(t,e){t.addFieldOffset(2,e,0)},e.startDictionariesVector=function(t,e){t.startVector(24,e,8)},e.addRecordBatches=function(t,e){t.addFieldOffset(3,e,0)},e.startRecordBatchesVector=function(t,e){t.startVector(24,e,8)},e.endFooter=function(t){return t.endObject()},e.finishFooterBuffer=function(t,e){t.finish(e)},e.createFooter=function(t,n,i,r,o){return e.startFooter(t),e.addVersion(t,n),e.addSchema(t,i),e.addDictionaries(t,r),e.addRecordBatches(t,o),e.endFooter(t)},e}();e.Footer=n}(e.flatbuf||(e.flatbuf={}))}(e.arrow||(e.arrow={}))}(t.apache||(t.apache={}))}(BG||(BG={})),function(t){!function(t){!function(t){!function(t){var e=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.offset=function(){return this.bb.readInt64(this.bb_pos)},t.prototype.metaDataLength=function(){return this.bb.readInt32(this.bb_pos+8)},t.prototype.bodyLength=function(){return this.bb.readInt64(this.bb_pos+16)},t.createBlock=function(t,e,n,i){return t.prep(8,24),t.writeInt64(i),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()},t}();t.Block=e}(t.flatbuf||(t.flatbuf={}))}(t.arrow||(t.arrow={}))}(t.apache||(t.apache={}))}(BG||(BG={}));var zG=Qm.Long,MG=Qm.Builder,jG=Qm.ByteBuffer,QG=BG.apache.arrow.flatbuf.Block,PG=BG.apache.arrow.flatbuf.Footer,EG=function(){function t(t,e,n,i){void 0===e&&(e=uy.V4),this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}return t.decode=function(t){t=new jG(Jf(t));var e=PG.getRootAsFooter(t),n=uG.decode(e.schema());return new DG(n,e)},t.encode=function(t){var e=new MG,n=uG.encode(e,t.schema);PG.startRecordBatchesVector(e,t.numRecordBatches),km(t.recordBatches()).slice().reverse().forEach((function(t){return OG.encode(e,t)}));var i=e.endVector();PG.startDictionariesVector(e,t.numDictionaries),km(t.dictionaryBatches()).slice().reverse().forEach((function(t){return OG.encode(e,t)}));var r=e.endVector();return PG.startFooter(e),PG.addSchema(e,n),PG.addVersion(e,uy.V4),PG.addRecordBatches(e,i),PG.addDictionaries(e,r),PG.finishFooterBuffer(e,PG.endFooter(e)),e.asUint8Array()},Object.defineProperty(t.prototype,"numRecordBatches",{get:function(){return this._recordBatches.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numDictionaries",{get:function(){return this._dictionaryBatches.length},enumerable:!1,configurable:!0}),t.prototype.recordBatches=function(){var t,e,n;return Um(this,(function(i){switch(i.label){case 0:t=void 0,e=-1,n=this.numRecordBatches,i.label=1;case 1:return++e=0&&t=0&&t=0&&t=0&&t0)return t.prototype.write.call(this,e)},e.prototype.toString=function(t){return void 0===t&&(t=!1),t?Am(this.toUint8Array(!0)):this.toUint8Array(!1).then(Am)},e.prototype.toUint8Array=function(t){var e=this;return void 0===t&&(t=!1),t?xf(this._values)[0]:Cm(e,void 0,void 0,(function(){var t,e,n,i,r,o,l,a;return Um(this,(function(s){switch(s.label){case 0:t=[],e=0,s.label=1;case 1:s.trys.push([1,6,7,12]),n=jm(this),s.label=2;case 2:return[4,n.next()];case 3:if((i=s.sent()).done)return[3,5];r=i.value,t.push(r),e+=r.byteLength,s.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return o=s.sent(),l={error:o},[3,12];case 7:return s.trys.push([7,,10,11]),i&&!i.done&&(a=n.return)?[4,a.call(n)]:[3,9];case 8:s.sent(),s.label=9;case 9:return[3,11];case 10:if(l)throw l.error;return[7];case 11:return[7];case 12:return[2,xf(t,e)[0]]}}))}))},e}(nf),qG=function(){function t(t){t&&(this.source=new tW(Tf.fromIterable(t)))}return t.prototype[Symbol.iterator]=function(){return this},t.prototype.next=function(t){return this.source.next(t)},t.prototype.throw=function(t){return this.source.throw(t)},t.prototype.return=function(t){return this.source.return(t)},t.prototype.peek=function(t){return this.source.peek(t)},t.prototype.read=function(t){return this.source.read(t)},t}(),$G=function(){function t(e){e instanceof t?this.source=e.source:e instanceof AG?this.source=new eW(Tf.fromAsyncIterable(e)):Sf(e)?this.source=new eW(Tf.fromNodeStream(e)):vf(e)?this.source=new eW(Tf.fromDOMStream(e)):Vf(e)?this.source=new eW(Tf.fromDOMStream(e.body)):yf(e)?this.source=new eW(Tf.fromIterable(e)):(ff(e)||Zf(e))&&(this.source=new eW(Tf.fromAsyncIterable(e)))}return t.prototype[Symbol.asyncIterator]=function(){return this},t.prototype.next=function(t){return this.source.next(t)},t.prototype.throw=function(t){return this.source.throw(t)},t.prototype.return=function(t){return this.source.return(t)},Object.defineProperty(t.prototype,"closed",{get:function(){return this.source.closed},enumerable:!1,configurable:!0}),t.prototype.cancel=function(t){return this.source.cancel(t)},t.prototype.peek=function(t){return this.source.peek(t)},t.prototype.read=function(t){return this.source.read(t)},t}(),tW=function(){function t(t){this.source=t}return t.prototype.cancel=function(t){this.return(t)},t.prototype.peek=function(t){return this.next(t,"peek").value},t.prototype.read=function(t){return this.next(t,"read").value},t.prototype.next=function(t,e){return void 0===e&&(e="read"),this.source.next({cmd:e,size:t})},t.prototype.throw=function(t){return Object.create(this.source.throw&&this.source.throw(t)||$m)},t.prototype.return=function(t){return Object.create(this.source.return&&this.source.return(t)||$m)},t}(),eW=function(){function t(t){var e=this;this.source=t,this._closedPromise=new Promise((function(t){return e._closedPromiseResolve=t}))}return t.prototype.cancel=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.return(t)];case 1:return e.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"closed",{get:function(){return this._closedPromise},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"read")];case 1:return[2,e.sent().value]}}))}))},t.prototype.peek=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this.next(t,"peek")];case 1:return[2,e.sent().value]}}))}))},t.prototype.next=function(t,e){return void 0===e&&(e="read"),Cm(this,void 0,void 0,(function(){return Um(this,(function(n){switch(n.label){case 0:return[4,this.source.next({cmd:e,size:t})];case 1:return[2,n.sent()]}}))}))},t.prototype.throw=function(t){return Cm(this,void 0,void 0,(function(){var e,n;return Um(this,(function(i){switch(i.label){case 0:return(n=this.source.throw)?[4,this.source.throw(t)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return e=n||$m,this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,[2,Object.create(e)]}}))}))},t.prototype.return=function(t){return Cm(this,void 0,void 0,(function(){var e,n;return Um(this,(function(i){switch(i.label){case 0:return(n=this.source.return)?[4,this.source.return(t)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return e=n||$m,this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,[2,Object.create(e)]}}))}))},t}(),nW=function(t){function e(e,n){var i=t.call(this)||this;return i.position=0,i.buffer=Jf(e),i.size=void 0===n?i.buffer.byteLength:n,i}return _m(e,t),e.prototype.readInt32=function(t){var e=this.readAt(t,4),n=e.buffer,i=e.byteOffset;return new DataView(n,i).getInt32(0,!0)},e.prototype.seek=function(t){return 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]]),i=e[3]*n[3];this.buffer[0]=65535&i;var r=i>>>16;return r+=i=e[2]*n[3],r+=i=e[3]*n[2]>>>0,this.buffer[0]+=r<<16,this.buffer[1]=r>>>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},t.prototype._plus=function(t){var e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e},t.prototype.lessThan=function(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},t.prototype.hex=function(){return rW(this.buffer[3])+" "+rW(this.buffer[2])+" "+rW(this.buffer[1])+" "+rW(this.buffer[0])},t.multiply=function(e,n){return new t(new Uint32Array(e.buffer)).times(n)},t.add=function(e,n){return new t(new Uint32Array(e.buffer)).plus(n)},t.from=function(e,n){return void 0===n&&(n=new Uint32Array(4)),t.fromString("string"==typeof e?e:e.toString(),n)},t.fromNumber=function(e,n){return void 0===n&&(n=new Uint32Array(4)),t.fromString(e.toString(),n)},t.fromString=function(e,n){void 0===n&&(n=new Uint32Array(4));for(var i=e.startsWith("-"),r=e.length,o=new t(n),l=i?1:0;l0&&this.readData(t,n)||new Uint8Array(0)},e.prototype.readOffsets=function(t,e){return this.readData(t,e)},e.prototype.readTypeIds=function(t,e){return this.readData(t,e)},e.prototype.readData=function(t,e){var n=void 0===e?this.nextBufferRange():e,i=n.length,r=n.offset;return this.bytes.subarray(r,r+i)},e.prototype.readDictionary=function(t){return this.dictionaries.get(t.id)},e}(Gy),hW=function(t){function e(e,n,i,r){var o=t.call(this,new Uint8Array(0),n,i,r)||this;return o.sources=e,o}return _m(e,t),e.prototype.readNullBitmap=function(t,e,n){var i=(void 0===n?this.nextBufferRange():n).offset;return e<=0?new Uint8Array(0):py(this.sources[i])},e.prototype.readOffsets=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset;return Yf(Uint8Array,Yf(Int32Array,this.sources[n]))},e.prototype.readTypeIds=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset;return Yf(Uint8Array,Yf(t.ArrayType,this.sources[n]))},e.prototype.readData=function(t,e){var n=(void 0===e?this.nextBufferRange():e).offset,i=this.sources;return wy.isTimestamp(t)||(wy.isInt(t)||wy.isTime(t))&&64===t.bitWidth||wy.isDate(t)&&t.unit===iy.MILLISECOND?Yf(Uint8Array,sW.convertArray(i[n])):wy.isDecimal(t)?Yf(Uint8Array,uW.convertArray(i[n])):wy.isBinary(t)||wy.isFixedSizeBinary(t)?function(t){for(var e=t.join(""),n=new Uint8Array(e.length/2),i=0;i>1]=parseInt(e.substr(i,2),16);return n}(i[n]):wy.isBool(t)?py(i[n]):wy.isUtf8(t)?qm(i[n].join("")):Yf(Uint8Array,Yf(t.ArrayType,i[n].map((function(t){return+t}))))},e}(dW);var bW=Qm.Long,pW=Pf.apache.arrow.flatbuf.Null,mW=Pf.apache.arrow.flatbuf.Int,fW=Pf.apache.arrow.flatbuf.FloatingPoint,yW=Pf.apache.arrow.flatbuf.Binary,ZW=Pf.apache.arrow.flatbuf.Bool,XW=Pf.apache.arrow.flatbuf.Utf8,GW=Pf.apache.arrow.flatbuf.Decimal,WW=Pf.apache.arrow.flatbuf.Date,VW=Pf.apache.arrow.flatbuf.Time,vW=Pf.apache.arrow.flatbuf.Timestamp,SW=Pf.apache.arrow.flatbuf.Interval,RW=Pf.apache.arrow.flatbuf.List,gW=Pf.apache.arrow.flatbuf.Struct_,LW=Pf.apache.arrow.flatbuf.Union,xW=Pf.apache.arrow.flatbuf.DictionaryEncoding,YW=Pf.apache.arrow.flatbuf.FixedSizeBinary,KW=Pf.apache.arrow.flatbuf.FixedSizeList,HW=Pf.apache.arrow.flatbuf.Map,JW=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.visit=function(e,n){return null==e||null==n?void 0:t.prototype.visit.call(this,e,n)},e.prototype.visitNull=function(t,e){return pW.startNull(e),pW.endNull(e)},e.prototype.visitInt=function(t,e){return mW.startInt(e),mW.addBitWidth(e,t.bitWidth),mW.addIsSigned(e,t.isSigned),mW.endInt(e)},e.prototype.visitFloat=function(t,e){return fW.startFloatingPoint(e),fW.addPrecision(e,t.precision),fW.endFloatingPoint(e)},e.prototype.visitBinary=function(t,e){return yW.startBinary(e),yW.endBinary(e)},e.prototype.visitBool=function(t,e){return ZW.startBool(e),ZW.endBool(e)},e.prototype.visitUtf8=function(t,e){return XW.startUtf8(e),XW.endUtf8(e)},e.prototype.visitDecimal=function(t,e){return GW.startDecimal(e),GW.addScale(e,t.scale),GW.addPrecision(e,t.precision),GW.endDecimal(e)},e.prototype.visitDate=function(t,e){return WW.startDate(e),WW.addUnit(e,t.unit),WW.endDate(e)},e.prototype.visitTime=function(t,e){return VW.startTime(e),VW.addUnit(e,t.unit),VW.addBitWidth(e,t.bitWidth),VW.endTime(e)},e.prototype.visitTimestamp=function(t,e){var n=t.timezone&&e.createString(t.timezone)||void 0;return vW.startTimestamp(e),vW.addUnit(e,t.unit),void 0!==n&&vW.addTimezone(e,n),vW.endTimestamp(e)},e.prototype.visitInterval=function(t,e){return SW.startInterval(e),SW.addUnit(e,t.unit),SW.endInterval(e)},e.prototype.visitList=function(t,e){return RW.startList(e),RW.endList(e)},e.prototype.visitStruct=function(t,e){return gW.startStruct_(e),gW.endStruct_(e)},e.prototype.visitUnion=function(t,e){LW.startTypeIdsVector(e,t.typeIds.length);var n=LW.createTypeIdsVector(e,t.typeIds);return LW.startUnion(e),LW.addMode(e,t.mode),LW.addTypeIds(e,n),LW.endUnion(e)},e.prototype.visitDictionary=function(t,e){var n=this.visit(t.indices,e);return xW.startDictionaryEncoding(e),xW.addId(e,new bW(t.id,0)),xW.addIsOrdered(e,t.isOrdered),void 0!==n&&xW.addIndexType(e,n),xW.endDictionaryEncoding(e)},e.prototype.visitFixedSizeBinary=function(t,e){return YW.startFixedSizeBinary(e),YW.addByteWidth(e,t.byteWidth),YW.endFixedSizeBinary(e)},e.prototype.visitFixedSizeList=function(t,e){return KW.startFixedSizeList(e),KW.addListSize(e,t.listSize),KW.endFixedSizeList(e)},e.prototype.visitMap=function(t,e){return HW.startMap(e),HW.addKeysSorted(e,t.keysSorted),HW.endMap(e)},e}(Gy));function wW(t){return new tV(t.count,IW(t.columns),NW(t.columns))}function _W(t,e){return(t.children||[]).filter(Boolean).map((function(t){return cG.fromJSON(t,e)}))}function IW(t){return(t||[]).reduce((function(t,e){return km(t,[new iV(e.count,(n=e.VALIDITY,(n||[]).reduce((function(t,e){return t+ +(0===e)}),0)))],IW(e.children));var n}),[])}function NW(t,e){void 0===e&&(e=[]);for(var n=-1,i=(t||[]).length;++n0?MW.createCustomMetadataVector(t,km(e.metadata).map((function(e){var n=Bm(e,2),i=n[0],r=n[1],o=t.createString(""+i),l=t.createString(""+r);return EW.startKeyValue(t),EW.addKey(t,o),EW.addValue(t,l),EW.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));MW.startField(t),MW.addType(t,i),MW.addTypeType(t,l),MW.addChildren(t,s),MW.addNullable(t,!!e.nullable),-1!==n&&MW.addName(t,n);-1!==r&&MW.addDictionary(t,r);-1!==u&&MW.addCustomMetadata(t,u);return MW.endField(t)},cG.decode=function(t,e){var n,i,r,o,l,a;e&&(a=t.dictionary())?e.has(n=a.id().low)?(o=(o=a.indexType())?lV(o):new Uy,l=new dZ(e.get(n),o,n,a.isOrdered()),i=new cG(t.name(),l,t.nullable(),oV(t))):(o=(o=a.indexType())?lV(o):new Uy,e.set(n,r=aV(t,rV(t,e))),l=new dZ(r,o,n,a.isOrdered()),i=new cG(t.name(),l,t.nullable(),oV(t))):(r=aV(t,rV(t,e)),i=new cG(t.name(),r,t.nullable(),oV(t)));return i||null},cG.fromJSON=function(t,e){var n,i,r,o,l,a;return e&&(o=t.dictionary)?e.has(n=o.id)?(i=(i=o.indexType)?UW(i):new Uy,a=new dZ(e.get(n),i,n,o.isOrdered),r=new cG(t.name,a,t.nullable,CW(t.customMetadata))):(i=(i=o.indexType)?UW(i):new Uy,e.set(n,l=FW(t,_W(t,e))),a=new dZ(l,i,n,o.isOrdered),r=new cG(t.name,a,t.nullable,CW(t.customMetadata))):(l=FW(t,_W(t,e)),r=new cG(t.name,l,t.nullable,CW(t.customMetadata))),r||null},uG.encode=function(t,e){var n=e.fields.map((function(e){return cG.encode(t,e)}));jW.startFieldsVector(t,n.length);var i=jW.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?jW.createCustomMetadataVector(t,km(e.metadata).map((function(e){var n=Bm(e,2),i=n[0],r=n[1],o=t.createString(""+i),l=t.createString(""+r);return EW.startKeyValue(t),EW.addKey(t,o),EW.addValue(t,l),EW.endKeyValue(t)}))):-1;jW.startSchema(t),jW.addFields(t,i),jW.addEndianness(t,uV?OW.Little:OW.Big),-1!==r&&jW.addCustomMetadata(t,r);return jW.endSchema(t)},uG.decode=function(t,e){void 0===e&&(e=new Map);var n=function(t,e){for(var n=[],i=void 0,r=-1,o=-1,l=t.fieldsLength();++r2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");wy.isNull(e.type)||LV.call(this,r<=0?new Uint8Array(0):by(n.offset,i,n.nullBitmap)),this.nodes.push(new iV(i,r))}return t.prototype.visit.call(this,e)},e.prototype.visitNull=function(t){return this},e.prototype.visitDictionary=function(t){return this.visit(t.indices)},Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffers",{get:function(){return this._buffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this._byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferRegions",{get:function(){return this._bufferRegions},enumerable:!1,configurable:!0}),e}(Gy);function LV(t){var e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new nV(this._byteLength,e)),this._byteLength+=e,this}function xV(t){return LV.call(this,t.values.subarray(0,t.length*t.stride))}function YV(t){var e=t.length,n=t.values,i=t.valueOffsets,r=i[0],o=i[e],l=Math.min(o-r,n.byteLength-r);return LV.call(this,Ff(-i[0],e,i)),LV.call(this,n.subarray(r,r+l)),this}function KV(t){var e=t.length,n=t.valueOffsets;return n&&LV.call(this,Ff(n[0],e,n)),this.visit(t.getChildAt(0))}function HV(t){return this.visitMany(t.type.children.map((function(e,n){return t.getChildAt(n)})).filter(Boolean))[0]}gV.prototype.visitBool=function(t){var e;return t.nullCount>=t.length?LV.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?LV.call(this,by(t.offset,t.length,e)):LV.call(this,py(t))},gV.prototype.visitInt=xV,gV.prototype.visitFloat=xV,gV.prototype.visitUtf8=YV,gV.prototype.visitBinary=YV,gV.prototype.visitFixedSizeBinary=xV,gV.prototype.visitDate=xV,gV.prototype.visitTimestamp=xV,gV.prototype.visitTime=xV,gV.prototype.visitDecimal=xV,gV.prototype.visitList=KV,gV.prototype.visitStruct=HV,gV.prototype.visitUnion=function(t){var e=t.type,n=t.length,i=t.typeIds,r=t.valueOffsets;if(LV.call(this,i),e.mode===ly.Sparse)return HV.call(this,t);if(e.mode===ly.Dense){if(t.offset<=0)return LV.call(this,r),HV.call(this,t);for(var o=i.reduce((function(t,e){return Math.max(t,e)}),i[0]),l=new Int32Array(o+1),a=new Int32Array(o+1).fill(-1),s=new Int32Array(n),u=Ff(-r[0],n,r),c=void 0,d=void 0,h=-1;++h0&&this._write(i),this._writePadding(a)},e.prototype._write=function(t){if(this._started){var e=Jf(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this},e.prototype._writeSchema=function(t){return this._writeMessage($W.from(t))},e.prototype._writeFooter=function(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))},e.prototype._writeMagic=function(){return this._write(GV)},e.prototype._writePadding=function(t){return t>0?this._write(new Uint8Array(t)):this},e.prototype._writeRecordBatch=function(t){var e=gV.assemble(t),n=e.byteLength,i=e.nodes,r=e.bufferRegions,o=e.buffers,l=new tV(t.length,i,r),a=$W.from(l,n);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(o)},e.prototype._writeDictionaryBatch=function(t,e,n){void 0===n&&(n=!1),this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));var i=gV.assemble(t),r=i.byteLength,o=i.nodes,l=i.bufferRegions,a=i.buffers,s=new tV(t.length,o,l),u=new eV(s,e,n),c=$W.from(u,r);return this._writeMessage(c)._writeBodyBuffers(a)},e.prototype._writeBodyBuffers=function(t){for(var e,n,i,r=-1,o=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this},e.prototype._writeDictionaries=function(t){var e,n,i,r;try{for(var o=Fm(t.dictionaries),l=o.next();!l.done;l=o.next()){var a=Bm(l.value,2),s=a[0],u=a[1],c=this._dictionaryDeltaOffsets.get(s)||0;if(0===c||(u=u.slice(c)).length>0){var d="chunks"in u?u.chunks:[u];try{for(var h=(i=void 0,Fm(d)),b=h.next();!b.done;b=h.next()){var p=b.value;this._writeDictionaryBatch(p,s,c>0),c+=p.length}}catch(m){i={error:m}}finally{try{b&&!b.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}}}}catch(f){e={error:f}}finally{try{l&&!l.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this},e}(ef),CV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.writeAll=function(t,n){var i=new e(n);return ff(t)?t.then((function(t){return i.writeAll(t)})):Zf(t)?BV(i,t):FV(i,t)},e}(NV),UV=function(t){function e(){var e=t.call(this)||this;return e._autoDestroy=!0,e}return _m(e,t),e.writeAll=function(t){var n=new e;return ff(t)?t.then((function(t){return n.writeAll(t)})):Zf(t)?BV(n,t):FV(n,t)},e.prototype._writeSchema=function(t){return this._writeMagic()._writePadding(2)},e.prototype._writeFooter=function(e){var n=EG.encode(new EG(e,uy.V4,this._recordBatchBlocks,this._dictionaryBlocks));return t.prototype._writeFooter.call(this,e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()},e}(NV);function FV(t,e){var n,i,r=e;e instanceof KS&&(r=e.chunks,t.reset(void 0,e.schema));try{for(var o=Fm(r),l=o.next();!l.done;l=o.next()){var a=l.value;t.write(a)}}catch(s){n={error:s}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return t.finish()}function BV(t,e){var n,i,r,o;return Cm(this,void 0,void 0,(function(){var l,a;return Um(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),n=jm(e),s.label=1;case 1:return[4,n.next()];case 2:if((i=s.sent()).done)return[3,4];l=i.value,t.write(l),s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=s.sent(),r={error:a},[3,11];case 6:return s.trys.push([6,,9,10]),i&&!i.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return[2,t.finish()]}}))}))}function kV(t){var e=t.name,n=t.type,i=t.nullable,r=new JV;return{name:e,nullable:i,type:r.visit(n),children:(n.children||[]).map(kV),dictionary:wy.isDictionary(n)?{id:n.id,isOrdered:n.isOrdered,indexType:r.visit(n.indices)}:void 0}}!function(t){function e(){var e=t.call(this)||this;return e._autoDestroy=!0,e._recordBatches=[],e._dictionaries=[],e}_m(e,t),e.writeAll=function(t){return(new e).writeAll(t)},e.prototype._writeMessage=function(){return this},e.prototype._writeFooter=function(t){return this},e.prototype._writeSchema=function(t){return this._write('{\n "schema": '+JSON.stringify({fields:t.fields.map(kV)},null,2))},e.prototype._writeDictionaries=function(t){return t.dictionaries.size>0&&this._dictionaries.push(t),this},e.prototype._writeDictionaryBatch=function(t,e,n){return void 0===n&&(n=!1),this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0)),this._write(0===this._dictionaryBlocks.length?" ":",\n "),this._write(""+function(t,e,n){void 0===n&&(n=!1);var i=new cG(""+e,t.type,t.nullCount>0),r=wV.assemble(new EX(i,[t]));return JSON.stringify({id:e,isDelta:n,data:{count:t.length,columns:r}},null,2)}(t,e,n)),this._dictionaryBlocks.push(new OG(0,0,0)),this},e.prototype._writeRecordBatch=function(t){return this._writeDictionaries(t),this._recordBatches.push(t),this},e.prototype.close=function(){var e,n,i;if(this._dictionaries.length>0){this._write(',\n "dictionaries": [\n');try{for(var r=Fm(this._dictionaries),o=r.next();!o.done;o=r.next()){var l=o.value;t.prototype._writeDictionaries.call(this,l)}}catch(u){e={error:u}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this._write("\n ]")}if(this._recordBatches.length>0){for(var a=-1,s=this._recordBatches.length;++a>3;++o0;){for(a=Number.POSITIVE_INFINITY,s=-1;++s0&&(r[l++]=[a,c.slice()]))}return[t=new uG(i,t.metadata),r.map((function(e){return new(HS.bind.apply(HS,km([void 0,t],e)))}))]}(t,e.map((function(t){return t instanceof jX?t.chunks.map((function(t){return t.data})):[t.data]})))}function PV(t,e,n,i,r){for(var o,l,a=0,s=-1,u=i.length,c=(e+63&-64)>>3;++s=e?a===e?n[s]=o:(n[s]=o.slice(0,e),o=o.slice(e,a-e),r.numBatches=Math.max(r.numBatches,i[s].unshift(o))):((l=t[s]).nullable||(t[s]=l.clone({nullable:!0})),n[s]=o?o._changeLengthAndBackfillNullBitmap(e):bZ.new(l.type,0,e,e,zV(c)));return n}var EV=function(t){function e(e,n){var i=t.call(this)||this;return i._children=n,i.numChildren=e.childData.length,i._bindDataAccessors(i.data=e),i}return _m(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return this.data.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typeId",{get:function(){return this.data.typeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.data.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offset",{get:function(){return this.data.offset},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this.data.stride},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullCount",{get:function(){return this.data.nullCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"byteLength",{get:function(){return this.data.byteLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"VectorName",{get:function(){return ty[this.typeId]+"Vector"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ArrayType",{get:function(){return this.type.ArrayType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.data.values},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typeIds",{get:function(){return this.data.typeIds},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nullBitmap",{get:function(){return this.data.nullBitmap},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueOffsets",{get:function(){return this.data.valueOffsets},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return this.VectorName+"<"+this.type[Symbol.toStringTag]+">"},enumerable:!1,configurable:!0}),e.prototype.clone=function(t,e){return void 0===e&&(e=this._children),$f.new(t,e)},e.prototype.concat=function(){for(var t=[],e=0;e0){var e=this.offset+t;return 0!==(this.nullBitmap[e>>3]&1<=this.numChildren?null:(this._children||(this._children=[]))[t]||(this._children[t]=$f.new(this.data.childData[t]))},e.prototype.toJSON=function(){return km(this)},e.prototype._sliceInternal=function(t,e,n){return t.clone(t.data.slice(e,n-e),null)},e.prototype._bindDataAccessors=function(t){},e}($f);EV.prototype[Symbol.isConcatSpreadable]=!0;var DV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.asUtf8=function(){return $f.new(this.data.clone(new Dy))},e}(EV),OV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.from=function(t){return YS((function(){return new Oy}),t)},e}(EV),AV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.from=function(){for(var t=[],e=0;e>>0)},Dv=function(t){return new Date(t)},Ov=function(t,e,n){var i=e,r=i[n],o=i[n+1];return null!=r&&null!=o?t.subarray(r,o):null},Av=function(t,e){return function(t,e){return Dv(function(t,e){return 864e5*t[e]}(t,e))}(t.values,e)},qv=function(t,e){return function(t,e){return Dv(Ev(t,e))}(t.values,2*e)},$v=function(t,e){var n=t.stride;return t.values[n*e]},tS=function(t,e){var n=t.stride;return IZ(t.values[n*e])},eS=function(t,e){var n=t.stride,i=t.values,r=t.type;return qZ.new(i.subarray(n*e,n*(e+1)),r.isSigned)},nS=function(t,e){var n=t.values;return 1e3*Ev(n,2*e)},iS=function(t,e){var n=t.values;return Ev(n,2*e)},rS=function(t,e){return function(t,e){return t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3}(t.values,2*e)},oS=function(t,e){return function(t,e){return t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6}(t.values,2*e)},lS=function(t,e){return t.values[t.stride*e]},aS=function(t,e){return t.values[t.stride*e]},sS=function(t,e){var n=t.values;return qZ.signed(n.subarray(2*e,2*(e+1)))},uS=function(t,e){var n=t.values;return qZ.signed(n.subarray(2*e,2*(e+1)))},cS=function(t,e){var n=t.typeIdToChildIndex[t.typeIds[e]],i=t.getChildAt(n);return i?i.get(t.valueOffsets[e]):null},dS=function(t,e){var n=t.typeIdToChildIndex[t.typeIds[e]],i=t.getChildAt(n);return i?i.get(e):null},hS=function(t,e){return t.values.subarray(2*e,2*(e+1))},bS=function(t,e){var n=t.values[e],i=new Int32Array(2);return i[0]=n/12|0,i[1]=n%12|0,i};Pv.prototype.visitNull=function(t,e){return null},Pv.prototype.visitBool=function(t,e){var n=t.offset+e;return 0!=(t.values[n>>3]&1<0?0:-1},mS.prototype.visitBool=fS,mS.prototype.visitInt=fS,mS.prototype.visitInt8=fS,mS.prototype.visitInt16=fS,mS.prototype.visitInt32=fS,mS.prototype.visitInt64=fS,mS.prototype.visitUint8=fS,mS.prototype.visitUint16=fS,mS.prototype.visitUint32=fS,mS.prototype.visitUint64=fS,mS.prototype.visitFloat=fS,mS.prototype.visitFloat16=fS,mS.prototype.visitFloat32=fS,mS.prototype.visitFloat64=fS,mS.prototype.visitUtf8=fS,mS.prototype.visitBinary=fS,mS.prototype.visitFixedSizeBinary=fS,mS.prototype.visitDate=fS,mS.prototype.visitDateDay=fS,mS.prototype.visitDateMillisecond=fS,mS.prototype.visitTimestamp=fS,mS.prototype.visitTimestampSecond=fS,mS.prototype.visitTimestampMillisecond=fS,mS.prototype.visitTimestampMicrosecond=fS,mS.prototype.visitTimestampNanosecond=fS,mS.prototype.visitTime=fS,mS.prototype.visitTimeSecond=fS,mS.prototype.visitTimeMillisecond=fS,mS.prototype.visitTimeMicrosecond=fS,mS.prototype.visitTimeNanosecond=fS,mS.prototype.visitDecimal=fS,mS.prototype.visitList=fS,mS.prototype.visitStruct=fS,mS.prototype.visitUnion=fS,mS.prototype.visitDenseUnion=yS,mS.prototype.visitSparseUnion=yS,mS.prototype.visitDictionary=fS,mS.prototype.visitInterval=fS,mS.prototype.visitIntervalDayTime=fS,mS.prototype.visitIntervalYearMonth=fS,mS.prototype.visitFixedSizeList=fS,mS.prototype.visitMap=fS;var ZS=new mS,XS=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e}(Gy);function GS(t){if(t.nullCount>0)return function(t){var e=pS.getVisitFn(t);return my(t.data.nullBitmap,t.data.offset,t.length,t,(function(t,n,i,r){return 0!=(i&1<0)?t.data.values.subarray(0,i)[Symbol.iterator]():function(e){var n;return Um(this,(function(r){switch(r.label){case 0:n=-1,r.label=1;case 1:return++n0&&(this.get=(e=this.get,function(t){return this.isValid(t)?e.call(this,t):null}),this.set=function(t){return function(e,n){hy(this.nullBitmap,this.offset+e,!(null==n))&&t.call(this,e,n)}}(this.set));var e},Object.keys(ty).map((function(t){return ty[t]})).filter((function(t){return"number"==typeof t})).filter((function(t){return t!==ty.NONE})).forEach((function(t){var e,n=xS.visit(t);n.prototype.get=(e=pS.getVisitFn(t),function(t){return e(this,t)}),n.prototype.set=Qv(kG.getVisitFn(t)),n.prototype.indexOf=Qv(ZS.getVisitFn(t)),n.prototype.toArray=jv(SS.getVisitFn(t)),n.prototype.getByteWidth=function(t){return function(){return t(this.type)}}(LS.getVisitFn(t)),n.prototype[Symbol.iterator]=jv(WS.getVisitFn(t))}));var KS=function(t){function e(){for(var e=[],n=0;n=this.numChildren)return null;var e,n,i=this._schema.fields,r=this._children||(this._children=[]);if(n=r[t])return n;if(e=i[t]){var o=this._chunks.map((function(e){return e.getChildAt(t)})).filter((function(t){return null!=t}));if(o.length>0)return r[t]=new EX(e,o)}return null},e.prototype.serialize=function(t,e){return void 0===e&&(e=!0),(e?CV:UV).writeAll(this).toUint8Array(!0)},e.prototype.count=function(){return this._length},e.prototype.select=function(){for(var t=[],e=0;e-1}))))},e.prototype.selectAt=function(){for(var t,n=[],i=0;i-1}))))},e.prototype.selectAt=function(){for(var t,n=this,i=[],r=0;r0&&this.dictionaries.set(e.id,n),this},e}(Gy),_S=function(t){function e(e){var n=t.call(this)||this;return n._impl=e,n}return _m(e,t),Object.defineProperty(e.prototype,"closed",{get:function(){return this._impl.closed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this._impl.schema},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoDestroy",{get:function(){return this._impl.autoDestroy},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dictionaries",{get:function(){return this._impl.dictionaries},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numDictionaries",{get:function(){return this._impl.numDictionaries},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRecordBatches",{get:function(){return this._impl.numRecordBatches},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"footer",{get:function(){return this._impl.isFile()?this._impl.footer:null},enumerable:!1,configurable:!0}),e.prototype.isSync=function(){return this._impl.isSync()},e.prototype.isAsync=function(){return this._impl.isAsync()},e.prototype.isFile=function(){return this._impl.isFile()},e.prototype.isStream=function(){return this._impl.isStream()},e.prototype.next=function(){return this._impl.next()},e.prototype.throw=function(t){return this._impl.throw(t)},e.prototype.return=function(t){return this._impl.return(t)},e.prototype.cancel=function(){return this._impl.cancel()},e.prototype.reset=function(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this},e.prototype.open=function(t){var e=this,n=this._impl.open(t);return ff(n)?n.then((function(){return e})):this},e.prototype.readRecordBatch=function(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null},e.prototype[Symbol.iterator]=function(){return this._impl[Symbol.iterator]()},e.prototype[Symbol.asyncIterator]=function(){return this._impl[Symbol.asyncIterator]()},e.prototype.toDOMStream=function(){var t,e,n=this;return Tf.toDOMStream(this.isSync()?((t={})[Symbol.iterator]=function(){return n},t):((e={})[Symbol.asyncIterator]=function(){return n},e))},e.prototype.toNodeStream=function(){var t,e,n=this;return Tf.toNodeStream(this.isSync()?((t={})[Symbol.iterator]=function(){return n},t):((e={})[Symbol.asyncIterator]=function(){return n},e),{objectMode:!0})},e.throughNode=function(t){throw new Error('"throughNode" not available in this environment')},e.throughDOM=function(t,e){throw new Error('"throughDOM" not available in this environment')},e.from=function(t){var n=this;return t instanceof e?t:Xf(t)?function(t){return new IS(new MS(t))}(t):Wf(t)?function(t){return Cm(this,void 0,void 0,(function(){var e,n,i;return Um(this,(function(r){switch(r.label){case 0:return[4,t.stat()];case 1:return e=r.sent().size,n=new iW(t,e),e>=RV?(i=VV,[4,n.readAt(0,vV+7&-8)]):[3,3];case 2:if(i.apply(void 0,[r.sent()]))return[2,new US(new zS(n))];r.label=3;case 3:return[2,new NS(new kS(n))]}}))}))}(t):ff(t)?Cm(n,void 0,void 0,(function(){var n,i;return Um(this,(function(r){switch(r.label){case 0:return i=(n=e).from,[4,t];case 1:return[4,i.apply(n,[r.sent()])];case 2:return[2,r.sent()]}}))})):Vf(t)||vf(t)||Sf(t)||Zf(t)?function(t){return Cm(this,void 0,void 0,(function(){var e,n,i,r,o;return Um(this,(function(l){switch(l.label){case 0:return[4,t.peek(vV+7&-8)];case 1:return(e=l.sent())&&e.byteLength>=4?VV(e)?[3,2]:(i=new NS(new kS(t)),[3,4]):[3,5];case 2:return r=CS.bind,o=TS.bind,[4,t.read()];case 3:i=new(r.apply(CS,[void 0,new(o.apply(TS,[void 0,l.sent()]))])),l.label=4;case 4:return n=i,[3,6];case 5:n=new NS(new kS(function(){return zm(this,arguments,(function(){return Um(this,(function(t){return[2]}))}))}())),l.label=6;case 6:return[2,n]}}))}))}(new $G(t)):function(t){var e=t.peek(vV+7&-8);return e&&e.byteLength>=4?VV(e)?new CS(new TS(t.read())):new IS(new BS(t)):new IS(new BS(function(){return Um(this,(function(t){return[2]}))}()))}(new qG(t))},e.readAll=function(t){return t instanceof e?t.isSync()?QS(t):PS(t):Xf(t)||ArrayBuffer.isView(t)||yf(t)||Gf(t)?QS(t):PS(t)},e}(ef),IS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return _m(e,t),e.prototype[Symbol.iterator]=function(){return this._impl[Symbol.iterator]()},e.prototype[Symbol.asyncIterator]=function(){return zm(this,arguments,(function(){return Um(this,(function(t){switch(t.label){case 0:return[5,Fm(Mm(jm(this[Symbol.iterator]())))];case 1:return[4,Tm.apply(void 0,[t.sent()])];case 2:return t.sent(),[2]}}))}))},e}(_S),NS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return _m(e,t),e.prototype[Symbol.iterator]=function(){throw new Error("AsyncRecordBatchStreamReader is not Iterable")},e.prototype[Symbol.asyncIterator]=function(){return this._impl[Symbol.asyncIterator]()},e}(_S),CS=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return _m(e,t),e}(IS),US=function(t){function e(e){var n=t.call(this,e)||this;return n._impl=e,n}return _m(e,t),e}(NS),FS=function(){function t(t){void 0===t&&(t=new Map),this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}return Object.defineProperty(t.prototype,"numDictionaries",{get:function(){return this._dictionaryIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numRecordBatches",{get:function(){return this._recordBatchIndex},enumerable:!1,configurable:!0}),t.prototype.isSync=function(){return!1},t.prototype.isAsync=function(){return!1},t.prototype.isFile=function(){return!1},t.prototype.isStream=function(){return!1},t.prototype.reset=function(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this},t.prototype._loadRecordBatch=function(t,e){return new HS(this.schema,t.length,this._loadVectors(t,e,this.schema.fields))},t.prototype._loadDictionaryBatch=function(t,e){var n=t.id,i=t.isDelta,r=t.data,o=this.dictionaries,l=this.schema,a=o.get(n);if(i||!a){var s=l.dictionaries.get(n);return a&&i?a.concat($f.new(this._loadVectors(r,e,[s])[0])):$f.new(this._loadVectors(r,e,[s])[0])}return a},t.prototype._loadVectors=function(t,e,n){return new dW(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)},t}(),BS=function(t){function e(e,n){var i=t.call(this,n)||this;return i._reader=Xf(e)?new yV(i._handle=e):new mV(i._handle=e),i}return _m(e,t),e.prototype.isSync=function(){return!0},e.prototype.isStream=function(){return!0},e.prototype[Symbol.iterator]=function(){return this},e.prototype.cancel=function(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)},e.prototype.open=function(t){return this.closed||(this.autoDestroy=jS(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this},e.prototype.throw=function(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):$m},e.prototype.return=function(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):$m},e.prototype.next=function(){if(this.closed)return $m;for(var t,e=this._reader;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;var n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;n=t.header(),i=e.readMessageBody(t.bodyLength);var r=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new JS(this.schema)}):this.return()},e.prototype._readNextMessageAndValidate=function(t){return this._reader.readMessage(t)},e}(FS),kS=function(t){function e(e,n){var i=t.call(this,n)||this;return i._reader=new fV(i._handle=e),i}return _m(e,t),e.prototype.isAsync=function(){return!0},e.prototype.isStream=function(){return!0},e.prototype[Symbol.asyncIterator]=function(){return this},e.prototype.cancel=function(){return Cm(this,void 0,void 0,(function(){return Um(this,(function(t){switch(t.label){case 0:return this.closed||!(this.closed=!0)?[3,2]:[4,this.reset()._reader.return()];case 1:t.sent(),this._reader=null,this.dictionaries=null,t.label=2;case 2:return[2]}}))}))},e.prototype.open=function(t){return Cm(this,void 0,void 0,(function(){var e,n;return Um(this,(function(i){switch(i.label){case 0:return this.closed?[3,4]:(this.autoDestroy=jS(this,t),(e=this.schema)?[3,2]:(n=this,[4,this._reader.readSchema()]));case 1:e=n.schema=i.sent(),i.label=2;case 2:return e?[3,4]:[4,this.cancel()];case 3:i.sent(),i.label=4;case 4:return[2,this]}}))}))},e.prototype.throw=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return!this.closed&&this.autoDestroy&&(this.closed=!0)?[4,this.reset()._reader.throw(t)]:[3,2];case 1:return[2,e.sent()];case 2:return[2,$m]}}))}))},e.prototype.return=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return!this.closed&&this.autoDestroy&&(this.closed=!0)?[4,this.reset()._reader.return(t)]:[3,2];case 1:return[2,e.sent()];case 2:return[2,$m]}}))}))},e.prototype.next=function(){return Cm(this,void 0,void 0,(function(){var t,e,n,i,r;return Um(this,(function(o){switch(o.label){case 0:if(this.closed)return[2,$m];e=this._reader,o.label=1;case 1:return[4,this._readNextMessageAndValidate()];case 2:return(t=o.sent())?t.isSchema()?[4,this.reset(t.header())]:[3,4]:[3,9];case 3:return o.sent(),[3,8];case 4:return t.isRecordBatch()?(this._recordBatchIndex++,n=t.header(),[4,e.readMessageBody(t.bodyLength)]):[3,6];case 5:return i=o.sent(),[2,{done:!1,value:this._loadRecordBatch(n,i)}];case 6:return t.isDictionaryBatch()?(this._dictionaryIndex++,n=t.header(),[4,e.readMessageBody(t.bodyLength)]):[3,8];case 7:i=o.sent(),r=this._loadDictionaryBatch(n,i),this.dictionaries.set(n.id,r),o.label=8;case 8:return[3,1];case 9:return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,[2,{done:!1,value:new JS(this.schema)}]):[4,this.return()];case 10:return[2,o.sent()]}}))}))},e.prototype._readNextMessageAndValidate=function(t){return Cm(this,void 0,void 0,(function(){return Um(this,(function(e){switch(e.label){case 0:return[4,this._reader.readMessage(t)];case 1:return[2,e.sent()]}}))}))},e}(FS),TS=function(t){function e(e,n){return t.call(this,e instanceof nW?e:new nW(e),n)||this}return _m(e,t),Object.defineProperty(e.prototype,"footer",{get:function(){return this._footer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numDictionaries",{get:function(){return this._footer?this._footer.numDictionaries:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRecordBatches",{get:function(){return this._footer?this._footer.numRecordBatches:0},enumerable:!1,configurable:!0}),e.prototype.isSync=function(){return!0},e.prototype.isFile=function(){return!0},e.prototype.open=function(e){var n,i;if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;try{for(var r=Fm(this._footer.dictionaryBatches()),o=r.next();!o.done;o=r.next()){o.value&&this._readDictionaryBatch(this._dictionaryIndex++)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}return t.prototype.open.call(this,e)},e.prototype.readRecordBatch=function(t){if(this.closed)return null;this._footer||this.open();var e=this._footer&&this._footer.getRecordBatch(t);if(e&&this._handle.seek(e.offset)){var n=this._reader.readMessage(sy.RecordBatch);if(n&&n.isRecordBatch()){var i=n.header(),r=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(i,r)}}return null},e.prototype._readDictionaryBatch=function(t){var e=this._footer&&this._footer.getDictionaryBatch(t);if(e&&this._handle.seek(e.offset)){var n=this._reader.readMessage(sy.DictionaryBatch);if(n&&n.isDictionaryBatch()){var i=n.header(),r=this._reader.readMessageBody(n.bodyLength),o=this._loadDictionaryBatch(i,r);this.dictionaries.set(i.id,o)}}},e.prototype._readFooter=function(){var t=this._handle,e=t.size-SV,n=t.readInt32(e),i=t.readAt(e-n,n);return EG.decode(i)},e.prototype._readNextMessageAndValidate=function(t){if(this._footer||this.open(),this._footer&&this._recordBatchIndex=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||0===this._numChunks)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))},t.prototype._enqueue=function(t,e){this._bufferedSize=0,this._controller=null,null===e?t.close():t.enqueue(e)},t}(),DS=function(t){return t.length},OS=function(t){return t.byteLength};var AS=function(){function t(){}return t.prototype.eq=function(e){return e instanceof t||(e=new qS(e)),new oR(this,e)},t.prototype.le=function(e){return e instanceof t||(e=new qS(e)),new lR(this,e)},t.prototype.ge=function(e){return e instanceof t||(e=new qS(e)),new aR(this,e)},t.prototype.lt=function(t){return new sR(this.ge(t))},t.prototype.gt=function(t){return new sR(this.le(t))},t.prototype.ne=function(t){return new sR(this.eq(t))},t}(),qS=function(t){function e(e){var n=t.call(this)||this;return n.v=e,n}return _m(e,t),e}(AS),$S=function(t){function e(e){var n=t.call(this)||this;return n.name=e,n}return _m(e,t),e.prototype.bind=function(t){if(!this.colidx){this.colidx=-1;for(var e=t.schema.fields,n=-1;++n=n.v;return function(){return i}},e.prototype._bindColCol=function(t,e,n){var i=e.bind(t),r=n.bind(t);return function(t,e){return i(t,e)>=r(t,e)}},e.prototype._bindColLit=function(t,e,n){var i=e.bind(t);return function(t,e){return i(t,e)>=n.v}},e.prototype._bindLitCol=function(t,e,n){var i=n.bind(t);return function(t,n){return e.v>=i(t,n)}},e}(eR),sR=function(t){function e(e){var n=t.call(this)||this;return n.child=e,n}return _m(e,t),e.prototype.bind=function(t){var e=this.child.bind(t);return function(t,n){return!e(t,n)}},e}(tR);!function(t){function e(e,n){var i=t.call(this)||this;return i.next=e,i.bind_=n,i}_m(e,t),e.prototype.bind=function(t){return this.bind_(t),this.next}}(tR),KS.prototype.countBy=function(t){return new uR(this.chunks).countBy(t)},KS.prototype.scan=function(t,e){return new uR(this.chunks).scan(t,e)},KS.prototype.scanReverse=function(t,e){return new uR(this.chunks).scanReverse(t,e)},KS.prototype.filter=function(t){return new uR(this.chunks).filter(t)};var uR=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return _m(e,t),e.prototype.filter=function(t){return new dR(this.chunks,t)},e.prototype.scan=function(t,e){for(var n=this.chunks,i=n.length,r=-1;++r=0;){var r=n[i];e&&e(r);for(var o=r.length;--o>=0;)t(o,r)}},e.prototype.countBy=function(t){var e=this.chunks,n=e.length,i="string"==typeof t?new $S(t):t;i.bind(e[n-1]);var r=i.vector;if(!wy.isDictionary(r.type))throw new Error("countBy currently only supports dictionary-encoded columns");for(var o=Math.ceil(Math.log(r.length)/Math.log(256)),l=new(4==o?Uint32Array:o>=2?Uint16Array:Uint8Array)(r.dictionary.length),a=-1;++a=0;)for(var r=n[i],o=this._predicate.bind(r),l=!1,a=r.length;--a>=0;)o(a,r)&&(e&&!l&&(e(r),l=!0),t(a,r))},e.prototype.count=function(){for(var t=0,e=this._chunks,n=e.length,i=-1;++i=2?Uint16Array:Uint8Array)(r.dictionary.length),a=-1;++a"object"==typeof t&&null!==t||"function"==typeof t,yR=new Map([["proxy",{canHandle:t=>fR(t)&&t[hR],serialize(t){const{port1:e,port2:n}=new MessageChannel;return ZR(t,e),[n,[n]]},deserialize:t=>(t.start(),GR(t))}],["throw",{canHandle:t=>fR(t)&&mR 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 ZR(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:r,type:o,path:l}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(LR);let s;try{const e=l.slice(0,-1).reduce(((t,e)=>t[e]),t),n=l.reduce(((t,e)=>t[e]),t);switch(o){case"GET":s=n;break;case"SET":e[l.slice(-1)[0]]=LR(i.data.value),s=!0;break;case"APPLY":s=n.apply(e,a);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[hR]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;ZR(t,n),s=RR(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(u){s={value:u,[mR]:0}}Promise.resolve(s).catch((t=>({value:t,[mR]:0}))).then((t=>{const[i,l]=gR(t);e.postMessage(Object.assign(Object.assign({},i),{id:r}),l),"RELEASE"===o&&(e.removeEventListener("message",n),XR(e))}))})),e.start&&e.start()}function XR(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function GR(t,e){return VR(t,[],e)}function WR(t){if(t)throw new Error("Proxy has been released and is not useable")}function VR(t,e=[],n=function(){}){let i=!1;const r=new Proxy(n,{get(n,o){if(WR(i),o===pR)return()=>xR(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{XR(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>r};const n=xR(t,{type:"GET",path:e.map((t=>t.toString()))}).then(LR);return n.then.bind(n)}return VR(t,[...e,o])},set(n,r,o){WR(i);const[l,a]=gR(o);return xR(t,{type:"SET",path:[...e,r].map((t=>t.toString())),value:l},a).then(LR)},apply(n,r,o){WR(i);const l=e[e.length-1];if(l===bR)return xR(t,{type:"ENDPOINT"}).then(LR);if("bind"===l)return VR(t,e.slice(0,-1));const[a,s]=vR(o);return xR(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:a},s).then(LR)},construct(n,r){WR(i);const[o,l]=vR(r);return xR(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},l).then(LR)}});return r}function vR(t){const e=t.map(gR);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const SR=new WeakMap;function RR(t,e){return SR.set(t,e),t}function gR(t){for(const[e,n]of yR)if(n.canHandle(t)){const[i,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},r]}return[{type:"RAW",value:t},SR.get(t)||[]]}function LR(t){switch(t.type){case"HANDLER":return yR.get(t.name).deserialize(t.value);case"RAW":return t.value}}function xR(t,e,n){return new Promise((i=>{const r=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===r&&(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:r},e),n)}))}class YR extends Map{get_count(t){return super.get(t)||0}get_counter(t){const e=super.get(t);return e||(super.set(t,new YR),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]}}const KR=new Blob([atob("Y29uc3QgdD1TeW1ib2woIkNvbWxpbmsucHJveHkiKSxlPVN5bWJvbCgiQ29tbGluay5lbmRwb2ludCIpLG49U3ltYm9sKCJDb21saW5rLnJlbGVhc2VQcm94eSIpLHI9U3ltYm9sKCJDb21saW5rLnRocm93biIpLGk9dD0+Im9iamVjdCI9PXR5cGVvZiB0JiZudWxsIT09dHx8ImZ1bmN0aW9uIj09dHlwZW9mIHQsbz1uZXcgTWFwKFtbInByb3h5Iix7Y2FuSGFuZGxlOmU9PmkoZSkmJmVbdF0sc2VyaWFsaXplKHQpe2NvbnN0e3BvcnQxOmUscG9ydDI6bn09bmV3IE1lc3NhZ2VDaGFubmVsO3JldHVybiBzKHQsZSksW24sW25dXX0sZGVzZXJpYWxpemUodCl7cmV0dXJuIHQuc3RhcnQoKSxjKHQsW10sZSk7dmFyIGV9fV0sWyJ0aHJvdyIse2NhbkhhbmRsZTp0PT5pKHQpJiZyIGluIHQsc2VyaWFsaXplKHt2YWx1ZTp0fSl7bGV0IGU7cmV0dXJuIGU9dCBpbnN0YW5jZW9mIEVycm9yP3tpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOnQubWVzc2FnZSxuYW1lOnQubmFtZSxzdGFjazp0LnN0YWNrfX06e2lzRXJyb3I6ITEsdmFsdWU6dH0sW2UsW11dfSxkZ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IGxvYWQiKTtjb25zdCBuPUJhLmZyb20odCk7Y29uc29sZS5sb2coIkxvYWRlZCIpO2NvbnN0e21ldGFkYXRhOnJ9PW4uc2NoZW1hO2xldCBpO09iamVjdC5rZXlzKGUpLmxlbmd0aCxpPWZjKGUsdCxyKSxjb25zb2xlLmxvZygiSGVyZSIpO2NvbnN0IG89Y2MoaSk7cmV0dXJuIGNvbnNvbGUubG9nKCJOb3cgaGVyZSIpLFtwKGksW2ldKSxyLG9dfSkpLHJ1bl90cmFuc2Zvcm1zKHQsZSl7Y29uc29sZS5sb2coIjUgaGVyZSIpO2NvbnN0IG49ZmModCxlKSxyPWNjKG4pO3JldHVybiBjb25zb2xlLmxvZygiNiBoZXJlIiksW3Aobixbbl0pLHJdfX0pOwo=")],{type:"text/javascript;charset=utf-8"});function HR(){const t=(window.URL||window.webkitURL).createObjectURL(KR);try{return new Worker(t)}finally{(window.URL||window.webkitURL).revokeObjectURL(t)}}class JR extends class{}{constructor(t,e,n,i){super(),this.url=t,this.parent=n,void 0===n&&(this._mutations=i.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 i of this._children)n.concat(i.download_to_depth(t,e,!1));return Promise.all(n)}return this.download().then((i=>{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,RR(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)_R([e.x,e.y],t)&&(yield e);if(0==e){for(const n of this.children)if(n.ready)for(const i of n.points(t,e))_R([i.x,i.y],t)&&(yield i)}else{let n=this.children.map((n=>{const i={t:n,iterator:n.points(t,e)};return i.next=i.iterator.next(),i}));for(n=n.filter((t=>t.next.value));n.length>0;){let t=0;for(let e=1;e0?(console.log("BYTES",this._table_buffer.byteLength),this._table=KS.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=this.url.match("//")?`${this.url}/${this.key}.feather`:`${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,console.log("Got buffer"),this._table=KS.from(t),console.log("Into table"),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 i,r=e;return this.visit((e=>{if(!(function(t,e,n){if(void 0===t)return parseFloat("inf");const i=Math.max(t.x[0]-e,0,e-t.x[1]),r=Math.max(t.y[0]-n,0,n-t.y[1]);return Math.sqrt(i*i+r*r)}(e.extent,t[0],t[1])>r)&&(e._kdtree||e.kdtree(),e._kdtree)){const o=e._kdtree.find(t[0],t[1],r,n);if(o){const e=Math.sqrt((o.x-t[0])**2+(o.y-t[1])**2);i=o,r=e}}})),i}get _schema(){if(this.__schema)return this.__schema;const t=[];for(const e of this.table.schema.fields){const{name:n,type:i,nullable:r}=e;i&&5==i.typeId&&t.push({name:n,type:"string"}),i&&i.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]}),i&&8==i.typeId&&t.push({name:n,type:"date",extent:Me(this.table.getColumn(n).data.values)}),i&&3==i.typeId&&t.push({name:n,type:"float",extent:Me(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 i=0;for(const[r,o]of n.entries())t.has(o)||(i=t.size/2,t.set(i,o),t.set(o,i)),this.dictionary_lookups[e]}this.dictionary_lookups}get theoretical_extent(){const t=this.root_extent,[e,n,i]=this.codes,r=(t.x[1]-t.x[0])/2**e,o=(t.y[1]-t.y[0])/2**e;return{x:[t.x[0]+n*r,t.x[0]+(n+1)*r],y:[t.y[0]+i*o,t.y[0]+(i+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 i of t)e.push(this.table.getColumn(i));const n=new YR;for(let i=0;it.get(i)));n.inc(...t)}return n}get root_extent(){return this.parent.root_extent}}class wR extends JR{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=[],i=Ee(2**t);for(const r of i){n[r]=[];for(const t of i)n[r][t]=" ";n[r][2**t]="|"}n[2**t]=Array(2**t+1).fill("-"),this.visit((i=>{const[r,o,l]=i.key.split("/").map((t=>+t));r==t&&(n[l][o]="_",n[l][o]=e(i))})),n.map((t=>t.join("")))}download_most_needed_tiles(t,e,n=4){this._download_queue||(this._download_queue=new Set);const i=this._download_queue;if(i.size>=n)return;const r=[];this.visit((e=>{const n=function(t,e){const n=t.extent;NR(n),NR(e),n.x[0]>e.x[1]||n.x[1]e.y[1]||(n.y[1],e.y[0]);const i={x:[je([e.x[0],n.x[0]]),Qe([e.x[1],n.x[1]])],y:[je([e.y[0],n.y[0]]),Qe([e.y[1],n.y[1]])]},{x:r,y:o}=i;let l=0;r[0]>r[1]&&(l-=1);o[0]>o[1]&&(l-=2);if(l<0)return l;return IR(i)/IR(e)}(e,t);r.push([n,e,t,e.download_state])})),r.sort(((t,e)=>t[0]-e[0]));for(const[o,l,a,s]of r);for(;r.length&&i.sizee||t<0||"Unattempted"===n.download_state&&(i.add(n.key),n.download().catch((t=>{throw console.warn("Error on",n.key),i.delete(n.key),t})).then((()=>i.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 JR(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=ze(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 Ee(8))console.log(`Allocating worker ${t}`),this._tileWorkers.push(GR(new HR));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 i=[this],r=[];let o;for(;o=i.shift();)e?r.push(o):t(o),n(o)&&"Complete"==o.download_state&&i.push(...o.children);if(e)for(;o=r.pop();)t(o)}}function _R(t,e){return void 0===e||t[0]e.x[0]&&t[1]e.y[0]}function IR(t){return(t.x[1]-t.x[0])*(t.y[1]-t.y[0])}const NR=function(t){if(t.x[1]t.arrayBuffer())).then((t=>{const e=Dl.from(t);return this.table=e,"complete"}))),this._promise}get_cached_crosstab_texture(t,e,n){const{x:i,y:r,z:o}=t,l=`${i}-${r}-${o}`;if(this.textures.get(l))return this.textures.get(l);const{crosstabs:a,y_domain:s,x_domain:u,shape:c}=this.crosstab_array(t,e),d=pm(a);return this.textures.set(l,{texture:n.texture({type:"uint8",format:"rgba",data:d.array,height:c[0],width:a[0].length}),x_domain:u,y_domain:s,z_domain:d.extent,shape:c}),console.log(d.extent,d.array),this.textures.get(l)}crosstab_array(t,e={}){const n=new UR,i=new UR,{x:r,y:o,z:l}=t,a=this.table,s=a.getColumn(o).data.values,u=a.getColumn(r).toArray(),c=a.getColumn(l).toArray();e.x?n.prepopulate(e.x(),!1):n.prepopulate(u),e.y?i.prepopulate(e.y(),!0):i.prepopulate(s);const d=Ee(n.size).map((t=>new Array(i.size).fill(0)));for(let h=0;ht-2047)),y_domain:Me(s)}}}class UR 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 i of n)this.get(i);this.fixed=!0}}class FR{constructor(t,e){console.log({regl:t}),this.feature_set=e,this.element_handler=new Map,this.coord_handler=new BR(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,i={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(i)}render(t){const e=[];for(let n of this.features){n.alpha=1,n.color=[.2,.2,.2];const i={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(i,t),e.push(i)}this._render(e)}prepare_features(){this.features=[];const{feature_set:t,features:e,element_handler:n,coord_handler:i}=this;for(let r=0;rthis.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 i=this.buffers[this.current_buffer];i.subdata(e,this.current_position);const r={buffer:i,stride:n||8,offset:this.current_position};return this.lookup.set(t,r),this.current_position+=4*e.length,r}}const kR=[{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 i of kR){const t=this.div.append("div").attr("id",`container-for-${i.id}`).style("position","fixed").style("top",0).style("left",0).style("pointer-events","deepscatter-svg"==i.id?"auto":"none");t.append(i.nodetype).attr("id",i.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 wR(this.source_url,t),await this._root.download(),this._renderer=new Km("#container-for-webgl-canvas",this._root,this),this._zoom=new Wb("#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=Dl.from(t),n=new FR(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_:i}=t._zoom.scales();e.strokeStyle="#888888";const r=t._root.map((t=>t));for(const o of Ee(13))setTimeout((()=>{for(const t of r){if(t.codes[0]!=o)continue;if(!t.extent)continue;const[r,l]=t.extent.x.map((t=>n(t))),[a,s]=t.extent.y.map((t=>i(t))),u=t.codes[0];e.lineWidth=8/Math.sqrt(u),e.globalAlpha=.33,e.strokeRect(r,a,l-r,s-a),"Unattempted"!==t.download_state&&e.fillRect(r,a,l-r,s-a),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]);ya(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 CR(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 i of t.polygons)this.registerPolygonMap(i);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,i=n.zoom.current_corners(),r=[],o=n.aes.filter.current.get_function();for(const l of e.points(i,!0))if(o(l)&&r.push(l),r.length>=t)return r;return r}drawContours(t,e){const n=(e||pt("body")).select("#canvas-2d").node().getContext("2d");for(const i 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=je([.45,.25*Math.exp(Math.log(this._zoom.transform.k/2))]);const t=Ne(Be().scale(this._zoom.transform.k).translate([this._zoom.transform.x,this._zoom.transform.y]),n);n.beginPath(),t(i),n.fill()}}contours(t){const e=this._renderer.calculate_contours(t),{x:n,y:i,x_:r,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(r.invert(e[0])),e[1]=i(o.invert(e[1]))}}}(e),this.drawContours(e)}}})); diff --git a/index.html b/index.html index 7a304fb1f..7cd1dba7a 100644 --- a/index.html +++ b/index.html @@ -19,11 +19,11 @@

Welcome to a demo/test page.

import { select } from 'd3-selection'; window.select = select; // For the click function below. const prefs = { - "source_url" : "/tiles", - "max_points" : 25000, // a full cap. - "alpha" : .7, // Target saturation for the full page. + "source_url" : "//localhost:3000/tiles", + "max_points" : 10000, // a full cap. + "alpha" : .9, // Target saturation for the full page. "zoom_balance" : 0.09, // Rate at which points increase size. https://observablehq.com/@bmschmidt/zoom-strategies-for-huge-scatterplots-with-three-js - "point_size": 10, // Default point size before application of size scaling + "point_size": 7, // Default point size before application of size scaling "background_color": "#EEEDDE", "click_function": "select('#ident').html(JSON.stringify(datum, undefined, 2))", "encoding": { diff --git a/index_prod.html b/index_prod.html new file mode 100644 index 000000000..6492d845a --- /dev/null +++ b/index_prod.html @@ -0,0 +1,90 @@ + + + +

Welcome to a demo/test page.

+
+
+ +

+
+
+
+
+
diff --git a/package.json b/package.json
index ff31866aa..0d4b483d5 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
   "homepage": "https://github.com/CreatingData/deepscatter#readme",
   "dependencies": {
     "@apache-arrow/es2015-esm": "^4.0.1",
+    "@apache-arrow/es5-esm": "^3.0.0",
     "@babel/runtime": "^7.9.6",
     "comlink": "^4.3.0",
     "d3-array": "^3.0.1",
@@ -80,6 +81,7 @@
     "regenerator-runtime": "^0.13.5",
     "rollup-plugin-glslify": "^1.2.0",
     "rollup-plugin-web-worker-loader": "^1.6.1",
-    "vite": "^2.3.8"
+    "vite": "^2.3.8",
+    "vite-plugin-legacy": "^2.1.0"
   }
 }
diff --git a/src/glsl/general.frag b/src/glsl/general.frag
index 572c5ea8d..e1e7104dd 100644
--- a/src/glsl/general.frag
+++ b/src/glsl/general.frag
@@ -1,3 +1,7 @@
+#ifdef GL_OES_standard_derivatives
+#extension GL_OES_standard_derivatives : enable
+#endif
+
 precision mediump float;
 
 varying float pic_mode;
@@ -8,17 +12,20 @@ uniform float u_only_color;
 uniform float u_color_picker_mode;
 uniform sampler2D u_sprites;
 
+float delta = 0.0, alpha = 1.0;
+
+
 bool out_of_circle(in vec2 coord) {
   vec2 cxy = 2.0 * coord - 1.0;
   float r_sq = dot(cxy, cxy);
-  if (r_sq > 1.0) {return true;}
+  if (r_sq > 1.03) {return true;}
   return false;
 }
 
 bool out_of_hollow_circle(in vec2 coord) {
   vec2 cxy = 2.0 * coord - 1.0;
   float r_sq = dot(cxy, cxy);
-  if (r_sq > 1.0) {return true;}
+  if (r_sq > 1.01) {return true;}
   float distance_from_edge = (1.0 - r_sq) * point_size;
   if (distance_from_edge > 4.0) {return true;}
   return false;
@@ -33,6 +40,8 @@ bool out_of_triangle(in vec2 coord) {
 
 void main() {
 
+
+  
   if (u_only_color >= -1.5) {
     gl_FragColor = vec4(0., 0., 0., 1./255.);
     return;
@@ -44,10 +53,18 @@ void main() {
       discard;
       return;
     }
+    float alpha = fill.a;
+    vec2 cxy = 2.0 * gl_PointCoord - 1.0;
+    float r = dot(cxy, cxy);
+    #ifdef GL_OES_standard_derivatives
+      delta = fwidth(r);
+      alpha *= (1.0 - smoothstep(1.0 - delta, 1.0 + delta, r));
+    #endif
+
     if (u_color_picker_mode > 0.5) {
       gl_FragColor = fill;
     } else {
       // Pre-blend the alpha channel.
-      gl_FragColor = vec4(fill.rgb * fill.a, fill.a);
+      gl_FragColor = vec4(fill.rgb * alpha, alpha);
     }
 }
diff --git a/src/regl_rendering.js b/src/regl_rendering.js
index 2df40b239..c4fb0b440 100644
--- a/src/regl_rendering.js
+++ b/src/regl_rendering.js
@@ -18,6 +18,7 @@ export class ReglRenderer extends Renderer {
       {
         //      extensions: 'angle_instanced_arrays',
         optionalExtensions: [
+          'OES_standard_derivatives',
           'OES_element_index_uint',
           'OES_texture_float',
           'OES_texture_half_float',
diff --git a/src/tile.js b/src/tile.js
index bf7a157ce..6e7f691e2 100644
--- a/src/tile.js
+++ b/src/tile.js
@@ -1,9 +1,10 @@
 
 import { extent, range, min, max, bisectLeft } from 'd3-array';
-import { Table } from '@apache-arrow/es2015-esm';
+import { Table } from '@apache-arrow/es5-esm';
 import * as Comlink from 'comlink';
 import Counter from './Counter';
-//import TileWorker from './tileworker.worker.js?worker&inline';
+
+import TileWorker from './tileworker.worker.js?worker&inline';
 
 class BaseTile {
   // Can this usefully do anything?
@@ -274,6 +275,7 @@ class Tile extends BaseTile {
     if (this._table) { return this._table; }
     // Constitute table if there's a present buffer.
     if (this._table_buffer && this._table_buffer.byteLength > 0) {
+      console.log("BYTES", this._table_buffer.byteLength)
       return this._table = Table.from(this._table_buffer);
     }
     return undefined;
@@ -298,7 +300,9 @@ class Tile extends BaseTile {
     }
     this._already_called = true;
 
-    const url = `${window.location.origin}/${this.url}/${this.key}.feather`;
+    const url = this.url.match("//") ? 
+    `${this.url}/${this.key}.feather` : 
+    `${window.location.origin}/${this.url}/${this.key}.feather`;
 
     this.download_state = 'In progress';
 
@@ -315,6 +319,9 @@ class Tile extends BaseTile {
         // how to fix it on the table in javascript, just python.
         this._current_mutations = JSON.parse(JSON.stringify(this.needed_mutations));
         this._table_buffer = buffer;
+        console.log("Got buffer")
+        this._table = Table.from(buffer)
+        console.log("Into table")
         this._extent = JSON.parse(metadata.get('extent'));
         this.child_locations = JSON.parse(metadata.get('children'));
         this._min_ix = this.table.getColumn('ix').get(0);
@@ -705,8 +712,8 @@ export default class RootTile extends Tile {
     for (const i of range(NUM_WORKERS)) {
       console.log(`Allocating worker ${i}`);
       this._tileWorkers.push(
-          Comlink.wrap(new Worker(this.url + '/../worker.js')),
-//        Comlink.wrap(new TileWorker()),
+//          Comlink.wrap(new Worker(this.url + '/../worker.js')),
+        Comlink.wrap(new TileWorker()),
       );
     }
 
diff --git a/src/tileworker.worker.js b/src/tileworker.worker.js
index 991908a14..5b5389ddb 100644
--- a/src/tileworker.worker.js
+++ b/src/tileworker.worker.js
@@ -4,11 +4,8 @@ import { transfer, expose } from 'comlink';
 import {
   Table, Column, Vector, Utf8, Float32,
   Uint32, Int32, Int64, Dictionary,
-} from '@apache-arrow/es5-cjs';
+} from '@apache-arrow/es5-esm';
 
-const {Table, Column, Vector, Utf8, Float32,
-  Uint32, Int32, Int64, Dictionary} = window.Arrow;
-const { transfer, expose } = window.comlink;
 function compose_functions(val) {
 
   function compose_singleton_function(val) {
diff --git a/vite.config.js b/vite.config.js
index 9faa7867c..48ded0a38 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,5 +1,4 @@
 import glslify from 'rollup-plugin-glslify';
-import worker from 'rollup-plugin-web-worker-loader';
 import path from 'path';
 import { fileURLToPath } from 'url';
 const __filename = fileURLToPath(import.meta.url);
@@ -7,25 +6,20 @@ const __dirname = path.dirname(__filename);
 
 export default {
   build: {
+    target: "esnext",
     lib: {
       entry: path.resolve(__dirname, 'src/deepscatter.js'),
-      name: 'deepscatter',
-      formats: [/*'es', */'umd'],
-    },
-  },
-  rollupOptions: {
-    output: {
-      inlineDynamicImports: true,
-      manualChunks: {},
+      name: 'Deepscatter',
+      formats: ['es', 'umd'],
     },
   },
   plugins: [
     glslify({ compress: false }),
-    worker({
+/*    worker({
       targetPlatform: 'browser',
       pattern: /(.+)\?worker/,
       //      extensions: supportedExts,
       preserveSource: true, // somehow results in slightly smaller bundle
-    }),
+    }), */
   ], 
 };