(function(){"use strict";var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(()=>{var hh=Object.create,rs=Object.defineProperty,ph=Object.getOwnPropertyDescriptor,mh=Object.getOwnPropertyNames,yh=Object.getPrototypeOf,_h=Object.prototype.hasOwnProperty,Ko=(e,t)=>{if(t=Symbol[e])return t;throw Error("Symbol."+e+" is not defined")},bh=(e=>typeof commonjsRequire<"u"?commonjsRequire:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof commonjsRequire<"u"?commonjsRequire:t)[i]}):e)(function(e){if(typeof commonjsRequire<"u")return commonjsRequire.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),ns=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Xr=(e,t)=>{for(var i in t)rs(e,i,{get:t[i],enumerable:!0})},Oc=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mh(t))!_h.call(e,r)&&r!==i&&rs(e,r,{get:()=>t[r],enumerable:!(n=ph(t,r))||n.enumerable});return e},Rc=(e,t,i)=>(i=e!=null?hh(yh(e)):{},Oc(!e||!e.__esModule?rs(i,"default",{value:e,enumerable:!0}):i,e)),gh=e=>Oc(rs({},"__esModule",{value:!0}),e),wh=function(e,t){this[0]=e,this[1]=t},Gr=e=>{var t=e[Ko("asyncIterator")],i=!1,n,r={};return t==null?(t=e[Ko("iterator")](),n=s=>r[s]=a=>t[s](a)):(t=t.call(e),n=s=>r[s]=a=>{if(i){if(i=!1,s==="throw")throw a;return a}return i=!0,{done:!1,value:new wh(new Promise(o=>{var u=t[s](a);if(!(u instanceof Object))throw TypeError("Object expected");o(u)}),1)}}),r[Ko("iterator")]=()=>r,n("next"),"throw"in t?n("throw"):r.throw=s=>{throw s},"return"in t&&n("return"),r},bu=ns(()=>{}),gu=ns(()=>{}),Su=ns((e,t)=>{var i=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(r={}){var s=r,a,o;s.ready=new Promise((l,c)=>{a=l,o=c});var u=Object.assign({},s),f="./this.program",y=(l,c)=>{throw c},g=typeof window=="object",I=typeof importScripts=="function",S=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",x="";function At(l){return s.locateFile?s.locateFile(l,x):x+l}var lt,Ht;if(S){var Yi=bu(),Xt=gu();I?x=Xt.dirname(x)+"/":x=__dirname+"/",lt=(l,c)=>(l=id(l)?new URL(l):Xt.normalize(l),Yi.readFileSync(l,c?void 0:"utf8")),Ht=l=>{var c=lt(l,!0);return c.buffer||(c=new Uint8Array(c)),c},!s.thisProgram&&process.argv.length>1&&(f=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),y=(l,c)=>{throw process.exitCode=l,c},s.inspect=()=>"[Emscripten Module object]"}else(g||I)&&(I?x=self.location.href:typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),n&&(x=n),x.indexOf("blob:")!==0?x=x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):x="",lt=l=>{var c=new XMLHttpRequest;return c.open("GET",l,!1),c.send(null),c.responseText},I&&(Ht=l=>{var c=new XMLHttpRequest;return c.open("GET",l,!1),c.responseType="arraybuffer",c.send(null),new Uint8Array(c.response)}));var ps=s.print||console.log.bind(console),ue=s.printErr||console.error.bind(console);Object.assign(s,u),u=null,s.arguments&&s.arguments,s.thisProgram&&(f=s.thisProgram),s.quit&&(y=s.quit);var Ki;s.wasmBinary&&(Ki=s.wasmBinary),typeof WebAssembly!="object"&&hn("no native wasm support detected");var Xi,Qi=!1,q;function de(l,c){l||hn(c)}var ct,bt,vt,Tt,m,ot;function er(){var l=Xi.buffer;s.HEAP8=ct=new Int8Array(l),s.HEAP16=vt=new Int16Array(l),s.HEAPU8=bt=new Uint8Array(l),s.HEAPU16=Tt=new Uint16Array(l),s.HEAP32=m=new Int32Array(l),s.HEAPU32=ot=new Uint32Array(l),s.HEAPF32=new Float32Array(l),s.HEAPF64=new Float64Array(l)}var $u=[],Qu=[],Ic=[],Zu=[],th=!1;function Sc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)Bc(s.preRun.shift());Vo($u)}function Ac(){th=!0,Vo(Qu)}function Tc(){Vo(Ic)}function Fc(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Dc(s.postRun.shift());Vo(Zu)}function Bc(l){$u.unshift(l)}function Ec(l){Qu.unshift(l)}function Dc(l){Zu.unshift(l)}var Zi=0,ys=null;function xc(l){Zi++,s.monitorRunDependencies&&s.monitorRunDependencies(Zi)}function td(l){if(Zi--,s.monitorRunDependencies&&s.monitorRunDependencies(Zi),Zi==0&&ys){var c=ys;ys=null,c()}}function hn(l){s.onAbort&&s.onAbort(l),l="Aborted("+l+")",ue(l),Qi=!0,q=1,l+=". Build with -sASSERTIONS for more info.",th&&lc();var c=new WebAssembly.RuntimeError(l);throw o(c),c}var ed="data:application/octet-stream;base64,",eh=l=>l.startsWith(ed),id=l=>l.startsWith("file://"),rr;rr="./duckdb-eh.wasm",eh(rr)||(rr=At(rr));function ih(l){if(l==rr&&Ki)return new Uint8Array(Ki);if(Ht)return Ht(l);throw"both async and sync fetching of the wasm failed"}function nd(l){return!Ki&&(g||I)&&typeof fetch=="function"?fetch(l,{credentials:"same-origin"}).then(c=>{if(!c.ok)throw"failed to load wasm binary file at '"+l+"'";return c.arrayBuffer()}).catch(()=>ih(l)):Promise.resolve().then(()=>ih(l))}function nh(l,c,d){return nd(l).then(p=>WebAssembly.instantiate(p,c)).then(p=>p).then(d,p=>{ue("failed to asynchronously prepare wasm: ".concat(p)),hn(p)})}function rd(l,c,d,p){return!l&&typeof WebAssembly.instantiateStreaming=="function"&&!eh(c)&&!S&&typeof fetch=="function"?fetch(c,{credentials:"same-origin"}).then(b=>{var A=WebAssembly.instantiateStreaming(b,d);return A.then(p,function(v){return ue("wasm streaming compile failed: ".concat(v)),ue("falling back to ArrayBuffer instantiation"),nh(c,d,p)})}):nh(c,d,p)}function sd(){var l={a:Mf};function c(p,b){return T=p.exports,T=Uf(T),Xi=T.fa,er(),Ec(T.ga),td(),T}xc();function d(p){c(p.instance)}if(s.instantiateWasm)try{return s.instantiateWasm(l,c)}catch(p){ue("Module.instantiateWasm callback failed with error: ".concat(p)),o(p)}return rd(Ki,rr,l,d).catch(o),{}}var Vt,Ir;function rh(l){this.name="ExitStatus",this.message="Program terminated with exit(".concat(l,")"),this.status=l}var Vo=l=>{for(;l.length>0;)l.shift()(s)},ad=s.noExitRuntime||!0,sh=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ah=(l,c,d)=>{c>>>=0;for(var p=c+d,b=c;l[b]&&!(b>=p);)++b;if(b-c>16&&l.buffer&&sh)return sh.decode(l.subarray(c,b));for(var A="";c>10,56320|X&1023)}}return A},Fr=(l,c)=>(l>>>=0,l?ah(bt,l,c):""),Gi={varargs:void 0,get(){var l=m[+Gi.varargs>>>2>>>0];return Gi.varargs+=4,l},getp(){return Gi.get()},getStr(l){var c=Fr(l);return c}};function od(l,c,d,p,b){c>>>=0,d>>>=0,p>>>=0,b>>>=0;for(var A=0,v=c?m[c>>>2>>>0]:0,w=c?m[c+4>>>2>>>0]:0,B=d?m[d>>>2>>>0]:0,X=d?m[d+4>>>2>>>0]:0,Q=p?m[p>>>2>>>0]:0,Mt=p?m[p+4>>>2>>>0]:0,Z=0,fe=0,wt=0,xt=0,ee=0,we=0,_=(c?m[c>>>2>>>0]:0)|(d?m[d>>>2>>>0]:0)|(p?m[p>>>2>>>0]:0),O=(c?m[c+4>>>2>>>0]:0)|(d?m[d+4>>>2>>>0]:0)|(p?m[p+4>>>2>>>0]:0),st=function(Lf,Cf,kf,dc){return Lf<32?Cf&dc:kf&dc},rt=0;rt>>2>>>0]:0,xf=c?m[b+8>>>2>>>0]:0;cc=(Nf+xf/1e6)*1e3}_u=ms.stream_ops.poll(ms,cc)}_u&1&&st(rt,v,w,Ft)&&(rt<32?Z=Z|Ft:fe=fe|Ft,A++),_u&4&&st(rt,B,X,Ft)&&(rt<32?wt=wt|Ft:xt=xt|Ft,A++),_u&2&&st(rt,Q,Mt,Ft)&&(rt<32?ee=ee|Ft:we=we|Ft,A++)}}return c&&(m[c>>>2>>>0]=Z,m[c+4>>>2>>>0]=fe),d&&(m[d>>>2>>>0]=wt,m[d+4>>>2>>>0]=xt),p&&(m[p>>>2>>>0]=ee,m[p+4>>>2>>>0]=we),A}function oh(){hn("missing function: $SOCKFS")}oh.stub=!0;function Uu(){hn("missing function: $FS")}Uu.stub=!0;var bs=l=>{var c=oh.getSocket(l);if(!c)throw new Uu.ErrnoError(8);return c},Nu=l=>(l&255)+"."+(l>>8&255)+"."+(l>>16&255)+"."+(l>>24&255),lh=l=>{var c="",d=0,p=0,b=0,A=0,v=0,w=0,B=[l[0]&65535,l[0]>>16,l[1]&65535,l[1]>>16,l[2]&65535,l[2]>>16,l[3]&65535,l[3]>>16],X=!0,Q="";for(w=0;w<5;w++)if(B[w]!==0){X=!1;break}if(X){if(Q=Nu(B[6]|B[7]<<16),B[5]===-1)return c="::ffff:",c+=Q,c;if(B[5]===0)return c="::",Q==="0.0.0.0"&&(Q=""),Q==="0.0.0.1"&&(Q="1"),c+=Q,c}for(d=0;d<8;d++)B[d]===0&&(d-b>1&&(v=0),b=d,v++),v>p&&(p=v,A=d-p+1);for(d=0;d<8;d++){if(p>1&&B[d]===0&&d>=A&&d{var d=vt[l>>>1>>>0],p=Hu(Tt[l+2>>>1>>>0]),b;switch(d){case 2:if(c!==16)return{errno:28};b=m[l+4>>>2>>>0],b=Nu(b);break;case 10:if(c!==28)return{errno:28};b=[m[l+8>>>2>>>0],m[l+12>>>2>>>0],m[l+16>>>2>>>0],m[l+20>>>2>>>0]],b=lh(b);break;default:return{errno:5}}return{family:d,addr:b,port:p}},zo=l=>{for(var c=l.split("."),d=0;d<4;d++){var p=Number(c[d]);if(isNaN(p))return null;c[d]=p}return(c[0]|c[1]<<8|c[2]<<16|c[3]<<24)>>>0},jo=l=>parseInt(l),Lu=l=>{var c,d,p,b,A=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,v=[];if(!A.test(l))return null;if(l==="::")return[0,0,0,0,0,0,0,0];for(l.startsWith("::")?l=l.replace("::","Z:"):l=l.replace("::",":Z:"),l.indexOf(".")>0?(l=l.replace(new RegExp("[.]","g"),":"),c=l.split(":"),c[c.length-4]=jo(c[c.length-4])+jo(c[c.length-3])*256,c[c.length-3]=jo(c[c.length-2])+jo(c[c.length-1])*256,c=c.slice(0,c.length-2)):c=l.split(":"),p=0,b=0,d=0;d{var p=uh(l,c);if(p.errno)throw new Uu.ErrnoError(p.errno);return p.addr=Yt.lookup_addr(p.addr)||p.addr,p};function ld(l,c,d,p,b,A){c>>>=0,d>>>=0;var v=bs(l),w=ch(c,d);return v.sock_ops.bind(v,w.addr,w.port),0}function ud(l,c,d,p,b,A){c>>>=0,d>>>=0;var v=bs(l),w=ch(c,d);return v.sock_ops.connect(v,w.addr,w.port),0}function hd(l,c,d,p){}function cd(l,c,d){return d>>>=0,Gi.varargs=d,0}function dd(l,c){}function fd(l,c,d){}var dh=(l,c,d,p)=>{if(d>>>=0,!(p>0))return 0;for(var b=d,A=d+p-1,v=0;v=55296&&w<=57343){var B=l.charCodeAt(++v);w=65536+((w&1023)<<10)|B&1023}if(w<=127){if(d>=A)break;c[d++>>>0]=w}else if(w<=2047){if(d+1>=A)break;c[d++>>>0]=192|w>>6,c[d++>>>0]=128|w&63}else if(w<=65535){if(d+2>=A)break;c[d++>>>0]=224|w>>12,c[d++>>>0]=128|w>>6&63,c[d++>>>0]=128|w&63}else{if(d+3>=A)break;c[d++>>>0]=240|w>>18,c[d++>>>0]=128|w>>12&63,c[d++>>>0]=128|w>>6&63,c[d++>>>0]=128|w&63}}return c[d>>>0]=0,d-b},Cu=(l,c,d)=>dh(l,bt,c,d);function pd(l,c,d){}var fh=(l,c)=>(bt.fill(0,l,l+c),l),ku=(l,c,d,p,b)=>{switch(c){case 2:d=zo(d),fh(l,16),b&&(m[b>>>2>>>0]=16),vt[l>>>1>>>0]=c,m[l+4>>>2>>>0]=d,vt[l+2>>>1>>>0]=Go(p);break;case 10:d=Lu(d),fh(l,28),b&&(m[b>>>2>>>0]=28),m[l>>>2>>>0]=c,m[l+8>>>2>>>0]=d[0],m[l+12>>>2>>>0]=d[1],m[l+16>>>2>>>0]=d[2],m[l+20>>>2>>>0]=d[3],vt[l+2>>>1>>>0]=Go(p);break;default:return 5}return 0};function yd(l,c,d,p,b,A){c>>>=0,d>>>=0;var v=bs(l);return v.daddr?(ku(c,v.family,Yt.lookup_name(v.daddr),v.dport,d),0):-53}function bd(l,c,d,p,b,A){p>>>=0,b>>>=0;var v=bs(l);return c===1&&d===4?(m[p>>>2>>>0]=v.error,m[b>>>2>>>0]=4,v.error=null,0):-50}function _d(l,c,d){return d>>>=0,Gi.varargs=d,0}function md(l,c){}function gd(l,c,d){}function vd(l,c,d,p){}function wd(l,c,d,p){p>>>=0,Gi.varargs=p}function Id(l,c,d,p,b,A){c>>>=0,d>>>=0,b>>>=0,A>>>=0;var v=bs(l),w=v.sock_ops.recvmsg(v,d);if(!w)return 0;if(b)var B=ku(b,v.family,Yt.lookup_name(w.addr),w.port,A);return bt.set(w.buffer,c>>>0),w.buffer.byteLength}function Sd(l,c,d,p){}function Ad(l){}function Td(l,c,d,p,b,A){}var Fd=(l,c,d)=>{};function Bd(l,c){}function Ed(l,c,d){}var Dd=!0,Od=()=>Dd,Md=()=>{hn("")};function Ud(l,c){return globalThis.DUCKDB_RUNTIME.createDirectory(s,l,c)}function Rd(l,c){return globalThis.DUCKDB_RUNTIME.checkDirectory(s,l,c)}function Nd(l,c){return globalThis.DUCKDB_RUNTIME.listDirectoryEntries(s,l,c)}function xd(l,c){return globalThis.DUCKDB_RUNTIME.removeDirectory(s,l,c)}function Ld(l){return globalThis.DUCKDB_RUNTIME.closeFile(s,l)}function Cd(l,c){return globalThis.DUCKDB_RUNTIME.checkFile(s,l,c)}function kd(l){return globalThis.DUCKDB_RUNTIME.getLastFileModificationTime(s,l)}function Pd(l,c,d,p){return globalThis.DUCKDB_RUNTIME.moveFile(s,l,c,d,p)}function Hd(l,c){return globalThis.DUCKDB_RUNTIME.openFile(s,l,c)}function Vd(l,c,d,p){return globalThis.DUCKDB_RUNTIME.readFile(s,l,c,d,p)}function zd(l,c){return globalThis.DUCKDB_RUNTIME.truncateFile(s,l,c)}function jd(l,c,d,p){return globalThis.DUCKDB_RUNTIME.writeFile(s,l,c,d,p)}function Wd(l){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(l)}function qd(l,c){return globalThis.DUCKDB_RUNTIME.glob(s,l,c)}function Yd(l){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(s,l)}function Gd(l,c,d,p,b,A){return globalThis.DUCKDB_RUNTIME.callScalarUDF(s,l,c,d,p,b,A)}var Jd=()=>Date.now(),tc=()=>4294901760;function Kd(){return tc()}var ec;ec=()=>performance.now();function Xd(l,c,d){return l>>>=0,c>>>=0,d>>>=0,bt.copyWithin(l>>>0,c>>>0,c+d>>>0)}var $d=l=>{var c=Xi.buffer,d=(l-c.byteLength+65535)/65536;try{return Xi.grow(d),er(),1}catch{}};function Qd(l){l>>>=0;var c=bt.length,d=tc();if(l>d)return!1;for(var p=(B,X)=>B+(X-B%X)%X,b=1;b<=4;b*=2){var A=c*(1+.2/b);A=Math.min(A,l+100663296);var v=Math.min(d,p(Math.max(l,A),65536)),w=$d(v);if(w)return!0}return!1}var Pu={},Zd=()=>f||"./this.program",_s=()=>{if(!_s.strings){var l=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",c={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:l,_:Zd()};for(var d in Pu)Pu[d]===void 0?delete c[d]:c[d]=Pu[d];var p=[];for(var d in c)p.push("".concat(d,"=").concat(c[d]));_s.strings=p}return _s.strings},tf=(l,c)=>{for(var d=0;d>>0>>>0]=l.charCodeAt(d);ct[c>>>0>>>0]=0},ef=function(l,c){l>>>=0,c>>>=0;var d=0;return _s().forEach((p,b)=>{var A=c+d;ot[l+b*4>>>2>>>0]=A,tf(p,A),d+=p.length+1}),0},nf=function(l,c){l>>>=0,c>>>=0;var d=_s();ot[l>>>2>>>0]=d.length;var p=0;return d.forEach(b=>p+=b.length+1),ot[c>>>2>>>0]=p,0},rf=l=>52;function sf(l,c){c>>>=0;var d=0,p=0,b=0;{var A=2;l==0?d=2:(l==1||l==2)&&(d=64),b=1}return ct[c>>>0>>>0]=A,vt[c+2>>>1>>>0]=b,Ir=[d>>>0,(Vt=d,+Math.abs(Vt)>=1?Vt>0?+Math.floor(Vt/4294967296)>>>0:~~+Math.ceil((Vt-+(~~Vt>>>0))/4294967296)>>>0:0)],m[c+8>>>2>>>0]=Ir[0],m[c+12>>>2>>>0]=Ir[1],Ir=[p>>>0,(Vt=p,+Math.abs(Vt)>=1?Vt>0?+Math.floor(Vt/4294967296)>>>0:~~+Math.ceil((Vt-+(~~Vt>>>0))/4294967296)>>>0:0)],m[c+16>>>2>>>0]=Ir[0],m[c+20>>>2>>>0]=Ir[1],0}function af(l,c,d,p,b,A){return 52}function of(l,c,d,p,b,A){return 52}function lf(l,c,d,p){return 52}function uf(l,c,d,p,b){return 70}var hf=l=>52,cf=[null,[],[]],df=(l,c)=>{var d=cf[l];c===0||c===10?((l===1?ps:ue)(ah(d,0)),d.length=0):d.push(c)};function ff(l,c,d,p){c>>>=0,d>>>=0,p>>>=0;for(var b=0,A=0;A>>2>>>0],w=ot[c+4>>>2>>>0];c+=8;for(var B=0;B>>0]);b+=w}return ot[p>>>2>>>0]=b,0}function pf(l,c,d,p){l>>>=0,c>>>=0,d>>>=0,p>>>=0;var b=0,A=0,v=0,w=0,B=0,X=0,Q;function Mt(Z,fe,wt,xt,ee,we){var _,O,st,rt;return O=Z===10?28:16,ee=Z===10?lh(ee):Nu(ee),_=Vu(O),rt=ku(_,Z,ee,we),de(!rt),st=Vu(32),m[st+4>>>2>>>0]=Z,m[st+8>>>2>>>0]=fe,m[st+12>>>2>>>0]=wt,ot[st+24>>>2>>>0]=xt,ot[st+20>>>2>>>0]=_,Z===10?m[st+16>>>2>>>0]=28:m[st+16>>>2>>>0]=16,m[st+28>>>2>>>0]=0,st}if(d&&(v=m[d>>>2>>>0],w=m[d+4>>>2>>>0],B=m[d+8>>>2>>>0],X=m[d+12>>>2>>>0]),B&&!X&&(X=B===2?17:6),!B&&X&&(B=X===17?2:1),X===0&&(X=6),B===0&&(B=1),!l&&!c)return-2;if(v&-1088||d!==0&&m[d>>>2>>>0]&2&&!l)return-1;if(v&32)return-2;if(B!==0&&B!==1&&B!==2)return-7;if(w!==0&&w!==2&&w!==10)return-6;if(c&&(c=Fr(c),A=parseInt(c,10),isNaN(A)))return v&1024?-2:-8;if(!l)return w===0&&(w=2),v&1||(w===2?b=Yo(2130706433):b=[0,0,0,1]),Q=Mt(w,B,X,null,b,A),ot[p>>>2>>>0]=Q,0;if(l=Fr(l),b=zo(l),b!==null)if(w===0||w===2)w=2;else if(w===10&&v&8)b=[0,0,Yo(65535),b],w=10;else return-2;else if(b=Lu(l),b!==null)if(w===0||w===10)w=10;else return-2;return b!=null?(Q=Mt(w,B,X,l,b,A),ot[p>>>2>>>0]=Q,0):v&4?-2:(l=Yt.lookup_name(l),b=zo(l),w===0?w=2:w===10&&(b=[0,0,Yo(65535),b]),Q=Mt(w,B,X,null,b,A),ot[p>>>2>>>0]=Q,0)}var yf=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return p=>crypto.getRandomValues(p);if(S)try{var l=bh("crypto"),c=l.randomFillSync;if(c)return p=>l.randomFillSync(p);var d=l.randomBytes;return p=>(p.set(d(p.byteLength)),p)}catch{}hn("initRandomDevice")},ic=l=>(ic=yf())(l);function bf(l,c){return l>>>=0,c>>>=0,ic(bt.subarray(l>>>0,l+c>>>0)),0}function _f(l,c,d,p,b,A,v){l>>>=0,d>>>=0,b>>>=0;var w=uh(l,c);if(w.errno)return-6;var B=w.port,X=w.addr,Q=!1;if(d&&p){var Mt;if(v&1||!(Mt=Yt.lookup_addr(X))){if(v&8)return-2}else X=Mt;var Z=Cu(X,d,p);Z+1>=p&&(Q=!0)}if(b&&A){B=""+B;var Z=Cu(B,b,A);Z+1>=A&&(Q=!0)}return Q?-12:0}var Wo=l=>l%4===0&&(l%100!==0||l%400===0),mf=(l,c)=>{for(var d=0,p=0;p<=c;d+=l[p++]);return d},nc=[31,29,31,30,31,30,31,31,30,31,30,31],rc=[31,28,31,30,31,30,31,31,30,31,30,31],gf=(l,c)=>{for(var d=new Date(l.getTime());c>0;){var p=Wo(d.getFullYear()),b=d.getMonth(),A=(p?nc:rc)[b];if(c>A-d.getDate())c-=A-d.getDate()+1,d.setDate(1),b<11?d.setMonth(b+1):(d.setMonth(0),d.setFullYear(d.getFullYear()+1));else return d.setDate(d.getDate()+c),d}return d},sc=l=>{for(var c=0,d=0;d=55296&&p<=57343?(c+=4,++d):c+=3}return c};function vf(l,c,d){var p=sc(l)+1,b=new Array(p);return dh(l,b,0,b.length),b}var ac=(l,c)=>{ct.set(l,c>>>0)};function wf(l,c,d,p){l>>>=0,c>>>=0,d>>>=0,p>>>=0;var b=ot[p+40>>>2>>>0],A={tm_sec:m[p>>>2>>>0],tm_min:m[p+4>>>2>>>0],tm_hour:m[p+8>>>2>>>0],tm_mday:m[p+12>>>2>>>0],tm_mon:m[p+16>>>2>>>0],tm_year:m[p+20>>>2>>>0],tm_wday:m[p+24>>>2>>>0],tm_yday:m[p+28>>>2>>>0],tm_isdst:m[p+32>>>2>>>0],tm_gmtoff:m[p+36>>>2>>>0],tm_zone:b?Fr(b):""},v=Fr(d),w={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var B in w)v=v.replace(new RegExp(B,"g"),w[B]);var X=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"];function Mt(_,O,st){for(var rt=typeof _=="number"?_.toString():_||"";rt.length0?1:0}var rt;return(rt=st(_.getFullYear()-O.getFullYear()))===0&&(rt=st(_.getMonth()-O.getMonth()))===0&&(rt=st(_.getDate()-O.getDate())),rt}function wt(_){switch(_.getDay()){case 0:return new Date(_.getFullYear()-1,11,29);case 1:return _;case 2:return new Date(_.getFullYear(),0,3);case 3:return new Date(_.getFullYear(),0,2);case 4:return new Date(_.getFullYear(),0,1);case 5:return new Date(_.getFullYear()-1,11,31);case 6:return new Date(_.getFullYear()-1,11,30)}}function xt(_){var O=gf(new Date(_.tm_year+1900,0,1),_.tm_yday),st=new Date(O.getFullYear(),0,4),rt=new Date(O.getFullYear()+1,0,4),Ft=wt(st),ms=wt(rt);return fe(Ft,O)<=0?fe(ms,O)<=0?O.getFullYear()+1:O.getFullYear():O.getFullYear()-1}var ee={"%a":_=>X[_.tm_wday].substring(0,3),"%A":_=>X[_.tm_wday],"%b":_=>Q[_.tm_mon].substring(0,3),"%B":_=>Q[_.tm_mon],"%C":_=>{var O=_.tm_year+1900;return Z(O/100|0,2)},"%d":_=>Z(_.tm_mday,2),"%e":_=>Mt(_.tm_mday,2," "),"%g":_=>xt(_).toString().substring(2),"%G":_=>xt(_),"%H":_=>Z(_.tm_hour,2),"%I":_=>{var O=_.tm_hour;return O==0?O=12:O>12&&(O-=12),Z(O,2)},"%j":_=>Z(_.tm_mday+mf(Wo(_.tm_year+1900)?nc:rc,_.tm_mon-1),3),"%m":_=>Z(_.tm_mon+1,2),"%M":_=>Z(_.tm_min,2),"%n":()=>` `,"%p":_=>_.tm_hour>=0&&_.tm_hour<12?"AM":"PM","%S":_=>Z(_.tm_sec,2),"%t":()=>" ","%u":_=>_.tm_wday||7,"%U":_=>{var O=_.tm_yday+7-_.tm_wday;return Z(Math.floor(O/7),2)},"%V":_=>{var O=Math.floor((_.tm_yday+7-(_.tm_wday+6)%7)/7);if((_.tm_wday+371-_.tm_yday-2)%7<=2&&O++,O){if(O==53){var st=(_.tm_wday+371-_.tm_yday)%7;st!=4&&(st!=3||!Wo(_.tm_year))&&(O=1)}}else{O=52;var rt=(_.tm_wday+7-_.tm_yday-1)%7;(rt==4||rt==5&&Wo(_.tm_year%400-1))&&O++}return Z(O,2)},"%w":_=>_.tm_wday,"%W":_=>{var O=_.tm_yday+7-(_.tm_wday+6)%7;return Z(Math.floor(O/7),2)},"%y":_=>(_.tm_year+1900).toString().substring(2),"%Y":_=>_.tm_year+1900,"%z":_=>{var O=_.tm_gmtoff,st=O>=0;return O=Math.abs(O)/60,O=O/60*100+O%60,(st?"+":"-")+("0000"+O).slice(-4)},"%Z":_=>_.tm_zone,"%%":()=>"%"};v=v.replace(/%%/g,"\0\0");for(var B in ee)v.includes(B)&&(v=v.replace(new RegExp(B,"g"),ee[B](A)));v=v.replace(/\0\0/g,"%");var we=vf(v);return we.length>c?0:(ac(we,l),we.length-1)}function If(l,c,d,p,b){return l>>>=0,c>>>=0,d>>>=0,p>>>=0,wf(l,c,d,p)}var Sf=0,Af=()=>ad||Sf>0,Tf=l=>{q=l,Af()||(s.onExit&&s.onExit(l),Qi=!0),y(l,new rh(l))},Ff=(l,c)=>{q=l,Tf(l)},Bf=l=>{if(l instanceof rh||l=="unwind")return q;y(1,l)},Ef=l=>{var c=s["_"+l];return c},Df=l=>{var c=sc(l)+1,d=Xo(c);return Cu(l,d,c),d},Of=(l,c,d,p,b)=>{var A={string:wt=>{var xt=0;return wt!=null&&wt!==0&&(xt=Df(wt)),xt},array:wt=>{var xt=Xo(wt.length);return ac(wt,xt),xt}};function v(wt){return c==="string"?Fr(wt):c==="boolean"?!!wt:wt}var w=Ef(l),B=[],X=0;if(p)for(var Q=0;Q(oc=s._main=T.ha)(l,c);s._duckdb_web_fs_glob_add_path=l=>(s._duckdb_web_fs_glob_add_path=T.ja)(l),s._duckdb_web_clear_response=()=>(s._duckdb_web_clear_response=T.ka)(),s._duckdb_web_fail_with=l=>(s._duckdb_web_fail_with=T.la)(l),s._duckdb_web_reset=l=>(s._duckdb_web_reset=T.ma)(l),s._duckdb_web_connect=()=>(s._duckdb_web_connect=T.na)(),s._duckdb_web_disconnect=l=>(s._duckdb_web_disconnect=T.oa)(l),s._duckdb_web_flush_files=()=>(s._duckdb_web_flush_files=T.pa)(),s._duckdb_web_flush_file=l=>(s._duckdb_web_flush_file=T.qa)(l),s._duckdb_web_open=(l,c)=>(s._duckdb_web_open=T.ra)(l,c),s._duckdb_web_get_global_file_info=(l,c)=>(s._duckdb_web_get_global_file_info=T.sa)(l,c),s._duckdb_web_collect_file_stats=(l,c,d)=>(s._duckdb_web_collect_file_stats=T.ta)(l,c,d),s._duckdb_web_export_file_stats=(l,c)=>(s._duckdb_web_export_file_stats=T.ua)(l,c),s._duckdb_web_fs_drop_file=(l,c)=>(s._duckdb_web_fs_drop_file=T.va)(l,c),s._duckdb_web_fs_drop_files=l=>(s._duckdb_web_fs_drop_files=T.wa)(l),s._duckdb_web_fs_glob_file_infos=(l,c)=>(s._duckdb_web_fs_glob_file_infos=T.xa)(l,c),s._duckdb_web_fs_get_file_info_by_id=(l,c,d)=>(s._duckdb_web_fs_get_file_info_by_id=T.ya)(l,c,d),s._duckdb_web_fs_get_file_info_by_name=(l,c,d)=>(s._duckdb_web_fs_get_file_info_by_name=T.za)(l,c,d),s._duckdb_web_fs_register_file_url=(l,c,d,p,b)=>(s._duckdb_web_fs_register_file_url=T.Aa)(l,c,d,p,b),s._duckdb_web_fs_register_file_buffer=(l,c,d,p)=>(s._duckdb_web_fs_register_file_buffer=T.Ba)(l,c,d,p),s._duckdb_web_copy_file_to_buffer=(l,c)=>(s._duckdb_web_copy_file_to_buffer=T.Ca)(l,c),s._duckdb_web_copy_file_to_path=(l,c,d)=>(s._duckdb_web_copy_file_to_path=T.Da)(l,c,d),s._duckdb_web_get_version=l=>(s._duckdb_web_get_version=T.Ea)(l),s._duckdb_web_get_feature_flags=()=>(s._duckdb_web_get_feature_flags=T.Fa)(),s._duckdb_web_tokenize=(l,c)=>(s._duckdb_web_tokenize=T.Ga)(l,c),s._duckdb_web_udf_scalar_create=(l,c,d)=>(s._duckdb_web_udf_scalar_create=T.Ha)(l,c,d),s._duckdb_web_prepared_create=(l,c,d)=>(s._duckdb_web_prepared_create=T.Ia)(l,c,d),s._duckdb_web_prepared_close=(l,c,d)=>(s._duckdb_web_prepared_close=T.Ja)(l,c,d),s._duckdb_web_prepared_run=(l,c,d,p)=>(s._duckdb_web_prepared_run=T.Ka)(l,c,d,p),s._duckdb_web_prepared_send=(l,c,d,p)=>(s._duckdb_web_prepared_send=T.La)(l,c,d,p),s._duckdb_web_query_run=(l,c,d)=>(s._duckdb_web_query_run=T.Ma)(l,c,d),s._duckdb_web_pending_query_start=(l,c,d)=>(s._duckdb_web_pending_query_start=T.Na)(l,c,d),s._duckdb_web_pending_query_poll=(l,c,d)=>(s._duckdb_web_pending_query_poll=T.Oa)(l,c,d),s._duckdb_web_pending_query_cancel=(l,c)=>(s._duckdb_web_pending_query_cancel=T.Pa)(l,c),s._duckdb_web_query_fetch_results=(l,c)=>(s._duckdb_web_query_fetch_results=T.Qa)(l,c),s._duckdb_web_get_tablenames=(l,c,d)=>(s._duckdb_web_get_tablenames=T.Ra)(l,c,d),s._duckdb_web_insert_arrow_from_ipc_stream=(l,c,d,p,b)=>(s._duckdb_web_insert_arrow_from_ipc_stream=T.Sa)(l,c,d,p,b),s._duckdb_web_insert_csv_from_path=(l,c,d,p)=>(s._duckdb_web_insert_csv_from_path=T.Ta)(l,c,d,p),s._duckdb_web_insert_json_from_path=(l,c,d,p)=>(s._duckdb_web_insert_json_from_path=T.Ua)(l,c,d,p);var Yo=l=>(Yo=T.Va)(l),Go=l=>(Go=T.Wa)(l),Hu=l=>(Hu=T.Xa)(l),Vu=s._malloc=l=>(Vu=s._malloc=T.Ya)(l);s._free=l=>(s._free=T.Za)(l);var lc=()=>(lc=T._a)(),zu=()=>(zu=T.$a)(),ju=l=>(ju=T.ab)(l),Xo=l=>(Xo=T.bb)(l);function Uf(l){l=Object.assign({},l);var c=p=>()=>p()>>>0,d=p=>b=>p(b)>>>0;return l.__errno_location=c(l.__errno_location),l.Ya=d(l.Ya),l.$a=c(l.$a),l.bb=d(l.bb),l}s.stackAlloc=Xo,s.stackSave=zu,s.stackRestore=ju,s.ccall=Of;var $o;ys=function l(){$o||uc(),$o||(ys=l)};function Rf(){var l=oc,c=0,d=0;try{var p=l(c,d);return Ff(p,!0),p}catch(b){return Bf(b)}}function uc(){if(Zi>0||(Sc(),Zi>0))return;function l(){$o||($o=!0,s.calledRun=!0,!Qi&&(Ac(),Tc(),a(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),hc&&Rf(),Fc()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),l()},1)):l()}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();var hc=!0;return s.noInitialRun&&(hc=!1),uc(),r.ready}})();typeof e=="object"&&typeof t=="object"&&(t.exports=i)}),xu=ns((exports,module)=>{(function(){var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;NODE_JS?root=commonjsGlobal:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,AMD=!1,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e,t){return function(i){return new Sha256(t,!0).update(i)[e]()}},createMethod=function(e){var t=createOutputMethod("hex",e);NODE_JS&&(t=nodeWrap(t,e)),t.create=function(){return new Sha256(e)},t.update=function(r){return t.create().update(r)};for(var i=0;i>2]|=e[r]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|n&63)<=57344?(o[s>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|n&63)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|n&63)<=64?(this.block=o[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var e=this.h0,t=this.h1,i=this.h2,n=this.h3,r=this.h4,s=this.h5,a=this.h6,o=this.h7,u=this.blocks,f,y,g,I,S,x,At,lt,Ht,Yi,Xt;for(f=16;f<64;++f)S=u[f-15],y=(S>>>7|S<<25)^(S>>>18|S<<14)^S>>>3,S=u[f-2],g=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10,u[f]=u[f-16]+y+u[f-7]+g<<0;for(Xt=t&i,f=0;f<64;f+=4)this.first?(this.is224?(lt=300032,S=u[0]-1413257819,o=S-150054599<<0,n=S+24177077<<0):(lt=704751109,S=u[0]-210244248,o=S-1521486534<<0,n=S+143694565<<0),this.first=!1):(y=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7),lt=e&t,I=lt^e&i^Xt,At=r&s^~r&a,S=o+g+At+K[f]+u[f],x=y+I,o=n+S<<0,n=S+x<<0),y=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),Ht=n&e,I=Ht^n&t^lt,At=o&r^~o&s,S=a+g+At+K[f+1]+u[f+1],x=y+I,a=i+S<<0,i=S+x<<0,y=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),Yi=i&n,I=Yi^i&e^Ht,At=a&o^~a&r,S=s+g+At+K[f+2]+u[f+2],x=y+I,s=t+S<<0,t=S+x<<0,y=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),Xt=t&i,I=Xt^t&n^Yi,At=s&a^~s&o,S=r+g+At+K[f+3]+u[f+3],x=y+I,r=e+S<<0,e=S+x<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+i<<0,this.h3=this.h3+n<<0,this.h4=this.h4+r<<0,this.h5=this.h5+s<<0,this.h6=this.h6+a<<0,this.h7=this.h7+o<<0},Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,i=this.h2,n=this.h3,r=this.h4,s=this.h5,a=this.h6,o=this.h7,u=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[a&15];return this.is224||(u+=HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[o&15]),u},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,i=this.h2,n=this.h3,r=this.h4,s=this.h5,a=this.h6,o=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24&255,i>>16&255,i>>8&255,i&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,s>>24&255,s>>16&255,s>>8&255,s&255,a>>24&255,a>>16&255,a>>8&255,a&255];return this.is224||u.push(o>>24&255,o>>16&255,o>>8&255,o&255),u},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function HmacSha256(e,t,i){var n,r=typeof e;if(r==="string"){var s=[],a=e.length,o=0,u;for(n=0;n>6,s[o++]=128|u&63):u<55296||u>=57344?(s[o++]=224|u>>12,s[o++]=128|u>>6&63,s[o++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++n)&1023),s[o++]=240|u>>18,s[o++]=128|u>>12&63,s[o++]=128|u>>6&63,s[o++]=128|u&63);e=s}else if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);e.length>64&&(e=new Sha256(t,!0).update(e).array());var f=[],y=[];for(n=0;n<64;++n){var g=e[n]||0;f[n]=92^g,y[n]=54^g}Sha256.call(this,t,i),this.update(y),this.oKeyPad=f,this.inner=!0,this.sharedMemory=i}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224)})()}),ly={};Xr(ly,{registerWorker:()=>Ru});function Uc(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(e){return this instanceof C?(this.v=e,this):new C(e)}function re(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=i.apply(e,t||[]),r,s=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(I){n[I]&&(r[I]=function(S){return new Promise(function(x,At){s.push([I,S,x,At])>1||o(I,S)})})}function o(I,S){try{u(n[I](S))}catch(x){g(s[0][3],x)}}function u(I){I.value instanceof C?Promise.resolve(I.value.v).then(f,y):g(s[0][2],I)}function f(I){o("next",I)}function y(I){o("throw",I)}function g(I,S){I(S),s.shift(),s.length&&o(s[0][0],s[0][1])}}function gn(e){var t,i;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,s){t[r]=e[r]?function(a){return(i=!i)?{value:C(e[r](a)),done:!1}:s?s(a):a}:s}}function ve(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],i;return t?t.call(e):(e=typeof Mc=="function"?Mc(e):e[Symbol.iterator](),i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i);function n(s){i[s]=e[s]&&function(a){return new Promise(function(o,u){a=e[s](a),r(o,u,a.done,a.value)})}}function r(s,a,o,u){Promise.resolve(u).then(function(f){s({value:f,done:o})},a)}}var ea={};Xr(ea,{compareArrayLike:()=>ta,joinUint8Arrays:()=>ne,memcpy:()=>wn,rebaseValueOffsets:()=>Zn,toArrayBufferView:()=>W,toArrayBufferViewAsyncIterator:()=>Fe,toArrayBufferViewIterator:()=>Ve,toBigInt64Array:()=>Th,toBigUint64Array:()=>Eh,toFloat32Array:()=>Oh,toFloat32ArrayAsyncIterator:()=>Xh,toFloat32ArrayIterator:()=>Ph,toFloat64Array:()=>Rh,toFloat64ArrayAsyncIterator:()=>Gh,toFloat64ArrayIterator:()=>Vh,toInt16Array:()=>Ah,toInt16ArrayAsyncIterator:()=>jh,toInt16ArrayIterator:()=>Nh,toInt32Array:()=>Kr,toInt32ArrayAsyncIterator:()=>Wh,toInt32ArrayIterator:()=>Lh,toInt8Array:()=>Bh,toInt8ArrayAsyncIterator:()=>zh,toInt8ArrayIterator:()=>Uh,toUint16Array:()=>xh,toUint16ArrayAsyncIterator:()=>$h,toUint16ArrayIterator:()=>kh,toUint32Array:()=>Dh,toUint32ArrayAsyncIterator:()=>Yh,toUint32ArrayIterator:()=>Ch,toUint8Array:()=>L,toUint8ArrayAsyncIterator:()=>Qo,toUint8ArrayIterator:()=>Zo,toUint8ClampedArray:()=>Mh,toUint8ClampedArrayAsyncIterator:()=>Kh,toUint8ClampedArrayIterator:()=>Hh});var vh=new TextDecoder("utf-8"),Jn=e=>vh.decode(e),Sh=new TextEncoder,Br=e=>Sh.encode(e),Ih=e=>typeof e=="number",Nc=e=>typeof e=="boolean",Dt=e=>typeof e=="function",zt=e=>e!=null&&Object(e)===e,Se=e=>zt(e)&&Dt(e.then),Ie=e=>zt(e)&&Dt(e[Symbol.iterator]),he=e=>zt(e)&&Dt(e[Symbol.asyncIterator]),is=e=>zt(e)&&zt(e.schema),ss=e=>zt(e)&&"done"in e&&"value"in e,os=e=>zt(e)&&Dt(e.stat)&&Ih(e.fd),as=e=>zt(e)&&qn(e.body),cs=e=>"_getDOMStream"in e&&"_getNodeStream"in e,Lc=e=>zt(e)&&Dt(e.abort)&&Dt(e.getWriter)&&!cs(e),qn=e=>zt(e)&&Dt(e.cancel)&&Dt(e.getReader)&&!cs(e),kc=e=>zt(e)&&Dt(e.end)&&Dt(e.write)&&Nc(e.writable)&&!cs(e),ls=e=>zt(e)&&Dt(e.read)&&Dt(e.pipe)&&Nc(e.readable)&&!cs(e),Cc=e=>zt(e)&&Dt(e.clear)&&Dt(e.bytes)&&Dt(e.position)&&Dt(e.setPosition)&&Dt(e.capacity)&&Dt(e.getBufferIdentifier)&&Dt(e.createLong),qo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Fh(e){let t=e[0]?[e[0]]:[],i,n,r,s;for(let a,o,u=0,f=0,y=e.length;++uy+g.byteLength,0),r,s,a,o=0,u=-1,f=Math.min(t||Number.POSITIVE_INFINITY,n);for(let y=i.length;++uW(Int8Array,e),Ah=e=>W(Int16Array,e),Kr=e=>W(Int32Array,e),Th=e=>W(BigInt64Array,e),L=e=>W(Uint8Array,e),xh=e=>W(Uint16Array,e),Dh=e=>W(Uint32Array,e),Eh=e=>W(BigUint64Array,e),Oh=e=>W(Float32Array,e),Rh=e=>W(Float64Array,e),Mh=e=>W(Uint8ClampedArray,e),Jo=e=>(e.next(),e);function*Ve(e,t){let i=function*(r){yield r},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof qo?i(t):Ie(t)?t:i(t);return yield*Gr(Jo(function*(r){let s=null;do s=r.next(yield W(e,s));while(!s.done)}(n[Symbol.iterator]()))),new e}var Uh=e=>Ve(Int8Array,e),Nh=e=>Ve(Int16Array,e),Lh=e=>Ve(Int32Array,e),Zo=e=>Ve(Uint8Array,e),kh=e=>Ve(Uint16Array,e),Ch=e=>Ve(Uint32Array,e),Ph=e=>Ve(Float32Array,e),Vh=e=>Ve(Float64Array,e),Hh=e=>Ve(Uint8ClampedArray,e);function Fe(e,t){return re(this,arguments,function*(){if(Se(t))return yield C(yield C(yield*Gr(gn(ve(Fe(e,yield C(t)))))));let i=function(s){return re(this,arguments,function*(){yield yield C(yield C(s))})},n=function(s){return re(this,arguments,function*(){yield C(yield*Gr(gn(ve(Jo(function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)}(s[Symbol.iterator]()))))))})},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof qo?i(t):Ie(t)?n(t):he(t)?t:i(t);return yield C(yield*Gr(gn(ve(Jo(function(s){return re(this,arguments,function*(){let a=null;do a=yield C(s.next(yield yield C(W(e,a))));while(!a.done)})}(r[Symbol.asyncIterator]())))))),yield C(new e)})}var zh=e=>Fe(Int8Array,e),jh=e=>Fe(Int16Array,e),Wh=e=>Fe(Int32Array,e),Qo=e=>Fe(Uint8Array,e),$h=e=>Fe(Uint16Array,e),Yh=e=>Fe(Uint32Array,e),Xh=e=>Fe(Float32Array,e),Gh=e=>Fe(Float64Array,e),Kh=e=>Fe(Uint8ClampedArray,e);function Zn(e,t,i){if(e!==0){i=i.slice(0,t+1);for(let n=-1;++n<=t;)i[n]+=e}return i}function ta(e,t){let i=0,n=e.length;if(n!==t.length)return!1;if(n>0)do if(e[i]!==t[i])return!1;while(++i(e.next(),e);function*Jh(e){let t,i=!1,n=[],r,s,a,o=0;function u(){return s==="peek"?ne(n,a)[0]:([r,n,o]=ne(n,a),r)}({cmd:s,size:a}=yield null);let f=Zo(e)[Symbol.iterator]();try{do if({done:t,value:r}=Number.isNaN(a-o)?f.next():f.next(a-o),!t&&r.byteLength>0&&(n.push(r),o+=r.byteLength),t||a<=o)do({cmd:s,size:a}=yield u());while(a0&&(n.push(r),o+=r.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield C(u()));while(a0&&(n.push(L(r)),o+=r.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield C(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return F(this,void 0,void 0,function*(){let{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return F(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let t=yield this.reader.read();return!t.done&&(t.value=L(t)),t})}},ra=(e,t)=>{let i=r=>n([t,r]),n;return[t,i,new Promise(r=>(n=r)&&e.once(t,i))]};function Qh(e){return re(this,arguments,function*(){let t=[],i="error",n=!1,r=null,s,a,o=0,u=[],f;function y(){return s==="peek"?ne(u,a)[0]:([f,u,o]=ne(u,a),f)}if({cmd:s,size:a}=yield yield C(null),e.isTTY)return yield yield C(new Uint8Array(0)),yield C(null);try{t[0]=ra(e,"end"),t[1]=ra(e,"error");do{if(t[2]=ra(e,"readable"),[i,r]=yield C(Promise.race(t.map(I=>I[2]))),i==="error")break;if((n=i==="end")||(Number.isFinite(a-o)?(f=L(e.read(a-o)),f.byteLength0&&(u.push(f),o+=f.byteLength)),n||a<=o)do({cmd:s,size:a}=yield yield C(y()));while(a{for(let[lt,Ht]of I)e.off(lt,Ht);try{let lt=e.destroy;lt&<.call(e,S),S=void 0}catch(lt){S=lt||S}finally{S!=null?At(S):x()}})}})}var Ot;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(Ot||(Ot={}));var yt;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(yt||(yt={}));var ht;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(ht||(ht={}));var Nt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Nt||(Nt={}));var G;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(G||(G={}));var jt;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(jt||(jt={}));var tt;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(tt||(tt={}));var h;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"})(h||(h={}));var pe;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(pe||(pe={}));var wa={};Xr(wa,{clampIndex:()=>jp,clampRange:()=>ri,createElementComparator:()=>xr});function He(e){if(e===null)return"null";if(e===void 0)return"undefined";switch(typeof e){case"number":return"".concat(e);case"bigint":return"".concat(e);case"string":return'"'.concat(e,'"')}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?"[".concat([...e].map(t=>He(t)),"]"):"[".concat(e,"]"):ArrayBuffer.isView(e)?"[".concat(e,"]"):JSON.stringify(e,(t,i)=>typeof i=="bigint"?"".concat(i):i)}var sa={};Xr(sa,{BN:()=>ti,bigNumToBigInt:()=>Hc,bigNumToString:()=>In,isArrowBigNumSymbol:()=>Pc});var Pc=Symbol.for("isArrowBigNum");function Be(e,...t){return t.length===0?Object.setPrototypeOf(W(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Be.prototype[Pc]=!0,Be.prototype.toJSON=function(){return'"'.concat(In(this),'"')},Be.prototype.valueOf=function(){return Vc(this)},Be.prototype.toString=function(){return In(this)},Be.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Vc(this);case"string":return In(this);case"default":return Hc(this)}return In(this)};function vn(...e){return Be.apply(this,e)}function Sn(...e){return Be.apply(this,e)}function Qn(...e){return Be.apply(this,e)}Object.setPrototypeOf(vn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Sn.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Qn.prototype,Object.create(Uint32Array.prototype)),Object.assign(vn.prototype,Be.prototype,{constructor:vn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Sn.prototype,Be.prototype,{constructor:Sn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Qn.prototype,Be.prototype,{constructor:Qn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});function Vc(e){let{buffer:t,byteOffset:i,length:n,signed:r}=e,s=new BigUint64Array(t,i,n),a=r&&s.at(-1)&BigInt(1)<{if(e.byteLength===8){let r=new e.BigIntArray(e.buffer,e.byteOffset,1);return"".concat(r[0])}if(!e.signed)return ia(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ia(e);t=t.slice();let i=1;for(let r=0;re.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:In(e);function ia(e){let t="",i=new Uint32Array(2),n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,a=n.length-1;do{for(i[0]=n[s=0];sNumber.MAX_SAFE_INTEGER))throw new TypeError("".concat(e," is not safe to convert to a number."));return Number(e)}var zc,jc,Wc,$c,Yc,Xc,Gc,Kc,Jc,qc,Zc,Qc,tl,el,rl,nl,il,sl,ol,D=class Wu{static isNull(t){return(t==null?void 0:t.typeId)===h.Null}static isInt(t){return(t==null?void 0:t.typeId)===h.Int}static isFloat(t){return(t==null?void 0:t.typeId)===h.Float}static isBinary(t){return(t==null?void 0:t.typeId)===h.Binary}static isUtf8(t){return(t==null?void 0:t.typeId)===h.Utf8}static isBool(t){return(t==null?void 0:t.typeId)===h.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===h.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===h.Date}static isTime(t){return(t==null?void 0:t.typeId)===h.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===h.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===h.Interval}static isList(t){return(t==null?void 0:t.typeId)===h.List}static isStruct(t){return(t==null?void 0:t.typeId)===h.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===h.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===h.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===h.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===h.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===h.Dictionary}static isDenseUnion(t){return Wu.isUnion(t)&&t.mode===yt.Dense}static isSparseUnion(t){return Wu.isUnion(t)&&t.mode===yt.Sparse}get typeId(){return h.NONE}};zc=Symbol.toStringTag,D[zc]=(e=>(e.children=null,e.ArrayType=Array,e[Symbol.toStringTag]="DataType"))(D.prototype);var Wt=class extends D{toString(){return"Null"}get typeId(){return h.Null}};jc=Symbol.toStringTag,Wt[jc]=(e=>e[Symbol.toStringTag]="Null")(Wt.prototype);var St=class extends D{constructor(e,t){super(),this.isSigned=e,this.bitWidth=t}get typeId(){return h.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 ".concat(this[Symbol.toStringTag]," type"))}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}};Wc=Symbol.toStringTag,St[Wc]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(St.prototype);var ze=class extends St{constructor(){super(!0,32)}get ArrayType(){return Int32Array}};Object.defineProperty(ze.prototype,"ArrayType",{value:Int32Array});var Kt=class extends D{constructor(e){super(),this.precision=e}get typeId(){return h.Float}get ArrayType(){switch(this.precision){case ht.HALF:return Uint16Array;case ht.SINGLE:return Float32Array;case ht.DOUBLE:return Float64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"Float".concat(this.precision<<5||16)}};$c=Symbol.toStringTag,Kt[$c]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(Kt.prototype);var nr=class extends D{constructor(){super()}get typeId(){return h.Binary}toString(){return"Binary"}};Yc=Symbol.toStringTag,nr[Yc]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(nr.prototype);var ir=class extends D{constructor(){super()}get typeId(){return h.Utf8}toString(){return"Utf8"}};Xc=Symbol.toStringTag,ir[Xc]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(ir.prototype);var sr=class extends D{constructor(){super()}get typeId(){return h.Bool}toString(){return"Bool"}};Gc=Symbol.toStringTag,sr[Gc]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(sr.prototype);var or=class extends D{constructor(e,t,i=128){super(),this.scale=e,this.precision=t,this.bitWidth=i}get typeId(){return h.Decimal}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};Kc=Symbol.toStringTag,or[Kc]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(or.prototype);var ar=class extends D{constructor(e){super(),this.unit=e}get typeId(){return h.Date}toString(){return"Date".concat((this.unit+1)*32,"<").concat(Nt[this.unit],">")}};Jc=Symbol.toStringTag,ar[Jc]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Date"))(ar.prototype);var Ae=class extends D{constructor(e,t){super(),this.unit=e,this.bitWidth=t}get typeId(){return h.Time}toString(){return"Time".concat(this.bitWidth,"<").concat(G[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};qc=Symbol.toStringTag,Ae[qc]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(Ae.prototype);var cr=class extends D{constructor(e,t){super(),this.unit=e,this.timezone=t}get typeId(){return h.Timestamp}toString(){return"Timestamp<".concat(G[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};Zc=Symbol.toStringTag,cr[Zc]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Timestamp"))(cr.prototype);var lr=class extends D{constructor(e){super(),this.unit=e}get typeId(){return h.Interval}toString(){return"Interval<".concat(jt[this.unit],">")}};Qc=Symbol.toStringTag,lr[Qc]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(lr.prototype);var Te=class extends D{constructor(e){super(),this.children=[e]}get typeId(){return h.List}toString(){return"List<".concat(this.valueType,">")}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};tl=Symbol.toStringTag,Te[tl]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Te.prototype);var ut=class extends D{constructor(e){super(),this.children=e}get typeId(){return h.Struct}toString(){return"Struct<{".concat(this.children.map(e=>"".concat(e.name,":").concat(e.type)).join(", "),"}>")}};el=Symbol.toStringTag,ut[el]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(ut.prototype);var xe=class extends D{constructor(e,t,i){super(),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((n,r,s)=>(n[r]=s)&&n||n,Object.create(null))}get typeId(){return h.Union}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(e=>"".concat(e.type)).join(" | "),">")}};rl=Symbol.toStringTag,xe[rl]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(xe.prototype);var ur=class extends D{constructor(e){super(),this.byteWidth=e}get typeId(){return h.FixedSizeBinary}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};nl=Symbol.toStringTag,ur[nl]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(ur.prototype);var De=class extends D{constructor(e,t){super(),this.listSize=e,this.children=[t]}get typeId(){return h.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}};il=Symbol.toStringTag,De[il]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(De.prototype);var Ee=class extends D{constructor(e,t=!1){super(),this.children=[e],this.keysSorted=t}get typeId(){return h.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<{".concat(this.children[0].type.children.map(e=>"".concat(e.name,":").concat(e.type)).join(", "),"}>")}};sl=Symbol.toStringTag,Ee[sl]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Ee.prototype);var tp=(e=>()=>++e)(-1),ie=class extends D{constructor(e,t,i,n){super(),this.indices=t,this.dictionary=e,this.isOrdered=n||!1,this.id=i==null?tp():Gt(i)}get typeId(){return h.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return"Dictionary<".concat(this.indices,", ").concat(this.dictionary,">")}};ol=Symbol.toStringTag,ie[ol]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(ie.prototype);function se(e){let t=e;switch(e.typeId){case h.Decimal:return e.bitWidth/32;case h.Timestamp:return 2;case h.Date:return 1+t.unit;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var E=class{visitMany(e,...t){return e.map((i,n)=>this.visit(i,...t.map(r=>r[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return ep(this,e,t)}getVisitFnByTypeId(e,t=!0){return Fn(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function ep(e,t,i=!0){return typeof t=="number"?Fn(e,t,i):typeof t=="string"&&t in h?Fn(e,h[t],i):t&&t instanceof D?Fn(e,al(t),i):t!=null&&t.type&&t.type instanceof D?Fn(e,al(t.type),i):Fn(e,h.NONE,i)}function Fn(e,t,i=!0){let n=null;switch(t){case h.Null:n=e.visitNull;break;case h.Bool:n=e.visitBool;break;case h.Int:n=e.visitInt;break;case h.Int8:n=e.visitInt8||e.visitInt;break;case h.Int16:n=e.visitInt16||e.visitInt;break;case h.Int32:n=e.visitInt32||e.visitInt;break;case h.Int64:n=e.visitInt64||e.visitInt;break;case h.Uint8:n=e.visitUint8||e.visitInt;break;case h.Uint16:n=e.visitUint16||e.visitInt;break;case h.Uint32:n=e.visitUint32||e.visitInt;break;case h.Uint64:n=e.visitUint64||e.visitInt;break;case h.Float:n=e.visitFloat;break;case h.Float16:n=e.visitFloat16||e.visitFloat;break;case h.Float32:n=e.visitFloat32||e.visitFloat;break;case h.Float64:n=e.visitFloat64||e.visitFloat;break;case h.Utf8:n=e.visitUtf8;break;case h.Binary:n=e.visitBinary;break;case h.FixedSizeBinary:n=e.visitFixedSizeBinary;break;case h.Date:n=e.visitDate;break;case h.DateDay:n=e.visitDateDay||e.visitDate;break;case h.DateMillisecond:n=e.visitDateMillisecond||e.visitDate;break;case h.Timestamp:n=e.visitTimestamp;break;case h.TimestampSecond:n=e.visitTimestampSecond||e.visitTimestamp;break;case h.TimestampMillisecond:n=e.visitTimestampMillisecond||e.visitTimestamp;break;case h.TimestampMicrosecond:n=e.visitTimestampMicrosecond||e.visitTimestamp;break;case h.TimestampNanosecond:n=e.visitTimestampNanosecond||e.visitTimestamp;break;case h.Time:n=e.visitTime;break;case h.TimeSecond:n=e.visitTimeSecond||e.visitTime;break;case h.TimeMillisecond:n=e.visitTimeMillisecond||e.visitTime;break;case h.TimeMicrosecond:n=e.visitTimeMicrosecond||e.visitTime;break;case h.TimeNanosecond:n=e.visitTimeNanosecond||e.visitTime;break;case h.Decimal:n=e.visitDecimal;break;case h.List:n=e.visitList;break;case h.Struct:n=e.visitStruct;break;case h.Union:n=e.visitUnion;break;case h.DenseUnion:n=e.visitDenseUnion||e.visitUnion;break;case h.SparseUnion:n=e.visitSparseUnion||e.visitUnion;break;case h.Dictionary:n=e.visitDictionary;break;case h.Interval:n=e.visitInterval;break;case h.IntervalDayTime:n=e.visitIntervalDayTime||e.visitInterval;break;case h.IntervalYearMonth:n=e.visitIntervalYearMonth||e.visitInterval;break;case h.FixedSizeList:n=e.visitFixedSizeList;break;case h.Map:n=e.visitMap;break}if(typeof n=="function")return n;if(!i)return()=>null;throw new Error("Unrecognized type '".concat(h[t],"'"))}function al(e){switch(e.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:i}=e;switch(t){case 8:return i?h.Int8:h.Uint8;case 16:return i?h.Int16:h.Uint16;case 32:return i?h.Int32:h.Uint32;case 64:return i?h.Int64:h.Uint64}return h.Int}case h.Float:switch(e.precision){case ht.HALF:return h.Float16;case ht.SINGLE:return h.Float32;case ht.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.Utf8:return h.Utf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(e.unit){case G.SECOND:return h.TimeSecond;case G.MILLISECOND:return h.TimeMillisecond;case G.MICROSECOND:return h.TimeMicrosecond;case G.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(e.unit){case G.SECOND:return h.TimestampSecond;case G.MILLISECOND:return h.TimestampMillisecond;case G.MICROSECOND:return h.TimestampMicrosecond;case G.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(e.unit){case Nt.DAY:return h.DateDay;case Nt.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(e.unit){case jt.DAY_TIME:return h.IntervalDayTime;case jt.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(e.mode){case yt.Dense:return h.DenseUnion;case yt.Sparse:return h.SparseUnion}return h.Union;case h.FixedSizeBinary:return h.FixedSizeBinary;case h.FixedSizeList:return h.FixedSizeList;case h.Dictionary:return h.Dictionary}throw new Error("Unrecognized type '".concat(h[e.typeId],"'"))}E.prototype.visitInt8=null,E.prototype.visitInt16=null,E.prototype.visitInt32=null,E.prototype.visitInt64=null,E.prototype.visitUint8=null,E.prototype.visitUint16=null,E.prototype.visitUint32=null,E.prototype.visitUint64=null,E.prototype.visitFloat16=null,E.prototype.visitFloat32=null,E.prototype.visitFloat64=null,E.prototype.visitDateDay=null,E.prototype.visitDateMillisecond=null,E.prototype.visitTimestampSecond=null,E.prototype.visitTimestampMillisecond=null,E.prototype.visitTimestampMicrosecond=null,E.prototype.visitTimestampNanosecond=null,E.prototype.visitTimeSecond=null,E.prototype.visitTimeMillisecond=null,E.prototype.visitTimeMicrosecond=null,E.prototype.visitTimeNanosecond=null,E.prototype.visitDenseUnion=null,E.prototype.visitSparseUnion=null,E.prototype.visitIntervalDayTime=null,E.prototype.visitIntervalYearMonth=null;var oa={};Xr(oa,{float64ToUint16:()=>ei,uint16ToFloat64:()=>vs});var cl=new Float64Array(1),Bn=new Uint32Array(cl.buffer);function vs(e){let t=(e&31744)>>10,i=(e&1023)/1024,n=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return n*(i?Number.NaN:1/0);case 0:return n*(i?6103515625e-14*i:0)}return n*Math.pow(2,t-15)*(1+i)}function ei(e){if(e!==e)return 32256;cl[0]=e;let t=(Bn[1]&2147483648)>>16&65535,i=Bn[1]&2146435072,n=0;return i>=1089470464?Bn[0]>0?i=31744:(i=(i&2080374784)>>16,n=(Bn[1]&1048575)>>10):i<=1056964608?(n=1048576+(Bn[1]&1048575),n=1048576+(n<<(i>>20)-998)>>21,i=0):(i=i-1056964608>>10,n=(Bn[1]&1048575)+512>>10),t|i|n&65535}var k=class extends E{};function j(e){return(t,i,n)=>{if(t.setValid(i,n!=null))return e(t,i,n)}}var rp=(e,t,i)=>{e[t]=Math.trunc(i/864e5)},aa=(e,t,i)=>{e[t]=Math.trunc(i%4294967296),e[t+1]=Math.trunc(i/4294967296)},np=(e,t,i)=>{e[t]=Math.trunc(i*1e3%4294967296),e[t+1]=Math.trunc(i*1e3/4294967296)},ip=(e,t,i)=>{e[t]=Math.trunc(i*1e6%4294967296),e[t+1]=Math.trunc(i*1e6/4294967296)},ll=(e,t,i,n)=>{if(i+1{let r=e+i;n?t[r>>3]|=1<>3]&=~(1<{e[t]=i},ca=({values:e},t,i)=>{e[t]=i},ul=({values:e},t,i)=>{e[t]=ei(i)},op=(e,t,i)=>{switch(e.type.precision){case ht.HALF:return ul(e,t,i);case ht.SINGLE:case ht.DOUBLE:return ca(e,t,i)}},Ss=({values:e},t,i)=>{rp(e,t,i.valueOf())},Is=({values:e},t,i)=>{aa(e,t*2,i.valueOf())},la=({stride:e,values:t},i,n)=>{t.set(n.subarray(0,e),e*i)},ap=({values:e,valueOffsets:t},i,n)=>ll(e,t,i,n),cp=({values:e,valueOffsets:t},i,n)=>{ll(e,t,i,Br(n))},ua=(e,t,i)=>{e.type.unit===Nt.DAY?Ss(e,t,i):Is(e,t,i)},Fs=({values:e},t,i)=>aa(e,t*2,i/1e3),Bs=({values:e},t,i)=>aa(e,t*2,i),As=({values:e},t,i)=>np(e,t*2,i),Ts=({values:e},t,i)=>ip(e,t*2,i),da=(e,t,i)=>{switch(e.type.unit){case G.SECOND:return Fs(e,t,i);case G.MILLISECOND:return Bs(e,t,i);case G.MICROSECOND:return As(e,t,i);case G.NANOSECOND:return Ts(e,t,i)}},xs=({values:e},t,i)=>{e[t]=i},Ds=({values:e},t,i)=>{e[t]=i},Es=({values:e},t,i)=>{e[t]=i},Os=({values:e},t,i)=>{e[t]=i},fa=(e,t,i)=>{switch(e.type.unit){case G.SECOND:return xs(e,t,i);case G.MILLISECOND:return Ds(e,t,i);case G.MICROSECOND:return Es(e,t,i);case G.NANOSECOND:return Os(e,t,i)}},ha=({values:e,stride:t},i,n)=>{e.set(n.subarray(0,t),t*i)},lp=(e,t,i)=>{let n=e.children[0],r=e.valueOffsets,s=Lt.getVisitFn(n);if(Array.isArray(i))for(let a=-1,o=r[t],u=r[t+1];o{let n=e.children[0],{valueOffsets:r}=e,s=Lt.getVisitFn(n),{[t]:a,[t+1]:o}=r,u=i instanceof Map?i.entries():Object.entries(i);for(let f of u)if(s(n,a,f),++a>=o)break},dp=(e,t)=>(i,n,r,s)=>n&&i(n,e,t[s]),fp=(e,t)=>(i,n,r,s)=>n&&i(n,e,t.get(s)),hp=(e,t)=>(i,n,r,s)=>n&&i(n,e,t.get(r.name)),pp=(e,t)=>(i,n,r,s)=>n&&i(n,e,t[r.name]),mp=(e,t,i)=>{let n=e.type.children.map(s=>Lt.getVisitFn(s.type)),r=i instanceof Map?hp(t,i):i instanceof J?fp(t,i):Array.isArray(i)?dp(t,i):pp(t,i);e.type.children.forEach((s,a)=>r(n[a],e.children[a],s,a))},yp=(e,t,i)=>{e.type.mode===yt.Dense?dl(e,t,i):fl(e,t,i)},dl=(e,t,i)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];Lt.visit(r,e.valueOffsets[t],i)},fl=(e,t,i)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];Lt.visit(r,t,i)},_p=(e,t,i)=>{var n;(n=e.dictionary)===null||n===void 0||n.set(e.values[t],i)},pa=(e,t,i)=>{e.type.unit===jt.DAY_TIME?Rs(e,t,i):Ms(e,t,i)},Rs=({values:e},t,i)=>{e.set(i.subarray(0,2),2*t)},Ms=({values:e},t,i)=>{e[t]=i[0]*12+i[1]%12},bp=(e,t,i)=>{let{stride:n}=e,r=e.children[0],s=Lt.getVisitFn(r);if(Array.isArray(i))for(let a=-1,o=t*n;++a"".concat(He(e),": ").concat(He(t))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ma(this[Oe],this[An])}},ma=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return et.name)}has(e,t){return e[Oe].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[Oe].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let i=e[Oe].type.children.findIndex(n=>n.name===t);if(i!==-1){let n=Bt.visit(e[Oe].children[i],e[An]);return Reflect.set(e,t,n),n}}set(e,t,i){let n=e[Oe].type.children.findIndex(r=>r.name===t);return n!==-1?(Lt.visit(e[Oe].children[n],e[An],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}},R=class extends E{};function V(e){return(t,i)=>t.getValid(i)?e(t,i):null}var gp=(e,t)=>864e5*e[t],_a=(e,t)=>4294967296*e[t+1]+(e[t]>>>0),wp=(e,t)=>4294967296*(e[t+1]/1e3)+(e[t]>>>0)/1e3,vp=(e,t)=>4294967296*(e[t+1]/1e6)+(e[t]>>>0)/1e6,hl=e=>new Date(e),Sp=(e,t)=>hl(gp(e,t)),Ip=(e,t)=>hl(_a(e,t)),Fp=(e,t)=>null,pl=(e,t,i)=>{if(i+1>=t.length)return null;let n=t[i],r=t[i+1];return e.subarray(n,r)},Bp=({offset:e,values:t},i)=>{let n=e+i;return(t[n>>3]&1<Sp(e,t),yl=({values:e},t)=>Ip(e,t*2),Tr=({stride:e,values:t},i)=>t[e*i],Ap=({stride:e,values:t},i)=>vs(t[e*i]),_l=({values:e},t)=>e[t],Tp=({stride:e,values:t},i)=>t.subarray(e*i,e*(i+1)),xp=({values:e,valueOffsets:t},i)=>pl(e,t,i),Dp=({values:e,valueOffsets:t},i)=>{let n=pl(e,t,i);return n!==null?Jn(n):null},Ep=({values:e},t)=>e[t],Op=({type:e,values:t},i)=>e.precision!==ht.HALF?t[i]:vs(t[i]),Rp=(e,t)=>e.type.unit===Nt.DAY?ml(e,t):yl(e,t),bl=({values:e},t)=>1e3*_a(e,t*2),gl=({values:e},t)=>_a(e,t*2),wl=({values:e},t)=>wp(e,t*2),vl=({values:e},t)=>vp(e,t*2),Mp=(e,t)=>{switch(e.type.unit){case G.SECOND:return bl(e,t);case G.MILLISECOND:return gl(e,t);case G.MICROSECOND:return wl(e,t);case G.NANOSECOND:return vl(e,t)}},Sl=({values:e},t)=>e[t],Il=({values:e},t)=>e[t],Fl=({values:e},t)=>e[t],Bl=({values:e},t)=>e[t],Up=(e,t)=>{switch(e.type.unit){case G.SECOND:return Sl(e,t);case G.MILLISECOND:return Il(e,t);case G.MICROSECOND:return Fl(e,t);case G.NANOSECOND:return Bl(e,t)}},Np=({values:e,stride:t},i)=>ti.decimal(e.subarray(t*i,t*(i+1))),Lp=(e,t)=>{let{valueOffsets:i,stride:n,children:r}=e,{[t*n]:s,[t*n+1]:a}=i,o=r[0].slice(s,a-s);return new J([o])},kp=(e,t)=>{let{valueOffsets:i,children:n}=e,{[t]:r,[t+1]:s}=i,a=n[0];return new je(a.slice(r,s-r))},Cp=(e,t)=>new Ar(e,t),Pp=(e,t)=>e.type.mode===yt.Dense?Al(e,t):Tl(e,t),Al=(e,t)=>{let i=e.type.typeIdToChildIndex[e.typeIds[t]],n=e.children[i];return Bt.visit(n,e.valueOffsets[t])},Tl=(e,t)=>{let i=e.type.typeIdToChildIndex[e.typeIds[t]],n=e.children[i];return Bt.visit(n,t)},Vp=(e,t)=>{var i;return(i=e.dictionary)===null||i===void 0?void 0:i.get(e.values[t])},Hp=(e,t)=>e.type.unit===jt.DAY_TIME?xl(e,t):Dl(e,t),xl=({values:e},t)=>e.subarray(2*t,2*(t+1)),Dl=({values:e},t)=>{let i=e[t],n=new Int32Array(2);return n[0]=Math.trunc(i/12),n[1]=Math.trunc(i%12),n},zp=(e,t)=>{let{stride:i,children:n}=e,r=n[0].slice(t*i,i);return new J([r])};R.prototype.visitNull=V(Fp),R.prototype.visitBool=V(Bp),R.prototype.visitInt=V(Ep),R.prototype.visitInt8=V(Tr),R.prototype.visitInt16=V(Tr),R.prototype.visitInt32=V(Tr),R.prototype.visitInt64=V(_l),R.prototype.visitUint8=V(Tr),R.prototype.visitUint16=V(Tr),R.prototype.visitUint32=V(Tr),R.prototype.visitUint64=V(_l),R.prototype.visitFloat=V(Op),R.prototype.visitFloat16=V(Ap),R.prototype.visitFloat32=V(Tr),R.prototype.visitFloat64=V(Tr),R.prototype.visitUtf8=V(Dp),R.prototype.visitBinary=V(xp),R.prototype.visitFixedSizeBinary=V(Tp),R.prototype.visitDate=V(Rp),R.prototype.visitDateDay=V(ml),R.prototype.visitDateMillisecond=V(yl),R.prototype.visitTimestamp=V(Mp),R.prototype.visitTimestampSecond=V(bl),R.prototype.visitTimestampMillisecond=V(gl),R.prototype.visitTimestampMicrosecond=V(wl),R.prototype.visitTimestampNanosecond=V(vl),R.prototype.visitTime=V(Up),R.prototype.visitTimeSecond=V(Sl),R.prototype.visitTimeMillisecond=V(Il),R.prototype.visitTimeMicrosecond=V(Fl),R.prototype.visitTimeNanosecond=V(Bl),R.prototype.visitDecimal=V(Np),R.prototype.visitList=V(Lp),R.prototype.visitStruct=V(Cp),R.prototype.visitUnion=V(Pp),R.prototype.visitDenseUnion=V(Al),R.prototype.visitSparseUnion=V(Tl),R.prototype.visitDictionary=V(Vp),R.prototype.visitInterval=V(Hp),R.prototype.visitIntervalDayTime=V(xl),R.prototype.visitIntervalYearMonth=V(Dl),R.prototype.visitFixedSizeList=V(zp),R.prototype.visitMap=V(kp);var Bt=new R,me=Symbol.for("keys"),Tn=Symbol.for("vals"),je=class{constructor(e){return this[me]=new J([e.children[0]]).memoize(),this[Tn]=e.children[1],new Proxy(this,new ga)}[Symbol.iterator](){return new ba(this[me],this[Tn])}get size(){return this[me].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[me],t=this[Tn],i={};for(let n=-1,r=e.length;++n"".concat(He(e),": ").concat(He(t))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},ba=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Bt.visit(this.vals,e)]})}},ga=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[me].toArray().map(String)}has(e,t){return e[me].includes(t)}getOwnPropertyDescriptor(e,t){if(e[me].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let i=e[me].indexOf(t);if(i!==-1){let n=Bt.visit(Reflect.get(e,Tn),i);return Reflect.set(e,t,n),n}}set(e,t,i){let n=e[me].indexOf(t);return n!==-1?(Lt.visit(Reflect.get(e,Tn),n,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}};Object.defineProperties(je.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[me]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Tn]:{writable:!0,enumerable:!1,configurable:!1,value:null}});function jp(e,t,i){let n=e.length,r=t>-1?t:n+t%n;return i?i(e,r):r}var El;function ri(e,t,i,n){let{length:r=0}=e,s=typeof t!="number"?0:t,a=typeof i!="number"?r:i;return s<0&&(s=(s%r+r)%r),a<0&&(a=(a%r+r)%r),ar&&(a=r),n?n(e,s,a):[s,a]}var Ol=e=>e!==e;function xr(e){if(typeof e!="object"||e===null)return Ol(e)?Ol:t=>t===e;if(e instanceof Date){let t=e.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?ta(e,t):!1:e instanceof Map?$p(e):Array.isArray(e)?Wp(e):e instanceof J?Yp(e):Xp(e,!0)}function Wp(e){let t=[];for(let i=-1,n=e.length;++i!1;let n=[];for(let r=-1,s=i.length;++r{if(!i||typeof i!="object")return!1;switch(i.constructor){case Array:return Gp(e,i);case Map:return Rl(e,i,i.keys());case je:case Ar:case Object:case void 0:return Rl(e,i,t||Object.keys(i))}return i instanceof J?Kp(e,i):!1}}function Gp(e,t){let i=e.length;if(t.length!==i)return!1;for(let n=-1;++nJr,getBit:()=>Ml,getBool:()=>Ls,packBools:()=>qr,popcnt_array:()=>Ul,popcnt_bit_range:()=>ni,popcnt_uint32:()=>Ns,setBool:()=>Jp,truncateBitmap:()=>xn});function Ls(e,t,i,n){return(i&1<>n}function Jp(e,t,i){return i?!!(e[t>>3]|=1<>3]&=~(1<0||i.byteLength>3):qr(new Jr(i,e,t,null,Ls)).subarray(0,n)),r}return i}function qr(e){let t=[],i=0,n=0,r=0;for(let a of e)a&&(r|=1<0)&&(t[i++]=r);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var Jr=class{constructor(e,t,i,n,r){this.bytes=e,this.length=i,this.context=n,this.get=r,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=t+(t%8===0?0:8-t%8);return ni(e,t,r)+ni(e,n,i)+Ul(e,r>>3,n-r>>3)}function Ul(e,t,i){let n=0,r=Math.trunc(t),s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=i===void 0?e.byteLength:r+i;for(;a-r>=4;)n+=Ns(s.getUint32(r)),r+=4;for(;a-r>=2;)n+=Ns(s.getUint16(r)),r+=2;for(;a-r>=1;)n+=Ns(s.getUint8(r)),r+=1;return n}function Ns(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var qp=-1,at=class qu{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,{valueOffsets:i,values:n,nullBitmap:r,typeIds:s}=this;return i&&(t+=i.byteLength),n&&(t+=n.byteLength),r&&(t+=r.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){let t=this._nullCount,i;return t<=qp&&(i=this.nullBitmap)&&(this._nullCount=t=this.length-ni(i,this.offset,this.offset+this.length)),t}constructor(t,i,n,r,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(i||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(r||0,-1));let u;s instanceof qu?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=se(t),s&&((u=s[0])&&(this.valueOffsets=u),(u=s[1])&&(this.values=u),(u=s[2])&&(this.nullBitmap=u),(u=s[3])&&(this.typeIds=u))),this.nullable=this._nullCount!==0&&this.nullBitmap&&this.nullBitmap.byteLength>0}getValid(t){if(this.nullable&&this.nullCount>0){let i=this.offset+t;return(this.nullBitmap[i>>3]&1<>3){let{nullBitmap:u}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:u,_nullCount:0})}let{nullBitmap:n,offset:r}=this,s=r+t>>3,a=(r+t)%8,o=n[s]>>a&1;return i?o===0&&(n[s]|=1<>3).fill(255,0,i>>3);r[i>>3]=(1<0&&r.set(xn(this.offset,i,this.nullBitmap),0);let s=this.buffers;return s[pe.VALIDITY]=r,this.clone(this.type,0,t,n+(t-i),s)}_sliceBuffers(t,i,n,r){let s,{buffers:a}=this;return(s=a[pe.TYPE])&&(a[pe.TYPE]=s.subarray(t,t+i)),(s=a[pe.OFFSET])&&(a[pe.OFFSET]=s.subarray(t,t+i+1))||(s=a[pe.DATA])&&(a[pe.DATA]=r===6?s:s.subarray(n*t,n*(t+i))),a}_sliceChildren(t,i,n){return t.map(r=>r.slice(i,n))}};at.prototype.children=Object.freeze([]);var Sa=class vu extends E{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:i,["offset"]:n=0,["length"]:r=0}=t;return new at(i,n,r,0)}visitBool(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitInt(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitFloat(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitUtf8(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.data),s=L(t.nullBitmap),a=Kr(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new at(i,n,o,u,[a,r,s])}visitBinary(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.data),s=L(t.nullBitmap),a=Kr(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new at(i,n,o,u,[a,r,s])}visitFixedSizeBinary(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitDate(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitTimestamp(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitTime(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitDecimal(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitList(t){let{["type"]:i,["offset"]:n=0,["child"]:r}=t,s=L(t.nullBitmap),a=Kr(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new at(i,n,o,u,[a,void 0,s],[r])}visitStruct(t){let{["type"]:i,["offset"]:n=0,["children"]:r=[]}=t,s=L(t.nullBitmap),{length:a=r.reduce((u,{length:f})=>Math.max(u,f),0),nullCount:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,void 0,s],r)}visitUnion(t){let{["type"]:i,["offset"]:n=0,["children"]:r=[]}=t,s=L(t.nullBitmap),a=W(i.ArrayType,t.typeIds),{["length"]:o=a.length,["nullCount"]:u=t.nullBitmap?-1:0}=t;if(D.isSparseUnion(i))return new at(i,n,o,u,[void 0,void 0,s,a],r);let f=Kr(t.valueOffsets);return new at(i,n,o,u,[f,void 0,s,a],r)}visitDictionary(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.indices.ArrayType,t.data),{["dictionary"]:a=new J([new vu().visit({type:i.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new at(i,n,o,u,[void 0,s,r],[],a)}visitInterval(t){let{["type"]:i,["offset"]:n=0}=t,r=L(t.nullBitmap),s=W(i.ArrayType,t.data),{["length"]:a=s.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,s,r])}visitFixedSizeList(t){let{["type"]:i,["offset"]:n=0,["child"]:r=new vu().visit({type:i.valueType})}=t,s=L(t.nullBitmap),{["length"]:a=r.length/se(i),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new at(i,n,a,o,[void 0,void 0,s],[r])}visitMap(t){let{["type"]:i,["offset"]:n=0,["child"]:r=new vu().visit({type:i.childType})}=t,s=L(t.nullBitmap),a=Kr(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new at(i,n,o,u,[a,void 0,s],[r])}};function P(e){return new Sa().visit(e)}var ii=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext+i.nullCount,0)}function Cs(e){return e.reduce((t,i,n)=>(t[n+1]=t[n]+i.length,t),new Uint32Array(e.length+1))}function Ps(e,t,i,n){let r=[];for(let s=-1,a=e.length;++s=n)break;if(i>=u+f)continue;if(u>=i&&u+f<=n){r.push(o);continue}let y=Math.max(0,i-u),g=Math.min(n-u,f);r.push(o.slice(y,g-y))}return r.length===0&&r.push(e[0].slice(0,0)),r}function Ia(e,t,i,n){let r=0,s=0,a=t.length-1;do{if(r>=a-1)return i0?0:-1}function Qp(e,t){let{nullBitmap:i}=e;if(!i||e.nullCount<=0)return-1;let n=0;for(let r of new Jr(i,e.offset+(t||0),e.length,i,Ls)){if(!r)return n;++n}return-1}function $(e,t,i){if(t===void 0)return-1;if(t===null)return Qp(e,i);let n=Bt.getVisitFn(e),r=xr(t);for(let s=(i||0)-1,a=e.length;++s{let r=e.data[n];return r.values.subarray(0,r.length)[Symbol.iterator]()});let i=0;return new ii(e.data.length,n=>{let r=e.data[n].length,s=e.slice(i,i+r);return i+=r,new Fa(s)})}var Fa=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe+t,We=class extends E{visitNull(e,t){return 0}visitInt(e,t){return e.type.bitWidth/8}visitFloat(e,t){return e.type.ArrayType.BYTES_PER_ELEMENT}visitBool(e,t){return 1/8}visitDecimal(e,t){return e.type.bitWidth/8}visitDate(e,t){return(e.type.unit+1)*4}visitTime(e,t){return e.type.bitWidth/8}visitTimestamp(e,t){return e.type.unit===G.SECOND?4:8}visitInterval(e,t){return(e.type.unit+1)*4}visitStruct(e,t){return e.children.reduce((i,n)=>i+oe.visit(n,t),0)}visitFixedSizeBinary(e,t){return e.type.byteWidth}visitMap(e,t){return 8+e.children.reduce((i,n)=>i+oe.visit(n,t),0)}visitDictionary(e,t){var i;return e.type.indices.bitWidth/8+(((i=e.dictionary)===null||i===void 0?void 0:i.getByteLength(e.values[t]))||0)}},em=({valueOffsets:e},t)=>8+(e[t+1]-e[t]),rm=({valueOffsets:e},t)=>8+(e[t+1]-e[t]),nm=({valueOffsets:e,stride:t,children:i},n)=>{let r=i[0],{[n*t]:s}=e,{[n*t+1]:a}=e,o=oe.getVisitFn(r.type),u=r.slice(s,a-s),f=8;for(let y=-1,g=a-s;++y{let n=t[0],r=n.slice(i*e,e),s=oe.getVisitFn(n.type),a=0;for(let o=-1,u=r.length;++oe.type.mode===yt.Dense?Ll(e,t):kl(e,t),Ll=({type:e,children:t,typeIds:i,valueOffsets:n},r)=>{let s=e.typeIdToChildIndex[i[r]];return 8+oe.visit(t[s],n[r])},kl=({children:e},t)=>4+oe.visitMany(e,e.map(()=>t)).reduce(tm,0);We.prototype.visitUtf8=em,We.prototype.visitBinary=rm,We.prototype.visitList=nm,We.prototype.visitFixedSizeList=im,We.prototype.visitUnion=sm,We.prototype.visitDenseUnion=Ll,We.prototype.visitSparseUnion=kl;var oe=new We,Cl,Pl={},Vl={},J=class pn{constructor(t){var i,n,r;let s=t[0]instanceof pn?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof at)))throw new TypeError("Vector constructor expects an Array of Data instances.");let a=(i=s[0])===null||i===void 0?void 0:i.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:o,set:u,indexOf:f,byteLength:y}=Pl[a.typeId],g=s[0];this.isValid=I=>si(g,I),this.get=I=>o(g,I),this.set=(I,S)=>u(g,I,S),this.indexOf=I=>f(g,I),this.getByteLength=I=>y(g,I),this._offsets=[0,g.length];break}default:Object.setPrototypeOf(this,Vl[a.typeId]),this._offsets=Cs(s);break}this.data=s,this.type=a,this.stride=se(a),this.numChildren=(r=(n=a.children)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0,this.length=this._offsets.at(-1)}get byteLength(){return this._byteLength===-1&&(this._byteLength=this.data.reduce((t,i)=>t+i.byteLength,0)),this._byteLength}get nullCount(){return this._nullCount===-1&&(this._nullCount=ks(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return"".concat(this.VectorName,"<").concat(this.type[Symbol.toStringTag],">")}get VectorName(){return"".concat(h[this.type.typeId],"Vector")}isValid(t){return!1}get(t){return null}set(t,i){}indexOf(t,i){return-1}includes(t,i){return this.indexOf(t,i)>0}getByteLength(t){return 0}[Symbol.iterator](){return Dn.visit(this)}concat(...t){return new pn(this.data.concat(t.flatMap(i=>i.data).flat(Number.POSITIVE_INFINITY)))}slice(t,i){return new pn(ri(this,t,i,({data:n,_offsets:r},s,a)=>Ps(n,r,s,a)))}toJSON(){return[...this]}toArray(){let{type:t,data:i,length:n,stride:r,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(i.length){case 0:return new s;case 1:return i[0].values.subarray(0,n*r);default:return i.reduce((a,{values:o,length:u})=>(a.array.set(o.subarray(0,u*r),a.offset),a.offset+=u*r,a),{array:new s(n*r),offset:0}).array}}return[...this]}toString(){return"[".concat([...this].join(","),"]")}getChild(t){var i;return this.getChildAt((i=this.type.children)===null||i===void 0?void 0:i.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&ti[t])):null}get isMemoized(){return D.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(D.isDictionary(this.type)){let t=new zs(this.data[0].dictionary),i=this.data.map(n=>{let r=n.clone();return r.dictionary=t,r});return new pn(i)}return new zs(this)}unmemoize(){if(D.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),i=this.data.map(n=>{let r=n.clone();return r.dictionary=t,r});return new pn(i)}return this}};Cl=Symbol.toStringTag,J[Cl]=(e=>{e.type=D.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._nullCount=-1,e._byteLength=-1,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(h).map(i=>h[i]).filter(i=>typeof i=="number"&&i!==h.NONE);for(let i of t){let n=Bt.getVisitFnByTypeId(i),r=Lt.getVisitFnByTypeId(i),s=Zr.getVisitFnByTypeId(i),a=oe.getVisitFnByTypeId(i);Pl[i]={get:n,set:r,indexOf:s,byteLength:a},Vl[i]=Object.create(e,{isValid:{value:Dr(si)},get:{value:Dr(Bt.getVisitFnByTypeId(i))},set:{value:Vs(Lt.getVisitFnByTypeId(i))},indexOf:{value:Hs(Zr.getVisitFnByTypeId(i))},getByteLength:{value:Dr(oe.getVisitFnByTypeId(i))}})}return"Vector"})(J.prototype);var zs=class pc extends J{constructor(t){super(t.data);let i=this.get,n=this.set,r=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){let o=s[a];if(o!==void 0)return o;let u=i.call(this,a);return s[a]=u,u}}),Object.defineProperty(this,"set",{value(a,o){n.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new pc(r.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new J(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Hl(e){if(!e||e.length<=0)return function(n){return!0};let t="",i=e.filter(n=>n===n);return i.length>0&&(t=` switch (x) {`.concat(i.map(n=>` case `.concat(om(n),":")).join(""),` return false; }`)),e.length!==i.length&&(t=`if (x !== x) return false; `.concat(t)),new Function("x","".concat(t,` return true;`))}function om(e){return typeof e!="bigint"?He(e):"".concat(He(e),"n")}var Ba=(e,t)=>(Math.ceil(e)*t+63&-64||64)/t,am=(e,t=0)=>e.length>=t?e.subarray(0,t):wn(new e.constructor(t),e,0),Er=class{constructor(e,t=1){this.buffer=e,this.stride=t,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e.constructor,this._resize(this.length=Math.ceil(e.length/t))}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(e,t){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let t=this.stride,i=this.length*t,n=this.buffer.length;i>=n&&this._resize(n===0?Ba(i*1,this.BYTES_PER_ELEMENT):Ba(i*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Ba(e*this.stride,this.BYTES_PER_ELEMENT);let t=am(this.buffer,e);return this.clear(),t}clear(){return this.length=0,this._resize(0),this}_resize(e){return this.buffer=wn(new this.ArrayType(e),this.buffer)}};Er.prototype.offset=0;var fr=class extends Er{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,t){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=t,this}},En=class extends fr{constructor(e=new Uint8Array(0)){super(e,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,t){let{buffer:i}=this.reserve(e-this.length+1),n=e>>3,r=e%8,s=i[n]>>r&1;return t?s===0&&(i[n]|=1<this.length&&this.set(e-1,0),super.flush(e+1)}},pt=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:t}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=t,this.stride=se(e),this._nulls=new En,t&&t.length>0&&(this._isValid=Hl(t))}toVector(){return new J([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:t,_values:i,_nulls:n,_typeIds:r,children:s}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),s.reduce((a,o)=>a+o.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((t,i)=>t+i.reservedByteLength,e)}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(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,t){return this.setValid(e,this.isValid(t))&&this.setValue(e,t),this}setValue(e,t){this._setValue(this,e,t)}setValid(e,t){return this.length=this._nulls.set(e,+t).length,t}addChild(e,t="".concat(this.numChildren)){throw new Error('Cannot append children to non-nested type "'.concat(this.type,'"'))}getChildAt(e){return this.children[e]||null}flush(){let e,t,i,n,{type:r,length:s,nullCount:a,_typeIds:o,_offsets:u,_values:f,_nulls:y}=this;(t=o==null?void 0:o.flush(s))?n=u==null?void 0:u.flush(s):(n=u==null?void 0:u.flush(s))?e=f==null?void 0:f.flush(u.last()):e=f==null?void 0:f.flush(s),a>0&&(i=y==null?void 0:y.flush(s));let g=this.children.map(I=>I.flush());return this.clear(),P({type:r,length:s,nullCount:a,children:g,child:g[0],data:e,typeIds:t,nullBitmap:i,valueOffsets:n})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,t,i,n;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(t=this._values)===null||t===void 0||t.clear(),(i=this._offsets)===null||i===void 0||i.clear(),(n=this._typeIds)===null||n===void 0||n.clear();for(let r of this.children)r.clear();return this}};pt.prototype.length=1,pt.prototype.stride=1,pt.prototype.children=null,pt.prototype.finished=!1,pt.prototype.nullValues=null,pt.prototype._isValid=()=>!0;var Rt=class extends pt{constructor(e){super(e),this._values=new fr(new this.ArrayType(0),this.stride)}setValue(e,t){let i=this._values;return i.reserve(e-i.length+1),super.setValue(e,t)}},$e=class extends pt{constructor(e){super(e),this._pendingLength=0,this._offsets=new On}setValue(e,t){let i=this._pending||(this._pending=new Map),n=i.get(e);n&&(this._pendingLength-=n.length),this._pendingLength+=t instanceof je?t[me].length:t.length,i.set(e,t)}setValid(e,t){return super.setValid(e,t)?!0:((this._pending||(this._pending=new Map)).set(e,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(){let e=this._pending,t=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,t),this}},Qr=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,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(e,t,i,n){return e.prep(8,24),e.writeInt64(BigInt(n??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}},Ye=new Int32Array(2),js=new Float32Array(Ye.buffer),Ws=new Float64Array(Ye.buffer),Rn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,oi;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(oi||(oi={}));var ae=class yc{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new yc(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,i){this.bytes_[t]=i,this.bytes_[t+1]=i>>8}writeInt32(t,i){this.bytes_[t]=i,this.bytes_[t+1]=i>>8,this.bytes_[t+2]=i>>16,this.bytes_[t+3]=i>>24}writeUint32(t,i){this.bytes_[t]=i,this.bytes_[t+1]=i>>8,this.bytes_[t+2]=i>>16,this.bytes_[t+3]=i>>24}writeInt64(t,i){this.writeInt32(t,Number(BigInt.asIntN(32,i))),this.writeInt32(t+4,Number(BigInt.asIntN(32,i>>BigInt(32))))}writeUint64(t,i){this.writeUint32(t,Number(BigInt.asUintN(32,i))),this.writeUint32(t+4,Number(BigInt.asUintN(32,i>>BigInt(32))))}writeFloat32(t,i){js[0]=i,this.writeInt32(t,Ye[0])}writeFloat64(t,i){Ws[0]=i,this.writeInt32(t,Ye[Rn?0:1]),this.writeInt32(t+4,Ye[Rn?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+i)+1&t-1;for(;this.space=0&&this.vtable[i]==0;i--);let n=i+1;for(;i>=0;i--)this.addInt16(this.vtable[i]!=0?t-this.vtable[i]:0);let r=2;this.addInt16(t-this.object_start);let s=(n+r)*2;this.addInt16(s);let a=0,o=this.space;t:for(i=0;i=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,i){this.finish(t,i,!0)}requiredField(t,i){let n=this.bb.capacity()-t,r=n-this.bb.readInt32(n);if(!(i=0;n--)t.addInt32(i[n]);return t.endVector()}static startTypeIdsVector(t,i){t.startVector(4,i,4)}static endUnion(t){return t.endObject()}static createUnion(t,i,n){return Yn.startUnion(t),Yn.addMode(t,i),Yn.addTypeIds(t,n),Yn.endUnion(t)}},_i=class Po{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsUtf8(t,i){return(i||new Po).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,i){return t.setPosition(t.position()+4),(i||new Po).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Po.startUtf8(t),Po.endUtf8(t)}},mt;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(mt||(mt={}));var Pt=class wu{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsField(t,i){return(i||new wu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,i){return t.setPosition(t.position()+4),(i||new wu).__init(t.readInt32(t.position())+t.position(),t)}name(t){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):mt.NONE}type(t){let i=this.bb.__offset(this.bb_pos,10);return i?this.bb.__union(t,this.bb_pos+i):null}dictionary(t){let i=this.bb.__offset(this.bb_pos,12);return i?(t||new Xe).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}children(t,i){let n=this.bb.__offset(this.bb_pos,14);return n?(i||new wu).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,i){let n=this.bb.__offset(this.bb_pos,16);return n?(i||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let 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,i){t.addFieldOffset(0,i,0)}static addNullable(t,i){t.addFieldInt8(1,+i,0)}static addTypeType(t,i){t.addFieldInt8(2,i,mt.NONE)}static addType(t,i){t.addFieldOffset(3,i,0)}static addDictionary(t,i){t.addFieldOffset(4,i,0)}static addChildren(t,i){t.addFieldOffset(5,i,0)}static createChildrenVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startChildrenVector(t,i){t.startVector(4,i,4)}static addCustomMetadata(t,i){t.addFieldOffset(6,i,0)}static createCustomMetadataVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startCustomMetadataVector(t,i){t.startVector(4,i,4)}static endField(t){return t.endObject()}},Jt=class Re{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsSchema(t,i){return(i||new Re).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,i){return t.setPosition(t.position()+4),(i||new Re).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Rr.Little}fields(t,i){let n=this.bb.__offset(this.bb_pos,6);return n?(i||new Pt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,i){let n=this.bb.__offset(this.bb_pos,8);return n?(i||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let i=this.bb.__offset(this.bb_pos,10);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+t*8):BigInt(0)}featuresLength(){let 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,i){t.addFieldInt16(0,i,Rr.Little)}static addFields(t,i){t.addFieldOffset(1,i,0)}static createFieldsVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startFieldsVector(t,i){t.startVector(4,i,4)}static addCustomMetadata(t,i){t.addFieldOffset(2,i,0)}static createCustomMetadataVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startCustomMetadataVector(t,i){t.startVector(4,i,4)}static addFeatures(t,i){t.addFieldOffset(3,i,0)}static createFeaturesVector(t,i){t.startVector(8,i.length,8);for(let n=i.length-1;n>=0;n--)t.addInt64(i[n]);return t.endVector()}static startFeaturesVector(t,i){t.startVector(8,i,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,i){t.finish(i)}static finishSizePrefixedSchemaBuffer(t,i){t.finish(i,void 0,!0)}static createSchema(t,i,n,r,s){return Re.startSchema(t),Re.addEndianness(t,i),Re.addFields(t,n),Re.addCustomMetadata(t,r),Re.addFeatures(t,s),Re.endSchema(t)}},ce=class Gu{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsFooter(t,i){return(i||new Gu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,i){return t.setPosition(t.position()+4),(i||new Gu).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Or.V1}schema(t){let i=this.bb.__offset(this.bb_pos,6);return i?(t||new Jt).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}dictionaries(t,i){let n=this.bb.__offset(this.bb_pos,8);return n?(i||new Qr).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,i){let n=this.bb.__offset(this.bb_pos,10);return n?(i||new Qr).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,i){let n=this.bb.__offset(this.bb_pos,12);return n?(i||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let 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,i){t.addFieldInt16(0,i,Or.V1)}static addSchema(t,i){t.addFieldOffset(1,i,0)}static addDictionaries(t,i){t.addFieldOffset(2,i,0)}static startDictionariesVector(t,i){t.startVector(24,i,8)}static addRecordBatches(t,i){t.addFieldOffset(3,i,0)}static startRecordBatchesVector(t,i){t.startVector(24,i,8)}static addCustomMetadata(t,i){t.addFieldOffset(4,i,0)}static createCustomMetadataVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startCustomMetadataVector(t,i){t.startVector(4,i,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,i){t.finish(i)}static finishSizePrefixedFooterBuffer(t,i){t.finish(i,void 0,!0)}},nt=class Gn{constructor(t=[],i,n){this.fields=t||[],this.metadata=i||new Map,n||(n=Aa(t)),this.dictionaries=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return"Schema<{ ".concat(this.fields.map((t,i)=>"".concat(i,": ").concat(t)).join(", ")," }>")}select(t){let i=new Set(t),n=this.fields.filter(r=>i.has(r.name));return new Gn(n,this.metadata)}selectAt(t){let i=t.map(n=>this.fields[n]).filter(Boolean);return new Gn(i,this.metadata)}assign(...t){let i=t[0]instanceof Gn?t[0]:Array.isArray(t[0])?new Gn(t[0]):new Gn(t),n=[...this.fields],r=Ys(Ys(new Map,this.metadata),i.metadata),s=i.fields.filter(o=>{let u=n.findIndex(f=>f.name===o.name);return~u?(n[u]=o.clone({metadata:Ys(Ys(new Map,n[u].metadata),o.metadata)}))&&!1:!0}),a=Aa(s,new Map);return new Gn([...n,...s],r,new Map([...this.dictionaries,...a]))}};nt.prototype.fields=null,nt.prototype.metadata=null,nt.prototype.dictionaries=null;var Y=class Ju{static new(...t){let[i,n,r,s]=t;return t[0]&&typeof t[0]=="object"&&({name:i}=t[0],n===void 0&&(n=t[0].type),r===void 0&&(r=t[0].nullable),s===void 0&&(s=t[0].metadata)),new Ju("".concat(i),n,r,s)}constructor(t,i,n=!1,r){this.name=t,this.type=i,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return"".concat(this.name,": ").concat(this.type)}clone(...t){let[i,n,r,s]=t;return!t[0]||typeof t[0]!="object"?[i=this.name,n=this.type,r=this.nullable,s=this.metadata]=t:{name:i=this.name,type:n=this.type,nullable:r=this.nullable,metadata:s=this.metadata}=t[0],Ju.new(i,n,r,s)}};Y.prototype.type=null,Y.prototype.name=null,Y.prototype.nullable=null,Y.prototype.metadata=null;function Ys(e,t){return new Map([...e||new Map,...t||new Map])}function Aa(e,t=new Map){for(let i=-1,n=e.length;++i0&&Aa(r.children,t)}return t}var cm=tn,lm=ae,mr=class{static decode(e){e=new lm(L(e));let t=ce.getRootAsFooter(e),i=nt.decode(t.schema());return new Ta(i,t)}static encode(e){let t=new cm,i=nt.encode(t,e.schema);ce.startRecordBatchesVector(t,e.numRecordBatches);for(let s of[...e.recordBatches()].slice().reverse())yr.encode(t,s);let n=t.endVector();ce.startDictionariesVector(t,e.numDictionaries);for(let s of[...e.dictionaryBatches()].slice().reverse())yr.encode(t,s);let r=t.endVector();return ce.startFooter(t),ce.addSchema(t,i),ce.addVersion(t,Ot.V4),ce.addRecordBatches(t,n),ce.addDictionaries(t,r),ce.finishFooterBuffer(t,ce.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=Ot.V4,i,n){this.schema=e,this.version=t,i&&(this._recordBatches=i),n&&(this._dictionaryBatches=n)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return F(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(dt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ut.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ut.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return F(this,void 0,void 0,function*(){return yield this.abort(e),dt})}return(e){return F(this,void 0,void 0,function*(){return yield this.close(),dt})}read(e){return F(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return F(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(dt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}},Ke=class extends Xs{write(e){if((e=L(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Jn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Jn)}toUint8Array(e=!1){return e?ne(this._values)[0]:F(this,void 0,void 0,function*(){var t,i,n,r;let s=[],a=0;try{for(var o=!0,u=ve(this),f;f=yield u.next(),t=f.done,!t;o=!0){r=f.value,o=!1;let y=r;s.push(y),a+=y.byteLength}}catch(y){i={error:y}}finally{try{!o&&!t&&(n=u.return)&&(yield n.call(u))}finally{if(i)throw i.error}}return ne(s,a)[0]})}},Je=class{constructor(e){e&&(this.source=new xa(Ut.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},_e=class mc{constructor(t){t instanceof mc?this.source=t.source:t instanceof Ke?this.source=new _r(Ut.fromAsyncIterable(t)):ls(t)?this.source=new _r(Ut.fromNodeStream(t)):qn(t)?this.source=new _r(Ut.fromDOMStream(t)):as(t)?this.source=new _r(Ut.fromDOMStream(t.body)):Ie(t)?this.source=new _r(Ut.fromIterable(t)):Se(t)?this.source=new _r(Ut.fromAsyncIterable(t)):he(t)&&(this.source=new _r(Ut.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)}},xa=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||dt)}return(e){return Object.create(this.source.return&&this.source.return(e)||dt)}},_r=class{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return F(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return F(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return F(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e,t="read"){return F(this,void 0,void 0,function*(){return yield this.source.next({cmd:t,size:e})})}throw(e){return F(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||dt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return F(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||dt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},gi=class extends Je{constructor(e,t){super(),this.position=0,this.buffer=L(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){let{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),ewi,Int128:()=>vi,Int64:()=>br,Uint64:()=>_t});function Mn(e){return e<0&&(e=4294967295+e+1),"0x".concat(e.toString(16))}var Un=8,Da=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],wi=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),n=t[3]*i[3];this.buffer[0]=n&65535;let r=n>>>16;return n=t[2]*i[3],r+=n,n=t[3]*i[2]>>>0,r+=n,this.buffer[0]+=r<<16,this.buffer[1]=r>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,i[2]=this.buffer[2]+t.buffer[2]>>>0,i[1]=this.buffer[1]+t.buffer[1]>>>0,i[0]=this.buffer[0]+t.buffer[0]>>>0,i[0]>>0&&++i[1],i[1]>>0&&++i[2],i[2]>>0&&++i[3],this.buffer[3]=i[3],this.buffer[2]=i[2],this.buffer[1]=i[1],this.buffer[0]=i[0],this}hex(){return"".concat(Mn(this.buffer[3])," ").concat(Mn(this.buffer[2])," ").concat(Mn(this.buffer[1])," ").concat(Mn(this.buffer[0]))}static multiply(t,i){return new qi(new Uint32Array(t.buffer)).times(i)}static add(t,i){return new qi(new Uint32Array(t.buffer)).plus(i)}static from(t,i=new Uint32Array(4)){return qi.fromString(typeof t=="string"?t:t.toString(),i)}static fromNumber(t,i=new Uint32Array(4)){return qi.fromString(t.toString(),i)}static fromString(t,i=new Uint32Array(4)){let n=t.startsWith("-"),r=t.length,s=new qi(i);for(let a=n?1:0;a0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}},Gs=class extends Si{constructor(e,t,i,n){super(new Uint8Array(0),t,i,n),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):qr(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return W(Uint8Array,W(Int32Array,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return W(Uint8Array,W(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:i}=this;return D.isTimestamp(e)||(D.isInt(e)||D.isTime(e))&&e.bitWidth===64||D.isDate(e)&&e.unit===Nt.MILLISECOND?W(Uint8Array,br.convertArray(i[t])):D.isDecimal(e)?W(Uint8Array,vi.convertArray(i[t])):D.isBinary(e)||D.isFixedSizeBinary(e)?um(i[t]):D.isBool(e)?qr(i[t]):D.isUtf8(e)?Br(i[t].join("")):W(Uint8Array,W(e.ArrayType,i[t].map(n=>+n)))}};function um(e){let t=e.join(""),i=new Uint8Array(t.length/2);for(let n=0;n>1]=Number.parseInt(t.slice(n,n+2),16);return i}var Nn=class extends $e{constructor(e){super(e),this._values=new Er(new Uint8Array(0))}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,L(t))}_flushPending(e,t){let i=this._offsets,n=this._values.reserve(t).buffer,r=0;for(let[s,a]of e)if(a===void 0)i.set(s,0);else{let o=a.length;n.set(a,r),i.set(s,o),r+=o}}},Ks=class extends pt{constructor(e){super(e),this._values=new En}setValue(e,t){this._values.set(e,+t)}},rn=class extends Rt{};rn.prototype._setValue=ua;var Ii=class extends rn{};Ii.prototype._setValue=Ss;var Fi=class extends rn{};Fi.prototype._setValue=Is;var Bi=class extends Rt{};Bi.prototype._setValue=ha;var Js=class extends pt{constructor({type:e,nullValues:t,dictionaryHashFunction:i}){super({type:new ie(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=nn({type:this.type.indices,nullValues:t}),this.dictionary=nn({type:this.type.dictionary,nullValues:null}),typeof i=="function"&&(this.valueToKey=i)}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(e){return this.indices.isValid(e)}setValid(e,t){let i=this.indices;return t=i.setValid(e,t),this.length=i.length,t}setValue(e,t){let i=this._keysToIndices,n=this.valueToKey(t),r=i[n];return r===void 0&&(i[n]=r=this._dictionaryOffset+this.dictionary.append(t).length-1),this.indices.setValue(e,r)}flush(){let e=this.type,t=this._dictionary,i=this.dictionary.toVector(),n=this.indices.flush().clone(e);return n.dictionary=t?t.concat(i):i,this.finished||(this._dictionaryOffset+=i.length),this._dictionary=n.dictionary,this.clear(),n}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(e){return typeof e=="string"?e:"".concat(e)}},Ai=class extends Rt{};Ai.prototype._setValue=la;var qs=class extends pt{setValue(e,t){let[i]=this.children,n=e*this.stride;for(let r=-1,s=t.length;++r0)throw new Error("FixedSizeListBuilder can only have one child.");let i=this.children.push(e);return this.type=new De(this.type.listSize,new Y(t,e.type,!0)),i}},sn=class extends Rt{setValue(e,t){this._values.set(e,t)}},Zs=class extends sn{setValue(e,t){super.setValue(e,ei(t))}},Qs=class extends sn{},to=class extends sn{},on=class extends Rt{};on.prototype._setValue=pa;var Ti=class extends on{};Ti.prototype._setValue=Rs;var xi=class extends on{};xi.prototype._setValue=Ms;var be=class extends Rt{setValue(e,t){this._values.set(e,t)}},eo=class extends be{},ro=class extends be{},no=class extends be{},io=class extends be{},so=class extends be{},oo=class extends be{},ao=class extends be{},co=class extends be{},lo=class extends $e{constructor(e){super(e),this._offsets=new On}addChild(e,t="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new Te(new Y(t,e.type,!0)),this.numChildren-1}_flushPending(e){let t=this._offsets,[i]=this.children;for(let[n,r]of e)if(typeof r>"u")t.set(n,0);else{let s=r,a=s.length,o=t.set(n,a).buffer[n];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new Ee(new Y(t,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let t=this._offsets,[i]=this.children;for(let[n,r]of e)if(r===void 0)t.set(n,0);else{let{[n]:s,[n+1]:a}=t.set(n,r.size).buffer;for(let o of r.entries())if(i.set(s,o),++s>=a)break}}},fo=class extends pt{setValue(e,t){}setValid(e,t){return this.length=Math.max(e+1,this.length),t}},ho=class extends pt{setValue(e,t){let{children:i,type:n}=this;switch(Array.isArray(t)||t.constructor){case!0:return n.children.forEach((r,s)=>i[s].set(e,t[s]));case Map:return n.children.forEach((r,s)=>i[s].set(e,t.get(r.name)));default:return n.children.forEach((r,s)=>i[s].set(e,t[r.name]))}}setValid(e,t){return super.setValid(e,t)||this.children.forEach(i=>i.setValid(e,t)),t}addChild(e,t="".concat(this.numChildren)){let i=this.children.push(e);return this.type=new ut([...this.type.children,new Y(t,e.type,!0)]),i}},gr=class extends Rt{};gr.prototype._setValue=da;var Di=class extends gr{};Di.prototype._setValue=Fs;var Ei=class extends gr{};Ei.prototype._setValue=Bs;var Oi=class extends gr{};Oi.prototype._setValue=As;var Ri=class extends gr{};Ri.prototype._setValue=Ts;var wr=class extends Rt{};wr.prototype._setValue=fa;var Mi=class extends wr{};Mi.prototype._setValue=xs;var Ui=class extends wr{};Ui.prototype._setValue=Ds;var Ni=class extends wr{};Ni.prototype._setValue=Es;var Li=class extends wr{};Li.prototype._setValue=Os;var Ln=class extends pt{constructor(e){super(e),this._typeIds=new fr(new Int8Array(0),1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,t){return this.set(this.length,e,t)}set(e,t,i){return i===void 0&&(i=this._valueToChildTypeId(this,t,e)),this.setValid(e,this.isValid(t))&&this.setValue(e,t,i),this}setValue(e,t,i){this._typeIds.set(e,i);let n=this.type.typeIdToChildIndex[i],r=this.children[n];r==null||r.set(e,t)}addChild(e,t="".concat(this.children.length)){let i=this.children.push(e),{type:{children:n,mode:r,typeIds:s}}=this,a=[...n,new Y(t,e.type)];return this.type=new xe(r,[...s,i],a),i}_valueToChildTypeId(e,t,i){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.")}},po=class extends Ln{},mo=class extends Ln{constructor(e){super(e),this._offsets=new fr(new Int32Array(0))}setValue(e,t,i){let n=this._typeIds.set(e,i).buffer[e],r=this.getChildAt(this.type.typeIdToChildIndex[n]),s=this._offsets.set(e,r.length).buffer[e];r==null||r.set(s,t)}},ki=class extends $e{constructor(e){super(e),this._values=new Er(new Uint8Array(0))}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,Br(t))}_flushPending(e,t){}};ki.prototype._flushPending=Nn.prototype._flushPending;var Oa=class extends E{visitNull(){return fo}visitBool(){return Ks}visitInt(){return be}visitInt8(){return eo}visitInt16(){return ro}visitInt32(){return no}visitInt64(){return io}visitUint8(){return so}visitUint16(){return oo}visitUint32(){return ao}visitUint64(){return co}visitFloat(){return sn}visitFloat16(){return Zs}visitFloat32(){return Qs}visitFloat64(){return to}visitUtf8(){return ki}visitBinary(){return Nn}visitFixedSizeBinary(){return Ai}visitDate(){return rn}visitDateDay(){return Ii}visitDateMillisecond(){return Fi}visitTimestamp(){return gr}visitTimestampSecond(){return Di}visitTimestampMillisecond(){return Ei}visitTimestampMicrosecond(){return Oi}visitTimestampNanosecond(){return Ri}visitTime(){return wr}visitTimeSecond(){return Mi}visitTimeMillisecond(){return Ui}visitTimeMicrosecond(){return Ni}visitTimeNanosecond(){return Li}visitDecimal(){return Bi}visitList(){return lo}visitStruct(){return ho}visitUnion(){return Ln}visitDenseUnion(){return mo}visitSparseUnion(){return po}visitDictionary(){return Js}visitInterval(){return on}visitIntervalDayTime(){return Ti}visitIntervalYearMonth(){return xi}visitFixedSizeList(){return qs}visitMap(){return uo}},zl=new Oa,N=class extends E{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,n)=>this.compareFields(i,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function qt(e,t){return t instanceof e.constructor}function Ci(e,t){return e===t||qt(e,t)}function vr(e,t){return e===t||qt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function yo(e,t){return e===t||qt(e,t)&&e.precision===t.precision}function dm(e,t){return e===t||qt(e,t)&&e.byteWidth===t.byteWidth}function Ra(e,t){return e===t||qt(e,t)&&e.unit===t.unit}function Pi(e,t){return e===t||qt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Vi(e,t){return e===t||qt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function fm(e,t){return e===t||qt(e,t)&&e.children.length===t.children.length&&qe.compareManyFields(e.children,t.children)}function hm(e,t){return e===t||qt(e,t)&&e.children.length===t.children.length&&qe.compareManyFields(e.children,t.children)}function Ma(e,t){return e===t||qt(e,t)&&e.mode===t.mode&&e.typeIds.every((i,n)=>i===t.typeIds[n])&&qe.compareManyFields(e.children,t.children)}function pm(e,t){return e===t||qt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&qe.visit(e.indices,t.indices)&&qe.visit(e.dictionary,t.dictionary)}function Ua(e,t){return e===t||qt(e,t)&&e.unit===t.unit}function mm(e,t){return e===t||qt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&qe.compareManyFields(e.children,t.children)}function ym(e,t){return e===t||qt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&qe.compareManyFields(e.children,t.children)}N.prototype.visitNull=Ci,N.prototype.visitBool=Ci,N.prototype.visitInt=vr,N.prototype.visitInt8=vr,N.prototype.visitInt16=vr,N.prototype.visitInt32=vr,N.prototype.visitInt64=vr,N.prototype.visitUint8=vr,N.prototype.visitUint16=vr,N.prototype.visitUint32=vr,N.prototype.visitUint64=vr,N.prototype.visitFloat=yo,N.prototype.visitFloat16=yo,N.prototype.visitFloat32=yo,N.prototype.visitFloat64=yo,N.prototype.visitUtf8=Ci,N.prototype.visitBinary=Ci,N.prototype.visitFixedSizeBinary=dm,N.prototype.visitDate=Ra,N.prototype.visitDateDay=Ra,N.prototype.visitDateMillisecond=Ra,N.prototype.visitTimestamp=Pi,N.prototype.visitTimestampSecond=Pi,N.prototype.visitTimestampMillisecond=Pi,N.prototype.visitTimestampMicrosecond=Pi,N.prototype.visitTimestampNanosecond=Pi,N.prototype.visitTime=Vi,N.prototype.visitTimeSecond=Vi,N.prototype.visitTimeMillisecond=Vi,N.prototype.visitTimeMicrosecond=Vi,N.prototype.visitTimeNanosecond=Vi,N.prototype.visitDecimal=Ci,N.prototype.visitList=fm,N.prototype.visitStruct=hm,N.prototype.visitUnion=Ma,N.prototype.visitDenseUnion=Ma,N.prototype.visitSparseUnion=Ma,N.prototype.visitDictionary=pm,N.prototype.visitInterval=Ua,N.prototype.visitIntervalDayTime=Ua,N.prototype.visitIntervalYearMonth=Ua,N.prototype.visitFixedSizeList=mm,N.prototype.visitMap=ym;var qe=new N;function an(e,t){return qe.compareSchemas(e,t)}function jl(e,t){return qe.compareFields(e,t)}function Wl(e,t){return qe.visit(e,t)}function nn(e){let t=e.type,i=new(zl.getVisitFn(t)())(e);if(t.children&&t.children.length>0){let n=e.children||[],r={nullValues:e.nullValues},s=Array.isArray(n)?(a,o)=>n[o]||r:({name:a})=>n[a]||r;for(let[a,o]of t.children.entries()){let{type:u}=o,f=s(o,a);i.children.push(nn(Object.assign(Object.assign({},f),{type:u})))}}return i}function _o(e,t){return _m(e,t.map(i=>i.data.concat()))}function _m(e,t){let i=[...e.fields],n=[],r={numBatches:t.reduce((g,I)=>Math.max(g,I.length),0)},s=0,a=0,o=-1,u=t.length,f,y=[];for(;r.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o0&&(n[s++]=P({type:new ut(i),length:a,nullCount:0,children:y.slice()})))}return[e=e.assign(i),n.map(g=>new gt(e,g))]}function bm(e,t,i,n,r){var s;let a=(t+63&-64)>>3;for(let o=-1,u=n.length;++o=t)y===t?i[o]=f:(i[o]=f.slice(0,t),r.numBatches=Math.max(r.numBatches,n[o].unshift(f.slice(t,y-t))));else{let g=e[o];e[o]=g.clone({nullable:!0}),i[o]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:P({type:g.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return i}var $l,$t=class Kn{constructor(...t){var i,n;if(t.length===0)return this.batches=[],this.schema=new nt([]),this._offsets=[0],this;let r,s;t[0]instanceof nt&&(r=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let a=u=>{if(u){if(u instanceof gt)return[u];if(u instanceof Kn)return u.batches;if(u instanceof at){if(u.type instanceof ut)return[new gt(new nt(u.type.children),u)]}else{if(Array.isArray(u))return u.flatMap(f=>a(f));if(typeof u[Symbol.iterator]=="function")return[...u].flatMap(f=>a(f));if(typeof u=="object"){let f=Object.keys(u),y=f.map(S=>new J([u[S]])),g=new nt(f.map((S,x)=>new Y(String(S),y[x].type))),[,I]=_o(g,y);return I.length===0?[new gt(u)]:I}}}return[]},o=t.flatMap(u=>a(u));if(r=(n=r??((i=o[0])===null||i===void 0?void 0:i.schema))!==null&&n!==void 0?n:new nt([]),!(r instanceof nt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let u of o){if(!(u instanceof gt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!an(r,u.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=r,this.batches=o,this._offsets=s??Cs(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,i)=>t+i.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=ks(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,i){}indexOf(t,i){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?Dn.visit(new J(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ `.concat(this.toArray().join(`, `),` ]`)}concat(...t){let i=this.schema,n=this.data.concat(t.flatMap(({data:r})=>r));return new Kn(i,n.map(r=>new gt(i,r)))}slice(t,i){let n=this.schema;[t,i]=ri({length:this.numRows},t,i);let r=Ps(this.data,this._offsets,t,i);return new Kn(n,r.map(s=>new gt(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(i=>i.name===t))}getChildAt(t){if(t>-1&&tn.children[t]);if(i.length===0){let{type:n}=this.schema.fields[t],r=P({type:n,length:0,nullCount:0});i.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new J(i)}return null}setChild(t,i){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t),i)}setChildAt(t,i){let n=this.schema,r=[...this.batches];if(t>-1&&tthis.getChildAt(f));[s[t],o[t]]=[a,i],[n,r]=_o(n,o)}return new Kn(n,r)}select(t){let i=this.schema.fields.reduce((n,r,s)=>n.set(r.name,s),new Map);return this.selectAt(t.map(n=>i.get(n)).filter(n=>n>-1))}selectAt(t){let i=this.schema.selectAt(t),n=this.batches.map(r=>r.selectAt(t));return new Kn(i,n)}assign(t){let i=this.schema.fields,[n,r]=t.schema.fields.reduce((o,u,f)=>{let[y,g]=o,I=i.findIndex(S=>S.name===u.name);return~I?g[I]=f:y.push(f),o},[[],[]]),s=this.schema.assign(t.schema),a=[...i.map((o,u)=>[u,r[u]]).map(([o,u])=>u===void 0?this.getChildAt(o):t.getChildAt(u)),...n.map(o=>t.getChildAt(o))].filter(Boolean);return new Kn(..._o(s,a))}};$l=Symbol.toStringTag,$t[$l]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Dr(si),e.get=Dr(Bt.getVisitFn(h.Struct)),e.set=Vs(Lt.getVisitFn(h.Struct)),e.indexOf=Hs(Zr.getVisitFn(h.Struct)),e.getByteLength=Dr(oe.getVisitFn(h.Struct)),"Table"))($t.prototype);var Xl,gt=class Ho{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof nt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=P({nullCount:0,type:new ut(this.schema.fields),children:this.schema.fields.map(i=>P({type:i.type,nullCount:0}))})]=t,!(this.data instanceof at))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Yl(this.schema,this.data.children);break}case 1:{let[i]=t,{fields:n,children:r,length:s}=Object.keys(i).reduce((u,f,y)=>(u.children[y]=i[f],u.length=Math.max(u.length,i[f].length),u.fields[y]=Y.new({name:f,type:i[f].type,nullable:!0}),u),{length:0,fields:new Array,children:new Array}),a=new nt(n),o=P({type:new ut(n),length:s,children:r,nullCount:0});[this.schema,this.data]=Yl(a,o.children,s);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=Gl(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 Bt.visit(this.data,t)}set(t,i){return Lt.visit(this.data,t,i)}indexOf(t,i){return Zr.visit(this.data,t,i)}getByteLength(t){return oe.visit(this.data,t)}[Symbol.iterator](){return Dn.visit(new J([this.data]))}toArray(){return[...this]}concat(...t){return new $t(this.schema,[this,...t])}slice(t,i){let[n]=new J([this.data]).slice(t,i).data;return new Ho(this.schema,n)}getChild(t){var i;return this.getChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&tr.name===t),i)}setChildAt(t,i){let n=this.schema,r=this.data;if(t>-1&&to.name===s);~a&&(r[a]=this.data.children[a])}return new Ho(i,P({type:n,length:this.numRows,children:r}))}selectAt(t){let i=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),r=P({type:new ut(i.fields),length:this.numRows,children:n});return new Ho(i,r)}};Xl=Symbol.toStringTag,gt[Xl]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(gt.prototype);function Yl(e,t,i=t.reduce((n,r)=>Math.max(n,r.length),0)){var n;let r=[...e.fields],s=[...t],a=(i+63&-64)>>3;for(let[o,u]of e.fields.entries()){let f=t[o];(!f||f.length!==i)&&(r[o]=u.clone({nullable:!0}),s[o]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(i))!==null&&n!==void 0?n:P({type:u.type,length:i,nullCount:i,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),P({type:new ut(r),length:i,children:s})]}function Gl(e,t,i=new Map){for(let n=-1,r=e.length;++n0&&Gl(s.children,a.children,i)}return i}var cn=class extends gt{constructor(e){let t=e.fields.map(n=>P({type:n.type})),i=P({type:new ut(e.fields),nullCount:0,children:t});super(e,i)}},Hi;(function(e){e[e.BUFFER=0]="BUFFER"})(Hi||(Hi={}));var zi;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(zi||(zi={}));var bo=class Xn{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsBodyCompression(t,i){return(i||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,i){return t.setPosition(t.position()+4),(i||new Xn).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):zi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Hi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,i){t.addFieldInt8(0,i,zi.LZ4_FRAME)}static addMethod(t,i){t.addFieldInt8(1,i,Hi.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,i,n){return Xn.startBodyCompression(t),Xn.addCodec(t,i),Xn.addMethod(t,n),Xn.endBodyCompression(t)}},kn=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,t,i){return e.prep(8,16),e.writeInt64(BigInt(i??0)),e.writeInt64(BigInt(t??0)),e.offset()}},Cn=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,i){return e.prep(8,16),e.writeInt64(BigInt(i??0)),e.writeInt64(BigInt(t??0)),e.offset()}},le=class Ku{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsRecordBatch(t,i){return(i||new Ku).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,i){return t.setPosition(t.position()+4),(i||new Ku).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,i){let n=this.bb.__offset(this.bb_pos,6);return n?(i||new Cn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,i){let n=this.bb.__offset(this.bb_pos,8);return n?(i||new kn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let i=this.bb.__offset(this.bb_pos,10);return i?(t||new bo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,i){t.addFieldInt64(0,i,BigInt("0"))}static addNodes(t,i){t.addFieldOffset(1,i,0)}static startNodesVector(t,i){t.startVector(16,i,8)}static addBuffers(t,i){t.addFieldOffset(2,i,0)}static startBuffersVector(t,i){t.startVector(16,i,8)}static addCompression(t,i){t.addFieldOffset(3,i,0)}static endRecordBatch(t){return t.endObject()}},Sr=class Xu{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsDictionaryBatch(t,i){return(i||new Xu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,i){return t.setPosition(t.position()+4),(i||new Xu).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let i=this.bb.__offset(this.bb_pos,6);return i?(t||new le).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}isDelta(){let 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,i){t.addFieldInt64(0,i,BigInt("0"))}static addData(t,i){t.addFieldOffset(1,i,0)}static addIsDelta(t,i){t.addFieldInt8(2,+i,0)}static endDictionaryBatch(t){return t.endObject()}},Pn;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(Pn||(Pn={}));var Ne=class ye{constructor(){this.bb=null,this.bb_pos=0}__init(t,i){return this.bb_pos=t,this.bb=i,this}static getRootAsMessage(t,i){return(i||new ye).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,i){return t.setPosition(t.position()+4),(i||new ye).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Or.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Pn.NONE}header(t){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__union(t,this.bb_pos+i):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,i){let n=this.bb.__offset(this.bb_pos,12);return n?(i||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let 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,i){t.addFieldInt16(0,i,Or.V1)}static addHeaderType(t,i){t.addFieldInt8(1,i,Pn.NONE)}static addHeader(t,i){t.addFieldOffset(2,i,0)}static addBodyLength(t,i){t.addFieldInt64(3,i,BigInt("0"))}static addCustomMetadata(t,i){t.addFieldOffset(4,i,0)}static createCustomMetadataVector(t,i){t.startVector(4,i.length,4);for(let n=i.length-1;n>=0;n--)t.addOffset(i[n]);return t.endVector()}static startCustomMetadataVector(t,i){t.startVector(4,i,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,i){t.finish(i)}static finishSizePrefixedMessageBuffer(t,i){t.finish(i,void 0,!0)}static createMessage(t,i,n,r,s,a){return ye.startMessage(t),ye.addVersion(t,i),ye.addHeaderType(t,n),ye.addHeader(t,r),ye.addBodyLength(t,s),ye.addCustomMetadata(t,a),ye.endMessage(t)}},Na=class extends E{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return pi.startNull(t),pi.endNull(t)}visitInt(e,t){return Me.startInt(t),Me.addBitWidth(t,e.bitWidth),Me.addIsSigned(t,e.isSigned),Me.endInt(t)}visitFloat(e,t){return kr.startFloatingPoint(t),kr.addPrecision(t,e.precision),kr.endFloatingPoint(t)}visitBinary(e,t){return ci.startBinary(t),ci.endBinary(t)}visitBool(e,t){return li.startBool(t),li.endBool(t)}visitUtf8(e,t){return _i.startUtf8(t),_i.endUtf8(t)}visitDecimal(e,t){return Ge.startDecimal(t),Ge.addScale(t,e.scale),Ge.addPrecision(t,e.precision),Ge.addBitWidth(t,e.bitWidth),Ge.endDecimal(t)}visitDate(e,t){return Mr.startDate(t),Mr.addUnit(t,e.unit),Mr.endDate(t)}visitTime(e,t){return hr.startTime(t),hr.addUnit(t,e.unit),hr.addBitWidth(t,e.bitWidth),hr.endTime(t)}visitTimestamp(e,t){let i=e.timezone&&t.createString(e.timezone)||void 0;return pr.startTimestamp(t),pr.addUnit(t,e.unit),i!==void 0&&pr.addTimezone(t,i),pr.endTimestamp(t)}visitInterval(e,t){return Cr.startInterval(t),Cr.addUnit(t,e.unit),Cr.endInterval(t)}visitList(e,t){return hi.startList(t),hi.endList(t)}visitStruct(e,t){return mi.startStruct_(t),mi.endStruct_(t)}visitUnion(e,t){Ue.startTypeIdsVector(t,e.typeIds.length);let i=Ue.createTypeIdsVector(t,e.typeIds);return Ue.startUnion(t),Ue.addMode(t,e.mode),Ue.addTypeIds(t,i),Ue.endUnion(t)}visitDictionary(e,t){let i=this.visit(e.indices,t);return Xe.startDictionaryEncoding(t),Xe.addId(t,BigInt(e.id)),Xe.addIsOrdered(t,e.isOrdered),i!==void 0&&Xe.addIndexType(t,i),Xe.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Nr.startFixedSizeBinary(t),Nr.addByteWidth(t,e.byteWidth),Nr.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Lr.startFixedSizeList(t),Lr.addListSize(t,e.listSize),Lr.endFixedSizeList(t)}visitMap(e,t){return Pr.startMap(t),Pr.addKeysSorted(t,e.keysSorted),Pr.endMap(t)}},go=new Na;function Zl(e,t=new Map){return new nt(wm(e,t),wo(e.customMetadata),t)}function La(e){return new kt(e.count,tu(e.columns),eu(e.columns))}function Ql(e){return new Qt(La(e.data),e.id,e.isDelta)}function wm(e,t){return(e.fields||[]).filter(Boolean).map(i=>Y.fromJSON(i,t))}function Kl(e,t){return(e.children||[]).filter(Boolean).map(i=>Y.fromJSON(i,t))}function tu(e){return(e||[]).reduce((t,i)=>[...t,new Le(i.count,vm(i.VALIDITY)),...tu(i.children)],[])}function eu(e,t=[]){for(let i=-1,n=(e||[]).length;++it+ +(i===0),0)}function ru(e,t){let i,n,r,s,a,o;return!t||!(s=e.dictionary)?(a=ql(e,Kl(e,t)),r=new Y(e.name,a,e.nullable,wo(e.customMetadata))):t.has(i=s.id)?(n=(n=s.indexType)?Jl(n):new ze,o=new ie(t.get(i),n,i,s.isOrdered),r=new Y(e.name,o,e.nullable,wo(e.customMetadata))):(n=(n=s.indexType)?Jl(n):new ze,t.set(i,a=ql(e,Kl(e,t))),o=new ie(a,n,i,s.isOrdered),r=new Y(e.name,o,e.nullable,wo(e.customMetadata))),r||null}function wo(e){return new Map(Object.entries(e||{}))}function Jl(e){return new St(e.isSigned,e.bitWidth)}function ql(e,t){let i=e.type.name;switch(i){case"NONE":return new Wt;case"null":return new Wt;case"binary":return new nr;case"utf8":return new ir;case"bool":return new sr;case"list":return new Te((t||[])[0]);case"struct":return new ut(t||[]);case"struct_":return new ut(t||[])}switch(i){case"int":{let n=e.type;return new St(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=e.type;return new Kt(ht[n.precision])}case"decimal":{let n=e.type;return new or(n.scale,n.precision,n.bitWidth)}case"date":{let n=e.type;return new ar(Nt[n.unit])}case"time":{let n=e.type;return new Ae(G[n.unit],n.bitWidth)}case"timestamp":{let n=e.type;return new cr(G[n.unit],n.timezone)}case"interval":{let n=e.type;return new lr(jt[n.unit])}case"union":{let n=e.type;return new xe(yt[n.mode],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=e.type;return new ur(n.byteWidth)}case"fixedsizelist":{let n=e.type;return new De(n.listSize,(t||[])[0])}case"map":{let n=e.type;return new Ee((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(i,'"'))}var Sm=tn,Im=ae,te=class fs{static fromJSON(t,i){let n=new fs(0,Ot.V4,i);return n._createHeader=Fm(t,i),n}static decode(t){t=new Im(L(t));let i=Ne.getRootAsMessage(t),n=i.bodyLength(),r=i.version(),s=i.headerType(),a=new fs(n,r,s);return a._createHeader=Bm(i,s),a}static encode(t){let i=new Sm,n=-1;return t.isSchema()?n=nt.encode(i,t.header()):t.isRecordBatch()?n=kt.encode(i,t.header()):t.isDictionaryBatch()&&(n=Qt.encode(i,t.header())),Ne.startMessage(i),Ne.addVersion(i,Ot.V4),Ne.addHeader(i,n),Ne.addHeaderType(i,t.headerType),Ne.addBodyLength(i,BigInt(t.bodyLength)),Ne.finishMessageBuffer(i,Ne.endMessage(i)),i.asUint8Array()}static from(t,i=0){if(t instanceof nt)return new fs(0,Ot.V4,tt.Schema,t);if(t instanceof kt)return new fs(i,Ot.V4,tt.RecordBatch,t);if(t instanceof Qt)return new fs(i,Ot.V4,tt.DictionaryBatch,t);throw new Error("Unrecognized Message header: ".concat(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===tt.Schema}isRecordBatch(){return this.headerType===tt.RecordBatch}isDictionaryBatch(){return this.headerType===tt.DictionaryBatch}constructor(t,i,n,r){this._version=i,this._headerType=n,this.body=new Uint8Array(0),r&&(this._createHeader=()=>r),this._bodyLength=Gt(t)}},kt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=Gt(e)}},Qt=class{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(e,t,i=!1){this._data=e,this._isDelta=i,this._id=Gt(t)}},Zt=class{constructor(e,t){this.offset=Gt(e),this.length=Gt(t)}},Le=class{constructor(e,t){this.length=Gt(e),this.nullCount=Gt(t)}};function Fm(e,t){return()=>{switch(t){case tt.Schema:return nt.fromJSON(e);case tt.RecordBatch:return kt.fromJSON(e);case tt.DictionaryBatch:return Qt.fromJSON(e)}throw new Error("Unrecognized Message type: { name: ".concat(tt[t],", type: ").concat(t," }"))}}function Bm(e,t){return()=>{switch(t){case tt.Schema:return nt.decode(e.header(new Jt));case tt.RecordBatch:return kt.decode(e.header(new le),e.version());case tt.DictionaryBatch:return Qt.decode(e.header(new Sr),e.version())}throw new Error("Unrecognized Message type: { name: ".concat(tt[t],", type: ").concat(t," }"))}}Y.encode=Lm,Y.decode=Um,Y.fromJSON=ru,nt.encode=Nm,nt.decode=Am,nt.fromJSON=Zl,kt.encode=km,kt.decode=Tm,kt.fromJSON=La,Qt.encode=Cm,Qt.decode=xm,Qt.fromJSON=Ql,Le.encode=Pm,Le.decode=Em,Zt.encode=Vm,Zt.decode=Dm;function Am(e,t=new Map){let i=Mm(e,t);return new nt(i,vo(e),t)}function Tm(e,t=Ot.V4){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new kt(e.length(),Om(e),Rm(e,t))}function xm(e,t=Ot.V4){return new Qt(kt.decode(e.data(),t),e.id(),e.isDelta())}function Dm(e){return new Zt(e.offset(),e.length())}function Em(e){return new Le(e.length(),e.nullCount())}function Om(e){let t=[];for(let i,n=-1,r=-1,s=e.nodesLength();++nY.encode(e,s));Jt.startFieldsVector(e,i.length);let n=Jt.createFieldsVector(e,i),r=t.metadata&&t.metadata.size>0?Jt.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{let o=e.createString("".concat(s)),u=e.createString("".concat(a));return Et.startKeyValue(e),Et.addKey(e,o),Et.addValue(e,u),Et.endKeyValue(e)})):-1;return Jt.startSchema(e),Jt.addFields(e,n),Jt.addEndianness(e,Hm?Rr.Little:Rr.Big),r!==-1&&Jt.addCustomMetadata(e,r),Jt.endSchema(e)}function Lm(e,t){let i=-1,n=-1,r=-1,s=t.type,a=t.typeId;D.isDictionary(s)?(a=s.dictionary.typeId,r=go.visit(s,e),n=go.visit(s.dictionary,e)):n=go.visit(s,e);let o=(s.children||[]).map(y=>Y.encode(e,y)),u=Pt.createChildrenVector(e,o),f=t.metadata&&t.metadata.size>0?Pt.createCustomMetadataVector(e,[...t.metadata].map(([y,g])=>{let I=e.createString("".concat(y)),S=e.createString("".concat(g));return Et.startKeyValue(e),Et.addKey(e,I),Et.addValue(e,S),Et.endKeyValue(e)})):-1;return t.name&&(i=e.createString(t.name)),Pt.startField(e),Pt.addType(e,n),Pt.addTypeType(e,a),Pt.addChildren(e,u),Pt.addNullable(e,!!t.nullable),i!==-1&&Pt.addName(e,i),r!==-1&&Pt.addDictionary(e,r),f!==-1&&Pt.addCustomMetadata(e,f),Pt.endField(e)}function km(e,t){let i=t.nodes||[],n=t.buffers||[];le.startNodesVector(e,i.length);for(let a of i.slice().reverse())Le.encode(e,a);let r=e.endVector();le.startBuffersVector(e,n.length);for(let a of n.slice().reverse())Zt.encode(e,a);let s=e.endVector();return le.startRecordBatch(e),le.addLength(e,BigInt(t.length)),le.addNodes(e,r),le.addBuffers(e,s),le.endRecordBatch(e)}function Cm(e,t){let i=kt.encode(e,t.data);return Sr.startDictionaryBatch(e),Sr.addId(e,BigInt(t.id)),Sr.addIsDelta(e,t.isDelta),Sr.addData(e,i),Sr.endDictionaryBatch(e)}function Pm(e,t){return Cn.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Vm(e,t){return kn.createBuffer(e,BigInt(t.offset),BigInt(t.length))}var Hm=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),Ca=e=>"Expected ".concat(tt[e]," Message in stream, but was null or length 0."),Pa=e=>"Header pointer of flatbuffer-encoded ".concat(tt[e]," Message is null or length 0."),ou=(e,t)=>"Expected to read ".concat(e," metadata bytes, but only read ").concat(t,"."),au=(e,t)=>"Expected to read ".concat(e," bytes for message body, but only read ").concat(t,"."),Vn=class{constructor(e){this.source=e instanceof Je?e:new Je(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?dt:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(Ca(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let t=L(this.source.read(e));if(t.byteLength[...n,...r.VALIDITY&&[r.VALIDITY]||[],...r.TYPE&&[r.TYPE]||[],...r.OFFSET&&[r.OFFSET]||[],...r.DATA&&[r.DATA]||[],...t(r.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(Ca(e));return t.value}readSchema(){let e=tt.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(Pa(e));return i}},So=4,ka="ARROW1",Hn=new Uint8Array(ka.length);for(let e=0;ethis):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 Ut.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ut.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,i){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Mu?t:is(t)?jm(t):os(t)?Ym(t):Se(t)?F(this,void 0,void 0,function*(){return yield Mu.from(yield t)}):as(t)||qn(t)||ls(t)||he(t)?$m(new _e(t)):Wm(new Je(t))}static readAll(t){return t instanceof Mu?t.isSync()?lu(t):uu(t):is(t)||ArrayBuffer.isView(t)||Ie(t)||ss(t)?lu(t):uu(t)}},Ze=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return re(this,arguments,function*(){yield C(yield*Gr(gn(ve(this[Symbol.iterator]()))))})}},Hr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){var e,t,i,n;return F(this,void 0,void 0,function*(){let r=new Array;try{for(var s=!0,a=ve(this),o;o=yield a.next(),e=o.done,!e;s=!0){n=o.value,s=!1;let u=n;r.push(u)}}catch(u){t={error:u}}finally{try{!s&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(t)throw t.error}}return r})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},zr=class extends Ze{constructor(e){super(e),this._impl=e}},$i=class extends Hr{constructor(e){super(e),this._impl=e}},Fo=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){let i=this._loadVectors(e,t,this.schema.fields),n=P({type:new ut(this.schema.fields),length:e.length,children:i});return new gt(this.schema,n)}_loadDictionaryBatch(e,t){let{id:i,isDelta:n}=e,{dictionaries:r,schema:s}=this,a=r.get(i);if(n||!a){let o=s.dictionaries.get(i),u=this._loadVectors(e.data,t,[o]);return(a&&n?a.concat(new J(u)):new J(u)).memoize()}return a.memoize()}_loadVectors(e,t,i){return new Si(t,e.nodes,e.buffers,this.dictionaries).visitMany(i)}},jn=class extends Fo{constructor(e,t){super(t),this._reader=is(e)?new Wi(this._handle=e):new Vn(this._handle=e)}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(e){return this.closed||(this.autoDestroy=du(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):dt}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):dt}next(){if(this.closed)return dt;let e,{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let i=e.header(),n=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let i=e.header(),n=t.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,r)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Wn=class extends Fo{constructor(e,t){super(t),this._reader=new ji(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return F(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return F(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=du(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return F(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):dt})}return(e){return F(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):dt})}next(){return F(this,void 0,void 0,function*(){if(this.closed)return dt;let e,{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let i=e.header(),n=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let i=e.header(),n=yield t.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,r)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return F(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Bo=class extends jn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof gi?e:new gi(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();let i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(tt.RecordBatch);if(n!=null&&n.isRecordBatch()){let r=n.header(),s=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(r,s)}}return null}_readDictionaryBatch(e){var t;let i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(tt.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let r=n.header(),s=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(r,s);this.dictionaries.set(r.id,a)}}}_readFooter(){let{_handle:e}=this,t=e.size-Va,i=e.readInt32(t),n=e.readAt(t-i,i);return mr.decode(n)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return F(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){var t;return F(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(tt.RecordBatch);if(n!=null&&n.isRecordBatch()){let r=n.header(),s=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(r,s)}}return null})}_readDictionaryBatch(e){var t;return F(this,void 0,void 0,function*(){let i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(tt.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let r=n.header(),s=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(r,s);this.dictionaries.set(r.id,a)}}})}_readFooter(){return F(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-Va,i=yield e.readInt32(t),n=yield e.readAt(t-i,i);return mr.decode(n)})}_readNextMessageAndValidate(e){return F(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Io(t)?new zr(new Bo(e.read())):new Ze(new jn(e)):new Ze(new jn(function*(){}()))}function $m(e){return F(this,void 0,void 0,function*(){let t=yield e.peek(zn+7&-8);return t&&t.byteLength>=4?Io(t)?new zr(new Bo(yield e.read())):new Hr(new Wn(e)):new Hr(new Wn(function(){return re(this,arguments,function*(){})}()))})}function Ym(e){return F(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),i=new Vr(e,t);return t>=cu&&Io(yield i.readAt(0,zn+7&-8))?new $i(new Ha(i)):new Hr(new Wn(i))})}var It=class gc extends E{static assemble(...t){let i=r=>r.flatMap(s=>Array.isArray(s)?i(s):s instanceof gt?s.data.children:s.data),n=new gc;return n.visitMany(i(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof J)return this.visitMany(t.data),this;let{type:i}=t;if(!D.isDictionary(i)){let{length:n,nullCount:r}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");D.isNull(i)||ke.call(this,r<=0?new Uint8Array(0):xn(t.offset,n,t.nullBitmap)),this.nodes.push(new Le(n,r))}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function ke(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Zt(this._byteLength,t)),this._byteLength+=t,this}function Xm(e){let{type:t,length:i,typeIds:n,valueOffsets:r}=e;if(ke.call(this,n),t.mode===yt.Sparse)return ja.call(this,e);if(t.mode===yt.Dense){if(e.offset<=0)return ke.call(this,r),ja.call(this,e);{let s=n.reduce((y,g)=>Math.max(y,g),n[0]),a=new Int32Array(s+1),o=new Int32Array(s+1).fill(-1),u=new Int32Array(i),f=Zn(-r[0],i,r);for(let y,g,I=-1;++I=e.length?ke.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?ke.call(this,xn(e.offset,e.length,t)):ke.call(this,qr(e.values))}function jr(e){return ke.call(this,e.values.subarray(0,e.length*e.stride))}function fu(e){let{length:t,values:i,valueOffsets:n}=e,r=n[0],s=n[t],a=Math.min(s-r,i.byteLength-r);return ke.call(this,Zn(-n[0],t,n)),ke.call(this,i.subarray(r,r+a)),this}function Wa(e){let{length:t,valueOffsets:i}=e;return i&&ke.call(this,Zn(i[0],t,i)),this.visit(e.children[0])}function ja(e){return this.visitMany(e.type.children.map((t,i)=>e.children[i]).filter(Boolean))[0]}It.prototype.visitBool=Gm,It.prototype.visitInt=jr,It.prototype.visitFloat=jr,It.prototype.visitUtf8=fu,It.prototype.visitBinary=fu,It.prototype.visitFixedSizeBinary=jr,It.prototype.visitDate=jr,It.prototype.visitTimestamp=jr,It.prototype.visitTime=jr,It.prototype.visitDecimal=jr,It.prototype.visitList=Wa,It.prototype.visitStruct=ja,It.prototype.visitUnion=Xm,It.prototype.visitInterval=jr,It.prototype.visitFixedSizeList=Wa,It.prototype.visitMap=Wa;var ln=class extends en{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Ke,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,zt(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Se(e)?e.then(t=>this.writeAll(t)):he(e)?Ya(this,e):$a(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof Ke?this._sink=e:(this._sink=new Ke,e&&Lc(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&kc(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!t||!an(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof $t&&!(t=e.schema))return this.finish()&&void 0;if(e instanceof gt&&!(t=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(t&&!an(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof gt?e instanceof cn||this._writeRecordBatch(e):e instanceof $t?this.writeAll(e.batches):Ie(e)&&this.writeAll(e)}_writeMessage(e,t=8){let i=t-1,n=te.encode(e),r=n.byteLength,s=this._writeLegacyIpcFormat?4:8,a=r+s+i&~i,o=a-r-s;return e.headerType===tt.RecordBatch?this._recordBatchBlocks.push(new yr(a,e.bodyLength,this._position)):e.headerType===tt.DictionaryBatch&&this._dictionaryBlocks.push(new yr(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-s)),r>0&&this._write(n),this._writePadding(o)}_write(e){if(this._started){let t=L(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(te.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Hn)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:i,bufferRegions:n,buffers:r}=It.assemble(e),s=new kt(e.numRows,i,n),a=te.from(s,t);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(r)}_writeDictionaryBatch(e,t,i=!1){this._dictionaryDeltaOffsets.set(t,e.length+(this._dictionaryDeltaOffsets.get(t)||0));let{byteLength:n,nodes:r,bufferRegions:s,buffers:a}=It.assemble(new J([e])),o=new kt(e.length,r,s),u=new Qt(o,t,i),f=te.from(u,n);return this._writeMessage(f)._writeBodyBuffers(a)}_writeBodyBuffers(e){let t,i,n;for(let r=-1,s=e.length;++r0&&(this._write(t),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(e){for(let[t,i]of e.dictionaries){let n=this._dictionaryDeltaOffsets.get(t)||0;if(n===0||(i=i==null?void 0:i.slice(n)).length>0)for(let r of i.data)this._writeDictionaryBatch(r,t,n>0),n+=r.length}return this}},un=class vc extends ln{static writeAll(t,i){let n=new vc(i);return Se(t)?t.then(r=>n.writeAll(r)):he(t)?Ya(n,t):$a(n,t)}},dn=class wc extends ln{static writeAll(t){let i=new wc;return Se(t)?t.then(n=>i.writeAll(n)):he(t)?Ya(i,t):$a(i,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let i=mr.encode(new mr(t,Ot.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(i)._write(Int32Array.of(i.byteLength))._writeMagic()}};function $a(e,t){let i=t;t instanceof $t&&(i=t.batches,e.reset(void 0,t.schema));for(let n of i)e.write(n);return e.finish()}function Ya(e,t){var i,n,r,s,a,o,u;return F(this,void 0,void 0,function*(){try{for(i=!0,n=ve(t);r=yield n.next(),s=r.done,!s;i=!0){u=r.value,i=!1;let f=u;e.write(f)}}catch(f){a={error:f}}finally{try{!i&&!s&&(o=n.return)&&(yield o.call(n))}finally{if(a)throw a.error}}return e.finish()})}function hu(e,t){if(he(e))return Jm(e,t);if(Ie(e))return Km(e,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Km(e,t){let i=null,n=(t==null?void 0:t.type)==="bytes"||!1,r=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(a){s(a,i||(i=e[Symbol.iterator]()))},pull(a){i?s(a,i):a.close()},cancel(){(i!=null&&i.return&&i.return()||!0)&&(i=null)}}),Object.assign({highWaterMark:n?r:void 0},t));function s(a,o){let u,f=null,y=a.desiredSize||null;for(;!(f=o.next(n?y:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=L(f.value))&&(y!=null&&n&&(y=y-u.byteLength+1),f.value=u),a.enqueue(f.value),y!=null&&--y<=0)return;a.close()}}function Jm(e,t){let i=null,n=(t==null?void 0:t.type)==="bytes"||!1,r=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(a){return F(this,void 0,void 0,function*(){yield s(a,i||(i=e[Symbol.asyncIterator]()))})},pull(a){return F(this,void 0,void 0,function*(){i?yield s(a,i):a.close()})},cancel(){return F(this,void 0,void 0,function*(){(i!=null&&i.return&&(yield i.return())||!0)&&(i=null)})}}),Object.assign({highWaterMark:n?r:void 0},t));function s(a,o){return F(this,void 0,void 0,function*(){let u,f=null,y=a.desiredSize||null;for(;!(f=yield o.next(n?y:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=L(f.value))&&(y!=null&&n&&(y=y-u.byteLength+1),f.value=u),a.enqueue(f.value),y!=null&&--y<=0)return;a.close()})}}function yu(e){return new Xa(e)}var Xa=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:t,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=e,r=Uc(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=nn(r),this._getSize=n!=="bytes"?pu:mu;let{["highWaterMark"]:s=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},t),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:o=>{this._maybeFlush(this._builder,this._controller=o)},start:o=>{this._maybeFlush(this._builder,this._controller=o)}},{highWaterMark:s,size:n!=="bytes"?pu:mu}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:o=>this._writeValueAndReturnChunkSize(o)})}_writeValueAndReturnChunkSize(e){let t=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-t}_maybeFlush(e,t){t!=null&&(this._bufferedSize>=t.desiredSize&&++this._numChunks&&this._enqueue(t,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(t,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(t,null)))}_enqueue(e,t){this._bufferedSize=0,this._controller=null,t==null?e.close():e.enqueue(t)}},pu=e=>{var t;return(t=e==null?void 0:e.length)!==null&&t!==void 0?t:0},mu=e=>{var t;return(t=e==null?void 0:e.byteLength)!==null&&t!==void 0?t:0};function Ao(e,t){let i=new Ke,n=null,r=new ReadableStream({cancel(){return F(this,void 0,void 0,function*(){yield i.close()})},start(o){return F(this,void 0,void 0,function*(){yield a(o,n||(n=yield s()))})},pull(o){return F(this,void 0,void 0,function*(){n?yield a(o,n):o.close()})}});return{writable:new WritableStream(i,Object.assign({highWaterMark:Math.pow(2,14)},e)),readable:r};function s(){return F(this,void 0,void 0,function*(){return yield(yield Ct.from(i)).open(t)})}function a(o,u){return F(this,void 0,void 0,function*(){let f=o.desiredSize,y=null;for(;!(y=yield u.next()).done;)if(o.enqueue(y.value),f!=null&&--f<=0)return;o.close()})}}function To(e,t){let i=new this(e),n=new _e(i),r=new ReadableStream({cancel(){return F(this,void 0,void 0,function*(){yield n.cancel()})},pull(a){return F(this,void 0,void 0,function*(){yield s(a)})},start(a){return F(this,void 0,void 0,function*(){yield s(a)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(i,e),readable:r};function s(a){return F(this,void 0,void 0,function*(){let o=null,u=a.desiredSize;for(;o=yield n.read(u||null);)if(a.enqueue(o),u!=null&&(u-=o.byteLength)<=0)return;a.close()})}}function xo(e,t="stream"){return(t==="stream"?un:dn).writeAll(e).toUint8Array(!0)}Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},sa),Ea),va),oa),ea),wa),{compareSchemas:an,compareFields:jl,compareTypes:Wl}),Ut.toDOMStream=hu,pt.throughDOM=yu,Ct.throughDOM=Ao,zr.throughDOM=Ao,Ze.throughDOM=Ao,ln.throughDOM=To,dn.throughDOM=To,un.throughDOM=To;function $n(e){switch(e.typeId){case h.Binary:return{sqlType:"binary"};case h.Bool:return{sqlType:"bool"};case h.Date:return{sqlType:"date"};case h.DateDay:return{sqlType:"date32[d]"};case h.DateMillisecond:return{sqlType:"date64[ms]"};case h.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case h.Float:return{sqlType:"float"};case h.Float16:return{sqlType:"float16"};case h.Float32:return{sqlType:"float32"};case h.Float64:return{sqlType:"float64"};case h.Int:return{sqlType:"int32"};case h.Int16:return{sqlType:"int16"};case h.Int32:return{sqlType:"int32"};case h.Int64:return{sqlType:"int64"};case h.Uint16:return{sqlType:"uint16"};case h.Uint32:return{sqlType:"uint32"};case h.Uint64:return{sqlType:"uint64"};case h.Uint8:return{sqlType:"uint8"};case h.IntervalDayTime:return{sqlType:"interval[dt]"};case h.IntervalYearMonth:return{sqlType:"interval[m]"};case h.List:return{sqlType:"list",valueType:$n(e.valueType)};case h.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case h.Null:return{sqlType:"null"};case h.Utf8:return{sqlType:"utf8"};case h.Struct:return{sqlType:"struct",fields:e.children.map(t=>Do(t.name,t.type))};case h.Map:{let t=e;return{sqlType:"map",keyType:$n(t.keyType),valueType:$n(t.valueType)}}case h.Time:return{sqlType:"time[s]"};case h.TimeMicrosecond:return{sqlType:"time[us]"};case h.TimeMillisecond:return{sqlType:"time[ms]"};case h.TimeNanosecond:return{sqlType:"time[ns]"};case h.TimeSecond:return{sqlType:"time[s]"};case h.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case h.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case h.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case h.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case h.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Do(e,t){let i=$n(t);return i.name=e,i}var Eo=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let i={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:i},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":this._bindings.open(e.data),this.sendOK(e);break;case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((i,n)=>n)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1]),i=[];t&&i.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},i);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),i=[];t&&i.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},i);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":this._bindings.registerFileHandle(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},Tu=Rc(Su()),Oo=class{constructor(e,t){this._bindings=e,this._conn=t}close(){this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}query(e){let t=this._bindings.runQuery(this._conn,e),i=Ct.from(t);return console.assert(i.isSync()),console.assert(i.isFile()),new $t(i)}async send(e){let t=this._bindings.startPendingQuery(this._conn,e);for(;t==null;)t=await new Promise((r,s)=>{try{r(this._bindings.pollPendingQuery(this._conn))}catch(a){console.log(a),s(a)}});let i=new Ro(this._bindings,this._conn,t),n=Ct.from(i);return console.assert(n.isSync()),console.assert(n.isStream()),n}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(e){return this._bindings.getTableNames(this._conn,e)}prepare(e){let t=this._bindings.createPrepared(this._conn,e);return new Ka(this._bindings,this._conn,t)}createScalarFunction(e,t,i){this._bindings.createScalarFunction(this._conn,e,t,i)}insertArrowTable(e,t){let i=xo(e,"stream");this.insertArrowFromIPCStream(i,t)}insertArrowFromIPCStream(e,t){this._bindings.insertArrowFromIPCStream(this._conn,e,t)}insertCSVFromPath(e,t){this._bindings.insertCSVFromPath(this._conn,e,t)}insertJSONFromPath(e,t){this._bindings.insertJSONFromPath(this._conn,e,t)}},Ro=class{constructor(e,t,i){this.bindings=e,this.conn=t,this.header=i,this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=this.bindings.fetchQueryResults(this.conn);return this._depleted=e.length==0,{done:this._depleted,value:e}}[Symbol.iterator](){return this}},Ka=class{constructor(e,t,i){this.bindings=e,this.connectionId=t,this.statementId=i}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...e){let t=this.bindings.runPrepared(this.connectionId,this.statementId,e),i=Ct.from(t);return console.assert(i.isSync()),console.assert(i.isFile()),new $t(i)}send(...e){let t=this.bindings.sendPrepared(this.connectionId,this.statementId,e),i=new Ro(this.bindings,this.connectionId,t),n=Ct.from(i);return console.assert(n.isSync()),console.assert(n.isStream()),n}},Bu=new TextEncoder,Iu=new TextDecoder("utf-8");function Ja(e,t,i){let n=Bu.encode(i),r=e._malloc(n.byteLength),s=e.HEAPU8.subarray(r,r+n.byteLength);s.set(n),e.HEAPF64[(t>>3)+0]=1,e.HEAPF64[(t>>3)+1]=r,e.HEAPF64[(t>>3)+2]=s.byteLength}function Za(e){switch(e){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function qa(e,t,i,n){let r=e.HEAPU8.subarray(t,t+n*Za(i));switch(i){case"UINT8":return new Uint8Array(r.buffer,r.byteOffset,n);case"INT8":return new Int8Array(r.buffer,r.byteOffset,n);case"INT32":return new Int32Array(r.buffer,r.byteOffset,n);case"FLOAT":return new Float32Array(r.buffer,r.byteOffset,n);case"DOUBLE":return new Float64Array(r.buffer,r.byteOffset,n);case"VARCHAR":return new Float64Array(r.buffer,r.byteOffset,n);default:return new Array(0)}}function Fu(e,t,i){let n=e.HEAPU8.subarray(t,t+i);return new Uint8Array(n.buffer,n.byteOffset,i)}function Mo(e,t,i){let n=e.HEAPU8.subarray(t,t+i*8);return new Float64Array(n.buffer,n.byteOffset,i)}function Au(e,t,i,n,r,s,a,o){try{let u=e._udfFunctions.get(n);if(!u){Ja(t,i,"Unknown UDF with id: "+n);return}let f=Iu.decode(t.HEAPU8.subarray(r,r+s)),y=JSON.parse(f),g=Mo(t,a,o/8),I=q=>{var de;let ct=null;switch(q.validityBuffer!==void 0&&(ct=Fu(t,g[q.validityBuffer],y.rows)),q.physicalType){case"VARCHAR":{if(q.dataBuffer===null||q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(q.lengthBuffer===null||q.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let bt=qa(t,g[q.dataBuffer],q.physicalType,y.rows),vt=[],Tt=Mo(t,g[q.lengthBuffer],y.rows);for(let m=0;mvt[m]}case"STRUCT":{let bt={},vt=[];for(let Tt=0;Tt<(((de=q.children)==null?void 0:de.length)||0);++Tt){let m=q.children[Tt],ot=I(m);vt.push(er=>{bt[m.name]=ot(er)})}return ct!=null?Tt=>{if(!ct[Tt])return null;for(let m of vt)m(Tt);return bt}:Tt=>{for(let m of vt)m(Tt);return bt}}default:{if(q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+q.physicalType);let bt=qa(t,g[q.dataBuffer],q.physicalType,y.rows);return ct!=null?vt=>ct[vt]?bt[vt]:null:vt=>bt[vt]}}},S=[];for(let q=0;q>3)+0]=0,t.HEAPF64[(i>>3)+1]=Xi,t.HEAPF64[(i>>3)+2]=0}catch(u){Ja(t,i,u.toString())}}function ry(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}var ny=ry();function ge(e,t){console.error("FAIL WITH: ".concat(t)),e.ccall("duckdb_web_fail_with",null,["string"],[t])}function fn(e,t,i){let n=e.HEAPU8.subarray(t,t+i),r=new Uint8Array(new ArrayBuffer(n.byteLength));return r.set(n),r}function z(e,t,i){return ny(e.HEAPU8.subarray(t,t+i))}function it(e,t,i,n){let r=e.stackSave(),s=e.stackAlloc(3*8);i.unshift("number"),n.unshift(s),e.ccall(t,null,i,n);let a=e.HEAPF64[(s>>3)+0],o=e.HEAPF64[(s>>3)+1],u=e.HEAPF64[(s>>3)+2];return e.stackRestore(r),[a,o,u]}function ft(e){e.ccall("duckdb_web_clear_response",null,[],[])}var Uo=class{constructor(e){let t=new Float64Array(e.buffer,e.byteOffset,e.byteLength/8),i=new Uint8Array(new ArrayBuffer(e.byteLength));i.set(e.subarray(7*8)),this.totalFileReadsCold=t[0],this.totalFileReadsAhead=t[1],this.totalFileReadsCached=t[2],this.totalFileWrites=t[3],this.totalPageAccesses=t[4],this.totalPageLoads=t[5],this.blockSize=t[6],this.blockStats=i}getBlockStats(e,t){return t=t||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},t.file_writes=this.blockStats[e*3+0]&15,t.file_reads_cold=this.blockStats[e*3+0]>>4,t.file_reads_ahead=this.blockStats[e*3+1]&15,t.file_reads_cached=this.blockStats[e*3+1]>>4,t.page_accesses=this.blockStats[e*3+1]&15,t.page_loads=this.blockStats[e*3+1]>>4,t}},iy=new TextEncoder,No=class{constructor(e,t){this._instance=null,this._initPromise=null,this._initPromiseResolver=()=>{},this.onInstantiationProgress=[],this._logger=e,this._runtime=t,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(e=t=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(e),await this._initPromise),this._initPromise=new Promise(t=>{this._initPromiseResolver=t}),this.onInstantiationProgress=[e],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(t=>t!=e),this)}open(e){let[t,i,n]=it(this.mod,"duckdb_web_open",["string"],[JSON.stringify(e)]);if(t!==0)throw new Error(z(this.mod,i,n));ft(this.mod)}reset(){let[e,t,i]=it(this.mod,"duckdb_web_reset",[],[]);if(e!==0)throw new Error(z(this.mod,t,i));ft(this.mod)}getVersion(){let[e,t,i]=it(this.mod,"duckdb_web_get_version",[],[]);if(e!==0)throw new Error(z(this.mod,t,i));let n=z(this.mod,t,i);return ft(this.mod),n}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(e){let[t,i,n]=it(this.mod,"duckdb_web_tokenize",["string"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));let r=z(this.mod,i,n);return ft(this.mod),JSON.parse(r)}connect(){let e=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Oo(this,e)}disconnect(e){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[e]),this.pthread)for(let t of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])t.postMessage({cmd:"dropUDFFunctions",connectionId:e})}runQuery(e,t){let[i,n,r]=it(this.mod,"duckdb_web_query_run",["number","string"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));let s=fn(this.mod,n,r);return ft(this.mod),s}startPendingQuery(e,t){let[i,n,r]=it(this.mod,"duckdb_web_pending_query_start",["number","string"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));if(n==0)return null;let s=fn(this.mod,n,r);return ft(this.mod),s}pollPendingQuery(e){let[t,i,n]=it(this.mod,"duckdb_web_pending_query_poll",["number"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));if(i==0)return null;let r=fn(this.mod,i,n);return ft(this.mod),r}cancelPendingQuery(e){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[e])}fetchQueryResults(e){let[t,i,n]=it(this.mod,"duckdb_web_query_fetch_results",["number"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));let r=fn(this.mod,i,n);return ft(this.mod),r}getTableNames(e,t){let[i,n,r]=it(this.mod,"duckdb_web_get_tablenames",["number","string"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));let s=z(this.mod,n,r);return ft(this.mod),JSON.parse(s)}createScalarFunction(e,t,i,n){let r={functionId:this._nextUDFId,name:t,returnType:$n(i)},s={functionId:r.functionId,connectionId:e,name:t,returnType:i,func:n};this._nextUDFId+=1;let[a,o,u]=it(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[e,JSON.stringify(r)]);if(a!==0)throw new Error(z(this.mod,o,u));if(ft(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(s.functionId,s),this.pthread)for(let f of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])f.postMessage({cmd:"registerUDFFunction",udf:s})}createPrepared(e,t){let[i,n,r]=it(this.mod,"duckdb_web_prepared_create",["number","string"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));return ft(this.mod),n}closePrepared(e,t){let[i,n,r]=it(this.mod,"duckdb_web_prepared_close",["number","number"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));ft(this.mod)}runPrepared(e,t,i){let[n,r,s]=it(this.mod,"duckdb_web_prepared_run",["number","number","string"],[e,t,JSON.stringify(i)]);if(n!==0)throw new Error(z(this.mod,r,s));let a=fn(this.mod,r,s);return ft(this.mod),a}sendPrepared(e,t,i){let[n,r,s]=it(this.mod,"duckdb_web_prepared_send",["number","number","string"],[e,t,JSON.stringify(i)]);if(n!==0)throw new Error(z(this.mod,r,s));let a=fn(this.mod,r,s);return ft(this.mod),a}insertArrowFromIPCStream(e,t,i){if(t.length==0)return;let n=this.mod._malloc(t.length);this.mod.HEAPU8.subarray(n,n+t.length).set(t);let r=i?JSON.stringify(i):"",[s,a,o]=it(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[e,n,t.length,r]);if(s!==0)throw new Error(z(this.mod,a,o))}insertCSVFromPath(e,t,i){if(i.columns!==void 0){i.columnsFlat=[];for(let u in i.columns)i.columnsFlat.push(Do(u,i.columns[u]))}let n={...i};n.columns=n.columnsFlat,delete n.columnsFlat;let r=JSON.stringify(n),[s,a,o]=it(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[e,t,r]);if(s!==0)throw new Error(z(this.mod,a,o))}insertJSONFromPath(e,t,i){if(i.columns!==void 0){i.columnsFlat=[];for(let u in i.columns)i.columnsFlat.push(Do(u,i.columns[u]))}let n={...i};n.columns=n.columnsFlat,delete n.columnsFlat;let r=JSON.stringify(n),[s,a,o]=it(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[e,t,r]);if(s!==0)throw new Error(z(this.mod,a,o))}globFiles(e){let[t,i,n]=it(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));let r=z(this.mod,i,n);ft(this.mod);let s=JSON.parse(r);return s??[]}registerFileURL(e,t,i,n=!1){t===void 0&&(t=e);let[r,s,a]=it(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[e,t,i,n]);if(r!==0)throw new Error(z(this.mod,s,a));ft(this.mod)}registerFileText(e,t){let i=iy.encode(t);this.registerFileBuffer(e,i)}registerFileBuffer(e,t){let i=this.mod._malloc(t.length);this.mod.HEAPU8.subarray(i,i+t.length).set(t);let[n,r,s]=it(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[e,i,t.length]);if(n!==0)throw new Error(z(this.mod,r,s));ft(this.mod)}registerFileHandle(e,t,i,n){let[r,s,a]=it(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[e,e,i,n]);if(r!==0)throw new Error(z(this.mod,s,a));if(ft(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(e,t),this.pthread){for(let o of this.pthread.runningWorkers)o.postMessage({cmd:"registerFileHandle",fileName:e,fileHandle:t});for(let o of this.pthread.unusedWorkers)o.postMessage({cmd:"dropFileHandle",fileName:e})}}dropFile(e){let[t,i,n]=it(this.mod,"duckdb_web_fs_drop_file",["string"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));ft(this.mod)}dropFiles(){let[e,t,i]=it(this.mod,"duckdb_web_fs_drop_files",[],[]);if(e!==0)throw new Error(z(this.mod,t,i));ft(this.mod)}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(e,t){let[i,n,r]=it(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r));ft(this.mod)}copyFileToBuffer(e){let[t,i,n]=it(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));let r=this.mod.HEAPU8.subarray(i,i+n),s=new Uint8Array(r.length);return s.set(r),ft(this.mod),s}collectFileStatistics(e,t){let[i,n,r]=it(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[e,t]);if(i!==0)throw new Error(z(this.mod,n,r))}exportFileStatistics(e){let[t,i,n]=it(this.mod,"duckdb_web_export_file_stats",["string"],[e]);if(t!==0)throw new Error(z(this.mod,i,n));return new Uo(this.mod.HEAPU8.subarray(i,i+n))}},Lo=class extends No{constructor(e,t,i,n){super(e,t),this.mainModuleURL=i,this.pthreadWorkerURL=n}locateFile(e,t){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error("WASM instantiation requested unexpected file: prefix=".concat(t," path=").concat(e))}instantiateWasm(e,t){globalThis.DUCKDB_RUNTIME=this._runtime;let i=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let n=(async()=>{var r;let s=new Request(this.mainModuleURL),a=await fetch(s),o=a.headers.get("content-length"),u=o&&parseInt(o,10)||0,f=new Date,y={startedAt:f,updatedAt:f,bytesTotal:u||0,bytesLoaded:0},g={transform(S,x){y.bytesLoaded+=S.byteLength;let At=new Date;if(At.getTime()-y.updatedAt.getTime()<20){y.updatedAt=At,x.enqueue(S);return}for(let lt of i)lt(y);x.enqueue(S)}},I=new TransformStream(g);return new Response((r=a.body)==null?void 0:r.pipeThrough(I),a)})();WebAssembly.instantiateStreaming(n,e).then(r=>{t(r.instance,r.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let n=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(n),e).then(r=>{t(r.instance,r.module)})}else if(typeof XMLHttpRequest=="function"){let n=new XMLHttpRequest,r=this.mainModuleURL,s=new Date,a={startedAt:s,updatedAt:s,bytesTotal:0,bytesLoaded:0};n.open("GET",r),n.responseType="arraybuffer",n.onerror=o=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+o}),new Error(o.toString())},n.onprogress=o=>{a.bytesTotal=o.total,a.bytesLoaded=o.loaded;let u=new Date;if(u.getTime()-a.updatedAt.getTime()<20){a.updatedAt=u;return}for(let f of i)f(a)},n.onload=()=>{WebAssembly.instantiate(n.response,e).then(o=>{t(o.instance,o.module)}).catch(o=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+o}),new Error(o)})},n.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let n=new Request(this.mainModuleURL),r=await(await fetch(n)).arrayBuffer();WebAssembly.instantiate(r,e).then(s=>{t(s.instance,s.module)})})();return[]}},ko=class extends Lo{constructor(e,t,i,n=null){super(e,t,i,n)}instantiateImpl(e){return(0,Tu.default)({...e,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}},Wr=Rc(xu()),Du=function(e,t,i){var n;if((n=e==null?void 0:e.endpoint)!=null&&n.startsWith("http")){let r="".concat(e==null?void 0:e.endpoint),s=r.indexOf("://")+3;return r.substring(s)}else return e!=null&&e.endpoint?"".concat(i,".").concat(e==null?void 0:e.endpoint):"".concat(i,".s3.amazonaws.com")};function sy(e,t,i){var n,r,s,a;let o=Eu(t),u=o.path;return Ou(e)&&(u="/".concat(o.bucket).concat(u)),{url:u,query:"",host:Du(e,t,o.bucket),region:(n=e==null?void 0:e.region)!=null?n:"",service:"s3",method:i,accessKeyId:(r=e==null?void 0:e.accessKeyId)!=null?r:"",secretAccessKey:(s=e==null?void 0:e.secretAccessKey)!=null?s:"",sessionToken:(a=e==null?void 0:e.sessionToken)!=null?a:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function oy(e,t=!1){let i="0123456789ABCDEF",n="";for(let r=0;r="A"&&s<="Z"||s>="a"&&s<="z"||s>="0"&&s<="9"||s=="_"||s=="-"||s=="~"||s=="."?n+=s:s=="/"?t?n+="%2F":n+=s:(n+="%",n+=i[s.charCodeAt(0)>>4],n+=i[s.charCodeAt(0)&15])}return n}function ay(e,t=null){var i;let n=(i=t==null?void 0:t.contentHash)!=null?i:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",r=new Map;r.set("x-amz-date",e.datetimeNow),r.set("x-amz-content-sha256",n),e.sessionToken&&r.set("x-amz-security-token",e.sessionToken);let s="";t!=null&&t.contentType&&(s+="content-type;"),s+="host;x-amz-content-sha256;x-amz-date",e.sessionToken&&(s+=";x-amz-security-token");let a=e.method+` `+oy(e.url)+` `+e.query;t!=null&&t.contentType&&(a+=` content-type:`+(t==null?void 0:t.contentType)),a+=` host:`+e.host+` x-amz-content-sha256:`+n+` x-amz-date:`+e.datetimeNow,e.sessionToken&&e.sessionToken.length>0&&(a+=` x-amz-security-token:`+e.sessionToken),a+=` `+s+` `+n;let o=(0,Wr.sha256)(a),u=`AWS4-HMAC-SHA256 `+e.datetimeNow+` `+e.dateNow+"/"+e.region+"/"+e.service+`/aws4_request `+o,f="AWS4"+e.secretAccessKey,y=Wr.sha256.hmac.arrayBuffer(f,e.dateNow),g=Wr.sha256.hmac.arrayBuffer(y,e.region),I=Wr.sha256.hmac.arrayBuffer(g,e.service),S=Wr.sha256.hmac.arrayBuffer(I,"aws4_request"),x=Wr.sha256.hmac(S,u);return r.set("Authorization","AWS4-HMAC-SHA256 Credential="+e.accessKeyId+"/"+e.dateNow+"/"+e.region+"/"+e.service+"/aws4_request, SignedHeaders="+s+", Signature="+x),r}var cy=function(e,t,i,n=null,r=null){let s=sy(e,t,i),a={contentType:n,contentHash:r?Wr.sha256.hex(r):null};return ay(s,a)};function Qe(e,t,i,n,r=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(cy(t,i,n,r,s).forEach((a,o)=>{e.setRequestHeader(o,a)}),r&&e.setRequestHeader("content-type",r))}function Eu(e){if(e.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let t=e.indexOf("/",5);if(t==-1)throw new Error("URL needs to contain a '/' after the host");let i=e.substring(5,t);if(!i)throw new Error("URL needs to contain a bucket name");let n=e.substring(t);if(!n)throw new Error("URL needs to contain key");return{bucket:i,path:n}}function Ou(e){var t;return!!((t=e==null?void 0:e.endpoint)!=null&&t.startsWith("http"))}function tr(e,t){let i=Eu(t);return Ou(e)?"".concat(e==null?void 0:e.endpoint,"/").concat(i.bucket)+i.path:"https://"+Du(e,t,i.bucket)+i.path}var et={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,getFileInfo(e,t){try{let i=et._fileInfoCache.get(t),[n,r,s]=it(e,"duckdb_web_fs_get_file_info_by_id",["number","number"],[t,(i==null?void 0:i.cacheEpoch)||0]);if(n!==0)return null;if(s===0)return i;let a=z(e,r,s);ft(e);let o=JSON.parse(a);if(o==null)return null;let u={...o,blob:null};return et._fileInfoCache.set(t,u),u}catch(i){return console.log(i),null}},getGlobalFileInfo(e){var t;try{let[i,n,r]=it(e,"duckdb_web_get_global_file_info",["number"],[((t=et._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(i!==0)return null;if(r===0)return et._globalFileInfo;let s=z(e,n,r);ft(e);let a=JSON.parse(s);return a==null?null:(et._globalFileInfo={...a,blob:null},et._globalFileInfo)}catch(i){return console.log(i),null}},testPlatformFeature:(e,t)=>{switch(t){case 1:return typeof BigInt64Array<"u";default:return console.warn("test for unknown feature: ".concat(t)),!1}},getDefaultDataProtocol(e){return 2},openFile:(e,t,i)=>{var n;try{et._fileInfoCache.delete(t);let r=et.getFileInfo(e,t);switch(r==null?void 0:r.dataProtocol){case 4:case 5:{if(i&1&&i&2)throw new Error("Opening file ".concat(r.fileName," failed: cannot open file with both read and write flags set"));if(i&32)throw new Error("Opening file ".concat(r.fileName," failed: appending to HTTP/S3 files is not supported"));if(i&2){let o=new XMLHttpRequest;if(r.dataProtocol==5?(o.open("HEAD",tr(r.s3Config,r.dataUrl),!1),Qe(o,r.s3Config,r.dataUrl,"HEAD")):o.open("HEAD",r.dataUrl,!1),o.send(null),o.status!=200&&o.status!=404)throw new Error("Opening file ".concat(r.fileName," failed: Unexpected return status from server (").concat(o.status,")"));if(o.status==404&&!(i&8||i&16))throw new Error("Opening file ".concat(r.fileName," failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag."));let u=e._malloc(1),f=new Uint8Array;e.HEAPU8.set(f,u);let y=e._malloc(2*8);return e.HEAPF64[(y>>3)+0]=1,e.HEAPF64[(y>>3)+1]=u,y}else if(i!=1)throw new Error("Opening file ".concat(r.fileName," failed: unsupported file flags: ").concat(i));let s=null,a=null;try{let o=new XMLHttpRequest;if(r.dataProtocol==5?(o.open("HEAD",tr(r.s3Config,r.dataUrl),!1),Qe(o,r.s3Config,r.dataUrl,"HEAD")):o.open("HEAD",r.dataUrl,!1),o.setRequestHeader("Range","bytes=0-"),o.send(null),s=o.getResponseHeader("Content-Length"),s!==null&&o.status==206){let u=e._malloc(16);return e.HEAPF64[(u>>3)+0]=+s,e.HEAPF64[(u>>3)+1]=0,u}}catch(o){a=o,console.warn("HEAD request with range header failed: ".concat(o))}if(r.allowFullHttpReads){if(s!==null&&+s>1){let u=new XMLHttpRequest;r.dataProtocol==5?(u.open("GET",tr(r.s3Config,r.dataUrl),!1),Qe(u,r.s3Config,r.dataUrl,"GET")):u.open("GET",r.dataUrl,!1),u.responseType="arraybuffer",u.setRequestHeader("Range","bytes=0-0"),u.send(null);let f=u.getResponseHeader("Content-Length");if(u.status==206&&f!==null&&+f==1){let y=e._malloc(16);return e.HEAPF64[(y>>3)+0]=+s,e.HEAPF64[(y>>3)+1]=0,y}if(u.status==200&&f!==null&&+f==+s){console.warn("fall back to full HTTP read for: ".concat(r.dataUrl));let y=e._malloc(u.response.byteLength),g=new Uint8Array(u.response,0,u.response.byteLength);e.HEAPU8.set(g,y);let I=e._malloc(2*8);return e.HEAPF64[(I>>3)+0]=u.response.byteLength,e.HEAPF64[(I>>3)+1]=y,I}}console.warn("falling back to full HTTP read for: ".concat(r.dataUrl));let o=new XMLHttpRequest;if(r.dataProtocol==5?(o.open("GET",tr(r.s3Config,r.dataUrl),!1),Qe(o,r.s3Config,r.dataUrl,"GET")):o.open("GET",r.dataUrl,!1),o.responseType="arraybuffer",o.send(null),o.status==200){let u=e._malloc(o.response.byteLength),f=new Uint8Array(o.response,0,o.response.byteLength);e.HEAPU8.set(f,u);let y=e._malloc(2*8);return e.HEAPF64[(y>>3)+0]=o.response.byteLength,e.HEAPF64[(y>>3)+1]=u,y}}if(a!=null)throw new Error("Reading file ".concat(r.fileName," failed with error: ").concat(a));return 0}case 2:{let s=(n=et._files)==null?void 0:n.get(r.fileName);if(s){let u=e._malloc(16);return e.HEAPF64[(u>>3)+0]=s.size,e.HEAPF64[(u>>3)+1]=0,u}console.warn("Buffering missing file: ".concat(r.fileName));let a=e._malloc(2*8),o=e._malloc(1);return e.HEAPF64[(a>>3)+0]=1,e.HEAPF64[(a>>3)+1]=o,a}}}catch(r){console.error(r.toString()),ge(e,r.toString())}return 0},glob:(e,t,i)=>{var n;try{let r=z(e,t,i);if(r.startsWith("http")||r.startsWith("s3://")){let s=new XMLHttpRequest;if(r.startsWith("s3://")){let a=et.getGlobalFileInfo(e);s.open("HEAD",tr(a==null?void 0:a.s3Config,r),!1),Qe(s,a==null?void 0:a.s3Config,r,"HEAD")}else s.open("HEAD",r,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=et.getGlobalFileInfo(e))!=null&&n.allowFullHttpReads)){ge(e,"HEAD request failed: ".concat(r,", with full http reads are disabled"));return}let a=new XMLHttpRequest;if(r.startsWith("s3://")){let u=et.getGlobalFileInfo(e);a.open("GET",tr(u==null?void 0:u.s3Config,r),!1),Qe(a,u==null?void 0:u.s3Config,r,"HEAD")}else a.open("GET",r,!1);if(a.setRequestHeader("Range","bytes=0-0"),a.send(null),a.status!=200&&a.status!==206){ge(e,"HEAD and GET requests failed: ".concat(r));return}let o=a.getResponseHeader("Content-Length");o&&+o>1&&console.warn("Range request for ".concat(r," did not return a partial response: ").concat(a.status,' "').concat(a.statusText,'"'))}e.ccall("duckdb_web_fs_glob_add_path",null,["string"],[r])}}catch(r){return console.log(r),ge(e,r.toString()),0}},checkFile:(e,t,i)=>{try{let n=z(e,t,i);if(n.startsWith("http")||n.startsWith("s3://")){let r=new XMLHttpRequest;if(n.startsWith("s3://")){let s=et.getGlobalFileInfo(e);r.open("HEAD",tr(s==null?void 0:s.s3Config,n),!1),Qe(r,s==null?void 0:s.s3Config,n,"HEAD")}else r.open("HEAD",n,!1);return r.send(null),r.status==206||r.status==200}}catch(n){return console.log(n),!1}return!1},syncFile:(e,t)=>{},closeFile:(e,t)=>{var i;let n=et.getFileInfo(e,t);switch(et._fileInfoCache.delete(t),n==null?void 0:n.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let r=(i=et._files)==null?void 0:i.get(n.fileName);if(!r)throw new Error("No OPFS access handle registered with name: ".concat(n.fileName));return r.flush()}}},truncateFile:(e,t,i)=>{var n;let r=et.getFileInfo(e,t);switch(r==null?void 0:r.dataProtocol){case 4:ge(e,"Cannot truncate a http file");return;case 5:ge(e,"Cannot truncate an s3 file");return;case 0:case 1:case 2:ge(e,"truncateFile not implemented");return;case 3:{let s=(n=et._files)==null?void 0:n.get(r.fileName);if(!s)throw new Error("No OPFS access handle registered with name: ".concat(r.fileName));return s.truncate(i)}}return 0},readFile(e,t,i,n,r){var s,a;if(n==0)return 0;try{let o=et.getFileInfo(e,t);switch(o==null?void 0:o.dataProtocol){case 4:case 5:{if(!o.dataUrl)throw new Error("Missing data URL for file ".concat(t));try{let u=new XMLHttpRequest;if(o.dataProtocol==5?(u.open("GET",tr(o==null?void 0:o.s3Config,o.dataUrl),!1),Qe(u,o==null?void 0:o.s3Config,o.dataUrl,"GET")):u.open("GET",o.dataUrl,!1),u.responseType="arraybuffer",u.setRequestHeader("Range","bytes=".concat(r,"-").concat(r+n-1)),u.send(null),u.status==206||u.status==200&&n==u.response.byteLength&&r==0){let f=new Uint8Array(u.response,0,Math.min(u.response.byteLength,n));return e.HEAPU8.set(f,i),f.byteLength}else if(u.status==200){console.warn("Range request for ".concat(o.dataUrl," did not return a partial response: ").concat(u.status,' "').concat(u.statusText,'"'));let f=new Uint8Array(u.response,r,Math.min(u.response.byteLength-r,n));return e.HEAPU8.set(f,i),f.byteLength}else throw new Error("Range request for ".concat(o.dataUrl," did returned non-success status: ").concat(u.status,' "').concat(u.statusText,'"'))}catch(u){throw console.log(u),new Error("Range request for ".concat(o.dataUrl," failed with error: ").concat(u,'"'))}}case 2:{let u=(s=et._files)==null?void 0:s.get(o.fileName);if(!u)throw new Error("No HTML5 file registered with name: ".concat(o.fileName));let f=u.slice(r,r+n),y=new Uint8Array(new FileReaderSync().readAsArrayBuffer(f));return e.HEAPU8.set(y,i),y.byteLength}case 3:{let u=(a=et._files)==null?void 0:a.get(o.fileName);if(!u)throw new Error("No OPFS access handle registered with name: ".concat(o.fileName));let f=e.HEAPU8.subarray(i,i+n);return u.read(f,{at:r})}}return 0}catch(o){return console.log(o),ge(e,o.toString()),0}},writeFile:(e,t,i,n,r)=>{var s;let a=et.getFileInfo(e,t);switch(a==null?void 0:a.dataProtocol){case 4:return ge(e,"Cannot write to HTTP file"),0;case 5:{let o=e.HEAPU8.subarray(i,i+n),u=new XMLHttpRequest;return u.open("PUT",tr(a==null?void 0:a.s3Config,a.dataUrl),!1),Qe(u,a==null?void 0:a.s3Config,a.dataUrl,"PUT","",o),u.send(o),u.status!==200?(ge(e,"Failed writing file: HTTP "+u.status),0):n}case 2:return ge(e,"cannot write using the html5 file reader api"),0;case 3:{let o=(s=et._files)==null?void 0:s.get(a.fileName);if(!o)throw new Error("No OPFS access handle registered with name: ".concat(a.fileName));let u=e.HEAPU8.subarray(i,i+n);return o.write(u,{at:r})}}return 0},getLastFileModificationTime:(e,t)=>{var i;let n=et.getFileInfo(e,t);switch(n==null?void 0:n.dataProtocol){case 2:{if(!((i=et._files)!=null&&i.get(n.fileName)))throw Error("No handle available for file: ".concat(n.fileName));return 0}case 4:case 5:return new Date().getTime()}return 0},checkDirectory:(e,t,i)=>{let n=z(e,t,i);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(e,t,i)=>{let n=z(e,t,i);console.log("createDirectory: ".concat(n))},removeDirectory:(e,t,i)=>{let n=z(e,t,i);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(e,t,i)=>{let n=z(e,t,i);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(e,t,i,n,r)=>{var s,a;let o=z(e,t,i),u=z(e,n,r),f=(s=et._files)==null?void 0:s.get(o);f!==void 0&&(et._files.delete(f),et._files.set(u,f));for(let[y,g]of((a=et._fileInfoCache)==null?void 0:a.entries())||[])if(g.dataUrl==o){et._fileInfoCache.delete(y);break}return!0},removeFile:(e,t,i)=>{},callScalarUDF:(e,t,i,n,r,s,a)=>{Au(et,e,t,i,n,r,s,a)}},Qa=class extends Eo{postMessage(e,t){globalThis.postMessage(e,t)}async instantiate(e,t,i){return await new ko(this,et,e,t).instantiate(i)}};function Ru(){let e=new Qa;globalThis.onmessage=async t=>{await e.onMessage(t.data)}}return Ru(),gh(ly)})()})();