@run-trace/duckdb-wasm 0.4.1 → 0.5.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.
- package/dist/duckdb-browser-blocking.cjs +1 -1
- package/dist/duckdb-browser-blocking.cjs.map +3 -3
- package/dist/duckdb-browser-blocking.mjs +1 -1
- package/dist/duckdb-browser-blocking.mjs.map +3 -3
- package/dist/duckdb-browser-coi.pthread.worker.js +1 -1
- package/dist/duckdb-browser-coi.pthread.worker.js.map +3 -3
- package/dist/duckdb-browser-coi.worker.js +1 -1
- package/dist/duckdb-browser-coi.worker.js.map +3 -3
- package/dist/duckdb-browser.cjs +1 -1
- package/dist/duckdb-browser.cjs.map +1 -1
- package/dist/duckdb-browser.mjs +1 -1
- package/dist/duckdb-browser.mjs.map +1 -1
- package/dist/duckdb-coi.wasm +0 -0
- package/dist/duckdb-eh.wasm +0 -0
- package/dist/duckdb-node-blocking.cjs +2 -2
- package/dist/duckdb-node-blocking.cjs.map +3 -3
- package/dist/duckdb-node-eh.worker.cjs +2 -2
- package/dist/duckdb-node-eh.worker.cjs.map +3 -3
- package/dist/duckdb-node.cjs +1 -1
- package/dist/duckdb-node.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var duckdb=(()=>{var wm=Object.create;var vi=Object.defineProperty;var vm=Object.getOwnPropertyDescriptor;var Sm=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,Fm=Object.prototype.hasOwnProperty;var Va=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var Bm=(r,t,e)=>t in r?vi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Wa=(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 Kr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),qr=(r,t)=>{for(var e in t)vi(r,e,{get:t[e],enumerable:!0})},tu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sm(t))!Fm.call(r,i)&&i!==e&&vi(r,i,{get:()=>t[i],enumerable:!(n=vm(t,i))||n.enumerable});return r};var eu=(r,t,e)=>(e=r!=null?wm(Im(r)):{},tu(t||!r||!r.__esModule?vi(e,"default",{value:r,enumerable:!0}):e,r)),Dm=r=>tu(vi({},"__esModule",{value:!0}),r);var Es=(r,t,e)=>(Bm(r,typeof t!="symbol"?t+"":t,e),e);var Am=function(r,t){this[0]=r,this[1]=t};var mn=r=>{var t=r[Va("asyncIterator")],e=!1,n,i={};return t==null?(t=r[Va("iterator")](),n=s=>i[s]=a=>t[s](a)):(t=t.call(r),n=s=>i[s]=a=>{if(e){if(e=!1,s==="throw")throw a;return a}return e=!0,{done:!1,value:new Am(new Promise(l=>{var u=t[s](a);if(!(u instanceof Object))throw TypeError("Object expected");l(u)}),1)}}),i[Va("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var ql=Kr(()=>{});var ef=Kr(()=>{});var rf=Kr(()=>{});var nf=Kr(()=>{});var df=Kr((uf,ya)=>{"use strict";var _a=(()=>{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 Zc;var n,i=e,s,a,l=new Promise((o,c)=>{s=o,a=c}),u=typeof window=="object",f=typeof WorkerGlobalScope<"u",h=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",w=f&&((Zc=self.name)==null?void 0:Zc.startsWith("em-pthread"));if(h){var A=ql();global.Worker=A.Worker,f=!A.isMainThread,w=f&&A.workerData=="em-pthread"}var E=Object.assign({},i),at=[],wt="./this.program",Vt=(o,c)=>{throw c},mt="";function Ot(o){return i.locateFile?i.locateFile(o,mt):mt+o}var yt,Gt;if(h){var Ct=ef(),S=rf();mt=__dirname+"/",Gt=o=>{o=Jl(o)?new URL(o):o;var c=Ct.readFileSync(o);return c},yt=async(o,c=!0)=>{o=Jl(o)?new URL(o):o;var d=Ct.readFileSync(o,c?void 0:"utf8");return d},!i.thisProgram&&process.argv.length>1&&(wt=process.argv[1].replace(/\\/g,"/")),at=process.argv.slice(2),Vt=(o,c)=>{throw process.exitCode=o,c}}else(u||f)&&(f?mt=self.location.href:typeof document<"u"&&document.currentScript&&(mt=document.currentScript.src),r&&(mt=r),mt.startsWith("blob:")?mt="":mt=mt.slice(0,mt.replace(/[?#].*/,"").lastIndexOf("/")+1),h||(f&&(Gt=o=>{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.responseType="arraybuffer",c.send(null),new Uint8Array(c.response)}),yt=async o=>{var c=await fetch(o,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}));var U=console.log.bind(console),V=console.error.bind(console);h&&(U=(...o)=>Ct.writeSync(1,o.join(" ")+"\n"),V=(...o)=>Ct.writeSync(2,o.join(" ")+"\n"));var I=i.print||U,O=i.printErr||V;Object.assign(i,E),E=null,i.arguments&&(at=i.arguments),i.thisProgram&&(wt=i.thisProgram);var B=i.wasmBinary,N,F,H=!1,W;function At(o,c){o||zr(c)}var Ut,Ae,_t,Xe,Te,Wr,hi,Nn,fn=!1,Jl=o=>o.startsWith("file://");function va(){return N.buffer!=Ut.buffer&&xe(),Ut}function Ze(){return N.buffer!=Ut.buffer&&xe(),Ae}function Sa(){return N.buffer!=Ut.buffer&&xe(),_t}function x(){return N.buffer!=Ut.buffer&&xe(),Te}function ge(){return N.buffer!=Ut.buffer&&xe(),Wr}function Ia(){return N.buffer!=Ut.buffer&&xe(),Nn}if(w){let o=function(...m){var _=m.join(" ");if(h){Ct.writeSync(2,_+"\n");return}console.error(_)},c=function(...m){var _=m.join(" ");postMessage({cmd:"alert",text:_,threadId:xs()})},d=function(m){try{var _=m.data,y=_.cmd;if(y==="load"){let b=[];self.onmessage=g=>b.push(g),self.startWorker=g=>{postMessage({cmd:"loaded"});for(let T of b)d(T);self.onmessage=d};for(let g of _.handlers)(!i[g]||i[g].proxy)&&(i[g]=(...T)=>{postMessage({cmd:"callHandler",handler:g,args:T})},g=="print"&&(I=i[g]),g=="printErr"&&(O=i[g]));N=_.wasmMemory,xe(),Xl(_.wasmModule)}else if(y==="run"){Of(_.pthread_ptr),Ca(_.pthread_ptr,0,0,1,0,0),ft.receiveObjectTransfer(_),ft.threadInitTLS(),Ea(_.pthread_ptr),Fa||(Fa=!0);try{Uf(_.start_routine,_.arg)}catch(b){if(b!="unwind")throw b}}else _.target==="setimmediate"||(y==="checkMailbox"?Fa&&Fs():y&&(O("worker: received unknown command ".concat(y)),O(_)))}catch(b){throw Hc(),b}};var sb=o,ob=c,ab=d,Xl;if(h){var Zl=A.parentPort;Zl.on("message",m=>onmessage({data:m})),Object.assign(globalThis,{self:global,postMessage:m=>Zl.postMessage(m)})}var Fa=!1;i.printErr||(O=o),self.alert=c,self.onunhandledrejection=m=>{throw m.reason||m},self.onmessage=d}function xe(){var o=N.buffer;i.HEAP8=Ut=new Int8Array(o),i.HEAP16=_t=new Int16Array(o),i.HEAPU8=Ae=new Uint8Array(o),i.HEAPU16=Xe=new Uint16Array(o),i.HEAP32=Te=new Int32Array(o),i.HEAPU32=Wr=new Uint32Array(o),i.HEAPF32=hi=new Float32Array(o),i.HEAPF64=Nn=new Float64Array(o)}if(w)i.wasmMemory&&(N=i.wasmMemory,xe());else{if(i.wasmMemory)N=i.wasmMemory;else{var vf=i.INITIAL_MEMORY||16777216;N=new WebAssembly.Memory({initial:vf/65536,maximum:65536,shared:!0})}xe()}function Sf(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)cc(i.preRun.shift());ac(lc)}function Ql(){if(fn=!0,w)return startWorker(i);M.Ha()}function ib(){}function If(){if(!w){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)Ef(i.postRun.shift());ac(hc)}}var hn=0,pi=null;function tc(o){var c;hn++,(c=i.monitorRunDependencies)==null||c.call(i,hn)}function ec(o){var d;if(hn--,(d=i.monitorRunDependencies)==null||d.call(i,hn),hn==0&&pi){var c=pi;pi=null,c()}}function zr(o){var d;(d=i.onAbort)==null||d.call(i,o),o="Aborted("+o+")",O(o),H=!0,o+=". Build with -sASSERTIONS for more info.",fn&&___trap();var c=new WebAssembly.RuntimeError(o);throw a(c),c}var mi;function Ff(){return Ot("./duckdb-coi.wasm")}function Bf(o){if(o==mi&&B)return new Uint8Array(B);if(Gt)return Gt(o);throw"both async and sync fetching of the wasm failed"}async function Df(o){if(!B)try{var c=await yt(o);return new Uint8Array(c)}catch(d){}return Bf(o)}async function Af(o,c){try{var d=await Df(o),m=await WebAssembly.instantiate(d,c);return m}catch(_){O("failed to asynchronously prepare wasm: ".concat(_)),zr(_)}}async function Tf(o,c,d){if(!o&&typeof WebAssembly.instantiateStreaming=="function"&&!h)try{var m=fetch(c,{credentials:"same-origin"}),_=await WebAssembly.instantiateStreaming(m,d);return _}catch(y){O("wasm streaming compile failed: ".concat(y)),O("falling back to ArrayBuffer instantiation")}return Af(c,d)}function rc(){return Bp(),{a:Cc}}async function xf(){function o(y,b){return M=y.exports,M=bm(M),Mf(M.zb),pc=M.Ja,F=b,ec("wasm-instantiate"),M}tc("wasm-instantiate");function c(y){return o(y.instance,y.module)}var d=rc();if(i.instantiateWasm)return new Promise((y,b)=>{i.instantiateWasm(d,(g,T)=>{o(g,T),y(g.exports)})});if(w)return new Promise(y=>{Xl=b=>{var g=new WebAssembly.Instance(b,rc());y(o(g,b))}});mi!=null||(mi=Ff());try{var m=await Tf(B,mi,d),_=c(m);return _}catch(y){return a(y),Promise.reject(y)}}var Bt,fr,nc={10184256:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,v=c;b<v*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];try{var k=encodeURI(ut(g));k==="Host"&&(k="X-Host-Override"),k==="User-Agent"&&(k="X-user-agent"),k==="Authorization"?y.setRequestHeader(k,ut(T)):y.setRequestHeader(k,encodeURI(ut(T)))}catch(Pt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Pt)}b+=2}try{y.send(null)}catch(Pt){return 0}if(y.status>=400)return 0;for(var Y=y.response,v=Y.byteLength,ht=mr(v+4),bt=new Uint8Array(Y),st=0;st<v;st++)i.HEAPU8[st+ht+4]=bt[st];var D=new Uint8Array(4);return D[0]=v%256,v-=D[0],v/=256,D[1]=v%256,v-=D[1],v/=256,D[2]=v%256,v-=D[2],v/=256,D[3]=v%256,v-=D[3],v/=256,i.HEAPU8.set(D,ht),ht},10185663:(o,c,d,m,_,y)=>{var b=ut(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(ut(m),b,!1),g.responseType="arraybuffer";for(var T=0,D=c;T<D*2;){var k=x()[d/4+T>>>0],Y=x()[d/4+T+1>>>0];try{var v=encodeURI(ut(k));v==="Host"&&(v="X-Host-Override"),v==="User-Agent"&&(v="X-user-agent"),v==="Authorization"?g.setRequestHeader(v,ut(Y)):g.setRequestHeader(v,encodeURI(ut(Y)))}catch(Qe){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Qe)}T+=2}try{for(var ht=new Uint8Array(y),bt=0;bt<y;bt++)ht[bt]=i.HEAPU8[bt+_];g.send(ht)}catch(Qe){return 0}if(g.status>=400)return 0;for(var st=Uint8Array.from(Array.from(g.getResponseHeader("Etag")).map(Qe=>Qe.charCodeAt(0))),D=st.byteLength,Pt=mr(D+4),Ee=new Uint8Array(st),bt=0;bt<D;bt++)i.HEAPU8[bt+Pt+4]=Ee[bt];var Tt=new Uint8Array(4);return Tt[0]=D%256,D-=Tt[0],D/=256,Tt[1]=D%256,D-=Tt[1],D/=256,Tt[2]=D%256,D-=Tt[2],D/=256,Tt[3]=D%256,D-=Tt[3],D/=256,i.HEAPU8.set(Tt,Pt),Pt},10187283:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,v=c;b<v*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];console.log("HEAD",ut(g),ut(T));try{var k=encodeURI(ut(g));k==="Host"&&(k="X-Host-Override"),k==="User-Agent"&&(k="X-user-agent"),k==="Authorization"?y.setRequestHeader(k,ut(T)):y.setRequestHeader(k,encodeURI(ut(T)))}catch(Tt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Tt)}b+=2}try{y.send(null)}catch(Tt){return 0}if(y.status>=400)return 0;for(var Y=y.response,v=Y.byteLength,ht=mr(v+8),bt=new Uint8Array(Y),st=0;st<v;st++)i.HEAPU8[st+ht+8]=bt[st];var D=new Uint8Array(4);D[0]=v%256,v-=D[0],v/=256,D[1]=v%256,v-=D[1],v/=256,D[2]=v%256,v-=D[2],v/=256,D[3]=v%256,v-=D[3],v/=256,i.HEAPU8.set(D,ht+4);var Pt=Uint8Array.from(Array.from(y.getAllResponseHeaders()).map(Tt=>Tt.charCodeAt(0)));v=Pt.byteLength;for(var Ee=mr(v+8),st=0;st<v;st++)i.HEAPU8[st+Ee+8]=Pt[st];return D=new Uint8Array(4),D[0]=v%256,v-=D[0],v/=256,D[1]=v%256,v-=D[1],v/=256,D[2]=v%256,v-=D[2],v/=256,D[3]=v%256,v-=D[3],v/=256,i.HEAPU8.set(D,Ee+4),v=Ee,D=new Uint8Array(4),D[0]=v%256,v-=D[0],v/=256,D[1]=v%256,v-=D[1],v/=256,D[2]=v%256,v-=D[2],v/=256,D[3]=v%256,v-=D[3],v/=256,i.HEAPU8.set(D,ht),ht},10189628:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,v=c;b<v*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];try{var k=encodeURI(ut(g));k==="Host"&&(k="X-Host-Override"),k==="User-Agent"&&(k="X-user-agent"),k==="Authorization"?y.setRequestHeader(k,ut(T)):y.setRequestHeader(k,encodeURI(ut(T)))}catch(Pt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Pt)}b+=2}try{y.send(null)}catch(Pt){return 0}if(y.status>=400)return 0;for(var Y=y.response,v=Y.byteLength,ht=mr(v+4),bt=new Uint8Array(Y),st=0;st<v;st++)i.HEAPU8[st+ht+4]=bt[st];var D=new Uint8Array(4);return D[0]=v%256,v-=D[0],v/=256,D[1]=v%256,v-=D[1],v/=256,D[2]=v%256,v-=D[2],v/=256,D[3]=v%256,v-=D[3],v/=256,i.HEAPU8.set(D,ht),ht},10191035:(o,c,d,m,_,y)=>{var b=ut(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(ut(m),b,!1),g.responseType="arraybuffer";for(var T=0,D=c;T<D*2;){var k=x()[d/4+T>>>0],Y=x()[d/4+T+1>>>0];try{var v=encodeURI(ut(k));v==="Host"&&(v="X-Host-Override"),v==="User-Agent"&&(v="X-user-agent"),v==="Authorization"?g.setRequestHeader(v,ut(Y)):g.setRequestHeader(v,encodeURI(ut(Y)))}catch(Qe){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Qe)}T+=2}try{for(var ht=new Uint8Array(y),bt=0;bt<y;bt++)ht[bt]=i.HEAPU8[bt+_];g.send(ht)}catch(Qe){return 0}if(g.status>=400)return 0;for(var st=g.response,D=st.byteLength,Pt=mr(D+4),Ee=new Uint8Array(st),bt=0;bt<D;bt++)i.HEAPU8[bt+Pt+4]=Ee[bt];var Tt=new Uint8Array(4);return Tt[0]=D%256,D-=Tt[0],D/=256,Tt[1]=D%256,D-=Tt[1],D/=256,Tt[2]=D%256,D-=Tt[2],D/=256,Tt[3]=D%256,D-=Tt[3],D/=256,i.HEAPU8.set(Tt,Pt),Pt}};class ic{constructor(c){Es(this,"name","ExitStatus");this.message="Program terminated with exit(".concat(c,")"),this.status=c}}var sc=o=>{o.terminate(),o.onmessage=c=>{}},oc=o=>{var c=ft.pthreads[o];ft.returnWorkerToPool(c)},ac=o=>{for(;o.length>0;)o.shift()(i)},lc=[],cc=o=>lc.unshift(o),uc=o=>{var c=ft.getNewWorker();if(!c)return 6;ft.runningWorkers.push(c),ft.pthreads[o.pthread_ptr]=c,c.pthread_ptr=o.pthread_ptr;var d={cmd:"run",start_routine:o.startRoutine,arg:o.arg,pthread_ptr:o.pthread_ptr};return h&&c.unref(),c.postMessage(d,o.transferList),0},vs=0,Ba=()=>xa||vs>0,Ss=()=>Xc(),_i=o=>Yc(o),yi=o=>Jc(o);i.stackAlloc=yi;var jr=(o,c)=>c+2097152>>>0<4194305-!!o?(o>>>0)+c*4294967296:NaN,kn=(o,c,d,...m)=>{for(var _=m.length,y=Ss(),b=yi(_*8),g=b>>>3,T=0;T<m.length;T++){var k=m[T];Ia()[g+T>>>0]=k}var Y=zc(o,c,_,b,d);return _i(y),Y};function Da(o){var c;if(w)return kn(0,0,1,o);W=o,Ba()||(ft.terminateAllThreads(),(c=i.onExit)==null||c.call(i,o),H=!0),Vt(o,new ic(o))}var Aa=o=>{if(o instanceof ic||o=="unwind")return W;Vt(1,o)};function dc(o){if(w)return kn(1,0,0,o);Ta(o)}var fc=(o,c)=>{if(W=o,w)throw dc(o),"unwind";Da(o)},Ta=fc,ft={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){w||ft.initMainThread()},initMainThread(){for(var o=4;o--;)ft.allocateUnusedWorker();cc(()=>{tc("loading-workers"),ft.loadWasmModuleToAllWorkers(()=>ec("loading-workers"))})},terminateAllThreads:()=>{for(var o of ft.runningWorkers)sc(o);for(var o of ft.unusedWorkers)sc(o);ft.unusedWorkers=[],ft.runningWorkers=[],ft.pthreads={}},returnWorkerToPool:o=>{var c=o.pthread_ptr;delete ft.pthreads[c],ft.unusedWorkers.push(o),ft.runningWorkers.splice(ft.runningWorkers.indexOf(o),1),o.pthread_ptr=0,jc(c)},receiveObjectTransfer(o){},threadInitTLS(){ft.tlsInitFunctions.forEach(o=>o())},loadWasmModuleToWorker:o=>new Promise(c=>{o.onmessage=y=>{var b=y.data,g=b.cmd;if(b.targetThread&&b.targetThread!=xs()){var T=ft.pthreads[b.targetThread];T?T.postMessage(b,b.transferList):O('Internal error! Worker sent a message "'.concat(g,'" to target pthread ').concat(b.targetThread,", but that thread no longer exists!"));return}g==="checkMailbox"?Fs():g==="spawnThread"?uc(b):g==="cleanupThread"?oc(b.thread):g==="loaded"?(o.loaded=!0,h&&!o.pthread_ptr&&o.unref(),c(o)):g==="alert"?alert("Thread ".concat(b.threadId,": ").concat(b.text)):b.target==="setimmediate"?o.postMessage(b):g==="callHandler"?i[b.handler](...b.args):g&&O("worker sent an unknown command ".concat(g))},o.onerror=y=>{var b="worker sent an error!";throw O("".concat(b," ").concat(y.filename,":").concat(y.lineno,": ").concat(y.message)),y},h&&(o.on("message",y=>o.onmessage({data:y})),o.on("error",y=>o.onerror(y)));var d=[],m=["onExit","onAbort","print","printErr"];for(var _ of m)i.propertyIsEnumerable(_)&&d.push(_);o.postMessage({cmd:"load",handlers:d,wasmMemory:N,wasmModule:F})}),loadWasmModuleToAllWorkers(o){if(w)return o();Promise.all(ft.unusedWorkers.map(ft.loadWasmModuleToWorker)).then(o)},allocateUnusedWorker(){var o,c={workerData:"em-pthread",name:"em-pthread"},d=r;i.mainScriptUrlOrBlob&&(d=i.mainScriptUrlOrBlob,typeof d!="string"&&(d=URL.createObjectURL(d))),o=new Worker(d,c),ft.unusedWorkers.push(o)},getNewWorker(){return ft.unusedWorkers.length==0&&(ft.allocateUnusedWorker(),ft.loadWasmModuleToWorker(ft.unusedWorkers[0])),ft.unusedWorkers.pop()}},hc=[],Ef=o=>hc.unshift(o),Of=o=>{xe();var c=ge()[o+52>>>2>>>0],d=ge()[o+56>>>2>>>0],m=c-d;qc(c,m),_i(c)},Is=[],pc,mc=o=>{var c=Is[o];return c||(o>=Is.length&&(Is.length=o+1),Is[o]=c=pc.get(o)),c},Uf=(o,c)=>{vs=0,xa=0;var d=mc(o)(c);function m(_){Ba()?W=_:Pa(_)}m(d)},xa=i.noExitRuntime||!0,Mf=o=>ft.tlsInitFunctions.push(o);function Rf(o,c){return o>>>=0,mc(o)(c)}function _c(o,c,d,m){return w?kn(2,0,1,o,c,d,m):yc(o,c,d,m)}var Lf=()=>typeof SharedArrayBuffer<"u";function yc(o,c,d,m){if(o>>>=0,c>>>=0,d>>>=0,m>>>=0,!Lf())return 6;var _=[],y=0;if(w&&(_.length===0||y))return _c(o,c,d,m);if(y)return y;var b={startRoutine:d,pthread_ptr:o,arg:m,transferList:_};return w?(b.cmd="spawnThread",postMessage(b,_),0):uc(b)}var Nf=()=>zr("");function kf(o){o>>>=0,Ca(o,!f,1,!u,1048576,!1),ft.threadInitTLS()}var Cf=()=>{if(!Ba())try{w?Pa(W):Ta(W)}catch(o){Aa(o)}},Pf=o=>{if(!H)try{o(),Cf()}catch(c){Aa(c)}};function Ea(o){if(o>>>=0,typeof Atomics.waitAsync=="function"){var c=Atomics.waitAsync(x(),o>>>2,o);c.value.then(Fs);var d=o+128;Atomics.store(x(),d>>>2,1)}}var Fs=()=>{var o=xs();o&&(Ea(o),Pf($c))};function Hf(o,c){if(o>>>=0,c>>>=0,o==c)setTimeout(Fs);else if(w)postMessage({targetThread:o,cmd:"checkMailbox"});else{var d=ft.pthreads[o];if(!d)return;d.postMessage({cmd:"checkMailbox"})}}var Oa=[];function Vf(o,c,d,m,_){c>>>=0,d>>>=0,_>>>=0,Oa.length=m;for(var y=_>>>3,b=0;b<m;b++)Oa[b]=Ia()[y+b>>>0];var g=c?nc[c]:Fp[o];ft.currentProxiedOperationCallerThread=d;var T=g(...Oa);return ft.currentProxiedOperationCallerThread=0,T}var Wf=()=>{xa=!1,vs=0},bc=typeof TextDecoder<"u"?new TextDecoder:void 0,zf=(o,c=0,d=NaN)=>{c>>>=0;for(var m=c+d,_=c;o[_]&&!(_>=m);)++_;if(_-c>16&&o.buffer&&bc)return bc.decode(o.buffer instanceof ArrayBuffer?o.subarray(c,_):o.slice(c,_));for(var y="";c<_;){var b=o[c++];if(!(b&128)){y+=String.fromCharCode(b);continue}var g=o[c++]&63;if((b&224)==192){y+=String.fromCharCode((b&31)<<6|g);continue}var T=o[c++]&63;if((b&240)==224?b=(b&15)<<12|g<<6|T:b=(b&7)<<18|g<<12|T<<6|o[c++]&63,b<65536)y+=String.fromCharCode(b);else{var k=b-65536;y+=String.fromCharCode(55296|k>>10,56320|k&1023)}}return y},ut=(o,c)=>(o>>>=0,o?zf(Ze(),o,c):"");function jf(o){if(o>>>=0,h){if(!o)return 1;var c=ut(o);if(!c.length)return 0;var d=["child_process"].map(Wa),m=d.spawnSync(c,[],{shell:!0,stdio:"inherit"}),_=(b,g)=>b<<8|g;if(m.status===null){var y=b=>{switch(b){case"SIGHUP":return 1;case"SIGQUIT":return 3;case"SIGFPE":return 8;case"SIGKILL":return 9;case"SIGALRM":return 14;case"SIGTERM":return 15;default:return 2}};return _(0,y(m.signal))}return _(m.status,0)}return o?-52:0}function $f(o){o>>>=0,w?postMessage({cmd:"cleanupThread",thread:o}):oc(o)}function Gf(o){o>>>=0,h&&ft.pthreads[o].ref()}function gc(){zr("missing function: _emval_call_method")}gc.stub=!0;function wc(){zr("missing function: _emval_decref")}wc.stub=!0;function vc(){zr("missing function: _emval_get_global")}vc.stub=!0;function Sc(){zr("missing function: _emval_get_method_caller")}Sc.stub=!0;function Ic(){zr("missing function: _emval_run_destructors")}Ic.stub=!0;function Kf(o,c,d){var m=jr(o,c);d>>>=0;var _=new Date(m*1e3);x()[d>>>2>>>0]=_.getUTCSeconds(),x()[d+4>>>2>>>0]=_.getUTCMinutes(),x()[d+8>>>2>>>0]=_.getUTCHours(),x()[d+12>>>2>>>0]=_.getUTCDate(),x()[d+16>>>2>>>0]=_.getUTCMonth(),x()[d+20>>>2>>>0]=_.getUTCFullYear()-1900,x()[d+24>>>2>>>0]=_.getUTCDay();var y=Date.UTC(_.getUTCFullYear(),0,1,0,0,0,0),b=(_.getTime()-y)/(1e3*60*60*24)|0;x()[d+28>>>2>>>0]=b}var qf=o=>o%4===0&&(o%100!==0||o%400===0),Yf=[0,31,60,91,121,152,182,213,244,274,305,335],Jf=[0,31,59,90,120,151,181,212,243,273,304,334],Fc=o=>{var c=qf(o.getFullYear()),d=c?Yf:Jf,m=d[o.getMonth()]+o.getDate()-1;return m};function Xf(o,c,d){var m=jr(o,c);d>>>=0;var _=new Date(m*1e3);x()[d>>>2>>>0]=_.getSeconds(),x()[d+4>>>2>>>0]=_.getMinutes(),x()[d+8>>>2>>>0]=_.getHours(),x()[d+12>>>2>>>0]=_.getDate(),x()[d+16>>>2>>>0]=_.getMonth(),x()[d+20>>>2>>>0]=_.getFullYear()-1900,x()[d+24>>>2>>>0]=_.getDay();var y=Fc(_)|0;x()[d+28>>>2>>>0]=y,x()[d+36>>>2>>>0]=-(_.getTimezoneOffset()*60);var b=new Date(_.getFullYear(),0,1),g=new Date(_.getFullYear(),6,1).getTimezoneOffset(),T=b.getTimezoneOffset(),k=(g!=T&&_.getTimezoneOffset()==Math.min(T,g))|0;x()[d+32>>>2>>>0]=k}var Ua=o=>Gc(o),Zf=function(o){o>>>=0;var c=(()=>{var d=new Date(x()[o+20>>>2>>>0]+1900,x()[o+16>>>2>>>0],x()[o+12>>>2>>>0],x()[o+8>>>2>>>0],x()[o+4>>>2>>>0],x()[o>>>2>>>0],0),m=x()[o+32>>>2>>>0],_=d.getTimezoneOffset(),y=new Date(d.getFullYear(),0,1),b=new Date(d.getFullYear(),6,1).getTimezoneOffset(),g=y.getTimezoneOffset(),T=Math.min(g,b);if(m<0)x()[o+32>>>2>>>0]=+(b!=g&&T==_);else if(m>0!=(T==_)){var k=Math.max(g,b),Y=m>0?T:k;d.setTime(d.getTime()+(Y-_)*6e4)}x()[o+24>>>2>>>0]=d.getDay();var v=Fc(d)|0;x()[o+28>>>2>>>0]=v,x()[o>>>2>>>0]=d.getSeconds(),x()[o+4>>>2>>>0]=d.getMinutes(),x()[o+8>>>2>>>0]=d.getHours(),x()[o+12>>>2>>>0]=d.getDate(),x()[o+16>>>2>>>0]=d.getMonth(),x()[o+20>>>2>>>0]=d.getYear();var ht=d.getTime();return isNaN(ht)?-1:ht/1e3})();return Ua((Bt=c,+Math.abs(Bt)>=1?Bt>0?+Math.floor(Bt/4294967296)>>>0:~~+Math.ceil((Bt-+(~~Bt>>>0))/4294967296)>>>0:0)),c>>>0},Bc=(o,c,d,m)=>{if(d>>>=0,!(m>0))return 0;for(var _=d,y=d+m-1,b=0;b<o.length;++b){var g=o.charCodeAt(b);if(g>=55296&&g<=57343){var T=o.charCodeAt(++b);g=65536+((g&1023)<<10)|T&1023}if(g<=127){if(d>=y)break;c[d++>>>0]=g}else if(g<=2047){if(d+1>=y)break;c[d++>>>0]=192|g>>6,c[d++>>>0]=128|g&63}else if(g<=65535){if(d+2>=y)break;c[d++>>>0]=224|g>>12,c[d++>>>0]=128|g>>6&63,c[d++>>>0]=128|g&63}else{if(d+3>=y)break;c[d++>>>0]=240|g>>18,c[d++>>>0]=128|g>>12&63,c[d++>>>0]=128|g>>6&63,c[d++>>>0]=128|g&63}}return c[d>>>0]=0,d-_},hr=(o,c,d)=>Bc(o,Ze(),c,d);i.stringToUTF8=hr;var Qf=function(o,c,d,m){o>>>=0,c>>>=0,d>>>=0,m>>>=0;var _=new Date().getFullYear(),y=new Date(_,0,1),b=new Date(_,6,1),g=y.getTimezoneOffset(),T=b.getTimezoneOffset(),k=Math.max(g,T);ge()[o>>>2>>>0]=k*60,x()[c>>>2>>>0]=+(g!=T);var Y=bt=>{var st=bt>=0?"-":"+",D=Math.abs(bt),Pt=String(Math.floor(D/60)).padStart(2,"0"),Ee=String(D%60).padStart(2,"0");return"UTC".concat(st).concat(Pt).concat(Ee)},v=Y(g),ht=Y(T);T<g?(hr(v,d,17),hr(ht,m,17)):(hr(v,m,17),hr(ht,d,17))};function th(o,c){return c>>>=0,Ze().set(bi[o].fileData,c>>>0)}var Ma=[],eh=()=>Ma.length,bi=[],rh=!1,nh=()=>(rh=!0,bi.length);function ih(o,c){c>>>=0;var d=Ma[o].childName,m=Cn(d)+1;hr(d,c,m)}var sh=o=>bi[o].mode;function oh(o){return bi[o].fileData.length}function ah(o,c){c>>>=0;var d=Ma[o].parentPath,m=Cn(d)+1;hr(d,c,m)}var Cn=o=>{for(var c=0,d=0;d<o.length;++d){var m=o.charCodeAt(d);m<=127?c++:m<=2047?c+=2:m>=55296&&m<=57343?(c+=4,++d):c+=3}return c};i.lengthBytesUTF8=Cn;function lh(o,c){c>>>=0;var d=bi[o].pathName,m=Cn(d)+1;hr(d,c,m)}class Bs{constructor(){Es(this,"allocated",[void 0]);Es(this,"freelist",[])}get(c){return this.allocated[c]}has(c){return this.allocated[c]!==void 0}allocate(c){var d=this.freelist.pop()||this.allocated.length;return this.allocated[d]=c,d}free(c){this.allocated[c]=void 0,this.freelist.push(c)}}var $r=new Bs,ee=o=>{Wc(o)};async function ch(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c);try{await m.close()}catch(_){let y=-29;x()[d>>>2>>>0]=y}$r.free(c),ee(o)}var Ds=new Bs,uh=o=>{Ds.free(o)};async function dh(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c);try{await m.flush()}catch(_){let y=-29;x()[d>>>2>>>0]=y}ee(o)}var pr=new Bs,fh=o=>{pr.free(o)},pn=new Bs,hh=o=>{pn.free(o)};async function Dc(o,c,d){let m=pr.get(o),_;try{_=await m.getFileHandle(c,{create:d})}catch(y){return y.name==="NotFoundError"?-20:y.name==="TypeMismatchError"?-31:-29}return pn.allocate(_)}async function Ac(o,c,d){let m=pr.get(o),_;try{_=await m.getDirectoryHandle(c,{create:d})}catch(y){return y.name==="NotFoundError"?-20:y.name==="TypeMismatchError"?-54:-29}return pr.allocate(_)}async function ph(o,c,d,m,_){o>>>=0,d>>>=0,m>>>=0,_>>>=0;let y=ut(d),b=1,g=await Dc(c,y,!1);g==-31&&(b=2,g=await Ac(c,y,!1)),x()[m>>>2>>>0]=b,x()[_>>>2>>>0]=g,ee(o)}async function mh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=pr.get(c);try{let y=_.entries();for(let b;b=await y.next(),!b.done;){let[g,T]=b.value,k=Ss(),Y=kc(g),v=T.kind=="file"?1:2;__wasmfs_opfs_record_entry(d,Y,v),_i(k)}}catch(y){let b=-29;x()[m>>>2>>>0]=b}ee(o)}async function _h(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c),_;try{_=await m.getSize()}catch(y){_=-29}fr=[_>>>0,(Bt=_,+Math.abs(Bt)>=1?Bt>0?+Math.floor(Bt/4294967296)>>>0:~~+Math.ceil((Bt-+(~~Bt>>>0))/4294967296)>>>0:0)],x()[d>>>2>>>0]=fr[0],x()[d+4>>>2>>>0]=fr[1],ee(o)}var yh=function(o){var c=Ds.get(o).size;return Ua((Bt=c,+Math.abs(Bt)>=1?Bt>0?+Math.floor(Bt/4294967296)>>>0:~~+Math.ceil((Bt-+(~~Bt>>>0))/4294967296)>>>0:0)),c>>>0};async function bh(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{_=(await m.getFile()).size}catch(y){_=-29}fr=[_>>>0,(Bt=_,+Math.abs(Bt)>=1?Bt>0?+Math.floor(Bt/4294967296)>>>0:~~+Math.ceil((Bt-+(~~Bt>>>0))/4294967296)>>>0:0)],x()[d>>>2>>>0]=fr[0],x()[d+4>>>2>>>0]=fr[1],ee(o)}async function gh(o){if(o>>>=0,pr.allocated.length==1){let c=await navigator.storage.getDirectory();pr.allocated.push(c)}ee(o)}async function wh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=await Ac(c,_,!0);x()[m>>>2>>>0]=y,ee(o)}async function vh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=await Dc(c,_,!0);x()[m>>>2>>>0]=y,ee(o)}async function Sh(o,c,d,m,_){o>>>=0,m>>>=0,_>>>=0;let y=ut(m),b=pn.get(c),g=pr.get(d);try{await b.move(g,y)}catch(T){let k=-29;x()[_>>>2>>>0]=k}ee(o)}async function Ih(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{let b;var y=FileSystemFileHandle.prototype.createSyncAccessHandle.length;y==0?b=await m.createSyncAccessHandle():b=await m.createSyncAccessHandle({mode:"in-place"}),_=$r.allocate(b)}catch(b){b.name==="InvalidStateError"||b.name==="NoModificationAllowedError"?_=-2:_=-29}x()[d>>>2>>>0]=_,ee(o)}async function Fh(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{let y=await m.getFile();_=Ds.allocate(y)}catch(y){y.name==="NotAllowedError"?_=-2:_=-29}x()[d>>>2>>>0]=_,ee(o)}function Bh(o,c,d,m,_){c>>>=0;var y=jr(m,_);let b=$r.get(o),g=Ze().subarray(c>>>0,c+d>>>0);try{return b.read(g,{at:y})}catch(T){return T.name=="TypeError"?-28:-29}}async function Dh(o,c,d,m,_,y,b){o>>>=0,d>>>=0;var g=jr(_,y);b>>>=0;let k=Ds.get(c).slice(g,g+m),Y=0;try{let v=await k.arrayBuffer(),ht=new Uint8Array(v);Ze().set(ht,d>>>0),Y+=ht.length}catch(v){v instanceof RangeError?Y=-21:Y=-29}x()[b>>>2>>>0]=Y,ee(o)}async function Ah(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=pr.get(c);try{await y.removeEntry(_)}catch(b){let g=-29;x()[m>>>2>>>0]=g}ee(o)}async function Th(o,c,d,m,_){o>>>=0;var y=jr(d,m);_>>>=0;let b=$r.get(c);try{await b.truncate(y)}catch(g){let T=-29;x()[_>>>2>>>0]=T}ee(o)}async function xh(o,c,d,m,_){o>>>=0;var y=jr(d,m);_>>>=0;let b=pn.get(c);try{let g=await b.createWritable({keepExistingData:!0});await g.truncate(y),await g.close()}catch(g){let T=-29;x()[_>>>2>>>0]=T}ee(o)}function Eh(o,c,d,m,_){c>>>=0;var y=jr(m,_);let b=$r.get(o),g=Ze().subarray(c>>>0,c+d>>>0);try{return b.write(g,{at:y})}catch(T){return T.name=="TypeError"?-28:-29}}var Ra=[],Oh=(o,c,d)=>{var m=d>0?d:Cn(o)+1,_=new Array(m),y=Bc(o,_,0,_.length);return c&&(_.length=y),_},Uh=()=>{if(!Ra.length){var o=null;if(h){var c=256,d=Buffer.alloc(c),m=0,_=process.stdin.fd;try{m=Ct.readSync(_,d,0,c)}catch(y){if(y.toString().includes("EOF"))m=0;else throw y}m>0&&(o=d.slice(0,m).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(o=window.prompt("Input: "),o!==null&&(o+="\n"));if(!o)return null;Ra=Oh(o,!0)}return Ra.shift()},Mh=()=>{var o=Uh();return typeof o=="number"?o:-1},Rh=function(o){o>>>=0;var c=setInterval(()=>{H?clearInterval(c):Vc(o)},50)},Tc=()=>performance.timeOrigin+performance.now(),xc=()=>Date.now(),Lh=1,Nh=o=>o>=0&&o<=3;function kh(o,c,d,m){var _=jr(c,d);if(m>>>=0,!Nh(o))return 28;var y;if(o===0)y=xc();else if(Lh)y=Tc();else return 52;var b=Math.round(y*1e3*1e3);return fr=[b>>>0,(Bt=b,+Math.abs(Bt)>=1?Bt>0?+Math.floor(Bt/4294967296)>>>0:~~+Math.ceil((Bt-+(~~Bt>>>0))/4294967296)>>>0:0)],x()[m>>>2>>>0]=fr[0],x()[m+4>>>2>>>0]=fr[1],0}function Ch(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(i,o,c)}function Ph(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(i,o,c)}function Hh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(i,o,c)}function Vh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(i,o,c)}function Wh(o){return globalThis.DUCKDB_RUNTIME.closeFile(i,o)}function zh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(i,o,c)}function jh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(i,o,c)}function $h(o,c,d,m){return o>>>=0,d>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(i,o,c,d,m)}function Gh(o,c){return globalThis.DUCKDB_RUNTIME.openFile(i,o,c)}function Kh(o,c,d,m){return c>>>=0,globalThis.DUCKDB_RUNTIME.readFile(i,o,c,d,m)}function qh(o,c){return globalThis.DUCKDB_RUNTIME.truncateFile(i,o,c)}function Yh(o,c,d,m){return c>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(i,o,c,d,m)}function Jh(o){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(o)}function Xh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.glob(i,o,c)}function Zh(o){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(i,o)}function Qh(o,c,d,m,_,y){return o>>>=0,d>>>=0,_>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(i,o,c,d,m,_,y)}var La=[],tp=(o,c)=>{La.length=0;for(var d;d=Ze()[o++>>>0];){var m=d!=105;m&=d!=112,c+=m&&c%8?4:0,La.push(d==112?ge()[c>>>2>>>0]:d==105?x()[c>>>2>>>0]:Ia()[c>>>3>>>0]),c+=m?8:4}return La},ep=(o,c,d)=>{var m=tp(c,d);return nc[o](...m)};function rp(o,c,d){return o>>>=0,c>>>=0,d>>>=0,ep(o,c,d)}var gi=o=>{gi.shown||(gi.shown={}),gi.shown[o]||(gi.shown[o]=1,h&&(o="warning: "+o),O(o))},np=()=>{};function ip(o){return o>>>=0,O(ut(o))}var sp=()=>{vs+=1},op=()=>{throw sp(),"unwind"},Ec=()=>4294901760;function ap(){return Ec()}var lp=()=>h?nf().cpus().length:navigator.hardwareConcurrency;function cp(o){return o>>>=0,I(ut(o))}var up=(o,c)=>Math.ceil(o/c)*c,dp=o=>{var c=N.buffer,d=(o-c.byteLength+65535)/65536|0;try{return N.grow(d),xe(),1}catch(m){}};function fp(o){o>>>=0;var c=Ze().length;if(o<=c)return!1;var d=Ec();if(o>d)return!1;for(var m=1;m<=4;m*=2){var _=c*(1+.2/m);_=Math.min(_,o+100663296);var y=Math.min(d,up(Math.max(o,_),65536)),b=dp(y);if(b)return!0}return!1}var hp=()=>{throw"unwind"},Na={},pp=()=>wt||"./this.program",wi=()=>{if(!wi.strings){var o=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",c={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:o,_:pp()};for(var d in Na)Na[d]===void 0?delete c[d]:c[d]=Na[d];var m=[];for(var d in c)m.push("".concat(d,"=").concat(c[d]));wi.strings=m}return wi.strings},mp=(o,c)=>{for(var d=0;d<o.length;++d)va()[c++>>>0]=o.charCodeAt(d);va()[c>>>0]=0},Oc=function(o,c){if(w)return kn(3,0,1,o,c);o>>>=0,c>>>=0;var d=0;return wi().forEach((m,_)=>{var y=c+d;ge()[o+_*4>>>2>>>0]=y,mp(m,y),d+=m.length+1}),0},Uc=function(o,c){if(w)return kn(4,0,1,o,c);o>>>=0,c>>>=0;var d=wi();ge()[o>>>2>>>0]=d.length;var m=0;return d.forEach(_=>m+=_.length+1),ge()[c>>>2>>>0]=m,0},As=o=>{for(var c=o.split("."),d=0;d<4;d++){var m=Number(c[d]);if(isNaN(m))return null;c[d]=m}return(c[0]|c[1]<<8|c[2]<<16|c[3]<<24)>>>0},Ts=o=>parseInt(o),ka=o=>{var c,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(!y.test(o))return null;if(o==="::")return[0,0,0,0,0,0,0,0];for(o.startsWith("::")?o=o.replace("::","Z:"):o=o.replace("::",":Z:"),o.indexOf(".")>0?(o=o.replace(new RegExp("[.]","g"),":"),c=o.split(":"),c[c.length-4]=Ts(c[c.length-4])+Ts(c[c.length-3])*256,c[c.length-3]=Ts(c[c.length-2])+Ts(c[c.length-1])*256,c=c.slice(0,c.length-2)):c=o.split(":"),m=0,_=0,d=0;d<c.length;d++)if(typeof c[d]=="string")if(c[d]==="Z"){for(_=0;_<8-c.length+1;_++)b[d+_]=0;m=_-1}else b[d+m]=_htons(parseInt(c[d],16));else b[d+m]=c[d];return[b[1]<<16|b[0],b[3]<<16|b[2],b[5]<<16|b[4],b[7]<<16|b[6]]},Gr={address_map:{id:1,addrs:{},names:{}},lookup_name(o){var c=As(o);if(c!==null||(c=ka(o),c!==null))return o;var d;if(Gr.address_map.addrs[o])d=Gr.address_map.addrs[o];else{var m=Gr.address_map.id++;At(m<65535,"exceeded max address mappings of 65535"),d="172.29."+(m&255)+"."+(m&65280),Gr.address_map.names[d]=o,Gr.address_map.addrs[o]=d}return d},lookup_addr(o){return Gr.address_map.names[o]?Gr.address_map.names[o]:null}},Mc=o=>(o&255)+"."+(o>>8&255)+"."+(o>>16&255)+"."+(o>>24&255),_p=o=>{var c="",d=0,m=0,_=0,y=0,b=0,g=0,T=[o[0]&65535,o[0]>>16,o[1]&65535,o[1]>>16,o[2]&65535,o[2]>>16,o[3]&65535,o[3]>>16],k=!0,Y="";for(g=0;g<5;g++)if(T[g]!==0){k=!1;break}if(k){if(Y=Mc(T[6]|T[7]<<16),T[5]===-1)return c="::ffff:",c+=Y,c;if(T[5]===0)return c="::",Y==="0.0.0.0"&&(Y=""),Y==="0.0.0.1"&&(Y="1"),c+=Y,c}for(d=0;d<8;d++)T[d]===0&&(d-_>1&&(b=0),_=d,b++),b>m&&(m=b,y=d-m+1);for(d=0;d<8;d++){if(m>1&&T[d]===0&&d>=y&&d<y+m){d===y&&(c+=":",y===0&&(c+=":"));continue}c+=Number(_ntohs(T[d]&65535)).toString(16),c+=d<7?":":""}return c},Rc=(o,c)=>{Ze().fill(0,o,o+c)},yp=(o,c,d,m,_)=>{switch(c){case 2:d=As(d),Rc(o,16),_&&(x()[_>>>2>>>0]=16),Sa()[o>>>1>>>0]=c,x()[o+4>>>2>>>0]=d,Sa()[o+2>>>1>>>0]=_htons(m);break;case 10:d=ka(d),Rc(o,28),_&&(x()[_>>>2>>>0]=28),x()[o>>>2>>>0]=c,x()[o+8>>>2>>>0]=d[0],x()[o+12>>>2>>>0]=d[1],x()[o+16>>>2>>>0]=d[2],x()[o+20>>>2>>>0]=d[3],Sa()[o+2>>>1>>>0]=_htons(m);break;default:return 5}return 0};function Lc(o,c,d,m){if(w)return kn(5,0,1,o,c,d,m);o>>>=0,c>>>=0,d>>>=0,m>>>=0;var _=0,y=0,b=0,g=0,T=0,k=0,Y;function v(ht,bt,st,D,Pt,Ee){var Tt,Qe,tr,Qc;return Qe=ht===10?28:16,Pt=ht===10?_p(Pt):Mc(Pt),Tt=mr(Qe),Qc=yp(Tt,ht,Pt,Ee),At(!Qc),tr=mr(32),x()[tr+4>>>2>>>0]=ht,x()[tr+8>>>2>>>0]=bt,x()[tr+12>>>2>>>0]=st,ge()[tr+24>>>2>>>0]=D,ge()[tr+20>>>2>>>0]=Tt,ht===10?x()[tr+16>>>2>>>0]=28:x()[tr+16>>>2>>>0]=16,x()[tr+28>>>2>>>0]=0,tr}if(d&&(b=x()[d>>>2>>>0],g=x()[d+4>>>2>>>0],T=x()[d+8>>>2>>>0],k=x()[d+12>>>2>>>0]),T&&!k&&(k=T===2?17:6),!T&&k&&(T=k===17?2:1),k===0&&(k=6),T===0&&(T=1),!o&&!c)return-2;if(b&-1088||d!==0&&x()[d>>>2>>>0]&2&&!o)return-1;if(b&32)return-2;if(T!==0&&T!==1&&T!==2)return-7;if(g!==0&&g!==2&&g!==10)return-6;if(c&&(c=ut(c),y=parseInt(c,10),isNaN(y)))return b&1024?-2:-8;if(!o)return g===0&&(g=2),b&1||(g===2?_=_htonl(2130706433):_=[0,0,0,_htonl(1)]),Y=v(g,T,k,null,_,y),ge()[m>>>2>>>0]=Y,0;if(o=ut(o),_=As(o),_!==null)if(g===0||g===2)g=2;else if(g===10&&b&8)_=[0,0,_htonl(65535),_],g=10;else return-2;else if(_=ka(o),_!==null)if(g===0||g===10)g=10;else return-2;return _!=null?(Y=v(g,T,k,o,_,y),ge()[m>>>2>>>0]=Y,0):b&4?-2:(o=Gr.lookup_name(o),_=As(o),g===0?g=2:g===10&&(_=[0,0,_htonl(65535),_]),Y=v(g,T,k,null,_,y),ge()[m>>>2>>>0]=Y,0)}var bp=()=>{if(h){var o=["crypto"].map(Wa).pop();return c=>o.randomFillSync(c)}return c=>c.set(crypto.getRandomValues(new Uint8Array(c.byteLength)))},Nc=o=>{(Nc=bp())(o)};function gp(o,c){return o>>>=0,c>>>=0,Nc(Ze().subarray(o>>>0,o+c>>>0)),0}var wp=o=>{var c=i["_"+o];return c},vp=(o,c)=>{va().set(o,c>>>0)},kc=o=>{var c=Cn(o)+1,d=yi(c);return hr(o,d,c),d},Sp=(o,c,d,m,_)=>{var y={string:st=>{var D=0;return st!=null&&st!==0&&(D=kc(st)),D},array:st=>{var D=yi(st.length);return vp(st,D),D}};function b(st){return c==="string"?ut(st):c==="boolean"?!!st:st}var g=wp(o),T=[],k=0;if(m)for(var Y=0;Y<m.length;Y++){var v=y[d[Y]];v?(k===0&&(k=Ss()),T[Y]=v(m[Y])):T[Y]=m[Y]}var ht=g(...T);function bt(st){return k!==0&&_i(k),b(st)}return ht=bt(ht),ht},Ip=o=>Kc();ft.init();var Fp=[Da,dc,_c,Oc,Uc,Lc],Cc;function Bp(){Cc={ka:Rf,pa:yc,q:Nf,ha:kf,Ga:Hf,oa:Vf,n:Wf,G:jf,p:$f,Z:Ea,Q:Gf,D:gc,i:wc,F:vc,E:Sc,C:Ic,y:Kf,z:Xf,A:Zf,qa:Qf,za:th,xa:eh,ya:nh,va:ih,ta:sh,Aa:oh,wa:ah,ua:lh,P:ch,R:uh,O:dh,H:fh,N:hh,V:ph,I:mh,T:_h,w:yh,U:bh,W:gh,L:wh,M:vh,K:Sh,k:Ih,S:Fh,v:Bh,u:Dh,J:Ah,s:Th,r:xh,t:Eh,Da:Mh,X:Rh,B:kh,ca:Ch,da:Ph,aa:Hh,ba:Vh,m:Wh,ga:zh,_:jh,$:$h,fa:Gh,f:Kh,ea:qh,g:Yh,ia:Jh,Y:Xh,l:Zh,ja:Qh,e:rp,o:np,b:xc,h:ip,j:op,Ea:ap,d:Tc,Fa:lp,Ca:cp,x:fp,na:hp,ra:Oc,sa:Uc,c:Ta,ma:Lc,a:N,la:Da,Ba:gp}}var M=await xf(),Pc=i._main=(o,c)=>(Pc=i._main=M.Ia)(o,c),Dp=i._duckdb_web_fs_glob_add_path=o=>(Dp=i._duckdb_web_fs_glob_add_path=M.Ka)(o),Ap=i._duckdb_web_clear_response=()=>(Ap=i._duckdb_web_clear_response=M.La)(),Tp=i._duckdb_web_fail_with=o=>(Tp=i._duckdb_web_fail_with=M.Ma)(o),xp=i._duckdb_web_reset=o=>(xp=i._duckdb_web_reset=M.Na)(o),Ep=i._duckdb_web_connect=()=>(Ep=i._duckdb_web_connect=M.Oa)(),Op=i._duckdb_web_disconnect=o=>(Op=i._duckdb_web_disconnect=M.Pa)(o),Up=i._duckdb_web_flush_files=()=>(Up=i._duckdb_web_flush_files=M.Qa)(),Mp=i._duckdb_web_flush_file=o=>(Mp=i._duckdb_web_flush_file=M.Ra)(o),Rp=i._duckdb_web_open=(o,c)=>(Rp=i._duckdb_web_open=M.Sa)(o,c),Lp=i._duckdb_web_get_global_file_info=(o,c)=>(Lp=i._duckdb_web_get_global_file_info=M.Ta)(o,c),Np=i._duckdb_web_collect_file_stats=(o,c,d)=>(Np=i._duckdb_web_collect_file_stats=M.Ua)(o,c,d),kp=i._duckdb_web_export_file_stats=(o,c)=>(kp=i._duckdb_web_export_file_stats=M.Va)(o,c),Cp=i._duckdb_web_fs_drop_file=(o,c)=>(Cp=i._duckdb_web_fs_drop_file=M.Wa)(o,c),Pp=i._duckdb_web_fs_drop_files=(o,c,d)=>(Pp=i._duckdb_web_fs_drop_files=M.Xa)(o,c,d),Hp=i._duckdb_web_fs_glob_file_infos=(o,c)=>(Hp=i._duckdb_web_fs_glob_file_infos=M.Ya)(o,c),Vp=i._duckdb_web_fs_get_file_info_by_id=(o,c,d)=>(Vp=i._duckdb_web_fs_get_file_info_by_id=M.Za)(o,c,d),Wp=i._duckdb_web_fs_get_file_info_by_name=(o,c,d)=>(Wp=i._duckdb_web_fs_get_file_info_by_name=M._a)(o,c,d),zp=i._duckdb_web_fs_register_file_url=(o,c,d,m,_)=>(zp=i._duckdb_web_fs_register_file_url=M.$a)(o,c,d,m,_),jp=i._duckdb_web_fs_register_file_buffer=(o,c,d,m)=>(jp=i._duckdb_web_fs_register_file_buffer=M.ab)(o,c,d,m),$p=i._duckdb_web_copy_file_to_buffer=(o,c)=>($p=i._duckdb_web_copy_file_to_buffer=M.bb)(o,c),Gp=i._duckdb_web_copy_file_to_path=(o,c,d)=>(Gp=i._duckdb_web_copy_file_to_path=M.cb)(o,c,d),Kp=i._duckdb_web_get_version=o=>(Kp=i._duckdb_web_get_version=M.db)(o),qp=i._duckdb_web_get_feature_flags=()=>(qp=i._duckdb_web_get_feature_flags=M.eb)(),Yp=i._duckdb_web_tokenize=(o,c)=>(Yp=i._duckdb_web_tokenize=M.fb)(o,c),Jp=i._duckdb_web_tokenize_buffer=(o,c,d)=>(Jp=i._duckdb_web_tokenize_buffer=M.gb)(o,c,d),Xp=i._duckdb_web_udf_scalar_create=(o,c,d)=>(Xp=i._duckdb_web_udf_scalar_create=M.hb)(o,c,d),Zp=i._duckdb_web_prepared_create=(o,c,d)=>(Zp=i._duckdb_web_prepared_create=M.ib)(o,c,d),Qp=i._duckdb_web_prepared_create_buffer=(o,c,d,m)=>(Qp=i._duckdb_web_prepared_create_buffer=M.jb)(o,c,d,m),tm=i._duckdb_web_prepared_close=(o,c,d)=>(tm=i._duckdb_web_prepared_close=M.kb)(o,c,d),em=i._duckdb_web_prepared_run=(o,c,d,m)=>(em=i._duckdb_web_prepared_run=M.lb)(o,c,d,m),rm=i._duckdb_web_prepared_send=(o,c,d,m)=>(rm=i._duckdb_web_prepared_send=M.mb)(o,c,d,m),nm=i._duckdb_web_query_run=(o,c,d)=>(nm=i._duckdb_web_query_run=M.nb)(o,c,d),im=i._duckdb_web_query_run_buffer=(o,c,d,m)=>(im=i._duckdb_web_query_run_buffer=M.ob)(o,c,d,m),sm=i._duckdb_web_pending_query_start=(o,c,d,m)=>(sm=i._duckdb_web_pending_query_start=M.pb)(o,c,d,m),om=i._duckdb_web_pending_query_start_buffer=(o,c,d,m,_)=>(om=i._duckdb_web_pending_query_start_buffer=M.qb)(o,c,d,m,_),am=i._duckdb_web_pending_query_poll=(o,c,d)=>(am=i._duckdb_web_pending_query_poll=M.rb)(o,c,d),lm=i._duckdb_web_pending_query_cancel=(o,c)=>(lm=i._duckdb_web_pending_query_cancel=M.sb)(o,c),cm=i._duckdb_web_query_fetch_results=(o,c)=>(cm=i._duckdb_web_query_fetch_results=M.tb)(o,c),um=i._duckdb_web_get_tablenames=(o,c,d)=>(um=i._duckdb_web_get_tablenames=M.ub)(o,c,d),dm=i._duckdb_web_get_tablenames_buffer=(o,c,d,m)=>(dm=i._duckdb_web_get_tablenames_buffer=M.vb)(o,c,d,m),fm=i._duckdb_web_insert_arrow_from_ipc_stream=(o,c,d,m,_)=>(fm=i._duckdb_web_insert_arrow_from_ipc_stream=M.wb)(o,c,d,m,_),hm=i._duckdb_web_insert_csv_from_path=(o,c,d,m)=>(hm=i._duckdb_web_insert_csv_from_path=M.xb)(o,c,d,m),pm=i._duckdb_web_insert_json_from_path=(o,c,d,m)=>(pm=i._duckdb_web_insert_json_from_path=M.yb)(o,c,d,m),mm=()=>(mm=M.zb)(),xs=()=>(xs=M.Ab)(),Ca=(o,c,d,m,_,y)=>(Ca=M.Bb)(o,c,d,m,_,y),Hc=()=>(Hc=M.Cb)(),Vc=o=>(Vc=M.Gb)(o),Wc=o=>(Wc=M.Hb)(o),zc=(o,c,d,m,_)=>(zc=M.Ib)(o,c,d,m,_),jc=o=>(jc=M.Jb)(o),Pa=o=>(Pa=M.Kb)(o),$c=()=>($c=M.Lb)(),mr=i._malloc=o=>(mr=i._malloc=M.Mb)(o),_m=i._free=o=>(_m=i._free=M.Nb)(o),ym=i._calloc=(o,c)=>(ym=i._calloc=M.Ob)(o,c),Gc=o=>(Gc=M.Qb)(o),Kc=()=>(Kc=M.Rb)(),qc=(o,c)=>(qc=M.Sb)(o,c),Yc=o=>(Yc=M.Tb)(o),Jc=o=>(Jc=M.Ub)(o),Xc=()=>(Xc=M.Vb)();function bm(o){o=Object.assign({},o);var c=_=>()=>_()>>>0,d=_=>y=>_(y)>>>0,m=_=>(y,b)=>_(y,b)>>>0;return o.Ab=c(o.Ab),o.Mb=d(o.Mb),o.Ob=m(o.Ob),o.Ub=d(o.Ub),o.Vb=c(o.Vb),o}i.stackSave=Ss,i.stackRestore=_i,i.stackAlloc=yi,i.getTempRet0=Ip,i.setTempRet0=Ua,i.ccall=Sp;function gm(){var o=Pc,c=0,d=0;try{var m=o(c,d);return fc(m,!0),m}catch(_){return Aa(_)}}function Ha(){if(hn>0){pi=Ha;return}if(w){s(i),Ql();return}if(Sf(),hn>0){pi=Ha;return}function o(){var d;if(i.calledRun=!0,!H){Ql(),s(i),(d=i.onRuntimeInitialized)==null||d.call(i);var c=i.noInitialRun;c||gm(),If()}}i.setStatus?(i.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>i.setStatus(""),1),o()},1)):o()}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Ha(),n=l,n}})();typeof uf=="object"&&typeof ya=="object"?(ya.exports=_a,ya.exports.default=_a):typeof define=="function"&&define.amd&&define([],()=>_a);var sf,of,cf=(of=(sf=globalThis.self)==null?void 0:sf.name)==null?void 0:of.startsWith("em-pthread"),af,lf,Xy=typeof((lf=(af=globalThis.process)==null?void 0:af.versions)==null?void 0:lf.node)=="string";Xy&&(cf=ql().workerData==="em-pthread");cf&&_a()});var hf=Kr(()=>{});var pf=Kr(()=>{});var mf=Kr((mA,wa)=>{(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 wa=="object"&&wa.exports,a=typeof define=="function"&&define.amd,l=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),f=[-2147483648,8388608,32768,128],h=[24,16,8,0],w=[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(S){return Object.prototype.toString.call(S)==="[object Array]"}),l&&(e.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(S){return typeof S=="object"&&S.buffer&&S.buffer.constructor===ArrayBuffer});var at=function(S,U){return function(V){return new yt(U,!0).update(V)[S]()}},wt=function(S){var U=at("hex",S);i&&(U=Vt(U,S)),U.create=function(){return new yt(S)},U.update=function(O){return U.create().update(O)};for(var V=0;V<A.length;++V){var I=A[V];U[I]=at(I,S)}return U},Vt=function(S,U){var V=hf(),I=pf().Buffer,O=U?"sha224":"sha256",B;I.from&&!e.JS_SHA256_NO_BUFFER_FROM?B=I.from:B=function(F){return new I(F)};var N=function(F){if(typeof F=="string")return V.createHash(O).update(F,"utf8").digest("hex");if(F==null)throw new Error(r);return F.constructor===ArrayBuffer&&(F=new Uint8Array(F)),Array.isArray(F)||ArrayBuffer.isView(F)||F.constructor===I?V.createHash(O).update(B(F)).digest("hex"):S(F)};return N},mt=function(S,U){return function(V,I){return new Gt(V,U,!0).update(I)[S]()}},Ot=function(S){var U=mt("hex",S);U.create=function(O){return new Gt(O,S)},U.update=function(O,B){return U.create(O).update(B)};for(var V=0;V<A.length;++V){var I=A[V];U[I]=mt(I,S)}return U};function yt(S,U){U?(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],S?(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=S}yt.prototype.update=function(S){if(!this.finalized){var U,V=typeof S;if(V!=="string"){if(V==="object"){if(S===null)throw new Error(r);if(l&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!l||!ArrayBuffer.isView(S)))throw new Error(r)}else throw new Error(r);U=!0}for(var I,O=0,B,N=S.length,F=this.blocks;O<N;){if(this.hashed&&(this.hashed=!1,F[0]=this.block,this.block=F[16]=F[1]=F[2]=F[3]=F[4]=F[5]=F[6]=F[7]=F[8]=F[9]=F[10]=F[11]=F[12]=F[13]=F[14]=F[15]=0),U)for(B=this.start;O<N&&B<64;++O)F[B>>>2]|=S[O]<<h[B++&3];else for(B=this.start;O<N&&B<64;++O)I=S.charCodeAt(O),I<128?F[B>>>2]|=I<<h[B++&3]:I<2048?(F[B>>>2]|=(192|I>>>6)<<h[B++&3],F[B>>>2]|=(128|I&63)<<h[B++&3]):I<55296||I>=57344?(F[B>>>2]|=(224|I>>>12)<<h[B++&3],F[B>>>2]|=(128|I>>>6&63)<<h[B++&3],F[B>>>2]|=(128|I&63)<<h[B++&3]):(I=65536+((I&1023)<<10|S.charCodeAt(++O)&1023),F[B>>>2]|=(240|I>>>18)<<h[B++&3],F[B>>>2]|=(128|I>>>12&63)<<h[B++&3],F[B>>>2]|=(128|I>>>6&63)<<h[B++&3],F[B>>>2]|=(128|I&63)<<h[B++&3]);this.lastByteIndex=B,this.bytes+=B-this.start,B>=64?(this.block=F[16],this.start=B-64,this.hash(),this.hashed=!0):this.start=B}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},yt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var S=this.blocks,U=this.lastByteIndex;S[16]=this.block,S[U>>>2]|=f[U&3],this.block=S[16],U>=56&&(this.hashed||this.hash(),S[0]=this.block,S[16]=S[1]=S[2]=S[3]=S[4]=S[5]=S[6]=S[7]=S[8]=S[9]=S[10]=S[11]=S[12]=S[13]=S[14]=S[15]=0),S[14]=this.hBytes<<3|this.bytes>>>29,S[15]=this.bytes<<3,this.hash()}},yt.prototype.hash=function(){var S=this.h0,U=this.h1,V=this.h2,I=this.h3,O=this.h4,B=this.h5,N=this.h6,F=this.h7,H=this.blocks,W,At,Ut,Ae,_t,Xe,Te,Wr,hi,Nn,fn;for(W=16;W<64;++W)_t=H[W-15],At=(_t>>>7|_t<<25)^(_t>>>18|_t<<14)^_t>>>3,_t=H[W-2],Ut=(_t>>>17|_t<<15)^(_t>>>19|_t<<13)^_t>>>10,H[W]=H[W-16]+At+H[W-7]+Ut<<0;for(fn=U&V,W=0;W<64;W+=4)this.first?(this.is224?(Wr=300032,_t=H[0]-1413257819,F=_t-150054599<<0,I=_t+24177077<<0):(Wr=704751109,_t=H[0]-210244248,F=_t-1521486534<<0,I=_t+143694565<<0),this.first=!1):(At=(S>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10),Ut=(O>>>6|O<<26)^(O>>>11|O<<21)^(O>>>25|O<<7),Wr=S&U,Ae=Wr^S&V^fn,Te=O&B^~O&N,_t=F+Ut+Te+w[W]+H[W],Xe=At+Ae,F=I+_t<<0,I=_t+Xe<<0),At=(I>>>2|I<<30)^(I>>>13|I<<19)^(I>>>22|I<<10),Ut=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),hi=I&S,Ae=hi^I&U^Wr,Te=F&O^~F&B,_t=N+Ut+Te+w[W+1]+H[W+1],Xe=At+Ae,N=V+_t<<0,V=_t+Xe<<0,At=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),Ut=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),Nn=V&I,Ae=Nn^V&S^hi,Te=N&F^~N&O,_t=B+Ut+Te+w[W+2]+H[W+2],Xe=At+Ae,B=U+_t<<0,U=_t+Xe<<0,At=(U>>>2|U<<30)^(U>>>13|U<<19)^(U>>>22|U<<10),Ut=(B>>>6|B<<26)^(B>>>11|B<<21)^(B>>>25|B<<7),fn=U&V,Ae=fn^U&I^Nn,Te=B&N^~B&F,_t=O+Ut+Te+w[W+3]+H[W+3],Xe=At+Ae,O=S+_t<<0,S=_t+Xe<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+S<<0,this.h1=this.h1+U<<0,this.h2=this.h2+V<<0,this.h3=this.h3+I<<0,this.h4=this.h4+O<<0,this.h5=this.h5+B<<0,this.h6=this.h6+N<<0,this.h7=this.h7+F<<0},yt.prototype.hex=function(){this.finalize();var S=this.h0,U=this.h1,V=this.h2,I=this.h3,O=this.h4,B=this.h5,N=this.h6,F=this.h7,H=u[S>>>28&15]+u[S>>>24&15]+u[S>>>20&15]+u[S>>>16&15]+u[S>>>12&15]+u[S>>>8&15]+u[S>>>4&15]+u[S&15]+u[U>>>28&15]+u[U>>>24&15]+u[U>>>20&15]+u[U>>>16&15]+u[U>>>12&15]+u[U>>>8&15]+u[U>>>4&15]+u[U&15]+u[V>>>28&15]+u[V>>>24&15]+u[V>>>20&15]+u[V>>>16&15]+u[V>>>12&15]+u[V>>>8&15]+u[V>>>4&15]+u[V&15]+u[I>>>28&15]+u[I>>>24&15]+u[I>>>20&15]+u[I>>>16&15]+u[I>>>12&15]+u[I>>>8&15]+u[I>>>4&15]+u[I&15]+u[O>>>28&15]+u[O>>>24&15]+u[O>>>20&15]+u[O>>>16&15]+u[O>>>12&15]+u[O>>>8&15]+u[O>>>4&15]+u[O&15]+u[B>>>28&15]+u[B>>>24&15]+u[B>>>20&15]+u[B>>>16&15]+u[B>>>12&15]+u[B>>>8&15]+u[B>>>4&15]+u[B&15]+u[N>>>28&15]+u[N>>>24&15]+u[N>>>20&15]+u[N>>>16&15]+u[N>>>12&15]+u[N>>>8&15]+u[N>>>4&15]+u[N&15];return this.is224||(H+=u[F>>>28&15]+u[F>>>24&15]+u[F>>>20&15]+u[F>>>16&15]+u[F>>>12&15]+u[F>>>8&15]+u[F>>>4&15]+u[F&15]),H},yt.prototype.toString=yt.prototype.hex,yt.prototype.digest=function(){this.finalize();var S=this.h0,U=this.h1,V=this.h2,I=this.h3,O=this.h4,B=this.h5,N=this.h6,F=this.h7,H=[S>>>24&255,S>>>16&255,S>>>8&255,S&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255,V>>>24&255,V>>>16&255,V>>>8&255,V&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255,B>>>24&255,B>>>16&255,B>>>8&255,B&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255];return this.is224||H.push(F>>>24&255,F>>>16&255,F>>>8&255,F&255),H},yt.prototype.array=yt.prototype.digest,yt.prototype.arrayBuffer=function(){this.finalize();var S=new ArrayBuffer(this.is224?28:32),U=new DataView(S);return U.setUint32(0,this.h0),U.setUint32(4,this.h1),U.setUint32(8,this.h2),U.setUint32(12,this.h3),U.setUint32(16,this.h4),U.setUint32(20,this.h5),U.setUint32(24,this.h6),this.is224||U.setUint32(28,this.h7),S};function Gt(S,U,V){var I,O=typeof S;if(O==="string"){var B=[],N=S.length,F=0,H;for(I=0;I<N;++I)H=S.charCodeAt(I),H<128?B[F++]=H:H<2048?(B[F++]=192|H>>>6,B[F++]=128|H&63):H<55296||H>=57344?(B[F++]=224|H>>>12,B[F++]=128|H>>>6&63,B[F++]=128|H&63):(H=65536+((H&1023)<<10|S.charCodeAt(++I)&1023),B[F++]=240|H>>>18,B[F++]=128|H>>>12&63,B[F++]=128|H>>>6&63,B[F++]=128|H&63);S=B}else if(O==="object"){if(S===null)throw new Error(r);if(l&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!l||!ArrayBuffer.isView(S)))throw new Error(r)}else throw new Error(r);S.length>64&&(S=new yt(U,!0).update(S).array());var W=[],At=[];for(I=0;I<64;++I){var Ut=S[I]||0;W[I]=92^Ut,At[I]=54^Ut}yt.call(this,U,V),this.update(At),this.oKeyPad=W,this.inner=!0,this.sharedMemory=V}Gt.prototype=new yt,Gt.prototype.finalize=function(){if(yt.prototype.finalize.call(this),this.inner){this.inner=!1;var S=this.array();yt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(S),yt.prototype.finalize.call(this)}};var Ct=wt();Ct.sha256=Ct,Ct.sha224=wt(!0),Ct.sha256.hmac=Ot(),Ct.sha224.hmac=Ot(!0),s?wa.exports=Ct:(e.sha256=Ct.sha256,e.sha224=Ct.sha224,a&&define(function(){return Ct}))})()});var nb={};qr(nb,{registerWorker:()=>wf});function nu(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(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(h){try{f(n.next(h))}catch(w){a(w)}}function u(h){try{f(n.throw(h))}catch(w){a(w)}}function f(h){h.done?s(h.value):i(h.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function ru(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 fe(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(A){n[A]&&(i[A]=function(E){return new Promise(function(at,wt){s.push([A,E,at,wt])>1||l(A,E)})})}function l(A,E){try{u(n[A](E))}catch(at){w(s[0][3],at)}}function u(A){A.value instanceof it?Promise.resolve(A.value.v).then(f,h):w(s[0][2],A)}function f(A){l("next",A)}function h(A){l("throw",A)}function w(A,E){A(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Pn(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(a){return(e=!e)?{value:it(r[i](a)),done:!1}:s?s(a):a}: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 ru=="function"?ru(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(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}var qa={};qr(qa,{compareArrayLike:()=>Ka,joinUint8Arrays:()=>he,memcpy:()=>Fi,rebaseValueOffsets:()=>Cs,toArrayBufferView:()=>ot,toArrayBufferViewAsyncIterator:()=>Re,toArrayBufferViewIterator:()=>rr,toBigInt64Array:()=>ks,toBigUint64Array:()=>Nm,toFloat32Array:()=>km,toFloat32ArrayAsyncIterator:()=>Qm,toFloat32ArrayIterator:()=>$m,toFloat64Array:()=>Cm,toFloat64ArrayAsyncIterator:()=>t_,toFloat64ArrayIterator:()=>Gm,toInt16Array:()=>Mm,toInt16ArrayAsyncIterator:()=>Ym,toInt16ArrayIterator:()=>Vm,toInt32Array:()=>_n,toInt32ArrayAsyncIterator:()=>Jm,toInt32ArrayIterator:()=>Wm,toInt8Array:()=>Um,toInt8ArrayAsyncIterator:()=>qm,toInt8ArrayIterator:()=>Hm,toUint16Array:()=>Rm,toUint16ArrayAsyncIterator:()=>Xm,toUint16ArrayIterator:()=>zm,toUint32Array:()=>Lm,toUint32ArrayAsyncIterator:()=>Zm,toUint32ArrayIterator:()=>jm,toUint8Array:()=>J,toUint8ArrayAsyncIterator:()=>Ga,toUint8ArrayIterator:()=>$a,toUint8ClampedArray:()=>Pm,toUint8ClampedArrayAsyncIterator:()=>e_,toUint8ClampedArrayIterator:()=>Km});var Tm=new TextDecoder("utf-8"),Si=r=>Tm.decode(r),xm=new TextEncoder,er=r=>xm.encode(r);var Em=r=>typeof r=="number",iu=r=>typeof r=="boolean",Kt=r=>typeof r=="function",ne=r=>r!=null&&Object(r)===r,Ue=r=>ne(r)&&Kt(r.then);var Me=r=>ne(r)&&Kt(r[Symbol.iterator]),we=r=>ne(r)&&Kt(r[Symbol.asyncIterator]),Os=r=>ne(r)&&ne(r.schema);var Us=r=>ne(r)&&"done"in r&&"value"in r;var Ms=r=>ne(r)&&Kt(r.stat)&&Em(r.fd);var Rs=r=>ne(r)&&Ii(r.body),Ls=r=>"_getDOMStream"in r&&"_getNodeStream"in r,su=r=>ne(r)&&Kt(r.abort)&&Kt(r.getWriter)&&!Ls(r),Ii=r=>ne(r)&&Kt(r.cancel)&&Kt(r.getReader)&&!Ls(r),ou=r=>ne(r)&&Kt(r.end)&&Kt(r.write)&&iu(r.writable)&&!Ls(r),Ns=r=>ne(r)&&Kt(r.read)&&Kt(r.pipe)&&iu(r.readable)&&!Ls(r),au=r=>ne(r)&&Kt(r.clear)&&Kt(r.bytes)&&Kt(r.position)&&Kt(r.setPosition)&&Kt(r.capacity)&&Kt(r.getBufferIdentifier)&&Kt(r.createLong);var ja=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Om(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let a,l,u=0,f=0,h=r.length;++u<h;){if(a=t[f],l=r[u],!a||!l||a.buffer!==l.buffer||l.byteOffset<a.byteOffset){l&&(t[++f]=l);continue}if({byteOffset:e,byteLength:i}=a,{byteOffset:n,byteLength:s}=l,e+i<n||n+s<e){l&&(t[++f]=l);continue}t[f]=new Uint8Array(a.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),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(a,e),r}function he(r,t){let e=Om(r),n=e.reduce((h,w)=>h+w.byteLength,0),i,s,a,l=0,u=-1,f=Math.min(t||Number.POSITIVE_INFINITY,n);for(let h=e.length;++u<h;){if(i=e[u],s=i.subarray(0,Math.min(i.length,f-l)),f<=l+s.length){s.length<i.length?e[u]=i.subarray(s.length):s.length===i.length&&u++,a?Fi(a,s,l):a=s;break}Fi(a||(a=new Uint8Array(f)),s,l),l+=s.length}return[a||new Uint8Array(0),e.slice(u),n-(a?a.byteLength:0)]}function ot(r,t){let e=Us(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=er(e)),e instanceof ArrayBuffer?new r(e):e instanceof ja?new r(e):au(e)?ot(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 Um=r=>ot(Int8Array,r),Mm=r=>ot(Int16Array,r),_n=r=>ot(Int32Array,r),ks=r=>ot(BigInt64Array,r),J=r=>ot(Uint8Array,r),Rm=r=>ot(Uint16Array,r),Lm=r=>ot(Uint32Array,r),Nm=r=>ot(BigUint64Array,r),km=r=>ot(Float32Array,r),Cm=r=>ot(Float64Array,r),Pm=r=>ot(Uint8ClampedArray,r),za=r=>(r.next(),r);function*rr(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ja?e(t):Me(t)?t:e(t);return yield*mn(za(function*(i){let s=null;do s=i.next(yield ot(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var Hm=r=>rr(Int8Array,r),Vm=r=>rr(Int16Array,r),Wm=r=>rr(Int32Array,r),$a=r=>rr(Uint8Array,r),zm=r=>rr(Uint16Array,r),jm=r=>rr(Uint32Array,r),$m=r=>rr(Float32Array,r),Gm=r=>rr(Float64Array,r),Km=r=>rr(Uint8ClampedArray,r);function Re(r,t){return fe(this,arguments,function*(){if(Ue(t))return yield it(yield it(yield*mn(Pn(Oe(Re(r,yield it(t)))))));let n=function(a){return fe(this,arguments,function*(){yield yield it(yield it(a))})},i=function(a){return fe(this,arguments,function*(){yield it(yield*mn(Pn(Oe(za(function*(l){let u=null;do u=l.next(yield u==null?void 0:u.value);while(!u.done)}(a[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ja?n(t):Me(t)?i(t):we(t)?t:n(t);return yield it(yield*mn(Pn(Oe(za(function(a){return fe(this,arguments,function*(){let l=null;do l=yield it(a.next(yield yield it(ot(r,l))));while(!l.done)})}(s[Symbol.asyncIterator]())))))),yield it(new r)})}var qm=r=>Re(Int8Array,r),Ym=r=>Re(Int16Array,r),Jm=r=>Re(Int32Array,r),Ga=r=>Re(Uint8Array,r),Xm=r=>Re(Uint16Array,r),Zm=r=>Re(Uint32Array,r),Qm=r=>Re(Float32Array,r),t_=r=>Re(Float64Array,r),e_=r=>Re(Uint8ClampedArray,r);function Cs(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 Ka(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 Ps(r_(r))},fromAsyncIterable(r){return Ps(n_(r))},fromDOMStream(r){return Ps(i_(r))},fromNodeStream(r){return Ps(s_(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')}},Ps=r=>(r.next(),r);function*r_(r){let t,e=!1,n=[],i,s,a,l=0;function u(){return s==="peek"?he(n,a)[0]:([i,n,l]=he(n,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});let f=$a(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-l)?f.next():f.next(a-l),!t&&i.byteLength>0&&(n.push(i),l+=i.byteLength),t||a<=l)do({cmd:s,size:a}=yield u());while(a<l);while(!t)}catch(h){(e=!0)&&typeof f.throw=="function"&&f.throw(h)}finally{e===!1&&typeof f.return=="function"&&f.return(null)}return null}function n_(r){return fe(this,arguments,function*(){let e,n=!1,i=[],s,a,l,u=0;function f(){return a==="peek"?he(i,l)[0]:([s,i,u]=he(i,l),s)}({cmd:a,size:l}=(yield yield it(null))||{cmd:"read",size:0});let h=Ga(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(l-u)?yield it(h.next()):yield it(h.next(l-u)),!e&&s.byteLength>0&&(i.push(s),u+=s.byteLength),e||l<=u)do({cmd:a,size:l}=yield yield it(f()));while(l<u);while(!e)}catch(w){(n=!0)&&typeof h.throw=="function"&&(yield it(h.throw(w)))}finally{n===!1&&typeof h.return=="function"&&(yield it(h.return(new Uint8Array(0))))}return yield it(null)})}function i_(r){return fe(this,arguments,function*(){let e=!1,n=!1,i=[],s,a,l,u=0;function f(){return a==="peek"?he(i,l)[0]:([s,i,u]=he(i,l),s)}({cmd:a,size:l}=(yield yield it(null))||{cmd:"read",size:0});let h=new Ja(r);try{do if({done:e,value:s}=Number.isNaN(l-u)?yield it(h.read()):yield it(h.read(l-u)),!e&&s.byteLength>0&&(i.push(J(s)),u+=s.byteLength),e||l<=u)do({cmd:a,size:l}=yield yield it(f()));while(l<u);while(!e)}catch(w){(n=!0)&&(yield it(h.cancel(w)))}finally{n===!1?yield it(h.cancel()):r.locked&&h.releaseLock()}return yield it(null)})}var Ja=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=J(e)),e})}},Ya=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function s_(r){return fe(this,arguments,function*(){let e=[],n="error",i=!1,s=null,a,l,u=0,f=[],h;function w(){return a==="peek"?he(f,l)[0]:([h,f,u]=he(f,l),h)}if({cmd:a,size:l}=(yield yield it(null))||{cmd:"read",size:0},r.isTTY)return yield yield it(new Uint8Array(0)),yield it(null);try{e[0]=Ya(r,"end"),e[1]=Ya(r,"error");do{if(e[2]=Ya(r,"readable"),[n,s]=yield it(Promise.race(e.map(E=>E[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(l-u)?(h=J(r.read(l-u)),h.byteLength<l-u&&(h=J(r.read()))):h=J(r.read()),h.byteLength>0&&(f.push(h),u+=h.byteLength)),i||l<=u)do({cmd:a,size:l}=yield yield it(w()));while(l<u)}while(!i)}finally{yield it(A(e,n==="error"?s:null))}return yield it(null);function A(E,at){return h=f=null,new Promise((wt,Vt)=>{for(let[mt,Ot]of E)r.off(mt,Ot);try{let mt=r.destroy;mt&&mt.call(r,at),at=void 0}catch(mt){at=mt||at}finally{at!=null?Vt(at):wt()}})}})}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 Dt;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var Wt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(Wt||(Wt={}));var C;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(C||(C={}));var qt;(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"})(qt||(qt={}));var nr=new Int32Array(2),Hs=new Float32Array(nr.buffer),Vs=new Float64Array(nr.buffer),Hn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Bi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Bi||(Bi={}));var pe=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 nr[0]=this.readInt32(t),Hs[0]}readFloat64(t){return nr[Hn?0:1]=this.readInt32(t),nr[Hn?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){Hs[0]=e,this.writeInt32(t,nr[0])}writeFloat64(t,e){Vs[0]=e,this.writeInt32(t,nr[Hn?0:1]),this.writeInt32(t+4,nr[Hn?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===Bi.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 yn=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=pe.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=pe.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 a=0,l=this.space;t:for(e=0;e<this.vtables.length;e++){let u=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(u)){for(let f=2;f<s;f+=2)if(this.bb.readInt16(l+f)!=this.bb.readInt16(u+f))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-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 a=3;a>=0;a--)this.writeInt8(s.charCodeAt(a))}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 Di;(function(r){r[r.BUFFER=0]="BUFFER"})(Di||(Di={}));var Ai;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ai||(Ai={}));var zs=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):Ai.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Di.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ai.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Di.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 Vn=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 Wn=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 me=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 Wn).__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 Vn).__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 zs).__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 _r=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 me).__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 Yr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Yr||(Yr={}));var Ti;(function(r){r[r.DenseArray=0]="DenseArray"})(Ti||(Ti={}));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 ir=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):Ti.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,Ti.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 xi=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 Ei=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 Jr=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):Wt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Wt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var sr=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 Xr=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):C.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,C.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 Qr=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 tn=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 en=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):qt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,qt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var Oi=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 Ui=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 Mi=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 rn=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 Ri=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 Li=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 yr=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):C.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,C.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 br=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):C.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,C.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 Ni=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 Et;(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"})(Et||(Et={}));var re=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):Et.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 ir).__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,Et.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):Yr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new re).__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,Yr.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 ct;(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"})(ct||(ct={}));var p;(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"})(p||(p={}));var Se;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Se||(Se={}));var _l={};qr(_l,{clampRange:()=>Hi,createElementComparator:()=>an,wrapIndex:()=>bn});var Xa={};qr(Xa,{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 el={};qr(el,{BN:()=>Ci,bigNumToBigInt:()=>cu,bigNumToNumber:()=>tl,bigNumToString:()=>$n,isArrowBigNumSymbol:()=>lu});function pt(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 Za(r,t){return pt(r/t)+pt(r%t)/pt(t)}var lu=Symbol.for("isArrowBigNum");function Pe(r,...t){return t.length===0?Object.setPrototypeOf(ot(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Pe.prototype[lu]=!0;Pe.prototype.toJSON=function(){return'"'.concat($n(this),'"')};Pe.prototype.valueOf=function(r){return tl(this,r)};Pe.prototype.toString=function(){return $n(this)};Pe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return tl(this);case"string":return $n(this);case"default":return cu(this)}return $n(this)};function zn(...r){return Pe.apply(this,r)}function jn(...r){return Pe.apply(this,r)}function ki(...r){return Pe.apply(this,r)}Object.setPrototypeOf(zn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(jn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(ki.prototype,Object.create(Uint32Array.prototype));Object.assign(zn.prototype,Pe.prototype,{constructor:zn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(jn.prototype,Pe.prototype,{constructor:jn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(ki.prototype,Pe.prototype,{constructor:ki,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var o_=BigInt(4294967296)*BigInt(4294967296),a_=o_-BigInt(1);function tl(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,a=new BigUint64Array(e,n,i/8),l=s&&a.at(-1)&BigInt(1)<<BigInt(63),u=BigInt(0),f=0;if(l){for(let h of a)u|=(h^a_)*(BigInt(1)<<BigInt(64*f++));u*=BigInt(-1),u-=BigInt(1)}else for(let h of a)u|=h*(BigInt(1)<<BigInt(64*f++));if(typeof t=="number"){let h=BigInt(Math.pow(10,t)),w=u/h,A=u%h;return pt(w)+pt(A)/pt(h)}return pt(u)}function $n(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return Qa(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Qa(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let a=t[s],l=~a+n;t[s]=l,n&=a===0?1:0}let i=Qa(t);return"-".concat(i)}function cu(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:$n(r)}function Qa(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,a=n.length-1;do{for(e[0]=n[s=0];s<a;)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 Ci=class r{static new(t,e){switch(e){case!0:return new zn(t);case!1:return new jn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new zn(t)}return t.byteLength===16?new ki(t):new jn(t)}static signed(t){return new zn(t)}static unsigned(t){return new jn(t)}static decimal(t){return new ki(t)}constructor(t,e){return r.new(t,e)}};var uu,du,fu,hu,pu,mu,_u,yu,bu,gu,wu,vu,Su,Iu,Fu,Bu,Du,Au,Tu,xu,Eu,Ou,L=class r{static isNull(t){return(t==null?void 0:t.typeId)===p.Null}static isInt(t){return(t==null?void 0:t.typeId)===p.Int}static isFloat(t){return(t==null?void 0:t.typeId)===p.Float}static isBinary(t){return(t==null?void 0:t.typeId)===p.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===p.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===p.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===p.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===p.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===p.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===p.Date}static isTime(t){return(t==null?void 0:t.typeId)===p.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===p.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===p.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===p.Duration}static isList(t){return(t==null?void 0:t.typeId)===p.List}static isStruct(t){return(t==null?void 0:t.typeId)===p.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===p.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===p.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===p.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===p.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===p.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}};uu=Symbol.toStringTag;L[uu]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(L.prototype);var ie=class extends L{constructor(){super(p.Null)}toString(){return"Null"}};du=Symbol.toStringTag;ie[du]=(r=>r[Symbol.toStringTag]="Null")(ie.prototype);var Jt=class extends L{constructor(t,e){super(p.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)}};fu=Symbol.toStringTag;Jt[fu]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Jt.prototype);var js=class extends Jt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},$s=class extends Jt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},or=class extends Jt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Gs=class extends Jt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ks=class extends Jt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},qs=class extends Jt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ys=class extends Jt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Js=class extends Jt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(js.prototype,"ArrayType",{value:Int8Array});Object.defineProperty($s.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(or.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Gs.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ks.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(qs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ys.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Js.prototype,"ArrayType",{value:BigUint64Array});var Ie=class extends L{constructor(t){super(p.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)}};hu=Symbol.toStringTag;Ie[hu]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Ie.prototype);var Xs=class extends Ie{constructor(){super(Dt.HALF)}},Zs=class extends Ie{constructor(){super(Dt.SINGLE)}},Qs=class extends Ie{constructor(){super(Dt.DOUBLE)}};Object.defineProperty(Xs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Zs.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Qs.prototype,"ArrayType",{value:Float64Array});var gr=class extends L{constructor(){super(p.Binary)}toString(){return"Binary"}};pu=Symbol.toStringTag;gr[pu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(gr.prototype);var wr=class extends L{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};mu=Symbol.toStringTag;wr[mu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(wr.prototype);var vr=class extends L{constructor(){super(p.Utf8)}toString(){return"Utf8"}};_u=Symbol.toStringTag;vr[_u]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(vr.prototype);var Sr=class extends L{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};yu=Symbol.toStringTag;Sr[yu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Sr.prototype);var Ir=class extends L{constructor(){super(p.Bool)}toString(){return"Bool"}};bu=Symbol.toStringTag;Ir[bu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Ir.prototype);var Fr=class extends L{constructor(t,e,n=128){super(p.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};gu=Symbol.toStringTag;Fr[gu]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Fr.prototype);var Br=class extends L{constructor(t){super(p.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat(Wt[this.unit],">")}get ArrayType(){return this.unit===Wt.DAY?Int32Array:BigInt64Array}};wu=Symbol.toStringTag;Br[wu]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Br.prototype);var Dr=class extends L{constructor(t,e){super(p.Time),this.unit=t,this.bitWidth=e}toString(){return"Time".concat(this.bitWidth,"<").concat(C[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};vu=Symbol.toStringTag;Dr[vu]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Dr.prototype);var Ar=class extends L{constructor(t,e){super(p.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(C[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};Su=Symbol.toStringTag;Ar[Su]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Ar.prototype);var Tr=class extends L{constructor(t){super(p.Interval),this.unit=t}toString(){return"Interval<".concat(qt[this.unit],">")}};Iu=Symbol.toStringTag;Tr[Iu]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Tr.prototype);var xr=class extends L{constructor(t){super(p.Duration),this.unit=t}toString(){return"Duration<".concat(C[this.unit],">")}};Fu=Symbol.toStringTag;xr[Fu]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(xr.prototype);var He=class extends L{constructor(t){super(p.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}};Bu=Symbol.toStringTag;He[Bu]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(He.prototype);var Rt=class extends L{constructor(t){super(p.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};Du=Symbol.toStringTag;Rt[Du]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Rt.prototype);var Ve=class extends L{constructor(t,e,n){super(p.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};Au=Symbol.toStringTag;Ve[Au]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Ve.prototype);var Er=class extends L{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};Tu=Symbol.toStringTag;Er[Tu]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Er.prototype);var We=class extends L{constructor(t,e){super(p.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,">")}};xu=Symbol.toStringTag;We[xu]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(We.prototype);var ze=class extends L{constructor(t,e=!1){var n,i,s;if(super(p.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 a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");let l=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];l&&(l.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(", "),"}>")}};Eu=Symbol.toStringTag;ze[Eu]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(ze.prototype);var l_=(r=>()=>++r)(-1),_e=class extends L{constructor(t,e,n,i){super(p.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?l_():pt(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,">")}};Ou=Symbol.toStringTag;_e[Ou]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(_e.prototype);function ye(r){let t=r;switch(r.typeId){case p.Decimal:return r.bitWidth/32;case p.Interval:return 1+t.unit;case p.FixedSizeList:return t.listSize;case p.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 c_(this,t,e)}getVisitFnByTypeId(t,e=!0){return Gn(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 c_(r,t,e=!0){return typeof t=="number"?Gn(r,t,e):typeof t=="string"&&t in p?Gn(r,p[t],e):t&&t instanceof L?Gn(r,Uu(t),e):t!=null&&t.type&&t.type instanceof L?Gn(r,Uu(t.type),e):Gn(r,p.NONE,e)}function Gn(r,t,e=!0){let n=null;switch(t){case p.Null:n=r.visitNull;break;case p.Bool:n=r.visitBool;break;case p.Int:n=r.visitInt;break;case p.Int8:n=r.visitInt8||r.visitInt;break;case p.Int16:n=r.visitInt16||r.visitInt;break;case p.Int32:n=r.visitInt32||r.visitInt;break;case p.Int64:n=r.visitInt64||r.visitInt;break;case p.Uint8:n=r.visitUint8||r.visitInt;break;case p.Uint16:n=r.visitUint16||r.visitInt;break;case p.Uint32:n=r.visitUint32||r.visitInt;break;case p.Uint64:n=r.visitUint64||r.visitInt;break;case p.Float:n=r.visitFloat;break;case p.Float16:n=r.visitFloat16||r.visitFloat;break;case p.Float32:n=r.visitFloat32||r.visitFloat;break;case p.Float64:n=r.visitFloat64||r.visitFloat;break;case p.Utf8:n=r.visitUtf8;break;case p.LargeUtf8:n=r.visitLargeUtf8;break;case p.Binary:n=r.visitBinary;break;case p.LargeBinary:n=r.visitLargeBinary;break;case p.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case p.Date:n=r.visitDate;break;case p.DateDay:n=r.visitDateDay||r.visitDate;break;case p.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case p.Timestamp:n=r.visitTimestamp;break;case p.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case p.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case p.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case p.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case p.Time:n=r.visitTime;break;case p.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case p.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case p.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case p.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case p.Decimal:n=r.visitDecimal;break;case p.List:n=r.visitList;break;case p.Struct:n=r.visitStruct;break;case p.Union:n=r.visitUnion;break;case p.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case p.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case p.Dictionary:n=r.visitDictionary;break;case p.Interval:n=r.visitInterval;break;case p.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case p.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case p.Duration:n=r.visitDuration;break;case p.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case p.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case p.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case p.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case p.FixedSizeList:n=r.visitFixedSizeList;break;case p.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(p[t],"'"))}function Uu(r){switch(r.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?p.Int8:p.Uint8;case 16:return e?p.Int16:p.Uint16;case 32:return e?p.Int32:p.Uint32;case 64:return e?p.Int64:p.Uint64}return p.Int}case p.Float:switch(r.precision){case Dt.HALF:return p.Float16;case Dt.SINGLE:return p.Float32;case Dt.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(r.unit){case C.SECOND:return p.TimeSecond;case C.MILLISECOND:return p.TimeMillisecond;case C.MICROSECOND:return p.TimeMicrosecond;case C.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(r.unit){case C.SECOND:return p.TimestampSecond;case C.MILLISECOND:return p.TimestampMillisecond;case C.MICROSECOND:return p.TimestampMicrosecond;case C.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(r.unit){case Wt.DAY:return p.DateDay;case Wt.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(r.unit){case qt.DAY_TIME:return p.IntervalDayTime;case qt.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(r.unit){case C.SECOND:return p.DurationSecond;case C.MILLISECOND:return p.DurationMillisecond;case C.MICROSECOND:return p.DurationMicrosecond;case C.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(r.mode){case xt.Dense:return p.DenseUnion;case xt.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error("Unrecognized type '".concat(p[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 rl={};qr(rl,{float64ToUint16:()=>Pi,uint16ToFloat64:()=>to});var Mu=new Float64Array(1),Kn=new Uint32Array(Mu.buffer);function to(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 Pi(r){if(r!==r)return 32256;Mu[0]=r;let t=(Kn[1]&2147483648)>>16&65535,e=Kn[1]&2146435072,n=0;return e>=1089470464?Kn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Kn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Kn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Kn[1]&1048575)+512>>10),t|e|n&65535}var q=class extends z{};function tt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var u_=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Ru=(r,t,e,n)=>{if(e+1<t.length){let i=pt(t[e]),s=pt(t[e+1]);r.set(n.subarray(0,s-i),i)}},d_=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Or=({values:r},t,e)=>{r[t]=e},nl=({values:r},t,e)=>{r[t]=e},Lu=({values:r},t,e)=>{r[t]=Pi(e)},f_=(r,t,e)=>{switch(r.type.precision){case Dt.HALF:return Lu(r,t,e);case Dt.SINGLE:case Dt.DOUBLE:return nl(r,t,e)}},eo=({values:r},t,e)=>{u_(r,t,e.valueOf())},ro=({values:r},t,e)=>{r[t]=BigInt(e)},il=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Nu=({values:r,valueOffsets:t},e,n)=>Ru(r,t,e,n),ku=({values:r,valueOffsets:t},e,n)=>Ru(r,t,e,er(n)),sl=(r,t,e)=>{r.type.unit===Wt.DAY?eo(r,t,e):ro(r,t,e)},no=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},io=({values:r},t,e)=>{r[t]=BigInt(e)},so=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},oo=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},ol=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return no(r,t,e);case C.MILLISECOND:return io(r,t,e);case C.MICROSECOND:return so(r,t,e);case C.NANOSECOND:return oo(r,t,e)}},ao=({values:r},t,e)=>{r[t]=e},lo=({values:r},t,e)=>{r[t]=e},co=({values:r},t,e)=>{r[t]=e},uo=({values:r},t,e)=>{r[t]=e},al=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return ao(r,t,e);case C.MILLISECOND:return lo(r,t,e);case C.MICROSECOND:return co(r,t,e);case C.NANOSECOND:return uo(r,t,e)}},ll=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},h_=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Zt.getVisitFn(n);if(Array.isArray(e))for(let a=-1,l=i[t],u=i[t+1];l<u;)s(n,l++,e[++a]);else for(let a=-1,l=i[t],u=i[t+1];l<u;)s(n,l++,e.get(++a))},p_=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Zt.getVisitFn(n),{[t]:a,[t+1]:l}=i,u=e instanceof Map?e.entries():Object.entries(e);for(let f of u)if(s(n,a,f),++a>=l)break},m_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),__=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),y_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),b_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),g_=(r,t,e)=>{let n=r.type.children.map(s=>Zt.getVisitFn(s.type)),i=e instanceof Map?y_(t,e):e instanceof dt?__(t,e):Array.isArray(e)?m_(t,e):b_(t,e);r.type.children.forEach((s,a)=>i(n[a],r.children[a],s,a))},w_=(r,t,e)=>{r.type.mode===xt.Dense?Cu(r,t,e):Pu(r,t,e)},Cu=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,r.valueOffsets[t],e)},Pu=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,t,e)},v_=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},cl=(r,t,e)=>{r.type.unit===qt.DAY_TIME?fo(r,t,e):ho(r,t,e)},fo=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},ho=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},po=({values:r},t,e)=>{r[t]=e},mo=({values:r},t,e)=>{r[t]=e},_o=({values:r},t,e)=>{r[t]=e},yo=({values:r},t,e)=>{r[t]=e},ul=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return po(r,t,e);case C.MILLISECOND:return mo(r,t,e);case C.MICROSECOND:return _o(r,t,e);case C.NANOSECOND:return yo(r,t,e)}},S_=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Zt.getVisitFn(i);if(Array.isArray(e))for(let a=-1,l=t*n;++a<n;)s(i,l+a,e[a]);else for(let a=-1,l=t*n;++a<n;)s(i,l+a,e.get(a))};q.prototype.visitBool=tt(d_);q.prototype.visitInt=tt(Or);q.prototype.visitInt8=tt(Or);q.prototype.visitInt16=tt(Or);q.prototype.visitInt32=tt(Or);q.prototype.visitInt64=tt(Or);q.prototype.visitUint8=tt(Or);q.prototype.visitUint16=tt(Or);q.prototype.visitUint32=tt(Or);q.prototype.visitUint64=tt(Or);q.prototype.visitFloat=tt(f_);q.prototype.visitFloat16=tt(Lu);q.prototype.visitFloat32=tt(nl);q.prototype.visitFloat64=tt(nl);q.prototype.visitUtf8=tt(ku);q.prototype.visitLargeUtf8=tt(ku);q.prototype.visitBinary=tt(Nu);q.prototype.visitLargeBinary=tt(Nu);q.prototype.visitFixedSizeBinary=tt(il);q.prototype.visitDate=tt(sl);q.prototype.visitDateDay=tt(eo);q.prototype.visitDateMillisecond=tt(ro);q.prototype.visitTimestamp=tt(ol);q.prototype.visitTimestampSecond=tt(no);q.prototype.visitTimestampMillisecond=tt(io);q.prototype.visitTimestampMicrosecond=tt(so);q.prototype.visitTimestampNanosecond=tt(oo);q.prototype.visitTime=tt(al);q.prototype.visitTimeSecond=tt(ao);q.prototype.visitTimeMillisecond=tt(lo);q.prototype.visitTimeMicrosecond=tt(co);q.prototype.visitTimeNanosecond=tt(uo);q.prototype.visitDecimal=tt(ll);q.prototype.visitList=tt(h_);q.prototype.visitStruct=tt(g_);q.prototype.visitUnion=tt(w_);q.prototype.visitDenseUnion=tt(Cu);q.prototype.visitSparseUnion=tt(Pu);q.prototype.visitDictionary=tt(v_);q.prototype.visitInterval=tt(cl);q.prototype.visitIntervalDayTime=tt(fo);q.prototype.visitIntervalYearMonth=tt(ho);q.prototype.visitDuration=tt(ul);q.prototype.visitDurationSecond=tt(po);q.prototype.visitDurationMillisecond=tt(mo);q.prototype.visitDurationMicrosecond=tt(_o);q.prototype.visitDurationNanosecond=tt(yo);q.prototype.visitFixedSizeList=tt(S_);q.prototype.visitMap=tt(p_);var Zt=new q;var je=Symbol.for("parent"),qn=Symbol.for("rowIndex"),nn=class{constructor(t,e){return this[je]=t,this[qn]=e,new Proxy(this,new fl)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[qn],e=this[je],n=e.type.children,i={};for(let s=-1,a=n.length;++s<a;)i[n[s].name]=jt.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 dl(this[je],this[qn])}},dl=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,jt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(nn.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[je]:{writable:!0,enumerable:!1,configurable:!1,value:null},[qn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var fl=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[je].type.children.map(e=>e.name)}has(t,e){return t[je].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[je].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[je].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=jt.visit(t[je].children[n],t[qn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[je].type.children.findIndex(s=>s.name===e);return i!==-1?(Zt.visit(t[je].children[i],t[qn],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 X(r){return(t,e)=>t.getValid(e)?r(t,e):null}var I_=(r,t)=>864e5*r[t],F_=(r,t)=>null,Hu=(r,t,e)=>{if(e+1>=t.length)return null;let n=pt(t[e]),i=pt(t[e+1]);return r.subarray(n,i)},B_=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Vu=({values:r},t)=>I_(r,t),Wu=({values:r},t)=>pt(r[t]),sn=({stride:r,values:t},e)=>t[r*e],D_=({stride:r,values:t},e)=>to(t[r*e]),zu=({values:r},t)=>r[t],A_=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),ju=({values:r,valueOffsets:t},e)=>Hu(r,t,e),$u=({values:r,valueOffsets:t},e)=>{let n=Hu(r,t,e);return n!==null?Si(n):null},T_=({values:r},t)=>r[t],x_=({type:r,values:t},e)=>r.precision!==Dt.HALF?t[e]:to(t[e]),E_=(r,t)=>r.type.unit===Wt.DAY?Vu(r,t):Wu(r,t),Gu=({values:r},t)=>1e3*pt(r[t]),Ku=({values:r},t)=>pt(r[t]),qu=({values:r},t)=>Za(r[t],BigInt(1e3)),Yu=({values:r},t)=>Za(r[t],BigInt(1e6)),O_=(r,t)=>{switch(r.type.unit){case C.SECOND:return Gu(r,t);case C.MILLISECOND:return Ku(r,t);case C.MICROSECOND:return qu(r,t);case C.NANOSECOND:return Yu(r,t)}},Ju=({values:r},t)=>r[t],Xu=({values:r},t)=>r[t],Zu=({values:r},t)=>r[t],Qu=({values:r},t)=>r[t],U_=(r,t)=>{switch(r.type.unit){case C.SECOND:return Ju(r,t);case C.MILLISECOND:return Xu(r,t);case C.MICROSECOND:return Zu(r,t);case C.NANOSECOND:return Qu(r,t)}},M_=({values:r,stride:t},e)=>Ci.decimal(r.subarray(t*e,t*(e+1))),R_=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:a}=e,u=i[0].slice(s,a-s);return new dt([u])},L_=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,a=n[0];return new ar(a.slice(i,s-i))},N_=(r,t)=>new nn(r,t),k_=(r,t)=>r.type.mode===xt.Dense?td(r,t):ed(r,t),td=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return jt.visit(n,r.valueOffsets[t])},ed=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return jt.visit(n,t)},C_=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},P_=(r,t)=>r.type.unit===qt.DAY_TIME?rd(r,t):nd(r,t),rd=({values:r},t)=>r.subarray(2*t,2*(t+1)),nd=({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},id=({values:r},t)=>r[t],sd=({values:r},t)=>r[t],od=({values:r},t)=>r[t],ad=({values:r},t)=>r[t],H_=(r,t)=>{switch(r.type.unit){case C.SECOND:return id(r,t);case C.MILLISECOND:return sd(r,t);case C.MICROSECOND:return od(r,t);case C.NANOSECOND:return ad(r,t)}},V_=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new dt([s])};j.prototype.visitNull=X(F_);j.prototype.visitBool=X(B_);j.prototype.visitInt=X(T_);j.prototype.visitInt8=X(sn);j.prototype.visitInt16=X(sn);j.prototype.visitInt32=X(sn);j.prototype.visitInt64=X(zu);j.prototype.visitUint8=X(sn);j.prototype.visitUint16=X(sn);j.prototype.visitUint32=X(sn);j.prototype.visitUint64=X(zu);j.prototype.visitFloat=X(x_);j.prototype.visitFloat16=X(D_);j.prototype.visitFloat32=X(sn);j.prototype.visitFloat64=X(sn);j.prototype.visitUtf8=X($u);j.prototype.visitLargeUtf8=X($u);j.prototype.visitBinary=X(ju);j.prototype.visitLargeBinary=X(ju);j.prototype.visitFixedSizeBinary=X(A_);j.prototype.visitDate=X(E_);j.prototype.visitDateDay=X(Vu);j.prototype.visitDateMillisecond=X(Wu);j.prototype.visitTimestamp=X(O_);j.prototype.visitTimestampSecond=X(Gu);j.prototype.visitTimestampMillisecond=X(Ku);j.prototype.visitTimestampMicrosecond=X(qu);j.prototype.visitTimestampNanosecond=X(Yu);j.prototype.visitTime=X(U_);j.prototype.visitTimeSecond=X(Ju);j.prototype.visitTimeMillisecond=X(Xu);j.prototype.visitTimeMicrosecond=X(Zu);j.prototype.visitTimeNanosecond=X(Qu);j.prototype.visitDecimal=X(M_);j.prototype.visitList=X(R_);j.prototype.visitStruct=X(N_);j.prototype.visitUnion=X(k_);j.prototype.visitDenseUnion=X(td);j.prototype.visitSparseUnion=X(ed);j.prototype.visitDictionary=X(C_);j.prototype.visitInterval=X(P_);j.prototype.visitIntervalDayTime=X(rd);j.prototype.visitIntervalYearMonth=X(nd);j.prototype.visitDuration=X(H_);j.prototype.visitDurationSecond=X(id);j.prototype.visitDurationMillisecond=X(sd);j.prototype.visitDurationMicrosecond=X(od);j.prototype.visitDurationNanosecond=X(ad);j.prototype.visitFixedSizeList=X(V_);j.prototype.visitMap=X(L_);var jt=new j;var on=Symbol.for("keys"),Jn=Symbol.for("vals"),Yn=Symbol.for("kKeysAsStrings"),hl=Symbol.for("_kKeysAsStrings"),ar=class{constructor(t){return this[on]=new dt([t.children[0]]).memoize(),this[Jn]=t.children[1],new Proxy(this,new ml)}get[Yn](){return this[hl]||(this[hl]=Array.from(this[on].toArray(),String))}[Symbol.iterator](){return new pl(this[on],this[Jn])}get size(){return this[on].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[on],e=this[Jn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=jt.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()}},pl=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),jt.visit(this.vals,t)]})}},ml=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Yn]}has(t,e){return t[Yn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Yn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[Yn].indexOf(e);if(n!==-1){let i=jt.visit(Reflect.get(t,Jn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[Yn].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(ar.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[on]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Jn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[hl]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var ld;function Hi(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,a=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(ld=s,s=a,a=ld),a>i&&(a=i),n?n(r,s,a):[s,a]}var bn=(r,t)=>r<0?t+r:r,cd=r=>r!==r;function an(r){if(typeof r!=="object"||r===null)return cd(r)?cd: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?Ka(r,e):!1:r instanceof Map?z_(r):Array.isArray(r)?W_(r):r instanceof dt?j_(r):$_(r,!0)}function W_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=an(r[e]);return bo(t)}function z_(r){let t=-1,e=[];for(let n of r.values())e[++t]=an(n);return bo(e)}function j_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=an(r.get(e));return bo(t)}function $_(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]=an(r[e[i]]);return bo(n,e)}function bo(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return G_(r,e);case Map:return ud(r,e,e.keys());case ar:case nn:case Object:case void 0:return ud(r,e,t||Object.keys(e))}return e instanceof dt?K_(r,e):!1}}function G_(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 K_(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 ud(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](),a=0,l=r.length,u=s.next(),f=n.next(),h=i.next();for(;a<l&&!f.done&&!h.done&&!u.done&&!(f.value!==h.value||!r[a](u.value));++a,f=n.next(),h=i.next(),u=s.next());return a===l&&f.done&&h.done&&u.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var yl={};qr(yl,{BitIterator:()=>gn,getBit:()=>dd,getBool:()=>wo,packBools:()=>vn,popcnt_array:()=>fd,popcnt_bit_range:()=>Vi,popcnt_uint32:()=>go,setBool:()=>q_,truncateBitmap:()=>wn});function wo(r,t,e,n){return(e&1<<n)!==0}function dd(r,t,e,n){return(e&1<<n)>>n}function q_(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function wn(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):vn(new gn(e,r,t,null,wo)).subarray(0,n)),i}return e}function vn(r){let t=[],e=0,n=0,i=0;for(let a of r)a&&(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 gn=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 Vi(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let a of new gn(r,t,e-t,r,dd))s+=a;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Vi(r,t,i)+Vi(r,n,e)+fd(r,i>>3,n-i>>3)}function fd(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),a=e===void 0?r.byteLength:i+e;for(;a-i>=4;)n+=go(s.getUint32(i)),i+=4;for(;a-i>=2;)n+=go(s.getUint16(i)),i+=2;for(;a-i>=1;)n+=go(s.getUint8(i)),i+=1;return n}function go(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 Y_=-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((a,l)=>a+l.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<=Y_&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Vi(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,a=[],l){this.type=t,this.children=a,this.dictionary=l,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let u;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=ye(t),s&&((u=s[0])&&(this.valueOffsets=u),(u=s[1])&&(this.values=u),(u=s[2])&&(this.nullBitmap=u),(u=s[3])&&(this.typeIds=u)))}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,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],l=s.mode===xt.Dense?this.valueOffsets[t]:t;n=a.getValid(l),a.setValid(l,e)}else{let{nullBitmap:s}=this,{offset:a,length:l}=this,u=a+t,f=1<<u%8,h=u>>3;(!s||s.byteLength<=h)&&(s=new Uint8Array((a+l+63&-64)>>3).fill(255),this.nullCount>0?(s.set(wn(a,l,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let w=s[h];n=(w&f)!==0,s[h]=e?w|f:w&~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,a=this.children){return new r(t,e,n,i,s,a,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,l=i===16?n:1,u=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,a,u,s.length===0||this.valueOffsets?s:this._sliceChildren(s,l*t,l*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===p.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(wn(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[Se.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:a}=this;return(s=a[Se.TYPE])&&(a[Se.TYPE]=s.subarray(t,t+e)),(s=a[Se.OFFSET])&&(a[Se.OFFSET]=s.subarray(t,t+e+1))||(s=a[Se.DATA])&&(a[Se.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),a}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};gt.prototype.children=Object.freeze([]);var bl=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 gt(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=ks(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=ks(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=J(t.nullBitmap),{length:a=i.reduce((u,{length:f})=>Math.max(u,f),0),nullCount:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=ot(e.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:l=-1}=t;if(L.isSparseUnion(e))return new gt(e,n,a,l,[void 0,void 0,void 0,s],i);let u=_n(t.valueOffsets);return new gt(e,n,a,l,[u,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.indices.ArrayType,t.data),{["dictionary"]:a=new dt([new r().visit({type:e.dictionary})])}=t,{["length"]:l=s.length,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[void 0,s,i],[],a)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=J(t.nullBitmap),{["length"]:a=i.length/ye(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,a,l,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.childType})}=t,s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new gt(e,n,l,u,[a,void 0,s],[i])}},J_=new bl;function et(r){return J_.visit(r)}var Wi=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 hd(r){return r.some(t=>t.nullable)}function vo(r){return r.reduce((t,e)=>t+e.nullCount,0)}function So(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function Io(r,t,e,n){let i=[];for(let s=-1,a=r.length;++s<a;){let l=r[s],u=t[s],{length:f}=l;if(u>=n)break;if(e>=u+f)continue;if(u>=e&&u+f<=n){i.push(l);continue}let h=Math.max(0,e-u),w=Math.min(n-u,f);i.push(l.slice(h,w-h))}return i.length===0&&i.push(r[0].slice(0,0)),i}function gl(r,t,e,n){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return e<t[a]?n(r,i,e-t[i]):null;s=i+Math.trunc((a-i)*.5),e<t[s]?a=s:i=s}while(i<a)}function zi(r,t){return r.getValid(t)}function Xn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return gl(n,this._offsets,e,t)}}function Fo(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 a=gl(s,this._offsets,n,e);return t=void 0,a}}function Bo(r){let t;function e(n,i,s){let a=s,l=0,u=0;for(let f=i-1,h=n.length;++f<h;){let w=n[f];if(~(l=r(w,t,a)))return u+l;a=0,u+=w.length}return-1}return function(n,i){t=n;let s=this.data,a=typeof i!="number"?e(s,0,0):gl(s,this._offsets,i,e);return t=void 0,a}}var $=class extends z{};function X_(r,t){return t===null&&r.length>0?0:-1}function Z_(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new gn(e,r.offset+(t||0),r.length,e,wo)){if(!i)return n;++n}return-1}function rt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case p.Union:break;case p.Dictionary:break;default:return Z_(r,e)}let n=jt.getVisitFn(r),i=an(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}function pd(r,t,e){let n=jt.getVisitFn(r),i=an(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}$.prototype.visitNull=X_;$.prototype.visitBool=rt;$.prototype.visitInt=rt;$.prototype.visitInt8=rt;$.prototype.visitInt16=rt;$.prototype.visitInt32=rt;$.prototype.visitInt64=rt;$.prototype.visitUint8=rt;$.prototype.visitUint16=rt;$.prototype.visitUint32=rt;$.prototype.visitUint64=rt;$.prototype.visitFloat=rt;$.prototype.visitFloat16=rt;$.prototype.visitFloat32=rt;$.prototype.visitFloat64=rt;$.prototype.visitUtf8=rt;$.prototype.visitLargeUtf8=rt;$.prototype.visitBinary=rt;$.prototype.visitLargeBinary=rt;$.prototype.visitFixedSizeBinary=rt;$.prototype.visitDate=rt;$.prototype.visitDateDay=rt;$.prototype.visitDateMillisecond=rt;$.prototype.visitTimestamp=rt;$.prototype.visitTimestampSecond=rt;$.prototype.visitTimestampMillisecond=rt;$.prototype.visitTimestampMicrosecond=rt;$.prototype.visitTimestampNanosecond=rt;$.prototype.visitTime=rt;$.prototype.visitTimeSecond=rt;$.prototype.visitTimeMillisecond=rt;$.prototype.visitTimeMicrosecond=rt;$.prototype.visitTimeNanosecond=rt;$.prototype.visitDecimal=rt;$.prototype.visitList=rt;$.prototype.visitStruct=rt;$.prototype.visitUnion=rt;$.prototype.visitDenseUnion=pd;$.prototype.visitSparseUnion=pd;$.prototype.visitDictionary=rt;$.prototype.visitInterval=rt;$.prototype.visitIntervalDayTime=rt;$.prototype.visitIntervalYearMonth=rt;$.prototype.visitDuration=rt;$.prototype.visitDurationSecond=rt;$.prototype.visitDurationMillisecond=rt;$.prototype.visitDurationMicrosecond=rt;$.prototype.visitDurationNanosecond=rt;$.prototype.visitFixedSizeList=rt;$.prototype.visitMap=rt;var Sn=new $;var G=class extends z{};function Z(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!==Dt.HALF))return new Wi(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Wi(r.data.length,n=>{let s=r.data[n].length,a=r.slice(e,e+s);return e+=s,new wl(a)})}var wl=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=Z;G.prototype.visitBool=Z;G.prototype.visitInt=Z;G.prototype.visitInt8=Z;G.prototype.visitInt16=Z;G.prototype.visitInt32=Z;G.prototype.visitInt64=Z;G.prototype.visitUint8=Z;G.prototype.visitUint16=Z;G.prototype.visitUint32=Z;G.prototype.visitUint64=Z;G.prototype.visitFloat=Z;G.prototype.visitFloat16=Z;G.prototype.visitFloat32=Z;G.prototype.visitFloat64=Z;G.prototype.visitUtf8=Z;G.prototype.visitLargeUtf8=Z;G.prototype.visitBinary=Z;G.prototype.visitLargeBinary=Z;G.prototype.visitFixedSizeBinary=Z;G.prototype.visitDate=Z;G.prototype.visitDateDay=Z;G.prototype.visitDateMillisecond=Z;G.prototype.visitTimestamp=Z;G.prototype.visitTimestampSecond=Z;G.prototype.visitTimestampMillisecond=Z;G.prototype.visitTimestampMicrosecond=Z;G.prototype.visitTimestampNanosecond=Z;G.prototype.visitTime=Z;G.prototype.visitTimeSecond=Z;G.prototype.visitTimeMillisecond=Z;G.prototype.visitTimeMicrosecond=Z;G.prototype.visitTimeNanosecond=Z;G.prototype.visitDecimal=Z;G.prototype.visitList=Z;G.prototype.visitStruct=Z;G.prototype.visitUnion=Z;G.prototype.visitDenseUnion=Z;G.prototype.visitSparseUnion=Z;G.prototype.visitDictionary=Z;G.prototype.visitInterval=Z;G.prototype.visitIntervalDayTime=Z;G.prototype.visitIntervalYearMonth=Z;G.prototype.visitDuration=Z;G.prototype.visitDurationSecond=Z;G.prototype.visitDurationMillisecond=Z;G.prototype.visitDurationMicrosecond=Z;G.prototype.visitDurationNanosecond=Z;G.prototype.visitFixedSizeList=Z;G.prototype.visitMap=Z;var Zn=new G;var md,_d={},yd={},dt=class r{constructor(t){var e,n,i;let s=t[0]instanceof r?t.flatMap(l=>l.data):t;if(s.length===0||s.some(l=>!(l instanceof gt)))throw new TypeError("Vector constructor expects an Array of Data instances.");let a=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:l,set:u,indexOf:f}=_d[a.typeId],h=s[0];this.isValid=w=>zi(h,w),this.get=w=>l(h,w),this.set=(w,A)=>u(h,w,A),this.indexOf=w=>f(h,w),this._offsets=[0,h.length];break}default:Object.setPrototypeOf(this,yd[a.typeId]),this._offsets=So(s);break}this.data=s,this.type=a,this.stride=ye(a),this.numChildren=(i=(n=a.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 hd(this.data)}get nullCount(){return vo(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return"".concat(this.VectorName,"<").concat(this.type[Symbol.toStringTag],">")}get VectorName(){return"".concat(p[this.type.typeId],"Vector")}isValid(t){return!1}get(t){return null}at(t){return this.get(bn(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Zn.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(Hi(this,t,e,({data:n,_offsets:i},s,a)=>Io(n,i,s,a)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((a,{values:l,length:u})=>(a.array.set(l.subarray(0,u*i),a.offset),a.offset+=u*i,a),{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 Do(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new Do(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}};md=Symbol.toStringTag;dt[md]=(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(p).map(e=>p[e]).filter(e=>typeof e=="number"&&e!==p.NONE);for(let e of t){let n=jt.getVisitFnByTypeId(e),i=Zt.getVisitFnByTypeId(e),s=Sn.getVisitFnByTypeId(e);_d[e]={get:n,set:i,indexOf:s},yd[e]=Object.create(r,{isValid:{value:Xn(zi)},get:{value:Xn(jt.getVisitFnByTypeId(e))},set:{value:Fo(Zt.getVisitFnByTypeId(e))},indexOf:{value:Bo(Sn.getVisitFnByTypeId(e))}})}return"Vector"})(dt.prototype);var Do=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(a){let l=s[a];if(l!==void 0)return l;let u=e.call(this,a);return s[a]=u,u}}),Object.defineProperty(this,"set",{value(a,l){n.call(this,a,l),s[a]=l}}),Object.defineProperty(this,"slice",{value:(a,l)=>new r(i.call(this,a,l))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new dt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function bd(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(Q_(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 Q_(r){return typeof r!="bigint"?Ce(r):"".concat(Ce(r),"n")}function vl(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function gd(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?vl(n*1,this.BYTES_PER_ELEMENT):vl(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=vl(t*this.stride,this.BYTES_PER_ELEMENT);let e=gd(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=gd(this.buffer,t)}},Ur=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}},Qn=class extends Ur{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,a=n[i]>>s&1;return e?a===0&&(n[i]|=1<<s,++this.numValid):a===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},ti=class extends Ur{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 Nt=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=ye(t),this._nulls=new Qn,e&&e.length>0&&(this._isValid=bd(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:a}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),a.reduce((l,u)=>l+u.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:a,nullCount:l,_typeIds:u,_offsets:f,_values:h,_nulls:w}=this;(e=u==null?void 0:u.flush(a))?i=f==null?void 0:f.flush(a):(i=f==null?void 0:f.flush(a))?t=h==null?void 0:h.flush(f.last()):t=h==null?void 0:h.flush(a),l>0&&(n=w==null?void 0:w.flush(a));let A=this.children.map(E=>E.flush());return this.clear(),et({type:s,length:a,nullCount:l,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}};Nt.prototype.length=1;Nt.prototype.stride=1;Nt.prototype.children=null;Nt.prototype.finished=!1;Nt.prototype.nullValues=null;Nt.prototype._isValid=()=>!0;var $t=class extends Nt{constructor(t){super(t),this._values=new Ur(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},le=class extends Nt{constructor(t){super(t),this._pendingLength=0,this._offsets=new ti(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 ar?e[on].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 In=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 be=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 In).__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 In).__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=Sl(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=Ao(Ao(new Map,this.metadata),e.metadata),s=e.fields.filter(l=>{let u=n.findIndex(f=>f.name===l.name);return~u?(n[u]=l.clone({metadata:Ao(Ao(new Map,n[u].metadata),l.metadata)}))&&!1:!0}),a=Sl(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...a]))}};It.prototype.fields=null;It.prototype.metadata=null;It.prototype.dictionaries=null;var lt=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)}};lt.prototype.type=null;lt.prototype.name=null;lt.prototype.nullable=null;lt.prototype.metadata=null;function Ao(r,t){return new Map([...r||new Map,...t||new Map])}function Sl(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&&Sl(s.children,t)}return t}var ty=yn,ey=pe,Mr=class{static decode(t){t=new ey(J(t));let e=be.getRootAsFooter(t),n=It.decode(e.schema(),new Map,e.version());return new Il(n,e)}static encode(t){let e=new ty,n=It.encode(e,t.schema);be.startRecordBatchesVector(e,t.numRecordBatches);for(let a of[...t.recordBatches()].slice().reverse())Rr.encode(e,a);let i=e.endVector();be.startDictionariesVector(e,t.numDictionaries);for(let a of[...t.dictionaryBatches()].slice().reverse())Rr.encode(e,a);let s=e.endVector();return be.startFooter(e),be.addSchema(e,n),be.addVersion(e,vt.V5),be.addRecordBatches(e,i),be.addDictionaries(e,s),be.finishFooterBuffer(e,be.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 Il=class extends Mr{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 Rr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Rr.decode(e)}return null}},Rr=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 In.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=pt(n),this.bodyLength=pt(e)}};var Lt=Object.freeze({done:!0,value:void 0}),ji=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Fn=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())}},To=class extends Fn{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(Lt);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),Lt})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),Lt})}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(Lt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var lr=class extends To{write(t){if((t=J(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Si(this.toUint8Array(!0)):this.toUint8Array(!1).then(Si)}toUint8Array(t=!1){return t?he(this._values)[0]:R(this,void 0,void 0,function*(){var e,n,i,s;let a=[],l=0;try{for(var u=!0,f=Oe(this),h;h=yield f.next(),e=h.done,!e;u=!0){s=h.value,u=!1;let w=s;a.push(w),l+=w.byteLength}}catch(w){n={error:w}}finally{try{!u&&!e&&(i=f.return)&&(yield i.call(f))}finally{if(n)throw n.error}}return he(a,l)[0]})}},cr=class{constructor(t){t&&(this.source=new Fl(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)}},Fe=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof lr?this.source=new Lr(Xt.fromAsyncIterable(t)):Ns(t)?this.source=new Lr(Xt.fromNodeStream(t)):Ii(t)?this.source=new Lr(Xt.fromDOMStream(t)):Rs(t)?this.source=new Lr(Xt.fromDOMStream(t.body)):Me(t)?this.source=new Lr(Xt.fromIterable(t)):Ue(t)?this.source=new Lr(Xt.fromAsyncIterable(t)):we(t)&&(this.source=new Lr(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)}},Fl=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)||Lt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Lt)}},Lr=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))||Lt;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))||Lt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var $i=class extends cr{constructor(t,e){super(),this.position=0,this.buffer=J(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}}},ln=class extends Fe{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,a=0,l=0,u=Math.min(n,s+Math.min(n-s,t)),f=new Uint8Array(Math.max(0,(this.position=u)-s));for(;(s+=l)<u&&(a+=l)<f.byteLength;)({bytesRead:l}=yield e.read(f,a,f.byteLength-a,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),a=new Uint8Array(s-t);return(yield n.read(a,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 Dl={};qr(Dl,{BaseInt64:()=>Gi,Int128:()=>Ki,Int64:()=>Nr,Uint64:()=>Ht});function ei(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var ri=8,Bl=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Gi=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(ei(this.buffer[1])," ").concat(ei(this.buffer[0]))}},Ht=class r extends Gi{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 a=ri<n-s?ri:n-s,l=new r(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),u=new r(new Uint32Array([Bl[a],0]));i.times(u),i.plus(l),s+=a}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)}},Nr=class r extends Gi{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 a=n?1:0;a<i;){let l=ri<i-a?ri:i-a,u=new r(new Uint32Array([Number.parseInt(t.slice(a,a+l),10),0])),f=new r(new Uint32Array([Bl[l],0]));s.times(f),s.plus(u),a+=l}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)}},Ki=class r{constructor(t){this.buffer=t}high(){return new Nr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Nr(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 Ht(new Uint32Array([this.buffer[3],0])),n=new Ht(new Uint32Array([this.buffer[2],0])),i=new Ht(new Uint32Array([this.buffer[1],0])),s=new Ht(new Uint32Array([this.buffer[0],0])),a=new Ht(new Uint32Array([t.buffer[3],0])),l=new Ht(new Uint32Array([t.buffer[2],0])),u=new Ht(new Uint32Array([t.buffer[1],0])),f=new Ht(new Uint32Array([t.buffer[0],0])),h=Ht.multiply(s,f);this.buffer[0]=h.low();let w=new Ht(new Uint32Array([h.high(),0]));return h=Ht.multiply(i,f),w.plus(h),h=Ht.multiply(s,u),w.plus(h),this.buffer[1]=w.low(),this.buffer[3]=w.lessThan(h)?1:0,this.buffer[2]=w.high(),new Ht(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ht.multiply(n,f)).plus(Ht.multiply(i,u)).plus(Ht.multiply(s,l)),this.buffer[3]+=Ht.multiply(e,f).plus(Ht.multiply(n,u)).plus(Ht.multiply(i,l)).plus(Ht.multiply(s,a)).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(ei(this.buffer[3])," ").concat(ei(this.buffer[2])," ").concat(ei(this.buffer[1])," ").concat(ei(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 a=n?1:0;a<i;){let l=ri<i-a?ri:i-a,u=new r(new Uint32Array([Number.parseInt(t.slice(a,a+l),10),0,0,0])),f=new r(new Uint32Array([Bl[l],0,0,0]));s.times(f),s.plus(u),a+=l}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 qi=class extends z{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 lt?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return et({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({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 et({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 et({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 et({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 et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({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 et({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 et({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 et({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({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 et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return et({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 et({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)}},xo=class extends qi{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):vn(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return ot(Uint8Array,ot(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return ot(Uint8Array,ot(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return L.isTimestamp(t)?ot(Uint8Array,Nr.convertArray(n[e])):(L.isInt(t)||L.isTime(t))&&t.bitWidth===64||L.isDuration(t)?ot(Uint8Array,Nr.convertArray(n[e])):L.isDate(t)&&t.unit===Wt.MILLISECOND?ot(Uint8Array,Nr.convertArray(n[e])):L.isDecimal(t)?ot(Uint8Array,Ki.convertArray(n[e])):L.isBinary(t)||L.isLargeBinary(t)||L.isFixedSizeBinary(t)?ry(n[e]):L.isBool(t)?vn(n[e]):L.isUtf8(t)||L.isLargeUtf8(t)?er(n[e].join("")):ot(Uint8Array,ot(t.ArrayType,n[e].map(i=>+i)))}};function ry(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 ni=class extends le{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,J(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,l]of t)if(l===void 0)n.set(a,0);else{let u=l.length;i.set(l,s),n.set(a,u),s+=u}}};var ii=class extends le{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,J(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,l]of t)if(l===void 0)n.set(a,BigInt(0));else{let u=l.length;i.set(l,s),n.set(a,BigInt(u)),s+=u}}};var Eo=class extends Nt{constructor(t){super(t),this._values=new Qn}setValue(t,e){this._values.set(t,+e)}};var Bn=class extends $t{};Bn.prototype._setValue=sl;var Yi=class extends Bn{};Yi.prototype._setValue=eo;var Ji=class extends Bn{};Ji.prototype._setValue=ro;var Xi=class extends $t{};Xi.prototype._setValue=ll;var Oo=class extends Nt{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=Dn({type:this.type.indices,nullValues:e}),this.dictionary=Dn({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 Zi=class extends $t{};Zi.prototype._setValue=il;var Uo=class extends Nt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,a=e.length;++s<a;)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 We(this.type.listSize,new lt(e,t.type,!0)),n}};var An=class extends $t{setValue(t,e){this._values.set(t,e)}},Mo=class extends An{setValue(t,e){super.setValue(t,Pi(e))}},Ro=class extends An{},Lo=class extends An{};var Tn=class extends $t{};Tn.prototype._setValue=cl;var Qi=class extends Tn{};Qi.prototype._setValue=fo;var ts=class extends Tn{};ts.prototype._setValue=ho;var kr=class extends $t{};kr.prototype._setValue=ul;var es=class extends kr{};es.prototype._setValue=po;var rs=class extends kr{};rs.prototype._setValue=mo;var ns=class extends kr{};ns.prototype._setValue=_o;var is=class extends kr{};is.prototype._setValue=yo;var Be=class extends $t{setValue(t,e){this._values.set(t,e)}},No=class extends Be{},ko=class extends Be{},Co=class extends Be{},Po=class extends Be{},Ho=class extends Be{},Vo=class extends Be{},Wo=class extends Be{},zo=class extends Be{};var jo=class extends le{constructor(t){super(t),this._offsets=new ti(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 He(new lt(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 a=s,l=a.length,u=e.set(i,l).buffer[i];for(let f=-1;++f<l;)n.set(u+f,a[f])}}};var $o=class extends le{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 ze(new lt(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]:a,[i+1]:l}=e.set(i,s.size).buffer;for(let u of s.entries())if(n.set(a,u),++a>=l)break}}};var Go=class extends Nt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Ko=class extends Nt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,a)=>n[a].set(t,e[a]));case Map:return i.children.forEach((s,a)=>n[a].set(t,e.get(s.name)));default:return i.children.forEach((s,a)=>n[a].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 Rt([...this.type.children,new lt(e,t.type,!0)]),n}};var Cr=class extends $t{};Cr.prototype._setValue=ol;var ss=class extends Cr{};ss.prototype._setValue=no;var os=class extends Cr{};os.prototype._setValue=io;var as=class extends Cr{};as.prototype._setValue=so;var ls=class extends Cr{};ls.prototype._setValue=oo;var Pr=class extends $t{};Pr.prototype._setValue=al;var cs=class extends Pr{};cs.prototype._setValue=ao;var us=class extends Pr{};us.prototype._setValue=lo;var ds=class extends Pr{};ds.prototype._setValue=co;var fs=class extends Pr{};fs.prototype._setValue=uo;var si=class extends Nt{constructor(t){super(t),this._typeIds=new Ur(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:a}}=this,l=[...i,new lt(e,t.type)];return this.type=new Ve(s,[...a,n],l),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.")}},qo=class extends si{},Yo=class extends si{constructor(t){super(t),this._offsets=new Ur(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),a=this._offsets.set(t,s.length).buffer[t];s==null||s.set(a,e)}};var hs=class extends le{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,er(e))}_flushPending(t,e){}};hs.prototype._flushPending=ni.prototype._flushPending;var ps=class extends le{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,er(e))}_flushPending(t,e){}};ps.prototype._flushPending=ii.prototype._flushPending;var Al=class extends z{visitNull(){return Go}visitBool(){return Eo}visitInt(){return Be}visitInt8(){return No}visitInt16(){return ko}visitInt32(){return Co}visitInt64(){return Po}visitUint8(){return Ho}visitUint16(){return Vo}visitUint32(){return Wo}visitUint64(){return zo}visitFloat(){return An}visitFloat16(){return Mo}visitFloat32(){return Ro}visitFloat64(){return Lo}visitUtf8(){return hs}visitLargeUtf8(){return ps}visitBinary(){return ni}visitLargeBinary(){return ii}visitFixedSizeBinary(){return Zi}visitDate(){return Bn}visitDateDay(){return Yi}visitDateMillisecond(){return Ji}visitTimestamp(){return Cr}visitTimestampSecond(){return ss}visitTimestampMillisecond(){return os}visitTimestampMicrosecond(){return as}visitTimestampNanosecond(){return ls}visitTime(){return Pr}visitTimeSecond(){return cs}visitTimeMillisecond(){return us}visitTimeMicrosecond(){return ds}visitTimeNanosecond(){return fs}visitDecimal(){return Xi}visitList(){return jo}visitStruct(){return Ko}visitUnion(){return si}visitDenseUnion(){return Yo}visitSparseUnion(){return qo}visitDictionary(){return Oo}visitInterval(){return Tn}visitIntervalDayTime(){return Qi}visitIntervalYearMonth(){return ts}visitDuration(){return kr}visitDurationSecond(){return es}visitDurationMillisecond(){return rs}visitDurationMicrosecond(){return ns}visitDurationNanosecond(){return is}visitFixedSizeList(){return Uo}visitMap(){return $o}},wd=new Al;var K=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 se(r,t){return t instanceof r.constructor}function xn(r,t){return r===t||se(r,t)}function Hr(r,t){return r===t||se(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Jo(r,t){return r===t||se(r,t)&&r.precision===t.precision}function ny(r,t){return r===t||se(r,t)&&r.byteWidth===t.byteWidth}function Tl(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ms(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function _s(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function iy(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function sy(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function xl(r,t){return r===t||se(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&ur.compareManyFields(r.children,t.children)}function oy(r,t){return r===t||se(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&ur.visit(r.indices,t.indices)&&ur.visit(r.dictionary,t.dictionary)}function El(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ys(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ay(r,t){return r===t||se(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function ly(r,t){return r===t||se(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}K.prototype.visitNull=xn;K.prototype.visitBool=xn;K.prototype.visitInt=Hr;K.prototype.visitInt8=Hr;K.prototype.visitInt16=Hr;K.prototype.visitInt32=Hr;K.prototype.visitInt64=Hr;K.prototype.visitUint8=Hr;K.prototype.visitUint16=Hr;K.prototype.visitUint32=Hr;K.prototype.visitUint64=Hr;K.prototype.visitFloat=Jo;K.prototype.visitFloat16=Jo;K.prototype.visitFloat32=Jo;K.prototype.visitFloat64=Jo;K.prototype.visitUtf8=xn;K.prototype.visitLargeUtf8=xn;K.prototype.visitBinary=xn;K.prototype.visitLargeBinary=xn;K.prototype.visitFixedSizeBinary=ny;K.prototype.visitDate=Tl;K.prototype.visitDateDay=Tl;K.prototype.visitDateMillisecond=Tl;K.prototype.visitTimestamp=ms;K.prototype.visitTimestampSecond=ms;K.prototype.visitTimestampMillisecond=ms;K.prototype.visitTimestampMicrosecond=ms;K.prototype.visitTimestampNanosecond=ms;K.prototype.visitTime=_s;K.prototype.visitTimeSecond=_s;K.prototype.visitTimeMillisecond=_s;K.prototype.visitTimeMicrosecond=_s;K.prototype.visitTimeNanosecond=_s;K.prototype.visitDecimal=xn;K.prototype.visitList=iy;K.prototype.visitStruct=sy;K.prototype.visitUnion=xl;K.prototype.visitDenseUnion=xl;K.prototype.visitSparseUnion=xl;K.prototype.visitDictionary=oy;K.prototype.visitInterval=El;K.prototype.visitIntervalDayTime=El;K.prototype.visitIntervalYearMonth=El;K.prototype.visitDuration=ys;K.prototype.visitDurationSecond=ys;K.prototype.visitDurationMillisecond=ys;K.prototype.visitDurationMicrosecond=ys;K.prototype.visitDurationNanosecond=ys;K.prototype.visitFixedSizeList=ay;K.prototype.visitMap=ly;var ur=new K;function En(r,t){return ur.compareSchemas(r,t)}function vd(r,t){return ur.compareFields(r,t)}function Sd(r,t){return ur.visit(r,t)}function Dn(r){let t=r.type,e=new(wd.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(a,l)=>n[l]||i:({name:a})=>n[a]||i;for(let[a,l]of t.children.entries()){let{type:u}=l,f=s(l,a);e.children.push(Dn(Object.assign(Object.assign({},f),{type:u})))}}return e}function Xo(r,t){return cy(r,t.map(e=>e.data.concat()))}function cy(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((w,A)=>Math.max(w,A.length),0)},s=0,a=0,l=-1,u=t.length,f,h=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,l=-1;++l<u;)h[l]=f=t[l].shift(),a=Math.min(a,f?f.length:a);Number.isFinite(a)&&(h=uy(e,a,h,t,i),a>0&&(n[s++]=et({type:new Rt(e),length:a,nullCount:0,children:h.slice()})))}return[r=r.assign(e),n.map(w=>new zt(r,w))]}function uy(r,t,e,n,i){var s;let a=(t+63&-64)>>3;for(let l=-1,u=n.length;++l<u;){let f=e[l],h=f==null?void 0:f.length;if(h>=t)h===t?e[l]=f:(e[l]=f.slice(0,t),i.numBatches=Math.max(i.numBatches,n[l].unshift(f.slice(t,h-t))));else{let w=r[l];r[l]=w.clone({nullable:!0}),e[l]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:et({type:w.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return e}var Id,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 a=u=>{if(u){if(u instanceof zt)return[u];if(u instanceof r)return u.batches;if(u instanceof gt){if(u.type instanceof Rt)return[new zt(new It(u.type.children),u)]}else{if(Array.isArray(u))return u.flatMap(f=>a(f));if(typeof u[Symbol.iterator]=="function")return[...u].flatMap(f=>a(f));if(typeof u=="object"){let f=Object.keys(u),h=f.map(E=>new dt([u[E]])),w=i!=null?i:new It(f.map((E,at)=>new lt(String(E),h[at].type,h[at].nullable))),[,A]=Xo(w,h);return A.length===0?[new zt(u)]:A}}}return[]},l=t.flatMap(u=>a(u));if(i=(n=i!=null?i:(e=l[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 u of l){if(!(u instanceof zt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!En(i,u.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=l,this._offsets=s!=null?s:So(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=vo(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(bn(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Zn.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 zt(e,i)))}slice(t,e){let n=this.schema;[t,e]=Hi({length:this.numRows},t,e);let i=Io(this.data,this._offsets,t,e);return new r(n,i.map(s=>new zt(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=et({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([et({type:new ie,length:this.numRows})]));let s=n.fields.slice(),a=s[t].clone({type:e.type}),l=this.schema.fields.map((u,f)=>this.getChildAt(f));[s[t],l[t]]=[a,e],[n,i]=Xo(n,l)}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((l,u,f)=>{let[h,w]=l,A=e.findIndex(E=>E.name===u.name);return~A?w[A]=f:h.push(f),l},[[],[]]),s=this.schema.assign(t.schema),a=[...e.map((l,u)=>[u,i[u]]).map(([l,u])=>u===void 0?this.getChildAt(l):t.getChildAt(u)),...n.map(l=>t.getChildAt(l))].filter(Boolean);return new r(...Xo(s,a))}};Id=Symbol.toStringTag;oe[Id]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Xn(zi),r.get=Xn(jt.getVisitFn(p.Struct)),r.set=Fo(Zt.getVisitFn(p.Struct)),r.indexOf=Bo(Sn.getVisitFn(p.Struct)),"Table"))(oe.prototype);var Bd,zt=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=et({nullCount:0,type:new Rt(this.schema.fields),children:this.schema.fields.map(e=>et({type:e.type,nullCount:0}))})]=t,!(this.data instanceof gt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Fd(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((u,f,h)=>(u.children[h]=e[f],u.length=Math.max(u.length,e[f].length),u.fields[h]=lt.new({name:f,type:e[f].type,nullable:!0}),u),{length:0,fields:new Array,children:new Array}),a=new It(n),l=et({type:new Rt(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Fd(a,l.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=Dd(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 jt.visit(this.data,t)}at(t){return this.get(bn(t,this.numRows))}set(t,e){return Zt.visit(this.data,t,e)}indexOf(t,e){return Sn.visit(this.data,t,e)}[Symbol.iterator](){return Zn.visit(new dt([this.data]))}toArray(){return[...this]}concat(...t){return new oe(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([et({type:new ie,length:this.numRows})]));let s=n.fields.slice(),a=i.children.slice(),l=s[t].clone({type:e.type});[s[t],a[t]]=[l,e.data[0]],n=new It(s,new Map(this.schema.metadata)),i=et({type:new Rt(s),children:a})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Rt(e.fields),i=[];for(let s of t){let a=this.schema.fields.findIndex(l=>l.name===s);~a&&(i[a]=this.data.children[a])}return new r(e,et({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=et({type:new Rt(e.fields),length:this.numRows,children:n});return new r(e,i)}};Bd=Symbol.toStringTag;zt[Bd]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(zt.prototype);function Fd(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],a=(e+63&-64)>>3;for(let[l,u]of r.fields.entries()){let f=t[l];(!f||f.length!==e)&&(i[l]=u.clone({nullable:!0}),s[l]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:et({type:u.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)}))}return[r.assign(i),et({type:new Rt(i),length:e,children:s})]}function Dd(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,a=r.length;++s<a;){let{type:l}=r[s],u=t[s];for(let f of[u,...((i=u==null?void 0:u.dictionary)===null||i===void 0?void 0:i.data)||[]])Dd(l.children,f==null?void 0:f.children,e);if(L.isDictionary(l)){let{id:f}=l;if(!e.has(f))u!=null&&u.dictionary&&e.set(f,u.dictionary);else if(e.get(f)!==u.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var On=class extends zt{constructor(t){let e=t.fields.map(i=>et({type:i.type})),n=et({type:new Rt(t.fields),nullCount:0,children:e});super(t,n)}};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 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):ct.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,ct.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,a){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,a),r.endMessage(t)}};var Ol=class extends z{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Ri.startNull(e),Ri.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 tn.startFloatingPoint(e),tn.addPrecision(e,t.precision),tn.endFloatingPoint(e)}visitBinary(t,e){return xi.startBinary(e),xi.endBinary(e)}visitLargeBinary(t,e){return Oi.startLargeBinary(e),Oi.endLargeBinary(e)}visitBool(t,e){return Ei.startBool(e),Ei.endBool(e)}visitUtf8(t,e){return Ni.startUtf8(e),Ni.endUtf8(e)}visitLargeUtf8(t,e){return Ui.startLargeUtf8(e),Ui.endLargeUtf8(e)}visitDecimal(t,e){return sr.startDecimal(e),sr.addScale(e,t.scale),sr.addPrecision(e,t.precision),sr.addBitWidth(e,t.bitWidth),sr.endDecimal(e)}visitDate(t,e){return Jr.startDate(e),Jr.addUnit(e,t.unit),Jr.endDate(e)}visitTime(t,e){return yr.startTime(e),yr.addUnit(e,t.unit),yr.addBitWidth(e,t.bitWidth),yr.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return br.startTimestamp(e),br.addUnit(e,t.unit),n!==void 0&&br.addTimezone(e,n),br.endTimestamp(e)}visitInterval(t,e){return en.startInterval(e),en.addUnit(e,t.unit),en.endInterval(e)}visitDuration(t,e){return Xr.startDuration(e),Xr.addUnit(e,t.unit),Xr.endDuration(e)}visitList(t,e){return Mi.startList(e),Mi.endList(e)}visitStruct(t,e){return Li.startStruct_(e),Li.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 ir.startDictionaryEncoding(e),ir.addId(e,BigInt(t.id)),ir.addIsOrdered(e,t.isOrdered),n!==void 0&&ir.addIndexType(e,n),ir.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Zr.startFixedSizeBinary(e),Zr.addByteWidth(e,t.byteWidth),Zr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Qr.startFixedSizeList(e),Qr.addListSize(e,t.listSize),Qr.endFixedSizeList(e)}visitMap(t,e){return rn.startMap(e),rn.addKeysSorted(e,t.keysSorted),rn.endMap(e)}},Zo=new Ol;function Ed(r,t=new Map){return new It(fy(r,t),Qo(r.metadata),t)}function Ul(r){return new Qt(r.count,Ud(r.columns),Md(r.columns))}function Od(r){return new ue(Ul(r.data),r.id,r.isDelta)}function fy(r,t){return(r.fields||[]).filter(Boolean).map(e=>lt.fromJSON(e,t))}function Ad(r,t){return(r.children||[]).filter(Boolean).map(e=>lt.fromJSON(e,t))}function Ud(r){return(r||[]).reduce((t,e)=>[...t,new De(e.count,hy(e.VALIDITY)),...Ud(e.children)],[])}function Md(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new ce(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new ce(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new ce(t.length,i.OFFSET.length)),i.DATA&&t.push(new ce(t.length,i.DATA.length)),t=Md(i.children,t)}return t}function hy(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Rd(r,t){let e,n,i,s,a,l;return!t||!(s=r.dictionary)?(a=xd(r,Ad(r,t)),i=new lt(r.name,a,r.nullable,Qo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?Td(n):new or,l=new _e(t.get(e),n,e,s.isOrdered),i=new lt(r.name,l,r.nullable,Qo(r.metadata))):(n=(n=s.indexType)?Td(n):new or,t.set(e,a=xd(r,Ad(r,t))),l=new _e(a,n,e,s.isOrdered),i=new lt(r.name,l,r.nullable,Qo(r.metadata))),i||null}function Qo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Td(r){return new Jt(r.isSigned,r.bitWidth)}function xd(r,t){let e=r.type.name;switch(e){case"NONE":return new ie;case"null":return new ie;case"binary":return new gr;case"largebinary":return new wr;case"utf8":return new vr;case"largeutf8":return new Sr;case"bool":return new Ir;case"list":return new He((t||[])[0]);case"struct":return new Rt(t||[]);case"struct_":return new Rt(t||[])}switch(e){case"int":{let n=r.type;return new Jt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Ie(Dt[n.precision])}case"decimal":{let n=r.type;return new Fr(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Br(Wt[n.unit])}case"time":{let n=r.type;return new Dr(C[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Ar(C[n.unit],n.timezone)}case"interval":{let n=r.type;return new Tr(qt[n.unit])}case"duration":{let n=r.type;return new xr(C[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Ve(xt[a],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Er(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new We(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new ze((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var py=yn,my=pe,de=class r{static fromJSON(t,e){let n=new r(0,vt.V5,e);return n._createHeader=_y(t,e),n}static decode(t){t=new my(J(t));let e=Ge.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),a=new r(n,i,s);return a._createHeader=yy(e,s),a}static encode(t){let e=new py,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())),Ge.startMessage(e),Ge.addVersion(e,vt.V5),Ge.addHeader(e,n),Ge.addHeaderType(e,t.headerType),Ge.addBodyLength(e,BigInt(t.bodyLength)),Ge.finishMessageBuffer(e,Ge.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof It)return new r(0,vt.V5,ct.Schema,t);if(t instanceof Qt)return new r(e,vt.V5,ct.RecordBatch,t);if(t instanceof ue)return new r(e,vt.V5,ct.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===ct.Schema}isRecordBatch(){return this.headerType===ct.RecordBatch}isDictionaryBatch(){return this.headerType===ct.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=pt(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=pt(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=pt(e)}},ce=class{constructor(t,e){this.offset=pt(t),this.length=pt(e)}},De=class{constructor(t,e){this.length=pt(t),this.nullCount=pt(e)}};function _y(r,t){return()=>{switch(t){case ct.Schema:return It.fromJSON(r);case ct.RecordBatch:return Qt.fromJSON(r);case ct.DictionaryBatch:return ue.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(ct[t],", type: ").concat(t," }"))}}function yy(r,t){return()=>{switch(t){case ct.Schema:return It.decode(r.header(new ae),new Map,r.version());case ct.RecordBatch:return Qt.decode(r.header(new me),r.version());case ct.DictionaryBatch:return ue.decode(r.header(new _r),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(ct[t],", type: ").concat(t," }"))}}lt.encode=Ty;lt.decode=Dy;lt.fromJSON=Rd;It.encode=Ay;It.decode=by;It.fromJSON=Ed;Qt.encode=xy;Qt.decode=gy;Qt.fromJSON=Ul;ue.encode=Ey;ue.decode=wy;ue.fromJSON=Od;De.encode=Oy;De.decode=Sy;ce.encode=Uy;ce.decode=vy;function by(r,t=new Map,e=vt.V5){let n=By(r,t);return new It(n,ta(r),t,e)}function gy(r,t=vt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Qt(r.length(),Iy(r),Fy(r,t))}function wy(r,t=vt.V5){return new ue(Qt.decode(r.data(),t),r.id(),r.isDelta())}function vy(r){return new ce(r.offset(),r.length())}function Sy(r){return new De(r.length(),r.nullCount())}function Iy(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=De.decode(e));return t}function Fy(r,t){let e=[];for(let n,i=-1,s=-1,a=r.buffersLength();++i<a;)(n=r.buffers(i))&&(t<vt.V4&&(n.bb_pos+=8*(i+1)),e[++s]=ce.decode(n));return e}function By(r,t){let e=[];for(let n,i=-1,s=-1,a=r.fieldsLength();++i<a;)(n=r.fields(i))&&(e[++s]=lt.decode(n,t));return e}function Ld(r,t){let e=[];for(let n,i=-1,s=-1,a=r.childrenLength();++i<a;)(n=r.children(i))&&(e[++s]=lt.decode(n,t));return e}function Dy(r,t){let e,n,i,s,a,l;return!t||!(l=r.dictionary())?(i=kd(r,Ld(r,t)),n=new lt(r.name(),i,r.nullable(),ta(r))):t.has(e=pt(l.id()))?(s=(s=l.indexType())?Nd(s):new or,a=new _e(t.get(e),s,e,l.isOrdered()),n=new lt(r.name(),a,r.nullable(),ta(r))):(s=(s=l.indexType())?Nd(s):new or,t.set(e,i=kd(r,Ld(r,t))),a=new _e(i,s,e,l.isOrdered()),n=new lt(r.name(),a,r.nullable(),ta(r))),n||null}function ta(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 Nd(r){return new Jt(r.isSigned(),r.bitWidth())}function kd(r,t){let e=r.typeType();switch(e){case Et.NONE:return new ie;case Et.Null:return new ie;case Et.Binary:return new gr;case Et.LargeBinary:return new wr;case Et.Utf8:return new vr;case Et.LargeUtf8:return new Sr;case Et.Bool:return new Ir;case Et.List:return new He((t||[])[0]);case Et.Struct_:return new Rt(t||[])}switch(e){case Et.Int:{let n=r.type(new Ne);return new Jt(n.isSigned(),n.bitWidth())}case Et.FloatingPoint:{let n=r.type(new tn);return new Ie(n.precision())}case Et.Decimal:{let n=r.type(new sr);return new Fr(n.scale(),n.precision(),n.bitWidth())}case Et.Date:{let n=r.type(new Jr);return new Br(n.unit())}case Et.Time:{let n=r.type(new yr);return new Dr(n.unit(),n.bitWidth())}case Et.Timestamp:{let n=r.type(new br);return new Ar(n.unit(),n.timezone())}case Et.Interval:{let n=r.type(new en);return new Tr(n.unit())}case Et.Duration:{let n=r.type(new Xr);return new xr(n.unit())}case Et.Union:{let n=r.type(new ke);return new Ve(n.mode(),n.typeIdsArray()||[],t||[])}case Et.FixedSizeBinary:{let n=r.type(new Zr);return new Er(n.byteWidth())}case Et.FixedSizeList:{let n=r.type(new Qr);return new We(n.listSize(),(t||[])[0])}case Et.Map:{let n=r.type(new rn);return new ze((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(Et[e],'" (').concat(e,")"))}function Ay(r,t){let e=t.fields.map(s=>lt.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,a])=>{let l=r.createString("".concat(s)),u=r.createString("".concat(a));return Yt.startKeyValue(r),Yt.addKey(r,l),Yt.addValue(r,u),Yt.endKeyValue(r)})):-1;return ae.startSchema(r),ae.addFields(r,n),ae.addEndianness(r,My?Yr.Little:Yr.Big),i!==-1&&ae.addCustomMetadata(r,i),ae.endSchema(r)}function Ty(r,t){let e=-1,n=-1,i=-1,s=t.type,a=t.typeId;L.isDictionary(s)?(a=s.dictionary.typeId,i=Zo.visit(s,r),n=Zo.visit(s.dictionary,r)):n=Zo.visit(s,r);let l=(s.children||[]).map(h=>lt.encode(r,h)),u=re.createChildrenVector(r,l),f=t.metadata&&t.metadata.size>0?re.createCustomMetadataVector(r,[...t.metadata].map(([h,w])=>{let A=r.createString("".concat(h)),E=r.createString("".concat(w));return Yt.startKeyValue(r),Yt.addKey(r,A),Yt.addValue(r,E),Yt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),re.startField(r),re.addType(r,n),re.addTypeType(r,a),re.addChildren(r,u),re.addNullable(r,!!t.nullable),e!==-1&&re.addName(r,e),i!==-1&&re.addDictionary(r,i),f!==-1&&re.addCustomMetadata(r,f),re.endField(r)}function xy(r,t){let e=t.nodes||[],n=t.buffers||[];me.startNodesVector(r,e.length);for(let a of e.slice().reverse())De.encode(r,a);let i=r.endVector();me.startBuffersVector(r,n.length);for(let a of n.slice().reverse())ce.encode(r,a);let s=r.endVector();return me.startRecordBatch(r),me.addLength(r,BigInt(t.length)),me.addNodes(r,i),me.addBuffers(r,s),me.endRecordBatch(r)}function Ey(r,t){let e=Qt.encode(r,t.data);return _r.startDictionaryBatch(r),_r.addId(r,BigInt(t.id)),_r.addIsDelta(r,t.isDelta),_r.addData(r,e),_r.endDictionaryBatch(r)}function Oy(r,t){return Wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Uy(r,t){return Vn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var My=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Rl=r=>"Expected ".concat(ct[r]," Message in stream, but was null or length 0."),Ll=r=>"Header pointer of flatbuffer-encoded ".concat(ct[r]," Message is null or length 0."),Cd=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),Pd=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),oi=class{constructor(t){this.source=t instanceof cr?t:new cr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Lt:t.value===-1&&(t=this.readMetadataLength()).done?Lt:(t=this.readMetadata(t.value)).done?Lt: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(Rl(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=J(this.source.read(t));if(e.byteLength<t)throw new Error(Pd(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=ct.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(Ll(e));return i}readMetadataLength(){let t=this.source.read(ea),e=t&&new pe(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 Lt;if(e.byteLength<t)throw new Error(Cd(t,e.byteLength));return{done:!1,value:de.decode(e)}}},bs=class{constructor(t,e){this.source=t instanceof Fe?t:Ms(t)?new ln(t,e):new Fe(t)}[Symbol.asyncIterator](){return this}next(){return R(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?Lt:t.value===-1&&(t=yield this.readMetadataLength()).done?Lt:(t=yield this.readMetadata(t.value)).done?Lt: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(Rl(t));return e.value})}readMessageBody(t){return R(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=J(yield this.source.read(t));if(e.byteLength<t)throw new Error(Pd(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=ct.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(Ll(e));return i})}readMetadataLength(){return R(this,void 0,void 0,function*(){let t=yield this.source.read(ea),e=t&&new pe(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 Lt;if(e.byteLength<t)throw new Error(Cd(t,e.byteLength));return{done:!1,value:de.decode(e)}})}},gs=class extends oi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ji?t:new ji(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:de.fromJSON(t.schema,ct.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,ct.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:de.fromJSON(e,ct.RecordBatch)}}return this._body=[],Lt}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(Rl(t));return e.value}readSchema(){let t=ct.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(Ll(t));return n}},ea=4,Ml="ARROW1",ai=new Uint8Array(Ml.length);for(let r=0;r<Ml.length;r+=1)ai[r]=Ml.codePointAt(r);function ra(r,t=0){for(let e=-1,n=ai.length;++e<n;)if(ai[e]!==r[t+e])return!1;return!0}var li=ai.length,Nl=li+ea,Hd=li*2+ea;var te=class r extends Fn{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:Os(t)?Ly(t):Ms(t)?Cy(t):Ue(t)?R(this,void 0,void 0,function*(){return yield r.from(yield t)}):Rs(t)||Ii(t)||Ns(t)||we(t)?ky(new Fe(t)):Ny(new cr(t))}static readAll(t){return t instanceof r?t.isSync()?Vd(t):Wd(t):Os(t)||ArrayBuffer.isView(t)||Me(t)||Us(t)?Vd(t):Wd(t)}},dr=class extends te{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return fe(this,arguments,function*(){yield it(yield*mn(Pn(Oe(this[Symbol.iterator]()))))})}},cn=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 a=!0,l=Oe(this),u;u=yield l.next(),t=u.done,!t;a=!0){i=u.value,a=!1;let f=i;s.push(f)}}catch(f){e={error:f}}finally{try{!a&&!t&&(n=l.return)&&(yield n.call(l))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},un=class extends dr{constructor(t){super(t),this._impl=t}},ws=class extends cn{constructor(t){super(t),this._impl=t}},na=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=et({type:new Rt(this.schema.fields),length:t.length,children:n});return new zt(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:a}=this,l=s.get(n),u=a.dictionaries.get(n),f=this._loadVectors(t.data,e,[u]);return(l&&i?l.concat(new dt(f)):new dt(f)).memoize()}_loadVectors(t,e,n){return new qi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},ci=class extends na{constructor(t,e){super(e),this._reader=Os(t)?new gs(this._handle=t):new oi(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=zd(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):Lt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Lt}next(){if(this.closed)return Lt;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 On(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ui=class extends na{constructor(t,e){super(e),this._reader=new bs(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=zd(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):Lt})}return(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Lt})}next(){return R(this,void 0,void 0,function*(){if(this.closed)return Lt;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 On(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return R(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},ia=class extends ci{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 $i?t:new $i(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(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}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(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength),l=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,l)}}}_readFooter(){let{_handle:t}=this,e=t.size-Nl,n=t.readInt32(e),i=t.readAt(e-n,n);return Mr.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}},kl=class extends ui{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 ln?t:new ln(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(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}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(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),l=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,l)}}})}_readFooter(){return R(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Nl,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Mr.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})}},Cl=class extends ci{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new xo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function zd(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Vd(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 Wd(r){return fe(this,arguments,function*(){let e=yield it(te.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 Ly(r){return new dr(new Cl(r))}function Ny(r){let t=r.peek(li+7&-8);return t&&t.byteLength>=4?ra(t)?new un(new ia(r.read())):new dr(new ci(r)):new dr(new ci(function*(){}()))}function ky(r){return R(this,void 0,void 0,function*(){let t=yield r.peek(li+7&-8);return t&&t.byteLength>=4?ra(t)?new un(new ia(yield r.read())):new cn(new ui(r)):new cn(new ui(function(){return fe(this,arguments,function*(){})}()))})}function Cy(r){return R(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new ln(r,t);return t>=Hd&&ra(yield e.readAt(0,li+7&-8))?new ws(new kl(e)):new cn(new ui(e))})}var kt=class r extends z{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof zt?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(!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 De(n,0));else{let{nullCount:i}=t;L.isNull(e)||Ke.call(this,i<=0?new Uint8Array(0):wn(t.offset,n,t.nullBitmap)),this.nodes.push(new De(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 Ke(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new ce(this._byteLength,t)),this._byteLength+=t,this}function Py(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ke.call(this,i),e.mode===xt.Sparse)return Pl.call(this,r);if(e.mode===xt.Dense){if(r.offset<=0)return Ke.call(this,s),Pl.call(this,r);{let a=new Int32Array(n),l=Object.create(null),u=Object.create(null);for(let f,h,w=-1;++w<n;)(f=i[w])!==void 0&&((h=l[f])===void 0&&(h=l[f]=s[w]),a[w]=s[w]-h,u[f]=((t=u[f])!==null&&t!==void 0?t:0)+1);Ke.call(this,a),this.visitMany(r.children.map((f,h)=>{let w=e.typeIds[h],A=l[w],E=u[w];return f.slice(A,Math.min(n,E))}))}}return this}function Hy(r){let t;return r.nullCount>=r.length?Ke.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ke.call(this,wn(r.offset,r.length,t)):Ke.call(this,vn(r.values))}function Vr(r){return Ke.call(this,r.values.subarray(0,r.length*r.stride))}function sa(r){let{length:t,values:e,valueOffsets:n}=r,i=pt(n[0]),s=pt(n[t]),a=Math.min(s-i,e.byteLength-i);return Ke.call(this,Cs(-i,t+1,n)),Ke.call(this,e.subarray(i,i+a)),this}function Hl(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ke.call(this,Cs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Pl(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}kt.prototype.visitBool=Hy;kt.prototype.visitInt=Vr;kt.prototype.visitFloat=Vr;kt.prototype.visitUtf8=sa;kt.prototype.visitLargeUtf8=sa;kt.prototype.visitBinary=sa;kt.prototype.visitLargeBinary=sa;kt.prototype.visitFixedSizeBinary=Vr;kt.prototype.visitDate=Vr;kt.prototype.visitTimestamp=Vr;kt.prototype.visitTime=Vr;kt.prototype.visitDecimal=Vr;kt.prototype.visitList=Hl;kt.prototype.visitStruct=Pl;kt.prototype.visitUnion=Py;kt.prototype.visitInterval=Vr;kt.prototype.visitDuration=Vr;kt.prototype.visitFixedSizeList=Hl;kt.prototype.visitMap=Hl;var Un=class extends Fn{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 lr,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)):we(t)?Wl(this,t):Vl(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 lr?this._sink=t:(this._sink=new lr,t&&su(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&ou(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||!En(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 zt&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!En(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof zt?t instanceof On||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,a=this._writeLegacyIpcFormat?4:8,l=s+a+n&~n,u=l-s-a;return t.headerType===ct.RecordBatch?this._recordBatchBlocks.push(new Rr(l,t.bodyLength,this._position)):t.headerType===ct.DictionaryBatch&&this._dictionaryBlocks.push(new Rr(l,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(l-a)),s>0&&this._write(i),this._writePadding(u)}_write(t){if(this._started){let e=J(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(ai)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=kt.assemble(t),a=new Qt(t.numRows,n,i),l=de.from(a,e);return this._writeDictionaries(t)._writeMessage(l)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:a,buffers:l}=kt.assemble(new dt([t])),u=new Qt(t.length,s,a),f=new ue(u,e,n),h=de.from(f,i);return this._writeMessage(h)._writeBodyBuffers(l)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,a=t.length;++s<a;)(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 a=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],l=this._seenDictionaries.get(i),u=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!l||l.data[0]!==a[0])for(let[f,h]of a.entries())this._writeDictionaryBatch(h,i,f>0);else if(u<a.length)for(let f of a.slice(u))this._writeDictionaryBatch(f,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}},Mn=class r extends Un{static writeAll(t,e){let n=new r(e);return Ue(t)?t.then(i=>n.writeAll(i)):we(t)?Wl(n,t):Vl(n,t)}},Rn=class r extends Un{static writeAll(t){let e=new r;return Ue(t)?t.then(n=>e.writeAll(n)):we(t)?Wl(e,t):Vl(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=Mr.encode(new Mr(t,vt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Vl(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 Wl(r,t){return R(this,void 0,void 0,function*(){var e,n,i,s,a,l,u;try{for(e=!0,n=Oe(t);i=yield n.next(),s=i.done,!s;e=!0){u=i.value,e=!1;let f=u;r.write(f)}}catch(f){a={error:f}}finally{try{!e&&!s&&(l=n.return)&&(yield l.call(n))}finally{if(a)throw a.error}}return r.finish()})}function jd(r,t){if(we(r))return Wy(r,t);if(Me(r))return Vy(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Vy(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(a){s(a,e||(e=r[Symbol.iterator]()))},pull(a){e?s(a,e):a.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(a,l){let u,f=null,h=a.desiredSize||null;for(;!(f=l.next(n?h:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=J(f.value))&&(h!=null&&n&&(h=h-u.byteLength+1),f.value=u),a.enqueue(f.value),h!=null&&--h<=0)return;a.close()}}function Wy(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(a){return R(this,void 0,void 0,function*(){yield s(a,e||(e=r[Symbol.asyncIterator]()))})},pull(a){return R(this,void 0,void 0,function*(){e?yield s(a,e):a.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(a,l){return R(this,void 0,void 0,function*(){let u,f=null,h=a.desiredSize||null;for(;!(f=yield l.next(n?h:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=J(f.value))&&(h!=null&&n&&(h=h-u.byteLength+1),f.value=u),a.enqueue(f.value),h!=null&&--h<=0)return;a.close()})}}function Kd(r){return new zl(r)}var zl=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=nu(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Dn(s),this._getSize=i!=="bytes"?$d:Gd;let{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:l=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:u=>{this._maybeFlush(this._builder,this._controller=u)},start:u=>{this._maybeFlush(this._builder,this._controller=u)}},{highWaterMark:a,size:i!=="bytes"?$d:Gd}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:l,size:u=>this._writeValueAndReturnChunkSize(u)})}_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)}},$d=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Gd=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function oa(r,t){let e=new lr,n=null,i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield e.close()})},start(l){return R(this,void 0,void 0,function*(){yield a(l,n||(n=yield s()))})},pull(l){return R(this,void 0,void 0,function*(){n?yield a(l,n):l.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 a(l,u){return R(this,void 0,void 0,function*(){let f=l.desiredSize,h=null;for(;!(h=yield u.next()).done;)if(l.enqueue(h.value),f!=null&&--f<=0)return;l.close()})}}function aa(r,t){let e=new this(r),n=new Fe(e),i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield n.cancel()})},pull(a){return R(this,void 0,void 0,function*(){yield s(a)})},start(a){return R(this,void 0,void 0,function*(){yield s(a)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(a){return R(this,void 0,void 0,function*(){let l=null,u=a.desiredSize;for(;l=yield n.read(u||null);)if(a.enqueue(l),u!=null&&(u-=l.byteLength)<=0)return;a.close()})}}function la(r,t="stream"){return(t==="stream"?Mn:Rn).writeAll(r).toUint8Array(!0)}var Gy=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},el),Dl),yl),rl),qa),_l),Xa),{compareSchemas:En,compareFields:vd,compareTypes:Sd});Xt.toDOMStream=jd;Nt.throughDOM=Kd;te.throughDOM=oa;un.throughDOM=oa;dr.throughDOM=oa;Un.throughDOM=aa;Rn.throughDOM=aa;Mn.throughDOM=aa;function di(r){switch(r.typeId){case p.Binary:return{sqlType:"binary"};case p.Bool:return{sqlType:"bool"};case p.Date:return{sqlType:"date"};case p.DateDay:return{sqlType:"date32[d]"};case p.DateMillisecond:return{sqlType:"date64[ms]"};case p.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case p.Float:return{sqlType:"float"};case p.Float16:return{sqlType:"float16"};case p.Float32:return{sqlType:"float32"};case p.Float64:return{sqlType:"float64"};case p.Int:return{sqlType:"int32"};case p.Int16:return{sqlType:"int16"};case p.Int32:return{sqlType:"int32"};case p.Int64:return{sqlType:"int64"};case p.Uint16:return{sqlType:"uint16"};case p.Uint32:return{sqlType:"uint32"};case p.Uint64:return{sqlType:"uint64"};case p.Uint8:return{sqlType:"uint8"};case p.IntervalDayTime:return{sqlType:"interval[dt]"};case p.IntervalYearMonth:return{sqlType:"interval[m]"};case p.List:return{sqlType:"list",valueType:di(r.valueType)};case p.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case p.Null:return{sqlType:"null"};case p.Utf8:return{sqlType:"utf8"};case p.Struct:return{sqlType:"struct",fields:r.children.map(e=>ca(e.name,e.type))};case p.Map:{let t=r;return{sqlType:"map",keyType:di(t.keyType),valueType:di(t.valueType)}}case p.Time:return{sqlType:"time[s]"};case p.TimeMicrosecond:return{sqlType:"time[us]"};case p.TimeMillisecond:return{sqlType:"time[ms]"};case p.TimeNanosecond:return{sqlType:"time[ns]"};case p.TimeSecond:return{sqlType:"time[s]"};case p.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case p.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case p.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case p.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case p.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function ca(r,t){let e=di(t);return e.name=r,e}var ua=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((a,l)=>{try{a(this._bindings.pollPendingQuery(this._conn))}catch(u){console.log(u),u.message.includes("worker is not set!")?l(new Error("Worker has been terminated")):l(u)}});let i=new da(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 jl(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=la(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)}},da=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}},jl=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 da(this.bindings,this.connectionId,e),i=te.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function Yd(r){return r<=255}function Jd(r){return r===256}var Qd=new TextEncoder,Xd=new TextDecoder("utf-8");function $l(r,t,e){let n=Qd.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 Kl(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 Gl(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*Kl(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 Zd(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function fa(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function tf(r,t,e,n,i,s,a,l){try{let u=r._udfFunctions.get(n);if(!u){$l(t,e,"Unknown UDF with id: "+n);return}let f=Xd.decode(t.HEAPU8.subarray(i,i+s)),h=JSON.parse(f),w=fa(t,a,l/8),A=I=>{var B;let O=null;switch(I.validityBuffer!==void 0&&(O=Zd(t,w[I.validityBuffer],h.rows)),I.physicalType){case"VARCHAR":{if(I.dataBuffer===null||I.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(I.lengthBuffer===null||I.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let N=Gl(t,w[I.dataBuffer],I.physicalType,h.rows),F=[],H=fa(t,w[I.lengthBuffer],h.rows);for(let W=0;W<h.rows;++W){if(O!=null&&!O[W]){F.push(null);continue}let At=t.HEAPU8.subarray(N[W],N[W]+H[W]),Ut=Xd.decode(At);F.push(Ut)}return W=>F[W]}case"STRUCT":{let N={},F=[];for(let H=0;H<(((B=I.children)==null?void 0:B.length)||0);++H){let W=I.children[H],At=A(W);F.push(Ut=>{N[W.name]=At(Ut)})}return O!=null?H=>{if(!O[H])return null;for(let W of F)W(H);return N}:H=>{for(let W of F)W(H);return N}}default:{if(I.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+I.physicalType);let N=Gl(t,w[I.dataBuffer],I.physicalType,h.rows);return O!=null?F=>O[F]?N[F]:null:F=>N[F]}}},E=[];for(let I=0;I<h.args.length;++I)E.push(A(h.args[I]));let at=h.rows*Kl(h.ret.physicalType),wt=t._malloc(at),Vt=Gl(t,wt,h.ret.physicalType,h.rows),mt=t._malloc(h.rows),Ot=Zd(t,mt,h.rows);if(Vt.length==0||Ot.length==0){$l(t,e,"Can't create physical arrays for result");return}let yt=Vt;h.ret.physicalType=="VARCHAR"&&(yt=new Array(h.rows));let Gt=[];for(let I=0;I<h.args.length;++I)Gt.push(null);for(let I=0;I<h.rows;++I){for(let B=0;B<h.args.length;++B)Gt[B]=E[B](I);let O=u.func(...Gt);yt[I]=O,Ot[I]=O==null?0:1}let Ct=0;switch(h.ret.physicalType){case"VARCHAR":{let I=new Array(0);Ct=t._malloc(h.rows*Kl("DOUBLE"));let O=fa(t,Ct,h.rows),B=0;for(let W=0;W<h.rows;++W){let At=Qd.encode(yt[W]||"");I.push(At),O[W]=At.length,B+=At.length}let N=t._malloc(B),F=t.HEAPU8.subarray(N,N+B),H=0;for(let W=0;W<h.rows;++W){Vt[W]=H;let At=I[W];F.subarray(H,H+At.length).set(At),H+=At.length}}}let S=3*8,U=t._malloc(S),V=fa(t,U,3);V[0]=wt,V[1]=mt,V[2]=Ct,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=U,t.HEAPF64[(e>>3)+2]=0}catch(u){$l(t,e,u.toString())}}function qy(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var Yy=qy();function qe(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Ln(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 nt(r,t,e){return Yy(new Uint8Array(r.HEAPU8.buffer,t>>>0,e))}function Ft(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 a=r.HEAPF64[(s>>3)+0],l=r.HEAPF64[(s>>3)+1],u=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[a,l,u]}function Mt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var ha=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 fi=new TextEncoder;var pa=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]=Ft(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(nt(this.mod,n,i));Mt(this.mod)}reset(){let[t,e,n]=Ft(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(nt(this.mod,e,n));Mt(this.mod)}getVersion(){let[t,e,n]=Ft(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(nt(this.mod,e,n));let i=nt(this.mod,e,n);return Mt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=fi.encode(t),n=this.mod._malloc(e.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,n,e.length).set(e);let[s,a,l]=Ft(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(nt(this.mod,a,l));let u=nt(this.mod,a,l);return Mt(this.mod),JSON.parse(u)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new ua(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=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Ft(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(nt(this.mod,l,u));let f=Ln(this.mod,l,u);return Mt(this.mod),f}startPendingQuery(t,e,n=!1){let i=fi.encode(e),s=this.mod._malloc(i.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,s,i.length).set(i);let[l,u,f]=Ft(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[t,s,i.length,n]);if(this.mod._free(s),l!==0)throw new Error(nt(this.mod,u,f));if(u==0)return null;let h=Ln(this.mod,u,f);return Mt(this.mod),h}pollPendingQuery(t){let[e,n,i]=Ft(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(nt(this.mod,n,i));if(n==0)return null;let s=Ln(this.mod,n,i);return Mt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=Ft(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(Jd(e))return Mt(this.mod),null;if(!Yd(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+nt(this.mod,n,i));if(e!==0)throw new Error(nt(this.mod,n,i));let s=Ln(this.mod,n,i);return Mt(this.mod),s}getTableNames(t,e){let n=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Ft(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(nt(this.mod,l,u));let f=nt(this.mod,l,u);return Mt(this.mod),JSON.parse(f)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:di(n)},a={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[l,u,f]=Ft(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(l!==0)throw new Error(nt(this.mod,u,f));if(Mt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(a.functionId,a),this.pthread)for(let h of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])h.postMessage({cmd:"registerUDFFunction",udf:a})}createPrepared(t,e){let n=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Ft(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(nt(this.mod,l,u));return Mt(this.mod),l}closePrepared(t,e){let[n,i,s]=Ft(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(nt(this.mod,i,s));Mt(this.mod)}runPrepared(t,e,n){let[i,s,a]=Ft(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(nt(this.mod,s,a));let l=Ln(this.mod,s,a);return Mt(this.mod),l}sendPrepared(t,e,n){let[i,s,a]=Ft(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(nt(this.mod,s,a));let l=Ln(this.mod,s,a);return Mt(this.mod),l}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 a=n?JSON.stringify(n):"",[l,u,f]=Ft(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,a]);if(this.mod._free(i),l!==0)throw new Error(nt(this.mod,u,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(ca(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,l,u]=Ft(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(nt(this.mod,l,u))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(ca(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,l,u]=Ft(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(nt(this.mod,l,u))}globFiles(t){let[e,n,i]=Ft(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(nt(this.mod,n,i));let s=nt(this.mod,n,i);Mt(this.mod);let a=JSON.parse(s);return a==null?[]:a}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,a,l]=Ft(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(nt(this.mod,a,l));Mt(this.mod)}registerFileText(t,e){let n=fi.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,a,l]=Ft(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(nt(this.mod,a,l));Mt(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:a,fromCached:l}=i;!l&&await this.registerFileHandleAsync(a,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:a,fromCached:l}=i;!l&&await this.registerFileHandleAsync(a,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(a){throw new Error(a.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 u;let[s,a,l]=Ft(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(nt(this.mod,a,l));/*PATCH_C1*/if(t.startsWith("opfs://")){let _alt="opfs:/"+t.slice(7);Ft(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[_alt,_alt,n,i])}if(Mt(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),(u=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&u[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]=Ft(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(nt(this.mod,n,i));Mt(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let l of t!=null?t:[])if(l!=null&&l.length>0){let u=this.mod.lengthBytesUTF8(l)+1,f=this.mod._malloc(u);if(!f)throw new Error("Failed to allocate memory for string: ".concat(l));this.mod.stringToUTF8(l,f,u),e.push(f)}if(n=this.mod._malloc(e.length*4),!n)throw new Error("Failed to allocate memory for pointers array");for(let l=0;l<e.length;l++)this.mod.HEAP32[(n>>2)+l]=e[l];let[i,s,a]=Ft(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(nt(this.mod,s,a));Mt(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]=Ft(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(nt(this.mod,i,s));Mt(this.mod)}copyFileToBuffer(t){let[e,n,i]=Ft(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(nt(this.mod,n,i));let s=new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i),a=new Uint8Array(s.length);return a.set(s),Mt(this.mod),a}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]=Ft(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(nt(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=Ft(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(nt(this.mod,n,i));return new ha(new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i))}};var ma=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 ff=eu(df());var ba=class extends pa{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 at;let a=new Request(this.mainModuleURL),l=await fetch(a),u=l.headers.get("content-length"),f=u&&parseInt(u,10)||0,h=new Date,w={startedAt:h,updatedAt:h,bytesTotal:f||0,bytesLoaded:0},A={transform(wt,Vt){w.bytesLoaded+=wt.byteLength;let mt=new Date;if(mt.getTime()-w.updatedAt.getTime()<20){w.updatedAt=mt,Vt.enqueue(wt);return}for(let Ot of n)Ot(w);Vt.enqueue(wt)}},E=new TransformStream(A);return new Response((at=l.body)==null?void 0:at.pipeThrough(E),l)})();WebAssembly.instantiateStreaming(s,t).then(a=>{e(a.instance,a.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,a=new Date,l={startedAt:a,updatedAt:a,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+u}),new Error(u.toString())},i.onprogress=u=>{l.bytesTotal=u.total,l.bytesLoaded=u.loaded;let f=new Date;if(f.getTime()-l.updatedAt.getTime()<20){l.updatedAt=f;return}for(let h of n)h(l)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(u=>{e(u.instance,u.module)}).catch(u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+u}),new Error(u)})},i.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let s=new Request(this.mainModuleURL),l=await(await fetch(s)).arrayBuffer();WebAssembly.instantiate(l,t).then(u=>{e(u.instance,u.module)})})();return[]}};var ga=class extends ba{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){let e={...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)};return this.pthreadWorkerURL&&(e.mainScriptUrlOrBlob=this.pthreadWorkerURL),(0,ff.default)(e)}};var dn=eu(mf()),_f=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 Zy(r,t,e){var s,a,l,u;let n=yf(t),i=n.path;if(bf(r)){let f="";if(r!=null&&r.endpoint){let h=new URL(r.endpoint);h.pathname!=="/"&&(f=h.pathname)}i="".concat(f,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:_f(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(a=r==null?void 0:r.accessKeyId)!=null?a:"",secretAccessKey:(l=r==null?void 0:r.secretAccessKey)!=null?l:"",sessionToken:(u=r==null?void 0:r.sessionToken)!=null?u:"",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 tb(r,t=null){var at;let e=(at=t==null?void 0:t.contentHash)!=null?at:"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 a=(0,dn.sha256)(s),l="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+a,u="AWS4"+r.secretAccessKey,f=dn.sha256.hmac.arrayBuffer(u,r.dateNow),h=dn.sha256.hmac.arrayBuffer(f,r.region),w=dn.sha256.hmac.arrayBuffer(h,r.service),A=dn.sha256.hmac.arrayBuffer(w,"aws4_request"),E=dn.sha256.hmac(A,l);return n.set("Authorization","AWS4-HMAC-SHA256 Credential="+r.accessKeyId+"/"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request, SignedHeaders="+i+", Signature="+E),n}var eb=function(r,t,e,n=null,i=null){let s=Zy(r,t,e),a={contentType:n,contentHash:i?dn.sha256.hex(i):null};return tb(s,a)};function Ye(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(eb(t,e,n,i,s).forEach((l,u)=>{r.setRequestHeader(u,l)}),i&&r.setRequestHeader("content-type",i))}function yf(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 bf(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function Je(r,t){let e=yf(t);return bf(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+_f(r,t,e.bucket)+e.path}var rb=7,gf=/\/|\\/,Q={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=Q._fileInfoCache.get(t),[n,i,s]=Ft(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 a=nt(r,i,s);Mt(r);try{let l=JSON.parse(a);if(l==null)return null;let u={...l,blob:null};return Q._fileInfoCache.set(t,u),!Q._files.has(u.fileName)&&(Q._preparedHandles[u.fileName]?(Q._files.set(u.fileName,Q._preparedHandles[u.fileName]),delete Q._preparedHandles[u.fileName]):u.fileName.startsWith("opfs:/")&&!u.fileName.startsWith("opfs://")&&Q._preparedHandles["opfs://"+u.fileName.slice(6)]&&(Q._files.set(u.fileName,Q._preparedHandles["opfs://"+u.fileName.slice(6)]),delete Q._preparedHandles["opfs://"+u.fileName.slice(6)])),u}catch(l){return console.warn(l),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=Ft(r,"duckdb_web_get_global_file_info",["number"],[((t=Q._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return Q._globalFileInfo;let s=nt(r,n,i);Mt(r);let a=JSON.parse(s);return a==null?null:(Q._globalFileInfo={...a,blob:null},Q._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){Q._opfsRoot||(Q._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await Q.assignOPFSRoot();let e=async i=>{if(Q._files.has(i))return{path:i,handle:Q._files.get(i),fromCached:!0};let a=Q._opfsRoot,l=i.slice(rb),u=l;if(gf.test(l)){let h=l.split(gf);if(h.length===0)throw new Error("Invalid path ".concat(l));if(u=h[h.length-1],!u)throw new Error("Invalid path ".concat(l,". File Not Found."));h.pop();for(let w of h)a=await a.getDirectoryHandle(w,{create:!0})}let f=await a.getFileHandle(u,{create:!1}).catch(h=>{if((h==null?void 0:h.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),a.getFileHandle(u,{create:!0});throw h});try{let h=await f.createSyncAccessHandle();return Q._preparedHandles[i]=h,/*PATCH_A*/i.startsWith("opfs://")&&(Q._preparedHandles["opfs:/"+i.slice(7)]=h),{path:i,handle:h,fromCached:!1}}catch(h){throw new Error(h.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,a,l,u;try{Q._fileInfoCache.delete(t);let f=Q.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),Ye(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),at=new Uint8Array;r.HEAPU8.set(at,E);let wt=r._malloc(3*8);return r.HEAPF64[(wt>>3)+0]=1,r.HEAPF64[(wt>>3)+1]=E,r.HEAPF64[(wt>>3)+2]=new Date().getTime()/1e3,wt}else if(!(e&1))throw new Error("Opening file ".concat(f.fileName," failed: unsupported file flags: ").concat(e));let h=null,w=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),Ye(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.setRequestHeader("Range","bytes=0-"),A.send(null),h=null;try{h=A.getResponseHeader("Content-Length")}catch(E){console.warn("Failed to get Content-Length on request")}if(h!==null&&A.status==206){let E=r._malloc(24);r.HEAPF64[(E>>3)+0]=+h,r.HEAPF64[(E>>3)+1]=0;let at=0;try{at=new Date((n=A.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(wt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(E>>3)+2]=+at,E}}catch(A){w=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),Ye(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 at=null;try{at=E.getResponseHeader("Content-Length")}catch(Ot){console.warn("Failed to get Content-Length on request")}let wt=at==null?void 0:at.split("/")[1],Vt=at,mt=null;if(wt!==void 0)mt=wt;else if(!f.reliableHeadRequests){let Ot=new XMLHttpRequest;f.dataProtocol==5?(Ot.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ye(Ot,f.s3Config,f.dataUrl,"HEAD")):Ot.open("HEAD",f.dataUrl,!1),Ot.setRequestHeader("Range","bytes=0-"),Ot.send(null),h=null;try{h=Ot.getResponseHeader("Content-Length")}catch(yt){console.warn("Failed to get Content-Length on request")}h!==null&&+h>1&&(mt=h)}if(E.status==206&&Vt!==null&&+Vt==1&&mt!==null){let Ot=r._malloc(24);r.HEAPF64[(Ot>>3)+0]=+mt,r.HEAPF64[(Ot>>3)+1]=0;let yt=0;try{yt=new Date((i=E.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(Gt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Ot>>3)+2]=+yt,Ot}if(E.status==200&&Vt!==null&&h!==null&&+Vt==+h){console.warn("fall back to full HTTP read for: ".concat(f.dataUrl));let Ot=r._malloc(E.response.byteLength),yt=new Uint8Array(E.response,0,E.response.byteLength);r.HEAPU8.set(yt,Ot);let Gt=r._malloc(3*8);r.HEAPF64[(Gt>>3)+0]=E.response.byteLength,r.HEAPF64[(Gt>>3)+1]=Ot;let Ct=0;try{Ct=new Date((s=E.getResponseHeader("Last-Modified"))!=null?s:"").getTime()/1e3}catch(S){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Gt>>3)+2]=+Ct,Gt}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),Ye(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),at=new Uint8Array(A.response,0,A.response.byteLength);r.HEAPU8.set(at,E);let wt=r._malloc(3*8);r.HEAPF64[(wt>>3)+0]=A.response.byteLength,r.HEAPF64[(wt>>3)+1]=E;let Vt=0;try{Vt=new Date((a=A.getResponseHeader("Last-Modified"))!=null?a:"").getTime()/1e3}catch(mt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(wt>>3)+2]=+Vt,wt}}if(w!=null)throw new Error("Reading file ".concat(f.fileName," failed with error: ").concat(w));return 0}case 2:{let h=(l=Q._files)==null?void 0:l.get(f.fileName);if(h){let E=r._malloc(24);return r.HEAPF64[(E>>3)+0]=h.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 w=r._malloc(3*8),A=r._malloc(1);return r.HEAPF64[(w>>3)+0]=1,r.HEAPF64[(w>>3)+1]=A,r.HEAPF64[(w>>3)+2]=0,w}case 3:{let h=(u=Q._files)==null?void 0:u.get(f.fileName);if(!h)throw new Error("No OPFS access handle registered with name: ".concat(f.fileName));e&16&&h.truncate(0);let w=r._malloc(3*8),A=h.getSize();return r.HEAPF64[(w>>3)+0]=A,r.HEAPF64[(w>>3)+1]=0,r.HEAPF64[(w>>3)+2]=0,w}}}catch(f){console.error(f.toString()),qe(r,f.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=nt(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let a=Q.getGlobalFileInfo(r);s.open("HEAD",Je(a==null?void 0:a.s3Config,i),!1),Ye(s,a==null?void 0:a.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=Q.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let a=new XMLHttpRequest;if(i.startsWith("s3://")){let u=Q.getGlobalFileInfo(r);a.open("GET",Je(u==null?void 0:u.s3Config,i),!1),Ye(a,u==null?void 0:u.s3Config,i,"HEAD")}else a.open("GET",i,!1);if(a.setRequestHeader("Range","bytes=0-0"),a.send(null),a.status!=200&&a.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let l=null;try{l=a.getResponseHeader("Content-Length")}catch(u){console.warn("Failed to get Content-Length on request")}l&&+l>1&&console.warn("Range request for ".concat(i," did not return a partial response: ").concat(a.status,' "').concat(a.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of Q._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=nt(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=Q.getGlobalFileInfo(r);i.open("HEAD",Je(s==null?void 0:s.s3Config,n),!1),Ye(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 Q._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=Q.getFileInfo(r,t);Q._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=Q._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=nt(r,t,e),i=(s=Q._files)==null?void 0:s.get(n);if(i){if(Q._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(a){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=Q.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=Q._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 a=Q.getFileInfo(r,t);switch(a==null?void 0:a.dataProtocol){case 4:case 5:{if(!a.dataUrl)throw new Error("Missing data URL for file ".concat(t));try{let l=new XMLHttpRequest;if(a.dataProtocol==5?(l.open("GET",Je(a==null?void 0:a.s3Config,a.dataUrl),!1),Ye(l,a==null?void 0:a.s3Config,a.dataUrl,"GET")):l.open("GET",a.dataUrl,!1),l.responseType="arraybuffer",l.setRequestHeader("Range","bytes=".concat(i,"-").concat(i+n-1)),l.send(null),l.status==206||l.status==200&&n==l.response.byteLength&&i==0){let u=new Uint8Array(l.response,0,Math.min(l.response.byteLength,n));return r.HEAPU8.set(u,e),u.byteLength}else if(l.status==200){console.warn("Range request for ".concat(a.dataUrl," did not return a partial response: ").concat(l.status,' "').concat(l.statusText,'"'));let u=new Uint8Array(l.response,i,Math.min(l.response.byteLength-i,n));return r.HEAPU8.set(u,e),u.byteLength}else throw new Error("Range request for ".concat(a.dataUrl," did returned non-success status: ").concat(l.status,' "').concat(l.statusText,'"'))}catch(l){throw console.log(l),new Error("Range request for ".concat(a.dataUrl," failed with error: ").concat(l,'"'))}}case 2:{let l=(s=Q._files)==null?void 0:s.get(a.fileName);if(!l)throw new Error("No HTML5 file registered with name: ".concat(a.fileName));let u=l.slice(i,i+n),f=new Uint8Array(new FileReaderSync().readAsArrayBuffer(u));return r.HEAPU8.set(f,e),f.byteLength}case 3:{let l=Q._files.get(a.fileName);if(!l)throw new Error("No OPFS access handle registered with name: ".concat(a.fileName));let u=r.HEAPU8.subarray(e,e+n);return l.read(u,{at:i})}}return 0}catch(a){return console.log(a),qe(r,a.toString()),0}},writeFile:(r,t,e,n,i)=>{var a;let s=Q.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return qe(r,"Cannot write to HTTP file"),0;case 5:{let l=r.HEAPU8.subarray(e,e+n),u=new XMLHttpRequest;return u.open("PUT",Je(s==null?void 0:s.s3Config,s.dataUrl),!1),Ye(u,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",l),u.send(l),u.status!==200?(qe(r,"Failed writing file: HTTP "+u.status),0):n}case 2:return qe(r,"cannot write using the html5 file reader api"),0;case 3:{let l=(a=Q._files)==null?void 0:a.get(s.fileName);if(!l)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let u=r.HEAPU8.subarray(e,e+n);return l.write(u,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=Q.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=Q._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=nt(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=nt(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=nt(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=nt(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var u,f;let s=nt(r,t,e),a=nt(r,n,i),l=(u=Q._files)==null?void 0:u.get(s);l!==void 0&&(Q._files.delete(l),Q._files.set(a,l));for(let[h,w]of((f=Q._fileInfoCache)==null?void 0:f.entries())||[])if(w.dataUrl==s){Q._fileInfoCache.delete(h);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,a)=>{tf(Q,r,t,e,n,i,s,a)}};var Yl=class extends ma{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new ga(this,Q,t,e).instantiate(n)}};function wf(){let r=new Yl;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}wf();return Dm(nb);})();
|
|
1
|
+
"use strict";var duckdb=(()=>{var wm=Object.create;var vi=Object.defineProperty;var vm=Object.getOwnPropertyDescriptor;var Sm=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,Fm=Object.prototype.hasOwnProperty;var Va=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var Bm=(r,t,e)=>t in r?vi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Wa=(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 Kr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),qr=(r,t)=>{for(var e in t)vi(r,e,{get:t[e],enumerable:!0})},tu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sm(t))!Fm.call(r,i)&&i!==e&&vi(r,i,{get:()=>t[i],enumerable:!(n=vm(t,i))||n.enumerable});return r};var eu=(r,t,e)=>(e=r!=null?wm(Im(r)):{},tu(t||!r||!r.__esModule?vi(e,"default",{value:r,enumerable:!0}):e,r)),Dm=r=>tu(vi({},"__esModule",{value:!0}),r);var Es=(r,t,e)=>(Bm(r,typeof t!="symbol"?t+"":t,e),e);var Am=function(r,t){this[0]=r,this[1]=t};var mn=r=>{var t=r[Va("asyncIterator")],e=!1,n,i={};return t==null?(t=r[Va("iterator")](),n=s=>i[s]=a=>t[s](a)):(t=t.call(r),n=s=>i[s]=a=>{if(e){if(e=!1,s==="throw")throw a;return a}return e=!0,{done:!1,value:new Am(new Promise(l=>{var u=t[s](a);if(!(u instanceof Object))throw TypeError("Object expected");l(u)}),1)}}),i[Va("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var ql=Kr(()=>{});var ef=Kr(()=>{});var rf=Kr(()=>{});var nf=Kr(()=>{});var df=Kr((uf,ya)=>{"use strict";var _a=(()=>{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 Zc;var n,i=e,s,a,l=new Promise((o,c)=>{s=o,a=c}),u=typeof window=="object",f=typeof WorkerGlobalScope<"u",h=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",v=f&&((Zc=self.name)==null?void 0:Zc.startsWith("em-pthread"));if(h){var A=ql();global.Worker=A.Worker,f=!A.isMainThread,v=f&&A.workerData=="em-pthread"}var E=Object.assign({},i),at=[],vt="./this.program",Vt=(o,c)=>{throw c},mt="";function Ut(o){return i.locateFile?i.locateFile(o,mt):mt+o}var bt,Gt;if(h){var Ct=ef(),I=rf();mt=__dirname+"/",Gt=o=>{o=Jl(o)?new URL(o):o;var c=Ct.readFileSync(o);return c},bt=async(o,c=!0)=>{o=Jl(o)?new URL(o):o;var d=Ct.readFileSync(o,c?void 0:"utf8");return d},!i.thisProgram&&process.argv.length>1&&(vt=process.argv[1].replace(/\\/g,"/")),at=process.argv.slice(2),Vt=(o,c)=>{throw process.exitCode=o,c}}else(u||f)&&(f?mt=self.location.href:typeof document<"u"&&document.currentScript&&(mt=document.currentScript.src),r&&(mt=r),mt.startsWith("blob:")?mt="":mt=mt.slice(0,mt.replace(/[?#].*/,"").lastIndexOf("/")+1),h||(f&&(Gt=o=>{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.responseType="arraybuffer",c.send(null),new Uint8Array(c.response)}),bt=async o=>{var c=await fetch(o,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}));var O=console.log.bind(console),V=console.error.bind(console);h&&(O=(...o)=>Ct.writeSync(1,o.join(" ")+"\n"),V=(...o)=>Ct.writeSync(2,o.join(" ")+"\n"));var F=i.print||O,U=i.printErr||V;Object.assign(i,E),E=null,i.arguments&&(at=i.arguments),i.thisProgram&&(vt=i.thisProgram);var D=i.wasmBinary,N,B,H=!1,W;function Tt(o,c){o||zr(c)}var Ot,Te,_t,Xe,xe,Wr,hi,Nn,fn=!1,Jl=o=>o.startsWith("file://");function va(){return N.buffer!=Ot.buffer&&Ee(),Ot}function Ze(){return N.buffer!=Ot.buffer&&Ee(),Te}function Sa(){return N.buffer!=Ot.buffer&&Ee(),_t}function x(){return N.buffer!=Ot.buffer&&Ee(),xe}function we(){return N.buffer!=Ot.buffer&&Ee(),Wr}function Ia(){return N.buffer!=Ot.buffer&&Ee(),Nn}if(v){let o=function(...m){var _=m.join(" ");if(h){Ct.writeSync(2,_+"\n");return}console.error(_)},c=function(...m){var _=m.join(" ");postMessage({cmd:"alert",text:_,threadId:xs()})},d=function(m){try{var _=m.data,y=_.cmd;if(y==="load"){let b=[];self.onmessage=g=>b.push(g),self.startWorker=g=>{postMessage({cmd:"loaded"});for(let T of b)d(T);self.onmessage=d};for(let g of _.handlers)(!i[g]||i[g].proxy)&&(i[g]=(...T)=>{postMessage({cmd:"callHandler",handler:g,args:T})},g=="print"&&(F=i[g]),g=="printErr"&&(U=i[g]));N=_.wasmMemory,Ee(),Xl(_.wasmModule)}else if(y==="run"){Uf(_.pthread_ptr),Ca(_.pthread_ptr,0,0,1,0,0),ht.receiveObjectTransfer(_),ht.threadInitTLS(),Ea(_.pthread_ptr),Fa||(Fa=!0);try{Of(_.start_routine,_.arg)}catch(b){if(b!="unwind")throw b}}else _.target==="setimmediate"||(y==="checkMailbox"?Fa&&Fs():y&&(U("worker: received unknown command ".concat(y)),U(_)))}catch(b){throw Hc(),b}};var sb=o,ob=c,ab=d,Xl;if(h){var Zl=A.parentPort;Zl.on("message",m=>onmessage({data:m})),Object.assign(globalThis,{self:global,postMessage:m=>Zl.postMessage(m)})}var Fa=!1;i.printErr||(U=o),self.alert=c,self.onunhandledrejection=m=>{throw m.reason||m},self.onmessage=d}function Ee(){var o=N.buffer;i.HEAP8=Ot=new Int8Array(o),i.HEAP16=_t=new Int16Array(o),i.HEAPU8=Te=new Uint8Array(o),i.HEAPU16=Xe=new Uint16Array(o),i.HEAP32=xe=new Int32Array(o),i.HEAPU32=Wr=new Uint32Array(o),i.HEAPF32=hi=new Float32Array(o),i.HEAPF64=Nn=new Float64Array(o)}if(v)i.wasmMemory&&(N=i.wasmMemory,Ee());else{if(i.wasmMemory)N=i.wasmMemory;else{var vf=i.INITIAL_MEMORY||16777216;N=new WebAssembly.Memory({initial:vf/65536,maximum:65536,shared:!0})}Ee()}function Sf(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)cc(i.preRun.shift());ac(lc)}function Ql(){if(fn=!0,v)return startWorker(i);M.Ha()}function ib(){}function If(){if(!v){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)Ef(i.postRun.shift());ac(hc)}}var hn=0,pi=null;function tc(o){var c;hn++,(c=i.monitorRunDependencies)==null||c.call(i,hn)}function ec(o){var d;if(hn--,(d=i.monitorRunDependencies)==null||d.call(i,hn),hn==0&&pi){var c=pi;pi=null,c()}}function zr(o){var d;(d=i.onAbort)==null||d.call(i,o),o="Aborted("+o+")",U(o),H=!0,o+=". Build with -sASSERTIONS for more info.",fn&&___trap();var c=new WebAssembly.RuntimeError(o);throw a(c),c}var mi;function Ff(){return Ut("./duckdb-coi.wasm")}function Bf(o){if(o==mi&&D)return new Uint8Array(D);if(Gt)return Gt(o);throw"both async and sync fetching of the wasm failed"}async function Df(o){if(!D)try{var c=await bt(o);return new Uint8Array(c)}catch(d){}return Bf(o)}async function Af(o,c){try{var d=await Df(o),m=await WebAssembly.instantiate(d,c);return m}catch(_){U("failed to asynchronously prepare wasm: ".concat(_)),zr(_)}}async function Tf(o,c,d){if(!o&&typeof WebAssembly.instantiateStreaming=="function"&&!h)try{var m=fetch(c,{credentials:"same-origin"}),_=await WebAssembly.instantiateStreaming(m,d);return _}catch(y){U("wasm streaming compile failed: ".concat(y)),U("falling back to ArrayBuffer instantiation")}return Af(c,d)}function rc(){return Bp(),{a:Cc}}async function xf(){function o(y,b){return M=y.exports,M=bm(M),Mf(M.zb),pc=M.Ja,B=b,ec("wasm-instantiate"),M}tc("wasm-instantiate");function c(y){return o(y.instance,y.module)}var d=rc();if(i.instantiateWasm)return new Promise((y,b)=>{i.instantiateWasm(d,(g,T)=>{o(g,T),y(g.exports)})});if(v)return new Promise(y=>{Xl=b=>{var g=new WebAssembly.Instance(b,rc());y(o(g,b))}});mi!=null||(mi=Ff());try{var m=await Tf(D,mi,d),_=c(m);return _}catch(y){return a(y),Promise.reject(y)}}var Dt,hr,nc={10231308:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,w=c;b<w*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];try{var C=encodeURI(ut(g));C==="Host"&&(C="X-Host-Override"),C==="User-Agent"||(C==="Authorization"?y.setRequestHeader(C,ut(T)):y.setRequestHeader(C,encodeURI(ut(T))))}catch(yt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",yt)}b+=2}try{y.send(null)}catch(yt){return 0}if(y.status>=400)return 0;for(var Y=y.response,w=Y.byteLength,dt=Qe(w+8),gt=new Uint8Array(Y),et=0;et<w;et++)i.HEAPU8[et+dt+8]=gt[et];var S=new Uint8Array(4);S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,dt+4);var Pt=Uint8Array.from(Array.from(y.getAllResponseHeaders()).map(yt=>yt.charCodeAt(0)));w=Pt.byteLength;for(var ne=Qe(w+8),et=0;et<w;et++)i.HEAPU8[et+ne+8]=Pt[et];return S=new Uint8Array(4),S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,ne+4),w=ne,S=new Uint8Array(4),S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,dt),dt},10233580:(o,c,d,m,_,y)=>{var b=ut(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(ut(m),b,!1),g.responseType="arraybuffer";for(var T=0,S=c;T<S*2;){var C=x()[d/4+T>>>0],Y=x()[d/4+T+1>>>0];try{var w=encodeURI(ut(C));w==="Host"&&(w="X-Host-Override"),w==="User-Agent"||(w==="Authorization"?g.setRequestHeader(w,ut(Y)):g.setRequestHeader(w,encodeURI(ut(Y))))}catch(tr){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",tr)}T+=2}try{for(var dt=new Uint8Array(y),gt=0;gt<y;gt++)dt[gt]=i.HEAPU8[gt+_];g.send(dt)}catch(tr){return 0}if(g.status>=400)return 0;for(var et=Uint8Array.from(Array.from(g.getResponseHeader("Etag")).map(tr=>tr.charCodeAt(0))),S=et.byteLength,Pt=Qe(S+4),ne=new Uint8Array(et),gt=0;gt<S;gt++)i.HEAPU8[gt+Pt+4]=ne[gt];var yt=new Uint8Array(4);return yt[0]=S%256,S-=yt[0],S/=256,yt[1]=S%256,S-=yt[1],S/=256,yt[2]=S%256,S-=yt[2],S/=256,yt[3]=S%256,S-=yt[3],S/=256,i.HEAPU8.set(yt,Pt),Pt},10235188:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,w=c;b<w*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];console.log("HEAD",ut(g),ut(T));try{var C=encodeURI(ut(g));C==="Host"&&(C="X-Host-Override"),C==="User-Agent"||(C==="Authorization"?y.setRequestHeader(C,ut(T)):y.setRequestHeader(C,encodeURI(ut(T))))}catch(yt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",yt)}b+=2}try{y.send(null)}catch(yt){return 0}if(y.status>=400)return 0;for(var Y=y.response,w=Y.byteLength,dt=Qe(w+8),gt=new Uint8Array(Y),et=0;et<w;et++)i.HEAPU8[et+dt+8]=gt[et];var S=new Uint8Array(4);S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,dt+4);var Pt=Uint8Array.from(Array.from(y.getAllResponseHeaders()).map(yt=>yt.charCodeAt(0)));w=Pt.byteLength;for(var ne=Qe(w+8),et=0;et<w;et++)i.HEAPU8[et+ne+8]=Pt[et];return S=new Uint8Array(4),S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,ne+4),w=ne,S=new Uint8Array(4),S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,dt),dt},10237521:(o,c,d,m)=>{var _=ut(o);if(typeof XMLHttpRequest>"u")return 0;let y=new XMLHttpRequest;y.open(ut(m),_,!1),y.responseType="arraybuffer";for(var b=0,w=c;b<w*2;){var g=x()[d/4+b>>>0],T=x()[d/4+b+1>>>0];try{var C=encodeURI(ut(g));C==="Host"&&(C="X-Host-Override"),C==="User-Agent"||(C==="Authorization"?y.setRequestHeader(C,ut(T)):y.setRequestHeader(C,encodeURI(ut(T))))}catch(Pt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Pt)}b+=2}try{y.send(null)}catch(Pt){return 0}if(y.status>=400)return 0;for(var Y=y.response,w=Y.byteLength,dt=Qe(w+4),gt=new Uint8Array(Y),et=0;et<w;et++)i.HEAPU8[et+dt+4]=gt[et];var S=new Uint8Array(4);return S[0]=w%256,w-=S[0],w/=256,S[1]=w%256,w-=S[1],w/=256,S[2]=w%256,w-=S[2],w/=256,S[3]=w%256,w-=S[3],w/=256,i.HEAPU8.set(S,dt),dt},10238916:(o,c,d,m,_,y)=>{var b=ut(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(ut(m),b,!1),g.responseType="arraybuffer";for(var T=0,S=c;T<S*2;){var C=x()[d/4+T>>>0],Y=x()[d/4+T+1>>>0];try{var w=encodeURI(ut(C));w==="Host"&&(w="X-Host-Override"),w==="User-Agent"||(w==="Authorization"?g.setRequestHeader(w,ut(Y)):g.setRequestHeader(w,encodeURI(ut(Y))))}catch(tr){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",tr)}T+=2}try{for(var dt=new Uint8Array(y),gt=0;gt<y;gt++)dt[gt]=i.HEAPU8[gt+_];g.send(dt)}catch(tr){return 0}if(g.status>=400)return 0;for(var et=g.response,S=et.byteLength,Pt=Qe(S+4),ne=new Uint8Array(et),gt=0;gt<S;gt++)i.HEAPU8[gt+Pt+4]=ne[gt];var yt=new Uint8Array(4);return yt[0]=S%256,S-=yt[0],S/=256,yt[1]=S%256,S-=yt[1],S/=256,yt[2]=S%256,S-=yt[2],S/=256,yt[3]=S%256,S-=yt[3],S/=256,i.HEAPU8.set(yt,Pt),Pt}};class ic{constructor(c){Es(this,"name","ExitStatus");this.message="Program terminated with exit(".concat(c,")"),this.status=c}}var sc=o=>{o.terminate(),o.onmessage=c=>{}},oc=o=>{var c=ht.pthreads[o];ht.returnWorkerToPool(c)},ac=o=>{for(;o.length>0;)o.shift()(i)},lc=[],cc=o=>lc.unshift(o),uc=o=>{var c=ht.getNewWorker();if(!c)return 6;ht.runningWorkers.push(c),ht.pthreads[o.pthread_ptr]=c,c.pthread_ptr=o.pthread_ptr;var d={cmd:"run",start_routine:o.startRoutine,arg:o.arg,pthread_ptr:o.pthread_ptr};return h&&c.unref(),c.postMessage(d,o.transferList),0},vs=0,Ba=()=>xa||vs>0,Ss=()=>Xc(),_i=o=>Yc(o),yi=o=>Jc(o);i.stackAlloc=yi;var jr=(o,c)=>c+2097152>>>0<4194305-!!o?(o>>>0)+c*4294967296:NaN,kn=(o,c,d,...m)=>{for(var _=m.length,y=Ss(),b=yi(_*8),g=b>>>3,T=0;T<m.length;T++){var C=m[T];Ia()[g+T>>>0]=C}var Y=zc(o,c,_,b,d);return _i(y),Y};function Da(o){var c;if(v)return kn(0,0,1,o);W=o,Ba()||(ht.terminateAllThreads(),(c=i.onExit)==null||c.call(i,o),H=!0),Vt(o,new ic(o))}var Aa=o=>{if(o instanceof ic||o=="unwind")return W;Vt(1,o)};function dc(o){if(v)return kn(1,0,0,o);Ta(o)}var fc=(o,c)=>{if(W=o,v)throw dc(o),"unwind";Da(o)},Ta=fc,ht={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){v||ht.initMainThread()},initMainThread(){for(var o=4;o--;)ht.allocateUnusedWorker();cc(()=>{tc("loading-workers"),ht.loadWasmModuleToAllWorkers(()=>ec("loading-workers"))})},terminateAllThreads:()=>{for(var o of ht.runningWorkers)sc(o);for(var o of ht.unusedWorkers)sc(o);ht.unusedWorkers=[],ht.runningWorkers=[],ht.pthreads={}},returnWorkerToPool:o=>{var c=o.pthread_ptr;delete ht.pthreads[c],ht.unusedWorkers.push(o),ht.runningWorkers.splice(ht.runningWorkers.indexOf(o),1),o.pthread_ptr=0,jc(c)},receiveObjectTransfer(o){},threadInitTLS(){ht.tlsInitFunctions.forEach(o=>o())},loadWasmModuleToWorker:o=>new Promise(c=>{o.onmessage=y=>{var b=y.data,g=b.cmd;if(b.targetThread&&b.targetThread!=xs()){var T=ht.pthreads[b.targetThread];T?T.postMessage(b,b.transferList):U('Internal error! Worker sent a message "'.concat(g,'" to target pthread ').concat(b.targetThread,", but that thread no longer exists!"));return}g==="checkMailbox"?Fs():g==="spawnThread"?uc(b):g==="cleanupThread"?oc(b.thread):g==="loaded"?(o.loaded=!0,h&&!o.pthread_ptr&&o.unref(),c(o)):g==="alert"?alert("Thread ".concat(b.threadId,": ").concat(b.text)):b.target==="setimmediate"?o.postMessage(b):g==="callHandler"?i[b.handler](...b.args):g&&U("worker sent an unknown command ".concat(g))},o.onerror=y=>{var b="worker sent an error!";throw U("".concat(b," ").concat(y.filename,":").concat(y.lineno,": ").concat(y.message)),y},h&&(o.on("message",y=>o.onmessage({data:y})),o.on("error",y=>o.onerror(y)));var d=[],m=["onExit","onAbort","print","printErr"];for(var _ of m)i.propertyIsEnumerable(_)&&d.push(_);o.postMessage({cmd:"load",handlers:d,wasmMemory:N,wasmModule:B})}),loadWasmModuleToAllWorkers(o){if(v)return o();Promise.all(ht.unusedWorkers.map(ht.loadWasmModuleToWorker)).then(o)},allocateUnusedWorker(){var o,c={workerData:"em-pthread",name:"em-pthread"},d=r;i.mainScriptUrlOrBlob&&(d=i.mainScriptUrlOrBlob,typeof d!="string"&&(d=URL.createObjectURL(d))),o=new Worker(d,c),ht.unusedWorkers.push(o)},getNewWorker(){return ht.unusedWorkers.length==0&&(ht.allocateUnusedWorker(),ht.loadWasmModuleToWorker(ht.unusedWorkers[0])),ht.unusedWorkers.pop()}},hc=[],Ef=o=>hc.unshift(o),Uf=o=>{Ee();var c=we()[o+52>>>2>>>0],d=we()[o+56>>>2>>>0],m=c-d;qc(c,m),_i(c)},Is=[],pc,mc=o=>{var c=Is[o];return c||(o>=Is.length&&(Is.length=o+1),Is[o]=c=pc.get(o)),c},Of=(o,c)=>{vs=0,xa=0;var d=mc(o)(c);function m(_){Ba()?W=_:Pa(_)}m(d)},xa=i.noExitRuntime||!0,Mf=o=>ht.tlsInitFunctions.push(o);function Rf(o,c){return o>>>=0,mc(o)(c)}function _c(o,c,d,m){return v?kn(2,0,1,o,c,d,m):yc(o,c,d,m)}var Lf=()=>typeof SharedArrayBuffer<"u";function yc(o,c,d,m){if(o>>>=0,c>>>=0,d>>>=0,m>>>=0,!Lf())return 6;var _=[],y=0;if(v&&(_.length===0||y))return _c(o,c,d,m);if(y)return y;var b={startRoutine:d,pthread_ptr:o,arg:m,transferList:_};return v?(b.cmd="spawnThread",postMessage(b,_),0):uc(b)}var Nf=()=>zr("");function kf(o){o>>>=0,Ca(o,!f,1,!u,1048576,!1),ht.threadInitTLS()}var Cf=()=>{if(!Ba())try{v?Pa(W):Ta(W)}catch(o){Aa(o)}},Pf=o=>{if(!H)try{o(),Cf()}catch(c){Aa(c)}};function Ea(o){if(o>>>=0,typeof Atomics.waitAsync=="function"){var c=Atomics.waitAsync(x(),o>>>2,o);c.value.then(Fs);var d=o+128;Atomics.store(x(),d>>>2,1)}}var Fs=()=>{var o=xs();o&&(Ea(o),Pf($c))};function Hf(o,c){if(o>>>=0,c>>>=0,o==c)setTimeout(Fs);else if(v)postMessage({targetThread:o,cmd:"checkMailbox"});else{var d=ht.pthreads[o];if(!d)return;d.postMessage({cmd:"checkMailbox"})}}var Ua=[];function Vf(o,c,d,m,_){c>>>=0,d>>>=0,_>>>=0,Ua.length=m;for(var y=_>>>3,b=0;b<m;b++)Ua[b]=Ia()[y+b>>>0];var g=c?nc[c]:Fp[o];ht.currentProxiedOperationCallerThread=d;var T=g(...Ua);return ht.currentProxiedOperationCallerThread=0,T}var Wf=()=>{xa=!1,vs=0},bc=typeof TextDecoder<"u"?new TextDecoder:void 0,zf=(o,c=0,d=NaN)=>{c>>>=0;for(var m=c+d,_=c;o[_]&&!(_>=m);)++_;if(_-c>16&&o.buffer&&bc)return bc.decode(o.buffer instanceof ArrayBuffer?o.subarray(c,_):o.slice(c,_));for(var y="";c<_;){var b=o[c++];if(!(b&128)){y+=String.fromCharCode(b);continue}var g=o[c++]&63;if((b&224)==192){y+=String.fromCharCode((b&31)<<6|g);continue}var T=o[c++]&63;if((b&240)==224?b=(b&15)<<12|g<<6|T:b=(b&7)<<18|g<<12|T<<6|o[c++]&63,b<65536)y+=String.fromCharCode(b);else{var C=b-65536;y+=String.fromCharCode(55296|C>>10,56320|C&1023)}}return y},ut=(o,c)=>(o>>>=0,o?zf(Ze(),o,c):"");function jf(o){if(o>>>=0,h){if(!o)return 1;var c=ut(o);if(!c.length)return 0;var d=["child_process"].map(Wa),m=d.spawnSync(c,[],{shell:!0,stdio:"inherit"}),_=(b,g)=>b<<8|g;if(m.status===null){var y=b=>{switch(b){case"SIGHUP":return 1;case"SIGQUIT":return 3;case"SIGFPE":return 8;case"SIGKILL":return 9;case"SIGALRM":return 14;case"SIGTERM":return 15;default:return 2}};return _(0,y(m.signal))}return _(m.status,0)}return o?-52:0}function $f(o){o>>>=0,v?postMessage({cmd:"cleanupThread",thread:o}):oc(o)}function Gf(o){o>>>=0,h&&ht.pthreads[o].ref()}function gc(){zr("missing function: _emval_call_method")}gc.stub=!0;function wc(){zr("missing function: _emval_decref")}wc.stub=!0;function vc(){zr("missing function: _emval_get_global")}vc.stub=!0;function Sc(){zr("missing function: _emval_get_method_caller")}Sc.stub=!0;function Ic(){zr("missing function: _emval_run_destructors")}Ic.stub=!0;function Kf(o,c,d){var m=jr(o,c);d>>>=0;var _=new Date(m*1e3);x()[d>>>2>>>0]=_.getUTCSeconds(),x()[d+4>>>2>>>0]=_.getUTCMinutes(),x()[d+8>>>2>>>0]=_.getUTCHours(),x()[d+12>>>2>>>0]=_.getUTCDate(),x()[d+16>>>2>>>0]=_.getUTCMonth(),x()[d+20>>>2>>>0]=_.getUTCFullYear()-1900,x()[d+24>>>2>>>0]=_.getUTCDay();var y=Date.UTC(_.getUTCFullYear(),0,1,0,0,0,0),b=(_.getTime()-y)/(1e3*60*60*24)|0;x()[d+28>>>2>>>0]=b}var qf=o=>o%4===0&&(o%100!==0||o%400===0),Yf=[0,31,60,91,121,152,182,213,244,274,305,335],Jf=[0,31,59,90,120,151,181,212,243,273,304,334],Fc=o=>{var c=qf(o.getFullYear()),d=c?Yf:Jf,m=d[o.getMonth()]+o.getDate()-1;return m};function Xf(o,c,d){var m=jr(o,c);d>>>=0;var _=new Date(m*1e3);x()[d>>>2>>>0]=_.getSeconds(),x()[d+4>>>2>>>0]=_.getMinutes(),x()[d+8>>>2>>>0]=_.getHours(),x()[d+12>>>2>>>0]=_.getDate(),x()[d+16>>>2>>>0]=_.getMonth(),x()[d+20>>>2>>>0]=_.getFullYear()-1900,x()[d+24>>>2>>>0]=_.getDay();var y=Fc(_)|0;x()[d+28>>>2>>>0]=y,x()[d+36>>>2>>>0]=-(_.getTimezoneOffset()*60);var b=new Date(_.getFullYear(),0,1),g=new Date(_.getFullYear(),6,1).getTimezoneOffset(),T=b.getTimezoneOffset(),C=(g!=T&&_.getTimezoneOffset()==Math.min(T,g))|0;x()[d+32>>>2>>>0]=C}var Oa=o=>Gc(o),Zf=function(o){o>>>=0;var c=(()=>{var d=new Date(x()[o+20>>>2>>>0]+1900,x()[o+16>>>2>>>0],x()[o+12>>>2>>>0],x()[o+8>>>2>>>0],x()[o+4>>>2>>>0],x()[o>>>2>>>0],0),m=x()[o+32>>>2>>>0],_=d.getTimezoneOffset(),y=new Date(d.getFullYear(),0,1),b=new Date(d.getFullYear(),6,1).getTimezoneOffset(),g=y.getTimezoneOffset(),T=Math.min(g,b);if(m<0)x()[o+32>>>2>>>0]=+(b!=g&&T==_);else if(m>0!=(T==_)){var C=Math.max(g,b),Y=m>0?T:C;d.setTime(d.getTime()+(Y-_)*6e4)}x()[o+24>>>2>>>0]=d.getDay();var w=Fc(d)|0;x()[o+28>>>2>>>0]=w,x()[o>>>2>>>0]=d.getSeconds(),x()[o+4>>>2>>>0]=d.getMinutes(),x()[o+8>>>2>>>0]=d.getHours(),x()[o+12>>>2>>>0]=d.getDate(),x()[o+16>>>2>>>0]=d.getMonth(),x()[o+20>>>2>>>0]=d.getYear();var dt=d.getTime();return isNaN(dt)?-1:dt/1e3})();return Oa((Dt=c,+Math.abs(Dt)>=1?Dt>0?+Math.floor(Dt/4294967296)>>>0:~~+Math.ceil((Dt-+(~~Dt>>>0))/4294967296)>>>0:0)),c>>>0},Bc=(o,c,d,m)=>{if(d>>>=0,!(m>0))return 0;for(var _=d,y=d+m-1,b=0;b<o.length;++b){var g=o.charCodeAt(b);if(g>=55296&&g<=57343){var T=o.charCodeAt(++b);g=65536+((g&1023)<<10)|T&1023}if(g<=127){if(d>=y)break;c[d++>>>0]=g}else if(g<=2047){if(d+1>=y)break;c[d++>>>0]=192|g>>6,c[d++>>>0]=128|g&63}else if(g<=65535){if(d+2>=y)break;c[d++>>>0]=224|g>>12,c[d++>>>0]=128|g>>6&63,c[d++>>>0]=128|g&63}else{if(d+3>=y)break;c[d++>>>0]=240|g>>18,c[d++>>>0]=128|g>>12&63,c[d++>>>0]=128|g>>6&63,c[d++>>>0]=128|g&63}}return c[d>>>0]=0,d-_},pr=(o,c,d)=>Bc(o,Ze(),c,d);i.stringToUTF8=pr;var Qf=function(o,c,d,m){o>>>=0,c>>>=0,d>>>=0,m>>>=0;var _=new Date().getFullYear(),y=new Date(_,0,1),b=new Date(_,6,1),g=y.getTimezoneOffset(),T=b.getTimezoneOffset(),C=Math.max(g,T);we()[o>>>2>>>0]=C*60,x()[c>>>2>>>0]=+(g!=T);var Y=gt=>{var et=gt>=0?"-":"+",S=Math.abs(gt),Pt=String(Math.floor(S/60)).padStart(2,"0"),ne=String(S%60).padStart(2,"0");return"UTC".concat(et).concat(Pt).concat(ne)},w=Y(g),dt=Y(T);T<g?(pr(w,d,17),pr(dt,m,17)):(pr(w,m,17),pr(dt,d,17))};function th(o,c){return c>>>=0,Ze().set(bi[o].fileData,c>>>0)}var Ma=[],eh=()=>Ma.length,bi=[],rh=!1,nh=()=>(rh=!0,bi.length);function ih(o,c){c>>>=0;var d=Ma[o].childName,m=Cn(d)+1;pr(d,c,m)}var sh=o=>bi[o].mode;function oh(o){return bi[o].fileData.length}function ah(o,c){c>>>=0;var d=Ma[o].parentPath,m=Cn(d)+1;pr(d,c,m)}var Cn=o=>{for(var c=0,d=0;d<o.length;++d){var m=o.charCodeAt(d);m<=127?c++:m<=2047?c+=2:m>=55296&&m<=57343?(c+=4,++d):c+=3}return c};i.lengthBytesUTF8=Cn;function lh(o,c){c>>>=0;var d=bi[o].pathName,m=Cn(d)+1;pr(d,c,m)}class Bs{constructor(){Es(this,"allocated",[void 0]);Es(this,"freelist",[])}get(c){return this.allocated[c]}has(c){return this.allocated[c]!==void 0}allocate(c){var d=this.freelist.pop()||this.allocated.length;return this.allocated[d]=c,d}free(c){this.allocated[c]=void 0,this.freelist.push(c)}}var $r=new Bs,ee=o=>{Wc(o)};async function ch(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c);try{await m.close()}catch(_){let y=-29;x()[d>>>2>>>0]=y}$r.free(c),ee(o)}var Ds=new Bs,uh=o=>{Ds.free(o)};async function dh(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c);try{await m.flush()}catch(_){let y=-29;x()[d>>>2>>>0]=y}ee(o)}var mr=new Bs,fh=o=>{mr.free(o)},pn=new Bs,hh=o=>{pn.free(o)};async function Dc(o,c,d){let m=mr.get(o),_;try{_=await m.getFileHandle(c,{create:d})}catch(y){return y.name==="NotFoundError"?-20:y.name==="TypeMismatchError"?-31:-29}return pn.allocate(_)}async function Ac(o,c,d){let m=mr.get(o),_;try{_=await m.getDirectoryHandle(c,{create:d})}catch(y){return y.name==="NotFoundError"?-20:y.name==="TypeMismatchError"?-54:-29}return mr.allocate(_)}async function ph(o,c,d,m,_){o>>>=0,d>>>=0,m>>>=0,_>>>=0;let y=ut(d),b=1,g=await Dc(c,y,!1);g==-31&&(b=2,g=await Ac(c,y,!1)),x()[m>>>2>>>0]=b,x()[_>>>2>>>0]=g,ee(o)}async function mh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=mr.get(c);try{let y=_.entries();for(let b;b=await y.next(),!b.done;){let[g,T]=b.value,C=Ss(),Y=kc(g),w=T.kind=="file"?1:2;__wasmfs_opfs_record_entry(d,Y,w),_i(C)}}catch(y){let b=-29;x()[m>>>2>>>0]=b}ee(o)}async function _h(o,c,d){o>>>=0,d>>>=0;let m=$r.get(c),_;try{_=await m.getSize()}catch(y){_=-29}hr=[_>>>0,(Dt=_,+Math.abs(Dt)>=1?Dt>0?+Math.floor(Dt/4294967296)>>>0:~~+Math.ceil((Dt-+(~~Dt>>>0))/4294967296)>>>0:0)],x()[d>>>2>>>0]=hr[0],x()[d+4>>>2>>>0]=hr[1],ee(o)}var yh=function(o){var c=Ds.get(o).size;return Oa((Dt=c,+Math.abs(Dt)>=1?Dt>0?+Math.floor(Dt/4294967296)>>>0:~~+Math.ceil((Dt-+(~~Dt>>>0))/4294967296)>>>0:0)),c>>>0};async function bh(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{_=(await m.getFile()).size}catch(y){_=-29}hr=[_>>>0,(Dt=_,+Math.abs(Dt)>=1?Dt>0?+Math.floor(Dt/4294967296)>>>0:~~+Math.ceil((Dt-+(~~Dt>>>0))/4294967296)>>>0:0)],x()[d>>>2>>>0]=hr[0],x()[d+4>>>2>>>0]=hr[1],ee(o)}async function gh(o){if(o>>>=0,mr.allocated.length==1){let c=await navigator.storage.getDirectory();mr.allocated.push(c)}ee(o)}async function wh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=await Ac(c,_,!0);x()[m>>>2>>>0]=y,ee(o)}async function vh(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=await Dc(c,_,!0);x()[m>>>2>>>0]=y,ee(o)}async function Sh(o,c,d,m,_){o>>>=0,m>>>=0,_>>>=0;let y=ut(m),b=pn.get(c),g=mr.get(d);try{await b.move(g,y)}catch(T){let C=-29;x()[_>>>2>>>0]=C}ee(o)}async function Ih(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{let b;var y=FileSystemFileHandle.prototype.createSyncAccessHandle.length;y==0?b=await m.createSyncAccessHandle():b=await m.createSyncAccessHandle({mode:"in-place"}),_=$r.allocate(b)}catch(b){b.name==="InvalidStateError"||b.name==="NoModificationAllowedError"?_=-2:_=-29}x()[d>>>2>>>0]=_,ee(o)}async function Fh(o,c,d){o>>>=0,d>>>=0;let m=pn.get(c),_;try{let y=await m.getFile();_=Ds.allocate(y)}catch(y){y.name==="NotAllowedError"?_=-2:_=-29}x()[d>>>2>>>0]=_,ee(o)}function Bh(o,c,d,m,_){c>>>=0;var y=jr(m,_);let b=$r.get(o),g=Ze().subarray(c>>>0,c+d>>>0);try{return b.read(g,{at:y})}catch(T){return T.name=="TypeError"?-28:-29}}async function Dh(o,c,d,m,_,y,b){o>>>=0,d>>>=0;var g=jr(_,y);b>>>=0;let C=Ds.get(c).slice(g,g+m),Y=0;try{let w=await C.arrayBuffer(),dt=new Uint8Array(w);Ze().set(dt,d>>>0),Y+=dt.length}catch(w){w instanceof RangeError?Y=-21:Y=-29}x()[b>>>2>>>0]=Y,ee(o)}async function Ah(o,c,d,m){o>>>=0,d>>>=0,m>>>=0;let _=ut(d),y=mr.get(c);try{await y.removeEntry(_)}catch(b){let g=-29;x()[m>>>2>>>0]=g}ee(o)}async function Th(o,c,d,m,_){o>>>=0;var y=jr(d,m);_>>>=0;let b=$r.get(c);try{await b.truncate(y)}catch(g){let T=-29;x()[_>>>2>>>0]=T}ee(o)}async function xh(o,c,d,m,_){o>>>=0;var y=jr(d,m);_>>>=0;let b=pn.get(c);try{let g=await b.createWritable({keepExistingData:!0});await g.truncate(y),await g.close()}catch(g){let T=-29;x()[_>>>2>>>0]=T}ee(o)}function Eh(o,c,d,m,_){c>>>=0;var y=jr(m,_);let b=$r.get(o),g=Ze().subarray(c>>>0,c+d>>>0);try{return b.write(g,{at:y})}catch(T){return T.name=="TypeError"?-28:-29}}var Ra=[],Uh=(o,c,d)=>{var m=d>0?d:Cn(o)+1,_=new Array(m),y=Bc(o,_,0,_.length);return c&&(_.length=y),_},Oh=()=>{if(!Ra.length){var o=null;if(h){var c=256,d=Buffer.alloc(c),m=0,_=process.stdin.fd;try{m=Ct.readSync(_,d,0,c)}catch(y){if(y.toString().includes("EOF"))m=0;else throw y}m>0&&(o=d.slice(0,m).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(o=window.prompt("Input: "),o!==null&&(o+="\n"));if(!o)return null;Ra=Uh(o,!0)}return Ra.shift()},Mh=()=>{var o=Oh();return typeof o=="number"?o:-1},Rh=function(o){o>>>=0;var c=setInterval(()=>{H?clearInterval(c):Vc(o)},50)},Tc=()=>performance.timeOrigin+performance.now(),xc=()=>Date.now(),Lh=1,Nh=o=>o>=0&&o<=3;function kh(o,c,d,m){var _=jr(c,d);if(m>>>=0,!Nh(o))return 28;var y;if(o===0)y=xc();else if(Lh)y=Tc();else return 52;var b=Math.round(y*1e3*1e3);return hr=[b>>>0,(Dt=b,+Math.abs(Dt)>=1?Dt>0?+Math.floor(Dt/4294967296)>>>0:~~+Math.ceil((Dt-+(~~Dt>>>0))/4294967296)>>>0:0)],x()[m>>>2>>>0]=hr[0],x()[m+4>>>2>>>0]=hr[1],0}function Ch(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(i,o,c)}function Ph(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(i,o,c)}function Hh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(i,o,c)}function Vh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(i,o,c)}function Wh(o){return globalThis.DUCKDB_RUNTIME.closeFile(i,o)}function zh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(i,o,c)}function jh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(i,o,c)}function $h(o,c,d,m){return o>>>=0,d>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(i,o,c,d,m)}function Gh(o,c){return globalThis.DUCKDB_RUNTIME.openFile(i,o,c)}function Kh(o,c,d,m){return c>>>=0,globalThis.DUCKDB_RUNTIME.readFile(i,o,c,d,m)}function qh(o,c){return globalThis.DUCKDB_RUNTIME.truncateFile(i,o,c)}function Yh(o,c,d,m){return c>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(i,o,c,d,m)}function Jh(o){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(o)}function Xh(o,c){return o>>>=0,globalThis.DUCKDB_RUNTIME.glob(i,o,c)}function Zh(o){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(i,o)}function Qh(o,c,d,m,_,y){return o>>>=0,d>>>=0,_>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(i,o,c,d,m,_,y)}var La=[],tp=(o,c)=>{La.length=0;for(var d;d=Ze()[o++>>>0];){var m=d!=105;m&=d!=112,c+=m&&c%8?4:0,La.push(d==112?we()[c>>>2>>>0]:d==105?x()[c>>>2>>>0]:Ia()[c>>>3>>>0]),c+=m?8:4}return La},ep=(o,c,d)=>{var m=tp(c,d);return nc[o](...m)};function rp(o,c,d){return o>>>=0,c>>>=0,d>>>=0,ep(o,c,d)}var gi=o=>{gi.shown||(gi.shown={}),gi.shown[o]||(gi.shown[o]=1,h&&(o="warning: "+o),U(o))},np=()=>{};function ip(o){return o>>>=0,U(ut(o))}var sp=()=>{vs+=1},op=()=>{throw sp(),"unwind"},Ec=()=>4294901760;function ap(){return Ec()}var lp=()=>h?nf().cpus().length:navigator.hardwareConcurrency;function cp(o){return o>>>=0,F(ut(o))}var up=(o,c)=>Math.ceil(o/c)*c,dp=o=>{var c=N.buffer,d=(o-c.byteLength+65535)/65536|0;try{return N.grow(d),Ee(),1}catch(m){}};function fp(o){o>>>=0;var c=Ze().length;if(o<=c)return!1;var d=Ec();if(o>d)return!1;for(var m=1;m<=4;m*=2){var _=c*(1+.2/m);_=Math.min(_,o+100663296);var y=Math.min(d,up(Math.max(o,_),65536)),b=dp(y);if(b)return!0}return!1}var hp=()=>{throw"unwind"},Na={},pp=()=>vt||"./this.program",wi=()=>{if(!wi.strings){var o=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",c={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:o,_:pp()};for(var d in Na)Na[d]===void 0?delete c[d]:c[d]=Na[d];var m=[];for(var d in c)m.push("".concat(d,"=").concat(c[d]));wi.strings=m}return wi.strings},mp=(o,c)=>{for(var d=0;d<o.length;++d)va()[c++>>>0]=o.charCodeAt(d);va()[c>>>0]=0},Uc=function(o,c){if(v)return kn(3,0,1,o,c);o>>>=0,c>>>=0;var d=0;return wi().forEach((m,_)=>{var y=c+d;we()[o+_*4>>>2>>>0]=y,mp(m,y),d+=m.length+1}),0},Oc=function(o,c){if(v)return kn(4,0,1,o,c);o>>>=0,c>>>=0;var d=wi();we()[o>>>2>>>0]=d.length;var m=0;return d.forEach(_=>m+=_.length+1),we()[c>>>2>>>0]=m,0},As=o=>{for(var c=o.split("."),d=0;d<4;d++){var m=Number(c[d]);if(isNaN(m))return null;c[d]=m}return(c[0]|c[1]<<8|c[2]<<16|c[3]<<24)>>>0},Ts=o=>parseInt(o),ka=o=>{var c,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(!y.test(o))return null;if(o==="::")return[0,0,0,0,0,0,0,0];for(o.startsWith("::")?o=o.replace("::","Z:"):o=o.replace("::",":Z:"),o.indexOf(".")>0?(o=o.replace(new RegExp("[.]","g"),":"),c=o.split(":"),c[c.length-4]=Ts(c[c.length-4])+Ts(c[c.length-3])*256,c[c.length-3]=Ts(c[c.length-2])+Ts(c[c.length-1])*256,c=c.slice(0,c.length-2)):c=o.split(":"),m=0,_=0,d=0;d<c.length;d++)if(typeof c[d]=="string")if(c[d]==="Z"){for(_=0;_<8-c.length+1;_++)b[d+_]=0;m=_-1}else b[d+m]=_htons(parseInt(c[d],16));else b[d+m]=c[d];return[b[1]<<16|b[0],b[3]<<16|b[2],b[5]<<16|b[4],b[7]<<16|b[6]]},Gr={address_map:{id:1,addrs:{},names:{}},lookup_name(o){var c=As(o);if(c!==null||(c=ka(o),c!==null))return o;var d;if(Gr.address_map.addrs[o])d=Gr.address_map.addrs[o];else{var m=Gr.address_map.id++;Tt(m<65535,"exceeded max address mappings of 65535"),d="172.29."+(m&255)+"."+(m&65280),Gr.address_map.names[d]=o,Gr.address_map.addrs[o]=d}return d},lookup_addr(o){return Gr.address_map.names[o]?Gr.address_map.names[o]:null}},Mc=o=>(o&255)+"."+(o>>8&255)+"."+(o>>16&255)+"."+(o>>24&255),_p=o=>{var c="",d=0,m=0,_=0,y=0,b=0,g=0,T=[o[0]&65535,o[0]>>16,o[1]&65535,o[1]>>16,o[2]&65535,o[2]>>16,o[3]&65535,o[3]>>16],C=!0,Y="";for(g=0;g<5;g++)if(T[g]!==0){C=!1;break}if(C){if(Y=Mc(T[6]|T[7]<<16),T[5]===-1)return c="::ffff:",c+=Y,c;if(T[5]===0)return c="::",Y==="0.0.0.0"&&(Y=""),Y==="0.0.0.1"&&(Y="1"),c+=Y,c}for(d=0;d<8;d++)T[d]===0&&(d-_>1&&(b=0),_=d,b++),b>m&&(m=b,y=d-m+1);for(d=0;d<8;d++){if(m>1&&T[d]===0&&d>=y&&d<y+m){d===y&&(c+=":",y===0&&(c+=":"));continue}c+=Number(_ntohs(T[d]&65535)).toString(16),c+=d<7?":":""}return c},Rc=(o,c)=>{Ze().fill(0,o,o+c)},yp=(o,c,d,m,_)=>{switch(c){case 2:d=As(d),Rc(o,16),_&&(x()[_>>>2>>>0]=16),Sa()[o>>>1>>>0]=c,x()[o+4>>>2>>>0]=d,Sa()[o+2>>>1>>>0]=_htons(m);break;case 10:d=ka(d),Rc(o,28),_&&(x()[_>>>2>>>0]=28),x()[o>>>2>>>0]=c,x()[o+8>>>2>>>0]=d[0],x()[o+12>>>2>>>0]=d[1],x()[o+16>>>2>>>0]=d[2],x()[o+20>>>2>>>0]=d[3],Sa()[o+2>>>1>>>0]=_htons(m);break;default:return 5}return 0};function Lc(o,c,d,m){if(v)return kn(5,0,1,o,c,d,m);o>>>=0,c>>>=0,d>>>=0,m>>>=0;var _=0,y=0,b=0,g=0,T=0,C=0,Y;function w(dt,gt,et,S,Pt,ne){var yt,tr,er,Qc;return tr=dt===10?28:16,Pt=dt===10?_p(Pt):Mc(Pt),yt=Qe(tr),Qc=yp(yt,dt,Pt,ne),Tt(!Qc),er=Qe(32),x()[er+4>>>2>>>0]=dt,x()[er+8>>>2>>>0]=gt,x()[er+12>>>2>>>0]=et,we()[er+24>>>2>>>0]=S,we()[er+20>>>2>>>0]=yt,dt===10?x()[er+16>>>2>>>0]=28:x()[er+16>>>2>>>0]=16,x()[er+28>>>2>>>0]=0,er}if(d&&(b=x()[d>>>2>>>0],g=x()[d+4>>>2>>>0],T=x()[d+8>>>2>>>0],C=x()[d+12>>>2>>>0]),T&&!C&&(C=T===2?17:6),!T&&C&&(T=C===17?2:1),C===0&&(C=6),T===0&&(T=1),!o&&!c)return-2;if(b&-1088||d!==0&&x()[d>>>2>>>0]&2&&!o)return-1;if(b&32)return-2;if(T!==0&&T!==1&&T!==2)return-7;if(g!==0&&g!==2&&g!==10)return-6;if(c&&(c=ut(c),y=parseInt(c,10),isNaN(y)))return b&1024?-2:-8;if(!o)return g===0&&(g=2),b&1||(g===2?_=_htonl(2130706433):_=[0,0,0,_htonl(1)]),Y=w(g,T,C,null,_,y),we()[m>>>2>>>0]=Y,0;if(o=ut(o),_=As(o),_!==null)if(g===0||g===2)g=2;else if(g===10&&b&8)_=[0,0,_htonl(65535),_],g=10;else return-2;else if(_=ka(o),_!==null)if(g===0||g===10)g=10;else return-2;return _!=null?(Y=w(g,T,C,o,_,y),we()[m>>>2>>>0]=Y,0):b&4?-2:(o=Gr.lookup_name(o),_=As(o),g===0?g=2:g===10&&(_=[0,0,_htonl(65535),_]),Y=w(g,T,C,null,_,y),we()[m>>>2>>>0]=Y,0)}var bp=()=>{if(h){var o=["crypto"].map(Wa).pop();return c=>o.randomFillSync(c)}return c=>c.set(crypto.getRandomValues(new Uint8Array(c.byteLength)))},Nc=o=>{(Nc=bp())(o)};function gp(o,c){return o>>>=0,c>>>=0,Nc(Ze().subarray(o>>>0,o+c>>>0)),0}var wp=o=>{var c=i["_"+o];return c},vp=(o,c)=>{va().set(o,c>>>0)},kc=o=>{var c=Cn(o)+1,d=yi(c);return pr(o,d,c),d},Sp=(o,c,d,m,_)=>{var y={string:et=>{var S=0;return et!=null&&et!==0&&(S=kc(et)),S},array:et=>{var S=yi(et.length);return vp(et,S),S}};function b(et){return c==="string"?ut(et):c==="boolean"?!!et:et}var g=wp(o),T=[],C=0;if(m)for(var Y=0;Y<m.length;Y++){var w=y[d[Y]];w?(C===0&&(C=Ss()),T[Y]=w(m[Y])):T[Y]=m[Y]}var dt=g(...T);function gt(et){return C!==0&&_i(C),b(et)}return dt=gt(dt),dt},Ip=o=>Kc();ht.init();var Fp=[Da,dc,_c,Uc,Oc,Lc],Cc;function Bp(){Cc={la:Rf,pa:yc,r:Nf,ia:kf,Ga:Hf,oa:Vf,n:Wf,H:jf,q:$f,_:Ea,R:Gf,E:gc,i:wc,G:vc,F:Sc,D:Ic,z:Kf,A:Xf,B:Zf,qa:Qf,za:th,xa:eh,ya:nh,va:ih,ta:sh,Aa:oh,wa:ah,ua:lh,Q:ch,S:uh,P:dh,I:fh,O:hh,W:ph,J:mh,U:_h,x:yh,V:bh,X:gh,M:wh,N:vh,L:Sh,k:Ih,T:Fh,w:Bh,v:Dh,K:Ah,t:Th,s:xh,u:Eh,Da:Mh,Y:Rh,C:kh,da:Ch,ea:Ph,ba:Hh,ca:Vh,m:Wh,ha:zh,$:jh,aa:$h,ga:Gh,f:Kh,fa:qh,g:Yh,ja:Jh,Z:Xh,l:Zh,ka:Qh,e:rp,p:np,b:xc,h:ip,j:op,Ea:ap,d:Tc,Fa:lp,Ca:cp,y:fp,na:hp,ra:Uc,sa:Oc,c:Ta,o:Lc,a:N,ma:Da,Ba:gp}}var M=await xf(),Pc=i._main=(o,c)=>(Pc=i._main=M.Ia)(o,c),Dp=i._duckdb_web_fs_glob_add_path=o=>(Dp=i._duckdb_web_fs_glob_add_path=M.Ka)(o),Ap=i._duckdb_web_clear_response=()=>(Ap=i._duckdb_web_clear_response=M.La)(),Tp=i._duckdb_web_fail_with=o=>(Tp=i._duckdb_web_fail_with=M.Ma)(o),xp=i._duckdb_web_reset=o=>(xp=i._duckdb_web_reset=M.Na)(o),Ep=i._duckdb_web_connect=()=>(Ep=i._duckdb_web_connect=M.Oa)(),Up=i._duckdb_web_disconnect=o=>(Up=i._duckdb_web_disconnect=M.Pa)(o),Op=i._duckdb_web_flush_files=()=>(Op=i._duckdb_web_flush_files=M.Qa)(),Mp=i._duckdb_web_flush_file=o=>(Mp=i._duckdb_web_flush_file=M.Ra)(o),Rp=i._duckdb_web_open=(o,c)=>(Rp=i._duckdb_web_open=M.Sa)(o,c),Lp=i._duckdb_web_get_global_file_info=(o,c)=>(Lp=i._duckdb_web_get_global_file_info=M.Ta)(o,c),Np=i._duckdb_web_collect_file_stats=(o,c,d)=>(Np=i._duckdb_web_collect_file_stats=M.Ua)(o,c,d),kp=i._duckdb_web_export_file_stats=(o,c)=>(kp=i._duckdb_web_export_file_stats=M.Va)(o,c),Cp=i._duckdb_web_fs_drop_file=(o,c)=>(Cp=i._duckdb_web_fs_drop_file=M.Wa)(o,c),Pp=i._duckdb_web_fs_drop_files=(o,c,d)=>(Pp=i._duckdb_web_fs_drop_files=M.Xa)(o,c,d),Hp=i._duckdb_web_fs_glob_file_infos=(o,c)=>(Hp=i._duckdb_web_fs_glob_file_infos=M.Ya)(o,c),Vp=i._duckdb_web_fs_get_file_info_by_id=(o,c,d)=>(Vp=i._duckdb_web_fs_get_file_info_by_id=M.Za)(o,c,d),Wp=i._duckdb_web_fs_get_file_info_by_name=(o,c,d)=>(Wp=i._duckdb_web_fs_get_file_info_by_name=M._a)(o,c,d),zp=i._duckdb_web_fs_register_file_url=(o,c,d,m,_)=>(zp=i._duckdb_web_fs_register_file_url=M.$a)(o,c,d,m,_),jp=i._duckdb_web_fs_register_file_buffer=(o,c,d,m)=>(jp=i._duckdb_web_fs_register_file_buffer=M.ab)(o,c,d,m),$p=i._duckdb_web_copy_file_to_buffer=(o,c)=>($p=i._duckdb_web_copy_file_to_buffer=M.bb)(o,c),Gp=i._duckdb_web_copy_file_to_path=(o,c,d)=>(Gp=i._duckdb_web_copy_file_to_path=M.cb)(o,c,d),Kp=i._duckdb_web_get_version=o=>(Kp=i._duckdb_web_get_version=M.db)(o),qp=i._duckdb_web_get_feature_flags=()=>(qp=i._duckdb_web_get_feature_flags=M.eb)(),Yp=i._duckdb_web_tokenize=(o,c)=>(Yp=i._duckdb_web_tokenize=M.fb)(o,c),Jp=i._duckdb_web_tokenize_buffer=(o,c,d)=>(Jp=i._duckdb_web_tokenize_buffer=M.gb)(o,c,d),Xp=i._duckdb_web_udf_scalar_create=(o,c,d)=>(Xp=i._duckdb_web_udf_scalar_create=M.hb)(o,c,d),Zp=i._duckdb_web_prepared_create=(o,c,d)=>(Zp=i._duckdb_web_prepared_create=M.ib)(o,c,d),Qp=i._duckdb_web_prepared_create_buffer=(o,c,d,m)=>(Qp=i._duckdb_web_prepared_create_buffer=M.jb)(o,c,d,m),tm=i._duckdb_web_prepared_close=(o,c,d)=>(tm=i._duckdb_web_prepared_close=M.kb)(o,c,d),em=i._duckdb_web_prepared_run=(o,c,d,m)=>(em=i._duckdb_web_prepared_run=M.lb)(o,c,d,m),rm=i._duckdb_web_prepared_send=(o,c,d,m)=>(rm=i._duckdb_web_prepared_send=M.mb)(o,c,d,m),nm=i._duckdb_web_query_run=(o,c,d)=>(nm=i._duckdb_web_query_run=M.nb)(o,c,d),im=i._duckdb_web_query_run_buffer=(o,c,d,m)=>(im=i._duckdb_web_query_run_buffer=M.ob)(o,c,d,m),sm=i._duckdb_web_pending_query_start=(o,c,d,m)=>(sm=i._duckdb_web_pending_query_start=M.pb)(o,c,d,m),om=i._duckdb_web_pending_query_start_buffer=(o,c,d,m,_)=>(om=i._duckdb_web_pending_query_start_buffer=M.qb)(o,c,d,m,_),am=i._duckdb_web_pending_query_poll=(o,c,d)=>(am=i._duckdb_web_pending_query_poll=M.rb)(o,c,d),lm=i._duckdb_web_pending_query_cancel=(o,c)=>(lm=i._duckdb_web_pending_query_cancel=M.sb)(o,c),cm=i._duckdb_web_query_fetch_results=(o,c)=>(cm=i._duckdb_web_query_fetch_results=M.tb)(o,c),um=i._duckdb_web_get_tablenames=(o,c,d)=>(um=i._duckdb_web_get_tablenames=M.ub)(o,c,d),dm=i._duckdb_web_get_tablenames_buffer=(o,c,d,m)=>(dm=i._duckdb_web_get_tablenames_buffer=M.vb)(o,c,d,m),fm=i._duckdb_web_insert_arrow_from_ipc_stream=(o,c,d,m,_)=>(fm=i._duckdb_web_insert_arrow_from_ipc_stream=M.wb)(o,c,d,m,_),hm=i._duckdb_web_insert_csv_from_path=(o,c,d,m)=>(hm=i._duckdb_web_insert_csv_from_path=M.xb)(o,c,d,m),pm=i._duckdb_web_insert_json_from_path=(o,c,d,m)=>(pm=i._duckdb_web_insert_json_from_path=M.yb)(o,c,d,m),mm=()=>(mm=M.zb)(),xs=()=>(xs=M.Ab)(),Ca=(o,c,d,m,_,y)=>(Ca=M.Bb)(o,c,d,m,_,y),Hc=()=>(Hc=M.Cb)(),Vc=o=>(Vc=M.Gb)(o),Wc=o=>(Wc=M.Hb)(o),zc=(o,c,d,m,_)=>(zc=M.Ib)(o,c,d,m,_),jc=o=>(jc=M.Jb)(o),Pa=o=>(Pa=M.Kb)(o),$c=()=>($c=M.Lb)(),Qe=i._malloc=o=>(Qe=i._malloc=M.Mb)(o),_m=i._free=o=>(_m=i._free=M.Nb)(o),ym=i._calloc=(o,c)=>(ym=i._calloc=M.Ob)(o,c),Gc=o=>(Gc=M.Qb)(o),Kc=()=>(Kc=M.Rb)(),qc=(o,c)=>(qc=M.Sb)(o,c),Yc=o=>(Yc=M.Tb)(o),Jc=o=>(Jc=M.Ub)(o),Xc=()=>(Xc=M.Vb)();function bm(o){o=Object.assign({},o);var c=_=>()=>_()>>>0,d=_=>y=>_(y)>>>0,m=_=>(y,b)=>_(y,b)>>>0;return o.Ab=c(o.Ab),o.Mb=d(o.Mb),o.Ob=m(o.Ob),o.Ub=d(o.Ub),o.Vb=c(o.Vb),o}i.stackSave=Ss,i.stackRestore=_i,i.stackAlloc=yi,i.getTempRet0=Ip,i.setTempRet0=Oa,i.ccall=Sp;function gm(){var o=Pc,c=0,d=0;try{var m=o(c,d);return fc(m,!0),m}catch(_){return Aa(_)}}function Ha(){if(hn>0){pi=Ha;return}if(v){s(i),Ql();return}if(Sf(),hn>0){pi=Ha;return}function o(){var d;if(i.calledRun=!0,!H){Ql(),s(i),(d=i.onRuntimeInitialized)==null||d.call(i);var c=i.noInitialRun;c||gm(),If()}}i.setStatus?(i.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>i.setStatus(""),1),o()},1)):o()}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Ha(),n=l,n}})();typeof uf=="object"&&typeof ya=="object"?(ya.exports=_a,ya.exports.default=_a):typeof define=="function"&&define.amd&&define([],()=>_a);var sf,of,cf=(of=(sf=globalThis.self)==null?void 0:sf.name)==null?void 0:of.startsWith("em-pthread"),af,lf,Xy=typeof((lf=(af=globalThis.process)==null?void 0:af.versions)==null?void 0:lf.node)=="string";Xy&&(cf=ql().workerData==="em-pthread");cf&&_a()});var hf=Kr(()=>{});var pf=Kr(()=>{});var mf=Kr((mA,wa)=>{(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 wa=="object"&&wa.exports,a=typeof define=="function"&&define.amd,l=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),f=[-2147483648,8388608,32768,128],h=[24,16,8,0],v=[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(I){return Object.prototype.toString.call(I)==="[object Array]"}),l&&(e.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(I){return typeof I=="object"&&I.buffer&&I.buffer.constructor===ArrayBuffer});var at=function(I,O){return function(V){return new bt(O,!0).update(V)[I]()}},vt=function(I){var O=at("hex",I);i&&(O=Vt(O,I)),O.create=function(){return new bt(I)},O.update=function(U){return O.create().update(U)};for(var V=0;V<A.length;++V){var F=A[V];O[F]=at(F,I)}return O},Vt=function(I,O){var V=hf(),F=pf().Buffer,U=O?"sha224":"sha256",D;F.from&&!e.JS_SHA256_NO_BUFFER_FROM?D=F.from:D=function(B){return new F(B)};var N=function(B){if(typeof B=="string")return V.createHash(U).update(B,"utf8").digest("hex");if(B==null)throw new Error(r);return B.constructor===ArrayBuffer&&(B=new Uint8Array(B)),Array.isArray(B)||ArrayBuffer.isView(B)||B.constructor===F?V.createHash(U).update(D(B)).digest("hex"):I(B)};return N},mt=function(I,O){return function(V,F){return new Gt(V,O,!0).update(F)[I]()}},Ut=function(I){var O=mt("hex",I);O.create=function(U){return new Gt(U,I)},O.update=function(U,D){return O.create(U).update(D)};for(var V=0;V<A.length;++V){var F=A[V];O[F]=mt(F,I)}return O};function bt(I,O){O?(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],I?(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=I}bt.prototype.update=function(I){if(!this.finalized){var O,V=typeof I;if(V!=="string"){if(V==="object"){if(I===null)throw new Error(r);if(l&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!l||!ArrayBuffer.isView(I)))throw new Error(r)}else throw new Error(r);O=!0}for(var F,U=0,D,N=I.length,B=this.blocks;U<N;){if(this.hashed&&(this.hashed=!1,B[0]=this.block,this.block=B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0),O)for(D=this.start;U<N&&D<64;++U)B[D>>>2]|=I[U]<<h[D++&3];else for(D=this.start;U<N&&D<64;++U)F=I.charCodeAt(U),F<128?B[D>>>2]|=F<<h[D++&3]:F<2048?(B[D>>>2]|=(192|F>>>6)<<h[D++&3],B[D>>>2]|=(128|F&63)<<h[D++&3]):F<55296||F>=57344?(B[D>>>2]|=(224|F>>>12)<<h[D++&3],B[D>>>2]|=(128|F>>>6&63)<<h[D++&3],B[D>>>2]|=(128|F&63)<<h[D++&3]):(F=65536+((F&1023)<<10|I.charCodeAt(++U)&1023),B[D>>>2]|=(240|F>>>18)<<h[D++&3],B[D>>>2]|=(128|F>>>12&63)<<h[D++&3],B[D>>>2]|=(128|F>>>6&63)<<h[D++&3],B[D>>>2]|=(128|F&63)<<h[D++&3]);this.lastByteIndex=D,this.bytes+=D-this.start,D>=64?(this.block=B[16],this.start=D-64,this.hash(),this.hashed=!0):this.start=D}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 I=this.blocks,O=this.lastByteIndex;I[16]=this.block,I[O>>>2]|=f[O&3],this.block=I[16],O>=56&&(this.hashed||this.hash(),I[0]=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),I[14]=this.hBytes<<3|this.bytes>>>29,I[15]=this.bytes<<3,this.hash()}},bt.prototype.hash=function(){var I=this.h0,O=this.h1,V=this.h2,F=this.h3,U=this.h4,D=this.h5,N=this.h6,B=this.h7,H=this.blocks,W,Tt,Ot,Te,_t,Xe,xe,Wr,hi,Nn,fn;for(W=16;W<64;++W)_t=H[W-15],Tt=(_t>>>7|_t<<25)^(_t>>>18|_t<<14)^_t>>>3,_t=H[W-2],Ot=(_t>>>17|_t<<15)^(_t>>>19|_t<<13)^_t>>>10,H[W]=H[W-16]+Tt+H[W-7]+Ot<<0;for(fn=O&V,W=0;W<64;W+=4)this.first?(this.is224?(Wr=300032,_t=H[0]-1413257819,B=_t-150054599<<0,F=_t+24177077<<0):(Wr=704751109,_t=H[0]-210244248,B=_t-1521486534<<0,F=_t+143694565<<0),this.first=!1):(Tt=(I>>>2|I<<30)^(I>>>13|I<<19)^(I>>>22|I<<10),Ot=(U>>>6|U<<26)^(U>>>11|U<<21)^(U>>>25|U<<7),Wr=I&O,Te=Wr^I&V^fn,xe=U&D^~U&N,_t=B+Ot+xe+v[W]+H[W],Xe=Tt+Te,B=F+_t<<0,F=_t+Xe<<0),Tt=(F>>>2|F<<30)^(F>>>13|F<<19)^(F>>>22|F<<10),Ot=(B>>>6|B<<26)^(B>>>11|B<<21)^(B>>>25|B<<7),hi=F&I,Te=hi^F&O^Wr,xe=B&U^~B&D,_t=N+Ot+xe+v[W+1]+H[W+1],Xe=Tt+Te,N=V+_t<<0,V=_t+Xe<<0,Tt=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),Ot=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),Nn=V&F,Te=Nn^V&I^hi,xe=N&B^~N&U,_t=D+Ot+xe+v[W+2]+H[W+2],Xe=Tt+Te,D=O+_t<<0,O=_t+Xe<<0,Tt=(O>>>2|O<<30)^(O>>>13|O<<19)^(O>>>22|O<<10),Ot=(D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7),fn=O&V,Te=fn^O&F^Nn,xe=D&N^~D&B,_t=U+Ot+xe+v[W+3]+H[W+3],Xe=Tt+Te,U=I+_t<<0,I=_t+Xe<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+I<<0,this.h1=this.h1+O<<0,this.h2=this.h2+V<<0,this.h3=this.h3+F<<0,this.h4=this.h4+U<<0,this.h5=this.h5+D<<0,this.h6=this.h6+N<<0,this.h7=this.h7+B<<0},bt.prototype.hex=function(){this.finalize();var I=this.h0,O=this.h1,V=this.h2,F=this.h3,U=this.h4,D=this.h5,N=this.h6,B=this.h7,H=u[I>>>28&15]+u[I>>>24&15]+u[I>>>20&15]+u[I>>>16&15]+u[I>>>12&15]+u[I>>>8&15]+u[I>>>4&15]+u[I&15]+u[O>>>28&15]+u[O>>>24&15]+u[O>>>20&15]+u[O>>>16&15]+u[O>>>12&15]+u[O>>>8&15]+u[O>>>4&15]+u[O&15]+u[V>>>28&15]+u[V>>>24&15]+u[V>>>20&15]+u[V>>>16&15]+u[V>>>12&15]+u[V>>>8&15]+u[V>>>4&15]+u[V&15]+u[F>>>28&15]+u[F>>>24&15]+u[F>>>20&15]+u[F>>>16&15]+u[F>>>12&15]+u[F>>>8&15]+u[F>>>4&15]+u[F&15]+u[U>>>28&15]+u[U>>>24&15]+u[U>>>20&15]+u[U>>>16&15]+u[U>>>12&15]+u[U>>>8&15]+u[U>>>4&15]+u[U&15]+u[D>>>28&15]+u[D>>>24&15]+u[D>>>20&15]+u[D>>>16&15]+u[D>>>12&15]+u[D>>>8&15]+u[D>>>4&15]+u[D&15]+u[N>>>28&15]+u[N>>>24&15]+u[N>>>20&15]+u[N>>>16&15]+u[N>>>12&15]+u[N>>>8&15]+u[N>>>4&15]+u[N&15];return this.is224||(H+=u[B>>>28&15]+u[B>>>24&15]+u[B>>>20&15]+u[B>>>16&15]+u[B>>>12&15]+u[B>>>8&15]+u[B>>>4&15]+u[B&15]),H},bt.prototype.toString=bt.prototype.hex,bt.prototype.digest=function(){this.finalize();var I=this.h0,O=this.h1,V=this.h2,F=this.h3,U=this.h4,D=this.h5,N=this.h6,B=this.h7,H=[I>>>24&255,I>>>16&255,I>>>8&255,I&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255,V>>>24&255,V>>>16&255,V>>>8&255,V&255,F>>>24&255,F>>>16&255,F>>>8&255,F&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255];return this.is224||H.push(B>>>24&255,B>>>16&255,B>>>8&255,B&255),H},bt.prototype.array=bt.prototype.digest,bt.prototype.arrayBuffer=function(){this.finalize();var I=new ArrayBuffer(this.is224?28:32),O=new DataView(I);return O.setUint32(0,this.h0),O.setUint32(4,this.h1),O.setUint32(8,this.h2),O.setUint32(12,this.h3),O.setUint32(16,this.h4),O.setUint32(20,this.h5),O.setUint32(24,this.h6),this.is224||O.setUint32(28,this.h7),I};function Gt(I,O,V){var F,U=typeof I;if(U==="string"){var D=[],N=I.length,B=0,H;for(F=0;F<N;++F)H=I.charCodeAt(F),H<128?D[B++]=H:H<2048?(D[B++]=192|H>>>6,D[B++]=128|H&63):H<55296||H>=57344?(D[B++]=224|H>>>12,D[B++]=128|H>>>6&63,D[B++]=128|H&63):(H=65536+((H&1023)<<10|I.charCodeAt(++F)&1023),D[B++]=240|H>>>18,D[B++]=128|H>>>12&63,D[B++]=128|H>>>6&63,D[B++]=128|H&63);I=D}else if(U==="object"){if(I===null)throw new Error(r);if(l&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!l||!ArrayBuffer.isView(I)))throw new Error(r)}else throw new Error(r);I.length>64&&(I=new bt(O,!0).update(I).array());var W=[],Tt=[];for(F=0;F<64;++F){var Ot=I[F]||0;W[F]=92^Ot,Tt[F]=54^Ot}bt.call(this,O,V),this.update(Tt),this.oKeyPad=W,this.inner=!0,this.sharedMemory=V}Gt.prototype=new bt,Gt.prototype.finalize=function(){if(bt.prototype.finalize.call(this),this.inner){this.inner=!1;var I=this.array();bt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(I),bt.prototype.finalize.call(this)}};var Ct=vt();Ct.sha256=Ct,Ct.sha224=vt(!0),Ct.sha256.hmac=Ut(),Ct.sha224.hmac=Ut(!0),s?wa.exports=Ct:(e.sha256=Ct.sha256,e.sha224=Ct.sha224,a&&define(function(){return Ct}))})()});var nb={};qr(nb,{registerWorker:()=>wf});function nu(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(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(h){try{f(n.next(h))}catch(v){a(v)}}function u(h){try{f(n.throw(h))}catch(v){a(v)}}function f(h){h.done?s(h.value):i(h.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function ru(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 st(r){return this instanceof st?(this.v=r,this):new st(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={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(A){n[A]&&(i[A]=function(E){return new Promise(function(at,vt){s.push([A,E,at,vt])>1||l(A,E)})})}function l(A,E){try{u(n[A](E))}catch(at){v(s[0][3],at)}}function u(A){A.value instanceof st?Promise.resolve(A.value.v).then(f,h):v(s[0][2],A)}function f(A){l("next",A)}function h(A){l("throw",A)}function v(A,E){A(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Pn(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(a){return(e=!e)?{value:st(r[i](a)),done:!1}:s?s(a):a}:s}}function Ue(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 ru=="function"?ru(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(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}var qa={};qr(qa,{compareArrayLike:()=>Ka,joinUint8Arrays:()=>pe,memcpy:()=>Fi,rebaseValueOffsets:()=>Cs,toArrayBufferView:()=>ot,toArrayBufferViewAsyncIterator:()=>Re,toArrayBufferViewIterator:()=>nr,toBigInt64Array:()=>ks,toBigUint64Array:()=>Nm,toFloat32Array:()=>km,toFloat32ArrayAsyncIterator:()=>Qm,toFloat32ArrayIterator:()=>$m,toFloat64Array:()=>Cm,toFloat64ArrayAsyncIterator:()=>t_,toFloat64ArrayIterator:()=>Gm,toInt16Array:()=>Mm,toInt16ArrayAsyncIterator:()=>Ym,toInt16ArrayIterator:()=>Vm,toInt32Array:()=>_n,toInt32ArrayAsyncIterator:()=>Jm,toInt32ArrayIterator:()=>Wm,toInt8Array:()=>Om,toInt8ArrayAsyncIterator:()=>qm,toInt8ArrayIterator:()=>Hm,toUint16Array:()=>Rm,toUint16ArrayAsyncIterator:()=>Xm,toUint16ArrayIterator:()=>zm,toUint32Array:()=>Lm,toUint32ArrayAsyncIterator:()=>Zm,toUint32ArrayIterator:()=>jm,toUint8Array:()=>J,toUint8ArrayAsyncIterator:()=>Ga,toUint8ArrayIterator:()=>$a,toUint8ClampedArray:()=>Pm,toUint8ClampedArrayAsyncIterator:()=>e_,toUint8ClampedArrayIterator:()=>Km});var Tm=new TextDecoder("utf-8"),Si=r=>Tm.decode(r),xm=new TextEncoder,rr=r=>xm.encode(r);var Em=r=>typeof r=="number",iu=r=>typeof r=="boolean",Kt=r=>typeof r=="function",ie=r=>r!=null&&Object(r)===r,Oe=r=>ie(r)&&Kt(r.then);var Me=r=>ie(r)&&Kt(r[Symbol.iterator]),ve=r=>ie(r)&&Kt(r[Symbol.asyncIterator]),Us=r=>ie(r)&&ie(r.schema);var Os=r=>ie(r)&&"done"in r&&"value"in r;var Ms=r=>ie(r)&&Kt(r.stat)&&Em(r.fd);var Rs=r=>ie(r)&&Ii(r.body),Ls=r=>"_getDOMStream"in r&&"_getNodeStream"in r,su=r=>ie(r)&&Kt(r.abort)&&Kt(r.getWriter)&&!Ls(r),Ii=r=>ie(r)&&Kt(r.cancel)&&Kt(r.getReader)&&!Ls(r),ou=r=>ie(r)&&Kt(r.end)&&Kt(r.write)&&iu(r.writable)&&!Ls(r),Ns=r=>ie(r)&&Kt(r.read)&&Kt(r.pipe)&&iu(r.readable)&&!Ls(r),au=r=>ie(r)&&Kt(r.clear)&&Kt(r.bytes)&&Kt(r.position)&&Kt(r.setPosition)&&Kt(r.capacity)&&Kt(r.getBufferIdentifier)&&Kt(r.createLong);var ja=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Um(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let a,l,u=0,f=0,h=r.length;++u<h;){if(a=t[f],l=r[u],!a||!l||a.buffer!==l.buffer||l.byteOffset<a.byteOffset){l&&(t[++f]=l);continue}if({byteOffset:e,byteLength:i}=a,{byteOffset:n,byteLength:s}=l,e+i<n||n+s<e){l&&(t[++f]=l);continue}t[f]=new Uint8Array(a.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),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(a,e),r}function pe(r,t){let e=Um(r),n=e.reduce((h,v)=>h+v.byteLength,0),i,s,a,l=0,u=-1,f=Math.min(t||Number.POSITIVE_INFINITY,n);for(let h=e.length;++u<h;){if(i=e[u],s=i.subarray(0,Math.min(i.length,f-l)),f<=l+s.length){s.length<i.length?e[u]=i.subarray(s.length):s.length===i.length&&u++,a?Fi(a,s,l):a=s;break}Fi(a||(a=new Uint8Array(f)),s,l),l+=s.length}return[a||new Uint8Array(0),e.slice(u),n-(a?a.byteLength:0)]}function ot(r,t){let e=Os(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=rr(e)),e instanceof ArrayBuffer?new r(e):e instanceof ja?new r(e):au(e)?ot(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 Om=r=>ot(Int8Array,r),Mm=r=>ot(Int16Array,r),_n=r=>ot(Int32Array,r),ks=r=>ot(BigInt64Array,r),J=r=>ot(Uint8Array,r),Rm=r=>ot(Uint16Array,r),Lm=r=>ot(Uint32Array,r),Nm=r=>ot(BigUint64Array,r),km=r=>ot(Float32Array,r),Cm=r=>ot(Float64Array,r),Pm=r=>ot(Uint8ClampedArray,r),za=r=>(r.next(),r);function*nr(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ja?e(t):Me(t)?t:e(t);return yield*mn(za(function*(i){let s=null;do s=i.next(yield ot(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var Hm=r=>nr(Int8Array,r),Vm=r=>nr(Int16Array,r),Wm=r=>nr(Int32Array,r),$a=r=>nr(Uint8Array,r),zm=r=>nr(Uint16Array,r),jm=r=>nr(Uint32Array,r),$m=r=>nr(Float32Array,r),Gm=r=>nr(Float64Array,r),Km=r=>nr(Uint8ClampedArray,r);function Re(r,t){return he(this,arguments,function*(){if(Oe(t))return yield st(yield st(yield*mn(Pn(Ue(Re(r,yield st(t)))))));let n=function(a){return he(this,arguments,function*(){yield yield st(yield st(a))})},i=function(a){return he(this,arguments,function*(){yield st(yield*mn(Pn(Ue(za(function*(l){let u=null;do u=l.next(yield u==null?void 0:u.value);while(!u.done)}(a[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ja?n(t):Me(t)?i(t):ve(t)?t:n(t);return yield st(yield*mn(Pn(Ue(za(function(a){return he(this,arguments,function*(){let l=null;do l=yield st(a.next(yield yield st(ot(r,l))));while(!l.done)})}(s[Symbol.asyncIterator]())))))),yield st(new r)})}var qm=r=>Re(Int8Array,r),Ym=r=>Re(Int16Array,r),Jm=r=>Re(Int32Array,r),Ga=r=>Re(Uint8Array,r),Xm=r=>Re(Uint16Array,r),Zm=r=>Re(Uint32Array,r),Qm=r=>Re(Float32Array,r),t_=r=>Re(Float64Array,r),e_=r=>Re(Uint8ClampedArray,r);function Cs(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 Ka(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 Ps(r_(r))},fromAsyncIterable(r){return Ps(n_(r))},fromDOMStream(r){return Ps(i_(r))},fromNodeStream(r){return Ps(s_(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')}},Ps=r=>(r.next(),r);function*r_(r){let t,e=!1,n=[],i,s,a,l=0;function u(){return s==="peek"?pe(n,a)[0]:([i,n,l]=pe(n,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});let f=$a(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-l)?f.next():f.next(a-l),!t&&i.byteLength>0&&(n.push(i),l+=i.byteLength),t||a<=l)do({cmd:s,size:a}=yield u());while(a<l);while(!t)}catch(h){(e=!0)&&typeof f.throw=="function"&&f.throw(h)}finally{e===!1&&typeof f.return=="function"&&f.return(null)}return null}function n_(r){return he(this,arguments,function*(){let e,n=!1,i=[],s,a,l,u=0;function f(){return a==="peek"?pe(i,l)[0]:([s,i,u]=pe(i,l),s)}({cmd:a,size:l}=(yield yield st(null))||{cmd:"read",size:0});let h=Ga(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(l-u)?yield st(h.next()):yield st(h.next(l-u)),!e&&s.byteLength>0&&(i.push(s),u+=s.byteLength),e||l<=u)do({cmd:a,size:l}=yield yield st(f()));while(l<u);while(!e)}catch(v){(n=!0)&&typeof h.throw=="function"&&(yield st(h.throw(v)))}finally{n===!1&&typeof h.return=="function"&&(yield st(h.return(new Uint8Array(0))))}return yield st(null)})}function i_(r){return he(this,arguments,function*(){let e=!1,n=!1,i=[],s,a,l,u=0;function f(){return a==="peek"?pe(i,l)[0]:([s,i,u]=pe(i,l),s)}({cmd:a,size:l}=(yield yield st(null))||{cmd:"read",size:0});let h=new Ja(r);try{do if({done:e,value:s}=Number.isNaN(l-u)?yield st(h.read()):yield st(h.read(l-u)),!e&&s.byteLength>0&&(i.push(J(s)),u+=s.byteLength),e||l<=u)do({cmd:a,size:l}=yield yield st(f()));while(l<u);while(!e)}catch(v){(n=!0)&&(yield st(h.cancel(v)))}finally{n===!1?yield st(h.cancel()):r.locked&&h.releaseLock()}return yield st(null)})}var Ja=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=J(e)),e})}},Ya=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function s_(r){return he(this,arguments,function*(){let e=[],n="error",i=!1,s=null,a,l,u=0,f=[],h;function v(){return a==="peek"?pe(f,l)[0]:([h,f,u]=pe(f,l),h)}if({cmd:a,size:l}=(yield yield st(null))||{cmd:"read",size:0},r.isTTY)return yield yield st(new Uint8Array(0)),yield st(null);try{e[0]=Ya(r,"end"),e[1]=Ya(r,"error");do{if(e[2]=Ya(r,"readable"),[n,s]=yield st(Promise.race(e.map(E=>E[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(l-u)?(h=J(r.read(l-u)),h.byteLength<l-u&&(h=J(r.read()))):h=J(r.read()),h.byteLength>0&&(f.push(h),u+=h.byteLength)),i||l<=u)do({cmd:a,size:l}=yield yield st(v()));while(l<u)}while(!i)}finally{yield st(A(e,n==="error"?s:null))}return yield st(null);function A(E,at){return h=f=null,new Promise((vt,Vt)=>{for(let[mt,Ut]of E)r.off(mt,Ut);try{let mt=r.destroy;mt&&mt.call(r,at),at=void 0}catch(mt){at=mt||at}finally{at!=null?Vt(at):vt()}})}})}var St;(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"})(St||(St={}));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 Wt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(Wt||(Wt={}));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 qt;(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"})(qt||(qt={}));var ir=new Int32Array(2),Hs=new Float32Array(ir.buffer),Vs=new Float64Array(ir.buffer),Hn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Bi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Bi||(Bi={}));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 ir[0]=this.readInt32(t),Hs[0]}readFloat64(t){return ir[Hn?0:1]=this.readInt32(t),ir[Hn?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){Hs[0]=e,this.writeInt32(t,ir[0])}writeFloat64(t,e){Vs[0]=e,this.writeInt32(t,ir[Hn?0:1]),this.writeInt32(t+4,ir[Hn?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===Bi.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 yn=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 a=0,l=this.space;t:for(e=0;e<this.vtables.length;e++){let u=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(u)){for(let f=2;f<s;f+=2)if(this.bb.readInt16(l+f)!=this.bb.readInt16(u+f))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-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 a=3;a>=0;a--)this.writeInt8(s.charCodeAt(a))}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 Di;(function(r){r[r.BUFFER=0]="BUFFER"})(Di||(Di={}));var Ai;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ai||(Ai={}));var zs=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):Ai.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Di.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ai.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Di.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 Vn=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 Wn=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 _e=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 Wn).__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 Vn).__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 zs).__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 _r=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 _e).__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 Yr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Yr||(Yr={}));var Ti;(function(r){r[r.DenseArray=0]="DenseArray"})(Ti||(Ti={}));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 sr=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):Ti.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,Ti.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 xi=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 Ei=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 Jr=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):Wt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Wt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var or=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 Xr=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 Qr=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 tn=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 en=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):qt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,qt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var Ui=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 Oi=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 Mi=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 rn=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 Ri=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 Li=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 yr=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 br=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 Ni=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 Et;(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"})(Et||(Et={}));var re=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):Et.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 sr).__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,Et.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 le=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):Yr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new re).__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,Yr.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 ct;(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"})(ct||(ct={}));var p;(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"})(p||(p={}));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 _l={};qr(_l,{clampRange:()=>Hi,createElementComparator:()=>an,wrapIndex:()=>bn});var Xa={};qr(Xa,{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 el={};qr(el,{BN:()=>Ci,bigNumToBigInt:()=>cu,bigNumToNumber:()=>tl,bigNumToString:()=>$n,isArrowBigNumSymbol:()=>lu});function pt(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 Za(r,t){return pt(r/t)+pt(r%t)/pt(t)}var lu=Symbol.for("isArrowBigNum");function Pe(r,...t){return t.length===0?Object.setPrototypeOf(ot(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Pe.prototype[lu]=!0;Pe.prototype.toJSON=function(){return'"'.concat($n(this),'"')};Pe.prototype.valueOf=function(r){return tl(this,r)};Pe.prototype.toString=function(){return $n(this)};Pe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return tl(this);case"string":return $n(this);case"default":return cu(this)}return $n(this)};function zn(...r){return Pe.apply(this,r)}function jn(...r){return Pe.apply(this,r)}function ki(...r){return Pe.apply(this,r)}Object.setPrototypeOf(zn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(jn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(ki.prototype,Object.create(Uint32Array.prototype));Object.assign(zn.prototype,Pe.prototype,{constructor:zn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(jn.prototype,Pe.prototype,{constructor:jn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(ki.prototype,Pe.prototype,{constructor:ki,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var o_=BigInt(4294967296)*BigInt(4294967296),a_=o_-BigInt(1);function tl(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,a=new BigUint64Array(e,n,i/8),l=s&&a.at(-1)&BigInt(1)<<BigInt(63),u=BigInt(0),f=0;if(l){for(let h of a)u|=(h^a_)*(BigInt(1)<<BigInt(64*f++));u*=BigInt(-1),u-=BigInt(1)}else for(let h of a)u|=h*(BigInt(1)<<BigInt(64*f++));if(typeof t=="number"){let h=BigInt(Math.pow(10,t)),v=u/h,A=u%h;return pt(v)+pt(A)/pt(h)}return pt(u)}function $n(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return Qa(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Qa(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let a=t[s],l=~a+n;t[s]=l,n&=a===0?1:0}let i=Qa(t);return"-".concat(i)}function cu(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:$n(r)}function Qa(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,a=n.length-1;do{for(e[0]=n[s=0];s<a;)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 Ci=class r{static new(t,e){switch(e){case!0:return new zn(t);case!1:return new jn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new zn(t)}return t.byteLength===16?new ki(t):new jn(t)}static signed(t){return new zn(t)}static unsigned(t){return new jn(t)}static decimal(t){return new ki(t)}constructor(t,e){return r.new(t,e)}};var uu,du,fu,hu,pu,mu,_u,yu,bu,gu,wu,vu,Su,Iu,Fu,Bu,Du,Au,Tu,xu,Eu,Uu,L=class r{static isNull(t){return(t==null?void 0:t.typeId)===p.Null}static isInt(t){return(t==null?void 0:t.typeId)===p.Int}static isFloat(t){return(t==null?void 0:t.typeId)===p.Float}static isBinary(t){return(t==null?void 0:t.typeId)===p.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===p.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===p.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===p.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===p.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===p.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===p.Date}static isTime(t){return(t==null?void 0:t.typeId)===p.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===p.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===p.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===p.Duration}static isList(t){return(t==null?void 0:t.typeId)===p.List}static isStruct(t){return(t==null?void 0:t.typeId)===p.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===p.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===p.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===p.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===p.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===p.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}};uu=Symbol.toStringTag;L[uu]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(L.prototype);var se=class extends L{constructor(){super(p.Null)}toString(){return"Null"}};du=Symbol.toStringTag;se[du]=(r=>r[Symbol.toStringTag]="Null")(se.prototype);var Jt=class extends L{constructor(t,e){super(p.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)}};fu=Symbol.toStringTag;Jt[fu]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Jt.prototype);var js=class extends Jt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},$s=class extends Jt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},ar=class extends Jt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Gs=class extends Jt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ks=class extends Jt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},qs=class extends Jt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ys=class extends Jt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Js=class extends Jt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(js.prototype,"ArrayType",{value:Int8Array});Object.defineProperty($s.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(ar.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Gs.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ks.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(qs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ys.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Js.prototype,"ArrayType",{value:BigUint64Array});var Fe=class extends L{constructor(t){super(p.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)}};hu=Symbol.toStringTag;Fe[hu]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Fe.prototype);var Xs=class extends Fe{constructor(){super(At.HALF)}},Zs=class extends Fe{constructor(){super(At.SINGLE)}},Qs=class extends Fe{constructor(){super(At.DOUBLE)}};Object.defineProperty(Xs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Zs.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Qs.prototype,"ArrayType",{value:Float64Array});var gr=class extends L{constructor(){super(p.Binary)}toString(){return"Binary"}};pu=Symbol.toStringTag;gr[pu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(gr.prototype);var wr=class extends L{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};mu=Symbol.toStringTag;wr[mu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(wr.prototype);var vr=class extends L{constructor(){super(p.Utf8)}toString(){return"Utf8"}};_u=Symbol.toStringTag;vr[_u]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(vr.prototype);var Sr=class extends L{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};yu=Symbol.toStringTag;Sr[yu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Sr.prototype);var Ir=class extends L{constructor(){super(p.Bool)}toString(){return"Bool"}};bu=Symbol.toStringTag;Ir[bu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Ir.prototype);var Fr=class extends L{constructor(t,e,n=128){super(p.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};gu=Symbol.toStringTag;Fr[gu]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Fr.prototype);var Br=class extends L{constructor(t){super(p.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat(Wt[this.unit],">")}get ArrayType(){return this.unit===Wt.DAY?Int32Array:BigInt64Array}};wu=Symbol.toStringTag;Br[wu]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Br.prototype);var Dr=class extends L{constructor(t,e){super(p.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"))}};vu=Symbol.toStringTag;Dr[vu]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Dr.prototype);var Ar=class extends L{constructor(t,e){super(p.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(k[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};Su=Symbol.toStringTag;Ar[Su]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Ar.prototype);var Tr=class extends L{constructor(t){super(p.Interval),this.unit=t}toString(){return"Interval<".concat(qt[this.unit],">")}};Iu=Symbol.toStringTag;Tr[Iu]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Tr.prototype);var xr=class extends L{constructor(t){super(p.Duration),this.unit=t}toString(){return"Duration<".concat(k[this.unit],">")}};Fu=Symbol.toStringTag;xr[Fu]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(xr.prototype);var He=class extends L{constructor(t){super(p.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}};Bu=Symbol.toStringTag;He[Bu]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(He.prototype);var Rt=class extends L{constructor(t){super(p.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};Du=Symbol.toStringTag;Rt[Du]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Rt.prototype);var Ve=class extends L{constructor(t,e,n){super(p.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};Au=Symbol.toStringTag;Ve[Au]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Ve.prototype);var Er=class extends L{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};Tu=Symbol.toStringTag;Er[Tu]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Er.prototype);var We=class extends L{constructor(t,e){super(p.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,">")}};xu=Symbol.toStringTag;We[xu]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(We.prototype);var ze=class extends L{constructor(t,e=!1){var n,i,s;if(super(p.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 a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");let l=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];l&&(l.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(", "),"}>")}};Eu=Symbol.toStringTag;ze[Eu]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(ze.prototype);var l_=(r=>()=>++r)(-1),ye=class extends L{constructor(t,e,n,i){super(p.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?l_():pt(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,">")}};Uu=Symbol.toStringTag;ye[Uu]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(ye.prototype);function be(r){let t=r;switch(r.typeId){case p.Decimal:return r.bitWidth/32;case p.Interval:return 1+t.unit;case p.FixedSizeList:return t.listSize;case p.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 c_(this,t,e)}getVisitFnByTypeId(t,e=!0){return Gn(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 c_(r,t,e=!0){return typeof t=="number"?Gn(r,t,e):typeof t=="string"&&t in p?Gn(r,p[t],e):t&&t instanceof L?Gn(r,Ou(t),e):t!=null&&t.type&&t.type instanceof L?Gn(r,Ou(t.type),e):Gn(r,p.NONE,e)}function Gn(r,t,e=!0){let n=null;switch(t){case p.Null:n=r.visitNull;break;case p.Bool:n=r.visitBool;break;case p.Int:n=r.visitInt;break;case p.Int8:n=r.visitInt8||r.visitInt;break;case p.Int16:n=r.visitInt16||r.visitInt;break;case p.Int32:n=r.visitInt32||r.visitInt;break;case p.Int64:n=r.visitInt64||r.visitInt;break;case p.Uint8:n=r.visitUint8||r.visitInt;break;case p.Uint16:n=r.visitUint16||r.visitInt;break;case p.Uint32:n=r.visitUint32||r.visitInt;break;case p.Uint64:n=r.visitUint64||r.visitInt;break;case p.Float:n=r.visitFloat;break;case p.Float16:n=r.visitFloat16||r.visitFloat;break;case p.Float32:n=r.visitFloat32||r.visitFloat;break;case p.Float64:n=r.visitFloat64||r.visitFloat;break;case p.Utf8:n=r.visitUtf8;break;case p.LargeUtf8:n=r.visitLargeUtf8;break;case p.Binary:n=r.visitBinary;break;case p.LargeBinary:n=r.visitLargeBinary;break;case p.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case p.Date:n=r.visitDate;break;case p.DateDay:n=r.visitDateDay||r.visitDate;break;case p.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case p.Timestamp:n=r.visitTimestamp;break;case p.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case p.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case p.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case p.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case p.Time:n=r.visitTime;break;case p.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case p.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case p.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case p.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case p.Decimal:n=r.visitDecimal;break;case p.List:n=r.visitList;break;case p.Struct:n=r.visitStruct;break;case p.Union:n=r.visitUnion;break;case p.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case p.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case p.Dictionary:n=r.visitDictionary;break;case p.Interval:n=r.visitInterval;break;case p.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case p.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case p.Duration:n=r.visitDuration;break;case p.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case p.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case p.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case p.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case p.FixedSizeList:n=r.visitFixedSizeList;break;case p.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(p[t],"'"))}function Ou(r){switch(r.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?p.Int8:p.Uint8;case 16:return e?p.Int16:p.Uint16;case 32:return e?p.Int32:p.Uint32;case 64:return e?p.Int64:p.Uint64}return p.Int}case p.Float:switch(r.precision){case At.HALF:return p.Float16;case At.SINGLE:return p.Float32;case At.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(r.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(r.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(r.unit){case Wt.DAY:return p.DateDay;case Wt.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(r.unit){case qt.DAY_TIME:return p.IntervalDayTime;case qt.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(r.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(r.mode){case xt.Dense:return p.DenseUnion;case xt.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error("Unrecognized type '".concat(p[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 rl={};qr(rl,{float64ToUint16:()=>Pi,uint16ToFloat64:()=>to});var Mu=new Float64Array(1),Kn=new Uint32Array(Mu.buffer);function to(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 Pi(r){if(r!==r)return 32256;Mu[0]=r;let t=(Kn[1]&2147483648)>>16&65535,e=Kn[1]&2146435072,n=0;return e>=1089470464?Kn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Kn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Kn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Kn[1]&1048575)+512>>10),t|e|n&65535}var q=class extends z{};function tt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var u_=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Ru=(r,t,e,n)=>{if(e+1<t.length){let i=pt(t[e]),s=pt(t[e+1]);r.set(n.subarray(0,s-i),i)}},d_=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Ur=({values:r},t,e)=>{r[t]=e},nl=({values:r},t,e)=>{r[t]=e},Lu=({values:r},t,e)=>{r[t]=Pi(e)},f_=(r,t,e)=>{switch(r.type.precision){case At.HALF:return Lu(r,t,e);case At.SINGLE:case At.DOUBLE:return nl(r,t,e)}},eo=({values:r},t,e)=>{u_(r,t,e.valueOf())},ro=({values:r},t,e)=>{r[t]=BigInt(e)},il=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Nu=({values:r,valueOffsets:t},e,n)=>Ru(r,t,e,n),ku=({values:r,valueOffsets:t},e,n)=>Ru(r,t,e,rr(n)),sl=(r,t,e)=>{r.type.unit===Wt.DAY?eo(r,t,e):ro(r,t,e)},no=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},io=({values:r},t,e)=>{r[t]=BigInt(e)},so=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},oo=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},ol=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return no(r,t,e);case k.MILLISECOND:return io(r,t,e);case k.MICROSECOND:return so(r,t,e);case k.NANOSECOND:return oo(r,t,e)}},ao=({values:r},t,e)=>{r[t]=e},lo=({values:r},t,e)=>{r[t]=e},co=({values:r},t,e)=>{r[t]=e},uo=({values:r},t,e)=>{r[t]=e},al=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return ao(r,t,e);case k.MILLISECOND:return lo(r,t,e);case k.MICROSECOND:return co(r,t,e);case k.NANOSECOND:return uo(r,t,e)}},ll=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},h_=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Zt.getVisitFn(n);if(Array.isArray(e))for(let a=-1,l=i[t],u=i[t+1];l<u;)s(n,l++,e[++a]);else for(let a=-1,l=i[t],u=i[t+1];l<u;)s(n,l++,e.get(++a))},p_=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Zt.getVisitFn(n),{[t]:a,[t+1]:l}=i,u=e instanceof Map?e.entries():Object.entries(e);for(let f of u)if(s(n,a,f),++a>=l)break},m_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),__=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),y_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),b_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),g_=(r,t,e)=>{let n=r.type.children.map(s=>Zt.getVisitFn(s.type)),i=e instanceof Map?y_(t,e):e instanceof ft?__(t,e):Array.isArray(e)?m_(t,e):b_(t,e);r.type.children.forEach((s,a)=>i(n[a],r.children[a],s,a))},w_=(r,t,e)=>{r.type.mode===xt.Dense?Cu(r,t,e):Pu(r,t,e)},Cu=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,r.valueOffsets[t],e)},Pu=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,t,e)},v_=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},cl=(r,t,e)=>{r.type.unit===qt.DAY_TIME?fo(r,t,e):ho(r,t,e)},fo=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},ho=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},po=({values:r},t,e)=>{r[t]=e},mo=({values:r},t,e)=>{r[t]=e},_o=({values:r},t,e)=>{r[t]=e},yo=({values:r},t,e)=>{r[t]=e},ul=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return po(r,t,e);case k.MILLISECOND:return mo(r,t,e);case k.MICROSECOND:return _o(r,t,e);case k.NANOSECOND:return yo(r,t,e)}},S_=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Zt.getVisitFn(i);if(Array.isArray(e))for(let a=-1,l=t*n;++a<n;)s(i,l+a,e[a]);else for(let a=-1,l=t*n;++a<n;)s(i,l+a,e.get(a))};q.prototype.visitBool=tt(d_);q.prototype.visitInt=tt(Ur);q.prototype.visitInt8=tt(Ur);q.prototype.visitInt16=tt(Ur);q.prototype.visitInt32=tt(Ur);q.prototype.visitInt64=tt(Ur);q.prototype.visitUint8=tt(Ur);q.prototype.visitUint16=tt(Ur);q.prototype.visitUint32=tt(Ur);q.prototype.visitUint64=tt(Ur);q.prototype.visitFloat=tt(f_);q.prototype.visitFloat16=tt(Lu);q.prototype.visitFloat32=tt(nl);q.prototype.visitFloat64=tt(nl);q.prototype.visitUtf8=tt(ku);q.prototype.visitLargeUtf8=tt(ku);q.prototype.visitBinary=tt(Nu);q.prototype.visitLargeBinary=tt(Nu);q.prototype.visitFixedSizeBinary=tt(il);q.prototype.visitDate=tt(sl);q.prototype.visitDateDay=tt(eo);q.prototype.visitDateMillisecond=tt(ro);q.prototype.visitTimestamp=tt(ol);q.prototype.visitTimestampSecond=tt(no);q.prototype.visitTimestampMillisecond=tt(io);q.prototype.visitTimestampMicrosecond=tt(so);q.prototype.visitTimestampNanosecond=tt(oo);q.prototype.visitTime=tt(al);q.prototype.visitTimeSecond=tt(ao);q.prototype.visitTimeMillisecond=tt(lo);q.prototype.visitTimeMicrosecond=tt(co);q.prototype.visitTimeNanosecond=tt(uo);q.prototype.visitDecimal=tt(ll);q.prototype.visitList=tt(h_);q.prototype.visitStruct=tt(g_);q.prototype.visitUnion=tt(w_);q.prototype.visitDenseUnion=tt(Cu);q.prototype.visitSparseUnion=tt(Pu);q.prototype.visitDictionary=tt(v_);q.prototype.visitInterval=tt(cl);q.prototype.visitIntervalDayTime=tt(fo);q.prototype.visitIntervalYearMonth=tt(ho);q.prototype.visitDuration=tt(ul);q.prototype.visitDurationSecond=tt(po);q.prototype.visitDurationMillisecond=tt(mo);q.prototype.visitDurationMicrosecond=tt(_o);q.prototype.visitDurationNanosecond=tt(yo);q.prototype.visitFixedSizeList=tt(S_);q.prototype.visitMap=tt(p_);var Zt=new q;var je=Symbol.for("parent"),qn=Symbol.for("rowIndex"),nn=class{constructor(t,e){return this[je]=t,this[qn]=e,new Proxy(this,new fl)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[qn],e=this[je],n=e.type.children,i={};for(let s=-1,a=n.length;++s<a;)i[n[s].name]=jt.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 dl(this[je],this[qn])}},dl=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,jt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(nn.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[je]:{writable:!0,enumerable:!1,configurable:!1,value:null},[qn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var fl=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[je].type.children.map(e=>e.name)}has(t,e){return t[je].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[je].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[je].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=jt.visit(t[je].children[n],t[qn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[je].type.children.findIndex(s=>s.name===e);return i!==-1?(Zt.visit(t[je].children[i],t[qn],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 X(r){return(t,e)=>t.getValid(e)?r(t,e):null}var I_=(r,t)=>864e5*r[t],F_=(r,t)=>null,Hu=(r,t,e)=>{if(e+1>=t.length)return null;let n=pt(t[e]),i=pt(t[e+1]);return r.subarray(n,i)},B_=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Vu=({values:r},t)=>I_(r,t),Wu=({values:r},t)=>pt(r[t]),sn=({stride:r,values:t},e)=>t[r*e],D_=({stride:r,values:t},e)=>to(t[r*e]),zu=({values:r},t)=>r[t],A_=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),ju=({values:r,valueOffsets:t},e)=>Hu(r,t,e),$u=({values:r,valueOffsets:t},e)=>{let n=Hu(r,t,e);return n!==null?Si(n):null},T_=({values:r},t)=>r[t],x_=({type:r,values:t},e)=>r.precision!==At.HALF?t[e]:to(t[e]),E_=(r,t)=>r.type.unit===Wt.DAY?Vu(r,t):Wu(r,t),Gu=({values:r},t)=>1e3*pt(r[t]),Ku=({values:r},t)=>pt(r[t]),qu=({values:r},t)=>Za(r[t],BigInt(1e3)),Yu=({values:r},t)=>Za(r[t],BigInt(1e6)),U_=(r,t)=>{switch(r.type.unit){case k.SECOND:return Gu(r,t);case k.MILLISECOND:return Ku(r,t);case k.MICROSECOND:return qu(r,t);case k.NANOSECOND:return Yu(r,t)}},Ju=({values:r},t)=>r[t],Xu=({values:r},t)=>r[t],Zu=({values:r},t)=>r[t],Qu=({values:r},t)=>r[t],O_=(r,t)=>{switch(r.type.unit){case k.SECOND:return Ju(r,t);case k.MILLISECOND:return Xu(r,t);case k.MICROSECOND:return Zu(r,t);case k.NANOSECOND:return Qu(r,t)}},M_=({values:r,stride:t},e)=>Ci.decimal(r.subarray(t*e,t*(e+1))),R_=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:a}=e,u=i[0].slice(s,a-s);return new ft([u])},L_=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,a=n[0];return new lr(a.slice(i,s-i))},N_=(r,t)=>new nn(r,t),k_=(r,t)=>r.type.mode===xt.Dense?td(r,t):ed(r,t),td=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return jt.visit(n,r.valueOffsets[t])},ed=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return jt.visit(n,t)},C_=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},P_=(r,t)=>r.type.unit===qt.DAY_TIME?rd(r,t):nd(r,t),rd=({values:r},t)=>r.subarray(2*t,2*(t+1)),nd=({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},id=({values:r},t)=>r[t],sd=({values:r},t)=>r[t],od=({values:r},t)=>r[t],ad=({values:r},t)=>r[t],H_=(r,t)=>{switch(r.type.unit){case k.SECOND:return id(r,t);case k.MILLISECOND:return sd(r,t);case k.MICROSECOND:return od(r,t);case k.NANOSECOND:return ad(r,t)}},V_=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new ft([s])};j.prototype.visitNull=X(F_);j.prototype.visitBool=X(B_);j.prototype.visitInt=X(T_);j.prototype.visitInt8=X(sn);j.prototype.visitInt16=X(sn);j.prototype.visitInt32=X(sn);j.prototype.visitInt64=X(zu);j.prototype.visitUint8=X(sn);j.prototype.visitUint16=X(sn);j.prototype.visitUint32=X(sn);j.prototype.visitUint64=X(zu);j.prototype.visitFloat=X(x_);j.prototype.visitFloat16=X(D_);j.prototype.visitFloat32=X(sn);j.prototype.visitFloat64=X(sn);j.prototype.visitUtf8=X($u);j.prototype.visitLargeUtf8=X($u);j.prototype.visitBinary=X(ju);j.prototype.visitLargeBinary=X(ju);j.prototype.visitFixedSizeBinary=X(A_);j.prototype.visitDate=X(E_);j.prototype.visitDateDay=X(Vu);j.prototype.visitDateMillisecond=X(Wu);j.prototype.visitTimestamp=X(U_);j.prototype.visitTimestampSecond=X(Gu);j.prototype.visitTimestampMillisecond=X(Ku);j.prototype.visitTimestampMicrosecond=X(qu);j.prototype.visitTimestampNanosecond=X(Yu);j.prototype.visitTime=X(O_);j.prototype.visitTimeSecond=X(Ju);j.prototype.visitTimeMillisecond=X(Xu);j.prototype.visitTimeMicrosecond=X(Zu);j.prototype.visitTimeNanosecond=X(Qu);j.prototype.visitDecimal=X(M_);j.prototype.visitList=X(R_);j.prototype.visitStruct=X(N_);j.prototype.visitUnion=X(k_);j.prototype.visitDenseUnion=X(td);j.prototype.visitSparseUnion=X(ed);j.prototype.visitDictionary=X(C_);j.prototype.visitInterval=X(P_);j.prototype.visitIntervalDayTime=X(rd);j.prototype.visitIntervalYearMonth=X(nd);j.prototype.visitDuration=X(H_);j.prototype.visitDurationSecond=X(id);j.prototype.visitDurationMillisecond=X(sd);j.prototype.visitDurationMicrosecond=X(od);j.prototype.visitDurationNanosecond=X(ad);j.prototype.visitFixedSizeList=X(V_);j.prototype.visitMap=X(L_);var jt=new j;var on=Symbol.for("keys"),Jn=Symbol.for("vals"),Yn=Symbol.for("kKeysAsStrings"),hl=Symbol.for("_kKeysAsStrings"),lr=class{constructor(t){return this[on]=new ft([t.children[0]]).memoize(),this[Jn]=t.children[1],new Proxy(this,new ml)}get[Yn](){return this[hl]||(this[hl]=Array.from(this[on].toArray(),String))}[Symbol.iterator](){return new pl(this[on],this[Jn])}get size(){return this[on].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[on],e=this[Jn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=jt.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()}},pl=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),jt.visit(this.vals,t)]})}},ml=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Yn]}has(t,e){return t[Yn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Yn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[Yn].indexOf(e);if(n!==-1){let i=jt.visit(Reflect.get(t,Jn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[Yn].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(lr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[on]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Jn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[hl]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var ld;function Hi(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,a=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(ld=s,s=a,a=ld),a>i&&(a=i),n?n(r,s,a):[s,a]}var bn=(r,t)=>r<0?t+r:r,cd=r=>r!==r;function an(r){if(typeof r!=="object"||r===null)return cd(r)?cd: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?Ka(r,e):!1:r instanceof Map?z_(r):Array.isArray(r)?W_(r):r instanceof ft?j_(r):$_(r,!0)}function W_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=an(r[e]);return bo(t)}function z_(r){let t=-1,e=[];for(let n of r.values())e[++t]=an(n);return bo(e)}function j_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=an(r.get(e));return bo(t)}function $_(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]=an(r[e[i]]);return bo(n,e)}function bo(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return G_(r,e);case Map:return ud(r,e,e.keys());case lr:case nn:case Object:case void 0:return ud(r,e,t||Object.keys(e))}return e instanceof ft?K_(r,e):!1}}function G_(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 K_(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 ud(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](),a=0,l=r.length,u=s.next(),f=n.next(),h=i.next();for(;a<l&&!f.done&&!h.done&&!u.done&&!(f.value!==h.value||!r[a](u.value));++a,f=n.next(),h=i.next(),u=s.next());return a===l&&f.done&&h.done&&u.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var yl={};qr(yl,{BitIterator:()=>gn,getBit:()=>dd,getBool:()=>wo,packBools:()=>vn,popcnt_array:()=>fd,popcnt_bit_range:()=>Vi,popcnt_uint32:()=>go,setBool:()=>q_,truncateBitmap:()=>wn});function wo(r,t,e,n){return(e&1<<n)!==0}function dd(r,t,e,n){return(e&1<<n)>>n}function q_(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function wn(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):vn(new gn(e,r,t,null,wo)).subarray(0,n)),i}return e}function vn(r){let t=[],e=0,n=0,i=0;for(let a of r)a&&(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 gn=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 Vi(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let a of new gn(r,t,e-t,r,dd))s+=a;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Vi(r,t,i)+Vi(r,n,e)+fd(r,i>>3,n-i>>3)}function fd(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),a=e===void 0?r.byteLength:i+e;for(;a-i>=4;)n+=go(s.getUint32(i)),i+=4;for(;a-i>=2;)n+=go(s.getUint16(i)),i+=2;for(;a-i>=1;)n+=go(s.getUint8(i)),i+=1;return n}function go(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 Y_=-1,wt=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((a,l)=>a+l.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<=Y_&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Vi(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,a=[],l){this.type=t,this.children=a,this.dictionary=l,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let u;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&&((u=s[0])&&(this.valueOffsets=u),(u=s[1])&&(this.values=u),(u=s[2])&&(this.nullBitmap=u),(u=s[3])&&(this.typeIds=u)))}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,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],l=s.mode===xt.Dense?this.valueOffsets[t]:t;n=a.getValid(l),a.setValid(l,e)}else{let{nullBitmap:s}=this,{offset:a,length:l}=this,u=a+t,f=1<<u%8,h=u>>3;(!s||s.byteLength<=h)&&(s=new Uint8Array((a+l+63&-64)>>3).fill(255),this.nullCount>0?(s.set(wn(a,l,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let v=s[h];n=(v&f)!==0,s[h]=e?v|f:v&~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,a=this.children){return new r(t,e,n,i,s,a,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,l=i===16?n:1,u=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,a,u,s.length===0||this.valueOffsets?s:this._sliceChildren(s,l*t,l*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===p.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(wn(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:a}=this;return(s=a[Ie.TYPE])&&(a[Ie.TYPE]=s.subarray(t,t+e)),(s=a[Ie.OFFSET])&&(a[Ie.OFFSET]=s.subarray(t,t+e+1))||(s=a[Ie.DATA])&&(a[Ie.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),a}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};wt.prototype.children=Object.freeze([]);var bl=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 wt(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=ks(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.data),s=J(t.nullBitmap),a=ks(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=J(t.nullBitmap),{length:a=i.reduce((u,{length:f})=>Math.max(u,f),0),nullCount:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=ot(e.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:l=-1}=t;if(L.isSparseUnion(e))return new wt(e,n,a,l,[void 0,void 0,void 0,s],i);let u=_n(t.valueOffsets);return new wt(e,n,a,l,[u,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.indices.ArrayType,t.data),{["dictionary"]:a=new ft([new r().visit({type:e.dictionary})])}=t,{["length"]:l=s.length,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[void 0,s,i],[],a)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=J(t.nullBitmap),s=ot(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=J(t.nullBitmap),{["length"]:a=i.length/be(e),["nullCount"]:l=t.nullBitmap?-1:0}=t;return new wt(e,n,a,l,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.childType})}=t,s=J(t.nullBitmap),a=_n(t.valueOffsets),{["length"]:l=a.length-1,["nullCount"]:u=t.nullBitmap?-1:0}=t;return new wt(e,n,l,u,[a,void 0,s],[i])}},J_=new bl;function rt(r){return J_.visit(r)}var Wi=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 hd(r){return r.some(t=>t.nullable)}function vo(r){return r.reduce((t,e)=>t+e.nullCount,0)}function So(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function Io(r,t,e,n){let i=[];for(let s=-1,a=r.length;++s<a;){let l=r[s],u=t[s],{length:f}=l;if(u>=n)break;if(e>=u+f)continue;if(u>=e&&u+f<=n){i.push(l);continue}let h=Math.max(0,e-u),v=Math.min(n-u,f);i.push(l.slice(h,v-h))}return i.length===0&&i.push(r[0].slice(0,0)),i}function gl(r,t,e,n){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return e<t[a]?n(r,i,e-t[i]):null;s=i+Math.trunc((a-i)*.5),e<t[s]?a=s:i=s}while(i<a)}function zi(r,t){return r.getValid(t)}function Xn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return gl(n,this._offsets,e,t)}}function Fo(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 a=gl(s,this._offsets,n,e);return t=void 0,a}}function Bo(r){let t;function e(n,i,s){let a=s,l=0,u=0;for(let f=i-1,h=n.length;++f<h;){let v=n[f];if(~(l=r(v,t,a)))return u+l;a=0,u+=v.length}return-1}return function(n,i){t=n;let s=this.data,a=typeof i!="number"?e(s,0,0):gl(s,this._offsets,i,e);return t=void 0,a}}var $=class extends z{};function X_(r,t){return t===null&&r.length>0?0:-1}function Z_(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new gn(e,r.offset+(t||0),r.length,e,wo)){if(!i)return n;++n}return-1}function nt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case p.Union:break;case p.Dictionary:break;default:return Z_(r,e)}let n=jt.getVisitFn(r),i=an(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}function pd(r,t,e){let n=jt.getVisitFn(r),i=an(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}$.prototype.visitNull=X_;$.prototype.visitBool=nt;$.prototype.visitInt=nt;$.prototype.visitInt8=nt;$.prototype.visitInt16=nt;$.prototype.visitInt32=nt;$.prototype.visitInt64=nt;$.prototype.visitUint8=nt;$.prototype.visitUint16=nt;$.prototype.visitUint32=nt;$.prototype.visitUint64=nt;$.prototype.visitFloat=nt;$.prototype.visitFloat16=nt;$.prototype.visitFloat32=nt;$.prototype.visitFloat64=nt;$.prototype.visitUtf8=nt;$.prototype.visitLargeUtf8=nt;$.prototype.visitBinary=nt;$.prototype.visitLargeBinary=nt;$.prototype.visitFixedSizeBinary=nt;$.prototype.visitDate=nt;$.prototype.visitDateDay=nt;$.prototype.visitDateMillisecond=nt;$.prototype.visitTimestamp=nt;$.prototype.visitTimestampSecond=nt;$.prototype.visitTimestampMillisecond=nt;$.prototype.visitTimestampMicrosecond=nt;$.prototype.visitTimestampNanosecond=nt;$.prototype.visitTime=nt;$.prototype.visitTimeSecond=nt;$.prototype.visitTimeMillisecond=nt;$.prototype.visitTimeMicrosecond=nt;$.prototype.visitTimeNanosecond=nt;$.prototype.visitDecimal=nt;$.prototype.visitList=nt;$.prototype.visitStruct=nt;$.prototype.visitUnion=nt;$.prototype.visitDenseUnion=pd;$.prototype.visitSparseUnion=pd;$.prototype.visitDictionary=nt;$.prototype.visitInterval=nt;$.prototype.visitIntervalDayTime=nt;$.prototype.visitIntervalYearMonth=nt;$.prototype.visitDuration=nt;$.prototype.visitDurationSecond=nt;$.prototype.visitDurationMillisecond=nt;$.prototype.visitDurationMicrosecond=nt;$.prototype.visitDurationNanosecond=nt;$.prototype.visitFixedSizeList=nt;$.prototype.visitMap=nt;var Sn=new $;var G=class extends z{};function Z(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 Wi(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Wi(r.data.length,n=>{let s=r.data[n].length,a=r.slice(e,e+s);return e+=s,new wl(a)})}var wl=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=Z;G.prototype.visitBool=Z;G.prototype.visitInt=Z;G.prototype.visitInt8=Z;G.prototype.visitInt16=Z;G.prototype.visitInt32=Z;G.prototype.visitInt64=Z;G.prototype.visitUint8=Z;G.prototype.visitUint16=Z;G.prototype.visitUint32=Z;G.prototype.visitUint64=Z;G.prototype.visitFloat=Z;G.prototype.visitFloat16=Z;G.prototype.visitFloat32=Z;G.prototype.visitFloat64=Z;G.prototype.visitUtf8=Z;G.prototype.visitLargeUtf8=Z;G.prototype.visitBinary=Z;G.prototype.visitLargeBinary=Z;G.prototype.visitFixedSizeBinary=Z;G.prototype.visitDate=Z;G.prototype.visitDateDay=Z;G.prototype.visitDateMillisecond=Z;G.prototype.visitTimestamp=Z;G.prototype.visitTimestampSecond=Z;G.prototype.visitTimestampMillisecond=Z;G.prototype.visitTimestampMicrosecond=Z;G.prototype.visitTimestampNanosecond=Z;G.prototype.visitTime=Z;G.prototype.visitTimeSecond=Z;G.prototype.visitTimeMillisecond=Z;G.prototype.visitTimeMicrosecond=Z;G.prototype.visitTimeNanosecond=Z;G.prototype.visitDecimal=Z;G.prototype.visitList=Z;G.prototype.visitStruct=Z;G.prototype.visitUnion=Z;G.prototype.visitDenseUnion=Z;G.prototype.visitSparseUnion=Z;G.prototype.visitDictionary=Z;G.prototype.visitInterval=Z;G.prototype.visitIntervalDayTime=Z;G.prototype.visitIntervalYearMonth=Z;G.prototype.visitDuration=Z;G.prototype.visitDurationSecond=Z;G.prototype.visitDurationMillisecond=Z;G.prototype.visitDurationMicrosecond=Z;G.prototype.visitDurationNanosecond=Z;G.prototype.visitFixedSizeList=Z;G.prototype.visitMap=Z;var Zn=new G;var md,_d={},yd={},ft=class r{constructor(t){var e,n,i;let s=t[0]instanceof r?t.flatMap(l=>l.data):t;if(s.length===0||s.some(l=>!(l instanceof wt)))throw new TypeError("Vector constructor expects an Array of Data instances.");let a=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:l,set:u,indexOf:f}=_d[a.typeId],h=s[0];this.isValid=v=>zi(h,v),this.get=v=>l(h,v),this.set=(v,A)=>u(h,v,A),this.indexOf=v=>f(h,v),this._offsets=[0,h.length];break}default:Object.setPrototypeOf(this,yd[a.typeId]),this._offsets=So(s);break}this.data=s,this.type=a,this.stride=be(a),this.numChildren=(i=(n=a.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 hd(this.data)}get nullCount(){return vo(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return"".concat(this.VectorName,"<").concat(this.type[Symbol.toStringTag],">")}get VectorName(){return"".concat(p[this.type.typeId],"Vector")}isValid(t){return!1}get(t){return null}at(t){return this.get(bn(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Zn.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(Hi(this,t,e,({data:n,_offsets:i},s,a)=>Io(n,i,s,a)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((a,{values:l,length:u})=>(a.array.set(l.subarray(0,u*i),a.offset),a.offset+=u*i,a),{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 Do(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new Do(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}};md=Symbol.toStringTag;ft[md]=(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(p).map(e=>p[e]).filter(e=>typeof e=="number"&&e!==p.NONE);for(let e of t){let n=jt.getVisitFnByTypeId(e),i=Zt.getVisitFnByTypeId(e),s=Sn.getVisitFnByTypeId(e);_d[e]={get:n,set:i,indexOf:s},yd[e]=Object.create(r,{isValid:{value:Xn(zi)},get:{value:Xn(jt.getVisitFnByTypeId(e))},set:{value:Fo(Zt.getVisitFnByTypeId(e))},indexOf:{value:Bo(Sn.getVisitFnByTypeId(e))}})}return"Vector"})(ft.prototype);var Do=class r extends ft{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(a){let l=s[a];if(l!==void 0)return l;let u=e.call(this,a);return s[a]=u,u}}),Object.defineProperty(this,"set",{value(a,l){n.call(this,a,l),s[a]=l}}),Object.defineProperty(this,"slice",{value:(a,l)=>new r(i.call(this,a,l))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new ft(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function bd(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(Q_(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 Q_(r){return typeof r!="bigint"?Ce(r):"".concat(Ce(r),"n")}function vl(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function gd(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?vl(n*1,this.BYTES_PER_ELEMENT):vl(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=vl(t*this.stride,this.BYTES_PER_ELEMENT);let e=gd(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=gd(this.buffer,t)}},Or=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}},Qn=class extends Or{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,a=n[i]>>s&1;return e?a===0&&(n[i]|=1<<s,++this.numValid):a===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},ti=class extends Or{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 Nt=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 Qn,e&&e.length>0&&(this._isValid=bd(e))}toVector(){return new ft([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:a}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),a.reduce((l,u)=>l+u.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:a,nullCount:l,_typeIds:u,_offsets:f,_values:h,_nulls:v}=this;(e=u==null?void 0:u.flush(a))?i=f==null?void 0:f.flush(a):(i=f==null?void 0:f.flush(a))?t=h==null?void 0:h.flush(f.last()):t=h==null?void 0:h.flush(a),l>0&&(n=v==null?void 0:v.flush(a));let A=this.children.map(E=>E.flush());return this.clear(),rt({type:s,length:a,nullCount:l,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}};Nt.prototype.length=1;Nt.prototype.stride=1;Nt.prototype.children=null;Nt.prototype.finished=!1;Nt.prototype.nullValues=null;Nt.prototype._isValid=()=>!0;var $t=class extends Nt{constructor(t){super(t),this._values=new Or(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 Nt{constructor(t){super(t),this._pendingLength=0,this._offsets=new ti(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 lr?e[on].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 In=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):St.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new le).__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 In).__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 In).__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,St.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 Ft=class r{constructor(t=[],e,n,i=St.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Sl(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=Ao(Ao(new Map,this.metadata),e.metadata),s=e.fields.filter(l=>{let u=n.findIndex(f=>f.name===l.name);return~u?(n[u]=l.clone({metadata:Ao(Ao(new Map,n[u].metadata),l.metadata)}))&&!1:!0}),a=Sl(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...a]))}};Ft.prototype.fields=null;Ft.prototype.metadata=null;Ft.prototype.dictionaries=null;var lt=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)}};lt.prototype.type=null;lt.prototype.name=null;lt.prototype.nullable=null;lt.prototype.metadata=null;function Ao(r,t){return new Map([...r||new Map,...t||new Map])}function Sl(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&&Sl(s.children,t)}return t}var ty=yn,ey=me,Mr=class{static decode(t){t=new ey(J(t));let e=ge.getRootAsFooter(t),n=Ft.decode(e.schema(),new Map,e.version());return new Il(n,e)}static encode(t){let e=new ty,n=Ft.encode(e,t.schema);ge.startRecordBatchesVector(e,t.numRecordBatches);for(let a of[...t.recordBatches()].slice().reverse())Rr.encode(e,a);let i=e.endVector();ge.startDictionariesVector(e,t.numDictionaries);for(let a of[...t.dictionaryBatches()].slice().reverse())Rr.encode(e,a);let s=e.endVector();return ge.startFooter(e),ge.addSchema(e,n),ge.addVersion(e,St.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=St.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 Il=class extends Mr{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 Rr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Rr.decode(e)}return null}},Rr=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 In.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=pt(n),this.bodyLength=pt(e)}};var Lt=Object.freeze({done:!0,value:void 0}),ji=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Fn=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())}},To=class extends Fn{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(Lt);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),Lt})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),Lt})}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(Lt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var cr=class extends To{write(t){if((t=J(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Si(this.toUint8Array(!0)):this.toUint8Array(!1).then(Si)}toUint8Array(t=!1){return t?pe(this._values)[0]:R(this,void 0,void 0,function*(){var e,n,i,s;let a=[],l=0;try{for(var u=!0,f=Ue(this),h;h=yield f.next(),e=h.done,!e;u=!0){s=h.value,u=!1;let v=s;a.push(v),l+=v.byteLength}}catch(v){n={error:v}}finally{try{!u&&!e&&(i=f.return)&&(yield i.call(f))}finally{if(n)throw n.error}}return pe(a,l)[0]})}},ur=class{constructor(t){t&&(this.source=new Fl(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 cr?this.source=new Lr(Xt.fromAsyncIterable(t)):Ns(t)?this.source=new Lr(Xt.fromNodeStream(t)):Ii(t)?this.source=new Lr(Xt.fromDOMStream(t)):Rs(t)?this.source=new Lr(Xt.fromDOMStream(t.body)):Me(t)?this.source=new Lr(Xt.fromIterable(t)):Oe(t)?this.source=new Lr(Xt.fromAsyncIterable(t)):ve(t)&&(this.source=new Lr(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)}},Fl=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)||Lt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Lt)}},Lr=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))||Lt;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))||Lt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var $i=class extends ur{constructor(t,e){super(),this.position=0,this.buffer=J(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}}},ln=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,a=0,l=0,u=Math.min(n,s+Math.min(n-s,t)),f=new Uint8Array(Math.max(0,(this.position=u)-s));for(;(s+=l)<u&&(a+=l)<f.byteLength;)({bytesRead:l}=yield e.read(f,a,f.byteLength-a,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),a=new Uint8Array(s-t);return(yield n.read(a,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 Dl={};qr(Dl,{BaseInt64:()=>Gi,Int128:()=>Ki,Int64:()=>Nr,Uint64:()=>Ht});function ei(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var ri=8,Bl=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Gi=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(ei(this.buffer[1])," ").concat(ei(this.buffer[0]))}},Ht=class r extends Gi{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 a=ri<n-s?ri:n-s,l=new r(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),u=new r(new Uint32Array([Bl[a],0]));i.times(u),i.plus(l),s+=a}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)}},Nr=class r extends Gi{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 a=n?1:0;a<i;){let l=ri<i-a?ri:i-a,u=new r(new Uint32Array([Number.parseInt(t.slice(a,a+l),10),0])),f=new r(new Uint32Array([Bl[l],0]));s.times(f),s.plus(u),a+=l}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)}},Ki=class r{constructor(t){this.buffer=t}high(){return new Nr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Nr(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 Ht(new Uint32Array([this.buffer[3],0])),n=new Ht(new Uint32Array([this.buffer[2],0])),i=new Ht(new Uint32Array([this.buffer[1],0])),s=new Ht(new Uint32Array([this.buffer[0],0])),a=new Ht(new Uint32Array([t.buffer[3],0])),l=new Ht(new Uint32Array([t.buffer[2],0])),u=new Ht(new Uint32Array([t.buffer[1],0])),f=new Ht(new Uint32Array([t.buffer[0],0])),h=Ht.multiply(s,f);this.buffer[0]=h.low();let v=new Ht(new Uint32Array([h.high(),0]));return h=Ht.multiply(i,f),v.plus(h),h=Ht.multiply(s,u),v.plus(h),this.buffer[1]=v.low(),this.buffer[3]=v.lessThan(h)?1:0,this.buffer[2]=v.high(),new Ht(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ht.multiply(n,f)).plus(Ht.multiply(i,u)).plus(Ht.multiply(s,l)),this.buffer[3]+=Ht.multiply(e,f).plus(Ht.multiply(n,u)).plus(Ht.multiply(i,l)).plus(Ht.multiply(s,a)).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(ei(this.buffer[3])," ").concat(ei(this.buffer[2])," ").concat(ei(this.buffer[1])," ").concat(ei(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 a=n?1:0;a<i;){let l=ri<i-a?ri:i-a,u=new r(new Uint32Array([Number.parseInt(t.slice(a,a+l),10),0,0,0])),f=new r(new Uint32Array([Bl[l],0,0,0]));s.times(f),s.plus(u),a+=l}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 qi=class extends z{constructor(t,e,n,i,s=St.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 lt?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return rt({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({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 rt({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 rt({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 rt({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 rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({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 rt({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<St.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 rt({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 rt({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({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 rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return rt({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 rt({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)}},xo=class extends qi{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):vn(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return ot(Uint8Array,ot(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return ot(Uint8Array,ot(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return L.isTimestamp(t)?ot(Uint8Array,Nr.convertArray(n[e])):(L.isInt(t)||L.isTime(t))&&t.bitWidth===64||L.isDuration(t)?ot(Uint8Array,Nr.convertArray(n[e])):L.isDate(t)&&t.unit===Wt.MILLISECOND?ot(Uint8Array,Nr.convertArray(n[e])):L.isDecimal(t)?ot(Uint8Array,Ki.convertArray(n[e])):L.isBinary(t)||L.isLargeBinary(t)||L.isFixedSizeBinary(t)?ry(n[e]):L.isBool(t)?vn(n[e]):L.isUtf8(t)||L.isLargeUtf8(t)?rr(n[e].join("")):ot(Uint8Array,ot(t.ArrayType,n[e].map(i=>+i)))}};function ry(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 ni=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,J(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,l]of t)if(l===void 0)n.set(a,0);else{let u=l.length;i.set(l,s),n.set(a,u),s+=u}}};var ii=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,J(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,l]of t)if(l===void 0)n.set(a,BigInt(0));else{let u=l.length;i.set(l,s),n.set(a,BigInt(u)),s+=u}}};var Eo=class extends Nt{constructor(t){super(t),this._values=new Qn}setValue(t,e){this._values.set(t,+e)}};var Bn=class extends $t{};Bn.prototype._setValue=sl;var Yi=class extends Bn{};Yi.prototype._setValue=eo;var Ji=class extends Bn{};Ji.prototype._setValue=ro;var Xi=class extends $t{};Xi.prototype._setValue=ll;var Uo=class extends Nt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new ye(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Dn({type:this.type.indices,nullValues:e}),this.dictionary=Dn({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 Zi=class extends $t{};Zi.prototype._setValue=il;var Oo=class extends Nt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,a=e.length;++s<a;)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 We(this.type.listSize,new lt(e,t.type,!0)),n}};var An=class extends $t{setValue(t,e){this._values.set(t,e)}},Mo=class extends An{setValue(t,e){super.setValue(t,Pi(e))}},Ro=class extends An{},Lo=class extends An{};var Tn=class extends $t{};Tn.prototype._setValue=cl;var Qi=class extends Tn{};Qi.prototype._setValue=fo;var ts=class extends Tn{};ts.prototype._setValue=ho;var kr=class extends $t{};kr.prototype._setValue=ul;var es=class extends kr{};es.prototype._setValue=po;var rs=class extends kr{};rs.prototype._setValue=mo;var ns=class extends kr{};ns.prototype._setValue=_o;var is=class extends kr{};is.prototype._setValue=yo;var De=class extends $t{setValue(t,e){this._values.set(t,e)}},No=class extends De{},ko=class extends De{},Co=class extends De{},Po=class extends De{},Ho=class extends De{},Vo=class extends De{},Wo=class extends De{},zo=class extends De{};var jo=class extends ce{constructor(t){super(t),this._offsets=new ti(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 He(new lt(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 a=s,l=a.length,u=e.set(i,l).buffer[i];for(let f=-1;++f<l;)n.set(u+f,a[f])}}};var $o=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 ze(new lt(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]:a,[i+1]:l}=e.set(i,s.size).buffer;for(let u of s.entries())if(n.set(a,u),++a>=l)break}}};var Go=class extends Nt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Ko=class extends Nt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,a)=>n[a].set(t,e[a]));case Map:return i.children.forEach((s,a)=>n[a].set(t,e.get(s.name)));default:return i.children.forEach((s,a)=>n[a].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 Rt([...this.type.children,new lt(e,t.type,!0)]),n}};var Cr=class extends $t{};Cr.prototype._setValue=ol;var ss=class extends Cr{};ss.prototype._setValue=no;var os=class extends Cr{};os.prototype._setValue=io;var as=class extends Cr{};as.prototype._setValue=so;var ls=class extends Cr{};ls.prototype._setValue=oo;var Pr=class extends $t{};Pr.prototype._setValue=al;var cs=class extends Pr{};cs.prototype._setValue=ao;var us=class extends Pr{};us.prototype._setValue=lo;var ds=class extends Pr{};ds.prototype._setValue=co;var fs=class extends Pr{};fs.prototype._setValue=uo;var si=class extends Nt{constructor(t){super(t),this._typeIds=new Or(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:a}}=this,l=[...i,new lt(e,t.type)];return this.type=new Ve(s,[...a,n],l),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.")}},qo=class extends si{},Yo=class extends si{constructor(t){super(t),this._offsets=new Or(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),a=this._offsets.set(t,s.length).buffer[t];s==null||s.set(a,e)}};var hs=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,rr(e))}_flushPending(t,e){}};hs.prototype._flushPending=ni.prototype._flushPending;var ps=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,rr(e))}_flushPending(t,e){}};ps.prototype._flushPending=ii.prototype._flushPending;var Al=class extends z{visitNull(){return Go}visitBool(){return Eo}visitInt(){return De}visitInt8(){return No}visitInt16(){return ko}visitInt32(){return Co}visitInt64(){return Po}visitUint8(){return Ho}visitUint16(){return Vo}visitUint32(){return Wo}visitUint64(){return zo}visitFloat(){return An}visitFloat16(){return Mo}visitFloat32(){return Ro}visitFloat64(){return Lo}visitUtf8(){return hs}visitLargeUtf8(){return ps}visitBinary(){return ni}visitLargeBinary(){return ii}visitFixedSizeBinary(){return Zi}visitDate(){return Bn}visitDateDay(){return Yi}visitDateMillisecond(){return Ji}visitTimestamp(){return Cr}visitTimestampSecond(){return ss}visitTimestampMillisecond(){return os}visitTimestampMicrosecond(){return as}visitTimestampNanosecond(){return ls}visitTime(){return Pr}visitTimeSecond(){return cs}visitTimeMillisecond(){return us}visitTimeMicrosecond(){return ds}visitTimeNanosecond(){return fs}visitDecimal(){return Xi}visitList(){return jo}visitStruct(){return Ko}visitUnion(){return si}visitDenseUnion(){return Yo}visitSparseUnion(){return qo}visitDictionary(){return Uo}visitInterval(){return Tn}visitIntervalDayTime(){return Qi}visitIntervalYearMonth(){return ts}visitDuration(){return kr}visitDurationSecond(){return es}visitDurationMillisecond(){return rs}visitDurationMicrosecond(){return ns}visitDurationNanosecond(){return is}visitFixedSizeList(){return Oo}visitMap(){return $o}},wd=new Al;var K=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 oe(r,t){return t instanceof r.constructor}function xn(r,t){return r===t||oe(r,t)}function Hr(r,t){return r===t||oe(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Jo(r,t){return r===t||oe(r,t)&&r.precision===t.precision}function ny(r,t){return r===t||oe(r,t)&&r.byteWidth===t.byteWidth}function Tl(r,t){return r===t||oe(r,t)&&r.unit===t.unit}function ms(r,t){return r===t||oe(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function _s(r,t){return r===t||oe(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function iy(r,t){return r===t||oe(r,t)&&r.children.length===t.children.length&&dr.compareManyFields(r.children,t.children)}function sy(r,t){return r===t||oe(r,t)&&r.children.length===t.children.length&&dr.compareManyFields(r.children,t.children)}function xl(r,t){return r===t||oe(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&dr.compareManyFields(r.children,t.children)}function oy(r,t){return r===t||oe(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&dr.visit(r.indices,t.indices)&&dr.visit(r.dictionary,t.dictionary)}function El(r,t){return r===t||oe(r,t)&&r.unit===t.unit}function ys(r,t){return r===t||oe(r,t)&&r.unit===t.unit}function ay(r,t){return r===t||oe(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&dr.compareManyFields(r.children,t.children)}function ly(r,t){return r===t||oe(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&dr.compareManyFields(r.children,t.children)}K.prototype.visitNull=xn;K.prototype.visitBool=xn;K.prototype.visitInt=Hr;K.prototype.visitInt8=Hr;K.prototype.visitInt16=Hr;K.prototype.visitInt32=Hr;K.prototype.visitInt64=Hr;K.prototype.visitUint8=Hr;K.prototype.visitUint16=Hr;K.prototype.visitUint32=Hr;K.prototype.visitUint64=Hr;K.prototype.visitFloat=Jo;K.prototype.visitFloat16=Jo;K.prototype.visitFloat32=Jo;K.prototype.visitFloat64=Jo;K.prototype.visitUtf8=xn;K.prototype.visitLargeUtf8=xn;K.prototype.visitBinary=xn;K.prototype.visitLargeBinary=xn;K.prototype.visitFixedSizeBinary=ny;K.prototype.visitDate=Tl;K.prototype.visitDateDay=Tl;K.prototype.visitDateMillisecond=Tl;K.prototype.visitTimestamp=ms;K.prototype.visitTimestampSecond=ms;K.prototype.visitTimestampMillisecond=ms;K.prototype.visitTimestampMicrosecond=ms;K.prototype.visitTimestampNanosecond=ms;K.prototype.visitTime=_s;K.prototype.visitTimeSecond=_s;K.prototype.visitTimeMillisecond=_s;K.prototype.visitTimeMicrosecond=_s;K.prototype.visitTimeNanosecond=_s;K.prototype.visitDecimal=xn;K.prototype.visitList=iy;K.prototype.visitStruct=sy;K.prototype.visitUnion=xl;K.prototype.visitDenseUnion=xl;K.prototype.visitSparseUnion=xl;K.prototype.visitDictionary=oy;K.prototype.visitInterval=El;K.prototype.visitIntervalDayTime=El;K.prototype.visitIntervalYearMonth=El;K.prototype.visitDuration=ys;K.prototype.visitDurationSecond=ys;K.prototype.visitDurationMillisecond=ys;K.prototype.visitDurationMicrosecond=ys;K.prototype.visitDurationNanosecond=ys;K.prototype.visitFixedSizeList=ay;K.prototype.visitMap=ly;var dr=new K;function En(r,t){return dr.compareSchemas(r,t)}function vd(r,t){return dr.compareFields(r,t)}function Sd(r,t){return dr.visit(r,t)}function Dn(r){let t=r.type,e=new(wd.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(a,l)=>n[l]||i:({name:a})=>n[a]||i;for(let[a,l]of t.children.entries()){let{type:u}=l,f=s(l,a);e.children.push(Dn(Object.assign(Object.assign({},f),{type:u})))}}return e}function Xo(r,t){return cy(r,t.map(e=>e.data.concat()))}function cy(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((v,A)=>Math.max(v,A.length),0)},s=0,a=0,l=-1,u=t.length,f,h=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,l=-1;++l<u;)h[l]=f=t[l].shift(),a=Math.min(a,f?f.length:a);Number.isFinite(a)&&(h=uy(e,a,h,t,i),a>0&&(n[s++]=rt({type:new Rt(e),length:a,nullCount:0,children:h.slice()})))}return[r=r.assign(e),n.map(v=>new zt(r,v))]}function uy(r,t,e,n,i){var s;let a=(t+63&-64)>>3;for(let l=-1,u=n.length;++l<u;){let f=e[l],h=f==null?void 0:f.length;if(h>=t)h===t?e[l]=f:(e[l]=f.slice(0,t),i.numBatches=Math.max(i.numBatches,n[l].unshift(f.slice(t,h-t))));else{let v=r[l];r[l]=v.clone({nullable:!0}),e[l]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:rt({type:v.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return e}var Id,ae=class r{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new Ft([]),this._offsets=[0],this;let i,s;t[0]instanceof Ft&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let a=u=>{if(u){if(u instanceof zt)return[u];if(u instanceof r)return u.batches;if(u instanceof wt){if(u.type instanceof Rt)return[new zt(new Ft(u.type.children),u)]}else{if(Array.isArray(u))return u.flatMap(f=>a(f));if(typeof u[Symbol.iterator]=="function")return[...u].flatMap(f=>a(f));if(typeof u=="object"){let f=Object.keys(u),h=f.map(E=>new ft([u[E]])),v=i!=null?i:new Ft(f.map((E,at)=>new lt(String(E),h[at].type,h[at].nullable))),[,A]=Xo(v,h);return A.length===0?[new zt(u)]:A}}}return[]},l=t.flatMap(u=>a(u));if(i=(n=i!=null?i:(e=l[0])===null||e===void 0?void 0:e.schema)!==null&&n!==void 0?n:new Ft([]),!(i instanceof Ft))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let u of l){if(!(u instanceof zt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!En(i,u.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=l,this._offsets=s!=null?s:So(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=vo(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(bn(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Zn.visit(new ft(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 zt(e,i)))}slice(t,e){let n=this.schema;[t,e]=Hi({length:this.numRows},t,e);let i=Io(this.data,this._offsets,t,e);return new r(n,i.map(s=>new zt(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=rt({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new ft(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 ft([rt({type:new se,length:this.numRows})]));let s=n.fields.slice(),a=s[t].clone({type:e.type}),l=this.schema.fields.map((u,f)=>this.getChildAt(f));[s[t],l[t]]=[a,e],[n,i]=Xo(n,l)}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((l,u,f)=>{let[h,v]=l,A=e.findIndex(E=>E.name===u.name);return~A?v[A]=f:h.push(f),l},[[],[]]),s=this.schema.assign(t.schema),a=[...e.map((l,u)=>[u,i[u]]).map(([l,u])=>u===void 0?this.getChildAt(l):t.getChildAt(u)),...n.map(l=>t.getChildAt(l))].filter(Boolean);return new r(...Xo(s,a))}};Id=Symbol.toStringTag;ae[Id]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Xn(zi),r.get=Xn(jt.getVisitFn(p.Struct)),r.set=Fo(Zt.getVisitFn(p.Struct)),r.indexOf=Bo(Sn.getVisitFn(p.Struct)),"Table"))(ae.prototype);var Bd,zt=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Ft))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=rt({nullCount:0,type:new Rt(this.schema.fields),children:this.schema.fields.map(e=>rt({type:e.type,nullCount:0}))})]=t,!(this.data instanceof wt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Fd(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((u,f,h)=>(u.children[h]=e[f],u.length=Math.max(u.length,e[f].length),u.fields[h]=lt.new({name:f,type:e[f].type,nullable:!0}),u),{length:0,fields:new Array,children:new Array}),a=new Ft(n),l=rt({type:new Rt(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Fd(a,l.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=Dd(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 jt.visit(this.data,t)}at(t){return this.get(bn(t,this.numRows))}set(t,e){return Zt.visit(this.data,t,e)}indexOf(t,e){return Sn.visit(this.data,t,e)}[Symbol.iterator](){return Zn.visit(new ft([this.data]))}toArray(){return[...this]}concat(...t){return new ae(this.schema,[this,...t])}slice(t,e){let[n]=new ft([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 ft([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 ft([rt({type:new se,length:this.numRows})]));let s=n.fields.slice(),a=i.children.slice(),l=s[t].clone({type:e.type});[s[t],a[t]]=[l,e.data[0]],n=new Ft(s,new Map(this.schema.metadata)),i=rt({type:new Rt(s),children:a})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Rt(e.fields),i=[];for(let s of t){let a=this.schema.fields.findIndex(l=>l.name===s);~a&&(i[a]=this.data.children[a])}return new r(e,rt({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=rt({type:new Rt(e.fields),length:this.numRows,children:n});return new r(e,i)}};Bd=Symbol.toStringTag;zt[Bd]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(zt.prototype);function Fd(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],a=(e+63&-64)>>3;for(let[l,u]of r.fields.entries()){let f=t[l];(!f||f.length!==e)&&(i[l]=u.clone({nullable:!0}),s[l]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:rt({type:u.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)}))}return[r.assign(i),rt({type:new Rt(i),length:e,children:s})]}function Dd(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,a=r.length;++s<a;){let{type:l}=r[s],u=t[s];for(let f of[u,...((i=u==null?void 0:u.dictionary)===null||i===void 0?void 0:i.data)||[]])Dd(l.children,f==null?void 0:f.children,e);if(L.isDictionary(l)){let{id:f}=l;if(!e.has(f))u!=null&&u.dictionary&&e.set(f,u.dictionary);else if(e.get(f)!==u.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Un=class extends zt{constructor(t){let e=t.fields.map(i=>rt({type:i.type})),n=rt({type:new Rt(t.fields),nullCount:0,children:e});super(t,n)}};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 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):St.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ct.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,St.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,ct.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,a){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,a),r.endMessage(t)}};var Ul=class extends z{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Ri.startNull(e),Ri.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 tn.startFloatingPoint(e),tn.addPrecision(e,t.precision),tn.endFloatingPoint(e)}visitBinary(t,e){return xi.startBinary(e),xi.endBinary(e)}visitLargeBinary(t,e){return Ui.startLargeBinary(e),Ui.endLargeBinary(e)}visitBool(t,e){return Ei.startBool(e),Ei.endBool(e)}visitUtf8(t,e){return Ni.startUtf8(e),Ni.endUtf8(e)}visitLargeUtf8(t,e){return Oi.startLargeUtf8(e),Oi.endLargeUtf8(e)}visitDecimal(t,e){return or.startDecimal(e),or.addScale(e,t.scale),or.addPrecision(e,t.precision),or.addBitWidth(e,t.bitWidth),or.endDecimal(e)}visitDate(t,e){return Jr.startDate(e),Jr.addUnit(e,t.unit),Jr.endDate(e)}visitTime(t,e){return yr.startTime(e),yr.addUnit(e,t.unit),yr.addBitWidth(e,t.bitWidth),yr.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return br.startTimestamp(e),br.addUnit(e,t.unit),n!==void 0&&br.addTimezone(e,n),br.endTimestamp(e)}visitInterval(t,e){return en.startInterval(e),en.addUnit(e,t.unit),en.endInterval(e)}visitDuration(t,e){return Xr.startDuration(e),Xr.addUnit(e,t.unit),Xr.endDuration(e)}visitList(t,e){return Mi.startList(e),Mi.endList(e)}visitStruct(t,e){return Li.startStruct_(e),Li.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 sr.startDictionaryEncoding(e),sr.addId(e,BigInt(t.id)),sr.addIsOrdered(e,t.isOrdered),n!==void 0&&sr.addIndexType(e,n),sr.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Zr.startFixedSizeBinary(e),Zr.addByteWidth(e,t.byteWidth),Zr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Qr.startFixedSizeList(e),Qr.addListSize(e,t.listSize),Qr.endFixedSizeList(e)}visitMap(t,e){return rn.startMap(e),rn.addKeysSorted(e,t.keysSorted),rn.endMap(e)}},Zo=new Ul;function Ed(r,t=new Map){return new Ft(fy(r,t),Qo(r.metadata),t)}function Ol(r){return new Qt(r.count,Od(r.columns),Md(r.columns))}function Ud(r){return new de(Ol(r.data),r.id,r.isDelta)}function fy(r,t){return(r.fields||[]).filter(Boolean).map(e=>lt.fromJSON(e,t))}function Ad(r,t){return(r.children||[]).filter(Boolean).map(e=>lt.fromJSON(e,t))}function Od(r){return(r||[]).reduce((t,e)=>[...t,new Ae(e.count,hy(e.VALIDITY)),...Od(e.children)],[])}function Md(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new ue(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new ue(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new ue(t.length,i.OFFSET.length)),i.DATA&&t.push(new ue(t.length,i.DATA.length)),t=Md(i.children,t)}return t}function hy(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Rd(r,t){let e,n,i,s,a,l;return!t||!(s=r.dictionary)?(a=xd(r,Ad(r,t)),i=new lt(r.name,a,r.nullable,Qo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?Td(n):new ar,l=new ye(t.get(e),n,e,s.isOrdered),i=new lt(r.name,l,r.nullable,Qo(r.metadata))):(n=(n=s.indexType)?Td(n):new ar,t.set(e,a=xd(r,Ad(r,t))),l=new ye(a,n,e,s.isOrdered),i=new lt(r.name,l,r.nullable,Qo(r.metadata))),i||null}function Qo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Td(r){return new Jt(r.isSigned,r.bitWidth)}function xd(r,t){let e=r.type.name;switch(e){case"NONE":return new se;case"null":return new se;case"binary":return new gr;case"largebinary":return new wr;case"utf8":return new vr;case"largeutf8":return new Sr;case"bool":return new Ir;case"list":return new He((t||[])[0]);case"struct":return new Rt(t||[]);case"struct_":return new Rt(t||[])}switch(e){case"int":{let n=r.type;return new Jt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Fe(At[n.precision])}case"decimal":{let n=r.type;return new Fr(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Br(Wt[n.unit])}case"time":{let n=r.type;return new Dr(k[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Ar(k[n.unit],n.timezone)}case"interval":{let n=r.type;return new Tr(qt[n.unit])}case"duration":{let n=r.type;return new xr(k[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Ve(xt[a],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Er(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new We(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new ze((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var py=yn,my=me,fe=class r{static fromJSON(t,e){let n=new r(0,St.V5,e);return n._createHeader=_y(t,e),n}static decode(t){t=new my(J(t));let e=Ge.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),a=new r(n,i,s);return a._createHeader=yy(e,s),a}static encode(t){let e=new py,n=-1;return t.isSchema()?n=Ft.encode(e,t.header()):t.isRecordBatch()?n=Qt.encode(e,t.header()):t.isDictionaryBatch()&&(n=de.encode(e,t.header())),Ge.startMessage(e),Ge.addVersion(e,St.V5),Ge.addHeader(e,n),Ge.addHeaderType(e,t.headerType),Ge.addBodyLength(e,BigInt(t.bodyLength)),Ge.finishMessageBuffer(e,Ge.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Ft)return new r(0,St.V5,ct.Schema,t);if(t instanceof Qt)return new r(e,St.V5,ct.RecordBatch,t);if(t instanceof de)return new r(e,St.V5,ct.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===ct.Schema}isRecordBatch(){return this.headerType===ct.RecordBatch}isDictionaryBatch(){return this.headerType===ct.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=pt(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=pt(t)}},de=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=pt(e)}},ue=class{constructor(t,e){this.offset=pt(t),this.length=pt(e)}},Ae=class{constructor(t,e){this.length=pt(t),this.nullCount=pt(e)}};function _y(r,t){return()=>{switch(t){case ct.Schema:return Ft.fromJSON(r);case ct.RecordBatch:return Qt.fromJSON(r);case ct.DictionaryBatch:return de.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(ct[t],", type: ").concat(t," }"))}}function yy(r,t){return()=>{switch(t){case ct.Schema:return Ft.decode(r.header(new le),new Map,r.version());case ct.RecordBatch:return Qt.decode(r.header(new _e),r.version());case ct.DictionaryBatch:return de.decode(r.header(new _r),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(ct[t],", type: ").concat(t," }"))}}lt.encode=Ty;lt.decode=Dy;lt.fromJSON=Rd;Ft.encode=Ay;Ft.decode=by;Ft.fromJSON=Ed;Qt.encode=xy;Qt.decode=gy;Qt.fromJSON=Ol;de.encode=Ey;de.decode=wy;de.fromJSON=Ud;Ae.encode=Uy;Ae.decode=Sy;ue.encode=Oy;ue.decode=vy;function by(r,t=new Map,e=St.V5){let n=By(r,t);return new Ft(n,ta(r),t,e)}function gy(r,t=St.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Qt(r.length(),Iy(r),Fy(r,t))}function wy(r,t=St.V5){return new de(Qt.decode(r.data(),t),r.id(),r.isDelta())}function vy(r){return new ue(r.offset(),r.length())}function Sy(r){return new Ae(r.length(),r.nullCount())}function Iy(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 Fy(r,t){let e=[];for(let n,i=-1,s=-1,a=r.buffersLength();++i<a;)(n=r.buffers(i))&&(t<St.V4&&(n.bb_pos+=8*(i+1)),e[++s]=ue.decode(n));return e}function By(r,t){let e=[];for(let n,i=-1,s=-1,a=r.fieldsLength();++i<a;)(n=r.fields(i))&&(e[++s]=lt.decode(n,t));return e}function Ld(r,t){let e=[];for(let n,i=-1,s=-1,a=r.childrenLength();++i<a;)(n=r.children(i))&&(e[++s]=lt.decode(n,t));return e}function Dy(r,t){let e,n,i,s,a,l;return!t||!(l=r.dictionary())?(i=kd(r,Ld(r,t)),n=new lt(r.name(),i,r.nullable(),ta(r))):t.has(e=pt(l.id()))?(s=(s=l.indexType())?Nd(s):new ar,a=new ye(t.get(e),s,e,l.isOrdered()),n=new lt(r.name(),a,r.nullable(),ta(r))):(s=(s=l.indexType())?Nd(s):new ar,t.set(e,i=kd(r,Ld(r,t))),a=new ye(i,s,e,l.isOrdered()),n=new lt(r.name(),a,r.nullable(),ta(r))),n||null}function ta(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 Nd(r){return new Jt(r.isSigned(),r.bitWidth())}function kd(r,t){let e=r.typeType();switch(e){case Et.NONE:return new se;case Et.Null:return new se;case Et.Binary:return new gr;case Et.LargeBinary:return new wr;case Et.Utf8:return new vr;case Et.LargeUtf8:return new Sr;case Et.Bool:return new Ir;case Et.List:return new He((t||[])[0]);case Et.Struct_:return new Rt(t||[])}switch(e){case Et.Int:{let n=r.type(new Ne);return new Jt(n.isSigned(),n.bitWidth())}case Et.FloatingPoint:{let n=r.type(new tn);return new Fe(n.precision())}case Et.Decimal:{let n=r.type(new or);return new Fr(n.scale(),n.precision(),n.bitWidth())}case Et.Date:{let n=r.type(new Jr);return new Br(n.unit())}case Et.Time:{let n=r.type(new yr);return new Dr(n.unit(),n.bitWidth())}case Et.Timestamp:{let n=r.type(new br);return new Ar(n.unit(),n.timezone())}case Et.Interval:{let n=r.type(new en);return new Tr(n.unit())}case Et.Duration:{let n=r.type(new Xr);return new xr(n.unit())}case Et.Union:{let n=r.type(new ke);return new Ve(n.mode(),n.typeIdsArray()||[],t||[])}case Et.FixedSizeBinary:{let n=r.type(new Zr);return new Er(n.byteWidth())}case Et.FixedSizeList:{let n=r.type(new Qr);return new We(n.listSize(),(t||[])[0])}case Et.Map:{let n=r.type(new rn);return new ze((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(Et[e],'" (').concat(e,")"))}function Ay(r,t){let e=t.fields.map(s=>lt.encode(r,s));le.startFieldsVector(r,e.length);let n=le.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?le.createCustomMetadataVector(r,[...t.metadata].map(([s,a])=>{let l=r.createString("".concat(s)),u=r.createString("".concat(a));return Yt.startKeyValue(r),Yt.addKey(r,l),Yt.addValue(r,u),Yt.endKeyValue(r)})):-1;return le.startSchema(r),le.addFields(r,n),le.addEndianness(r,My?Yr.Little:Yr.Big),i!==-1&&le.addCustomMetadata(r,i),le.endSchema(r)}function Ty(r,t){let e=-1,n=-1,i=-1,s=t.type,a=t.typeId;L.isDictionary(s)?(a=s.dictionary.typeId,i=Zo.visit(s,r),n=Zo.visit(s.dictionary,r)):n=Zo.visit(s,r);let l=(s.children||[]).map(h=>lt.encode(r,h)),u=re.createChildrenVector(r,l),f=t.metadata&&t.metadata.size>0?re.createCustomMetadataVector(r,[...t.metadata].map(([h,v])=>{let A=r.createString("".concat(h)),E=r.createString("".concat(v));return Yt.startKeyValue(r),Yt.addKey(r,A),Yt.addValue(r,E),Yt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),re.startField(r),re.addType(r,n),re.addTypeType(r,a),re.addChildren(r,u),re.addNullable(r,!!t.nullable),e!==-1&&re.addName(r,e),i!==-1&&re.addDictionary(r,i),f!==-1&&re.addCustomMetadata(r,f),re.endField(r)}function xy(r,t){let e=t.nodes||[],n=t.buffers||[];_e.startNodesVector(r,e.length);for(let a of e.slice().reverse())Ae.encode(r,a);let i=r.endVector();_e.startBuffersVector(r,n.length);for(let a of n.slice().reverse())ue.encode(r,a);let s=r.endVector();return _e.startRecordBatch(r),_e.addLength(r,BigInt(t.length)),_e.addNodes(r,i),_e.addBuffers(r,s),_e.endRecordBatch(r)}function Ey(r,t){let e=Qt.encode(r,t.data);return _r.startDictionaryBatch(r),_r.addId(r,BigInt(t.id)),_r.addIsDelta(r,t.isDelta),_r.addData(r,e),_r.endDictionaryBatch(r)}function Uy(r,t){return Wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Oy(r,t){return Vn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var My=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Rl=r=>"Expected ".concat(ct[r]," Message in stream, but was null or length 0."),Ll=r=>"Header pointer of flatbuffer-encoded ".concat(ct[r]," Message is null or length 0."),Cd=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),Pd=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),oi=class{constructor(t){this.source=t instanceof ur?t:new ur(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Lt:t.value===-1&&(t=this.readMetadataLength()).done?Lt:(t=this.readMetadata(t.value)).done?Lt: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(Rl(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=J(this.source.read(t));if(e.byteLength<t)throw new Error(Pd(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=ct.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(Ll(e));return i}readMetadataLength(){let t=this.source.read(ea),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 Lt;if(e.byteLength<t)throw new Error(Cd(t,e.byteLength));return{done:!1,value:fe.decode(e)}}},bs=class{constructor(t,e){this.source=t instanceof Be?t:Ms(t)?new ln(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?Lt:t.value===-1&&(t=yield this.readMetadataLength()).done?Lt:(t=yield this.readMetadata(t.value)).done?Lt: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(Rl(t));return e.value})}readMessageBody(t){return R(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=J(yield this.source.read(t));if(e.byteLength<t)throw new Error(Pd(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=ct.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(Ll(e));return i})}readMetadataLength(){return R(this,void 0,void 0,function*(){let t=yield this.source.read(ea),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 Lt;if(e.byteLength<t)throw new Error(Cd(t,e.byteLength));return{done:!1,value:fe.decode(e)}})}},gs=class extends oi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ji?t:new ji(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:fe.fromJSON(t.schema,ct.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:fe.fromJSON(e,ct.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:fe.fromJSON(e,ct.RecordBatch)}}return this._body=[],Lt}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(Rl(t));return e.value}readSchema(){let t=ct.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(Ll(t));return n}},ea=4,Ml="ARROW1",ai=new Uint8Array(Ml.length);for(let r=0;r<Ml.length;r+=1)ai[r]=Ml.codePointAt(r);function ra(r,t=0){for(let e=-1,n=ai.length;++e<n;)if(ai[e]!==r[t+e])return!1;return!0}var li=ai.length,Nl=li+ea,Hd=li*2+ea;var te=class r extends Fn{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 Oe(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:Us(t)?Ly(t):Ms(t)?Cy(t):Oe(t)?R(this,void 0,void 0,function*(){return yield r.from(yield t)}):Rs(t)||Ii(t)||Ns(t)||ve(t)?ky(new Be(t)):Ny(new ur(t))}static readAll(t){return t instanceof r?t.isSync()?Vd(t):Wd(t):Us(t)||ArrayBuffer.isView(t)||Me(t)||Os(t)?Vd(t):Wd(t)}},fr=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 st(yield*mn(Pn(Ue(this[Symbol.iterator]()))))})}},cn=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 a=!0,l=Ue(this),u;u=yield l.next(),t=u.done,!t;a=!0){i=u.value,a=!1;let f=i;s.push(f)}}catch(f){e={error:f}}finally{try{!a&&!t&&(n=l.return)&&(yield n.call(l))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},un=class extends fr{constructor(t){super(t),this._impl=t}},ws=class extends cn{constructor(t){super(t),this._impl=t}},na=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=rt({type:new Rt(this.schema.fields),length:t.length,children:n});return new zt(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:a}=this,l=s.get(n),u=a.dictionaries.get(n),f=this._loadVectors(t.data,e,[u]);return(l&&i?l.concat(new ft(f)):new ft(f)).memoize()}_loadVectors(t,e,n){return new qi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},ci=class extends na{constructor(t,e){super(e),this._reader=Us(t)?new gs(this._handle=t):new oi(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=zd(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):Lt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Lt}next(){if(this.closed)return Lt;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 Un(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ui=class extends na{constructor(t,e){super(e),this._reader=new bs(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=zd(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):Lt})}return(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Lt})}next(){return R(this,void 0,void 0,function*(){if(this.closed)return Lt;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 Un(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return R(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},ia=class extends ci{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 $i?t:new $i(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(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}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(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength),l=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,l)}}}_readFooter(){let{_handle:t}=this,e=t.size-Nl,n=t.readInt32(e),i=t.readAt(e-n,n);return Mr.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}},kl=class extends ui{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 ln?t:new ln(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(ct.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}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(ct.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),l=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,l)}}})}_readFooter(){return R(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Nl,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Mr.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})}},Cl=class extends ci{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new xo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function zd(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Vd(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 Wd(r){return he(this,arguments,function*(){let e=yield st(te.from(r));try{if(!(yield st(e.open({autoDestroy:!1}))).closed)do yield yield st(e);while(!(yield st(e.reset().open())).closed)}finally{yield st(e.cancel())}})}function Ly(r){return new fr(new Cl(r))}function Ny(r){let t=r.peek(li+7&-8);return t&&t.byteLength>=4?ra(t)?new un(new ia(r.read())):new fr(new ci(r)):new fr(new ci(function*(){}()))}function ky(r){return R(this,void 0,void 0,function*(){let t=yield r.peek(li+7&-8);return t&&t.byteLength>=4?ra(t)?new un(new ia(yield r.read())):new cn(new ui(r)):new cn(new ui(function(){return he(this,arguments,function*(){})}()))})}function Cy(r){return R(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new ln(r,t);return t>=Hd&&ra(yield e.readAt(0,li+7&-8))?new ws(new kl(e)):new cn(new ui(e))})}var kt=class r extends z{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof zt?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 ft)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)||Ke.call(this,i<=0?new Uint8Array(0):wn(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 Ke(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new ue(this._byteLength,t)),this._byteLength+=t,this}function Py(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ke.call(this,i),e.mode===xt.Sparse)return Pl.call(this,r);if(e.mode===xt.Dense){if(r.offset<=0)return Ke.call(this,s),Pl.call(this,r);{let a=new Int32Array(n),l=Object.create(null),u=Object.create(null);for(let f,h,v=-1;++v<n;)(f=i[v])!==void 0&&((h=l[f])===void 0&&(h=l[f]=s[v]),a[v]=s[v]-h,u[f]=((t=u[f])!==null&&t!==void 0?t:0)+1);Ke.call(this,a),this.visitMany(r.children.map((f,h)=>{let v=e.typeIds[h],A=l[v],E=u[v];return f.slice(A,Math.min(n,E))}))}}return this}function Hy(r){let t;return r.nullCount>=r.length?Ke.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ke.call(this,wn(r.offset,r.length,t)):Ke.call(this,vn(r.values))}function Vr(r){return Ke.call(this,r.values.subarray(0,r.length*r.stride))}function sa(r){let{length:t,values:e,valueOffsets:n}=r,i=pt(n[0]),s=pt(n[t]),a=Math.min(s-i,e.byteLength-i);return Ke.call(this,Cs(-i,t+1,n)),Ke.call(this,e.subarray(i,i+a)),this}function Hl(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ke.call(this,Cs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Pl(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}kt.prototype.visitBool=Hy;kt.prototype.visitInt=Vr;kt.prototype.visitFloat=Vr;kt.prototype.visitUtf8=sa;kt.prototype.visitLargeUtf8=sa;kt.prototype.visitBinary=sa;kt.prototype.visitLargeBinary=sa;kt.prototype.visitFixedSizeBinary=Vr;kt.prototype.visitDate=Vr;kt.prototype.visitTimestamp=Vr;kt.prototype.visitTime=Vr;kt.prototype.visitDecimal=Vr;kt.prototype.visitList=Hl;kt.prototype.visitStruct=Pl;kt.prototype.visitUnion=Py;kt.prototype.visitInterval=Vr;kt.prototype.visitDuration=Vr;kt.prototype.visitFixedSizeList=Hl;kt.prototype.visitMap=Hl;var On=class extends Fn{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 cr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ie(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 Oe(t)?t.then(e=>this.writeAll(e)):ve(t)?Wl(this,t):Vl(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 cr?this._sink=t:(this._sink=new cr,t&&su(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&ou(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||!En(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 ae&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof zt&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!En(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof zt?t instanceof Un||this._writeRecordBatch(t):t instanceof ae?this.writeAll(t.batches):Me(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=fe.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,l=s+a+n&~n,u=l-s-a;return t.headerType===ct.RecordBatch?this._recordBatchBlocks.push(new Rr(l,t.bodyLength,this._position)):t.headerType===ct.DictionaryBatch&&this._dictionaryBlocks.push(new Rr(l,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(l-a)),s>0&&this._write(i),this._writePadding(u)}_write(t){if(this._started){let e=J(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(fe.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(ai)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=kt.assemble(t),a=new Qt(t.numRows,n,i),l=fe.from(a,e);return this._writeDictionaries(t)._writeMessage(l)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:a,buffers:l}=kt.assemble(new ft([t])),u=new Qt(t.length,s,a),f=new de(u,e,n),h=fe.from(f,i);return this._writeMessage(h)._writeBodyBuffers(l)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,a=t.length;++s<a;)(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 a=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],l=this._seenDictionaries.get(i),u=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!l||l.data[0]!==a[0])for(let[f,h]of a.entries())this._writeDictionaryBatch(h,i,f>0);else if(u<a.length)for(let f of a.slice(u))this._writeDictionaryBatch(f,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}},Mn=class r extends On{static writeAll(t,e){let n=new r(e);return Oe(t)?t.then(i=>n.writeAll(i)):ve(t)?Wl(n,t):Vl(n,t)}},Rn=class r extends On{static writeAll(t){let e=new r;return Oe(t)?t.then(n=>e.writeAll(n)):ve(t)?Wl(e,t):Vl(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=Mr.encode(new Mr(t,St.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Vl(r,t){let e=t;t instanceof ae&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Wl(r,t){return R(this,void 0,void 0,function*(){var e,n,i,s,a,l,u;try{for(e=!0,n=Ue(t);i=yield n.next(),s=i.done,!s;e=!0){u=i.value,e=!1;let f=u;r.write(f)}}catch(f){a={error:f}}finally{try{!e&&!s&&(l=n.return)&&(yield l.call(n))}finally{if(a)throw a.error}}return r.finish()})}function jd(r,t){if(ve(r))return Wy(r,t);if(Me(r))return Vy(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Vy(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(a){s(a,e||(e=r[Symbol.iterator]()))},pull(a){e?s(a,e):a.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(a,l){let u,f=null,h=a.desiredSize||null;for(;!(f=l.next(n?h:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=J(f.value))&&(h!=null&&n&&(h=h-u.byteLength+1),f.value=u),a.enqueue(f.value),h!=null&&--h<=0)return;a.close()}}function Wy(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(a){return R(this,void 0,void 0,function*(){yield s(a,e||(e=r[Symbol.asyncIterator]()))})},pull(a){return R(this,void 0,void 0,function*(){e?yield s(a,e):a.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(a,l){return R(this,void 0,void 0,function*(){let u,f=null,h=a.desiredSize||null;for(;!(f=yield l.next(n?h:null)).done;)if(ArrayBuffer.isView(f.value)&&(u=J(f.value))&&(h!=null&&n&&(h=h-u.byteLength+1),f.value=u),a.enqueue(f.value),h!=null&&--h<=0)return;a.close()})}}function Kd(r){return new zl(r)}var zl=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=nu(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Dn(s),this._getSize=i!=="bytes"?$d:Gd;let{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:l=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:u=>{this._maybeFlush(this._builder,this._controller=u)},start:u=>{this._maybeFlush(this._builder,this._controller=u)}},{highWaterMark:a,size:i!=="bytes"?$d:Gd}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:l,size:u=>this._writeValueAndReturnChunkSize(u)})}_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)}},$d=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Gd=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function oa(r,t){let e=new cr,n=null,i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield e.close()})},start(l){return R(this,void 0,void 0,function*(){yield a(l,n||(n=yield s()))})},pull(l){return R(this,void 0,void 0,function*(){n?yield a(l,n):l.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 a(l,u){return R(this,void 0,void 0,function*(){let f=l.desiredSize,h=null;for(;!(h=yield u.next()).done;)if(l.enqueue(h.value),f!=null&&--f<=0)return;l.close()})}}function aa(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(a){return R(this,void 0,void 0,function*(){yield s(a)})},start(a){return R(this,void 0,void 0,function*(){yield s(a)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(a){return R(this,void 0,void 0,function*(){let l=null,u=a.desiredSize;for(;l=yield n.read(u||null);)if(a.enqueue(l),u!=null&&(u-=l.byteLength)<=0)return;a.close()})}}function la(r,t="stream"){return(t==="stream"?Mn:Rn).writeAll(r).toUint8Array(!0)}var Gy=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},el),Dl),yl),rl),qa),_l),Xa),{compareSchemas:En,compareFields:vd,compareTypes:Sd});Xt.toDOMStream=jd;Nt.throughDOM=Kd;te.throughDOM=oa;un.throughDOM=oa;fr.throughDOM=oa;On.throughDOM=aa;Rn.throughDOM=aa;Mn.throughDOM=aa;function di(r){switch(r.typeId){case p.Binary:return{sqlType:"binary"};case p.Bool:return{sqlType:"bool"};case p.Date:return{sqlType:"date"};case p.DateDay:return{sqlType:"date32[d]"};case p.DateMillisecond:return{sqlType:"date64[ms]"};case p.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case p.Float:return{sqlType:"float"};case p.Float16:return{sqlType:"float16"};case p.Float32:return{sqlType:"float32"};case p.Float64:return{sqlType:"float64"};case p.Int:return{sqlType:"int32"};case p.Int16:return{sqlType:"int16"};case p.Int32:return{sqlType:"int32"};case p.Int64:return{sqlType:"int64"};case p.Uint16:return{sqlType:"uint16"};case p.Uint32:return{sqlType:"uint32"};case p.Uint64:return{sqlType:"uint64"};case p.Uint8:return{sqlType:"uint8"};case p.IntervalDayTime:return{sqlType:"interval[dt]"};case p.IntervalYearMonth:return{sqlType:"interval[m]"};case p.List:return{sqlType:"list",valueType:di(r.valueType)};case p.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case p.Null:return{sqlType:"null"};case p.Utf8:return{sqlType:"utf8"};case p.Struct:return{sqlType:"struct",fields:r.children.map(e=>ca(e.name,e.type))};case p.Map:{let t=r;return{sqlType:"map",keyType:di(t.keyType),valueType:di(t.valueType)}}case p.Time:return{sqlType:"time[s]"};case p.TimeMicrosecond:return{sqlType:"time[us]"};case p.TimeMillisecond:return{sqlType:"time[ms]"};case p.TimeNanosecond:return{sqlType:"time[ns]"};case p.TimeSecond:return{sqlType:"time[s]"};case p.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case p.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case p.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case p.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case p.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function ca(r,t){let e=di(t);return e.name=r,e}var ua=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 ae(n)}async send(t,e=!1){let n=this._bindings.startPendingQuery(this._conn,t,e);for(;n==null;)n=await new Promise((a,l)=>{try{a(this._bindings.pollPendingQuery(this._conn))}catch(u){console.log(u),u.message.includes("worker is not set!")?l(new Error("Worker has been terminated")):l(u)}});let i=new da(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 jl(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=la(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)}},da=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}},jl=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 ae(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new da(this.bindings,this.connectionId,e),i=te.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function Yd(r){return r<=255}function Jd(r){return r===256}var Qd=new TextEncoder,Xd=new TextDecoder("utf-8");function $l(r,t,e){let n=Qd.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 Kl(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 Gl(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*Kl(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 Zd(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function fa(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function tf(r,t,e,n,i,s,a,l){try{let u=r._udfFunctions.get(n);if(!u){$l(t,e,"Unknown UDF with id: "+n);return}let f=Xd.decode(t.HEAPU8.subarray(i,i+s)),h=JSON.parse(f),v=fa(t,a,l/8),A=F=>{var D;let U=null;switch(F.validityBuffer!==void 0&&(U=Zd(t,v[F.validityBuffer],h.rows)),F.physicalType){case"VARCHAR":{if(F.dataBuffer===null||F.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(F.lengthBuffer===null||F.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let N=Gl(t,v[F.dataBuffer],F.physicalType,h.rows),B=[],H=fa(t,v[F.lengthBuffer],h.rows);for(let W=0;W<h.rows;++W){if(U!=null&&!U[W]){B.push(null);continue}let Tt=t.HEAPU8.subarray(N[W],N[W]+H[W]),Ot=Xd.decode(Tt);B.push(Ot)}return W=>B[W]}case"STRUCT":{let N={},B=[];for(let H=0;H<(((D=F.children)==null?void 0:D.length)||0);++H){let W=F.children[H],Tt=A(W);B.push(Ot=>{N[W.name]=Tt(Ot)})}return U!=null?H=>{if(!U[H])return null;for(let W of B)W(H);return N}:H=>{for(let W of B)W(H);return N}}default:{if(F.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+F.physicalType);let N=Gl(t,v[F.dataBuffer],F.physicalType,h.rows);return U!=null?B=>U[B]?N[B]:null:B=>N[B]}}},E=[];for(let F=0;F<h.args.length;++F)E.push(A(h.args[F]));let at=h.rows*Kl(h.ret.physicalType),vt=t._malloc(at),Vt=Gl(t,vt,h.ret.physicalType,h.rows),mt=t._malloc(h.rows),Ut=Zd(t,mt,h.rows);if(Vt.length==0||Ut.length==0){$l(t,e,"Can't create physical arrays for result");return}let bt=Vt;h.ret.physicalType=="VARCHAR"&&(bt=new Array(h.rows));let Gt=[];for(let F=0;F<h.args.length;++F)Gt.push(null);for(let F=0;F<h.rows;++F){for(let D=0;D<h.args.length;++D)Gt[D]=E[D](F);let U=u.func(...Gt);bt[F]=U,Ut[F]=U==null?0:1}let Ct=0;switch(h.ret.physicalType){case"VARCHAR":{let F=new Array(0);Ct=t._malloc(h.rows*Kl("DOUBLE"));let U=fa(t,Ct,h.rows),D=0;for(let W=0;W<h.rows;++W){let Tt=Qd.encode(bt[W]||"");F.push(Tt),U[W]=Tt.length,D+=Tt.length}let N=t._malloc(D),B=t.HEAPU8.subarray(N,N+D),H=0;for(let W=0;W<h.rows;++W){Vt[W]=H;let Tt=F[W];B.subarray(H,H+Tt.length).set(Tt),H+=Tt.length}}}let I=3*8,O=t._malloc(I),V=fa(t,O,3);V[0]=vt,V[1]=mt,V[2]=Ct,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=O,t.HEAPF64[(e>>3)+2]=0}catch(u){$l(t,e,u.toString())}}function qy(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var Yy=qy();function qe(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Ln(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 it(r,t,e){return Yy(new Uint8Array(r.HEAPU8.buffer,t>>>0,e))}function Bt(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 a=r.HEAPF64[(s>>3)+0],l=r.HEAPF64[(s>>3)+1],u=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[a,l,u]}function Mt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var ha=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 fi=new TextEncoder;var pa=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]=Bt(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(it(this.mod,n,i));Mt(this.mod)}reset(){let[t,e,n]=Bt(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(it(this.mod,e,n));Mt(this.mod)}getVersion(){let[t,e,n]=Bt(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(it(this.mod,e,n));let i=it(this.mod,e,n);return Mt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=fi.encode(t),n=this.mod._malloc(e.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,n,e.length).set(e);let[s,a,l]=Bt(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(it(this.mod,a,l));let u=it(this.mod,a,l);return Mt(this.mod),JSON.parse(u)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new ua(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=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Bt(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(it(this.mod,l,u));let f=Ln(this.mod,l,u);return Mt(this.mod),f}startPendingQuery(t,e,n=!1){let i=fi.encode(e),s=this.mod._malloc(i.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,s,i.length).set(i);let[l,u,f]=Bt(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[t,s,i.length,n]);if(this.mod._free(s),l!==0)throw new Error(it(this.mod,u,f));if(u==0)return null;let h=Ln(this.mod,u,f);return Mt(this.mod),h}pollPendingQuery(t){let[e,n,i]=Bt(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(it(this.mod,n,i));if(n==0)return null;let s=Ln(this.mod,n,i);return Mt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=Bt(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(Jd(e))return Mt(this.mod),null;if(!Yd(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+it(this.mod,n,i));if(e!==0)throw new Error(it(this.mod,n,i));let s=Ln(this.mod,n,i);return Mt(this.mod),s}getTableNames(t,e){let n=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Bt(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(it(this.mod,l,u));let f=it(this.mod,l,u);return Mt(this.mod),JSON.parse(f)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:di(n)},a={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[l,u,f]=Bt(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(l!==0)throw new Error(it(this.mod,u,f));if(Mt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(a.functionId,a),this.pthread)for(let h of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])h.postMessage({cmd:"registerUDFFunction",udf:a})}createPrepared(t,e){let n=fi.encode(e),i=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,i,n.length).set(n);let[a,l,u]=Bt(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(it(this.mod,l,u));return Mt(this.mod),l}closePrepared(t,e){let[n,i,s]=Bt(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(it(this.mod,i,s));Mt(this.mod)}runPrepared(t,e,n){let[i,s,a]=Bt(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(it(this.mod,s,a));let l=Ln(this.mod,s,a);return Mt(this.mod),l}sendPrepared(t,e,n){let[i,s,a]=Bt(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(it(this.mod,s,a));let l=Ln(this.mod,s,a);return Mt(this.mod),l}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 a=n?JSON.stringify(n):"",[l,u,f]=Bt(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,a]);if(this.mod._free(i),l!==0)throw new Error(it(this.mod,u,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(ca(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,l,u]=Bt(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(it(this.mod,l,u))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(ca(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,l,u]=Bt(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(it(this.mod,l,u))}globFiles(t){let[e,n,i]=Bt(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(it(this.mod,n,i));let s=it(this.mod,n,i);Mt(this.mod);let a=JSON.parse(s);return a==null?[]:a}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,a,l]=Bt(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(it(this.mod,a,l));Mt(this.mod)}registerFileText(t,e){let n=fi.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,a,l]=Bt(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(it(this.mod,a,l));Mt(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:a,fromCached:l}=i;!l&&await this.registerFileHandleAsync(a,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:a,fromCached:l}=i;!l&&await this.registerFileHandleAsync(a,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(a){throw new Error(a.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 u;let[s,a,l]=Bt(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(it(this.mod,a,l));/*PATCH_C1*/if(t.startsWith("opfs://")){let _alt="opfs:/"+t.slice(7);Bt(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[_alt,_alt,n,i])}if(Mt(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),(u=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&u[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]=Bt(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(it(this.mod,n,i));Mt(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let l of t!=null?t:[])if(l!=null&&l.length>0){let u=this.mod.lengthBytesUTF8(l)+1,f=this.mod._malloc(u);if(!f)throw new Error("Failed to allocate memory for string: ".concat(l));this.mod.stringToUTF8(l,f,u),e.push(f)}if(n=this.mod._malloc(e.length*4),!n)throw new Error("Failed to allocate memory for pointers array");for(let l=0;l<e.length;l++)this.mod.HEAP32[(n>>2)+l]=e[l];let[i,s,a]=Bt(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(it(this.mod,s,a));Mt(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]=Bt(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(it(this.mod,i,s));Mt(this.mod)}copyFileToBuffer(t){let[e,n,i]=Bt(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(it(this.mod,n,i));let s=new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i),a=new Uint8Array(s.length);return a.set(s),Mt(this.mod),a}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]=Bt(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(it(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=Bt(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(it(this.mod,n,i));return new ha(new Uint8Array(this.mod.HEAPU8.buffer,n>>>0,i))}};var ma=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 ff=eu(df());var ba=class extends pa{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 at;let a=new Request(this.mainModuleURL),l=await fetch(a),u=l.headers.get("content-length"),f=u&&parseInt(u,10)||0,h=new Date,v={startedAt:h,updatedAt:h,bytesTotal:f||0,bytesLoaded:0},A={transform(vt,Vt){v.bytesLoaded+=vt.byteLength;let mt=new Date;if(mt.getTime()-v.updatedAt.getTime()<20){v.updatedAt=mt,Vt.enqueue(vt);return}for(let Ut of n)Ut(v);Vt.enqueue(vt)}},E=new TransformStream(A);return new Response((at=l.body)==null?void 0:at.pipeThrough(E),l)})();WebAssembly.instantiateStreaming(s,t).then(a=>{e(a.instance,a.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,a=new Date,l={startedAt:a,updatedAt:a,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+u}),new Error(u.toString())},i.onprogress=u=>{l.bytesTotal=u.total,l.bytesLoaded=u.loaded;let f=new Date;if(f.getTime()-l.updatedAt.getTime()<20){l.updatedAt=f;return}for(let h of n)h(l)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(u=>{e(u.instance,u.module)}).catch(u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+u}),new Error(u)})},i.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let s=new Request(this.mainModuleURL),l=await(await fetch(s)).arrayBuffer();WebAssembly.instantiate(l,t).then(u=>{e(u.instance,u.module)})})();return[]}};var ga=class extends ba{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){let e={...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)};return this.pthreadWorkerURL&&(e.mainScriptUrlOrBlob=this.pthreadWorkerURL),(0,ff.default)(e)}};var dn=eu(mf()),_f=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 Zy(r,t,e){var s,a,l,u;let n=yf(t),i=n.path;if(bf(r)){let f="";if(r!=null&&r.endpoint){let h=new URL(r.endpoint);h.pathname!=="/"&&(f=h.pathname)}i="".concat(f,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:_f(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(a=r==null?void 0:r.accessKeyId)!=null?a:"",secretAccessKey:(l=r==null?void 0:r.secretAccessKey)!=null?l:"",sessionToken:(u=r==null?void 0:r.sessionToken)!=null?u:"",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 tb(r,t=null){var at;let e=(at=t==null?void 0:t.contentHash)!=null?at:"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 a=(0,dn.sha256)(s),l="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+a,u="AWS4"+r.secretAccessKey,f=dn.sha256.hmac.arrayBuffer(u,r.dateNow),h=dn.sha256.hmac.arrayBuffer(f,r.region),v=dn.sha256.hmac.arrayBuffer(h,r.service),A=dn.sha256.hmac.arrayBuffer(v,"aws4_request"),E=dn.sha256.hmac(A,l);return n.set("Authorization","AWS4-HMAC-SHA256 Credential="+r.accessKeyId+"/"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request, SignedHeaders="+i+", Signature="+E),n}var eb=function(r,t,e,n=null,i=null){let s=Zy(r,t,e),a={contentType:n,contentHash:i?dn.sha256.hex(i):null};return tb(s,a)};function Ye(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(eb(t,e,n,i,s).forEach((l,u)=>{r.setRequestHeader(u,l)}),i&&r.setRequestHeader("content-type",i))}function yf(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 bf(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function Je(r,t){let e=yf(t);return bf(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+_f(r,t,e.bucket)+e.path}var rb=7,gf=/\/|\\/,Q={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=Q._fileInfoCache.get(t),[n,i,s]=Bt(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 a=it(r,i,s);Mt(r);try{let l=JSON.parse(a);if(l==null)return null;let u={...l,blob:null};return Q._fileInfoCache.set(t,u),!Q._files.has(u.fileName)&&(Q._preparedHandles[u.fileName]?(Q._files.set(u.fileName,Q._preparedHandles[u.fileName]),delete Q._preparedHandles[u.fileName]):u.fileName.startsWith("opfs:/")&&!u.fileName.startsWith("opfs://")&&Q._preparedHandles["opfs://"+u.fileName.slice(6)]&&(Q._files.set(u.fileName,Q._preparedHandles["opfs://"+u.fileName.slice(6)]),delete Q._preparedHandles["opfs://"+u.fileName.slice(6)])),u}catch(l){return console.warn(l),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=Bt(r,"duckdb_web_get_global_file_info",["number"],[((t=Q._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return Q._globalFileInfo;let s=it(r,n,i);Mt(r);let a=JSON.parse(s);return a==null?null:(Q._globalFileInfo={...a,blob:null},Q._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){Q._opfsRoot||(Q._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await Q.assignOPFSRoot();let e=async i=>{if(Q._files.has(i))return{path:i,handle:Q._files.get(i),fromCached:!0};let a=Q._opfsRoot,l=i.slice(rb),u=l;if(gf.test(l)){let h=l.split(gf);if(h.length===0)throw new Error("Invalid path ".concat(l));if(u=h[h.length-1],!u)throw new Error("Invalid path ".concat(l,". File Not Found."));h.pop();for(let v of h)a=await a.getDirectoryHandle(v,{create:!0})}let f=await a.getFileHandle(u,{create:!1}).catch(h=>{if((h==null?void 0:h.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),a.getFileHandle(u,{create:!0});throw h});try{let h=await f.createSyncAccessHandle();return Q._preparedHandles[i]=h,/*PATCH_A*/i.startsWith("opfs://")&&(Q._preparedHandles["opfs:/"+i.slice(7)]=h),{path:i,handle:h,fromCached:!1}}catch(h){throw new Error(h.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,a,l,u;try{Q._fileInfoCache.delete(t);let f=Q.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),Ye(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),at=new Uint8Array;r.HEAPU8.set(at,E);let vt=r._malloc(3*8);return r.HEAPF64[(vt>>3)+0]=1,r.HEAPF64[(vt>>3)+1]=E,r.HEAPF64[(vt>>3)+2]=new Date().getTime()/1e3,vt}else if(!(e&1))throw new Error("Opening file ".concat(f.fileName," failed: unsupported file flags: ").concat(e));let h=null,v=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),Ye(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.setRequestHeader("Range","bytes=0-"),A.send(null),h=null;try{h=A.getResponseHeader("Content-Length")}catch(E){console.warn("Failed to get Content-Length on request")}if(h!==null&&A.status==206){let E=r._malloc(24);r.HEAPF64[(E>>3)+0]=+h,r.HEAPF64[(E>>3)+1]=0;let at=0;try{at=new Date((n=A.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(vt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(E>>3)+2]=+at,E}}catch(A){v=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),Ye(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 at=null;try{at=E.getResponseHeader("Content-Length")}catch(Ut){console.warn("Failed to get Content-Length on request")}let vt=at==null?void 0:at.split("/")[1],Vt=at,mt=null;if(vt!==void 0)mt=vt;else if(!f.reliableHeadRequests){let Ut=new XMLHttpRequest;f.dataProtocol==5?(Ut.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ye(Ut,f.s3Config,f.dataUrl,"HEAD")):Ut.open("HEAD",f.dataUrl,!1),Ut.setRequestHeader("Range","bytes=0-"),Ut.send(null),h=null;try{h=Ut.getResponseHeader("Content-Length")}catch(bt){console.warn("Failed to get Content-Length on request")}h!==null&&+h>1&&(mt=h)}if(E.status==206&&Vt!==null&&+Vt==1&&mt!==null){let Ut=r._malloc(24);r.HEAPF64[(Ut>>3)+0]=+mt,r.HEAPF64[(Ut>>3)+1]=0;let bt=0;try{bt=new Date((i=E.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(Gt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Ut>>3)+2]=+bt,Ut}if(E.status==200&&Vt!==null&&h!==null&&+Vt==+h){console.warn("fall back to full HTTP read for: ".concat(f.dataUrl));let Ut=r._malloc(E.response.byteLength),bt=new Uint8Array(E.response,0,E.response.byteLength);r.HEAPU8.set(bt,Ut);let Gt=r._malloc(3*8);r.HEAPF64[(Gt>>3)+0]=E.response.byteLength,r.HEAPF64[(Gt>>3)+1]=Ut;let Ct=0;try{Ct=new Date((s=E.getResponseHeader("Last-Modified"))!=null?s:"").getTime()/1e3}catch(I){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Gt>>3)+2]=+Ct,Gt}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),Ye(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),at=new Uint8Array(A.response,0,A.response.byteLength);r.HEAPU8.set(at,E);let vt=r._malloc(3*8);r.HEAPF64[(vt>>3)+0]=A.response.byteLength,r.HEAPF64[(vt>>3)+1]=E;let Vt=0;try{Vt=new Date((a=A.getResponseHeader("Last-Modified"))!=null?a:"").getTime()/1e3}catch(mt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(vt>>3)+2]=+Vt,vt}}if(v!=null)throw new Error("Reading file ".concat(f.fileName," failed with error: ").concat(v));return 0}case 2:{let h=(l=Q._files)==null?void 0:l.get(f.fileName);if(h){let E=r._malloc(24);return r.HEAPF64[(E>>3)+0]=h.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 v=r._malloc(3*8),A=r._malloc(1);return r.HEAPF64[(v>>3)+0]=1,r.HEAPF64[(v>>3)+1]=A,r.HEAPF64[(v>>3)+2]=0,v}case 3:{let h=(u=Q._files)==null?void 0:u.get(f.fileName);if(!h)throw new Error("No OPFS access handle registered with name: ".concat(f.fileName));e&16&&h.truncate(0);let v=r._malloc(3*8),A=h.getSize();return r.HEAPF64[(v>>3)+0]=A,r.HEAPF64[(v>>3)+1]=0,r.HEAPF64[(v>>3)+2]=0,v}}}catch(f){console.error(f.toString()),qe(r,f.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=it(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let a=Q.getGlobalFileInfo(r);s.open("HEAD",Je(a==null?void 0:a.s3Config,i),!1),Ye(s,a==null?void 0:a.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=Q.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let a=new XMLHttpRequest;if(i.startsWith("s3://")){let u=Q.getGlobalFileInfo(r);a.open("GET",Je(u==null?void 0:u.s3Config,i),!1),Ye(a,u==null?void 0:u.s3Config,i,"HEAD")}else a.open("GET",i,!1);if(a.setRequestHeader("Range","bytes=0-0"),a.send(null),a.status!=200&&a.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let l=null;try{l=a.getResponseHeader("Content-Length")}catch(u){console.warn("Failed to get Content-Length on request")}l&&+l>1&&console.warn("Range request for ".concat(i," did not return a partial response: ").concat(a.status,' "').concat(a.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of Q._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=it(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=Q.getGlobalFileInfo(r);i.open("HEAD",Je(s==null?void 0:s.s3Config,n),!1),Ye(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 Q._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=Q.getFileInfo(r,t);Q._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=Q._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=it(r,t,e),i=(s=Q._files)==null?void 0:s.get(n);if(i){if(Q._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(a){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=Q.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=Q._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 a=Q.getFileInfo(r,t);switch(a==null?void 0:a.dataProtocol){case 4:case 5:{if(!a.dataUrl)throw new Error("Missing data URL for file ".concat(t));try{let l=new XMLHttpRequest;if(a.dataProtocol==5?(l.open("GET",Je(a==null?void 0:a.s3Config,a.dataUrl),!1),Ye(l,a==null?void 0:a.s3Config,a.dataUrl,"GET")):l.open("GET",a.dataUrl,!1),l.responseType="arraybuffer",l.setRequestHeader("Range","bytes=".concat(i,"-").concat(i+n-1)),l.send(null),l.status==206||l.status==200&&n==l.response.byteLength&&i==0){let u=new Uint8Array(l.response,0,Math.min(l.response.byteLength,n));return r.HEAPU8.set(u,e),u.byteLength}else if(l.status==200){console.warn("Range request for ".concat(a.dataUrl," did not return a partial response: ").concat(l.status,' "').concat(l.statusText,'"'));let u=new Uint8Array(l.response,i,Math.min(l.response.byteLength-i,n));return r.HEAPU8.set(u,e),u.byteLength}else throw new Error("Range request for ".concat(a.dataUrl," did returned non-success status: ").concat(l.status,' "').concat(l.statusText,'"'))}catch(l){throw console.log(l),new Error("Range request for ".concat(a.dataUrl," failed with error: ").concat(l,'"'))}}case 2:{let l=(s=Q._files)==null?void 0:s.get(a.fileName);if(!l)throw new Error("No HTML5 file registered with name: ".concat(a.fileName));let u=l.slice(i,i+n),f=new Uint8Array(new FileReaderSync().readAsArrayBuffer(u));return r.HEAPU8.set(f,e),f.byteLength}case 3:{let l=Q._files.get(a.fileName);if(!l)throw new Error("No OPFS access handle registered with name: ".concat(a.fileName));let u=r.HEAPU8.subarray(e,e+n);return l.read(u,{at:i})}}return 0}catch(a){return console.log(a),qe(r,a.toString()),0}},writeFile:(r,t,e,n,i)=>{var a;let s=Q.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return qe(r,"Cannot write to HTTP file"),0;case 5:{let l=r.HEAPU8.subarray(e,e+n),u=new XMLHttpRequest;return u.open("PUT",Je(s==null?void 0:s.s3Config,s.dataUrl),!1),Ye(u,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",l),u.send(l),u.status!==200?(qe(r,"Failed writing file: HTTP "+u.status),0):n}case 2:return qe(r,"cannot write using the html5 file reader api"),0;case 3:{let l=(a=Q._files)==null?void 0:a.get(s.fileName);if(!l)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let u=r.HEAPU8.subarray(e,e+n);return l.write(u,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=Q.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=Q._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=it(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=it(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=it(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=it(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var u,f;let s=it(r,t,e),a=it(r,n,i),l=(u=Q._files)==null?void 0:u.get(s);l!==void 0&&(Q._files.delete(l),Q._files.set(a,l));for(let[h,v]of((f=Q._fileInfoCache)==null?void 0:f.entries())||[])if(v.dataUrl==s){Q._fileInfoCache.delete(h);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,a)=>{tf(Q,r,t,e,n,i,s,a)}};var Yl=class extends ma{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new ga(this,Q,t,e).instantiate(n)}};function wf(){let r=new Yl;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}wf();return Dm(nb);})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
js-sha256/src/sha256.js:
|