(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const f of o.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&r(f)}).observe(document,{childList:!0,subtree:!0});function e(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=e(s);fetch(s.href,o)}})();var v0="http://www.w3.org/1999/xhtml";const Uy={svg:"http://www.w3.org/2000/svg",xhtml:v0,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Op(n){var t=n+="",e=t.indexOf(":");return e>=0&&(t=n.slice(0,e))!=="xmlns"&&(n=n.slice(e+1)),Uy.hasOwnProperty(t)?{space:Uy[t],local:n}:n}function v6(n){return function(){var t=this.ownerDocument,e=this.namespaceURI;return e===v0&&t.documentElement.namespaceURI===v0?t.createElement(n):t.createElementNS(e,n)}}function b6(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function ib(n){var t=Op(n);return(t.local?b6:v6)(t)}function w6(){}function sg(n){return n==null?w6:function(){return this.querySelector(n)}}function x6(n){typeof n!="function"&&(n=sg(n));for(var t=this._groups,e=t.length,r=new Array(e),s=0;s=Zt&&(Zt=oe+1);!(zt=Qt[Zt])&&++Zt=0;)(f=r[s])&&(o&&f.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(f,o),o=f);return this}function H6(n){n||(n=X6);function t(w,I){return w&&I?n(w.__data__,I.__data__):!w-!I}for(var e=this._groups,r=e.length,s=new Array(r),o=0;ot?1:n>=t?0:NaN}function q6(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function Z6(){return Array.from(this)}function K6(){for(var n=this._groups,t=0,e=n.length;t1?this.each((t==null?f4:typeof t=="function"?c4:u4)(n,t,e??"")):zc(this.node(),n)}function zc(n,t){return n.style.getPropertyValue(t)||ub(n).getComputedStyle(n,null).getPropertyValue(t)}function h4(n){return function(){delete this[n]}}function d4(n,t){return function(){this[n]=t}}function _4(n,t){return function(){var e=t.apply(this,arguments);e==null?delete this[n]:this[n]=e}}function p4(n,t){return arguments.length>1?this.each((t==null?h4:typeof t=="function"?_4:d4)(n,t)):this.node()[n]}function cb(n){return n.trim().split(/^|\s+/)}function ag(n){return n.classList||new lb(n)}function lb(n){this._node=n,this._names=cb(n.getAttribute("class")||"")}lb.prototype={add:function(n){var t=this._names.indexOf(n);t<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var t=this._names.indexOf(n);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function hb(n,t){for(var e=ag(n),r=-1,s=t.length;++r=0&&(e=t.slice(r+1),t=t.slice(0,r)),{type:t,name:e}})}function V4(n){return function(){var t=this.__on;if(t){for(var e=0,r=-1,s=t.length,o;et?1:n>=t?0:NaN}function J4(n,t){return n==null||t==null?NaN:tn?1:t>=n?0:NaN}function mb(n){let t,e,r;n.length!==2?(t=A_,e=(c,l)=>A_(n(c),l),r=(c,l)=>n(c)-l):(t=n===A_||n===J4?n:Q4,e=n,r=n);function s(c,l,d=0,p=c.length){if(d>>1;e(c[w],l)<0?d=w+1:p=w}while(d>>1;e(c[w],l)<=0?d=w+1:p=w}while(dd&&r(c[w-1],l)>-r(c[w],l)?w-1:w}return{left:s,center:f,right:o}}function Q4(){return 0}function t5(n){return n===null?NaN:+n}const gb=mb(A_),e5=gb.right,yb=gb.left;mb(t5).center;function $h(n,t){let e,r;if(t===void 0)for(const s of n)s!=null&&(e===void 0?s>=s&&(e=r=s):(e>s&&(e=s),r=o&&(e=r=o):(e>o&&(e=o),r0){for(f=t[--e];e>0&&(r=f,s=t[--e],f=r+s,o=s-(f-r),!o););e>0&&(o<0&&t[e-1]<0||o>0&&t[e-1]>0)&&(s=o*2,r=f+s,s==r-f&&(f=r))}return f}}class Gy extends Map{constructor(t,e=i5){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const[r,s]of t)this.set(r,s)}get(t){return super.get($y(this,t))}has(t){return super.has($y(this,t))}set(t,e){return super.set(n5(this,t),e)}delete(t){return super.delete(r5(this,t))}}function $y({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):e}function n5({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):(n.set(r,e),e)}function r5({_intern:n,_key:t},e){const r=t(e);return n.has(r)&&(e=n.get(e),n.delete(r)),e}function i5(n){return n!==null&&typeof n=="object"?n.valueOf():n}const s5=Math.sqrt(50),a5=Math.sqrt(10),o5=Math.sqrt(2);function P_(n,t,e){const r=(t-n)/Math.max(0,e),s=Math.floor(Math.log10(r)),o=r/Math.pow(10,s),f=o>=s5?10:o>=a5?5:o>=o5?2:1;let c,l,d;return s<0?(d=Math.pow(10,-s)/f,c=Math.round(n*d),l=Math.round(t*d),c/dt&&--l,d=-d):(d=Math.pow(10,s)*f,c=Math.round(n/d),l=Math.round(t/d),c*dt&&--l),l0))return[];if(n===t)return[n];const r=t=s))return[];const c=o-s+1,l=new Array(c);if(r)if(f<0)for(let d=0;d=r)&&(e=r);else{let r=-1;for(let s of n)(s=t(s,++r,n))!=null&&(e=s)&&(e=s)}return e}function S0(n,t){let e;if(t===void 0)for(const r of n)r!=null&&(e>r||e===void 0&&r>=r)&&(e=r);else{let r=-1;for(let s of n)(s=t(s,++r,n))!=null&&(e>s||e===void 0&&s>=s)&&(e=s)}return e}function f_(n,t){let e=0,r=0;if(t===void 0)for(let s of n)s!=null&&(s=+s)>=s&&(++e,r+=s);else{let s=-1;for(let o of n)(o=t(o,++s,n))!=null&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e}function*u5(n){for(const t of n)yield*t}function c5(n){return Array.from(u5(n))}function au(n,t,e){n=+n,t=+t,e=(s=arguments.length)<2?(t=n,n=0,1):s<3?1:+e;for(var r=-1,s=Math.max(0,Math.ceil((t-n)/e))|0,o=new Array(s);++r1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function v5(n,t){return Ic(n[0]-t[0])=0;--c)s.point((w=p[c])[0],w[1]);else r(I.x,I.p.x,-1,s);I=I.p}I=I.o,p=I.z,C=!C}while(!I.v);s.lineEnd()}}}function Yy(n){if(t=n.length){for(var t,e=0,r=n[0],s;++e0)){if(V/=I,I<0){if(V0){if(V>w)return;V>p&&(p=V)}if(V=s-f,!(!I&&V<0)){if(V/=I,I<0){if(V>w)return;V>p&&(p=V)}else if(I>0){if(V0)){if(V/=C,C<0){if(V0){if(V>w)return;V>p&&(p=V)}if(V=o-c,!(!C&&V<0)){if(V/=C,C<0){if(V>w)return;V>p&&(p=V)}else if(C>0){if(V0&&(n[0]=f+p*I,n[1]=c+p*C),w<1&&(t[0]=f+w*I,t[1]=c+w*C),!0}}}}}var Lh=1e9,c_=-Lh;function x5(n,t,e,r){function s(d,p){return n<=d&&d<=e&&t<=p&&p<=r}function o(d,p,w,I){var C=0,V=0;if(d==null||(C=f(d,w))!==(V=f(p,w))||l(d,p)<0^w>0)do I.point(C===0||C===3?n:e,C>1?r:t);while((C=(C+w+4)%4)!==V);else I.point(p[0],p[1])}function f(d,p){return Ic(d[0]-n)0?0:3:Ic(d[0]-e)0?2:1:Ic(d[1]-t)0?1:0:p>0?3:2}function c(d,p){return l(d.x,p.x)}function l(d,p){var w=f(d,1),I=f(p,1);return w!==I?w-I:w===0?p[1]-d[1]:w===1?d[0]-p[0]:w===2?d[1]-p[1]:p[0]-d[0]}return function(d){var p=d,w=y5(),I,C,V,Wt,Qt,Rt,oe,Zt,st,zt,ue,ve={point:an,lineStart:Bt,lineEnd:Dt,polygonStart:Y,polygonEnd:rt};function an(ft,H){s(ft,H)&&p.point(ft,H)}function at(){for(var ft=0,H=0,yt=C.length;Hr&&(Ze-Oe)*(r-ye)>(on-ye)*(n-Oe)&&++ft:on<=r&&(Ze-Oe)*(r-ye)<(on-ye)*(n-Oe)&&--ft;return ft}function Y(){p=w,I=[],C=[],ue=!0}function rt(){var ft=at(),H=ue&&ft,yt=(I=c5(I)).length;(H||yt)&&(d.polygonStart(),H&&(d.lineStart(),o(null,null,1,d),d.lineEnd()),yt&&b5(I,c,ft,o,d),d.polygonEnd()),p=d,I=C=V=null}function Bt(){ve.point=F,C&&C.push(V=[]),zt=!0,st=!1,oe=Zt=NaN}function Dt(){I&&(F(Wt,Qt),Rt&&st&&w.rejoin(),I.push(w.result())),ve.point=an,st&&p.lineEnd()}function F(ft,H){var yt=s(ft,H);if(C&&V.push([ft,H]),zt)Wt=ft,Qt=H,Rt=yt,zt=!1,yt&&(p.lineStart(),p.point(ft,H));else if(yt&&st)p.point(ft,H);else{var Mt=[oe=Math.max(c_,Math.min(Lh,oe)),Zt=Math.max(c_,Math.min(Lh,Zt))],Kt=[ft=Math.max(c_,Math.min(Lh,ft)),H=Math.max(c_,Math.min(Lh,H))];w5(Mt,Kt,n,t,e,r)?(st||(p.lineStart(),p.point(Mt[0],Mt[1])),p.point(Kt[0],Kt[1]),yt||p.lineEnd(),ue=!1):yt&&(p.lineStart(),p.point(ft,H),ue=!1)}oe=ft,Zt=H,st=yt}return ve}}const E0=n=>n;var n0=new Uc,T0=new Uc,vb,bb,I0,O0,Ko={point:Gi,lineStart:Gi,lineEnd:Gi,polygonStart:function(){Ko.lineStart=S5,Ko.lineEnd=E5},polygonEnd:function(){Ko.lineStart=Ko.lineEnd=Ko.point=Gi,n0.add(Ic(T0)),T0=new Uc},result:function(){var n=n0/2;return n0=new Uc,n}};function S5(){Ko.point=A5}function A5(n,t){Ko.point=wb,vb=I0=n,bb=O0=t}function wb(n,t){T0.add(O0*n-I0*t),I0=n,O0=t}function E5(){wb(vb,bb)}const Hy=Ko;var Gc=1/0,U_=Gc,Vh=-Gc,G_=Vh,T5={point:I5,lineStart:Gi,lineEnd:Gi,polygonStart:Gi,polygonEnd:Gi,result:function(){var n=[[Gc,U_],[Vh,G_]];return Vh=G_=-(U_=Gc=1/0),n}};function I5(n,t){nVh&&(Vh=n),tG_&&(G_=t)}const $_=T5;var B0=0,L0=0,Mh=0,V_=0,j_=0,Ac=0,M0=0,R0=0,Rh=0,xb,Sb,Ys,Hs,cs={point:cu,lineStart:Xy,lineEnd:qy,polygonStart:function(){cs.lineStart=L5,cs.lineEnd=M5},polygonEnd:function(){cs.point=cu,cs.lineStart=Xy,cs.lineEnd=qy},result:function(){var n=Rh?[M0/Rh,R0/Rh]:Ac?[V_/Ac,j_/Ac]:Mh?[B0/Mh,L0/Mh]:[NaN,NaN];return B0=L0=Mh=V_=j_=Ac=M0=R0=Rh=0,n}};function cu(n,t){B0+=n,L0+=t,++Mh}function Xy(){cs.point=O5}function O5(n,t){cs.point=B5,cu(Ys=n,Hs=t)}function B5(n,t){var e=n-Ys,r=t-Hs,s=fg(e*e+r*r);V_+=s*(Ys+n)/2,j_+=s*(Hs+t)/2,Ac+=s,cu(Ys=n,Hs=t)}function qy(){cs.point=cu}function L5(){cs.point=R5}function M5(){Ab(xb,Sb)}function R5(n,t){cs.point=Ab,cu(xb=Ys=n,Sb=Hs=t)}function Ab(n,t){var e=n-Ys,r=t-Hs,s=fg(e*e+r*r);V_+=s*(Ys+n)/2,j_+=s*(Hs+t)/2,Ac+=s,s=Hs*n-Ys*t,M0+=s*(Ys+n),R0+=s*(Hs+t),Rh+=s*3,cu(Ys=n,Hs=t)}const Zy=cs;function Eb(n){this._context=n}Eb.prototype={_radius:4.5,pointRadius:function(n){return this._radius=n,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(n,t){switch(this._point){case 0:{this._context.moveTo(n,t),this._point=1;break}case 1:{this._context.lineTo(n,t);break}default:{this._context.moveTo(n+this._radius,t),this._context.arc(n,t,this._radius,0,d5);break}}},result:Gi};var N0=new Uc,r0,Tb,Ib,Nh,Dh,W_={point:Gi,lineStart:function(){W_.point=N5},lineEnd:function(){r0&&Ob(Tb,Ib),W_.point=Gi},polygonStart:function(){r0=!0},polygonEnd:function(){r0=null},result:function(){var n=+N0;return N0=new Uc,n}};function N5(n,t){W_.point=Ob,Tb=Nh=n,Ib=Dh=t}function Ob(n,t){Nh-=n,Dh-=t,N0.add(fg(Nh*Nh+Dh*Dh)),Nh=n,Dh=t}const Ky=W_;let Jy,Y_,Qy,tv;class ev{constructor(t){this._append=t==null?Bb:D5(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:{this._append`M${t},${e}`,this._point=1;break}case 1:{this._append`L${t},${e}`;break}default:{if(this._append`M${t},${e}`,this._radius!==Qy||this._append!==Y_){const r=this._radius,s=this._;this._="",this._append`m0,${r}a${r},${r} 0 1,1 0,${-2*r}a${r},${r} 0 1,1 0,${2*r}z`,Qy=r,Y_=this._append,tv=this._,this._=s}this._+=tv;break}}}result(){const t=this._;return this._="",t.length?t:null}}function Bb(n){let t=1;this._+=n[0];for(const e=n.length;t=0))throw new RangeError(`invalid digits: ${n}`);if(t>15)return Bb;if(t!==Jy){const e=10**t;Jy=t,Y_=function(s){let o=1;this._+=s[0];for(const f=s.length;o=0))throw new RangeError(`invalid digits: ${c}`);e=l}return t===null&&(o=new ev(e)),f},f.projection(n).digits(e).context(t)}function C5(n){return function(t){var e=new D0;for(var r in n)e[r]=n[r];return e.stream=t,e}}function D0(){}D0.prototype={constructor:D0,point:function(n,t){this.stream.point(n,t)},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()}};function ug(n,t,e){var r=n.clipExtent&&n.clipExtent();return n.scale(150).translate([0,0]),r!=null&&n.clipExtent(null),vc(e,n.stream($_)),t($_.result()),r!=null&&n.clipExtent(r),n}function Lb(n,t,e){return ug(n,function(r){var s=t[1][0]-t[0][0],o=t[1][1]-t[0][1],f=Math.min(s/(r[1][0]-r[0][0]),o/(r[1][1]-r[0][1])),c=+t[0][0]+(s-f*(r[1][0]+r[0][0]))/2,l=+t[0][1]+(o-f*(r[1][1]+r[0][1]))/2;n.scale(150*f).translate([c,l])},e)}function k5(n,t,e){return Lb(n,[[0,0],t],e)}function P5(n,t,e){return ug(n,function(r){var s=+t,o=s/(r[1][0]-r[0][0]),f=(s-o*(r[1][0]+r[0][0]))/2,c=-o*r[0][1];n.scale(150*o).translate([f,c])},e)}function z5(n,t,e){return ug(n,function(r){var s=+t,o=s/(r[1][1]-r[0][1]),f=-o*r[0][0],c=(s-o*(r[1][1]+r[0][1]))/2;n.scale(150*o).translate([f,c])},e)}function U5(){var n=1,t=0,e=0,r=1,s=1,o=0,f,c,l=null,d,p,w,I=1,C=1,V=C5({point:function(st,zt){var ue=Zt([st,zt]);this.stream.point(ue[0],ue[1])}}),Wt=E0,Qt,Rt;function oe(){return I=n*r,C=n*s,Qt=Rt=null,Zt}function Zt(st){var zt=st[0]*I,ue=st[1]*C;if(o){var ve=ue*f-zt*c;zt=zt*f+ue*c,ue=ve}return[zt+t,ue+e]}return Zt.invert=function(st){var zt=st[0]-t,ue=st[1]-e;if(o){var ve=ue*f+zt*c;zt=zt*f-ue*c,ue=ve}return[zt/I,ue/C]},Zt.stream=function(st){return Qt&&Rt===st?Qt:Qt=V(Wt(Rt=st))},Zt.postclip=function(st){return arguments.length?(Wt=st,l=d=p=w=null,oe()):Wt},Zt.clipExtent=function(st){return arguments.length?(Wt=st==null?(l=d=p=w=null,E0):x5(l=+st[0][0],d=+st[0][1],p=+st[1][0],w=+st[1][1]),oe()):l==null?null:[[l,d],[p,w]]},Zt.scale=function(st){return arguments.length?(n=+st,oe()):n},Zt.translate=function(st){return arguments.length?(t=+st[0],e=+st[1],oe()):[t,e]},Zt.angle=function(st){return arguments.length?(o=st%360*p5,c=g5(o),f=m5(o),oe()):o*_5},Zt.reflectX=function(st){return arguments.length?(r=st?-1:1,oe()):r<0},Zt.reflectY=function(st){return arguments.length?(s=st?-1:1,oe()):s<0},Zt.fitExtent=function(st,zt){return Lb(Zt,st,zt)},Zt.fitSize=function(st,zt){return k5(Zt,st,zt)},Zt.fitWidth=function(st,zt){return P5(Zt,st,zt)},Zt.fitHeight=function(st,zt){return z5(Zt,st,zt)},Zt}var ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},H_={},G5={get exports(){return H_},set exports(n){H_=n}};(function(n,t){var e=200,r="__lodash_hash_undefined__",s=800,o=16,f=9007199254740991,c="[object Arguments]",l="[object Array]",d="[object AsyncFunction]",p="[object Boolean]",w="[object Date]",I="[object Error]",C="[object Function]",V="[object GeneratorFunction]",Wt="[object Map]",Qt="[object Number]",Rt="[object Null]",oe="[object Object]",Zt="[object Proxy]",st="[object RegExp]",zt="[object Set]",ue="[object String]",ve="[object Undefined]",an="[object WeakMap]",at="[object ArrayBuffer]",Y="[object DataView]",rt="[object Float32Array]",Bt="[object Float64Array]",Dt="[object Int8Array]",F="[object Int16Array]",ft="[object Int32Array]",H="[object Uint8Array]",yt="[object Uint8ClampedArray]",Mt="[object Uint16Array]",Kt="[object Uint32Array]",ee=/[\\^$.*+?()[\]{}|]/g,de=/^\[object .+?Constructor\]$/,Oe=/^(?:0|[1-9]\d*)$/,ye={};ye[rt]=ye[Bt]=ye[Dt]=ye[F]=ye[ft]=ye[H]=ye[yt]=ye[Mt]=ye[Kt]=!0,ye[c]=ye[l]=ye[at]=ye[p]=ye[Y]=ye[w]=ye[I]=ye[C]=ye[Wt]=ye[Qt]=ye[oe]=ye[st]=ye[zt]=ye[ue]=ye[an]=!1;var Ze=typeof ls=="object"&&ls&&ls.Object===Object&&ls,on=typeof self=="object"&&self&&self.Object===Object&&self,En=Ze||on||Function("return this")(),Dn=t&&!t.nodeType&&t,hn=Dn&&!0&&n&&!n.nodeType&&n,Fn=hn&&hn.exports===Dn,ir=Fn&&Ze.process,Kn=function(){try{var B=hn&&hn.require&&hn.require("util").types;return B||ir&&ir.binding&&ir.binding("util")}catch{}}(),Yr=Kn&&Kn.isTypedArray;function rf(B,G,it){switch(it.length){case 0:return B.call(G);case 1:return B.call(G,it[0]);case 2:return B.call(G,it[0],it[1]);case 3:return B.call(G,it[0],it[1],it[2])}return B.apply(G,it)}function Rr(B,G){for(var it=-1,ie=Array(B);++it-1}function ml(B,G){var it=this.__data__,ie=Hi(it,B);return ie<0?(++this.size,it.push([B,G])):it[ie][1]=G,this}fi.prototype.clear=af,fi.prototype.delete=_l,fi.prototype.get=of,fi.prototype.has=pl,fi.prototype.set=ml;function Wi(B){var G=-1,it=B==null?0:B.length;for(this.clear();++G1?it[Ke-1]:void 0,De=Ke>2?it[2]:void 0;for(_n=B.length>3&&typeof _n=="function"?(Ke--,_n):void 0,De&&Lu(it[0],it[1],De)&&(_n=Ke<3?void 0:_n,Ke=1),G=Object(G);++ie-1&&B%1==0&&B0){if(++G>=s)return arguments[0]}else G=0;return B.apply(void 0,arguments)}}function Mu(B){if(B!=null){try{return Ei.call(B)}catch{}try{return B+""}catch{}}return""}function vo(B,G){return B===G||B!==B&&G!==G}var da=uf(function(){return arguments}())?uf:function(B){return _a(B)&&b.call(B,"callee")&&!_o.call(B,"callee")},gf=Array.isArray;function bo(B){return B!=null&&Nu(B.length)&&!yf(B)}function Rl(B){return _a(B)&&bo(B)}var Ru=fl||Dl;function yf(B){if(!ui(B))return!1;var G=po(B);return G==C||G==V||G==d||G==Zt}function Nu(B){return typeof B=="number"&&B>-1&&B%1==0&&B<=f}function ui(B){var G=typeof B;return B!=null&&(G=="object"||G=="function")}function _a(B){return B!=null&&typeof B=="object"}function Xi(B){if(!_a(B)||po(B)!=oe)return!1;var G=lo(B);if(G===null)return!0;var it=b.call(G,"constructor")&&G.constructor;return typeof it=="function"&&it instanceof it&&Ei.call(it)==ol}var Du=Yr?ws(Yr):Su;function Nl(B){return lf(B,pa(B))}function pa(B){return bo(B)?El(B,!0):Ol(B)}var yn=go(function(B,G,it){Au(B,G,it)});function vn(B){return function(){return B}}function vf(B){return B}function Dl(){return!1}n.exports=yn})(G5,H_);var $c=0,Fh=0,Th=0,Mb=1e3,X_,Ch,q_=0,lu=0,Bp=0,jh=typeof performance=="object"&&performance.now?performance:Date,Rb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function cg(){return lu||(Rb($5),lu=jh.now()+Bp)}function $5(){lu=0}function Z_(){this._call=this._time=this._next=null}Z_.prototype=ad.prototype={constructor:Z_,restart:function(n,t,e){if(typeof n!="function")throw new TypeError("callback is not a function");e=(e==null?cg():+e)+(t==null?0:+t),!this._next&&Ch!==this&&(Ch?Ch._next=this:X_=this,Ch=this),this._call=n,this._time=e,F0()},stop:function(){this._call&&(this._call=null,this._time=1/0,F0())}};function ad(n,t,e){var r=new Z_;return r.restart(n,t,e),r}function V5(){cg(),++$c;for(var n=X_,t;n;)(t=lu-n._time)>=0&&n._call.call(void 0,t),n=n._next;--$c}function nv(){lu=(q_=jh.now())+Bp,$c=Fh=0;try{V5()}finally{$c=0,W5(),lu=0}}function j5(){var n=jh.now(),t=n-q_;t>Mb&&(Bp-=t,q_=n)}function W5(){for(var n,t=X_,e,r=1/0;t;)t._call?(r>t._time&&(r=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:X_=e);Ch=n,F0(r)}function F0(n){if(!$c){Fh&&(Fh=clearTimeout(Fh));var t=n-lu;t>24?(n<1/0&&(Fh=setTimeout(nv,n-jh.now()-Bp)),Th&&(Th=clearInterval(Th))):(Th||(q_=jh.now(),Th=setInterval(j5,Mb)),$c=1,Rb(nv))}}function rv(n,t,e){var r=new Z_;return t=t==null?0:+t,r.restart(s=>{r.stop(),n(s+t)},t,e),r}var Y5={value:()=>{}};function Lp(){for(var n=0,t=arguments.length,e={},r;n=0&&(r=e.slice(s+1),e=e.slice(0,s)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:r}})}E_.prototype=Lp.prototype={constructor:E_,on:function(n,t){var e=this._,r=H5(n+"",e),s,o=-1,f=r.length;if(arguments.length<2){for(;++o0)for(var e=new Array(s),r=0,s,o;r()=>n;function C0(n,{sourceEvent:t,subject:e,target:r,identifier:s,active:o,x:f,y:c,dx:l,dy:d,dispatch:p}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:f,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}C0.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Z5(n){return!n.ctrlKey&&!n.button}function K5(){return this.parentNode}function J5(n,t){return t??{x:n.x,y:n.y}}function Q5(){return navigator.maxTouchPoints||"ontouchstart"in this}function t8(){var n=Z5,t=K5,e=J5,r=Q5,s={},o=Lp("start","drag","end"),f=0,c,l,d,p,w=0;function I(st){st.on("mousedown.drag",C).filter(r).on("touchstart.drag",Qt).on("touchmove.drag",Rt,q5).on("touchend.drag touchcancel.drag",oe).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function C(st,zt){if(!(p||!n.call(this,st,zt))){var ue=Zt(this,t.call(this,st,zt),st,zt,"mouse");ue&&(Wn(st.view).on("mousemove.drag",V,Wh).on("mouseup.drag",Wt,Wh),Nb(st.view),i0(st),d=!1,c=st.clientX,l=st.clientY,ue("start",st))}}function V(st){if(Oc(st),!d){var zt=st.clientX-c,ue=st.clientY-l;d=zt*zt+ue*ue>w}s.mouse("drag",st)}function Wt(st){Wn(st.view).on("mousemove.drag mouseup.drag",null),Db(st.view,d),Oc(st),s.mouse("end",st)}function Qt(st,zt){if(n.call(this,st,zt)){var ue=st.changedTouches,ve=t.call(this,st,zt),an=ue.length,at,Y;for(at=0;at>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?h_(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?h_(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=n8.exec(n))?new Fr(t[1],t[2],t[3],1):(t=r8.exec(n))?new Fr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=i8.exec(n))?h_(t[1],t[2],t[3],t[4]):(t=s8.exec(n))?h_(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=a8.exec(n))?lv(t[1],t[2]/100,t[3]/100,1):(t=o8.exec(n))?lv(t[1],t[2]/100,t[3]/100,t[4]):sv.hasOwnProperty(n)?fv(sv[n]):n==="transparent"?new Fr(NaN,NaN,NaN,0):null}function fv(n){return new Fr(n>>16&255,n>>8&255,n&255,1)}function h_(n,t,e,r){return r<=0&&(n=t=e=NaN),new Fr(n,t,e,r)}function Fb(n){return n instanceof nl||(n=du(n)),n?(n=n.rgb(),new Fr(n.r,n.g,n.b,n.opacity)):new Fr}function no(n,t,e,r){return arguments.length===1?Fb(n):new Fr(n,t,e,r??1)}function Fr(n,t,e,r){this.r=+n,this.g=+t,this.b=+e,this.opacity=+r}Mp(Fr,no,lg(nl,{brighter(n){return n=n==null?Vc:Math.pow(Vc,n),new Fr(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?hu:Math.pow(hu,n),new Fr(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new Fr(ou(this.r),ou(this.g),ou(this.b),K_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:uv,formatHex:uv,formatHex8:c8,formatRgb:cv,toString:cv}));function uv(){return`#${Qf(this.r)}${Qf(this.g)}${Qf(this.b)}`}function c8(){return`#${Qf(this.r)}${Qf(this.g)}${Qf(this.b)}${Qf((isNaN(this.opacity)?1:this.opacity)*255)}`}function cv(){const n=K_(this.opacity);return`${n===1?"rgb(":"rgba("}${ou(this.r)}, ${ou(this.g)}, ${ou(this.b)}${n===1?")":`, ${n})`}`}function K_(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function ou(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function Qf(n){return n=ou(n),(n<16?"0":"")+n.toString(16)}function lv(n,t,e,r){return r<=0?n=t=e=NaN:e<=0||e>=1?n=t=NaN:t<=0&&(n=NaN),new hs(n,t,e,r)}function Cb(n){if(n instanceof hs)return new hs(n.h,n.s,n.l,n.opacity);if(n instanceof nl||(n=du(n)),!n)return new hs;if(n instanceof hs)return n;n=n.rgb();var t=n.r/255,e=n.g/255,r=n.b/255,s=Math.min(t,e,r),o=Math.max(t,e,r),f=NaN,c=o-s,l=(o+s)/2;return c?(t===o?f=(e-r)/c+(e0&&l<1?0:f,new hs(f,c,l,n.opacity)}function l8(n,t,e,r){return arguments.length===1?Cb(n):new hs(n,t,e,r??1)}function hs(n,t,e,r){this.h=+n,this.s=+t,this.l=+e,this.opacity=+r}Mp(hs,l8,lg(nl,{brighter(n){return n=n==null?Vc:Math.pow(Vc,n),new hs(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?hu:Math.pow(hu,n),new hs(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,t=isNaN(n)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*t,s=2*e-r;return new Fr(s0(n>=240?n-240:n+120,s,r),s0(n,s,r),s0(n<120?n+240:n-120,s,r),this.opacity)},clamp(){return new hs(hv(this.h),d_(this.s),d_(this.l),K_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=K_(this.opacity);return`${n===1?"hsl(":"hsla("}${hv(this.h)}, ${d_(this.s)*100}%, ${d_(this.l)*100}%${n===1?")":`, ${n})`}`}}));function hv(n){return n=(n||0)%360,n<0?n+360:n}function d_(n){return Math.max(0,Math.min(1,n||0))}function s0(n,t,e){return(n<60?t+(e-t)*n/60:n<180?e:n<240?t+(e-t)*(240-n)/60:t)*255}const h8=Math.PI/180,d8=180/Math.PI;var kb=-.14861,hg=1.78277,dg=-.29227,Rp=-.90649,Hh=1.97294,dv=Hh*Rp,_v=Hh*hg,pv=hg*dg-Rp*kb;function _8(n){if(n instanceof fu)return new fu(n.h,n.s,n.l,n.opacity);n instanceof Fr||(n=Fb(n));var t=n.r/255,e=n.g/255,r=n.b/255,s=(pv*r+dv*t-_v*e)/(pv+dv-_v),o=r-s,f=(Hh*(e-s)-dg*o)/Rp,c=Math.sqrt(f*f+o*o)/(Hh*s*(1-s)),l=c?Math.atan2(f,o)*d8-120:NaN;return new fu(l<0?l+360:l,c,s,n.opacity)}function ra(n,t,e,r){return arguments.length===1?_8(n):new fu(n,t,e,r??1)}function fu(n,t,e,r){this.h=+n,this.s=+t,this.l=+e,this.opacity=+r}Mp(fu,ra,lg(nl,{brighter(n){return n=n==null?Vc:Math.pow(Vc,n),new fu(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?hu:Math.pow(hu,n),new fu(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=isNaN(this.h)?0:(this.h+120)*h8,t=+this.l,e=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(n),s=Math.sin(n);return new Fr(255*(t+e*(kb*r+hg*s)),255*(t+e*(dg*r+Rp*s)),255*(t+e*(Hh*r)),this.opacity)}}));function p8(n,t,e,r,s){var o=n*n,f=o*n;return((1-3*n+3*o-f)*t+(4-6*o+3*f)*e+(1+3*n+3*o-3*f)*r+f*s)/6}function m8(n){var t=n.length-1;return function(e){var r=e<=0?e=0:e>=1?(e=1,t-1):Math.floor(e*t),s=n[r],o=n[r+1],f=r>0?n[r-1]:2*s-o,c=r()=>n;function Pb(n,t){return function(e){return n+e*t}}function g8(n,t,e){return n=Math.pow(n,e),t=Math.pow(t,e)-n,e=1/e,function(r){return Math.pow(n+r*t,e)}}function y8(n,t){var e=t-n;return e?Pb(n,e>180||e<-180?e-360*Math.round(e/360):e):Np(isNaN(n)?t:n)}function v8(n){return(n=+n)==1?Lc:function(t,e){return e-t?g8(t,e,n):Np(isNaN(t)?e:t)}}function Lc(n,t){var e=t-n;return e?Pb(n,e):Np(isNaN(n)?t:n)}const J_=function n(t){var e=v8(t);function r(s,o){var f=e((s=no(s)).r,(o=no(o)).r),c=e(s.g,o.g),l=e(s.b,o.b),d=Lc(s.opacity,o.opacity);return function(p){return s.r=f(p),s.g=c(p),s.b=l(p),s.opacity=d(p),s+""}}return r.gamma=n,r}(1);function b8(n){return function(t){var e=t.length,r=new Array(e),s=new Array(e),o=new Array(e),f,c;for(f=0;fe&&(o=t.slice(e,o),c[f]?c[f]+=o:c[++f]=o),(r=r[0])===(s=s[0])?c[f]?c[f]+=s:c[++f]=s:(c[++f]=null,l.push({i:f,x:us(r,s)})),e=a0.lastIndex;return e180?p+=360:p-d>180&&(d+=360),I.push({i:w.push(s(w)+"rotate(",null,r)-2,x:us(d,p)})):p&&w.push(s(w)+"rotate("+p+r)}function c(d,p,w,I){d!==p?I.push({i:w.push(s(w)+"skewX(",null,r)-2,x:us(d,p)}):p&&w.push(s(w)+"skewX("+p+r)}function l(d,p,w,I,C,V){if(d!==w||p!==I){var Wt=C.push(s(C)+"scale(",null,",",null,")");V.push({i:Wt-4,x:us(d,w)},{i:Wt-2,x:us(p,I)})}else(w!==1||I!==1)&&C.push(s(C)+"scale("+w+","+I+")")}return function(d,p){var w=[],I=[];return d=n(d),p=n(p),o(d.translateX,d.translateY,p.translateX,p.translateY,w,I),f(d.rotate,p.rotate,w,I),c(d.skewX,p.skewX,w,I),l(d.scaleX,d.scaleY,p.scaleX,p.scaleY,w,I),d=p=null,function(C){for(var V=-1,Wt=I.length,Qt;++Vjb)throw new Error("too late; already scheduled");return e}function oa(n,t){var e=vs(n,t);if(e.state>T_)throw new Error("too late; already running");return e}function vs(n,t){var e=n.__transition;if(!e||!(e=e[t]))throw new Error("transition not found");return e}function z8(n,t,e){var r=n.__transition,s;r[t]=e,e.timer=ad(o,0,e.time);function o(d){e.state=yv,e.timer.restart(f,e.delay,e.time),e.delay<=d&&f(d-e.delay)}function f(d){var p,w,I,C;if(e.state!==yv)return l();for(p in r)if(C=r[p],C.name===e.name){if(C.state===T_)return rv(f);C.state===vv?(C.state=I_,C.timer.stop(),C.on.call("interrupt",n,n.__data__,C.index,C.group),delete r[p]):+pz0&&r.state=0&&(t=t.slice(0,e)),!t||t==="start"})}function pE(n,t,e){var r,s,o=_E(t)?pg:oa;return function(){var f=o(this,n),c=f.on;c!==r&&(s=(r=c).copy()).on(t,e),f.on=s}}function mE(n,t){var e=this._id;return arguments.length<2?vs(this.node(),e).on.on(n):this.each(pE(e,n,t))}function gE(n){return function(){var t=this.parentNode;for(var e in this.__transition)if(+e!==n)return;t&&t.removeChild(this)}}function yE(){return this.on("end.remove",gE(this._id))}function vE(n){var t=this._name,e=this._id;typeof n!="function"&&(n=sg(n));for(var r=this._groups,s=r.length,o=new Array(s),f=0;f()=>n;function jE(n,{sourceEvent:t,target:e,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Qa(n,t,e){this.k=n,this.x=t,this.y=e}Qa.prototype={constructor:Qa,scale:function(n){return n===1?this:new Qa(this.k*n,this.x,this.y)},translate:function(n,t){return n===0&t===0?this:new Qa(this.k,this.x+this.k*n,this.y+this.k*t)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var zh=new Qa(1,0,0);Qa.prototype;function o0(n){n.stopImmediatePropagation()}function Ih(n){n.preventDefault(),n.stopImmediatePropagation()}function WE(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function YE(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function bv(){return this.__zoom||zh}function HE(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function XE(){return navigator.maxTouchPoints||"ontouchstart"in this}function qE(n,t,e){var r=n.invertX(t[0][0])-e[0][0],s=n.invertX(t[1][0])-e[1][0],o=n.invertY(t[0][1])-e[0][1],f=n.invertY(t[1][1])-e[1][1];return n.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),f>o?(o+f)/2:Math.min(0,o)||Math.max(0,f))}function ZE(){var n=WE,t=YE,e=qE,r=HE,s=XE,o=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],c=250,l=C8,d=Lp("start","zoom","end"),p,w,I,C=500,V=150,Wt=0,Qt=10;function Rt(F){F.property("__zoom",bv).on("wheel.zoom",an,{passive:!1}).on("mousedown.zoom",at).on("dblclick.zoom",Y).filter(s).on("touchstart.zoom",rt).on("touchmove.zoom",Bt).on("touchend.zoom touchcancel.zoom",Dt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}Rt.transform=function(F,ft,H,yt){var Mt=F.selection?F.selection():F;Mt.property("__zoom",bv),F!==Mt?zt(F,ft,H,yt):Mt.interrupt().each(function(){ue(this,arguments).event(yt).start().zoom(null,typeof ft=="function"?ft.apply(this,arguments):ft).end()})},Rt.scaleBy=function(F,ft,H,yt){Rt.scaleTo(F,function(){var Mt=this.__zoom.k,Kt=typeof ft=="function"?ft.apply(this,arguments):ft;return Mt*Kt},H,yt)},Rt.scaleTo=function(F,ft,H,yt){Rt.transform(F,function(){var Mt=t.apply(this,arguments),Kt=this.__zoom,ee=H==null?st(Mt):typeof H=="function"?H.apply(this,arguments):H,de=Kt.invert(ee),Oe=typeof ft=="function"?ft.apply(this,arguments):ft;return e(Zt(oe(Kt,Oe),ee,de),Mt,f)},H,yt)},Rt.translateBy=function(F,ft,H,yt){Rt.transform(F,function(){return e(this.__zoom.translate(typeof ft=="function"?ft.apply(this,arguments):ft,typeof H=="function"?H.apply(this,arguments):H),t.apply(this,arguments),f)},null,yt)},Rt.translateTo=function(F,ft,H,yt,Mt){Rt.transform(F,function(){var Kt=t.apply(this,arguments),ee=this.__zoom,de=yt==null?st(Kt):typeof yt=="function"?yt.apply(this,arguments):yt;return e(zh.translate(de[0],de[1]).scale(ee.k).translate(typeof ft=="function"?-ft.apply(this,arguments):-ft,typeof H=="function"?-H.apply(this,arguments):-H),Kt,f)},yt,Mt)};function oe(F,ft){return ft=Math.max(o[0],Math.min(o[1],ft)),ft===F.k?F:new Qa(ft,F.x,F.y)}function Zt(F,ft,H){var yt=ft[0]-H[0]*F.k,Mt=ft[1]-H[1]*F.k;return yt===F.x&&Mt===F.y?F:new Qa(F.k,yt,Mt)}function st(F){return[(+F[0][0]+ +F[1][0])/2,(+F[0][1]+ +F[1][1])/2]}function zt(F,ft,H,yt){F.on("start.zoom",function(){ue(this,arguments).event(yt).start()}).on("interrupt.zoom end.zoom",function(){ue(this,arguments).event(yt).end()}).tween("zoom",function(){var Mt=this,Kt=arguments,ee=ue(Mt,Kt).event(yt),de=t.apply(Mt,Kt),Oe=H==null?st(de):typeof H=="function"?H.apply(Mt,Kt):H,ye=Math.max(de[1][0]-de[0][0],de[1][1]-de[0][1]),Ze=Mt.__zoom,on=typeof ft=="function"?ft.apply(Mt,Kt):ft,En=l(Ze.invert(Oe).concat(ye/Ze.k),on.invert(Oe).concat(ye/on.k));return function(Dn){if(Dn===1)Dn=on;else{var hn=En(Dn),Fn=ye/hn[2];Dn=new Qa(Fn,Oe[0]-hn[0]*Fn,Oe[1]-hn[1]*Fn)}ee.zoom(null,Dn)}})}function ue(F,ft,H){return!H&&F.__zooming||new ve(F,ft)}function ve(F,ft){this.that=F,this.args=ft,this.active=0,this.sourceEvent=null,this.extent=t.apply(F,ft),this.taps=0}ve.prototype={event:function(F){return F&&(this.sourceEvent=F),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(F,ft){return this.mouse&&F!=="mouse"&&(this.mouse[1]=ft.invert(this.mouse[0])),this.touch0&&F!=="touch"&&(this.touch0[1]=ft.invert(this.touch0[0])),this.touch1&&F!=="touch"&&(this.touch1[1]=ft.invert(this.touch1[0])),this.that.__zoom=ft,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(F){var ft=Wn(this.that).datum();d.call(F,this.that,new jE(F,{sourceEvent:this.sourceEvent,target:Rt,type:F,transform:this.that.__zoom,dispatch:d}),ft)}};function an(F,...ft){if(!n.apply(this,arguments))return;var H=ue(this,ft).event(F),yt=this.__zoom,Mt=Math.max(o[0],Math.min(o[1],yt.k*Math.pow(2,r.apply(this,arguments)))),Kt=Xa(F);if(H.wheel)(H.mouse[0][0]!==Kt[0]||H.mouse[0][1]!==Kt[1])&&(H.mouse[1]=yt.invert(H.mouse[0]=Kt)),clearTimeout(H.wheel);else{if(yt.k===Mt)return;H.mouse=[Kt,yt.invert(Kt)],O_(this),H.start()}Ih(F),H.wheel=setTimeout(ee,V),H.zoom("mouse",e(Zt(oe(yt,Mt),H.mouse[0],H.mouse[1]),H.extent,f));function ee(){H.wheel=null,H.end()}}function at(F,...ft){if(I||!n.apply(this,arguments))return;var H=F.currentTarget,yt=ue(this,ft,!0).event(F),Mt=Wn(F.view).on("mousemove.zoom",Oe,!0).on("mouseup.zoom",ye,!0),Kt=Xa(F,H),ee=F.clientX,de=F.clientY;Nb(F.view),o0(F),yt.mouse=[Kt,this.__zoom.invert(Kt)],O_(this),yt.start();function Oe(Ze){if(Ih(Ze),!yt.moved){var on=Ze.clientX-ee,En=Ze.clientY-de;yt.moved=on*on+En*En>Wt}yt.event(Ze).zoom("mouse",e(Zt(yt.that.__zoom,yt.mouse[0]=Xa(Ze,H),yt.mouse[1]),yt.extent,f))}function ye(Ze){Mt.on("mousemove.zoom mouseup.zoom",null),Db(Ze.view,yt.moved),Ih(Ze),yt.event(Ze).end()}}function Y(F,...ft){if(n.apply(this,arguments)){var H=this.__zoom,yt=Xa(F.changedTouches?F.changedTouches[0]:F,this),Mt=H.invert(yt),Kt=H.k*(F.shiftKey?.5:2),ee=e(Zt(oe(H,Kt),yt,Mt),t.apply(this,ft),f);Ih(F),c>0?Wn(this).transition().duration(c).call(zt,ee,yt,F):Wn(this).call(Rt.transform,ee,yt,F)}}function rt(F,...ft){if(n.apply(this,arguments)){var H=F.touches,yt=H.length,Mt=ue(this,ft,F.changedTouches.length===yt).event(F),Kt,ee,de,Oe;for(o0(F),ee=0;eet&&(e=n,n=t,t=e),function(r){return Math.max(n,Math.min(t,r))}}function QE(n,t,e){var r=n[0],s=n[1],o=t[0],f=t[1];return s2?tT:QE,l=d=null,w}function w(I){return I==null||isNaN(I=+I)?o:(l||(l=c(n.map(r),t,e)))(r(f(I)))}return w.invert=function(I){return f(s((d||(d=c(t,n.map(r),us)))(I)))},w.domain=function(I){return arguments.length?(n=Array.from(I,$0),p()):n.slice()},w.range=function(I){return arguments.length?(t=Array.from(I),p()):t.slice()},w.rangeRound=function(I){return t=Array.from(I),e=Ub,p()},w.clamp=function(I){return arguments.length?(f=I?!0:$i,p()):f!==$i},w.interpolate=function(I){return arguments.length?(e=I,p()):e},w.unknown=function(I){return arguments.length?(o=I,w):o},function(I,C){return r=I,s=C,p()}}function eT(){return vg()($i,$i)}function nT(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function Q_(n,t){if((e=(n=t?n.toExponential(t-1):n.toExponential()).indexOf("e"))<0)return null;var e,r=n.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+n.slice(e+1)]}function jc(n){return n=Q_(Math.abs(n)),n?n[1]:NaN}function rT(n,t){return function(e,r){for(var s=e.length,o=[],f=0,c=n[0],l=0;s>0&&c>0&&(l+c+1>r&&(c=Math.max(1,r-l)),o.push(e.substring(s-=c,s+c)),!((l+=c+1)>r));)c=n[f=(f+1)%n.length];return o.reverse().join(t)}}function iT(n){return function(t){return t.replace(/[0-9]/g,function(e){return n[+e]})}}var sT=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Xh(n){if(!(t=sT.exec(n)))throw new Error("invalid format: "+n);var t;return new bg({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Xh.prototype=bg.prototype;function bg(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}bg.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function aT(n){t:for(var t=n.length,e=1,r=-1,s;e0&&(r=0);break}return r>0?n.slice(0,r)+n.slice(s+1):n}var Xb;function oT(n,t){var e=Q_(n,t);if(!e)return n+"";var r=e[0],s=e[1],o=s-(Xb=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,f=r.length;return o===f?r:o>f?r+new Array(o-f+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Q_(n,Math.max(0,t+o-1))[0]}function Sv(n,t){var e=Q_(n,t);if(!e)return n+"";var r=e[0],s=e[1];return s<0?"0."+new Array(-s).join("0")+r:r.length>s+1?r.slice(0,s+1)+"."+r.slice(s+1):r+new Array(s-r.length+2).join("0")}const Av={"%":(n,t)=>(n*100).toFixed(t),b:n=>Math.round(n).toString(2),c:n=>n+"",d:nT,e:(n,t)=>n.toExponential(t),f:(n,t)=>n.toFixed(t),g:(n,t)=>n.toPrecision(t),o:n=>Math.round(n).toString(8),p:(n,t)=>Sv(n*100,t),r:Sv,s:oT,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Ev(n){return n}var Tv=Array.prototype.map,Iv=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function fT(n){var t=n.grouping===void 0||n.thousands===void 0?Ev:rT(Tv.call(n.grouping,Number),n.thousands+""),e=n.currency===void 0?"":n.currency[0]+"",r=n.currency===void 0?"":n.currency[1]+"",s=n.decimal===void 0?".":n.decimal+"",o=n.numerals===void 0?Ev:iT(Tv.call(n.numerals,String)),f=n.percent===void 0?"%":n.percent+"",c=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function d(w){w=Xh(w);var I=w.fill,C=w.align,V=w.sign,Wt=w.symbol,Qt=w.zero,Rt=w.width,oe=w.comma,Zt=w.precision,st=w.trim,zt=w.type;zt==="n"?(oe=!0,zt="g"):Av[zt]||(Zt===void 0&&(Zt=12),st=!0,zt="g"),(Qt||I==="0"&&C==="=")&&(Qt=!0,I="0",C="=");var ue=Wt==="$"?e:Wt==="#"&&/[boxX]/.test(zt)?"0"+zt.toLowerCase():"",ve=Wt==="$"?r:/[%p]/.test(zt)?f:"",an=Av[zt],at=/[defgprs%]/.test(zt);Zt=Zt===void 0?6:/[gprs]/.test(zt)?Math.max(1,Math.min(21,Zt)):Math.max(0,Math.min(20,Zt));function Y(rt){var Bt=ue,Dt=ve,F,ft,H;if(zt==="c")Dt=an(rt)+Dt,rt="";else{rt=+rt;var yt=rt<0||1/rt<0;if(rt=isNaN(rt)?l:an(Math.abs(rt),Zt),st&&(rt=aT(rt)),yt&&+rt==0&&V!=="+"&&(yt=!1),Bt=(yt?V==="("?V:c:V==="-"||V==="("?"":V)+Bt,Dt=(zt==="s"?Iv[8+Xb/3]:"")+Dt+(yt&&V==="("?")":""),at){for(F=-1,ft=rt.length;++FH||H>57){Dt=(H===46?s+rt.slice(F+1):rt.slice(F))+Dt,rt=rt.slice(0,F);break}}}oe&&!Qt&&(rt=t(rt,1/0));var Mt=Bt.length+rt.length+Dt.length,Kt=Mt>1)+Bt+rt+Dt+Kt.slice(Mt);break;default:rt=Kt+Bt+rt+Dt;break}return o(rt)}return Y.toString=function(){return w+""},Y}function p(w,I){var C=d((w=Xh(w),w.type="f",w)),V=Math.max(-8,Math.min(8,Math.floor(jc(I)/3)))*3,Wt=Math.pow(10,-V),Qt=Iv[8+V/3];return function(Rt){return C(Wt*Rt)+Qt}}return{format:d,formatPrefix:p}}var m_,wg,qb;uT({thousands:",",grouping:[3],currency:["$",""]});function uT(n){return m_=fT(n),wg=m_.format,qb=m_.formatPrefix,m_}function cT(n){return Math.max(0,-jc(Math.abs(n)))}function lT(n,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(jc(t)/3)))*3-jc(Math.abs(n)))}function hT(n,t){return n=Math.abs(n),t=Math.abs(t)-n,Math.max(0,jc(t)-jc(n))+1}function dT(n,t,e,r){var s=f5(n,t,e),o;switch(r=Xh(r??",f"),r.type){case"s":{var f=Math.max(Math.abs(n),Math.abs(t));return r.precision==null&&!isNaN(o=lT(s,f))&&(r.precision=o),qb(r,f)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=hT(s,Math.max(Math.abs(n),Math.abs(t))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=cT(s))&&(r.precision=o-(r.type==="%")*2);break}}return wg(r)}function kp(n){var t=n.domain;return n.ticks=function(e){var r=t();return b0(r[0],r[r.length-1],e??10)},n.tickFormat=function(e,r){var s=t();return dT(s[0],s[s.length-1],e??10,r)},n.nice=function(e){e==null&&(e=10);var r=t(),s=0,o=r.length-1,f=r[s],c=r[o],l,d,p=10;for(c0;){if(d=w0(f,c,e),d===l)return r[s]=f,r[o]=c,t(r);if(d>0)f=Math.floor(f/d)*d,c=Math.ceil(c/d)*d;else if(d<0)f=Math.ceil(f*d)/d,c=Math.floor(c*d)/d;else break;l=d}return n},n}function tp(){var n=eT();return n.copy=function(){return yg(n,tp())},Cp.apply(n,arguments),kp(n)}function Zb(n){var t;function e(r){return r==null||isNaN(r=+r)?t:r}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(n=Array.from(r,$0),e):n.slice()},e.unknown=function(r){return arguments.length?(t=r,e):t},e.copy=function(){return Zb(n).unknown(t)},n=arguments.length?Array.from(n,$0):[0,1],kp(e)}function _T(n,t){n=n.slice();var e=0,r=n.length-1,s=n[e],o=n[r],f;return oMath.pow(n,t)}function vT(n){return n===Math.E?Math.log:n===10&&Math.log10||n===2&&Math.log2||(n=Math.log(n),t=>Math.log(t)/n)}function Lv(n){return(t,e)=>-n(-t,e)}function Kb(n){const t=n(Ov,Bv),e=t.domain;let r=10,s,o;function f(){return s=vT(r),o=yT(r),e()[0]<0?(s=Lv(s),o=Lv(o),n(pT,mT)):n(Ov,Bv),t}return t.base=function(c){return arguments.length?(r=+c,f()):r},t.domain=function(c){return arguments.length?(e(c),f()):e()},t.ticks=c=>{const l=e();let d=l[0],p=l[l.length-1];const w=p0){for(;I<=C;++I)for(V=1;Vp)break;Rt.push(Wt)}}else for(;I<=C;++I)for(V=r-1;V>=1;--V)if(Wt=I>0?V/o(-I):V*o(I),!(Wtp)break;Rt.push(Wt)}Rt.length*2{if(c==null&&(c=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=Xh(l)).precision==null&&(l.trim=!0),l=wg(l)),c===1/0)return l;const d=Math.max(1,r*c/t.ticks().length);return p=>{let w=p/o(Math.round(s(p)));return w*re(_T(e(),{floor:c=>o(Math.floor(s(c))),ceil:c=>o(Math.ceil(s(c)))})),t}function Jb(){const n=Kb(vg()).domain([1,10]);return n.copy=()=>yg(n,Jb()).base(n.base()),Cp.apply(n,arguments),n}function Mv(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function bT(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function wT(n){return n<0?-n*n:n*n}function Qb(n){var t=n($i,$i),e=1;function r(){return e===1?n($i,$i):e===.5?n(bT,wT):n(Mv(e),Mv(1/e))}return t.exponent=function(s){return arguments.length?(e=+s,r()):e},kp(t)}function t1(){var n=Qb(vg());return n.copy=function(){return yg(n,t1()).exponent(n.exponent())},Cp.apply(n,arguments),n}function xT(){return t1.apply(null,arguments).exponent(.5)}function xg(){var n=0,t=1,e,r,s,o,f=$i,c=!1,l;function d(w){return w==null||isNaN(w=+w)?l:f(s===0?.5:(w=(o(w)-e)*s,c?Math.max(0,Math.min(1,w)):w))}d.domain=function(w){return arguments.length?([n,t]=w,e=o(n=+n),r=o(t=+t),s=e===r?0:1/(r-e),d):[n,t]},d.clamp=function(w){return arguments.length?(c=!!w,d):c},d.interpolator=function(w){return arguments.length?(f=w,d):f};function p(w){return function(I){var C,V;return arguments.length?([C,V]=I,f=w(C,V),d):[f(0),f(1)]}}return d.range=p(Dp),d.rangeRound=p(Ub),d.unknown=function(w){return arguments.length?(l=w,d):l},function(w){return o=w,e=w(n),r=w(t),s=e===r?0:1/(r-e),d}}function Sg(n,t){return t.domain(n.domain()).interpolator(n.interpolator()).clamp(n.clamp()).unknown(n.unknown())}function e1(){var n=kp(xg()($i));return n.copy=function(){return Sg(n,e1())},gg.apply(n,arguments)}function n1(){var n=Kb(xg()).domain([1,10]);return n.copy=function(){return Sg(n,n1()).base(n.base())},gg.apply(n,arguments)}function r1(){var n=Qb(xg());return n.copy=function(){return Sg(n,r1()).exponent(n.exponent())},gg.apply(n,arguments)}class ST{constructor(t,e,r){this.prefs=e,this.svg_element_selection=Wn(t),this.width=+this.svg_element_selection.attr("width"),this.height=+this.svg_element_selection.attr("height"),this.renderers=new Map,this.scatterplot=r,this.renderers=new Map}attach_tiles(t){return this.tileSet=t,this.tileSet._zoom=this,this}attach_renderer(t,e){return this.renderers.set(t,e),e.bind_zoom(this),e.zoom.initialize_zoom(),this}zoom_to(t,e,r,s=4e3){const o=this.scales(),{svg_element_selection:f,zoomer:c,width:l,height:d}=this,p=zh.translate(l/2,d/2).scale(t).translate(-o.x(e),-o.y(r));f.transition().duration(s).call(c.transform,p)}html_annotation(t){const e=this.svg_element_selection.node().parentNode.parentNode;let r=.75;this.scatterplot.prefs.tooltip_opacity!==void 0&&(r=this.scatterplot.prefs.tooltip_opacity),Wn(e).selectAll("div.tooltip").data(t).join(o=>o.append("div").attr("class","tooltip").style("top",0).style("left",0).style("position","absolute").style("z-index",100).style("border-radius","8px").style("padding","10px").style("background","ivory").style("opacity",r),o=>o.html(f=>this.scatterplot.tooltip_html(f.data,this.scatterplot)),o=>o.call(f=>f.remove())).html(o=>this.scatterplot.tooltip_html(o.data,this)).style("transform",o=>`translate(${+o.x+o.dx}px, ${+o.y+o.dy}px)`)}zoom_to_bbox(t,e=4e3,r=1.111){const s=this.scales();let[o,f]=t.x.map(s.x);const[c,l]=t.y.map(s.y);if(this.scatterplot.prefs.zoom_align==="right"){const V=this.width/this.height,Wt=(f-o)/(l-c);if(Wt{var f,c,l;try{document.getElementById("tooltipcircle").remove()}catch{}this.transform=o.transform,this.restart_timer(10*1e3),(c=(f=this.scatterplot).on_zoom)==null||c.call(f,o.transform),(l=o==null?void 0:o.sourceEvent)==null||l.stopPropagation()});r.call(s),this.add_mouseover(),this.zoomer=s}set_highlit_points(t){const{x_:e,y_:r}=this.scales(),s=this.scatterplot.dim("x"),o=this.scatterplot.dim("y"),f=t.map(l=>({x:e(s.apply(l)),y:r(o.apply(l)),data:l,dx:0,dy:30}));this.html_annotation(f),this.svg_element_selection.select("#mousepoints").selectAll("circle.label").data(t,l=>l.ix).join(l=>l.append("circle").attr("id","tooltipcircle").attr("class","label").attr("stroke","#110022").attr("r",12).attr("fill",d=>this.scatterplot.dim("color").apply(d)).attr("cx",d=>e(s.apply(d))).attr("cy",d=>r(o.apply(d))),l=>l.attr("fill",d=>this.scatterplot.dim("color").apply(d)),l=>l.call(d=>{d.remove()})).on("click",(l,d)=>{this.scatterplot.click_function(d,this.scatterplot)})}set_highlit_point(t){this.set_highlit_points([t])}add_mouseover(){let t=0;const e=this.renderers.get("regl");this.svg_element_selection.on("mousemove",r=>{if(Date.now()-t<75)return;t=Date.now();const s=e.color_pick(r.offsetX,r.offsetY);s===null?this.set_highlit_points([]):this.set_highlit_points([s])})}current_corners(){const{width:t,height:e}=this,r=this.scales();if(r===void 0)return;const{x_:s,y_:o}=r;return{x:[s.invert(0),s.invert(t)],y:[o.invert(0),o.invert(e)]}}current_center(){const{x:t,y:e}=this.current_corners();return[(t[0]+t[1])/2,(e[0]+e[1])/2]}restart_timer(t=1e4){let e=Date.now()+t;this._timer&&(this._timer.stop_at>e&&(e=this._timer.stop_at),this._timer.stop());const r=ad(this.tick.bind(this));return this._timer=r,this._timer.stop_at=e,this._timer}data(t){return t===void 0?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:r}=this;if(this.tileSet===void 0)throw new Error("Error--scales created before tileSet present.");const{extent:s}=this.tileSet,o={};if(s===void 0)throw new Error("Error--scales created before extent present.");const f={};for(const[I,C]of[["x",e],["y",r]]){const V=s[I],Wt=V[1]-V[0];f[I]={limits:V,size_range:Wt,pixels_per_unit:C/Wt}}const c=f.x.pixels_per_unit/f.y.pixels_per_unit;let l=0,d=0,p=e,w=r;return c>1?(p=e/c,l=(e-p)/2):(w=r*c,d=(r-w)/2),o.x=tp().domain(f.x.limits).range([l,e-l]),o.y=tp().domain(f.y.limits).range([d,r-d]),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:r}=this.scales();return AT(e,r).flat()}tick(t=!1){this._start=this._start||Date.now(),t!==!0&&this._timer&&this._timer.stop_at<=Date.now()&&this._timer.stop()}}function AT(n,t){function e(l){return l[1]-l[0]}const r=f_(n.domain()),s=f_(t.domain()),o=e(n.range())/e(n.domain()),f=e(t.range())/e(t.domain());return[[o,0,-o*r+f_(n.range())],[0,f,-f*s+f_(t.range())],[0,0,1]]}var j0={},ET={get exports(){return j0},set exports(n){j0=n}};(function(n,t){(function(e,r){n.exports=r()})(ls,function(){var e=function(_){return _ instanceof Uint8Array||_ instanceof Uint16Array||_ instanceof Uint32Array||_ instanceof Int8Array||_ instanceof Int16Array||_ instanceof Int32Array||_ instanceof Float32Array||_ instanceof Float64Array||_ instanceof Uint8ClampedArray},r=function(_,v){for(var L=Object.keys(v),tt=0;tt"u";case"symbol":return typeof _=="symbol"}}function I(_,v,L){w(_,v)||f("invalid parameter type"+l(L)+". expected "+v+", got "+typeof _)}function C(_,v){_>=0&&(_|0)===_||f("invalid parameter type, ("+_+")"+l(v)+". must be a nonnegative integer")}function V(_,v,L){v.indexOf(_)<0&&f("invalid value"+l(L)+". must be one of: "+v)}var Wt=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function Qt(_){Object.keys(_).forEach(function(v){Wt.indexOf(v)<0&&f('invalid regl constructor argument "'+v+'". must be one of '+Wt)})}function Rt(_,v){for(_=_+"";_.length0&&v.push(new st("unknown",0,L))}}),v}function at(_,v){v.forEach(function(L){var tt=_[L.file];if(tt){var lt=tt.index[L.line];if(lt){lt.errors.push(L),tt.hasErrors=!0;return}}_.unknown.hasErrors=!0,_.unknown.lines[0].errors.push(L)})}function Y(_,v,L,tt,lt){if(!_.getShaderParameter(v,_.COMPILE_STATUS)){var K=_.getShaderInfoLog(v),et=tt===_.FRAGMENT_SHADER?"fragment":"vertex";yt(L,"string",et+" shader source must be a string",lt);var bt=ve(L,lt),vt=an(K);at(bt,vt),Object.keys(bt).forEach(function(It){var Lt=bt[It];if(!Lt.hasErrors)return;var Ot=[""],Ct=[""];function wt(Et,z){Ot.push(Et),Ct.push(z||"")}wt("file number "+It+": "+Lt.name+` `,"color:red;text-decoration:underline;font-weight:bold"),Lt.lines.forEach(function(Et){if(Et.errors.length>0){wt(Rt(Et.number,4)+"| ","background-color:yellow; font-weight:bold"),wt(Et.line+s,"color:red; background-color:yellow; font-weight:bold");var z=0;Et.errors.forEach(function(J){var xt=J.message,Yt=/^\s*'(.*)'\s*:\s*(.*)$/.exec(xt);if(Yt){var pt=Yt[1];switch(xt=Yt[2],pt){case"assign":pt="=";break}z=Math.max(Et.line.indexOf(pt,z),0)}else z=0;wt(Rt("| ",6)),wt(Rt("^^^",z+3)+s,"font-weight:bold"),wt(Rt("| ",6)),wt(xt+s,"font-weight:bold")}),wt(Rt("| ",6)+s)}else wt(Rt(Et.number,4)+"| "),wt(Et.line+s,"color:red")}),typeof document<"u"&&!window.chrome?(Ct[0]=Ot.join("%c"),console.log.apply(console,Ct)):console.log(Ot.join(""))}),c.raise("Error compiling "+et+" shader, "+bt[0].name)}}function rt(_,v,L,tt,lt){if(!_.getProgramParameter(v,_.LINK_STATUS)){var K=_.getProgramInfoLog(v),et=ve(L,lt),bt=ve(tt,lt),vt='Error linking program with vertex shader, "'+bt[0].name+'", and fragment shader "'+et[0].name+'"';typeof document<"u"?console.log("%c"+vt+s+"%c"+K,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(vt+s+K),c.raise(vt)}}function Bt(_){_._commandRef=zt()}function Dt(_,v,L,tt){Bt(_);function lt(vt){return vt?tt.id(vt):0}_._fragId=lt(_.static.frag),_._vertId=lt(_.static.vert);function K(vt,It){Object.keys(It).forEach(function(Lt){vt[tt.id(Lt)]=!0})}var et=_._uniformSet={};K(et,v.static),K(et,v.dynamic);var bt=_._attributeSet={};K(bt,L.static),K(bt,L.dynamic),_._hasCount="count"in _.static||"count"in _.dynamic||"elements"in _.static||"elements"in _.dynamic}function F(_,v){var L=ue();f(_+" in command "+(v||zt())+(L==="unknown"?"":" called from "+L))}function ft(_,v,L){_||F(v,L||zt())}function H(_,v,L,tt){_ in v||F("unknown parameter ("+_+")"+l(L)+". possible values: "+Object.keys(v).join(),tt||zt())}function yt(_,v,L,tt){w(_,v)||F("invalid parameter type"+l(L)+". expected "+v+", got "+typeof _,tt||zt())}function Mt(_){_()}function Kt(_,v,L){_.texture?V(_.texture._texture.internalformat,v,"unsupported texture format for attachment"):V(_.renderbuffer._renderbuffer.format,L,"unsupported renderbuffer format for attachment")}var ee=33071,de=9728,Oe=9984,ye=9985,Ze=9986,on=9987,En=5120,Dn=5121,hn=5122,Fn=5123,ir=5124,Kn=5125,Yr=5126,rf=32819,Rr=32820,ws=33635,mu=34042,oi=36193,yr={};yr[En]=yr[Dn]=1,yr[hn]=yr[Fn]=yr[oi]=yr[ws]=yr[rf]=yr[Rr]=2,yr[ir]=yr[Kn]=yr[Yr]=yr[mu]=4;function gu(_,v){return _===Rr||_===rf||_===ws?2:_===mu?4:yr[_]*v}function kr(_){return!(_&_-1)&&!!_}function Ir(_,v,L){var tt,lt=v.width,K=v.height,et=v.channels;c(lt>0&<<=L.maxTextureSize&&K>0&&K<=L.maxTextureSize,"invalid texture shape"),(_.wrapS!==ee||_.wrapT!==ee)&&c(kr(lt)&&kr(K),"incompatible wrap mode for texture, both width and height must be power of 2"),v.mipmask===1?lt!==1&&K!==1&&c(_.minFilter!==Oe&&_.minFilter!==Ze&&_.minFilter!==ye&&_.minFilter!==on,"min filter requires mipmap"):(c(kr(lt)&&kr(K),"texture must be a square power of 2 to support mipmapping"),c(v.mipmask===(lt<<1)-1,"missing or incomplete mipmap data")),v.type===Yr&&(L.extensions.indexOf("oes_texture_float_linear")<0&&c(_.minFilter===de&&_.magFilter===de,"filter not supported, must enable oes_texture_float_linear"),c(!_.genMipmaps,"mipmap generation not supported with float textures"));var bt=v.images;for(tt=0;tt<16;++tt)if(bt[tt]){var vt=lt>>tt,It=K>>tt;c(v.mipmask&1<0&<<=tt.maxTextureSize&&K>0&&K<=tt.maxTextureSize,"invalid texture shape"),c(lt===K,"cube map must be square"),c(v.wrapS===ee&&v.wrapT===ee,"wrap mode not supported by cube map");for(var bt=0;bt>Lt,wt=K>>Lt;c(vt.mipmask&1<1&&v===L&&(v==='"'||v==="'"))return['"'+ua(_.substr(1,_.length-2))+'"'];var tt=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(_);if(tt)return Ti(_.substr(0,tt.index)).concat(Ti(tt[1])).concat(Ti(_.substr(tt.index+tt[0].length)));var lt=_.split(".");if(lt.length===1)return['"'+ua(_)+'"'];for(var K=[],et=0;et"u"?1:window.devicePixelRatio,Lt=!1,Ot=function(Et){Et&&b.raise(Et)},Ct=function(){};if(typeof v=="string"?(b(typeof document<"u","selector queries only supported in DOM enviroments"),L=document.querySelector(v),b(L,"invalid query string for element")):typeof v=="object"?sf(v)?L=v:Ss(v)?(K=v,lt=K.canvas):(b.constructor(v),"gl"in v?K=v.gl:"canvas"in v?lt=Ii(v.canvas):"container"in v&&(tt=Ii(v.container)),"attributes"in v&&(et=v.attributes,b.type(et,"object","invalid context attributes")),"extensions"in v&&(bt=bu(v.extensions)),"optionalExtensions"in v&&(vt=bu(v.optionalExtensions)),"onDone"in v&&(b.type(v.onDone,"function","invalid or missing onDone callback"),Ot=v.onDone),"profile"in v&&(Lt=!!v.profile),"pixelRatio"in v&&(It=+v.pixelRatio,b(It>0,"invalid pixel ratio"))):b.raise("invalid arguments to regl"),L&&(L.nodeName.toLowerCase()==="canvas"?lt=L:tt=L),!K){if(!lt){b(typeof document<"u","must manually specify webgl context outside of DOM environments");var wt=vu(tt||document.body,Ot,It);if(!wt)return null;lt=wt.canvas,Ct=wt.onDestroy}et.premultipliedAlpha===void 0&&(et.premultipliedAlpha=!0),K=ul(lt,et)}return K?{gl:K,canvas:lt,container:tt,extensions:bt,optionalExtensions:vt,pixelRatio:It,profile:Lt,onDone:Ot,onDestroy:Ct}:(Ct(),Ot("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function ll(_,v){var L={};function tt(et){b.type(et,"string","extension name must be string");var bt=et.toLowerCase(),vt;try{vt=L[bt]=_.getExtension(bt)}catch{}return!!vt}for(var lt=0;lt65535)<<4,_>>>=v,L=(_>255)<<3,_>>>=L,v|=L,L=(_>15)<<2,_>>>=L,v|=L,L=(_>3)<<1,_>>>=L,v|=L,v|_>>1}function wu(){var _=vr(8,function(){return[]});function v(K){var et=ml(K),bt=_[Wi(et)>>2];return bt.length>0?bt.pop():new ArrayBuffer(et)}function L(K){_[Wi(K.byteLength)>>2].push(K)}function tt(K,et){var bt=null;switch(K){case hl:bt=new Int8Array(v(et),0,et);break;case dl:bt=new Uint8Array(v(et),0,et);break;case fi:bt=new Int16Array(v(2*et),0,et);break;case af:bt=new Uint16Array(v(2*et),0,et);break;case _l:bt=new Int32Array(v(4*et),0,et);break;case of:bt=new Uint32Array(v(4*et),0,et);break;case pl:bt=new Float32Array(v(4*et),0,et);break;default:return null}return bt.length!==et?bt.subarray(0,et):bt}function lt(K){L(K.buffer)}return{alloc:v,free:L,allocType:tt,freeType:lt}}var Cn=wu();Cn.zero=wu();var gl=3408,yl=3410,vl=3411,Yi=3412,bl=3413,wl=3414,xl=3415,Sl=33901,Al=33902,El=3379,As=3386,Tl=34921,Hi=36347,ff=36348,Il=35661,po=35660,uf=34930,xu=36349,Su=34076,Ol=34024,Au=7936,Bl=7937,Ll=7938,Eu=35724,Tu=34047,Iu=36063,cf=34852,mo=3553,lf=34067,go=34069,Ou=33984,Oi=6408,Es=5126,hf=5121,la=36160,Bu=36053,Lu=36064,df=16384,_f=function(_,v){var L=1;v.ext_texture_filter_anisotropic&&(L=_.getParameter(Tu));var tt=1,lt=1;v.webgl_draw_buffers&&(tt=_.getParameter(cf),lt=_.getParameter(Iu));var K=!!v.oes_texture_float;if(K){var et=_.createTexture();_.bindTexture(mo,et),_.texImage2D(mo,0,Oi,1,1,0,Oi,Es,null);var bt=_.createFramebuffer();if(_.bindFramebuffer(la,bt),_.framebufferTexture2D(la,Lu,mo,et,0),_.bindTexture(mo,null),_.checkFramebufferStatus(la)!==Bu)K=!1;else{_.viewport(0,0,1,1),_.clearColor(1,0,0,1),_.clear(df);var vt=Cn.allocType(Es,4);_.readPixels(0,0,1,1,Oi,Es,vt),_.getError()?K=!1:(_.deleteFramebuffer(bt),_.deleteTexture(et),K=vt[0]===1),Cn.freeType(vt)}}var It=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),Lt=!0;if(!It){var Ot=_.createTexture(),Ct=Cn.allocType(hf,36);_.activeTexture(Ou),_.bindTexture(lf,Ot),_.texImage2D(go,0,Oi,3,3,0,Oi,hf,Ct),Cn.freeType(Ct),_.bindTexture(lf,null),_.deleteTexture(Ot),Lt=!_.getError()}return{colorBits:[_.getParameter(yl),_.getParameter(vl),_.getParameter(Yi),_.getParameter(bl)],depthBits:_.getParameter(wl),stencilBits:_.getParameter(xl),subpixelBits:_.getParameter(gl),extensions:Object.keys(v).filter(function(wt){return!!v[wt]}),maxAnisotropic:L,maxDrawbuffers:tt,maxColorAttachments:lt,pointSizeDims:_.getParameter(Sl),lineWidthDims:_.getParameter(Al),maxViewportDims:_.getParameter(As),maxCombinedTextureUnits:_.getParameter(Il),maxCubeMapSize:_.getParameter(Su),maxRenderbufferSize:_.getParameter(Ol),maxTextureUnits:_.getParameter(uf),maxTextureSize:_.getParameter(El),maxAttributes:_.getParameter(Tl),maxVertexUniforms:_.getParameter(Hi),maxVertexTextureUnits:_.getParameter(po),maxVaryingVectors:_.getParameter(ff),maxFragmentUniforms:_.getParameter(xu),glsl:_.getParameter(Eu),renderer:_.getParameter(Bl),vendor:_.getParameter(Au),version:_.getParameter(Ll),readFloat:K,npotTextureCube:Lt}};function Jn(_){return!!_&&typeof _=="object"&&Array.isArray(_.shape)&&Array.isArray(_.stride)&&typeof _.offset=="number"&&_.shape.length===_.stride.length&&(Array.isArray(_.data)||e(_.data))}var br=function(_){return Object.keys(_).map(function(v){return _[v]})},ha={shape:vo,flatten:Mu};function Ml(_,v,L){for(var tt=0;tt0){var re;if(Array.isArray(J[0])){$t=vn(J);for(var dt=1,ht=1;ht<$t.length;++ht)dt*=$t[ht];z.dimension=dt,re=yn(J,$t,z.dtype),Lt(z,re,xt),Vt?z.persistentData=re:Cn.freeType(re)}else if(typeof J[0]=="number"){z.dimension=pt;var qt=Cn.allocType(z.dtype,J.length);Ke(qt,J),Lt(z,qt,xt),Vt?z.persistentData=qt:Cn.freeType(qt)}else e(J[0])?(z.dimension=J[0].length,z.dtype=Yt||ie(J[0])||G,re=yn(J,[J.length,J[0].length],z.dtype),Lt(z,re,xt),Vt?z.persistentData=re:Cn.freeType(re)):b.raise("invalid buffer data")}}else if(e(J))z.dtype=Yt||ie(J),z.dimension=pt,Lt(z,J,xt),Vt&&(z.persistentData=new Uint8Array(new Uint8Array(J.buffer)));else if(Jn(J)){$t=J.shape;var kt=J.stride,St=J.offset,Pt=0,Ut=0,ge=0,_e=0;$t.length===1?(Pt=$t[0],Ut=1,ge=kt[0],_e=0):$t.length===2?(Pt=$t[0],Ut=$t[1],ge=kt[0],_e=kt[1]):b.raise("invalid shape"),z.dtype=Yt||ie(J.data)||G,z.dimension=Ut;var Gt=Cn.allocType(z.dtype,Pt*Ut);_n(Gt,J.data,Pt,Ut,ge,_e,St),Lt(z,Gt,xt),Vt?z.persistentData=Gt:Cn.freeType(Gt)}else J instanceof ArrayBuffer?(z.dtype=B,z.dimension=pt,Lt(z,J,xt),Vt&&(z.persistentData=new Uint8Array(new Uint8Array(J)))):b.raise("invalid buffer data")}function Ct(z){v.bufferCount--,tt(z);var J=z.buffer;b(J,"buffer must not be deleted already"),_.deleteBuffer(J),z.buffer=null,delete K[z.id]}function wt(z,J,xt,Yt){v.bufferCount++;var pt=new et(J);K[pt.id]=pt;function Vt(dt){var ht=vf,qt=null,kt=0,St=0,Pt=1;return Array.isArray(dt)||e(dt)||Jn(dt)||dt instanceof ArrayBuffer?qt=dt:typeof dt=="number"?kt=dt|0:dt&&(b.type(dt,"object","buffer arguments must be an object, a number or an array"),"data"in dt&&(b(qt===null||Array.isArray(qt)||e(qt)||Jn(qt),"invalid data for buffer"),qt=dt.data),"usage"in dt&&(b.parameter(dt.usage,pa,"invalid buffer usage"),ht=pa[dt.usage]),"type"in dt&&(b.parameter(dt.type,Xi,"invalid buffer type"),St=Xi[dt.type]),"dimension"in dt&&(b.type(dt.dimension,"number","invalid dimension"),Pt=dt.dimension|0),"length"in dt&&(b.nni(kt,"buffer length must be a nonnegative integer"),kt=dt.length|0)),pt.bind(),qt?Ot(pt,qt,ht,St,Pt,Yt):(kt&&_.bufferData(pt.type,kt,ht),pt.dtype=St||B,pt.usage=ht,pt.dimension=Pt,pt.byteLength=kt),L.profile&&(pt.stats.size=pt.byteLength*it[pt.dtype]),Vt}function $t(dt,ht){b(ht+dt.byteLength<=pt.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+dt.byteLength+" starting from offset "+ht+" to a buffer of size "+pt.byteLength),_.bufferSubData(pt.type,ht,dt)}function re(dt,ht){var qt=(ht||0)|0,kt;if(pt.bind(),e(dt)||dt instanceof ArrayBuffer)$t(dt,qt);else if(Array.isArray(dt)){if(dt.length>0)if(typeof dt[0]=="number"){var St=Cn.allocType(pt.dtype,dt.length);Ke(St,dt),$t(St,qt),Cn.freeType(St)}else if(Array.isArray(dt[0])||e(dt[0])){kt=vn(dt);var Pt=yn(dt,kt,pt.dtype);$t(Pt,qt),Cn.freeType(Pt)}else b.raise("invalid buffer data")}else if(Jn(dt)){kt=dt.shape;var Ut=dt.stride,ge=0,_e=0,Gt=0,jt=0;kt.length===1?(ge=kt[0],_e=1,Gt=Ut[0],jt=0):kt.length===2?(ge=kt[0],_e=kt[1],Gt=Ut[0],jt=Ut[1]):b.raise("invalid shape");var fe=Array.isArray(dt.data)?pt.dtype:ie(dt.data),me=Cn.allocType(fe,ge*_e);_n(me,dt.data,ge,_e,Gt,jt,dt.offset),$t(me,qt),Cn.freeType(me)}else b.raise("invalid data for buffer subdata");return Vt}return xt||Vt(z),Vt._reglType="buffer",Vt._buffer=pt,Vt.subdata=re,L.profile&&(Vt.stats=pt.stats),Vt.destroy=function(){Ct(pt)},Vt}function Et(){br(K).forEach(function(z){z.buffer=_.createBuffer(),_.bindBuffer(z.type,z.buffer),_.bufferData(z.type,z.persistentData||z.byteLength,z.usage)})}return L.profile&&(v.getTotalBufferSize=function(){var z=0;return Object.keys(K).forEach(function(J){z+=K[J].stats.size}),z}),{create:wt,createStream:vt,destroyStream:It,clear:function(){br(K).forEach(Ct),bt.forEach(Ct)},getBuffer:function(z){return z&&z._buffer instanceof et?z._buffer:null},restore:Et,_initBuffer:Ot}}var We=0,dn=0,Or=1,dr=1,sr=4,wo=4,zr={points:We,point:dn,lines:Or,line:dr,triangles:sr,triangle:wo,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},bf=0,dd=1,xo=4,_d=5120,ar=5121,pd=5122,_r=5123,md=5124,Ts=5125,Bi=34963,Fu=35040,Fl=35044;function kn(_,v,L,tt){var lt={},K=0,et={uint8:ar,uint16:_r};v.oes_element_index_uint&&(et.uint32=Ts);function bt(Et){this.id=K++,lt[this.id]=this,this.buffer=Et,this.primType=xo,this.vertCount=0,this.type=0}bt.prototype.bind=function(){this.buffer.bind()};var vt=[];function It(Et){var z=vt.pop();return z||(z=new bt(L.create(null,Bi,!0,!1)._buffer)),Ot(z,Et,Fu,-1,-1,0,0),z}function Lt(Et){vt.push(Et)}function Ot(Et,z,J,xt,Yt,pt,Vt){Et.buffer.bind();var $t;if(z){var re=Vt;!Vt&&(!e(z)||Jn(z)&&!e(z.data))&&(re=v.oes_element_index_uint?Ts:_r),L._initBuffer(Et.buffer,z,J,re,3)}else _.bufferData(Bi,pt,J),Et.buffer.dtype=$t||ar,Et.buffer.usage=J,Et.buffer.dimension=3,Et.buffer.byteLength=pt;if($t=Vt,!Vt){switch(Et.buffer.dtype){case ar:case _d:$t=ar;break;case _r:case pd:$t=_r;break;case Ts:case md:$t=Ts;break;default:b.raise("unsupported type for element array")}Et.buffer.dtype=$t}Et.type=$t,b($t!==Ts||!!v.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var dt=Yt;dt<0&&(dt=Et.buffer.byteLength,$t===_r?dt>>=1:$t===Ts&&(dt>>=2)),Et.vertCount=dt;var ht=xt;if(xt<0){ht=xo;var qt=Et.buffer.dimension;qt===1&&(ht=bf),qt===2&&(ht=dd),qt===3&&(ht=xo)}Et.primType=ht}function Ct(Et){tt.elementsCount--,b(Et.buffer!==null,"must not double destroy elements"),delete lt[Et.id],Et.buffer.destroy(),Et.buffer=null}function wt(Et,z){var J=L.create(null,Bi,!0),xt=new bt(J._buffer);tt.elementsCount++;function Yt(pt){if(!pt)J(),xt.primType=xo,xt.vertCount=0,xt.type=ar;else if(typeof pt=="number")J(pt),xt.primType=xo,xt.vertCount=pt|0,xt.type=ar;else{var Vt=null,$t=Fl,re=-1,dt=-1,ht=0,qt=0;Array.isArray(pt)||e(pt)||Jn(pt)?Vt=pt:(b.type(pt,"object","invalid arguments for elements"),"data"in pt&&(Vt=pt.data,b(Array.isArray(Vt)||e(Vt)||Jn(Vt),"invalid data for element buffer")),"usage"in pt&&(b.parameter(pt.usage,pa,"invalid element buffer usage"),$t=pa[pt.usage]),"primitive"in pt&&(b.parameter(pt.primitive,zr,"invalid element buffer primitive"),re=zr[pt.primitive]),"count"in pt&&(b(typeof pt.count=="number"&&pt.count>=0,"invalid vertex count for elements"),dt=pt.count|0),"type"in pt&&(b.parameter(pt.type,et,"invalid buffer type"),qt=et[pt.type]),"length"in pt?ht=pt.length|0:(ht=dt,qt===_r||qt===pd?ht*=2:(qt===Ts||qt===md)&&(ht*=4))),Ot(xt,Vt,$t,re,dt,ht,qt)}return Yt}return Yt(Et),Yt._reglType="elements",Yt._elements=xt,Yt.subdata=function(pt,Vt){return J.subdata(pt,Vt),Yt},Yt.destroy=function(){Ct(xt)},Yt}return{create:wt,createStream:It,destroyStream:Lt,getElements:function(Et){return typeof Et=="function"&&Et._elements instanceof bt?Et._elements:null},clear:function(){br(lt).forEach(Ct)}}}var qi=new Float32Array(1),Cl=new Uint32Array(qi.buffer),Jp=5123;function Cu(_){for(var v=Cn.allocType(Jp,_.length),L=0;L<_.length;++L)if(isNaN(_[L]))v[L]=65535;else if(_[L]===1/0)v[L]=31744;else if(_[L]===-1/0)v[L]=64512;else{qi[0]=_[L];var tt=Cl[0],lt=tt>>>31<<15,K=(tt<<1>>>24)-127,et=tt>>13&1023;if(K<-24)v[L]=lt;else if(K<-14){var bt=-14-K;v[L]=lt+(et+1024>>bt)}else K>15?v[L]=lt+31744:v[L]=lt+(K+15<<10)+et}return v}function Bn(_){return Array.isArray(_)||e(_)}var gd=function(_){return!(_&_-1)&&!!_},Qp=34467,ci=3553,So=34067,Zi=34069,ma=6408,ku=6406,wf=6407,ga=6409,Ao=6410,kl=32854,Pl=32855,Pu=36194,zl=32819,tm=32820,yd=33635,Ur=34042,xf=6402,Is=34041,zu=35904,Uu=35906,Eo=36193,Ul=33776,Gl=33777,$l=33778,Vl=33779,ya=35986,vd=35987,bd=34798,Gu=35840,jl=35841,Ki=35842,Sf=35843,wd=36196,To=5121,Wl=5123,Os=5125,Br=5126,xd=10242,em=10243,nm=10497,Yl=33071,rm=33648,im=10240,Io=10241,W=9728,gt=9729,ut=9984,se=9985,Be=9986,fn=9987,Qn=33170,pn=4352,Hl=4353,sm=4354,Hr=34046,$u=3317,am=37440,Oo=37441,Vu=37443,Af=37444,un=33984,om=[ut,Be,se,fn],Ef=[0,ga,Ao,wf,ma],Lr={};Lr[ga]=Lr[ku]=Lr[xf]=1,Lr[Is]=Lr[Ao]=2,Lr[wf]=Lr[zu]=3,Lr[ma]=Lr[Uu]=4;function Bo(_){return"[object "+_+"]"}var Sd=Bo("HTMLCanvasElement"),Ad=Bo("OffscreenCanvas"),Tf=Bo("CanvasRenderingContext2D"),Ji=Bo("ImageBitmap"),If=Bo("HTMLImageElement"),Xl=Bo("HTMLVideoElement"),ju=Object.keys(da).concat([Sd,Ad,Tf,Ji,If,Xl]),va=[];va[To]=1,va[Br]=4,va[Eo]=2,va[Wl]=2,va[Os]=4;var tr=[];tr[kl]=2,tr[Pl]=2,tr[Pu]=2,tr[Is]=4,tr[Ul]=.5,tr[Gl]=.5,tr[$l]=1,tr[Vl]=1,tr[ya]=.5,tr[vd]=1,tr[bd]=1,tr[Gu]=.5,tr[jl]=.25,tr[Ki]=.5,tr[Sf]=.25,tr[wd]=.5;function Of(_){return Array.isArray(_)&&(_.length===0||typeof _[0]=="number")}function ql(_){if(!Array.isArray(_))return!1;var v=_.length;return!(v===0||!Bn(_[0]))}function li(_){return Object.prototype.toString.call(_)}function Bs(_){return li(_)===Sd}function Bf(_){return li(_)===Ad}function fm(_){return li(_)===Tf}function um(_){return li(_)===Ji}function cm(_){return li(_)===If}function Wu(_){return li(_)===Xl}function Lo(_){if(!_)return!1;var v=li(_);return ju.indexOf(v)>=0?!0:Of(_)||ql(_)||Jn(_)}function Yu(_){return da[Object.prototype.toString.call(_)]|0}function lm(_,v){var L=v.length;switch(_.type){case To:case Wl:case Os:case Br:var tt=Cn.allocType(_.type,L);tt.set(v),_.data=tt;break;case Eo:_.data=Cu(v);break;default:b.raise("unsupported texture type, must specify a typed array")}}function Zl(_,v){return Cn.allocType(_.type===Eo?Br:_.type,v)}function Ed(_,v){_.type===Eo?(_.data=Cu(v),Cn.freeType(v)):_.data=v}function hm(_,v,L,tt,lt,K){for(var et=_.width,bt=_.height,vt=_.channels,It=et*bt*vt,Lt=Zl(_,It),Ot=0,Ct=0;Ct=1;)bt+=et*vt*vt,vt/=2;return bt}else return et*L*tt}function wr(_,v,L,tt,lt,K,et){var bt={"don't care":pn,"dont care":pn,nice:sm,fast:Hl},vt={repeat:nm,clamp:Yl,mirror:rm},It={nearest:W,linear:gt},Lt=r({mipmap:fn,"nearest mipmap nearest":ut,"linear mipmap nearest":se,"nearest mipmap linear":Be,"linear mipmap linear":fn},It),Ot={none:0,browser:Af},Ct={uint8:To,rgba4:zl,rgb565:yd,"rgb5 a1":tm},wt={alpha:ku,luminance:ga,"luminance alpha":Ao,rgb:wf,rgba:ma,rgba4:kl,"rgb5 a1":Pl,rgb565:Pu},Et={};v.ext_srgb&&(wt.srgb=zu,wt.srgba=Uu),v.oes_texture_float&&(Ct.float32=Ct.float=Br),v.oes_texture_half_float&&(Ct.float16=Ct["half float"]=Eo),v.webgl_depth_texture&&(r(wt,{depth:xf,"depth stencil":Is}),r(Ct,{uint16:Wl,uint32:Os,"depth stencil":Ur})),v.webgl_compressed_texture_s3tc&&r(Et,{"rgb s3tc dxt1":Ul,"rgba s3tc dxt1":Gl,"rgba s3tc dxt3":$l,"rgba s3tc dxt5":Vl}),v.webgl_compressed_texture_atc&&r(Et,{"rgb atc":ya,"rgba atc explicit alpha":vd,"rgba atc interpolated alpha":bd}),v.webgl_compressed_texture_pvrtc&&r(Et,{"rgb pvrtc 4bppv1":Gu,"rgb pvrtc 2bppv1":jl,"rgba pvrtc 4bppv1":Ki,"rgba pvrtc 2bppv1":Sf}),v.webgl_compressed_texture_etc1&&(Et["rgb etc1"]=wd);var z=Array.prototype.slice.call(_.getParameter(Qp));Object.keys(Et).forEach(function(T){var nt=Et[T];z.indexOf(nt)>=0&&(wt[T]=nt)});var J=Object.keys(wt);L.textureFormats=J;var xt=[];Object.keys(wt).forEach(function(T){var nt=wt[T];xt[nt]=T});var Yt=[];Object.keys(Ct).forEach(function(T){var nt=Ct[T];Yt[nt]=T});var pt=[];Object.keys(It).forEach(function(T){var nt=It[T];pt[nt]=T});var Vt=[];Object.keys(Lt).forEach(function(T){var nt=Lt[T];Vt[nt]=T});var $t=[];Object.keys(vt).forEach(function(T){var nt=vt[T];$t[nt]=T});var re=J.reduce(function(T,nt){var q=wt[nt];return q===ga||q===ku||q===ga||q===Ao||q===xf||q===Is||v.ext_srgb&&(q===zu||q===Uu)?T[q]=q:q===Pl||nt.indexOf("rgba")>=0?T[q]=ma:T[q]=wf,T},{});function dt(){this.internalformat=ma,this.format=ma,this.type=To,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Af,this.width=0,this.height=0,this.channels=0}function ht(T,nt){T.internalformat=nt.internalformat,T.format=nt.format,T.type=nt.type,T.compressed=nt.compressed,T.premultiplyAlpha=nt.premultiplyAlpha,T.flipY=nt.flipY,T.unpackAlignment=nt.unpackAlignment,T.colorSpace=nt.colorSpace,T.width=nt.width,T.height=nt.height,T.channels=nt.channels}function qt(T,nt){if(!(typeof nt!="object"||!nt)){if("premultiplyAlpha"in nt&&(b.type(nt.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),T.premultiplyAlpha=nt.premultiplyAlpha),"flipY"in nt&&(b.type(nt.flipY,"boolean","invalid texture flip"),T.flipY=nt.flipY),"alignment"in nt&&(b.oneOf(nt.alignment,[1,2,4,8],"invalid texture unpack alignment"),T.unpackAlignment=nt.alignment),"colorSpace"in nt&&(b.parameter(nt.colorSpace,Ot,"invalid colorSpace"),T.colorSpace=Ot[nt.colorSpace]),"type"in nt){var q=nt.type;b(v.oes_texture_float||!(q==="float"||q==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),b(v.oes_texture_half_float||!(q==="half float"||q==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),b(v.webgl_depth_texture||!(q==="uint16"||q==="uint32"||q==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),b.parameter(q,Ct,"invalid texture type"),T.type=Ct[q]}var Xt=T.width,Ae=T.height,S=T.channels,g=!1;"shape"in nt?(b(Array.isArray(nt.shape)&&nt.shape.length>=2,"shape must be an array"),Xt=nt.shape[0],Ae=nt.shape[1],nt.shape.length===3&&(S=nt.shape[2],b(S>0&&S<=4,"invalid number of channels"),g=!0),b(Xt>=0&&Xt<=L.maxTextureSize,"invalid width"),b(Ae>=0&&Ae<=L.maxTextureSize,"invalid height")):("radius"in nt&&(Xt=Ae=nt.radius,b(Xt>=0&&Xt<=L.maxTextureSize,"invalid radius")),"width"in nt&&(Xt=nt.width,b(Xt>=0&&Xt<=L.maxTextureSize,"invalid width")),"height"in nt&&(Ae=nt.height,b(Ae>=0&&Ae<=L.maxTextureSize,"invalid height")),"channels"in nt&&(S=nt.channels,b(S>0&&S<=4,"invalid number of channels"),g=!0)),T.width=Xt|0,T.height=Ae|0,T.channels=S|0;var R=!1;if("format"in nt){var U=nt.format;b(v.webgl_depth_texture||!(U==="depth"||U==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),b.parameter(U,wt,"invalid texture format");var $=T.internalformat=wt[U];T.format=re[$],U in Ct&&("type"in nt||(T.type=Ct[U])),U in Et&&(T.compressed=!0),R=!0}!g&&R?T.channels=Lr[T.format]:g&&!R?T.channels!==Ef[T.format]&&(T.format=T.internalformat=Ef[T.channels]):R&&g&&b(T.channels===Lr[T.format],"number of channels inconsistent with specified format")}}function kt(T){_.pixelStorei(am,T.flipY),_.pixelStorei(Oo,T.premultiplyAlpha),_.pixelStorei(Vu,T.colorSpace),_.pixelStorei($u,T.unpackAlignment)}function St(){dt.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function Pt(T,nt){var q=null;if(Lo(nt)?q=nt:nt&&(b.type(nt,"object","invalid pixel data type"),qt(T,nt),"x"in nt&&(T.xOffset=nt.x|0),"y"in nt&&(T.yOffset=nt.y|0),Lo(nt.data)&&(q=nt.data)),b(!T.compressed||q instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),nt.copy){b(!q,"can not specify copy and data field for the same texture");var Xt=lt.viewportWidth,Ae=lt.viewportHeight;T.width=T.width||Xt-T.xOffset,T.height=T.height||Ae-T.yOffset,T.needsCopy=!0,b(T.xOffset>=0&&T.xOffset=0&&T.yOffset0&&T.width<=Xt&&T.height>0&&T.height<=Ae,"copy texture read out of bounds")}else if(!q)T.width=T.width||1,T.height=T.height||1,T.channels=T.channels||4;else if(e(q))T.channels=T.channels||4,T.data=q,!("type"in nt)&&T.type===To&&(T.type=Yu(q));else if(Of(q))T.channels=T.channels||4,lm(T,q),T.alignment=1,T.needsFree=!0;else if(Jn(q)){var S=q.data;!Array.isArray(S)&&T.type===To&&(T.type=Yu(S));var g=q.shape,R=q.stride,U,$,D,M,P,A;g.length===3?(D=g[2],A=R[2]):(b(g.length===2,"invalid ndarray pixel data, must be 2 or 3D"),D=1,A=1),U=g[0],$=g[1],M=R[0],P=R[1],T.alignment=1,T.width=U,T.height=$,T.channels=D,T.format=T.internalformat=Ef[D],T.needsFree=!0,hm(T,S,M,P,A,q.offset)}else if(Bs(q)||Bf(q)||fm(q))Bs(q)||Bf(q)?T.element=q:T.element=q.canvas,T.width=T.element.width,T.height=T.element.height,T.channels=4;else if(um(q))T.element=q,T.width=q.width,T.height=q.height,T.channels=4;else if(cm(q))T.element=q,T.width=q.naturalWidth,T.height=q.naturalHeight,T.channels=4;else if(Wu(q))T.element=q,T.width=q.videoWidth,T.height=q.videoHeight,T.channels=4;else if(ql(q)){var O=T.width||q[0].length,E=T.height||q.length,X=T.channels;Bn(q[0][0])?X=X||q[0][0].length:X=X||1;for(var j=ha.shape(q),ct=1,_t=0;_t=0,"oes_texture_float extension not enabled"):T.type===Eo&&b(L.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function Ut(T,nt,q){var Xt=T.element,Ae=T.data,S=T.internalformat,g=T.format,R=T.type,U=T.width,$=T.height;kt(T),Xt?_.texImage2D(nt,q,g,g,R,Xt):T.compressed?_.compressedTexImage2D(nt,q,S,U,$,0,Ae):T.needsCopy?(tt(),_.copyTexImage2D(nt,q,g,T.xOffset,T.yOffset,U,$,0)):_.texImage2D(nt,q,g,U,$,0,g,R,Ae||null)}function ge(T,nt,q,Xt,Ae){var S=T.element,g=T.data,R=T.internalformat,U=T.format,$=T.type,D=T.width,M=T.height;kt(T),S?_.texSubImage2D(nt,Ae,q,Xt,U,$,S):T.compressed?_.compressedTexSubImage2D(nt,Ae,q,Xt,R,D,M,g):T.needsCopy?(tt(),_.copyTexSubImage2D(nt,Ae,q,Xt,T.xOffset,T.yOffset,D,M)):_.texSubImage2D(nt,Ae,q,Xt,D,M,U,$,g)}var _e=[];function Gt(){return _e.pop()||new St}function jt(T){T.needsFree&&Cn.freeType(T.data),St.call(T),_e.push(T)}function fe(){dt.call(this),this.genMipmaps=!1,this.mipmapHint=pn,this.mipmask=0,this.images=Array(16)}function me(T,nt,q){var Xt=T.images[0]=Gt();T.mipmask=1,Xt.width=T.width=nt,Xt.height=T.height=q,Xt.channels=T.channels=4}function Ee(T,nt){var q=null;if(Lo(nt))q=T.images[0]=Gt(),ht(q,T),Pt(q,nt),T.mipmask=1;else if(qt(T,nt),Array.isArray(nt.mipmap))for(var Xt=nt.mipmap,Ae=0;Ae>=Ae,q.height>>=Ae,Pt(q,Xt[Ae]),T.mipmask|=1<=0&&!("faces"in nt)&&(T.genMipmaps=!0)}if("mag"in nt){var Xt=nt.mag;b.parameter(Xt,It),T.magFilter=It[Xt]}var Ae=T.wrapS,S=T.wrapT;if("wrap"in nt){var g=nt.wrap;typeof g=="string"?(b.parameter(g,vt),Ae=S=vt[g]):Array.isArray(g)&&(b.parameter(g[0],vt),b.parameter(g[1],vt),Ae=vt[g[0]],S=vt[g[1]])}else{if("wrapS"in nt){var R=nt.wrapS;b.parameter(R,vt),Ae=vt[R]}if("wrapT"in nt){var U=nt.wrapT;b.parameter(U,vt),S=vt[U]}}if(T.wrapS=Ae,T.wrapT=S,"anisotropic"in nt){var $=nt.anisotropic;b(typeof $=="number"&&$>=1&&$<=L.maxAnisotropic,"aniso samples must be between 1 and "),T.anisotropic=nt.anisotropic}if("mipmap"in nt){var D=!1;switch(typeof nt.mipmap){case"string":b.parameter(nt.mipmap,bt,"invalid mipmap hint"),T.mipmapHint=bt[nt.mipmap],T.genMipmaps=!0,D=!0;break;case"boolean":D=T.genMipmaps=nt.mipmap;break;case"object":b(Array.isArray(nt.mipmap),"invalid mipmap type"),T.genMipmaps=!1,D=!0;break;default:b.raise("invalid mipmap type")}D&&!("min"in nt)&&(T.minFilter=ut)}}function jn(T,nt){_.texParameteri(nt,Io,T.minFilter),_.texParameteri(nt,im,T.magFilter),_.texParameteri(nt,xd,T.wrapS),_.texParameteri(nt,em,T.wrapT),v.ext_texture_filter_anisotropic&&_.texParameteri(nt,Hr,T.anisotropic),T.genMipmaps&&(_.hint(Qn,T.mipmapHint),_.generateMipmap(nt))}var Yn=0,er={},fr=L.maxTextureUnits,Un=Array(fr).map(function(){return null});function we(T){dt.call(this),this.mipmask=0,this.internalformat=ma,this.id=Yn++,this.refCount=1,this.target=T,this.texture=_.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new sn,et.profile&&(this.stats={size:0})}function ur(T){_.activeTexture(un),_.bindTexture(T.target,T.texture)}function en(){var T=Un[0];T?_.bindTexture(T.target,T.texture):_.bindTexture(ci,null)}function ce(T){var nt=T.texture;b(nt,"must not double destroy texture");var q=T.unit,Xt=T.target;q>=0&&(_.activeTexture(un+q),_.bindTexture(Xt,null),Un[q]=null),_.deleteTexture(nt),T.texture=null,T.params=null,T.pixels=null,T.refCount=0,delete er[T.id],K.textureCount--}r(we.prototype,{bind:function(){var T=this;T.bindCount+=1;var nt=T.unit;if(nt<0){for(var q=0;q0)continue;Xt.unit=-1}Un[q]=T,nt=q;break}nt>=fr&&b.raise("insufficient number of texture units"),et.profile&&K.maxTextureUnits>P)-D,A.height=A.height||(q.height>>P)-M,b(q.type===A.type&&q.format===A.format&&q.internalformat===A.internalformat,"incompatible format for texture.subimage"),b(D>=0&&M>=0&&D+A.width<=q.width&&M+A.height<=q.height,"texture.subimage write out of bounds"),b(q.mipmask&1<>D;++D){var M=U>>D,P=$>>D;if(!M||!P)break;_.texImage2D(ci,D,q.format,M,P,0,q.format,q.type,null)}return en(),et.profile&&(q.stats.size=$n(q.internalformat,q.type,U,$,!1,!1)),Xt}return Xt(T,nt),Xt.subimage=Ae,Xt.resize=S,Xt._reglType="texture2d",Xt._texture=q,et.profile&&(Xt.stats=q.stats),Xt.destroy=function(){q.decRef()},Xt}function Ve(T,nt,q,Xt,Ae,S){var g=new we(So);er[g.id]=g,K.cubeCount++;var R=new Array(6);function U(M,P,A,O,E,X){var j,ct=g.texInfo;for(sn.call(ct),j=0;j<6;++j)R[j]=Le();if(typeof M=="number"||!M){var _t=M|0||1;for(j=0;j<6;++j)me(R[j],_t,_t)}else if(typeof M=="object")if(P)Ee(R[0],M),Ee(R[1],P),Ee(R[2],A),Ee(R[3],O),Ee(R[4],E),Ee(R[5],X);else if(Vn(ct,M),qt(g,M),"faces"in M){var Nt=M.faces;for(b(Array.isArray(Nt)&&Nt.length===6,"cube faces must be a length 6 array"),j=0;j<6;++j)b(typeof Nt[j]=="object"&&!!Nt[j],"invalid input for cube map face"),ht(R[j],g),Ee(R[j],Nt[j])}else for(j=0;j<6;++j)Ee(R[j],M);else b.raise("invalid arguments to cube map");for(ht(g,R[0]),b.optional(function(){L.npotTextureCube||b(gd(g.width)&&gd(g.height),"your browser does not support non power or two texture dimensions")}),ct.genMipmaps?g.mipmask=(R[0].width<<1)-1:g.mipmask=R[0].mipmask,b.textureCube(g,ct,R,L),g.internalformat=R[0].internalformat,U.width=R[0].width,U.height=R[0].height,ur(g),j=0;j<6;++j)Tn(R[j],Zi+j);for(jn(ct,So),en(),et.profile&&(g.stats.size=$n(g.internalformat,g.type,U.width,U.height,ct.genMipmaps,!0)),U.format=xt[g.internalformat],U.type=Yt[g.type],U.mag=pt[ct.magFilter],U.min=Vt[ct.minFilter],U.wrapS=$t[ct.wrapS],U.wrapT=$t[ct.wrapT],j=0;j<6;++j)mn(R[j]);return U}function $(M,P,A,O,E){b(!!P,"must specify image data"),b(typeof M=="number"&&M===(M|0)&&M>=0&&M<6,"invalid face");var X=A|0,j=O|0,ct=E|0,_t=Gt();return ht(_t,g),_t.width=0,_t.height=0,Pt(_t,P),_t.width=_t.width||(g.width>>ct)-X,_t.height=_t.height||(g.height>>ct)-j,b(g.type===_t.type&&g.format===_t.format&&g.internalformat===_t.internalformat,"incompatible format for texture.subimage"),b(X>=0&&j>=0&&X+_t.width<=g.width&&j+_t.height<=g.height,"texture.subimage write out of bounds"),b(g.mipmask&1<>O;++O)_.texImage2D(Zi+A,O,g.format,P>>O,P>>O,0,g.format,g.type,null);return en(),et.profile&&(g.stats.size=$n(g.internalformat,g.type,U.width,U.height,!1,!0)),U}}return U(T,nt,q,Xt,Ae,S),U.subimage=$,U.resize=D,U._reglType="textureCube",U._texture=g,et.profile&&(U.stats=g.stats),U.destroy=function(){g.decRef()},U}function Gn(){for(var T=0;T>Xt,q.height>>Xt,0,q.internalformat,q.type,null);else for(var Ae=0;Ae<6;++Ae)_.texImage2D(Zi+Ae,Xt,q.internalformat,q.width>>Xt,q.height>>Xt,0,q.internalformat,q.type,null);jn(q.texInfo,q.target)})}function Us(){for(var T=0;T=2,"invalid renderbuffer shape"),Vt=ht[0]|0,$t=ht[1]|0}else"radius"in dt&&(Vt=$t=dt.radius|0),"width"in dt&&(Vt=dt.width|0),"height"in dt&&($t=dt.height|0);"format"in dt&&(b.parameter(dt.format,K,"invalid renderbuffer format"),re=K[dt.format])}else typeof Yt=="number"?(Vt=Yt|0,typeof pt=="number"?$t=pt|0:$t=Vt):Yt?b.raise("invalid arguments to renderbuffer constructor"):Vt=$t=1;if(b(Vt>0&&$t>0&&Vt<=L.maxRenderbufferSize&&$t<=L.maxRenderbufferSize,"invalid renderbuffer size"),!(Vt===z.width&&$t===z.height&&re===z.format))return J.width=z.width=Vt,J.height=z.height=$t,z.format=re,_.bindRenderbuffer(Ls,z.renderbuffer),_.renderbufferStorage(Ls,re,Vt,$t),b(_.getError()===0,"invalid render buffer format"),lt.profile&&(z.stats.size=Id(z.format,z.width,z.height)),J.format=et[z.format],J}function xt(Yt,pt){var Vt=Yt|0,$t=pt|0||Vt;return Vt===z.width&&$t===z.height||(b(Vt>0&&$t>0&&Vt<=L.maxRenderbufferSize&&$t<=L.maxRenderbufferSize,"invalid renderbuffer size"),J.width=z.width=Vt,J.height=z.height=$t,_.bindRenderbuffer(Ls,z.renderbuffer),_.renderbufferStorage(Ls,z.format,Vt,$t),b(_.getError()===0,"invalid render buffer format"),lt.profile&&(z.stats.size=Id(z.format,z.width,z.height))),J}return J(wt,Et),J.resize=xt,J._reglType="renderbuffer",J._renderbuffer=z,lt.profile&&(J.stats=z.stats),J.destroy=function(){z.decRef()},J}lt.profile&&(tt.getTotalRenderbufferSize=function(){var wt=0;return Object.keys(vt).forEach(function(Et){wt+=vt[Et].stats.size}),wt});function Ct(){br(vt).forEach(function(wt){wt.renderbuffer=_.createRenderbuffer(),_.bindRenderbuffer(Ls,wt.renderbuffer),_.renderbufferStorage(Ls,wt.format,wt.width,wt.height)}),_.bindRenderbuffer(Ls,null)}return{create:Ot,clear:function(){br(vt).forEach(Lt)},restore:Ct}},Qi=36160,Jl=36161,wa=3553,xa=34069,Do=36064,Ql=36096,y=36128,Sa=33306,Mf=36053,Xr=36054,tn=36055,_m=36057,pm=36061,mm=36193,Aa=5121,gm=5126,Od=6407,Bd=6408,ym=6402,vm=[Od,Bd],hi=[];hi[Bd]=4,hi[Od]=3;var Zu=[];Zu[Aa]=1,Zu[gm]=4,Zu[mm]=2;var bm=32854,wm=32855,xm=36194,Sm=33189,ts=36168,Ld=34041,Am=35907,Em=34836,Tm=34842,Im=34843,Ea=[bm,wm,xm,Am,Tm,Im,Em],Fo={};Fo[Mf]="complete",Fo[Xr]="incomplete attachment",Fo[_m]="incomplete dimensions",Fo[tn]="incomplete, missing attachment",Fo[pm]="unsupported";function Om(_,v,L,tt,lt,K){var et={cur:null,next:null,dirty:!1,setFBO:null},bt=["rgba"],vt=["rgba4","rgb565","rgb5 a1"];v.ext_srgb&&vt.push("srgba"),v.ext_color_buffer_half_float&&vt.push("rgba16f","rgb16f"),v.webgl_color_buffer_float&&vt.push("rgba32f");var It=["uint8"];v.oes_texture_half_float&&It.push("half float","float16"),v.oes_texture_float&&It.push("float","float32");function Lt(St,Pt,Ut){this.target=St,this.texture=Pt,this.renderbuffer=Ut;var ge=0,_e=0;Pt?(ge=Pt.width,_e=Pt.height):Ut&&(ge=Ut.width,_e=Ut.height),this.width=ge,this.height=_e}function Ot(St){St&&(St.texture&&St.texture._texture.decRef(),St.renderbuffer&&St.renderbuffer._renderbuffer.decRef())}function Ct(St,Pt,Ut){if(St)if(St.texture){var ge=St.texture._texture,_e=Math.max(1,ge.width),Gt=Math.max(1,ge.height);b(_e===Pt&&Gt===Ut,"inconsistent width/height for supplied texture"),ge.refCount+=1}else{var jt=St.renderbuffer._renderbuffer;b(jt.width===Pt&&jt.height===Ut,"inconsistent width/height for renderbuffer"),jt.refCount+=1}}function wt(St,Pt){Pt&&(Pt.texture?_.framebufferTexture2D(Qi,St,Pt.target,Pt.texture._texture.texture,0):_.framebufferRenderbuffer(Qi,St,Jl,Pt.renderbuffer._renderbuffer.renderbuffer))}function Et(St){var Pt=wa,Ut=null,ge=null,_e=St;typeof St=="object"&&(_e=St.data,"target"in St&&(Pt=St.target|0)),b.type(_e,"function","invalid attachment data");var Gt=_e._reglType;return Gt==="texture2d"?(Ut=_e,b(Pt===wa)):Gt==="textureCube"?(Ut=_e,b(Pt>=xa&&Pt=2,"invalid shape for framebuffer"),me=ur[0],Ee=ur[1]}else"radius"in we&&(me=Ee=we.radius),"width"in we&&(me=we.width),"height"in we&&(Ee=we.height);("color"in we||"colors"in we)&&(Le=we.color||we.colors,Array.isArray(Le)&&b(Le.length===1||v.webgl_draw_buffers,"multiple render targets not supported")),Le||("colorCount"in we&&(jn=we.colorCount|0,b(jn>0,"invalid color buffer count")),"colorTexture"in we&&(mn=!!we.colorTexture,sn="rgba4"),"colorType"in we&&(Vn=we.colorType,mn?(b(v.oes_texture_float||!(Vn==="float"||Vn==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),b(v.oes_texture_half_float||!(Vn==="half float"||Vn==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):Vn==="half float"||Vn==="float16"?(b(v.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),sn="rgba16f"):(Vn==="float"||Vn==="float32")&&(b(v.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),sn="rgba32f"),b.oneOf(Vn,It,"invalid color type")),"colorFormat"in we&&(sn=we.colorFormat,bt.indexOf(sn)>=0?mn=!0:vt.indexOf(sn)>=0?mn=!1:b.optional(function(){mn?b.oneOf(we.colorFormat,bt,"invalid color format for texture"):b.oneOf(we.colorFormat,vt,"invalid color format for renderbuffer")}))),("depthTexture"in we||"depthStencilTexture"in we)&&(Un=!!(we.depthTexture||we.depthStencilTexture),b(!Un||v.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in we&&(typeof we.depth=="boolean"?Tn=we.depth:(Yn=we.depth,xn=!1)),"stencil"in we&&(typeof we.stencil=="boolean"?xn=we.stencil:(er=we.stencil,Tn=!1)),"depthStencil"in we&&(typeof we.depthStencil=="boolean"?Tn=xn=we.depthStencil:(fr=we.depthStencil,Tn=!1,xn=!1))}var en=null,ce=null,Me=null,Ve=null;if(Array.isArray(Le))en=Le.map(Et);else if(Le)en=[Et(Le)];else for(en=new Array(jn),fe=0;fe=0||en[fe].renderbuffer&&Ea.indexOf(en[fe].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+fe+" is invalid"),en[fe]&&en[fe].texture){var gi=hi[en[fe].texture._texture.format]*Zu[en[fe].texture._texture.type];Gn===null?Gn=gi:b(Gn===gi,"all color attachments much have the same number of bits per pixel.")}return Ct(ce,me,Ee),b(!ce||ce.texture&&ce.texture._texture.format===ym||ce.renderbuffer&&ce.renderbuffer._renderbuffer.format===Sm,"invalid depth attachment for framebuffer object"),Ct(Me,me,Ee),b(!Me||Me.renderbuffer&&Me.renderbuffer._renderbuffer.format===ts,"invalid stencil attachment for framebuffer object"),Ct(Ve,me,Ee),b(!Ve||Ve.texture&&Ve.texture._texture.format===Ld||Ve.renderbuffer&&Ve.renderbuffer._renderbuffer.format===Ld,"invalid depth-stencil attachment for framebuffer object"),$t(Ut),Ut.width=me,Ut.height=Ee,Ut.colorAttachments=en,Ut.depthAttachment=ce,Ut.stencilAttachment=Me,Ut.depthStencilAttachment=Ve,ge.color=en.map(J),ge.depth=J(ce),ge.stencil=J(Me),ge.depthStencil=J(Ve),ge.width=Ut.width,ge.height=Ut.height,dt(Ut),ge}function _e(Gt,jt){b(et.next!==Ut,"can not resize a framebuffer which is currently in use");var fe=Math.max(Gt|0,1),me=Math.max(jt|0||fe,1);if(fe===Ut.width&&me===Ut.height)return ge;for(var Ee=Ut.colorAttachments,Tn=0;Tn=2,"invalid shape for framebuffer"),b(mn[0]===mn[1],"cube framebuffer must be square"),fe=mn[0]}else"radius"in Le&&(fe=Le.radius|0),"width"in Le?(fe=Le.width|0,"height"in Le&&b(Le.height===fe,"must be square")):"height"in Le&&(fe=Le.height|0);("color"in Le||"colors"in Le)&&(me=Le.color||Le.colors,Array.isArray(me)&&b(me.length===1||v.webgl_draw_buffers,"multiple render targets not supported")),me||("colorCount"in Le&&(xn=Le.colorCount|0,b(xn>0,"invalid color buffer count")),"colorType"in Le&&(b.oneOf(Le.colorType,It,"invalid color type"),Tn=Le.colorType),"colorFormat"in Le&&(Ee=Le.colorFormat,b.oneOf(Le.colorFormat,bt,"invalid color format for texture"))),"depth"in Le&&(jt.depth=Le.depth),"stencil"in Le&&(jt.stencil=Le.stencil),"depthStencil"in Le&&(jt.depthStencil=Le.depthStencil)}var sn;if(me)if(Array.isArray(me))for(sn=[],Gt=0;Gt0&&(jt.depth=Pt[0].depth,jt.stencil=Pt[0].stencil,jt.depthStencil=Pt[0].depthStencil),Pt[Gt]?Pt[Gt](jt):Pt[Gt]=ht(jt)}return r(Ut,{width:fe,height:fe,color:sn})}function ge(_e){var Gt,jt=_e|0;if(b(jt>0&&jt<=L.maxCubeMapSize,"invalid radius for cube fbo"),jt===Ut.width)return Ut;var fe=Ut.color;for(Gt=0;Gt{for(var Tn=Object.keys(kt),xn=0;xn=0,'invalid option for vao: "'+Tn[xn]+'" valid options are '+Rd)}),b(Array.isArray(St),"attributes must be an array")}b(St.length0,"must specify at least one attribute");var Ut={},ge=ht.attributes;ge.length=St.length;for(var _e=0;_e=fe.byteLength?me.subdata(fe):(me.destroy(),ht.buffers[_e]=null)),ht.buffers[_e]||(me=ht.buffers[_e]=lt.create(Gt,Md,!1,!0)),jt.buffer=lt.getBuffer(me),jt.size=jt.buffer.dimension|0,jt.normalized=!1,jt.type=jt.buffer.dtype,jt.offset=0,jt.stride=0,jt.divisor=0,jt.state=1,Ut[_e]=1}else lt.getBuffer(Gt)?(jt.buffer=lt.getBuffer(Gt),jt.size=jt.buffer.dimension|0,jt.normalized=!1,jt.type=jt.buffer.dtype,jt.offset=0,jt.stride=0,jt.divisor=0,jt.state=1):lt.getBuffer(Gt.buffer)?(jt.buffer=lt.getBuffer(Gt.buffer),jt.size=(+Gt.size||jt.buffer.dimension)|0,jt.normalized=!!Gt.normalized||!1,"type"in Gt?(b.parameter(Gt.type,Xi,"invalid buffer type"),jt.type=Xi[Gt.type]):jt.type=jt.buffer.dtype,jt.offset=(Gt.offset||0)|0,jt.stride=(Gt.stride||0)|0,jt.divisor=(Gt.divisor||0)|0,jt.state=1,b(jt.size>=1&&jt.size<=4,"size must be between 1 and 4"),b(jt.offset>=0,"invalid offset"),b(jt.stride>=0&&jt.stride<=255,"stride must be between 0 and 255"),b(jt.divisor>=0,"divisor must be positive"),b(!jt.divisor||!!v.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in Gt?(b(_e>0,"first attribute must not be a constant"),jt.x=+Gt.x||0,jt.y=+Gt.y||0,jt.z=+Gt.z||0,jt.w=+Gt.w||0,jt.state=2):b(!1,"invalid attribute spec for location "+_e)}for(var Ee=0;Ee1)for(var kt=0;kt1&&(Pt=Pt.replace("[0]","")),bt(qt,new et(Pt,v.id(Pt),_.getUniformLocation(re,Pt),pt))}var Ut=_.getProgramParameter(re,Mm);tt.profile&&(z.stats.attributesCount=Ut);var ge=z.attributes;for(Yt=0;Ytz&&(z=J.stats.uniformsCount)}),z},L.getMaxAttributesCount=function(){var z=0;return Lt.forEach(function(J){J.stats.attributesCount>z&&(z=J.stats.attributesCount)}),z});function Et(){lt={},K={};for(var z=0;z=0,"missing vertex shader",xt),b.command(J>=0,"missing fragment shader",xt);var pt=It[J];pt||(pt=It[J]={});var Vt=pt[z];if(Vt&&(Vt.refCount++,!Yt))return Vt;var $t=new Ct(J,z);return L.shaderCount++,wt($t,xt,Yt),Vt||(pt[z]=$t),Lt.push($t),r($t,{destroy:function(){if($t.refCount--,$t.refCount<=0){_.deleteProgram($t.program);var re=Lt.indexOf($t);Lt.splice(re,1),L.shaderCount--}pt[$t.vertId].refCount<=0&&(_.deleteShader(K[$t.vertId]),delete K[$t.vertId],delete It[$t.fragId][$t.vertId]),Object.keys(It[$t.fragId]).length||(_.deleteShader(lt[$t.fragId]),delete lt[$t.fragId],delete It[$t.fragId])}})},restore:Et,shader:vt,frag:-1,vert:-1}}var Rf=6408,Ms=5121,Rm=3333,Nf=5126;function Nm(_,v,L,tt,lt,K,et){function bt(Lt){var Ot;v.next===null?(b(lt.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),Ot=Ms):(b(v.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),Ot=v.next.colorAttachments[0].texture._texture.type,b.optional(function(){K.oes_texture_float?(b(Ot===Ms||Ot===Nf,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),Ot===Nf&&b(et.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):b(Ot===Ms,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var Ct=0,wt=0,Et=tt.framebufferWidth,z=tt.framebufferHeight,J=null;e(Lt)?J=Lt:Lt&&(b.type(Lt,"object","invalid arguments to regl.read()"),Ct=Lt.x|0,wt=Lt.y|0,b(Ct>=0&&Ct=0&&wt0&&Et+Ct<=tt.framebufferWidth,"invalid width for read pixels"),b(z>0&&z+wt<=tt.framebufferHeight,"invalid height for read pixels"),L();var xt=Et*z*4;return J||(Ot===Ms?J=new Uint8Array(xt):Ot===Nf&&(J=J||new Float32Array(xt))),b.isTypedArray(J,"data buffer for regl.read() must be a typedarray"),b(J.byteLength>=xt,"data buffer for regl.read() too small"),_.pixelStorei(Rm,4),_.readPixels(Ct,wt,Et,z,Rf,Ot,J),J}function vt(Lt){var Ot;return v.setFBO({framebuffer:Lt.framebuffer},function(){Ot=bt(Lt)}),Ot}function It(Lt){return!Lt||!("framebuffer"in Lt)?bt(Lt):vt(Lt)}return It}function Nr(_){return Array.prototype.slice.call(_)}function Rs(_){return Nr(_).join("")}function Ta(){var _=0,v=[],L=[];function tt(Ot){for(var Ct=0;Ct0&&(Ot.push(z,"="),Ot.push.apply(Ot,Nr(arguments)),Ot.push(";")),z}return r(Ct,{def:Et,toString:function(){return Rs([wt.length>0?"var "+wt.join(",")+";":"",Rs(Ot)])}})}function K(){var Ot=lt(),Ct=lt(),wt=Ot.toString,Et=Ct.toString;function z(J,xt){Ct(J,xt,"=",Ot.def(J,xt),";")}return r(function(){Ot.apply(Ot,Nr(arguments))},{def:Ot.def,entry:Ot,exit:Ct,save:z,set:function(J,xt,Yt){z(J,xt),Ot(J,xt,"=",Yt,";")},toString:function(){return wt()+Et()}})}function et(){var Ot=Rs(arguments),Ct=K(),wt=K(),Et=Ct.toString,z=wt.toString;return r(Ct,{then:function(){return Ct.apply(Ct,Nr(arguments)),this},else:function(){return wt.apply(wt,Nr(arguments)),this},toString:function(){var J=z();return J&&(J="else{"+J+"}"),Rs(["if(",Ot,"){",Et(),"}",J])}})}var bt=lt(),vt={};function It(Ot,Ct){var wt=[];function Et(){var pt="a"+wt.length;return wt.push(pt),pt}Ct=Ct||0;for(var z=0;z":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},rs={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Xf={frag:Uf,vert:jd},cc={cw:gh,ccw:Ar};function Pa(_){return Array.isArray(_)||e(_)||Jn(_)}function lc(_){return _.sort(function(v,L){return v===es?-1:L===es?1:v=1,tt>=2,v)}else if(L===Ba){var lt=_.data;return new Pn(lt.thisDep,lt.contextDep,lt.propDep,v)}else{if(L===Fd)return new Pn(!1,!1,!1,v);if(L===ih){for(var K=!1,et=!1,bt=!1,vt=0;vt<_.data.length;++vt){var It=_.data[vt];if(It.type===Li)bt=!0;else if(It.type===Qu)et=!0;else if(It.type===rh)K=!0;else if(It.type===Oa){K=!0;var Lt=It.data;Lt>=1&&(et=!0),Lt>=2&&(bt=!0)}else It.type===Ba&&(K=K||It.data.thisDep,et=et||It.data.contextDep,bt=bt||It.data.propDep)}return new Pn(K,et,bt,v)}else return new Pn(L===rh,L===Qu,L===Li,v)}}var wh=new Pn(!1,!1,!1,function(){});function xh(_,v,L,tt,lt,K,et,bt,vt,It,Lt,Ot,Ct,wt,Et){var z=It.Record,J={add:32774,subtract:32778,"reverse subtract":32779};L.ext_blend_minmax&&(J.min=Mi,J.max=Cm);var xt=L.angle_instanced_arrays,Yt=L.webgl_draw_buffers,pt=L.oes_vertex_array_object,Vt={dirty:!0,profile:Et.profile},$t={},re=[],dt={},ht={};function qt(S){return S.replace(".","_")}function kt(S,g,R){var U=qt(S);re.push(S),$t[U]=Vt[U]=!!R,dt[U]=g}function St(S,g,R){var U=qt(S);re.push(S),Array.isArray(R)?(Vt[U]=R.slice(),$t[U]=R.slice()):Vt[U]=$t[U]=R,ht[U]=g}kt(or,ac),kt(tc,Fm),St(sh,"blendColor",[0,0,0,0]),St(qr,"blendEquationSeparate",[vh,vh]),St(Df,"blendFuncSeparate",[yh,Ca,yh,Ca]),kt(Ff,Yd,!0),St(Ns,"depthFunc",Pm),St(ah,"depthRange",[0,1]),St(Sr,"depthMask",!0),St(Cf,Cf,[!0,!0,!0,!0]),kt(Cd,Zr),St(kd,"cullFace",Ps),St(oh,oh,Ar),St(kf,kf,1),kt(Pd,Gr),St(La,"polygonOffset",[0,0]),kt(fh,ks),kt(zd,ph),St(uh,"sampleCoverage",[1,!1]),kt(Co,_h),St(Ud,"stencilMask",-1),St(ch,"stencilFunc",[km,0,-1]),St(Pf,"stencilOpSeparate",[Hf,mi,mi,mi]),St(ko,"stencilOpSeparate",[Ps,mi,mi,mi]),kt(Gd,Hd),St(ec,"scissor",[0,0,_.drawingBufferWidth,_.drawingBufferHeight]),St(es,es,[0,0,_.drawingBufferWidth,_.drawingBufferHeight]);var Pt={gl:_,context:Ct,strings:v,next:$t,current:Vt,draw:Ot,elements:K,buffer:lt,shader:Lt,attributes:It.state,vao:It,uniforms:vt,framebuffer:bt,extensions:L,timer:wt,isBufferArgs:Pa},Ut={primTypes:zr,compareFuncs:ka,blendFuncs:Dr,blendEquations:J,stencilOps:rs,glTypes:Xi,orientationType:cc};b.optional(function(){Pt.isArrayLike=Bn}),Yt&&(Ut.backBuffer=[Ps],Ut.drawBuffer=vr(tt.maxDrawbuffers,function(S){return S===0?[0]:vr(S,function(g){return Yo+g})}));var ge=0;function _e(){var S=Ta(),g=S.link,R=S.global;S.id=ge++,S.batchId="0";var U=g(Pt),$=S.shared={props:"a0"};Object.keys(Pt).forEach(function(O){$[O]=R.def(U,".",O)}),b.optional(function(){S.CHECK=g(b),S.commandStr=b.guessCommand(),S.command=g(S.commandStr),S.assert=function(O,E,X){O("if(!(",E,"))",this.CHECK,".commandRaise(",g(X),",",this.command,");")},Ut.invalidBlendCombinations=Xd});var D=S.next={},M=S.current={};Object.keys(ht).forEach(function(O){Array.isArray(Vt[O])&&(D[O]=R.def($.next,".",O),M[O]=R.def($.current,".",O))});var P=S.constants={};Object.keys(Ut).forEach(function(O){P[O]=R.def(JSON.stringify(Ut[O]))}),S.invoke=function(O,E){switch(E.type){case Oa:var X=["this",$.context,$.props,S.batchId];return O.def(g(E.data),".call(",X.slice(0,Math.max(E.data.length+1,4)),")");case Li:return O.def($.props,E.data);case Qu:return O.def($.context,E.data);case rh:return O.def("this",E.data);case Ba:return E.data.append(S,O),E.data.ref;case Fd:return E.data.toString();case ih:return E.data.map(function(j){return S.invoke(O,j)})}},S.attribCache={};var A={};return S.scopeAttrib=function(O){var E=v.id(O);if(E in A)return A[E];var X=It.scope[E];X||(X=It.scope[E]=new z);var j=A[E]=g(X);return j},S}function Gt(S){var g=S.static,R=S.dynamic,U;if(Po in g){var $=!!g[Po];U=zn(function(M,P){return $}),U.enable=$}else if(Po in R){var D=R[Po];U=mr(D,function(M,P){return M.invoke(P,D)})}return U}function jt(S,g){var R=S.static,U=S.dynamic;if(ns in R){var $=R[ns];return $?($=bt.getFramebuffer($),b.command($,"invalid framebuffer object"),zn(function(M,P){var A=M.link($),O=M.shared;P.set(O.framebuffer,".next",A);var E=O.context;return P.set(E,"."+Na,A+".width"),P.set(E,"."+Uo,A+".height"),A})):zn(function(M,P){var A=M.shared;P.set(A.framebuffer,".next","null");var O=A.context;return P.set(O,"."+Na,O+"."+Vd),P.set(O,"."+Uo,O+"."+sc),"null"})}else if(ns in U){var D=U[ns];return mr(D,function(M,P){var A=M.invoke(P,D),O=M.shared,E=O.framebuffer,X=P.def(E,".getFramebuffer(",A,")");b.optional(function(){M.assert(P,"!"+A+"||"+X,"invalid framebuffer object")}),P.set(E,".next",X);var j=O.context;return P.set(j,"."+Na,X+"?"+X+".width:"+j+"."+Vd),P.set(j,"."+Uo,X+"?"+X+".height:"+j+"."+sc),X})}else return null}function fe(S,g,R){var U=S.static,$=S.dynamic;function D(A){if(A in U){var O=U[A];b.commandType(O,"object","invalid "+A,R.commandStr);var E=!0,X=O.x|0,j=O.y|0,ct,_t;return"width"in O?(ct=O.width|0,b.command(ct>=0,"invalid "+A,R.commandStr)):E=!1,"height"in O?(_t=O.height|0,b.command(_t>=0,"invalid "+A,R.commandStr)):E=!1,new Pn(!E&&g&&g.thisDep,!E&&g&&g.contextDep,!E&&g&&g.propDep,function(ae,Ht){var mt=ae.shared.context,ot=ct;"width"in O||(ot=Ht.def(mt,".",Na,"-",X));var te=_t;return"height"in O||(te=Ht.def(mt,".",Uo,"-",j)),[X,j,ot,te]})}else if(A in $){var Nt=$[A],he=mr(Nt,function(ae,Ht){var mt=ae.invoke(Ht,Nt);b.optional(function(){ae.assert(Ht,mt+"&&typeof "+mt+'==="object"',"invalid "+A)});var ot=ae.shared.context,te=Ht.def(mt,".x|0"),Jt=Ht.def(mt,".y|0"),le=Ht.def('"width" in ',mt,"?",mt,".width|0:","(",ot,".",Na,"-",te,")"),nn=Ht.def('"height" in ',mt,"?",mt,".height|0:","(",ot,".",Uo,"-",Jt,")");return b.optional(function(){ae.assert(Ht,le+">=0&&"+nn+">=0","invalid "+A)}),[te,Jt,le,nn]});return g&&(he.thisDep=he.thisDep||g.thisDep,he.contextDep=he.contextDep||g.contextDep,he.propDep=he.propDep||g.propDep),he}else return g?new Pn(g.thisDep,g.contextDep,g.propDep,function(ae,Ht){var mt=ae.shared.context;return[0,0,Ht.def(mt,".",Na),Ht.def(mt,".",Uo)]}):null}var M=D(es);if(M){var P=M;M=new Pn(M.thisDep,M.contextDep,M.propDep,function(A,O){var E=P.append(A,O),X=A.shared.context;return O.set(X,"."+hh,E[2]),O.set(X,"."+$d,E[3]),E})}return{viewport:M,scissor_box:D(ec)}}function me(S,g){var R=S.static,U=typeof R[Ma]=="string"&&typeof R[zf]=="string";if(U){if(Object.keys(g.dynamic).length>0)return null;var $=g.static,D=Object.keys($);if(D.length>0&&typeof $[D[0]]=="number"){for(var M=[],P=0;P=0,"invalid "+Ht,g.commandStr),zn(function(Jt,le){return mt&&(Jt.OFFSET=ot),ot})}else if(Ht in U){var te=U[Ht];return mr(te,function(Jt,le){var nn=Jt.invoke(le,te);return mt&&(Jt.OFFSET=nn,b.optional(function(){Jt.assert(le,nn+">=0","invalid "+Ht)})),nn})}else if(mt){if(A)return zn(function(Jt,le){return Jt.OFFSET=0,0});if(D)return new Pn(P.thisDep,P.contextDep,P.propDep,function(Jt,le){return le.def(Jt.shared.vao+".currentVAO?"+Jt.shared.vao+".currentVAO.offset:0")})}else if(D)return new Pn(P.thisDep,P.contextDep,P.propDep,function(Jt,le){return le.def(Jt.shared.vao+".currentVAO?"+Jt.shared.vao+".currentVAO.instances:-1")});return null}var ct=j(Ra,!0);function _t(){if(Cs in R){var Ht=R[Cs]|0;return $.count=Ht,b.command(typeof Ht=="number"&&Ht>=0,"invalid vertex count",g.commandStr),zn(function(){return Ht})}else if(Cs in U){var mt=U[Cs];return mr(mt,function(le,nn){var cr=le.invoke(nn,mt);return b.optional(function(){le.assert(nn,"typeof "+cr+'==="number"&&'+cr+">=0&&"+cr+"===("+cr+"|0)","invalid vertex count")}),cr})}else if(A)if(zs(E)){if(E)return ct?new Pn(ct.thisDep,ct.contextDep,ct.propDep,function(le,nn){var cr=nn.def(le.ELEMENTS,".vertCount-",le.OFFSET);return b.optional(function(){le.assert(nn,cr+">=0","invalid vertex offset/element buffer too small")}),cr}):zn(function(le,nn){return nn.def(le.ELEMENTS,".vertCount")});var ot=zn(function(){return-1});return b.optional(function(){ot.MISSING=!0}),ot}else{var te=new Pn(E.thisDep||ct.thisDep,E.contextDep||ct.contextDep,E.propDep||ct.propDep,function(le,nn){var cr=le.ELEMENTS;return le.OFFSET?nn.def(cr,"?",cr,".vertCount-",le.OFFSET,":-1"):nn.def(cr,"?",cr,".vertCount:-1")});return b.optional(function(){te.DYNAMIC=!0}),te}else if(D){var Jt=new Pn(P.thisDep,P.contextDep,P.propDep,function(le,nn){return nn.def(le.shared.vao,".currentVAO?",le.shared.vao,".currentVAO.count:-1")});return Jt}return null}var Nt=X(),he=_t(),ae=j(nc,!1);return{elements:E,primitive:Nt,count:he,instances:ae,offset:ct,vao:P,vaoActive:D,elementsActive:A,static:$}}function xn(S,g){var R=S.static,U=S.dynamic,$={};return re.forEach(function(D){var M=qt(D);function P(A,O){if(D in R){var E=A(R[D]);$[M]=zn(function(){return E})}else if(D in U){var X=U[D];$[M]=mr(X,function(j,ct){return O(j,ct,j.invoke(ct,X))})}}switch(D){case Cd:case tc:case or:case Co:case Ff:case Gd:case Pd:case fh:case zd:case Sr:return P(function(A){return b.commandType(A,"boolean",D,g.commandStr),A},function(A,O,E){return b.optional(function(){A.assert(O,"typeof "+E+'==="boolean"',"invalid flag "+D,A.commandStr)}),E});case Ns:return P(function(A){return b.commandParameter(A,ka,"invalid "+D,g.commandStr),ka[A]},function(A,O,E){var X=A.constants.compareFuncs;return b.optional(function(){A.assert(O,E+" in "+X,"invalid "+D+", must be one of "+Object.keys(ka))}),O.def(X,"[",E,"]")});case ah:return P(function(A){return b.command(Bn(A)&&A.length===2&&typeof A[0]=="number"&&typeof A[1]=="number"&&A[0]<=A[1],"depth range is 2d array",g.commandStr),A},function(A,O,E){b.optional(function(){A.assert(O,A.shared.isArrayLike+"("+E+")&&"+E+".length===2&&typeof "+E+'[0]==="number"&&typeof '+E+'[1]==="number"&&'+E+"[0]<="+E+"[1]","depth range must be a 2d array")});var X=O.def("+",E,"[0]"),j=O.def("+",E,"[1]");return[X,j]});case Df:return P(function(A){b.commandType(A,"object","blend.func",g.commandStr);var O="srcRGB"in A?A.srcRGB:A.src,E="srcAlpha"in A?A.srcAlpha:A.src,X="dstRGB"in A?A.dstRGB:A.dst,j="dstAlpha"in A?A.dstAlpha:A.dst;return b.commandParameter(O,Dr,M+".srcRGB",g.commandStr),b.commandParameter(E,Dr,M+".srcAlpha",g.commandStr),b.commandParameter(X,Dr,M+".dstRGB",g.commandStr),b.commandParameter(j,Dr,M+".dstAlpha",g.commandStr),b.command(Xd.indexOf(O+", "+X)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+O+", "+X+")",g.commandStr),[Dr[O],Dr[X],Dr[E],Dr[j]]},function(A,O,E){var X=A.constants.blendFuncs;b.optional(function(){A.assert(O,E+"&&typeof "+E+'==="object"',"invalid blend func, must be an object")});function j(mt,ot){var te=O.def('"',mt,ot,'" in ',E,"?",E,".",mt,ot,":",E,".",mt);return b.optional(function(){A.assert(O,te+" in "+X,"invalid "+D+"."+mt+ot+", must be one of "+Object.keys(Dr))}),te}var ct=j("src","RGB"),_t=j("dst","RGB");b.optional(function(){var mt=A.constants.invalidBlendCombinations;A.assert(O,mt+".indexOf("+ct+'+", "+'+_t+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var Nt=O.def(X,"[",ct,"]"),he=O.def(X,"[",j("src","Alpha"),"]"),ae=O.def(X,"[",_t,"]"),Ht=O.def(X,"[",j("dst","Alpha"),"]");return[Nt,ae,he,Ht]});case qr:return P(function(A){if(typeof A=="string")return b.commandParameter(A,J,"invalid "+D,g.commandStr),[J[A],J[A]];if(typeof A=="object")return b.commandParameter(A.rgb,J,D+".rgb",g.commandStr),b.commandParameter(A.alpha,J,D+".alpha",g.commandStr),[J[A.rgb],J[A.alpha]];b.commandRaise("invalid blend.equation",g.commandStr)},function(A,O,E){var X=A.constants.blendEquations,j=O.def(),ct=O.def(),_t=A.cond("typeof ",E,'==="string"');return b.optional(function(){function Nt(he,ae,Ht){A.assert(he,Ht+" in "+X,"invalid "+ae+", must be one of "+Object.keys(J))}Nt(_t.then,D,E),A.assert(_t.else,E+"&&typeof "+E+'==="object"',"invalid "+D),Nt(_t.else,D+".rgb",E+".rgb"),Nt(_t.else,D+".alpha",E+".alpha")}),_t.then(j,"=",ct,"=",X,"[",E,"];"),_t.else(j,"=",X,"[",E,".rgb];",ct,"=",X,"[",E,".alpha];"),O(_t),[j,ct]});case sh:return P(function(A){return b.command(Bn(A)&&A.length===4,"blend.color must be a 4d array",g.commandStr),vr(4,function(O){return+A[O]})},function(A,O,E){return b.optional(function(){A.assert(O,A.shared.isArrayLike+"("+E+")&&"+E+".length===4","blend.color must be a 4d array")}),vr(4,function(X){return O.def("+",E,"[",X,"]")})});case Ud:return P(function(A){return b.commandType(A,"number",M,g.commandStr),A|0},function(A,O,E){return b.optional(function(){A.assert(O,"typeof "+E+'==="number"',"invalid stencil.mask")}),O.def(E,"|0")});case ch:return P(function(A){b.commandType(A,"object",M,g.commandStr);var O=A.cmp||"keep",E=A.ref||0,X="mask"in A?A.mask:-1;return b.commandParameter(O,ka,D+".cmp",g.commandStr),b.commandType(E,"number",D+".ref",g.commandStr),b.commandType(X,"number",D+".mask",g.commandStr),[ka[O],E,X]},function(A,O,E){var X=A.constants.compareFuncs;b.optional(function(){function Nt(){A.assert(O,Array.prototype.join.call(arguments,""),"invalid stencil.func")}Nt(E+"&&typeof ",E,'==="object"'),Nt('!("cmp" in ',E,")||(",E,".cmp in ",X,")")});var j=O.def('"cmp" in ',E,"?",X,"[",E,".cmp]",":",mi),ct=O.def(E,".ref|0"),_t=O.def('"mask" in ',E,"?",E,".mask|0:-1");return[j,ct,_t]});case Pf:case ko:return P(function(A){b.commandType(A,"object",M,g.commandStr);var O=A.fail||"keep",E=A.zfail||"keep",X=A.zpass||"keep";return b.commandParameter(O,rs,D+".fail",g.commandStr),b.commandParameter(E,rs,D+".zfail",g.commandStr),b.commandParameter(X,rs,D+".zpass",g.commandStr),[D===ko?Ps:Hf,rs[O],rs[E],rs[X]]},function(A,O,E){var X=A.constants.stencilOps;b.optional(function(){A.assert(O,E+"&&typeof "+E+'==="object"',"invalid "+D)});function j(ct){return b.optional(function(){A.assert(O,'!("'+ct+'" in '+E+")||("+E+"."+ct+" in "+X+")","invalid "+D+"."+ct+", must be one of "+Object.keys(rs))}),O.def('"',ct,'" in ',E,"?",X,"[",E,".",ct,"]:",mi)}return[D===ko?Ps:Hf,j("fail"),j("zfail"),j("zpass")]});case La:return P(function(A){b.commandType(A,"object",M,g.commandStr);var O=A.factor|0,E=A.units|0;return b.commandType(O,"number",M+".factor",g.commandStr),b.commandType(E,"number",M+".units",g.commandStr),[O,E]},function(A,O,E){b.optional(function(){A.assert(O,E+"&&typeof "+E+'==="object"',"invalid "+D)});var X=O.def(E,".factor|0"),j=O.def(E,".units|0");return[X,j]});case kd:return P(function(A){var O=0;return A==="front"?O=Hf:A==="back"&&(O=Ps),b.command(!!O,M,g.commandStr),O},function(A,O,E){return b.optional(function(){A.assert(O,E+'==="front"||'+E+'==="back"',"invalid cull.face")}),O.def(E,'==="front"?',Hf,":",Ps)});case kf:return P(function(A){return b.command(typeof A=="number"&&A>=tt.lineWidthDims[0]&&A<=tt.lineWidthDims[1],"invalid line width, must be a positive number between "+tt.lineWidthDims[0]+" and "+tt.lineWidthDims[1],g.commandStr),A},function(A,O,E){return b.optional(function(){A.assert(O,"typeof "+E+'==="number"&&'+E+">="+tt.lineWidthDims[0]+"&&"+E+"<="+tt.lineWidthDims[1],"invalid line width")}),E});case oh:return P(function(A){return b.commandParameter(A,cc,M,g.commandStr),cc[A]},function(A,O,E){return b.optional(function(){A.assert(O,E+'==="cw"||'+E+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),O.def(E+'==="cw"?'+gh+":"+Ar)});case Cf:return P(function(A){return b.command(Bn(A)&&A.length===4,"color.mask must be length 4 array",g.commandStr),A.map(function(O){return!!O})},function(A,O,E){return b.optional(function(){A.assert(O,A.shared.isArrayLike+"("+E+")&&"+E+".length===4","invalid color.mask")}),vr(4,function(X){return"!!"+E+"["+X+"]"})});case uh:return P(function(A){b.command(typeof A=="object"&&A,M,g.commandStr);var O="value"in A?A.value:1,E=!!A.invert;return b.command(typeof O=="number"&&O>=0&&O<=1,"sample.coverage.value must be a number between 0 and 1",g.commandStr),[O,E]},function(A,O,E){b.optional(function(){A.assert(O,E+"&&typeof "+E+'==="object"',"invalid sample.coverage")});var X=O.def('"value" in ',E,"?+",E,".value:1"),j=O.def("!!",E,".invert");return[X,j]})}}),$}function Le(S,g){var R=S.static,U=S.dynamic,$={};return Object.keys(R).forEach(function(D){var M=R[D],P;if(typeof M=="number"||typeof M=="boolean")P=zn(function(){return M});else if(typeof M=="function"){var A=M._reglType;A==="texture2d"||A==="textureCube"?P=zn(function(O){return O.link(M)}):A==="framebuffer"||A==="framebufferCube"?(b.command(M.color.length>0,'missing color attachment for framebuffer sent to uniform "'+D+'"',g.commandStr),P=zn(function(O){return O.link(M.color[0])})):b.commandRaise('invalid data for uniform "'+D+'"',g.commandStr)}else Bn(M)?P=zn(function(O){var E=O.global.def("[",vr(M.length,function(X){return b.command(typeof M[X]=="number"||typeof M[X]=="boolean","invalid uniform "+D,O.commandStr),M[X]}),"]");return E}):b.commandRaise('invalid or missing data for uniform "'+D+'"',g.commandStr);P.value=M,$[D]=P}),Object.keys(U).forEach(function(D){var M=U[D];$[D]=mr(M,function(P,A){return P.invoke(A,M)})}),$}function mn(S,g){var R=S.static,U=S.dynamic,$={};return Object.keys(R).forEach(function(D){var M=R[D],P=v.id(D),A=new z;if(Pa(M))A.state=Ia,A.buffer=lt.getBuffer(lt.create(M,Go,!1,!0)),A.type=0;else{var O=lt.getBuffer(M);if(O)A.state=Ia,A.buffer=O,A.type=0;else if(b.command(typeof M=="object"&&M,"invalid data for attribute "+D,g.commandStr),"constant"in M){var E=M.constant;A.buffer="null",A.state=Ju,typeof E=="number"?A.x=E:(b.command(Bn(E)&&E.length>0&&E.length<=4,"invalid constant for attribute "+D,g.commandStr),pr.forEach(function(ae,Ht){Ht=0,'invalid offset for attribute "'+D+'"',g.commandStr);var j=M.stride|0;b.command(j>=0&&j<256,'invalid stride for attribute "'+D+'", must be integer betweeen [0, 255]',g.commandStr);var ct=M.size|0;b.command(!("size"in M)||ct>0&&ct<=4,'invalid size for attribute "'+D+'", must be 1,2,3,4',g.commandStr);var _t=!!M.normalized,Nt=0;"type"in M&&(b.commandParameter(M.type,Xi,"invalid type for attribute "+D,g.commandStr),Nt=Xi[M.type]);var he=M.divisor|0;b.optional(function(){"divisor"in M&&(b.command(he===0||xt,'cannot specify divisor for attribute "'+D+'", instancing not supported',g.commandStr),b.command(he>=0,'invalid divisor for attribute "'+D+'"',g.commandStr));var ae=g.commandStr,Ht=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(M).forEach(function(mt){b.command(Ht.indexOf(mt)>=0,'unknown parameter "'+mt+'" for attribute pointer "'+D+'" (valid parameters are '+Ht+")",ae)})}),A.buffer=O,A.state=Ia,A.size=ct,A.normalized=_t,A.type=Nt||O.dtype,A.offset=X,A.stride=j,A.divisor=he}}$[D]=zn(function(ae,Ht){var mt=ae.attribCache;if(P in mt)return mt[P];var ot={isStream:!1};return Object.keys(A).forEach(function(te){ot[te]=A[te]}),A.buffer&&(ot.buffer=ae.link(A.buffer),ot.type=ot.type||ot.buffer+".dtype"),mt[P]=ot,ot})}),Object.keys(U).forEach(function(D){var M=U[D];function P(A,O){var E=A.invoke(O,M),X=A.shared,j=A.constants,ct=X.isBufferArgs,_t=X.buffer;b.optional(function(){A.assert(O,E+"&&(typeof "+E+'==="object"||typeof '+E+'==="function")&&('+ct+"("+E+")||"+_t+".getBuffer("+E+")||"+_t+".getBuffer("+E+".buffer)||"+ct+"("+E+'.buffer)||("constant" in '+E+"&&(typeof "+E+'.constant==="number"||'+X.isArrayLike+"("+E+".constant))))",'invalid dynamic attribute "'+D+'"')});var Nt={isStream:O.def(!1)},he=new z;he.state=Ia,Object.keys(he).forEach(function(ot){Nt[ot]=O.def(""+he[ot])});var ae=Nt.buffer,Ht=Nt.type;O("if(",ct,"(",E,")){",Nt.isStream,"=true;",ae,"=",_t,".createStream(",Go,",",E,");",Ht,"=",ae,".dtype;","}else{",ae,"=",_t,".getBuffer(",E,");","if(",ae,"){",Ht,"=",ae,".dtype;",'}else if("constant" in ',E,"){",Nt.state,"=",Ju,";","if(typeof "+E+'.constant === "number"){',Nt[pr[0]],"=",E,".constant;",pr.slice(1).map(function(ot){return Nt[ot]}).join("="),"=0;","}else{",pr.map(function(ot,te){return Nt[ot]+"="+E+".constant.length>"+te+"?"+E+".constant["+te+"]:0;"}).join(""),"}}else{","if(",ct,"(",E,".buffer)){",ae,"=",_t,".createStream(",Go,",",E,".buffer);","}else{",ae,"=",_t,".getBuffer(",E,".buffer);","}",Ht,'="type" in ',E,"?",j.glTypes,"[",E,".type]:",ae,".dtype;",Nt.normalized,"=!!",E,".normalized;");function mt(ot){O(Nt[ot],"=",E,".",ot,"|0;")}return mt("size"),mt("offset"),mt("stride"),mt("divisor"),O("}}"),O.exit("if(",Nt.isStream,"){",_t,".destroyStream(",ae,");","}"),Nt}$[D]=mr(M,P)}),$}function sn(S){var g=S.static,R=S.dynamic,U={};return Object.keys(g).forEach(function($){var D=g[$];U[$]=zn(function(M,P){return typeof D=="number"||typeof D=="boolean"?""+D:M.link(D)})}),Object.keys(R).forEach(function($){var D=R[$];U[$]=mr(D,function(M,P){return M.invoke(P,D)})}),U}function Vn(S,g,R,U,$){var D=S.static,M=S.dynamic;b.optional(function(){var mt=[ns,zf,Ma,Ds,Fs,Ra,Cs,nc,Po,zo].concat(re);function ot(te){Object.keys(te).forEach(function(Jt){b.command(mt.indexOf(Jt)>=0,'unknown parameter "'+Jt+'"',$.commandStr)})}ot(D),ot(M)});var P=me(S,g),A=jt(S),O=fe(S,A,$),E=Tn(S,$),X=xn(S,$),j=Ee(S,$,P);function ct(mt){var ot=O[mt];ot&&(X[mt]=ot)}ct(es),ct(qt(ec));var _t=Object.keys(X).length>0,Nt={framebuffer:A,draw:E,shader:j,state:X,dirty:_t,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(Nt.profile=Gt(S),Nt.uniforms=Le(R,$),Nt.drawVAO=Nt.scopeVAO=E.vao,!Nt.drawVAO&&j.program&&!P&&L.angle_instanced_arrays&&E.static.elements){var he=!0,ae=j.program.attributes.map(function(mt){var ot=g.static[mt];return he=he&&!!ot,ot});if(he&&ae.length>0){var Ht=It.getVAO(It.createVAO({attributes:ae,elements:E.static.elements}));Nt.drawVAO=new Pn(null,null,null,function(mt,ot){return mt.link(Ht)}),Nt.useVAO=!0}}return P?Nt.useVAO=!0:Nt.attributes=mn(g,$),Nt.context=sn(U),Nt}function jn(S,g,R){var U=S.shared,$=U.context,D=S.scope();Object.keys(R).forEach(function(M){g.save($,"."+M);var P=R[M],A=P.append(S,g);Array.isArray(A)?D($,".",M,"=[",A.join(),"];"):D($,".",M,"=",A,";")}),g(D)}function Yn(S,g,R,U){var $=S.shared,D=$.gl,M=$.framebuffer,P;Yt&&(P=g.def($.extensions,".webgl_draw_buffers"));var A=S.constants,O=A.drawBuffer,E=A.backBuffer,X;R?X=R.append(S,g):X=g.def(M,".next"),U||g("if(",X,"!==",M,".cur){"),g("if(",X,"){",D,".bindFramebuffer(",bh,",",X,".framebuffer);"),Yt&&g(P,".drawBuffersWEBGL(",O,"[",X,".colorAttachments.length]);"),g("}else{",D,".bindFramebuffer(",bh,",null);"),Yt&&g(P,".drawBuffersWEBGL(",E,");"),g("}",M,".cur=",X,";"),U||g("}")}function er(S,g,R){var U=S.shared,$=U.gl,D=S.current,M=S.next,P=U.current,A=U.next,O=S.cond(P,".dirty");re.forEach(function(E){var X=qt(E);if(!(X in R.state)){var j,ct;if(X in M){j=M[X],ct=D[X];var _t=vr(Vt[X].length,function(he){return O.def(j,"[",he,"]")});O(S.cond(_t.map(function(he,ae){return he+"!=="+ct+"["+ae+"]"}).join("||")).then($,".",ht[X],"(",_t,");",_t.map(function(he,ae){return ct+"["+ae+"]="+he}).join(";"),";"))}else{j=O.def(A,".",X);var Nt=S.cond(j,"!==",P,".",X);O(Nt),X in dt?Nt(S.cond(j).then($,".enable(",dt[X],");").else($,".disable(",dt[X],");"),P,".",X,"=",j,";"):Nt($,".",ht[X],"(",j,");",P,".",X,"=",j,";")}}}),Object.keys(R.state).length===0&&O(P,".dirty=false;"),g(O)}function fr(S,g,R,U){var $=S.shared,D=S.current,M=$.current,P=$.gl;lc(Object.keys(R)).forEach(function(A){var O=R[A];if(!(U&&!U(O))){var E=O.append(S,g);if(dt[A]){var X=dt[A];zs(O)?E?g(P,".enable(",X,");"):g(P,".disable(",X,");"):g(S.cond(E).then(P,".enable(",X,");").else(P,".disable(",X,");")),g(M,".",A,"=",E,";")}else if(Bn(E)){var j=D[A];g(P,".",ht[A],"(",E,");",E.map(function(ct,_t){return j+"["+_t+"]="+ct}).join(";"),";")}else g(P,".",ht[A],"(",E,");",M,".",A,"=",E,";")}})}function Un(S,g){xt&&(S.instancing=g.def(S.shared.extensions,".angle_instanced_arrays"))}function we(S,g,R,U,$){var D=S.shared,M=S.stats,P=D.current,A=D.timer,O=R.profile;function E(){return typeof performance>"u"?"Date.now()":"performance.now()"}var X,j;function ct(mt){X=g.def(),mt(X,"=",E(),";"),typeof $=="string"?mt(M,".count+=",$,";"):mt(M,".count++;"),wt&&(U?(j=g.def(),mt(j,"=",A,".getNumPendingQueries();")):mt(A,".beginQuery(",M,");"))}function _t(mt){mt(M,".cpuTime+=",E(),"-",X,";"),wt&&(U?mt(A,".pushScopeStats(",j,",",A,".getNumPendingQueries(),",M,");"):mt(A,".endQuery();"))}function Nt(mt){var ot=g.def(P,".profile");g(P,".profile=",mt,";"),g.exit(P,".profile=",ot,";")}var he;if(O){if(zs(O)){O.enable?(ct(g),_t(g.exit),Nt("true")):Nt("false");return}he=O.append(S,g),Nt(he)}else he=g.def(P,".profile");var ae=S.block();ct(ae),g("if(",he,"){",ae,"}");var Ht=S.block();_t(Ht),g.exit("if(",he,"){",Ht,"}")}function ur(S,g,R,U,$){var D=S.shared;function M(A){switch(A){case Da:case Vo:case pi:return 2;case Gf:case jo:case $f:return 3;case $o:case _i:case Vf:return 4;default:return 1}}function P(A,O,E){var X=D.gl,j=g.def(A,".location"),ct=g.def(D.attributes,"[",j,"]"),_t=E.state,Nt=E.buffer,he=[E.x,E.y,E.z,E.w],ae=["buffer","normalized","offset","stride"];function Ht(){g("if(!",ct,".buffer){",X,".enableVertexAttribArray(",j,");}");var ot=E.type,te;if(E.size?te=g.def(E.size,"||",O):te=O,g("if(",ct,".type!==",ot,"||",ct,".size!==",te,"||",ae.map(function(le){return ct+"."+le+"!=="+E[le]}).join("||"),"){",X,".bindBuffer(",Go,",",Nt,".buffer);",X,".vertexAttribPointer(",[j,te,ot,E.normalized,E.stride,E.offset],");",ct,".type=",ot,";",ct,".size=",te,";",ae.map(function(le){return ct+"."+le+"="+E[le]+";"}).join(""),"}"),xt){var Jt=E.divisor;g("if(",ct,".divisor!==",Jt,"){",S.instancing,".vertexAttribDivisorANGLE(",[j,Jt],");",ct,".divisor=",Jt,";}")}}function mt(){g("if(",ct,".buffer){",X,".disableVertexAttribArray(",j,");",ct,".buffer=null;","}if(",pr.map(function(ot,te){return ct+"."+ot+"!=="+he[te]}).join("||"),"){",X,".vertexAttrib4f(",j,",",he,");",pr.map(function(ot,te){return ct+"."+ot+"="+he[te]+";"}).join(""),"}")}_t===Ia?Ht():_t===Ju?mt():(g("if(",_t,"===",Ia,"){"),Ht(),g("}else{"),mt(),g("}"))}U.forEach(function(A){var O=A.name,E=R.attributes[O],X;if(E){if(!$(E))return;X=E.append(S,g)}else{if(!$(wh))return;var j=S.scopeAttrib(O);b.optional(function(){S.assert(g,j+".state","missing attribute "+O)}),X={},Object.keys(new z).forEach(function(ct){X[ct]=g.def(j,".",ct)})}P(S.link(A),M(A.info.type),X)})}function en(S,g,R,U,$,D){for(var M=S.shared,P=M.gl,A={},O,E=0;E1){if(!Nt)continue;var he=j.replace("[0]","");if(A[he])continue;A[he]=1}var ae=S.link(X),Ht=ae+".location",mt;if(Nt){if(!$(Nt))continue;if(zs(Nt)){var ot=Nt.value;if(b.command(ot!==null&&typeof ot<"u",'missing uniform "'+j+'"',S.commandStr),ct===Yf||ct===Wo){b.command(typeof ot=="function"&&(ct===Yf&&(ot._reglType==="texture2d"||ot._reglType==="framebuffer")||ct===Wo&&(ot._reglType==="textureCube"||ot._reglType==="framebufferCube")),"invalid texture for uniform "+j,S.commandStr);var te=S.link(ot._texture||ot.color[0]._texture);g(P,".uniform1i(",Ht,",",te+".bind());"),g.exit(te,".unbind();")}else if(ct===Fa||ct===jf||ct===Wf){b.optional(function(){b.command(Bn(ot),"invalid matrix for uniform "+j,S.commandStr),b.command(ct===Fa&&ot.length===4||ct===jf&&ot.length===9||ct===Wf&&ot.length===16,"invalid length for matrix uniform "+j,S.commandStr)});var Jt=S.global.def("new Float32Array(["+Array.prototype.slice.call(ot)+"])"),le=2;ct===jf?le=3:ct===Wf&&(le=4),g(P,".uniformMatrix",le,"fv(",Ht,",false,",Jt,");")}else{switch(ct){case oc:_t===1?b.commandType(ot,"number","uniform "+j,S.commandStr):b.command(Bn(ot)&&ot.length===_t,"uniform "+j,S.commandStr),O="1f";break;case Da:b.command(Bn(ot)&&ot.length&&ot.length%2===0&&ot.length<=_t*2,"uniform "+j,S.commandStr),O="2f";break;case Gf:b.command(Bn(ot)&&ot.length&&ot.length%3===0&&ot.length<=_t*3,"uniform "+j,S.commandStr),O="3f";break;case $o:b.command(Bn(ot)&&ot.length&&ot.length%4===0&&ot.length<=_t*4,"uniform "+j,S.commandStr),O="4f";break;case mh:_t===1?b.commandType(ot,"boolean","uniform "+j,S.commandStr):b.command(Bn(ot)&&ot.length===_t,"uniform "+j,S.commandStr),O="1i";break;case fc:_t===1?b.commandType(ot,"number","uniform "+j,S.commandStr):b.command(Bn(ot)&&ot.length===_t,"uniform "+j,S.commandStr),O="1i";break;case pi:b.command(Bn(ot)&&ot.length&&ot.length%2===0&&ot.length<=_t*2,"uniform "+j,S.commandStr),O="2i";break;case Vo:b.command(Bn(ot)&&ot.length&&ot.length%2===0&&ot.length<=_t*2,"uniform "+j,S.commandStr),O="2i";break;case $f:b.command(Bn(ot)&&ot.length&&ot.length%3===0&&ot.length<=_t*3,"uniform "+j,S.commandStr),O="3i";break;case jo:b.command(Bn(ot)&&ot.length&&ot.length%3===0&&ot.length<=_t*3,"uniform "+j,S.commandStr),O="3i";break;case Vf:b.command(Bn(ot)&&ot.length&&ot.length%4===0&&ot.length<=_t*4,"uniform "+j,S.commandStr),O="4i";break;case _i:b.command(Bn(ot)&&ot.length&&ot.length%4===0&&ot.length<=_t*4,"uniform "+j,S.commandStr),O="4i";break}_t>1?(O+="v",ot=S.global.def("["+Array.prototype.slice.call(ot)+"]")):ot=Bn(ot)?Array.prototype.slice.call(ot):ot,g(P,".uniform",O,"(",Ht,",",ot,");")}continue}else mt=Nt.append(S,g)}else{if(!$(wh))continue;mt=g.def(M.uniforms,"[",v.id(j),"]")}ct===Yf?(b(!Array.isArray(mt),"must specify a scalar prop for textures"),g("if(",mt,"&&",mt,'._reglType==="framebuffer"){',mt,"=",mt,".color[0];","}")):ct===Wo&&(b(!Array.isArray(mt),"must specify a scalar prop for cube maps"),g("if(",mt,"&&",mt,'._reglType==="framebufferCube"){',mt,"=",mt,".color[0];","}")),b.optional(function(){function $r(Er,qf){S.assert(g,Er,'bad data or missing for uniform "'+j+'". '+qf)}function $a(Er,qf){qf===1&&b(!Array.isArray(mt),"must not specify an array type for uniform"),$r("Array.isArray("+mt+") && typeof "+mt+'[0]===" '+Er+'" || typeof '+mt+'==="'+Er+'"',"invalid type, expected "+Er)}function Kr(Er,qf,pc){Array.isArray(mt)?b(mt.length&&mt.length%Er===0&&mt.length<=Er*pc,"must have length of "+(pc===1?"":"n * ")+Er):$r(M.isArrayLike+"("+mt+")&&"+mt+".length && "+mt+".length % "+Er+" === 0 && "+mt+".length<="+Er*pc,"invalid vector, should have length of "+(pc===1?"":"n * ")+Er,S.commandStr)}function Qd(Er){b(!Array.isArray(mt),"must not specify a value type"),$r("typeof "+mt+'==="function"&&'+mt+'._reglType==="texture'+(Er===Wd?"2d":"Cube")+'"',"invalid texture type",S.commandStr)}switch(ct){case fc:$a("number",_t);break;case Vo:Kr(2,"number",_t);break;case jo:Kr(3,"number",_t);break;case _i:Kr(4,"number",_t);break;case oc:$a("number",_t);break;case Da:Kr(2,"number",_t);break;case Gf:Kr(3,"number",_t);break;case $o:Kr(4,"number",_t);break;case mh:$a("boolean",_t);break;case pi:Kr(2,"boolean",_t);break;case $f:Kr(3,"boolean",_t);break;case Vf:Kr(4,"boolean",_t);break;case Fa:Kr(4,"number",_t);break;case jf:Kr(9,"number",_t);break;case Wf:Kr(16,"number",_t);break;case Yf:Qd(Wd);break;case Wo:Qd(Dm);break}});var nn=1;switch(ct){case Yf:case Wo:var cr=g.def(mt,"._texture");g(P,".uniform1i(",Ht,",",cr,".bind());"),g.exit(cr,".unbind();");continue;case fc:case mh:O="1i";break;case Vo:case pi:O="2i",nn=2;break;case jo:case $f:O="3i",nn=3;break;case _i:case Vf:O="4i",nn=4;break;case oc:O="1f";break;case Da:O="2f",nn=2;break;case Gf:O="3f",nn=3;break;case $o:O="4f",nn=4;break;case Fa:O="Matrix2fv";break;case jf:O="Matrix3fv";break;case Wf:O="Matrix4fv";break}if(O.indexOf("Matrix")===-1&&_t>1&&(O+="v",nn=1),O.charAt(0)==="M"){g(P,".uniform",O,"(",Ht,",");var Ua=Math.pow(ct-Fa+2,2),ss=S.global.def("new Float32Array(",Ua,")");Array.isArray(mt)?g("false,(",vr(Ua,function($r){return ss+"["+$r+"]="+mt[$r]}),",",ss,")"):g("false,(Array.isArray(",mt,")||",mt," instanceof Float32Array)?",mt,":(",vr(Ua,function($r){return ss+"["+$r+"]="+mt+"["+$r+"]"}),",",ss,")"),g(");")}else if(nn>1){for(var Ni=[],Gs=[],Ga=0;Ga=0","missing vertex count")})):(Jt=le.def(M,".",Cs),b.optional(function(){S.assert(le,Jt+">=0","missing vertex count")})),Jt}var E=A();function X(te){var Jt=P[te];return Jt?Jt.contextDep&&U.contextDynamic||Jt.propDep?Jt.append(S,R):Jt.append(S,g):g.def(M,".",te)}var j=X(Fs),ct=X(Ra),_t=O();if(typeof _t=="number"){if(_t===0)return}else R("if(",_t,"){"),R.exit("}");var Nt,he;xt&&(Nt=X(nc),he=S.instancing);var ae=E+".type",Ht=P.elements&&zs(P.elements)&&!P.vaoActive;function mt(){function te(){R(he,".drawElementsInstancedANGLE(",[j,_t,ae,ct+"<<(("+ae+"-"+Dd+")>>1)",Nt],");")}function Jt(){R(he,".drawArraysInstancedANGLE(",[j,ct,_t,Nt],");")}E&&E!=="null"?Ht?te():(R("if(",E,"){"),te(),R("}else{"),Jt(),R("}")):Jt()}function ot(){function te(){R(D+".drawElements("+[j,_t,ae,ct+"<<(("+ae+"-"+Dd+")>>1)"]+");")}function Jt(){R(D+".drawArrays("+[j,ct,_t]+");")}E&&E!=="null"?Ht?te():(R("if(",E,"){"),te(),R("}else{"),Jt(),R("}")):Jt()}xt&&(typeof Nt!="number"||Nt>=0)?typeof Nt=="string"?(R("if(",Nt,">0){"),mt(),R("}else if(",Nt,"<0){"),ot(),R("}")):mt():ot()}function Me(S,g,R,U,$){var D=_e(),M=D.proc("body",$);return b.optional(function(){D.commandStr=g.commandStr,D.command=D.link(g.commandStr)}),xt&&(D.instancing=M.def(D.shared.extensions,".angle_instanced_arrays")),S(D,M,R,U),D.compile().body}function Ve(S,g,R,U){Un(S,g),R.useVAO?R.drawVAO?g(S.shared.vao,".setVAO(",R.drawVAO.append(S,g),");"):g(S.shared.vao,".setVAO(",S.shared.vao,".targetVAO);"):(g(S.shared.vao,".setVAO(null);"),ur(S,g,R,U.attributes,function(){return!0})),en(S,g,R,U.uniforms,function(){return!0},!1),ce(S,g,g,R)}function Gn(S,g){var R=S.proc("draw",1);Un(S,R),jn(S,R,g.context),Yn(S,R,g.framebuffer),er(S,R,g),fr(S,R,g.state),we(S,R,g,!1,!0);var U=g.shader.progVar.append(S,R);if(R(S.shared.gl,".useProgram(",U,".program);"),g.shader.program)Ve(S,R,g,g.shader.program);else{R(S.shared.vao,".setVAO(null);");var $=S.global.def("{}"),D=R.def(U,".id"),M=R.def($,"[",D,"]");R(S.cond(M).then(M,".call(this,a0);").else(M,"=",$,"[",D,"]=",S.link(function(P){return Me(Ve,S,g,P,1)}),"(",U,");",M,".call(this,a0);"))}Object.keys(g.state).length>0&&R(S.shared.current,".dirty=true;"),S.shared.vao&&R(S.shared.vao,".setVAO(null);")}function gi(S,g,R,U){S.batchId="a1",Un(S,g);function $(){return!0}ur(S,g,R,U.attributes,$),en(S,g,R,U.uniforms,$,!1),ce(S,g,g,R)}function Us(S,g,R,U){Un(S,g);var $=R.contextDep,D=g.def(),M="a0",P="a1",A=g.def();S.shared.props=A,S.batchId=D;var O=S.scope(),E=S.scope();g(O.entry,"for(",D,"=0;",D,"<",P,";++",D,"){",A,"=",M,"[",D,"];",E,"}",O.exit);function X(ae){return ae.contextDep&&$||ae.propDep}function j(ae){return!X(ae)}if(R.needsContext&&jn(S,E,R.context),R.needsFramebuffer&&Yn(S,E,R.framebuffer),fr(S,E,R.state,X),R.profile&&X(R.profile)&&we(S,E,R,!1,!0),U)R.useVAO?R.drawVAO?X(R.drawVAO)?E(S.shared.vao,".setVAO(",R.drawVAO.append(S,E),");"):O(S.shared.vao,".setVAO(",R.drawVAO.append(S,O),");"):O(S.shared.vao,".setVAO(",S.shared.vao,".targetVAO);"):(O(S.shared.vao,".setVAO(null);"),ur(S,O,R,U.attributes,j),ur(S,E,R,U.attributes,X)),en(S,O,R,U.uniforms,j,!1),en(S,E,R,U.uniforms,X,!0),ce(S,O,E,R);else{var ct=S.global.def("{}"),_t=R.shader.progVar.append(S,E),Nt=E.def(_t,".id"),he=E.def(ct,"[",Nt,"]");E(S.shared.gl,".useProgram(",_t,".program);","if(!",he,"){",he,"=",ct,"[",Nt,"]=",S.link(function(ae){return Me(gi,S,R,ae,2)}),"(",_t,");}",he,".call(this,a0[",D,"],",D,");")}}function T(S,g){var R=S.proc("batch",2);S.batchId="0",Un(S,R);var U=!1,$=!0;Object.keys(g.context).forEach(function(ct){U=U||g.context[ct].propDep}),U||(jn(S,R,g.context),$=!1);var D=g.framebuffer,M=!1;D?(D.propDep?U=M=!0:D.contextDep&&U&&(M=!0),M||Yn(S,R,D)):Yn(S,R,null),g.state.viewport&&g.state.viewport.propDep&&(U=!0);function P(ct){return ct.contextDep&&U||ct.propDep}er(S,R,g),fr(S,R,g.state,function(ct){return!P(ct)}),(!g.profile||!P(g.profile))&&we(S,R,g,!1,"a1"),g.contextDep=U,g.needsContext=$,g.needsFramebuffer=M;var A=g.shader.progVar;if(A.contextDep&&U||A.propDep)Us(S,R,g,null);else{var O=A.append(S,R);if(R(S.shared.gl,".useProgram(",O,".program);"),g.shader.program)Us(S,R,g,g.shader.program);else{R(S.shared.vao,".setVAO(null);");var E=S.global.def("{}"),X=R.def(O,".id"),j=R.def(E,"[",X,"]");R(S.cond(j).then(j,".call(this,a0,a1);").else(j,"=",E,"[",X,"]=",S.link(function(ct){return Me(Us,S,g,ct,2)}),"(",O,");",j,".call(this,a0,a1);"))}}Object.keys(g.state).length>0&&R(S.shared.current,".dirty=true;"),S.shared.vao&&R(S.shared.vao,".setVAO(null);")}function nt(S,g){var R=S.proc("scope",3);S.batchId="a2";var U=S.shared,$=U.current;jn(S,R,g.context),g.framebuffer&&g.framebuffer.append(S,R),lc(Object.keys(g.state)).forEach(function(M){var P=g.state[M],A=P.append(S,R);Bn(A)?A.forEach(function(O,E){R.set(S.next[M],"["+E+"]",O)}):R.set(U.next,"."+M,A)}),we(S,R,g,!0,!0),[Ds,Ra,Cs,nc,Fs].forEach(function(M){var P=g.draw[M];P&&R.set(U.draw,"."+M,""+P.append(S,R))}),Object.keys(g.uniforms).forEach(function(M){var P=g.uniforms[M].append(S,R);Array.isArray(P)&&(P="["+P.join()+"]"),R.set(U.uniforms,"["+v.id(M)+"]",P)}),Object.keys(g.attributes).forEach(function(M){var P=g.attributes[M].append(S,R),A=S.scopeAttrib(M);Object.keys(new z).forEach(function(O){R.set(A,"."+O,P[O])})}),g.scopeVAO&&R.set(U.vao,".targetVAO",g.scopeVAO.append(S,R));function D(M){var P=g.shader[M];P&&R.set(U.shader,"."+M,P.append(S,R))}D(zf),D(Ma),Object.keys(g.state).length>0&&(R($,".dirty=true;"),R.exit($,".dirty=true;")),R("a1(",S.shared.context,",a0,",S.batchId,");")}function q(S){if(!(typeof S!="object"||Bn(S))){for(var g=Object.keys(S),R=0;R=0;--ce){var Me=Ut[ce];Me&&Me(wt,null,0)}L.flush(),It&&It.update()}function me(){!jt&&Ut.length>0&&(jt=Pr.next(fe))}function Ee(){jt&&(Pr.cancel(fe),jt=null)}function Tn(ce){ce.preventDefault(),lt=!0,Ee(),ge.forEach(function(Me){Me()})}function xn(ce){L.getError(),lt=!1,K.restore(),$t.restore(),xt.restore(),re.restore(),dt.restore(),ht.restore(),pt.restore(),It&&It.restore(),qt.procs.refresh(),me(),_e.forEach(function(Me){Me()})}Pt&&(Pt.addEventListener(Ri,Tn,!1),Pt.addEventListener(hc,xn,!1));function Le(){Ut.length=0,Ee(),Pt&&(Pt.removeEventListener(Ri,Tn),Pt.removeEventListener(hc,xn)),$t.clear(),ht.clear(),dt.clear(),pt.clear(),re.clear(),Yt.clear(),xt.clear(),It&&It.clear(),Gt.forEach(function(ce){ce()})}function mn(ce){b(!!ce,"invalid args to regl({...})"),b.type(ce,"object","invalid args to regl({...})");function Me($){var D=r({},$);delete D.uniforms,delete D.attributes,delete D.context,delete D.vao,"stencil"in D&&D.stencil.op&&(D.stencil.opBack=D.stencil.opFront=D.stencil.op,delete D.stencil.op);function M(P){if(P in D){var A=D[P];delete D[P],Object.keys(A).forEach(function(O){D[P+"."+O]=A[O]})}}return M("blend"),M("depth"),M("cull"),M("stencil"),M("polygonOffset"),M("scissor"),M("sample"),"vao"in $&&(D.vao=$.vao),D}function Ve($,D){var M={},P={};return Object.keys($).forEach(function(A){var O=$[A];if(hr.isDynamic(O)){P[A]=hr.unbox(O,A);return}else if(D&&Array.isArray(O)){for(var E=0;E0)return Ae.call(this,R($|0),$|0)}else if(Array.isArray($)){if($.length)return Ae.call(this,$,$.length)}else return Xt.call(this,$)}return r(U,{stats:nt,destroy:function(){q.destroy()}})}var sn=ht.setFBO=mn({framebuffer:hr.define.call(null,dc,"framebuffer")});function Vn(ce,Me){var Ve=0;qt.procs.poll();var Gn=Me.color;Gn&&(L.clearColor(+Gn[0]||0,+Gn[1]||0,+Gn[2]||0,+Gn[3]||0),Ve|=Um),"depth"in Me&&(L.clearDepth(+Me.depth),Ve|=Kd),"stencil"in Me&&(L.clearStencil(Me.stencil|0),Ve|=Gm),b(!!Ve,"called regl.clear with no buffer specified"),L.clear(Ve)}function jn(ce){if(b(typeof ce=="object"&&ce,"regl.clear() takes an object as input"),"framebuffer"in ce)if(ce.framebuffer&&ce.framebuffer_reglType==="framebufferCube")for(var Me=0;Me<6;++Me)sn(r({framebuffer:ce.framebuffer.faces[Me]},ce),Vn);else sn(ce,Vn);else Vn(null,ce)}function Yn(ce){b.type(ce,"function","regl.frame() callback must be a function"),Ut.push(ce);function Me(){var Ve=za(Ut,ce);b(Ve>=0,"cannot cancel a frame twice");function Gn(){var gi=za(Ut,Gn);Ut[gi]=Ut[Ut.length-1],Ut.length-=1,Ut.length<=0&&Ee()}Ut[Ve]=Gn}return me(),{cancel:Me}}function er(){var ce=St.viewport,Me=St.scissor_box;ce[0]=ce[1]=Me[0]=Me[1]=0,wt.viewportWidth=wt.framebufferWidth=wt.drawingBufferWidth=ce[2]=Me[2]=L.drawingBufferWidth,wt.viewportHeight=wt.framebufferHeight=wt.drawingBufferHeight=ce[3]=Me[3]=L.drawingBufferHeight}function fr(){wt.tick+=1,wt.time=we(),er(),qt.procs.poll()}function Un(){re.refresh(),er(),qt.procs.refresh(),It&&It.update()}function we(){return(ji()-Lt)/1e3}Un();function ur(ce,Me){b.type(Me,"function","listener callback must be a function");var Ve;switch(ce){case"frame":return Yn(Me);case"lost":Ve=ge;break;case"restore":Ve=_e;break;case"destroy":Ve=Gt;break;default:b.raise("invalid event, must be one of frame,lost,restore,destroy")}return Ve.push(Me),{cancel:function(){for(var Gn=0;Gn=0},read:kt,destroy:Le,_gl:L,_refresh:Un,poll:function(){fr(),It&&It.update()},now:we,stats:bt});return v.onDone(null,en),en}return be})})(ET);var TT=OT,kh=new Uint8Array(4),IT=new Float32Array(kh.buffer);function OT(n,t,e,r){return kh[0]=r,kh[1]=e,kh[2]=t,kh[3]=n,IT[0]}class Kf{constructor(t,e="arithmetic"){this.transform="arithmetic",this.transform=e,this.start=t,this.value=t,this.target=t}update(t,e){if(e===0){this.value=t,this.timer!==void 0&&this.timer.stop();return}this.start=this.value,this.target=t,this.start_timer(e)}start_timer(t){this.timer!==void 0&&this.timer.stop();const e=ad(r=>{const s=r/t;if(s>=1){this.value=this.target,e.stop();return}const o=1-s,f=s;this.value=this.transform==="geometric"?this.start**o*this.target**f:this.start*o+this.target*f});this.timer=e}}class BT{constructor(){this.maxPoints=new Kf(1e4,"geometric"),this.pointSize=new Kf(1,"geometric"),this.targetOpacity=new Kf(50),this.foregroundOpacity=new Kf(1),this.backgroundOpacity=new Kf(.5),this.foregroundSize=new Kf(1,"geometric"),this.backgroundSize=new Kf(1,"geometric")}apply_prefs(t){const{duration:e}=t;this.maxPoints.update(t.max_points,e),this.targetOpacity.update(t.alpha,e),this.pointSize.update(t.point_size,e),this.foregroundOpacity.update(t.background_options.opacity[1],e),this.backgroundOpacity.update(t.background_options.opacity[0],e),this.foregroundSize.update(t.background_options.size[1],e),this.backgroundSize.update(t.background_options.size[0],e)}get max_points(){return this.maxPoints.value}get alpha(){return this.targetOpacity.value}get point_size(){return this.pointSize.value}get foreground_opacity(){return this.foregroundOpacity.value}get background_opacity(){return this.backgroundOpacity.value}get foreground_size(){return this.foregroundSize.value}get background_size(){return this.backgroundSize.value}}class i1{constructor(t,e,r){this._use_scale_to_download_tiles=!0,this._initializations=[],this.render_props=new BT,this.scatterplot=r,this.holder=Wn(t),this.canvas=Wn(this.holder.node().firstElementChild).node(),this.dataset=e,this.width=+Wn(this.canvas).attr("width"),this.height=+Wn(this.canvas).attr("height"),this.deferred_functions=[],this._use_scale_to_download_tiles=!0}get discard_share(){return 0}get prefs(){const t={...this.scatterplot.prefs};return t.arrow_table=void 0,t.arrow_buffer=void 0,t}get alpha(){return this.render_props.alpha}get optimal_alpha(){var t,e,r,s;const o=(t=this.prefs.zoom_balance)!=null?t:1,{alpha:f,point_size:c,max_ix:l,width:d,discard_share:p,height:w}=this,I=(s=(r=(e=this.zoom)==null?void 0:e.transform)==null?void 0:r.k)!=null?s:1,C=f/100,V=1/I**2,Wt=window.devicePixelRatio||1,Qt=d*w/Wt,oe=S0([l,this.dataset.highest_known_ix||1e10])*(1-p),Zt=Math.exp(Math.log(I)*o),st=Math.PI*(Zt*c/Wt/2)**2,zt=C*Qt/(oe*V*st);return zt<1/255?1/255:zt}get point_size(){return this.render_props.point_size}get max_ix(){const{prefs:t}=this,{max_points:e}=this.render_props;if(!this._use_scale_to_download_tiles)return e;const{k:r}=this.zoom.transform,s=Math.exp(Math.log(r)*t.zoom_balance);return e*r*r/s/s}visible_tiles(){const{max_ix:t}=this,{dataset:e}=this;this.aes.dim("x");const s=this.aes.dim("x").current.field=="x"&&this.aes.dim("y").current.field=="y"&&this.aes.dim("x").last.field=="x"&&this.aes.dim("y").last.field=="y"?e.map(o=>o).filter(o=>o.is_visible(t,this.zoom.current_corners())):e.map(o=>o).filter(o=>o.min_ixo.min_ix-f.min_ix),s}bind_zoom(t){return this.zoom=t,this}async initialize(){}}const LT=`precision mediump float; #define GLSLIFY 1 vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { vec4 color = vec4(0.0); vec2 off1 = vec2(1.411764705882353) * direction; vec2 off2 = vec2(3.2941176470588234) * direction; vec2 off3 = vec2(5.176470588235294) * direction; color += texture2D(image, uv) * 0.1964825501511404; color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344; color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344; color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732; color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732; color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057; color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057; return color; } uniform vec2 iResolution; uniform sampler2D iChannel0; uniform vec2 direction; void main() { vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy); gl_FragColor = blur13(iChannel0, uv, iResolution.xy, direction); } `,MT=`precision mediump float; #define GLSLIFY 1 uniform float u_zoom_balance; uniform float u_tile_id; uniform float u_update_time; uniform float u_transition_duration; uniform vec2 u_wrap_colors_after; // Type of jitter. uniform float u_jitter; uniform float u_last_jitter; // Whether to plot only a single category. uniform float u_only_color; uniform float u_grid_mode; uniform vec3 u_filter_numeric; // An override for simple numeric operations. uniform vec3 u_last_filter_numeric; // An override for simple numeric operations. uniform vec3 u_filter2_numeric; // An override for simple numeric operations. uniform vec3 u_last_filter2_numeric; // An override for simple numeric operations. uniform vec3 u_foreground_numeric; // An override for simple numeric operations. uniform vec3 u_last_foreground_numeric; // An override for simple numeric operations. // Transform from data space to the open window. uniform mat3 u_window_scale; uniform mat3 u_last_window_scale; // Transform from the open window to the d3-zoom. uniform mat3 u_zoom; uniform float u_width; uniform float u_height; uniform float u_use_glyphset; varying vec2 letter_pos; // store which letter to use. uniform float u_maxix; // The maximum index to plot. uniform float u_time; // The current time. uniform float u_k; // The d3-scale factor. uniform float u_color_picker_mode; uniform float u_base_size; uniform float u_alpha; uniform float u_foreground_number; // -1 -- everything is foreground; 0 -- background; 1 -- foreground. uniform vec4 u_background_rgba; uniform float u_foreground_alpha; uniform float u_background_mouseover; uniform float u_foreground_size; uniform float u_background_size; uniform sampler2D u_one_d_aesthetic_map; uniform sampler2D u_color_aesthetic_map; // The same set of items for a variety of aesthetics. // whether to continuously interpolate between // x0 and x, y0 and y. uniform float u_position_interpolation_mode; float a_color; float a_last_color; uniform float u_color_buffer_num; uniform float u_last_color_buffer_num; uniform vec3 u_color_constant; uniform vec3 u_last_color_constant; uniform float u_color_transform; uniform float u_last_color_transform; uniform vec2 u_color_domain; uniform vec2 u_last_color_domain; uniform float u_last_color_map_position; uniform float u_color_map_position; bool a_color_is_constant; bool a_last_color_is_constant; /* python code to generate what follows. def autogenerate_code(): ks = ["x", "y", "jitter_radius", "jitter_speed", "size", "filter", "filter2", "x0", "y0", "foreground"] times = ["", "last_"] print(""" // BEGIN AUTOGENERATED. DO NOT EDIT. // ------------------------------------------------ """) for k in ks: for time in times: timek = time + k print(f""" uniform float u_{timek}_buffer_num; uniform float u_{timek}_constant; uniform float u_{timek}_transform; uniform vec2 u_{timek}_domain; uniform vec2 u_{timek}_range; uniform float u_{timek}_map_position; float a_{timek}; bool a_{timek}_is_constant; """) for i in range(0, 16): print(f"attribute float buffer_{i};") for k in ks: for time in times: timek = time + k print(f""" if (u_{timek}_buffer_num > -0.5) {{ a_{timek} = get_buffer(u_{timek}_buffer_num); a_{timek}_is_constant = false; }} else {{ a_{timek} = u_{timek}_constant; a_{timek}_is_constant = true; }}""") print(""" // END AUTOGENERATED. DO NOT EDIT ABOVE. // ------------------------------------------------ """) autogenerate_code() */ // BEGIN AUTOGENERATED. DO NOT EDIT. // ------------------------------------------------ uniform float u_x_buffer_num; uniform float u_x_constant; uniform float u_x_transform; uniform vec2 u_x_domain; uniform vec2 u_x_range; uniform float u_x_map_position; float a_x; bool a_x_is_constant; uniform float u_last_x_buffer_num; uniform float u_last_x_constant; uniform float u_last_x_transform; uniform vec2 u_last_x_domain; uniform vec2 u_last_x_range; uniform float u_last_x_map_position; float a_last_x; bool a_last_x_is_constant; uniform float u_y_buffer_num; uniform float u_y_constant; uniform float u_y_transform; uniform vec2 u_y_domain; uniform vec2 u_y_range; uniform float u_y_map_position; float a_y; bool a_y_is_constant; uniform float u_last_y_buffer_num; uniform float u_last_y_constant; uniform float u_last_y_transform; uniform vec2 u_last_y_domain; uniform vec2 u_last_y_range; uniform float u_last_y_map_position; float a_last_y; bool a_last_y_is_constant; uniform float u_jitter_radius_buffer_num; uniform float u_jitter_radius_constant; uniform float u_jitter_radius_transform; uniform vec2 u_jitter_radius_domain; uniform vec2 u_jitter_radius_range; uniform float u_jitter_radius_map_position; float a_jitter_radius; bool a_jitter_radius_is_constant; uniform float u_last_jitter_radius_buffer_num; uniform float u_last_jitter_radius_constant; uniform float u_last_jitter_radius_transform; uniform vec2 u_last_jitter_radius_domain; uniform vec2 u_last_jitter_radius_range; uniform float u_last_jitter_radius_map_position; float a_last_jitter_radius; bool a_last_jitter_radius_is_constant; uniform float u_jitter_speed_buffer_num; uniform float u_jitter_speed_constant; uniform float u_jitter_speed_transform; uniform vec2 u_jitter_speed_domain; uniform vec2 u_jitter_speed_range; uniform float u_jitter_speed_map_position; float a_jitter_speed; bool a_jitter_speed_is_constant; uniform float u_last_jitter_speed_buffer_num; uniform float u_last_jitter_speed_constant; uniform float u_last_jitter_speed_transform; uniform vec2 u_last_jitter_speed_domain; uniform vec2 u_last_jitter_speed_range; uniform float u_last_jitter_speed_map_position; float a_last_jitter_speed; bool a_last_jitter_speed_is_constant; uniform float u_size_buffer_num; uniform float u_size_constant; uniform float u_size_transform; uniform vec2 u_size_domain; uniform vec2 u_size_range; uniform float u_size_map_position; float a_size; bool a_size_is_constant; uniform float u_last_size_buffer_num; uniform float u_last_size_constant; uniform float u_last_size_transform; uniform vec2 u_last_size_domain; uniform vec2 u_last_size_range; uniform float u_last_size_map_position; float a_last_size; bool a_last_size_is_constant; uniform float u_filter_buffer_num; uniform float u_filter_constant; uniform float u_filter_transform; uniform vec2 u_filter_domain; uniform vec2 u_filter_range; uniform float u_filter_map_position; float a_filter; bool a_filter_is_constant; uniform float u_last_filter_buffer_num; uniform float u_last_filter_constant; uniform float u_last_filter_transform; uniform vec2 u_last_filter_domain; uniform vec2 u_last_filter_range; uniform float u_last_filter_map_position; float a_last_filter; bool a_last_filter_is_constant; uniform float u_filter2_buffer_num; uniform float u_filter2_constant; uniform float u_filter2_transform; uniform vec2 u_filter2_domain; uniform vec2 u_filter2_range; uniform float u_filter2_map_position; float a_filter2; bool a_filter2_is_constant; uniform float u_last_filter2_buffer_num; uniform float u_last_filter2_constant; uniform float u_last_filter2_transform; uniform vec2 u_last_filter2_domain; uniform vec2 u_last_filter2_range; uniform float u_last_filter2_map_position; float a_last_filter2; bool a_last_filter2_is_constant; uniform float u_x0_buffer_num; uniform float u_x0_constant; uniform float u_x0_transform; uniform vec2 u_x0_domain; uniform vec2 u_x0_range; uniform float u_x0_map_position; float a_x0; bool a_x0_is_constant; uniform float u_last_x0_buffer_num; uniform float u_last_x0_constant; uniform float u_last_x0_transform; uniform vec2 u_last_x0_domain; uniform vec2 u_last_x0_range; uniform float u_last_x0_map_position; float a_last_x0; bool a_last_x0_is_constant; uniform float u_y0_buffer_num; uniform float u_y0_constant; uniform float u_y0_transform; uniform vec2 u_y0_domain; uniform vec2 u_y0_range; uniform float u_y0_map_position; float a_y0; bool a_y0_is_constant; uniform float u_last_y0_buffer_num; uniform float u_last_y0_constant; uniform float u_last_y0_transform; uniform vec2 u_last_y0_domain; uniform vec2 u_last_y0_range; uniform float u_last_y0_map_position; float a_last_y0; bool a_last_y0_is_constant; uniform float u_foreground_buffer_num; uniform float u_foreground_constant; uniform float u_foreground_transform; uniform vec2 u_foreground_domain; uniform vec2 u_foreground_range; uniform float u_foreground_map_position; float a_foreground; bool a_foreground_is_constant; uniform float u_last_foreground_buffer_num; uniform float u_last_foreground_constant; uniform float u_last_foreground_transform; uniform vec2 u_last_foreground_domain; uniform vec2 u_last_foreground_range; uniform float u_last_foreground_map_position; float a_last_foreground; bool a_last_foreground_is_constant; attribute float buffer_0; attribute float buffer_1; attribute float buffer_2; attribute float buffer_3; attribute float buffer_4; attribute float buffer_5; attribute float buffer_6; attribute float buffer_7; attribute float buffer_8; attribute float buffer_9; attribute float buffer_10; attribute float buffer_11; attribute float buffer_12; attribute float buffer_13; attribute float buffer_14; attribute float buffer_15; // END AUTOGENERATED. DO NOT EDIT ABOVE. // ------------------------------------------------ highp float ix_to_random(in float ix, in float seed) { // For high numbers, taking the log avoids coincidence. highp float seed2 = log(ix + 2.) + 1.; vec2 co = vec2(seed2, seed); highp float a = 12.9898; highp float b = 78.233; highp float c = 43758.5453; highp float dt = dot(co.xy, vec2(a, b)); highp float sn = mod(dt, 3.14); return fract(sin(sn) * c); } // The fill color. varying vec4 fill; varying float point_size; uniform float u_jitter_radius_lookup; uniform float u_jitter_radius_lookup_y_constant; uniform vec2 u_jitter_radius_lookup_x_domain; uniform vec2 u_jitter_radius_lookup_y_domain; float point_size_adjust; // A coordinate to throw away a vertex point. vec4 discard_me = vec4(100.0, 100.0, 1.0, 1.0); // Initialized in the main loop // mat3 from_coord_to_gl; const float e = 1.618282; // I've been convinced. const float tau = 2. * 3.14159265359; float interpolate_raw(in float x, in float min, in float max) { if (x < min) {return 0.;} if (x > max) {return 1.;} return (x - min)/(max - min); } float interpolate(in float x, in float min, in float max) { if (max < min) { return 1. - interpolate_raw(x, max, min); } else { return interpolate_raw(x, min, max); } } /* The following glsl code was written in python. buffers = [*range(16)] def write_buffs(buffs): if len(buffs) == 1: return[f"return buffer_{buffs[0]}"] condition_1 = [" " + line for line in write_buffs(buffs[:len(buffs)//2])] condition_2 = ["" + line for line in write_buffs(buffs[len(buffs)//2:])] args = [ f"if (i < {buffs[len(buffs) // 2 - 1]}.5) {{", *condition_1, "}", *condition_2 ] return args print("\\n".join(write_buffs(buffers))) */ float get_buffer(in float i) { //given an index, returns the appropriate buffer. if (i < 7.5) { if (i < 3.5) { if (i < 1.5) { if (i < 0.5) { return buffer_0; } return buffer_1; } if (i < 2.5) { return buffer_2; } return buffer_3; } if (i < 5.5) { if (i < 4.5) { return buffer_4; } return buffer_5; } if (i < 6.5) { return buffer_6; } return buffer_7; } if (i < 11.5) { if (i < 9.5) { if (i < 8.5) { return buffer_8; } return buffer_9; } if (i < 10.5) { return buffer_10; } return buffer_11; } if (i < 13.5) { if (i < 12.5) { return buffer_12; } return buffer_13; } if (i < 14.5) { return buffer_14; } return buffer_15; } float linstep(in vec2 range, in float x) { return interpolate(x, range.x, range.y); float scale_size = range.y - range.x; float from_left = x - range.x; return clamp(from_left / scale_size, 0.0, 1.0); } float linscale(in vec2 range, in float x) { float scale_size = range.y - range.x; float from_left = x - range.x; return from_left / scale_size; } vec2 box_muller(in float ix, in float seed) { // Box-Muller transform gives you two gaussian randoms for two uniforms. highp float U = ix_to_random(ix, seed); highp float V = ix_to_random(ix, seed + 17.123123); return vec2(sqrt(-2. * log(U)) * cos(tau * V), sqrt(-2. * log(U)) * sin(tau * V)); } /*************** END COLOR SCALES *******************************/ float domainify(in vec2 domain, in float transform, in float attr, in float overflow_behavior) { // Clamp an attribute into a domain, with an optional log or sqrt transform. if (transform == 2.) { domain = sqrt(domain); attr = sqrt(attr); } if (transform == 3.) { domain = log(domain); attr = log(attr); } if (overflow_behavior == 1.) { // clamp return linstep(domain, attr); } if (overflow_behavior == 2.) { //wrap return fract(linscale(domain, attr)); } return linscale(domain, attr); } mat3 pixelspace_to_glspace; float run_numeric_filter (in float a_filter, in float u_filter_op, in float u_filter_param_1, in float u_filter_param_2) { bool truthy; if (u_filter_op < 1.5) { truthy = a_filter < u_filter_param_1; } else if (u_filter_op < 2.5) { truthy = a_filter > u_filter_param_1; } else if (u_filter_op < 3.5) { truthy = a_filter == u_filter_param_1; } else if (u_filter_op < 4.5) { truthy = abs(a_filter - u_filter_param_2) < u_filter_param_1; } if (truthy) {return 1.;} else {return 0.;} } float choose_and_run_filter( in vec3 u_filter_numeric, in float a_filter, in float map_location, in bool filter_is_constant ) { if (filter_is_constant) { return 1.; } if (u_filter_numeric.r < 0.5) { // Must be on a dictionary. Unreasonable assumption, maybe? float frac_filter = linstep(vec2(-0., 4096.), a_filter); float map_coords = (map_location + .5) / 32.; return texture2D(u_one_d_aesthetic_map, vec2(map_coords, frac_filter)).a; } else { return run_numeric_filter(a_filter, u_filter_numeric.r, u_filter_numeric.g, u_filter_numeric.b); } } const float tau_0 = 2. * 3.14159265359; highp float ix_to_random_1540259130(in float ix, in float seed) { // For high numbers, taking the log avoids coincidence. highp float seed2 = log(ix) + 1.; vec2 co = vec2(seed2, seed); highp float a = 12.9898; highp float b = 78.233; highp float c = 43758.5453; highp float dt= dot(co.xy ,vec2(a,b)); highp float sn= mod(dt,3.14); return fract(sin(sn) * c); } highp vec2 box_muller_1540259130(in float ix, in float seed) { // Box-Muller transform gives you two gaussian randoms for two uniforms. highp float U = ix_to_random_1540259130(ix, seed); highp float V = ix_to_random_1540259130(ix, seed + 17.123123); return vec2( sqrt(-2.*log(U))*cos(tau_0*V), sqrt(-2.*log(U))*sin(tau_0*V) ); } vec2 logarithmic_spiral_jitter_1540259130( in float ix, // a random seed. in float a, // offset in float angle_parameter_1540259130, // angle parameter in float randomize_angle_1540259130, // sd radians in float max_r_1540259130, // Maximum radius of spiral. in float randomize_rotation_max_radians_1540259130, // in standard deviations to the log-multiplier. in float randomize_radius_1540259130, // in standard deviation percentage points. in float hole, // donut hole size. in float speed_0, // webgl units per second. in float time_0,// The time, in seconds, to plot at. Generally passed as a uniform or something. in float acceleration, in float n_spirals_1540259130, in float shear, in float aspect_ratio_1540259130 ) { // Each point starts at a different place on the spiral. vec2 two_gaussians_1540259130 = box_muller_1540259130(ix, 55.1); highp float calculated_angle = angle_parameter_1540259130 + two_gaussians_1540259130.x * randomize_angle_1540259130; float k = 1. / tan(calculated_angle); if (k > 100000.) { k = 0.; } // The length of the segment to be traversed. float arc_length = sqrt((1. + k*k)/k) * (max_r_1540259130 - a); float period = arc_length / speed_0; // Every point needs to start at a different place along the curve. float stagger_time = ix_to_random_1540259130(ix, 3.); // How long does a circuit take? Add some random noise. float time_period = period * exp(box_muller_1540259130(ix, 0.031).x / 6.); // Adjust u_time from the clock to our current spot. float varying_time = time_0 + stagger_time * time_period; // Adjust that time by raising to a power to set the speed along the curve. // Not sure if this is the soundest way to parametrize. float relative_time = pow(1. - mod(varying_time, time_period)/time_period, acceleration); // Calculate the radius at this time point. float radius = max_r_1540259130 * relative_time + a; // The angle implied by that radius. float theta = 1./k * log(radius / a); /* A different way to calculate radius from the theta. Not used float max_theta = 1. / k * log(max_r / a); float theta2 = max_theta * relative_time; vec2 pos_theta_style = vec2(a * exp(k * theta2), theta2); radius = pos_theta_style.x; theta = pos_theta_style.y; */ // If multiple spirals, the theta needs to be rotated for which spiral we're in. // Choose it based on a new random seed. float which_spiral = floor(ix_to_random_1540259130(ix, 13.13) * n_spirals_1540259130); float which_spiral_adjust = which_spiral / n_spirals_1540259130 * tau_0; theta = theta + which_spiral_adjust; // Add some gaussian jitter to the polar coordinates. vec2 polar_jitter = box_muller_1540259130(ix, 24.); highp float radius_adjust = 1. + polar_jitter.x * randomize_radius_1540259130; highp float theta_adjust = polar_jitter.y * randomize_rotation_max_radians_1540259130; vec2 shear_adjust = box_muller_1540259130(ix, 59.1) * shear; mat3 shear_mat = mat3( 1., shear_adjust.x, 0., shear_adjust.y, 1., 0., 0., 0., 1.); // into euclidean space. vec3 pos_spiral = vec3( cos(theta + theta_adjust)*(radius * radius_adjust + hole), sin(theta + theta_adjust)*(radius * radius_adjust + hole), 0. ); mat3 adjust_to_viewport = mat3( 1./aspect_ratio_1540259130, 0., 0., 0., 1., 0., 0., 0., 1.); pos_spiral = pos_spiral * shear_mat * adjust_to_viewport; return pos_spiral.xy; } #define FLOAT_MAX 1.70141184e38 #define FLOAT_MIN 1.17549435e-38 lowp vec4 encode_float_1604150559(highp float v) { highp float av = abs(v); //Handle special cases if(av < FLOAT_MIN) { return vec4(0.0, 0.0, 0.0, 0.0); } else if(v > FLOAT_MAX) { return vec4(127.0, 128.0, 0.0, 0.0) / 255.0; } else if(v < -FLOAT_MAX) { return vec4(255.0, 128.0, 0.0, 0.0) / 255.0; } highp vec4 c = vec4(0,0,0,0); //Compute exponent and mantissa highp float e = floor(log2(av)); highp float m = av * pow(2.0, -e) - 1.0; //Unpack mantissa c[1] = floor(128.0 * m); m -= c[1] / 128.0; c[2] = floor(32768.0 * m); m -= c[2] / 32768.0; c[3] = floor(8388608.0 * m); //Unpack exponent highp float ebias = e + 127.0; c[0] = floor(ebias / 2.0); ebias -= c[0] * 2.0; c[1] += floor(ebias) * 128.0; //Unpack sign bit c[0] += 128.0 * step(0.0, -v); //Scale back to range return c / 255.0; } #ifndef PI #define PI 3.141592653589793 #endif float sineInOut_0(float t) { return -0.5 * (cos(PI * t) - 1.0); } #ifndef PI #define PI 3.141592653589793 #endif vec2 bezier_interpolate(vec2 p1, vec2 p2, float frac, float ix) { // Interpolates between two points on a Bezier curve around a jittered middle. // Makes animations look cooler. vec2 midpoint = box_muller(ix, 3.) * .05 * dot(p2 - p1, p2 - p1) + p2 / 2. + p1 / 2.; return mix( mix(p2, midpoint, frac), mix(midpoint, p1, frac), frac); } float sineInOut(float t) { return -0.5 * (cos(PI * t) - 1.0); } const vec4 decoder = vec4(1./256./256./256., 1. / 256. / 256., 1. / 256., 1.); float RGBAtoFloat(in vec4 floater) { // Scale values up by 256. return dot(floater, decoder); } float texture_float_lookup(in vec2 domain, in vec2 range, in float transform, in float attr, in float texture_position) { if (transform == 4.0) { // Literal transforms aren't looked up, just returned as is. return attr; } float inrange = domainify(domain, transform, attr, 1.); if (texture_position > 0.5) { float y_pos = texture_position / 32. - 0.5 / 32.; vec4 encoded = texture2D(u_one_d_aesthetic_map, vec2(y_pos, inrange)); return encoded.a; return RGBAtoFloat(encoded); // unreachable. } else { return mix(range.x, range.y, inrange); } } vec2 calculate_position(in vec2 position, in float x_scale_type, in vec2 x_domain, in vec2 x_range, in float y_scale_type, in vec2 y_domain, in vec2 y_range, in mat3 window_scale, in mat3 zoom, in float x_map_position, in float y_map_position ) { float x; float y; if (x_scale_type < 4.0) { float x_ = linscale(u_color_domain, a_color); x = texture_float_lookup(x_domain, x_range, x_scale_type, position.x, 0. // ymap position 0 means never use a texture lookup. ); } else { x = position.x; } if (y_scale_type < 4.0) { y = texture_float_lookup(y_domain, y_range, y_scale_type, position.y, 0. // ymap position 0 means never use a texture lookup. ); } else { y = position.y; } vec3 pos2d = vec3(x, y, 1.0) * window_scale * zoom * pixelspace_to_glspace; return pos2d.xy; } float cubicInOut(float t) { return t < 0.5 ? 4.0 * t * t * t : 1. - 4.0 * pow(1. - t, 3.0); } vec4 ixToRGBA(in float ix) { float min = fract(ix / 256.); float mid = fract((ix - min) / 256.); float high = fract((ix - min - mid * 256.) / (256.) / 256.); return vec4(min, mid, high, 1.); } vec2 circle_jitter(in float ix, in float aspect_ratio, in float time, in float radius, in float speed) { vec2 two_gaussians = box_muller(ix, 12.); float stagger_time = two_gaussians.y * tau; // How long does a circuit take? float units_per_period = radius * tau; float units_per_second = speed; float seconds_per_period = units_per_period / units_per_second; float time_period = seconds_per_period; if (time_period > 1e4) { return vec2(0., 0.); } // Adjust time from the clock to our current spot. float varying_time = time + stagger_time * time_period; // Where are we from 0 to 1 relative to the time period float relative_time = 1. - mod(varying_time, time_period) / time_period; float theta = relative_time * tau; // Problem--should it lie on a disk, or on a circle? float r_mult = 1.;//(sqrt(ix_to_random(ix, 7.))); return vec2(cos(theta) * r_mult, aspect_ratio * sin(theta) * r_mult) * radius; } vec2 calculate_jitter( in float jitter_type, in float ix, // distinguishing index in vec2 jitter_radius_domain, in vec2 jitter_radius_range, in float jitter_radius_transform, in float jitter_radius, in float jitter_radius_map_position, in bool jitter_radius_is_constant, in vec2 jitter_speed_domain, in vec2 jitter_speed_range, in float jitter_speed_transform, in float jitter_speed, in float jitter_speed_map_position, in bool jitter_speed_is_constant ) { // Jitter is calculated based on speed, so requires two full maps in. if (jitter_type == 0.) { // No jitter return vec2(0., 0.); } if (jitter_type == 5.) { // Temporal jitter--should be broken out into a separate channel/channels. float time_period = 60.; float share = 1./4.; float offset = ix_to_random(ix, 12.); float fractional = fract((offset * time_period + u_time)/time_period); if (fractional > share) { return vec2(0., 0.); } float size = 0.5 * (1. - cos(2. * 3.1415926 * min(fractional/share, 1. - fractional/share))); size = clamp(size, 0., 1.); return vec2(size, 0.); } float jitter_r; if (jitter_radius_is_constant) { jitter_r = jitter_radius; } else { jitter_r = texture_float_lookup( jitter_radius_domain, jitter_radius_range, jitter_radius_transform, jitter_radius, 0.); } if (jitter_type == 3.) { float r = box_muller(ix, 1.).r * jitter_r; r = r * point_size_adjust; float theta = ix_to_random(ix, 15.) * tau; return vec2(cos(theta) * r, sin(theta) * r * u_width / u_height); } if (jitter_type == 2.) { // uniform in the circle. float theta = ix_to_random(ix, 15.) * tau; float r = jitter_r * sqrt(ix_to_random(ix, 115.)); r = r * point_size_adjust; return vec2(cos(theta) * r, sin(theta) * r * u_width / u_height); } /* Jittering that includes motion) */ float p_jitter_speed = texture_float_lookup(jitter_speed_domain, jitter_speed_range, jitter_speed_transform, jitter_speed, jitter_speed_map_position); if (jitter_type == 1.) { return logarithmic_spiral_jitter_1540259130( ix, 0.005 * jitter_r, // a 1.3302036, // angle parameter 0.005, // angle random jitter_r, // max radius 0.03, // random_rotation 0.06, // random radius 0.003 * point_size_adjust * jitter_r, // donut. .5 * p_jitter_speed * jitter_r / point_size_adjust, // speed u_time, // time 0.8, // acceleration 2.0, // n_spirals .09, //shear u_width/u_height // shear ); } if (jitter_type == 4.) { // circle return circle_jitter(ix, u_width/u_height, u_time, jitter_r, p_jitter_speed); } } void run_color_fill(in float ease) { float alpha = min(u_alpha, 1.0); if (u_only_color >= -1.5) { if (u_only_color > -.5 && a_color != u_only_color) { gl_Position = discard_me; return; } else { // -1 is a special value meaning 'plot everything'. fill = vec4(0., 0., 0., 1. / 255.); gl_PointSize = 1.; } } else { if (a_color_is_constant) { fill = vec4(u_color_constant.rgb, alpha); } else { float color_pos = (u_color_map_position * -1. - 1.) / 32. + 0.5 / 32.; float overflow_behavior = 1.; // means--clamp float fractional_color; if (u_wrap_colors_after.y > 0.) { fractional_color = fract(a_color / u_wrap_colors_after.y); } else { fractional_color = domainify(u_color_domain, u_color_transform, a_color, overflow_behavior); } fill = texture2D(u_color_aesthetic_map , vec2(color_pos, fractional_color)); fill = vec4(fill.rgb, alpha); } if (ease < 1.) { vec4 last_fill; if (a_last_color_is_constant) { last_fill = vec4(u_last_color_constant.rgb, alpha); } else { float last_fractional = linstep(u_last_color_domain, a_last_color); float color_pos = (u_last_color_map_position * -1. - 1.) / 32. + 0.5 / 32.; float overflow_behavior = 1.; // means--clamp if (u_last_color_domain.y == 4096. && u_last_color_domain.x == 0.) { // Assume we're in dictionary land. Unsafe, but whatever. overflow_behavior = 2.; } last_fractional = domainify(u_last_color_domain, u_last_color_transform, a_last_color, overflow_behavior); last_fill = texture2D(u_color_aesthetic_map, vec2(color_pos, last_fractional)); // Alpha channel interpolation already happened. last_fill = vec4(last_fill.rgb, alpha); } // RGB blending is bad--maybe use https://www.shadertoy.com/view/lsdGzN // instead? fill = mix(last_fill, fill, ease); } } } vec2 calc_and_interpolate_positions( inout vec2 old_position, in float u_last_x_transform, in vec2 u_last_x_domain, in vec2 u_last_x_range, in float u_last_y_transform, in vec2 u_last_y_domain, in vec2 u_last_y_range, in mat3 u_last_window_scale, in mat3 u_zoom, in float u_last_x_map_position, in float u_last_y_map_position, inout vec2 position, in float u_x_transform, in vec2 u_x_domain, in vec2 u_x_range, in float u_y_transform, in vec2 u_y_domain, in vec2 u_y_range, in mat3 u_window_scale, in float u_x_map_position, in float u_y_map_position, in float interpolation, in float u_grid_mode, in float ix) { old_position = calculate_position(old_position, u_last_x_transform, u_last_x_domain, u_last_x_range, u_last_y_transform, u_last_y_domain, u_last_y_range, u_last_window_scale, u_zoom, u_last_x_map_position, u_last_y_map_position); bool plot_actual_position = u_grid_mode < .5; if (plot_actual_position) { position = calculate_position(position, u_x_transform, u_x_domain, u_x_range, u_y_transform, u_y_domain, u_y_range, u_window_scale, u_zoom, u_x_map_position, u_y_map_position); float xpos = clamp((1. + position.x) / 2., 0., 1.); float randy = ix_to_random(ix, 13.76); float delay = xpos + randy * .1; delay = delay * 3.; float frac = interpolate( u_update_time, delay, u_transition_duration + delay ); frac = sineInOut_0(frac); if (frac <= 0.) { position = old_position; } else if (frac < 1.) { frac = fract(frac); position = bezier_interpolate(position, old_position, frac, ix); } } else { position.x = -1. + 2. * linscale(u_x_domain, position.x); //position.y = -1.0; vec2 jitterspec = vec2( (ix_to_random(ix, 3.) * a_jitter_radius ) * 2., (ix_to_random(ix, 1.5) * a_jitter_speed ) * 2. ); position = position + jitterspec; } return position; } void main() { float debug_mode = 0.; float ix = buffer_0; float ix_in_tile = buffer_1; if (ix > u_maxix) { // throw away points that are too low. gl_Position = discard_me; return; } if (debug_mode > 1.5) { // Debug mode. gl_PointSize = 2.; gl_Position = vec4(box_muller(ix, 2.).xy * .33, 0., 1.); return; } // Autogenerated below this point if (u_x_buffer_num > -0.5) { a_x = get_buffer(u_x_buffer_num); a_x_is_constant = false; } else { a_x = u_x_constant; a_x_is_constant = true; } if (u_last_x_buffer_num > -0.5) { a_last_x = get_buffer(u_last_x_buffer_num); a_last_x_is_constant = false; } else { a_last_x = u_last_x_constant; a_last_x_is_constant = true; } if (u_y_buffer_num > -0.5) { a_y = get_buffer(u_y_buffer_num); a_y_is_constant = false; } else { a_y = u_y_constant; a_y_is_constant = true; } if (u_last_y_buffer_num > -0.5) { a_last_y = get_buffer(u_last_y_buffer_num); a_last_y_is_constant = false; } else { a_last_y = u_last_y_constant; a_last_y_is_constant = true; } if (u_jitter_radius_buffer_num > -0.5) { a_jitter_radius = get_buffer(u_jitter_radius_buffer_num); a_jitter_radius_is_constant = false; } else { a_jitter_radius = u_jitter_radius_constant; a_jitter_radius_is_constant = true; } if (u_last_jitter_radius_buffer_num > -0.5) { a_last_jitter_radius = get_buffer(u_last_jitter_radius_buffer_num); a_last_jitter_radius_is_constant = false; } else { a_last_jitter_radius = u_last_jitter_radius_constant; a_last_jitter_radius_is_constant = true; } if (u_jitter_speed_buffer_num > -0.5) { a_jitter_speed = get_buffer(u_jitter_speed_buffer_num); a_jitter_speed_is_constant = false; } else { a_jitter_speed = u_jitter_speed_constant; a_jitter_speed_is_constant = true; } if (u_last_jitter_speed_buffer_num > -0.5) { a_last_jitter_speed = get_buffer(u_last_jitter_speed_buffer_num); a_last_jitter_speed_is_constant = false; } else { a_last_jitter_speed = u_last_jitter_speed_constant; a_last_jitter_speed_is_constant = true; } if (u_size_buffer_num > -0.5) { a_size = get_buffer(u_size_buffer_num); a_size_is_constant = false; } else { a_size = u_size_constant; a_size_is_constant = true; } if (u_last_size_buffer_num > -0.5) { a_last_size = get_buffer(u_last_size_buffer_num); a_last_size_is_constant = false; } else { a_last_size = u_last_size_constant; a_last_size_is_constant = true; } if (u_filter_buffer_num > -0.5) { a_filter = get_buffer(u_filter_buffer_num); a_filter_is_constant = false; } else { a_filter = u_filter_constant; a_filter_is_constant = true; } if (u_last_filter_buffer_num > -0.5) { a_last_filter = get_buffer(u_last_filter_buffer_num); a_last_filter_is_constant = false; } else { a_last_filter = u_last_filter_constant; a_last_filter_is_constant = true; } if (u_filter2_buffer_num > -0.5) { a_filter2 = get_buffer(u_filter2_buffer_num); a_filter2_is_constant = false; } else { a_filter2 = u_filter2_constant; a_filter2_is_constant = true; } if (u_last_filter2_buffer_num > -0.5) { a_last_filter2 = get_buffer(u_last_filter2_buffer_num); a_last_filter2_is_constant = false; } else { a_last_filter2 = u_last_filter2_constant; a_last_filter2_is_constant = true; } if (u_x0_buffer_num > -0.5) { a_x0 = get_buffer(u_x0_buffer_num); a_x0_is_constant = false; } else { a_x0 = u_x0_constant; a_x0_is_constant = true; } if (u_last_x0_buffer_num > -0.5) { a_last_x0 = get_buffer(u_last_x0_buffer_num); a_last_x0_is_constant = false; } else { a_last_x0 = u_last_x0_constant; a_last_x0_is_constant = true; } if (u_y0_buffer_num > -0.5) { a_y0 = get_buffer(u_y0_buffer_num); a_y0_is_constant = false; } else { a_y0 = u_y0_constant; a_y0_is_constant = true; } if (u_last_y0_buffer_num > -0.5) { a_last_y0 = get_buffer(u_last_y0_buffer_num); a_last_y0_is_constant = false; } else { a_last_y0 = u_last_y0_constant; a_last_y0_is_constant = true; } if (u_foreground_buffer_num > -0.5) { a_foreground = get_buffer(u_foreground_buffer_num); a_foreground_is_constant = false; } else { a_foreground = u_foreground_constant; a_foreground_is_constant = true; } if (u_last_foreground_buffer_num > -0.5) { a_last_foreground = get_buffer(u_last_foreground_buffer_num); a_last_foreground_is_constant = false; } else { a_last_foreground = u_last_foreground_constant; a_last_foreground_is_constant = true; } // END AUTOGENERATED. DO NOT EDIT ABOVE. // ------------------------------------------------ gl_PointSize = 1.; if (u_color_buffer_num > -0.5) { a_color = get_buffer(u_color_buffer_num); a_color_is_constant = false; } else { a_color = ix; a_color_is_constant = true; } if (u_last_color_buffer_num > -0.5) { a_last_color = get_buffer(u_last_color_buffer_num); a_last_color_is_constant = false; } else { a_last_color = ix; a_last_color_is_constant = true; } pixelspace_to_glspace = mat3( 2. / u_width, 0., -1., 0., - 2. / u_height, 1., 0., 0., 1. ); float interpolation = interpolate(u_update_time, 0., u_transition_duration); float ease = interpolation; // I set this sometimes. vec2 position = vec2(a_x, a_y); vec2 old_position = vec2(a_last_x, a_last_y); position = calc_and_interpolate_positions( old_position, u_last_x_transform, u_last_x_domain, u_last_x_range, u_last_y_transform, u_last_y_domain, u_last_y_range, u_last_window_scale, u_zoom, u_last_x_map_position, u_last_y_map_position, position, u_x_transform, u_x_domain, u_x_range, u_y_transform, u_y_domain, u_y_range, u_window_scale, u_x_map_position, u_y_map_position, interpolation, u_grid_mode, ix ); if (u_x0_buffer_num > 0.) { vec2 position0 = vec2(a_x0, a_y0); vec2 old_position0 = vec2(a_last_x0, a_last_y0); position0 = calc_and_interpolate_positions( old_position0, u_last_x0_transform, u_last_x0_domain, u_last_x0_range, u_last_y0_transform, u_last_y0_domain, u_last_y0_range, u_last_window_scale, u_zoom, u_last_x0_map_position, u_last_y0_map_position, position0, u_x0_transform, u_x0_domain, u_x0_range, u_y0_transform, u_y0_domain, u_y0_range, u_window_scale, u_x0_map_position, u_y0_map_position, interpolation, u_grid_mode, ix ); if (u_position_interpolation_mode > 0.) { float rand2 = ix_to_random(ix, 11.76); // If it's a continuous loop, just choose a random point along that loop. float rand_offset = fract(u_update_time/u_transition_duration / 10. + rand2); position = mix(position0, position, rand_offset); } } bool plot_actual_position = u_grid_mode < .5; if (u_position_interpolation_mode > 0.) { float rand2 = ix_to_random(ix, 11.76); // If it's a continuous loop, just choose a random point along that loop. float rand_offset = fract(u_update_time/u_transition_duration + rand2); } /* position = vec2( ix_to_random(ix, .1), ix_to_random(ix, .2) );*/ /* FILTERING */ float filter_status = choose_and_run_filter( u_filter_numeric, a_filter, u_filter_map_position, a_filter_is_constant ); float last_filter_status = choose_and_run_filter( u_last_filter_numeric, a_last_filter, u_last_filter_map_position, a_last_filter_is_constant ); float filter2_status = choose_and_run_filter( u_filter2_numeric, a_filter2, u_filter2_map_position, a_filter2_is_constant ); float last_filter2_status = choose_and_run_filter( u_last_filter2_numeric, a_last_filter2, u_last_filter2_map_position, a_last_filter2_is_constant ); float foreground_status = choose_and_run_filter( u_foreground_numeric, a_foreground, u_foreground_map_position, a_foreground_is_constant ); float last_foreground_status = choose_and_run_filter( u_last_foreground_numeric, a_last_foreground, u_last_foreground_map_position, a_last_foreground_is_constant ); float fg_ease = mix(last_foreground_status, foreground_status, ease); if (ease < ix_to_random(ix, 1.)) { foreground_status = last_foreground_status; } /*if (a_foreground_is_constant) { foreground_status = 1.; }*/ bool was_filtered = last_filter2_status < .5 || last_filter_status < .5; bool will_be_filtered = filter2_status < .5 || filter_status < .5; bool overall_filter_status = will_be_filtered; if (ease < ix_to_random(ix, 1.)) { overall_filter_status = was_filtered; } if (overall_filter_status == true) { gl_Position = discard_me; return; } float size_multiplier = texture_float_lookup( u_size_domain, u_size_range, u_size_transform, a_size, u_size_map_position); float last_size_multiplier = texture_float_lookup( u_last_size_domain, u_last_size_range, u_last_size_transform, a_last_size, u_last_size_map_position); size_multiplier = u_base_size * mix(last_size_multiplier, size_multiplier, ease); float depth_size_adjust = (1.0 - ix / (u_maxix)); point_size_adjust = exp(log(u_k) * u_zoom_balance) ;// * depth_size_adjust; // point_size_adjust = exp(log(u_k) * u_zoom_balance); gl_PointSize = point_size_adjust * size_multiplier; if (gl_PointSize <= 5.1) { // It's ugly on new macs when it jumps straight from one to two for a bunch of points at once. float size_fuzz = exp(ix_to_random(ix, 3.1) * .5 - .25); gl_PointSize *= size_fuzz; } if (gl_PointSize <= 0.01) { gl_Position = discard_me; return; } vec2 jitter = vec2(0., 0.); if (plot_actual_position && (u_jitter > 0. || u_last_jitter > 0.)) { /* JITTER */ jitter = vec2(ix_to_random(ix, 2. + u_time), ix_to_random(ix, 3. + u_time)) * .01; float jitter_radius_fraction; jitter = calculate_jitter( u_jitter, ix, u_jitter_radius_domain, u_jitter_radius_range, u_jitter_radius_transform, a_jitter_radius, u_jitter_radius_map_position, a_jitter_radius_is_constant, u_jitter_speed_domain, u_jitter_speed_range, u_jitter_speed_transform, a_jitter_speed, u_jitter_speed_map_position, a_jitter_speed_is_constant ); vec2 last_jitter; if (ease < 1.) { last_jitter = calculate_jitter( u_last_jitter, ix, u_last_jitter_radius_domain, u_last_jitter_radius_range, u_last_jitter_radius_transform, a_last_jitter_radius, u_last_jitter_radius_map_position, a_last_jitter_radius_is_constant, u_last_jitter_speed_domain, u_last_jitter_speed_range, u_last_jitter_speed_transform, a_last_jitter_speed, u_last_jitter_speed_map_position, a_last_jitter_speed_is_constant ); jitter = mix(last_jitter, jitter, ease); } if (u_jitter == 5.) { // temporal jitter: rescale the point from the first dimension gl_PointSize *= jitter.x; jitter = vec2(0., 0.); if (gl_PointSize < 0.05) { gl_Position = discard_me; return; } } gl_Position = vec4(position + jitter, 0., 1.); } else { gl_Position = vec4(position + jitter, 0., 1.); } if (u_color_picker_mode == 1.) { // Add one so the first element is distinguishable. fill = encode_float_1604150559(ix + 1.); } else if (u_color_picker_mode == 2.) { fill = encode_float_1604150559(u_tile_id + 1.); } else if (u_color_picker_mode == 3.) { fill = encode_float_1604150559(ix_in_tile + 1.); } else { run_color_fill(ease); } // Are we in a mode where we need to plot foreground and background? if (u_foreground_number > -1.) { // In that case, throw away points from the other half of the set. if (u_foreground_number != foreground_status) { gl_Position = discard_me; return; } if (u_foreground_number == 1.) { gl_PointSize *= u_foreground_size; fill = vec4(fill.rgb, min(1., fill.a * u_foreground_alpha)); } // If we're in background mode, got to change the points a bit. if (u_foreground_number == 0.) { gl_PointSize *= u_background_size; // Should the color piker run? if (u_color_picker_mode >= 1.) { if (u_background_mouseover == 1.) { // pass--keep the colors as are. } else { gl_Position = discard_me; return; } } else { float alpha = min(u_alpha * u_background_rgba.a, 1.); if (alpha < 1./255.) { // Very light alphas must be quantized. Only show an appropriate sample. float seed = ix_to_random(ix, 38.6); if (alpha * 255. < seed) { gl_Position = discard_me; return; } else { alpha = 1. / 255.; } } fill = vec4(u_background_rgba.rgb, alpha); } } } point_size = gl_PointSize; /* if (u_use_glyphset > 0. && point_size > 5.0) { float random_letter = floor(64. * ix_to_random(ix, 1.3)); letter_pos = vec2( // start at a number between 0 and 7. mod(random_letter, 8.) / 8., floor(random_letter / 8.) / 8. ); gl_PointSize *= 3.0; }*/ } `,RT=`#ifdef GL_OES_standard_derivatives #extension GL_OES_standard_derivatives : enable #endif precision mediump float; #define GLSLIFY 1 varying vec4 fill; varying vec2 letter_pos; varying float point_size; uniform float u_only_color; uniform float u_color_picker_mode; //uniform float u_use_glyphset; //uniform sampler2D u_glyphset; 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.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.01) {return true;} float distance_from_edge = (1.0 - r_sq) * point_size; if (distance_from_edge > 4.0) {return true;} return false; } bool out_of_triangle(in vec2 coord) { if (coord.y > (2. * abs(coord.x - .5))) { return false; } return true; } void main() { if (u_only_color >= -1.5) { gl_FragColor = vec4(0., 0., 0., 1./255.); return; } float alpha = fill.a; // if (u_use_glyphset == 0. || point_size < 5.0) { if (out_of_circle(gl_PointCoord)) { discard; return; } 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 /* } else { vec2 coords = letter_pos + gl_PointCoord/8.; // vec2 coords = vec2(.2, .2); vec4 sprite = texture2D(u_glyphset, coords); alpha *= (sprite.a); // fill = vec4(1.0, 1.0, 1.0, alpha); if (alpha <= 0.03) discard; }*/ // Pre-blend the alpha channel. if (u_color_picker_mode >= 1.) { // no alpha when color picking; we use all four channels for that. gl_FragColor = fill; } else { gl_FragColor = vec4(fill.rgb * alpha, alpha); } } `;function W0(n){return n.op!==void 0}function s1(n){return n.lambda!==void 0}function qh(n){return n.constant!==void 0}function NT(n){return n!==null&&n.url!==void 0}function DT(n){return n!==null&&n.labels!==void 0}var ep={},FT={get exports(){return ep},set exports(n){ep=n}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(n,t){(function(){var e,r="4.17.21",s=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",c="Invalid `variable` option passed into `_.template`",l="__lodash_hash_undefined__",d=500,p="__lodash_placeholder__",w=1,I=2,C=4,V=1,Wt=2,Qt=1,Rt=2,oe=4,Zt=8,st=16,zt=32,ue=64,ve=128,an=256,at=512,Y=30,rt="...",Bt=800,Dt=16,F=1,ft=2,H=3,yt=1/0,Mt=9007199254740991,Kt=17976931348623157e292,ee=NaN,de=4294967295,Oe=de-1,ye=de>>>1,Ze=[["ary",ve],["bind",Qt],["bindKey",Rt],["curry",Zt],["curryRight",st],["flip",at],["partial",zt],["partialRight",ue],["rearg",an]],on="[object Arguments]",En="[object Array]",Dn="[object AsyncFunction]",hn="[object Boolean]",Fn="[object Date]",ir="[object DOMException]",Kn="[object Error]",Yr="[object Function]",rf="[object GeneratorFunction]",Rr="[object Map]",ws="[object Number]",mu="[object Null]",oi="[object Object]",yr="[object Promise]",gu="[object Proxy]",kr="[object RegExp]",Ir="[object Set]",Ei="[object String]",b="[object Symbol]",yu="[object Undefined]",xs="[object WeakMap]",ol="[object WeakSet]",fa="[object ArrayBuffer]",lr="[object DataView]",ua="[object Float32Array]",Ti="[object Float64Array]",ca="[object Int8Array]",lo="[object Int16Array]",ho="[object Int32Array]",_o="[object Uint8Array]",hr="[object Uint8ClampedArray]",Pr="[object Uint16Array]",ji="[object Uint32Array]",fl=/\b__p \+= '';/g,vu=/\b(__p \+=) '' \+/g,ul=/(__e\(.*?\)|\b__t\)) \+\n'';/g,sf=/&(?:amp|lt|gt|quot|#39);/g,Ss=/[&<>"']/g,bu=RegExp(sf.source),Ii=RegExp(Ss.source),cl=/<%-([\s\S]+?)%>/g,ll=/<%([\s\S]+?)%>/g,vr=/<%=([\s\S]+?)%>/g,hl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dl=/^\w*$/,fi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,af=/[\\^$.*+?()[\]{}|]/g,_l=RegExp(af.source),of=/^\s+/,pl=/\s/,ml=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Wi=/\{\n\/\* \[wrapped with (.+)\] \*/,wu=/,? & /,Cn=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,gl=/[()=,{}\[\]\/\s]/,yl=/\\(\\)?/g,vl=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Yi=/\w*$/,bl=/^[-+]0x[0-9a-f]+$/i,wl=/^0b[01]+$/i,xl=/^\[object .+?Constructor\]$/,Sl=/^0o[0-7]+$/i,Al=/^(?:0|[1-9]\d*)$/,El=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,As=/($^)/,Tl=/['\n\r\u2028\u2029\\]/g,Hi="\\ud800-\\udfff",ff="\\u0300-\\u036f",Il="\\ufe20-\\ufe2f",po="\\u20d0-\\u20ff",uf=ff+Il+po,xu="\\u2700-\\u27bf",Su="a-z\\xdf-\\xf6\\xf8-\\xff",Ol="\\xac\\xb1\\xd7\\xf7",Au="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Bl="\\u2000-\\u206f",Ll=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Eu="A-Z\\xc0-\\xd6\\xd8-\\xde",Tu="\\ufe0e\\ufe0f",Iu=Ol+Au+Bl+Ll,cf="['’]",mo="["+Hi+"]",lf="["+Iu+"]",go="["+uf+"]",Ou="\\d+",Oi="["+xu+"]",Es="["+Su+"]",hf="[^"+Hi+Iu+Ou+xu+Su+Eu+"]",la="\\ud83c[\\udffb-\\udfff]",Bu="(?:"+go+"|"+la+")",Lu="[^"+Hi+"]",df="(?:\\ud83c[\\udde6-\\uddff]){2}",_f="[\\ud800-\\udbff][\\udc00-\\udfff]",Jn="["+Eu+"]",br="\\u200d",ha="(?:"+Es+"|"+hf+")",Ml="(?:"+Jn+"|"+hf+")",yo="(?:"+cf+"(?:d|ll|m|re|s|t|ve))?",pf="(?:"+cf+"(?:D|LL|M|RE|S|T|VE))?",mf=Bu+"?",Mu="["+Tu+"]?",vo="(?:"+br+"(?:"+[Lu,df,_f].join("|")+")"+Mu+mf+")*",da="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",gf="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",bo=Mu+mf+vo,Rl="(?:"+[Oi,df,_f].join("|")+")"+bo,Ru="(?:"+[Lu+go+"?",go,df,_f,mo].join("|")+")",yf=RegExp(cf,"g"),Nu=RegExp(go,"g"),ui=RegExp(la+"(?="+la+")|"+Ru+bo,"g"),_a=RegExp([Jn+"?"+Es+"+"+yo+"(?="+[lf,Jn,"$"].join("|")+")",Ml+"+"+pf+"(?="+[lf,Jn+ha,"$"].join("|")+")",Jn+"?"+ha+"+"+yo,Jn+"+"+pf,gf,da,Ou,Rl].join("|"),"g"),Xi=RegExp("["+br+Hi+uf+Tu+"]"),Du=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Nl=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],pa=-1,yn={};yn[ua]=yn[Ti]=yn[ca]=yn[lo]=yn[ho]=yn[_o]=yn[hr]=yn[Pr]=yn[ji]=!0,yn[on]=yn[En]=yn[fa]=yn[hn]=yn[lr]=yn[Fn]=yn[Kn]=yn[Yr]=yn[Rr]=yn[ws]=yn[oi]=yn[kr]=yn[Ir]=yn[Ei]=yn[xs]=!1;var vn={};vn[on]=vn[En]=vn[fa]=vn[lr]=vn[hn]=vn[Fn]=vn[ua]=vn[Ti]=vn[ca]=vn[lo]=vn[ho]=vn[Rr]=vn[ws]=vn[oi]=vn[kr]=vn[Ir]=vn[Ei]=vn[b]=vn[_o]=vn[hr]=vn[Pr]=vn[ji]=!0,vn[Kn]=vn[Yr]=vn[xs]=!1;var vf={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Dl={"&":"&","<":"<",">":">",'"':""","'":"'"},B={"&":"&","<":"<",">":">",""":'"',"'":"'"},G={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},it=parseFloat,ie=parseInt,Ke=typeof ls=="object"&&ls&&ls.Object===Object&&ls,_n=typeof self=="object"&&self&&self.Object===Object&&self,De=Ke||_n||Function("return this")(),We=t&&!t.nodeType&&t,dn=We&&!0&&n&&!n.nodeType&&n,Or=dn&&dn.exports===We,dr=Or&&Ke.process,sr=function(){try{var W=dn&&dn.require&&dn.require("util").types;return W||dr&&dr.binding&&dr.binding("util")}catch{}}(),wo=sr&&sr.isArrayBuffer,zr=sr&&sr.isDate,bf=sr&&sr.isMap,dd=sr&&sr.isRegExp,xo=sr&&sr.isSet,_d=sr&&sr.isTypedArray;function ar(W,gt,ut){switch(ut.length){case 0:return W.call(gt);case 1:return W.call(gt,ut[0]);case 2:return W.call(gt,ut[0],ut[1]);case 3:return W.call(gt,ut[0],ut[1],ut[2])}return W.apply(gt,ut)}function pd(W,gt,ut,se){for(var Be=-1,fn=W==null?0:W.length;++Be-1}function Fl(W,gt,ut){for(var se=-1,Be=W==null?0:W.length;++se-1;);return ut}function Uu(W,gt){for(var ut=W.length;ut--&&Zi(gt,W[ut],0)>-1;);return ut}function Eo(W,gt){for(var ut=W.length,se=0;ut--;)W[ut]===gt&&++se;return se}var Ul=Ao(vf),Gl=Ao(Dl);function $l(W){return"\\"+G[W]}function Vl(W,gt){return W==null?e:W[gt]}function ya(W){return Xi.test(W)}function vd(W){return Du.test(W)}function bd(W){for(var gt,ut=[];!(gt=W.next()).done;)ut.push(gt.value);return ut}function Gu(W){var gt=-1,ut=Array(W.size);return W.forEach(function(se,Be){ut[++gt]=[Be,se]}),ut}function jl(W,gt){return function(ut){return W(gt(ut))}}function Ki(W,gt){for(var ut=-1,se=W.length,Be=0,fn=[];++ut-1}function Sm(i,a){var u=this.__data__,h=Ms(u,i);return h<0?(++this.size,u.push([i,a])):u[h][1]=a,this}hi.prototype.clear=Zu,hi.prototype.delete=bm,hi.prototype.get=wm,hi.prototype.has=xm,hi.prototype.set=Sm;function ts(i){var a=-1,u=i==null?0:i.length;for(this.clear();++a=a?i:a)),i}function pr(i,a,u,h,m,x){var N,k=a&w,Z=a&I,At=a&C;if(u&&(N=m?u(i,h,m,x):u(i)),N!==e)return N;if(!Hn(i))return i;var Tt=ze(i);if(Tt){if(N=Lt(i),!k)return Ar(i,N)}else{var Ft=et(i),ne=Ft==Yr||Ft==rf;if(Ho(i))return Vf(i,k);if(Ft==oi||Ft==on||ne&&!m){if(N=Z||ne?{}:Ot(i),!k)return Z?km(i,Nm(N,i)):Cm(i,Nf(N,i))}else{if(!vn[Ft])return m?i:{};N=Ct(i,Ft,k)}}x||(x=new di);var pe=x.get(i);if(pe)return pe;x.set(i,N),Ey(i)?i.forEach(function(Se){N.add(pr(Se,a,u,Se,i,x))}):Sy(i)&&i.forEach(function(Se,rn){N.set(rn,pr(Se,a,u,rn,i,x))});var xe=At?Z?dc:hc:Z?Qr:Tr,Je=Tt?e:xe(i);return _r(Je||i,function(Se,rn){Je&&(rn=Se,Se=i[rn]),Rf(N,rn,pr(Se,a,u,rn,i,x))}),N}function Dd(i){var a=Tr(i);return function(u){return Ia(u,i,a)}}function Ia(i,a,u){var h=u.length;if(i==null)return!h;for(i=pn(i);h--;){var m=u[h],x=a[m],N=i[m];if(N===e&&!(m in i)||!x(N))return!1}return!0}function Ju(i,a,u){if(typeof i!="function")throw new Hr(f);return fe(function(){i.apply(e,u)},a)}function Oa(i,a,u,h){var m=-1,x=Fu,N=!0,k=i.length,Z=[],At=a.length;if(!k)return Z;u&&(a=kn(a,Ur(u))),h?(x=Fl,N=!1):a.length>=s&&(x=Is,N=!1,a=new Ea(a));t:for(;++mm?0:m+u),h=h===e||h>m?m:He(h),h<0&&(h+=m),h=u>h?0:Iy(h);u0&&u(k)?a>1?or(k,a-1,u,h,m):qi(m,k):h||(m[m.length]=k)}return m}var tc=vh(),sh=vh(!0);function qr(i,a){return i&&tc(i,a,Tr)}function Df(i,a){return i&&sh(i,a,Tr)}function Ff(i,a){return Bi(a,function(u){return Va(i[u])})}function Ns(i,a){a=_i(a,i);for(var u=0,h=a.length;i!=null&&ua}function Cd(i,a){return i!=null&&un.call(i,a)}function kd(i,a){return i!=null&&a in pn(i)}function oh(i,a,u){return i>=wr(a,u)&&i<$n(a,u)}function kf(i,a,u){for(var h=u?Fl:Fu,m=i[0].length,x=i.length,N=x,k=ut(x),Z=1/0,At=[];N--;){var Tt=i[N];N&&a&&(Tt=kn(Tt,Ur(a))),Z=wr(Tt.length,Z),k[N]=!u&&(a||m>=120&&Tt.length>=120)?new Ea(N&&Tt):e}Tt=i[0];var Ft=-1,ne=k[0];t:for(;++Ft-1;)k!==i&&Of.call(k,Z,1),Of.call(i,Z,1);return i}function $d(i,a){for(var u=i?a.length:0,h=u-1;u--;){var m=a[u];if(u==h||m!==x){var x=m;z(m)?Of.call(i,m,1):ph(i,m)}}return i}function ic(i,a){return i+Lo(Kl()*(a-i+1))}function Vd(i,a,u,h){for(var m=-1,x=$n(Wu((a-i)/(u||1)),0),N=ut(x);x--;)N[h?x:++m]=i,i+=u;return N}function sc(i,a){var u="";if(!i||a<1||a>Mt)return u;do a%2&&(u+=i),a=Lo(a/2),a&&(i+=i);while(a);return u}function Ye(i,a){return me(Ut(i,a,ti),i+"")}function Go(i){return Nd(gc(i))}function dh(i,a){var u=gc(i);return xn(u,Ta(a,0,u.length))}function Uf(i,a,u,h){if(!Hn(i))return i;a=_i(a,i);for(var m=-1,x=a.length,N=x-1,k=i;k!=null&&++mm?0:m+a),u=u>m?m:u,u<0&&(u+=m),m=a>u?0:u-a>>>0,a>>>=0;for(var x=ut(m);++h>>1,N=i[x];N!==null&&!yi(N)&&(u?N<=a:N=s){var At=a?null:zm(i);if(At)return Sf(At);N=!1,m=Is,Z=new Ea}else Z=a?[]:k;t:for(;++h=h?i:Zr(i,a,u)}var $f=fm||function(i){return De.clearTimeout(i)};function Vf(i,a){if(a)return i.slice();var u=i.length,h=Xl?Xl(u):new i.constructor(u);return i.copy(h),h}function Fa(i){var a=new i.constructor(i.byteLength);return new If(a).set(new If(i)),a}function jf(i,a){var u=a?Fa(i.buffer):i.buffer;return new i.constructor(u,i.byteOffset,i.byteLength)}function Wf(i){var a=new i.constructor(i.source,Yi.exec(i));return a.lastIndex=i.lastIndex,a}function Yf(i){return Do?pn(Do.call(i)):{}}function Wo(i,a){var u=a?Fa(i.buffer):i.buffer;return new i.constructor(u,i.byteOffset,i.length)}function uc(i,a){if(i!==a){var u=i!==e,h=i===null,m=i===i,x=yi(i),N=a!==e,k=a===null,Z=a===a,At=yi(a);if(!k&&!At&&!x&&i>a||x&&N&&Z&&!k&&!At||h&&N&&Z||!u&&Z||!m)return 1;if(!h&&!x&&!At&&i=k)return Z;var At=u[h];return Z*(At=="desc"?-1:1)}}return i.index-a.index}function Ps(i,a,u,h){for(var m=-1,x=i.length,N=u.length,k=-1,Z=a.length,At=$n(x-N,0),Tt=ut(Z+At),Ft=!h;++k1?u[m-1]:e,N=m>2?u[2]:e;for(x=i.length>3&&typeof x=="function"?(m--,x):e,N&&J(u[0],u[1],N)&&(x=m<3?e:x,m=1),a=pn(a);++h-1?m[x?a[N]:N]:e}}function rs(i){return Ri(function(a){var u=a.length,h=u,m=Xr.prototype.thru;for(i&&a.reverse();h--;){var x=a[h];if(typeof x!="function")throw new Hr(f);if(m&&!N&&_c(x)=="wrapper")var N=new Xr([],!0)}for(h=N?h:u;++h1&&cn.reverse(),Tt&&Zk))return!1;var At=x.get(i),Tt=x.get(a);if(At&&Tt)return At==a&&Tt==i;var Ft=-1,ne=!0,pe=u&Wt?new Ea:e;for(x.set(i,a),x.set(a,i);++Ft1?"& ":"")+a[h],a=a.join(u>2?", ":" "),i.replace(ml,`{ /* [wrapped with `+a+`] */ `)}function Et(i){return ze(i)||Zf(i)||!!(ql&&i&&i[ql])}function z(i,a){var u=typeof i;return a=a??Mt,!!a&&(u=="number"||u!="symbol"&&Al.test(i))&&i>-1&&i%1==0&&i0){if(++a>=Bt)return arguments[0]}else a=0;return i.apply(e,arguments)}}function xn(i,a){var u=-1,h=i.length,m=h-1;for(a=a===e?h:a;++u1?i[a-1]:e;return u=typeof u=="function"?(i.pop(),u):e,qf(i,u)});function hy(i){var a=y(i);return a.__chain__=!0,a}function f3(i,a){return a(i),i}function t_(i,a){return a(i)}var u3=Ri(function(i){var a=i.length,u=a?i[0]:0,h=this.__wrapped__,m=function(x){return Rs(x,i)};return a>1||this.__actions__.length||!(h instanceof tn)||!z(u)?this.thru(m):(h=h.slice(u,+u+(a?1:0)),h.__actions__.push({func:t_,args:[m],thisArg:e}),new Xr(h,this.__chain__).thru(function(x){return a&&!x.length&&x.push(e),x}))});function c3(){return hy(this)}function l3(){return new Xr(this.value(),this.__chain__)}function h3(){this.__values__===e&&(this.__values__=Ty(this.value()));var i=this.__index__>=this.__values__.length,a=i?e:this.__values__[this.__index__++];return{done:i,value:a}}function d3(){return this}function _3(i){for(var a,u=this;u instanceof Mf;){var h=jn(u);h.__index__=0,h.__values__=e,a?m.__wrapped__=h:a=h;var m=h;u=u.__wrapped__}return m.__wrapped__=i,a}function p3(){var i=this.__wrapped__;if(i instanceof tn){var a=i;return this.__actions__.length&&(a=new tn(this)),a=a.reverse(),a.__actions__.push({func:t_,args:[Nt],thisArg:e}),new Xr(a,this.__chain__)}return this.thru(Nt)}function m3(){return Gf(this.__wrapped__,this.__actions__)}var g3=mi(function(i,a,u){un.call(i,u)?++i[u]:Nr(i,u,1)});function y3(i,a,u){var h=ze(i)?Ts:rh;return u&&J(i,a,u)&&(a=e),h(i,be(a,3))}function v3(i,a){var u=ze(i)?Bi:ih;return u(i,be(a,3))}var b3=ka(gi),w3=ka(Us);function x3(i,a){return or(e_(i,a),1)}function S3(i,a){return or(e_(i,a),yt)}function A3(i,a,u){return u=u===e?1:He(u),or(e_(i,a),u)}function dy(i,a){var u=ze(i)?_r:Li;return u(i,be(a,3))}function _y(i,a){var u=ze(i)?md:Qu;return u(i,be(a,3))}var E3=mi(function(i,a,u){un.call(i,u)?i[u].push(a):Nr(i,u,[a])});function T3(i,a,u,h){i=Jr(i)?i:gc(i),u=u&&!h?He(u):0;var m=i.length;return u<0&&(u=$n(m+u,0)),a_(i)?u<=m&&i.indexOf(a,u)>-1:!!m&&Zi(i,a,u)>-1}var I3=Ye(function(i,a,u){var h=-1,m=typeof a=="function",x=Jr(i)?ut(i.length):[];return Li(i,function(N){x[++h]=m?ar(a,N,u):La(N,a,u)}),x}),O3=mi(function(i,a,u){Nr(i,u,a)});function e_(i,a){var u=ze(i)?kn:Ds;return u(i,be(a,3))}function B3(i,a,u,h){return i==null?[]:(ze(a)||(a=a==null?[]:[a]),u=h?e:u,ze(u)||(u=u==null?[]:[u]),rc(i,a,u))}var L3=mi(function(i,a,u){i[u?0:1].push(a)},function(){return[[],[]]});function M3(i,a,u){var h=ze(i)?Cl:kl,m=arguments.length<3;return h(i,be(a,4),u,m,Li)}function R3(i,a,u){var h=ze(i)?Jp:kl,m=arguments.length<3;return h(i,be(a,4),u,m,Qu)}function N3(i,a){var u=ze(i)?Bi:ih;return u(i,i_(be(a,3)))}function D3(i){var a=ze(i)?Nd:Go;return a(i)}function F3(i,a,u){(u?J(i,a,u):a===e)?a=1:a=He(a);var h=ze(i)?Lm:dh;return h(i,a)}function C3(i){var a=ze(i)?Mm:Dm;return a(i)}function k3(i){if(i==null)return 0;if(Jr(i))return a_(i)?Os(i):i.length;var a=et(i);return a==Rr||a==Ir?i.size:ns(i).length}function P3(i,a,u){var h=ze(i)?Cu:Fm;return u&&J(i,a,u)&&(a=e),h(i,be(a,3))}var z3=Ye(function(i,a){if(i==null)return[];var u=a.length;return u>1&&J(i,a[0],a[1])?a=[]:u>2&&J(a[0],a[1],a[2])&&(a=[a[0]]),rc(i,or(a,1),[])}),n_=um||function(){return De.Date.now()};function U3(i,a){if(typeof a!="function")throw new Hr(f);return i=He(i),function(){if(--i<1)return a.apply(this,arguments)}}function py(i,a,u){return a=u?e:a,a=i&&a==null?i.length:a,is(i,ve,e,e,e,e,a)}function my(i,a){var u;if(typeof a!="function")throw new Hr(f);return i=He(i),function(){return--i>0&&(u=a.apply(this,arguments)),i<=1&&(a=e),u}}var Vm=Ye(function(i,a,u){var h=Qt;if(u.length){var m=Ki(u,za(Vm));h|=zt}return is(i,h,a,u,m)}),gy=Ye(function(i,a,u){var h=Qt|Rt;if(u.length){var m=Ki(u,za(gy));h|=zt}return is(a,h,i,u,m)});function yy(i,a,u){a=u?e:a;var h=is(i,Zt,e,e,e,e,e,a);return h.placeholder=yy.placeholder,h}function vy(i,a,u){a=u?e:a;var h=is(i,st,e,e,e,e,e,a);return h.placeholder=vy.placeholder,h}function by(i,a,u){var h,m,x,N,k,Z,At=0,Tt=!1,Ft=!1,ne=!0;if(typeof i!="function")throw new Hr(f);a=Di(a)||0,Hn(u)&&(Tt=!!u.leading,Ft="maxWait"in u,x=Ft?$n(Di(u.maxWait)||0,a):x,ne="trailing"in u?!!u.trailing:ne);function pe(rr){var os=h,Wa=m;return h=m=e,At=rr,N=i.apply(Wa,os),N}function xe(rr){return At=rr,k=fe(rn,a),Tt?pe(rr):N}function Je(rr){var os=rr-Z,Wa=rr-At,zy=a-os;return Ft?wr(zy,x-Wa):zy}function Se(rr){var os=rr-Z,Wa=rr-At;return Z===e||os>=a||os<0||Ft&&Wa>=x}function rn(){var rr=n_();if(Se(rr))return cn(rr);k=fe(rn,Je(rr))}function cn(rr){return k=e,ne&&h?pe(rr):(h=m=e,N)}function vi(){k!==e&&$f(k),At=0,h=Z=m=k=e}function Vr(){return k===e?N:cn(n_())}function bi(){var rr=n_(),os=Se(rr);if(h=arguments,m=this,Z=rr,os){if(k===e)return xe(Z);if(Ft)return $f(k),k=fe(rn,a),pe(Z)}return k===e&&(k=fe(rn,a)),N}return bi.cancel=vi,bi.flush=Vr,bi}var G3=Ye(function(i,a){return Ju(i,1,a)}),$3=Ye(function(i,a,u){return Ju(i,Di(a)||0,u)});function V3(i){return is(i,at)}function r_(i,a){if(typeof i!="function"||a!=null&&typeof a!="function")throw new Hr(f);var u=function(){var h=arguments,m=a?a.apply(this,h):h[0],x=u.cache;if(x.has(m))return x.get(m);var N=i.apply(this,h);return u.cache=x.set(m,N)||x,N};return u.cache=new(r_.Cache||ts),u}r_.Cache=ts;function i_(i){if(typeof i!="function")throw new Hr(f);return function(){var a=arguments;switch(a.length){case 0:return!i.call(this);case 1:return!i.call(this,a[0]);case 2:return!i.call(this,a[0],a[1]);case 3:return!i.call(this,a[0],a[1],a[2])}return!i.apply(this,a)}}function j3(i){return my(2,i)}var W3=mh(function(i,a){a=a.length==1&&ze(a[0])?kn(a[0],Ur(be())):kn(or(a,1),Ur(be()));var u=a.length;return Ye(function(h){for(var m=-1,x=wr(h.length,u);++m=a}),Zf=fh(function(){return arguments}())?fh:function(i){return Zn(i)&&un.call(i,"callee")&&!tr.call(i,"callee")},ze=ut.isArray,aS=wo?Ur(wo):zd;function Jr(i){return i!=null&&s_(i.length)&&!Va(i)}function nr(i){return Zn(i)&&Jr(i)}function oS(i){return i===!0||i===!1||Zn(i)&&Sr(i)==hn}var Ho=lm||e0,fS=zr?Ur(zr):uh;function uS(i){return Zn(i)&&i.nodeType===1&&!Eh(i)}function cS(i){if(i==null)return!0;if(Jr(i)&&(ze(i)||typeof i=="string"||typeof i.splice=="function"||Ho(i)||mc(i)||Zf(i)))return!i.length;var a=et(i);if(a==Rr||a==Ir)return!i.size;if(re(i))return!ns(i).length;for(var u in i)if(un.call(i,u))return!1;return!0}function lS(i,a){return Co(i,a)}function hS(i,a,u){u=typeof u=="function"?u:e;var h=u?u(i,a):e;return h===e?Co(i,a,e,u):!!h}function Wm(i){if(!Zn(i))return!1;var a=Sr(i);return a==Kn||a==ir||typeof i.message=="string"&&typeof i.name=="string"&&!Eh(i)}function dS(i){return typeof i=="number"&&Zl(i)}function Va(i){if(!Hn(i))return!1;var a=Sr(i);return a==Yr||a==rf||a==Dn||a==gu}function xy(i){return typeof i=="number"&&i==He(i)}function s_(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Mt}function Hn(i){var a=typeof i;return i!=null&&(a=="object"||a=="function")}function Zn(i){return i!=null&&typeof i=="object"}var Sy=bf?Ur(bf):ch;function _S(i,a){return i===a||Pf(i,a,v(a))}function pS(i,a,u){return u=typeof u=="function"?u:e,Pf(i,a,v(a),u)}function mS(i){return Ay(i)&&i!=+i}function gS(i){if($t(i))throw new Be(o);return ko(i)}function yS(i){return i===null}function vS(i){return i==null}function Ay(i){return typeof i=="number"||Zn(i)&&Sr(i)==ws}function Eh(i){if(!Zn(i)||Sr(i)!=oi)return!1;var a=ju(i);if(a===null)return!0;var u=un.call(a,"constructor")&&a.constructor;return typeof u=="function"&&u instanceof u&&Af.call(u)==Bo}var Ym=dd?Ur(dd):Gd;function bS(i){return xy(i)&&i>=-Mt&&i<=Mt}var Ey=xo?Ur(xo):ec;function a_(i){return typeof i=="string"||!ze(i)&&Zn(i)&&Sr(i)==Ei}function yi(i){return typeof i=="symbol"||Zn(i)&&Sr(i)==b}var mc=_d?Ur(_d):es;function wS(i){return i===e}function xS(i){return Zn(i)&&et(i)==xs}function SS(i){return Zn(i)&&Sr(i)==ol}var AS=mr(Ma),ES=mr(function(i,a){return i<=a});function Ty(i){if(!i)return[];if(Jr(i))return a_(i)?Br(i):Ar(i);if(li&&i[li])return bd(i[li]());var a=et(i),u=a==Rr?Gu:a==Ir?Sf:gc;return u(i)}function ja(i){if(!i)return i===0?i:0;if(i=Di(i),i===yt||i===-yt){var a=i<0?-1:1;return a*Kt}return i===i?i:0}function He(i){var a=ja(i),u=a%1;return a===a?u?a-u:a:0}function Iy(i){return i?Ta(He(i),0,de):0}function Di(i){if(typeof i=="number")return i;if(yi(i))return ee;if(Hn(i)){var a=typeof i.valueOf=="function"?i.valueOf():i;i=Hn(a)?a+"":a}if(typeof i!="string")return i===0?i:+i;i=yd(i);var u=wl.test(i);return u||Sl.test(i)?ie(i.slice(2),u?2:8):bl.test(i)?ee:+i}function Oy(i){return Mi(i,Qr(i))}function TS(i){return i?Ta(He(i),-Mt,Mt):i===0?i:0}function Sn(i){return i==null?"":Gr(i)}var IS=Ca(function(i,a){if(re(a)||Jr(a)){Mi(a,Tr(a),i);return}for(var u in a)un.call(a,u)&&Rf(i,u,a[u])}),By=Ca(function(i,a){Mi(a,Qr(a),i)}),o_=Ca(function(i,a,u,h){Mi(a,Qr(a),i,h)}),OS=Ca(function(i,a,u,h){Mi(a,Tr(a),i,h)}),BS=Ri(Rs);function LS(i,a){var u=Sa(i);return a==null?u:Nf(u,a)}var MS=Ye(function(i,a){i=pn(i);var u=-1,h=a.length,m=h>2?a[2]:e;for(m&&J(a[0],a[1],m)&&(h=1);++u1),x}),Mi(i,dc(i),u),h&&(u=pr(u,w|I|C,Um));for(var m=a.length;m--;)ph(u,a[m]);return u});function qS(i,a){return My(i,i_(be(a)))}var ZS=Ri(function(i,a){return i==null?{}:lh(i,a)});function My(i,a){if(i==null)return{};var u=kn(dc(i),function(h){return[h]});return a=be(a),Na(i,u,function(h,m){return a(h,m[0])})}function KS(i,a,u){a=_i(a,i);var h=-1,m=a.length;for(m||(m=1,i=e);++ha){var h=i;i=a,a=h}if(u||i%1||a%1){var m=Kl();return wr(i+m*(a-i+it("1e-"+((m+"").length-1))),a)}return ic(i,a)}var fA=Yo(function(i,a,u){return a=a.toLowerCase(),i+(u?Dy(a):a)});function Dy(i){return qm(Sn(i).toLowerCase())}function Fy(i){return i=Sn(i),i&&i.replace(El,Ul).replace(Nu,"")}function uA(i,a,u){i=Sn(i),a=Gr(a);var h=i.length;u=u===e?h:Ta(He(u),0,h);var m=u;return u-=a.length,u>=0&&i.slice(u,m)==a}function cA(i){return i=Sn(i),i&&Ii.test(i)?i.replace(Ss,Gl):i}function lA(i){return i=Sn(i),i&&_l.test(i)?i.replace(af,"\\$&"):i}var hA=Yo(function(i,a,u){return i+(u?"-":"")+a.toLowerCase()}),dA=Yo(function(i,a,u){return i+(u?" ":"")+a.toLowerCase()}),_A=bh("toLowerCase");function pA(i,a,u){i=Sn(i),a=He(a);var h=a?Os(i):0;if(!a||h>=a)return i;var m=(a-h)/2;return Pn(Lo(m),u)+i+Pn(Wu(m),u)}function mA(i,a,u){i=Sn(i),a=He(a);var h=a?Os(i):0;return a&&h>>0,u?(i=Sn(i),i&&(typeof a=="string"||a!=null&&!Ym(a))&&(a=Gr(a),!a&&ya(i))?pi(Br(i),0,u):i.split(a,u)):[]}var SA=Yo(function(i,a,u){return i+(u?" ":"")+qm(a)});function AA(i,a,u){return i=Sn(i),u=u==null?0:Ta(He(u),0,i.length),a=Gr(a),i.slice(u,u+a.length)==a}function EA(i,a,u){var h=y.templateSettings;u&&J(i,a,u)&&(a=e),i=Sn(i),a=o_({},a,h,Sh);var m=o_({},a.imports,h.imports,Sh),x=Tr(m),N=xf(m,x),k,Z,At=0,Tt=a.interpolate||As,Ft="__p += '",ne=Hl((a.escape||As).source+"|"+Tt.source+"|"+(Tt===vr?vl:As).source+"|"+(a.evaluate||As).source+"|$","g"),pe="//# sourceURL="+(un.call(a,"sourceURL")?(a.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++pa+"]")+` `;i.replace(ne,function(Se,rn,cn,vi,Vr,bi){return cn||(cn=vi),Ft+=i.slice(At,bi).replace(Tl,$l),rn&&(k=!0,Ft+=`' + __e(`+rn+`) + '`),Vr&&(Z=!0,Ft+=`'; `+Vr+`; __p += '`),cn&&(Ft+=`' + ((__t = (`+cn+`)) == null ? '' : __t) + '`),At=bi+Se.length,Se}),Ft+=`'; `;var xe=un.call(a,"variable")&&a.variable;if(!xe)Ft=`with (obj) { `+Ft+` } `;else if(gl.test(xe))throw new Be(c);Ft=(Z?Ft.replace(fl,""):Ft).replace(vu,"$1").replace(ul,"$1;"),Ft="function("+(xe||"obj")+`) { `+(xe?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(k?", __e = _.escape":"")+(Z?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Ft+`return __p }`;var Je=ky(function(){return fn(x,pe+"return "+Ft).apply(e,N)});if(Je.source=Ft,Wm(Je))throw Je;return Je}function TA(i){return Sn(i).toLowerCase()}function IA(i){return Sn(i).toUpperCase()}function OA(i,a,u){if(i=Sn(i),i&&(u||a===e))return yd(i);if(!i||!(a=Gr(a)))return i;var h=Br(i),m=Br(a),x=zu(h,m),N=Uu(h,m)+1;return pi(h,x,N).join("")}function BA(i,a,u){if(i=Sn(i),i&&(u||a===e))return i.slice(0,xd(i)+1);if(!i||!(a=Gr(a)))return i;var h=Br(i),m=Uu(h,Br(a))+1;return pi(h,0,m).join("")}function LA(i,a,u){if(i=Sn(i),i&&(u||a===e))return i.replace(of,"");if(!i||!(a=Gr(a)))return i;var h=Br(i),m=zu(h,Br(a));return pi(h,m).join("")}function MA(i,a){var u=Y,h=rt;if(Hn(a)){var m="separator"in a?a.separator:m;u="length"in a?He(a.length):u,h="omission"in a?Gr(a.omission):h}i=Sn(i);var x=i.length;if(ya(i)){var N=Br(i);x=N.length}if(u>=x)return i;var k=u-Os(h);if(k<1)return h;var Z=N?pi(N,0,k).join(""):i.slice(0,k);if(m===e)return Z+h;if(N&&(k+=Z.length-k),Ym(m)){if(i.slice(k).search(m)){var At,Tt=Z;for(m.global||(m=Hl(m.source,Sn(Yi.exec(m))+"g")),m.lastIndex=0;At=m.exec(Tt);)var Ft=At.index;Z=Z.slice(0,Ft===e?k:Ft)}}else if(i.indexOf(Gr(m),k)!=k){var ne=Z.lastIndexOf(m);ne>-1&&(Z=Z.slice(0,ne))}return Z+h}function RA(i){return i=Sn(i),i&&bu.test(i)?i.replace(sf,em):i}var NA=Yo(function(i,a,u){return i+(u?" ":"")+a.toUpperCase()}),qm=bh("toUpperCase");function Cy(i,a,u){return i=Sn(i),a=u?e:a,a===e?vd(i)?rm(i):Qp(i):i.match(a)||[]}var ky=Ye(function(i,a){try{return ar(i,e,a)}catch(u){return Wm(u)?u:new Be(u)}}),DA=Ri(function(i,a){return _r(a,function(u){u=mn(u),Nr(i,u,Vm(i[u],i))}),i});function FA(i){var a=i==null?0:i.length,u=be();return i=a?kn(i,function(h){if(typeof h[1]!="function")throw new Hr(f);return[u(h[0]),h[1]]}):[],Ye(function(h){for(var m=-1;++mMt)return[];var u=de,h=wr(i,de);a=be(a),i-=de;for(var m=zl(h,a);++u0||a<0)?new tn(u):(i<0?u=u.takeRight(-i):i&&(u=u.drop(i)),a!==e&&(a=He(a),u=a<0?u.dropRight(-a):u.take(a-i)),u)},tn.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},tn.prototype.toArray=function(){return this.take(de)},qr(tn.prototype,function(i,a){var u=/^(?:filter|find|map|reject)|While$/.test(a),h=/^(?:head|last)$/.test(a),m=y[h?"take"+(a=="last"?"Right":""):a],x=h||/^find/.test(a);m&&(y.prototype[a]=function(){var N=this.__wrapped__,k=h?[1]:arguments,Z=N instanceof tn,At=k[0],Tt=Z||ze(N),Ft=function(rn){var cn=m.apply(y,qi([rn],k));return h&&ne?cn[0]:cn};Tt&&u&&typeof At=="function"&&At.length!=1&&(Z=Tt=!1);var ne=this.__chain__,pe=!!this.__actions__.length,xe=x&&!ne,Je=Z&&!pe;if(!x&&Tt){N=Je?N:new tn(this);var Se=i.apply(N,k);return Se.__actions__.push({func:t_,args:[Ft],thisArg:e}),new Xr(Se,ne)}return xe&&Je?i.apply(this,k):(Se=this.thru(Ft),xe?h?Se.value()[0]:Se.value():Se)})}),_r(["pop","push","shift","sort","splice","unshift"],function(i){var a=$u[i],u=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",h=/^(?:pop|shift)$/.test(i);y.prototype[i]=function(){var m=arguments;if(h&&!this.__chain__){var x=this.value();return a.apply(ze(x)?x:[],m)}return this[u](function(N){return a.apply(ze(N)?N:[],m)})}}),qr(tn.prototype,function(i,a){var u=y[a];if(u){var h=u.name+"";un.call(xr,h)||(xr[h]=[]),xr[h].push({name:a,func:u})}}),xr[Xf(e,Rt).name]=[{name:"wrapper",func:e}],tn.prototype.clone=_m,tn.prototype.reverse=pm,tn.prototype.value=mm,y.prototype.at=u3,y.prototype.chain=c3,y.prototype.commit=l3,y.prototype.next=h3,y.prototype.plant=_3,y.prototype.reverse=p3,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=m3,y.prototype.first=y.prototype.head,li&&(y.prototype[li]=d3),y},Io=im();dn?((dn.exports=Io)._=Io,We._=Io):De._=Io}).call(ls)})(FT,ep);const Rv={sqrt:xT,log:Jb,linear:tp,literal:Zb};class Pp{constructor(t,e,r,s){if(this._transform="linear",this.field=null,this._texture_buffer=null,this.partner=null,this._textures={},this.current_encoding=null,this.aesthetic_map=s,this.aesthetic_map===void 0)throw new Error("Aesthetic map is undefined");this.scatterplot=t,this.regl=e,this._range=[0,1],this.dataset=r,this.id=Math.random().toString()}apply(t){return this.scale===void 0?this.default_constant:this.scale(this.value_for(t))}get transform(){return this._transform?this._transform:this.default_transform}set transform(t){this._transform=t}get scale(){if(this._scale)return this._scale;if(this.is_dictionary())throw new Error("Dictionary scales only supported for colors");const t=Rv[this.transform]();return t.domain(this.domain).range(this.range),this._scale=t}get column(){var t,e;if(this.field===null)throw new Error("Can't retrieve column for aesthetic without a field");if((e=(t=this.dataset)==null?void 0:t.root_tile)!=null&&e.record_batch){const r=this.dataset.root_tile.record_batch.getChild(this.field);if(r==null)throw new Error("Can't find column "+this.field);return r}throw new Error("Table is null")}get default_domain(){var t;if(this.field==null)return[1,1];if(!this.scatterplot._root._schema)return[1,1];const{column:e}=this;return e?((t=e.type)==null?void 0:t.dictionary)!==void 0?[0,this.aesthetic_map.texture_size]:(this.dataset.domain(this.field),this.dataset.domain(this.field)):[1,1]}default_data(){const t=this.toGLType(this.default_constant);return Array(this.aesthetic_map.texture_size).fill(t)}get webGLDomain(){return this.is_dictionary()?[0,4096]:this.domain}get domain(){return this._domain===void 0&&(this._domain=this.default_domain),this._domain||this.default_domain}get range(){return this._range||this.default_range}value_for(t){return this.field&&t[this.field]?t[this.field]:null}get map_position(){return this.use_map_on_regl===0?0:this.aesthetic_map.get_position(this.id)}get texture_buffer(){return this._texture_buffer?this._texture_buffer:(this._texture_buffer=new Float32Array(this.aesthetic_map.texture_size),this._texture_buffer.set(this.default_data()),this._texture_buffer)}post_to_regl_buffer(){this.aesthetic_map.set_one_d(this.id,this.texture_buffer)}convert_string_encoding(t){return{field:t,domain:this.default_domain,range:this.default_range}}complete_domain(t){return t.domain=t.domain||this.default_domain,t}reset_to_defaults(){this._domain=this.default_domain,this._range=[0,1],this._transform=void 0,this._constant=this.default_constant,this.field=null,this.current_encoding=null,this._scale=void 0}update(t){var e;if(t===void 0){console.warn("Should never be calling update with undefined.");return}if(t===null||t==="null"){this.current_encoding=null,this.reset_to_defaults();return}if(this._scale=void 0,typeof t=="string"&&(t=this.convert_string_encoding(t)),ep.isNumber(t)){const r={constant:t};this.current_encoding=r;return}if(Object.keys(t).length===0){console.warn("Resetting parameters with an empty object is deprecated: use 'null'"),this.reset_to_defaults();return}if(this.current_encoding=t,!qh(t)&&(this.field=t.field,!W0(t))){if(s1(t)){const{lambda:r,field:s}=t;r&&(this.apply_function_for_textures(s,this.domain,r),this.post_to_regl_buffer());return}t.domain===void 0&&(t.domain=this.default_domain),t.range&&(this._domain=t.domain,this._range=t.range),this._transform=(e=t.transform)!=null?e:void 0}}encode_for_textures(t){const{texture_size:e}=this.aesthetic_map,r=Array(e),s=Rv[this.transform]().range(t).domain([0,e-1]);for(let o=0;o1));return}const{column:l}=this;if(!l)throw new Error(`Column ${t} does not exist on table.`);if((s=l==null?void 0:l.type)!=null&&s.dictionary){c.fill("");const p=l.data[0].dictionary.toArray();for(const[w,I]of p.entries())c[w]=I}else c=c.map(p=>this.scale(p));const d=c.map(p=>f(p));this.texture_buffer.set(d)}}class Ag extends Pp{constructor(t,e,r,s){super(t,e,r,s),this.current_encoding=null}toGLType(t){return t}static get_default_domain(){return[0,1]}get default_domain(){return[0,1]}}class CT extends Ag{constructor(){super(...arguments),this._constant=1,this.default_constant=1,this.default_transform="sqrt"}static get default_constant(){return 1.5}get default_range(){return[0,1]}}class a1 extends Ag{constructor(t,e,r,s){super(t,e,r,s),this.default_range=[-1,1],this.default_constant=0,this.default_transform="literal",this._constant=0,this._transform="literal"}get range(){return this._range?this._range:this.dataset.extent&&this.field&&this.dataset.extent[this.field]?this.dataset.extent[this.field]:this.default_range}static get default_constant(){return 0}}class o1 extends a1{constructor(){super(...arguments),this.field="x"}}class kT extends o1{}class f1 extends a1{constructor(){super(...arguments),this.field="y"}}class PT extends f1{}class u1 extends Pp{constructor(t,e,r,s){super(t,e,r,s)}toGLType(t){return t?1:0}update(t){super.update(t),this.current_encoding!==null&&Object.keys(this.current_encoding).length===0&&(this.current_encoding=null)}ops_to_array(){const t=this.current_encoding;return t===null?[0,0,0]:t===void 0?[0,0,0]:W0(t)?t.op==="within"?[4,t.a,t.b]:t.op==="between"?[4,(t.b-t.a)/2,(t.b+t.a)/2]:[[null,"lt","gt","eq"].indexOf(t.op),t.a,0]:[0,0,0]}apply(t){const e=this.current_encoding;if(e==null)return!0;if(W0(e))return this.apply_op(t,e);if(qh(e))return e.constant===0?(console.warn("Deprecated: pass `true` or `false` to boolean fields, not numbers"),!1):e.constant===1?(console.warn("Deprecated: pass `true` or `false` to boolean fields, not numbers"),!0):e.constant;if(s1(e)){if(this._func===void 0)throw new Error("_func should have been bound"+JSON.stringify(this.current_encoding));const r=this.value_for(t);return r===null?!1:!!this._func(r)}return!0}apply_op(t,e){const{op:r,a:s}=e,o=this.value_for(t);if(o===null)return!1;if(r==="eq")return o==s;if(r==="gt")return o>s;if(r==="lt")return o").map(s=>s.trim());if(e===void 0)throw new Error(`Couldn't parse ${n} into a function`);e.slice(0,1)!=="{"&&e.slice(0,6)!=="return"&&(e=`return ${e}`);const r=`${t} => ${e}`;return{field:t,lambda:r}}function VT(n){if(typeof n.lambda=="function")throw"Must pass a string to lambda, not a function.";const{lambda:t,field:e}=n;if(e===void 0)throw"Must pass a field to lambda.";const r=c1(t).lambda,[s,o]=r.split("=>",2).map(c=>c.trim());return new Function(s,o)}function qe(n){for(var t=n.length/6|0,e=new Array(t),r=0;rw8(n[n.length-1]);var l1=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(qe);const tI=Rn(l1);var h1=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(qe);const eI=Rn(h1);var d1=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(qe);const nI=Rn(d1);var _1=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(qe);const rI=Rn(_1);var p1=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(qe);const iI=Rn(p1);var m1=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(qe);const sI=Rn(m1);var g1=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(qe);const aI=Rn(g1);var y1=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(qe);const oI=Rn(y1);var v1=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(qe);const fI=Rn(v1);var b1=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(qe);const uI=Rn(b1);var w1=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(qe);const cI=Rn(w1);var x1=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(qe);const lI=Rn(x1);var S1=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(qe);const hI=Rn(S1);var A1=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(qe);const dI=Rn(A1);var E1=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(qe);const _I=Rn(E1);var T1=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(qe);const pI=Rn(T1);var I1=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(qe);const mI=Rn(I1);var O1=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(qe);const gI=Rn(O1);var B1=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(qe);const yI=Rn(B1);var L1=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(qe);const vI=Rn(L1);var M1=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(qe);const bI=Rn(M1);var R1=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(qe);const wI=Rn(R1);var N1=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(qe);const xI=Rn(N1);var D1=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(qe);const SI=Rn(D1);var F1=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(qe);const AI=Rn(F1);var C1=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(qe);const EI=Rn(C1);var k1=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(qe);const TI=Rn(k1);function II(n){return n=Math.max(0,Math.min(1,n)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-n*(35.34-n*(2381.73-n*(6402.7-n*(7024.72-n*2710.57)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+n*(170.73+n*(52.82-n*(131.46-n*(176.58-n*67.37)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+n*(442.36-n*(2482.43-n*(6167.24-n*(6614.94-n*2475.67)))))))+")"}const OI=_g(ra(300,.5,0),ra(-240,.5,1));var BI=_g(ra(-100,.75,.35),ra(80,1.5,.8)),LI=_g(ra(260,.75,.35),ra(80,1.5,.8)),g_=ra();function MI(n){(n<0||n>1)&&(n-=Math.floor(n));var t=Math.abs(n-.5);return g_.h=360*n-100,g_.s=1.5-1.5*t,g_.l=.8-.9*t,g_+""}var y_=no(),RI=Math.PI/3,NI=Math.PI*2/3;function DI(n){var t;return n=(.5-n)*Math.PI,y_.r=255*(t=Math.sin(n))*t,y_.g=255*(t=Math.sin(n+RI))*t,y_.b=255*(t=Math.sin(n+NI))*t,y_+""}function FI(n){return n=Math.max(0,Math.min(1,n)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+n*(1172.33-n*(10793.56-n*(33300.12-n*(38394.49-n*14825.05)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+n*(557.33+n*(1225.33-n*(3574.96-n*(1073.77+n*707.56)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+n*(3211.1-n*(15327.97-n*(27814-n*(22569.18-n*6838.66)))))))+")"}function zp(n){var t=n.length;return function(e){return n[Math.max(0,Math.min(t-1,Math.floor(e*t)))]}}const CI=zp(qe("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var kI=zp(qe("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),PI=zp(qe("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),zI=zp(qe("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));const Eg=Object.freeze(Object.defineProperty({__proto__:null,interpolateBlues:wI,interpolateBrBG:tI,interpolateBuGn:uI,interpolateBuPu:cI,interpolateCividis:II,interpolateCool:LI,interpolateCubehelixDefault:OI,interpolateGnBu:lI,interpolateGreens:xI,interpolateGreys:SI,interpolateInferno:PI,interpolateMagma:kI,interpolateOrRd:hI,interpolateOranges:TI,interpolatePRGn:eI,interpolatePiYG:nI,interpolatePlasma:zI,interpolatePuBu:_I,interpolatePuBuGn:dI,interpolatePuOr:rI,interpolatePuRd:pI,interpolatePurples:AI,interpolateRainbow:MI,interpolateRdBu:iI,interpolateRdGy:sI,interpolateRdPu:mI,interpolateRdYlBu:aI,interpolateRdYlGn:oI,interpolateReds:EI,interpolateSinebow:DI,interpolateSpectral:fI,interpolateTurbo:FI,interpolateViridis:CI,interpolateWarm:BI,interpolateYlGn:yI,interpolateYlGnBu:gI,interpolateYlOrBr:vI,interpolateYlOrRd:bI,schemeAccent:WT,schemeBlues:R1,schemeBrBG:l1,schemeBuGn:b1,schemeBuPu:w1,schemeCategory10:jT,schemeDark2:YT,schemeGnBu:x1,schemeGreens:N1,schemeGreys:D1,schemeOrRd:S1,schemeOranges:k1,schemePRGn:h1,schemePaired:HT,schemePastel1:XT,schemePastel2:qT,schemePiYG:d1,schemePuBu:E1,schemePuBuGn:A1,schemePuOr:_1,schemePuRd:T1,schemePurples:F1,schemeRdBu:p1,schemeRdGy:m1,schemeRdPu:I1,schemeRdYlBu:g1,schemeRdYlGn:y1,schemeReds:C1,schemeSet1:ZT,schemeSet2:KT,schemeSet3:JT,schemeSpectral:v1,schemeTableau10:QT,schemeYlGn:B1,schemeYlGnBu:O1,schemeYlOrBr:L1,schemeYlOrRd:M1},Symbol.toStringTag,{value:"Module"})),UI=1664525,GI=1013904223,Dv=1/4294967296;function $I(n=Math.random()){let t=(0<=n&&n<1?n/Dv:Math.abs(n))|0;return()=>(t=UI*t+GI|0,Dv*(t>>>0))}const uu=4096;function VI(n){const t=new Uint8Array(4*uu);return au(uu).forEach(e=>{const r=no(n(e/uu));t.set([r.r,r.g,r.b,255],e*4)}),t}const Xs={white:new Uint8Array(4*uu).fill(255)},np={};function rp(n){const t=n.map(s=>{const o=no(s);return[o.r,o.g,o.b,255]}),e=new Uint8Array(uu*4),r=Math.floor(uu/n.length);for(let s=0;s[c,l])),f=[];for(let c=0;c=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Xe(n){return this instanceof Xe?(this.v=n,this):new Xe(n)}function ea(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,o=[];return s={},f("next"),f("throw"),f("return"),s[Symbol.asyncIterator]=function(){return this},s;function f(I){r[I]&&(s[I]=function(C){return new Promise(function(V,Wt){o.push([I,C,V,Wt])>1||c(I,C)})})}function c(I,C){try{l(r[I](C))}catch(V){w(o[0][3],V)}}function l(I){I.value instanceof Xe?Promise.resolve(I.value.v).then(d,p):w(o[0][2],I)}function d(I){c("next",I)}function p(I){c("throw",I)}function w(I,C){I(C),o.shift(),o.length&&c(o[0][0],o[0][1])}}function B_(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,o){t[s]=n[s]?function(f){return(e=!e)?{value:Xe(n[s](f)),done:!1}:o?o(f):f}:o}}function Mc(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof Fv=="function"?Fv(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(f){return new Promise(function(c,l){f=n[o](f),s(c,l,f.done,f.value)})}}function s(o,f,c,l){Promise.resolve(l).then(function(d){o({value:d,done:c})},f)}}const qI=new TextDecoder("utf-8"),Y0=n=>qI.decode(n),ZI=new TextEncoder,Up=n=>ZI.encode(n),KI=n=>typeof n=="number",JI=n=>typeof n=="boolean",jr=n=>typeof n=="function",ps=n=>n!=null&&Object(n)===n,Zh=n=>ps(n)&&jr(n.then),Gp=n=>ps(n)&&jr(n[Symbol.iterator]),Tg=n=>ps(n)&&jr(n[Symbol.asyncIterator]),H0=n=>ps(n)&&ps(n.schema),P1=n=>ps(n)&&"done"in n&&"value"in n,z1=n=>ps(n)&&jr(n.stat)&&KI(n.fd),U1=n=>ps(n)&&Ig(n.body),G1=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Ig=n=>ps(n)&&jr(n.cancel)&&jr(n.getReader)&&!G1(n),$1=n=>ps(n)&&jr(n.read)&&jr(n.pipe)&&JI(n.readable)&&!G1(n),QI=n=>ps(n)&&jr(n.clear)&&jr(n.bytes)&&jr(n.position)&&jr(n.setPosition)&&jr(n.capacity)&&jr(n.getBufferIdentifier)&&jr(n.createLong),Og=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function t2(n){const t=n[0]?[n[0]]:[];let e,r,s,o;for(let f,c,l=0,d=0,p=n.length;++lp+w.byteLength,0);let s,o,f,c=0,l=-1;const d=Math.min(t||Number.POSITIVE_INFINITY,r);for(const p=e.length;++lMn(Int32Array,n),bn=n=>Mn(Uint8Array,n),X0=n=>(n.next(),n);function*e2(n,t){const e=function*(s){yield s},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Og?e(t):Gp(t)?t:e(t);return yield*X0(function*(s){let o=null;do o=s.next(yield Mn(n,o));while(!o.done)}(r[Symbol.iterator]())),new n}const n2=n=>e2(Uint8Array,n);function V1(n,t){return ea(this,arguments,function*(){if(Zh(t))return yield Xe(yield Xe(yield*B_(Mc(V1(n,yield Xe(t))))));const r=function(f){return ea(this,arguments,function*(){yield yield Xe(yield Xe(f))})},s=function(f){return ea(this,arguments,function*(){yield Xe(yield*B_(Mc(X0(function*(c){let l=null;do l=c.next(yield l==null?void 0:l.value);while(!l.done)}(f[Symbol.iterator]())))))})},o=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Og?r(t):Gp(t)?s(t):Tg(t)?t:r(t);return yield Xe(yield*B_(Mc(X0(function(f){return ea(this,arguments,function*(){let c=null;do c=yield Xe(f.next(yield yield Xe(Mn(n,c))));while(!c.done)})}(o[Symbol.asyncIterator]()))))),yield Xe(new n)})}const r2=n=>V1(Uint8Array,n);function i2(n,t){let e=0;const r=n.length;if(r!==t.length)return!1;if(r>0)do if(n[e]!==t[e])return!1;while(++e(n.next(),n);function*s2(n){let t,e=!1,r=[],s,o,f,c=0;function l(){return o==="peek"?ia(r,f)[0]:([s,r,c]=ia(r,f),s)}({cmd:o,size:f}=yield null);const d=n2(n)[Symbol.iterator]();try{do if({done:t,value:s}=Number.isNaN(f-c)?d.next():d.next(f-c),!t&&s.byteLength>0&&(r.push(s),c+=s.byteLength),t||f<=c)do({cmd:o,size:f}=yield l());while(f0&&(s.push(o),l+=o.byteLength),e||c<=l)do({cmd:f,size:c}=yield yield Xe(d()));while(c0&&(s.push(bn(o)),l+=o.byteLength),e||c<=l)do({cmd:f,size:c}=yield yield Xe(d()));while(c{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Ne(this,void 0,void 0,function*(){const{reader:e,source:r}=this;e&&(yield e.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Ne(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=bn(e)),e})}}const u0=(n,t)=>{const e=s=>r([t,s]);let r;return[t,e,new Promise(s=>(r=s)&&n.once(t,e))]};function u2(n){return ea(this,arguments,function*(){const e=[];let r="error",s=!1,o=null,f,c,l=0,d=[],p;function w(){return f==="peek"?ia(d,c)[0]:([p,d,l]=ia(d,c),p)}if({cmd:f,size:c}=yield yield Xe(null),n.isTTY)return yield yield Xe(new Uint8Array(0)),yield Xe(null);try{e[0]=u0(n,"end"),e[1]=u0(n,"error");do{if(e[2]=u0(n,"readable"),[r,o]=yield Xe(Promise.race(e.map(C=>C[2]))),r==="error")break;if((s=r==="end")||(Number.isFinite(c-l)?(p=bn(n.read(c-l)),p.byteLength0&&(d.push(p),l+=p.byteLength)),s||c<=l)do({cmd:f,size:c}=yield yield Xe(w()));while(c{for(const[Rt,oe]of C)n.off(Rt,oe);try{const Rt=n.destroy;Rt&&Rt.call(n,V),V=void 0}catch(Rt){V=Rt||V}finally{V!=null?Qt(V):Wt()}})}})}var Ui;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(Ui||(Ui={}));var ms;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(ms||(ms={}));var Cr;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Cr||(Cr={}));var sa;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(sa||(sa={}));var wn;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(wn||(wn={}));var Jo;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Jo||(Jo={}));var Ln;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ln||(Ln={}));var Q;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth"})(Q||(Q={}));var qa;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(qa||(qa={}));const c2=void 0;function _u(n){if(n===null)return"null";if(n===c2)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(t=>_u(t))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(t,e)=>typeof e=="bigint"?`${e}`:e)}const l2=Symbol.for("isArrowBigNum");function bs(n,...t){return t.length===0?Object.setPrototypeOf(Mn(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...t),this.constructor.prototype)}bs.prototype[l2]=!0;bs.prototype.toJSON=function(){return`"${Jh(this)}"`};bs.prototype.valueOf=function(){return j1(this)};bs.prototype.toString=function(){return Jh(this)};bs.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return j1(this);case"string":return Jh(this);case"default":return h2(this)}return Jh(this)};function Rc(...n){return bs.apply(this,n)}function Nc(...n){return bs.apply(this,n)}function Kh(...n){return bs.apply(this,n)}Object.setPrototypeOf(Rc.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Nc.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Kh.prototype,Object.create(Uint32Array.prototype));Object.assign(Rc.prototype,bs.prototype,{constructor:Rc,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Nc.prototype,bs.prototype,{constructor:Nc,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Kh.prototype,bs.prototype,{constructor:Kh,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});function j1(n){const{buffer:t,byteOffset:e,length:r,signed:s}=n,o=new BigUint64Array(t,e,r),f=s&&o.at(-1)&BigInt(1)<{if(n.byteLength===8)return`${new n.BigIntArray(n.buffer,n.byteOffset,1)[0]}`;if(!n.signed)return c0(n);let t=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return c0(n);t=t.slice();let r=1;for(let o=0;on.byteLength===8?new n.BigIntArray(n.buffer,n.byteOffset,1)[0]:Jh(n);function c0(n){let t="";const e=new Uint32Array(2);let r=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2);const s=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let o=-1;const f=r.length-1;do{for(e[0]=r[o=0];oNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}var W1,Y1,H1,X1,q1,Z1,K1,J1,Q1,tw,ew,nw,rw,iw,sw,aw,ow,fw,uw;class Re{static isNull(t){return(t==null?void 0:t.typeId)===Q.Null}static isInt(t){return(t==null?void 0:t.typeId)===Q.Int}static isFloat(t){return(t==null?void 0:t.typeId)===Q.Float}static isBinary(t){return(t==null?void 0:t.typeId)===Q.Binary}static isUtf8(t){return(t==null?void 0:t.typeId)===Q.Utf8}static isBool(t){return(t==null?void 0:t.typeId)===Q.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===Q.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===Q.Date}static isTime(t){return(t==null?void 0:t.typeId)===Q.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===Q.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===Q.Interval}static isList(t){return(t==null?void 0:t.typeId)===Q.List}static isStruct(t){return(t==null?void 0:t.typeId)===Q.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===Q.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===Q.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===Q.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===Q.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===Q.Dictionary}static isDenseUnion(t){return Re.isUnion(t)&&t.mode===ms.Dense}static isSparseUnion(t){return Re.isUnion(t)&&t.mode===ms.Sparse}get typeId(){return Q.NONE}}W1=Symbol.toStringTag;Re[W1]=(n=>(n.children=null,n.ArrayType=Array,n[Symbol.toStringTag]="DataType"))(Re.prototype);let io=class extends Re{toString(){return"Null"}get typeId(){return Q.Null}};Y1=Symbol.toStringTag;io[Y1]=(n=>n[Symbol.toStringTag]="Null")(io.prototype);class Wr extends Re{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return Q.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}H1=Symbol.toStringTag;Wr[H1]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Wr.prototype);class Lg extends Wr{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class Mg extends Wr{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class Qo extends Wr{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}let $p=class extends Wr{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}};class Rg extends Wr{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}class cw extends Wr{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class lw extends Wr{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}let hw=class extends Wr{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Lg.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Mg.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});Object.defineProperty($p.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Rg.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(cw.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(lw.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(hw.prototype,"ArrayType",{value:BigUint64Array});class pu extends Re{constructor(t){super(),this.precision=t}get typeId(){return Q.Float}get ArrayType(){switch(this.precision){case Cr.HALF:return Uint16Array;case Cr.SINGLE:return Float32Array;case Cr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}X1=Symbol.toStringTag;pu[X1]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(pu.prototype);class Ng extends pu{constructor(){super(Cr.SINGLE)}}class Dg extends pu{constructor(){super(Cr.DOUBLE)}}Object.defineProperty(Ng.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Dg.prototype,"ArrayType",{value:Float64Array});let sp=class extends Re{constructor(){super()}get typeId(){return Q.Binary}toString(){return"Binary"}};q1=Symbol.toStringTag;sp[q1]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(sp.prototype);let Wc=class extends Re{constructor(){super()}get typeId(){return Q.Utf8}toString(){return"Utf8"}};Z1=Symbol.toStringTag;Wc[Z1]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Wc.prototype);let Yc=class extends Re{constructor(){super()}get typeId(){return Q.Bool}toString(){return"Bool"}};K1=Symbol.toStringTag;Yc[K1]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Yc.prototype);let ap=class extends Re{constructor(t,e,r=128){super(),this.scale=t,this.precision=e,this.bitWidth=r}get typeId(){return Q.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};J1=Symbol.toStringTag;ap[J1]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(ap.prototype);class Qh extends Re{constructor(t){super(),this.unit=t}get typeId(){return Q.Date}toString(){return`Date${(this.unit+1)*32}<${sa[this.unit]}>`}}Q1=Symbol.toStringTag;Qh[Q1]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Date"))(Qh.prototype);class d2 extends Qh{constructor(){super(sa.MILLISECOND)}}class td extends Re{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return Q.Time}toString(){return`Time${this.bitWidth}<${wn[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}tw=Symbol.toStringTag;td[tw]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(td.prototype);class op extends Re{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return Q.Timestamp}toString(){return`Timestamp<${wn[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}ew=Symbol.toStringTag;op[ew]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Timestamp"))(op.prototype);class fp extends Re{constructor(t){super(),this.unit=t}get typeId(){return Q.Interval}toString(){return`Interval<${Jo[this.unit]}>`}}nw=Symbol.toStringTag;fp[nw]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(fp.prototype);let Hc=class extends Re{constructor(t){super(),this.children=[t]}get typeId(){return Q.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}};rw=Symbol.toStringTag;Hc[rw]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Hc.prototype);class Mr extends Re{constructor(t){super(),this.children=t}get typeId(){return Q.Struct}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}iw=Symbol.toStringTag;Mr[iw]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Mr.prototype);class ed extends Re{constructor(t,e,r){super(),this.mode=t,this.children=r,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((s,o,f)=>(s[o]=f)&&s||s,Object.create(null))}get typeId(){return Q.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}sw=Symbol.toStringTag;ed[sw]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ed.prototype);let up=class extends Re{constructor(t){super(),this.byteWidth=t}get typeId(){return Q.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};aw=Symbol.toStringTag;up[aw]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(up.prototype);let nd=class extends Re{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return Q.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}>`}};ow=Symbol.toStringTag;nd[ow]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(nd.prototype);class rd extends Re{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return Q.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}fw=Symbol.toStringTag;rd[fw]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(rd.prototype);const _2=(n=>()=>++n)(-1);class so extends Re{constructor(t,e,r,s){super(),this.indices=e,this.dictionary=t,this.isOrdered=s||!1,this.id=r==null?_2():gs(r)}get typeId(){return Q.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}>`}}uw=Symbol.toStringTag;so[uw]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(so.prototype);function Ws(n){const t=n;switch(n.typeId){case Q.Decimal:return n.bitWidth/32;case Q.Timestamp:return 2;case Q.Date:return 1+t.unit;case Q.Interval:return 1+t.unit;case Q.FixedSizeList:return t.listSize;case Q.FixedSizeBinary:return t.byteWidth;default:return 1}}class ln{visitMany(t,...e){return t.map((r,s)=>this.visit(r,...e.map(o=>o[s])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return p2(this,t,e)}getVisitFnByTypeId(t,e=!0){return bc(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 p2(n,t,e=!0){return typeof t=="number"?bc(n,t,e):typeof t=="string"&&t in Q?bc(n,Q[t],e):t&&t instanceof Re?bc(n,Cv(t),e):t!=null&&t.type&&t.type instanceof Re?bc(n,Cv(t.type),e):bc(n,Q.NONE,e)}function bc(n,t,e=!0){let r=null;switch(t){case Q.Null:r=n.visitNull;break;case Q.Bool:r=n.visitBool;break;case Q.Int:r=n.visitInt;break;case Q.Int8:r=n.visitInt8||n.visitInt;break;case Q.Int16:r=n.visitInt16||n.visitInt;break;case Q.Int32:r=n.visitInt32||n.visitInt;break;case Q.Int64:r=n.visitInt64||n.visitInt;break;case Q.Uint8:r=n.visitUint8||n.visitInt;break;case Q.Uint16:r=n.visitUint16||n.visitInt;break;case Q.Uint32:r=n.visitUint32||n.visitInt;break;case Q.Uint64:r=n.visitUint64||n.visitInt;break;case Q.Float:r=n.visitFloat;break;case Q.Float16:r=n.visitFloat16||n.visitFloat;break;case Q.Float32:r=n.visitFloat32||n.visitFloat;break;case Q.Float64:r=n.visitFloat64||n.visitFloat;break;case Q.Utf8:r=n.visitUtf8;break;case Q.Binary:r=n.visitBinary;break;case Q.FixedSizeBinary:r=n.visitFixedSizeBinary;break;case Q.Date:r=n.visitDate;break;case Q.DateDay:r=n.visitDateDay||n.visitDate;break;case Q.DateMillisecond:r=n.visitDateMillisecond||n.visitDate;break;case Q.Timestamp:r=n.visitTimestamp;break;case Q.TimestampSecond:r=n.visitTimestampSecond||n.visitTimestamp;break;case Q.TimestampMillisecond:r=n.visitTimestampMillisecond||n.visitTimestamp;break;case Q.TimestampMicrosecond:r=n.visitTimestampMicrosecond||n.visitTimestamp;break;case Q.TimestampNanosecond:r=n.visitTimestampNanosecond||n.visitTimestamp;break;case Q.Time:r=n.visitTime;break;case Q.TimeSecond:r=n.visitTimeSecond||n.visitTime;break;case Q.TimeMillisecond:r=n.visitTimeMillisecond||n.visitTime;break;case Q.TimeMicrosecond:r=n.visitTimeMicrosecond||n.visitTime;break;case Q.TimeNanosecond:r=n.visitTimeNanosecond||n.visitTime;break;case Q.Decimal:r=n.visitDecimal;break;case Q.List:r=n.visitList;break;case Q.Struct:r=n.visitStruct;break;case Q.Union:r=n.visitUnion;break;case Q.DenseUnion:r=n.visitDenseUnion||n.visitUnion;break;case Q.SparseUnion:r=n.visitSparseUnion||n.visitUnion;break;case Q.Dictionary:r=n.visitDictionary;break;case Q.Interval:r=n.visitInterval;break;case Q.IntervalDayTime:r=n.visitIntervalDayTime||n.visitInterval;break;case Q.IntervalYearMonth:r=n.visitIntervalYearMonth||n.visitInterval;break;case Q.FixedSizeList:r=n.visitFixedSizeList;break;case Q.Map:r=n.visitMap;break}if(typeof r=="function")return r;if(!e)return()=>null;throw new Error(`Unrecognized type '${Q[t]}'`)}function Cv(n){switch(n.typeId){case Q.Null:return Q.Null;case Q.Int:{const{bitWidth:t,isSigned:e}=n;switch(t){case 8:return e?Q.Int8:Q.Uint8;case 16:return e?Q.Int16:Q.Uint16;case 32:return e?Q.Int32:Q.Uint32;case 64:return e?Q.Int64:Q.Uint64}return Q.Int}case Q.Float:switch(n.precision){case Cr.HALF:return Q.Float16;case Cr.SINGLE:return Q.Float32;case Cr.DOUBLE:return Q.Float64}return Q.Float;case Q.Binary:return Q.Binary;case Q.Utf8:return Q.Utf8;case Q.Bool:return Q.Bool;case Q.Decimal:return Q.Decimal;case Q.Time:switch(n.unit){case wn.SECOND:return Q.TimeSecond;case wn.MILLISECOND:return Q.TimeMillisecond;case wn.MICROSECOND:return Q.TimeMicrosecond;case wn.NANOSECOND:return Q.TimeNanosecond}return Q.Time;case Q.Timestamp:switch(n.unit){case wn.SECOND:return Q.TimestampSecond;case wn.MILLISECOND:return Q.TimestampMillisecond;case wn.MICROSECOND:return Q.TimestampMicrosecond;case wn.NANOSECOND:return Q.TimestampNanosecond}return Q.Timestamp;case Q.Date:switch(n.unit){case sa.DAY:return Q.DateDay;case sa.MILLISECOND:return Q.DateMillisecond}return Q.Date;case Q.Interval:switch(n.unit){case Jo.DAY_TIME:return Q.IntervalDayTime;case Jo.YEAR_MONTH:return Q.IntervalYearMonth}return Q.Interval;case Q.Map:return Q.Map;case Q.List:return Q.List;case Q.Struct:return Q.Struct;case Q.Union:switch(n.mode){case ms.Dense:return Q.DenseUnion;case ms.Sparse:return Q.SparseUnion}return Q.Union;case Q.FixedSizeBinary:return Q.FixedSizeBinary;case Q.FixedSizeList:return Q.FixedSizeList;case Q.Dictionary:return Q.Dictionary}throw new Error(`Unrecognized type '${Q[n.typeId]}'`)}ln.prototype.visitInt8=null;ln.prototype.visitInt16=null;ln.prototype.visitInt32=null;ln.prototype.visitInt64=null;ln.prototype.visitUint8=null;ln.prototype.visitUint16=null;ln.prototype.visitUint32=null;ln.prototype.visitUint64=null;ln.prototype.visitFloat16=null;ln.prototype.visitFloat32=null;ln.prototype.visitFloat64=null;ln.prototype.visitDateDay=null;ln.prototype.visitDateMillisecond=null;ln.prototype.visitTimestampSecond=null;ln.prototype.visitTimestampMillisecond=null;ln.prototype.visitTimestampMicrosecond=null;ln.prototype.visitTimestampNanosecond=null;ln.prototype.visitTimeSecond=null;ln.prototype.visitTimeMillisecond=null;ln.prototype.visitTimeMicrosecond=null;ln.prototype.visitTimeNanosecond=null;ln.prototype.visitDenseUnion=null;ln.prototype.visitSparseUnion=null;ln.prototype.visitIntervalDayTime=null;ln.prototype.visitIntervalYearMonth=null;const dw=new Float64Array(1),yc=new Uint32Array(dw.buffer);function _w(n){const t=(n&31744)>>10,e=(n&1023)/1024,r=Math.pow(-1,(n&32768)>>15);switch(t){case 31:return r*(e?Number.NaN:1/0);case 0:return r*(e?6103515625e-14*e:0)}return r*Math.pow(2,t-15)*(1+e)}function pw(n){if(n!==n)return 32256;dw[0]=n;const t=(yc[1]&2147483648)>>16&65535;let e=yc[1]&2146435072,r=0;return e>=1089470464?yc[0]>0?e=31744:(e=(e&2080374784)>>16,r=(yc[1]&1048575)>>10):e<=1056964608?(r=1048576+(yc[1]&1048575),r=1048576+(r<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,r=(yc[1]&1048575)+512>>10),t|e|r&65535}class Ue extends ln{}function je(n){return(t,e,r)=>{if(t.setValid(e,r!=null))return n(t,e,r)}}const m2=(n,t,e)=>{n[t]=Math.trunc(e/864e5)},Fg=(n,t,e)=>{n[t]=Math.trunc(e%4294967296),n[t+1]=Math.trunc(e/4294967296)},g2=(n,t,e)=>{n[t]=Math.trunc(e*1e3%4294967296),n[t+1]=Math.trunc(e*1e3/4294967296)},y2=(n,t,e)=>{n[t]=Math.trunc(e*1e6%4294967296),n[t+1]=Math.trunc(e*1e6/4294967296)},mw=(n,t,e,r)=>{if(e+1{const s=n+e;r?t[s>>3]|=1<>3]&=~(1<{n[t]=e},Cg=({values:n},t,e)=>{n[t]=e},gw=({values:n},t,e)=>{n[t]=pw(e)},b2=(n,t,e)=>{switch(n.type.precision){case Cr.HALF:return gw(n,t,e);case Cr.SINGLE:case Cr.DOUBLE:return Cg(n,t,e)}},kg=({values:n},t,e)=>{m2(n,t,e.valueOf())},Pg=({values:n},t,e)=>{Fg(n,t*2,e.valueOf())},yw=({stride:n,values:t},e,r)=>{t.set(r.subarray(0,n),n*e)},w2=({values:n,valueOffsets:t},e,r)=>mw(n,t,e,r),x2=({values:n,valueOffsets:t},e,r)=>{mw(n,t,e,Up(r))},vw=(n,t,e)=>{n.type.unit===sa.DAY?kg(n,t,e):Pg(n,t,e)},zg=({values:n},t,e)=>Fg(n,t*2,e/1e3),Ug=({values:n},t,e)=>Fg(n,t*2,e),Gg=({values:n},t,e)=>g2(n,t*2,e),$g=({values:n},t,e)=>y2(n,t*2,e),bw=(n,t,e)=>{switch(n.type.unit){case wn.SECOND:return zg(n,t,e);case wn.MILLISECOND:return Ug(n,t,e);case wn.MICROSECOND:return Gg(n,t,e);case wn.NANOSECOND:return $g(n,t,e)}},Vg=({values:n},t,e)=>{n[t]=e},jg=({values:n},t,e)=>{n[t]=e},Wg=({values:n},t,e)=>{n[t]=e},Yg=({values:n},t,e)=>{n[t]=e},ww=(n,t,e)=>{switch(n.type.unit){case wn.SECOND:return Vg(n,t,e);case wn.MILLISECOND:return jg(n,t,e);case wn.MICROSECOND:return Wg(n,t,e);case wn.NANOSECOND:return Yg(n,t,e)}},xw=({values:n,stride:t},e,r)=>{n.set(r.subarray(0,t),t*e)},S2=(n,t,e)=>{const r=n.children[0],s=n.valueOffsets,o=Vi.getVisitFn(r);if(Array.isArray(e))for(let f=-1,c=s[t],l=s[t+1];c{const r=n.children[0],{valueOffsets:s}=n,o=Vi.getVisitFn(r);let{[t]:f,[t+1]:c}=s;const l=e instanceof Map?e.entries():Object.entries(e);for(const d of l)if(o(r,f,d),++f>=c)break},E2=(n,t)=>(e,r,s,o)=>r&&e(r,n,t[o]),T2=(n,t)=>(e,r,s,o)=>r&&e(r,n,t.get(o)),I2=(n,t)=>(e,r,s,o)=>r&&e(r,n,t.get(s.name)),O2=(n,t)=>(e,r,s,o)=>r&&e(r,n,t[s.name]),B2=(n,t,e)=>{const r=n.type.children.map(o=>Vi.getVisitFn(o.type)),s=e instanceof Map?I2(t,e):e instanceof Ie?T2(t,e):Array.isArray(e)?E2(t,e):O2(t,e);n.type.children.forEach((o,f)=>s(r[f],n.children[f],o,f))},L2=(n,t,e)=>{n.type.mode===ms.Dense?Sw(n,t,e):Aw(n,t,e)},Sw=(n,t,e)=>{const r=n.type.typeIdToChildIndex[n.typeIds[t]],s=n.children[r];Vi.visit(s,n.valueOffsets[t],e)},Aw=(n,t,e)=>{const r=n.type.typeIdToChildIndex[n.typeIds[t]],s=n.children[r];Vi.visit(s,t,e)},M2=(n,t,e)=>{var r;(r=n.dictionary)===null||r===void 0||r.set(n.values[t],e)},Ew=(n,t,e)=>{n.type.unit===Jo.DAY_TIME?Hg(n,t,e):Xg(n,t,e)},Hg=({values:n},t,e)=>{n.set(e.subarray(0,2),2*t)},Xg=({values:n},t,e)=>{n[t]=e[0]*12+e[1]%12},R2=(n,t,e)=>{const{stride:r}=n,s=n.children[0],o=Vi.getVisitFn(s);if(Array.isArray(e))for(let f=-1,c=t*r;++f`${_u(t)}: ${_u(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new N2(this[fs],this[Dc])}}class N2{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[fs].type.children.findIndex(r=>r.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[fs].type.children.findIndex(r=>r.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const r=t[fs].type.children.findIndex(s=>s.name===e);if(r!==-1){const s=ii.visit(t[fs].children[r],t[Dc]);return Reflect.set(t,e,s),s}}set(t,e,r){const s=t[fs].type.children.findIndex(o=>o.name===e);return s!==-1?(Vi.visit(t[fs].children[s],t[Dc],r),Reflect.set(t,e,r)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,r):!1}}class Fe extends ln{}function Ge(n){return(t,e)=>t.getValid(e)?n(t,e):null}const F2=(n,t)=>864e5*n[t],Zg=(n,t)=>4294967296*n[t+1]+(n[t]>>>0),C2=(n,t)=>4294967296*(n[t+1]/1e3)+(n[t]>>>0)/1e3,k2=(n,t)=>4294967296*(n[t+1]/1e6)+(n[t]>>>0)/1e6,Tw=n=>new Date(n),P2=(n,t)=>Tw(F2(n,t)),z2=(n,t)=>Tw(Zg(n,t)),U2=(n,t)=>null,Iw=(n,t,e)=>{if(e+1>=t.length)return null;const r=t[e],s=t[e+1];return n.subarray(r,s)},G2=({offset:n,values:t},e)=>{const r=n+e;return(t[r>>3]&1<P2(n,t),Bw=({values:n},t)=>z2(n,t*2),tf=({stride:n,values:t},e)=>t[n*e],$2=({stride:n,values:t},e)=>_w(t[n*e]),Lw=({values:n},t)=>n[t],V2=({stride:n,values:t},e)=>t.subarray(n*e,n*(e+1)),j2=({values:n,valueOffsets:t},e)=>Iw(n,t,e),W2=({values:n,valueOffsets:t},e)=>{const r=Iw(n,t,e);return r!==null?Y0(r):null},Y2=({values:n},t)=>n[t],H2=({type:n,values:t},e)=>n.precision!==Cr.HALF?t[e]:_w(t[e]),X2=(n,t)=>n.type.unit===sa.DAY?Ow(n,t):Bw(n,t),Mw=({values:n},t)=>1e3*Zg(n,t*2),Rw=({values:n},t)=>Zg(n,t*2),Nw=({values:n},t)=>C2(n,t*2),Dw=({values:n},t)=>k2(n,t*2),q2=(n,t)=>{switch(n.type.unit){case wn.SECOND:return Mw(n,t);case wn.MILLISECOND:return Rw(n,t);case wn.MICROSECOND:return Nw(n,t);case wn.NANOSECOND:return Dw(n,t)}},Fw=({values:n},t)=>n[t],Cw=({values:n},t)=>n[t],kw=({values:n},t)=>n[t],Pw=({values:n},t)=>n[t],Z2=(n,t)=>{switch(n.type.unit){case wn.SECOND:return Fw(n,t);case wn.MILLISECOND:return Cw(n,t);case wn.MICROSECOND:return kw(n,t);case wn.NANOSECOND:return Pw(n,t)}},K2=({values:n,stride:t},e)=>Bg.decimal(n.subarray(t*e,t*(e+1))),J2=(n,t)=>{const{valueOffsets:e,stride:r,children:s}=n,{[t*r]:o,[t*r+1]:f}=e,l=s[0].slice(o,f-o);return new Ie([l])},Q2=(n,t)=>{const{valueOffsets:e,children:r}=n,{[t]:s,[t+1]:o}=e,f=r[0];return new Vp(f.slice(s,o-s))},tO=(n,t)=>new qg(n,t),eO=(n,t)=>n.type.mode===ms.Dense?zw(n,t):Uw(n,t),zw=(n,t)=>{const e=n.type.typeIdToChildIndex[n.typeIds[t]],r=n.children[e];return ii.visit(r,n.valueOffsets[t])},Uw=(n,t)=>{const e=n.type.typeIdToChildIndex[n.typeIds[t]],r=n.children[e];return ii.visit(r,t)},nO=(n,t)=>{var e;return(e=n.dictionary)===null||e===void 0?void 0:e.get(n.values[t])},rO=(n,t)=>n.type.unit===Jo.DAY_TIME?Gw(n,t):$w(n,t),Gw=({values:n},t)=>n.subarray(2*t,2*(t+1)),$w=({values:n},t)=>{const e=n[t],r=new Int32Array(2);return r[0]=Math.trunc(e/12),r[1]=Math.trunc(e%12),r},iO=(n,t)=>{const{stride:e,children:r}=n,o=r[0].slice(t*e,e);return new Ie([o])};Fe.prototype.visitNull=Ge(U2);Fe.prototype.visitBool=Ge(G2);Fe.prototype.visitInt=Ge(Y2);Fe.prototype.visitInt8=Ge(tf);Fe.prototype.visitInt16=Ge(tf);Fe.prototype.visitInt32=Ge(tf);Fe.prototype.visitInt64=Ge(Lw);Fe.prototype.visitUint8=Ge(tf);Fe.prototype.visitUint16=Ge(tf);Fe.prototype.visitUint32=Ge(tf);Fe.prototype.visitUint64=Ge(Lw);Fe.prototype.visitFloat=Ge(H2);Fe.prototype.visitFloat16=Ge($2);Fe.prototype.visitFloat32=Ge(tf);Fe.prototype.visitFloat64=Ge(tf);Fe.prototype.visitUtf8=Ge(W2);Fe.prototype.visitBinary=Ge(j2);Fe.prototype.visitFixedSizeBinary=Ge(V2);Fe.prototype.visitDate=Ge(X2);Fe.prototype.visitDateDay=Ge(Ow);Fe.prototype.visitDateMillisecond=Ge(Bw);Fe.prototype.visitTimestamp=Ge(q2);Fe.prototype.visitTimestampSecond=Ge(Mw);Fe.prototype.visitTimestampMillisecond=Ge(Rw);Fe.prototype.visitTimestampMicrosecond=Ge(Nw);Fe.prototype.visitTimestampNanosecond=Ge(Dw);Fe.prototype.visitTime=Ge(Z2);Fe.prototype.visitTimeSecond=Ge(Fw);Fe.prototype.visitTimeMillisecond=Ge(Cw);Fe.prototype.visitTimeMicrosecond=Ge(kw);Fe.prototype.visitTimeNanosecond=Ge(Pw);Fe.prototype.visitDecimal=Ge(K2);Fe.prototype.visitList=Ge(J2);Fe.prototype.visitStruct=Ge(tO);Fe.prototype.visitUnion=Ge(eO);Fe.prototype.visitDenseUnion=Ge(zw);Fe.prototype.visitSparseUnion=Ge(Uw);Fe.prototype.visitDictionary=Ge(nO);Fe.prototype.visitInterval=Ge(rO);Fe.prototype.visitIntervalDayTime=Ge(Gw);Fe.prototype.visitIntervalYearMonth=Ge($w);Fe.prototype.visitFixedSizeList=Ge(iO);Fe.prototype.visitMap=Ge(Q2);const ii=new Fe,ds=Symbol.for("keys"),Fc=Symbol.for("vals");class Vp{constructor(t){return this[ds]=new Ie([t.children[0]]).memoize(),this[Fc]=t.children[1],new Proxy(this,new aO)}[Symbol.iterator](){return new sO(this[ds],this[Fc])}get size(){return this[ds].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[ds],e=this[Fc],r={};for(let s=-1,o=t.length;++s`${_u(t)}: ${_u(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class sO{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ii.visit(this.vals,t)]})}}class aO{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ds].toArray().map(String)}has(t,e){return t[ds].includes(e)}getOwnPropertyDescriptor(t,e){if(t[ds].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const r=t[ds].indexOf(e);if(r!==-1){const s=ii.visit(Reflect.get(t,Fc),r);return Reflect.set(t,e,s),s}}set(t,e,r){const s=t[ds].indexOf(e);return s!==-1?(Vi.visit(Reflect.get(t,Fc),s,r),Reflect.set(t,e,r)):Reflect.has(t,e)?Reflect.set(t,e,r):!1}}Object.defineProperties(Vp.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ds]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Fc]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let kv;function Vw(n,t,e,r){const{length:s=0}=n;let o=typeof t!="number"?0:t,f=typeof e!="number"?s:e;return o<0&&(o=(o%s+s)%s),f<0&&(f=(f%s+s)%s),fs&&(f=s),r?r(n,o,f):[o,f]}const Pv=n=>n!==n;function rl(n){if(typeof n!=="object"||n===null)return Pv(n)?Pv:e=>e===n;if(n instanceof Date){const e=n.valueOf();return r=>r instanceof Date?r.valueOf()===e:!1}return ArrayBuffer.isView(n)?e=>e?i2(n,e):!1:n instanceof Map?fO(n):Array.isArray(n)?oO(n):n instanceof Ie?uO(n):cO(n,!0)}function oO(n){const t=[];for(let e=-1,r=n.length;++e!1;const r=[];for(let s=-1,o=e.length;++s{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return lO(n,e);case Map:return zv(n,e,e.keys());case Vp:case qg:case Object:case void 0:return zv(n,e,t||Object.keys(e))}return e instanceof Ie?hO(n,e):!1}}function lO(n,t){const e=n.length;if(t.length!==e)return!1;for(let r=-1;++r>r}function _O(n,t,e){const r=e.byteLength+7&-8;if(n>0||e.byteLength>3):q0(new Kg(e,n,t,null,jw)).subarray(0,r)),s}return e}function q0(n){const t=[];let e=0,r=0,s=0;for(const f of n)f&&(s|=1<0)&&(t[e++]=s);const o=new Uint8Array(t.length+7&-8);return o.set(t),o}class Kg{constructor(t,e,r,s,o){this.bytes=t,this.length=r,this.context=s,this.get=o,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,s=t+(t%8===0?0:8-t%8);return Z0(n,t,s)+Z0(n,r,e)+pO(n,s>>3,r-s>>3)}function pO(n,t,e){let r=0,s=Math.trunc(t);const o=new DataView(n.buffer,n.byteOffset,n.byteLength),f=e===void 0?n.byteLength:s+e;for(;f-s>=4;)r+=l0(o.getUint32(s)),s+=4;for(;f-s>=2;)r+=l0(o.getUint16(s)),s+=2;for(;f-s>=1;)r+=l0(o.getUint8(s)),s+=1;return r}function l0(n){let t=Math.trunc(n);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const mO=-1;class On{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:r,nullBitmap:s,typeIds:o}=this;return e&&(t+=e.byteLength),r&&(t+=r.byteLength),s&&(t+=s.byteLength),o&&(t+=o.byteLength),this.children.reduce((f,c)=>f+c.byteLength,t)}get nullCount(){let t=this._nullCount,e;return t<=mO&&(e=this.nullBitmap)&&(this._nullCount=t=this.length-Z0(e,this.offset,this.offset+this.length)),t}constructor(t,e,r,s,o,f=[],c){this.type=t,this.children=f,this.dictionary=c,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(s||0,-1));let l;o instanceof On?(this.stride=o.stride,this.values=o.values,this.typeIds=o.typeIds,this.nullBitmap=o.nullBitmap,this.valueOffsets=o.valueOffsets):(this.stride=Ws(t),o&&((l=o[0])&&(this.valueOffsets=l),(l=o[1])&&(this.values=l),(l=o[2])&&(this.nullBitmap=l),(l=o[3])&&(this.typeIds=l))),this.nullable=this._nullCount!==0&&this.nullBitmap&&this.nullBitmap.byteLength>0}getValid(t){if(this.nullable&&this.nullCount>0){const e=this.offset+t;return(this.nullBitmap[e>>3]&1<>3){const{nullBitmap:l}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:l,_nullCount:0})}const{nullBitmap:r,offset:s}=this,o=s+t>>3,f=(s+t)%8,c=r[o]>>f&1;return e?c===0&&(r[o]|=1<>3).fill(255,0,e>>3);s[e>>3]=(1<0&&s.set(_O(this.offset,e,this.nullBitmap),0);const o=this.buffers;return o[qa.VALIDITY]=s,this.clone(this.type,0,t,r+(t-e),o)}_sliceBuffers(t,e,r,s){let o;const{buffers:f}=this;return(o=f[qa.TYPE])&&(f[qa.TYPE]=o.subarray(t,t+e)),(o=f[qa.OFFSET])&&(f[qa.OFFSET]=o.subarray(t,t+e+1))||(o=f[qa.DATA])&&(f[qa.DATA]=s===6?o:o.subarray(r*t,r*(t+e))),f}_sliceChildren(t,e,r){return t.map(s=>s.slice(e,r))}}On.prototype.children=Object.freeze([]);class Uh extends ln{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:r=0,["length"]:s=0}=t;return new On(e,r,s,0)}visitBool(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitInt(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitFloat(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitUtf8(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.data),o=bn(t.nullBitmap),f=Oh(t.valueOffsets),{["length"]:c=f.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(e,r,c,l,[f,s,o])}visitBinary(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.data),o=bn(t.nullBitmap),f=Oh(t.valueOffsets),{["length"]:c=f.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(e,r,c,l,[f,s,o])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitDate(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitTimestamp(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitTime(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitDecimal(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitList(t){const{["type"]:e,["offset"]:r=0,["child"]:s}=t,o=bn(t.nullBitmap),f=Oh(t.valueOffsets),{["length"]:c=f.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(e,r,c,l,[f,void 0,o],[s])}visitStruct(t){const{["type"]:e,["offset"]:r=0,["children"]:s=[]}=t,o=bn(t.nullBitmap),{length:f=s.reduce((l,{length:d})=>Math.max(l,d),0),nullCount:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,void 0,o],s)}visitUnion(t){const{["type"]:e,["offset"]:r=0,["children"]:s=[]}=t,o=bn(t.nullBitmap),f=Mn(e.ArrayType,t.typeIds),{["length"]:c=f.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;if(Re.isSparseUnion(e))return new On(e,r,c,l,[void 0,void 0,o,f],s);const d=Oh(t.valueOffsets);return new On(e,r,c,l,[d,void 0,o,f],s)}visitDictionary(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.indices.ArrayType,t.data),{["dictionary"]:f=new Ie([new Uh().visit({type:e.dictionary})])}=t,{["length"]:c=o.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(e,r,c,l,[void 0,o,s],[],f)}visitInterval(t){const{["type"]:e,["offset"]:r=0}=t,s=bn(t.nullBitmap),o=Mn(e.ArrayType,t.data),{["length"]:f=o.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,o,s])}visitFixedSizeList(t){const{["type"]:e,["offset"]:r=0,["child"]:s=new Uh().visit({type:e.valueType})}=t,o=bn(t.nullBitmap),{["length"]:f=s.length/Ws(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new On(e,r,f,c,[void 0,void 0,o],[s])}visitMap(t){const{["type"]:e,["offset"]:r=0,["child"]:s=new Uh().visit({type:e.childType})}=t,o=bn(t.nullBitmap),f=Oh(t.valueOffsets),{["length"]:c=f.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(e,r,c,l,[f,void 0,o],[s])}}function Te(n){return new Uh().visit(n)}class Uv{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext+e.nullCount,0)}function Yw(n){return n.reduce((t,e,r)=>(t[r+1]=t[r]+e.length,t),new Uint32Array(n.length+1))}function Hw(n,t,e,r){const s=[];for(let o=-1,f=n.length;++o=r)break;if(e>=l+d)continue;if(l>=e&&l+d<=r){s.push(c);continue}const p=Math.max(0,e-l),w=Math.min(r-l,d);s.push(c.slice(p,w-p))}return s.length===0&&s.push(n[0].slice(0,0)),s}function Jg(n,t,e,r){let s=0,o=0,f=t.length-1;do{if(s>=f-1)return e0?0:-1}function yO(n,t){const{nullBitmap:e}=n;if(!e||n.nullCount<=0)return-1;let r=0;for(const s of new Kg(e,n.offset+(t||0),n.length,e,jw)){if(!s)return r;++r}return-1}function Qe(n,t,e){if(t===void 0)return-1;if(t===null)return yO(n,e);const r=ii.getVisitFn(n),s=rl(t);for(let o=(e||0)-1,f=n.length;++o{const s=n.data[r];return s.values.subarray(0,s.length)[Symbol.iterator]()});let e=0;return new Uv(n.data.length,r=>{const o=n.data[r].length,f=n.slice(e,e+o);return e+=o,new vO(f)})}class vO{constructor(t){this.vector=t,this.index=0}next(){return this.indexn+t;class ef extends ln{visitNull(t,e){return 0}visitInt(t,e){return t.type.bitWidth/8}visitFloat(t,e){return t.type.ArrayType.BYTES_PER_ELEMENT}visitBool(t,e){return 1/8}visitDecimal(t,e){return t.type.bitWidth/8}visitDate(t,e){return(t.type.unit+1)*4}visitTime(t,e){return t.type.bitWidth/8}visitTimestamp(t,e){return t.type.unit===wn.SECOND?4:8}visitInterval(t,e){return(t.type.unit+1)*4}visitStruct(t,e){return t.children.reduce((r,s)=>r+aa.visit(s,e),0)}visitFixedSizeBinary(t,e){return t.type.byteWidth}visitMap(t,e){return 8+t.children.reduce((r,s)=>r+aa.visit(s,e),0)}visitDictionary(t,e){var r;return t.type.indices.bitWidth/8+(((r=t.dictionary)===null||r===void 0?void 0:r.getByteLength(t.values[e]))||0)}}const wO=({valueOffsets:n},t)=>8+(n[t+1]-n[t]),xO=({valueOffsets:n},t)=>8+(n[t+1]-n[t]),SO=({valueOffsets:n,stride:t,children:e},r)=>{const s=e[0],{[r*t]:o}=n,{[r*t+1]:f}=n,c=aa.getVisitFn(s.type),l=s.slice(o,f-o);let d=8;for(let p=-1,w=f-o;++p{const r=t[0],s=r.slice(e*n,n),o=aa.getVisitFn(r.type);let f=0;for(let c=-1,l=s.length;++cn.type.mode===ms.Dense?Kw(n,t):Jw(n,t),Kw=({type:n,children:t,typeIds:e,valueOffsets:r},s)=>{const o=n.typeIdToChildIndex[e[s]];return 8+aa.visit(t[o],r[s])},Jw=({children:n},t)=>4+aa.visitMany(n,n.map(()=>t)).reduce(bO,0);ef.prototype.visitUtf8=wO;ef.prototype.visitBinary=xO;ef.prototype.visitList=SO;ef.prototype.visitFixedSizeList=AO;ef.prototype.visitUnion=EO;ef.prototype.visitDenseUnion=Kw;ef.prototype.visitSparseUnion=Jw;const aa=new ef;var Qw;const tx={},ex={};class Ie{constructor(t){var e,r,s;const o=t[0]instanceof Ie?t.flatMap(c=>c.data):t;if(o.length===0||o.some(c=>!(c instanceof On)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(e=o[0])===null||e===void 0?void 0:e.type;switch(o.length){case 0:this._offsets=[0];break;case 1:{const{get:c,set:l,indexOf:d,byteLength:p}=tx[f.typeId],w=o[0];this.isValid=I=>Qg(w,I),this.get=I=>c(w,I),this.set=(I,C)=>l(w,I,C),this.indexOf=I=>d(w,I),this.getByteLength=I=>p(w,I),this._offsets=[0,w.length];break}default:Object.setPrototypeOf(this,ex[f.typeId]),this._offsets=Yw(o);break}this.data=o,this.type=f,this.stride=Ws(f),this.numChildren=(s=(r=f.children)===null||r===void 0?void 0:r.length)!==null&&s!==void 0?s:0,this.length=this._offsets.at(-1)}get byteLength(){return this._byteLength===-1&&(this._byteLength=this.data.reduce((t,e)=>t+e.byteLength,0)),this._byteLength}get nullCount(){return this._nullCount===-1&&(this._nullCount=Ww(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${Q[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>0}getByteLength(t){return 0}[Symbol.iterator](){return ty.visit(this)}concat(...t){return new Ie(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Ie(Vw(this,t,e,({data:r,_offsets:s},o,f)=>Hw(r,s,o,f)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:r,stride:s,ArrayType:o}=this;switch(t.typeId){case Q.Int:case Q.Float:case Q.Decimal:case Q.Time:case Q.Timestamp:switch(e.length){case 0:return new o;case 1:return e[0].values.subarray(0,r*s);default:return e.reduce((f,{values:c,length:l})=>(f.array.set(c.subarray(0,l*s),f.offset),f.offset+=l*s,f),{array:new o(r*s),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return Re.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(Re.isDictionary(this.type)){const t=new lp(this.data[0].dictionary),e=this.data.map(r=>{const s=r.clone();return s.dictionary=t,s});return new Ie(e)}return new lp(this)}unmemoize(){if(Re.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(r=>{const s=r.clone();return s.dictionary=t,s});return new Ie(e)}return this}}Qw=Symbol.toStringTag;Ie[Qw]=(n=>{n.type=Re.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._nullCount=-1,n._byteLength=-1,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const t=Object.keys(Q).map(e=>Q[e]).filter(e=>typeof e=="number"&&e!==Q.NONE);for(const e of t){const r=ii.getVisitFnByTypeId(e),s=Vi.getVisitFnByTypeId(e),o=cp.getVisitFnByTypeId(e),f=aa.getVisitFnByTypeId(e);tx[e]={get:r,set:s,indexOf:o,byteLength:f},ex[e]=Object.create(n,{isValid:{value:Cc(Qg)},get:{value:Cc(ii.getVisitFnByTypeId(e))},set:{value:Xw(Vi.getVisitFnByTypeId(e))},indexOf:{value:qw(cp.getVisitFnByTypeId(e))},getByteLength:{value:Cc(aa.getVisitFnByTypeId(e))}})}return"Vector"})(Ie.prototype);class lp extends Ie{constructor(t){super(t.data);const e=this.get,r=this.set,s=this.slice,o=new Array(this.length);Object.defineProperty(this,"get",{value(f){const c=o[f];if(c!==void 0)return c;const l=e.call(this,f);return o[f]=l,l}}),Object.defineProperty(this,"set",{value(f,c){r.call(this,f,c),o[f]=c}}),Object.defineProperty(this,"slice",{value:(f,c)=>new lp(s.call(this,f,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ie(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}function kc(n){if(n){if(n instanceof On)return new Ie([n]);if(n instanceof Ie)return new Ie(n.data);if(n.type instanceof Re)return new Ie([Te(n)]);if(Array.isArray(n))return new Ie(n.flatMap(t=>TO(t)));if(ArrayBuffer.isView(n)){n instanceof DataView&&(n=new Uint8Array(n.buffer));const t={offset:0,length:n.length,nullCount:0,data:n};if(n instanceof Int8Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Lg}))]);if(n instanceof Int16Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Mg}))]);if(n instanceof Int32Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Qo}))]);if(n instanceof BigInt64Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new $p}))]);if(n instanceof Uint8Array||n instanceof Uint8ClampedArray)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Rg}))]);if(n instanceof Uint16Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new cw}))]);if(n instanceof Uint32Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new lw}))]);if(n instanceof BigUint64Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new hw}))]);if(n instanceof Float32Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Ng}))]);if(n instanceof Float64Array)return new Ie([Te(Object.assign(Object.assign({},t),{type:new Dg}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function TO(n){return n instanceof On?[n]:n instanceof Ie?n.data:kc(n).data}function IO(n){if(!n||n.length<=0)return function(s){return!0};let t="";const e=n.filter(r=>r===r);return e.length>0&&(t=` switch (x) {${e.map(r=>` case ${OO(r)}:`).join("")} return false; }`),n.length!==e.length&&(t=`if (x !== x) return false; ${t}`),new Function("x",`${t} return true;`)}function OO(n){return typeof n!="bigint"?_u(n):`${_u(n)}n`}const h0=(n,t)=>(Math.ceil(n)*t+63&-64||64)/t,BO=(n,t=0)=>n.length>=t?n.subarray(0,t):ip(new n.constructor(t),n,0);class Wp{constructor(t,e=1){this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=Math.ceil(t.length/e))}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;const e=this.stride,r=this.length*e,s=this.buffer.length;r>=s&&this._resize(s===0?h0(r*1,this.BYTES_PER_ELEMENT):h0(r*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=h0(t*this.stride,this.BYTES_PER_ELEMENT);const e=BO(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this._resize(0),this}_resize(t){return this.buffer=ip(new this.ArrayType(t),this.buffer)}}Wp.prototype.offset=0;class od extends Wp{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}}class nx extends od{constructor(t=new Uint8Array(0)){super(t,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){const{buffer:r}=this.reserve(t-this.length+1),s=t>>3,o=t%8,f=r[s]>>o&1;return e?f===0&&(r[s]|=1<this.length&&this.set(t-1,0),super.flush(t+1)}}let si=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=Ws(t),this._nulls=new nx,e&&e.length>0&&(this._isValid=IO(e))}toVector(){return new Ie([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0;const{_offsets:e,_values:r,_nulls:s,_typeIds:o,children:f}=this;return e&&(t+=e.byteLength),r&&(t+=r.byteLength),s&&(t+=s.byteLength),o&&(t+=o.byteLength),f.reduce((c,l)=>c+l.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,r)=>e+r.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,r,s;const{type:o,length:f,nullCount:c,_typeIds:l,_offsets:d,_values:p,_nulls:w}=this;(e=l==null?void 0:l.flush(f))?s=d==null?void 0:d.flush(f):(s=d==null?void 0:d.flush(f))?t=p==null?void 0:p.flush(d.last()):t=p==null?void 0:p.flush(f),c>0&&(r=w==null?void 0:w.flush(f));const I=this.children.map(C=>C.flush());return this.clear(),Te({type:o,length:f,nullCount:c,children:I,child:I[0],data:t,typeIds:e,nullBitmap:r,valueOffsets:s})}finish(){this.finished=!0;for(const t of this.children)t.finish();return this}clear(){var t,e,r,s;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(s=this._typeIds)===null||s===void 0||s.clear();for(const o of this.children)o.clear();return this}};si.prototype.length=1;si.prototype.stride=1;si.prototype.children=null;si.prototype.finished=!1;si.prototype.nullValues=null;si.prototype._isValid=()=>!0;class nf extends si{constructor(t){super(t),this._values=new od(new this.ArrayType(0),this.stride)}setValue(t,e){const r=this._values;return r.reserve(t-r.length+1),super.setValue(t,e)}}class Yp extends si{constructor(t){super(t),this._pendingLength=0,this._offsets=new rx}setValue(t,e){const r=this._pending||(this._pending=new Map),s=r.get(t);s&&(this._pendingLength-=s.length),this._pendingLength+=e instanceof Vp?e[ds].length:e.length,r.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){const t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}class K0{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,r,s){return t.prep(8,24),t.writeInt64(BigInt(s??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(e??0)),t.offset()}}const d0=2,qs=4,Ka=4,Nn=4,qo=new Int32Array(2),Gv=new Float32Array(qo.buffer),$v=new Float64Array(qo.buffer),b_=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var J0;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(J0||(J0={}));let Xc=class ix{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new ix(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Gv[0]=e,this.writeInt32(t,qo[0])}writeFloat64(t,e){$v[0]=e,this.writeInt32(t,qo[b_?0:1]),this.writeInt32(t+4,qo[b_?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);const r=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const s=2;this.addInt16(t-this.object_start);const o=(r+s)*d0;this.addInt16(o);let f=0;const c=this.space;t:for(e=0;e=0;f--)this.writeInt8(o.charCodeAt(f))}this.prep(this.minalign,qs+s),this.addOffset(t),s&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const r=this.bb.capacity()-t,s=r-this.bb.readInt32(r);if(!(e=0;r--)t.addInt32(e[r]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,r){return ri.startUnion(t),ri.addMode(t,e),ri.addTypeIds(t,r),ri.endUnion(t)}}class su{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 su).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+Nn),(e||new su).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return su.startUtf8(t),su.endUtf8(t)}}var Xn;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Xn||(Xn={}));let Fi=class R_{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 R_).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+Nn),(e||new R_).__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):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Xn.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 Ja).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const r=this.bb.__offset(this.bb_pos,14);return r?(e||new R_).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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 r=this.bb.__offset(this.bb_pos,16);return r?(e||new gr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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,Xn.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},Vs=class Ha{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 Ha).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+Nn),(e||new Ha).__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):Zc.Little}fields(t,e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new Fi).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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 r=this.bb.__offset(this.bb_pos,8);return r?(e||new gr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,Zc.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);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 r=e.length-1;r>=0;r--)t.addInt64(e[r]);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,r,s,o){return Ha.startSchema(t),Ha.addEndianness(t,e),Ha.addFields(t,r),Ha.addCustomMetadata(t,s),Ha.addFeatures(t,o),Ha.endSchema(t)}};class wi{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 wi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+Nn),(e||new wi).__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):qc.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Vs).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const r=this.bb.__offset(this.bb_pos,8);return r?(e||new K0).__init(this.bb.__vector(this.bb_pos+r)+t*24,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 r=this.bb.__offset(this.bb_pos,10);return r?(e||new K0).__init(this.bb.__vector(this.bb_pos+r)+t*24,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 r=this.bb.__offset(this.bb_pos,12);return r?(e||new gr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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,qc.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 r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}class An{constructor(t=[],e,r){this.fields=t||[],this.metadata=e||new Map,r||(r=Q0(t)),this.dictionaries=r}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){const e=new Set(t),r=this.fields.filter(s=>e.has(s.name));return new An(r,this.metadata)}selectAt(t){const e=t.map(r=>this.fields[r]).filter(Boolean);return new An(e,this.metadata)}assign(...t){const e=t[0]instanceof An?t[0]:Array.isArray(t[0])?new An(t[0]):new An(t),r=[...this.fields],s=w_(w_(new Map,this.metadata),e.metadata),o=e.fields.filter(c=>{const l=r.findIndex(d=>d.name===c.name);return~l?(r[l]=c.clone({metadata:w_(w_(new Map,r[l].metadata),c.metadata)}))&&!1:!0}),f=Q0(o,new Map);return new An([...r,...o],s,new Map([...this.dictionaries,...f]))}}An.prototype.fields=null;An.prototype.metadata=null;An.prototype.dictionaries=null;class gn{static new(...t){let[e,r,s,o]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],r===void 0&&(r=t[0].type),s===void 0&&(s=t[0].nullable),o===void 0&&(o=t[0].metadata)),new gn(`${e}`,r,s,o)}constructor(t,e,r=!1,s){this.name=t,this.type=e,this.nullable=r,this.metadata=s||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,r,s,o]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,r=this.type,s=this.nullable,o=this.metadata]=t:{name:e=this.name,type:r=this.type,nullable:s=this.nullable,metadata:o=this.metadata}=t[0],gn.new(e,r,s,o)}}gn.prototype.type=null;gn.prototype.name=null;gn.prototype.nullable=null;gn.prototype.metadata=null;function w_(n,t){return new Map([...n||new Map,...t||new Map])}function Q0(n,t=new Map){for(let e=-1,r=n.length;++e0&&Q0(o.children,t)}return t}var LO=sx,MO=Xc;class ey{static decode(t){t=new MO(bn(t));const e=wi.getRootAsFooter(t),r=An.decode(e.schema());return new RO(r,e)}static encode(t){const e=new LO,r=An.encode(e,t.schema);wi.startRecordBatchesVector(e,t.numRecordBatches);for(const f of[...t.recordBatches()].slice().reverse())Jc.encode(e,f);const s=e.endVector();wi.startDictionariesVector(e,t.numDictionaries);for(const f of[...t.dictionaryBatches()].slice().reverse())Jc.encode(e,f);const o=e.endVector();return wi.startFooter(e),wi.addSchema(e,r),wi.addVersion(e,Ui.V4),wi.addRecordBatches(e,s),wi.addDictionaries(e,o),wi.finishFooterBuffer(e,wi.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=Ui.V4,r,s){this.schema=t,this.version=e,r&&(this._recordBatches=r),s&&(this._dictionaryBatches=s)}*recordBatches(){for(let t,e=-1,r=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Ne(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(qn);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Ci.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Ci.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Ne(this,void 0,void 0,function*(){return yield this.abort(t),qn})}return(t){return Ne(this,void 0,void 0,function*(){return yield this.close(),qn})}read(t){return Ne(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ne(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((e,r)=>{this.resolvers.push({resolve:e,reject:r})}):Promise.resolve(qn)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class DO extends NO{write(t){if((t=bn(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Y0(this.toUint8Array(!0)):this.toUint8Array(!1).then(Y0)}toUint8Array(t=!1){return t?ia(this._values)[0]:Ne(this,void 0,void 0,function*(){var e,r,s,o;const f=[];let c=0;try{for(var l=!0,d=Mc(this),p;p=yield d.next(),e=p.done,!e;l=!0){o=p.value,l=!1;const w=o;f.push(w),c+=w.byteLength}}catch(w){r={error:w}}finally{try{!l&&!e&&(s=d.return)&&(yield s.call(d))}finally{if(r)throw r.error}}return ia(f,c)[0]})}}class gp{constructor(t){t&&(this.source=new FO(Ci.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 Qc{constructor(t){t instanceof Qc?this.source=t.source:t instanceof DO?this.source=new Jf(Ci.fromAsyncIterable(t)):$1(t)?this.source=new Jf(Ci.fromNodeStream(t)):Ig(t)?this.source=new Jf(Ci.fromDOMStream(t)):U1(t)?this.source=new Jf(Ci.fromDOMStream(t.body)):Gp(t)?this.source=new Jf(Ci.fromIterable(t)):Zh(t)?this.source=new Jf(Ci.fromAsyncIterable(t)):Tg(t)&&(this.source=new Jf(Ci.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 FO{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)||qn)}return(t){return Object.create(this.source.return&&this.source.return(t)||qn)}}class Jf{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return Ne(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Ne(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ne(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t,e="read"){return Ne(this,void 0,void 0,function*(){return yield this.source.next({cmd:e,size:t})})}throw(t){return Ne(this,void 0,void 0,function*(){const e=this.source.throw&&(yield this.source.throw(t))||qn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return Ne(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||qn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class jv extends gp{constructor(t,e){super(),this.position=0,this.buffer=bn(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:r}=this.readAt(t,4);return new DataView(e,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let s=e[3]*r[3];this.buffer[0]=s&65535;let o=s>>>16;return s=e[2]*r[3],o+=s,s=e[3]*r[2]>>>0,o+=s,this.buffer[0]+=o<<16,this.buffer[1]=o>>>0>>16,this.buffer[1]+=e[1]*r[3]+e[2]*r[2]+e[3]*r[1],this.buffer[1]+=e[0]*r[3]+e[1]*r[2]+e[2]*r[1]+e[3]*r[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`${Ec(this.buffer[3])} ${Ec(this.buffer[2])} ${Ec(this.buffer[1])} ${Ec(this.buffer[0])}`}static multiply(t,e){return new js(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new js(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return js.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return js.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const r=t.startsWith("-"),s=t.length,o=new js(e);for(let f=r?1:0;f0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class kO extends ux{constructor(t,e,r,s){super(new Uint8Array(0),e,r,s),this.sources=t}readNullBitmap(t,e,{offset:r}=this.nextBufferRange()){return e<=0?new Uint8Array(0):q0(this.sources[r])}readOffsets(t,{offset:e}=this.nextBufferRange()){return Mn(Uint8Array,Mn(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return Mn(Uint8Array,Mn(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:r}=this;return Re.isTimestamp(t)||(Re.isInt(t)||Re.isTime(t))&&t.bitWidth===64||Re.isDate(t)&&t.unit===sa.MILLISECOND?Mn(Uint8Array,ei.convertArray(r[e])):Re.isDecimal(t)?Mn(Uint8Array,js.convertArray(r[e])):Re.isBinary(t)||Re.isFixedSizeBinary(t)?PO(r[e]):Re.isBool(t)?q0(r[e]):Re.isUtf8(t)?Up(r[e].join("")):Mn(Uint8Array,Mn(t.ArrayType,r[e].map(s=>+s)))}}function PO(n){const t=n.join(""),e=new Uint8Array(t.length/2);for(let r=0;r>1]=Number.parseInt(t.slice(r,r+2),16);return e}class cx extends Yp{constructor(t){super(t),this._values=new Wp(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,bn(e))}_flushPending(t,e){const r=this._offsets,s=this._values.reserve(e).buffer;let o=0;for(const[f,c]of t)if(c===void 0)r.set(f,0);else{const l=c.length;s.set(c,o),r.set(f,l),o+=l}}}class zO extends si{constructor(t){super(t),this._values=new nx}setValue(t,e){this._values.set(t,+e)}}class Hp extends nf{}Hp.prototype._setValue=vw;class lx extends Hp{}lx.prototype._setValue=kg;class hx extends Hp{}hx.prototype._setValue=Pg;class dx extends nf{}dx.prototype._setValue=xw;class UO extends si{constructor({type:t,nullValues:e,dictionaryHashFunction:r}){super({type:new so(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=vp({type:this.type.indices,nullValues:e}),this.dictionary=vp({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){const r=this.indices;return e=r.setValid(t,e),this.length=r.length,e}setValue(t,e){const r=this._keysToIndices,s=this.valueToKey(e);let o=r[s];return o===void 0&&(r[s]=o=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,o)}flush(){const t=this.type,e=this._dictionary,r=this.dictionary.toVector(),s=this.indices.flush().clone(t);return s.dictionary=e?e.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=s.dictionary,this.clear(),s}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}}class _x extends nf{}_x.prototype._setValue=yw;class GO extends si{setValue(t,e){const[r]=this.children,s=t*this.stride;for(let o=-1,f=e.length;++o0)throw new Error("FixedSizeListBuilder can only have one child.");const r=this.children.push(t);return this.type=new nd(this.type.listSize,new gn(e,t.type,!0)),r}}class Xp extends nf{setValue(t,e){this._values.set(t,e)}}class $O extends Xp{setValue(t,e){super.setValue(t,pw(e))}}class VO extends Xp{}class jO extends Xp{}class qp extends nf{}qp.prototype._setValue=Ew;class px extends qp{}px.prototype._setValue=Hg;class mx extends qp{}mx.prototype._setValue=Xg;class uo extends nf{setValue(t,e){this._values.set(t,e)}}class WO extends uo{}class YO extends uo{}class HO extends uo{}class XO extends uo{}class qO extends uo{}class ZO extends uo{}class KO extends uo{}class JO extends uo{}class QO extends Yp{constructor(t){super(t),this._offsets=new rx}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Hc(new gn(e,t.type,!0)),this.numChildren-1}_flushPending(t){const e=this._offsets,[r]=this.children;for(const[s,o]of t)if(typeof o>"u")e.set(s,0);else{const f=o,c=f.length,l=e.set(s,c).buffer[s];for(let d=-1;++d0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new rd(new gn(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){const e=this._offsets,[r]=this.children;for(const[s,o]of t)if(o===void 0)e.set(s,0);else{let{[s]:f,[s+1]:c}=e.set(s,o.size).buffer;for(const l of o.entries())if(r.set(f,l),++f>=c)break}}}class e7 extends si{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}class n7 extends si{setValue(t,e){const{children:r,type:s}=this;switch(Array.isArray(e)||e.constructor){case!0:return s.children.forEach((o,f)=>r[f].set(t,e[f]));case Map:return s.children.forEach((o,f)=>r[f].set(t,e.get(o.name)));default:return s.children.forEach((o,f)=>r[f].set(t,e[o.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(r=>r.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){const r=this.children.push(t);return this.type=new Mr([...this.type.children,new gn(e,t.type,!0)]),r}}class il extends nf{}il.prototype._setValue=bw;class gx extends il{}gx.prototype._setValue=zg;class yx extends il{}yx.prototype._setValue=Ug;class vx extends il{}vx.prototype._setValue=Gg;class bx extends il{}bx.prototype._setValue=$g;class sl extends nf{}sl.prototype._setValue=ww;class wx extends sl{}wx.prototype._setValue=Vg;class xx extends sl{}xx.prototype._setValue=jg;class Sx extends sl{}Sx.prototype._setValue=Wg;class Ax extends sl{}Ax.prototype._setValue=Yg;class ry extends si{constructor(t){super(t),this._typeIds=new od(new Int8Array(0),1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,r){return r===void 0&&(r=this._valueToChildTypeId(this,e,t)),this.setValid(t,this.isValid(e))&&this.setValue(t,e,r),this}setValue(t,e,r){this._typeIds.set(t,r);const s=this.type.typeIdToChildIndex[r],o=this.children[s];o==null||o.set(t,e)}addChild(t,e=`${this.children.length}`){const r=this.children.push(t),{type:{children:s,mode:o,typeIds:f}}=this,c=[...s,new gn(e,t.type)];return this.type=new ed(o,[...f,r],c),r}_valueToChildTypeId(t,e,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}}class r7 extends ry{}class i7 extends ry{constructor(t){super(t),this._offsets=new od(new Int32Array(0))}setValue(t,e,r){const s=this._typeIds.set(t,r).buffer[t],o=this.getChildAt(this.type.typeIdToChildIndex[s]),f=this._offsets.set(t,o.length).buffer[t];o==null||o.set(f,e)}}class Ex extends Yp{constructor(t){super(t),this._values=new Wp(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Up(e))}_flushPending(t,e){}}Ex.prototype._flushPending=cx.prototype._flushPending;class s7 extends ln{visitNull(){return e7}visitBool(){return zO}visitInt(){return uo}visitInt8(){return WO}visitInt16(){return YO}visitInt32(){return HO}visitInt64(){return XO}visitUint8(){return qO}visitUint16(){return ZO}visitUint32(){return KO}visitUint64(){return JO}visitFloat(){return Xp}visitFloat16(){return $O}visitFloat32(){return VO}visitFloat64(){return jO}visitUtf8(){return Ex}visitBinary(){return cx}visitFixedSizeBinary(){return _x}visitDate(){return Hp}visitDateDay(){return lx}visitDateMillisecond(){return hx}visitTimestamp(){return il}visitTimestampSecond(){return gx}visitTimestampMillisecond(){return yx}visitTimestampMicrosecond(){return vx}visitTimestampNanosecond(){return bx}visitTime(){return sl}visitTimeSecond(){return wx}visitTimeMillisecond(){return xx}visitTimeMicrosecond(){return Sx}visitTimeNanosecond(){return Ax}visitDecimal(){return dx}visitList(){return QO}visitStruct(){return n7}visitUnion(){return ry}visitDenseUnion(){return i7}visitSparseUnion(){return r7}visitDictionary(){return UO}visitInterval(){return qp}visitIntervalDayTime(){return px}visitIntervalYearMonth(){return mx}visitFixedSizeList(){return GO}visitMap(){return t7}}const a7=new s7;class Pe extends ln{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((r,s)=>this.compareFields(r,e[s]))}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 ai(n,t){return t instanceof n.constructor}function fd(n,t){return n===t||ai(n,t)}function co(n,t){return n===t||ai(n,t)&&n.bitWidth===t.bitWidth&&n.isSigned===t.isSigned}function Zp(n,t){return n===t||ai(n,t)&&n.precision===t.precision}function o7(n,t){return n===t||ai(n,t)&&n.byteWidth===t.byteWidth}function iy(n,t){return n===t||ai(n,t)&&n.unit===t.unit}function ud(n,t){return n===t||ai(n,t)&&n.unit===t.unit&&n.timezone===t.timezone}function cd(n,t){return n===t||ai(n,t)&&n.unit===t.unit&&n.bitWidth===t.bitWidth}function f7(n,t){return n===t||ai(n,t)&&n.children.length===t.children.length&&ao.compareManyFields(n.children,t.children)}function u7(n,t){return n===t||ai(n,t)&&n.children.length===t.children.length&&ao.compareManyFields(n.children,t.children)}function sy(n,t){return n===t||ai(n,t)&&n.mode===t.mode&&n.typeIds.every((e,r)=>e===t.typeIds[r])&&ao.compareManyFields(n.children,t.children)}function c7(n,t){return n===t||ai(n,t)&&n.id===t.id&&n.isOrdered===t.isOrdered&&ao.visit(n.indices,t.indices)&&ao.visit(n.dictionary,t.dictionary)}function ay(n,t){return n===t||ai(n,t)&&n.unit===t.unit}function l7(n,t){return n===t||ai(n,t)&&n.listSize===t.listSize&&n.children.length===t.children.length&&ao.compareManyFields(n.children,t.children)}function h7(n,t){return n===t||ai(n,t)&&n.keysSorted===t.keysSorted&&n.children.length===t.children.length&&ao.compareManyFields(n.children,t.children)}Pe.prototype.visitNull=fd;Pe.prototype.visitBool=fd;Pe.prototype.visitInt=co;Pe.prototype.visitInt8=co;Pe.prototype.visitInt16=co;Pe.prototype.visitInt32=co;Pe.prototype.visitInt64=co;Pe.prototype.visitUint8=co;Pe.prototype.visitUint16=co;Pe.prototype.visitUint32=co;Pe.prototype.visitUint64=co;Pe.prototype.visitFloat=Zp;Pe.prototype.visitFloat16=Zp;Pe.prototype.visitFloat32=Zp;Pe.prototype.visitFloat64=Zp;Pe.prototype.visitUtf8=fd;Pe.prototype.visitBinary=fd;Pe.prototype.visitFixedSizeBinary=o7;Pe.prototype.visitDate=iy;Pe.prototype.visitDateDay=iy;Pe.prototype.visitDateMillisecond=iy;Pe.prototype.visitTimestamp=ud;Pe.prototype.visitTimestampSecond=ud;Pe.prototype.visitTimestampMillisecond=ud;Pe.prototype.visitTimestampMicrosecond=ud;Pe.prototype.visitTimestampNanosecond=ud;Pe.prototype.visitTime=cd;Pe.prototype.visitTimeSecond=cd;Pe.prototype.visitTimeMillisecond=cd;Pe.prototype.visitTimeMicrosecond=cd;Pe.prototype.visitTimeNanosecond=cd;Pe.prototype.visitDecimal=fd;Pe.prototype.visitList=f7;Pe.prototype.visitStruct=u7;Pe.prototype.visitUnion=sy;Pe.prototype.visitDenseUnion=sy;Pe.prototype.visitSparseUnion=sy;Pe.prototype.visitDictionary=c7;Pe.prototype.visitInterval=ay;Pe.prototype.visitIntervalDayTime=ay;Pe.prototype.visitIntervalYearMonth=ay;Pe.prototype.visitFixedSizeList=l7;Pe.prototype.visitMap=h7;const ao=new Pe;function d7(n,t){return ao.compareSchemas(n,t)}function _7(n,t){return ao.visit(n,t)}function vp(n){const t=n.type,e=new(a7.getVisitFn(t)())(n);if(t.children&&t.children.length>0){const r=n.children||[],s={nullValues:n.nullValues},o=Array.isArray(r)?(f,c)=>r[c]||s:({name:f})=>r[f]||s;for(const[f,c]of t.children.entries()){const{type:l}=c,d=o(c,f);e.children.push(vp(Object.assign(Object.assign({},d),{type:l})))}}return e}function p7(n,t){if(n instanceof On||n instanceof Ie||n.type instanceof Re||ArrayBuffer.isView(n))return kc(n);const e={type:t??N_(n),nullValues:[null]},r=[...m7(e)(n)],s=r.length===1?r[0]:r.reduce((o,f)=>o.concat(f));return Re.isDictionary(s.type)?s.memoize():s}function N_(n){if(n.length===0)return new io;let t=0,e=0,r=0,s=0,o=0,f=0,c=0,l=0;for(const d of n){if(d==null){++t;continue}switch(typeof d){case"bigint":++f;continue;case"boolean":++c;continue;case"number":++s;continue;case"string":++o;continue;case"object":Array.isArray(d)?++e:Object.prototype.toString.call(d)==="[object Date]"?++l:++r;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(s+t===n.length)return new Dg;if(o+t===n.length)return new so(new Wc,new Qo);if(f+t===n.length)return new $p;if(c+t===n.length)return new Yc;if(l+t===n.length)return new d2;if(e+t===n.length){const d=n,p=N_(d[d.findIndex(w=>w!=null)]);if(d.every(w=>w==null||_7(p,N_(w))))return new Hc(new gn("",p,!0))}else if(r+t===n.length){const d=new Map;for(const p of n)for(const w of Object.keys(p))!d.has(w)&&p[w]!=null&&d.set(w,new gn(w,N_([p[w]]),!0));return new Mr([...d.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function m7(n){const{["queueingStrategy"]:t="count"}=n,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=n,r=t!=="bytes"?"length":"byteLength";return function*(s){let o=0;const f=vp(n);for(const c of s)f.append(c)[r]>=e&&++o&&(yield f.toVector());(f.finish().length>0||o===0)&&(yield f.toVector())}}function _0(n,t){return g7(n,t.map(e=>e.data.concat()))}function g7(n,t){const e=[...n.fields],r=[],s={numBatches:t.reduce((w,I)=>Math.max(w,I.length),0)};let o=0,f=0,c=-1;const l=t.length;let d,p=[];for(;s.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,c=-1;++c0&&(r[o++]=Te({type:new Mr(e),length:f,nullCount:0,children:p.slice()})))}return[n=n.assign(e),r.map(w=>new zi(n,w))]}function y7(n,t,e,r,s){var o;const f=(t+63&-64)>>3;for(let c=-1,l=r.length;++c=t)p===t?e[c]=d:(e[c]=d.slice(0,t),s.numBatches=Math.max(s.numBatches,r[c].unshift(d.slice(t,p-t))));else{const w=n[c];n[c]=w.clone({nullable:!0}),e[c]=(o=d==null?void 0:d._changeLengthAndBackfillNullBitmap(t))!==null&&o!==void 0?o:Te({type:w.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)})}}return e}var Tx;class Si{constructor(...t){var e,r;if(t.length===0)return this.batches=[],this.schema=new An([]),this._offsets=[0],this;let s,o;t[0]instanceof An&&(s=t.shift()),t.at(-1)instanceof Uint32Array&&(o=t.pop());const f=l=>{if(l){if(l instanceof zi)return[l];if(l instanceof Si)return l.batches;if(l instanceof On){if(l.type instanceof Mr)return[new zi(new An(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(d=>f(d));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(d=>f(d));if(typeof l=="object"){const d=Object.keys(l),p=d.map(C=>new Ie([l[C]])),w=new An(d.map((C,V)=>new gn(String(C),p[V].type))),[,I]=_0(w,p);return I.length===0?[new zi(l)]:I}}}return[]},c=t.flatMap(l=>f(l));if(s=(r=s??((e=c[0])===null||e===void 0?void 0:e.schema))!==null&&r!==void 0?r:new An([]),!(s instanceof An))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of c){if(!(l instanceof zi))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!d7(s,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=s,this.batches=c,this._offsets=o??Yw(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Ww(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?ty.visit(new Ie(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} ]`}concat(...t){const e=this.schema,r=this.data.concat(t.flatMap(({data:s})=>s));return new Si(e,r.map(s=>new zi(e,s)))}slice(t,e){const r=this.schema;[t,e]=Vw({length:this.numRows},t,e);const s=Hw(this.data,this._offsets,t,e);return new Si(r,s.map(o=>new zi(r,o)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&tr.children[t]);if(e.length===0){const{type:r}=this.schema.fields[t],s=Te({type:r,length:0,nullCount:0});e.push(s._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ie(e)}return null}setChild(t,e){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(s=>s.name===t),e)}setChildAt(t,e){let r=this.schema,s=[...this.batches];if(t>-1&&tthis.getChildAt(d));[o[t],c[t]]=[f,e],[r,s]=_0(r,c)}return new Si(r,s)}select(t){const e=this.schema.fields.reduce((r,s,o)=>r.set(s.name,o),new Map);return this.selectAt(t.map(r=>e.get(r)).filter(r=>r>-1))}selectAt(t){const e=this.schema.selectAt(t),r=this.batches.map(s=>s.selectAt(t));return new Si(e,r)}assign(t){const e=this.schema.fields,[r,s]=t.schema.fields.reduce((c,l,d)=>{const[p,w]=c,I=e.findIndex(C=>C.name===l.name);return~I?w[I]=d:p.push(d),c},[[],[]]),o=this.schema.assign(t.schema),f=[...e.map((c,l)=>[l,s[l]]).map(([c,l])=>l===void 0?this.getChildAt(c):t.getChildAt(l)),...r.map(c=>t.getChildAt(c))].filter(Boolean);return new Si(..._0(o,f))}}Tx=Symbol.toStringTag;Si[Tx]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=Cc(Qg),n.get=Cc(ii.getVisitFn(Q.Struct)),n.set=Xw(Vi.getVisitFn(Q.Struct)),n.indexOf=qw(cp.getVisitFn(Q.Struct)),n.getByteLength=Cc(aa.getVisitFn(Q.Struct)),"Table"))(Si.prototype);var Ix;let zi=class Ph{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof An))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Te({nullCount:0,type:new Mr(this.schema.fields),children:this.schema.fields.map(e=>Te({type:e.type,nullCount:0}))})]=t,!(this.data instanceof On))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Wv(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:r,children:s,length:o}=Object.keys(e).reduce((l,d,p)=>(l.children[p]=e[d],l.length=Math.max(l.length,e[d].length),l.fields[p]=gn.new({name:d,type:e[d].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),f=new An(r),c=Te({type:new Mr(r),length:o,children:s,nullCount:0});[this.schema,this.data]=Wv(f,c.children,o);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Ox(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return ii.visit(this.data,t)}set(t,e){return Vi.visit(this.data,t,e)}indexOf(t,e){return cp.visit(this.data,t,e)}getByteLength(t){return aa.visit(this.data,t)}[Symbol.iterator](){return ty.visit(new Ie([this.data]))}toArray(){return[...this]}concat(...t){return new Si(this.schema,[this,...t])}slice(t,e){const[r]=new Ie([this.data]).slice(t,e).data;return new Ph(this.schema,r)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&ts.name===t),e)}setChildAt(t,e){let r=this.schema,s=this.data;if(t>-1&&tc.name===o);~f&&(s[f]=this.data.children[f])}return new Ph(e,Te({type:r,length:this.numRows,children:s}))}selectAt(t){const e=this.schema.selectAt(t),r=t.map(o=>this.data.children[o]).filter(Boolean),s=Te({type:new Mr(e.fields),length:this.numRows,children:r});return new Ph(e,s)}};Ix=Symbol.toStringTag;zi[Ix]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(zi.prototype);function Wv(n,t,e=t.reduce((r,s)=>Math.max(r,s.length),0)){var r;const s=[...n.fields],o=[...t],f=(e+63&-64)>>3;for(const[c,l]of n.fields.entries()){const d=t[c];(!d||d.length!==e)&&(s[c]=l.clone({nullable:!0}),o[c]=(r=d==null?void 0:d._changeLengthAndBackfillNullBitmap(e))!==null&&r!==void 0?r:Te({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)}))}return[n.assign(s),Te({type:new Mr(s),length:e,children:o})]}function Ox(n,t,e=new Map){for(let r=-1,s=n.length;++r0&&Ox(f.children,c.children,e)}return e}class Bx extends zi{constructor(t){const e=t.fields.map(s=>Te({type:s.type})),r=Te({type:new Mr(t.fields),nullCount:0,children:e});super(t,r)}}var bp;(function(n){n[n.BUFFER=0]="BUFFER"})(bp||(bp={}));var wp;(function(n){n[n.LZ4_FRAME=0]="LZ4_FRAME",n[n.ZSTD=1]="ZSTD"})(wp||(wp={}));class Zo{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 Zo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+Nn),(e||new Zo).__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):wp.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):bp.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,wp.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,bp.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,r){return Zo.startBodyCompression(t),Zo.addCodec(t,e),Zo.addMethod(t,r),Zo.endBodyCompression(t)}}class Lx{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(e??0)),t.offset()}}let Mx=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(e??0)),t.offset()}},Za=class tg{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 tg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+Nn),(e||new tg).__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):BigInt("0")}nodes(t,e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new Mx).__init(this.bb.__vector(this.bb_pos+r)+t*16,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 r=this.bb.__offset(this.bb_pos,8);return r?(e||new Lx).__init(this.bb.__vector(this.bb_pos+r)+t*16,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 Zo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}},Sc=class eg{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 eg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+Nn),(e||new eg).__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):BigInt("0")}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Za).__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):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var xp;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(xp||(xp={}));let Xo=class $s{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 $s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+Nn),(e||new $s).__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):qc.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):xp.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const r=this.bb.__offset(this.bb_pos,12);return r?(e||new gr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),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,qc.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,xp.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);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,r,s,o,f){return $s.startMessage(t),$s.addVersion(t,e),$s.addHeaderType(t,r),$s.addHeader(t,s),$s.addBodyLength(t,o),$s.addCustomMetadata(t,f),$s.endMessage(t)}};class v7 extends ln{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return ru.startNull(e),ru.endNull(e)}visitInt(t,e){return xi.startInt(e),xi.addBitWidth(e,t.bitWidth),xi.addIsSigned(e,t.isSigned),xi.endInt(e)}visitFloat(t,e){return Js.startFloatingPoint(e),Js.addPrecision(e,t.precision),Js.endFloatingPoint(e)}visitBinary(t,e){return tu.startBinary(e),tu.endBinary(e)}visitBool(t,e){return eu.startBool(e),eu.endBool(e)}visitUtf8(t,e){return su.startUtf8(e),su.endUtf8(e)}visitDecimal(t,e){return ni.startDecimal(e),ni.addScale(e,t.scale),ni.addPrecision(e,t.precision),ni.addBitWidth(e,t.bitWidth),ni.endDecimal(e)}visitDate(t,e){return L_.startDate(e),L_.addUnit(e,t.unit),L_.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 r=t.timezone&&e.createString(t.timezone)||void 0;return Pi.startTimestamp(e),Pi.addUnit(e,t.unit),r!==void 0&&Pi.addTimezone(e,r),Pi.endTimestamp(e)}visitInterval(t,e){return Qs.startInterval(e),Qs.addUnit(e,t.unit),Qs.endInterval(e)}visitList(t,e){return nu.startList(e),nu.endList(e)}visitStruct(t,e){return iu.startStruct_(e),iu.endStruct_(e)}visitUnion(t,e){ri.startTypeIdsVector(e,t.typeIds.length);const r=ri.createTypeIdsVector(e,t.typeIds);return ri.startUnion(e),ri.addMode(e,t.mode),ri.addTypeIds(e,r),ri.endUnion(e)}visitDictionary(t,e){const r=this.visit(t.indices,e);return Ja.startDictionaryEncoding(e),Ja.addId(e,BigInt(t.id)),Ja.addIsOrdered(e,t.isOrdered),r!==void 0&&Ja.addIndexType(e,r),Ja.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Zs.startFixedSizeBinary(e),Zs.addByteWidth(e,t.byteWidth),Zs.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Ks.startFixedSizeList(e),Ks.addListSize(e,t.listSize),Ks.endFixedSizeList(e)}visitMap(t,e){return M_.startMap(e),M_.addKeysSorted(e,t.keysSorted),M_.endMap(e)}}const p0=new v7;function b7(n,t=new Map){return new An(x7(n,t),D_(n.customMetadata),t)}function Rx(n){return new ys(n.count,Nx(n.columns),Dx(n.columns))}function w7(n){return new oo(Rx(n.data),n.id,n.isDelta)}function x7(n,t){return(n.fields||[]).filter(Boolean).map(e=>gn.fromJSON(e,t))}function Yv(n,t){return(n.children||[]).filter(Boolean).map(e=>gn.fromJSON(e,t))}function Nx(n){return(n||[]).reduce((t,e)=>[...t,new al(e.count,S7(e.VALIDITY)),...Nx(e.children)],[])}function Dx(n,t=[]){for(let e=-1,r=(n||[]).length;++et+ +(e===0),0)}function A7(n,t){let e,r,s,o,f,c;return!t||!(o=n.dictionary)?(f=Xv(n,Yv(n,t)),s=new gn(n.name,f,n.nullable,D_(n.customMetadata))):t.has(e=o.id)?(r=(r=o.indexType)?Hv(r):new Qo,c=new so(t.get(e),r,e,o.isOrdered),s=new gn(n.name,c,n.nullable,D_(n.customMetadata))):(r=(r=o.indexType)?Hv(r):new Qo,t.set(e,f=Xv(n,Yv(n,t))),c=new so(f,r,e,o.isOrdered),s=new gn(n.name,c,n.nullable,D_(n.customMetadata))),s||null}function D_(n){return new Map(Object.entries(n||{}))}function Hv(n){return new Wr(n.isSigned,n.bitWidth)}function Xv(n,t){const e=n.type.name;switch(e){case"NONE":return new io;case"null":return new io;case"binary":return new sp;case"utf8":return new Wc;case"bool":return new Yc;case"list":return new Hc((t||[])[0]);case"struct":return new Mr(t||[]);case"struct_":return new Mr(t||[])}switch(e){case"int":{const r=n.type;return new Wr(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=n.type;return new pu(Cr[r.precision])}case"decimal":{const r=n.type;return new ap(r.scale,r.precision,r.bitWidth)}case"date":{const r=n.type;return new Qh(sa[r.unit])}case"time":{const r=n.type;return new td(wn[r.unit],r.bitWidth)}case"timestamp":{const r=n.type;return new op(wn[r.unit],r.timezone)}case"interval":{const r=n.type;return new fp(Jo[r.unit])}case"union":{const r=n.type;return new ed(ms[r.mode],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=n.type;return new up(r.byteWidth)}case"fixedsizelist":{const r=n.type;return new nd(r.listSize,(t||[])[0])}case"map":{const r=n.type;return new rd((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var E7=sx,T7=Xc;class _s{static fromJSON(t,e){const r=new _s(0,Ui.V4,e);return r._createHeader=I7(t,e),r}static decode(t){t=new T7(bn(t));const e=Xo.getRootAsMessage(t),r=e.bodyLength(),s=e.version(),o=e.headerType(),f=new _s(r,s,o);return f._createHeader=O7(e,o),f}static encode(t){const e=new E7;let r=-1;return t.isSchema()?r=An.encode(e,t.header()):t.isRecordBatch()?r=ys.encode(e,t.header()):t.isDictionaryBatch()&&(r=oo.encode(e,t.header())),Xo.startMessage(e),Xo.addVersion(e,Ui.V4),Xo.addHeader(e,r),Xo.addHeaderType(e,t.headerType),Xo.addBodyLength(e,BigInt(t.bodyLength)),Xo.finishMessageBuffer(e,Xo.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof An)return new _s(0,Ui.V4,Ln.Schema,t);if(t instanceof ys)return new _s(e,Ui.V4,Ln.RecordBatch,t);if(t instanceof oo)return new _s(e,Ui.V4,Ln.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===Ln.Schema}isRecordBatch(){return this.headerType===Ln.RecordBatch}isDictionaryBatch(){return this.headerType===Ln.DictionaryBatch}constructor(t,e,r,s){this._version=e,this._headerType=r,this.body=new Uint8Array(0),s&&(this._createHeader=()=>s),this._bodyLength=gs(t)}}class ys{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,r){this._nodes=e,this._buffers=r,this._length=gs(t)}}class oo{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,r=!1){this._data=t,this._isDelta=r,this._id=gs(e)}}class to{constructor(t,e){this.offset=gs(t),this.length=gs(e)}}class al{constructor(t,e){this.length=gs(t),this.nullCount=gs(e)}}function I7(n,t){return()=>{switch(t){case Ln.Schema:return An.fromJSON(n);case Ln.RecordBatch:return ys.fromJSON(n);case Ln.DictionaryBatch:return oo.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ln[t]}, type: ${t} }`)}}function O7(n,t){return()=>{switch(t){case Ln.Schema:return An.decode(n.header(new Vs));case Ln.RecordBatch:return ys.decode(n.header(new Za),n.version());case Ln.DictionaryBatch:return oo.decode(n.header(new Sc),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ln[t]}, type: ${t} }`)}}gn.encode=z7;gn.decode=k7;gn.fromJSON=A7;An.encode=P7;An.decode=B7;An.fromJSON=b7;ys.encode=U7;ys.decode=L7;ys.fromJSON=Rx;oo.encode=G7;oo.decode=M7;oo.fromJSON=w7;al.encode=$7;al.decode=N7;to.encode=V7;to.decode=R7;function B7(n,t=new Map){const e=C7(n,t);return new An(e,F_(n),t)}function L7(n,t=Ui.V4){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new ys(n.length(),D7(n),F7(n,t))}function M7(n,t=Ui.V4){return new oo(ys.decode(n.data(),t),n.id(),n.isDelta())}function R7(n){return new to(n.offset(),n.length())}function N7(n){return new al(n.length(),n.nullCount())}function D7(n){const t=[];for(let e,r=-1,s=-1,o=n.nodesLength();++rgn.encode(n,o));Vs.startFieldsVector(n,e.length);const r=Vs.createFieldsVector(n,e),s=t.metadata&&t.metadata.size>0?Vs.createCustomMetadataVector(n,[...t.metadata].map(([o,f])=>{const c=n.createString(`${o}`),l=n.createString(`${f}`);return gr.startKeyValue(n),gr.addKey(n,c),gr.addValue(n,l),gr.endKeyValue(n)})):-1;return Vs.startSchema(n),Vs.addFields(n,r),Vs.addEndianness(n,j7?Zc.Little:Zc.Big),s!==-1&&Vs.addCustomMetadata(n,s),Vs.endSchema(n)}function z7(n,t){let e=-1,r=-1,s=-1;const o=t.type;let f=t.typeId;Re.isDictionary(o)?(f=o.dictionary.typeId,s=p0.visit(o,n),r=p0.visit(o.dictionary,n)):r=p0.visit(o,n);const c=(o.children||[]).map(p=>gn.encode(n,p)),l=Fi.createChildrenVector(n,c),d=t.metadata&&t.metadata.size>0?Fi.createCustomMetadataVector(n,[...t.metadata].map(([p,w])=>{const I=n.createString(`${p}`),C=n.createString(`${w}`);return gr.startKeyValue(n),gr.addKey(n,I),gr.addValue(n,C),gr.endKeyValue(n)})):-1;return t.name&&(e=n.createString(t.name)),Fi.startField(n),Fi.addType(n,r),Fi.addTypeType(n,f),Fi.addChildren(n,l),Fi.addNullable(n,!!t.nullable),e!==-1&&Fi.addName(n,e),s!==-1&&Fi.addDictionary(n,s),d!==-1&&Fi.addCustomMetadata(n,d),Fi.endField(n)}function U7(n,t){const e=t.nodes||[],r=t.buffers||[];Za.startNodesVector(n,e.length);for(const f of e.slice().reverse())al.encode(n,f);const s=n.endVector();Za.startBuffersVector(n,r.length);for(const f of r.slice().reverse())to.encode(n,f);const o=n.endVector();return Za.startRecordBatch(n),Za.addLength(n,BigInt(t.length)),Za.addNodes(n,s),Za.addBuffers(n,o),Za.endRecordBatch(n)}function G7(n,t){const e=ys.encode(n,t.data);return Sc.startDictionaryBatch(n),Sc.addId(n,BigInt(t.id)),Sc.addIsDelta(n,t.isDelta),Sc.addData(n,e),Sc.endDictionaryBatch(n)}function $7(n,t){return Mx.createFieldNode(n,BigInt(t.length),BigInt(t.nullCount))}function V7(n,t){return Lx.createBuffer(n,BigInt(t.offset),BigInt(t.length))}const j7=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),oy=n=>`Expected ${Ln[n]} Message in stream, but was null or length 0.`,fy=n=>`Header pointer of flatbuffer-encoded ${Ln[n]} Message is null or length 0.`,Fx=(n,t)=>`Expected to read ${n} metadata bytes, but only read ${t}.`,Cx=(n,t)=>`Expected to read ${n} bytes for message body, but only read ${t}.`;class kx{constructor(t){this.source=t instanceof gp?t:new gp(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?qn: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(t!=null&&e.value.headerType!==t)throw new Error(oy(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=bn(this.source.read(t));if(e.byteLength[...s,...o.VALIDITY&&[o.VALIDITY]||[],...o.TYPE&&[o.TYPE]||[],...o.OFFSET&&[o.OFFSET]||[],...o.DATA&&[o.DATA]||[],...e(o.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(oy(t));return e.value}readSchema(){const t=Ln.Schema,e=this.readMessage(t),r=e==null?void 0:e.header();if(!e||!r)throw new Error(fy(t));return r}}const Kp=4,ng="ARROW1",Sp=new Uint8Array(ng.length);for(let n=0;nthis):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 Ci.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ci.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 eo?t:H0(t)?K7(t):z1(t)?tB(t):Zh(t)?Ne(this,void 0,void 0,function*(){return yield eo.from(yield t)}):U1(t)||Ig(t)||$1(t)||Tg(t)?Q7(new Qc(t)):J7(new gp(t))}static readAll(t){return t instanceof eo?t.isSync()?Jv(t):Qv(t):H0(t)||ArrayBuffer.isView(t)||Gp(t)||P1(t)?Jv(t):Qv(t)}}class Ap extends eo{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ea(this,arguments,function*(){yield Xe(yield*B_(Mc(this[Symbol.iterator]())))})}}class Ep extends eo{constructor(t){super(t),this._impl=t}readAll(){var t,e,r,s;return Ne(this,void 0,void 0,function*(){const o=new Array;try{for(var f=!0,c=Mc(this),l;l=yield c.next(),t=l.done,!t;f=!0){s=l.value,f=!1;const d=s;o.push(d)}}catch(d){e={error:d}}finally{try{!f&&!t&&(r=c.return)&&(yield r.call(c))}finally{if(e)throw e.error}}return o})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class zx extends Ap{constructor(t){super(t),this._impl=t}}class X7 extends Ep{constructor(t){super(t),this._impl=t}}class Ux{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){const r=this._loadVectors(t,e,this.schema.fields),s=Te({type:new Mr(this.schema.fields),length:t.length,children:r});return new zi(this.schema,s)}_loadDictionaryBatch(t,e){const{id:r,isDelta:s}=t,{dictionaries:o,schema:f}=this,c=o.get(r);if(s||!c){const l=f.dictionaries.get(r),d=this._loadVectors(t.data,e,[l]);return(c&&s?c.concat(new Ie(d)):new Ie(d)).memoize()}return c.memoize()}_loadVectors(t,e,r){return new ux(e,t.nodes,t.buffers,this.dictionaries).visitMany(r)}}class Tp extends Ux{constructor(t,e){super(e),this._reader=H0(t)?new Y7(this._handle=t):new kx(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=$x(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):qn}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):qn}next(){if(this.closed)return qn;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),s=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,s)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),s=e.readMessageBody(t.bodyLength),o=this._loadDictionaryBatch(r,s);this.dictionaries.set(r.id,o)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Bx(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ip extends Ux{constructor(t,e){super(e),this._reader=new W7(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Ne(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 Ne(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=$x(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Ne(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):qn})}return(t){return Ne(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):qn})}next(){return Ne(this,void 0,void 0,function*(){if(this.closed)return qn;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 r=t.header(),s=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,s)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),s=yield e.readMessageBody(t.bodyLength),o=this._loadDictionaryBatch(r,s);this.dictionaries.set(r.id,o)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Bx(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Ne(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Gx extends Tp{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof jv?t:new jv(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const r=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const s=this._reader.readMessage(Ln.RecordBatch);if(s!=null&&s.isRecordBatch()){const o=s.header(),f=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(o,f)}}return null}_readDictionaryBatch(t){var e;const r=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const s=this._reader.readMessage(Ln.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const o=s.header(),f=this._reader.readMessageBody(s.bodyLength),c=this._loadDictionaryBatch(o,f);this.dictionaries.set(o.id,c)}}}_readFooter(){const{_handle:t}=this,e=t.size-Px,r=t.readInt32(e),s=t.readAt(e-r,r);return ey.decode(s)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Ne(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return Ne(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());const r=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const s=yield this._reader.readMessage(Ln.RecordBatch);if(s!=null&&s.isRecordBatch()){const o=s.header(),f=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(o,f)}}return null})}_readDictionaryBatch(t){var e;return Ne(this,void 0,void 0,function*(){const r=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const s=yield this._reader.readMessage(Ln.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const o=s.header(),f=yield this._reader.readMessageBody(s.bodyLength),c=this._loadDictionaryBatch(o,f);this.dictionaries.set(o.id,c)}}})}_readFooter(){return Ne(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-Px,r=yield t.readInt32(e),s=yield t.readAt(e-r,r);return ey.decode(s)})}_readNextMessageAndValidate(t){return Ne(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?uy(t)?new zx(new Gx(n.read())):new Ap(new Tp(n)):new Ap(new Tp(function*(){}()))}function Q7(n){return Ne(this,void 0,void 0,function*(){const t=yield n.peek(ld+7&-8);return t&&t.byteLength>=4?uy(t)?new zx(new Gx(yield n.read())):new Ep(new Ip(n)):new Ep(new Ip(function(){return ea(this,arguments,function*(){})}()))})}function tB(n){return Ne(this,void 0,void 0,function*(){const{size:t}=yield n.stat(),e=new yp(n,t);return t>=H7&&uy(yield e.readAt(0,ld+7&-8))?new X7(new q7(e)):new Ep(new Ip(e))})}function el(n){const t=eo.from(n);return Zh(t)?t.then(e=>el(e)):t.isAsync()?t.readAll().then(e=>new Si(e)):new Si(t.readAll())}class eB extends i1{constructor(t,e,r){super(t,e,r),this.buffer_size=1024*1024*64,this._use_scale_to_download_tiles=!0,this.fbos={},this.textures={};const s=this.canvas;if(this.canvas===void 0)throw new Error("No canvas found");this.regl=j0({optionalExtensions:["OES_standard_derivatives","OES_element_index_uint","OES_texture_float","OES_texture_half_float"],canvas:s}),this.tileSet=e,this.aes=new HI(r,this.regl,e),this.initialize_textures(),this._initializations=[this.tileSet.promise.then(()=>{this.remake_renderer(),this._webgl_scale_history=[this.default_webgl_scale,this.default_webgl_scale]})],this.initialize(),this._buffers=new tb(this.regl,this.buffer_size)}get buffers(){return this._buffers=this._buffers||new tb(this.regl,this.buffer_size),this._buffers}data(t){return t===void 0?this.tileSet:(this.tileSet=t,this)}get props(){this.allocate_aesthetic_buffers();const{prefs:t,aes_to_buffer_num:e,buffer_num_to_variable:r,variable_to_buffer_num:s}=this,{transform:o}=this.zoom,f=this.aes.dim("color"),[c,l]=[f.current,f.last],d=[l.colorscheme_size,c.colorscheme_size],p={aes:{encoding:this.aes.encoding},colors_as_grid:0,corners:this.zoom.current_corners(),zoom_balance:t.zoom_balance,transform:o,max_ix:this.max_ix,point_size:this.point_size,alpha:this.optimal_alpha,time:Date.now()-this.zoom._start,update_time:Date.now()-this.most_recent_restart,relative_time:(Date.now()-this.most_recent_restart)/t.duration,string_index:0,prefs:JSON.parse(JSON.stringify(t)),color_type:void 0,wrap_colors_after:d,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:e,variable_to_buffer_num:s,color_picker_mode:0,zoom_matrix:[[o.k,0,o.x],[0,o.k,o.y],[0,0,1]].flat()};return JSON.parse(JSON.stringify(p))}get default_webgl_scale(){return this._default_webgl_scale?this._default_webgl_scale:(this._default_webgl_scale=this.zoom.webgl_scale(),this._default_webgl_scale)}render_points(t){const e=[];let r=0;const s=this.aes.store.foreground.states[0].active||this.aes.store.foreground.states[1].active;for(const o of this.visible_tiles()){if(o._buffer_manager=o._buffer_manager||new nB(this.regl,o,this),!o._buffer_manager.ready(t.block_for_buffers))continue;const f={manager:o._buffer_manager,number:r++,foreground:s?1:-1,tile_id:o.numeric_id,sprites:this.sprites};if(Object.assign(f,t),e.push(f),s){const c={...f,foreground:0};e.push(c)}}e.sort((o,f)=>(3+o.foreground)*1e3-(3+f.foreground)*1e3+f.number-o.number),this._renderer(e)}tick(){const{prefs:t}=this,{regl:e,tileSet:r}=this,{props:s}=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,5):r.download_most_needed_tiles(t.max_points,this.max_ix,5),e.clear({color:[.9,.9,.93,0],depth:1});const o=Date.now();async function f(c){for(;Date.now()-o<10&&c.length>0;){const l=c.shift();if(l!==void 0)try{await l()}catch(d){console.warn(d,l)}}}f(this.deferred_functions);try{this.render_all(s)}catch(c){throw console.warn("ERROR NOTED"),this.reglframe.cancel(),c}}single_blur_pass(t,e,r){const{regl:s}=this;e.use(()=>{s.clear({color:[0,0,0,0]}),s({frag:LT,uniforms:{iResolution:({viewportWidth:o,viewportHeight:f})=>[o,f],iChannel0:t,direction:r},vert:` precision mediump float; attribute vec2 position; varying vec2 uv; void main() { uv = 0.5 * (position + 1.0); gl_Position = vec4(position, 0, 1); }`,attributes:{position:[-4,-4,4,-4,0,4]},depth:{enable:!1},count:3})()})}blur(t,e,r=3){let s=r-1;for(;s>-1;)this.single_blur_pass(t,e,[2**s,0]),this.single_blur_pass(e,t,[0,2**s]),s-=1}render_all(t){const{regl:e}=this;this.fbos.points.use(()=>{e.clear({color:[0,0,0,0]}),this.render_points(t)}),e.clear({color:[0,0,0,0]}),this.fbos.lines.use(()=>e.clear({color:[0,0,0,0]})),this.scatterplot.trimap&&this.fbos.lines.use(()=>{this.scatterplot.trimap.zoom=this.zoom,this.scatterplot.trimap.tick("polygon")});for(const r 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:` precision mediump float; varying vec2 uv; uniform sampler2D tex; uniform float wRcp, hRcp; void main() { gl_FragColor = texture2D(tex, uv); } `,vert:` precision mediump float; attribute vec2 position; varying vec2 uv; void main() { uv = 0.5 * (position + 1.0); gl_Position = vec4(position, 0., 1.); } `,attributes:{position:this.fill_buffer},depth:{enable:!1},count:3,uniforms:{tex:()=>r,wRcp:({viewportWidth:s})=>1/s,hRcp:({viewportHeight:s})=>1/s}})()}initialize_textures(){const{regl:t}=this;this.fbos=this.fbos||{},this.textures=this.textures||{},this.textures.empty_texture=t.texture(au(128).map(e=>au(128).map(r=>[0,0,0]))),this.fbos.minicounter=t.framebuffer({width:512,height:512,depth:!1}),this.fbos.lines=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.points=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.ping=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.pong=t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.contour=this.fbos.contour||t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.colorpicker=this.fbos.colorpicker||t.framebuffer({width:this.width,height:this.height,depth:!1}),this.fbos.dummy=this.fbos.dummy||t.framebuffer({width:1,height:1,depth:!1})}get_image_texture(t){const{regl:e}=this;if(this.textures=this.textures||{},this.textures[t])return this.textures[t];const r=new Image;return r.src=t,r.addEventListener("load",()=>{this.textures[t]=e.texture(r)}),this.textures[t]}n_visible(t=-1){let{width:e,height:r}=this;e=Math.floor(e),r=Math.floor(r),this.contour_vals===void 0&&(this.contour_vals=new Uint8Array(e*r*4));const{props:s}=this;s.only_color=t;let o;return this.fbos.contour.use(()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(s),this.regl.read(this.contour_vals),o=h5(this.contour_vals)}),o}get integer_buffer(){if(this._integer_buffer===void 0){const t=new Float32Array(65536);for(let e=0;e<2**16;e++)t[e]=e;this._integer_buffer=this.regl.buffer(t)}return this._integer_buffer}color_pick(t,e){if(e===0)return null;const r=this.color_pick_single(t,e,"tile_id");if(r==-1)return null;const s=this.color_pick_single(t,e,"ix_in_tile");if(s===-1)return null;for(const o of this.visible_tiles())if(o.numeric_id===r)return o.record_batch.get(s);return null}color_pick_single(t,e,r="tile_id"){const{props:s,height:o}=this;s.color_picker_mode=["ix","tile_id","ix_in_tile"].indexOf(r)+1;let f=[0,0,0,0];this.fbos.colorpicker.use(()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(s);try{f=this.regl.read({x:t,y:o-e,width:1,height:1})}catch{console.warn("Read bad data from",{x:t,y:e,height:o,attempted:o-e})}});const c=TT(...f)-1;return Math.round(c)}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:r,height:s}=this;r=Math.floor(r),s=Math.floor(s),this.contour_vals=this.contour_vals||new Uint8Array(4*r*s),this.contour_alpha_vals=this.contour_alpha_vals||new Uint16Array(r*s);const{props:o}=this;o.aes.encoding.color={field:t},o.only_color=e,this.fbos.contour.use(()=>{this.regl.clear({color:[0,0,0,0]}),this.render_points(o),this.regl.read(this.contour_vals)}),this.blur(this.fbos.contour,this.fbos.ping,3),this.fbos.contour.use(()=>{this.regl.read(this.contour_vals)});let f=0;for(;f{if(s===void 0)throw new Error("wrap_colors_after is undefined");return s},u_use_glyphset:(r,{prefs:s})=>s.glyph_set?1:0,u_glyphset:(r,{prefs:s})=>s.glyph_set?this.get_image_texture(s.glyph_set):this.textures.empty_texture,u_color_picker_mode:t.prop("color_picker_mode"),u_position_interpolation_mode(){return this.aes.position_interpolation?1:0},u_grid_mode:(r,{grid_mode:s})=>s,u_colors_as_grid:t.prop("colors_as_grid"),u_tile_id:(r,s)=>s.tile_id,u_width:({viewportWidth:r})=>r,u_height:({viewportHeight:r})=>r,u_one_d_aesthetic_map:this.aes.aesthetic_map.one_d_texture,u_color_aesthetic_map:this.aes.aesthetic_map.color_texture,u_aspect_ratio:({viewportWidth:r,viewportHeight:s})=>r/s,u_zoom_balance:t.prop("zoom_balance"),u_base_size:(r,{point_size:s})=>s,u_maxix:(r,{max_ix:s})=>s,u_alpha:(r,{alpha:s})=>s,u_foreground_number:(r,{foreground:s})=>s,u_foreground_alpha:()=>this.render_props.foreground_opacity,u_background_rgba:()=>{const r=this.prefs.background_options.color,{r:s,g:o,b:f}=no(r);return[s/255,o/255,f/255,this.prefs.background_options.opacity[0]]},u_background_mouseover:()=>this.prefs.background_options.mouseover?1:0,u_background_size:()=>this.render_props.background_size,u_foreground_size:()=>this.render_props.foreground_size,u_k:(r,s)=>s.transform.k,u_window_scale:t.prop("webgl_scale"),u_last_window_scale:t.prop("last_webgl_scale"),u_time:({time:r})=>r,u_filter_numeric(){return this.aes.dim("filter").current.ops_to_array()},u_last_filter_numeric(){return this.aes.dim("filter").last.ops_to_array()},u_filter2_numeric(){return this.aes.dim("filter2").current.ops_to_array()},u_last_filter2_numeric(){return this.aes.dim("filter2").last.ops_to_array()},u_foreground_numeric(){return this.aes.dim("foreground").current.ops_to_array()},u_last_foreground_numeric(){return this.aes.dim("foreground").last.ops_to_array()},u_jitter:()=>this.aes.dim("jitter_radius").current.jitter_int_format,u_last_jitter:()=>this.aes.dim("jitter_radius").last.jitter_int_format,u_zoom(r,s){return s.zoom_matrix}}};for(const r of au(0,16))e.attributes[`buffer_${r}`]=(s,{manager:o,buffer_num_to_variable:f})=>o.regl_elements.get(f[r])||{constant:0};for(const r of["x","y","color","jitter_radius","x0","y0","jitter_speed","size","filter","filter2","foreground"])for(const s of["current","last"]){const o=s==="current"?"":"last_";e.uniforms[`u_${o}${r}_map_position`]=()=>this.aes.dim(r)[s].map_position,e.uniforms[`u_${o}${r}_buffer_num`]=(f,{aes_to_buffer_num:c})=>{const l=c[`${r}--${s}`];return l===void 0?-1:l},e.uniforms[`u_${o}${r}_domain`]=()=>this.aes.dim(r)[s].webGLDomain,e.uniforms[`u_${o}${r}_range`]=()=>this.aes.dim(r)[s].range,e.uniforms[`u_${o}${r}_transform`]=()=>{const f=this.aes.dim(r)[s].transform;if(f==="linear")return 1;if(f==="sqrt")return 2;if(f==="log")return 3;if(f==="literal")return 4;throw"Invalid transform"},e.uniforms[`u_${o}${r}_constant`]=()=>this.aes.dim(r)[s].constant}return this._renderer=t(e),this._renderer}allocate_aesthetic_buffers(){const t=[],e=["x","y","color","x0","y0","size","jitter_radius","jitter_speed","filter","filter2","foreground"];for(const c of e){const l=["current","last"];for(const d of l)try{this.aes.dim(c)[d].field&&t.push({aesthetic:c,time:d,field:this.aes.dim(c)[d].field})}catch(p){throw this.reglframe=void 0,p}}t.sort((c,l)=>c.time{e.deferred_functions.push(async()=>{await this.create_regl_buffer(t),f()})})}):{ready:!1,promise:null}:{ready:!0,promise:Promise.resolve()}}release(t){let e;(e=this.regl_elements.get(t))&&this.renderer.buffers.free_block(e)}get count(){return this.tile.record_batch.numRows}async create_buffer_data(t){const{tile:e}=this;if(!e.ready)throw new Error("Tile table not present.");let r=e.record_batch.getChild(t);if(!r)if(e.dataset.transformations[t]!==void 0){if(await e.apply_transformation(t),r=e.record_batch.getChild(t),!r)throw new Error(`${t} was not created.`)}else{const o=e.record_batch.schema.fields.map(f=>f.name);throw new Error(`Requested ${t} but table only has columns ["${o.join('", "')}]"`)}if(r.data.length!==1)throw new Error(`Column ${t} has ${r.data.length} buffers, not 1.`);if(!r.type||!r.type.typeId)throw new Error(`Column ${t} has no type.`);if(!r.type||r.type.typeId!==Q.Float32){const s=new Float32Array(e.record_batch.numRows),o=r.data[0];if(r.type.dictionary)for(let f=0;f128&&this.freed_buffers.push({buffer:this.buffers[0],offset:this.pointer,stride:4,byte_size:this.buffer_size-this.pointer}),this.pointer=0,this.buffers.unshift(this.regl.buffer({type:"float",length:this.buffer_size,usage:"dynamic"}))}free_block(t){this.freed_buffers.push(t)}allocate_block(t,e){const r=t*e;let s=0;for(const f of this.freed_buffers){if(f.byte_size===r)return this.freed_buffers.splice(s,1),{buffer:f.buffer,offset:f.offset,stride:e,byte_size:r};s+=1}this.pointer+t*e>this.buffer_size&&this.generate_new_buffer();const o={buffer:this.buffers[0],offset:this.pointer,stride:e,byte_size:t*e};return this.pointer+=t*e,o}}let rB=0;class Vx{constructor(t){if(this.max_ix=-1,this._children=[],this.transformation_holder={},this.promise=Promise.resolve(),this.download_state="Unattempted",this.key=String(Math.random()),this.parent=null,this.dataset=t,this.ready=!1,t===void 0)throw new Error("No dataset provided");this.numeric_id=rB++}get children(){return this._children}download(){throw new Error("Not implemented")}delete_column_if_exists(t){var e;this._batch&&((e=this._buffer_manager)==null||e.release(t),this._batch=C_(this.record_batch,t,null))}async get_column(t){this._batch===void 0&&await this.promise;const e=this.record_batch.getChild(t);if(e)return e;if(this.dataset.transformations[t])return await this.apply_transformation(t),this.record_batch.getChild(t);throw new Error(`Column ${t} not found`)}async apply_transformation(t){if(this.transformation_holder[t]!==void 0)return this.transformation_holder[t];const e=this.dataset.transformations[t];if(e===void 0)throw new Error(`Transformation ${t} is not defined`);return this.transformation_holder[t]=Promise.resolve(e(this)).then(r=>{if(r===void 0)throw new Error(`Transformation ${t} failed`);this._batch=C_(this.record_batch,t,r)}),this.transformation_holder[t]}add_column(t,e){return this._batch=C_(this.record_batch,t,e),this._batch}is_visible(t,e){if(this.min_ix===void 0||this.min_ix>t)return!1;if(e===void 0)return!0;const r=this.extent;return!(r.x[0]>e.x[1]||r.x[1]e.y[1]||r.y[1]t()),this.promise}get _schema(){if(this.__schema)return this.__schema;const t=[];for(const e of this.record_batch.schema.fields){const{name:r,type:s}=e;if((s==null?void 0:s.typeId)==5&&t.push({name:r,type:"string",extent:[]}),s&&s.dictionary&&t.push({name:r,type:"dictionary",keys:this.record_batch.getChild(r).data[0].dictionary.toArray(),extent:[-2047,this.record_batch.getChild(r).data[0].dictionary.length-2047]}),s&&s.typeId==8&&t.push({name:r,type:"date",extent:$h(this.record_batch.getChild(r).data[0].values)}),(s==null?void 0:s.typeId)===10)return[10,100];s&&s.typeId==3&&t.push({name:r,type:"float",extent:$h(this.record_batch.getChild(r).data[0].values)})}return this.__schema=t,t}*yielder(){for(const t of this.record_batch)t&&(yield t)}get extent(){return this._extent?this._extent:{x:[Number.MIN_VALUE,Number.MAX_VALUE],y:[Number.MIN_VALUE,Number.MAX_VALUE]}}[Symbol.iterator](){return this.yielder()}get root_extent(){return this.parent===null?{x:[Number.MIN_VALUE,Number.MAX_VALUE],y:[Number.MIN_VALUE,Number.MAX_VALUE]}:this.parent.root_extent}}class iB extends Vx{constructor(t,e,r,s){super(s),this._children=[],this._already_called=!1,this.child_locations=[],this.url=t,this.parent=r,this.key=e;const[o,f,c]=e.split("/").map(l=>Number.parseInt(l));this.codes=[o,f,c]}get extent(){return this._extent?this._extent:this.theoretical_extent}async download_to_depth(t){await this.download();let e=[];this.max_ixr.download_to_depth(t))),await Promise.all(e)}async get_arrow(t=void 0){let e=`${this.url}/${this.key}.feather`;t&&(e=e.replace(".feather",`.${t}.feather`));let r,s;if(this.dataset.tileProxy!==void 0){const f=new URL(e).pathname,c=await this.dataset.tileProxy.apiCall(f,"GET",null,null,{octetStreamAsUint8:!0});r=el(c)}else{let f={};window.localStorage.getItem("isLoggedIn")==="true"&&(e=e.replace("/public",""),f={Authorization:`Bearer ${localStorage.getItem("access_token")}`});const c={method:"GET",...f};s=await(await fetch(e,c)).arrayBuffer(),r=el(s)}r.batches.length>1&&console.warn(`More than one record batch at ${e}; all but first batch will be ignored.`);const o=r.batches[0];return t===void 0&&(this.download_state="Complete",this._batch=r.batches[0]),o}async download(){if(this._download!==void 0)return this._download;if(this._already_called)throw"Illegally attempting to download twice";return this._already_called=!0,this.download_state="In progress",this._download=this.get_arrow().then(t=>{this.ready=!0;const e=t.schema.metadata,r=e.get("extent");r&&(this._extent=JSON.parse(r));const s=e.get("children");s&&(this.child_locations=JSON.parse(s));const o=t.getChild("ix");if(o===null)throw"No ix column in table";this._min_ix=Number(o.get(0)),this.max_ix=Number(o.get(o.length-1)),this._min_ix>this.max_ix&&(this.max_ix=this._min_ix+1e5,this._min_ix=0),this.highest_known_ix=this.max_ix}).catch(t=>{throw this.download_state="Failed",console.error(`Error: Remote Tile at ${this.url}/${this.key}.feather not found. `),console.warn(t),t})}get macrotile(){return jx(this.key)}get macro_siblings(){return sB(this.key)}get children(){if(this.download_state!=="Complete")return[];const t=this.constructor;if(this._children.lengtht.x[0]&&n[1]t.y[0]}function jx(n,t=2,e=2){let[r,s,o]=n.split("/").map(c=>parseInt(c)),f=0;for(;!(f>=e&&r%t==0);)s=Math.floor(s/2),o=Math.floor(o/2),r=r-1,f++;return`${r}/${s}/${o}`}function sB(n,t=2,e=2){return aB(jx(n,t,e),t,e)}const m0=new Map;function aB(n,t=2,e=2){if(m0.has(n))return m0.get(n);const r=[[n]];for(;r.lengthparseInt(o)),s=[];for(let o=0;o<4;o++)s.push(`${t+1}/${e*2+o%2}/${r*2+Math.floor(o/2)}`);return s}class Gh{constructor(t){this.transformations={},this.extents={},this._ix_seed=0,this.plot=t}get highest_known_ix(){return this.root_tile.highest_known_ix}register_transformation(t,e,r=[]){const s=async o=>{await Promise.all(r.map(l=>o.get_column(l)));const f=new Float32Array(o.record_batch.numRows);let c=0;for(const l of o.record_batch)f[c]=e(l),c++;return f};this.transformations[t]=s}download_to_depth(t){return Promise.resolve()}get table(){return new Si(this.map(t=>t).filter(t=>t.ready).map(t=>t.record_batch))}static from_quadfeather(t,e){const r={};return e.tileProxy&&(r.tileProxy=e.tileProxy),new Yx(t,e,r)}static from_arrow_table(t,e){return new Wx(t,e)}has_column(t){return this.root_tile.record_batch.schema.fields.some(e=>e.name==t)||t in this.transformations}delete_column_if_exists(t){this.map(e=>e.delete_column_if_exists(t)),delete this.transformations[t]}domain(t,e=1e6){var r;if(this.extents[t])return this.extents[t];const s=(r=this._schema)==null?void 0:r.fields.find(o=>o.name===t);if(s!==void 0){let o,f;const c=s.metadata.get("extent");c&&([o,f]=JSON.parse(c));const l=s.metadata.get("min");l&&(o=JSON.parse(l));const d=s.metadata.get("max");if(d&&(f=JSON.parse(d)),s.type.typeId===10&&typeof o=="string"&&(o=Number(new Date(o))),s.type.typeId===10&&typeof f=="string"&&(f=Number(new Date(f))),typeof f=="string")throw new Error("Failed to parse min-max as numbers");if(o!==void 0)return this.extents[t]=[o,f]}return this.extents[t]=$h([...new Ie(this.map(o=>o).filter(o=>o.ready).map(o=>o.record_batch.getChild(t)).filter(o=>o!==null))])}*points(t,e=1e99){const r=[this.root_tile];let s;for(;s=r.shift();)if(s.download_state=="Complete"&&(t===void 0||s.is_visible(e,t))){for(const o of s)rg([o.x,o.y],t)&&o.ix<=e&&(yield o);r.push(...s.children)}}map(t,e=!1){const r=[];return this.visit(s=>{r.push(t(s))},e),r}visit(t,e=!1,r=s=>!0){const s=[this.root_tile],o=[];let f;for(;f=s.shift();)e?o.push(f):t(f),r(f)&&f.download_state=="Complete"&&s.push(...f.children);if(e)for(;f=o.pop();)t(f)}async schema(){return await this.ready,this._schema?this._schema:(this._schema=this.root_tile.record_batch.schema,this.root_tile.record_batch.schema)}add_tiled_column(t,e){const r=el(e),s={};for(const o of r.batches){const f=o.getChild("data").data[0];if(f===null)throw new Error('tiled columns must contain "data" field.');const c=f.valueOffsets,l=f.children[0];for(let d=0;de)}findPointRaw(t){const e=[];return this.visit(r=>{if(!(r.ready&&r.record_batch&&r.min_ix<=t&&r.max_ix>=t))return;const s=r.record_batch.getChild("ix"),o=yb(s.toArray(),t),f=r.record_batch.get(o);f!==null&&f.ix===t&&e.push([r,f,o])}),e}}class Wx extends Gh{constructor(t,e){super(e),this.promise=Promise.resolve(),this.root_tile=new cy(t,this,0)}get extent(){return this.root_tile.extent}get ready(){return Promise.resolve()}download_most_needed_tiles(...t){}}class Yx extends Gh{constructor(t,e,r={}){super(e),this._download_queue=new Set,r.tileProxy&&(this.tileProxy=r.tileProxy),this.root_tile=new iB(t,"0/0/0",null,this);const s=this.root_tile.download();this.promise=s.then(o=>{const f=this.root_tile.record_batch.schema;if(f.metadata.has("sidecars")){const c=f.metadata.get("sidecars"),l=JSON.parse(c);for(const[d,p]of Object.entries(l))this.transformations[d]=async function(w){const I=await w.get_arrow(p),C=I.getChild(d);if(C===null)throw new Error(`No column named ${d} in sidecar tile ${I.schema.fields.map(V=>V.name).join(", ")}`);return C}}})}get ready(){return this.root_tile.download()}get extent(){return this.root_tile.extent}async download_to_depth(t){await this.root_tile.download_to_depth(t)}download_most_needed_tiles(t,e,r=4){const s=this._download_queue;if(s.size>=r)return;const o=[];function f(c){if(t===void 0)return 1/c.codes[0];if(c.download_state==="Unattempted"){const l=oB(c,t);o.push([l,c,t])}}for(this.visit(f),o.sort((c,l)=>Number(c[0])-Number(l[0]));o.length>0&&s.sizee||l<=0||(s.add(d.key),d.download().then(()=>s.delete(d.key)).catch(w=>{throw console.warn("Error on",d.key),s.delete(d.key),w}))}}add_macrotiled_column(t,e){const r={},s={};async function o(f){const{macrotile:c}=f;return r[c]!==void 0?await r[c]:(r[c]=e(f.macro_siblings).then(l=>{const d=el(l);for(const p of d.batches){const w=p.getChild("data");for(let I=0;I>w&1;l[d*8+w]=I}}return l}else return c}}}function eb(n){return(n.x[1]-n.x[0])*(n.y[1]-n.y[0])}function oB(n,t){const e=n.extent;if(e.x[0]>t.x[1]||e.x[1]t.y[1]||e.y[1]s[1]&&(f-=1),o[0]>o[1]&&(f-=2),f<0?f:eb(r)/eb(t)}function C_(n,t,e){const r={};for(const o of n.schema.fields){if(o.name===t){if(e===null)continue;throw new Error(`Name ${o.name} already exists, can't add.`)}const c=n.getChild(o.name).data[0];r[o.name]=c}if(e===void 0)throw new Error("Must pass data to bind_column");e!==null&&(e instanceof Float32Array?r[t]=kc({type:new Ng,data:e,length:e.length}).data[0]:e instanceof BigInt64Array?r[t]=kc({type:new $p,data:e,length:e.length}).data[0]:e instanceof Uint8Array?r[t]=kc({type:new Rg,data:e,length:e.length}).data[0]:e.data.length>0?r[t]=e.data[0]:(console.warn("Unknown data format object passed to add or remove columns--treating as Data, but this behavior is deprecated",e),r[t]=e));const s=new zi(r);for(const[o,f]of n.schema.metadata)s.schema.metadata.set(o,f);for(const o of n.schema.fields){const f=s.schema.fields.find(c=>c.name===o.name);if(f!==void 0)for(const[c,l]of o.metadata)f.metadata.set(c,l);else if(e!==null)throw new Error("Error!")}if(e!==null){const o=s.schema.fields.find(f=>f.name===t);o==null||o.metadata.set("created by deepscatter",new Date().toISOString())}return s}function fB(n,t,e,r="_id"){const s=new Float32Array(n.numRows),o=n.getChild(r);if(o===null)throw new Error(`Field ${r} not found in batch`);if(o.type.typeId===Q.Int64||o.type.typeId===Q.Uint64){for(let d=0;dd.charCodeAt(w)||"").join("");f.add(p)}const c=o.data[0].valueOffsets,l=o.data[0].values;for(let d=0;dl;){if(d-l>600){var w=d-l+1,I=c-l+1,C=Math.log(w),V=.5*Math.exp(2*C/3),Wt=.5*Math.sqrt(C*V*(w-V)/w)*(I-w/2<0?-1:1),Qt=Math.max(l,Math.floor(c-I*V/w+Wt)),Rt=Math.min(d,Math.floor(c+(w-I)*V/w+Wt));r(f,c,Qt,Rt,p)}var oe=f[c],Zt=l,st=d;for(s(f,l,c),p(f[d],oe)>0&&s(f,l,d);Zt0;)st--}p(f[l],oe)===0?s(f,l,st):(st++,s(f,st,d)),st<=c&&(l=st+1),c<=st&&(d=st-1)}}function s(f,c,l){var d=f[c];f[c]=f[l],f[l]=d}function o(f,c){return fc?1:0}return e})})(uB);(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t=ig,e=[],r=function(at){return e.push(at)},s=function(at){at&&(r(at),d(at)||at.children.forEach(s))},o=function(at){var Y=e.pop();return Y?(Y.children=at,Y.height=1,Y.leaf=!0,Y.minX=1/0,Y.minY=1/0,Y.minZ=1/0,Y.maxX=-1/0,Y.maxY=-1/0,Y.maxZ=-1/0):Y={children:at,height:1,leaf:!0,minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0},Y},f=[],c=function(at){return f.push(at)},l=function(at,Y){var rt=f.pop();return rt?(rt.dist=at,rt.node=Y):rt={dist:at,node:Y},rt},d=function(at){return at.leaf},p=function(at,Y){return at.leaf},w=function(at,Y,rt){if(!rt)return Y.indexOf(at);for(var Bt=0;Bt=at.minX&&Y.maxY>=at.minY&&Y.maxZ>=at.minZ},n.boxRayIntersects=function(at,Y,rt,Bt,Dt,F,ft){var H=(at.minX-Y)*Dt,yt=(at.maxX-Y)*Dt,Mt=(at.minY-rt)*F,Kt=(at.maxY-rt)*F,ee=(at.minZ-Bt)*ft,de=(at.maxZ-Bt)*ft,Oe=Math.min(ee,de),ye=Math.max(ee,de),Ze=Math.min(Mt,Kt),on=Math.max(Mt,Kt),En=Math.min(H,yt),Dn=Math.max(H,yt),hn=Math.max(0,En,Ze,Oe),Fn=Math.min(Dn,on,ye);return Fn>=hn?hn:1/0};var st=function(at,Y,rt,Bt,Dt){for(var F=[Y,rt],ft;F.length;)rt=F.pop(),Y=F.pop(),!(rt-Y<=Bt)&&(ft=Y+Math.ceil((rt-Y)/Bt/2)*Bt,t(at,ft,Y,rt,Dt),F.push(Y,ft,ft,rt))},zt=function(at,Y){return at.minX-Y.minX},ue=function(at,Y){return at.minY-Y.minY},ve=function(at,Y){return at.minZ-Y.minZ},an=function(){function at(Y){Y===void 0&&(Y=16),this.maxEntries=Math.max(Y,8),this.minEntries=Math.max(4,Math.ceil(this.maxEntries*.4)),this.clear()}return at.alloc=function(){return this.pool.pop()||new this},at.free=function(Y){Y.clear(),this.pool.push(Y)},at.prototype.search=function(Y){var rt=this.data,Bt=[];if(!n.intersects(Y,rt))return Bt;for(var Dt=[];rt;){for(var F=0,ft=rt.children.length;F=Fn)break;var Yr=Kn+1;if(Yr0;){var Kn=ir-1>>1;if(Mt[Kn].dist<=Mt[ir].dist)break;Kt(ir,Kn),ir=Kn}},Oe=H,ye;Mt.length&&Mt[0].dist=rt;yt--){var Mt=Y.children[yt];V(ft,Mt),H+=Qt(ft)}return H},at.prototype.adjustParentBBoxes=function(Y,rt,Bt){for(var Dt=Bt;Dt>=0;Dt--)V(rt[Dt],Y)},at.prototype.condense=function(Y){for(var rt=Y.length-1,Bt=void 0;rt>=0;rt--)Y[rt].children.length===0?rt>0?(Bt=Y[rt-1].children,Bt.splice(Bt.indexOf(Y[rt]),1),r(Y[rt])):this.clear():I(Y[rt])},at.prototype._insert=function(Y,rt,Bt){var Dt=[],F=this.chooseSubtree(Y,this.data,rt,Dt);for(F.children.push(Y),V(F,Y);rt>=0&&Dt[rt].children.length>this.maxEntries;)this.split(Dt,rt),rt--;this.adjustParentBBoxes(Y,Dt,rt)},at.pool=[],at}();n.RBush3D=an})(Hx);const y0=t8();function cB(n){const[t,e]=n._zoom.scales().x.range(),[r,s]=n._zoom.scales().x.domain();return(e-t)/(s-r)}const nb=0;class lB extends i1{constructor(t,e,r={}){super(t.div.node(),t._root,t),this.layers=[],this.options={},this.options=r,this.canvas=t.elements[2].selectAll("canvas").node();const s=t.elements[3].selectAll("svg").node(),o=e.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"---"),f=s.querySelectorAll(`#${o}`);if(f.length===0?this.labelgroup=Wn(s).select("#labelrects").append("g").attr("id",o).node():this.labelgroup=f[1],this.canvas===void 0)throw new Error("WTF?");this.ctx=this.canvas.getContext("2d"),this.tree=new _B(this.ctx,cB(t),.5,[.5,1e6],r.margin===void 0?30:r.margin),this.bind_zoom(t._renderer.zoom)}start(t=1e9){this.timer&&this.timer.stop(),Wn(this.labelgroup).attr("display","inline"),this.timer=ad(()=>{this.render(),t-=1,t<=0&&this.stop()})}delete(){Wn(this.labelgroup).remove()}stop(){this.timer&&(this.timer.stop(),Wn(this.labelgroup).attr("display","none"),this.ctx.clearRect(0,0,4096,4096),this.timer=void 0)}update(t,e,r){var s;this.label_key=e;for(const o of t.features){const{properties:f,geometry:c}=o;if(f!==null&&c.type==="Point"){const l=(s=f[r])!=null?s:16;let d="";f[e]!==void 0&&f[e]!==null&&(d=f[e]);const p={x:c.coordinates[0]+Math.random()*.1,y:c.coordinates[1]+Math.random()*.1,text:d,height:l,properties:f};this.tree.insert_point(p)}}}render(){const t=this.ctx,{x_:e,y_:r}=this.zoom.scales(),{transform:s}=this.zoom,{width:o,height:f}=this;t.clearRect(0,0,o,f),t.textAlign="center",t.textBaseline="middle",t.globalAlpha=1;const c=1,l=this.zoom.current_corners(),d=this.tree.search({minX:l.x[0],minY:l.y[0],minZ:s.k,maxX:l.x[1],maxY:l.y[1],maxZ:s.k});t.clearRect(0,0,4096,4096);const p=this.scatterplot.dim("color"),w=Wn(this.labelgroup).selectAll("rect.labelbbox").data(d,C=>""+C.minZ+C.minX).join(C=>C.append("rect").attr("class","labellbox").style("opacity",nb)),I=5;for(const C of d){const V=C.data,Wt=e(V.x),Qt=r(V.y);t.globalAlpha=1,t.fillStyle="white";let Rt=!1;for(const Zt of[this.scatterplot.dim("filter"),this.scatterplot.dim("filter2")])V.properties[Zt.field]&&(Zt.apply(V.properties)||(Rt=!0));if(Rt){V.properties.__display="none";continue}else V.properties.__display="inline";this.options.useColorScale===!1||this.options.useColorScale===void 0?(t.shadowColor="#71797E",t.strokeStyle="#71797E"):V.properties[p.field]?p.scale.domain().indexOf(V.properties[p.field])>-1?(t.shadowColor=p.scale(V.properties[p.field]),t.strokeStyle=p.scale(V.properties[p.field])):(t.shadowColor="gray",t.strokeStyle="gray"):t.shadowColor="black";let oe=0;this.hovered===""+C.minZ+C.minX&&(oe+=2),t.font=`${V.height*c+oe}pt verdana`,t.shadowBlur=12+oe*3,t.lineWidth=3+oe,t.strokeText(V.text,Wt,Qt),t.shadowBlur=0,t.lineWidth=4+oe,t.fillStyle="white",t.fillText(V.text,Wt,Qt)}w.attr("class","labelbbox").attr("x",C=>e(C.data.x)-C.data.pixel_width*this.tree.pixel_ratio/2).attr("y",C=>r(C.data.y)-C.data.pixel_height*this.tree.pixel_ratio/2-I).attr("width",C=>C.data.pixel_width*this.tree.pixel_ratio).attr("stroke","red").attr("height",C=>C.data.pixel_height*this.tree.pixel_ratio+I*2).attr("display",C=>C.data.properties.__display||"inline").on("mouseover",(C,V)=>{Wn(C.target).style("opacity",nb),this.hovered=""+V.minZ+V.minX,C.stopPropagation()}).on("mousemove",function(C,V){C.stopPropagation()}).on("click",(C,V)=>{this.scatterplot.label_click(V.data,this.scatterplot,this)}).on("mouseout",(C,V)=>{this.hovered=void 0,C.stopPropagation()}),this.options.draggable_labels&&(y0.on("drag",(C,V)=>{V.data.x=e.invert(C.x),V.data.y=r.invert(C.y)}),y0.on("end",(C,V)=>{console.log({text:V.data.text,x:V.data.x,y:V.data.y})}),w.call(y0)),t.shadowColor="black",t.strokeStyle="black"}}let x_=null;function hB(){if(x_!==null)return x_;const n=document.createElement("canvas");return n.width=500,n.height=400,x_=n.getContext("2d"),x_}function dB(n,t,e){const r=hB();if(r.font=`${n.height}pt verdana`,n.text==="")return null;const s=r.measureText(n.text);let{actualBoundingBoxLeft:o,actualBoundingBoxRight:f,actualBoundingBoxAscent:c,actualBoundingBoxDescent:l}=s;return(Number.isNaN(o)||o===void 0)&&(o=0,f=s.width,c=n.height,l=0),{pixel_height:(c-l)/t+e/t,pixel_width:(f-o)/t+e/t}}class _B extends Hx.RBush3D{constructor(t,e,r=.5,s=[.1,1e3],o=10){super(),this._accessor=f=>[f.x,f.y],this.scale_factor=r,this.mindepth=s[0],this.maxdepth=s[1],this.context=t,this.pixel_ratio=e,this.margin=o}max_collision_depth(t,e){const[r,s]=this._accessor(t),[o,f]=this._accessor(e),c=Math.abs(r-o),d=(t.pixel_width+e.pixel_width)/2/c,p=Math.abs(s-f),I=(t.pixel_height+e.pixel_height)/2/p;return Math.min(d,I)}set accessor(t){this._accessor=t}get accessor(){return this._accessor}to3d(t,e=1,r){const[s,o]=this.accessor(t),{pixel_height:f,pixel_width:c}=t,l={minX:s-c/e/2,maxX:s+c/e/2,minY:o-f/e/2,maxY:o+f/e/2,minZ:e,maxZ:r||this.maxdepth,data:t};if(Number.isNaN(s)||Number.isNaN(o))throw"Missing position"+JSON.stringify(t);if(Number.isNaN(c))throw"Missing Aspect Ratio"+JSON.stringify(t);return l}insert_point(t,e=1/4){if(t.text===void 0||t.text==="")return;let r;t.pixel_width===void 0?r={...t,...dB(t,this.pixel_ratio,this.margin)}:r=t;const s=this.to3d(r,e,this.maxdepth);this.collides(s)?this.insert_after_collisions(s):e<=this.mindepth?this.insert(s):this.insert_point(t,e/2)}insert_after_collisions(t){let e=-1,r;for(const s of this.search(t)){const o=this.max_collision_depth(t.data,s.data);o>e&&(e=o,r=s)}if(r&&eS_(n,o))),s=r.slice(1).reduce((o,f)=>{switch(e){case"ALL":return o.and(f);case"ANY":return o.or(f);case"NONE":return o.or(f)}},r[0]);return e==="NONE"?s.not():s}throw console.error("UNABLE TO PARSE",t),new Error("UNABLE TO PARSE")}function vB(n){return new Set(["ANY","ALL","NONE"]).has(n[0])}function bB(n){return new Set(["AND","OR","XOR","NAND"]).has(n[0])}function wB(n){return n.tileFunction!==void 0}class ta{constructor(t,e){this.length=t,this.mask=e||new Uint8Array(Math.ceil(t/8))}static from_arrow(t){const e=t.data[0].values;return new ta(t.length,e)}to_arrow(){return new Ie([Te({type:new Yc,data:this.mask,length:this.length})])}set(t){const e=Math.floor(t/8),r=t%8;this.mask[e]|=1<{r=s}),this.composition=null,pB(e))this.add_identifier_column(e.name,e.ids,e.idField).then(r);else if(mB(e))this.add_boolean_column(e.name,e.field).then(r);else if(wB(e))this.add_function_column(e.name,e.tileFunction).then(r);else if(gB(e)){const{name:s,composition:o}=e;this.composition=o,this.add_function_column(s,async f=>(await Xx(f,o)).to_arrow()).then(r)}}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}dispatch(t,e){this.events[t]&&this.events[t].forEach(r=>r(e))}applyToAllLoadedTiles(){return Promise.all(this.dataset.map(t=>{if(t.ready)return t.get_column(this.name)})).then(()=>{})}applyToAllTiles(){throw new Error("Method not implemented.")}union(t,e){return new Pc(this.plot,{name:e||this.name+" union "+t.name,composition:["OR",this,t]})}intersection(t,e){return new Pc(this.plot,{name:e||this.name+" intersection "+t.name,composition:["AND",this,t]})}moveCursor(t){return this.cursor+=t,this.cursor>=this.selectionSize&&(this.cursor=this.cursor%this.selectionSize),this.cursor<0&&(this.cursor=this.selectionSize+this.cursor),this}async removePoints(t,e){return this.add_or_remove_points(t,e,"remove")}async addPoints(t,e){return this.add_or_remove_points(t,e,"add")}async export(t,e="json"){const r=Object.fromEntries(t.map(s=>[s,[]]));for(let s of this)for(let o of t)r[o].push(s[o]);return r}async add_or_remove_points(t,e,r){let s=0,o;const f=async l=>{s=-1,await this.ready;let d=(await l.get_column(this.name)).toArray();const p=l.record_batch.getChild("ix").data[0].values;for(let w of e){const I=yb([...p],w),C=l.record_batch.get(I);if(C!==null&&C.ix===w)if(d=new Float32Array(d),r==="add"){if(d[I]=1,e.length===1){o=l.key;let V=0;for(let Wt=0;Wt0&&(V+=1);s=V}}else d[I]=0}return d},c=new Pc(this.plot,{name:t,tileFunction:f});c.on("tile loaded",()=>{if(s>=0){c.cursor=s;for(let l=0;l{const r=await t(e),s=e.record_batch;let o=0;for(let f=0;fthis.selectionSize)throw new Error(`Index ${t} out of bounds for selection of size ${this.selectionSize}`);let e=0,r,s=0;for(let l of this.match_count){if(trb(e,r):rb(e,t)}function rb(n,t){let e;if(t[Symbol.toStringTag]==="Int8Array")e=new Lg;else if(t[Symbol.toStringTag]==="Int16Array")e=new Mg;else if(t[Symbol.toStringTag]==="Int32Array")e=new Qo;else throw new Error("values must be an array of signed integers, 32 bit or smaller.");const r=new so(n.type,e,AB++,!1);return kc({type:r,length:t.length,nullCount:0,data:t,dictionary:n})}const TB={color:"gray",opacity:[.2,1],size:[.66,1],mouseover:!1},IB={zoom_balance:.35,duration:1e3,max_points:1e3,encoding:{},point_size:1,alpha:40,background_options:TB,zoom_align:"center"},OB=[{id:"canvas-2d-background",nodetype:"canvas"},{id:"webgl-canvas",nodetype:"canvas"},{id:"canvas-2d",nodetype:"canvas"},{id:"deepscatter-svg",nodetype:"svg"}];class hd{constructor(t,e,r,s={}){this.secondary_renderers={},this.selection_history=[],this.util={dictionaryFromArrays:EB},this.plot_queue=Promise.resolve(),this.hooks={},this.mark_ready=function(){},this.bound=!1,t!==void 0&&this.bind(t,e,r),this.width=e,this.height=r,this.ready=new Promise((o,f)=>{this.mark_ready=o}),this.click_handler=new LB(this),this.tooltip_handler=new MB(this),this.label_click_handler=new BB(this),s.tileProxy&&(this.tileProxy=s.tileProxy),s.dataset&&this.load_dataset(s.dataset),this.prefs={...IB}}bind(t,e,r){if(this.div=Wn(t).selectAll("div.deepscatter_container").data([1]).join("div").attr("class","deepscatter_container").style("position","absolute"),this.div.empty())throw console.error(t),"Must pass a valid div selector";this.elements=[];for(const s of OB){const o=this.div.append("div").attr("id",`container-for-${s.id}`).style("position","absolute").style("top",0).style("left",0).style("pointer-events",s.id==="deepscatter-svg"?"auto":"none"),f=o.append(s.nodetype).attr("id",s.id).attr("width",e||window.innerWidth).attr("height",r||window.innerHeight);s.nodetype==="svg"&&(f.append("g").attr("id","mousepoints"),f.append("g").attr("id","labelrects")),this.elements.push(o)}this.bound=!0}async select_and_plot(t,e=this.prefs.duration){const r=await this.select_data(t);await r.ready,await this.plotAPI({duration:e,encoding:{foreground:{field:r.name,op:"eq",a:1}}})}async select_data(t){const e=new Pc(this,t);return await e.ready,this.selection_history.push({selection:e,name:e.name,flushed:!1}),e}add_identifier_column(t,e,r){const s=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,1])):e;this._root.add_label_identifiers(s,t,r)}async add_labels_from_url(t,e,r,s,o){return await this.ready,await this._root.promise,fetch(t).then(async f=>{const c=await f.json();this.add_labels(c,e,r,s,o)}).catch(f=>{console.warn(f),console.error("Broken addition of ",e)})}add_labels(t,e,r,s,o={}){const f=new lB(this,e,o);f.update(t,r,s),this.secondary_renderers[e]=f,this.secondary_renderers[e].start()}get dataset(){if(this._root===void 0)throw new Error("No dataset has been loaded");return this._root}add_api_label(t){const e={type:"FeatureCollection",features:t.labels.map(r=>({type:"Feature",geometry:{type:"Point",coordinates:[r.x,r.y]},properties:{text:r.text,size:r.size||void 0}}))};this.add_labels(e,t.name,"text","size",t.options||{})}async load_dataset(t){if(t.source_url!==void 0)this._root=Gh.from_quadfeather(t.source_url,this);else if(t.arrow_table!==void 0)this._root=Gh.from_arrow_table(t.arrow_table,this);else if(t.arrow_buffer!==void 0){const e=el(t.arrow_buffer);this._root=Gh.from_arrow_table(e,this)}else throw new Error("No source_url or arrow_table specified");return await this._root.ready,this._root}async reinitialize(){var t;const{prefs:e}=this;await this._root.ready,this._renderer=new eB("#container-for-webgl-canvas",this._root,this),this._zoom=new ST("#deepscatter-svg",this.prefs,this),this._zoom.attach_tiles(this._root),this._zoom.attach_renderer("regl",this._renderer),this._zoom.initialize_zoom();const s=Wn("#container-for-canvas-2d-background").select("canvas").node().getContext("2d");return s.fillStyle=(t=e.background_color)!=null?t:"rgba(133, 133, 111, .8)",s.fillRect(0,0,window.innerWidth*2,window.innerHeight*2),this._renderer.initialize(),this._root.promise.then(()=>this.mark_ready()),this.ready}visualize_tiles(){const e=this.elements[2].selectAll("canvas").node().getContext("2d");e.clearRect(0,0,1e4,1e4);const{x_:r,y_:s}=this._zoom.scales();e.strokeStyle="#888888";const o=this._root.map(f=>f);for(const f of au(20))setTimeout(()=>{for(const c of o){if(!c.codes||c.codes[0]!=f||!c.extent)continue;const[l,d]=c.extent.x.map(C=>r(C)),[p,w]=c.extent.y.map(C=>s(C)),I=c.codes[0];e.lineWidth=8/Math.sqrt(I),e.globalAlpha=.33,e.strokeRect(l,p,d-l,w-p),c.download_state!=="Unattempted"&&e.fillRect(l,p,d-l,w-p),e.globalAlpha=1}},f*400);setTimeout(()=>e.clearRect(0,0,1e4,1e4),17*400)}destroy(){var t,e,r;(e=(t=this._renderer)==null?void 0:t.regl)==null||e.destroy(),(r=this.div)==null||r.node().parentElement.replaceChildren()}update_prefs(t){if(this.prefs.encoding&&t.encoding)for(const e of Object.keys(this.prefs.encoding))t.encoding[e]!==void 0&&(this.prefs.encoding[e]=t.encoding[e]);H_(this.prefs,t)}add_hook(t,e,r=!1){if(this.hooks[t]!==void 0&&!r)throw new Error(`Hook ${t} already exists`);this.hooks[t]=e}remove_hook(t,e=!1){if(this.hooks[t]===void 0){if(e)return;throw new Error(`Hook ${t} does not exist`)}delete this.hooks[t]}stop_labellers(){console.log("Stopping labels");for(const[t,e]of Object.entries(this.secondary_renderers))e&&e.label_key!==void 0&&(this.secondary_renderers[t].stop(),this.secondary_renderers[t].delete(),this.secondary_renderers[t]=void 0)}dim(t){return this._renderer.aes.dim(t).current}set tooltip_html(t){this.tooltip_handler.f=t}get tooltip_html(){return this.tooltip_handler.f}set label_click(t){this.label_click_handler.f=t}get label_click(){return this.label_click_handler.f.bind(this.label_click_handler)}set click_function(t){this.click_handler.f=t}get click_function(){return this.click_handler.f}async plotAPI(t){if(t!==void 0){await this.plot_queue,t&&await this.start_transformations(t),this.plot_queue=this.unsafe_plotAPI(t),await this.plot_queue;for(const[e,r]of Object.entries(this.hooks))r()}}async start_transformations(t,e=110){return new Promise(r=>{this.prefs.duration{const d=Date.now()-c;d{r()},e-d):r()})}}else r()})}async unsafe_plotAPI(t){var e;if(t===null)return;if(t.click_function&&(this.click_function=Function("datum",t.click_function)),t.tooltip_html&&(this.tooltip_html=Function("datum",t.tooltip_html)),t.background_options&&(t.background_options.opacity&&typeof t.background_options.opacity=="number"&&(t.background_options.opacity=[t.background_options.opacity,1]),t.background_options.size&&typeof t.background_options.size=="number"&&(t.background_options.size=[t.background_options.size,1])),this.update_prefs(t),this._root===void 0){const{source_url:o,arrow_table:f,arrow_buffer:c}=t,l={source_url:o,arrow_table:f,arrow_buffer:c};if(Object.values(l).filter(d=>d!==void 0).length!==1)throw new Error("The initial API call specify exactly one of source_url, arrow_table, or arrow_buffer");await this.load_dataset(l)}if(t.transformations){console.log(t);for(const[o,f]of Object.entries(t.transformations)){const c=Function("datum",f);this.dataset.transformations[o]?console.log("Already",o,f):this.dataset.register_transformation(o,c)}}this._zoom===void 0&&await this.reinitialize(),t.basemap_gleofeather&&(t.polygons=[{file:t.basemap_gleofeather}]),this._renderer.render_props.apply_prefs(this.prefs);const{width:r,height:s}=this;if(this.update_prefs(t),t.zoom!==void 0&&(t.zoom===null?(this._zoom.zoom_to(1,r/2,s/2),t.zoom=void 0):(e=t.zoom)!=null&&e.bbox&&this._zoom.zoom_to_bbox(t.zoom.bbox,t.duration)),this._renderer.most_recent_restart=Date.now(),this._renderer.aes.apply_encoding(t.encoding),this._renderer.apply_webgl_scale&&this._renderer.apply_webgl_scale(t),this._renderer.reglframe&&(this._renderer.reglframe.cancel(),this._renderer.reglframe=void 0),this._renderer.reglframe=this._renderer.regl.frame(()=>{this._renderer.tick("Basic")}),t.labels!==void 0)if(NT(t.labels)){const{url:o,label_field:f,size_field:c}=t.labels,l=t.labels.name||o;this.secondary_renderers[l]||(this.stop_labellers(),this.add_labels_from_url(o,l,f,c).catch(d=>{console.error("Label addition failed."),console.error(d)}))}else if(DT(t.labels)){if(!t.labels.name)throw new Error("API field `labels` must have a name.");this.stop_labellers(),this.add_api_label(t.labels)}else if(t.labels===null)this.stop_labellers();else throw new Error("API field `labels` format not recognized.");this._zoom.restart_timer(6e4)}get root_batch(){if(!this._root)throw new Error("No dataset has been loaded");return this.dataset.root_tile.record_batch}get query(){const t=JSON.parse(JSON.stringify(this.prefs));return t.zoom={bbox:this._renderer.zoom.current_corners()},t}drawContours(t,e){const o=(e||Wn("body")).select("#canvas-2d").node().getContext("2d");for(const f of t){o.fillStyle="rgba(25, 25, 29, 1)",o.fillRect(0,0,window.innerWidth*2,window.innerHeight*2),o.strokeStyle="#8a0303",o.fillStyle="rgba(30, 30, 34, 1)",o.lineWidth=x0([.45,.25*Math.exp(Math.log(this._zoom.transform.k/2))]);const c=F5(U5().scale(this._zoom.transform.k).translate([this._zoom.transform.x,this._zoom.transform.y]),o);o.beginPath(),c(f),o.fill()}}sample_points(t=10){const e=[];for(const r of this._root.points(this._zoom.current_corners()))if(e.push({...r}),e.length>=t*3)break;return e.sort((r,s)=>Number(r.ix)-Number(s.ix)),e.slice(0,t)}contours(t){const e=this._renderer.calculate_contours(t),{x:r,y:s,x_:o,y_:f}=this._zoom.scales();function c(l){if(l){if(l.coordinates)return c(l.coordinates);if(l.length!==0){if(l[0].length>0)return l.map(c);l[0]=r(o.invert(l[0])),l[1]=s(f.invert(l[1]))}}}c(e),this.drawContours(e)}}hd.Bitmask=ta;hd.ArrowDataset=Wx;hd.QuadtileDataset=Yx;hd.DataSelection=Pc;class ly{constructor(t){this.string_rep="",this.plot=t}get f(){return this._f===void 0?(t,e)=>this.default(t,e):this._f}set f(t){typeof t=="string"?this.string_rep!==t&&(this.string_rep=t,this._f=Function("datum","plot",t)):this._f=t}}class BB extends ly{default(t,e=void 0,r=void 0){let s;t!==null&&(t.__activated==!0?(s=null,t.__activated=void 0):(t.__activated=!0,s={field:r.label_key,lambda:`d => d === '${t.properties[r.label_key]}'`}),this.plot.plotAPI({encoding:{filter:s}}))}}class LB extends ly{default(t,e=void 0){console.log({...t})}}class MB extends ly{default(t,e=void 0){let r="
";const s=new Set(["x","y","ix",null,"tile_key"]);for(const[o,f]of t)f!==null&&(s.has(o)||f!==""&&(r+=`
${String(o)}
`,r+=`
${String(f)}
`));return`${r}
`}}async function RB(n){let t;try{t=await caches.open("semantic-audio-search");const s=await t.match(n);if(s)return await s.arrayBuffer()}catch(s){console.warn("Unable to open cache",s)}const e=await fetch(n),r=await e.arrayBuffer();if(t)try{await t.put(n,new Response(r,{headers:e.headers}))}catch(s){console.warn("Unable to cache file",s)}return r}async function qx(n){let t=await RB(n),r=new TextDecoder("utf-8").decode(t);return JSON.parse(r)}let Zx={};qx("https://huggingface.co/datasets/Xenova/MusicBenchEmbedded/resolve/main/metadata.json").then(n=>{Zx=n}).catch(n=>console.error(n));let Kx={};qx("https://huggingface.co/datasets/Xenova/MusicBenchEmbedded/resolve/main/positions.json").then(n=>{Kx=n}).catch(n=>console.error(n));const id=new hd("#deepscatter");window.scatterplot=id;id.plotAPI({source_url:"https://huggingface.co/datasets/Xenova/MusicBenchEmbedded/resolve/main/atlas",max_points:52768,alpha:35,zoom_balance:.5,point_size:3,background_color:"transparent",encoding:{x:{field:"x",transform:"literal"},y:{field:"y",transform:"literal"},jitter_radius:{method:"uniform",constant:5}},tooltip_opacity:1,duration:4e3}).then(n=>id.plotAPI({encoding:{jitter_radius:{method:"uniform",constant:0}}}));id.tooltip_html=n=>{const t=Zx[n.ix];if(!t)return"Loading...";const e=t.location;return setTimeout(()=>{const r=document.querySelector(".tooltip");r&&(r.innerHTML=` ${t.main_caption}
`)},0),t.main_caption};const Bh=document.getElementById("overlay"),Jx=document.getElementById("query"),NB=document.getElementById("search"),Qx=new Worker(new URL("/assets/worker-UdpdUYBV.js",import.meta.url),{type:"module"});Qx.addEventListener("message",n=>{switch(n.data.status){case"initiate":Bh.innerText="Loading model and embeddings database...",Bh.style.display="flex",Bh.style.pointerEvents="all";break;case"ready":Bh.style.display="none",Bh.style.pointerEvents="none";break;case"complete":const t=n.data.output[0][1],e=Kx[t];e&&id.plotAPI({zoom:{bbox:{x:[e[0]-.5,e[0]+.5],y:[e[1]-.5,e[1]+.5]}},duration:2e3});break}});const t3=()=>{Qx.postMessage({status:"search",query:Jx.value})};Jx.addEventListener("keypress",n=>{n.keyCode===13&&t3()});NB.addEventListener("click",t3);