@run-trace/duckdb-wasm 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var duckdb=(()=>{var yp=Object.create;var ys=Object.defineProperty;var _p=Object.getOwnPropertyDescriptor;var bp=Object.getOwnPropertyNames;var gp=Object.getPrototypeOf,wp=Object.prototype.hasOwnProperty;var pa=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var vp=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var On=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Cr=(r,t)=>{for(var e in t)ys(r,e,{get:t[e],enumerable:!0})},sl=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bp(t))!wp.call(r,i)&&i!==e&&ys(r,i,{get:()=>t[i],enumerable:!(n=_p(t,i))||n.enumerable});return r};var ol=(r,t,e)=>(e=r!=null?yp(gp(r)):{},sl(t||!r||!r.__esModule?ys(e,"default",{value:r,enumerable:!0}):e,r)),Sp=r=>sl(ys({},"__esModule",{value:!0}),r);var Ip=function(r,t){this[0]=r,this[1]=t};var sn=r=>{var t=r[pa("asyncIterator")],e=!1,n,i={};return t==null?(t=r[pa("iterator")](),n=s=>i[s]=o=>t[s](o)):(t=t.call(r),n=s=>i[s]=o=>{if(e){if(e=!1,s==="throw")throw o;return o}return e=!0,{done:!1,value:new Ip(new Promise(c=>{var l=t[s](o);if(!(l instanceof Object))throw TypeError("Object expected");c(l)}),1)}}),i[pa("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var od=On(()=>{});var ad=On(()=>{});var ud=On((ld,wc)=>{"use strict";var cd=(()=>{var t;var r=typeof document<"u"?(t=document.currentScript)==null?void 0:t.src:void 0;return typeof __filename<"u"&&(r||(r=__filename)),function(e={}){var n=e,i,s,o=new Promise((a,u)=>{i=a,s=u}),c=Object.assign({},n),l=[],f="./this.program",p=(a,u)=>{throw u},B=typeof window=="object",A=typeof importScripts=="function",E=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",X="";function Ft(a){return n.locateFile?n.locateFile(a,X):X+a}var Pt,Lt,Bt;if(E){var wt=od(),qt=ad();A?X=qt.dirname(X)+"/":X=__dirname+"/",Pt=(a,u)=>(a=Ic(a)?new URL(a):qt.normalize(a),wt.readFileSync(a,u?void 0:"utf8")),Bt=a=>{var u=Pt(a,!0);return u.buffer||(u=new Uint8Array(u)),u},Lt=(a,u,d,m=!0)=>{a=Ic(a)?new URL(a):qt.normalize(a),wt.readFile(a,m?void 0:"utf8",(y,_)=>{y?d(y):u(m?_.buffer:_)})},!n.thisProgram&&process.argv.length>1&&(f=process.argv[1].replace(/\\/g,"/")),l=process.argv.slice(2),p=(a,u)=>{throw process.exitCode=a,u}}else(B||A)&&(A?X=self.location.href:typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),r&&(X=r),X.startsWith("blob:")?X="":X=X.substr(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1),Pt=a=>{var u=new XMLHttpRequest;return u.open("GET",a,!1),u.send(null),u.responseText},A&&(Bt=a=>{var u=new XMLHttpRequest;return u.open("GET",a,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}),Lt=(a,u,d)=>{var m=new XMLHttpRequest;m.open("GET",a,!0),m.responseType="arraybuffer",m.onload=()=>{if(m.status==200||m.status==0&&m.response){u(m.response);return}d()},m.onerror=d,m.send(null)});var Kt=n.print||console.log.bind(console),w=n.printErr||console.error.bind(console);Object.assign(n,c),c=null,n.arguments&&(l=n.arguments),n.thisProgram&&(f=n.thisProgram),n.quit&&(p=n.quit);var M;n.wasmBinary&&(M=n.wasmBinary);var V,D=!1,N;function x(a,u){a||Ee(u)}var j,I,H,Z,T,mt,Xe,_t;function xe(){var a=V.buffer;n.HEAP8=j=new Int8Array(a),n.HEAP16=H=new Int16Array(a),n.HEAPU8=I=new Uint8Array(a),n.HEAPU16=Z=new Uint16Array(a),n.HEAP32=T=new Int32Array(a),n.HEAPU32=mt=new Uint32Array(a),n.HEAPF32=Xe=new Float32Array(a),n.HEAPF64=_t=new Float64Array(a)}var Te=[],Nr=[],oi=[],Fn=[],en=!1;function wd(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)Dd(n.preRun.shift());ls(Te)}function vd(){en=!0,ls(Nr)}function Sd(){ls(oi)}function Id(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Fd(n.postRun.shift());ls(Fn)}function Dd(a){Te.unshift(a)}function Bd(a){Nr.unshift(a)}function Fd(a){Fn.unshift(a)}var rn=0,sa=null,ai=null;function Ad(a){var u;rn++,(u=n.monitorRunDependencies)==null||u.call(n,rn)}function xd(a){var d;if(rn--,(d=n.monitorRunDependencies)==null||d.call(n,rn),rn==0&&(sa!==null&&(clearInterval(sa),sa=null),ai)){var u=ai;ai=null,u()}}function Ee(a){var d;(d=n.onAbort)==null||d.call(n,a),a="Aborted("+a+")",w(a),D=!0,N=1,a+=". Build with -sASSERTIONS for more info.",en&&___trap();var u=new WebAssembly.RuntimeError(a);throw s(u),u}var Td="data:application/octet-stream;base64,",Sc=a=>a.startsWith(Td),Ic=a=>a.startsWith("file://"),An;An="./duckdb-eh.wasm",Sc(An)||(An=Ft(An));function Dc(a){if(a==An&&M)return new Uint8Array(M);if(Bt)return Bt(a);throw"both async and sync fetching of the wasm failed"}function Ed(a){return!M&&(B||A)&&typeof fetch=="function"?fetch(a,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '".concat(a,"'");return u.arrayBuffer()}).catch(()=>Dc(a)):Promise.resolve().then(()=>Dc(a))}function Bc(a,u,d){return Ed(a).then(m=>WebAssembly.instantiate(m,u)).then(d,m=>{w("failed to asynchronously prepare wasm: ".concat(m)),Ee(m)})}function Od(a,u,d,m){return!a&&typeof WebAssembly.instantiateStreaming=="function"&&!Sc(u)&&!E&&typeof fetch=="function"?fetch(u,{credentials:"same-origin"}).then(y=>{var _=WebAssembly.instantiateStreaming(y,d);return _.then(m,function(b){return w("wasm streaming compile failed: ".concat(b)),w("falling back to ArrayBuffer instantiation"),Bc(u,d,m)})}):Bc(u,d,m)}function Ud(){var a={a:vh};function u(m,y){return P=m.exports,P=hp(P),V=P.ua,xe(),Jc=P.xa,Bd(P.va),xd("wasm-instantiate"),P}Ad("wasm-instantiate");function d(m){u(m.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(a,u)}catch(m){w("Module.instantiateWasm callback failed with error: ".concat(m)),s(m)}return Od(M,An,a,d).catch(s),{}}var we,xn,Md={10168112:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(Ot){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ot)}b+=2}try{_.send(null)}catch(Ot){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+4),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+4]=ft[st];var F=new Uint8Array(4);return F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10169519:(a,u,d,m,y,_)=>{var b=bt(a);if(typeof XMLHttpRequest>"u")return 0;let S=new XMLHttpRequest;S.open(bt(m),b,!1),S.responseType="arraybuffer";for(var O=0,F=u;O<F*2;){var U=T[d/4+O>>>0],K=T[d/4+O+1>>>0];try{var g=encodeURI(bt(U));g==="Host"&&(g="X-Host-Override"),g==="User-Agent"&&(g="X-user-agent"),g==="Authorization"?S.setRequestHeader(g,bt(K)):S.setRequestHeader(g,encodeURI(bt(K)))}catch(z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",z)}O+=2}try{for(var Q=new Uint8Array(_),ft=0;ft<_;ft++)Q[ft]=n.HEAPU8[ft+y];S.send(Q)}catch(z){return 0}if(S.status>=400)return 0;for(var st=Uint8Array.from(Array.from(S.getResponseHeader("Etag")).map(z=>z.charCodeAt(0))),F=st.byteLength,Ot=lr(F+4),re=new Uint8Array(st),ft=0;ft<F;ft++)n.HEAPU8[ft+Ot+4]=re[ft];var v=new Uint8Array(4);return v[0]=F%256,F-=v[0],F/=256,v[1]=F%256,F-=v[1],F/=256,v[2]=F%256,F-=v[2],F/=256,v[3]=F%256,F-=v[3],F/=256,n.HEAPU8.set(v,Ot),Ot},10171139:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];console.log("HEAD",bt(S),bt(O));try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(v){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",v)}b+=2}try{_.send(null)}catch(v){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+8),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+8]=ft[st];var F=new Uint8Array(4);F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q+4);var Ot=Uint8Array.from(Array.from(_.getAllResponseHeaders()).map(v=>v.charCodeAt(0)));g=Ot.byteLength;for(var re=lr(g+8),st=0;st<g;st++)n.HEAPU8[st+re+8]=Ot[st];return F=new Uint8Array(4),F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,re+4),g=re,F=new Uint8Array(4),F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10173484:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(Ot){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ot)}b+=2}try{_.send(null)}catch(Ot){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+4),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+4]=ft[st];var F=new Uint8Array(4);return F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10174891:(a,u,d,m,y,_)=>{var b=bt(a);if(typeof XMLHttpRequest>"u")return 0;let S=new XMLHttpRequest;S.open(bt(m),b,!1),S.responseType="arraybuffer";for(var O=0,F=u;O<F*2;){var U=T[d/4+O>>>0],K=T[d/4+O+1>>>0];try{var g=encodeURI(bt(U));g==="Host"&&(g="X-Host-Override"),g==="User-Agent"&&(g="X-user-agent"),g==="Authorization"?S.setRequestHeader(g,bt(K)):S.setRequestHeader(g,encodeURI(bt(K)))}catch(z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",z)}O+=2}try{for(var Q=new Uint8Array(_),ft=0;ft<_;ft++)Q[ft]=n.HEAPU8[ft+y];S.send(Q)}catch(z){return 0}if(S.status>=400)return 0;for(var st=S.response,F=st.byteLength,Ot=lr(F+4),re=new Uint8Array(st),ft=0;ft<F;ft++)n.HEAPU8[ft+Ot+4]=re[ft];var v=new Uint8Array(4);return v[0]=F%256,F-=v[0],F/=256,v[1]=F%256,F-=v[1],F/=256,v[2]=F%256,F-=v[2],F/=256,v[3]=F%256,F-=v[3],F/=256,n.HEAPU8.set(v,Ot),Ot}};function Fc(a){this.name="ExitStatus",this.message="Program terminated with exit(".concat(a,")"),this.status=a}var ls=a=>{for(;a.length>0;)a.shift()(n)},Rd=n.noExitRuntime||!0;function Ac(){Ee("missing function: $SOCKFS")}Ac.stub=!0;function oa(){Ee("missing function: $FS")}oa.stub=!0;var Tn=a=>{var u=Ac.getSocket(a);if(!u)throw new oa.ErrnoError(8);return u},aa=a=>(a&255)+"."+(a>>8&255)+"."+(a>>16&255)+"."+(a>>24&255),xc=a=>{var u="",d=0,m=0,y=0,_=0,b=0,S=0,O=[a[0]&65535,a[0]>>16,a[1]&65535,a[1]>>16,a[2]&65535,a[2]>>16,a[3]&65535,a[3]>>16],U=!0,K="";for(S=0;S<5;S++)if(O[S]!==0){U=!1;break}if(U){if(K=aa(O[6]|O[7]<<16),O[5]===-1)return u="::ffff:",u+=K,u;if(O[5]===0)return u="::",K==="0.0.0.0"&&(K=""),K==="0.0.0.1"&&(K="1"),u+=K,u}for(d=0;d<8;d++)O[d]===0&&(d-y>1&&(b=0),y=d,b++),b>m&&(m=b,_=d-m+1);for(d=0;d<8;d++){if(m>1&&O[d]===0&&d>=_&&d<_+m){d===_&&(u+=":",_===0&&(u+=":"));continue}u+=Number(_ntohs(O[d]&65535)).toString(16),u+=d<7?":":""}return u},Tc=(a,u)=>{var d=H[a>>>1>>>0],m=_ntohs(Z[a+2>>>1>>>0]),y;switch(d){case 2:if(u!==16)return{errno:28};y=T[a+4>>>2>>>0],y=aa(y);break;case 10:if(u!==28)return{errno:28};y=[T[a+8>>>2>>>0],T[a+12>>>2>>>0],T[a+16>>>2>>>0],T[a+20>>>2>>>0]],y=xc(y);break;default:return{errno:5}}return{family:d,addr:y,port:m}},us=a=>{for(var u=a.split("."),d=0;d<4;d++){var m=Number(u[d]);if(isNaN(m))return null;u[d]=m}return(u[0]|u[1]<<8|u[2]<<16|u[3]<<24)>>>0},ds=a=>parseInt(a),ca=a=>{var u,d,m,y,_=/^((?=.*::)(?!.*::.+::)(::)?([\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,b=[];if(!_.test(a))return null;if(a==="::")return[0,0,0,0,0,0,0,0];for(a.startsWith("::")?a=a.replace("::","Z:"):a=a.replace("::",":Z:"),a.indexOf(".")>0?(a=a.replace(new RegExp("[.]","g"),":"),u=a.split(":"),u[u.length-4]=ds(u[u.length-4])+ds(u[u.length-3])*256,u[u.length-3]=ds(u[u.length-2])+ds(u[u.length-1])*256,u=u.slice(0,u.length-2)):u=a.split(":"),m=0,y=0,d=0;d<u.length;d++)if(typeof u[d]=="string")if(u[d]==="Z"){for(y=0;y<8-u.length+1;y++)b[d+y]=0;m=y-1}else b[d+m]=_htons(parseInt(u[d],16));else b[d+m]=u[d];return[b[1]<<16|b[0],b[3]<<16|b[2],b[5]<<16|b[4],b[7]<<16|b[6]]},fe={address_map:{id:1,addrs:{},names:{}},lookup_name(a){var u=us(a);if(u!==null||(u=ca(a),u!==null))return a;var d;if(fe.address_map.addrs[a])d=fe.address_map.addrs[a];else{var m=fe.address_map.id++;x(m<65535,"exceeded max address mappings of 65535"),d="172.29."+(m&255)+"."+(m&65280),fe.address_map.names[d]=a,fe.address_map.addrs[a]=d}return d},lookup_addr(a){return fe.address_map.names[a]?fe.address_map.names[a]:null}},Ec=(a,u,d)=>{if(d&&a===0)return null;var m=Tc(a,u);if(m.errno)throw new oa.ErrnoError(m.errno);return m.addr=fe.lookup_addr(m.addr)||m.addr,m},nn=(a,u)=>u+2097152>>>0<4194305-!!a?(a>>>0)+u*4294967296:NaN;function Ld(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=Ec(u,d);return b.sock_ops.bind(b,S.addr,S.port),0}function Nd(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=Ec(u,d);return b.sock_ops.connect(b,S.addr,S.port),0}var kd=(a,u,d)=>{};function Cd(a,u,d,m){u>>>=0}var Oc=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Uc=(a,u,d)=>{u>>>=0;for(var m=u+d,y=u;a[y]&&!(y>=m);)++y;if(y-u>16&&a.buffer&&Oc)return Oc.decode(a.subarray(u,y));for(var _="";u<y;){var b=a[u++];if(!(b&128)){_+=String.fromCharCode(b);continue}var S=a[u++]&63;if((b&224)==192){_+=String.fromCharCode((b&31)<<6|S);continue}var O=a[u++]&63;if((b&240)==224?b=(b&15)<<12|S<<6|O:b=(b&7)<<18|S<<12|O<<6|a[u++]&63,b<65536)_+=String.fromCharCode(b);else{var U=b-65536;_+=String.fromCharCode(55296|U>>10,56320|U&1023)}}return _},bt=(a,u)=>(a>>>=0,a?Uc(I,a,u):""),la={varargs:void 0,getStr(a){var u=bt(a);return u}};function Pd(a,u,d){return d>>>=0,la.varargs=d,0}function Vd(a,u){u>>>=0}function Hd(a,u,d){var m=nn(u,d)}var ua=a=>{for(var u=0,d=0;d<a.length;++d){var m=a.charCodeAt(d);m<=127?u++:m<=2047?u+=2:m>=55296&&m<=57343?(u+=4,++d):u+=3}return u};n.lengthBytesUTF8=ua;var Mc=(a,u,d,m)=>{if(d>>>=0,!(m>0))return 0;for(var y=d,_=d+m-1,b=0;b<a.length;++b){var S=a.charCodeAt(b);if(S>=55296&&S<=57343){var O=a.charCodeAt(++b);S=65536+((S&1023)<<10)|O&1023}if(S<=127){if(d>=_)break;u[d++>>>0]=S}else if(S<=2047){if(d+1>=_)break;u[d++>>>0]=192|S>>6,u[d++>>>0]=128|S&63}else if(S<=65535){if(d+2>=_)break;u[d++>>>0]=224|S>>12,u[d++>>>0]=128|S>>6&63,u[d++>>>0]=128|S&63}else{if(d+3>=_)break;u[d++>>>0]=240|S>>18,u[d++>>>0]=128|S>>12&63,u[d++>>>0]=128|S>>6&63,u[d++>>>0]=128|S&63}}return u[d>>>0]=0,d-y},kr=(a,u,d)=>Mc(a,I,u,d);n.stringToUTF8=kr;function zd(a,u){a>>>=0,u>>>=0}function jd(a,u,d){u>>>=0,d>>>=0}var Rc=(a,u)=>(I.fill(0,a,a+u),a),fs=(a,u,d,m,y)=>{switch(u){case 2:d=us(d),Rc(a,16),y&&(T[y>>>2>>>0]=16),H[a>>>1>>>0]=u,T[a+4>>>2>>>0]=d,H[a+2>>>1>>>0]=_htons(m);break;case 10:d=ca(d),Rc(a,28),y&&(T[y>>>2>>>0]=28),T[a>>>2>>>0]=u,T[a+8>>>2>>>0]=d[0],T[a+12>>>2>>>0]=d[1],T[a+16>>>2>>>0]=d[2],T[a+20>>>2>>>0]=d[3],H[a+2>>>1>>>0]=_htons(m);break;default:return 5}return 0};function Wd(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a);if(!b.daddr)return-53;var S=fs(u,b.family,fe.lookup_name(b.daddr),b.dport,d);return 0}function $d(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=fs(u,b.family,fe.lookup_name(b.saddr||"0.0.0.0"),b.sport,d);return 0}function Yd(a,u,d,m,y,_){m>>>=0,y>>>=0;var b=Tn(a);return u===1&&d===4?(T[m>>>2>>>0]=b.error,T[y>>>2>>>0]=4,b.error=null,0):-50}function Gd(a,u,d){return d>>>=0,la.varargs=d,0}function qd(a,u){a>>>=0,u>>>=0}function Kd(a,u,d){u>>>=0}function Jd(a,u,d,m){u>>>=0,d>>>=0}function Xd(a,u,d,m){u>>>=0,m>>>=0,la.varargs=m}function Zd(a,u,d){a>>>=0}function Qd(a,u,d,m){u>>>=0,d>>>=0,m>>>=0}function tf(a,u,d,m,y,_){u>>>=0,d>>>=0,y>>>=0,_>>>=0;var b=Tn(a),S=b.sock_ops.recvmsg(b,d);if(!S)return 0;if(y)var O=fs(y,b.family,fe.lookup_name(S.addr),S.port,_);return I.set(S.buffer,u>>>0),S.buffer.byteLength}function ef(a,u,d,m){u>>>=0,m>>>=0}function rf(a){a>>>=0}function nf(a,u,d,m,y,_){u>>>=0,d>>>=0,y>>>=0,_>>>=0}var sf=(a,u,d)=>{};function of(a,u){a>>>=0,u>>>=0}function af(a,u,d){a>>>=0,u>>>=0,d>>>=0}function cf(a,u,d){u>>>=0}var lf=1,uf=()=>lf;function Lc(){Ee("missing function: _emval_call_method")}Lc.stub=!0;function Nc(){Ee("missing function: _emval_decref")}Nc.stub=!0;function kc(){Ee("missing function: _emval_get_global")}kc.stub=!0;function Cc(){Ee("missing function: _emval_get_method_caller")}Cc.stub=!0;function Pc(){Ee("missing function: _emval_run_destructors")}Pc.stub=!0;var ci=a=>a%4===0&&(a%100!==0||a%400===0),df=[0,31,60,91,121,152,182,213,244,274,305,335],ff=[0,31,59,90,120,151,181,212,243,273,304,334],hf=a=>{var u=ci(a.getFullYear()),d=u?df:ff,m=d[a.getMonth()]+a.getDate()-1;return m};function pf(a,u,d){var m=nn(a,u);d>>>=0;var y=new Date(m*1e3);T[d>>>2>>>0]=y.getSeconds(),T[d+4>>>2>>>0]=y.getMinutes(),T[d+8>>>2>>>0]=y.getHours(),T[d+12>>>2>>>0]=y.getDate(),T[d+16>>>2>>>0]=y.getMonth(),T[d+20>>>2>>>0]=y.getFullYear()-1900,T[d+24>>>2>>>0]=y.getDay();var _=hf(y)|0;T[d+28>>>2>>>0]=_,T[d+36>>>2>>>0]=-(y.getTimezoneOffset()*60);var b=new Date(y.getFullYear(),0,1),S=new Date(y.getFullYear(),6,1).getTimezoneOffset(),O=b.getTimezoneOffset(),U=(S!=O&&y.getTimezoneOffset()==Math.min(O,S))|0;T[d+32>>>2>>>0]=U}function mf(a,u,d,m,y,_,b,S){a>>>=0;var O=nn(y,_);return b>>>=0,S>>>=0,-52}function yf(a,u,d,m,y,_,b){a>>>=0,u>>>=0;var S=nn(_,b)}var _f=function(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=new Date().getFullYear(),_=new Date(y,0,1),b=new Date(y,6,1),S=_.getTimezoneOffset(),O=b.getTimezoneOffset(),U=Math.max(S,O);mt[a>>>2>>>0]=U*60,T[u>>>2>>>0]=+(S!=O);var K=ft=>ft.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],g=K(_),Q=K(b);O<S?(kr(g,d,17),kr(Q,m,17)):(kr(g,m,17),kr(Q,d,17))},bf=()=>{Ee("")};function gf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(n,a,u)}function wf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(n,a,u)}function vf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(n,a,u)}function Sf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(n,a,u)}function If(a){return globalThis.DUCKDB_RUNTIME.closeFile(n,a)}function Df(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(n,a,u)}function Bf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(n,a,u)}function Ff(a,u,d,m){return a>>>=0,d>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(n,a,u,d,m)}function Af(a,u){return globalThis.DUCKDB_RUNTIME.openFile(n,a,u)}function xf(a,u,d,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.readFile(n,a,u,d,m)}function Tf(a,u){return globalThis.DUCKDB_RUNTIME.truncateFile(n,a,u)}function Ef(a,u,d,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(n,a,u,d,m)}function Of(a){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(a)}function Uf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.glob(n,a,u)}function Mf(a){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(n,a)}function Rf(a,u,d,m,y,_){return a>>>=0,d>>>=0,y>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(n,a,u,d,m,y,_)}var da=[],Lf=(a,u)=>{da.length=0;for(var d;d=I[a++>>>0];){var m=d!=105;m&=d!=112,u+=m&&u%8?4:0,da.push(d==112?mt[u>>>2>>>0]:d==105?T[u>>>2>>>0]:_t[u>>>3>>>0]),u+=m?8:4}return da},Nf=(a,u,d)=>{var m=Lf(u,d);return Md[a](...m)};function kf(a,u,d){return a>>>=0,u>>>=0,d>>>=0,Nf(a,u,d)}var Cf=()=>Date.now(),Vc=()=>4294901760;function Pf(){return Vc()}var Hc;Hc=()=>performance.now();var Vf=a=>{var u=V.buffer,d=(a-u.byteLength+65535)/65536;try{return V.grow(d),xe(),1}catch(m){}};function Hf(a){a>>>=0;var u=I.length,d=Vc();if(a>d)return!1;for(var m=(O,U)=>O+(U-O%U)%U,y=1;y<=4;y*=2){var _=u*(1+.2/y);_=Math.min(_,a+100663296);var b=Math.min(d,m(Math.max(a,_),65536)),S=Vf(b);if(S)return!0}return!1}var fa={},zf=()=>f||"./this.program",li=()=>{if(!li.strings){var a=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",u={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:a,_:zf()};for(var d in fa)fa[d]===void 0?delete u[d]:u[d]=fa[d];var m=[];for(var d in u)m.push("".concat(d,"=").concat(u[d]));li.strings=m}return li.strings},jf=(a,u)=>{for(var d=0;d<a.length;++d)j[u++>>>0]=a.charCodeAt(d);j[u>>>0]=0},Wf=function(a,u){a>>>=0,u>>>=0;var d=0;return li().forEach((m,y)=>{var _=u+d;mt[a+y*4>>>2>>>0]=_,jf(m,_),d+=m.length+1}),0},$f=function(a,u){a>>>=0,u>>>=0;var d=li();mt[a>>>2>>>0]=d.length;var m=0;return d.forEach(y=>m+=y.length+1),mt[u>>>2>>>0]=m,0},Yf=0,Gf=()=>Rd||Yf>0,qf=a=>{var u;N=a,Gf()||((u=n.onExit)==null||u.call(n,a),D=!0),p(a,new Fc(a))},zc=(a,u)=>{N=a,qf(a)},Kf=zc,Jf=a=>52;function Xf(a,u){u>>>=0;var d=0,m=0,y=0;{var _=2;a==0?d=2:(a==1||a==2)&&(d=64),y=1}return j[u>>>0]=_,H[u+2>>>1>>>0]=y,xn=[d>>>0,(we=d,+Math.abs(we)>=1?we>0?+Math.floor(we/4294967296)>>>0:~~+Math.ceil((we-+(~~we>>>0))/4294967296)>>>0:0)],T[u+8>>>2>>>0]=xn[0],T[u+12>>>2>>>0]=xn[1],xn=[m>>>0,(we=m,+Math.abs(we)>=1?we>0?+Math.floor(we/4294967296)>>>0:~~+Math.ceil((we-+(~~we>>>0))/4294967296)>>>0:0)],T[u+16>>>2>>>0]=xn[0],T[u+20>>>2>>>0]=xn[1],0}function Zf(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=nn(m,y);return _>>>=0,52}function Qf(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=nn(m,y);return _>>>=0,52}function th(a,u,d,m){return u>>>=0,d>>>=0,m>>>=0,52}function eh(a,u,d,m,y){var _=nn(u,d);return y>>>=0,70}var rh=a=>52,nh=[null,[],[]],ih=(a,u)=>{var d=nh[a];u===0||u===10?((a===1?Kt:w)(Uc(d,0)),d.length=0):d.push(u)};function sh(a,u,d,m){u>>>=0,d>>>=0,m>>>=0;for(var y=0,_=0;_<d;_++){var b=mt[u>>>2>>>0],S=mt[u+4>>>2>>>0];u+=8;for(var O=0;O<S;O++)ih(a,I[b+O>>>0]);y+=S}return mt[m>>>2>>>0]=y,0}function oh(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=0,_=0,b=0,S=0,O=0,U=0,K;function g(Q,ft,st,F,Ot,re){var v,z,kt,Jt;return z=Q===10?28:16,Ot=Q===10?xc(Ot):aa(Ot),v=lr(z),Jt=fs(v,Q,Ot,re),x(!Jt),kt=lr(32),T[kt+4>>>2>>>0]=Q,T[kt+8>>>2>>>0]=ft,T[kt+12>>>2>>>0]=st,mt[kt+24>>>2>>>0]=F,mt[kt+20>>>2>>>0]=v,Q===10?T[kt+16>>>2>>>0]=28:T[kt+16>>>2>>>0]=16,T[kt+28>>>2>>>0]=0,kt}if(d&&(b=T[d>>>2>>>0],S=T[d+4>>>2>>>0],O=T[d+8>>>2>>>0],U=T[d+12>>>2>>>0]),O&&!U&&(U=O===2?17:6),!O&&U&&(O=U===17?2:1),U===0&&(U=6),O===0&&(O=1),!a&&!u)return-2;if(b&-1088||d!==0&&T[d>>>2>>>0]&2&&!a)return-1;if(b&32)return-2;if(O!==0&&O!==1&&O!==2)return-7;if(S!==0&&S!==2&&S!==10)return-6;if(u&&(u=bt(u),_=parseInt(u,10),isNaN(_)))return b&1024?-2:-8;if(!a)return S===0&&(S=2),b&1||(S===2?y=_htonl(2130706433):y=[0,0,0,1]),K=g(S,O,U,null,y,_),mt[m>>>2>>>0]=K,0;if(a=bt(a),y=us(a),y!==null)if(S===0||S===2)S=2;else if(S===10&&b&8)y=[0,0,_htonl(65535),y],S=10;else return-2;else if(y=ca(a),y!==null)if(S===0||S===10)S=10;else return-2;return y!=null?(K=g(S,O,U,a,y,_),mt[m>>>2>>>0]=K,0):b&4?-2:(a=fe.lookup_name(a),y=us(a),S===0?S=2:S===10&&(y=[0,0,_htonl(65535),y]),K=g(S,O,U,null,y,_),mt[m>>>2>>>0]=K,0)}var ah=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return m=>crypto.getRandomValues(m);if(E)try{var a=vp("crypto"),u=a.randomFillSync;if(u)return m=>a.randomFillSync(m);var d=a.randomBytes;return m=>(m.set(d(m.byteLength)),m)}catch(m){}Ee("initRandomDevice")},jc=a=>(jc=ah())(a);function ch(a,u){return a>>>=0,u>>>=0,jc(I.subarray(a>>>0,a+u>>>0)),0}function lh(a,u,d,m,y,_,b){a>>>=0,d>>>=0,y>>>=0;var S=Tc(a,u);if(S.errno)return-6;var O=S.port,U=S.addr,K=!1;if(d&&m){var g;if(b&1||!(g=fe.lookup_addr(U))){if(b&8)return-2}else U=g;var Q=kr(U,d,m);Q+1>=m&&(K=!0)}if(y&&_){O=""+O;var Q=kr(O,y,_);Q+1>=_&&(K=!0)}return K?-12:0}var uh=(a,u)=>{for(var d=0,m=0;m<=u;d+=a[m++]);return d},Wc=[31,29,31,30,31,30,31,31,30,31,30,31],$c=[31,28,31,30,31,30,31,31,30,31,30,31],dh=(a,u)=>{for(var d=new Date(a.getTime());u>0;){var m=ci(d.getFullYear()),y=d.getMonth(),_=(m?Wc:$c)[y];if(u>_-d.getDate())u-=_-d.getDate()+1,d.setDate(1),y<11?d.setMonth(y+1):(d.setMonth(0),d.setFullYear(d.getFullYear()+1));else return d.setDate(d.getDate()+u),d}return d};function fh(a,u,d){var m=d>0?d:ua(a)+1,y=new Array(m),_=Mc(a,y,0,y.length);return u&&(y.length=_),y}var Yc=(a,u)=>{j.set(a,u>>>0)};function hh(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=mt[m+40>>>2>>>0],_={tm_sec:T[m>>>2>>>0],tm_min:T[m+4>>>2>>>0],tm_hour:T[m+8>>>2>>>0],tm_mday:T[m+12>>>2>>>0],tm_mon:T[m+16>>>2>>>0],tm_year:T[m+20>>>2>>>0],tm_wday:T[m+24>>>2>>>0],tm_yday:T[m+28>>>2>>>0],tm_isdst:T[m+32>>>2>>>0],tm_gmtoff:T[m+36>>>2>>>0],tm_zone:y?bt(y):""},b=bt(d),S={"%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 O in S)b=b.replace(new RegExp(O,"g"),S[O]);var U=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],K=["January","February","March","April","May","June","July","August","September","October","November","December"];function g(v,z,kt){for(var Jt=typeof v=="number"?v.toString():v||"";Jt.length<z;)Jt=kt[0]+Jt;return Jt}function Q(v,z){return g(v,z,"0")}function ft(v,z){function kt(ms){return ms<0?-1:ms>0?1:0}var Jt;return(Jt=kt(v.getFullYear()-z.getFullYear()))===0&&(Jt=kt(v.getMonth()-z.getMonth()))===0&&(Jt=kt(v.getDate()-z.getDate())),Jt}function st(v){switch(v.getDay()){case 0:return new Date(v.getFullYear()-1,11,29);case 1:return v;case 2:return new Date(v.getFullYear(),0,3);case 3:return new Date(v.getFullYear(),0,2);case 4:return new Date(v.getFullYear(),0,1);case 5:return new Date(v.getFullYear()-1,11,31);case 6:return new Date(v.getFullYear()-1,11,30)}}function F(v){var z=dh(new Date(v.tm_year+1900,0,1),v.tm_yday),kt=new Date(z.getFullYear(),0,4),Jt=new Date(z.getFullYear()+1,0,4),ms=st(kt),mp=st(Jt);return ft(ms,z)<=0?ft(mp,z)<=0?z.getFullYear()+1:z.getFullYear():z.getFullYear()-1}var Ot={"%a":v=>U[v.tm_wday].substring(0,3),"%A":v=>U[v.tm_wday],"%b":v=>K[v.tm_mon].substring(0,3),"%B":v=>K[v.tm_mon],"%C":v=>{var z=v.tm_year+1900;return Q(z/100|0,2)},"%d":v=>Q(v.tm_mday,2),"%e":v=>g(v.tm_mday,2," "),"%g":v=>F(v).toString().substring(2),"%G":F,"%H":v=>Q(v.tm_hour,2),"%I":v=>{var z=v.tm_hour;return z==0?z=12:z>12&&(z-=12),Q(z,2)},"%j":v=>Q(v.tm_mday+uh(ci(v.tm_year+1900)?Wc:$c,v.tm_mon-1),3),"%m":v=>Q(v.tm_mon+1,2),"%M":v=>Q(v.tm_min,2),"%n":()=>"\n","%p":v=>v.tm_hour>=0&&v.tm_hour<12?"AM":"PM","%S":v=>Q(v.tm_sec,2),"%t":()=>" ","%u":v=>v.tm_wday||7,"%U":v=>{var z=v.tm_yday+7-v.tm_wday;return Q(Math.floor(z/7),2)},"%V":v=>{var z=Math.floor((v.tm_yday+7-(v.tm_wday+6)%7)/7);if((v.tm_wday+371-v.tm_yday-2)%7<=2&&z++,z){if(z==53){var Jt=(v.tm_wday+371-v.tm_yday)%7;Jt!=4&&(Jt!=3||!ci(v.tm_year))&&(z=1)}}else{z=52;var kt=(v.tm_wday+7-v.tm_yday-1)%7;(kt==4||kt==5&&ci(v.tm_year%400-1))&&z++}return Q(z,2)},"%w":v=>v.tm_wday,"%W":v=>{var z=v.tm_yday+7-(v.tm_wday+6)%7;return Q(Math.floor(z/7),2)},"%y":v=>(v.tm_year+1900).toString().substring(2),"%Y":v=>v.tm_year+1900,"%z":v=>{var z=v.tm_gmtoff,kt=z>=0;return z=Math.abs(z)/60,z=z/60*100+z%60,(kt?"+":"-")+("0000"+z).slice(-4)},"%Z":v=>v.tm_zone,"%%":()=>"%"};b=b.replace(/%%/g,"\0\0");for(var O in Ot)b.includes(O)&&(b=b.replace(new RegExp(O,"g"),Ot[O](_)));b=b.replace(/\0\0/g,"%");var re=fh(b,!1);return re.length>u?0:(Yc(re,a),re.length-1)}function ph(a,u,d,m,y){return a>>>=0,u>>>=0,d>>>=0,m>>>=0,y>>>=0,hh(a,u,d,m)}var mh=a=>{if(a instanceof Fc||a=="unwind")return N;p(1,a)},yh=a=>{var u=n["_"+a];return u},hs=a=>el(a);n.stackAlloc=hs;var _h=a=>{var u=ua(a)+1,d=hs(u);return kr(a,d,u),d},Gc=()=>rl(),qc=a=>tl(a),bh=(a,u,d,m,y)=>{var _={string:st=>{var F=0;return st!=null&&st!==0&&(F=_h(st)),F},array:st=>{var F=hs(st.length);return Yc(st,F),F}};function b(st){return u==="string"?bt(st):u==="boolean"?!!st:st}var S=yh(a),O=[],U=0;if(m)for(var K=0;K<m.length;K++){var g=_[d[K]];g?(U===0&&(U=Gc()),O[K]=g(m[K])):O[K]=m[K]}var Q=S(...O);function ft(st){return U!==0&&qc(U),b(st)}return Q=ft(Q),Q},En=(a,u)=>{a<128?u.push(a):u.push(a%128|128,a>>7)},ha=(a,u)=>{var d=a.slice(0,1),m=a.slice(1),y={i:127,p:127,j:126,f:125,d:124,e:111};u.push(96),En(m.length,u);for(var _=0;_<m.length;++_)u.push(y[m[_]]);d=="v"?u.push(0):u.push(1,y[d])},Kc=a=>Zc(a),Jc,gh=a=>{var u=[],d=[0,97,115,109,1,0,0,0];u.push(d);var m=[a[0].replace("j","i"),"i",a.slice(1).replace(/j/g,"ii")].join(""),y=[3];ha(m,y),ha(a,y),ha("vi",y);var _=[1];En(y.length,_),_.push(...y),u.push(_);var b=[2,15,2,1,101,1,116,1,112,0,0,1,101,1,114,0,2];u.push(b);var S=[3,2,1,0];u.push(S);var O=[7,5,1,1,102,0,1];u.push(O);var U=[];a[0]==="j"?U=[1,1,126]:U.push(0);function K(z){U.push(32),En(z,U)}for(var g=1,Q=1;Q<a.length;Q++)a[Q]=="j"?(K(g+1),U.push(173,66,32,134),K(g),U.push(172,132),g+=2):(K(g),g++);U.push(32,0,17,1,0),a[0]==="j"&&(U.push(34),En(g,U),U.push(66,32,136,167,16,0),K(g),U.push(167)),U.push(11);var ft=[1];En(U.length,ft),ft.push(...U);var st=[10];En(ft.length,st),st.push(...ft),u.push(st);var F=new Uint8Array([].concat.apply([],u)),Ot=new WebAssembly.Module(F),re=new WebAssembly.Instance(Ot,{e:{t:Jc,r:Kc}}),v=re.exports.f;return v},wh=a=>Qc(),vh={la:Ld,qa:Nd,J:kd,fa:Cd,d:Pd,ea:Vd,y:Hd,ga:zd,$:jd,ka:Wd,ja:$d,oa:Yd,k:Gd,ba:qd,aa:Kd,ca:Jd,v:Xd,pa:Zd,Y:Qd,ma:tf,Z:ef,q:rf,na:nf,u:sf,da:of,ha:af,r:cf,ra:uf,G:Lc,l:Nc,I:kc,H:Cc,F:Pc,B:pf,C:mf,D:yf,ia:_f,a:bf,Q:gf,R:wf,O:vf,P:Sf,o:If,U:Df,M:Bf,N:Ff,T:Af,i:xf,S:Tf,p:Ef,V:Of,L:Uf,m:Mf,W:Rf,g:kf,h:Cf,sa:Pf,e:Hc,ta:Hf,w:Wf,x:$f,c:Kf,f:Jf,K:Xf,A:Zf,z:Qf,n:th,E:eh,_:rh,j:sh,t:oh,X:ch,s:lh,b:ph},P=Ud(),Xc=n._main=(a,u)=>(Xc=n._main=P.wa)(a,u),Sh=n._duckdb_web_fs_glob_add_path=a=>(Sh=n._duckdb_web_fs_glob_add_path=P.ya)(a),Ih=n._duckdb_web_clear_response=()=>(Ih=n._duckdb_web_clear_response=P.za)(),Dh=n._duckdb_web_fail_with=a=>(Dh=n._duckdb_web_fail_with=P.Aa)(a),Bh=n._duckdb_web_reset=a=>(Bh=n._duckdb_web_reset=P.Ba)(a),Fh=n._duckdb_web_connect=()=>(Fh=n._duckdb_web_connect=P.Ca)(),Ah=n._duckdb_web_disconnect=a=>(Ah=n._duckdb_web_disconnect=P.Da)(a),xh=n._duckdb_web_flush_files=()=>(xh=n._duckdb_web_flush_files=P.Ea)(),Th=n._duckdb_web_flush_file=a=>(Th=n._duckdb_web_flush_file=P.Fa)(a),Eh=n._duckdb_web_open=(a,u)=>(Eh=n._duckdb_web_open=P.Ga)(a,u),Oh=n._duckdb_web_get_global_file_info=(a,u)=>(Oh=n._duckdb_web_get_global_file_info=P.Ha)(a,u),Uh=n._duckdb_web_collect_file_stats=(a,u,d)=>(Uh=n._duckdb_web_collect_file_stats=P.Ia)(a,u,d),Mh=n._duckdb_web_export_file_stats=(a,u)=>(Mh=n._duckdb_web_export_file_stats=P.Ja)(a,u),Rh=n._duckdb_web_fs_drop_file=(a,u)=>(Rh=n._duckdb_web_fs_drop_file=P.Ka)(a,u),Lh=n._duckdb_web_fs_drop_files=(a,u,d)=>(Lh=n._duckdb_web_fs_drop_files=P.La)(a,u,d),Nh=n._duckdb_web_fs_glob_file_infos=(a,u)=>(Nh=n._duckdb_web_fs_glob_file_infos=P.Ma)(a,u),kh=n._duckdb_web_fs_get_file_info_by_id=(a,u,d)=>(kh=n._duckdb_web_fs_get_file_info_by_id=P.Na)(a,u,d),Ch=n._duckdb_web_fs_get_file_info_by_name=(a,u,d)=>(Ch=n._duckdb_web_fs_get_file_info_by_name=P.Oa)(a,u,d),Ph=n._duckdb_web_fs_register_file_url=(a,u,d,m,y)=>(Ph=n._duckdb_web_fs_register_file_url=P.Pa)(a,u,d,m,y),Vh=n._duckdb_web_fs_register_file_buffer=(a,u,d,m)=>(Vh=n._duckdb_web_fs_register_file_buffer=P.Qa)(a,u,d,m),Hh=n._duckdb_web_copy_file_to_buffer=(a,u)=>(Hh=n._duckdb_web_copy_file_to_buffer=P.Ra)(a,u),zh=n._duckdb_web_copy_file_to_path=(a,u,d)=>(zh=n._duckdb_web_copy_file_to_path=P.Sa)(a,u,d),jh=n._duckdb_web_get_version=a=>(jh=n._duckdb_web_get_version=P.Ta)(a),Wh=n._duckdb_web_get_feature_flags=()=>(Wh=n._duckdb_web_get_feature_flags=P.Ua)(),$h=n._duckdb_web_tokenize=(a,u)=>($h=n._duckdb_web_tokenize=P.Va)(a,u),Yh=n._duckdb_web_tokenize_buffer=(a,u,d)=>(Yh=n._duckdb_web_tokenize_buffer=P.Wa)(a,u,d),Gh=n._duckdb_web_udf_scalar_create=(a,u,d)=>(Gh=n._duckdb_web_udf_scalar_create=P.Xa)(a,u,d),qh=n._duckdb_web_prepared_create=(a,u,d)=>(qh=n._duckdb_web_prepared_create=P.Ya)(a,u,d),Kh=n._duckdb_web_prepared_create_buffer=(a,u,d,m)=>(Kh=n._duckdb_web_prepared_create_buffer=P.Za)(a,u,d,m),Jh=n._duckdb_web_prepared_close=(a,u,d)=>(Jh=n._duckdb_web_prepared_close=P._a)(a,u,d),Xh=n._duckdb_web_prepared_run=(a,u,d,m)=>(Xh=n._duckdb_web_prepared_run=P.$a)(a,u,d,m),Zh=n._duckdb_web_prepared_send=(a,u,d,m)=>(Zh=n._duckdb_web_prepared_send=P.ab)(a,u,d,m),Qh=n._duckdb_web_query_run=(a,u,d)=>(Qh=n._duckdb_web_query_run=P.bb)(a,u,d),tp=n._duckdb_web_query_run_buffer=(a,u,d,m)=>(tp=n._duckdb_web_query_run_buffer=P.cb)(a,u,d,m),ep=n._duckdb_web_pending_query_start=(a,u,d,m)=>(ep=n._duckdb_web_pending_query_start=P.db)(a,u,d,m),rp=n._duckdb_web_pending_query_start_buffer=(a,u,d,m,y)=>(rp=n._duckdb_web_pending_query_start_buffer=P.eb)(a,u,d,m,y),np=n._duckdb_web_pending_query_poll=(a,u,d)=>(np=n._duckdb_web_pending_query_poll=P.fb)(a,u,d),ip=n._duckdb_web_pending_query_cancel=(a,u)=>(ip=n._duckdb_web_pending_query_cancel=P.gb)(a,u),sp=n._duckdb_web_query_fetch_results=(a,u)=>(sp=n._duckdb_web_query_fetch_results=P.hb)(a,u),op=n._duckdb_web_get_tablenames=(a,u,d)=>(op=n._duckdb_web_get_tablenames=P.ib)(a,u,d),ap=n._duckdb_web_get_tablenames_buffer=(a,u,d,m)=>(ap=n._duckdb_web_get_tablenames_buffer=P.jb)(a,u,d,m),cp=n._duckdb_web_insert_arrow_from_ipc_stream=(a,u,d,m,y)=>(cp=n._duckdb_web_insert_arrow_from_ipc_stream=P.kb)(a,u,d,m,y),lp=n._duckdb_web_insert_csv_from_path=(a,u,d,m)=>(lp=n._duckdb_web_insert_csv_from_path=P.lb)(a,u,d,m),up=n._duckdb_web_insert_json_from_path=(a,u,d,m)=>(up=n._duckdb_web_insert_json_from_path=P.mb)(a,u,d,m),lr=n._malloc=a=>(lr=n._malloc=P.qb)(a),dp=n._free=a=>(dp=n._free=P.rb)(a),fp=n._calloc=(a,u)=>(fp=n._calloc=P.sb)(a,u),Zc=a=>(Zc=P.ub)(a),Qc=()=>(Qc=P.vb)(),tl=a=>(tl=P.wb)(a),el=a=>(el=P.xb)(a),rl=()=>(rl=P.yb)();function hp(a){a=Object.assign({},a);var u=m=>y=>m(y)>>>0,d=m=>()=>m()>>>0;return a.qb=u(a.qb),a.xb=u(a.xb),a.yb=d(a.yb),a}n.stackSave=Gc,n.stackRestore=qc,n.stackAlloc=hs,n.getTempRet0=wh,n.setTempRet0=Kc,n.ccall=bh,n.createDyncallWrapper=gh;var ps;ai=function a(){ps||nl(),ps||(ai=a)};function pp(){var a=Xc,u=0,d=0;try{var m=a(u,d);return zc(m,!0),m}catch(y){return mh(y)}}function nl(){if(rn>0||(wd(),rn>0))return;function a(){ps||(ps=!0,n.calledRun=!0,!D&&(vd(),Sd(),i(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),il&&pp(),Id()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),a()},1)):a()}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();var il=!0;return n.noInitialRun&&(il=!1),nl(),o}})();typeof ld=="object"&&typeof wc=="object"?wc.exports=cd:typeof define=="function"&&define.amd&&define([],()=>cd)});var fd=On(()=>{});var hd=On(()=>{});var pd=On((eF,ia)=>{(function(){"use strict";var r="input is invalid type",t=typeof window=="object",e=t?window:{};e.JS_SHA256_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",i=!e.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";i?e=global:n&&(e=self);var s=!e.JS_SHA256_NO_COMMON_JS&&typeof ia=="object"&&ia.exports,o=typeof define=="function"&&define.amd,c=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),f=[-2147483648,8388608,32768,128],p=[24,16,8,0],B=[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],A=["hex","array","digest","arrayBuffer"],E=[];(e.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(w){return Object.prototype.toString.call(w)==="[object Array]"}),c&&(e.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(w){return typeof w=="object"&&w.buffer&&w.buffer.constructor===ArrayBuffer});var X=function(w,M){return function(V){return new wt(M,!0).update(V)[w]()}},Ft=function(w){var M=X("hex",w);i&&(M=Pt(M,w)),M.create=function(){return new wt(w)},M.update=function(N){return M.create().update(N)};for(var V=0;V<A.length;++V){var D=A[V];M[D]=X(D,w)}return M},Pt=function(w,M){var V=fd(),D=hd().Buffer,N=M?"sha224":"sha256",x;D.from&&!e.JS_SHA256_NO_BUFFER_FROM?x=D.from:x=function(I){return new D(I)};var j=function(I){if(typeof I=="string")return V.createHash(N).update(I,"utf8").digest("hex");if(I==null)throw new Error(r);return I.constructor===ArrayBuffer&&(I=new Uint8Array(I)),Array.isArray(I)||ArrayBuffer.isView(I)||I.constructor===D?V.createHash(N).update(x(I)).digest("hex"):w(I)};return j},Lt=function(w,M){return function(V,D){return new qt(V,M,!0).update(D)[w]()}},Bt=function(w){var M=Lt("hex",w);M.create=function(N){return new qt(N,w)},M.update=function(N,x){return M.create(N).update(x)};for(var V=0;V<A.length;++V){var D=A[V];M[D]=Lt(D,w)}return M};function wt(w,M){M?(E[0]=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,this.blocks=E):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],w?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=w}wt.prototype.update=function(w){if(!this.finalized){var M,V=typeof w;if(V!=="string"){if(V==="object"){if(w===null)throw new Error(r);if(c&&w.constructor===ArrayBuffer)w=new Uint8Array(w);else if(!Array.isArray(w)&&(!c||!ArrayBuffer.isView(w)))throw new Error(r)}else throw new Error(r);M=!0}for(var D,N=0,x,j=w.length,I=this.blocks;N<j;){if(this.hashed&&(this.hashed=!1,I[0]=this.block,this.block=I[16]=I[1]=I[2]=I[3]=I[4]=I[5]=I[6]=I[7]=I[8]=I[9]=I[10]=I[11]=I[12]=I[13]=I[14]=I[15]=0),M)for(x=this.start;N<j&&x<64;++N)I[x>>>2]|=w[N]<<p[x++&3];else for(x=this.start;N<j&&x<64;++N)D=w.charCodeAt(N),D<128?I[x>>>2]|=D<<p[x++&3]:D<2048?(I[x>>>2]|=(192|D>>>6)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]):D<55296||D>=57344?(I[x>>>2]|=(224|D>>>12)<<p[x++&3],I[x>>>2]|=(128|D>>>6&63)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]):(D=65536+((D&1023)<<10|w.charCodeAt(++N)&1023),I[x>>>2]|=(240|D>>>18)<<p[x++&3],I[x>>>2]|=(128|D>>>12&63)<<p[x++&3],I[x>>>2]|=(128|D>>>6&63)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]);this.lastByteIndex=x,this.bytes+=x-this.start,x>=64?(this.block=I[16],this.start=x-64,this.hash(),this.hashed=!0):this.start=x}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},wt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var w=this.blocks,M=this.lastByteIndex;w[16]=this.block,w[M>>>2]|=f[M&3],this.block=w[16],M>=56&&(this.hashed||this.hash(),w[0]=this.block,w[16]=w[1]=w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=w[12]=w[13]=w[14]=w[15]=0),w[14]=this.hBytes<<3|this.bytes>>>29,w[15]=this.bytes<<3,this.hash()}},wt.prototype.hash=function(){var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=this.blocks,Z,T,mt,Xe,_t,xe,Te,Nr,oi,Fn,en;for(Z=16;Z<64;++Z)_t=H[Z-15],T=(_t>>>7|_t<<25)^(_t>>>18|_t<<14)^_t>>>3,_t=H[Z-2],mt=(_t>>>17|_t<<15)^(_t>>>19|_t<<13)^_t>>>10,H[Z]=H[Z-16]+T+H[Z-7]+mt<<0;for(en=M&V,Z=0;Z<64;Z+=4)this.first?(this.is224?(Nr=300032,_t=H[0]-1413257819,I=_t-150054599<<0,D=_t+24177077<<0):(Nr=704751109,_t=H[0]-210244248,I=_t-1521486534<<0,D=_t+143694565<<0),this.first=!1):(T=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),mt=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),Nr=w&M,Xe=Nr^w&V^en,Te=N&x^~N&j,_t=I+mt+Te+B[Z]+H[Z],xe=T+Xe,I=D+_t<<0,D=_t+xe<<0),T=(D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10),mt=(I>>>6|I<<26)^(I>>>11|I<<21)^(I>>>25|I<<7),oi=D&w,Xe=oi^D&M^Nr,Te=I&N^~I&x,_t=j+mt+Te+B[Z+1]+H[Z+1],xe=T+Xe,j=V+_t<<0,V=_t+xe<<0,T=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),mt=(j>>>6|j<<26)^(j>>>11|j<<21)^(j>>>25|j<<7),Fn=V&D,Xe=Fn^V&w^oi,Te=j&I^~j&N,_t=x+mt+Te+B[Z+2]+H[Z+2],xe=T+Xe,x=M+_t<<0,M=_t+xe<<0,T=(M>>>2|M<<30)^(M>>>13|M<<19)^(M>>>22|M<<10),mt=(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7),en=M&V,Xe=en^M&D^Fn,Te=x&j^~x&I,_t=N+mt+Te+B[Z+3]+H[Z+3],xe=T+Xe,N=w+_t<<0,w=_t+xe<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+w<<0,this.h1=this.h1+M<<0,this.h2=this.h2+V<<0,this.h3=this.h3+D<<0,this.h4=this.h4+N<<0,this.h5=this.h5+x<<0,this.h6=this.h6+j<<0,this.h7=this.h7+I<<0},wt.prototype.hex=function(){this.finalize();var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=l[w>>>28&15]+l[w>>>24&15]+l[w>>>20&15]+l[w>>>16&15]+l[w>>>12&15]+l[w>>>8&15]+l[w>>>4&15]+l[w&15]+l[M>>>28&15]+l[M>>>24&15]+l[M>>>20&15]+l[M>>>16&15]+l[M>>>12&15]+l[M>>>8&15]+l[M>>>4&15]+l[M&15]+l[V>>>28&15]+l[V>>>24&15]+l[V>>>20&15]+l[V>>>16&15]+l[V>>>12&15]+l[V>>>8&15]+l[V>>>4&15]+l[V&15]+l[D>>>28&15]+l[D>>>24&15]+l[D>>>20&15]+l[D>>>16&15]+l[D>>>12&15]+l[D>>>8&15]+l[D>>>4&15]+l[D&15]+l[N>>>28&15]+l[N>>>24&15]+l[N>>>20&15]+l[N>>>16&15]+l[N>>>12&15]+l[N>>>8&15]+l[N>>>4&15]+l[N&15]+l[x>>>28&15]+l[x>>>24&15]+l[x>>>20&15]+l[x>>>16&15]+l[x>>>12&15]+l[x>>>8&15]+l[x>>>4&15]+l[x&15]+l[j>>>28&15]+l[j>>>24&15]+l[j>>>20&15]+l[j>>>16&15]+l[j>>>12&15]+l[j>>>8&15]+l[j>>>4&15]+l[j&15];return this.is224||(H+=l[I>>>28&15]+l[I>>>24&15]+l[I>>>20&15]+l[I>>>16&15]+l[I>>>12&15]+l[I>>>8&15]+l[I>>>4&15]+l[I&15]),H},wt.prototype.toString=wt.prototype.hex,wt.prototype.digest=function(){this.finalize();var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=[w>>>24&255,w>>>16&255,w>>>8&255,w&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255,V>>>24&255,V>>>16&255,V>>>8&255,V&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255,j>>>24&255,j>>>16&255,j>>>8&255,j&255];return this.is224||H.push(I>>>24&255,I>>>16&255,I>>>8&255,I&255),H},wt.prototype.array=wt.prototype.digest,wt.prototype.arrayBuffer=function(){this.finalize();var w=new ArrayBuffer(this.is224?28:32),M=new DataView(w);return M.setUint32(0,this.h0),M.setUint32(4,this.h1),M.setUint32(8,this.h2),M.setUint32(12,this.h3),M.setUint32(16,this.h4),M.setUint32(20,this.h5),M.setUint32(24,this.h6),this.is224||M.setUint32(28,this.h7),w};function qt(w,M,V){var D,N=typeof w;if(N==="string"){var x=[],j=w.length,I=0,H;for(D=0;D<j;++D)H=w.charCodeAt(D),H<128?x[I++]=H:H<2048?(x[I++]=192|H>>>6,x[I++]=128|H&63):H<55296||H>=57344?(x[I++]=224|H>>>12,x[I++]=128|H>>>6&63,x[I++]=128|H&63):(H=65536+((H&1023)<<10|w.charCodeAt(++D)&1023),x[I++]=240|H>>>18,x[I++]=128|H>>>12&63,x[I++]=128|H>>>6&63,x[I++]=128|H&63);w=x}else if(N==="object"){if(w===null)throw new Error(r);if(c&&w.constructor===ArrayBuffer)w=new Uint8Array(w);else if(!Array.isArray(w)&&(!c||!ArrayBuffer.isView(w)))throw new Error(r)}else throw new Error(r);w.length>64&&(w=new wt(M,!0).update(w).array());var Z=[],T=[];for(D=0;D<64;++D){var mt=w[D]||0;Z[D]=92^mt,T[D]=54^mt}wt.call(this,M,V),this.update(T),this.oKeyPad=Z,this.inner=!0,this.sharedMemory=V}qt.prototype=new wt,qt.prototype.finalize=function(){if(wt.prototype.finalize.call(this),this.inner){this.inner=!1;var w=this.array();wt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(w),wt.prototype.finalize.call(this)}};var Kt=Ft();Kt.sha256=Kt,Kt.sha224=Ft(!0),Kt.sha256.hmac=Bt(),Kt.sha224.hmac=Bt(!0),s?ia.exports=Kt:(e.sha256=Kt.sha256,e.sha224=Kt.sha224,o&&define(function(){return Kt}))})()});var Zy={};Cr(Zy,{registerWorker:()=>gd});function cl(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e}function R(r,t,e,n){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(p){try{f(n.next(p))}catch(B){o(B)}}function l(p){try{f(n.throw(p))}catch(B){o(B)}}function f(p){p.done?s(p.value):i(p.value).then(c,l)}f((n=n.apply(r,t||[])).next())})}function al(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function lt(r){return this instanceof lt?(this.v=r,this):new lt(r)}function he(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(A){n[A]&&(i[A]=function(E){return new Promise(function(X,Ft){s.push([A,E,X,Ft])>1||c(A,E)})})}function c(A,E){try{l(n[A](E))}catch(X){B(s[0][3],X)}}function l(A){A.value instanceof lt?Promise.resolve(A.value.v).then(f,p):B(s[0][2],A)}function f(A){c("next",A)}function p(A){c("throw",A)}function B(A,E){A(E),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Un(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:lt(r[i](o)),done:!1}:s?s(o):o}:s}}function Oe(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof al=="function"?al(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(o){return new Promise(function(c,l){o=r[s](o),i(c,l,o.done,o.value)})}}function i(s,o,c,l){Promise.resolve(l).then(function(f){s({value:f,done:c})},o)}}var wa={};Cr(wa,{compareArrayLike:()=>ga,joinUint8Arrays:()=>pe,memcpy:()=>fi,rebaseValueOffsets:()=>Ds,toArrayBufferView:()=>ut,toArrayBufferViewAsyncIterator:()=>Re,toArrayBufferViewIterator:()=>Qe,toBigInt64Array:()=>Is,toBigUint64Array:()=>Up,toFloat32Array:()=>Mp,toFloat32ArrayAsyncIterator:()=>Kp,toFloat32ArrayIterator:()=>Hp,toFloat64Array:()=>Rp,toFloat64ArrayAsyncIterator:()=>Jp,toFloat64ArrayIterator:()=>zp,toInt16Array:()=>Tp,toInt16ArrayAsyncIterator:()=>$p,toInt16ArrayIterator:()=>kp,toInt32Array:()=>on,toInt32ArrayAsyncIterator:()=>Yp,toInt32ArrayIterator:()=>Cp,toInt8Array:()=>xp,toInt8ArrayAsyncIterator:()=>Wp,toInt8ArrayIterator:()=>Np,toUint16Array:()=>Ep,toUint16ArrayAsyncIterator:()=>Gp,toUint16ArrayIterator:()=>Pp,toUint32Array:()=>Op,toUint32ArrayAsyncIterator:()=>qp,toUint32ArrayIterator:()=>Vp,toUint8Array:()=>tt,toUint8ArrayAsyncIterator:()=>ba,toUint8ArrayIterator:()=>_a,toUint8ClampedArray:()=>Lp,toUint8ClampedArrayAsyncIterator:()=>Xp,toUint8ClampedArrayIterator:()=>jp});var Dp=new TextDecoder("utf-8"),ui=r=>Dp.decode(r),Bp=new TextEncoder,Ze=r=>Bp.encode(r);var Fp=r=>typeof r=="number",ll=r=>typeof r=="boolean",Wt=r=>typeof r=="function",ne=r=>r!=null&&Object(r)===r,Ue=r=>ne(r)&&Wt(r.then);var Me=r=>ne(r)&&Wt(r[Symbol.iterator]),ve=r=>ne(r)&&Wt(r[Symbol.asyncIterator]),_s=r=>ne(r)&&ne(r.schema);var bs=r=>ne(r)&&"done"in r&&"value"in r;var gs=r=>ne(r)&&Wt(r.stat)&&Fp(r.fd);var ws=r=>ne(r)&&di(r.body),vs=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ul=r=>ne(r)&&Wt(r.abort)&&Wt(r.getWriter)&&!vs(r),di=r=>ne(r)&&Wt(r.cancel)&&Wt(r.getReader)&&!vs(r),dl=r=>ne(r)&&Wt(r.end)&&Wt(r.write)&&ll(r.writable)&&!vs(r),Ss=r=>ne(r)&&Wt(r.read)&&Wt(r.pipe)&&ll(r.readable)&&!vs(r),fl=r=>ne(r)&&Wt(r.clear)&&Wt(r.bytes)&&Wt(r.position)&&Wt(r.setPosition)&&Wt(r.capacity)&&Wt(r.getBufferIdentifier)&&Wt(r.createLong);var ya=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ap(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let o,c,l=0,f=0,p=r.length;++l<p;){if(o=t[f],c=r[l],!o||!c||o.buffer!==c.buffer||c.byteOffset<o.byteOffset){c&&(t[++f]=c);continue}if({byteOffset:e,byteLength:i}=o,{byteOffset:n,byteLength:s}=c,e+i<n||n+s<e){c&&(t[++f]=c);continue}t[f]=new Uint8Array(o.buffer,e,n-e+s)}return t}function fi(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(o,e),r}function pe(r,t){let e=Ap(r),n=e.reduce((p,B)=>p+B.byteLength,0),i,s,o,c=0,l=-1,f=Math.min(t||Number.POSITIVE_INFINITY,n);for(let p=e.length;++l<p;){if(i=e[l],s=i.subarray(0,Math.min(i.length,f-c)),f<=c+s.length){s.length<i.length?e[l]=i.subarray(s.length):s.length===i.length&&l++,o?fi(o,s,c):o=s;break}fi(o||(o=new Uint8Array(f)),s,c),c+=s.length}return[o||new Uint8Array(0),e.slice(l),n-(o?o.byteLength:0)]}function ut(r,t){let e=bs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Ze(e)),e instanceof ArrayBuffer?new r(e):e instanceof ya?new r(e):fl(e)?ut(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var xp=r=>ut(Int8Array,r),Tp=r=>ut(Int16Array,r),on=r=>ut(Int32Array,r),Is=r=>ut(BigInt64Array,r),tt=r=>ut(Uint8Array,r),Ep=r=>ut(Uint16Array,r),Op=r=>ut(Uint32Array,r),Up=r=>ut(BigUint64Array,r),Mp=r=>ut(Float32Array,r),Rp=r=>ut(Float64Array,r),Lp=r=>ut(Uint8ClampedArray,r),ma=r=>(r.next(),r);function*Qe(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ya?e(t):Me(t)?t:e(t);return yield*sn(ma(function*(i){let s=null;do s=i.next(yield ut(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var Np=r=>Qe(Int8Array,r),kp=r=>Qe(Int16Array,r),Cp=r=>Qe(Int32Array,r),_a=r=>Qe(Uint8Array,r),Pp=r=>Qe(Uint16Array,r),Vp=r=>Qe(Uint32Array,r),Hp=r=>Qe(Float32Array,r),zp=r=>Qe(Float64Array,r),jp=r=>Qe(Uint8ClampedArray,r);function Re(r,t){return he(this,arguments,function*(){if(Ue(t))return yield lt(yield lt(yield*sn(Un(Oe(Re(r,yield lt(t)))))));let n=function(o){return he(this,arguments,function*(){yield yield lt(yield lt(o))})},i=function(o){return he(this,arguments,function*(){yield lt(yield*sn(Un(Oe(ma(function*(c){let l=null;do l=c.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ya?n(t):Me(t)?i(t):ve(t)?t:n(t);return yield lt(yield*sn(Un(Oe(ma(function(o){return he(this,arguments,function*(){let c=null;do c=yield lt(o.next(yield yield lt(ut(r,c))));while(!c.done)})}(s[Symbol.asyncIterator]())))))),yield lt(new r)})}var Wp=r=>Re(Int8Array,r),$p=r=>Re(Int16Array,r),Yp=r=>Re(Int32Array,r),ba=r=>Re(Uint8Array,r),Gp=r=>Re(Uint16Array,r),qp=r=>Re(Uint32Array,r),Kp=r=>Re(Float32Array,r),Jp=r=>Re(Float64Array,r),Xp=r=>Re(Uint8ClampedArray,r);function Ds(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n<i;)e[n]+=r}return e.subarray(0,t)}function ga(r,t){let e=0,n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}var Xt={fromIterable(r){return Bs(Zp(r))},fromAsyncIterable(r){return Bs(Qp(r))},fromDOMStream(r){return Bs(tm(r))},fromNodeStream(r){return Bs(em(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},Bs=r=>(r.next(),r);function*Zp(r){let t,e=!1,n=[],i,s,o,c=0;function l(){return s==="peek"?pe(n,o)[0]:([i,n,c]=pe(n,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let f=_a(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-c)?f.next():f.next(o-c),!t&&i.byteLength>0&&(n.push(i),c+=i.byteLength),t||o<=c)do({cmd:s,size:o}=yield l());while(o<c);while(!t)}catch(p){(e=!0)&&typeof f.throw=="function"&&f.throw(p)}finally{e===!1&&typeof f.return=="function"&&f.return(null)}return null}function Qp(r){return he(this,arguments,function*(){let e,n=!1,i=[],s,o,c,l=0;function f(){return o==="peek"?pe(i,c)[0]:([s,i,l]=pe(i,c),s)}({cmd:o,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let p=ba(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(c-l)?yield lt(p.next()):yield lt(p.next(c-l)),!e&&s.byteLength>0&&(i.push(s),l+=s.byteLength),e||c<=l)do({cmd:o,size:c}=yield yield lt(f()));while(c<l);while(!e)}catch(B){(n=!0)&&typeof p.throw=="function"&&(yield lt(p.throw(B)))}finally{n===!1&&typeof p.return=="function"&&(yield lt(p.return(new Uint8Array(0))))}return yield lt(null)})}function tm(r){return he(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,c,l=0;function f(){return o==="peek"?pe(i,c)[0]:([s,i,l]=pe(i,c),s)}({cmd:o,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let p=new Sa(r);try{do if({done:e,value:s}=Number.isNaN(c-l)?yield lt(p.read()):yield lt(p.read(c-l)),!e&&s.byteLength>0&&(i.push(tt(s)),l+=s.byteLength),e||c<=l)do({cmd:o,size:c}=yield yield lt(f()));while(c<l);while(!e)}catch(B){(n=!0)&&(yield lt(p.cancel(B)))}finally{n===!1?yield lt(p.cancel()):r.locked&&p.releaseLock()}return yield lt(null)})}var Sa=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return R(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return R(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=tt(e)),e})}},va=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function em(r){return he(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,c,l=0,f=[],p;function B(){return o==="peek"?pe(f,c)[0]:([p,f,l]=pe(f,c),p)}if({cmd:o,size:c}=(yield yield lt(null))||{cmd:"read",size:0},r.isTTY)return yield yield lt(new Uint8Array(0)),yield lt(null);try{e[0]=va(r,"end"),e[1]=va(r,"error");do{if(e[2]=va(r,"readable"),[n,s]=yield lt(Promise.race(e.map(E=>E[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(c-l)?(p=tt(r.read(c-l)),p.byteLength<c-l&&(p=tt(r.read()))):p=tt(r.read()),p.byteLength>0&&(f.push(p),l+=p.byteLength)),i||c<=l)do({cmd:o,size:c}=yield yield lt(B()));while(c<l)}while(!i)}finally{yield lt(A(e,n==="error"?s:null))}return yield lt(null);function A(E,X){return p=f=null,new Promise((Ft,Pt)=>{for(let[Lt,Bt]of E)r.off(Lt,Bt);try{let Lt=r.destroy;Lt&&Lt.call(r,X),X=void 0}catch(Lt){X=Lt||X}finally{X!=null?Pt(X):Ft()}})}})}var vt;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(vt||(vt={}));var xt;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(xt||(xt={}));var At;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(At||(At={}));var Vt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(Vt||(Vt={}));var k;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var $t;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})($t||($t={}));var tr=new Int32Array(2),Fs=new Float32Array(tr.buffer),As=new Float64Array(tr.buffer),Mn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var hi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(hi||(hi={}));var me=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(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))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return tr[0]=this.readInt32(t),Fs[0]}readFloat64(t){return tr[Mn?0:1]=this.readInt32(t),tr[Mn?1:0]=this.readInt32(t+4),As[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Fs[0]=e,this.writeInt32(t,tr[0])}writeFloat64(t,e){As[0]=e,this.writeInt32(t,tr[Mn?0:1]),this.writeInt32(t+4,tr[Mn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let n=this.readInt32(t);t+=4;let i=this.bytes_.subarray(t,t+n);return e===hi.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s)}return n}createObjList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s.unpack())}return n}};var an=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=me.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let i=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,i=me.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let o=0,c=this.space;t:for(e=0;e<this.vtables.length;e++){let l=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(l)){for(let f=2;f<s;f+=2)if(this.bb.readInt16(c+f)!=this.bb.readInt16(l+f))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,8+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var pi;(function(r){r[r.BUFFER=0]="BUFFER"})(pi||(pi={}));var mi;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(mi||(mi={}));var Ts=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__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):mi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):pi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,mi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,pi.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,n),r.endBodyCompression(t)}};var Rn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Ln=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var ye=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__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,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new Ln).__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,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Rn).__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 e=this.bb.__offset(this.bb_pos,10);return e?(t||new Ts).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var ur=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__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 e=this.bb.__offset(this.bb_pos,6);return e?(t||new ye).__init(this.bb.__indirect(this.bb_pos+e),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,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var Pr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Pr||(Pr={}));var yi;(function(r){r[r.DenseArray=0]="DenseArray"})(yi||(yi={}));var Ne=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,n),r.endInt(t)}};var er=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__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")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ne).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):yi.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,yi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Yt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,n),r.endKeyValue(t)}};var _i=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}};var bi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}};var Vr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Vt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Vt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var rr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,i){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,n),r.addBitWidth(t,i),r.endDecimal(t)}};var Hr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,k.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}};var zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}};var jr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}};var Wr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):At.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,At.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}};var $r=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$t.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,$t.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var gi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}};var wi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}};var vi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}};var Yr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}};var Si=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}};var Ii=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}};var dr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,k.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,n),r.endTime(t)}};var fr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,k.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,n),r.endTimestamp(t)}};var ke=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):xt.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,xt.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,n),r.endUnion(t)}};var Di=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}};var Tt;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(Tt||(Tt={}));var ee=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,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):Tt.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new er).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new r).__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,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Yt).__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,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Tt.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}};var ae=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__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):Pr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new ee).__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,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Yt).__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 e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){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,e){t.addFieldInt16(0,e,Pr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,n),r.addCustomMetadata(t,i),r.addFeatures(t,s),r.endSchema(t)}};var ht;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(ht||(ht={}));var h;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(h||(h={}));var Ie;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Ie||(Ie={}));var za={};Cr(za,{clampRange:()=>xi,createElementComparator:()=>Jr,wrapIndex:()=>cn});var Ia={};Cr(Ia,{valueToString:()=>Ce});function Ce(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return"".concat(r);case"bigint":return"".concat(r);case"string":return'"'.concat(r,'"')}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?"[".concat([...r].map(t=>Ce(t)),"]"):"[".concat(r,"]"):ArrayBuffer.isView(r)?"[".concat(r,"]"):JSON.stringify(r,(t,e)=>typeof e=="bigint"?"".concat(e):e)}var Aa={};Cr(Aa,{BN:()=>Fi,bigNumToBigInt:()=>pl,bigNumToNumber:()=>Fa,bigNumToString:()=>Cn,isArrowBigNumSymbol:()=>hl});function yt(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError("".concat(r," is not safe to convert to a number."));return Number(r)}function Da(r,t){return yt(r/t)+yt(r%t)/yt(t)}var hl=Symbol.for("isArrowBigNum");function Pe(r,...t){return t.length===0?Object.setPrototypeOf(ut(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Pe.prototype[hl]=!0;Pe.prototype.toJSON=function(){return'"'.concat(Cn(this),'"')};Pe.prototype.valueOf=function(r){return Fa(this,r)};Pe.prototype.toString=function(){return Cn(this)};Pe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Fa(this);case"string":return Cn(this);case"default":return pl(this)}return Cn(this)};function Nn(...r){return Pe.apply(this,r)}function kn(...r){return Pe.apply(this,r)}function Bi(...r){return Pe.apply(this,r)}Object.setPrototypeOf(Nn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(kn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Bi.prototype,Object.create(Uint32Array.prototype));Object.assign(Nn.prototype,Pe.prototype,{constructor:Nn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(kn.prototype,Pe.prototype,{constructor:kn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Bi.prototype,Pe.prototype,{constructor:Bi,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var rm=BigInt(4294967296)*BigInt(4294967296),nm=rm-BigInt(1);function Fa(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),c=s&&o.at(-1)&BigInt(1)<<BigInt(63),l=BigInt(0),f=0;if(c){for(let p of o)l|=(p^nm)*(BigInt(1)<<BigInt(64*f++));l*=BigInt(-1),l-=BigInt(1)}else for(let p of o)l|=p*(BigInt(1)<<BigInt(64*f++));if(typeof t=="number"){let p=BigInt(Math.pow(10,t)),B=l/p,A=l%p;return yt(B)+yt(A)/yt(p)}return yt(l)}function Cn(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return Ba(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ba(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let o=t[s],c=~o+n;t[s]=c,n&=o===0?1:0}let i=Ba(t);return"-".concat(i)}function pl(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:Cn(r)}function Ba(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),i=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,o=n.length-1;do{for(e[0]=n[s=0];s<o;)n[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[s];n[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t="".concat(e[0]).concat(t)}while(i[0]||i[1]||i[2]||i[3]);return t!=null?t:"0"}var Fi=class r{static new(t,e){switch(e){case!0:return new Nn(t);case!1:return new kn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Nn(t)}return t.byteLength===16?new Bi(t):new kn(t)}static signed(t){return new Nn(t)}static unsigned(t){return new kn(t)}static decimal(t){return new Bi(t)}constructor(t,e){return r.new(t,e)}};var ml,yl,_l,bl,gl,wl,vl,Sl,Il,Dl,Bl,Fl,Al,xl,Tl,El,Ol,Ul,Ml,Rl,Ll,Nl,L=class r{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 isLargeBinary(t){return(t==null?void 0:t.typeId)===h.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===h.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===h.LargeUtf8}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 isDuration(t){return(t==null?void 0:t.typeId)===h.Duration}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 r.isUnion(t)&&t.mode===xt.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===xt.Sparse}constructor(t){this.typeId=t}};ml=Symbol.toStringTag;L[ml]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(L.prototype);var ie=class extends L{constructor(){super(h.Null)}toString(){return"Null"}};yl=Symbol.toStringTag;ie[yl]=(r=>r[Symbol.toStringTag]="Null")(ie.prototype);var Gt=class extends L{constructor(t,e){super(h.Int),this.isSigned=t,this.bitWidth=e}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)}};_l=Symbol.toStringTag;Gt[_l]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Gt.prototype);var Es=class extends Gt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Os=class extends Gt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},nr=class extends Gt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Us=class extends Gt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ms=class extends Gt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Rs=class extends Gt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ls=class extends Gt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Ns=class extends Gt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Es.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Os.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(nr.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Us.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ms.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Rs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ls.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Ns.prototype,"ArrayType",{value:BigUint64Array});var De=class extends L{constructor(t){super(h.Float),this.precision=t}get ArrayType(){switch(this.precision){case At.HALF:return Uint16Array;case At.SINGLE:return Float32Array;case At.DOUBLE:return Float64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"Float".concat(this.precision<<5||16)}};bl=Symbol.toStringTag;De[bl]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(De.prototype);var ks=class extends De{constructor(){super(At.HALF)}},Cs=class extends De{constructor(){super(At.SINGLE)}},Ps=class extends De{constructor(){super(At.DOUBLE)}};Object.defineProperty(ks.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Cs.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Ps.prototype,"ArrayType",{value:Float64Array});var hr=class extends L{constructor(){super(h.Binary)}toString(){return"Binary"}};gl=Symbol.toStringTag;hr[gl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(hr.prototype);var pr=class extends L{constructor(){super(h.LargeBinary)}toString(){return"LargeBinary"}};wl=Symbol.toStringTag;pr[wl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(pr.prototype);var mr=class extends L{constructor(){super(h.Utf8)}toString(){return"Utf8"}};vl=Symbol.toStringTag;mr[vl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(mr.prototype);var yr=class extends L{constructor(){super(h.LargeUtf8)}toString(){return"LargeUtf8"}};Sl=Symbol.toStringTag;yr[Sl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(yr.prototype);var _r=class extends L{constructor(){super(h.Bool)}toString(){return"Bool"}};Il=Symbol.toStringTag;_r[Il]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(_r.prototype);var br=class extends L{constructor(t,e,n=128){super(h.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};Dl=Symbol.toStringTag;br[Dl]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(br.prototype);var gr=class extends L{constructor(t){super(h.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat(Vt[this.unit],">")}get ArrayType(){return this.unit===Vt.DAY?Int32Array:BigInt64Array}};Bl=Symbol.toStringTag;gr[Bl]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(gr.prototype);var wr=class extends L{constructor(t,e){super(h.Time),this.unit=t,this.bitWidth=e}toString(){return"Time".concat(this.bitWidth,"<").concat(k[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};Fl=Symbol.toStringTag;wr[Fl]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(wr.prototype);var vr=class extends L{constructor(t,e){super(h.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(k[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};Al=Symbol.toStringTag;vr[Al]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(vr.prototype);var Sr=class extends L{constructor(t){super(h.Interval),this.unit=t}toString(){return"Interval<".concat($t[this.unit],">")}};xl=Symbol.toStringTag;Sr[xl]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Sr.prototype);var Ir=class extends L{constructor(t){super(h.Duration),this.unit=t}toString(){return"Duration<".concat(k[this.unit],">")}};Tl=Symbol.toStringTag;Ir[Tl]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Ir.prototype);var Ve=class extends L{constructor(t){super(h.List),this.children=[t]}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}};El=Symbol.toStringTag;Ve[El]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Ve.prototype);var Ut=class extends L{constructor(t){super(h.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};Ol=Symbol.toStringTag;Ut[Ol]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Ut.prototype);var He=class extends L{constructor(t,e,n){super(h.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};Ul=Symbol.toStringTag;He[Ul]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(He.prototype);var Dr=class extends L{constructor(t){super(h.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};Ml=Symbol.toStringTag;Dr[Ml]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Dr.prototype);var ze=class extends L{constructor(t,e){super(h.FixedSizeList),this.listSize=t,this.children=[e]}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,">")}};Rl=Symbol.toStringTag;ze[Rl]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(ze.prototype);var je=class extends L{constructor(t,e=!1){var n,i,s;if(super(h.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t==null?void 0:t.type)===null||n===void 0)&&n.children)){let o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let c=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];c&&(c.name="value")}}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(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};Ll=Symbol.toStringTag;je[Ll]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(je.prototype);var im=(r=>()=>++r)(-1),_e=class extends L{constructor(t,e,n,i){super(h.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?im():yt(n)}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,">")}};Nl=Symbol.toStringTag;_e[Nl]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(_e.prototype);function be(r){let t=r;switch(r.typeId){case h.Decimal:return r.bitWidth/32;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var W=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return sm(this,t,e)}getVisitFnByTypeId(t,e=!0){return Pn(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function sm(r,t,e=!0){return typeof t=="number"?Pn(r,t,e):typeof t=="string"&&t in h?Pn(r,h[t],e):t&&t instanceof L?Pn(r,kl(t),e):t!=null&&t.type&&t.type instanceof L?Pn(r,kl(t.type),e):Pn(r,h.NONE,e)}function Pn(r,t,e=!0){let n=null;switch(t){case h.Null:n=r.visitNull;break;case h.Bool:n=r.visitBool;break;case h.Int:n=r.visitInt;break;case h.Int8:n=r.visitInt8||r.visitInt;break;case h.Int16:n=r.visitInt16||r.visitInt;break;case h.Int32:n=r.visitInt32||r.visitInt;break;case h.Int64:n=r.visitInt64||r.visitInt;break;case h.Uint8:n=r.visitUint8||r.visitInt;break;case h.Uint16:n=r.visitUint16||r.visitInt;break;case h.Uint32:n=r.visitUint32||r.visitInt;break;case h.Uint64:n=r.visitUint64||r.visitInt;break;case h.Float:n=r.visitFloat;break;case h.Float16:n=r.visitFloat16||r.visitFloat;break;case h.Float32:n=r.visitFloat32||r.visitFloat;break;case h.Float64:n=r.visitFloat64||r.visitFloat;break;case h.Utf8:n=r.visitUtf8;break;case h.LargeUtf8:n=r.visitLargeUtf8;break;case h.Binary:n=r.visitBinary;break;case h.LargeBinary:n=r.visitLargeBinary;break;case h.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case h.Date:n=r.visitDate;break;case h.DateDay:n=r.visitDateDay||r.visitDate;break;case h.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case h.Timestamp:n=r.visitTimestamp;break;case h.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case h.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case h.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case h.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case h.Time:n=r.visitTime;break;case h.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case h.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case h.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case h.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case h.Decimal:n=r.visitDecimal;break;case h.List:n=r.visitList;break;case h.Struct:n=r.visitStruct;break;case h.Union:n=r.visitUnion;break;case h.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case h.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case h.Dictionary:n=r.visitDictionary;break;case h.Interval:n=r.visitInterval;break;case h.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case h.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case h.Duration:n=r.visitDuration;break;case h.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case h.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case h.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case h.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case h.FixedSizeList:n=r.visitFixedSizeList;break;case h.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(h[t],"'"))}function kl(r){switch(r.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?h.Int8:h.Uint8;case 16:return e?h.Int16:h.Uint16;case 32:return e?h.Int32:h.Uint32;case 64:return e?h.Int64:h.Uint64}return h.Int}case h.Float:switch(r.precision){case At.HALF:return h.Float16;case At.SINGLE:return h.Float32;case At.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.LargeBinary:return h.LargeBinary;case h.Utf8:return h.Utf8;case h.LargeUtf8:return h.LargeUtf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(r.unit){case k.SECOND:return h.TimeSecond;case k.MILLISECOND:return h.TimeMillisecond;case k.MICROSECOND:return h.TimeMicrosecond;case k.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(r.unit){case k.SECOND:return h.TimestampSecond;case k.MILLISECOND:return h.TimestampMillisecond;case k.MICROSECOND:return h.TimestampMicrosecond;case k.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(r.unit){case Vt.DAY:return h.DateDay;case Vt.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(r.unit){case $t.DAY_TIME:return h.IntervalDayTime;case $t.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Duration:switch(r.unit){case k.SECOND:return h.DurationSecond;case k.MILLISECOND:return h.DurationMillisecond;case k.MICROSECOND:return h.DurationMicrosecond;case k.NANOSECOND:return h.DurationNanosecond}return h.Duration;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(r.mode){case xt.Dense:return h.DenseUnion;case xt.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[r.typeId],"'"))}W.prototype.visitInt8=null;W.prototype.visitInt16=null;W.prototype.visitInt32=null;W.prototype.visitInt64=null;W.prototype.visitUint8=null;W.prototype.visitUint16=null;W.prototype.visitUint32=null;W.prototype.visitUint64=null;W.prototype.visitFloat16=null;W.prototype.visitFloat32=null;W.prototype.visitFloat64=null;W.prototype.visitDateDay=null;W.prototype.visitDateMillisecond=null;W.prototype.visitTimestampSecond=null;W.prototype.visitTimestampMillisecond=null;W.prototype.visitTimestampMicrosecond=null;W.prototype.visitTimestampNanosecond=null;W.prototype.visitTimeSecond=null;W.prototype.visitTimeMillisecond=null;W.prototype.visitTimeMicrosecond=null;W.prototype.visitTimeNanosecond=null;W.prototype.visitDenseUnion=null;W.prototype.visitSparseUnion=null;W.prototype.visitIntervalDayTime=null;W.prototype.visitIntervalYearMonth=null;W.prototype.visitDuration=null;W.prototype.visitDurationSecond=null;W.prototype.visitDurationMillisecond=null;W.prototype.visitDurationMicrosecond=null;W.prototype.visitDurationNanosecond=null;var xa={};Cr(xa,{float64ToUint16:()=>Ai,uint16ToFloat64:()=>Vs});var Cl=new Float64Array(1),Vn=new Uint32Array(Cl.buffer);function Vs(r){let t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function Ai(r){if(r!==r)return 32256;Cl[0]=r;let t=(Vn[1]&2147483648)>>16&65535,e=Vn[1]&2146435072,n=0;return e>=1089470464?Vn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Vn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Vn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Vn[1]&1048575)+512>>10),t|e|n&65535}var J=class extends W{};function it(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var om=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Pl=(r,t,e,n)=>{if(e+1<t.length){let i=yt(t[e]),s=yt(t[e+1]);r.set(n.subarray(0,s-i),i)}},am=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Br=({values:r},t,e)=>{r[t]=e},Ta=({values:r},t,e)=>{r[t]=e},Vl=({values:r},t,e)=>{r[t]=Ai(e)},cm=(r,t,e)=>{switch(r.type.precision){case At.HALF:return Vl(r,t,e);case At.SINGLE:case At.DOUBLE:return Ta(r,t,e)}},Hs=({values:r},t,e)=>{om(r,t,e.valueOf())},zs=({values:r},t,e)=>{r[t]=BigInt(e)},Ea=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Hl=({values:r,valueOffsets:t},e,n)=>Pl(r,t,e,n),zl=({values:r,valueOffsets:t},e,n)=>Pl(r,t,e,Ze(n)),Oa=(r,t,e)=>{r.type.unit===Vt.DAY?Hs(r,t,e):zs(r,t,e)},js=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Ws=({values:r},t,e)=>{r[t]=BigInt(e)},$s=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Ys=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Ua=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return js(r,t,e);case k.MILLISECOND:return Ws(r,t,e);case k.MICROSECOND:return $s(r,t,e);case k.NANOSECOND:return Ys(r,t,e)}},Gs=({values:r},t,e)=>{r[t]=e},qs=({values:r},t,e)=>{r[t]=e},Ks=({values:r},t,e)=>{r[t]=e},Js=({values:r},t,e)=>{r[t]=e},Ma=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return Gs(r,t,e);case k.MILLISECOND:return qs(r,t,e);case k.MICROSECOND:return Ks(r,t,e);case k.NANOSECOND:return Js(r,t,e)}},Ra=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},lm=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Zt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,c=i[t],l=i[t+1];c<l;)s(n,c++,e[++o]);else for(let o=-1,c=i[t],l=i[t+1];c<l;)s(n,c++,e.get(++o))},um=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Zt.getVisitFn(n),{[t]:o,[t+1]:c}=i,l=e instanceof Map?e.entries():Object.entries(e);for(let f of l)if(s(n,o,f),++o>=c)break},dm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),fm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),hm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),pm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),mm=(r,t,e)=>{let n=r.type.children.map(s=>Zt.getVisitFn(s.type)),i=e instanceof Map?hm(t,e):e instanceof pt?fm(t,e):Array.isArray(e)?dm(t,e):pm(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},ym=(r,t,e)=>{r.type.mode===xt.Dense?jl(r,t,e):Wl(r,t,e)},jl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,r.valueOffsets[t],e)},Wl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,t,e)},_m=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},La=(r,t,e)=>{r.type.unit===$t.DAY_TIME?Xs(r,t,e):Zs(r,t,e)},Xs=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Zs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Qs=({values:r},t,e)=>{r[t]=e},to=({values:r},t,e)=>{r[t]=e},eo=({values:r},t,e)=>{r[t]=e},ro=({values:r},t,e)=>{r[t]=e},Na=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return Qs(r,t,e);case k.MILLISECOND:return to(r,t,e);case k.MICROSECOND:return eo(r,t,e);case k.NANOSECOND:return ro(r,t,e)}},bm=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Zt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,c=t*n;++o<n;)s(i,c+o,e[o]);else for(let o=-1,c=t*n;++o<n;)s(i,c+o,e.get(o))};J.prototype.visitBool=it(am);J.prototype.visitInt=it(Br);J.prototype.visitInt8=it(Br);J.prototype.visitInt16=it(Br);J.prototype.visitInt32=it(Br);J.prototype.visitInt64=it(Br);J.prototype.visitUint8=it(Br);J.prototype.visitUint16=it(Br);J.prototype.visitUint32=it(Br);J.prototype.visitUint64=it(Br);J.prototype.visitFloat=it(cm);J.prototype.visitFloat16=it(Vl);J.prototype.visitFloat32=it(Ta);J.prototype.visitFloat64=it(Ta);J.prototype.visitUtf8=it(zl);J.prototype.visitLargeUtf8=it(zl);J.prototype.visitBinary=it(Hl);J.prototype.visitLargeBinary=it(Hl);J.prototype.visitFixedSizeBinary=it(Ea);J.prototype.visitDate=it(Oa);J.prototype.visitDateDay=it(Hs);J.prototype.visitDateMillisecond=it(zs);J.prototype.visitTimestamp=it(Ua);J.prototype.visitTimestampSecond=it(js);J.prototype.visitTimestampMillisecond=it(Ws);J.prototype.visitTimestampMicrosecond=it($s);J.prototype.visitTimestampNanosecond=it(Ys);J.prototype.visitTime=it(Ma);J.prototype.visitTimeSecond=it(Gs);J.prototype.visitTimeMillisecond=it(qs);J.prototype.visitTimeMicrosecond=it(Ks);J.prototype.visitTimeNanosecond=it(Js);J.prototype.visitDecimal=it(Ra);J.prototype.visitList=it(lm);J.prototype.visitStruct=it(mm);J.prototype.visitUnion=it(ym);J.prototype.visitDenseUnion=it(jl);J.prototype.visitSparseUnion=it(Wl);J.prototype.visitDictionary=it(_m);J.prototype.visitInterval=it(La);J.prototype.visitIntervalDayTime=it(Xs);J.prototype.visitIntervalYearMonth=it(Zs);J.prototype.visitDuration=it(Na);J.prototype.visitDurationSecond=it(Qs);J.prototype.visitDurationMillisecond=it(to);J.prototype.visitDurationMicrosecond=it(eo);J.prototype.visitDurationNanosecond=it(ro);J.prototype.visitFixedSizeList=it(bm);J.prototype.visitMap=it(um);var Zt=new J;var We=Symbol.for("parent"),Hn=Symbol.for("rowIndex"),Gr=class{constructor(t,e){return this[We]=t,this[Hn]=e,new Proxy(this,new Ca)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Hn],e=this[We],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=zt.visit(e.children[s],t);return i}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Ce(t),": ").concat(Ce(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ka(this[We],this[Hn])}},ka=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,zt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Gr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[We]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Hn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Ca=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[We].type.children.map(e=>e.name)}has(t,e){return t[We].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[We].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[We].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=zt.visit(t[We].children[n],t[Hn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[We].type.children.findIndex(s=>s.name===e);return i!==-1?(Zt.visit(t[We].children[i],t[Hn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var $=class extends W{};function et(r){return(t,e)=>t.getValid(e)?r(t,e):null}var gm=(r,t)=>864e5*r[t],wm=(r,t)=>null,$l=(r,t,e)=>{if(e+1>=t.length)return null;let n=yt(t[e]),i=yt(t[e+1]);return r.subarray(n,i)},vm=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Yl=({values:r},t)=>gm(r,t),Gl=({values:r},t)=>yt(r[t]),qr=({stride:r,values:t},e)=>t[r*e],Sm=({stride:r,values:t},e)=>Vs(t[r*e]),ql=({values:r},t)=>r[t],Im=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Kl=({values:r,valueOffsets:t},e)=>$l(r,t,e),Jl=({values:r,valueOffsets:t},e)=>{let n=$l(r,t,e);return n!==null?ui(n):null},Dm=({values:r},t)=>r[t],Bm=({type:r,values:t},e)=>r.precision!==At.HALF?t[e]:Vs(t[e]),Fm=(r,t)=>r.type.unit===Vt.DAY?Yl(r,t):Gl(r,t),Xl=({values:r},t)=>1e3*yt(r[t]),Zl=({values:r},t)=>yt(r[t]),Ql=({values:r},t)=>Da(r[t],BigInt(1e3)),tu=({values:r},t)=>Da(r[t],BigInt(1e6)),Am=(r,t)=>{switch(r.type.unit){case k.SECOND:return Xl(r,t);case k.MILLISECOND:return Zl(r,t);case k.MICROSECOND:return Ql(r,t);case k.NANOSECOND:return tu(r,t)}},eu=({values:r},t)=>r[t],ru=({values:r},t)=>r[t],nu=({values:r},t)=>r[t],iu=({values:r},t)=>r[t],xm=(r,t)=>{switch(r.type.unit){case k.SECOND:return eu(r,t);case k.MILLISECOND:return ru(r,t);case k.MICROSECOND:return nu(r,t);case k.NANOSECOND:return iu(r,t)}},Tm=({values:r,stride:t},e)=>Fi.decimal(r.subarray(t*e,t*(e+1))),Em=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,l=i[0].slice(s,o-s);return new pt([l])},Om=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new ir(o.slice(i,s-i))},Um=(r,t)=>new Gr(r,t),Mm=(r,t)=>r.type.mode===xt.Dense?su(r,t):ou(r,t),su=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return zt.visit(n,r.valueOffsets[t])},ou=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return zt.visit(n,t)},Rm=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Lm=(r,t)=>r.type.unit===$t.DAY_TIME?au(r,t):cu(r,t),au=({values:r},t)=>r.subarray(2*t,2*(t+1)),cu=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},lu=({values:r},t)=>r[t],uu=({values:r},t)=>r[t],du=({values:r},t)=>r[t],fu=({values:r},t)=>r[t],Nm=(r,t)=>{switch(r.type.unit){case k.SECOND:return lu(r,t);case k.MILLISECOND:return uu(r,t);case k.MICROSECOND:return du(r,t);case k.NANOSECOND:return fu(r,t)}},km=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new pt([s])};$.prototype.visitNull=et(wm);$.prototype.visitBool=et(vm);$.prototype.visitInt=et(Dm);$.prototype.visitInt8=et(qr);$.prototype.visitInt16=et(qr);$.prototype.visitInt32=et(qr);$.prototype.visitInt64=et(ql);$.prototype.visitUint8=et(qr);$.prototype.visitUint16=et(qr);$.prototype.visitUint32=et(qr);$.prototype.visitUint64=et(ql);$.prototype.visitFloat=et(Bm);$.prototype.visitFloat16=et(Sm);$.prototype.visitFloat32=et(qr);$.prototype.visitFloat64=et(qr);$.prototype.visitUtf8=et(Jl);$.prototype.visitLargeUtf8=et(Jl);$.prototype.visitBinary=et(Kl);$.prototype.visitLargeBinary=et(Kl);$.prototype.visitFixedSizeBinary=et(Im);$.prototype.visitDate=et(Fm);$.prototype.visitDateDay=et(Yl);$.prototype.visitDateMillisecond=et(Gl);$.prototype.visitTimestamp=et(Am);$.prototype.visitTimestampSecond=et(Xl);$.prototype.visitTimestampMillisecond=et(Zl);$.prototype.visitTimestampMicrosecond=et(Ql);$.prototype.visitTimestampNanosecond=et(tu);$.prototype.visitTime=et(xm);$.prototype.visitTimeSecond=et(eu);$.prototype.visitTimeMillisecond=et(ru);$.prototype.visitTimeMicrosecond=et(nu);$.prototype.visitTimeNanosecond=et(iu);$.prototype.visitDecimal=et(Tm);$.prototype.visitList=et(Em);$.prototype.visitStruct=et(Um);$.prototype.visitUnion=et(Mm);$.prototype.visitDenseUnion=et(su);$.prototype.visitSparseUnion=et(ou);$.prototype.visitDictionary=et(Rm);$.prototype.visitInterval=et(Lm);$.prototype.visitIntervalDayTime=et(au);$.prototype.visitIntervalYearMonth=et(cu);$.prototype.visitDuration=et(Nm);$.prototype.visitDurationSecond=et(lu);$.prototype.visitDurationMillisecond=et(uu);$.prototype.visitDurationMicrosecond=et(du);$.prototype.visitDurationNanosecond=et(fu);$.prototype.visitFixedSizeList=et(km);$.prototype.visitMap=et(Om);var zt=new $;var Kr=Symbol.for("keys"),jn=Symbol.for("vals"),zn=Symbol.for("kKeysAsStrings"),Pa=Symbol.for("_kKeysAsStrings"),ir=class{constructor(t){return this[Kr]=new pt([t.children[0]]).memoize(),this[jn]=t.children[1],new Proxy(this,new Ha)}get[zn](){return this[Pa]||(this[Pa]=Array.from(this[Kr].toArray(),String))}[Symbol.iterator](){return new Va(this[Kr],this[jn])}get size(){return this[Kr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Kr],e=this[jn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=zt.visit(e,i);return n}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Ce(t),": ").concat(Ce(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Va=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),zt.visit(this.vals,t)]})}},Ha=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[zn]}has(t,e){return t[zn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[zn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[zn].indexOf(e);if(n!==-1){let i=zt.visit(Reflect.get(t,jn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[zn].indexOf(e);return i!==-1?(Zt.visit(Reflect.get(t,jn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(ir.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Kr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[jn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Pa]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var hu;function xi(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(hu=s,s=o,o=hu),o>i&&(o=i),n?n(r,s,o):[s,o]}var cn=(r,t)=>r<0?t+r:r,pu=r=>r!==r;function Jr(r){if(typeof r!=="object"||r===null)return pu(r)?pu:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?ga(r,e):!1:r instanceof Map?Pm(r):Array.isArray(r)?Cm(r):r instanceof pt?Vm(r):Hm(r,!0)}function Cm(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Jr(r[e]);return no(t)}function Pm(r){let t=-1,e=[];for(let n of r.values())e[++t]=Jr(n);return no(e)}function Vm(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Jr(r.get(e));return no(t)}function Hm(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let i=-1,s=e.length;++i<s;)n[i]=Jr(r[e[i]]);return no(n,e)}function no(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return zm(r,e);case Map:return mu(r,e,e.keys());case ir:case Gr:case Object:case void 0:return mu(r,e,t||Object.keys(e))}return e instanceof pt?jm(r,e):!1}}function zm(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function jm(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function mu(r,t,e){let n=e[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,c=r.length,l=s.next(),f=n.next(),p=i.next();for(;o<c&&!f.done&&!p.done&&!l.done&&!(f.value!==p.value||!r[o](l.value));++o,f=n.next(),p=i.next(),l=s.next());return o===c&&f.done&&p.done&&l.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var ja={};Cr(ja,{BitIterator:()=>ln,getBit:()=>yu,getBool:()=>so,packBools:()=>dn,popcnt_array:()=>_u,popcnt_bit_range:()=>Ti,popcnt_uint32:()=>io,setBool:()=>Wm,truncateBitmap:()=>un});function so(r,t,e,n){return(e&1<<n)!==0}function yu(r,t,e,n){return(e&1<<n)>>n}function Wm(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function un(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let i=new Uint8Array(n);return i.set(r%8===0?e.subarray(r>>3):dn(new ln(e,r,t,null,so)).subarray(0,n)),i}return e}function dn(r){let t=[],e=0,n=0,i=0;for(let o of r)o&&(i|=1<<n),++n===8&&(t[e++]=i,i=n=0);(e===0||n>0)&&(t[e++]=i);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var ln=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Ti(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new ln(r,t,e-t,r,yu))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Ti(r,t,i)+Ti(r,n,e)+_u(r,i>>3,n-i>>3)}function _u(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=io(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=io(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=io(s.getUint8(i)),i+=1;return n}function io(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var $m=-1,gt=class r{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return L.isSparseUnion(t)?this.children.some(e=>e.nullable):L.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,c)=>o+c.byteLength,t)}get nullCount(){if(L.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=$m&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Ti(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],c){this.type=t,this.children=o,this.dictionary=c,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof r?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=be(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){let{type:e}=this;if(L.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===xt.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(L.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],c=s.mode===xt.Dense?this.valueOffsets[t]:t;n=o.getValid(c),o.setValid(c,e)}else{let{nullBitmap:s}=this,{offset:o,length:c}=this,l=o+t,f=1<<l%8,p=l>>3;(!s||s.byteLength<=p)&&(s=new Uint8Array((o+c+63&-64)>>3).fill(255),this.nullCount>0?(s.set(un(o,c,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let B=s[p];n=(B&f)!==0,s[p]=e?B|f:B&~f}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new r(t,e,n,i,s,o,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,c=i===16?n:1,l=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,c*t,c*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===h.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<<e-(e&-8))-1,n>0&&i.set(un(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[Ie.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:o}=this;return(s=o[Ie.TYPE])&&(o[Ie.TYPE]=s.subarray(t,t+e)),(s=o[Ie.OFFSET])&&(o[Ie.OFFSET]=s.subarray(t,t+e+1))||(s=o[Ie.DATA])&&(o[Ie.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};gt.prototype.children=Object.freeze([]);var Wa=class r extends W{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new gt(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=Is(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=Is(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=tt(t.nullBitmap),{length:o=i.reduce((l,{length:f})=>Math.max(l,f),0),nullCount:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=ut(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:c=-1}=t;if(L.isSparseUnion(e))return new gt(e,n,o,c,[void 0,void 0,void 0,s],i);let l=on(t.valueOffsets);return new gt(e,n,o,c,[l,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.indices.ArrayType,t.data),{["dictionary"]:o=new pt([new r().visit({type:e.dictionary})])}=t,{["length"]:c=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=tt(t.nullBitmap),{["length"]:o=i.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.childType})}=t,s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,void 0,s],[i])}},Ym=new Wa;function ot(r){return Ym.visit(r)}var Ei=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function bu(r){return r.some(t=>t.nullable)}function oo(r){return r.reduce((t,e)=>t+e.nullCount,0)}function ao(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function co(r,t,e,n){let i=[];for(let s=-1,o=r.length;++s<o;){let c=r[s],l=t[s],{length:f}=c;if(l>=n)break;if(e>=l+f)continue;if(l>=e&&l+f<=n){i.push(c);continue}let p=Math.max(0,e-l),B=Math.min(n-l,f);i.push(c.slice(p,B-p))}return i.length===0&&i.push(r[0].slice(0,0)),i}function $a(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e<t[o]?n(r,i,e-t[i]):null;s=i+Math.trunc((o-i)*.5),e<t[s]?o=s:i=s}while(i<o)}function Oi(r,t){return r.getValid(t)}function Wn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return $a(n,this._offsets,e,t)}}function lo(r){let t;function e(n,i,s){return r(n[i],s,t)}return function(n,i){let s=this.data;t=i;let o=$a(s,this._offsets,n,e);return t=void 0,o}}function uo(r){let t;function e(n,i,s){let o=s,c=0,l=0;for(let f=i-1,p=n.length;++f<p;){let B=n[f];if(~(c=r(B,t,o)))return l+c;o=0,l+=B.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):$a(s,this._offsets,i,e);return t=void 0,o}}var Y=class extends W{};function Gm(r,t){return t===null&&r.length>0?0:-1}function qm(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new ln(e,r.offset+(t||0),r.length,e,so)){if(!i)return n;++n}return-1}function at(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case h.Union:break;case h.Dictionary:break;default:return qm(r,e)}let n=zt.getVisitFn(r),i=Jr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function gu(r,t,e){let n=zt.getVisitFn(r),i=Jr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}Y.prototype.visitNull=Gm;Y.prototype.visitBool=at;Y.prototype.visitInt=at;Y.prototype.visitInt8=at;Y.prototype.visitInt16=at;Y.prototype.visitInt32=at;Y.prototype.visitInt64=at;Y.prototype.visitUint8=at;Y.prototype.visitUint16=at;Y.prototype.visitUint32=at;Y.prototype.visitUint64=at;Y.prototype.visitFloat=at;Y.prototype.visitFloat16=at;Y.prototype.visitFloat32=at;Y.prototype.visitFloat64=at;Y.prototype.visitUtf8=at;Y.prototype.visitLargeUtf8=at;Y.prototype.visitBinary=at;Y.prototype.visitLargeBinary=at;Y.prototype.visitFixedSizeBinary=at;Y.prototype.visitDate=at;Y.prototype.visitDateDay=at;Y.prototype.visitDateMillisecond=at;Y.prototype.visitTimestamp=at;Y.prototype.visitTimestampSecond=at;Y.prototype.visitTimestampMillisecond=at;Y.prototype.visitTimestampMicrosecond=at;Y.prototype.visitTimestampNanosecond=at;Y.prototype.visitTime=at;Y.prototype.visitTimeSecond=at;Y.prototype.visitTimeMillisecond=at;Y.prototype.visitTimeMicrosecond=at;Y.prototype.visitTimeNanosecond=at;Y.prototype.visitDecimal=at;Y.prototype.visitList=at;Y.prototype.visitStruct=at;Y.prototype.visitUnion=at;Y.prototype.visitDenseUnion=gu;Y.prototype.visitSparseUnion=gu;Y.prototype.visitDictionary=at;Y.prototype.visitInterval=at;Y.prototype.visitIntervalDayTime=at;Y.prototype.visitIntervalYearMonth=at;Y.prototype.visitDuration=at;Y.prototype.visitDurationSecond=at;Y.prototype.visitDurationMillisecond=at;Y.prototype.visitDurationMicrosecond=at;Y.prototype.visitDurationNanosecond=at;Y.prototype.visitFixedSizeList=at;Y.prototype.visitMap=at;var fn=new Y;var G=class extends W{};function rt(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(L.isInt(t)&&t.bitWidth!==64||L.isTime(t)&&t.bitWidth!==64||L.isFloat(t)&&t.precision!==At.HALF))return new Ei(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Ei(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Ya(o)})}var Ya=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};G.prototype.visitNull=rt;G.prototype.visitBool=rt;G.prototype.visitInt=rt;G.prototype.visitInt8=rt;G.prototype.visitInt16=rt;G.prototype.visitInt32=rt;G.prototype.visitInt64=rt;G.prototype.visitUint8=rt;G.prototype.visitUint16=rt;G.prototype.visitUint32=rt;G.prototype.visitUint64=rt;G.prototype.visitFloat=rt;G.prototype.visitFloat16=rt;G.prototype.visitFloat32=rt;G.prototype.visitFloat64=rt;G.prototype.visitUtf8=rt;G.prototype.visitLargeUtf8=rt;G.prototype.visitBinary=rt;G.prototype.visitLargeBinary=rt;G.prototype.visitFixedSizeBinary=rt;G.prototype.visitDate=rt;G.prototype.visitDateDay=rt;G.prototype.visitDateMillisecond=rt;G.prototype.visitTimestamp=rt;G.prototype.visitTimestampSecond=rt;G.prototype.visitTimestampMillisecond=rt;G.prototype.visitTimestampMicrosecond=rt;G.prototype.visitTimestampNanosecond=rt;G.prototype.visitTime=rt;G.prototype.visitTimeSecond=rt;G.prototype.visitTimeMillisecond=rt;G.prototype.visitTimeMicrosecond=rt;G.prototype.visitTimeNanosecond=rt;G.prototype.visitDecimal=rt;G.prototype.visitList=rt;G.prototype.visitStruct=rt;G.prototype.visitUnion=rt;G.prototype.visitDenseUnion=rt;G.prototype.visitSparseUnion=rt;G.prototype.visitDictionary=rt;G.prototype.visitInterval=rt;G.prototype.visitIntervalDayTime=rt;G.prototype.visitIntervalYearMonth=rt;G.prototype.visitDuration=rt;G.prototype.visitDurationSecond=rt;G.prototype.visitDurationMillisecond=rt;G.prototype.visitDurationMicrosecond=rt;G.prototype.visitDurationNanosecond=rt;G.prototype.visitFixedSizeList=rt;G.prototype.visitMap=rt;var $n=new G;var wu,vu={},Su={},pt=class r{constructor(t){var e,n,i;let s=t[0]instanceof r?t.flatMap(c=>c.data):t;if(s.length===0||s.some(c=>!(c instanceof gt)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:c,set:l,indexOf:f}=vu[o.typeId],p=s[0];this.isValid=B=>Oi(p,B),this.get=B=>c(p,B),this.set=(B,A)=>l(p,B,A),this.indexOf=B=>f(p,B),this._offsets=[0,p.length];break}default:Object.setPrototypeOf(this,Su[o.typeId]),this._offsets=ao(s);break}this.data=s,this.type=o,this.stride=be(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return bu(this.data)}get nullCount(){return oo(this.data)}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}at(t){return this.get(cn(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return $n.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(xi(this,t,e,({data:n,_offsets:i},s,o)=>co(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:c,length:l})=>(o.array.set(c.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return"[".concat([...this].join(","),"]")}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return L.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(L.isDictionary(this.type)){let t=new fo(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new fo(this)}unmemoize(){if(L.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return this}};wu=Symbol.toStringTag;pt[wu]=(r=>{r.type=L.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(h).map(e=>h[e]).filter(e=>typeof e=="number"&&e!==h.NONE);for(let e of t){let n=zt.getVisitFnByTypeId(e),i=Zt.getVisitFnByTypeId(e),s=fn.getVisitFnByTypeId(e);vu[e]={get:n,set:i,indexOf:s},Su[e]=Object.create(r,{isValid:{value:Wn(Oi)},get:{value:Wn(zt.getVisitFnByTypeId(e))},set:{value:lo(Zt.getVisitFnByTypeId(e))},indexOf:{value:uo(fn.getVisitFnByTypeId(e))}})}return"Vector"})(pt.prototype);var fo=class r extends pt{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let c=s[o];if(c!==void 0)return c;let l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,c){n.call(this,o,c),s[o]=c}}),Object.defineProperty(this,"slice",{value:(o,c)=>new r(i.call(this,o,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new pt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Iu(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t="\n switch (x) {".concat(e.map(n=>"\n case ".concat(Km(n),":")).join(""),"\n return false;\n }")),r.length!==e.length&&(t="if (x !== x) return false;\n".concat(t)),new Function("x","".concat(t,"\nreturn true;"))}function Km(r){return typeof r!="bigint"?Ce(r):"".concat(Ce(r),"n")}function Ga(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function Du(r,t=0){return r.length>=t?r.subarray(0,t):fi(new r.constructor(t),r,0)}var $e=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=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(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?Ga(n*1,this.BYTES_PER_ELEMENT):Ga(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Ga(t*this.stride,this.BYTES_PER_ELEMENT);let e=Du(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=Du(this.buffer,t)}},Fr=class extends $e{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Yn=class extends Fr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Gn=class extends Fr{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var Rt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=be(t),this._nulls=new Yn,e&&e.length>0&&(this._isValid=Iu(e))}toVector(){return new pt([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((c,l)=>c+l.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e="".concat(this.numChildren)){throw new Error('Cannot append children to non-nested type "'.concat(this.type,'"'))}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:c,_typeIds:l,_offsets:f,_values:p,_nulls:B}=this;(e=l==null?void 0:l.flush(o))?i=f==null?void 0:f.flush(o):(i=f==null?void 0:f.flush(o))?t=p==null?void 0:p.flush(f.last()):t=p==null?void 0:p.flush(o),c>0&&(n=B==null?void 0:B.flush(o));let A=this.children.map(E=>E.flush());return this.clear(),ot({type:s,length:o,nullCount:c,children:A,child:A[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};Rt.prototype.length=1;Rt.prototype.stride=1;Rt.prototype.children=null;Rt.prototype.finished=!1;Rt.prototype.nullValues=null;Rt.prototype._isValid=()=>!0;var jt=class extends Rt{constructor(t){super(t),this._values=new Fr(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},ce=class extends Rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Gn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof ir?e[Kr].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var hn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i!=null?i:0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var ge=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__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):vt.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ae).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new hn).__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,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new hn).__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,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Yt).__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,e){t.addFieldInt16(0,e,vt.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var It=class r{constructor(t=[],e,n,i=vt.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=qa(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return"Schema<{ ".concat(this.fields.map((t,e)=>"".concat(e,": ").concat(t)).join(", ")," }>")}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new r(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),n=[...this.fields],i=ho(ho(new Map,this.metadata),e.metadata),s=e.fields.filter(c=>{let l=n.findIndex(f=>f.name===c.name);return~l?(n[l]=c.clone({metadata:ho(ho(new Map,n[l].metadata),c.metadata)}))&&!1:!0}),o=qa(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...o]))}};It.prototype.fields=null;It.prototype.metadata=null;It.prototype.dictionaries=null;var dt=class r{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new r("".concat(e),n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return"".concat(this.name,": ").concat(this.type)}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],r.new(e,n,i,s)}};dt.prototype.type=null;dt.prototype.name=null;dt.prototype.nullable=null;dt.prototype.metadata=null;function ho(r,t){return new Map([...r||new Map,...t||new Map])}function qa(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(L.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&qa(s.children,t)}return t}var Jm=an,Xm=me,Ar=class{static decode(t){t=new Xm(tt(t));let e=ge.getRootAsFooter(t),n=It.decode(e.schema(),new Map,e.version());return new Ka(n,e)}static encode(t){let e=new Jm,n=It.encode(e,t.schema);ge.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())xr.encode(e,o);let i=e.endVector();ge.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())xr.encode(e,o);let s=e.endVector();return ge.startFooter(e),ge.addSchema(e,n),ge.addVersion(e,vt.V5),ge.addRecordBatches(e,i),ge.addDictionaries(e,s),ge.finishFooterBuffer(e,ge.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=vt.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var Ka=class extends Ar{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return xr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return xr.decode(e)}return null}},xr=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return hn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=yt(n),this.bodyLength=yt(e)}};var Mt=Object.freeze({done:!0,value:void 0}),Ui=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},pn=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},po=class extends pn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return R(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Mt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Xt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Xt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return R(this,void 0,void 0,function*(){return yield this.abort(t),Mt})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),Mt})}read(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Mt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var sr=class extends po{write(t){if((t=tt(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?ui(this.toUint8Array(!0)):this.toUint8Array(!1).then(ui)}toUint8Array(t=!1){return t?pe(this._values)[0]:R(this,void 0,void 0,function*(){var e,n,i,s;let o=[],c=0;try{for(var l=!0,f=Oe(this),p;p=yield f.next(),e=p.done,!e;l=!0){s=p.value,l=!1;let B=s;o.push(B),c+=B.byteLength}}catch(B){n={error:B}}finally{try{!l&&!e&&(i=f.return)&&(yield i.call(f))}finally{if(n)throw n.error}}return pe(o,c)[0]})}},or=class{constructor(t){t&&(this.source=new Ja(Xt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Be=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof sr?this.source=new Tr(Xt.fromAsyncIterable(t)):Ss(t)?this.source=new Tr(Xt.fromNodeStream(t)):di(t)?this.source=new Tr(Xt.fromDOMStream(t)):ws(t)?this.source=new Tr(Xt.fromDOMStream(t.body)):Me(t)?this.source=new Tr(Xt.fromIterable(t)):Ue(t)?this.source=new Tr(Xt.fromAsyncIterable(t)):ve(t)&&(this.source=new Tr(Xt.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)}},Ja=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Mt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Mt)}},Tr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return R(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return R(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return R(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||Mt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return R(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||Mt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Mi=class extends or{constructor(t,e){super(),this.position=0,this.buffer=tt(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},Xr=class extends Be{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=R(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return R(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return R(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return R(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,c=0,l=Math.min(n,s+Math.min(n-s,t)),f=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=c)<l&&(o+=c)<f.byteLength;)({bytesRead:c}=yield e.read(f,o,f.byteLength-o,s));return f}return null})}readAt(t,e){return R(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return R(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return R(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Za={};Cr(Za,{BaseInt64:()=>Ri,Int128:()=>Li,Int64:()=>Er,Uint64:()=>Ct});function qn(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var Kn=8,Xa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Ri=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return"".concat(qn(this.buffer[1])," ").concat(qn(this.buffer[0]))}},Ct=class r extends Ri{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new r(e);for(let s=0;s<n;){let o=Kn<n-s?Kn:n-s,c=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),l=new r(new Uint32Array([Xa[o],0]));i.times(l),i.plus(c),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Er=class r extends Ri{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let o=n?1:0;o<i;){let c=Kn<i-o?Kn:i-o,l=new r(new Uint32Array([Number.parseInt(t.slice(o,o+c),10),0])),f=new r(new Uint32Array([Xa[c],0]));s.times(f),s.plus(l),o+=c}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Li=class r{constructor(t){this.buffer=t}high(){return new Er(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Er(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new Ct(new Uint32Array([this.buffer[3],0])),n=new Ct(new Uint32Array([this.buffer[2],0])),i=new Ct(new Uint32Array([this.buffer[1],0])),s=new Ct(new Uint32Array([this.buffer[0],0])),o=new Ct(new Uint32Array([t.buffer[3],0])),c=new Ct(new Uint32Array([t.buffer[2],0])),l=new Ct(new Uint32Array([t.buffer[1],0])),f=new Ct(new Uint32Array([t.buffer[0],0])),p=Ct.multiply(s,f);this.buffer[0]=p.low();let B=new Ct(new Uint32Array([p.high(),0]));return p=Ct.multiply(i,f),B.plus(p),p=Ct.multiply(s,l),B.plus(p),this.buffer[1]=B.low(),this.buffer[3]=B.lessThan(p)?1:0,this.buffer[2]=B.high(),new Ct(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ct.multiply(n,f)).plus(Ct.multiply(i,l)).plus(Ct.multiply(s,c)),this.buffer[3]+=Ct.multiply(e,f).plus(Ct.multiply(n,l)).plus(Ct.multiply(i,c)).plus(Ct.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return"".concat(qn(this.buffer[3])," ").concat(qn(this.buffer[2])," ").concat(qn(this.buffer[1])," ").concat(qn(this.buffer[0]))}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let o=n?1:0;o<i;){let c=Kn<i-o?Kn:i-o,l=new r(new Uint32Array([Number.parseInt(t.slice(o,o+c),10),0,0,0])),f=new r(new Uint32Array([Xa[c],0,0,0]));s.times(f),s.plus(l),o+=c}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var Ni=class extends W{constructor(t,e,n,i,s=vt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof dt?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return ot({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<vt.V5&&this.readNullBitmap(t,n),t.mode===xt.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},mo=class extends Ni{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):dn(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return ut(Uint8Array,ut(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return ut(Uint8Array,ut(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return L.isTimestamp(t)?ut(Uint8Array,Er.convertArray(n[e])):(L.isInt(t)||L.isTime(t))&&t.bitWidth===64||L.isDuration(t)?ut(Uint8Array,Er.convertArray(n[e])):L.isDate(t)&&t.unit===Vt.MILLISECOND?ut(Uint8Array,Er.convertArray(n[e])):L.isDecimal(t)?ut(Uint8Array,Li.convertArray(n[e])):L.isBinary(t)||L.isLargeBinary(t)||L.isFixedSizeBinary(t)?Zm(n[e]):L.isBool(t)?dn(n[e]):L.isUtf8(t)||L.isLargeUtf8(t)?Ze(n[e].join("")):ut(Uint8Array,ut(t.ArrayType,n[e].map(i=>+i)))}};function Zm(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var Jn=class extends ce{constructor(t){super(t),this._values=new $e(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,tt(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,c]of t)if(c===void 0)n.set(o,0);else{let l=c.length;i.set(c,s),n.set(o,l),s+=l}}};var Xn=class extends ce{constructor(t){super(t),this._values=new $e(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,tt(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,c]of t)if(c===void 0)n.set(o,BigInt(0));else{let l=c.length;i.set(c,s),n.set(o,BigInt(l)),s+=l}}};var yo=class extends Rt{constructor(t){super(t),this._values=new Yn}setValue(t,e){this._values.set(t,+e)}};var mn=class extends jt{};mn.prototype._setValue=Oa;var ki=class extends mn{};ki.prototype._setValue=Hs;var Ci=class extends mn{};Ci.prototype._setValue=zs;var Pi=class extends jt{};Pi.prototype._setValue=Ra;var _o=class extends Rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new _e(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=yn({type:this.type.indices,nullValues:e}),this.dictionary=yn({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:"".concat(t)}};var Vi=class extends jt{};Vi.prototype._setValue=Ea;var bo=class extends Rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new ze(this.type.listSize,new dt(e,t.type,!0)),n}};var _n=class extends jt{setValue(t,e){this._values.set(t,e)}},go=class extends _n{setValue(t,e){super.setValue(t,Ai(e))}},wo=class extends _n{},vo=class extends _n{};var bn=class extends jt{};bn.prototype._setValue=La;var Hi=class extends bn{};Hi.prototype._setValue=Xs;var zi=class extends bn{};zi.prototype._setValue=Zs;var Or=class extends jt{};Or.prototype._setValue=Na;var ji=class extends Or{};ji.prototype._setValue=Qs;var Wi=class extends Or{};Wi.prototype._setValue=to;var $i=class extends Or{};$i.prototype._setValue=eo;var Yi=class extends Or{};Yi.prototype._setValue=ro;var Fe=class extends jt{setValue(t,e){this._values.set(t,e)}},So=class extends Fe{},Io=class extends Fe{},Do=class extends Fe{},Bo=class extends Fe{},Fo=class extends Fe{},Ao=class extends Fe{},xo=class extends Fe{},To=class extends Fe{};var Eo=class extends ce{constructor(t){super(t),this._offsets=new Gn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ve(new dt(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,c=o.length,l=e.set(i,c).buffer[i];for(let f=-1;++f<c;)n.set(l+f,o[f])}}};var Oo=class extends ce{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e="".concat(this.numChildren)){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new je(new dt(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:c}=e.set(i,s.size).buffer;for(let l of s.entries())if(n.set(o,l),++o>=c)break}}};var Uo=class extends Rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Mo=class extends Rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e="".concat(this.numChildren)){let n=this.children.push(t);return this.type=new Ut([...this.type.children,new dt(e,t.type,!0)]),n}};var Ur=class extends jt{};Ur.prototype._setValue=Ua;var Gi=class extends Ur{};Gi.prototype._setValue=js;var qi=class extends Ur{};qi.prototype._setValue=Ws;var Ki=class extends Ur{};Ki.prototype._setValue=$s;var Ji=class extends Ur{};Ji.prototype._setValue=Ys;var Mr=class extends jt{};Mr.prototype._setValue=Ma;var Xi=class extends Mr{};Xi.prototype._setValue=Gs;var Zi=class extends Mr{};Zi.prototype._setValue=qs;var Qi=class extends Mr{};Qi.prototype._setValue=Ks;var ts=class extends Mr{};ts.prototype._setValue=Js;var Zn=class extends Rt{constructor(t){super(t),this._typeIds=new Fr(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s==null||s.set(t,e)}addChild(t,e="".concat(this.children.length)){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,c=[...i,new dt(e,t.type)];return this.type=new He(s,[...o,n],c),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Ro=class extends Zn{},Lo=class extends Zn{constructor(t){super(t),this._offsets=new Fr(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s==null||s.set(o,e)}};var es=class extends ce{constructor(t){super(t),this._values=new $e(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ze(e))}_flushPending(t,e){}};es.prototype._flushPending=Jn.prototype._flushPending;var rs=class extends ce{constructor(t){super(t),this._values=new $e(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ze(e))}_flushPending(t,e){}};rs.prototype._flushPending=Xn.prototype._flushPending;var Qa=class extends W{visitNull(){return Uo}visitBool(){return yo}visitInt(){return Fe}visitInt8(){return So}visitInt16(){return Io}visitInt32(){return Do}visitInt64(){return Bo}visitUint8(){return Fo}visitUint16(){return Ao}visitUint32(){return xo}visitUint64(){return To}visitFloat(){return _n}visitFloat16(){return go}visitFloat32(){return wo}visitFloat64(){return vo}visitUtf8(){return es}visitLargeUtf8(){return rs}visitBinary(){return Jn}visitLargeBinary(){return Xn}visitFixedSizeBinary(){return Vi}visitDate(){return mn}visitDateDay(){return ki}visitDateMillisecond(){return Ci}visitTimestamp(){return Ur}visitTimestampSecond(){return Gi}visitTimestampMillisecond(){return qi}visitTimestampMicrosecond(){return Ki}visitTimestampNanosecond(){return Ji}visitTime(){return Mr}visitTimeSecond(){return Xi}visitTimeMillisecond(){return Zi}visitTimeMicrosecond(){return Qi}visitTimeNanosecond(){return ts}visitDecimal(){return Pi}visitList(){return Eo}visitStruct(){return Mo}visitUnion(){return Zn}visitDenseUnion(){return Lo}visitSparseUnion(){return Ro}visitDictionary(){return _o}visitInterval(){return bn}visitIntervalDayTime(){return Hi}visitIntervalYearMonth(){return zi}visitDuration(){return Or}visitDurationSecond(){return ji}visitDurationMillisecond(){return Wi}visitDurationMicrosecond(){return $i}visitDurationNanosecond(){return Yi}visitFixedSizeList(){return bo}visitMap(){return Oo}},Bu=new Qa;var q=class extends W{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function se(r,t){return t instanceof r.constructor}function gn(r,t){return r===t||se(r,t)}function Rr(r,t){return r===t||se(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function No(r,t){return r===t||se(r,t)&&r.precision===t.precision}function Qm(r,t){return r===t||se(r,t)&&r.byteWidth===t.byteWidth}function tc(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ns(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function is(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function ty(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function ey(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function ec(r,t){return r===t||se(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&ar.compareManyFields(r.children,t.children)}function ry(r,t){return r===t||se(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&ar.visit(r.indices,t.indices)&&ar.visit(r.dictionary,t.dictionary)}function rc(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ss(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ny(r,t){return r===t||se(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function iy(r,t){return r===t||se(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}q.prototype.visitNull=gn;q.prototype.visitBool=gn;q.prototype.visitInt=Rr;q.prototype.visitInt8=Rr;q.prototype.visitInt16=Rr;q.prototype.visitInt32=Rr;q.prototype.visitInt64=Rr;q.prototype.visitUint8=Rr;q.prototype.visitUint16=Rr;q.prototype.visitUint32=Rr;q.prototype.visitUint64=Rr;q.prototype.visitFloat=No;q.prototype.visitFloat16=No;q.prototype.visitFloat32=No;q.prototype.visitFloat64=No;q.prototype.visitUtf8=gn;q.prototype.visitLargeUtf8=gn;q.prototype.visitBinary=gn;q.prototype.visitLargeBinary=gn;q.prototype.visitFixedSizeBinary=Qm;q.prototype.visitDate=tc;q.prototype.visitDateDay=tc;q.prototype.visitDateMillisecond=tc;q.prototype.visitTimestamp=ns;q.prototype.visitTimestampSecond=ns;q.prototype.visitTimestampMillisecond=ns;q.prototype.visitTimestampMicrosecond=ns;q.prototype.visitTimestampNanosecond=ns;q.prototype.visitTime=is;q.prototype.visitTimeSecond=is;q.prototype.visitTimeMillisecond=is;q.prototype.visitTimeMicrosecond=is;q.prototype.visitTimeNanosecond=is;q.prototype.visitDecimal=gn;q.prototype.visitList=ty;q.prototype.visitStruct=ey;q.prototype.visitUnion=ec;q.prototype.visitDenseUnion=ec;q.prototype.visitSparseUnion=ec;q.prototype.visitDictionary=ry;q.prototype.visitInterval=rc;q.prototype.visitIntervalDayTime=rc;q.prototype.visitIntervalYearMonth=rc;q.prototype.visitDuration=ss;q.prototype.visitDurationSecond=ss;q.prototype.visitDurationMillisecond=ss;q.prototype.visitDurationMicrosecond=ss;q.prototype.visitDurationNanosecond=ss;q.prototype.visitFixedSizeList=ny;q.prototype.visitMap=iy;var ar=new q;function wn(r,t){return ar.compareSchemas(r,t)}function Fu(r,t){return ar.compareFields(r,t)}function Au(r,t){return ar.visit(r,t)}function yn(r){let t=r.type,e=new(Bu.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,c)=>n[c]||i:({name:o})=>n[o]||i;for(let[o,c]of t.children.entries()){let{type:l}=c,f=s(c,o);e.children.push(yn(Object.assign(Object.assign({},f),{type:l})))}}return e}function ko(r,t){return sy(r,t.map(e=>e.data.concat()))}function sy(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((B,A)=>Math.max(B,A.length),0)},s=0,o=0,c=-1,l=t.length,f,p=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,c=-1;++c<l;)p[c]=f=t[c].shift(),o=Math.min(o,f?f.length:o);Number.isFinite(o)&&(p=oy(e,o,p,t,i),o>0&&(n[s++]=ot({type:new Ut(e),length:o,nullCount:0,children:p.slice()})))}return[r=r.assign(e),n.map(B=>new Ht(r,B))]}function oy(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let c=-1,l=n.length;++c<l;){let f=e[c],p=f==null?void 0:f.length;if(p>=t)p===t?e[c]=f:(e[c]=f.slice(0,t),i.numBatches=Math.max(i.numBatches,n[c].unshift(f.slice(t,p-t))));else{let B=r[c];r[c]=B.clone({nullable:!0}),e[c]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:ot({type:B.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var xu,oe=class r{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new It([]),this._offsets=[0],this;let i,s;t[0]instanceof It&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=l=>{if(l){if(l instanceof Ht)return[l];if(l instanceof r)return l.batches;if(l instanceof gt){if(l.type instanceof Ut)return[new Ht(new It(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(f=>o(f));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(f=>o(f));if(typeof l=="object"){let f=Object.keys(l),p=f.map(E=>new pt([l[E]])),B=i!=null?i:new It(f.map((E,X)=>new dt(String(E),p[X].type,p[X].nullable))),[,A]=ko(B,p);return A.length===0?[new Ht(l)]:A}}}return[]},c=t.flatMap(l=>o(l));if(i=(n=i!=null?i:(e=c[0])===null||e===void 0?void 0:e.schema)!==null&&n!==void 0?n:new It([]),!(i instanceof It))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of c){if(!(l instanceof Ht))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!wn(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=c,this._offsets=s!=null?s:ao(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=oo(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(cn(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?$n.visit(new pt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return"[\n ".concat(this.toArray().join(",\n "),"\n]")}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new r(e,n.map(i=>new Ht(e,i)))}slice(t,e){let n=this.schema;[t,e]=xi({length:this.numRows},t,e);let i=co(this.data,this._offsets,t,e);return new r(n,i.map(s=>new Ht(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=ot({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new pt(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new pt([ot({type:new ie,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),c=this.schema.fields.map((l,f)=>this.getChildAt(f));[s[t],c[t]]=[o,e],[n,i]=ko(n,c)}return new r(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new r(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((c,l,f)=>{let[p,B]=c,A=e.findIndex(E=>E.name===l.name);return~A?B[A]=f:p.push(f),c},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((c,l)=>[l,i[l]]).map(([c,l])=>l===void 0?this.getChildAt(c):t.getChildAt(l)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new r(...ko(s,o))}};xu=Symbol.toStringTag;oe[xu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Wn(Oi),r.get=Wn(zt.getVisitFn(h.Struct)),r.set=lo(Zt.getVisitFn(h.Struct)),r.indexOf=uo(fn.getVisitFn(h.Struct)),"Table"))(oe.prototype);var Eu,Ht=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof It))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=ot({nullCount:0,type:new Ut(this.schema.fields),children:this.schema.fields.map(e=>ot({type:e.type,nullCount:0}))})]=t,!(this.data instanceof gt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Tu(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((l,f,p)=>(l.children[p]=e[f],l.length=Math.max(l.length,e[f].length),l.fields[p]=dt.new({name:f,type:e[f].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new It(n),c=ot({type:new Ut(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Tu(o,c.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=Ou(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 zt.visit(this.data,t)}at(t){return this.get(cn(t,this.numRows))}set(t,e){return Zt.visit(this.data,t,e)}indexOf(t,e){return fn.visit(this.data,t,e)}[Symbol.iterator](){return $n.visit(new pt([this.data]))}toArray(){return[...this]}concat(...t){return new oe(this.schema,[this,...t])}slice(t,e){let[n]=new pt([this.data]).slice(t,e).data;return new r(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new pt([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new pt([ot({type:new ie,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),c=s[t].clone({type:e.type});[s[t],o[t]]=[c,e.data[0]],n=new It(s,new Map(this.schema.metadata)),i=ot({type:new Ut(s),children:o})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Ut(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(c=>c.name===s);~o&&(i[o]=this.data.children[o])}return new r(e,ot({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=ot({type:new Ut(e.fields),length:this.numRows,children:n});return new r(e,i)}};Eu=Symbol.toStringTag;Ht[Eu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ht.prototype);function Tu(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[c,l]of r.fields.entries()){let f=t[c];(!f||f.length!==e)&&(i[c]=l.clone({nullable:!0}),s[c]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:ot({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),ot({type:new Ut(i),length:e,children:s})]}function Ou(r,t,e=new Map){var n,i;if(((n=r==null?void 0:r.length)!==null&&n!==void 0?n:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:c}=r[s],l=t[s];for(let f of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Ou(c.children,f==null?void 0:f.children,e);if(L.isDictionary(c)){let{id:f}=c;if(!e.has(f))l!=null&&l.dictionary&&e.set(f,l.dictionary);else if(e.get(f)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var vn=class extends Ht{constructor(t){let e=t.fields.map(i=>ot({type:i.type})),n=ot({type:new Ut(t.fields),nullCount:0,children:e});super(t,n)}};var Ye=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__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):vt.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ht.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Yt).__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,e){t.addFieldInt16(0,e,vt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,ht.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var nc=class extends W{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Si.startNull(e),Si.endNull(e)}visitInt(t,e){return Ne.startInt(e),Ne.addBitWidth(e,t.bitWidth),Ne.addIsSigned(e,t.isSigned),Ne.endInt(e)}visitFloat(t,e){return Wr.startFloatingPoint(e),Wr.addPrecision(e,t.precision),Wr.endFloatingPoint(e)}visitBinary(t,e){return _i.startBinary(e),_i.endBinary(e)}visitLargeBinary(t,e){return gi.startLargeBinary(e),gi.endLargeBinary(e)}visitBool(t,e){return bi.startBool(e),bi.endBool(e)}visitUtf8(t,e){return Di.startUtf8(e),Di.endUtf8(e)}visitLargeUtf8(t,e){return wi.startLargeUtf8(e),wi.endLargeUtf8(e)}visitDecimal(t,e){return rr.startDecimal(e),rr.addScale(e,t.scale),rr.addPrecision(e,t.precision),rr.addBitWidth(e,t.bitWidth),rr.endDecimal(e)}visitDate(t,e){return Vr.startDate(e),Vr.addUnit(e,t.unit),Vr.endDate(e)}visitTime(t,e){return dr.startTime(e),dr.addUnit(e,t.unit),dr.addBitWidth(e,t.bitWidth),dr.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return fr.startTimestamp(e),fr.addUnit(e,t.unit),n!==void 0&&fr.addTimezone(e,n),fr.endTimestamp(e)}visitInterval(t,e){return $r.startInterval(e),$r.addUnit(e,t.unit),$r.endInterval(e)}visitDuration(t,e){return Hr.startDuration(e),Hr.addUnit(e,t.unit),Hr.endDuration(e)}visitList(t,e){return vi.startList(e),vi.endList(e)}visitStruct(t,e){return Ii.startStruct_(e),Ii.endStruct_(e)}visitUnion(t,e){ke.startTypeIdsVector(e,t.typeIds.length);let n=ke.createTypeIdsVector(e,t.typeIds);return ke.startUnion(e),ke.addMode(e,t.mode),ke.addTypeIds(e,n),ke.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return er.startDictionaryEncoding(e),er.addId(e,BigInt(t.id)),er.addIsOrdered(e,t.isOrdered),n!==void 0&&er.addIndexType(e,n),er.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return zr.startFixedSizeBinary(e),zr.addByteWidth(e,t.byteWidth),zr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return jr.startFixedSizeList(e),jr.addListSize(e,t.listSize),jr.endFixedSizeList(e)}visitMap(t,e){return Yr.startMap(e),Yr.addKeysSorted(e,t.keysSorted),Yr.endMap(e)}},Co=new nc;function Lu(r,t=new Map){return new It(cy(r,t),Po(r.metadata),t)}function ic(r){return new Qt(r.count,ku(r.columns),Cu(r.columns))}function Nu(r){return new ue(ic(r.data),r.id,r.isDelta)}function cy(r,t){return(r.fields||[]).filter(Boolean).map(e=>dt.fromJSON(e,t))}function Uu(r,t){return(r.children||[]).filter(Boolean).map(e=>dt.fromJSON(e,t))}function ku(r){return(r||[]).reduce((t,e)=>[...t,new Ae(e.count,ly(e.VALIDITY)),...ku(e.children)],[])}function Cu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new le(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new le(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new le(t.length,i.OFFSET.length)),i.DATA&&t.push(new le(t.length,i.DATA.length)),t=Cu(i.children,t)}return t}function ly(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Pu(r,t){let e,n,i,s,o,c;return!t||!(s=r.dictionary)?(o=Ru(r,Uu(r,t)),i=new dt(r.name,o,r.nullable,Po(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?Mu(n):new nr,c=new _e(t.get(e),n,e,s.isOrdered),i=new dt(r.name,c,r.nullable,Po(r.metadata))):(n=(n=s.indexType)?Mu(n):new nr,t.set(e,o=Ru(r,Uu(r,t))),c=new _e(o,n,e,s.isOrdered),i=new dt(r.name,c,r.nullable,Po(r.metadata))),i||null}function Po(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Mu(r){return new Gt(r.isSigned,r.bitWidth)}function Ru(r,t){let e=r.type.name;switch(e){case"NONE":return new ie;case"null":return new ie;case"binary":return new hr;case"largebinary":return new pr;case"utf8":return new mr;case"largeutf8":return new yr;case"bool":return new _r;case"list":return new Ve((t||[])[0]);case"struct":return new Ut(t||[]);case"struct_":return new Ut(t||[])}switch(e){case"int":{let n=r.type;return new Gt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new De(At[n.precision])}case"decimal":{let n=r.type;return new br(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new gr(Vt[n.unit])}case"time":{let n=r.type;return new wr(k[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new vr(k[n.unit],n.timezone)}case"interval":{let n=r.type;return new Sr($t[n.unit])}case"duration":{let n=r.type;return new Ir(k[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new He(xt[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Dr(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new ze(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new je((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var uy=an,dy=me,de=class r{static fromJSON(t,e){let n=new r(0,vt.V5,e);return n._createHeader=fy(t,e),n}static decode(t){t=new dy(tt(t));let e=Ye.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new r(n,i,s);return o._createHeader=hy(e,s),o}static encode(t){let e=new uy,n=-1;return t.isSchema()?n=It.encode(e,t.header()):t.isRecordBatch()?n=Qt.encode(e,t.header()):t.isDictionaryBatch()&&(n=ue.encode(e,t.header())),Ye.startMessage(e),Ye.addVersion(e,vt.V5),Ye.addHeader(e,n),Ye.addHeaderType(e,t.headerType),Ye.addBodyLength(e,BigInt(t.bodyLength)),Ye.finishMessageBuffer(e,Ye.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof It)return new r(0,vt.V5,ht.Schema,t);if(t instanceof Qt)return new r(e,vt.V5,ht.RecordBatch,t);if(t instanceof ue)return new r(e,vt.V5,ht.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===ht.Schema}isRecordBatch(){return this.headerType===ht.RecordBatch}isDictionaryBatch(){return this.headerType===ht.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=yt(t)}},Qt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=yt(t)}},ue=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(t,e,n=!1){this._data=t,this._isDelta=n,this._id=yt(e)}},le=class{constructor(t,e){this.offset=yt(t),this.length=yt(e)}},Ae=class{constructor(t,e){this.length=yt(t),this.nullCount=yt(e)}};function fy(r,t){return()=>{switch(t){case ht.Schema:return It.fromJSON(r);case ht.RecordBatch:return Qt.fromJSON(r);case ht.DictionaryBatch:return ue.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(ht[t],", type: ").concat(t," }"))}}function hy(r,t){return()=>{switch(t){case ht.Schema:return It.decode(r.header(new ae),new Map,r.version());case ht.RecordBatch:return Qt.decode(r.header(new ye),r.version());case ht.DictionaryBatch:return ue.decode(r.header(new ur),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(ht[t],", type: ").concat(t," }"))}}dt.encode=Dy;dt.decode=Sy;dt.fromJSON=Pu;It.encode=Iy;It.decode=py;It.fromJSON=Lu;Qt.encode=By;Qt.decode=my;Qt.fromJSON=ic;ue.encode=Fy;ue.decode=yy;ue.fromJSON=Nu;Ae.encode=Ay;Ae.decode=by;le.encode=xy;le.decode=_y;function py(r,t=new Map,e=vt.V5){let n=vy(r,t);return new It(n,Vo(r),t,e)}function my(r,t=vt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Qt(r.length(),gy(r),wy(r,t))}function yy(r,t=vt.V5){return new ue(Qt.decode(r.data(),t),r.id(),r.isDelta())}function _y(r){return new le(r.offset(),r.length())}function by(r){return new Ae(r.length(),r.nullCount())}function gy(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Ae.decode(e));return t}function wy(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<vt.V4&&(n.bb_pos+=8*(i+1)),e[++s]=le.decode(n));return e}function vy(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=dt.decode(n,t));return e}function Vu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=dt.decode(n,t));return e}function Sy(r,t){let e,n,i,s,o,c;return!t||!(c=r.dictionary())?(i=zu(r,Vu(r,t)),n=new dt(r.name(),i,r.nullable(),Vo(r))):t.has(e=yt(c.id()))?(s=(s=c.indexType())?Hu(s):new nr,o=new _e(t.get(e),s,e,c.isOrdered()),n=new dt(r.name(),o,r.nullable(),Vo(r))):(s=(s=c.indexType())?Hu(s):new nr,t.set(e,i=zu(r,Vu(r,t))),o=new _e(i,s,e,c.isOrdered()),n=new dt(r.name(),o,r.nullable(),Vo(r))),n||null}function Vo(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function Hu(r){return new Gt(r.isSigned(),r.bitWidth())}function zu(r,t){let e=r.typeType();switch(e){case Tt.NONE:return new ie;case Tt.Null:return new ie;case Tt.Binary:return new hr;case Tt.LargeBinary:return new pr;case Tt.Utf8:return new mr;case Tt.LargeUtf8:return new yr;case Tt.Bool:return new _r;case Tt.List:return new Ve((t||[])[0]);case Tt.Struct_:return new Ut(t||[])}switch(e){case Tt.Int:{let n=r.type(new Ne);return new Gt(n.isSigned(),n.bitWidth())}case Tt.FloatingPoint:{let n=r.type(new Wr);return new De(n.precision())}case Tt.Decimal:{let n=r.type(new rr);return new br(n.scale(),n.precision(),n.bitWidth())}case Tt.Date:{let n=r.type(new Vr);return new gr(n.unit())}case Tt.Time:{let n=r.type(new dr);return new wr(n.unit(),n.bitWidth())}case Tt.Timestamp:{let n=r.type(new fr);return new vr(n.unit(),n.timezone())}case Tt.Interval:{let n=r.type(new $r);return new Sr(n.unit())}case Tt.Duration:{let n=r.type(new Hr);return new Ir(n.unit())}case Tt.Union:{let n=r.type(new ke);return new He(n.mode(),n.typeIdsArray()||[],t||[])}case Tt.FixedSizeBinary:{let n=r.type(new zr);return new Dr(n.byteWidth())}case Tt.FixedSizeList:{let n=r.type(new jr);return new ze(n.listSize(),(t||[])[0])}case Tt.Map:{let n=r.type(new Yr);return new je((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(Tt[e],'" (').concat(e,")"))}function Iy(r,t){let e=t.fields.map(s=>dt.encode(r,s));ae.startFieldsVector(r,e.length);let n=ae.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ae.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let c=r.createString("".concat(s)),l=r.createString("".concat(o));return Yt.startKeyValue(r),Yt.addKey(r,c),Yt.addValue(r,l),Yt.endKeyValue(r)})):-1;return ae.startSchema(r),ae.addFields(r,n),ae.addEndianness(r,Ty?Pr.Little:Pr.Big),i!==-1&&ae.addCustomMetadata(r,i),ae.endSchema(r)}function Dy(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;L.isDictionary(s)?(o=s.dictionary.typeId,i=Co.visit(s,r),n=Co.visit(s.dictionary,r)):n=Co.visit(s,r);let c=(s.children||[]).map(p=>dt.encode(r,p)),l=ee.createChildrenVector(r,c),f=t.metadata&&t.metadata.size>0?ee.createCustomMetadataVector(r,[...t.metadata].map(([p,B])=>{let A=r.createString("".concat(p)),E=r.createString("".concat(B));return Yt.startKeyValue(r),Yt.addKey(r,A),Yt.addValue(r,E),Yt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),ee.startField(r),ee.addType(r,n),ee.addTypeType(r,o),ee.addChildren(r,l),ee.addNullable(r,!!t.nullable),e!==-1&&ee.addName(r,e),i!==-1&&ee.addDictionary(r,i),f!==-1&&ee.addCustomMetadata(r,f),ee.endField(r)}function By(r,t){let e=t.nodes||[],n=t.buffers||[];ye.startNodesVector(r,e.length);for(let o of e.slice().reverse())Ae.encode(r,o);let i=r.endVector();ye.startBuffersVector(r,n.length);for(let o of n.slice().reverse())le.encode(r,o);let s=r.endVector();return ye.startRecordBatch(r),ye.addLength(r,BigInt(t.length)),ye.addNodes(r,i),ye.addBuffers(r,s),ye.endRecordBatch(r)}function Fy(r,t){let e=Qt.encode(r,t.data);return ur.startDictionaryBatch(r),ur.addId(r,BigInt(t.id)),ur.addIsDelta(r,t.isDelta),ur.addData(r,e),ur.endDictionaryBatch(r)}function Ay(r,t){return Ln.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function xy(r,t){return Rn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Ty=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var oc=r=>"Expected ".concat(ht[r]," Message in stream, but was null or length 0."),ac=r=>"Header pointer of flatbuffer-encoded ".concat(ht[r]," Message is null or length 0."),ju=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),Wu=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),Qn=class{constructor(t){this.source=t instanceof or?t:new or(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Mt:t.value===-1&&(t=this.readMetadataLength()).done?Mt:(t=this.readMetadata(t.value)).done?Mt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(oc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=tt(this.source.read(t));if(e.byteLength<t)throw new Error(Wu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=ht.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ac(e));return i}readMetadataLength(){let t=this.source.read(Ho),e=t&&new me(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return Mt;if(e.byteLength<t)throw new Error(ju(t,e.byteLength));return{done:!1,value:de.decode(e)}}},os=class{constructor(t,e){this.source=t instanceof Be?t:gs(t)?new Xr(t,e):new Be(t)}[Symbol.asyncIterator](){return this}next(){return R(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?Mt:t.value===-1&&(t=yield this.readMetadataLength()).done?Mt:(t=yield this.readMetadata(t.value)).done?Mt:t})}throw(t){return R(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return R(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return R(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(oc(t));return e.value})}readMessageBody(t){return R(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=tt(yield this.source.read(t));if(e.byteLength<t)throw new Error(Wu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return R(this,arguments,void 0,function*(t=!1){let e=ht.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ac(e));return i})}readMetadataLength(){return R(this,void 0,void 0,function*(){let t=yield this.source.read(Ho),e=t&&new me(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(t){return R(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return Mt;if(e.byteLength<t)throw new Error(ju(t,e.byteLength));return{done:!1,value:de.decode(e)}})}},as=class extends Qn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Ui?t:new Ui(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:de.fromJSON(t.schema,ht.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:de.fromJSON(e,ht.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:de.fromJSON(e,ht.RecordBatch)}}return this._body=[],Mt}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(oc(t));return e.value}readSchema(){let t=ht.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(ac(t));return n}},Ho=4,sc="ARROW1",ti=new Uint8Array(sc.length);for(let r=0;r<sc.length;r+=1)ti[r]=sc.codePointAt(r);function zo(r,t=0){for(let e=-1,n=ti.length;++e<n;)if(ti[e]!==r[t+e])return!1;return!0}var ei=ti.length,cc=ei+Ho,$u=ei*2+Ho;var te=class r extends pn{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return Ue(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Xt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Xt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:_s(t)?Oy(t):gs(t)?Ry(t):Ue(t)?R(this,void 0,void 0,function*(){return yield r.from(yield t)}):ws(t)||di(t)||Ss(t)||ve(t)?My(new Be(t)):Uy(new or(t))}static readAll(t){return t instanceof r?t.isSync()?Yu(t):Gu(t):_s(t)||ArrayBuffer.isView(t)||Me(t)||bs(t)?Yu(t):Gu(t)}},cr=class extends te{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return he(this,arguments,function*(){yield lt(yield*sn(Un(Oe(this[Symbol.iterator]()))))})}},Zr=class extends te{constructor(t){super(t),this._impl=t}readAll(){return R(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,c=Oe(this),l;l=yield c.next(),t=l.done,!t;o=!0){i=l.value,o=!1;let f=i;s.push(f)}}catch(f){e={error:f}}finally{try{!o&&!t&&(n=c.return)&&(yield n.call(c))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Qr=class extends cr{constructor(t){super(t),this._impl=t}},cs=class extends Zr{constructor(t){super(t),this._impl=t}},jo=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=ot({type:new Ut(this.schema.fields),length:t.length,children:n});return new Ht(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,c=s.get(n),l=o.dictionaries.get(n),f=this._loadVectors(t.data,e,[l]);return(c&&i?c.concat(new pt(f)):new pt(f)).memoize()}_loadVectors(t,e,n){return new Ni(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},ri=class extends jo{constructor(t,e){super(e),this._reader=_s(t)?new as(this._handle=t):new Qn(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=qu(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Mt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Mt}next(){if(this.closed)return Mt;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ni=class extends jo{constructor(t,e){super(e),this._reader=new os(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return R(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return R(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=qu(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Mt})}return(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Mt})}next(){return R(this,void 0,void 0,function*(){if(this.closed)return Mt;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return R(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Wo=class extends ri{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof Mi?t:new Mi(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(ht.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(ht.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}}_readFooter(){let{_handle:t}=this,e=t.size-cc,n=t.readInt32(e),i=t.readAt(e-n,n);return Ar.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},lc=class extends ni{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Xr?t:new Xr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return R(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return R(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(ht.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return R(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(ht.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}})}_readFooter(){return R(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-cc,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Ar.decode(i)})}_readNextMessageAndValidate(t){return R(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},uc=class extends ri{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new mo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function qu(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Yu(r){let t=te.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Gu(r){return he(this,arguments,function*(){let e=yield lt(te.from(r));try{if(!(yield lt(e.open({autoDestroy:!1}))).closed)do yield yield lt(e);while(!(yield lt(e.reset().open())).closed)}finally{yield lt(e.cancel())}})}function Oy(r){return new cr(new uc(r))}function Uy(r){let t=r.peek(ei+7&-8);return t&&t.byteLength>=4?zo(t)?new Qr(new Wo(r.read())):new cr(new ri(r)):new cr(new ri(function*(){}()))}function My(r){return R(this,void 0,void 0,function*(){let t=yield r.peek(ei+7&-8);return t&&t.byteLength>=4?zo(t)?new Qr(new Wo(yield r.read())):new Zr(new ni(r)):new Zr(new ni(function(){return he(this,arguments,function*(){})}()))})}function Ry(r){return R(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Xr(r,t);return t>=$u&&zo(yield e.readAt(0,ei+7&-8))?new cs(new lc(e)):new Zr(new ni(e))})}var Nt=class r extends W{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Ht?s.data.children:s.data),n=new r;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof pt)return this.visitMany(t.data),this;let{type:e}=t;if(!L.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(L.isUnion(e))this.nodes.push(new Ae(n,0));else{let{nullCount:i}=t;L.isNull(e)||Ge.call(this,i<=0?new Uint8Array(0):un(t.offset,n,t.nullBitmap)),this.nodes.push(new Ae(n,i))}}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 Ge(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new le(this._byteLength,t)),this._byteLength+=t,this}function Ly(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ge.call(this,i),e.mode===xt.Sparse)return dc.call(this,r);if(e.mode===xt.Dense){if(r.offset<=0)return Ge.call(this,s),dc.call(this,r);{let o=new Int32Array(n),c=Object.create(null),l=Object.create(null);for(let f,p,B=-1;++B<n;)(f=i[B])!==void 0&&((p=c[f])===void 0&&(p=c[f]=s[B]),o[B]=s[B]-p,l[f]=((t=l[f])!==null&&t!==void 0?t:0)+1);Ge.call(this,o),this.visitMany(r.children.map((f,p)=>{let B=e.typeIds[p],A=c[B],E=l[B];return f.slice(A,Math.min(n,E))}))}}return this}function Ny(r){let t;return r.nullCount>=r.length?Ge.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ge.call(this,un(r.offset,r.length,t)):Ge.call(this,dn(r.values))}function Lr(r){return Ge.call(this,r.values.subarray(0,r.length*r.stride))}function $o(r){let{length:t,values:e,valueOffsets:n}=r,i=yt(n[0]),s=yt(n[t]),o=Math.min(s-i,e.byteLength-i);return Ge.call(this,Ds(-i,t+1,n)),Ge.call(this,e.subarray(i,i+o)),this}function fc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ge.call(this,Ds(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function dc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Nt.prototype.visitBool=Ny;Nt.prototype.visitInt=Lr;Nt.prototype.visitFloat=Lr;Nt.prototype.visitUtf8=$o;Nt.prototype.visitLargeUtf8=$o;Nt.prototype.visitBinary=$o;Nt.prototype.visitLargeBinary=$o;Nt.prototype.visitFixedSizeBinary=Lr;Nt.prototype.visitDate=Lr;Nt.prototype.visitTimestamp=Lr;Nt.prototype.visitTime=Lr;Nt.prototype.visitDecimal=Lr;Nt.prototype.visitList=fc;Nt.prototype.visitStruct=dc;Nt.prototype.visitUnion=Ly;Nt.prototype.visitInterval=Lr;Nt.prototype.visitDuration=Lr;Nt.prototype.visitFixedSizeList=fc;Nt.prototype.visitMap=fc;var Sn=class extends pn{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new sr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ne(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Ue(t)?t.then(e=>this.writeAll(e)):ve(t)?pc(this,t):hc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof sr?this._sink=t:(this._sink=new sr,t&&ul(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&dl(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!wn(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof oe&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ht&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!wn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ht?t instanceof vn||this._writeRecordBatch(t):t instanceof oe?this.writeAll(t.batches):Me(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=de.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,c=s+o+n&~n,l=c-s-o;return t.headerType===ht.RecordBatch?this._recordBatchBlocks.push(new xr(c,t.bodyLength,this._position)):t.headerType===ht.DictionaryBatch&&this._dictionaryBlocks.push(new xr(c,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(c-o)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){let e=tt(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(de.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(ti)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=Nt.assemble(t),o=new Qt(t.numRows,n,i),c=de.from(o,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:c}=Nt.assemble(new pt([t])),l=new Qt(t.length,s,o),f=new ue(l,e,n),p=de.from(f,i);return this._writeMessage(p)._writeBodyBuffers(c)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,n;for(let[i,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],c=this._seenDictionaries.get(i),l=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!c||c.data[0]!==o[0])for(let[f,p]of o.entries())this._writeDictionaryBatch(p,i,f>0);else if(l<o.length)for(let f of o.slice(l))this._writeDictionaryBatch(f,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},In=class r extends Sn{static writeAll(t,e){let n=new r(e);return Ue(t)?t.then(i=>n.writeAll(i)):ve(t)?pc(n,t):hc(n,t)}},Dn=class r extends Sn{static writeAll(t){let e=new r;return Ue(t)?t.then(n=>e.writeAll(n)):ve(t)?pc(e,t):hc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=Ar.encode(new Ar(t,vt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function hc(r,t){let e=t;t instanceof oe&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function pc(r,t){return R(this,void 0,void 0,function*(){var e,n,i,s,o,c,l;try{for(e=!0,n=Oe(t);i=yield n.next(),s=i.done,!s;e=!0){l=i.value,e=!1;let f=l;r.write(f)}}catch(f){o={error:f}}finally{try{!e&&!s&&(c=n.return)&&(yield c.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Ku(r,t){if(ve(r))return Cy(r,t);if(Me(r))return ky(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function ky(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,c){let l,f=null,p=o.desiredSize||null;for(;!(f=c.next(n?p:null)).done;)if(ArrayBuffer.isView(f.value)&&(l=tt(f.value))&&(p!=null&&n&&(p=p-l.byteLength+1),f.value=l),o.enqueue(f.value),p!=null&&--p<=0)return;o.close()}}function Cy(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return R(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return R(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return R(this,void 0,void 0,function*(){(e!=null&&e.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,c){return R(this,void 0,void 0,function*(){let l,f=null,p=o.desiredSize||null;for(;!(f=yield c.next(n?p:null)).done;)if(ArrayBuffer.isView(f.value)&&(l=tt(f.value))&&(p!=null&&n&&(p=p-l.byteLength+1),f.value=l),o.enqueue(f.value),p!=null&&--p<=0)return;o.close()})}}function Zu(r){return new mc(r)}var mc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=cl(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=yn(s),this._getSize=i!=="bytes"?Ju:Xu;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:c=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ju:Xu}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:c,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Ju=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Xu=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function Yo(r,t){let e=new sr,n=null,i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield e.close()})},start(c){return R(this,void 0,void 0,function*(){yield o(c,n||(n=yield s()))})},pull(c){return R(this,void 0,void 0,function*(){n?yield o(c,n):c.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return R(this,void 0,void 0,function*(){return yield(yield te.from(e)).open(t)})}function o(c,l){return R(this,void 0,void 0,function*(){let f=c.desiredSize,p=null;for(;!(p=yield l.next()).done;)if(c.enqueue(p.value),f!=null&&--f<=0)return;c.close()})}}function Go(r,t){let e=new this(r),n=new Be(e),i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return R(this,void 0,void 0,function*(){yield s(o)})},start(o){return R(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return R(this,void 0,void 0,function*(){let c=null,l=o.desiredSize;for(;c=yield n.read(l||null);)if(o.enqueue(c),l!=null&&(l-=c.byteLength)<=0)return;o.close()})}}function qo(r,t="stream"){return(t==="stream"?In:Dn).writeAll(r).toUint8Array(!0)}var zy=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Aa),Za),ja),xa),wa),za),Ia),{compareSchemas:wn,compareFields:Fu,compareTypes:Au});Xt.toDOMStream=Ku;Rt.throughDOM=Zu;te.throughDOM=Yo;Qr.throughDOM=Yo;cr.throughDOM=Yo;Sn.throughDOM=Go;Dn.throughDOM=Go;In.throughDOM=Go;function ii(r){switch(r.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=r;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:ii(r.valueType)};case h.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case h.Null:return{sqlType:"null"};case h.Utf8:return{sqlType:"utf8"};case h.Struct:return{sqlType:"struct",fields:r.children.map(e=>Ko(e.name,e.type))};case h.Map:{let t=r;return{sqlType:"map",keyType:ii(t.keyType),valueType:ii(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:r.timezone||void 0};case h.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case h.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case h.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case h.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function Ko(r,t){let e=ii(t);return e.name=r,e}var Jo=class{constructor(t,e){this._bindings=t,this._conn=e}close(){this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}query(t){let e=this._bindings.runQuery(this._conn,t),n=te.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new oe(n)}async send(t,e=!1){let n=this._bindings.startPendingQuery(this._conn,t,e);for(;n==null;)n=await new Promise((o,c)=>{try{o(this._bindings.pollPendingQuery(this._conn))}catch(l){console.log(l),l.message.includes("worker is not set!")?c(new Error("Worker has been terminated")):c(l)}});let i=new Xo(this._bindings,this._conn,n),s=te.from(i);return console.assert(s.isSync()),console.assert(s.isStream()),s}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(t){return this._bindings.getTableNames(this._conn,t)}prepare(t){let e=this._bindings.createPrepared(this._conn,t);return new yc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=qo(t,"stream");this.insertArrowFromIPCStream(n,e)}insertArrowFromIPCStream(t,e){this._bindings.insertArrowFromIPCStream(this._conn,t,e)}insertCSVFromPath(t,e){this._bindings.insertCSVFromPath(this._conn,t,e)}insertJSONFromPath(t,e){this._bindings.insertJSONFromPath(this._conn,t,e)}},Xo=class{constructor(t,e,n){this.bindings=t;this.conn=e;this.header=n;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 t=null;do t=this.bindings.fetchQueryResults(this.conn);while(t==null);return this._depleted=t.length==0,{done:this._depleted,value:t}}[Symbol.iterator](){return this}},yc=class{constructor(t,e,n){this.bindings=t,this.connectionId=e,this.statementId=n}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...t){let e=this.bindings.runPrepared(this.connectionId,this.statementId,t),n=te.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new oe(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new Xo(this.bindings,this.connectionId,e),i=te.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function td(r){return r<=255}function ed(r){return r===256}var id=new TextEncoder,rd=new TextDecoder("utf-8");function _c(r,t,e){let n=id.encode(e),i=r._malloc(n.byteLength),s=r.HEAPU8.subarray(i,i+n.byteLength);s.set(n),r.HEAPF64[(t>>3)+0]=1,r.HEAPF64[(t>>3)+1]=i,r.HEAPF64[(t>>3)+2]=s.byteLength}function gc(r){switch(r){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 bc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*gc(e));switch(e){case"UINT8":return new Uint8Array(i.buffer,i.byteOffset,n);case"INT8":return new Int8Array(i.buffer,i.byteOffset,n);case"INT32":return new Int32Array(i.buffer,i.byteOffset,n);case"FLOAT":return new Float32Array(i.buffer,i.byteOffset,n);case"DOUBLE":return new Float64Array(i.buffer,i.byteOffset,n);case"VARCHAR":return new Float64Array(i.buffer,i.byteOffset,n);default:return new Array(0)}}function nd(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function Zo(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function sd(r,t,e,n,i,s,o,c){try{let l=r._udfFunctions.get(n);if(!l){_c(t,e,"Unknown UDF with id: "+n);return}let f=rd.decode(t.HEAPU8.subarray(i,i+s)),p=JSON.parse(f),B=Zo(t,o,c/8),A=D=>{var x;let N=null;switch(D.validityBuffer!==void 0&&(N=nd(t,B[D.validityBuffer],p.rows)),D.physicalType){case"VARCHAR":{if(D.dataBuffer===null||D.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(D.lengthBuffer===null||D.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let j=bc(t,B[D.dataBuffer],D.physicalType,p.rows),I=[],H=Zo(t,B[D.lengthBuffer],p.rows);for(let Z=0;Z<p.rows;++Z){if(N!=null&&!N[Z]){I.push(null);continue}let T=t.HEAPU8.subarray(j[Z],j[Z]+H[Z]),mt=rd.decode(T);I.push(mt)}return Z=>I[Z]}case"STRUCT":{let j={},I=[];for(let H=0;H<(((x=D.children)==null?void 0:x.length)||0);++H){let Z=D.children[H],T=A(Z);I.push(mt=>{j[Z.name]=T(mt)})}return N!=null?H=>{if(!N[H])return null;for(let Z of I)Z(H);return j}:H=>{for(let Z of I)Z(H);return j}}default:{if(D.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+D.physicalType);let j=bc(t,B[D.dataBuffer],D.physicalType,p.rows);return N!=null?I=>N[I]?j[I]:null:I=>j[I]}}},E=[];for(let D=0;D<p.args.length;++D)E.push(A(p.args[D]));let X=p.rows*gc(p.ret.physicalType),Ft=t._malloc(X),Pt=bc(t,Ft,p.ret.physicalType,p.rows),Lt=t._malloc(p.rows),Bt=nd(t,Lt,p.rows);if(Pt.length==0||Bt.length==0){_c(t,e,"Can't create physical arrays for result");return}let wt=Pt;p.ret.physicalType=="VARCHAR"&&(wt=new Array(p.rows));let qt=[];for(let D=0;D<p.args.length;++D)qt.push(null);for(let D=0;D<p.rows;++D){for(let x=0;x<p.args.length;++x)qt[x]=E[x](D);let N=l.func(...qt);wt[D]=N,Bt[D]=N==null?0:1}let Kt=0;switch(p.ret.physicalType){case"VARCHAR":{let D=new Array(0);Kt=t._malloc(p.rows*gc("DOUBLE"));let N=Zo(t,Kt,p.rows),x=0;for(let Z=0;Z<p.rows;++Z){let T=id.encode(wt[Z]||"");D.push(T),N[Z]=T.length,x+=T.length}let j=t._malloc(x),I=t.HEAPU8.subarray(j,j+x),H=0;for(let Z=0;Z<p.rows;++Z){Pt[Z]=H;let T=D[Z];I.subarray(H,H+T.length).set(T),H+=T.length}}}let w=3*8,M=t._malloc(w),V=Zo(t,M,3);V[0]=Ft,V[1]=Lt,V[2]=Kt,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=M,t.HEAPF64[(e>>3)+2]=0}catch(l){_c(t,e,l.toString())}}function Wy(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var $y=Wy();function qe(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Bn(r,t,e){let n=r.HEAPU8.subarray(t,t+e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function ct(r,t,e){return $y(r.HEAPU8.subarray(t,t+e))}function Dt(r,t,e,n){let i=r.stackSave(),s=r.stackAlloc(3*8);e.unshift("number"),n.unshift(s),r.ccall(t,null,e,n);let o=r.HEAPF64[(s>>3)+0],c=r.HEAPF64[(s>>3)+1],l=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[o,c,l]}function Et(r){r.ccall("duckdb_web_clear_response",null,[],[])}var Qo=class{constructor(t){let e=new Float64Array(t.buffer,t.byteOffset,t.byteLength/8),n=new Uint8Array(new ArrayBuffer(t.byteLength));n.set(t.subarray(7*8)),this.totalFileReadsCold=e[0],this.totalFileReadsAhead=e[1],this.totalFileReadsCached=e[2],this.totalFileWrites=e[3],this.totalPageAccesses=e[4],this.totalPageLoads=e[5],this.blockSize=e[6],this.blockStats=n}getBlockStats(t,e){return e=e||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},e.file_writes=this.blockStats[t*3+0]&15,e.file_reads_cold=this.blockStats[t*3+0]>>4,e.file_reads_ahead=this.blockStats[t*3+1]&15,e.file_reads_cached=this.blockStats[t*3+1]>>4,e.page_accesses=this.blockStats[t*3+1]&15,e.page_loads=this.blockStats[t*3+1]>>4,e}};var si=new TextEncoder;var ta=class{constructor(t,e){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=t,this._runtime=e,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(t=e=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(t),await this._initPromise),this._initPromise=new Promise(e=>{this._initPromiseResolver=e}),this.onInstantiationProgress=[t],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(e=>e!=t),globalThis.DUCKDB_BINDINGS=this,this)}open(t){let[e,n,i]=Dt(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(ct(this.mod,n,i));Et(this.mod)}reset(){let[t,e,n]=Dt(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(ct(this.mod,e,n));Et(this.mod)}getVersion(){let[t,e,n]=Dt(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(ct(this.mod,e,n));let i=ct(this.mod,e,n);return Et(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=si.encode(t),n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,o,c]=Dt(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(ct(this.mod,o,c));let l=ct(this.mod,o,c);return Et(this.mod),JSON.parse(l)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Jo(this,t)}disconnect(t){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[t]),this.pthread)for(let e of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])e.postMessage({cmd:"dropUDFFunctions",connectionId:t})}runQuery(t,e){let n=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));let f=Bn(this.mod,c,l);return Et(this.mod),f}startPendingQuery(t,e,n=!1){let i=si.encode(e),s=this.mod._malloc(i.length);this.mod.HEAPU8.subarray(s,s+i.length).set(i);let[c,l,f]=Dt(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[t,s,i.length,n]);if(this.mod._free(s),c!==0)throw new Error(ct(this.mod,l,f));if(l==0)return null;let p=Bn(this.mod,l,f);return Et(this.mod),p}pollPendingQuery(t){let[e,n,i]=Dt(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));if(n==0)return null;let s=Bn(this.mod,n,i);return Et(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=Dt(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(ed(e))return Et(this.mod),null;if(!td(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+ct(this.mod,n,i));if(e!==0)throw new Error(ct(this.mod,n,i));let s=Bn(this.mod,n,i);return Et(this.mod),s}getTableNames(t,e){let n=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));let f=ct(this.mod,c,l);return Et(this.mod),JSON.parse(f)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:ii(n)},o={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[c,l,f]=Dt(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(c!==0)throw new Error(ct(this.mod,l,f));if(Et(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(o.functionId,o),this.pthread)for(let p of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])p.postMessage({cmd:"registerUDFFunction",udf:o})}createPrepared(t,e){let n=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));return Et(this.mod),c}closePrepared(t,e){let[n,i,s]=Dt(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s));Et(this.mod)}runPrepared(t,e,n){let[i,s,o]=Dt(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(ct(this.mod,s,o));let c=Bn(this.mod,s,o);return Et(this.mod),c}sendPrepared(t,e,n){let[i,s,o]=Dt(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(ct(this.mod,s,o));let c=Bn(this.mod,s,o);return Et(this.mod),c}insertArrowFromIPCStream(t,e,n){if(e.length==0)return;let i=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(i,i+e.length).set(e);let o=n?JSON.stringify(n):"",[c,l,f]=Dt(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,o]);if(this.mod._free(i),c!==0)throw new Error(ct(this.mod,l,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(Ko(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,l]=Dt(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(ct(this.mod,c,l))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(Ko(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,l]=Dt(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(ct(this.mod,c,l))}globFiles(t){let[e,n,i]=Dt(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));let s=ct(this.mod,n,i);Et(this.mod);let o=JSON.parse(s);return o==null?[]:o}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(ct(this.mod,o,c));Et(this.mod)}registerFileText(t,e){let n=si.encode(e);this.registerFileBuffer(t,n)}registerFileBuffer(t,e){let n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(ct(this.mod,o,c));Et(this.mod)}async prepareFileHandle(t,e){if(e===3&&this._runtime.prepareFileHandles){let n=await this._runtime.prepareFileHandles([t],3);for(let i of n){let{handle:s,path:o,fromCached:c}=i;!c&&await this.registerFileHandleAsync(o,s,3,!0)}return}throw new Error("prepareFileHandle: unsupported protocol ".concat(e))}async prepareDBFileHandle(t,e){if(e===3&&this._runtime.prepareDBFileHandle){let n=await this._runtime.prepareDBFileHandle(t,3);for(let i of n){let{handle:s,path:o,fromCached:c}=i;!c&&await this.registerFileHandleAsync(o,s,3,!0)}return}throw new Error("prepareDBFileHandle: unsupported protocol ".concat(e))}async prepareFileHandleAsync(t,e,n,i){if(n===3&&!(e instanceof FileSystemSyncAccessHandle)){if(e instanceof FileSystemFileHandle){let s=e;try{e=await s.createSyncAccessHandle()}catch(o){throw new Error(o.message+":"+t)}}else if(t!=null)try{e=await(await(await navigator.storage.getDirectory()).getFileHandle(t)).createSyncAccessHandle()}catch(s){throw new Error(s.message+":"+t)}}return e}async registerFileHandleAsync(t,e,n,i){let s=await this.prepareFileHandleAsync(t,e,n,i);this.registerFileHandle(t,s,n,i)}registerFileHandle(t,e,n,i){var l;let[s,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(ct(this.mod,o,c));/*PATCH_C1*/if(t.startsWith("opfs://")){let _alt="opfs:/"+t.slice(7);Dt(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[_alt,_alt,n,i])}if(Et(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),t.startsWith("opfs://")&&globalThis.DUCKDB_RUNTIME._files.set("opfs:/"+t.slice(7),e),(l=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&l[t]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[t],this.pthread){/*PATCH_D*/try{for(let f of this.pthread.runningWorkers)f.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e})}catch(_e){};for(let f of this.pthread.unusedWorkers)f.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=Dt(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));Et(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let c of t!=null?t:[])if(c!=null&&c.length>0){let l=this.mod.lengthBytesUTF8(c)+1,f=this.mod._malloc(l);if(!f)throw new Error("Failed to allocate memory for string: ".concat(c));this.mod.stringToUTF8(c,f,l),e.push(f)}if(n=this.mod._malloc(e.length*4),!n)throw new Error("Failed to allocate memory for pointers array");for(let c=0;c<e.length;c++)this.mod.HEAP32[(n>>2)+c]=e[c];let[i,s,o]=Dt(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(ct(this.mod,s,o));Et(this.mod)}finally{for(let i of e)this.mod._free(i);n>0&&this.mod._free(n)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(t,e){let[n,i,s]=Dt(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s));Et(this.mod)}copyFileToBuffer(t){let[e,n,i]=Dt(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));let s=this.mod.HEAPU8.subarray(n,n+i),o=new Uint8Array(s.length);return o.set(s),Et(this.mod),o}async registerOPFSFileName(t){if(t.startsWith("opfs://"))return this.prepareFileHandle(t,3);throw new Error("Not an OPFS file name: "+t)}collectFileStatistics(t,e){let[n,i,s]=Dt(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=Dt(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));return new Qo(this.mod.HEAPU8.subarray(n,n+i))}};var ea=class{constructor(){this._bindings=null;this._nextMessageId=0}log(t){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:t},[])}sendOK(t){this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"OK",data:null},[])}failWith(t,e){let n={name:e.name,message:e.message,stack:e.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"ERROR",data:n},[])}async onMessage(t){switch(t.type){case"PING":this.sendOK(t);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(t,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(t.data[0],t.data[1],e=>{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"INSTANTIATE_PROGRESS",data:e},[])}),this.sendOK(t)}catch(e){console.log(e),this._bindings=null,this.failWith(t,e)}return;default:break}if(!this._bindings)return this.failWith(t,new Error("duckdb is not initialized"));try{switch(t.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(t);break;case"OPEN":{let e=t.data.path;e!=null&&e.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(e,3),t.data.useDirectIO=!0),this._bindings.open(t.data),this.sendOK(t);break}case"DROP_FILE":this._bindings.dropFile(t.data),this.sendOK(t);break;case"DROP_FILES":this._bindings.dropFiles(t.data),this.sendOK(t);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(t);break;case"CONNECT":{let e=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"CONNECTION_INFO",data:e.useUnsafe((n,i)=>i)},[]);break}case"DISCONNECT":this._bindings.disconnect(t.data),this.sendOK(t);break;case"CREATE_PREPARED":{let e=this._bindings.createPrepared(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"PREPARED_STATEMENT_ID",data:e},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(t.data[0],t.data[1]),this.sendOK(t);break}case"RUN_PREPARED":{let e=this._bindings.runPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"RUN_QUERY":{let e=this._bindings.runQuery(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"SEND_PREPARED":{let e=this._bindings.sendPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER",data:e},[e.buffer]);break}case"START_PENDING_QUERY":{let e=this._bindings.startPendingQuery(t.data[0],t.data[1],t.data[2]),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"POLL_PENDING_QUERY":{let e=this._bindings.pollPendingQuery(t.data),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"CANCEL_PENDING_QUERY":{let e=this._bindings.cancelPendingQuery(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SUCCESS",data:e},[]);break}case"FETCH_QUERY_RESULTS":{let e=this._bindings.fetchQueryResults(t.data),n=e?[e.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_CHUNK",data:e},n);break}case"GET_TABLE_NAMES":{let e=this._bindings.getTableNames(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"TABLE_NAMES",data:e},[]);break}case"GLOB_FILE_INFOS":{let e=this._bindings.globFiles(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_INFOS",data:e},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(t.data[0],t.data[1]),this.sendOK(t);break;case"COPY_FILE_TO_BUFFER":{let e=this._bindings.copyFileToBuffer(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_BUFFER",data:e},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(t.data[0]),this.sendOK(t);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(t.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"TOKENIZE":{let e=this._bindings.tokenize(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SCRIPT_TOKENS",data:e},[]);break}}}catch(e){return console.log(e),this.failWith(t,e)}}};var dd=ol(ud());var ra=class extends ta{constructor(t,e,n,i){super(t,e),this.mainModuleURL=n,this.pthreadWorkerURL=i}locateFile(t,e){if(t.endsWith(".wasm"))return this.mainModuleURL;if(t.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(e," path=").concat(t))}instantiateWasm(t,e){globalThis.DUCKDB_RUNTIME=this._runtime;let n=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let s=(async()=>{var X;let o=new Request(this.mainModuleURL),c=await fetch(o),l=c.headers.get("content-length"),f=l&&parseInt(l,10)||0,p=new Date,B={startedAt:p,updatedAt:p,bytesTotal:f||0,bytesLoaded:0},A={transform(Ft,Pt){B.bytesLoaded+=Ft.byteLength;let Lt=new Date;if(Lt.getTime()-B.updatedAt.getTime()<20){B.updatedAt=Lt,Pt.enqueue(Ft);return}for(let Bt of n)Bt(B);Pt.enqueue(Ft)}},E=new TransformStream(A);return new Response((X=c.body)==null?void 0:X.pipeThrough(E),c)})();WebAssembly.instantiateStreaming(s,t).then(o=>{e(o.instance,o.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let i=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(i),t).then(s=>{e(s.instance,s.module)})}else if(typeof XMLHttpRequest=="function"){let i=new XMLHttpRequest,s=this.mainModuleURL,o=new Date,c={startedAt:o,updatedAt:o,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=l=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+l}),new Error(l.toString())},i.onprogress=l=>{c.bytesTotal=l.total,c.bytesLoaded=l.loaded;let f=new Date;if(f.getTime()-c.updatedAt.getTime()<20){c.updatedAt=f;return}for(let p of n)p(c)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(l=>{e(l.instance,l.module)}).catch(l=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+l}),new Error(l)})},i.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let s=new Request(this.mainModuleURL),c=await(await fetch(s)).arrayBuffer();WebAssembly.instantiate(c,t).then(l=>{e(l.instance,l.module)})})();return[]}};var na=class extends ra{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return(0,dd.default)({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var tn=ol(pd()),md=function(r,t,e){var n;return(n=r==null?void 0:r.endpoint)!=null&&n.startsWith("http")?new URL(r.endpoint).host:r!=null&&r.endpoint?"".concat(e,".").concat(r==null?void 0:r.endpoint):"".concat(e,".s3.amazonaws.com")};function Gy(r,t,e){var s,o,c,l;let n=yd(t),i=n.path;if(_d(r)){let f="";if(r!=null&&r.endpoint){let p=new URL(r.endpoint);p.pathname!=="/"&&(f=p.pathname)}i="".concat(f,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:md(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(o=r==null?void 0:r.accessKeyId)!=null?o:"",secretAccessKey:(c=r==null?void 0:r.secretAccessKey)!=null?c:"",sessionToken:(l=r==null?void 0:r.sessionToken)!=null?l:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function qy(r,t=!1){let e="0123456789ABCDEF",n="";for(let i=0;i<r.length;i++){let s=r[i];s>="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+=e[s.charCodeAt(0)>>4],n+=e[s.charCodeAt(0)&15])}return n}function Ky(r,t=null){var X;let e=(X=t==null?void 0:t.contentHash)!=null?X:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n=new Map;n.set("x-amz-date",r.datetimeNow),n.set("x-amz-content-sha256",e),r.sessionToken&&n.set("x-amz-security-token",r.sessionToken);let i="";t!=null&&t.contentType&&(i+="content-type;"),i+="host;x-amz-content-sha256;x-amz-date",r.sessionToken&&(i+=";x-amz-security-token");let s=r.method+"\n"+qy(r.url)+"\n"+r.query;t!=null&&t.contentType&&(s+="\ncontent-type:"+(t==null?void 0:t.contentType)),s+="\nhost:"+r.host+"\nx-amz-content-sha256:"+e+"\nx-amz-date:"+r.datetimeNow,r.sessionToken&&r.sessionToken.length>0&&(s+="\nx-amz-security-token:"+r.sessionToken),s+="\n\n"+i+"\n"+e;let o=(0,tn.sha256)(s),c="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+o,l="AWS4"+r.secretAccessKey,f=tn.sha256.hmac.arrayBuffer(l,r.dateNow),p=tn.sha256.hmac.arrayBuffer(f,r.region),B=tn.sha256.hmac.arrayBuffer(p,r.service),A=tn.sha256.hmac.arrayBuffer(B,"aws4_request"),E=tn.sha256.hmac(A,c);return n.set("Authorization","AWS4-HMAC-SHA256 Credential="+r.accessKeyId+"/"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request, SignedHeaders="+i+", Signature="+E),n}var Jy=function(r,t,e,n=null,i=null){let s=Gy(r,t,e),o={contentType:n,contentHash:i?tn.sha256.hex(i):null};return Ky(s,o)};function Ke(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(Jy(t,e,n,i,s).forEach((c,l)=>{r.setRequestHeader(l,c)}),i&&r.setRequestHeader("content-type",i))}function yd(r){if(r.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let t=r.indexOf("/",5);if(t==-1)throw new Error("URL needs to contain a '/' after the host");let e=r.substring(5,t);if(!e)throw new Error("URL needs to contain a bucket name");let n=r.substring(t);if(!n)throw new Error("URL needs to contain key");return{bucket:e,path:n}}function _d(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function Je(r,t){let e=yd(t);return _d(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+md(r,t,e.bucket)+e.path}var Xy=7,bd=/\/|\\/,nt={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=nt._fileInfoCache.get(t),[n,i,s]=Dt(r,"duckdb_web_fs_get_file_info_by_id",["number","number"],[t,(e==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(s===0)return e;let o=ct(r,i,s);Et(r);try{let c=JSON.parse(o);if(c==null)return null;let l={...c,blob:null};return nt._fileInfoCache.set(t,l),!nt._files.has(l.fileName)&&(nt._preparedHandles[l.fileName]?(nt._files.set(l.fileName,nt._preparedHandles[l.fileName]),delete nt._preparedHandles[l.fileName]):l.fileName.startsWith("opfs:/")&&!l.fileName.startsWith("opfs://")&&nt._preparedHandles["opfs://"+l.fileName.slice(6)]&&(nt._files.set(l.fileName,nt._preparedHandles["opfs://"+l.fileName.slice(6)]),delete nt._preparedHandles["opfs://"+l.fileName.slice(6)])),l}catch(c){return console.warn(c),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=Dt(r,"duckdb_web_get_global_file_info",["number"],[((t=nt._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return nt._globalFileInfo;let s=ct(r,n,i);Et(r);let o=JSON.parse(s);return o==null?null:(nt._globalFileInfo={...o,blob:null},nt._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){nt._opfsRoot||(nt._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await nt.assignOPFSRoot();let e=async i=>{if(nt._files.has(i))return{path:i,handle:nt._files.get(i),fromCached:!0};let o=nt._opfsRoot,c=i.slice(Xy),l=c;if(bd.test(c)){let p=c.split(bd);if(p.length===0)throw new Error("Invalid path ".concat(c));if(l=p[p.length-1],!l)throw new Error("Invalid path ".concat(c,". File Not Found."));p.pop();for(let B of p)o=await o.getDirectoryHandle(B,{create:!0})}let f=await o.getFileHandle(l,{create:!1}).catch(p=>{if((p==null?void 0:p.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),o.getFileHandle(l,{create:!0});throw p});try{let p=await f.createSyncAccessHandle();return nt._preparedHandles[i]=p,/*PATCH_A*/i.startsWith("opfs://")&&(nt._preparedHandles["opfs:/"+i.slice(7)]=p),{path:i,handle:p,fromCached:!1}}catch(p){throw new Error(p.message+":"+name)}},n=[];for(let i of r){let s=await e(i);n.push(s)}return n}throw new Error("Unsupported protocol ".concat(t," for paths ").concat(r," with protocol ").concat(t))},async prepareDBFileHandle(r,t){if(t===3&&this.prepareFileHandles){let e=[r,"".concat(r,".wal")];return this.prepareFileHandles(e,t)}throw new Error("Unsupported protocol ".concat(t," for path ").concat(r," with protocol ").concat(t))},testPlatformFeature:(r,t)=>{switch(t){case 1:return typeof BigInt64Array<"u";default:return console.warn("test for unknown feature: ".concat(t)),!1}},getDefaultDataProtocol(r){return 2},openFile:(r,t,e)=>{var n,i,s,o,c,l;try{nt._fileInfoCache.delete(t);let f=nt.getFileInfo(r,t);switch(f==null?void 0:f.dataProtocol){case 4:case 5:{if(e&1&&e&2)throw new Error("Opening file ".concat(f.fileName," failed: cannot open file with both read and write flags set"));if(e&32)throw new Error("Opening file ".concat(f.fileName," failed: appending to HTTP/S3 files is not supported"));if(e&2){let A=new XMLHttpRequest;if(f.dataProtocol==5?(A.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.send(null),A.status!=200&&A.status!=404)throw new Error("Opening file ".concat(f.fileName," failed: Unexpected return status from server (").concat(A.status,")"));if(A.status==404&&!(e&8||e&16))throw new Error("Opening file ".concat(f.fileName," failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag."));let E=r._malloc(1),X=new Uint8Array;r.HEAPU8.set(X,E);let Ft=r._malloc(3*8);return r.HEAPF64[(Ft>>3)+0]=1,r.HEAPF64[(Ft>>3)+1]=E,r.HEAPF64[(Ft>>3)+2]=new Date().getTime()/1e3,Ft}else if(!(e&1))throw new Error("Opening file ".concat(f.fileName," failed: unsupported file flags: ").concat(e));let p=null,B=null;if(!f.forceFullHttpReads&&(f.reliableHeadRequests||!f.allowFullHttpReads))try{let A=new XMLHttpRequest;f.dataProtocol==5?(A.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.setRequestHeader("Range","bytes=0-"),A.send(null),p=null;try{p=A.getResponseHeader("Content-Length")}catch(E){console.warn("Failed to get Content-Length on request")}if(p!==null&&A.status==206){let E=r._malloc(24);r.HEAPF64[(E>>3)+0]=+p,r.HEAPF64[(E>>3)+1]=0;let X=0;try{X=new Date((n=A.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(Ft){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(E>>3)+2]=+X,E}}catch(A){B=A,console.warn("HEAD request with range header failed: ".concat(A))}if(f.allowFullHttpReads){if(!f.forceFullHttpReads){let E=new XMLHttpRequest;f.dataProtocol==5?(E.open("GET",Je(f.s3Config,f.dataUrl),!1),Ke(E,f.s3Config,f.dataUrl,"GET")):E.open("GET",f.dataUrl,!1),E.responseType="arraybuffer",E.setRequestHeader("Range","bytes=0-0"),E.send(null);let X=null;try{X=E.getResponseHeader("Content-Length")}catch(Bt){console.warn("Failed to get Content-Length on request")}let Ft=X==null?void 0:X.split("/")[1],Pt=X,Lt=null;if(Ft!==void 0)Lt=Ft;else if(!f.reliableHeadRequests){let Bt=new XMLHttpRequest;f.dataProtocol==5?(Bt.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(Bt,f.s3Config,f.dataUrl,"HEAD")):Bt.open("HEAD",f.dataUrl,!1),Bt.setRequestHeader("Range","bytes=0-"),Bt.send(null),p=null;try{p=Bt.getResponseHeader("Content-Length")}catch(wt){console.warn("Failed to get Content-Length on request")}p!==null&&+p>1&&(Lt=p)}if(E.status==206&&Pt!==null&&+Pt==1&&Lt!==null){let Bt=r._malloc(24);r.HEAPF64[(Bt>>3)+0]=+Lt,r.HEAPF64[(Bt>>3)+1]=0;let wt=0;try{wt=new Date((i=E.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(qt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Bt>>3)+2]=+wt,Bt}if(E.status==200&&Pt!==null&&p!==null&&+Pt==+p){console.warn("fall back to full HTTP read for: ".concat(f.dataUrl));let Bt=r._malloc(E.response.byteLength),wt=new Uint8Array(E.response,0,E.response.byteLength);r.HEAPU8.set(wt,Bt);let qt=r._malloc(3*8);r.HEAPF64[(qt>>3)+0]=E.response.byteLength,r.HEAPF64[(qt>>3)+1]=Bt;let Kt=0;try{Kt=new Date((s=E.getResponseHeader("Last-Modified"))!=null?s:"").getTime()/1e3}catch(w){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(qt>>3)+2]=+Kt,qt}console.warn("falling back to full HTTP read for: ".concat(f.dataUrl))}let A=new XMLHttpRequest;if(f.dataProtocol==5?(A.open("GET",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"GET")):A.open("GET",f.dataUrl,!1),A.responseType="arraybuffer",A.send(null),A.status==200){let E=r._malloc(A.response.byteLength),X=new Uint8Array(A.response,0,A.response.byteLength);r.HEAPU8.set(X,E);let Ft=r._malloc(3*8);r.HEAPF64[(Ft>>3)+0]=A.response.byteLength,r.HEAPF64[(Ft>>3)+1]=E;let Pt=0;try{Pt=new Date((o=A.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch(Lt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Ft>>3)+2]=+Pt,Ft}}if(B!=null)throw new Error("Reading file ".concat(f.fileName," failed with error: ").concat(B));return 0}case 2:{let p=(c=nt._files)==null?void 0:c.get(f.fileName);if(p){let E=r._malloc(24);return r.HEAPF64[(E>>3)+0]=p.size,r.HEAPF64[(E>>3)+1]=0,r.HEAPF64[(E>>3)+2]=0,E}if(e&128)return 0;console.warn("Buffering missing file: ".concat(f.fileName));let B=r._malloc(3*8),A=r._malloc(1);return r.HEAPF64[(B>>3)+0]=1,r.HEAPF64[(B>>3)+1]=A,r.HEAPF64[(B>>3)+2]=0,B}case 3:{let p=(l=nt._files)==null?void 0:l.get(f.fileName);if(!p)throw new Error("No OPFS access handle registered with name: ".concat(f.fileName));e&16&&p.truncate(0);let B=r._malloc(3*8),A=p.getSize();return r.HEAPF64[(B>>3)+0]=A,r.HEAPF64[(B>>3)+1]=0,r.HEAPF64[(B>>3)+2]=0,B}}}catch(f){console.error(f.toString()),qe(r,f.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=ct(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let o=nt.getGlobalFileInfo(r);s.open("HEAD",Je(o==null?void 0:o.s3Config,i),!1),Ke(s,o==null?void 0:o.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=nt.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let o=new XMLHttpRequest;if(i.startsWith("s3://")){let l=nt.getGlobalFileInfo(r);o.open("GET",Je(l==null?void 0:l.s3Config,i),!1),Ke(o,l==null?void 0:l.s3Config,i,"HEAD")}else o.open("GET",i,!1);if(o.setRequestHeader("Range","bytes=0-0"),o.send(null),o.status!=200&&o.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let c=null;try{c=o.getResponseHeader("Content-Length")}catch(l){console.warn("Failed to get Content-Length on request")}c&&+c>1&&console.warn("Range request for ".concat(i," did not return a partial response: ").concat(o.status,' "').concat(o.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of nt._files.entries()||[])s.startsWith(i)&&r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[s])}catch(i){return console.log(i),qe(r,i.toString()),0}},checkFile:(r,t,e)=>{try{let n=ct(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=nt.getGlobalFileInfo(r);i.open("HEAD",Je(s==null?void 0:s.s3Config,n),!1),Ke(i,s==null?void 0:s.s3Config,n,"HEAD")}else i.open("HEAD",n,!1);return i.send(null),i.status==206||i.status==200}else return nt._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=nt.getFileInfo(r,t);nt._fileInfoCache.delete(t);try{switch(e==null?void 0:e.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let i=(n=nt._files)==null?void 0:n.get(e.fileName);if(!i)throw new Error("No OPFS access handle registered with name: ".concat(e.fileName));return i.flush()}}}catch(i){console.log(i),qe(r,i.toString())}},dropFile:(r,t,e)=>{var s;let n=ct(r,t,e),i=(s=nt._files)==null?void 0:s.get(n);if(i){if(nt._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(o){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=nt.getFileInfo(r,t);switch(n==null?void 0:n.dataProtocol){case 4:qe(r,"Cannot truncate a http file");return;case 5:qe(r,"Cannot truncate an s3 file");return;case 0:case 1:case 2:qe(r,"truncateFile not implemented");return;case 3:{let s=(i=nt._files)==null?void 0:i.get(n.fileName);if(!s)throw new Error("No OPFS access handle registered with name: ".concat(n.fileName));return s.truncate(e)}}return 0},readFile(r,t,e,n,i){var s;if(n==0)return 0;try{let o=nt.getFileInfo(r,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 c=new XMLHttpRequest;if(o.dataProtocol==5?(c.open("GET",Je(o==null?void 0:o.s3Config,o.dataUrl),!1),Ke(c,o==null?void 0:o.s3Config,o.dataUrl,"GET")):c.open("GET",o.dataUrl,!1),c.responseType="arraybuffer",c.setRequestHeader("Range","bytes=".concat(i,"-").concat(i+n-1)),c.send(null),c.status==206||c.status==200&&n==c.response.byteLength&&i==0){let l=new Uint8Array(c.response,0,Math.min(c.response.byteLength,n));return r.HEAPU8.set(l,e),l.byteLength}else if(c.status==200){console.warn("Range request for ".concat(o.dataUrl," did not return a partial response: ").concat(c.status,' "').concat(c.statusText,'"'));let l=new Uint8Array(c.response,i,Math.min(c.response.byteLength-i,n));return r.HEAPU8.set(l,e),l.byteLength}else throw new Error("Range request for ".concat(o.dataUrl," did returned non-success status: ").concat(c.status,' "').concat(c.statusText,'"'))}catch(c){throw console.log(c),new Error("Range request for ".concat(o.dataUrl," failed with error: ").concat(c,'"'))}}case 2:{let c=(s=nt._files)==null?void 0:s.get(o.fileName);if(!c)throw new Error("No HTML5 file registered with name: ".concat(o.fileName));let l=c.slice(i,i+n),f=new Uint8Array(new FileReaderSync().readAsArrayBuffer(l));return r.HEAPU8.set(f,e),f.byteLength}case 3:{let c=nt._files.get(o.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(o.fileName));let l=r.HEAPU8.subarray(e,e+n);return c.read(l,{at:i})}}return 0}catch(o){return console.log(o),qe(r,o.toString()),0}},writeFile:(r,t,e,n,i)=>{var o;let s=nt.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return qe(r,"Cannot write to HTTP file"),0;case 5:{let c=r.HEAPU8.subarray(e,e+n),l=new XMLHttpRequest;return l.open("PUT",Je(s==null?void 0:s.s3Config,s.dataUrl),!1),Ke(l,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",c),l.send(c),l.status!==200?(qe(r,"Failed writing file: HTTP "+l.status),0):n}case 2:return qe(r,"cannot write using the html5 file reader api"),0;case 3:{let c=(o=nt._files)==null?void 0:o.get(s.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let l=r.HEAPU8.subarray(e,e+n);return c.write(l,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=nt.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=nt._files)==null?void 0:n.get(e.fileName)))throw Error("No handle available for file: ".concat(e.fileName));return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(r,t,e)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:r?"completed":"in-progress",percentage:t,repetitions:e}})},checkDirectory:(r,t,e)=>{let n=ct(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=ct(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=ct(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=ct(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var l,f;let s=ct(r,t,e),o=ct(r,n,i),c=(l=nt._files)==null?void 0:l.get(s);c!==void 0&&(nt._files.delete(c),nt._files.set(o,c));for(let[p,B]of((f=nt._fileInfoCache)==null?void 0:f.entries())||[])if(B.dataUrl==s){nt._fileInfoCache.delete(p);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,o)=>{sd(nt,r,t,e,n,i,s,o)}};var vc=class extends ea{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new na(this,nt,t,e).instantiate(n)}};function gd(){let r=new vc;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}gd();return Sp(Zy);})();
1
+ "use strict";var duckdb=(()=>{var uh=Object.create;var ai=Object.defineProperty;var dh=Object.getOwnPropertyDescriptor;var fh=Object.getOwnPropertyNames;var hh=Object.getPrototypeOf,ph=Object.prototype.hasOwnProperty;var aa=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var mh=(r,t,e)=>t in r?ai(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Vc=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Fn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Pr=(r,t)=>{for(var e in t)ai(r,e,{get:t[e],enumerable:!0})},Hc=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of fh(t))!ph.call(r,i)&&i!==e&&ai(r,i,{get:()=>t[i],enumerable:!(n=dh(t,i))||n.enumerable});return r};var zc=(r,t,e)=>(e=r!=null?uh(hh(r)):{},Hc(t||!r||!r.__esModule?ai(e,"default",{value:r,enumerable:!0}):e,r)),yh=r=>Hc(ai({},"__esModule",{value:!0}),r);var jc=(r,t,e)=>(mh(r,typeof t!="symbol"?t+"":t,e),e);var _h=function(r,t){this[0]=r,this[1]=t};var nn=r=>{var t=r[aa("asyncIterator")],e=!1,n,i={};return t==null?(t=r[aa("iterator")](),n=s=>i[s]=o=>t[s](o)):(t=t.call(r),n=s=>i[s]=o=>{if(e){if(e=!1,s==="throw")throw o;return o}return e=!0,{done:!1,value:new _h(new Promise(a=>{var c=t[s](o);if(!(c instanceof Object))throw TypeError("Object expected");a(c)}),1)}}),i[aa("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var ju=Fn(()=>{});var Wu=Fn(()=>{});var Gu=Fn(($u,Jo)=>{"use strict";var hc=(()=>{var t;var r=typeof document<"u"?(t=document.currentScript)==null?void 0:t.src:void 0;return typeof __filename<"u"&&(r=r||__filename),async function(e={}){var n,i=e,s,o,a=new Promise((l,u)=>{s=l,o=u}),c=typeof window=="object",d=typeof WorkerGlobalScope<"u",p=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",S=Object.assign({},i),A=[],x="./this.program",ot=(l,u)=>{throw u},lt="";function Pt(l){return i.locateFile?i.locateFile(l,lt):lt+l}var Ot,Bt;if(p){var bt=ju(),Qt=Wu();lt=__dirname+"/",Bt=l=>{l=De(l)?new URL(l):l;var u=bt.readFileSync(l);return u},Ot=async(l,u=!0)=>{l=De(l)?new URL(l):l;var f=bt.readFileSync(l,u?void 0:"utf8");return f},!i.thisProgram&&process.argv.length>1&&(x=process.argv[1].replace(/\\/g,"/")),A=process.argv.slice(2),ot=(l,u)=>{throw process.exitCode=l,u}}else(c||d)&&(d?lt=self.location.href:typeof document<"u"&&document.currentScript&&(lt=document.currentScript.src),r&&(lt=r),lt.startsWith("blob:")?lt="":lt=lt.slice(0,lt.replace(/[?#].*/,"").lastIndexOf("/")+1),d&&(Bt=l=>{var u=new XMLHttpRequest;return u.open("GET",l,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}),Ot=async l=>{var u=await fetch(l,{credentials:"same-origin"});if(u.ok)return u.arrayBuffer();throw new Error(u.status+" : "+u.url)});var Gt=i.print||console.log.bind(console),_=i.printErr||console.error.bind(console);Object.assign(i,S),S=null,i.arguments&&(A=i.arguments),i.thisProgram&&(x=i.thisProgram);var E=i.wasmBinary,k,w=!1,R;function F(l,u){l||qe(u)}var H,g,C,q,T,pt,Ke,mt,Be=!1,De=l=>l.startsWith("file://");function Lr(){var l=k.buffer;i.HEAP8=H=new Int8Array(l),i.HEAP16=C=new Int16Array(l),i.HEAPU8=g=new Uint8Array(l),i.HEAPU16=q=new Uint16Array(l),i.HEAP32=T=new Int32Array(l),i.HEAPU32=pt=new Uint32Array(l),i.HEAPF32=Ke=new Float32Array(l),i.HEAPF64=mt=new Float64Array(l)}function ei(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)pd(i.preRun.shift());yc(bc)}function ri(){Be=!0,P.ua()}function ni(){}function rd(){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)hd(i.postRun.shift());yc(_c)}var rn=0,ii=null;function nd(l){var u;rn++,(u=i.monitorRunDependencies)==null||u.call(i,rn)}function id(l){var f;if(rn--,(f=i.monitorRunDependencies)==null||f.call(i,rn),rn==0&&ii){var u=ii;ii=null,u()}}function qe(l){var f;(f=i.onAbort)==null||f.call(i,l),l="Aborted("+l+")",_(l),w=!0,l+=". Build with -sASSERTIONS for more info.",Be&&___trap();var u=new WebAssembly.RuntimeError(l);throw o(u),u}var si;function sd(){return Pt("./duckdb-eh.wasm")}function od(l){if(l==si&&E)return new Uint8Array(E);if(Bt)return Bt(l);throw"both async and sync fetching of the wasm failed"}async function ad(l){if(!E)try{var u=await Ot(l);return new Uint8Array(u)}catch(f){}return od(l)}async function cd(l,u){try{var f=await ad(l),m=await WebAssembly.instantiate(f,u);return m}catch(y){_("failed to asynchronously prepare wasm: ".concat(y)),qe(y)}}async function ld(l,u,f){if(!l&&typeof WebAssembly.instantiateStreaming=="function"&&!p)try{var m=fetch(u,{credentials:"same-origin"}),y=await WebAssembly.instantiateStreaming(m,f);return y}catch(b){_("wasm streaming compile failed: ".concat(b)),_("falling back to ArrayBuffer instantiation")}return cd(u,f)}function ud(){return{a:eh}}async function dd(){function l(b,v){return P=b.exports,P=ch(P),k=P.ta,Lr(),id("wasm-instantiate"),P}nd("wasm-instantiate");function u(b){return l(b.instance)}var f=ud();if(i.instantiateWasm)return new Promise((b,v)=>{i.instantiateWasm(f,(I,U)=>{l(I,U),b(I.exports)})});si!=null||(si=sd());try{var m=await ld(E,si,f),y=u(m);return y}catch(b){return o(b),Promise.reject(b)}}var Kt,cr,fd={10168112:(l,u,f,m)=>{var y=gt(l);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(m),y,!1),b.responseType="arraybuffer";for(var v=0,B=u;v<B*2;){var I=T[f/4+v>>>0],U=T[f/4+v+1>>>0];try{var V=encodeURI(gt(I));V==="Host"&&(V="X-Host-Override"),V==="User-Agent"&&(V="X-user-agent"),V==="Authorization"?b.setRequestHeader(V,gt(U)):b.setRequestHeader(V,encodeURI(gt(U)))}catch(Lt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Lt)}v+=2}try{b.send(null)}catch(Lt){return 0}if(b.status>=400)return 0;for(var nt=b.response,B=nt.byteLength,ft=Cr(B+4),yt=new Uint8Array(nt),st=0;st<B;st++)i.HEAPU8[st+ft+4]=yt[st];var D=new Uint8Array(4);return D[0]=B%256,B-=D[0],B/=256,D[1]=B%256,B-=D[1],B/=256,D[2]=B%256,B-=D[2],B/=256,D[3]=B%256,B-=D[3],B/=256,i.HEAPU8.set(D,ft),ft},10169519:(l,u,f,m,y,b)=>{var v=gt(l);if(typeof XMLHttpRequest>"u")return 0;let I=new XMLHttpRequest;I.open(gt(m),v,!1),I.responseType="arraybuffer";for(var U=0,D=u;U<D*2;){var V=T[f/4+U>>>0],nt=T[f/4+U+1>>>0];try{var B=encodeURI(gt(V));B==="Host"&&(B="X-Host-Override"),B==="User-Agent"&&(B="X-user-agent"),B==="Authorization"?I.setRequestHeader(B,gt(nt)):I.setRequestHeader(B,encodeURI(gt(nt)))}catch(Ye){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ye)}U+=2}try{for(var ft=new Uint8Array(b),yt=0;yt<b;yt++)ft[yt]=i.HEAPU8[yt+y];I.send(ft)}catch(Ye){return 0}if(I.status>=400)return 0;for(var st=Uint8Array.from(Array.from(I.getResponseHeader("Etag")).map(Ye=>Ye.charCodeAt(0))),D=st.byteLength,Lt=Cr(D+4),Fe=new Uint8Array(st),yt=0;yt<D;yt++)i.HEAPU8[yt+Lt+4]=Fe[yt];var Ft=new Uint8Array(4);return Ft[0]=D%256,D-=Ft[0],D/=256,Ft[1]=D%256,D-=Ft[1],D/=256,Ft[2]=D%256,D-=Ft[2],D/=256,Ft[3]=D%256,D-=Ft[3],D/=256,i.HEAPU8.set(Ft,Lt),Lt},10171139:(l,u,f,m)=>{var y=gt(l);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(m),y,!1),b.responseType="arraybuffer";for(var v=0,B=u;v<B*2;){var I=T[f/4+v>>>0],U=T[f/4+v+1>>>0];console.log("HEAD",gt(I),gt(U));try{var V=encodeURI(gt(I));V==="Host"&&(V="X-Host-Override"),V==="User-Agent"&&(V="X-user-agent"),V==="Authorization"?b.setRequestHeader(V,gt(U)):b.setRequestHeader(V,encodeURI(gt(U)))}catch(Ft){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ft)}v+=2}try{b.send(null)}catch(Ft){return 0}if(b.status>=400)return 0;for(var nt=b.response,B=nt.byteLength,ft=Cr(B+8),yt=new Uint8Array(nt),st=0;st<B;st++)i.HEAPU8[st+ft+8]=yt[st];var D=new Uint8Array(4);D[0]=B%256,B-=D[0],B/=256,D[1]=B%256,B-=D[1],B/=256,D[2]=B%256,B-=D[2],B/=256,D[3]=B%256,B-=D[3],B/=256,i.HEAPU8.set(D,ft+4);var Lt=Uint8Array.from(Array.from(b.getAllResponseHeaders()).map(Ft=>Ft.charCodeAt(0)));B=Lt.byteLength;for(var Fe=Cr(B+8),st=0;st<B;st++)i.HEAPU8[st+Fe+8]=Lt[st];return D=new Uint8Array(4),D[0]=B%256,B-=D[0],B/=256,D[1]=B%256,B-=D[1],B/=256,D[2]=B%256,B-=D[2],B/=256,D[3]=B%256,B-=D[3],B/=256,i.HEAPU8.set(D,Fe+4),B=Fe,D=new Uint8Array(4),D[0]=B%256,B-=D[0],B/=256,D[1]=B%256,B-=D[1],B/=256,D[2]=B%256,B-=D[2],B/=256,D[3]=B%256,B-=D[3],B/=256,i.HEAPU8.set(D,ft),ft},10173484:(l,u,f,m)=>{var y=gt(l);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(m),y,!1),b.responseType="arraybuffer";for(var v=0,B=u;v<B*2;){var I=T[f/4+v>>>0],U=T[f/4+v+1>>>0];try{var V=encodeURI(gt(I));V==="Host"&&(V="X-Host-Override"),V==="User-Agent"&&(V="X-user-agent"),V==="Authorization"?b.setRequestHeader(V,gt(U)):b.setRequestHeader(V,encodeURI(gt(U)))}catch(Lt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Lt)}v+=2}try{b.send(null)}catch(Lt){return 0}if(b.status>=400)return 0;for(var nt=b.response,B=nt.byteLength,ft=Cr(B+4),yt=new Uint8Array(nt),st=0;st<B;st++)i.HEAPU8[st+ft+4]=yt[st];var D=new Uint8Array(4);return D[0]=B%256,B-=D[0],B/=256,D[1]=B%256,B-=D[1],B/=256,D[2]=B%256,B-=D[2],B/=256,D[3]=B%256,B-=D[3],B/=256,i.HEAPU8.set(D,ft),ft},10174891:(l,u,f,m,y,b)=>{var v=gt(l);if(typeof XMLHttpRequest>"u")return 0;let I=new XMLHttpRequest;I.open(gt(m),v,!1),I.responseType="arraybuffer";for(var U=0,D=u;U<D*2;){var V=T[f/4+U>>>0],nt=T[f/4+U+1>>>0];try{var B=encodeURI(gt(V));B==="Host"&&(B="X-Host-Override"),B==="User-Agent"&&(B="X-user-agent"),B==="Authorization"?I.setRequestHeader(B,gt(nt)):I.setRequestHeader(B,encodeURI(gt(nt)))}catch(Ye){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ye)}U+=2}try{for(var ft=new Uint8Array(b),yt=0;yt<b;yt++)ft[yt]=i.HEAPU8[yt+y];I.send(ft)}catch(Ye){return 0}if(I.status>=400)return 0;for(var st=I.response,D=st.byteLength,Lt=Cr(D+4),Fe=new Uint8Array(st),yt=0;yt<D;yt++)i.HEAPU8[yt+Lt+4]=Fe[yt];var Ft=new Uint8Array(4);return Ft[0]=D%256,D-=Ft[0],D/=256,Ft[1]=D%256,D-=Ft[1],D/=256,Ft[2]=D%256,D-=Ft[2],D/=256,Ft[3]=D%256,D-=Ft[3],D/=256,i.HEAPU8.set(Ft,Lt),Lt}};class mc{constructor(u){jc(this,"name","ExitStatus");this.message="Program terminated with exit(".concat(u,")"),this.status=u}}var yc=l=>{for(;l.length>0;)l.shift()(i)},_c=[],hd=l=>_c.unshift(l),bc=[],pd=l=>bc.unshift(l),md=i.noExitRuntime||!0;function gc(){qe("missing function: $SOCKFS")}gc.stub=!0;function ta(){qe("missing function: $FS")}ta.stub=!0;var Dn=l=>{var u=gc.getSocket(l);if(!u)throw new ta.ErrnoError(8);return u},ea=l=>(l&255)+"."+(l>>8&255)+"."+(l>>16&255)+"."+(l>>24&255),wc=l=>{var u="",f=0,m=0,y=0,b=0,v=0,I=0,U=[l[0]&65535,l[0]>>16,l[1]&65535,l[1]>>16,l[2]&65535,l[2]>>16,l[3]&65535,l[3]>>16],V=!0,nt="";for(I=0;I<5;I++)if(U[I]!==0){V=!1;break}if(V){if(nt=ea(U[6]|U[7]<<16),U[5]===-1)return u="::ffff:",u+=nt,u;if(U[5]===0)return u="::",nt==="0.0.0.0"&&(nt=""),nt==="0.0.0.1"&&(nt="1"),u+=nt,u}for(f=0;f<8;f++)U[f]===0&&(f-y>1&&(v=0),y=f,v++),v>m&&(m=v,b=f-m+1);for(f=0;f<8;f++){if(m>1&&U[f]===0&&f>=b&&f<b+m){f===b&&(u+=":",b===0&&(u+=":"));continue}u+=Number(_ntohs(U[f]&65535)).toString(16),u+=f<7?":":""}return u},vc=(l,u)=>{var f=C[l>>>1>>>0],m=_ntohs(q[l+2>>>1>>>0]),y;switch(f){case 2:if(u!==16)return{errno:28};y=T[l+4>>>2>>>0],y=ea(y);break;case 10:if(u!==28)return{errno:28};y=[T[l+8>>>2>>>0],T[l+12>>>2>>>0],T[l+16>>>2>>>0],T[l+20>>>2>>>0]],y=wc(y);break;default:return{errno:5}}return{family:f,addr:y,port:m}},as=l=>{for(var u=l.split("."),f=0;f<4;f++){var m=Number(u[f]);if(isNaN(m))return null;u[f]=m}return(u[0]|u[1]<<8|u[2]<<16|u[3]<<24)>>>0},cs=l=>parseInt(l),ra=l=>{var u,f,m,y,b=/^((?=.*::)(?!.*::.+::)(::)?([\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(!b.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"),":"),u=l.split(":"),u[u.length-4]=cs(u[u.length-4])+cs(u[u.length-3])*256,u[u.length-3]=cs(u[u.length-2])+cs(u[u.length-1])*256,u=u.slice(0,u.length-2)):u=l.split(":"),m=0,y=0,f=0;f<u.length;f++)if(typeof u[f]=="string")if(u[f]==="Z"){for(y=0;y<8-u.length+1;y++)v[f+y]=0;m=y-1}else v[f+m]=_htons(parseInt(u[f],16));else v[f+m]=u[f];return[v[1]<<16|v[0],v[3]<<16|v[2],v[5]<<16|v[4],v[7]<<16|v[6]]},le={address_map:{id:1,addrs:{},names:{}},lookup_name(l){var u=as(l);if(u!==null||(u=ra(l),u!==null))return l;var f;if(le.address_map.addrs[l])f=le.address_map.addrs[l];else{var m=le.address_map.id++;F(m<65535,"exceeded max address mappings of 65535"),f="172.29."+(m&255)+"."+(m&65280),le.address_map.names[f]=l,le.address_map.addrs[l]=f}return f},lookup_addr(l){return le.address_map.names[l]?le.address_map.names[l]:null}},Sc=(l,u)=>{var f=vc(l,u);if(f.errno)throw new ta.ErrnoError(f.errno);return f.addr=le.lookup_addr(f.addr)||f.addr,f},Nr=(l,u)=>u+2097152>>>0<4194305-!!l?(l>>>0)+u*4294967296:NaN;function yd(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Dn(l),I=Sc(u,f);return v.sock_ops.bind(v,I.addr,I.port),0}function _d(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Dn(l),I=Sc(u,f);return v.sock_ops.connect(v,I.addr,I.port),0}var bd=(l,u,f)=>{};function gd(l,u,f,m){u>>>=0}var Ic=typeof TextDecoder<"u"?new TextDecoder:void 0,Bc=(l,u=0,f=NaN)=>{u>>>=0;for(var m=u+f,y=u;l[y]&&!(y>=m);)++y;if(y-u>16&&l.buffer&&Ic)return Ic.decode(l.subarray(u,y));for(var b="";u<y;){var v=l[u++];if(!(v&128)){b+=String.fromCharCode(v);continue}var I=l[u++]&63;if((v&224)==192){b+=String.fromCharCode((v&31)<<6|I);continue}var U=l[u++]&63;if((v&240)==224?v=(v&15)<<12|I<<6|U:v=(v&7)<<18|I<<12|U<<6|l[u++]&63,v<65536)b+=String.fromCharCode(v);else{var V=v-65536;b+=String.fromCharCode(55296|V>>10,56320|V&1023)}}return b},gt=(l,u)=>(l>>>=0,l?Bc(g,l,u):""),na={varargs:void 0,getStr(l){var u=gt(l);return u}};function wd(l,u,f){return f>>>=0,na.varargs=f,0}function vd(l,u){u>>>=0}function Sd(l,u,f){var m=Nr(u,f)}var Dc=l=>{for(var u=0,f=0;f<l.length;++f){var m=l.charCodeAt(f);m<=127?u++:m<=2047?u+=2:m>=55296&&m<=57343?(u+=4,++f):u+=3}return u};i.lengthBytesUTF8=Dc;var Id=(l,u,f,m)=>{if(f>>>=0,!(m>0))return 0;for(var y=f,b=f+m-1,v=0;v<l.length;++v){var I=l.charCodeAt(v);if(I>=55296&&I<=57343){var U=l.charCodeAt(++v);I=65536+((I&1023)<<10)|U&1023}if(I<=127){if(f>=b)break;u[f++>>>0]=I}else if(I<=2047){if(f+1>=b)break;u[f++>>>0]=192|I>>6,u[f++>>>0]=128|I&63}else if(I<=65535){if(f+2>=b)break;u[f++>>>0]=224|I>>12,u[f++>>>0]=128|I>>6&63,u[f++>>>0]=128|I&63}else{if(f+3>=b)break;u[f++>>>0]=240|I>>18,u[f++>>>0]=128|I>>12&63,u[f++>>>0]=128|I>>6&63,u[f++>>>0]=128|I&63}}return u[f>>>0]=0,f-y},kr=(l,u,f)=>Id(l,g,u,f);i.stringToUTF8=kr;function Bd(l,u){l>>>=0,u>>>=0}function Dd(l,u,f){u>>>=0,f>>>=0}var Fc=(l,u)=>{g.fill(0,l,l+u)},ls=(l,u,f,m,y)=>{switch(u){case 2:f=as(f),Fc(l,16),y&&(T[y>>>2>>>0]=16),C[l>>>1>>>0]=u,T[l+4>>>2>>>0]=f,C[l+2>>>1>>>0]=_htons(m);break;case 10:f=ra(f),Fc(l,28),y&&(T[y>>>2>>>0]=28),T[l>>>2>>>0]=u,T[l+8>>>2>>>0]=f[0],T[l+12>>>2>>>0]=f[1],T[l+16>>>2>>>0]=f[2],T[l+20>>>2>>>0]=f[3],C[l+2>>>1>>>0]=_htons(m);break;default:return 5}return 0};function Fd(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Dn(l);if(!v.daddr)return-53;var I=ls(u,v.family,le.lookup_name(v.daddr),v.dport,f);return 0}function Ad(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Dn(l),I=ls(u,v.family,le.lookup_name(v.saddr||"0.0.0.0"),v.sport,f);return 0}function xd(l,u,f,m,y,b){m>>>=0,y>>>=0;var v=Dn(l);return u===1&&f===4?(T[m>>>2>>>0]=v.error,T[y>>>2>>>0]=4,v.error=null,0):-50}function Td(l,u,f){return f>>>=0,na.varargs=f,0}function Ed(l,u){l>>>=0,u>>>=0}function Ud(l,u,f){u>>>=0}function Od(l,u,f,m){u>>>=0,f>>>=0}function Md(l,u,f,m){u>>>=0,m>>>=0,na.varargs=m}function Rd(l,u,f){l>>>=0}function Ld(l,u,f,m){u>>>=0,f>>>=0,m>>>=0}function Nd(l,u,f,m,y,b){u>>>=0,f>>>=0,y>>>=0,b>>>=0;var v=Dn(l),I=v.sock_ops.recvmsg(v,f);if(!I)return 0;if(y)var U=ls(y,v.family,le.lookup_name(I.addr),I.port,b);return g.set(I.buffer,u>>>0),I.buffer.byteLength}function kd(l,u,f,m){u>>>=0,m>>>=0}function Cd(l){l>>>=0}function Pd(l,u,f,m,y,b){u>>>=0,f>>>=0,y>>>=0,b>>>=0}var Vd=(l,u,f)=>{};function Hd(l,u){l>>>=0,u>>>=0}function zd(l,u,f){l>>>=0,u>>>=0,f>>>=0}function jd(l,u,f){u>>>=0}var Wd=()=>qe("");function Ac(){qe("missing function: _emval_call_method")}Ac.stub=!0;function xc(){qe("missing function: _emval_decref")}xc.stub=!0;function Tc(){qe("missing function: _emval_get_global")}Tc.stub=!0;function Ec(){qe("missing function: _emval_get_method_caller")}Ec.stub=!0;function Uc(){qe("missing function: _emval_run_destructors")}Uc.stub=!0;var $d=l=>l%4===0&&(l%100!==0||l%400===0),Gd=[0,31,60,91,121,152,182,213,244,274,305,335],Kd=[0,31,59,90,120,151,181,212,243,273,304,334],qd=l=>{var u=$d(l.getFullYear()),f=u?Gd:Kd,m=f[l.getMonth()]+l.getDate()-1;return m};function Yd(l,u,f){var m=Nr(l,u);f>>>=0;var y=new Date(m*1e3);T[f>>>2>>>0]=y.getSeconds(),T[f+4>>>2>>>0]=y.getMinutes(),T[f+8>>>2>>>0]=y.getHours(),T[f+12>>>2>>>0]=y.getDate(),T[f+16>>>2>>>0]=y.getMonth(),T[f+20>>>2>>>0]=y.getFullYear()-1900,T[f+24>>>2>>>0]=y.getDay();var b=qd(y)|0;T[f+28>>>2>>>0]=b,T[f+36>>>2>>>0]=-(y.getTimezoneOffset()*60);var v=new Date(y.getFullYear(),0,1),I=new Date(y.getFullYear(),6,1).getTimezoneOffset(),U=v.getTimezoneOffset(),V=(I!=U&&y.getTimezoneOffset()==Math.min(U,I))|0;T[f+32>>>2>>>0]=V}function Jd(l,u,f,m,y,b,v,I){l>>>=0;var U=Nr(y,b);return v>>>=0,I>>>=0,-52}function Xd(l,u,f,m,y,b,v){l>>>=0,u>>>=0;var I=Nr(b,v)}var Zd=function(l,u,f,m){l>>>=0,u>>>=0,f>>>=0,m>>>=0;var y=new Date().getFullYear(),b=new Date(y,0,1),v=new Date(y,6,1),I=b.getTimezoneOffset(),U=v.getTimezoneOffset(),V=Math.max(I,U);pt[l>>>2>>>0]=V*60,T[u>>>2>>>0]=+(I!=U);var nt=yt=>{var st=yt>=0?"-":"+",D=Math.abs(yt),Lt=String(Math.floor(D/60)).padStart(2,"0"),Fe=String(D%60).padStart(2,"0");return"UTC".concat(st).concat(Lt).concat(Fe)},B=nt(I),ft=nt(U);U<I?(kr(B,f,17),kr(ft,m,17)):(kr(B,m,17),kr(ft,f,17))},Oc=()=>performance.now(),Mc=()=>Date.now(),Qd=1,tf=l=>l>=0&&l<=3;function ef(l,u,f,m){var y=Nr(u,f);if(m>>>=0,!tf(l))return 28;var b;if(l===0)b=Mc();else if(Qd)b=Oc();else return 52;var v=Math.round(b*1e3*1e3);return cr=[v>>>0,(Kt=v,+Math.abs(Kt)>=1?Kt>0?+Math.floor(Kt/4294967296)>>>0:~~+Math.ceil((Kt-+(~~Kt>>>0))/4294967296)>>>0:0)],T[m>>>2>>>0]=cr[0],T[m+4>>>2>>>0]=cr[1],0}function rf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(i,l,u)}function nf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(i,l,u)}function sf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(i,l,u)}function of(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(i,l,u)}function af(l){return globalThis.DUCKDB_RUNTIME.closeFile(i,l)}function cf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(i,l,u)}function lf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(i,l,u)}function uf(l,u,f,m){return l>>>=0,f>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(i,l,u,f,m)}function df(l,u){return globalThis.DUCKDB_RUNTIME.openFile(i,l,u)}function ff(l,u,f,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.readFile(i,l,u,f,m)}function hf(l,u){return globalThis.DUCKDB_RUNTIME.truncateFile(i,l,u)}function pf(l,u,f,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(i,l,u,f,m)}function mf(l){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(l)}function yf(l,u){return l>>>=0,globalThis.DUCKDB_RUNTIME.glob(i,l,u)}function _f(l){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(i,l)}function bf(l,u,f,m,y,b){return l>>>=0,f>>>=0,y>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(i,l,u,f,m,y,b)}var ia=[],gf=(l,u)=>{ia.length=0;for(var f;f=g[l++>>>0];){var m=f!=105;m&=f!=112,u+=m&&u%8?4:0,ia.push(f==112?pt[u>>>2>>>0]:f==105?T[u>>>2>>>0]:mt[u>>>3>>>0]),u+=m?8:4}return ia},wf=(l,u,f)=>{var m=gf(u,f);return fd[l](...m)};function vf(l,u,f){return l>>>=0,u>>>=0,f>>>=0,wf(l,u,f)}var Rc=()=>4294901760;function Sf(){return Rc()}var If=(l,u)=>Math.ceil(l/u)*u,Bf=l=>{var u=k.buffer,f=(l-u.byteLength+65535)/65536|0;try{return k.grow(f),Lr(),1}catch(m){}};function Df(l){l>>>=0;var u=g.length,f=Rc();if(l>f)return!1;for(var m=1;m<=4;m*=2){var y=u*(1+.2/m);y=Math.min(y,l+100663296);var b=Math.min(f,If(Math.max(l,y),65536)),v=Bf(b);if(v)return!0}return!1}var sa={},Ff=()=>x||"./this.program",oi=()=>{if(!oi.strings){var l=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",u={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:l,_:Ff()};for(var f in sa)sa[f]===void 0?delete u[f]:u[f]=sa[f];var m=[];for(var f in u)m.push("".concat(f,"=").concat(u[f]));oi.strings=m}return oi.strings},Af=(l,u)=>{for(var f=0;f<l.length;++f)H[u++>>>0]=l.charCodeAt(f);H[u>>>0]=0},xf=function(l,u){l>>>=0,u>>>=0;var f=0;return oi().forEach((m,y)=>{var b=u+f;pt[l+y*4>>>2>>>0]=b,Af(m,b),f+=m.length+1}),0},Tf=function(l,u){l>>>=0,u>>>=0;var f=oi();pt[l>>>2>>>0]=f.length;var m=0;return f.forEach(y=>m+=y.length+1),pt[u>>>2>>>0]=m,0},Ef=0,Uf=()=>md||Ef>0,Of=l=>{var u;R=l,Uf()||((u=i.onExit)==null||u.call(i,l),w=!0),ot(l,new mc(l))},Lc=(l,u)=>{R=l,Of(l)},Mf=Lc,Rf=l=>52;function Lf(l,u){u>>>=0;var f=0,m=0,y=0;{var b=2;l==0?f=2:(l==1||l==2)&&(f=64),y=1}return H[u>>>0]=b,C[u+2>>>1>>>0]=y,cr=[f>>>0,(Kt=f,+Math.abs(Kt)>=1?Kt>0?+Math.floor(Kt/4294967296)>>>0:~~+Math.ceil((Kt-+(~~Kt>>>0))/4294967296)>>>0:0)],T[u+8>>>2>>>0]=cr[0],T[u+12>>>2>>>0]=cr[1],cr=[m>>>0,(Kt=m,+Math.abs(Kt)>=1?Kt>0?+Math.floor(Kt/4294967296)>>>0:~~+Math.ceil((Kt-+(~~Kt>>>0))/4294967296)>>>0:0)],T[u+16>>>2>>>0]=cr[0],T[u+20>>>2>>>0]=cr[1],0}function Nf(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Nr(m,y);return b>>>=0,52}function kf(l,u,f,m,y,b){u>>>=0,f>>>=0;var v=Nr(m,y);return b>>>=0,52}function Cf(l,u,f,m){return u>>>=0,f>>>=0,m>>>=0,52}function Pf(l,u,f,m,y){var b=Nr(u,f);return y>>>=0,70}var Vf=l=>52,Hf=[null,[],[]],zf=(l,u)=>{var f=Hf[l];u===0||u===10?((l===1?Gt:_)(Bc(f)),f.length=0):f.push(u)};function jf(l,u,f,m){u>>>=0,f>>>=0,m>>>=0;for(var y=0,b=0;b<f;b++){var v=pt[u>>>2>>>0],I=pt[u+4>>>2>>>0];u+=8;for(var U=0;U<I;U++)zf(l,g[v+U>>>0]);y+=I}return pt[m>>>2>>>0]=y,0}function Wf(l,u,f,m){l>>>=0,u>>>=0,f>>>=0,m>>>=0;var y=0,b=0,v=0,I=0,U=0,V=0,nt;function B(ft,yt,st,D,Lt,Fe){var Ft,Ye,Je,Pc;return Ye=ft===10?28:16,Lt=ft===10?wc(Lt):ea(Lt),Ft=Cr(Ye),Pc=ls(Ft,ft,Lt,Fe),F(!Pc),Je=Cr(32),T[Je+4>>>2>>>0]=ft,T[Je+8>>>2>>>0]=yt,T[Je+12>>>2>>>0]=st,pt[Je+24>>>2>>>0]=D,pt[Je+20>>>2>>>0]=Ft,ft===10?T[Je+16>>>2>>>0]=28:T[Je+16>>>2>>>0]=16,T[Je+28>>>2>>>0]=0,Je}if(f&&(v=T[f>>>2>>>0],I=T[f+4>>>2>>>0],U=T[f+8>>>2>>>0],V=T[f+12>>>2>>>0]),U&&!V&&(V=U===2?17:6),!U&&V&&(U=V===17?2:1),V===0&&(V=6),U===0&&(U=1),!l&&!u)return-2;if(v&-1088||f!==0&&T[f>>>2>>>0]&2&&!l)return-1;if(v&32)return-2;if(U!==0&&U!==1&&U!==2)return-7;if(I!==0&&I!==2&&I!==10)return-6;if(u&&(u=gt(u),b=parseInt(u,10),isNaN(b)))return v&1024?-2:-8;if(!l)return I===0&&(I=2),v&1||(I===2?y=_htonl(2130706433):y=[0,0,0,_htonl(1)]),nt=B(I,U,V,null,y,b),pt[m>>>2>>>0]=nt,0;if(l=gt(l),y=as(l),y!==null)if(I===0||I===2)I=2;else if(I===10&&v&8)y=[0,0,_htonl(65535),y],I=10;else return-2;else if(y=ra(l),y!==null)if(I===0||I===10)I=10;else return-2;return y!=null?(nt=B(I,U,V,l,y,b),pt[m>>>2>>>0]=nt,0):v&4?-2:(l=le.lookup_name(l),y=as(l),I===0?I=2:I===10&&(y=[0,0,_htonl(65535),y]),nt=B(I,U,V,null,y,b),pt[m>>>2>>>0]=nt,0)}function $f(l,u,f,m,y,b,v){l>>>=0,f>>>=0,y>>>=0;var I=vc(l,u);if(I.errno)return-6;var U=I.port,V=I.addr,nt=!1;if(f&&m){var B;if(v&1||!(B=le.lookup_addr(V))){if(v&8)return-2}else V=B;var ft=kr(V,f,m);ft+1>=m&&(nt=!0)}if(y&&b){U=""+U;var ft=kr(U,y,b);ft+1>=b&&(nt=!0)}return nt?-12:0}var Gf=()=>{if(p){var l=["crypto"].map(Vc).pop();return u=>l.randomFillSync(u)}return u=>crypto.getRandomValues(u)},Nc=l=>{(Nc=Gf())(l)};function Kf(l,u){return l>>>=0,u>>>=0,Nc(g.subarray(l>>>0,l+u>>>0)),0}var qf=l=>{if(l instanceof mc||l=="unwind")return R;ot(1,l)},Yf=l=>{var u=i["_"+l];return u},Jf=(l,u)=>{H.set(l,u>>>0)},us=l=>oh(l);i.stackAlloc=us;var Xf=l=>{var u=Dc(l)+1,f=us(u);return kr(l,f,u),f},kc=()=>ah(),Cc=l=>sh(l),Zf=(l,u,f,m,y)=>{var b={string:st=>{var D=0;return st!=null&&st!==0&&(D=Xf(st)),D},array:st=>{var D=us(st.length);return Jf(st,D),D}};function v(st){return u==="string"?gt(st):u==="boolean"?!!st:st}var I=Yf(l),U=[],V=0;if(m)for(var nt=0;nt<m.length;nt++){var B=b[f[nt]];B?(V===0&&(V=kc()),U[nt]=B(m[nt])):U[nt]=m[nt]}var ft=I(...U);function yt(st){return V!==0&&Cc(V),v(st)}return ft=yt(ft),ft},Qf=l=>ih(),th=l=>nh(l),eh={ja:yd,oa:_d,I:bd,ea:gd,b:wd,da:vd,w:Sd,fa:Bd,_:Dd,ia:Fd,ha:Ad,ma:xd,h:Td,aa:Ed,$:Ud,ba:Od,t:Md,na:Rd,X:Ld,ka:Nd,Y:kd,o:Cd,la:Pd,s:Vd,ca:Hd,ga:zd,p:jd,ra:Wd,F:Ac,i:xc,H:Tc,G:Ec,E:Uc,z:Yd,A:Jd,B:Xd,qa:Zd,C:ef,O:rf,Q:nf,M:sf,N:of,m:af,T:cf,K:lf,L:uf,S:df,f:ff,R:hf,n:pf,U:mf,J:yf,l:_f,V:bf,e:vf,k:Mc,pa:Sf,c:Oc,sa:Df,u:xf,v:Tf,a:Mf,d:Rf,P:Lf,y:Nf,x:kf,j:Cf,D:Pf,Z:Vf,g:jf,r:Wf,q:$f,W:Kf},P=await dd(),rh=i._main=P.va,Km=i._duckdb_web_fs_glob_add_path=P.xa,qm=i._duckdb_web_clear_response=P.ya,Ym=i._duckdb_web_fail_with=P.za,Jm=i._duckdb_web_reset=P.Aa,Xm=i._duckdb_web_connect=P.Ba,Zm=i._duckdb_web_disconnect=P.Ca,Qm=i._duckdb_web_flush_files=P.Da,ty=i._duckdb_web_flush_file=P.Ea,ey=i._duckdb_web_open=P.Fa,ry=i._duckdb_web_get_global_file_info=P.Ga,ny=i._duckdb_web_collect_file_stats=P.Ha,iy=i._duckdb_web_export_file_stats=P.Ia,sy=i._duckdb_web_fs_drop_file=P.Ja,oy=i._duckdb_web_fs_drop_files=P.Ka,ay=i._duckdb_web_fs_glob_file_infos=P.La,cy=i._duckdb_web_fs_get_file_info_by_id=P.Ma,ly=i._duckdb_web_fs_get_file_info_by_name=P.Na,uy=i._duckdb_web_fs_register_file_url=P.Oa,dy=i._duckdb_web_fs_register_file_buffer=P.Pa,fy=i._duckdb_web_copy_file_to_buffer=P.Qa,hy=i._duckdb_web_copy_file_to_path=P.Ra,py=i._duckdb_web_get_version=P.Sa,my=i._duckdb_web_get_feature_flags=P.Ta,yy=i._duckdb_web_tokenize=P.Ua,_y=i._duckdb_web_tokenize_buffer=P.Va,by=i._duckdb_web_udf_scalar_create=P.Wa,gy=i._duckdb_web_prepared_create=P.Xa,wy=i._duckdb_web_prepared_create_buffer=P.Ya,vy=i._duckdb_web_prepared_close=P.Za,Sy=i._duckdb_web_prepared_run=P._a,Iy=i._duckdb_web_prepared_send=P.$a,By=i._duckdb_web_query_run=P.ab,Dy=i._duckdb_web_query_run_buffer=P.bb,Fy=i._duckdb_web_pending_query_start=P.cb,Ay=i._duckdb_web_pending_query_start_buffer=P.db,xy=i._duckdb_web_pending_query_poll=P.eb,Ty=i._duckdb_web_pending_query_cancel=P.fb,Ey=i._duckdb_web_query_fetch_results=P.gb,Uy=i._duckdb_web_get_tablenames=P.hb,Oy=i._duckdb_web_get_tablenames_buffer=P.ib,My=i._duckdb_web_insert_arrow_from_ipc_stream=P.jb,Ry=i._duckdb_web_insert_csv_from_path=P.kb,Ly=i._duckdb_web_insert_json_from_path=P.lb,Cr=i._malloc=P.pb,Ny=i._free=P.qb,ky=i._calloc=P.rb,nh=P.tb,ih=P.ub,sh=P.vb,oh=P.wb,ah=P.xb;function ch(l){l=Object.assign({},l);var u=y=>b=>y(b)>>>0,f=y=>(b,v)=>y(b,v)>>>0,m=y=>()=>y()>>>0;return l.pb=u(l.pb),l.rb=f(l.rb),l.wb=u(l.wb),l.xb=m(l.xb),l}i.stackSave=kc,i.stackRestore=Cc,i.stackAlloc=us,i.getTempRet0=Qf,i.setTempRet0=th,i.ccall=Zf;function lh(){var l=rh,u=0,f=0;try{var m=l(u,f);return Lc(m,!0),m}catch(y){return qf(y)}}function oa(){if(rn>0){ii=oa;return}if(ei(),rn>0){ii=oa;return}function l(){var f;if(i.calledRun=!0,!w){ri(),s(i),(f=i.onRuntimeInitialized)==null||f.call(i);var u=i.noInitialRun;u||lh(),rd()}}i.setStatus?(i.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>i.setStatus(""),1),l()},1)):l()}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return oa(),n=a,n}})();typeof $u=="object"&&typeof Jo=="object"?(Jo.exports=hc,Jo.exports.default=hc):typeof define=="function"&&define.amd&&define([],()=>hc)});var qu=Fn(()=>{});var Yu=Fn(()=>{});var Ju=Fn((HD,Qo)=>{(function(){"use strict";var r="input is invalid type",t=typeof window=="object",e=t?window:{};e.JS_SHA256_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",i=!e.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";i?e=global:n&&(e=self);var s=!e.JS_SHA256_NO_COMMON_JS&&typeof Qo=="object"&&Qo.exports,o=typeof define=="function"&&define.amd,a=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),d=[-2147483648,8388608,32768,128],p=[24,16,8,0],S=[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],A=["hex","array","digest","arrayBuffer"],x=[];(e.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(_){return Object.prototype.toString.call(_)==="[object Array]"}),a&&(e.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(_){return typeof _=="object"&&_.buffer&&_.buffer.constructor===ArrayBuffer});var ot=function(_,E){return function(k){return new bt(E,!0).update(k)[_]()}},lt=function(_){var E=ot("hex",_);i&&(E=Pt(E,_)),E.create=function(){return new bt(_)},E.update=function(R){return E.create().update(R)};for(var k=0;k<A.length;++k){var w=A[k];E[w]=ot(w,_)}return E},Pt=function(_,E){var k=qu(),w=Yu().Buffer,R=E?"sha224":"sha256",F;w.from&&!e.JS_SHA256_NO_BUFFER_FROM?F=w.from:F=function(g){return new w(g)};var H=function(g){if(typeof g=="string")return k.createHash(R).update(g,"utf8").digest("hex");if(g==null)throw new Error(r);return g.constructor===ArrayBuffer&&(g=new Uint8Array(g)),Array.isArray(g)||ArrayBuffer.isView(g)||g.constructor===w?k.createHash(R).update(F(g)).digest("hex"):_(g)};return H},Ot=function(_,E){return function(k,w){return new Qt(k,E,!0).update(w)[_]()}},Bt=function(_){var E=Ot("hex",_);E.create=function(R){return new Qt(R,_)},E.update=function(R,F){return E.create(R).update(F)};for(var k=0;k<A.length;++k){var w=A[k];E[w]=Ot(w,_)}return E};function bt(_,E){E?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],_?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=_}bt.prototype.update=function(_){if(!this.finalized){var E,k=typeof _;if(k!=="string"){if(k==="object"){if(_===null)throw new Error(r);if(a&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!a||!ArrayBuffer.isView(_)))throw new Error(r)}else throw new Error(r);E=!0}for(var w,R=0,F,H=_.length,g=this.blocks;R<H;){if(this.hashed&&(this.hashed=!1,g[0]=this.block,this.block=g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0),E)for(F=this.start;R<H&&F<64;++R)g[F>>>2]|=_[R]<<p[F++&3];else for(F=this.start;R<H&&F<64;++R)w=_.charCodeAt(R),w<128?g[F>>>2]|=w<<p[F++&3]:w<2048?(g[F>>>2]|=(192|w>>>6)<<p[F++&3],g[F>>>2]|=(128|w&63)<<p[F++&3]):w<55296||w>=57344?(g[F>>>2]|=(224|w>>>12)<<p[F++&3],g[F>>>2]|=(128|w>>>6&63)<<p[F++&3],g[F>>>2]|=(128|w&63)<<p[F++&3]):(w=65536+((w&1023)<<10|_.charCodeAt(++R)&1023),g[F>>>2]|=(240|w>>>18)<<p[F++&3],g[F>>>2]|=(128|w>>>12&63)<<p[F++&3],g[F>>>2]|=(128|w>>>6&63)<<p[F++&3],g[F>>>2]|=(128|w&63)<<p[F++&3]);this.lastByteIndex=F,this.bytes+=F-this.start,F>=64?(this.block=g[16],this.start=F-64,this.hash(),this.hashed=!0):this.start=F}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},bt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var _=this.blocks,E=this.lastByteIndex;_[16]=this.block,_[E>>>2]|=d[E&3],this.block=_[16],E>=56&&(this.hashed||this.hash(),_[0]=this.block,_[16]=_[1]=_[2]=_[3]=_[4]=_[5]=_[6]=_[7]=_[8]=_[9]=_[10]=_[11]=_[12]=_[13]=_[14]=_[15]=0),_[14]=this.hBytes<<3|this.bytes>>>29,_[15]=this.bytes<<3,this.hash()}},bt.prototype.hash=function(){var _=this.h0,E=this.h1,k=this.h2,w=this.h3,R=this.h4,F=this.h5,H=this.h6,g=this.h7,C=this.blocks,q,T,pt,Ke,mt,Be,De,Lr,ei,ri,ni;for(q=16;q<64;++q)mt=C[q-15],T=(mt>>>7|mt<<25)^(mt>>>18|mt<<14)^mt>>>3,mt=C[q-2],pt=(mt>>>17|mt<<15)^(mt>>>19|mt<<13)^mt>>>10,C[q]=C[q-16]+T+C[q-7]+pt<<0;for(ni=E&k,q=0;q<64;q+=4)this.first?(this.is224?(Lr=300032,mt=C[0]-1413257819,g=mt-150054599<<0,w=mt+24177077<<0):(Lr=704751109,mt=C[0]-210244248,g=mt-1521486534<<0,w=mt+143694565<<0),this.first=!1):(T=(_>>>2|_<<30)^(_>>>13|_<<19)^(_>>>22|_<<10),pt=(R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7),Lr=_&E,Ke=Lr^_&k^ni,De=R&F^~R&H,mt=g+pt+De+S[q]+C[q],Be=T+Ke,g=w+mt<<0,w=mt+Be<<0),T=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),pt=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7),ei=w&_,Ke=ei^w&E^Lr,De=g&R^~g&F,mt=H+pt+De+S[q+1]+C[q+1],Be=T+Ke,H=k+mt<<0,k=mt+Be<<0,T=(k>>>2|k<<30)^(k>>>13|k<<19)^(k>>>22|k<<10),pt=(H>>>6|H<<26)^(H>>>11|H<<21)^(H>>>25|H<<7),ri=k&w,Ke=ri^k&_^ei,De=H&g^~H&R,mt=F+pt+De+S[q+2]+C[q+2],Be=T+Ke,F=E+mt<<0,E=mt+Be<<0,T=(E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10),pt=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),ni=E&k,Ke=ni^E&w^ri,De=F&H^~F&g,mt=R+pt+De+S[q+3]+C[q+3],Be=T+Ke,R=_+mt<<0,_=mt+Be<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+_<<0,this.h1=this.h1+E<<0,this.h2=this.h2+k<<0,this.h3=this.h3+w<<0,this.h4=this.h4+R<<0,this.h5=this.h5+F<<0,this.h6=this.h6+H<<0,this.h7=this.h7+g<<0},bt.prototype.hex=function(){this.finalize();var _=this.h0,E=this.h1,k=this.h2,w=this.h3,R=this.h4,F=this.h5,H=this.h6,g=this.h7,C=c[_>>>28&15]+c[_>>>24&15]+c[_>>>20&15]+c[_>>>16&15]+c[_>>>12&15]+c[_>>>8&15]+c[_>>>4&15]+c[_&15]+c[E>>>28&15]+c[E>>>24&15]+c[E>>>20&15]+c[E>>>16&15]+c[E>>>12&15]+c[E>>>8&15]+c[E>>>4&15]+c[E&15]+c[k>>>28&15]+c[k>>>24&15]+c[k>>>20&15]+c[k>>>16&15]+c[k>>>12&15]+c[k>>>8&15]+c[k>>>4&15]+c[k&15]+c[w>>>28&15]+c[w>>>24&15]+c[w>>>20&15]+c[w>>>16&15]+c[w>>>12&15]+c[w>>>8&15]+c[w>>>4&15]+c[w&15]+c[R>>>28&15]+c[R>>>24&15]+c[R>>>20&15]+c[R>>>16&15]+c[R>>>12&15]+c[R>>>8&15]+c[R>>>4&15]+c[R&15]+c[F>>>28&15]+c[F>>>24&15]+c[F>>>20&15]+c[F>>>16&15]+c[F>>>12&15]+c[F>>>8&15]+c[F>>>4&15]+c[F&15]+c[H>>>28&15]+c[H>>>24&15]+c[H>>>20&15]+c[H>>>16&15]+c[H>>>12&15]+c[H>>>8&15]+c[H>>>4&15]+c[H&15];return this.is224||(C+=c[g>>>28&15]+c[g>>>24&15]+c[g>>>20&15]+c[g>>>16&15]+c[g>>>12&15]+c[g>>>8&15]+c[g>>>4&15]+c[g&15]),C},bt.prototype.toString=bt.prototype.hex,bt.prototype.digest=function(){this.finalize();var _=this.h0,E=this.h1,k=this.h2,w=this.h3,R=this.h4,F=this.h5,H=this.h6,g=this.h7,C=[_>>>24&255,_>>>16&255,_>>>8&255,_&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255,k>>>24&255,k>>>16&255,k>>>8&255,k&255,w>>>24&255,w>>>16&255,w>>>8&255,w&255,R>>>24&255,R>>>16&255,R>>>8&255,R&255,F>>>24&255,F>>>16&255,F>>>8&255,F&255,H>>>24&255,H>>>16&255,H>>>8&255,H&255];return this.is224||C.push(g>>>24&255,g>>>16&255,g>>>8&255,g&255),C},bt.prototype.array=bt.prototype.digest,bt.prototype.arrayBuffer=function(){this.finalize();var _=new ArrayBuffer(this.is224?28:32),E=new DataView(_);return E.setUint32(0,this.h0),E.setUint32(4,this.h1),E.setUint32(8,this.h2),E.setUint32(12,this.h3),E.setUint32(16,this.h4),E.setUint32(20,this.h5),E.setUint32(24,this.h6),this.is224||E.setUint32(28,this.h7),_};function Qt(_,E,k){var w,R=typeof _;if(R==="string"){var F=[],H=_.length,g=0,C;for(w=0;w<H;++w)C=_.charCodeAt(w),C<128?F[g++]=C:C<2048?(F[g++]=192|C>>>6,F[g++]=128|C&63):C<55296||C>=57344?(F[g++]=224|C>>>12,F[g++]=128|C>>>6&63,F[g++]=128|C&63):(C=65536+((C&1023)<<10|_.charCodeAt(++w)&1023),F[g++]=240|C>>>18,F[g++]=128|C>>>12&63,F[g++]=128|C>>>6&63,F[g++]=128|C&63);_=F}else if(R==="object"){if(_===null)throw new Error(r);if(a&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!a||!ArrayBuffer.isView(_)))throw new Error(r)}else throw new Error(r);_.length>64&&(_=new bt(E,!0).update(_).array());var q=[],T=[];for(w=0;w<64;++w){var pt=_[w]||0;q[w]=92^pt,T[w]=54^pt}bt.call(this,E,k),this.update(T),this.oKeyPad=q,this.inner=!0,this.sharedMemory=k}Qt.prototype=new bt,Qt.prototype.finalize=function(){if(bt.prototype.finalize.call(this),this.inner){this.inner=!1;var _=this.array();bt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(_),bt.prototype.finalize.call(this)}};var Gt=lt();Gt.sha256=Gt,Gt.sha224=lt(!0),Gt.sha256.hmac=Bt(),Gt.sha224.hmac=Bt(!0),s?Qo.exports=Gt:(e.sha256=Gt.sha256,e.sha224=Gt.sha224,o&&define(function(){return Gt}))})()});var Gm={};Pr(Gm,{registerWorker:()=>ed});function $c(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e}function O(r,t,e,n){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(p){try{d(n.next(p))}catch(S){o(S)}}function c(p){try{d(n.throw(p))}catch(S){o(S)}}function d(p){p.done?s(p.value):i(p.value).then(a,c)}d((n=n.apply(r,t||[])).next())})}function Wc(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function it(r){return this instanceof it?(this.v=r,this):new it(r)}function ue(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(A){n[A]&&(i[A]=function(x){return new Promise(function(ot,lt){s.push([A,x,ot,lt])>1||a(A,x)})})}function a(A,x){try{c(n[A](x))}catch(ot){S(s[0][3],ot)}}function c(A){A.value instanceof it?Promise.resolve(A.value.v).then(d,p):S(s[0][2],A)}function d(A){a("next",A)}function p(A){a("throw",A)}function S(A,x){A(x),s.shift(),s.length&&a(s[0][0],s[0][1])}}function An(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:it(r[i](o)),done:!1}:s?s(o):o}:s}}function Ae(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Wc=="function"?Wc(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(o){return new Promise(function(a,c){o=r[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(d){s({value:d,done:a})},o)}}var ha={};Pr(ha,{compareArrayLike:()=>fa,joinUint8Arrays:()=>de,memcpy:()=>ui,rebaseValueOffsets:()=>bs,toArrayBufferView:()=>at,toArrayBufferViewAsyncIterator:()=>Ee,toArrayBufferViewIterator:()=>Ze,toBigInt64Array:()=>_s,toBigUint64Array:()=>Fh,toFloat32Array:()=>Ah,toFloat32ArrayAsyncIterator:()=>jh,toFloat32ArrayIterator:()=>Lh,toFloat64Array:()=>xh,toFloat64ArrayAsyncIterator:()=>Wh,toFloat64ArrayIterator:()=>Nh,toInt16Array:()=>Ih,toInt16ArrayAsyncIterator:()=>Ph,toInt16ArrayIterator:()=>Uh,toInt32Array:()=>sn,toInt32ArrayAsyncIterator:()=>Vh,toInt32ArrayIterator:()=>Oh,toInt8Array:()=>Sh,toInt8ArrayAsyncIterator:()=>Ch,toInt8ArrayIterator:()=>Eh,toUint16Array:()=>Bh,toUint16ArrayAsyncIterator:()=>Hh,toUint16ArrayIterator:()=>Mh,toUint32Array:()=>Dh,toUint32ArrayAsyncIterator:()=>zh,toUint32ArrayIterator:()=>Rh,toUint8Array:()=>Y,toUint8ArrayAsyncIterator:()=>da,toUint8ArrayIterator:()=>ua,toUint8ClampedArray:()=>Th,toUint8ClampedArrayAsyncIterator:()=>$h,toUint8ClampedArrayIterator:()=>kh});var bh=new TextDecoder("utf-8"),ci=r=>bh.decode(r),gh=new TextEncoder,Xe=r=>gh.encode(r);var wh=r=>typeof r=="number",Gc=r=>typeof r=="boolean",zt=r=>typeof r=="function",te=r=>r!=null&&Object(r)===r,xe=r=>te(r)&&zt(r.then);var Te=r=>te(r)&&zt(r[Symbol.iterator]),_e=r=>te(r)&&zt(r[Symbol.asyncIterator]),ds=r=>te(r)&&te(r.schema);var fs=r=>te(r)&&"done"in r&&"value"in r;var hs=r=>te(r)&&zt(r.stat)&&wh(r.fd);var ps=r=>te(r)&&li(r.body),ms=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Kc=r=>te(r)&&zt(r.abort)&&zt(r.getWriter)&&!ms(r),li=r=>te(r)&&zt(r.cancel)&&zt(r.getReader)&&!ms(r),qc=r=>te(r)&&zt(r.end)&&zt(r.write)&&Gc(r.writable)&&!ms(r),ys=r=>te(r)&&zt(r.read)&&zt(r.pipe)&&Gc(r.readable)&&!ms(r),Yc=r=>te(r)&&zt(r.clear)&&zt(r.bytes)&&zt(r.position)&&zt(r.setPosition)&&zt(r.capacity)&&zt(r.getBufferIdentifier)&&zt(r.createLong);var la=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function vh(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let o,a,c=0,d=0,p=r.length;++c<p;){if(o=t[d],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++d]=a);continue}if({byteOffset:e,byteLength:i}=o,{byteOffset:n,byteLength:s}=a,e+i<n||n+s<e){a&&(t[++d]=a);continue}t[d]=new Uint8Array(o.buffer,e,n-e+s)}return t}function ui(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(o,e),r}function de(r,t){let e=vh(r),n=e.reduce((p,S)=>p+S.byteLength,0),i,s,o,a=0,c=-1,d=Math.min(t||Number.POSITIVE_INFINITY,n);for(let p=e.length;++c<p;){if(i=e[c],s=i.subarray(0,Math.min(i.length,d-a)),d<=a+s.length){s.length<i.length?e[c]=i.subarray(s.length):s.length===i.length&&c++,o?ui(o,s,a):o=s;break}ui(o||(o=new Uint8Array(d)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function at(r,t){let e=fs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Xe(e)),e instanceof ArrayBuffer?new r(e):e instanceof la?new r(e):Yc(e)?at(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Sh=r=>at(Int8Array,r),Ih=r=>at(Int16Array,r),sn=r=>at(Int32Array,r),_s=r=>at(BigInt64Array,r),Y=r=>at(Uint8Array,r),Bh=r=>at(Uint16Array,r),Dh=r=>at(Uint32Array,r),Fh=r=>at(BigUint64Array,r),Ah=r=>at(Float32Array,r),xh=r=>at(Float64Array,r),Th=r=>at(Uint8ClampedArray,r),ca=r=>(r.next(),r);function*Ze(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof la?e(t):Te(t)?t:e(t);return yield*nn(ca(function*(i){let s=null;do s=i.next(yield at(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var Eh=r=>Ze(Int8Array,r),Uh=r=>Ze(Int16Array,r),Oh=r=>Ze(Int32Array,r),ua=r=>Ze(Uint8Array,r),Mh=r=>Ze(Uint16Array,r),Rh=r=>Ze(Uint32Array,r),Lh=r=>Ze(Float32Array,r),Nh=r=>Ze(Float64Array,r),kh=r=>Ze(Uint8ClampedArray,r);function Ee(r,t){return ue(this,arguments,function*(){if(xe(t))return yield it(yield it(yield*nn(An(Ae(Ee(r,yield it(t)))))));let n=function(o){return ue(this,arguments,function*(){yield yield it(yield it(o))})},i=function(o){return ue(this,arguments,function*(){yield it(yield*nn(An(Ae(ca(function*(a){let c=null;do c=a.next(yield c==null?void 0:c.value);while(!c.done)}(o[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof la?n(t):Te(t)?i(t):_e(t)?t:n(t);return yield it(yield*nn(An(Ae(ca(function(o){return ue(this,arguments,function*(){let a=null;do a=yield it(o.next(yield yield it(at(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]())))))),yield it(new r)})}var Ch=r=>Ee(Int8Array,r),Ph=r=>Ee(Int16Array,r),Vh=r=>Ee(Int32Array,r),da=r=>Ee(Uint8Array,r),Hh=r=>Ee(Uint16Array,r),zh=r=>Ee(Uint32Array,r),jh=r=>Ee(Float32Array,r),Wh=r=>Ee(Float64Array,r),$h=r=>Ee(Uint8ClampedArray,r);function bs(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n<i;)e[n]+=r}return e.subarray(0,t)}function fa(r,t){let e=0,n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}var qt={fromIterable(r){return gs(Gh(r))},fromAsyncIterable(r){return gs(Kh(r))},fromDOMStream(r){return gs(qh(r))},fromNodeStream(r){return gs(Yh(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},gs=r=>(r.next(),r);function*Gh(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?de(n,o)[0]:([i,n,a]=de(n,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let d=ua(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?d.next():d.next(o-a),!t&&i.byteLength>0&&(n.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(p){(e=!0)&&typeof d.throw=="function"&&d.throw(p)}finally{e===!1&&typeof d.return=="function"&&d.return(null)}return null}function Kh(r){return ue(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function d(){return o==="peek"?de(i,a)[0]:([s,i,c]=de(i,a),s)}({cmd:o,size:a}=(yield yield it(null))||{cmd:"read",size:0});let p=da(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield it(p.next()):yield it(p.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield it(d()));while(a<c);while(!e)}catch(S){(n=!0)&&typeof p.throw=="function"&&(yield it(p.throw(S)))}finally{n===!1&&typeof p.return=="function"&&(yield it(p.return(new Uint8Array(0))))}return yield it(null)})}function qh(r){return ue(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function d(){return o==="peek"?de(i,a)[0]:([s,i,c]=de(i,a),s)}({cmd:o,size:a}=(yield yield it(null))||{cmd:"read",size:0});let p=new ma(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield it(p.read()):yield it(p.read(a-c)),!e&&s.byteLength>0&&(i.push(Y(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield it(d()));while(a<c);while(!e)}catch(S){(n=!0)&&(yield it(p.cancel(S)))}finally{n===!1?yield it(p.cancel()):r.locked&&p.releaseLock()}return yield it(null)})}var ma=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return O(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return O(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=Y(e)),e})}},pa=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function Yh(r){return ue(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,d=[],p;function S(){return o==="peek"?de(d,a)[0]:([p,d,c]=de(d,a),p)}if({cmd:o,size:a}=(yield yield it(null))||{cmd:"read",size:0},r.isTTY)return yield yield it(new Uint8Array(0)),yield it(null);try{e[0]=pa(r,"end"),e[1]=pa(r,"error");do{if(e[2]=pa(r,"readable"),[n,s]=yield it(Promise.race(e.map(x=>x[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-c)?(p=Y(r.read(a-c)),p.byteLength<a-c&&(p=Y(r.read()))):p=Y(r.read()),p.byteLength>0&&(d.push(p),c+=p.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield it(S()));while(a<c)}while(!i)}finally{yield it(A(e,n==="error"?s:null))}return yield it(null);function A(x,ot){return p=d=null,new Promise((lt,Pt)=>{for(let[Ot,Bt]of x)r.off(Ot,Bt);try{let Ot=r.destroy;Ot&&Ot.call(r,ot),ot=void 0}catch(Ot){ot=Ot||ot}finally{ot!=null?Pt(ot):lt()}})}})}var wt;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(wt||(wt={}));var At;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(At||(At={}));var Dt;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var kt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(kt||(kt={}));var L;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(L||(L={}));var jt;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(jt||(jt={}));var Qe=new Int32Array(2),ws=new Float32Array(Qe.buffer),vs=new Float64Array(Qe.buffer),xn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var di;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(di||(di={}));var fe=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(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))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Qe[0]=this.readInt32(t),ws[0]}readFloat64(t){return Qe[xn?0:1]=this.readInt32(t),Qe[xn?1:0]=this.readInt32(t+4),vs[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){ws[0]=e,this.writeInt32(t,Qe[0])}writeFloat64(t,e){vs[0]=e,this.writeInt32(t,Qe[xn?0:1]),this.writeInt32(t+4,Qe[xn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let n=this.readInt32(t);t+=4;let i=this.bytes_.subarray(t,t+n);return e===di.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s)}return n}createObjList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s.unpack())}return n}};var on=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=fe.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let i=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,i=fe.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let d=2;d<s;d+=2)if(this.bb.readInt16(a+d)!=this.bb.readInt16(c+d))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,8+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var fi;(function(r){r[r.BUFFER=0]="BUFFER"})(fi||(fi={}));var hi;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(hi||(hi={}));var Is=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__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):hi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):fi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,hi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,fi.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,n),r.endBodyCompression(t)}};var Tn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var En=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var he=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__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,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new En).__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,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Tn).__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 e=this.bb.__offset(this.bb_pos,10);return e?(t||new Is).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var lr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__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 e=this.bb.__offset(this.bb_pos,6);return e?(t||new he).__init(this.bb.__indirect(this.bb_pos+e),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,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var Vr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Vr||(Vr={}));var pi;(function(r){r[r.DenseArray=0]="DenseArray"})(pi||(pi={}));var Oe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,n),r.endInt(t)}};var tr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__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")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Oe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):pi.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,pi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Wt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,n),r.endKeyValue(t)}};var mi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}};var yi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}};var Hr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):kt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,kt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var er=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,i){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,n),r.addBitWidth(t,i),r.endDecimal(t)}};var zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):L.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,L.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}};var jr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}};var Wr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}};var $r=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Dt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Dt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}};var Gr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):jt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,jt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var _i=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}};var bi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}};var gi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}};var Kr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}};var wi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}};var vi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}};var ur=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):L.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,L.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,n),r.endTime(t)}};var dr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):L.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,L.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,n),r.endTimestamp(t)}};var Me=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):At.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,At.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,n),r.endUnion(t)}};var Si=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}};var xt;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(xt||(xt={}));var Zt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,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):xt.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new tr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new r).__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,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Wt).__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,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,xt.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}};var ie=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__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):Vr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new Zt).__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,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Wt).__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 e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){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,e){t.addFieldInt16(0,e,Vr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,n),r.addCustomMetadata(t,i),r.addFeatures(t,s),r.endSchema(t)}};var ut;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(ut||(ut={}));var h;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(h||(h={}));var ge;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(ge||(ge={}));var La={};Pr(La,{clampRange:()=>Fi,createElementComparator:()=>Xr,wrapIndex:()=>an});var ya={};Pr(ya,{valueToString:()=>Re});function Re(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return"".concat(r);case"bigint":return"".concat(r);case"string":return'"'.concat(r,'"')}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?"[".concat([...r].map(t=>Re(t)),"]"):"[".concat(r,"]"):ArrayBuffer.isView(r)?"[".concat(r,"]"):JSON.stringify(r,(t,e)=>typeof e=="bigint"?"".concat(e):e)}var wa={};Pr(wa,{BN:()=>Bi,bigNumToBigInt:()=>Xc,bigNumToNumber:()=>ga,bigNumToString:()=>Mn,isArrowBigNumSymbol:()=>Jc});function ht(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError("".concat(r," is not safe to convert to a number."));return Number(r)}function _a(r,t){return ht(r/t)+ht(r%t)/ht(t)}var Jc=Symbol.for("isArrowBigNum");function Le(r,...t){return t.length===0?Object.setPrototypeOf(at(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Le.prototype[Jc]=!0;Le.prototype.toJSON=function(){return'"'.concat(Mn(this),'"')};Le.prototype.valueOf=function(r){return ga(this,r)};Le.prototype.toString=function(){return Mn(this)};Le.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return ga(this);case"string":return Mn(this);case"default":return Xc(this)}return Mn(this)};function Un(...r){return Le.apply(this,r)}function On(...r){return Le.apply(this,r)}function Ii(...r){return Le.apply(this,r)}Object.setPrototypeOf(Un.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(On.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Ii.prototype,Object.create(Uint32Array.prototype));Object.assign(Un.prototype,Le.prototype,{constructor:Un,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(On.prototype,Le.prototype,{constructor:On,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Ii.prototype,Le.prototype,{constructor:Ii,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jh=BigInt(4294967296)*BigInt(4294967296),Xh=Jh-BigInt(1);function ga(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),d=0;if(a){for(let p of o)c|=(p^Xh)*(BigInt(1)<<BigInt(64*d++));c*=BigInt(-1),c-=BigInt(1)}else for(let p of o)c|=p*(BigInt(1)<<BigInt(64*d++));if(typeof t=="number"){let p=BigInt(Math.pow(10,t)),S=c/p,A=c%p;return ht(S)+ht(A)/ht(p)}return ht(c)}function Mn(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return ba(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ba(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let o=t[s],a=~o+n;t[s]=a,n&=o===0?1:0}let i=ba(t);return"-".concat(i)}function Xc(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:Mn(r)}function ba(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),i=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,o=n.length-1;do{for(e[0]=n[s=0];s<o;)n[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[s];n[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t="".concat(e[0]).concat(t)}while(i[0]||i[1]||i[2]||i[3]);return t!=null?t:"0"}var Bi=class r{static new(t,e){switch(e){case!0:return new Un(t);case!1:return new On(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Un(t)}return t.byteLength===16?new Ii(t):new On(t)}static signed(t){return new Un(t)}static unsigned(t){return new On(t)}static decimal(t){return new Ii(t)}constructor(t,e){return r.new(t,e)}};var Zc,Qc,tl,el,rl,nl,il,sl,ol,al,cl,ll,ul,dl,fl,hl,pl,ml,yl,_l,bl,gl,M=class r{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 isLargeBinary(t){return(t==null?void 0:t.typeId)===h.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===h.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===h.LargeUtf8}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 isDuration(t){return(t==null?void 0:t.typeId)===h.Duration}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 r.isUnion(t)&&t.mode===At.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===At.Sparse}constructor(t){this.typeId=t}};Zc=Symbol.toStringTag;M[Zc]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(M.prototype);var ee=class extends M{constructor(){super(h.Null)}toString(){return"Null"}};Qc=Symbol.toStringTag;ee[Qc]=(r=>r[Symbol.toStringTag]="Null")(ee.prototype);var $t=class extends M{constructor(t,e){super(h.Int),this.isSigned=t,this.bitWidth=e}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)}};tl=Symbol.toStringTag;$t[tl]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))($t.prototype);var Bs=class extends $t{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Ds=class extends $t{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},rr=class extends $t{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Fs=class extends $t{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},As=class extends $t{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},xs=class extends $t{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ts=class extends $t{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Es=class extends $t{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Bs.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Ds.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(rr.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Fs.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(As.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(xs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ts.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Es.prototype,"ArrayType",{value:BigUint64Array});var we=class extends M{constructor(t){super(h.Float),this.precision=t}get ArrayType(){switch(this.precision){case Dt.HALF:return Uint16Array;case Dt.SINGLE:return Float32Array;case Dt.DOUBLE:return Float64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"Float".concat(this.precision<<5||16)}};el=Symbol.toStringTag;we[el]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(we.prototype);var Us=class extends we{constructor(){super(Dt.HALF)}},Os=class extends we{constructor(){super(Dt.SINGLE)}},Ms=class extends we{constructor(){super(Dt.DOUBLE)}};Object.defineProperty(Us.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Os.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Ms.prototype,"ArrayType",{value:Float64Array});var fr=class extends M{constructor(){super(h.Binary)}toString(){return"Binary"}};rl=Symbol.toStringTag;fr[rl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(fr.prototype);var hr=class extends M{constructor(){super(h.LargeBinary)}toString(){return"LargeBinary"}};nl=Symbol.toStringTag;hr[nl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(hr.prototype);var pr=class extends M{constructor(){super(h.Utf8)}toString(){return"Utf8"}};il=Symbol.toStringTag;pr[il]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(pr.prototype);var mr=class extends M{constructor(){super(h.LargeUtf8)}toString(){return"LargeUtf8"}};sl=Symbol.toStringTag;mr[sl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(mr.prototype);var yr=class extends M{constructor(){super(h.Bool)}toString(){return"Bool"}};ol=Symbol.toStringTag;yr[ol]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(yr.prototype);var _r=class extends M{constructor(t,e,n=128){super(h.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};al=Symbol.toStringTag;_r[al]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(_r.prototype);var br=class extends M{constructor(t){super(h.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat(kt[this.unit],">")}get ArrayType(){return this.unit===kt.DAY?Int32Array:BigInt64Array}};cl=Symbol.toStringTag;br[cl]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(br.prototype);var gr=class extends M{constructor(t,e){super(h.Time),this.unit=t,this.bitWidth=e}toString(){return"Time".concat(this.bitWidth,"<").concat(L[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};ll=Symbol.toStringTag;gr[ll]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(gr.prototype);var wr=class extends M{constructor(t,e){super(h.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(L[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};ul=Symbol.toStringTag;wr[ul]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(wr.prototype);var vr=class extends M{constructor(t){super(h.Interval),this.unit=t}toString(){return"Interval<".concat(jt[this.unit],">")}};dl=Symbol.toStringTag;vr[dl]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(vr.prototype);var Sr=class extends M{constructor(t){super(h.Duration),this.unit=t}toString(){return"Duration<".concat(L[this.unit],">")}};fl=Symbol.toStringTag;Sr[fl]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Sr.prototype);var Ne=class extends M{constructor(t){super(h.List),this.children=[t]}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}};hl=Symbol.toStringTag;Ne[hl]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Ne.prototype);var Et=class extends M{constructor(t){super(h.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};pl=Symbol.toStringTag;Et[pl]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Et.prototype);var ke=class extends M{constructor(t,e,n){super(h.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};ml=Symbol.toStringTag;ke[ml]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(ke.prototype);var Ir=class extends M{constructor(t){super(h.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};yl=Symbol.toStringTag;Ir[yl]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Ir.prototype);var Ce=class extends M{constructor(t,e){super(h.FixedSizeList),this.listSize=t,this.children=[e]}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,">")}};_l=Symbol.toStringTag;Ce[_l]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Ce.prototype);var Pe=class extends M{constructor(t,e=!1){var n,i,s;if(super(h.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t==null?void 0:t.type)===null||n===void 0)&&n.children)){let o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}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(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};bl=Symbol.toStringTag;Pe[bl]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(Pe.prototype);var Zh=(r=>()=>++r)(-1),pe=class extends M{constructor(t,e,n,i){super(h.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?Zh():ht(n)}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,">")}};gl=Symbol.toStringTag;pe[gl]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(pe.prototype);function me(r){let t=r;switch(r.typeId){case h.Decimal:return r.bitWidth/32;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var z=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return Qh(this,t,e)}getVisitFnByTypeId(t,e=!0){return Rn(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function Qh(r,t,e=!0){return typeof t=="number"?Rn(r,t,e):typeof t=="string"&&t in h?Rn(r,h[t],e):t&&t instanceof M?Rn(r,wl(t),e):t!=null&&t.type&&t.type instanceof M?Rn(r,wl(t.type),e):Rn(r,h.NONE,e)}function Rn(r,t,e=!0){let n=null;switch(t){case h.Null:n=r.visitNull;break;case h.Bool:n=r.visitBool;break;case h.Int:n=r.visitInt;break;case h.Int8:n=r.visitInt8||r.visitInt;break;case h.Int16:n=r.visitInt16||r.visitInt;break;case h.Int32:n=r.visitInt32||r.visitInt;break;case h.Int64:n=r.visitInt64||r.visitInt;break;case h.Uint8:n=r.visitUint8||r.visitInt;break;case h.Uint16:n=r.visitUint16||r.visitInt;break;case h.Uint32:n=r.visitUint32||r.visitInt;break;case h.Uint64:n=r.visitUint64||r.visitInt;break;case h.Float:n=r.visitFloat;break;case h.Float16:n=r.visitFloat16||r.visitFloat;break;case h.Float32:n=r.visitFloat32||r.visitFloat;break;case h.Float64:n=r.visitFloat64||r.visitFloat;break;case h.Utf8:n=r.visitUtf8;break;case h.LargeUtf8:n=r.visitLargeUtf8;break;case h.Binary:n=r.visitBinary;break;case h.LargeBinary:n=r.visitLargeBinary;break;case h.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case h.Date:n=r.visitDate;break;case h.DateDay:n=r.visitDateDay||r.visitDate;break;case h.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case h.Timestamp:n=r.visitTimestamp;break;case h.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case h.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case h.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case h.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case h.Time:n=r.visitTime;break;case h.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case h.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case h.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case h.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case h.Decimal:n=r.visitDecimal;break;case h.List:n=r.visitList;break;case h.Struct:n=r.visitStruct;break;case h.Union:n=r.visitUnion;break;case h.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case h.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case h.Dictionary:n=r.visitDictionary;break;case h.Interval:n=r.visitInterval;break;case h.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case h.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case h.Duration:n=r.visitDuration;break;case h.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case h.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case h.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case h.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case h.FixedSizeList:n=r.visitFixedSizeList;break;case h.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(h[t],"'"))}function wl(r){switch(r.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?h.Int8:h.Uint8;case 16:return e?h.Int16:h.Uint16;case 32:return e?h.Int32:h.Uint32;case 64:return e?h.Int64:h.Uint64}return h.Int}case h.Float:switch(r.precision){case Dt.HALF:return h.Float16;case Dt.SINGLE:return h.Float32;case Dt.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.LargeBinary:return h.LargeBinary;case h.Utf8:return h.Utf8;case h.LargeUtf8:return h.LargeUtf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(r.unit){case L.SECOND:return h.TimeSecond;case L.MILLISECOND:return h.TimeMillisecond;case L.MICROSECOND:return h.TimeMicrosecond;case L.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(r.unit){case L.SECOND:return h.TimestampSecond;case L.MILLISECOND:return h.TimestampMillisecond;case L.MICROSECOND:return h.TimestampMicrosecond;case L.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(r.unit){case kt.DAY:return h.DateDay;case kt.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(r.unit){case jt.DAY_TIME:return h.IntervalDayTime;case jt.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Duration:switch(r.unit){case L.SECOND:return h.DurationSecond;case L.MILLISECOND:return h.DurationMillisecond;case L.MICROSECOND:return h.DurationMicrosecond;case L.NANOSECOND:return h.DurationNanosecond}return h.Duration;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(r.mode){case At.Dense:return h.DenseUnion;case At.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[r.typeId],"'"))}z.prototype.visitInt8=null;z.prototype.visitInt16=null;z.prototype.visitInt32=null;z.prototype.visitInt64=null;z.prototype.visitUint8=null;z.prototype.visitUint16=null;z.prototype.visitUint32=null;z.prototype.visitUint64=null;z.prototype.visitFloat16=null;z.prototype.visitFloat32=null;z.prototype.visitFloat64=null;z.prototype.visitDateDay=null;z.prototype.visitDateMillisecond=null;z.prototype.visitTimestampSecond=null;z.prototype.visitTimestampMillisecond=null;z.prototype.visitTimestampMicrosecond=null;z.prototype.visitTimestampNanosecond=null;z.prototype.visitTimeSecond=null;z.prototype.visitTimeMillisecond=null;z.prototype.visitTimeMicrosecond=null;z.prototype.visitTimeNanosecond=null;z.prototype.visitDenseUnion=null;z.prototype.visitSparseUnion=null;z.prototype.visitIntervalDayTime=null;z.prototype.visitIntervalYearMonth=null;z.prototype.visitDuration=null;z.prototype.visitDurationSecond=null;z.prototype.visitDurationMillisecond=null;z.prototype.visitDurationMicrosecond=null;z.prototype.visitDurationNanosecond=null;var va={};Pr(va,{float64ToUint16:()=>Di,uint16ToFloat64:()=>Rs});var vl=new Float64Array(1),Ln=new Uint32Array(vl.buffer);function Rs(r){let t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function Di(r){if(r!==r)return 32256;vl[0]=r;let t=(Ln[1]&2147483648)>>16&65535,e=Ln[1]&2146435072,n=0;return e>=1089470464?Ln[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Ln[1]&1048575)>>10):e<=1056964608?(n=1048576+(Ln[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Ln[1]&1048575)+512>>10),t|e|n&65535}var K=class extends z{};function Q(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var tp=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Sl=(r,t,e,n)=>{if(e+1<t.length){let i=ht(t[e]),s=ht(t[e+1]);r.set(n.subarray(0,s-i),i)}},ep=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Br=({values:r},t,e)=>{r[t]=e},Sa=({values:r},t,e)=>{r[t]=e},Il=({values:r},t,e)=>{r[t]=Di(e)},rp=(r,t,e)=>{switch(r.type.precision){case Dt.HALF:return Il(r,t,e);case Dt.SINGLE:case Dt.DOUBLE:return Sa(r,t,e)}},Ls=({values:r},t,e)=>{tp(r,t,e.valueOf())},Ns=({values:r},t,e)=>{r[t]=BigInt(e)},Ia=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Bl=({values:r,valueOffsets:t},e,n)=>Sl(r,t,e,n),Dl=({values:r,valueOffsets:t},e,n)=>Sl(r,t,e,Xe(n)),Ba=(r,t,e)=>{r.type.unit===kt.DAY?Ls(r,t,e):Ns(r,t,e)},ks=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Cs=({values:r},t,e)=>{r[t]=BigInt(e)},Ps=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Vs=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Da=(r,t,e)=>{switch(r.type.unit){case L.SECOND:return ks(r,t,e);case L.MILLISECOND:return Cs(r,t,e);case L.MICROSECOND:return Ps(r,t,e);case L.NANOSECOND:return Vs(r,t,e)}},Hs=({values:r},t,e)=>{r[t]=e},zs=({values:r},t,e)=>{r[t]=e},js=({values:r},t,e)=>{r[t]=e},Ws=({values:r},t,e)=>{r[t]=e},Fa=(r,t,e)=>{switch(r.type.unit){case L.SECOND:return Hs(r,t,e);case L.MILLISECOND:return zs(r,t,e);case L.MICROSECOND:return js(r,t,e);case L.NANOSECOND:return Ws(r,t,e)}},Aa=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},np=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Yt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e[++o]);else for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e.get(++o))},ip=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Yt.getVisitFn(n),{[t]:o,[t+1]:a}=i,c=e instanceof Map?e.entries():Object.entries(e);for(let d of c)if(s(n,o,d),++o>=a)break},sp=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),op=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),ap=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),cp=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),lp=(r,t,e)=>{let n=r.type.children.map(s=>Yt.getVisitFn(s.type)),i=e instanceof Map?ap(t,e):e instanceof dt?op(t,e):Array.isArray(e)?sp(t,e):cp(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},up=(r,t,e)=>{r.type.mode===At.Dense?Fl(r,t,e):Al(r,t,e)},Fl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Yt.visit(i,r.valueOffsets[t],e)},Al=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Yt.visit(i,t,e)},dp=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},xa=(r,t,e)=>{r.type.unit===jt.DAY_TIME?$s(r,t,e):Gs(r,t,e)},$s=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Gs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Ks=({values:r},t,e)=>{r[t]=e},qs=({values:r},t,e)=>{r[t]=e},Ys=({values:r},t,e)=>{r[t]=e},Js=({values:r},t,e)=>{r[t]=e},Ta=(r,t,e)=>{switch(r.type.unit){case L.SECOND:return Ks(r,t,e);case L.MILLISECOND:return qs(r,t,e);case L.MICROSECOND:return Ys(r,t,e);case L.NANOSECOND:return Js(r,t,e)}},fp=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Yt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)s(i,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)s(i,a+o,e.get(o))};K.prototype.visitBool=Q(ep);K.prototype.visitInt=Q(Br);K.prototype.visitInt8=Q(Br);K.prototype.visitInt16=Q(Br);K.prototype.visitInt32=Q(Br);K.prototype.visitInt64=Q(Br);K.prototype.visitUint8=Q(Br);K.prototype.visitUint16=Q(Br);K.prototype.visitUint32=Q(Br);K.prototype.visitUint64=Q(Br);K.prototype.visitFloat=Q(rp);K.prototype.visitFloat16=Q(Il);K.prototype.visitFloat32=Q(Sa);K.prototype.visitFloat64=Q(Sa);K.prototype.visitUtf8=Q(Dl);K.prototype.visitLargeUtf8=Q(Dl);K.prototype.visitBinary=Q(Bl);K.prototype.visitLargeBinary=Q(Bl);K.prototype.visitFixedSizeBinary=Q(Ia);K.prototype.visitDate=Q(Ba);K.prototype.visitDateDay=Q(Ls);K.prototype.visitDateMillisecond=Q(Ns);K.prototype.visitTimestamp=Q(Da);K.prototype.visitTimestampSecond=Q(ks);K.prototype.visitTimestampMillisecond=Q(Cs);K.prototype.visitTimestampMicrosecond=Q(Ps);K.prototype.visitTimestampNanosecond=Q(Vs);K.prototype.visitTime=Q(Fa);K.prototype.visitTimeSecond=Q(Hs);K.prototype.visitTimeMillisecond=Q(zs);K.prototype.visitTimeMicrosecond=Q(js);K.prototype.visitTimeNanosecond=Q(Ws);K.prototype.visitDecimal=Q(Aa);K.prototype.visitList=Q(np);K.prototype.visitStruct=Q(lp);K.prototype.visitUnion=Q(up);K.prototype.visitDenseUnion=Q(Fl);K.prototype.visitSparseUnion=Q(Al);K.prototype.visitDictionary=Q(dp);K.prototype.visitInterval=Q(xa);K.prototype.visitIntervalDayTime=Q($s);K.prototype.visitIntervalYearMonth=Q(Gs);K.prototype.visitDuration=Q(Ta);K.prototype.visitDurationSecond=Q(Ks);K.prototype.visitDurationMillisecond=Q(qs);K.prototype.visitDurationMicrosecond=Q(Ys);K.prototype.visitDurationNanosecond=Q(Js);K.prototype.visitFixedSizeList=Q(fp);K.prototype.visitMap=Q(ip);var Yt=new K;var Ve=Symbol.for("parent"),Nn=Symbol.for("rowIndex"),qr=class{constructor(t,e){return this[Ve]=t,this[Nn]=e,new Proxy(this,new Ua)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Nn],e=this[Ve],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=Vt.visit(e.children[s],t);return i}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Re(t),": ").concat(Re(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Ea(this[Ve],this[Nn])}},Ea=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Vt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(qr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ve]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Nn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Ua=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ve].type.children.map(e=>e.name)}has(t,e){return t[Ve].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[Ve].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[Ve].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=Vt.visit(t[Ve].children[n],t[Nn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[Ve].type.children.findIndex(s=>s.name===e);return i!==-1?(Yt.visit(t[Ve].children[i],t[Nn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var j=class extends z{};function J(r){return(t,e)=>t.getValid(e)?r(t,e):null}var hp=(r,t)=>864e5*r[t],pp=(r,t)=>null,xl=(r,t,e)=>{if(e+1>=t.length)return null;let n=ht(t[e]),i=ht(t[e+1]);return r.subarray(n,i)},mp=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Tl=({values:r},t)=>hp(r,t),El=({values:r},t)=>ht(r[t]),Yr=({stride:r,values:t},e)=>t[r*e],yp=({stride:r,values:t},e)=>Rs(t[r*e]),Ul=({values:r},t)=>r[t],_p=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Ol=({values:r,valueOffsets:t},e)=>xl(r,t,e),Ml=({values:r,valueOffsets:t},e)=>{let n=xl(r,t,e);return n!==null?ci(n):null},bp=({values:r},t)=>r[t],gp=({type:r,values:t},e)=>r.precision!==Dt.HALF?t[e]:Rs(t[e]),wp=(r,t)=>r.type.unit===kt.DAY?Tl(r,t):El(r,t),Rl=({values:r},t)=>1e3*ht(r[t]),Ll=({values:r},t)=>ht(r[t]),Nl=({values:r},t)=>_a(r[t],BigInt(1e3)),kl=({values:r},t)=>_a(r[t],BigInt(1e6)),vp=(r,t)=>{switch(r.type.unit){case L.SECOND:return Rl(r,t);case L.MILLISECOND:return Ll(r,t);case L.MICROSECOND:return Nl(r,t);case L.NANOSECOND:return kl(r,t)}},Cl=({values:r},t)=>r[t],Pl=({values:r},t)=>r[t],Vl=({values:r},t)=>r[t],Hl=({values:r},t)=>r[t],Sp=(r,t)=>{switch(r.type.unit){case L.SECOND:return Cl(r,t);case L.MILLISECOND:return Pl(r,t);case L.MICROSECOND:return Vl(r,t);case L.NANOSECOND:return Hl(r,t)}},Ip=({values:r,stride:t},e)=>Bi.decimal(r.subarray(t*e,t*(e+1))),Bp=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,c=i[0].slice(s,o-s);return new dt([c])},Dp=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new nr(o.slice(i,s-i))},Fp=(r,t)=>new qr(r,t),Ap=(r,t)=>r.type.mode===At.Dense?zl(r,t):jl(r,t),zl=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Vt.visit(n,r.valueOffsets[t])},jl=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Vt.visit(n,t)},xp=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Tp=(r,t)=>r.type.unit===jt.DAY_TIME?Wl(r,t):$l(r,t),Wl=({values:r},t)=>r.subarray(2*t,2*(t+1)),$l=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},Gl=({values:r},t)=>r[t],Kl=({values:r},t)=>r[t],ql=({values:r},t)=>r[t],Yl=({values:r},t)=>r[t],Ep=(r,t)=>{switch(r.type.unit){case L.SECOND:return Gl(r,t);case L.MILLISECOND:return Kl(r,t);case L.MICROSECOND:return ql(r,t);case L.NANOSECOND:return Yl(r,t)}},Up=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new dt([s])};j.prototype.visitNull=J(pp);j.prototype.visitBool=J(mp);j.prototype.visitInt=J(bp);j.prototype.visitInt8=J(Yr);j.prototype.visitInt16=J(Yr);j.prototype.visitInt32=J(Yr);j.prototype.visitInt64=J(Ul);j.prototype.visitUint8=J(Yr);j.prototype.visitUint16=J(Yr);j.prototype.visitUint32=J(Yr);j.prototype.visitUint64=J(Ul);j.prototype.visitFloat=J(gp);j.prototype.visitFloat16=J(yp);j.prototype.visitFloat32=J(Yr);j.prototype.visitFloat64=J(Yr);j.prototype.visitUtf8=J(Ml);j.prototype.visitLargeUtf8=J(Ml);j.prototype.visitBinary=J(Ol);j.prototype.visitLargeBinary=J(Ol);j.prototype.visitFixedSizeBinary=J(_p);j.prototype.visitDate=J(wp);j.prototype.visitDateDay=J(Tl);j.prototype.visitDateMillisecond=J(El);j.prototype.visitTimestamp=J(vp);j.prototype.visitTimestampSecond=J(Rl);j.prototype.visitTimestampMillisecond=J(Ll);j.prototype.visitTimestampMicrosecond=J(Nl);j.prototype.visitTimestampNanosecond=J(kl);j.prototype.visitTime=J(Sp);j.prototype.visitTimeSecond=J(Cl);j.prototype.visitTimeMillisecond=J(Pl);j.prototype.visitTimeMicrosecond=J(Vl);j.prototype.visitTimeNanosecond=J(Hl);j.prototype.visitDecimal=J(Ip);j.prototype.visitList=J(Bp);j.prototype.visitStruct=J(Fp);j.prototype.visitUnion=J(Ap);j.prototype.visitDenseUnion=J(zl);j.prototype.visitSparseUnion=J(jl);j.prototype.visitDictionary=J(xp);j.prototype.visitInterval=J(Tp);j.prototype.visitIntervalDayTime=J(Wl);j.prototype.visitIntervalYearMonth=J($l);j.prototype.visitDuration=J(Ep);j.prototype.visitDurationSecond=J(Gl);j.prototype.visitDurationMillisecond=J(Kl);j.prototype.visitDurationMicrosecond=J(ql);j.prototype.visitDurationNanosecond=J(Yl);j.prototype.visitFixedSizeList=J(Up);j.prototype.visitMap=J(Dp);var Vt=new j;var Jr=Symbol.for("keys"),Cn=Symbol.for("vals"),kn=Symbol.for("kKeysAsStrings"),Oa=Symbol.for("_kKeysAsStrings"),nr=class{constructor(t){return this[Jr]=new dt([t.children[0]]).memoize(),this[Cn]=t.children[1],new Proxy(this,new Ra)}get[kn](){return this[Oa]||(this[Oa]=Array.from(this[Jr].toArray(),String))}[Symbol.iterator](){return new Ma(this[Jr],this[Cn])}get size(){return this[Jr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Jr],e=this[Cn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=Vt.visit(e,i);return n}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Re(t),": ").concat(Re(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Ma=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Vt.visit(this.vals,t)]})}},Ra=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[kn]}has(t,e){return t[kn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[kn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[kn].indexOf(e);if(n!==-1){let i=Vt.visit(Reflect.get(t,Cn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[kn].indexOf(e);return i!==-1?(Yt.visit(Reflect.get(t,Cn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(nr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Jr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Cn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Oa]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Jl;function Fi(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(Jl=s,s=o,o=Jl),o>i&&(o=i),n?n(r,s,o):[s,o]}var an=(r,t)=>r<0?t+r:r,Xl=r=>r!==r;function Xr(r){if(typeof r!=="object"||r===null)return Xl(r)?Xl:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?fa(r,e):!1:r instanceof Map?Mp(r):Array.isArray(r)?Op(r):r instanceof dt?Rp(r):Lp(r,!0)}function Op(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Xr(r[e]);return Xs(t)}function Mp(r){let t=-1,e=[];for(let n of r.values())e[++t]=Xr(n);return Xs(e)}function Rp(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Xr(r.get(e));return Xs(t)}function Lp(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let i=-1,s=e.length;++i<s;)n[i]=Xr(r[e[i]]);return Xs(n,e)}function Xs(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Np(r,e);case Map:return Zl(r,e,e.keys());case nr:case qr:case Object:case void 0:return Zl(r,e,t||Object.keys(e))}return e instanceof dt?kp(r,e):!1}}function Np(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function kp(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function Zl(r,t,e){let n=e[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,a=r.length,c=s.next(),d=n.next(),p=i.next();for(;o<a&&!d.done&&!p.done&&!c.done&&!(d.value!==p.value||!r[o](c.value));++o,d=n.next(),p=i.next(),c=s.next());return o===a&&d.done&&p.done&&c.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var Na={};Pr(Na,{BitIterator:()=>cn,getBit:()=>Ql,getBool:()=>Qs,packBools:()=>un,popcnt_array:()=>tu,popcnt_bit_range:()=>Ai,popcnt_uint32:()=>Zs,setBool:()=>Cp,truncateBitmap:()=>ln});function Qs(r,t,e,n){return(e&1<<n)!==0}function Ql(r,t,e,n){return(e&1<<n)>>n}function Cp(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function ln(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let i=new Uint8Array(n);return i.set(r%8===0?e.subarray(r>>3):un(new cn(e,r,t,null,Qs)).subarray(0,n)),i}return e}function un(r){let t=[],e=0,n=0,i=0;for(let o of r)o&&(i|=1<<n),++n===8&&(t[e++]=i,i=n=0);(e===0||n>0)&&(t[e++]=i);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var cn=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Ai(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new cn(r,t,e-t,r,Ql))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Ai(r,t,i)+Ai(r,n,e)+tu(r,i>>3,n-i>>3)}function tu(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=Zs(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=Zs(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=Zs(s.getUint8(i)),i+=1;return n}function Zs(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Pp=-1,_t=class r{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return M.isSparseUnion(t)?this.children.some(e=>e.nullable):M.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(M.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=Pp&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Ai(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof r?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=me(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(M.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===At.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(M.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===At.Dense?this.valueOffsets[t]:t;n=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,d=1<<c%8,p=c>>3;(!s||s.byteLength<=p)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(ln(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let S=s[p];n=(S&d)!==0,s[p]=e?S|d:S&~d}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new r(t,e,n,i,s,o,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?n:1,c=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===h.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<<e-(e&-8))-1,n>0&&i.set(ln(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[ge.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:o}=this;return(s=o[ge.TYPE])&&(o[ge.TYPE]=s.subarray(t,t+e)),(s=o[ge.OFFSET])&&(o[ge.OFFSET]=s.subarray(t,t+e+1))||(s=o[ge.DATA])&&(o[ge.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};_t.prototype.children=Object.freeze([]);var ka=class r extends z{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new _t(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.data),s=Y(t.nullBitmap),o=sn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.data),s=Y(t.nullBitmap),o=_s(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.data),s=Y(t.nullBitmap),o=sn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.data),s=Y(t.nullBitmap),o=_s(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=Y(t.nullBitmap),o=sn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=Y(t.nullBitmap),{length:o=i.reduce((c,{length:d})=>Math.max(c,d),0),nullCount:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=at(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(M.isSparseUnion(e))return new _t(e,n,o,a,[void 0,void 0,void 0,s],i);let c=sn(t.valueOffsets);return new _t(e,n,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.indices.ArrayType,t.data),{["dictionary"]:o=new dt([new r().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=Y(t.nullBitmap),s=at(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=Y(t.nullBitmap),{["length"]:o=i.length/me(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new _t(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.childType})}=t,s=Y(t.nullBitmap),o=sn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new _t(e,n,a,c,[o,void 0,s],[i])}},Vp=new ka;function tt(r){return Vp.visit(r)}var xi=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function eu(r){return r.some(t=>t.nullable)}function to(r){return r.reduce((t,e)=>t+e.nullCount,0)}function eo(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function ro(r,t,e,n){let i=[];for(let s=-1,o=r.length;++s<o;){let a=r[s],c=t[s],{length:d}=a;if(c>=n)break;if(e>=c+d)continue;if(c>=e&&c+d<=n){i.push(a);continue}let p=Math.max(0,e-c),S=Math.min(n-c,d);i.push(a.slice(p,S-p))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Ca(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e<t[o]?n(r,i,e-t[i]):null;s=i+Math.trunc((o-i)*.5),e<t[s]?o=s:i=s}while(i<o)}function Ti(r,t){return r.getValid(t)}function Pn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Ca(n,this._offsets,e,t)}}function no(r){let t;function e(n,i,s){return r(n[i],s,t)}return function(n,i){let s=this.data;t=i;let o=Ca(s,this._offsets,n,e);return t=void 0,o}}function io(r){let t;function e(n,i,s){let o=s,a=0,c=0;for(let d=i-1,p=n.length;++d<p;){let S=n[d];if(~(a=r(S,t,o)))return c+a;o=0,c+=S.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):Ca(s,this._offsets,i,e);return t=void 0,o}}var W=class extends z{};function Hp(r,t){return t===null&&r.length>0?0:-1}function zp(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new cn(e,r.offset+(t||0),r.length,e,Qs)){if(!i)return n;++n}return-1}function et(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case h.Union:break;case h.Dictionary:break;default:return zp(r,e)}let n=Vt.getVisitFn(r),i=Xr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function ru(r,t,e){let n=Vt.getVisitFn(r),i=Xr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}W.prototype.visitNull=Hp;W.prototype.visitBool=et;W.prototype.visitInt=et;W.prototype.visitInt8=et;W.prototype.visitInt16=et;W.prototype.visitInt32=et;W.prototype.visitInt64=et;W.prototype.visitUint8=et;W.prototype.visitUint16=et;W.prototype.visitUint32=et;W.prototype.visitUint64=et;W.prototype.visitFloat=et;W.prototype.visitFloat16=et;W.prototype.visitFloat32=et;W.prototype.visitFloat64=et;W.prototype.visitUtf8=et;W.prototype.visitLargeUtf8=et;W.prototype.visitBinary=et;W.prototype.visitLargeBinary=et;W.prototype.visitFixedSizeBinary=et;W.prototype.visitDate=et;W.prototype.visitDateDay=et;W.prototype.visitDateMillisecond=et;W.prototype.visitTimestamp=et;W.prototype.visitTimestampSecond=et;W.prototype.visitTimestampMillisecond=et;W.prototype.visitTimestampMicrosecond=et;W.prototype.visitTimestampNanosecond=et;W.prototype.visitTime=et;W.prototype.visitTimeSecond=et;W.prototype.visitTimeMillisecond=et;W.prototype.visitTimeMicrosecond=et;W.prototype.visitTimeNanosecond=et;W.prototype.visitDecimal=et;W.prototype.visitList=et;W.prototype.visitStruct=et;W.prototype.visitUnion=et;W.prototype.visitDenseUnion=ru;W.prototype.visitSparseUnion=ru;W.prototype.visitDictionary=et;W.prototype.visitInterval=et;W.prototype.visitIntervalDayTime=et;W.prototype.visitIntervalYearMonth=et;W.prototype.visitDuration=et;W.prototype.visitDurationSecond=et;W.prototype.visitDurationMillisecond=et;W.prototype.visitDurationMicrosecond=et;W.prototype.visitDurationNanosecond=et;W.prototype.visitFixedSizeList=et;W.prototype.visitMap=et;var dn=new W;var $=class extends z{};function X(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(M.isInt(t)&&t.bitWidth!==64||M.isTime(t)&&t.bitWidth!==64||M.isFloat(t)&&t.precision!==Dt.HALF))return new xi(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new xi(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Pa(o)})}var Pa=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};$.prototype.visitNull=X;$.prototype.visitBool=X;$.prototype.visitInt=X;$.prototype.visitInt8=X;$.prototype.visitInt16=X;$.prototype.visitInt32=X;$.prototype.visitInt64=X;$.prototype.visitUint8=X;$.prototype.visitUint16=X;$.prototype.visitUint32=X;$.prototype.visitUint64=X;$.prototype.visitFloat=X;$.prototype.visitFloat16=X;$.prototype.visitFloat32=X;$.prototype.visitFloat64=X;$.prototype.visitUtf8=X;$.prototype.visitLargeUtf8=X;$.prototype.visitBinary=X;$.prototype.visitLargeBinary=X;$.prototype.visitFixedSizeBinary=X;$.prototype.visitDate=X;$.prototype.visitDateDay=X;$.prototype.visitDateMillisecond=X;$.prototype.visitTimestamp=X;$.prototype.visitTimestampSecond=X;$.prototype.visitTimestampMillisecond=X;$.prototype.visitTimestampMicrosecond=X;$.prototype.visitTimestampNanosecond=X;$.prototype.visitTime=X;$.prototype.visitTimeSecond=X;$.prototype.visitTimeMillisecond=X;$.prototype.visitTimeMicrosecond=X;$.prototype.visitTimeNanosecond=X;$.prototype.visitDecimal=X;$.prototype.visitList=X;$.prototype.visitStruct=X;$.prototype.visitUnion=X;$.prototype.visitDenseUnion=X;$.prototype.visitSparseUnion=X;$.prototype.visitDictionary=X;$.prototype.visitInterval=X;$.prototype.visitIntervalDayTime=X;$.prototype.visitIntervalYearMonth=X;$.prototype.visitDuration=X;$.prototype.visitDurationSecond=X;$.prototype.visitDurationMillisecond=X;$.prototype.visitDurationMicrosecond=X;$.prototype.visitDurationNanosecond=X;$.prototype.visitFixedSizeList=X;$.prototype.visitMap=X;var Vn=new $;var nu,iu={},su={},dt=class r{constructor(t){var e,n,i;let s=t[0]instanceof r?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof _t)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:d}=iu[o.typeId],p=s[0];this.isValid=S=>Ti(p,S),this.get=S=>a(p,S),this.set=(S,A)=>c(p,S,A),this.indexOf=S=>d(p,S),this._offsets=[0,p.length];break}default:Object.setPrototypeOf(this,su[o.typeId]),this._offsets=eo(s);break}this.data=s,this.type=o,this.stride=me(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return eu(this.data)}get nullCount(){return to(this.data)}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}at(t){return this.get(an(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Vn.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(Fi(this,t,e,({data:n,_offsets:i},s,o)=>ro(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return"[".concat([...this].join(","),"]")}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return M.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(M.isDictionary(this.type)){let t=new so(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new so(this)}unmemoize(){if(M.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return this}};nu=Symbol.toStringTag;dt[nu]=(r=>{r.type=M.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(h).map(e=>h[e]).filter(e=>typeof e=="number"&&e!==h.NONE);for(let e of t){let n=Vt.getVisitFnByTypeId(e),i=Yt.getVisitFnByTypeId(e),s=dn.getVisitFnByTypeId(e);iu[e]={get:n,set:i,indexOf:s},su[e]=Object.create(r,{isValid:{value:Pn(Ti)},get:{value:Pn(Vt.getVisitFnByTypeId(e))},set:{value:no(Yt.getVisitFnByTypeId(e))},indexOf:{value:io(dn.getVisitFnByTypeId(e))}})}return"Vector"})(dt.prototype);var so=class r extends dt{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new r(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new dt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ou(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t="\n switch (x) {".concat(e.map(n=>"\n case ".concat(jp(n),":")).join(""),"\n return false;\n }")),r.length!==e.length&&(t="if (x !== x) return false;\n".concat(t)),new Function("x","".concat(t,"\nreturn true;"))}function jp(r){return typeof r!="bigint"?Re(r):"".concat(Re(r),"n")}function Va(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function au(r,t=0){return r.length>=t?r.subarray(0,t):ui(new r.constructor(t),r,0)}var He=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=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(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?Va(n*1,this.BYTES_PER_ELEMENT):Va(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Va(t*this.stride,this.BYTES_PER_ELEMENT);let e=au(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=au(this.buffer,t)}},Dr=class extends He{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Hn=class extends Dr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},zn=class extends Dr{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var Mt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=me(t),this._nulls=new Hn,e&&e.length>0&&(this._isValid=ou(e))}toVector(){return new dt([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e="".concat(this.numChildren)){throw new Error('Cannot append children to non-nested type "'.concat(this.type,'"'))}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:d,_values:p,_nulls:S}=this;(e=c==null?void 0:c.flush(o))?i=d==null?void 0:d.flush(o):(i=d==null?void 0:d.flush(o))?t=p==null?void 0:p.flush(d.last()):t=p==null?void 0:p.flush(o),a>0&&(n=S==null?void 0:S.flush(o));let A=this.children.map(x=>x.flush());return this.clear(),tt({type:s,length:o,nullCount:a,children:A,child:A[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};Mt.prototype.length=1;Mt.prototype.stride=1;Mt.prototype.children=null;Mt.prototype.finished=!1;Mt.prototype.nullValues=null;Mt.prototype._isValid=()=>!0;var Ht=class extends Mt{constructor(t){super(t),this._values=new Dr(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},se=class extends Mt{constructor(t){super(t),this._pendingLength=0,this._offsets=new zn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof nr?e[Jr].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var fn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i!=null?i:0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var ye=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__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):wt.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ie).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new fn).__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,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new fn).__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,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Wt).__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,e){t.addFieldInt16(0,e,wt.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var St=class r{constructor(t=[],e,n,i=wt.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Ha(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return"Schema<{ ".concat(this.fields.map((t,e)=>"".concat(e,": ").concat(t)).join(", ")," }>")}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new r(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),n=[...this.fields],i=oo(oo(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=n.findIndex(d=>d.name===a.name);return~c?(n[c]=a.clone({metadata:oo(oo(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Ha(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...o]))}};St.prototype.fields=null;St.prototype.metadata=null;St.prototype.dictionaries=null;var ct=class r{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new r("".concat(e),n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return"".concat(this.name,": ").concat(this.type)}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],r.new(e,n,i,s)}};ct.prototype.type=null;ct.prototype.name=null;ct.prototype.nullable=null;ct.prototype.metadata=null;function oo(r,t){return new Map([...r||new Map,...t||new Map])}function Ha(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(M.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&Ha(s.children,t)}return t}var Wp=on,$p=fe,Fr=class{static decode(t){t=new $p(Y(t));let e=ye.getRootAsFooter(t),n=St.decode(e.schema(),new Map,e.version());return new za(n,e)}static encode(t){let e=new Wp,n=St.encode(e,t.schema);ye.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Ar.encode(e,o);let i=e.endVector();ye.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Ar.encode(e,o);let s=e.endVector();return ye.startFooter(e),ye.addSchema(e,n),ye.addVersion(e,wt.V5),ye.addRecordBatches(e,i),ye.addDictionaries(e,s),ye.finishFooterBuffer(e,ye.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=wt.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var za=class extends Fr{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return Ar.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Ar.decode(e)}return null}},Ar=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return fn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=ht(n),this.bodyLength=ht(e)}};var Ut=Object.freeze({done:!0,value:void 0}),Ei=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},hn=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},ao=class extends hn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return O(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Ut);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return qt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return qt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return O(this,void 0,void 0,function*(){return yield this.abort(t),Ut})}return(t){return O(this,void 0,void 0,function*(){return yield this.close(),Ut})}read(t){return O(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return O(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Ut)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var ir=class extends ao{write(t){if((t=Y(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?ci(this.toUint8Array(!0)):this.toUint8Array(!1).then(ci)}toUint8Array(t=!1){return t?de(this._values)[0]:O(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,d=Ae(this),p;p=yield d.next(),e=p.done,!e;c=!0){s=p.value,c=!1;let S=s;o.push(S),a+=S.byteLength}}catch(S){n={error:S}}finally{try{!c&&!e&&(i=d.return)&&(yield i.call(d))}finally{if(n)throw n.error}}return de(o,a)[0]})}},sr=class{constructor(t){t&&(this.source=new ja(qt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},ve=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof ir?this.source=new xr(qt.fromAsyncIterable(t)):ys(t)?this.source=new xr(qt.fromNodeStream(t)):li(t)?this.source=new xr(qt.fromDOMStream(t)):ps(t)?this.source=new xr(qt.fromDOMStream(t.body)):Te(t)?this.source=new xr(qt.fromIterable(t)):xe(t)?this.source=new xr(qt.fromAsyncIterable(t)):_e(t)&&(this.source=new xr(qt.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)}},ja=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Ut)}return(t){return Object.create(this.source.return&&this.source.return(t)||Ut)}},xr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return O(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return O(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return O(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return O(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return O(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||Ut;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return O(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||Ut;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Ui=class extends sr{constructor(t,e){super(),this.position=0,this.buffer=Y(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},Zr=class extends ve{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=O(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return O(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return O(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return O(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-s,t)),d=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<d.byteLength;)({bytesRead:a}=yield e.read(d,o,d.byteLength-o,s));return d}return null})}readAt(t,e){return O(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return O(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return O(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return O(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var $a={};Pr($a,{BaseInt64:()=>Oi,Int128:()=>Mi,Int64:()=>Tr,Uint64:()=>Nt});function jn(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var Wn=8,Wa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Oi=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return"".concat(jn(this.buffer[1])," ").concat(jn(this.buffer[0]))}},Nt=class r extends Oi{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new r(e);for(let s=0;s<n;){let o=Wn<n-s?Wn:n-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([Wa[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Tr=class r extends Oi{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let o=n?1:0;o<i;){let a=Wn<i-o?Wn:i-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),d=new r(new Uint32Array([Wa[a],0]));s.times(d),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Mi=class r{constructor(t){this.buffer=t}high(){return new Tr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Tr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new Nt(new Uint32Array([this.buffer[3],0])),n=new Nt(new Uint32Array([this.buffer[2],0])),i=new Nt(new Uint32Array([this.buffer[1],0])),s=new Nt(new Uint32Array([this.buffer[0],0])),o=new Nt(new Uint32Array([t.buffer[3],0])),a=new Nt(new Uint32Array([t.buffer[2],0])),c=new Nt(new Uint32Array([t.buffer[1],0])),d=new Nt(new Uint32Array([t.buffer[0],0])),p=Nt.multiply(s,d);this.buffer[0]=p.low();let S=new Nt(new Uint32Array([p.high(),0]));return p=Nt.multiply(i,d),S.plus(p),p=Nt.multiply(s,c),S.plus(p),this.buffer[1]=S.low(),this.buffer[3]=S.lessThan(p)?1:0,this.buffer[2]=S.high(),new Nt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Nt.multiply(n,d)).plus(Nt.multiply(i,c)).plus(Nt.multiply(s,a)),this.buffer[3]+=Nt.multiply(e,d).plus(Nt.multiply(n,c)).plus(Nt.multiply(i,a)).plus(Nt.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return"".concat(jn(this.buffer[3])," ").concat(jn(this.buffer[2])," ").concat(jn(this.buffer[1])," ").concat(jn(this.buffer[0]))}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let o=n?1:0;o<i;){let a=Wn<i-o?Wn:i-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),d=new r(new Uint32Array([Wa[a],0,0,0]));s.times(d),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var Ri=class extends z{constructor(t,e,n,i,s=wt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof ct?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return tt({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<wt.V5&&this.readNullBitmap(t,n),t.mode===At.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return tt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},co=class extends Ri{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):un(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return at(Uint8Array,at(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return at(Uint8Array,at(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return M.isTimestamp(t)?at(Uint8Array,Tr.convertArray(n[e])):(M.isInt(t)||M.isTime(t))&&t.bitWidth===64||M.isDuration(t)?at(Uint8Array,Tr.convertArray(n[e])):M.isDate(t)&&t.unit===kt.MILLISECOND?at(Uint8Array,Tr.convertArray(n[e])):M.isDecimal(t)?at(Uint8Array,Mi.convertArray(n[e])):M.isBinary(t)||M.isLargeBinary(t)||M.isFixedSizeBinary(t)?Gp(n[e]):M.isBool(t)?un(n[e]):M.isUtf8(t)||M.isLargeUtf8(t)?Xe(n[e].join("")):at(Uint8Array,at(t.ArrayType,n[e].map(i=>+i)))}};function Gp(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var $n=class extends se{constructor(t){super(t),this._values=new He(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Y(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;i.set(a,s),n.set(o,c),s+=c}}};var Gn=class extends se{constructor(t){super(t),this._values=new He(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Y(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;i.set(a,s),n.set(o,BigInt(c)),s+=c}}};var lo=class extends Mt{constructor(t){super(t),this._values=new Hn}setValue(t,e){this._values.set(t,+e)}};var pn=class extends Ht{};pn.prototype._setValue=Ba;var Li=class extends pn{};Li.prototype._setValue=Ls;var Ni=class extends pn{};Ni.prototype._setValue=Ns;var ki=class extends Ht{};ki.prototype._setValue=Aa;var uo=class extends Mt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new pe(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=mn({type:this.type.indices,nullValues:e}),this.dictionary=mn({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:"".concat(t)}};var Ci=class extends Ht{};Ci.prototype._setValue=Ia;var fo=class extends Mt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new Ce(this.type.listSize,new ct(e,t.type,!0)),n}};var yn=class extends Ht{setValue(t,e){this._values.set(t,e)}},ho=class extends yn{setValue(t,e){super.setValue(t,Di(e))}},po=class extends yn{},mo=class extends yn{};var _n=class extends Ht{};_n.prototype._setValue=xa;var Pi=class extends _n{};Pi.prototype._setValue=$s;var Vi=class extends _n{};Vi.prototype._setValue=Gs;var Er=class extends Ht{};Er.prototype._setValue=Ta;var Hi=class extends Er{};Hi.prototype._setValue=Ks;var zi=class extends Er{};zi.prototype._setValue=qs;var ji=class extends Er{};ji.prototype._setValue=Ys;var Wi=class extends Er{};Wi.prototype._setValue=Js;var Se=class extends Ht{setValue(t,e){this._values.set(t,e)}},yo=class extends Se{},_o=class extends Se{},bo=class extends Se{},go=class extends Se{},wo=class extends Se{},vo=class extends Se{},So=class extends Se{},Io=class extends Se{};var Bo=class extends se{constructor(t){super(t),this._offsets=new zn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ne(new ct(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,a=o.length,c=e.set(i,a).buffer[i];for(let d=-1;++d<a;)n.set(c+d,o[d])}}};var Do=class extends se{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e="".concat(this.numChildren)){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Pe(new ct(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:a}=e.set(i,s.size).buffer;for(let c of s.entries())if(n.set(o,c),++o>=a)break}}};var Fo=class extends Mt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Ao=class extends Mt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e="".concat(this.numChildren)){let n=this.children.push(t);return this.type=new Et([...this.type.children,new ct(e,t.type,!0)]),n}};var Ur=class extends Ht{};Ur.prototype._setValue=Da;var $i=class extends Ur{};$i.prototype._setValue=ks;var Gi=class extends Ur{};Gi.prototype._setValue=Cs;var Ki=class extends Ur{};Ki.prototype._setValue=Ps;var qi=class extends Ur{};qi.prototype._setValue=Vs;var Or=class extends Ht{};Or.prototype._setValue=Fa;var Yi=class extends Or{};Yi.prototype._setValue=Hs;var Ji=class extends Or{};Ji.prototype._setValue=zs;var Xi=class extends Or{};Xi.prototype._setValue=js;var Zi=class extends Or{};Zi.prototype._setValue=Ws;var Kn=class extends Mt{constructor(t){super(t),this._typeIds=new Dr(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s==null||s.set(t,e)}addChild(t,e="".concat(this.children.length)){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new ct(e,t.type)];return this.type=new ke(s,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},xo=class extends Kn{},To=class extends Kn{constructor(t){super(t),this._offsets=new Dr(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s==null||s.set(o,e)}};var Qi=class extends se{constructor(t){super(t),this._values=new He(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};Qi.prototype._flushPending=$n.prototype._flushPending;var ts=class extends se{constructor(t){super(t),this._values=new He(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Xe(e))}_flushPending(t,e){}};ts.prototype._flushPending=Gn.prototype._flushPending;var Ga=class extends z{visitNull(){return Fo}visitBool(){return lo}visitInt(){return Se}visitInt8(){return yo}visitInt16(){return _o}visitInt32(){return bo}visitInt64(){return go}visitUint8(){return wo}visitUint16(){return vo}visitUint32(){return So}visitUint64(){return Io}visitFloat(){return yn}visitFloat16(){return ho}visitFloat32(){return po}visitFloat64(){return mo}visitUtf8(){return Qi}visitLargeUtf8(){return ts}visitBinary(){return $n}visitLargeBinary(){return Gn}visitFixedSizeBinary(){return Ci}visitDate(){return pn}visitDateDay(){return Li}visitDateMillisecond(){return Ni}visitTimestamp(){return Ur}visitTimestampSecond(){return $i}visitTimestampMillisecond(){return Gi}visitTimestampMicrosecond(){return Ki}visitTimestampNanosecond(){return qi}visitTime(){return Or}visitTimeSecond(){return Yi}visitTimeMillisecond(){return Ji}visitTimeMicrosecond(){return Xi}visitTimeNanosecond(){return Zi}visitDecimal(){return ki}visitList(){return Bo}visitStruct(){return Ao}visitUnion(){return Kn}visitDenseUnion(){return To}visitSparseUnion(){return xo}visitDictionary(){return uo}visitInterval(){return _n}visitIntervalDayTime(){return Pi}visitIntervalYearMonth(){return Vi}visitDuration(){return Er}visitDurationSecond(){return Hi}visitDurationMillisecond(){return zi}visitDurationMicrosecond(){return ji}visitDurationNanosecond(){return Wi}visitFixedSizeList(){return fo}visitMap(){return Do}},cu=new Ga;var G=class extends z{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function re(r,t){return t instanceof r.constructor}function bn(r,t){return r===t||re(r,t)}function Mr(r,t){return r===t||re(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Eo(r,t){return r===t||re(r,t)&&r.precision===t.precision}function Kp(r,t){return r===t||re(r,t)&&r.byteWidth===t.byteWidth}function Ka(r,t){return r===t||re(r,t)&&r.unit===t.unit}function es(r,t){return r===t||re(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function rs(r,t){return r===t||re(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function qp(r,t){return r===t||re(r,t)&&r.children.length===t.children.length&&or.compareManyFields(r.children,t.children)}function Yp(r,t){return r===t||re(r,t)&&r.children.length===t.children.length&&or.compareManyFields(r.children,t.children)}function qa(r,t){return r===t||re(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&or.compareManyFields(r.children,t.children)}function Jp(r,t){return r===t||re(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&or.visit(r.indices,t.indices)&&or.visit(r.dictionary,t.dictionary)}function Ya(r,t){return r===t||re(r,t)&&r.unit===t.unit}function ns(r,t){return r===t||re(r,t)&&r.unit===t.unit}function Xp(r,t){return r===t||re(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&or.compareManyFields(r.children,t.children)}function Zp(r,t){return r===t||re(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&or.compareManyFields(r.children,t.children)}G.prototype.visitNull=bn;G.prototype.visitBool=bn;G.prototype.visitInt=Mr;G.prototype.visitInt8=Mr;G.prototype.visitInt16=Mr;G.prototype.visitInt32=Mr;G.prototype.visitInt64=Mr;G.prototype.visitUint8=Mr;G.prototype.visitUint16=Mr;G.prototype.visitUint32=Mr;G.prototype.visitUint64=Mr;G.prototype.visitFloat=Eo;G.prototype.visitFloat16=Eo;G.prototype.visitFloat32=Eo;G.prototype.visitFloat64=Eo;G.prototype.visitUtf8=bn;G.prototype.visitLargeUtf8=bn;G.prototype.visitBinary=bn;G.prototype.visitLargeBinary=bn;G.prototype.visitFixedSizeBinary=Kp;G.prototype.visitDate=Ka;G.prototype.visitDateDay=Ka;G.prototype.visitDateMillisecond=Ka;G.prototype.visitTimestamp=es;G.prototype.visitTimestampSecond=es;G.prototype.visitTimestampMillisecond=es;G.prototype.visitTimestampMicrosecond=es;G.prototype.visitTimestampNanosecond=es;G.prototype.visitTime=rs;G.prototype.visitTimeSecond=rs;G.prototype.visitTimeMillisecond=rs;G.prototype.visitTimeMicrosecond=rs;G.prototype.visitTimeNanosecond=rs;G.prototype.visitDecimal=bn;G.prototype.visitList=qp;G.prototype.visitStruct=Yp;G.prototype.visitUnion=qa;G.prototype.visitDenseUnion=qa;G.prototype.visitSparseUnion=qa;G.prototype.visitDictionary=Jp;G.prototype.visitInterval=Ya;G.prototype.visitIntervalDayTime=Ya;G.prototype.visitIntervalYearMonth=Ya;G.prototype.visitDuration=ns;G.prototype.visitDurationSecond=ns;G.prototype.visitDurationMillisecond=ns;G.prototype.visitDurationMicrosecond=ns;G.prototype.visitDurationNanosecond=ns;G.prototype.visitFixedSizeList=Xp;G.prototype.visitMap=Zp;var or=new G;function gn(r,t){return or.compareSchemas(r,t)}function lu(r,t){return or.compareFields(r,t)}function uu(r,t){return or.visit(r,t)}function mn(r){let t=r.type,e=new(cu.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,a)=>n[a]||i:({name:o})=>n[o]||i;for(let[o,a]of t.children.entries()){let{type:c}=a,d=s(a,o);e.children.push(mn(Object.assign(Object.assign({},d),{type:c})))}}return e}function Uo(r,t){return Qp(r,t.map(e=>e.data.concat()))}function Qp(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((S,A)=>Math.max(S,A.length),0)},s=0,o=0,a=-1,c=t.length,d,p=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)p[a]=d=t[a].shift(),o=Math.min(o,d?d.length:o);Number.isFinite(o)&&(p=tm(e,o,p,t,i),o>0&&(n[s++]=tt({type:new Et(e),length:o,nullCount:0,children:p.slice()})))}return[r=r.assign(e),n.map(S=>new Ct(r,S))]}function tm(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let d=e[a],p=d==null?void 0:d.length;if(p>=t)p===t?e[a]=d:(e[a]=d.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(d.slice(t,p-t))));else{let S=r[a];r[a]=S.clone({nullable:!0}),e[a]=(s=d==null?void 0:d._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:tt({type:S.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var du,ne=class r{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new St([]),this._offsets=[0],this;let i,s;t[0]instanceof St&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Ct)return[c];if(c instanceof r)return c.batches;if(c instanceof _t){if(c.type instanceof Et)return[new Ct(new St(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(d=>o(d));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(d=>o(d));if(typeof c=="object"){let d=Object.keys(c),p=d.map(x=>new dt([c[x]])),S=i!=null?i:new St(d.map((x,ot)=>new ct(String(x),p[ot].type,p[ot].nullable))),[,A]=Uo(S,p);return A.length===0?[new Ct(c)]:A}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i!=null?i:(e=a[0])===null||e===void 0?void 0:e.schema)!==null&&n!==void 0?n:new St([]),!(i instanceof St))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Ct))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!gn(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s!=null?s:eo(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=to(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(an(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Vn.visit(new dt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return"[\n ".concat(this.toArray().join(",\n "),"\n]")}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new r(e,n.map(i=>new Ct(e,i)))}slice(t,e){let n=this.schema;[t,e]=Fi({length:this.numRows},t,e);let i=ro(this.data,this._offsets,t,e);return new r(n,i.map(s=>new Ct(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=tt({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new dt(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new dt([tt({type:new ee,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,d)=>this.getChildAt(d));[s[t],a[t]]=[o,e],[n,i]=Uo(n,a)}return new r(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new r(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,d)=>{let[p,S]=a,A=e.findIndex(x=>x.name===c.name);return~A?S[A]=d:p.push(d),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...Uo(s,o))}};du=Symbol.toStringTag;ne[du]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Pn(Ti),r.get=Pn(Vt.getVisitFn(h.Struct)),r.set=no(Yt.getVisitFn(h.Struct)),r.indexOf=io(dn.getVisitFn(h.Struct)),"Table"))(ne.prototype);var hu,Ct=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof St))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=tt({nullCount:0,type:new Et(this.schema.fields),children:this.schema.fields.map(e=>tt({type:e.type,nullCount:0}))})]=t,!(this.data instanceof _t))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=fu(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((c,d,p)=>(c.children[p]=e[d],c.length=Math.max(c.length,e[d].length),c.fields[p]=ct.new({name:d,type:e[d].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new St(n),a=tt({type:new Et(n),length:s,children:i,nullCount:0});[this.schema,this.data]=fu(o,a.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=pu(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 Vt.visit(this.data,t)}at(t){return this.get(an(t,this.numRows))}set(t,e){return Yt.visit(this.data,t,e)}indexOf(t,e){return dn.visit(this.data,t,e)}[Symbol.iterator](){return Vn.visit(new dt([this.data]))}toArray(){return[...this]}concat(...t){return new ne(this.schema,[this,...t])}slice(t,e){let[n]=new dt([this.data]).slice(t,e).data;return new r(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new dt([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new dt([tt({type:new ee,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new St(s,new Map(this.schema.metadata)),i=tt({type:new Et(s),children:o})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Et(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new r(e,tt({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=tt({type:new Et(e.fields),length:this.numRows,children:n});return new r(e,i)}};hu=Symbol.toStringTag;Ct[hu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ct.prototype);function fu(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let d=t[a];(!d||d.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=d==null?void 0:d._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:tt({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),tt({type:new Et(i),length:e,children:s})]}function pu(r,t,e=new Map){var n,i;if(((n=r==null?void 0:r.length)!==null&&n!==void 0?n:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let d of[c,...((i=c==null?void 0:c.dictionary)===null||i===void 0?void 0:i.data)||[]])pu(a.children,d==null?void 0:d.children,e);if(M.isDictionary(a)){let{id:d}=a;if(!e.has(d))c!=null&&c.dictionary&&e.set(d,c.dictionary);else if(e.get(d)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var wn=class extends Ct{constructor(t){let e=t.fields.map(i=>tt({type:i.type})),n=tt({type:new Et(t.fields),nullCount:0,children:e});super(t,n)}};var ze=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__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):wt.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ut.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Wt).__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,e){t.addFieldInt16(0,e,wt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,ut.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var Ja=class extends z{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return wi.startNull(e),wi.endNull(e)}visitInt(t,e){return Oe.startInt(e),Oe.addBitWidth(e,t.bitWidth),Oe.addIsSigned(e,t.isSigned),Oe.endInt(e)}visitFloat(t,e){return $r.startFloatingPoint(e),$r.addPrecision(e,t.precision),$r.endFloatingPoint(e)}visitBinary(t,e){return mi.startBinary(e),mi.endBinary(e)}visitLargeBinary(t,e){return _i.startLargeBinary(e),_i.endLargeBinary(e)}visitBool(t,e){return yi.startBool(e),yi.endBool(e)}visitUtf8(t,e){return Si.startUtf8(e),Si.endUtf8(e)}visitLargeUtf8(t,e){return bi.startLargeUtf8(e),bi.endLargeUtf8(e)}visitDecimal(t,e){return er.startDecimal(e),er.addScale(e,t.scale),er.addPrecision(e,t.precision),er.addBitWidth(e,t.bitWidth),er.endDecimal(e)}visitDate(t,e){return Hr.startDate(e),Hr.addUnit(e,t.unit),Hr.endDate(e)}visitTime(t,e){return ur.startTime(e),ur.addUnit(e,t.unit),ur.addBitWidth(e,t.bitWidth),ur.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return dr.startTimestamp(e),dr.addUnit(e,t.unit),n!==void 0&&dr.addTimezone(e,n),dr.endTimestamp(e)}visitInterval(t,e){return Gr.startInterval(e),Gr.addUnit(e,t.unit),Gr.endInterval(e)}visitDuration(t,e){return zr.startDuration(e),zr.addUnit(e,t.unit),zr.endDuration(e)}visitList(t,e){return gi.startList(e),gi.endList(e)}visitStruct(t,e){return vi.startStruct_(e),vi.endStruct_(e)}visitUnion(t,e){Me.startTypeIdsVector(e,t.typeIds.length);let n=Me.createTypeIdsVector(e,t.typeIds);return Me.startUnion(e),Me.addMode(e,t.mode),Me.addTypeIds(e,n),Me.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return tr.startDictionaryEncoding(e),tr.addId(e,BigInt(t.id)),tr.addIsOrdered(e,t.isOrdered),n!==void 0&&tr.addIndexType(e,n),tr.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return jr.startFixedSizeBinary(e),jr.addByteWidth(e,t.byteWidth),jr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Wr.startFixedSizeList(e),Wr.addListSize(e,t.listSize),Wr.endFixedSizeList(e)}visitMap(t,e){return Kr.startMap(e),Kr.addKeysSorted(e,t.keysSorted),Kr.endMap(e)}},Oo=new Ja;function bu(r,t=new Map){return new St(rm(r,t),Mo(r.metadata),t)}function Xa(r){return new Jt(r.count,wu(r.columns),vu(r.columns))}function gu(r){return new ae(Xa(r.data),r.id,r.isDelta)}function rm(r,t){return(r.fields||[]).filter(Boolean).map(e=>ct.fromJSON(e,t))}function mu(r,t){return(r.children||[]).filter(Boolean).map(e=>ct.fromJSON(e,t))}function wu(r){return(r||[]).reduce((t,e)=>[...t,new Ie(e.count,nm(e.VALIDITY)),...wu(e.children)],[])}function vu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new oe(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new oe(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new oe(t.length,i.OFFSET.length)),i.DATA&&t.push(new oe(t.length,i.DATA.length)),t=vu(i.children,t)}return t}function nm(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Su(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=_u(r,mu(r,t)),i=new ct(r.name,o,r.nullable,Mo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?yu(n):new rr,a=new pe(t.get(e),n,e,s.isOrdered),i=new ct(r.name,a,r.nullable,Mo(r.metadata))):(n=(n=s.indexType)?yu(n):new rr,t.set(e,o=_u(r,mu(r,t))),a=new pe(o,n,e,s.isOrdered),i=new ct(r.name,a,r.nullable,Mo(r.metadata))),i||null}function Mo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function yu(r){return new $t(r.isSigned,r.bitWidth)}function _u(r,t){let e=r.type.name;switch(e){case"NONE":return new ee;case"null":return new ee;case"binary":return new fr;case"largebinary":return new hr;case"utf8":return new pr;case"largeutf8":return new mr;case"bool":return new yr;case"list":return new Ne((t||[])[0]);case"struct":return new Et(t||[]);case"struct_":return new Et(t||[])}switch(e){case"int":{let n=r.type;return new $t(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new we(Dt[n.precision])}case"decimal":{let n=r.type;return new _r(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new br(kt[n.unit])}case"time":{let n=r.type;return new gr(L[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new wr(L[n.unit],n.timezone)}case"interval":{let n=r.type;return new vr(jt[n.unit])}case"duration":{let n=r.type;return new Sr(L[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ke(At[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Ir(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Ce(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new Pe((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var im=on,sm=fe,ce=class r{static fromJSON(t,e){let n=new r(0,wt.V5,e);return n._createHeader=om(t,e),n}static decode(t){t=new sm(Y(t));let e=ze.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new r(n,i,s);return o._createHeader=am(e,s),o}static encode(t){let e=new im,n=-1;return t.isSchema()?n=St.encode(e,t.header()):t.isRecordBatch()?n=Jt.encode(e,t.header()):t.isDictionaryBatch()&&(n=ae.encode(e,t.header())),ze.startMessage(e),ze.addVersion(e,wt.V5),ze.addHeader(e,n),ze.addHeaderType(e,t.headerType),ze.addBodyLength(e,BigInt(t.bodyLength)),ze.finishMessageBuffer(e,ze.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof St)return new r(0,wt.V5,ut.Schema,t);if(t instanceof Jt)return new r(e,wt.V5,ut.RecordBatch,t);if(t instanceof ae)return new r(e,wt.V5,ut.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===ut.Schema}isRecordBatch(){return this.headerType===ut.RecordBatch}isDictionaryBatch(){return this.headerType===ut.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ht(t)}},Jt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=ht(t)}},ae=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(t,e,n=!1){this._data=t,this._isDelta=n,this._id=ht(e)}},oe=class{constructor(t,e){this.offset=ht(t),this.length=ht(e)}},Ie=class{constructor(t,e){this.length=ht(t),this.nullCount=ht(e)}};function om(r,t){return()=>{switch(t){case ut.Schema:return St.fromJSON(r);case ut.RecordBatch:return Jt.fromJSON(r);case ut.DictionaryBatch:return ae.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(ut[t],", type: ").concat(t," }"))}}function am(r,t){return()=>{switch(t){case ut.Schema:return St.decode(r.header(new ie),new Map,r.version());case ut.RecordBatch:return Jt.decode(r.header(new he),r.version());case ut.DictionaryBatch:return ae.decode(r.header(new lr),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(ut[t],", type: ").concat(t," }"))}}ct.encode=bm;ct.decode=ym;ct.fromJSON=Su;St.encode=_m;St.decode=cm;St.fromJSON=bu;Jt.encode=gm;Jt.decode=lm;Jt.fromJSON=Xa;ae.encode=wm;ae.decode=um;ae.fromJSON=gu;Ie.encode=vm;Ie.decode=fm;oe.encode=Sm;oe.decode=dm;function cm(r,t=new Map,e=wt.V5){let n=mm(r,t);return new St(n,Ro(r),t,e)}function lm(r,t=wt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Jt(r.length(),hm(r),pm(r,t))}function um(r,t=wt.V5){return new ae(Jt.decode(r.data(),t),r.id(),r.isDelta())}function dm(r){return new oe(r.offset(),r.length())}function fm(r){return new Ie(r.length(),r.nullCount())}function hm(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Ie.decode(e));return t}function pm(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<wt.V4&&(n.bb_pos+=8*(i+1)),e[++s]=oe.decode(n));return e}function mm(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=ct.decode(n,t));return e}function Iu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=ct.decode(n,t));return e}function ym(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=Du(r,Iu(r,t)),n=new ct(r.name(),i,r.nullable(),Ro(r))):t.has(e=ht(a.id()))?(s=(s=a.indexType())?Bu(s):new rr,o=new pe(t.get(e),s,e,a.isOrdered()),n=new ct(r.name(),o,r.nullable(),Ro(r))):(s=(s=a.indexType())?Bu(s):new rr,t.set(e,i=Du(r,Iu(r,t))),o=new pe(i,s,e,a.isOrdered()),n=new ct(r.name(),o,r.nullable(),Ro(r))),n||null}function Ro(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function Bu(r){return new $t(r.isSigned(),r.bitWidth())}function Du(r,t){let e=r.typeType();switch(e){case xt.NONE:return new ee;case xt.Null:return new ee;case xt.Binary:return new fr;case xt.LargeBinary:return new hr;case xt.Utf8:return new pr;case xt.LargeUtf8:return new mr;case xt.Bool:return new yr;case xt.List:return new Ne((t||[])[0]);case xt.Struct_:return new Et(t||[])}switch(e){case xt.Int:{let n=r.type(new Oe);return new $t(n.isSigned(),n.bitWidth())}case xt.FloatingPoint:{let n=r.type(new $r);return new we(n.precision())}case xt.Decimal:{let n=r.type(new er);return new _r(n.scale(),n.precision(),n.bitWidth())}case xt.Date:{let n=r.type(new Hr);return new br(n.unit())}case xt.Time:{let n=r.type(new ur);return new gr(n.unit(),n.bitWidth())}case xt.Timestamp:{let n=r.type(new dr);return new wr(n.unit(),n.timezone())}case xt.Interval:{let n=r.type(new Gr);return new vr(n.unit())}case xt.Duration:{let n=r.type(new zr);return new Sr(n.unit())}case xt.Union:{let n=r.type(new Me);return new ke(n.mode(),n.typeIdsArray()||[],t||[])}case xt.FixedSizeBinary:{let n=r.type(new jr);return new Ir(n.byteWidth())}case xt.FixedSizeList:{let n=r.type(new Wr);return new Ce(n.listSize(),(t||[])[0])}case xt.Map:{let n=r.type(new Kr);return new Pe((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(xt[e],'" (').concat(e,")"))}function _m(r,t){let e=t.fields.map(s=>ct.encode(r,s));ie.startFieldsVector(r,e.length);let n=ie.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ie.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString("".concat(s)),c=r.createString("".concat(o));return Wt.startKeyValue(r),Wt.addKey(r,a),Wt.addValue(r,c),Wt.endKeyValue(r)})):-1;return ie.startSchema(r),ie.addFields(r,n),ie.addEndianness(r,Im?Vr.Little:Vr.Big),i!==-1&&ie.addCustomMetadata(r,i),ie.endSchema(r)}function bm(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;M.isDictionary(s)?(o=s.dictionary.typeId,i=Oo.visit(s,r),n=Oo.visit(s.dictionary,r)):n=Oo.visit(s,r);let a=(s.children||[]).map(p=>ct.encode(r,p)),c=Zt.createChildrenVector(r,a),d=t.metadata&&t.metadata.size>0?Zt.createCustomMetadataVector(r,[...t.metadata].map(([p,S])=>{let A=r.createString("".concat(p)),x=r.createString("".concat(S));return Wt.startKeyValue(r),Wt.addKey(r,A),Wt.addValue(r,x),Wt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Zt.startField(r),Zt.addType(r,n),Zt.addTypeType(r,o),Zt.addChildren(r,c),Zt.addNullable(r,!!t.nullable),e!==-1&&Zt.addName(r,e),i!==-1&&Zt.addDictionary(r,i),d!==-1&&Zt.addCustomMetadata(r,d),Zt.endField(r)}function gm(r,t){let e=t.nodes||[],n=t.buffers||[];he.startNodesVector(r,e.length);for(let o of e.slice().reverse())Ie.encode(r,o);let i=r.endVector();he.startBuffersVector(r,n.length);for(let o of n.slice().reverse())oe.encode(r,o);let s=r.endVector();return he.startRecordBatch(r),he.addLength(r,BigInt(t.length)),he.addNodes(r,i),he.addBuffers(r,s),he.endRecordBatch(r)}function wm(r,t){let e=Jt.encode(r,t.data);return lr.startDictionaryBatch(r),lr.addId(r,BigInt(t.id)),lr.addIsDelta(r,t.isDelta),lr.addData(r,e),lr.endDictionaryBatch(r)}function vm(r,t){return En.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Sm(r,t){return Tn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Im=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Qa=r=>"Expected ".concat(ut[r]," Message in stream, but was null or length 0."),tc=r=>"Header pointer of flatbuffer-encoded ".concat(ut[r]," Message is null or length 0."),Fu=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),Au=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),qn=class{constructor(t){this.source=t instanceof sr?t:new sr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Ut:t.value===-1&&(t=this.readMetadataLength()).done?Ut:(t=this.readMetadata(t.value)).done?Ut:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Qa(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=Y(this.source.read(t));if(e.byteLength<t)throw new Error(Au(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=ut.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(tc(e));return i}readMetadataLength(){let t=this.source.read(Lo),e=t&&new fe(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return Ut;if(e.byteLength<t)throw new Error(Fu(t,e.byteLength));return{done:!1,value:ce.decode(e)}}},is=class{constructor(t,e){this.source=t instanceof ve?t:hs(t)?new Zr(t,e):new ve(t)}[Symbol.asyncIterator](){return this}next(){return O(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?Ut:t.value===-1&&(t=yield this.readMetadataLength()).done?Ut:(t=yield this.readMetadata(t.value)).done?Ut:t})}throw(t){return O(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return O(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return O(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Qa(t));return e.value})}readMessageBody(t){return O(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=Y(yield this.source.read(t));if(e.byteLength<t)throw new Error(Au(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return O(this,arguments,void 0,function*(t=!1){let e=ut.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(tc(e));return i})}readMetadataLength(){return O(this,void 0,void 0,function*(){let t=yield this.source.read(Lo),e=t&&new fe(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(t){return O(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return Ut;if(e.byteLength<t)throw new Error(Fu(t,e.byteLength));return{done:!1,value:ce.decode(e)}})}},ss=class extends qn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Ei?t:new Ei(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ce.fromJSON(t.schema,ut.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:ce.fromJSON(e,ut.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:ce.fromJSON(e,ut.RecordBatch)}}return this._body=[],Ut}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Qa(t));return e.value}readSchema(){let t=ut.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(tc(t));return n}},Lo=4,Za="ARROW1",Yn=new Uint8Array(Za.length);for(let r=0;r<Za.length;r+=1)Yn[r]=Za.codePointAt(r);function No(r,t=0){for(let e=-1,n=Yn.length;++e<n;)if(Yn[e]!==r[t+e])return!1;return!0}var Jn=Yn.length,ec=Jn+Lo,xu=Jn*2+Lo;var Xt=class r extends hn{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return xe(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return qt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return qt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:ds(t)?Dm(t):hs(t)?xm(t):xe(t)?O(this,void 0,void 0,function*(){return yield r.from(yield t)}):ps(t)||li(t)||ys(t)||_e(t)?Am(new ve(t)):Fm(new sr(t))}static readAll(t){return t instanceof r?t.isSync()?Tu(t):Eu(t):ds(t)||ArrayBuffer.isView(t)||Te(t)||fs(t)?Tu(t):Eu(t)}},ar=class extends Xt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ue(this,arguments,function*(){yield it(yield*nn(An(Ae(this[Symbol.iterator]()))))})}},Qr=class extends Xt{constructor(t){super(t),this._impl=t}readAll(){return O(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,a=Ae(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let d=i;s.push(d)}}catch(d){e={error:d}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},tn=class extends ar{constructor(t){super(t),this._impl=t}},os=class extends Qr{constructor(t){super(t),this._impl=t}},ko=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=tt({type:new Et(this.schema.fields),length:t.length,children:n});return new Ct(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n),c=o.dictionaries.get(n),d=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new dt(d)):new dt(d)).memoize()}_loadVectors(t,e,n){return new Ri(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Xn=class extends ko{constructor(t,e){super(e),this._reader=ds(t)?new ss(this._handle=t):new qn(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Uu(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Ut}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Ut}next(){if(this.closed)return Ut;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new wn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Zn=class extends ko{constructor(t,e){super(e),this._reader=new is(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Uu(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Ut})}return(t){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Ut})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return Ut;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new wn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Co=class extends Xn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof Ui?t:new Ui(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(ut.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(ut.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-ec,n=t.readInt32(e),i=t.readAt(e-n,n);return Fr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},rc=class extends Zn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Zr?t:new Zr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return O(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(ut.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return O(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(ut.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-ec,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Fr.decode(i)})}_readNextMessageAndValidate(t){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},nc=class extends Xn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new co(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Uu(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Tu(r){let t=Xt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Eu(r){return ue(this,arguments,function*(){let e=yield it(Xt.from(r));try{if(!(yield it(e.open({autoDestroy:!1}))).closed)do yield yield it(e);while(!(yield it(e.reset().open())).closed)}finally{yield it(e.cancel())}})}function Dm(r){return new ar(new nc(r))}function Fm(r){let t=r.peek(Jn+7&-8);return t&&t.byteLength>=4?No(t)?new tn(new Co(r.read())):new ar(new Xn(r)):new ar(new Xn(function*(){}()))}function Am(r){return O(this,void 0,void 0,function*(){let t=yield r.peek(Jn+7&-8);return t&&t.byteLength>=4?No(t)?new tn(new Co(yield r.read())):new Qr(new Zn(r)):new Qr(new Zn(function(){return ue(this,arguments,function*(){})}()))})}function xm(r){return O(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Zr(r,t);return t>=xu&&No(yield e.readAt(0,Jn+7&-8))?new os(new rc(e)):new Qr(new Zn(e))})}var Rt=class r extends z{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Ct?s.data.children:s.data),n=new r;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof dt)return this.visitMany(t.data),this;let{type:e}=t;if(!M.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(M.isUnion(e))this.nodes.push(new Ie(n,0));else{let{nullCount:i}=t;M.isNull(e)||je.call(this,i<=0?new Uint8Array(0):ln(t.offset,n,t.nullBitmap)),this.nodes.push(new Ie(n,i))}}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 je(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new oe(this._byteLength,t)),this._byteLength+=t,this}function Tm(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(je.call(this,i),e.mode===At.Sparse)return ic.call(this,r);if(e.mode===At.Dense){if(r.offset<=0)return je.call(this,s),ic.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let d,p,S=-1;++S<n;)(d=i[S])!==void 0&&((p=a[d])===void 0&&(p=a[d]=s[S]),o[S]=s[S]-p,c[d]=((t=c[d])!==null&&t!==void 0?t:0)+1);je.call(this,o),this.visitMany(r.children.map((d,p)=>{let S=e.typeIds[p],A=a[S],x=c[S];return d.slice(A,Math.min(n,x))}))}}return this}function Em(r){let t;return r.nullCount>=r.length?je.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?je.call(this,ln(r.offset,r.length,t)):je.call(this,un(r.values))}function Rr(r){return je.call(this,r.values.subarray(0,r.length*r.stride))}function Po(r){let{length:t,values:e,valueOffsets:n}=r,i=ht(n[0]),s=ht(n[t]),o=Math.min(s-i,e.byteLength-i);return je.call(this,bs(-i,t+1,n)),je.call(this,e.subarray(i,i+o)),this}function sc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return je.call(this,bs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function ic(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Rt.prototype.visitBool=Em;Rt.prototype.visitInt=Rr;Rt.prototype.visitFloat=Rr;Rt.prototype.visitUtf8=Po;Rt.prototype.visitLargeUtf8=Po;Rt.prototype.visitBinary=Po;Rt.prototype.visitLargeBinary=Po;Rt.prototype.visitFixedSizeBinary=Rr;Rt.prototype.visitDate=Rr;Rt.prototype.visitTimestamp=Rr;Rt.prototype.visitTime=Rr;Rt.prototype.visitDecimal=Rr;Rt.prototype.visitList=sc;Rt.prototype.visitStruct=ic;Rt.prototype.visitUnion=Tm;Rt.prototype.visitInterval=Rr;Rt.prototype.visitDuration=Rr;Rt.prototype.visitFixedSizeList=sc;Rt.prototype.visitMap=sc;var vn=class extends hn{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new ir,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,te(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return xe(t)?t.then(e=>this.writeAll(e)):_e(t)?ac(this,t):oc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof ir?this._sink=t:(this._sink=new ir,t&&Kc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&qc(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!gn(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof ne&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ct&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!gn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ct?t instanceof wn||this._writeRecordBatch(t):t instanceof ne?this.writeAll(t.batches):Te(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=ce.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===ut.RecordBatch?this._recordBatchBlocks.push(new Ar(a,t.bodyLength,this._position)):t.headerType===ut.DictionaryBatch&&this._dictionaryBlocks.push(new Ar(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=Y(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(ce.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Yn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=Rt.assemble(t),o=new Jt(t.numRows,n,i),a=ce.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=Rt.assemble(new dt([t])),c=new Jt(t.length,s,o),d=new ae(c,e,n),p=ce.from(d,i);return this._writeMessage(p)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,n;for(let[i,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),c=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[d,p]of o.entries())this._writeDictionaryBatch(p,i,d>0);else if(c<o.length)for(let d of o.slice(c))this._writeDictionaryBatch(d,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},Sn=class r extends vn{static writeAll(t,e){let n=new r(e);return xe(t)?t.then(i=>n.writeAll(i)):_e(t)?ac(n,t):oc(n,t)}},In=class r extends vn{static writeAll(t){let e=new r;return xe(t)?t.then(n=>e.writeAll(n)):_e(t)?ac(e,t):oc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=Fr.encode(new Fr(t,wt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function oc(r,t){let e=t;t instanceof ne&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function ac(r,t){return O(this,void 0,void 0,function*(){var e,n,i,s,o,a,c;try{for(e=!0,n=Ae(t);i=yield n.next(),s=i.done,!s;e=!0){c=i.value,e=!1;let d=c;r.write(d)}}catch(d){o={error:d}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Ou(r,t){if(_e(r))return Om(r,t);if(Te(r))return Um(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Um(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,d=null,p=o.desiredSize||null;for(;!(d=a.next(n?p:null)).done;)if(ArrayBuffer.isView(d.value)&&(c=Y(d.value))&&(p!=null&&n&&(p=p-c.byteLength+1),d.value=c),o.enqueue(d.value),p!=null&&--p<=0)return;o.close()}}function Om(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return O(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(e!=null&&e.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return O(this,void 0,void 0,function*(){let c,d=null,p=o.desiredSize||null;for(;!(d=yield a.next(n?p:null)).done;)if(ArrayBuffer.isView(d.value)&&(c=Y(d.value))&&(p!=null&&n&&(p=p-c.byteLength+1),d.value=c),o.enqueue(d.value),p!=null&&--p<=0)return;o.close()})}}function Lu(r){return new cc(r)}var cc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=$c(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=mn(s),this._getSize=i!=="bytes"?Mu:Ru;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:i!=="bytes"?Mu:Ru}),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:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Mu=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Ru=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function Vo(r,t){let e=new ir,n=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield e.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Xt.from(e)).open(t)})}function o(a,c){return O(this,void 0,void 0,function*(){let d=a.desiredSize,p=null;for(;!(p=yield c.next()).done;)if(a.enqueue(p.value),d!=null&&--d<=0)return;a.close()})}}function Ho(r,t){let e=new this(r),n=new ve(e),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}function zo(r,t="stream"){return(t==="stream"?Sn:In).writeAll(r).toUint8Array(!0)}var Nm=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},wa),$a),Na),va),ha),La),ya),{compareSchemas:gn,compareFields:lu,compareTypes:uu});qt.toDOMStream=Ou;Mt.throughDOM=Lu;Xt.throughDOM=Vo;tn.throughDOM=Vo;ar.throughDOM=Vo;vn.throughDOM=Ho;In.throughDOM=Ho;Sn.throughDOM=Ho;function Qn(r){switch(r.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=r;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:Qn(r.valueType)};case h.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case h.Null:return{sqlType:"null"};case h.Utf8:return{sqlType:"utf8"};case h.Struct:return{sqlType:"struct",fields:r.children.map(e=>jo(e.name,e.type))};case h.Map:{let t=r;return{sqlType:"map",keyType:Qn(t.keyType),valueType:Qn(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:r.timezone||void 0};case h.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case h.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case h.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case h.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function jo(r,t){let e=Qn(t);return e.name=r,e}var Wo=class{constructor(t,e){this._bindings=t,this._conn=e}close(){this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}query(t){let e=this._bindings.runQuery(this._conn,t),n=Xt.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new ne(n)}async send(t,e=!1){let n=this._bindings.startPendingQuery(this._conn,t,e);for(;n==null;)n=await new Promise((o,a)=>{try{o(this._bindings.pollPendingQuery(this._conn))}catch(c){console.log(c),c.message.includes("worker is not set!")?a(new Error("Worker has been terminated")):a(c)}});let i=new $o(this._bindings,this._conn,n),s=Xt.from(i);return console.assert(s.isSync()),console.assert(s.isStream()),s}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(t){return this._bindings.getTableNames(this._conn,t)}prepare(t){let e=this._bindings.createPrepared(this._conn,t);return new lc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=zo(t,"stream");this.insertArrowFromIPCStream(n,e)}insertArrowFromIPCStream(t,e){this._bindings.insertArrowFromIPCStream(this._conn,t,e)}insertCSVFromPath(t,e){this._bindings.insertCSVFromPath(this._conn,t,e)}insertJSONFromPath(t,e){this._bindings.insertJSONFromPath(this._conn,t,e)}},$o=class{constructor(t,e,n){this.bindings=t;this.conn=e;this.header=n;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 t=null;do t=this.bindings.fetchQueryResults(this.conn);while(t==null);return this._depleted=t.length==0,{done:this._depleted,value:t}}[Symbol.iterator](){return this}},lc=class{constructor(t,e,n){this.bindings=t,this.connectionId=e,this.statementId=n}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...t){let e=this.bindings.runPrepared(this.connectionId,this.statementId,t),n=Xt.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new ne(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new $o(this.bindings,this.connectionId,e),i=Xt.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function ku(r){return r<=255}function Cu(r){return r===256}var Hu=new TextEncoder,Pu=new TextDecoder("utf-8");function uc(r,t,e){let n=Hu.encode(e),i=r._malloc(n.byteLength),s=r.HEAPU8.subarray(i,i+n.byteLength);s.set(n),r.HEAPF64[(t>>3)+0]=1,r.HEAPF64[(t>>3)+1]=i,r.HEAPF64[(t>>3)+2]=s.byteLength}function fc(r){switch(r){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 dc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*fc(e));switch(e){case"UINT8":return new Uint8Array(i.buffer,i.byteOffset,n);case"INT8":return new Int8Array(i.buffer,i.byteOffset,n);case"INT32":return new Int32Array(i.buffer,i.byteOffset,n);case"FLOAT":return new Float32Array(i.buffer,i.byteOffset,n);case"DOUBLE":return new Float64Array(i.buffer,i.byteOffset,n);case"VARCHAR":return new Float64Array(i.buffer,i.byteOffset,n);default:return new Array(0)}}function Vu(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function Go(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function zu(r,t,e,n,i,s,o,a){try{let c=r._udfFunctions.get(n);if(!c){uc(t,e,"Unknown UDF with id: "+n);return}let d=Pu.decode(t.HEAPU8.subarray(i,i+s)),p=JSON.parse(d),S=Go(t,o,a/8),A=w=>{var F;let R=null;switch(w.validityBuffer!==void 0&&(R=Vu(t,S[w.validityBuffer],p.rows)),w.physicalType){case"VARCHAR":{if(w.dataBuffer===null||w.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(w.lengthBuffer===null||w.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let H=dc(t,S[w.dataBuffer],w.physicalType,p.rows),g=[],C=Go(t,S[w.lengthBuffer],p.rows);for(let q=0;q<p.rows;++q){if(R!=null&&!R[q]){g.push(null);continue}let T=t.HEAPU8.subarray(H[q],H[q]+C[q]),pt=Pu.decode(T);g.push(pt)}return q=>g[q]}case"STRUCT":{let H={},g=[];for(let C=0;C<(((F=w.children)==null?void 0:F.length)||0);++C){let q=w.children[C],T=A(q);g.push(pt=>{H[q.name]=T(pt)})}return R!=null?C=>{if(!R[C])return null;for(let q of g)q(C);return H}:C=>{for(let q of g)q(C);return H}}default:{if(w.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+w.physicalType);let H=dc(t,S[w.dataBuffer],w.physicalType,p.rows);return R!=null?g=>R[g]?H[g]:null:g=>H[g]}}},x=[];for(let w=0;w<p.args.length;++w)x.push(A(p.args[w]));let ot=p.rows*fc(p.ret.physicalType),lt=t._malloc(ot),Pt=dc(t,lt,p.ret.physicalType,p.rows),Ot=t._malloc(p.rows),Bt=Vu(t,Ot,p.rows);if(Pt.length==0||Bt.length==0){uc(t,e,"Can't create physical arrays for result");return}let bt=Pt;p.ret.physicalType=="VARCHAR"&&(bt=new Array(p.rows));let Qt=[];for(let w=0;w<p.args.length;++w)Qt.push(null);for(let w=0;w<p.rows;++w){for(let F=0;F<p.args.length;++F)Qt[F]=x[F](w);let R=c.func(...Qt);bt[w]=R,Bt[w]=R==null?0:1}let Gt=0;switch(p.ret.physicalType){case"VARCHAR":{let w=new Array(0);Gt=t._malloc(p.rows*fc("DOUBLE"));let R=Go(t,Gt,p.rows),F=0;for(let q=0;q<p.rows;++q){let T=Hu.encode(bt[q]||"");w.push(T),R[q]=T.length,F+=T.length}let H=t._malloc(F),g=t.HEAPU8.subarray(H,H+F),C=0;for(let q=0;q<p.rows;++q){Pt[q]=C;let T=w[q];g.subarray(C,C+T.length).set(T),C+=T.length}}}let _=3*8,E=t._malloc(_),k=Go(t,E,3);k[0]=lt,k[1]=Ot,k[2]=Gt,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=E,t.HEAPF64[(e>>3)+2]=0}catch(c){uc(t,e,c.toString())}}function Cm(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var Pm=Cm();function We(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Bn(r,t,e){let n=new Uint8Array(r.HEAPU8.buffer,t>>>0,e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function rt(r,t,e){return Pm(new Uint8Array(r.HEAPU8.buffer,t>>>0,e))}function It(r,t,e,n){let i=r.stackSave(),s=r.stackAlloc(3*8);e.unshift("number"),n.unshift(s),r.ccall(t,null,e,n);let o=r.HEAPF64[(s>>3)+0],a=r.HEAPF64[(s>>3)+1],c=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[o,a,c]}function Tt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var Ko=class{constructor(t){let e=new Float64Array(t.buffer,t.byteOffset,t.byteLength/8),n=new Uint8Array(new ArrayBuffer(t.byteLength));n.set(t.subarray(7*8)),this.totalFileReadsCold=e[0],this.totalFileReadsAhead=e[1],this.totalFileReadsCached=e[2],this.totalFileWrites=e[3],this.totalPageAccesses=e[4],this.totalPageLoads=e[5],this.blockSize=e[6],this.blockStats=n}getBlockStats(t,e){return e=e||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},e.file_writes=this.blockStats[t*3+0]&15,e.file_reads_cold=this.blockStats[t*3+0]>>4,e.file_reads_ahead=this.blockStats[t*3+1]&15,e.file_reads_cached=this.blockStats[t*3+1]>>4,e.page_accesses=this.blockStats[t*3+1]&15,e.page_loads=this.blockStats[t*3+1]>>4,e}};var ti=new TextEncoder;var qo=class{constructor(t,e){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=t,this._runtime=e,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(t=e=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(t),await this._initPromise),this._initPromise=new Promise(e=>{this._initPromiseResolver=e}),this.onInstantiationProgress=[t],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(e=>e!=t),globalThis.DUCKDB_BINDINGS=this,this)}open(t){let[e,n,i]=It(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(rt(this.mod,n,i));Tt(this.mod)}reset(){let[t,e,n]=It(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(rt(this.mod,e,n));Tt(this.mod)}getVersion(){let[t,e,n]=It(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(rt(this.mod,e,n));let i=rt(this.mod,e,n);return Tt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=ti.encode(t),n=this.mod._malloc(e.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,n,e.length).set(e);let[s,o,a]=It(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(rt(this.mod,o,a));let c=rt(this.mod,o,a);return Tt(this.mod),JSON.parse(c)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Wo(this,t)}disconnect(t){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[t]),this.pthread)for(let e of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])e.postMessage({cmd:"dropUDFFunctions",connectionId:t})}runQuery(t,e){let n=ti.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[o,a,c]=It(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(rt(this.mod,a,c));let d=Bn(this.mod,a,c);return Tt(this.mod),d}startPendingQuery(t,e,n=!1){let i=ti.encode(e),s=this.mod._malloc(i.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,s,i.length).set(i);let[a,c,d]=It(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[t,s,i.length,n]);if(this.mod._free(s),a!==0)throw new Error(rt(this.mod,c,d));if(c==0)return null;let p=Bn(this.mod,c,d);return Tt(this.mod),p}pollPendingQuery(t){let[e,n,i]=It(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(rt(this.mod,n,i));if(n==0)return null;let s=Bn(this.mod,n,i);return Tt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=It(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(Cu(e))return Tt(this.mod),null;if(!ku(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+rt(this.mod,n,i));if(e!==0)throw new Error(rt(this.mod,n,i));let s=Bn(this.mod,n,i);return Tt(this.mod),s}getTableNames(t,e){let n=ti.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[o,a,c]=It(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(rt(this.mod,a,c));let d=rt(this.mod,a,c);return Tt(this.mod),JSON.parse(d)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:Qn(n)},o={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[a,c,d]=It(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(a!==0)throw new Error(rt(this.mod,c,d));if(Tt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(o.functionId,o),this.pthread)for(let p of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])p.postMessage({cmd:"registerUDFFunction",udf:o})}createPrepared(t,e){let n=ti.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[o,a,c]=It(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(rt(this.mod,a,c));return Tt(this.mod),a}closePrepared(t,e){let[n,i,s]=It(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(rt(this.mod,i,s));Tt(this.mod)}runPrepared(t,e,n){let[i,s,o]=It(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(rt(this.mod,s,o));let a=Bn(this.mod,s,o);return Tt(this.mod),a}sendPrepared(t,e,n){let[i,s,o]=It(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(rt(this.mod,s,o));let a=Bn(this.mod,s,o);return Tt(this.mod),a}insertArrowFromIPCStream(t,e,n){if(e.length==0)return;let i=this.mod._malloc(e.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,e.length).set(e);let o=n?JSON.stringify(n):"",[a,c,d]=It(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,o]);if(this.mod._free(i),a!==0)throw new Error(rt(this.mod,c,d))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let d in n.columns)n.columnsFlat.push(jo(d,n.columns[d]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,a,c]=It(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(rt(this.mod,a,c))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let d in n.columns)n.columnsFlat.push(jo(d,n.columns[d]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,a,c]=It(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(rt(this.mod,a,c))}globFiles(t){let[e,n,i]=It(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(rt(this.mod,n,i));let s=rt(this.mod,n,i);Tt(this.mod);let o=JSON.parse(s);return o==null?[]:o}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,o,a]=It(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(rt(this.mod,o,a));Tt(this.mod)}registerFileText(t,e){let n=ti.encode(e);this.registerFileBuffer(t,n)}registerFileBuffer(t,e){let n=this.mod._malloc(e.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,n,e.length).set(e);let[s,o,a]=It(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(rt(this.mod,o,a));Tt(this.mod)}async prepareFileHandle(t,e){if(e===3&&this._runtime.prepareFileHandles){let n=await this._runtime.prepareFileHandles([t],3);for(let i of n){let{handle:s,path:o,fromCached:a}=i;!a&&s.getSize()&&await this.registerFileHandleAsync(o,s,3,!0)}return}throw new Error("prepareFileHandle: unsupported protocol ".concat(e))}async prepareDBFileHandle(t,e){if(e===3&&this._runtime.prepareDBFileHandle){let n=await this._runtime.prepareDBFileHandle(t,3);for(let i of n){let{handle:s,path:o,fromCached:a}=i;!a&&s.getSize()&&await this.registerFileHandleAsync(o,s,3,!0)}return}throw new Error("prepareDBFileHandle: unsupported protocol ".concat(e))}async prepareFileHandleAsync(t,e,n,i){if(n===3&&!(e instanceof FileSystemSyncAccessHandle)){if(e instanceof FileSystemFileHandle){let s=e;try{e=await s.createSyncAccessHandle()}catch(o){throw new Error(o.message+":"+t)}}else if(t!=null)try{e=await(await(await navigator.storage.getDirectory()).getFileHandle(t)).createSyncAccessHandle()}catch(s){throw new Error(s.message+":"+t)}}return e}async registerFileHandleAsync(t,e,n,i){let s=await this.prepareFileHandleAsync(t,e,n,i);this.registerFileHandle(t,s,n,i)}registerFileHandle(t,e,n,i){var c;let[s,o,a]=It(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(rt(this.mod,o,a));if(Tt(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),(c=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&c[t]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[t],this.pthread){for(let d of this.pthread.runningWorkers)d.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e});for(let d of this.pthread.unusedWorkers)d.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=It(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(rt(this.mod,n,i));Tt(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let a of t!=null?t:[])if(a!=null&&a.length>0){let c=this.mod.lengthBytesUTF8(a)+1,d=this.mod._malloc(c);if(!d)throw new Error("Failed to allocate memory for string: ".concat(a));this.mod.stringToUTF8(a,d,c),e.push(d)}if(n=this.mod._malloc(e.length*4),!n)throw new Error("Failed to allocate memory for pointers array");for(let a=0;a<e.length;a++)this.mod.HEAP32[(n>>2)+a]=e[a];let[i,s,o]=It(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(rt(this.mod,s,o));Tt(this.mod)}finally{for(let i of e)this.mod._free(i);n>0&&this.mod._free(n)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(t,e){let[n,i,s]=It(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(rt(this.mod,i,s));Tt(this.mod)}copyFileToBuffer(t){let[e,n,i]=It(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(rt(this.mod,n,i));let s=new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i),o=new Uint8Array(s.length);return o.set(s),Tt(this.mod),o}async registerOPFSFileName(t){if(t.startsWith("opfs://"))return this.prepareFileHandle(t,3);throw new Error("Not an OPFS file name: "+t)}collectFileStatistics(t,e){let[n,i,s]=It(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(rt(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=It(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(rt(this.mod,n,i));return new Ko(new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i))}};var Yo=class{constructor(){this._bindings=null;this._nextMessageId=0}log(t){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:t},[])}sendOK(t){this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"OK",data:null},[])}failWith(t,e){let n={name:e.name,message:e.message,stack:e.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"ERROR",data:n},[])}async onMessage(t){switch(t.type){case"PING":this.sendOK(t);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(t,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(t.data[0],t.data[1],e=>{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"INSTANTIATE_PROGRESS",data:e},[])}),this.sendOK(t)}catch(e){console.log(e),this._bindings=null,this.failWith(t,e)}return;default:break}if(!this._bindings)return this.failWith(t,new Error("duckdb is not initialized"));try{switch(t.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(t);break;case"OPEN":{let e=t.data.path,n=!!(this._bindings.getFeatureFlags()&32);e!=null&&e.startsWith("opfs://")&&!n&&(await this._bindings.prepareDBFileHandle(e,3),t.data.useDirectIO=!0),this._bindings.open(t.data),this.sendOK(t);break}case"DROP_FILE":this._bindings.dropFile(t.data),this.sendOK(t);break;case"DROP_FILES":this._bindings.dropFiles(t.data),this.sendOK(t);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(t);break;case"CONNECT":{let e=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"CONNECTION_INFO",data:e.useUnsafe((n,i)=>i)},[]);break}case"DISCONNECT":this._bindings.disconnect(t.data),this.sendOK(t);break;case"CREATE_PREPARED":{let e=this._bindings.createPrepared(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"PREPARED_STATEMENT_ID",data:e},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(t.data[0],t.data[1]),this.sendOK(t);break}case"RUN_PREPARED":{let e=this._bindings.runPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"RUN_QUERY":{let e=this._bindings.runQuery(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"SEND_PREPARED":{let e=this._bindings.sendPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER",data:e},[e.buffer]);break}case"START_PENDING_QUERY":{let e=this._bindings.startPendingQuery(t.data[0],t.data[1],t.data[2]),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"POLL_PENDING_QUERY":{let e=this._bindings.pollPendingQuery(t.data),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"CANCEL_PENDING_QUERY":{let e=this._bindings.cancelPendingQuery(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SUCCESS",data:e},[]);break}case"FETCH_QUERY_RESULTS":{let e=this._bindings.fetchQueryResults(t.data),n=e?[e.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_CHUNK",data:e},n);break}case"GET_TABLE_NAMES":{let e=this._bindings.getTableNames(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"TABLE_NAMES",data:e},[]);break}case"GLOB_FILE_INFOS":{let e=this._bindings.globFiles(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_INFOS",data:e},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(t.data[0],t.data[1]),this.sendOK(t);break;case"COPY_FILE_TO_BUFFER":{let e=this._bindings.copyFileToBuffer(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_BUFFER",data:e},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_OPFS_FILE_NAME":{!!(this._bindings.getFeatureFlags()&32)||await this._bindings.registerOPFSFileName(t.data[0]),this.sendOK(t);break}case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(t.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"TOKENIZE":{let e=this._bindings.tokenize(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SCRIPT_TOKENS",data:e},[]);break}}}catch(e){return console.log(e),this.failWith(t,e)}}};var Ku=zc(Gu());var Xo=class extends qo{constructor(t,e,n,i){super(t,e),this.mainModuleURL=n,this.pthreadWorkerURL=i}locateFile(t,e){if(t.endsWith(".wasm"))return this.mainModuleURL;if(t.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(e," path=").concat(t))}instantiateWasm(t,e){globalThis.DUCKDB_RUNTIME=this._runtime;let n=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let s=(async()=>{var ot;let o=new Request(this.mainModuleURL),a=await fetch(o),c=a.headers.get("content-length"),d=c&&parseInt(c,10)||0,p=new Date,S={startedAt:p,updatedAt:p,bytesTotal:d||0,bytesLoaded:0},A={transform(lt,Pt){S.bytesLoaded+=lt.byteLength;let Ot=new Date;if(Ot.getTime()-S.updatedAt.getTime()<20){S.updatedAt=Ot,Pt.enqueue(lt);return}for(let Bt of n)Bt(S);Pt.enqueue(lt)}},x=new TransformStream(A);return new Response((ot=a.body)==null?void 0:ot.pipeThrough(x),a)})();WebAssembly.instantiateStreaming(s,t).then(o=>{e(o.instance,o.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let i=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(i),t).then(s=>{e(s.instance,s.module)})}else if(typeof XMLHttpRequest=="function"){let i=new XMLHttpRequest,s=this.mainModuleURL,o=new Date,a={startedAt:o,updatedAt:o,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=c=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+c}),new Error(c.toString())},i.onprogress=c=>{a.bytesTotal=c.total,a.bytesLoaded=c.loaded;let d=new Date;if(d.getTime()-a.updatedAt.getTime()<20){a.updatedAt=d;return}for(let p of n)p(a)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(c=>{e(c.instance,c.module)}).catch(c=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+c}),new Error(c)})},i.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let s=new Request(this.mainModuleURL),a=await(await fetch(s)).arrayBuffer();WebAssembly.instantiate(a,t).then(c=>{e(c.instance,c.module)})})();return[]}};var Zo=class extends Xo{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return(0,Ku.default)({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var en=zc(Ju()),Xu=function(r,t,e){var n;return(n=r==null?void 0:r.endpoint)!=null&&n.startsWith("http")?new URL(r.endpoint).host:r!=null&&r.endpoint?"".concat(e,".").concat(r==null?void 0:r.endpoint):"".concat(e,".s3.amazonaws.com")};function Hm(r,t,e){var s,o,a,c;let n=Zu(t),i=n.path;if(Qu(r)){let d="";if(r!=null&&r.endpoint){let p=new URL(r.endpoint);p.pathname!=="/"&&(d=p.pathname)}i="".concat(d,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:Xu(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(o=r==null?void 0:r.accessKeyId)!=null?o:"",secretAccessKey:(a=r==null?void 0:r.secretAccessKey)!=null?a:"",sessionToken:(c=r==null?void 0:r.sessionToken)!=null?c:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function zm(r,t=!1){let e="0123456789ABCDEF",n="";for(let i=0;i<r.length;i++){let s=r[i];s>="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+=e[s.charCodeAt(0)>>4],n+=e[s.charCodeAt(0)&15])}return n}function jm(r,t=null){var ot;let e=(ot=t==null?void 0:t.contentHash)!=null?ot:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n=new Map;n.set("x-amz-date",r.datetimeNow),n.set("x-amz-content-sha256",e),r.sessionToken&&n.set("x-amz-security-token",r.sessionToken);let i="";t!=null&&t.contentType&&(i+="content-type;"),i+="host;x-amz-content-sha256;x-amz-date",r.sessionToken&&(i+=";x-amz-security-token");let s=r.method+"\n"+zm(r.url)+"\n"+r.query;t!=null&&t.contentType&&(s+="\ncontent-type:"+(t==null?void 0:t.contentType)),s+="\nhost:"+r.host+"\nx-amz-content-sha256:"+e+"\nx-amz-date:"+r.datetimeNow,r.sessionToken&&r.sessionToken.length>0&&(s+="\nx-amz-security-token:"+r.sessionToken),s+="\n\n"+i+"\n"+e;let o=(0,en.sha256)(s),a="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+o,c="AWS4"+r.secretAccessKey,d=en.sha256.hmac.arrayBuffer(c,r.dateNow),p=en.sha256.hmac.arrayBuffer(d,r.region),S=en.sha256.hmac.arrayBuffer(p,r.service),A=en.sha256.hmac.arrayBuffer(S,"aws4_request"),x=en.sha256.hmac(A,a);return n.set("Authorization","AWS4-HMAC-SHA256 Credential="+r.accessKeyId+"/"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request, SignedHeaders="+i+", Signature="+x),n}var Wm=function(r,t,e,n=null,i=null){let s=Hm(r,t,e),o={contentType:n,contentHash:i?en.sha256.hex(i):null};return jm(s,o)};function $e(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(Wm(t,e,n,i,s).forEach((a,c)=>{r.setRequestHeader(c,a)}),i&&r.setRequestHeader("content-type",i))}function Zu(r){if(r.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let t=r.indexOf("/",5);if(t==-1)throw new Error("URL needs to contain a '/' after the host");let e=r.substring(5,t);if(!e)throw new Error("URL needs to contain a bucket name");let n=r.substring(t);if(!n)throw new Error("URL needs to contain key");return{bucket:e,path:n}}function Qu(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function Ge(r,t){let e=Zu(t);return Qu(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+Xu(r,t,e.bucket)+e.path}var $m=7,td=/\/|\\/,Z={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=Z._fileInfoCache.get(t),[n,i,s]=It(r,"duckdb_web_fs_get_file_info_by_id",["number","number"],[t,(e==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(s===0)return e;let o=rt(r,i,s);Tt(r);try{let a=JSON.parse(o);if(a==null)return null;let c={...a,blob:null};return Z._fileInfoCache.set(t,c),!Z._files.has(c.fileName)&&Z._preparedHandles[c.fileName]&&(Z._files.set(c.fileName,Z._preparedHandles[c.fileName]),delete Z._preparedHandles[c.fileName]),c}catch(a){return console.warn(a),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=It(r,"duckdb_web_get_global_file_info",["number"],[((t=Z._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return Z._globalFileInfo;let s=rt(r,n,i);Tt(r);let o=JSON.parse(s);return o==null?null:(Z._globalFileInfo={...o,blob:null},Z._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){Z._opfsRoot||(Z._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await Z.assignOPFSRoot();let e=async i=>{if(Z._files.has(i))return{path:i,handle:Z._files.get(i),fromCached:!0};let o=Z._opfsRoot,a=i.slice($m),c=a;if(td.test(a)){let p=a.split(td);if(p.length===0)throw new Error("Invalid path ".concat(a));if(c=p[p.length-1],!c)throw new Error("Invalid path ".concat(a,". File Not Found."));p.pop();for(let S of p)o=await o.getDirectoryHandle(S,{create:!0})}let d=await o.getFileHandle(c,{create:!1}).catch(p=>{if((p==null?void 0:p.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),o.getFileHandle(c,{create:!0});throw p});try{let p=await d.createSyncAccessHandle();return Z._preparedHandles[i]=p,{path:i,handle:p,fromCached:!1}}catch(p){throw new Error(p.message+":"+name)}},n=[];for(let i of r){let s=await e(i);n.push(s)}return n}throw new Error("Unsupported protocol ".concat(t," for paths ").concat(r," with protocol ").concat(t))},async prepareDBFileHandle(r,t){if(t===3&&this.prepareFileHandles){let e=[r,"".concat(r,".wal")];return this.prepareFileHandles(e,t)}throw new Error("Unsupported protocol ".concat(t," for path ").concat(r," with protocol ").concat(t))},testPlatformFeature:(r,t)=>{switch(t){case 1:return typeof BigInt64Array<"u";default:return console.warn("test for unknown feature: ".concat(t)),!1}},getDefaultDataProtocol(r){return 2},openFile:(r,t,e)=>{var n,i,s,o,a,c;try{Z._fileInfoCache.delete(t);let d=Z.getFileInfo(r,t);switch(d==null?void 0:d.dataProtocol){case 4:case 5:{if(e&1&&e&2)throw new Error("Opening file ".concat(d.fileName," failed: cannot open file with both read and write flags set"));if(e&32)throw new Error("Opening file ".concat(d.fileName," failed: appending to HTTP/S3 files is not supported"));if(e&2){let A=new XMLHttpRequest;if(d.dataProtocol==5?(A.open("HEAD",Ge(d.s3Config,d.dataUrl),!1),$e(A,d.s3Config,d.dataUrl,"HEAD")):A.open("HEAD",d.dataUrl,!1),A.send(null),A.status!=200&&A.status!=404)throw new Error("Opening file ".concat(d.fileName," failed: Unexpected return status from server (").concat(A.status,")"));if(A.status==404&&!(e&8||e&16))throw new Error("Opening file ".concat(d.fileName," failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag."));let x=r._malloc(1),ot=new Uint8Array;r.HEAPU8.set(ot,x);let lt=r._malloc(3*8);return r.HEAPF64[(lt>>3)+0]=1,r.HEAPF64[(lt>>3)+1]=x,r.HEAPF64[(lt>>3)+2]=new Date().getTime()/1e3,lt}else if(!(e&1))throw new Error("Opening file ".concat(d.fileName," failed: unsupported file flags: ").concat(e));let p=null,S=null;if(!d.forceFullHttpReads&&(d.reliableHeadRequests||!d.allowFullHttpReads))try{let A=new XMLHttpRequest;d.dataProtocol==5?(A.open("HEAD",Ge(d.s3Config,d.dataUrl),!1),$e(A,d.s3Config,d.dataUrl,"HEAD")):A.open("HEAD",d.dataUrl,!1),A.setRequestHeader("Range","bytes=0-"),A.send(null),p=null;try{p=A.getResponseHeader("Content-Length")}catch(x){console.warn("Failed to get Content-Length on request")}if(p!==null&&A.status==206){let x=r._malloc(24);r.HEAPF64[(x>>3)+0]=+p,r.HEAPF64[(x>>3)+1]=0;let ot=0;try{ot=new Date((n=A.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(lt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(x>>3)+2]=+ot,x}}catch(A){S=A,console.warn("HEAD request with range header failed: ".concat(A))}if(d.allowFullHttpReads){if(!d.forceFullHttpReads){let x=new XMLHttpRequest;d.dataProtocol==5?(x.open("GET",Ge(d.s3Config,d.dataUrl),!1),$e(x,d.s3Config,d.dataUrl,"GET")):x.open("GET",d.dataUrl,!1),x.responseType="arraybuffer",x.setRequestHeader("Range","bytes=0-0"),x.send(null);let ot=null;try{ot=x.getResponseHeader("Content-Length")}catch(Bt){console.warn("Failed to get Content-Length on request")}let lt=ot==null?void 0:ot.split("/")[1],Pt=ot,Ot=null;if(lt!==void 0)Ot=lt;else if(!d.reliableHeadRequests){let Bt=new XMLHttpRequest;d.dataProtocol==5?(Bt.open("HEAD",Ge(d.s3Config,d.dataUrl),!1),$e(Bt,d.s3Config,d.dataUrl,"HEAD")):Bt.open("HEAD",d.dataUrl,!1),Bt.setRequestHeader("Range","bytes=0-"),Bt.send(null),p=null;try{p=Bt.getResponseHeader("Content-Length")}catch(bt){console.warn("Failed to get Content-Length on request")}p!==null&&+p>1&&(Ot=p)}if(x.status==206&&Pt!==null&&+Pt==1&&Ot!==null){let Bt=r._malloc(24);r.HEAPF64[(Bt>>3)+0]=+Ot,r.HEAPF64[(Bt>>3)+1]=0;let bt=0;try{bt=new Date((i=x.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(Qt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Bt>>3)+2]=+bt,Bt}if(x.status==200&&Pt!==null&&p!==null&&+Pt==+p){console.warn("fall back to full HTTP read for: ".concat(d.dataUrl));let Bt=r._malloc(x.response.byteLength),bt=new Uint8Array(x.response,0,x.response.byteLength);r.HEAPU8.set(bt,Bt);let Qt=r._malloc(3*8);r.HEAPF64[(Qt>>3)+0]=x.response.byteLength,r.HEAPF64[(Qt>>3)+1]=Bt;let Gt=0;try{Gt=new Date((s=x.getResponseHeader("Last-Modified"))!=null?s:"").getTime()/1e3}catch(_){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Qt>>3)+2]=+Gt,Qt}console.warn("falling back to full HTTP read for: ".concat(d.dataUrl))}let A=new XMLHttpRequest;if(d.dataProtocol==5?(A.open("GET",Ge(d.s3Config,d.dataUrl),!1),$e(A,d.s3Config,d.dataUrl,"GET")):A.open("GET",d.dataUrl,!1),A.responseType="arraybuffer",A.send(null),A.status==200){let x=r._malloc(A.response.byteLength),ot=new Uint8Array(A.response,0,A.response.byteLength);r.HEAPU8.set(ot,x);let lt=r._malloc(3*8);r.HEAPF64[(lt>>3)+0]=A.response.byteLength,r.HEAPF64[(lt>>3)+1]=x;let Pt=0;try{Pt=new Date((o=A.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch(Ot){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(lt>>3)+2]=+Pt,lt}}if(S!=null)throw new Error("Reading file ".concat(d.fileName," failed with error: ").concat(S));return 0}case 2:{let p=(a=Z._files)==null?void 0:a.get(d.fileName);if(p){let x=r._malloc(24);return r.HEAPF64[(x>>3)+0]=p.size,r.HEAPF64[(x>>3)+1]=0,r.HEAPF64[(x>>3)+2]=0,x}if(e&128)return 0;console.warn("Buffering missing file: ".concat(d.fileName));let S=r._malloc(3*8),A=r._malloc(1);return r.HEAPF64[(S>>3)+0]=1,r.HEAPF64[(S>>3)+1]=A,r.HEAPF64[(S>>3)+2]=0,S}case 3:{let p=(c=Z._files)==null?void 0:c.get(d.fileName);if(!p)throw new Error("No OPFS access handle registered with name: ".concat(d.fileName));e&16&&p.truncate(0);let S=r._malloc(3*8),A=p.getSize();return r.HEAPF64[(S>>3)+0]=A,r.HEAPF64[(S>>3)+1]=0,r.HEAPF64[(S>>3)+2]=0,S}}}catch(d){console.error(d.toString()),We(r,d.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=rt(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let o=Z.getGlobalFileInfo(r);s.open("HEAD",Ge(o==null?void 0:o.s3Config,i),!1),$e(s,o==null?void 0:o.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=Z.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let o=new XMLHttpRequest;if(i.startsWith("s3://")){let c=Z.getGlobalFileInfo(r);o.open("GET",Ge(c==null?void 0:c.s3Config,i),!1),$e(o,c==null?void 0:c.s3Config,i,"HEAD")}else o.open("GET",i,!1);if(o.setRequestHeader("Range","bytes=0-0"),o.send(null),o.status!=200&&o.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let a=null;try{a=o.getResponseHeader("Content-Length")}catch(c){console.warn("Failed to get Content-Length on request")}a&&+a>1&&console.warn("Range request for ".concat(i," did not return a partial response: ").concat(o.status,' "').concat(o.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of Z._files.entries()||[])s.startsWith(i)&&r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[s])}catch(i){return console.log(i),We(r,i.toString()),0}},checkFile:(r,t,e)=>{try{let n=rt(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=Z.getGlobalFileInfo(r);i.open("HEAD",Ge(s==null?void 0:s.s3Config,n),!1),$e(i,s==null?void 0:s.s3Config,n,"HEAD")}else i.open("HEAD",n,!1);return i.send(null),i.status==206||i.status==200}else return Z._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=Z.getFileInfo(r,t);Z._fileInfoCache.delete(t);try{switch(e==null?void 0:e.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let i=(n=Z._files)==null?void 0:n.get(e.fileName);if(!i)throw new Error("No OPFS access handle registered with name: ".concat(e.fileName));return i.flush()}}}catch(i){console.log(i),We(r,i.toString())}},dropFile:(r,t,e)=>{var s;let n=rt(r,t,e),i=(s=Z._files)==null?void 0:s.get(n);if(i){if(Z._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(o){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=Z.getFileInfo(r,t);switch(n==null?void 0:n.dataProtocol){case 4:We(r,"Cannot truncate a http file");return;case 5:We(r,"Cannot truncate an s3 file");return;case 0:case 1:case 2:We(r,"truncateFile not implemented");return;case 3:{let s=(i=Z._files)==null?void 0:i.get(n.fileName);if(!s)throw new Error("No OPFS access handle registered with name: ".concat(n.fileName));return s.truncate(e)}}return 0},readFile(r,t,e,n,i){var s;if(n==0)return 0;try{let o=Z.getFileInfo(r,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 a=new XMLHttpRequest;if(o.dataProtocol==5?(a.open("GET",Ge(o==null?void 0:o.s3Config,o.dataUrl),!1),$e(a,o==null?void 0:o.s3Config,o.dataUrl,"GET")):a.open("GET",o.dataUrl,!1),a.responseType="arraybuffer",a.setRequestHeader("Range","bytes=".concat(i,"-").concat(i+n-1)),a.send(null),a.status==206||a.status==200&&n==a.response.byteLength&&i==0){let c=new Uint8Array(a.response,0,Math.min(a.response.byteLength,n));return r.HEAPU8.set(c,e),c.byteLength}else if(a.status==200){console.warn("Range request for ".concat(o.dataUrl," did not return a partial response: ").concat(a.status,' "').concat(a.statusText,'"'));let c=new Uint8Array(a.response,i,Math.min(a.response.byteLength-i,n));return r.HEAPU8.set(c,e),c.byteLength}else throw new Error("Range request for ".concat(o.dataUrl," did returned non-success status: ").concat(a.status,' "').concat(a.statusText,'"'))}catch(a){throw console.log(a),new Error("Range request for ".concat(o.dataUrl," failed with error: ").concat(a,'"'))}}case 2:{let a=(s=Z._files)==null?void 0:s.get(o.fileName);if(!a)throw new Error("No HTML5 file registered with name: ".concat(o.fileName));let c=a.slice(i,i+n),d=new Uint8Array(new FileReaderSync().readAsArrayBuffer(c));return r.HEAPU8.set(d,e),d.byteLength}case 3:{let a=Z._files.get(o.fileName);if(!a)throw new Error("No OPFS access handle registered with name: ".concat(o.fileName));let c=r.HEAPU8.subarray(e,e+n);return a.read(c,{at:i})}}return 0}catch(o){return console.log(o),We(r,o.toString()),0}},writeFile:(r,t,e,n,i)=>{var o;let s=Z.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return We(r,"Cannot write to HTTP file"),0;case 5:{let a=r.HEAPU8.subarray(e,e+n),c=new XMLHttpRequest;return c.open("PUT",Ge(s==null?void 0:s.s3Config,s.dataUrl),!1),$e(c,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",a),c.send(a),c.status!==200?(We(r,"Failed writing file: HTTP "+c.status),0):n}case 2:return We(r,"cannot write using the html5 file reader api"),0;case 3:{let a=(o=Z._files)==null?void 0:o.get(s.fileName);if(!a)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let c=r.HEAPU8.subarray(e,e+n);return a.write(c,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=Z.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=Z._files)==null?void 0:n.get(e.fileName)))throw Error("No handle available for file: ".concat(e.fileName));return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(r,t,e)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:r?"completed":"in-progress",percentage:t,repetitions:e}})},checkDirectory:(r,t,e)=>{let n=rt(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=rt(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=rt(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=rt(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var c,d;let s=rt(r,t,e),o=rt(r,n,i),a=(c=Z._files)==null?void 0:c.get(s);a!==void 0&&(Z._files.delete(a),Z._files.set(o,a));for(let[p,S]of((d=Z._fileInfoCache)==null?void 0:d.entries())||[])if(S.dataUrl==s){Z._fileInfoCache.delete(p);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,o)=>{zu(Z,r,t,e,n,i,s,o)}};var pc=class extends Yo{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new Zo(this,Z,t,e).instantiate(n)}};function ed(){let r=new pc;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}ed();return yh(Gm);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  js-sha256/src/sha256.js: