precision-dashwidgets 0.1.3 → 0.2.1
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/precision-dashwidgets.es.js +2061 -3257
- package/dist/precision-dashwidgets.umd.js +16 -23
- package/dist/static/duckdb/duckdb-browser-eh.worker.js +14 -0
- package/dist/static/duckdb/duckdb-browser-mvp.worker.js +14 -0
- package/dist/static/duckdb/duckdb-eh.wasm +0 -0
- package/dist/static/duckdb/duckdb-mvp.wasm +0 -0
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
CREATE OR REPLACE TABLE ${
|
|
3
|
-
SELECT * FROM read_csv('${
|
|
4
|
-
`}else if(
|
|
5
|
-
CREATE OR REPLACE TABLE ${
|
|
6
|
-
SELECT * FROM read_parquet('${
|
|
7
|
-
`;else throw new Error(`Unsupported file type: ${
|
|
1
|
+
(function(te,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("element-plus"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia"],h):(te=typeof globalThis<"u"?globalThis:te||self,h(te["precision-dashwidgets"]={},te.Vue,te.ElementPlus,te.Pinia))})(this,function(te,h,Pc,Vc){"use strict";/*! Element Plus Icons Vue v2.3.2 */var zc=h.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(h.openBlock(),h.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[h.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.99 12.99 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"})]))}}),jc=zc;function ft(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Ce(e){return function t(n){return arguments.length===0||ft(n)?t:e.apply(this,arguments)}}function ke(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:Ce(function(i){return e(n,i)});default:return ft(n)&&ft(r)?t:ft(n)?Ce(function(i){return e(i,r)}):ft(r)?Ce(function(i){return e(n,i)}):e(n,r)}}}function Yc(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:ke(function(s,a){return e(n,s,a)});case 2:return ft(n)&&ft(r)?t:ft(n)?ke(function(s,a){return e(s,r,a)}):ft(r)?ke(function(s,a){return e(n,s,a)}):Ce(function(s){return e(n,r,s)});default:return ft(n)&&ft(r)&&ft(i)?t:ft(n)&&ft(r)?ke(function(s,a){return e(s,a,i)}):ft(n)&&ft(i)?ke(function(s,a){return e(s,r,a)}):ft(r)&&ft(i)?ke(function(s,a){return e(n,s,a)}):ft(n)?Ce(function(s){return e(s,r,i)}):ft(r)?Ce(function(s){return e(n,s,i)}):ft(i)?Ce(function(s){return e(n,r,s)}):e(n,r,i)}}}const Wc=Number.isInteger||function(e){return e<<0===e};function qc(e,t){var n=e<0?t.length+e:e;return t[n]}var Gc=ke(function(e,t){return t==null||t!==t?e:t});function Hc(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];Wc(i)?n=qc(i,n):n=n[i]}return n}var Kc=Yc(function(e,t,n){return Gc(e,Hc(t,n))});const js=Vc.defineStore("duckdb",()=>{const e=h.ref(null),t=h.ref(!1),n=h.ref(!1),r=h.ref(""),i=h.ref(new Map),s=h.ref(new Map),a=h.ref(new Map);let o=null;const l=h.computed(()=>t.value&&!r.value),c=h.computed(()=>R=>i.value.get(R)),d=h.computed(()=>R=>{const F=i.value.get(R);return F&&!F.isLoading&&!F.error}),y=h.computed(()=>s.value.size),_=h.computed(()=>s.value.size>0),v=async()=>{if(typeof window>"u"||typeof Worker>"u"){const R="DuckDB can only be initialized in the browser.";throw r.value=R,new Error(R)}return e.value?e.value:o?(await o,e.value):(n.value=!0,r.value="",o=(async()=>{try{const R=await Promise.resolve().then(()=>bb),F={mvp:{mainModule:"/static/duckdb/duckdb-mvp.wasm",mainWorker:"/static/duckdb/duckdb-browser-mvp.worker.js"},eh:{mainModule:"/static/duckdb/duckdb-eh.wasm",mainWorker:"/static/duckdb/duckdb-browser-eh.worker.js"}},p=await R.selectBundle(F),g=new Worker(p.mainWorker),u=new R.ConsoleLogger(R.LogLevel.WARNING);return e.value=new R.AsyncDuckDB(u,g),await e.value.instantiate(p.mainModule),t.value=!0,e.value}catch(R){throw r.value=`Failed to initialize DuckDB: ${(R==null?void 0:R.message)||R}`,e.value=null,R}finally{n.value=!1,o=null}})(),await o,e.value)},E=async R=>{e.value||await v();const F=await e.value.connect(),p=R||`conn_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;return s.value.set(p,{connection:F,viewerId:p,createdAt:new Date}),{connection:F,connectionId:p}},T=async R=>{const F=s.value.get(R);F&&(await F.connection.close(),s.value.delete(R),N(R),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},N=R=>{for(const[F,p]of a.value)p.delete(R),p.size===0&&console.log(`File ${F} is no longer used by any viewers`)},B=(R,F)=>{a.value.has(R)||a.value.set(R,new Set),a.value.get(R).add(F)},Q=async R=>{const F=i.value.get(R);if(F&&F.tableName)try{const p=await e.value.connect();await p.query(`DROP TABLE IF EXISTS ${F.tableName};`),await p.close()}catch(p){console.warn(`Failed to drop table ${F.tableName}:`,p)}i.value.delete(R),a.value.delete(R)},it=async(R,F,p="my_data",g={},u=null,m=null)=>{const b=m||R,w=i.value.get(b);if(w&&!w.isLoading&&!w.error)return u&&B(b,u),w.tableName;l.value||await v(),i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!0,error:null});try{const I=await fetch(R);if(!I.ok)throw new Error(`Failed to fetch file: ${I.status} ${I.statusText}`);let S;if(F==="csv"){const M=await I.text(),J=await new Blob([M],{type:"text/csv"}).arrayBuffer();S=new Uint8Array(J)}else{const M=await I.arrayBuffer();S=new Uint8Array(M)}const O=`${m||p}.${F}`;await e.value.registerFileBuffer(O,S);const A=await e.value.connect();try{let M;if(F==="csv"){const st={header:!0,delimiter:",",...g};M=`
|
|
2
|
+
CREATE OR REPLACE TABLE ${p} AS
|
|
3
|
+
SELECT * FROM read_csv('${O}', header=${st.header}, delim='${st.delimiter}');
|
|
4
|
+
`}else if(F==="parquet")M=`
|
|
5
|
+
CREATE OR REPLACE TABLE ${p} AS
|
|
6
|
+
SELECT * FROM read_parquet('${O}');
|
|
7
|
+
`;else throw new Error(`Unsupported file type: ${F}`);await A.query(M);const J=(await A.query(`SELECT COUNT(*) as count FROM ${p};`)).toArray()[0].count;return i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!1,error:null,rowCount:J,loadedAt:new Date}),u&&B(b,u),p}finally{await A.close()}}catch(I){throw i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!1,error:I.message}),I}},mt=async(R,F)=>{const p=s.value.get(F);if(!p)throw new Error(`Connection not found: ${F}`);return(await p.connection.query(R)).toArray().map(g=>{const u={};for(const[m,b]of Object.entries(g))u[m]=b;return u})},bt=async()=>{for(const[R,F]of s.value)try{await F.connection.close(),console.log(`Closed connection: ${R}`)}catch(p){console.warn(`Error closing connection ${R}:`,p)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(R){console.warn("Error terminating DuckDB:",R)}e.value=null}t.value=!1,i.value.clear(),a.value.clear(),r.value=""},gt=async(R=!1)=>{R||s.value.size===0?await bt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},It=()=>{const R=[];for(const[F,p]of s.value)R.push({connectionId:F,viewerId:p.viewerId,createdAt:p.createdAt});return R},$t=()=>{const R=[];for(const[F,p]of a.value){const g=i.value.get(F);R.push({fileId:F,tableName:g==null?void 0:g.tableName,fileType:g==null?void 0:g.fileType,fileUrl:g==null?void 0:g.fileUrl,rowCount:g==null?void 0:g.rowCount,loadedAt:g==null?void 0:g.loadedAt,usedByViewers:Array.from(p)})}return R},dt=h.ref(null),ht=h.ref(0);function Zt(R){return`"${String(R).replace(/"/g,'""')}"`}return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:a,sharedResultName:dt,sharedVersion:ht,isReady:l,getLoadedFile:c,isFileLoaded:d,activeConnectionCount:y,hasActiveConnections:_,initDuckDB:v,createConnection:E,closeConnection:T,cleanupViewerFileUsage:N,trackFileUsage:B,unloadFile:Q,loadFile:it,executeQuery:mt,cleanup:gt,performGlobalCleanup:bt,getConnectionInfo:It,getFileUsageInfo:$t,publishViewFromQuery:async(R,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE VIEW ${Zt(R)} AS ${F}`),dt.value=R,ht.value++},publishTableFromQuery:async(R,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE TABLE ${Zt(R)} AS ${F}`),dt.value=R,ht.value++}}}),Sn=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Qc={class:"dashboard-container"},Xc={class:"dashboard-header"},Jc={class:"dashboard-content"},Zc={key:0,class:"query-panel"},tu={class:"query-examples"},eu=["onClick"],nu={key:1,class:"results-panel"},ru={class:"results-controls"},iu={class:"left-controls"},su={class:"right-controls"},au={key:0,class:"table-container"},ou={class:"results-table"},lu={key:0,class:"bottom-pagination"},cu={key:1,class:"json-container"},uu={key:2,class:"error-panel"},hu={__name:"DataExplorer",props:{url:{type:String,default:""},fileType:{type:String,default:"parquet",validator:e=>["parquet","csv"].includes(e)},viewerId:{type:String,default:()=>`viewer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`},fileId:{type:String,default:null}},emits:["query-results"],setup(e,{emit:t}){const n=e,r=t,i=js(),s=h.ref({header:!0,dynamicTyping:!0,delimiter:","}),a=h.ref(!1),o=h.ref(!1),l=h.ref(n.url),c=h.ref("my_data"),d=h.ref(""),y=h.ref(null),_=h.ref(""),v=h.ref("table"),E=h.ref(1),T=h.ref(50),N=h.ref(null);h.watch(()=>n.url,async m=>{if(l.value=m,m)try{await $t(),await ht()}catch{console.error("file can not be loaded")}},{immediate:!0});const B=h.computed(()=>i.isReady&&N.value&&!a.value),Q=h.computed(()=>a.value?"Loading...":i.isInitializing?"Initializing...":i.isReady?B.value?"Connected":"Not Connected":"Not Ready"),it=h.computed(()=>!y.value||!Array.isArray(y.value)||y.value.length===0?[]:Object.keys(y.value[0]||{})),mt=h.computed(()=>!y.value||!Array.isArray(y.value)?0:Math.ceil(y.value.length/T.value)),bt=h.computed(()=>{if(!y.value||!Array.isArray(y.value))return[];const m=(E.value-1)*T.value,b=m+T.value;return y.value.slice(m,b)}),gt=h.computed(()=>[{name:"Show All",query:"SELECT * FROM data LIMIT 100;"},{name:"Count Rows",query:"SELECT COUNT(*) as row_count FROM data;"},{name:"Group By",query:`SELECT
|
|
8
8
|
column1, column2,
|
|
9
9
|
COUNT(*) as count
|
|
10
10
|
FROM data
|
|
11
11
|
GROUP BY column1, column2
|
|
12
12
|
ORDER BY column1, column2
|
|
13
|
-
LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);
|
|
14
|
-
`),w=new Blob([h],{type:"text/csv"}),I=URL.createObjectURL(w),S=document.createElement("a");S.href=I,S.download="query-results.csv",S.click(),URL.revokeObjectURL(I)},g=()=>{u.value=""};return f.onMounted(async()=>{await N()}),f.onUnmounted(async()=>{b.value&&(n.activeConnectionCount,n.loadedFiles.size,await n.closeConnection(b.value),n.activeConnectionCount,n.loadedFiles.size)}),(v,h)=>{const w=f.resolveComponent("bf-button"),I=f.resolveComponent("el-pagination");return f.openBlock(),f.createElementBlock("div",Vu,[f.createElementVNode("header",zu,[h[3]||(h[3]=f.createElementVNode("h1",null,"Data Explorer",-1)),f.createElementVNode("div",{class:f.normalizeClass(["status-indicator",{connected:E.value,loading:i.value}])},f.toDisplayString(A.value),3)]),f.createElementVNode("div",Yu,[E.value?(f.openBlock(),f.createElementBlock("div",ju,[h[5]||(h[5]=f.createElementVNode("h3",null,"SQL Query",-1)),f.createElementVNode("div",qu,[h[4]||(h[4]=f.createElementVNode("span",null,"Quick queries:",-1)),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(vt.value,S=>(f.openBlock(),f.createElementBlock("button",{key:S.name,onClick:R=>ct(S.query),class:"example-btn"},f.toDisplayString(S.name),9,Gu))),128))]),f.withDirectives(f.createElementVNode("textarea",{"onUpdate:modelValue":h[0]||(h[0]=S=>c.value=S),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[f.vModelText,c.value]]),f.createVNode(w,{onClick:D,disabled:s.value||!c.value},{default:f.withCtx(()=>[f.createTextVNode(f.toDisplayString(s.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):f.createCommentVNode("",!0),l.value?(f.openBlock(),f.createElementBlock("div",Wu,[f.createElementVNode("h3",null,"Results ("+f.toDisplayString(l.value.length)+" rows)",1),f.createElementVNode("div",Hu,[f.createElementVNode("div",Ku,[f.createVNode(w,{class:"secondary",onClick:yt},{default:f.withCtx(()=>[...h[6]||(h[6]=[f.createTextVNode("Export to CSV",-1)])]),_:1})]),f.createElementVNode("div",Qu,[d.value==="table"&&H.value>1?(f.openBlock(),f.createBlock(I,{key:0,"current-page":y.value,"onUpdate:currentPage":h[1]||(h[1]=S=>y.value=S),"page-size":m.value,total:l.value.length,layout:"prev, pager, next",onCurrentChange:Y,class:"results-pagination"},null,8,["current-page","page-size","total"])):f.createCommentVNode("",!0)])]),h[7]||(h[7]=f.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),d.value==="table"?(f.openBlock(),f.createElementBlock("div",Xu,[f.createElementVNode("table",Ju,[f.createElementVNode("thead",null,[f.createElementVNode("tr",null,[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(_.value,S=>(f.openBlock(),f.createElementBlock("th",{key:S},f.toDisplayString(S),1))),128))])]),f.createElementVNode("tbody",null,[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(L.value,(S,R)=>(f.openBlock(),f.createElementBlock("tr",{key:R},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(_.value,B=>(f.openBlock(),f.createElementBlock("td",{key:B},f.toDisplayString(bt(S[B])),1))),128))]))),128))])]),H.value>1?(f.openBlock(),f.createElementBlock("div",Zu,[f.createVNode(I,{"current-page":y.value,"onUpdate:currentPage":h[2]||(h[2]=S=>y.value=S),"page-size":m.value,total:l.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:Y,onSizeChange:G},null,8,["current-page","page-size","total"])])):f.createCommentVNode("",!0)])):(f.openBlock(),f.createElementBlock("div",th,[f.createElementVNode("pre",null,f.toDisplayString(JSON.stringify(l.value.slice(0,100),null,2)),1)]))])):f.createCommentVNode("",!0),u.value?(f.openBlock(),f.createElementBlock("div",eh,[h[8]||(h[8]=f.createElementVNode("h3",null,"Error",-1)),f.createElementVNode("p",null,f.toDisplayString(u.value),1),f.createElementVNode("button",{onClick:g,class:"clear-error-btn"},"Clear")])):f.createCommentVNode("",!0)])])}}},rh=Dn(nh,[["__scopeId","data-v-6635a757"]]),ih={class:"app-container"},sh=f.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=f.ref([]),r=f.ref(""),i=f.ref("parquet"),s=f.ref("");f.onMounted(async()=>{var u,d,y,m,b;if(t.srcUrl){r.value=t.srcUrl,i.value=t.srcFileType??(t.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),s.value=t.srcFileId??"url_"+btoa(t.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const l=ku("",["content","id"],t.pkg);if(!l||!t.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await a(l);const E=(y=(d=(u=n.value)==null?void 0:u[0])==null?void 0:d.content)==null?void 0:y.id;if(!E){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}s.value=E,r.value=await c(l,E);const A=(b=(m=t.pkg)==null?void 0:m.content)==null?void 0:b.packageType;i.value=A==="CSV"?"csv":"parquet"}catch(E){console.error(E)}});async function o(){const{useGetToken:l}=await Promise.resolve().then(()=>hu);return l()}async function a(l){const u=await o(),d=`${t.apiUrl}/packages/${l}/view?api_key=${u}`,y=await fetch(d);if(!y.ok)throw new Error(`view failed: ${y.status}`);n.value=await y.json()}async function c(l,u){const d=await o(),y=`${t.apiUrl}/packages/${l}/files/${u}?api_key=${d}`,m=await fetch(y);if(!m.ok)throw new Error(`file url failed: ${m.status}`);return(await m.json()).url}return(l,u)=>(f.openBlock(),f.createElementBlock("div",ih,[f.createVNode(rh,{url:r.value,"file-type":i.value,"file-id":s.value},null,8,["url","file-type","file-id"])]))}}),oh=Dn(sh,[["__scopeId","data-v-0974a90e"]]);var ah={value:()=>{}};function Fi(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new fr(n)}function fr(e){this._=e}function lh(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}fr.prototype=Fi.prototype={constructor:fr,on:function(e,t){var n=this._,r=lh(e+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((i=(e=r[s]).type)&&(i=ch(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(i=(e=r[s]).type)n[i]=io(n[i],e.name,t);else if(t==null)for(i in n)n[i]=io(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new fr(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function ch(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function io(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ah,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Mi="http://www.w3.org/1999/xhtml";const so={svg:"http://www.w3.org/2000/svg",xhtml:Mi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function pr(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),so.hasOwnProperty(t)?{space:so[t],local:e}:e}function uh(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Mi&&t.documentElement.namespaceURI===Mi?t.createElement(e):t.createElementNS(n,e)}}function hh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function oo(e){var t=pr(e);return(t.local?hh:uh)(t)}function dh(){}function Ui(e){return e==null?dh:function(){return this.querySelector(e)}}function fh(e){typeof e!="function"&&(e=Ui(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=new Array(o),c,l,u=0;u<o;++u)(c=s[u])&&(l=e.call(c,c.__data__,u,s))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new Pt(r,this._parents)}function ph(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function yh(){return[]}function ao(e){return e==null?yh:function(){return this.querySelectorAll(e)}}function mh(e){return function(){return ph(e.apply(this,arguments))}}function gh(e){typeof e=="function"?e=mh(e):e=ao(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Pt(r,i)}function lo(e){return function(){return this.matches(e)}}function co(e){return function(t){return t.matches(e)}}var _h=Array.prototype.find;function bh(e){return function(){return _h.call(this.children,e)}}function vh(){return this.firstElementChild}function wh(e){return this.select(e==null?vh:bh(typeof e=="function"?e:co(e)))}var Ih=Array.prototype.filter;function Sh(){return Array.from(this.children)}function Eh(e){return function(){return Ih.call(this.children,e)}}function Th(e){return this.selectAll(e==null?Sh:Eh(typeof e=="function"?e:co(e)))}function Ah(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new Pt(r,this._parents)}function uo(e){return new Array(e.length)}function Nh(){return new Pt(this._enter||this._groups.map(uo),this._parents)}function yr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}yr.prototype={constructor:yr,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Rh(e){return function(){return e}}function Bh(e,t,n,r,i,s){for(var o=0,a,c=t.length,l=s.length;o<l;++o)(a=t[o])?(a.__data__=s[o],r[o]=a):n[o]=new yr(e,s[o]);for(;o<c;++o)(a=t[o])&&(i[o]=a)}function Oh(e,t,n,r,i,s,o){var a,c,l=new Map,u=t.length,d=s.length,y=new Array(u),m;for(a=0;a<u;++a)(c=t[a])&&(y[a]=m=o.call(c,c.__data__,a,t)+"",l.has(m)?i[a]=c:l.set(m,c));for(a=0;a<d;++a)m=o.call(e,s[a],a,s)+"",(c=l.get(m))?(r[a]=c,c.__data__=s[a],l.delete(m)):n[a]=new yr(e,s[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(y[a])===c&&(i[a]=c)}function Dh(e){return e.__data__}function Lh(e,t){if(!arguments.length)return Array.from(this,Dh);var n=t?Oh:Bh,r=this._parents,i=this._groups;typeof e!="function"&&(e=Rh(e));for(var s=i.length,o=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var u=r[l],d=i[l],y=d.length,m=Fh(e.call(u,u&&u.__data__,l,r)),b=m.length,E=a[l]=new Array(b),A=o[l]=new Array(b),_=c[l]=new Array(y);n(u,d,E,A,_,m,t);for(var H=0,L=0,vt,N;H<b;++H)if(vt=E[H]){for(H>=L&&(L=H+1);!(N=A[L])&&++L<b;);vt._next=N||null}}return o=new Pt(o,r),o._enter=a,o._exit=c,o}function Fh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Mh(){return new Pt(this._exit||this._groups.map(uo),this._parents)}function Uh(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function xh(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,o=Math.min(i,s),a=new Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,y=a[c]=new Array(d),m,b=0;b<d;++b)(m=l[b]||u[b])&&(y[b]=m);for(;c<i;++c)a[c]=n[c];return new Pt(a,this._parents)}function Ch(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],o;--i>=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function $h(e){e||(e=kh);function t(d,y){return d&&y?e(d.__data__,y.__data__):!d-!y}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o=n[s],a=o.length,c=i[s]=new Array(a),l,u=0;u<a;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Pt(i,this._parents).order()}function kh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ph(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Vh(){return Array.from(this)}function zh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var o=r[i];if(o)return o}return null}function Yh(){let e=0;for(const t of this)++e;return e}function jh(){return!this.node()}function qh(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,o=i.length,a;s<o;++s)(a=i[s])&&e.call(a,a.__data__,s,i);return this}function Gh(e){return function(){this.removeAttribute(e)}}function Wh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hh(e,t){return function(){this.setAttribute(e,t)}}function Kh(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Xh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Jh(e,t){var n=pr(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Wh:Gh:typeof t=="function"?n.local?Xh:Qh:n.local?Kh:Hh)(n,t))}function ho(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zh(e){return function(){this.style.removeProperty(e)}}function td(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ed(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function nd(e,t,n){return arguments.length>1?this.each((t==null?Zh:typeof t=="function"?ed:td)(e,t,n??"")):sn(this.node(),e)}function sn(e,t){return e.style.getPropertyValue(t)||ho(e).getComputedStyle(e,null).getPropertyValue(t)}function rd(e){return function(){delete this[e]}}function id(e,t){return function(){this[e]=t}}function sd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function od(e,t){return arguments.length>1?this.each((t==null?rd:typeof t=="function"?sd:id)(e,t)):this.node()[e]}function fo(e){return e.trim().split(/^|\s+/)}function xi(e){return e.classList||new po(e)}function po(e){this._node=e,this._names=fo(e.getAttribute("class")||"")}po.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function yo(e,t){for(var n=xi(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function mo(e,t){for(var n=xi(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function ad(e){return function(){yo(this,e)}}function ld(e){return function(){mo(this,e)}}function cd(e,t){return function(){(t.apply(this,arguments)?yo:mo)(this,e)}}function ud(e,t){var n=fo(e+"");if(arguments.length<2){for(var r=xi(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?cd:t?ad:ld)(n,t))}function hd(){this.textContent=""}function dd(e){return function(){this.textContent=e}}function fd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function pd(e){return arguments.length?this.each(e==null?hd:(typeof e=="function"?fd:dd)(e)):this.node().textContent}function yd(){this.innerHTML=""}function md(e){return function(){this.innerHTML=e}}function gd(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _d(e){return arguments.length?this.each(e==null?yd:(typeof e=="function"?gd:md)(e)):this.node().innerHTML}function bd(){this.nextSibling&&this.parentNode.appendChild(this)}function vd(){return this.each(bd)}function wd(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Id(){return this.each(wd)}function Sd(e){var t=typeof e=="function"?e:oo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ed(){return null}function Td(e,t){var n=typeof e=="function"?e:oo(e),r=t==null?Ed:typeof t=="function"?t:Ui(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Ad(){var e=this.parentNode;e&&e.removeChild(this)}function Nd(){return this.each(Ad)}function Rd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bd(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Od(e){return this.select(e?Bd:Rd)}function Dd(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ld(e){return function(t){e.call(this,t,this.__data__)}}function Fd(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Md(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function Ud(e,t,n){return function(){var r=this.__on,i,s=Ld(t);if(r){for(var o=0,a=r.length;o<a;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function xd(e,t,n){var r=Fd(e+""),i,s=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(i=0,u=a[c];i<s;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(a=t?Ud:Md,i=0;i<s;++i)this.each(a(r[i],t,n));return this}function go(e,t,n){var r=ho(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Cd(e,t){return function(){return go(this,e,t)}}function $d(e,t){return function(){return go(this,e,t.apply(this,arguments))}}function kd(e,t){return this.each((typeof t=="function"?$d:Cd)(e,t))}function*Pd(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,o;i<s;++i)(o=r[i])&&(yield o)}var _o=[null];function Pt(e,t){this._groups=e,this._parents=t}function Ln(){return new Pt([[document.documentElement]],_o)}function Vd(){return this}Pt.prototype=Ln.prototype={constructor:Pt,select:fh,selectAll:gh,selectChild:wh,selectChildren:Th,filter:Ah,data:Lh,enter:Nh,exit:Mh,join:Uh,merge:xh,selection:Vd,order:Ch,sort:$h,call:Ph,nodes:Vh,node:zh,size:Yh,empty:jh,each:qh,attr:Jh,style:nd,property:od,classed:ud,text:pd,html:_d,raise:vd,lower:Id,append:Sd,insert:Td,remove:Nd,clone:Od,datum:Dd,on:xd,dispatch:kd,[Symbol.iterator]:Pd};function be(e){return typeof e=="string"?new Pt([[document.querySelector(e)]],[document.documentElement]):new Pt([[e]],_o)}function zd(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Fe(e,t){if(e=zd(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ci={capture:!0,passive:!1};function $i(e){e.preventDefault(),e.stopImmediatePropagation()}function Yd(e){var t=e.document.documentElement,n=be(e).on("dragstart.drag",$i,Ci);"onselectstart"in t?n.on("selectstart.drag",$i,Ci):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function jd(e,t){var n=e.document.documentElement,r=be(e).on("dragstart.drag",null);t&&(r.on("click.drag",$i,Ci),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function ki(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function bo(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Fn(){}var Mn=.7,mr=1/Mn,on="\\s*([+-]?\\d+)\\s*",Un="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qd=/^#([0-9a-f]{3,8})$/,Gd=new RegExp(`^rgb\\(${on},${on},${on}\\)$`),Wd=new RegExp(`^rgb\\(${se},${se},${se}\\)$`),Hd=new RegExp(`^rgba\\(${on},${on},${on},${Un}\\)$`),Kd=new RegExp(`^rgba\\(${se},${se},${se},${Un}\\)$`),Qd=new RegExp(`^hsl\\(${Un},${se},${se}\\)$`),Xd=new RegExp(`^hsla\\(${Un},${se},${se},${Un}\\)$`),vo={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ki(Fn,xn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:wo,formatHex:wo,formatHex8:Jd,formatHsl:Zd,formatRgb:Io,toString:Io});function wo(){return this.rgb().formatHex()}function Jd(){return this.rgb().formatHex8()}function Zd(){return No(this).formatHsl()}function Io(){return this.rgb().formatRgb()}function xn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=qd.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?So(t):n===3?new Ut(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?gr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?gr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Gd.exec(e))?new Ut(t[1],t[2],t[3],1):(t=Wd.exec(e))?new Ut(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Hd.exec(e))?gr(t[1],t[2],t[3],t[4]):(t=Kd.exec(e))?gr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qd.exec(e))?Ao(t[1],t[2]/100,t[3]/100,1):(t=Xd.exec(e))?Ao(t[1],t[2]/100,t[3]/100,t[4]):vo.hasOwnProperty(e)?So(vo[e]):e==="transparent"?new Ut(NaN,NaN,NaN,0):null}function So(e){return new Ut(e>>16&255,e>>8&255,e&255,1)}function gr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ut(e,t,n,r)}function tf(e){return e instanceof Fn||(e=xn(e)),e?(e=e.rgb(),new Ut(e.r,e.g,e.b,e.opacity)):new Ut}function Pi(e,t,n,r){return arguments.length===1?tf(e):new Ut(e,t,n,r??1)}function Ut(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ki(Ut,Pi,bo(Fn,{brighter(e){return e=e==null?mr:Math.pow(mr,e),new Ut(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mn:Math.pow(Mn,e),new Ut(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ut(We(this.r),We(this.g),We(this.b),_r(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Eo,formatHex:Eo,formatHex8:ef,formatRgb:To,toString:To}));function Eo(){return`#${He(this.r)}${He(this.g)}${He(this.b)}`}function ef(){return`#${He(this.r)}${He(this.g)}${He(this.b)}${He((isNaN(this.opacity)?1:this.opacity)*255)}`}function To(){const e=_r(this.opacity);return`${e===1?"rgb(":"rgba("}${We(this.r)}, ${We(this.g)}, ${We(this.b)}${e===1?")":`, ${e})`}`}function _r(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function We(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function He(e){return e=We(e),(e<16?"0":"")+e.toString(16)}function Ao(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Zt(e,t,n,r)}function No(e){if(e instanceof Zt)return new Zt(e.h,e.s,e.l,e.opacity);if(e instanceof Fn||(e=xn(e)),!e)return new Zt;if(e instanceof Zt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=NaN,a=s-i,c=(s+i)/2;return a?(t===s?o=(n-r)/a+(n<r)*6:n===s?o=(r-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+i:2-s-i,o*=60):a=c>0&&c<1?0:o,new Zt(o,a,c,e.opacity)}function nf(e,t,n,r){return arguments.length===1?No(e):new Zt(e,t,n,r??1)}function Zt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ki(Zt,nf,bo(Fn,{brighter(e){return e=e==null?mr:Math.pow(mr,e),new Zt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mn:Math.pow(Mn,e),new Zt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Ut(Vi(e>=240?e-240:e+120,i,r),Vi(e,i,r),Vi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Zt(Ro(this.h),br(this.s),br(this.l),_r(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=_r(this.opacity);return`${e===1?"hsl(":"hsla("}${Ro(this.h)}, ${br(this.s)*100}%, ${br(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ro(e){return e=(e||0)%360,e<0?e+360:e}function br(e){return Math.max(0,Math.min(1,e||0))}function Vi(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Bo=e=>()=>e;function rf(e,t){return function(n){return e+n*t}}function sf(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function of(e){return(e=+e)==1?Oo:function(t,n){return n-t?sf(t,n,e):Bo(isNaN(t)?n:t)}}function Oo(e,t){var n=t-e;return n?rf(e,n):Bo(isNaN(e)?t:e)}const Do=function e(t){var n=of(t);function r(i,s){var o=n((i=Pi(i)).r,(s=Pi(s)).r),a=n(i.g,s.g),c=n(i.b,s.b),l=Oo(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=a(u),i.b=c(u),i.opacity=l(u),i+""}}return r.gamma=e,r}(1);function Me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var zi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yi=new RegExp(zi.source,"g");function af(e){return function(){return e}}function lf(e){return function(t){return e(t)+""}}function cf(e,t){var n=zi.lastIndex=Yi.lastIndex=0,r,i,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(r=zi.exec(e))&&(i=Yi.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,c.push({i:o,x:Me(r,i)})),n=Yi.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?lf(c[0].x):af(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}var Lo=180/Math.PI,Fo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Mo(e,t,n,r,i,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*Lo,skewX:Math.atan(c)*Lo,scaleX:o,scaleY:a}}var vr;function uf(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fo:Mo(t.a,t.b,t.c,t.d,t.e,t.f)}function hf(e){return e==null||(vr||(vr=document.createElementNS("http://www.w3.org/2000/svg","g")),vr.setAttribute("transform",e),!(e=vr.transform.baseVal.consolidate()))?Fo:(e=e.matrix,Mo(e.a,e.b,e.c,e.d,e.e,e.f))}function Uo(e,t,n,r){function i(l){return l.length?l.pop()+" ":""}function s(l,u,d,y,m,b){if(l!==d||u!==y){var E=m.push("translate(",null,t,null,n);b.push({i:E-4,x:Me(l,d)},{i:E-2,x:Me(u,y)})}else(d||y)&&m.push("translate("+d+t+y+n)}function o(l,u,d,y){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),y.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Me(l,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(l,u,d,y){l!==u?y.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Me(l,u)}):u&&d.push(i(d)+"skewX("+u+r)}function c(l,u,d,y,m,b){if(l!==d||u!==y){var E=m.push(i(m)+"scale(",null,",",null,")");b.push({i:E-4,x:Me(l,d)},{i:E-2,x:Me(u,y)})}else(d!==1||y!==1)&&m.push(i(m)+"scale("+d+","+y+")")}return function(l,u){var d=[],y=[];return l=e(l),u=e(u),s(l.translateX,l.translateY,u.translateX,u.translateY,d,y),o(l.rotate,u.rotate,d,y),a(l.skewX,u.skewX,d,y),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,y),l=u=null,function(m){for(var b=-1,E=y.length,A;++b<E;)d[(A=y[b]).i]=A.x(m);return d.join("")}}}var df=Uo(uf,"px, ","px)","deg)"),ff=Uo(hf,", ",")",")"),pf=1e-12;function xo(e){return((e=Math.exp(e))+1/e)/2}function yf(e){return((e=Math.exp(e))-1/e)/2}function mf(e){return((e=Math.exp(2*e))-1)/(e+1)}const gf=function e(t,n,r){function i(s,o){var a=s[0],c=s[1],l=s[2],u=o[0],d=o[1],y=o[2],m=u-a,b=d-c,E=m*m+b*b,A,_;if(E<pf)_=Math.log(y/l)/t,A=function(T){return[a+T*m,c+T*b,l*Math.exp(t*T*_)]};else{var H=Math.sqrt(E),L=(y*y-l*l+r*E)/(2*l*n*H),vt=(y*y-l*l-r*E)/(2*y*n*H),N=Math.log(Math.sqrt(L*L+1)-L),O=Math.log(Math.sqrt(vt*vt+1)-vt);_=(O-N)/t,A=function(T){var D=T*_,Y=xo(N),G=l/(n*H)*(Y*mf(t*D+N)-yf(N));return[a+G*m,c+G*b,l*Y/xo(t*D+N)]}}return A.duration=_*1e3*t/Math.SQRT2,A}return i.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},i}(Math.SQRT2,2,4);var an=0,Cn=0,$n=0,Co=1e3,wr,kn,Ir=0,Ke=0,Sr=0,Pn=typeof performance=="object"&&performance.now?performance:Date,$o=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ji(){return Ke||($o(_f),Ke=Pn.now()+Sr)}function _f(){Ke=0}function Er(){this._call=this._time=this._next=null}Er.prototype=ko.prototype={constructor:Er,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ji():+n)+(t==null?0:+t),!this._next&&kn!==this&&(kn?kn._next=this:wr=this,kn=this),this._call=e,this._time=n,qi()},stop:function(){this._call&&(this._call=null,this._time=1/0,qi())}};function ko(e,t,n){var r=new Er;return r.restart(e,t,n),r}function bf(){ji(),++an;for(var e=wr,t;e;)(t=Ke-e._time)>=0&&e._call.call(void 0,t),e=e._next;--an}function Po(){Ke=(Ir=Pn.now())+Sr,an=Cn=0;try{bf()}finally{an=0,wf(),Ke=0}}function vf(){var e=Pn.now(),t=e-Ir;t>Co&&(Sr-=t,Ir=e)}function wf(){for(var e,t=wr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:wr=n);kn=e,qi(r)}function qi(e){if(!an){Cn&&(Cn=clearTimeout(Cn));var t=e-Ke;t>24?(e<1/0&&(Cn=setTimeout(Po,e-Pn.now()-Sr)),$n&&($n=clearInterval($n))):($n||(Ir=Pn.now(),$n=setInterval(vf,Co)),an=1,$o(Po))}}function Vo(e,t,n){var r=new Er;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var If=Fi("start","end","cancel","interrupt"),Sf=[],zo=0,Yo=1,Gi=2,Tr=3,jo=4,Wi=5,Ar=6;function Nr(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Ef(e,n,{name:t,index:r,group:i,on:If,tween:Sf,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:zo})}function Hi(e,t){var n=te(e,t);if(n.state>zo)throw new Error("too late; already scheduled");return n}function oe(e,t){var n=te(e,t);if(n.state>Tr)throw new Error("too late; already running");return n}function te(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ef(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=ko(s,0,n.time);function s(l){n.state=Yo,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,d,y,m;if(n.state!==Yo)return c();for(u in r)if(m=r[u],m.name===n.name){if(m.state===Tr)return Vo(o);m.state===jo?(m.state=Ar,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<t&&(m.state=Ar,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(Vo(function(){n.state===Tr&&(n.state=jo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Gi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Gi){for(n.state=Tr,i=new Array(y=n.tween.length),u=0,d=-1;u<y;++u)(m=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(i[++d]=m);i.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wi,1),d=-1,y=i.length;++d<y;)i[d].call(e,u);n.state===Wi&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ar,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Rr(e,t){var n=e.__transition,r,i,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){s=!1;continue}i=r.state>Gi&&r.state<Wi,r.state=Ar,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}s&&delete e.__transition}}function Tf(e){return this.each(function(){Rr(this,e)})}function Af(e,t){var n,r;return function(){var i=oe(this,e),s=i.tween;if(s!==n){r=n=s;for(var o=0,a=r.length;o<a;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Nf(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=oe(this,e),o=s.tween;if(o!==r){i=(r=o).slice();for(var a={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=a;break}c===l&&i.push(a)}s.tween=i}}function Rf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=te(this.node(),n).tween,i=0,s=r.length,o;i<s;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Af:Nf)(n,e,t))}function Ki(e,t,n){var r=e._id;return e.each(function(){var i=oe(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return te(i,r).value[t]}}function qo(e,t){var n;return(typeof t=="number"?Me:t instanceof xn?Do:(n=xn(t))?(t=n,Do):cf)(e,t)}function Bf(e){return function(){this.removeAttribute(e)}}function Of(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Df(e,t,n){var r,i=n+"",s;return function(){var o=this.getAttribute(e);return o===i?null:o===r?s:s=t(r=o,n)}}function Lf(e,t,n){var r,i=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?s:s=t(r=o,n)}}function Ff(e,t,n){var r,i,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a)))}}function Mf(e,t,n){var r,i,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a)))}}function Uf(e,t){var n=pr(e),r=n==="transform"?ff:qo;return this.attrTween(e,typeof t=="function"?(n.local?Mf:Ff)(n,r,Ki(this,"attr."+e,t)):t==null?(n.local?Of:Bf)(n):(n.local?Lf:Df)(n,r,t))}function xf(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Cf(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function $f(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Cf(e,s)),n}return i._value=t,i}function kf(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&xf(e,s)),n}return i._value=t,i}function Pf(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=pr(e);return this.tween(n,(r.local?$f:kf)(r,t))}function Vf(e,t){return function(){Hi(this,e).delay=+t.apply(this,arguments)}}function zf(e,t){return t=+t,function(){Hi(this,e).delay=t}}function Yf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Vf:zf)(t,e)):te(this.node(),t).delay}function jf(e,t){return function(){oe(this,e).duration=+t.apply(this,arguments)}}function qf(e,t){return t=+t,function(){oe(this,e).duration=t}}function Gf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jf:qf)(t,e)):te(this.node(),t).duration}function Wf(e,t){if(typeof t!="function")throw new Error;return function(){oe(this,e).ease=t}}function Hf(e){var t=this._id;return arguments.length?this.each(Wf(t,e)):te(this.node(),t).ease}function Kf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;oe(this,e).ease=n}}function Qf(e){if(typeof e!="function")throw new Error;return this.each(Kf(this._id,e))}function Xf(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new ve(r,this._parents,this._name,this._id)}function Jf(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),o=new Array(r),a=0;a<s;++a)for(var c=t[a],l=n[a],u=c.length,d=o[a]=new Array(u),y,m=0;m<u;++m)(y=c[m]||l[m])&&(d[m]=y);for(;a<r;++a)o[a]=t[a];return new ve(o,this._parents,this._name,this._id)}function Zf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function tp(e,t,n){var r,i,s=Zf(t)?Hi:oe;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function ep(e,t){var n=this._id;return arguments.length<2?te(this.node(),n).on.on(e):this.each(tp(n,e,t))}function np(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function rp(){return this.on("end.remove",np(this._id))}function ip(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ui(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a=r[o],c=a.length,l=s[o]=new Array(c),u,d,y=0;y<c;++y)(u=a[y])&&(d=e.call(u,u.__data__,y,a))&&("__data__"in u&&(d.__data__=u.__data__),l[y]=d,Nr(l[y],t,n,y,l,te(u,n)));return new ve(s,this._parents,t,n)}function sp(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ao(e));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var y=e.call(u,u.__data__,d,c),m,b=te(u,n),E=0,A=y.length;E<A;++E)(m=y[E])&&Nr(m,t,n,E,y,b);s.push(y),o.push(u)}return new ve(s,o,t,n)}var op=Ln.prototype.constructor;function ap(){return new op(this._groups,this._parents)}function lp(e,t){var n,r,i;return function(){var s=sn(this,e),o=(this.style.removeProperty(e),sn(this,e));return s===o?null:s===n&&o===r?i:i=t(n=s,r=o)}}function Go(e){return function(){this.style.removeProperty(e)}}function cp(e,t,n){var r,i=n+"",s;return function(){var o=sn(this,e);return o===i?null:o===r?s:s=t(r=o,n)}}function up(e,t,n){var r,i,s;return function(){var o=sn(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),sn(this,e))),o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a))}}function hp(e,t){var n,r,i,s="style."+t,o="end."+s,a;return function(){var c=oe(this,e),l=c.on,u=c.value[s]==null?a||(a=Go(t)):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function dp(e,t,n){var r=(e+="")=="transform"?df:qo;return t==null?this.styleTween(e,lp(e,r)).on("end.style."+e,Go(e)):typeof t=="function"?this.styleTween(e,up(e,r,Ki(this,"style."+e,t))).each(hp(this._id,e)):this.styleTween(e,cp(e,r,t),n).on("end.style."+e,null)}function fp(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function pp(e,t,n){var r,i;function s(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&fp(e,o,n)),r}return s._value=t,s}function yp(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,pp(e,t,n??""))}function mp(e){return function(){this.textContent=e}}function gp(e){return function(){var t=e(this);this.textContent=t??""}}function _p(e){return this.tween("text",typeof e=="function"?gp(Ki(this,"text",e)):mp(e==null?"":e+""))}function bp(e){return function(t){this.textContent=e.call(this,t)}}function vp(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&bp(i)),t}return r._value=e,r}function wp(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,vp(e))}function Ip(){for(var e=this._name,t=this._id,n=Wo(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var u=te(c,t);Nr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new ve(r,this._parents,e,n)}function Sp(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--i===0&&s()}};n.each(function(){var l=oe(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),i===0&&s()})}var Ep=0;function ve(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Wo(){return++Ep}var we=Ln.prototype;ve.prototype={constructor:ve,select:ip,selectAll:sp,selectChild:we.selectChild,selectChildren:we.selectChildren,filter:Xf,merge:Jf,selection:ap,transition:Ip,call:we.call,nodes:we.nodes,node:we.node,size:we.size,empty:we.empty,each:we.each,on:ep,attr:Uf,attrTween:Pf,style:dp,styleTween:yp,text:_p,textTween:wp,remove:rp,tween:Rf,delay:Yf,duration:Gf,ease:Hf,easeVarying:Qf,end:Sp,[Symbol.iterator]:we[Symbol.iterator]};function Tp(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ap={time:null,delay:0,duration:250,ease:Tp};function Np(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Rp(e){var t,n;e instanceof ve?(t=e._id,e=e._name):(t=Wo(),(n=Ap).time=ji(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&Nr(c,e,t,l,o,n||Np(c,t));return new ve(r,this._parents,e,t)}Ln.prototype.interrupt=Tf,Ln.prototype.transition=Rp;const Br=e=>()=>e;function Bp(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ie(e,t,n){this.k=e,this.x=t,this.y=n}Ie.prototype={constructor:Ie,scale:function(e){return e===1?this:new Ie(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ie(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Or=new Ie(1,0,0);Ie.prototype;function Qi(e){e.stopImmediatePropagation()}function Vn(e){e.preventDefault(),e.stopImmediatePropagation()}function Op(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Dp(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ho(){return this.__zoom||Or}function Lp(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fp(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mp(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Up(){var e=Op,t=Dp,n=Mp,r=Lp,i=Fp,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=gf,l=Fi("start","zoom","end"),u,d,y,m=500,b=150,E=0,A=10;function _(g){g.property("__zoom",Ho).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",Y).on("dblclick.zoom",G).filter(i).on("touchstart.zoom",ct).on("touchmove.zoom",bt).on("touchend.zoom touchcancel.zoom",yt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(g,v,h,w){var I=g.selection?g.selection():g;I.property("__zoom",Ho),g!==I?N(g,v,h,w):I.interrupt().each(function(){O(this,arguments).event(w).start().zoom(null,typeof v=="function"?v.apply(this,arguments):v).end()})},_.scaleBy=function(g,v,h,w){_.scaleTo(g,function(){var I=this.__zoom.k,S=typeof v=="function"?v.apply(this,arguments):v;return I*S},h,w)},_.scaleTo=function(g,v,h,w){_.transform(g,function(){var I=t.apply(this,arguments),S=this.__zoom,R=h==null?vt(I):typeof h=="function"?h.apply(this,arguments):h,B=S.invert(R),Q=typeof v=="function"?v.apply(this,arguments):v;return n(L(H(S,Q),R,B),I,o)},h,w)},_.translateBy=function(g,v,h,w){_.transform(g,function(){return n(this.__zoom.translate(typeof v=="function"?v.apply(this,arguments):v,typeof h=="function"?h.apply(this,arguments):h),t.apply(this,arguments),o)},null,w)},_.translateTo=function(g,v,h,w,I){_.transform(g,function(){var S=t.apply(this,arguments),R=this.__zoom,B=w==null?vt(S):typeof w=="function"?w.apply(this,arguments):w;return n(Or.translate(B[0],B[1]).scale(R.k).translate(typeof v=="function"?-v.apply(this,arguments):-v,typeof h=="function"?-h.apply(this,arguments):-h),S,o)},w,I)};function H(g,v){return v=Math.max(s[0],Math.min(s[1],v)),v===g.k?g:new Ie(v,g.x,g.y)}function L(g,v,h){var w=v[0]-h[0]*g.k,I=v[1]-h[1]*g.k;return w===g.x&&I===g.y?g:new Ie(g.k,w,I)}function vt(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function N(g,v,h,w){g.on("start.zoom",function(){O(this,arguments).event(w).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(w).end()}).tween("zoom",function(){var I=this,S=arguments,R=O(I,S).event(w),B=t.apply(I,S),Q=h==null?vt(B):typeof h=="function"?h.apply(I,S):h,rt=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),tt=I.__zoom,ut=typeof v=="function"?v.apply(I,S):v,It=c(tt.invert(Q).concat(rt/tt.k),ut.invert(Q).concat(rt/ut.k));return function(nt){if(nt===1)nt=ut;else{var mt=It(nt),Bt=rt/mt[2];nt=new Ie(Bt,Q[0]-mt[0]*Bt,Q[1]-mt[1]*Bt)}R.zoom(null,nt)}})}function O(g,v,h){return!h&&g.__zooming||new T(g,v)}function T(g,v){this.that=g,this.args=v,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,v),this.taps=0}T.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,v){return this.mouse&&g!=="mouse"&&(this.mouse[1]=v.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=v.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=v.invert(this.touch1[0])),this.that.__zoom=v,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var v=be(this.that).datum();l.call(g,this.that,new Bp(g,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:l}),v)}};function D(g,...v){if(!e.apply(this,arguments))return;var h=O(this,v).event(g),w=this.__zoom,I=Math.max(s[0],Math.min(s[1],w.k*Math.pow(2,r.apply(this,arguments)))),S=Fe(g);if(h.wheel)(h.mouse[0][0]!==S[0]||h.mouse[0][1]!==S[1])&&(h.mouse[1]=w.invert(h.mouse[0]=S)),clearTimeout(h.wheel);else{if(w.k===I)return;h.mouse=[S,w.invert(S)],Rr(this),h.start()}Vn(g),h.wheel=setTimeout(R,b),h.zoom("mouse",n(L(H(w,I),h.mouse[0],h.mouse[1]),h.extent,o));function R(){h.wheel=null,h.end()}}function Y(g,...v){if(y||!e.apply(this,arguments))return;var h=g.currentTarget,w=O(this,v,!0).event(g),I=be(g.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",rt,!0),S=Fe(g,h),R=g.clientX,B=g.clientY;Yd(g.view),Qi(g),w.mouse=[S,this.__zoom.invert(S)],Rr(this),w.start();function Q(tt){if(Vn(tt),!w.moved){var ut=tt.clientX-R,It=tt.clientY-B;w.moved=ut*ut+It*It>E}w.event(tt).zoom("mouse",n(L(w.that.__zoom,w.mouse[0]=Fe(tt,h),w.mouse[1]),w.extent,o))}function rt(tt){I.on("mousemove.zoom mouseup.zoom",null),jd(tt.view,w.moved),Vn(tt),w.event(tt).end()}}function G(g,...v){if(e.apply(this,arguments)){var h=this.__zoom,w=Fe(g.changedTouches?g.changedTouches[0]:g,this),I=h.invert(w),S=h.k*(g.shiftKey?.5:2),R=n(L(H(h,S),w,I),t.apply(this,v),o);Vn(g),a>0?be(this).transition().duration(a).call(N,R,w,g):be(this).call(_.transform,R,w,g)}}function ct(g,...v){if(e.apply(this,arguments)){var h=g.touches,w=h.length,I=O(this,v,g.changedTouches.length===w).event(g),S,R,B,Q;for(Qi(g),R=0;R<w;++R)B=h[R],Q=Fe(B,this),Q=[Q,this.__zoom.invert(Q),B.identifier],I.touch0?!I.touch1&&I.touch0[2]!==Q[2]&&(I.touch1=Q,I.taps=0):(I.touch0=Q,S=!0,I.taps=1+!!u);u&&(u=clearTimeout(u)),S&&(I.taps<2&&(d=Q[0],u=setTimeout(function(){u=null},m)),Rr(this),I.start())}}function bt(g,...v){if(this.__zooming){var h=O(this,v).event(g),w=g.changedTouches,I=w.length,S,R,B,Q;for(Vn(g),S=0;S<I;++S)R=w[S],B=Fe(R,this),h.touch0&&h.touch0[2]===R.identifier?h.touch0[0]=B:h.touch1&&h.touch1[2]===R.identifier&&(h.touch1[0]=B);if(R=h.that.__zoom,h.touch1){var rt=h.touch0[0],tt=h.touch0[1],ut=h.touch1[0],It=h.touch1[1],nt=(nt=ut[0]-rt[0])*nt+(nt=ut[1]-rt[1])*nt,mt=(mt=It[0]-tt[0])*mt+(mt=It[1]-tt[1])*mt;R=H(R,Math.sqrt(nt/mt)),B=[(rt[0]+ut[0])/2,(rt[1]+ut[1])/2],Q=[(tt[0]+It[0])/2,(tt[1]+It[1])/2]}else if(h.touch0)B=h.touch0[0],Q=h.touch0[1];else return;h.zoom("touch",n(L(R,B,Q),h.extent,o))}}function yt(g,...v){if(this.__zooming){var h=O(this,v).event(g),w=g.changedTouches,I=w.length,S,R;for(Qi(g),y&&clearTimeout(y),y=setTimeout(function(){y=null},m),S=0;S<I;++S)R=w[S],h.touch0&&h.touch0[2]===R.identifier?delete h.touch0:h.touch1&&h.touch1[2]===R.identifier&&delete h.touch1;if(h.touch1&&!h.touch0&&(h.touch0=h.touch1,delete h.touch1),h.touch0)h.touch0[1]=this.__zoom.invert(h.touch0[0]);else if(h.end(),h.taps===2&&(R=Fe(R,this),Math.hypot(d[0]-R[0],d[1]-R[1])<A)){var B=be(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return _.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:Br(+g),_):r},_.filter=function(g){return arguments.length?(e=typeof g=="function"?g:Br(!!g),_):e},_.touchable=function(g){return arguments.length?(i=typeof g=="function"?g:Br(!!g),_):i},_.extent=function(g){return arguments.length?(t=typeof g=="function"?g:Br([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),_):t},_.scaleExtent=function(g){return arguments.length?(s[0]=+g[0],s[1]=+g[1],_):[s[0],s[1]]},_.translateExtent=function(g){return arguments.length?(o[0][0]=+g[0][0],o[1][0]=+g[1][0],o[0][1]=+g[0][1],o[1][1]=+g[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(g){return arguments.length?(n=g,_):n},_.duration=function(g){return arguments.length?(a=+g,_):a},_.interpolate=function(g){return arguments.length?(c=g,_):c},_.on=function(){var g=l.on.apply(l,arguments);return g===l?_:g},_.clickDistance=function(g){return arguments.length?(E=(g=+g)*g,_):Math.sqrt(E)},_.tapDistance=function(g){return arguments.length?(A=+g,_):A},_}const xp=f.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random",validator:e=>["random","gradient","single","species","sex","Type"].includes(e)},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=f.ref(null),i=f.ref(null),s=f.ref(null),o=f.ref(null);let a=null,c=null,l=null,u=[],d=null,y=null,m=null,b=0,E=0,A=1;function _(h){if(!h||h.length<7)return[1,0,0];const w=parseInt(h.slice(1,3),16)/255,I=parseInt(h.slice(3,5),16)/255,S=parseInt(h.slice(5,7),16)/255;return[w,I,S].some(Number.isNaN)?[1,0,0]:[w,I,S]}const H=(h,w,I)=>h+(w-h)*I;function L(h,w){const I=h.parentElement;I&&(A=window.devicePixelRatio||1,b=I.clientWidth||800,E=I.clientHeight||400,h.style.width=`${b}px`,h.style.height=`${E}px`,h.width=Math.round(b*A),h.height=Math.round(E*A),w.viewport(0,0,h.width,h.height))}function vt(h,w,I,S,R){var ge,jt,Ot,De,rr,ir;if(!I)return{x:0,y:0};const B=h/S*2,Q=-(w/R*2),rt=(ir=(rr=(De=(Ot=(jt=(ge=n.metaData)==null?void 0:ge.row_groups)==null?void 0:jt[0])==null?void 0:Ot.columns)==null?void 0:De[0])==null?void 0:rr.meta_data)==null?void 0:ir.statistics,tt=2/Math.max(1e-9,((rt==null?void 0:rt.max_value)??1)-((rt==null?void 0:rt.min_value)??-1)),ut=I.x/S*2-1,It=-I.y/R*2+1,nt=I.k*tt,mt=(B-ut-1)/nt,Bt=(Q-It+1)/nt;return{x:mt,y:Bt}}function N(h,w,I,S,R,B){if(!h.length||!S)return null;const Q=vt(w,I,S,R,B);let rt=1/0,tt=null;for(const ut of h){const It=ut.x-Q.x,nt=ut.y-Q.y,mt=Math.hypot(It,nt),Bt=3/(S.k/2);mt<rt&&mt<Bt&&(rt=mt,tt=ut)}return tt&&o.value&&(o.value.innerHTML=`
|
|
15
|
-
Mouse: (${w.toFixed(2)}, ${I.toFixed(2)})<br/>
|
|
16
|
-
Data: (${Q.x.toFixed(2)}, ${Q.y.toFixed(2)})<br/>
|
|
17
|
-
Scale: ${S.k.toFixed(2)}
|
|
18
|
-
`),tt}function O(h,w,I,S,R){const B=_(I),Q=_(S),rt=_(R),tt=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(_),ut=new Map,It=[];for(let nt=0;nt<n.data.length;nt++){const mt=n.data[nt],Bt=mt[0],ge=mt[1],jt=Math.round(Math.sqrt(Bt*Bt+ge*ge)*10)/10;ut.has(mt[5])||ut.set(mt[5],tt[nt%tt.length]);let Ot;switch(w){case"random":Ot=[Math.random(),Math.random(),Math.random()];break;case"gradient":{const De=(Bt+50)/100;Ot=[H(B[0],Q[0],De),H(B[1],Q[1],De),H(B[2],Q[2],De)];break}case"single":Ot=[...rt];break;case"Type":Ot=[...ut.get(mt[5])||[1,1,1]];break;default:Ot=[Math.random(),Math.random(),Math.random()]}It.push({x:Bt,y:ge,rawX:Bt,rawY:ge,color:Ot,id:nt,species:mt[4],value:jt,label:`Point ${nt+1}: (${parseFloat(Bt).toFixed(2)}, ${parseFloat(ge).toFixed(2)})`,category:jt<25?"Near":jt<50?"Medium":"Far"})}return It}function T(h){const w={preserveDrawingBuffer:!0,antialias:!0,alpha:!0},I=h.getContext("webgl",w)||h.getContext("experimental-webgl",w);return I?(I.clearColor(0,0,0,1),I.enable(I.BLEND),I.blendFunc(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA),I.disable(I.DEPTH_TEST),I):(console.error("WebGL not supported"),null)}function D(h,w,I){const S=h.createShader(h.VERTEX_SHADER);if(h.shaderSource(S,w),h.compileShader(S),!h.getShaderParameter(S,h.COMPILE_STATUS))return console.error("Vertex shader error:",h.getShaderInfoLog(S)),null;const R=h.createShader(h.FRAGMENT_SHADER);if(h.shaderSource(R,I),h.compileShader(R),!h.getShaderParameter(R,h.COMPILE_STATUS))return console.error("Fragment shader error:",h.getShaderInfoLog(R)),null;const B=h.createProgram();return h.attachShader(B,S),h.attachShader(B,R),h.linkProgram(B),h.getProgramParameter(B,h.LINK_STATUS)?(h.validateProgram(B),h.getProgramParameter(B,h.VALIDATE_STATUS)?B:(console.error("Program validate error:",h.getProgramInfoLog(B)),null)):(console.error("Program link error:",h.getProgramInfoLog(B)),null)}function Y(h,w,I){if(!I.length)return null;const S=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,S);const R=new Float32Array(I.flatMap(nt=>[nt.x,nt.y]));h.bufferData(h.ARRAY_BUFFER,R,h.STATIC_DRAW);const B=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,B);const Q=new Float32Array(I.flatMap(nt=>nt.color));h.bufferData(h.ARRAY_BUFFER,Q,h.STATIC_DRAW);const rt=h.getAttribLocation(w,"a_position"),tt=h.getAttribLocation(w,"a_color"),ut=h.getUniformLocation(w,"u_viewMatrix"),It=h.getUniformLocation(w,"u_pointSize");return rt===-1||tt===-1||!ut||!It?(console.error("Failed to lookup attrib/uniform locations"),null):{program:w,positionBuffer:S,colorBuffer:B,positionAttributeLocation:rt,colorAttributeLocation:tt,viewMatrixLocation:ut,pointSizeLocation:It,count:I.length}}function G(h,w,I,S,R=null){var fu,pu,yu,mu,gu,_u,bu,vu,wu,Iu,Su,Eu;if(!h||!w||!I)return;const{program:B,positionBuffer:Q,colorBuffer:rt,positionAttributeLocation:tt,colorAttributeLocation:ut,viewMatrixLocation:It,pointSizeLocation:nt,count:mt}=w;h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.useProgram(B),h.enableVertexAttribArray(tt),h.bindBuffer(h.ARRAY_BUFFER,Q),h.vertexAttribPointer(tt,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(ut),h.bindBuffer(h.ARRAY_BUFFER,rt),h.vertexAttribPointer(ut,3,h.FLOAT,!1,0,0);const Bt=h.canvas.clientWidth,ge=h.canvas.clientHeight,jt=(_u=(gu=(mu=(yu=(pu=(fu=n.metaData)==null?void 0:fu.row_groups)==null?void 0:pu[0])==null?void 0:yu.columns)==null?void 0:mu[0])==null?void 0:gu.meta_data)==null?void 0:_u.statistics,Ot=(Eu=(Su=(Iu=(wu=(vu=(bu=n.metaData)==null?void 0:bu.row_groups)==null?void 0:vu[0])==null?void 0:wu.columns)==null?void 0:Iu[1])==null?void 0:Su.meta_data)==null?void 0:Eu.statistics,De=Number((jt==null?void 0:jt.min_value)??-1),rr=Number((jt==null?void 0:jt.max_value)??1),ir=Number((Ot==null?void 0:Ot.min_value)??-1),du=Number((Ot==null?void 0:Ot.max_value)??1),eb=(De+rr)/2,nb=(ir+du)/2,rb=Math.max(1e-9,rr-De),ib=Math.max(1e-9,du-ir),sb=2/Math.max(rb,ib),ob=I.x/Bt*2-1,ab=-I.y/ge*2+1,Di=I.k*sb,lb=ob-Di*eb,cb=ab-Di*nb,ub=new Float32Array([Di,0,0,0,0,Di,0,0,0,0,1,0,lb,cb,0,1]);if(h.uniformMatrix4fv(It,!1,ub),h.uniform1f(nt,S*Math.sqrt(I.k)*A),h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),h.drawArrays(h.POINTS,0,mt),R){const Tu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,Tu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([R.x,R.y]),h.STATIC_DRAW),h.vertexAttribPointer(tt,2,h.FLOAT,!1,0,0);const Au=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,Au),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,1,.5]),h.STATIC_DRAW),h.vertexAttribPointer(ut,3,h.FLOAT,!1,0,0),h.uniform1f(nt,S*Math.sqrt(I.k)*2.5*A),h.drawArrays(h.POINTS,0,1);const Nu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,Nu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,.8,.2]),h.STATIC_DRAW),h.vertexAttribPointer(ut,3,h.FLOAT,!1,0,0),h.uniform1f(nt,S*Math.sqrt(I.k)*3*A),h.drawArrays(h.POINTS,0,1),h.deleteBuffer(Tu),h.deleteBuffer(Au),h.deleteBuffer(Nu)}}function ct(){!i.value||!r.value||(a=T(i.value),!a)||(L(i.value,a),c=D(a,`
|
|
13
|
+
LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);h.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:N.value,tableName:c.value,isConnected:B.value,activeConnections:i.activeConnectionCount,hasActiveConnections:i.hasActiveConnections}));const It=async()=>{try{const{connection:m,connectionId:b}=await i.createConnection(n.viewerId);N.value=b,l.value&&(await $t(),ht())}catch(m){console.error("Failed to initialize viewer:",m),_.value=`Failed to initialize: ${m.message}`}},$t=async()=>{if(!l.value){_.value="Please provide a valid S3 URL";return}const m=n.fileId||l.value,b=i.getLoadedFile(m);if(b&&!b.isLoading&&!b.error){c.value=b.tableName,F("SELECT * FROM data LIMIT 10;");return}a.value=!0,_.value="";try{const w=n.fileId?`file_${n.fileId}`:`data_${Date.now()}`,I=await i.loadFile(l.value,n.fileType,w,s.value,n.viewerId,n.fileId);c.value=I,F("SELECT * FROM data LIMIT 10;")}catch{}finally{a.value=!1}},dt=m=>!c.value||!m?m:m.replace(/\bFROM\s+data\b/gi,`FROM ${c.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${c.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${c.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${c.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${c.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${c.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${c.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${c.value})`),ht=async()=>{if(!d.value||!N.value){_.value="Please provide a valid SQL query";return}if(!c.value){_.value="No data table loaded";return}o.value=!0,_.value="",E.value=1;try{const m=dt(d.value.trim());y.value=await i.executeQuery(m,N.value),await i.publishViewFromQuery("umap_result",m,N.value),r("query-results",{results:y.value,query:m})}catch(m){console.error("Query execution failed:",m),_.value=`Query execution failed: ${m.message}`,y.value=null}finally{o.value=!1}},Zt=m=>{E.value=m},R=m=>{T.value=m,E.value=1},F=m=>{d.value=m},p=m=>m==null?"NULL":typeof m=="number"?Number.isInteger(m)?m.toString():m.toFixed(4):typeof m=="string"&&m.length>100?m.substring(0,100)+"...":m.toString(),g=()=>{if(!y.value||y.value.length===0)return;const m=Object.keys(y.value[0]),b=[m.join(","),...y.value.map(O=>m.map(A=>{const M=O[A],J=M==null?"":M.toString();return J.includes(",")?`"${J}"`:J}).join(","))].join(`
|
|
14
|
+
`),w=new Blob([b],{type:"text/csv"}),I=URL.createObjectURL(w),S=document.createElement("a");S.href=I,S.download="query-results.csv",S.click(),URL.revokeObjectURL(I)},u=()=>{_.value=""};return h.onMounted(async()=>{await It()}),h.onUnmounted(async()=>{N.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(N.value),i.activeConnectionCount,i.loadedFiles.size)}),(m,b)=>{const w=h.resolveComponent("bf-button"),I=h.resolveComponent("el-pagination");return h.openBlock(),h.createElementBlock("div",Qc,[h.createElementVNode("header",Xc,[b[3]||(b[3]=h.createElementVNode("h1",null,"Data Explorer",-1)),h.createElementVNode("div",{class:h.normalizeClass(["status-indicator",{connected:B.value,loading:a.value}])},h.toDisplayString(Q.value),3)]),h.createElementVNode("div",Jc,[B.value?(h.openBlock(),h.createElementBlock("div",Zc,[b[5]||(b[5]=h.createElementVNode("h3",null,"SQL Query",-1)),h.createElementVNode("div",tu,[b[4]||(b[4]=h.createElementVNode("span",null,"Quick queries:",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(gt.value,S=>(h.openBlock(),h.createElementBlock("button",{key:S.name,onClick:O=>F(S.query),class:"example-btn"},h.toDisplayString(S.name),9,eu))),128))]),h.withDirectives(h.createElementVNode("textarea",{"onUpdate:modelValue":b[0]||(b[0]=S=>d.value=S),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[h.vModelText,d.value]]),h.createVNode(w,{onClick:ht,disabled:o.value||!d.value},{default:h.withCtx(()=>[h.createTextVNode(h.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):h.createCommentVNode("",!0),y.value?(h.openBlock(),h.createElementBlock("div",nu,[h.createElementVNode("h3",null,"Results ("+h.toDisplayString(y.value.length)+" rows)",1),h.createElementVNode("div",ru,[h.createElementVNode("div",iu,[h.createVNode(w,{class:"secondary",onClick:g},{default:h.withCtx(()=>[...b[6]||(b[6]=[h.createTextVNode("Export to CSV",-1)])]),_:1})]),h.createElementVNode("div",su,[v.value==="table"&&mt.value>1?(h.openBlock(),h.createBlock(I,{key:0,"current-page":E.value,"onUpdate:currentPage":b[1]||(b[1]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:"prev, pager, next",onCurrentChange:Zt,class:"results-pagination"},null,8,["current-page","page-size","total"])):h.createCommentVNode("",!0)])]),b[7]||(b[7]=h.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),v.value==="table"?(h.openBlock(),h.createElementBlock("div",au,[h.createElementVNode("table",ou,[h.createElementVNode("thead",null,[h.createElementVNode("tr",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,S=>(h.openBlock(),h.createElementBlock("th",{key:S},h.toDisplayString(S),1))),128))])]),h.createElementVNode("tbody",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(bt.value,(S,O)=>(h.openBlock(),h.createElementBlock("tr",{key:O},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,A=>(h.openBlock(),h.createElementBlock("td",{key:A},h.toDisplayString(p(S[A])),1))),128))]))),128))])]),mt.value>1?(h.openBlock(),h.createElementBlock("div",lu,[h.createVNode(I,{"current-page":E.value,"onUpdate:currentPage":b[2]||(b[2]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:Zt,onSizeChange:R},null,8,["current-page","page-size","total"])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.createElementBlock("div",cu,[h.createElementVNode("pre",null,h.toDisplayString(JSON.stringify(y.value.slice(0,100),null,2)),1)]))])):h.createCommentVNode("",!0),_.value?(h.openBlock(),h.createElementBlock("div",uu,[b[8]||(b[8]=h.createElementVNode("h3",null,"Error",-1)),h.createElementVNode("p",null,h.toDisplayString(_.value),1),h.createElementVNode("button",{onClick:u,class:"clear-error-btn"},"Clear")])):h.createCommentVNode("",!0)])])}}},du=Sn(hu,[["__scopeId","data-v-6d7b972b"]]),fu={class:"app-container"},pu=h.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=h.ref([]),s=h.ref(""),a=h.ref("parquet"),o=h.ref("");h.onMounted(async()=>{var v,E,T,N,B;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),o.value=n.srcFileId??"url_"+btoa(n.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const _=Kc("",["content","id"],n.pkg);if(!_||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await d(_);const Q=(T=(E=(v=i.value)==null?void 0:v[0])==null?void 0:E.content)==null?void 0:T.id;if(!Q){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=Q,s.value=await y(_,Q);const it=(B=(N=n.pkg)==null?void 0:N.content)==null?void 0:B.packageType;a.value=it==="CSV"?"csv":"parquet"}catch(Q){console.error(Q)}});function l(_){r("queryResults",_)}async function c(){const{useGetToken:_}=await Promise.resolve().then(()=>Bc);return _()}async function d(_){const v=await c(),E=`${n.apiUrl}/packages/${_}/view?api_key=${v}`,T=await fetch(E);if(!T.ok)throw new Error(`view failed: ${T.status}`);i.value=await T.json()}async function y(_,v){const E=await c(),T=`${n.apiUrl}/packages/${_}/files/${v}?api_key=${E}`,N=await fetch(T);if(!N.ok)throw new Error(`file url failed: ${N.status}`);return(await N.json()).url}return(_,v)=>(h.openBlock(),h.createElementBlock("div",fu,[h.createVNode(du,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:v[0]||(v[0]=E=>l(E))},null,8,["url","file-type","file-id"])]))}}),yu=Sn(pu,[["__scopeId","data-v-d6dbc8b5"]]);var mu={value:()=>{}};function vi(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new sr(n)}function sr(e){this._=e}function bu(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}sr.prototype=vi.prototype={constructor:sr,on:function(e,t){var n=this._,r=bu(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=gu(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=Ys(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ys(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new sr(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function gu(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ys(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=mu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var wi="http://www.w3.org/1999/xhtml";const Ws={svg:"http://www.w3.org/2000/svg",xhtml:wi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ar(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ws.hasOwnProperty(t)?{space:Ws[t],local:e}:e}function _u(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===wi&&t.documentElement.namespaceURI===wi?t.createElement(e):t.createElementNS(n,e)}}function vu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qs(e){var t=ar(e);return(t.local?vu:_u)(t)}function wu(){}function Ii(e){return e==null?wu:function(){return this.querySelector(e)}}function Iu(e){typeof e!="function"&&(e=Ii(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,c,d=0;d<a;++d)(l=s[d])&&(c=e.call(l,l.__data__,d,s))&&("__data__"in l&&(c.__data__=l.__data__),o[d]=c);return new xt(r,this._parents)}function Su(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Eu(){return[]}function Gs(e){return e==null?Eu:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return Su(e.apply(this,arguments))}}function Au(e){typeof e=="function"?e=Tu(e):e=Gs(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&(r.push(e.call(l,l.__data__,c,a)),i.push(l));return new xt(r,i)}function Hs(e){return function(){return this.matches(e)}}function Ks(e){return function(t){return t.matches(e)}}var Nu=Array.prototype.find;function Bu(e){return function(){return Nu.call(this.children,e)}}function Ru(){return this.firstElementChild}function Ou(e){return this.select(e==null?Ru:Bu(typeof e=="function"?e:Ks(e)))}var Du=Array.prototype.filter;function Fu(){return Array.from(this.children)}function Mu(e){return function(){return Du.call(this.children,e)}}function Lu(e){return this.selectAll(e==null?Fu:Mu(typeof e=="function"?e:Ks(e)))}function xu(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new xt(r,this._parents)}function Qs(e){return new Array(e.length)}function Uu(){return new xt(this._enter||this._groups.map(Qs),this._parents)}function or(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}or.prototype={constructor:or,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Cu(e){return function(){return e}}function ku(e,t,n,r,i,s){for(var a=0,o,l=t.length,c=s.length;a<c;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new or(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function $u(e,t,n,r,i,s,a){var o,l,c=new Map,d=t.length,y=s.length,_=new Array(d),v;for(o=0;o<d;++o)(l=t[o])&&(_[o]=v=a.call(l,l.__data__,o,t)+"",c.has(v)?i[o]=l:c.set(v,l));for(o=0;o<y;++o)v=a.call(e,s[o],o,s)+"",(l=c.get(v))?(r[o]=l,l.__data__=s[o],c.delete(v)):n[o]=new or(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&c.get(_[o])===l&&(i[o]=l)}function Pu(e){return e.__data__}function Vu(e,t){if(!arguments.length)return Array.from(this,Pu);var n=t?$u:ku,r=this._parents,i=this._groups;typeof e!="function"&&(e=Cu(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),c=0;c<s;++c){var d=r[c],y=i[c],_=y.length,v=zu(e.call(d,d&&d.__data__,c,r)),E=v.length,T=o[c]=new Array(E),N=a[c]=new Array(E),B=l[c]=new Array(_);n(d,y,T,N,B,v,t);for(var Q=0,it=0,mt,bt;Q<E;++Q)if(mt=T[Q]){for(Q>=it&&(it=Q+1);!(bt=N[it])&&++it<E;);mt._next=bt||null}}return a=new xt(a,r),a._enter=o,a._exit=l,a}function zu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ju(){return new xt(this._exit||this._groups.map(Qs),this._parents)}function Yu(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function Wu(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var c=n[l],d=r[l],y=c.length,_=o[l]=new Array(y),v,E=0;E<y;++E)(v=c[E]||d[E])&&(_[E]=v);for(;l<i;++l)o[l]=n[l];return new xt(o,this._parents)}function qu(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function Gu(e){e||(e=Hu);function t(y,_){return y&&_?e(y.__data__,_.__data__):!y-!_}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),c,d=0;d<o;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new xt(i,this._parents).order()}function Hu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ku(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qu(){return Array.from(this)}function Xu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function Ju(){let e=0;for(const t of this)++e;return e}function Zu(){return!this.node()}function th(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function eh(e){return function(){this.removeAttribute(e)}}function nh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t){return function(){this.setAttribute(e,t)}}function ih(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ah(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function oh(e,t){var n=ar(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?nh:eh:typeof t=="function"?n.local?ah:sh:n.local?ih:rh)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lh(e){return function(){this.style.removeProperty(e)}}function ch(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uh(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hh(e,t,n){return arguments.length>1?this.each((t==null?lh:typeof t=="function"?uh:ch)(e,t,n??"")):Qe(this.node(),e)}function Qe(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function dh(e){return function(){delete this[e]}}function fh(e,t){return function(){this[e]=t}}function ph(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yh(e,t){return arguments.length>1?this.each((t==null?dh:typeof t=="function"?ph:fh)(e,t)):this.node()[e]}function Js(e){return e.trim().split(/^|\s+/)}function Si(e){return e.classList||new Zs(e)}function Zs(e){this._node=e,this._names=Js(e.getAttribute("class")||"")}Zs.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ta(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function ea(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mh(e){return function(){ta(this,e)}}function bh(e){return function(){ea(this,e)}}function gh(e,t){return function(){(t.apply(this,arguments)?ta:ea)(this,e)}}function _h(e,t){var n=Js(e+"");if(arguments.length<2){for(var r=Si(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?gh:t?mh:bh)(n,t))}function vh(){this.textContent=""}function wh(e){return function(){this.textContent=e}}function Ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sh(e){return arguments.length?this.each(e==null?vh:(typeof e=="function"?Ih:wh)(e)):this.node().textContent}function Eh(){this.innerHTML=""}function Th(e){return function(){this.innerHTML=e}}function Ah(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Nh(e){return arguments.length?this.each(e==null?Eh:(typeof e=="function"?Ah:Th)(e)):this.node().innerHTML}function Bh(){this.nextSibling&&this.parentNode.appendChild(this)}function Rh(){return this.each(Bh)}function Oh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dh(){return this.each(Oh)}function Fh(e){var t=typeof e=="function"?e:qs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mh(){return null}function Lh(e,t){var n=typeof e=="function"?e:qs(e),r=t==null?Mh:typeof t=="function"?t:Ii(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function xh(){var e=this.parentNode;e&&e.removeChild(this)}function Uh(){return this.each(xh)}function Ch(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $h(e){return this.select(e?kh:Ch)}function Ph(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vh(e){return function(t){e.call(this,t,this.__data__)}}function zh(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function jh(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function Yh(e,t,n){return function(){var r=this.__on,i,s=Vh(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function Wh(e,t,n){var r=zh(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,d;l<c;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?Yh:jh,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function na(e,t,n){var r=Xs(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function qh(e,t){return function(){return na(this,e,t)}}function Gh(e,t){return function(){return na(this,e,t.apply(this,arguments))}}function Hh(e,t){return this.each((typeof t=="function"?Gh:qh)(e,t))}function*Kh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var ra=[null];function xt(e,t){this._groups=e,this._parents=t}function En(){return new xt([[document.documentElement]],ra)}function Qh(){return this}xt.prototype=En.prototype={constructor:xt,select:Iu,selectAll:Au,selectChild:Ou,selectChildren:Lu,filter:xu,data:Vu,enter:Uu,exit:ju,join:Yu,merge:Wu,selection:Qh,order:qu,sort:Gu,call:Ku,nodes:Qu,node:Xu,size:Ju,empty:Zu,each:th,attr:oh,style:hh,property:yh,classed:_h,text:Sh,html:Nh,raise:Rh,lower:Dh,append:Fh,insert:Lh,remove:Uh,clone:$h,datum:Ph,on:Wh,dispatch:Hh,[Symbol.iterator]:Kh};function pe(e){return typeof e=="string"?new xt([[document.querySelector(e)]],[document.documentElement]):new xt([[e]],ra)}function Xh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=Xh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ei={capture:!0,passive:!1};function Ti(e){e.preventDefault(),e.stopImmediatePropagation()}function Jh(e){var t=e.document.documentElement,n=pe(e).on("dragstart.drag",Ti,Ei);"onselectstart"in t?n.on("selectstart.drag",Ti,Ei):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zh(e,t){var n=e.document.documentElement,r=pe(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ti,Ei),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Ai(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ia(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Tn(){}var An=.7,lr=1/An,Xe="\\s*([+-]?\\d+)\\s*",Nn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",td=/^#([0-9a-f]{3,8})$/,ed=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),nd=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),rd=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Nn}\\)$`),id=new RegExp(`^rgba\\(${ee},${ee},${ee},${Nn}\\)$`),sd=new RegExp(`^hsl\\(${Nn},${ee},${ee}\\)$`),ad=new RegExp(`^hsla\\(${Nn},${ee},${ee},${Nn}\\)$`),sa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ai(Tn,Bn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:od,formatHsl:ld,formatRgb:oa,toString:oa});function aa(){return this.rgb().formatHex()}function od(){return this.rgb().formatHex8()}function ld(){return da(this).formatHsl()}function oa(){return this.rgb().formatRgb()}function Bn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=td.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?la(t):n===3?new Ot(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?cr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?cr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ed.exec(e))?new Ot(t[1],t[2],t[3],1):(t=nd.exec(e))?new Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rd.exec(e))?cr(t[1],t[2],t[3],t[4]):(t=id.exec(e))?cr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sd.exec(e))?ha(t[1],t[2]/100,t[3]/100,1):(t=ad.exec(e))?ha(t[1],t[2]/100,t[3]/100,t[4]):sa.hasOwnProperty(e)?la(sa[e]):e==="transparent"?new Ot(NaN,NaN,NaN,0):null}function la(e){return new Ot(e>>16&255,e>>8&255,e&255,1)}function cr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ot(e,t,n,r)}function cd(e){return e instanceof Tn||(e=Bn(e)),e?(e=e.rgb(),new Ot(e.r,e.g,e.b,e.opacity)):new Ot}function Ni(e,t,n,r){return arguments.length===1?cd(e):new Ot(e,t,n,r??1)}function Ot(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ai(Ot,Ni,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ot(Pe(this.r),Pe(this.g),Pe(this.b),ur(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ca,formatHex:ca,formatHex8:ud,formatRgb:ua,toString:ua}));function ca(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function ud(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function ua(){const e=ur(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function ur(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function ha(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ht(e,t,n,r)}function da(e){if(e instanceof Ht)return new Ht(e.h,e.s,e.l,e.opacity);if(e instanceof Tn||(e=Bn(e)),!e)return new Ht;if(e instanceof Ht)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new Ht(a,o,l,e.opacity)}function hd(e,t,n,r){return arguments.length===1?da(e):new Ht(e,t,n,r??1)}function Ht(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ai(Ht,hd,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ht(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ht(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Ot(Bi(e>=240?e-240:e+120,i,r),Bi(e,i,r),Bi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ht(fa(this.h),hr(this.s),hr(this.l),ur(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ur(this.opacity);return`${e===1?"hsl(":"hsla("}${fa(this.h)}, ${hr(this.s)*100}%, ${hr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fa(e){return e=(e||0)%360,e<0?e+360:e}function hr(e){return Math.max(0,Math.min(1,e||0))}function Bi(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const pa=e=>()=>e;function dd(e,t){return function(n){return e+n*t}}function fd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function pd(e){return(e=+e)==1?ya:function(t,n){return n-t?fd(t,n,e):pa(isNaN(t)?n:t)}}function ya(e,t){var n=t-e;return n?dd(e,n):pa(isNaN(e)?t:e)}const ma=function e(t){var n=pd(t);function r(i,s){var a=n((i=Ni(i)).r,(s=Ni(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=ya(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=e,r}(1);function Ne(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Ri=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oi=new RegExp(Ri.source,"g");function yd(e){return function(){return e}}function md(e){return function(t){return e(t)+""}}function bd(e,t){var n=Ri.lastIndex=Oi.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Ri.exec(e))&&(i=Oi.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Ne(r,i)})),n=Oi.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?md(l[0].x):yd(t):(t=l.length,function(c){for(var d=0,y;d<t;++d)o[(y=l[d]).i]=y.x(c);return o.join("")})}var ba=180/Math.PI,ga={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _a(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*ba,skewX:Math.atan(l)*ba,scaleX:a,scaleY:o}}var dr;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ga:_a(t.a,t.b,t.c,t.d,t.e,t.f)}function _d(e){return e==null||(dr||(dr=document.createElementNS("http://www.w3.org/2000/svg","g")),dr.setAttribute("transform",e),!(e=dr.transform.baseVal.consolidate()))?ga:(e=e.matrix,_a(e.a,e.b,e.c,e.d,e.e,e.f))}function va(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function s(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push("translate(",null,t,null,n);E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y||_)&&v.push("translate("+y+t+_+n)}function a(c,d,y,_){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),_.push({i:y.push(i(y)+"rotate(",null,r)-2,x:Ne(c,d)})):d&&y.push(i(y)+"rotate("+d+r)}function o(c,d,y,_){c!==d?_.push({i:y.push(i(y)+"skewX(",null,r)-2,x:Ne(c,d)}):d&&y.push(i(y)+"skewX("+d+r)}function l(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push(i(v)+"scale(",null,",",null,")");E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y!==1||_!==1)&&v.push(i(v)+"scale("+y+","+_+")")}return function(c,d){var y=[],_=[];return c=e(c),d=e(d),s(c.translateX,c.translateY,d.translateX,d.translateY,y,_),a(c.rotate,d.rotate,y,_),o(c.skewX,d.skewX,y,_),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,y,_),c=d=null,function(v){for(var E=-1,T=_.length,N;++E<T;)y[(N=_[E]).i]=N.x(v);return y.join("")}}}var vd=va(gd,"px, ","px)","deg)"),wd=va(_d,", ",")",")"),Id=1e-12;function wa(e){return((e=Math.exp(e))+1/e)/2}function Sd(e){return((e=Math.exp(e))-1/e)/2}function Ed(e){return((e=Math.exp(2*e))-1)/(e+1)}const Td=function e(t,n,r){function i(s,a){var o=s[0],l=s[1],c=s[2],d=a[0],y=a[1],_=a[2],v=d-o,E=y-l,T=v*v+E*E,N,B;if(T<Id)B=Math.log(_/c)/t,N=function(It){return[o+It*v,l+It*E,c*Math.exp(t*It*B)]};else{var Q=Math.sqrt(T),it=(_*_-c*c+r*T)/(2*c*n*Q),mt=(_*_-c*c-r*T)/(2*_*n*Q),bt=Math.log(Math.sqrt(it*it+1)-it),gt=Math.log(Math.sqrt(mt*mt+1)-mt);B=(gt-bt)/t,N=function(It){var $t=It*B,dt=wa(bt),ht=c/(n*Q)*(dt*Ed(t*$t+bt)-Sd(bt));return[o+ht*v,l+ht*E,c*dt/wa(t*$t+bt)]}}return N.duration=B*1e3*t/Math.SQRT2,N}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i}(Math.SQRT2,2,4);var Je=0,Rn=0,On=0,Ia=1e3,fr,Dn,pr=0,ze=0,yr=0,Fn=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Di(){return ze||(Sa(Ad),ze=Fn.now()+yr)}function Ad(){ze=0}function mr(){this._call=this._time=this._next=null}mr.prototype=Ea.prototype={constructor:mr,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Di():+n)+(t==null?0:+t),!this._next&&Dn!==this&&(Dn?Dn._next=this:fr=this,Dn=this),this._call=e,this._time=n,Fi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fi())}};function Ea(e,t,n){var r=new mr;return r.restart(e,t,n),r}function Nd(){Di(),++Je;for(var e=fr,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Je}function Ta(){ze=(pr=Fn.now())+yr,Je=Rn=0;try{Nd()}finally{Je=0,Rd(),ze=0}}function Bd(){var e=Fn.now(),t=e-pr;t>Ia&&(yr-=t,pr=e)}function Rd(){for(var e,t=fr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:fr=n);Dn=e,Fi(r)}function Fi(e){if(!Je){Rn&&(Rn=clearTimeout(Rn));var t=e-ze;t>24?(e<1/0&&(Rn=setTimeout(Ta,e-Fn.now()-yr)),On&&(On=clearInterval(On))):(On||(pr=Fn.now(),On=setInterval(Bd,Ia)),Je=1,Sa(Ta))}}function Aa(e,t,n){var r=new mr;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Od=vi("start","end","cancel","interrupt"),Dd=[],Na=0,Ba=1,Mi=2,br=3,Ra=4,Li=5,gr=6;function _r(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Fd(e,n,{name:t,index:r,group:i,on:Od,tween:Dd,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Na})}function xi(e,t){var n=Kt(e,t);if(n.state>Na)throw new Error("too late; already scheduled");return n}function ne(e,t){var n=Kt(e,t);if(n.state>br)throw new Error("too late; already running");return n}function Kt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fd(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ea(s,0,n.time);function s(c){n.state=Ba,n.timer.restart(a,n.delay,n.time),n.delay<=c&&a(c-n.delay)}function a(c){var d,y,_,v;if(n.state!==Ba)return l();for(d in r)if(v=r[d],v.name===n.name){if(v.state===br)return Aa(a);v.state===Ra?(v.state=gr,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[d]):+d<t&&(v.state=gr,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[d])}if(Aa(function(){n.state===br&&(n.state=Ra,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=Mi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Mi){for(n.state=br,i=new Array(_=n.tween.length),d=0,y=-1;d<_;++d)(v=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++y]=v);i.length=y+1}}function o(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Li,1),y=-1,_=i.length;++y<_;)i[y].call(e,d);n.state===Li&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=gr,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function vr(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>Mi&&r.state<Li,r.state=gr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Md(e){return this.each(function(){vr(this,e)})}function Ld(e,t){var n,r;return function(){var i=ne(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function xd(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ne(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=o;break}l===c&&i.push(o)}s.tween=i}}function Ud(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Kt(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?Ld:xd)(n,e,t))}function Ui(e,t,n){var r=e._id;return e.each(function(){var i=ne(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Kt(i,r).value[t]}}function Oa(e,t){var n;return(typeof t=="number"?Ne:t instanceof Bn?ma:(n=Bn(t))?(t=n,ma):bd)(e,t)}function Cd(e){return function(){this.removeAttribute(e)}}function kd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $d(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function Pd(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function Vd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function zd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function jd(e,t){var n=ar(e),r=n==="transform"?wd:Oa;return this.attrTween(e,typeof t=="function"?(n.local?zd:Vd)(n,r,Ui(this,"attr."+e,t)):t==null?(n.local?kd:Cd)(n):(n.local?Pd:$d)(n,r,t))}function Yd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Wd(e,s)),n}return i._value=t,i}function Gd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Yd(e,s)),n}return i._value=t,i}function Hd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=ar(e);return this.tween(n,(r.local?qd:Gd)(r,t))}function Kd(e,t){return function(){xi(this,e).delay=+t.apply(this,arguments)}}function Qd(e,t){return t=+t,function(){xi(this,e).delay=t}}function Xd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kd:Qd)(t,e)):Kt(this.node(),t).delay}function Jd(e,t){return function(){ne(this,e).duration=+t.apply(this,arguments)}}function Zd(e,t){return t=+t,function(){ne(this,e).duration=t}}function tf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jd:Zd)(t,e)):Kt(this.node(),t).duration}function ef(e,t){if(typeof t!="function")throw new Error;return function(){ne(this,e).ease=t}}function nf(e){var t=this._id;return arguments.length?this.each(ef(t,e)):Kt(this.node(),t).ease}function rf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ne(this,e).ease=n}}function sf(e){if(typeof e!="function")throw new Error;return this.each(rf(this._id,e))}function af(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new ye(r,this._parents,this._name,this._id)}function of(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],c=n[o],d=l.length,y=a[o]=new Array(d),_,v=0;v<d;++v)(_=l[v]||c[v])&&(y[v]=_);for(;o<r;++o)a[o]=t[o];return new ye(a,this._parents,this._name,this._id)}function lf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function cf(e,t,n){var r,i,s=lf(t)?xi:ne;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function uf(e,t){var n=this._id;return arguments.length<2?Kt(this.node(),n).on.on(e):this.each(cf(n,e,t))}function hf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function df(){return this.on("end.remove",hf(this._id))}function ff(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ii(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,c=s[a]=new Array(l),d,y,_=0;_<l;++_)(d=o[_])&&(y=e.call(d,d.__data__,_,o))&&("__data__"in d&&(y.__data__=d.__data__),c[_]=y,_r(c[_],t,n,_,c,Kt(d,n)));return new ye(s,this._parents,t,n)}function pf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gs(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],c=l.length,d,y=0;y<c;++y)if(d=l[y]){for(var _=e.call(d,d.__data__,y,l),v,E=Kt(d,n),T=0,N=_.length;T<N;++T)(v=_[T])&&_r(v,t,n,T,_,E);s.push(_),a.push(d)}return new ye(s,a,t,n)}var yf=En.prototype.constructor;function mf(){return new yf(this._groups,this._parents)}function bf(e,t){var n,r,i;return function(){var s=Qe(this,e),a=(this.style.removeProperty(e),Qe(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function Da(e){return function(){this.style.removeProperty(e)}}function gf(e,t,n){var r,i=n+"",s;return function(){var a=Qe(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function _f(e,t,n){var r,i,s;return function(){var a=Qe(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Qe(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function vf(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=ne(this,e),c=l.on,d=l.value[s]==null?o||(o=Da(t)):void 0;(c!==n||i!==d)&&(r=(n=c).copy()).on(a,i=d),l.on=r}}function wf(e,t,n){var r=(e+="")=="transform"?vd:Oa;return t==null?this.styleTween(e,bf(e,r)).on("end.style."+e,Da(e)):typeof t=="function"?this.styleTween(e,_f(e,r,Ui(this,"style."+e,t))).each(vf(this._id,e)):this.styleTween(e,gf(e,r,t),n).on("end.style."+e,null)}function If(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Sf(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&If(e,a,n)),r}return s._value=t,s}function Ef(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Sf(e,t,n??""))}function Tf(e){return function(){this.textContent=e}}function Af(e){return function(){var t=e(this);this.textContent=t??""}}function Nf(e){return this.tween("text",typeof e=="function"?Af(Ui(this,"text",e)):Tf(e==null?"":e+""))}function Bf(e){return function(t){this.textContent=e.call(this,t)}}function Rf(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Bf(i)),t}return r._value=e,r}function Of(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Rf(e))}function Df(){for(var e=this._name,t=this._id,n=Fa(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)if(l=a[c]){var d=Kt(l,t);_r(l,e,n,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ye(r,this._parents,e,n)}function Ff(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var c=ne(this,r),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),c.on=t}),i===0&&s()})}var Mf=0;function ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fa(){return++Mf}var me=En.prototype;ye.prototype={constructor:ye,select:ff,selectAll:pf,selectChild:me.selectChild,selectChildren:me.selectChildren,filter:af,merge:of,selection:mf,transition:Df,call:me.call,nodes:me.nodes,node:me.node,size:me.size,empty:me.empty,each:me.each,on:uf,attr:jd,attrTween:Hd,style:wf,styleTween:Ef,text:Nf,textTween:Of,remove:df,tween:Ud,delay:Xd,duration:tf,ease:nf,easeVarying:sf,end:Ff,[Symbol.iterator]:me[Symbol.iterator]};function Lf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xf={time:null,delay:0,duration:250,ease:Lf};function Uf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Cf(e){var t,n;e instanceof ye?(t=e._id,e=e._name):(t=Fa(),(n=xf).time=Di(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&_r(l,e,t,c,a,n||Uf(l,t));return new ye(r,this._parents,e,t)}En.prototype.interrupt=Md,En.prototype.transition=Cf;const wr=e=>()=>e;function kf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ir=new be(1,0,0);be.prototype;function Ci(e){e.stopImmediatePropagation()}function Mn(e){e.preventDefault(),e.stopImmediatePropagation()}function $f(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Pf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ma(){return this.__zoom||Ir}function Vf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zf(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Yf(){var e=$f,t=Pf,n=jf,r=Vf,i=zf,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Td,c=vi("start","zoom","end"),d,y,_,v=500,E=150,T=0,N=10;function B(p){p.property("__zoom",Ma).on("wheel.zoom",$t,{passive:!1}).on("mousedown.zoom",dt).on("dblclick.zoom",ht).filter(i).on("touchstart.zoom",Zt).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}B.transform=function(p,g,u,m){var b=p.selection?p.selection():p;b.property("__zoom",Ma),p!==b?bt(p,g,u,m):b.interrupt().each(function(){gt(this,arguments).event(m).start().zoom(null,typeof g=="function"?g.apply(this,arguments):g).end()})},B.scaleBy=function(p,g,u,m){B.scaleTo(p,function(){var b=this.__zoom.k,w=typeof g=="function"?g.apply(this,arguments):g;return b*w},u,m)},B.scaleTo=function(p,g,u,m){B.transform(p,function(){var b=t.apply(this,arguments),w=this.__zoom,I=u==null?mt(b):typeof u=="function"?u.apply(this,arguments):u,S=w.invert(I),O=typeof g=="function"?g.apply(this,arguments):g;return n(it(Q(w,O),I,S),b,a)},u,m)},B.translateBy=function(p,g,u,m){B.transform(p,function(){return n(this.__zoom.translate(typeof g=="function"?g.apply(this,arguments):g,typeof u=="function"?u.apply(this,arguments):u),t.apply(this,arguments),a)},null,m)},B.translateTo=function(p,g,u,m,b){B.transform(p,function(){var w=t.apply(this,arguments),I=this.__zoom,S=m==null?mt(w):typeof m=="function"?m.apply(this,arguments):m;return n(Ir.translate(S[0],S[1]).scale(I.k).translate(typeof g=="function"?-g.apply(this,arguments):-g,typeof u=="function"?-u.apply(this,arguments):-u),w,a)},m,b)};function Q(p,g){return g=Math.max(s[0],Math.min(s[1],g)),g===p.k?p:new be(g,p.x,p.y)}function it(p,g,u){var m=g[0]-u[0]*p.k,b=g[1]-u[1]*p.k;return m===p.x&&b===p.y?p:new be(p.k,m,b)}function mt(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function bt(p,g,u,m){p.on("start.zoom",function(){gt(this,arguments).event(m).start()}).on("interrupt.zoom end.zoom",function(){gt(this,arguments).event(m).end()}).tween("zoom",function(){var b=this,w=arguments,I=gt(b,w).event(m),S=t.apply(b,w),O=u==null?mt(S):typeof u=="function"?u.apply(b,w):u,A=Math.max(S[1][0]-S[0][0],S[1][1]-S[0][1]),M=b.__zoom,J=typeof g=="function"?g.apply(b,w):g,st=l(M.invert(O).concat(A/M.k),J.invert(O).concat(A/J.k));return function(ct){if(ct===1)ct=J;else{var St=st(ct),Ke=A/St[2];ct=new be(Ke,O[0]-St[0]*Ke,O[1]-St[1]*Ke)}I.zoom(null,ct)}})}function gt(p,g,u){return!u&&p.__zooming||new It(p,g)}function It(p,g){this.that=p,this.args=g,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,g),this.taps=0}It.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,g){return this.mouse&&p!=="mouse"&&(this.mouse[1]=g.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=g.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=g.invert(this.touch1[0])),this.that.__zoom=g,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var g=pe(this.that).datum();c.call(p,this.that,new kf(p,{sourceEvent:this.sourceEvent,target:B,transform:this.that.__zoom,dispatch:c}),g)}};function $t(p,...g){if(!e.apply(this,arguments))return;var u=gt(this,g).event(p),m=this.__zoom,b=Math.max(s[0],Math.min(s[1],m.k*Math.pow(2,r.apply(this,arguments)))),w=$e(p);if(u.wheel)(u.mouse[0][0]!==w[0]||u.mouse[0][1]!==w[1])&&(u.mouse[1]=m.invert(u.mouse[0]=w)),clearTimeout(u.wheel);else{if(m.k===b)return;u.mouse=[w,m.invert(w)],vr(this),u.start()}Mn(p),u.wheel=setTimeout(I,E),u.zoom("mouse",n(it(Q(m,b),u.mouse[0],u.mouse[1]),u.extent,a));function I(){u.wheel=null,u.end()}}function dt(p,...g){if(_||!e.apply(this,arguments))return;var u=p.currentTarget,m=gt(this,g,!0).event(p),b=pe(p.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",A,!0),w=$e(p,u),I=p.clientX,S=p.clientY;Jh(p.view),Ci(p),m.mouse=[w,this.__zoom.invert(w)],vr(this),m.start();function O(M){if(Mn(M),!m.moved){var J=M.clientX-I,st=M.clientY-S;m.moved=J*J+st*st>T}m.event(M).zoom("mouse",n(it(m.that.__zoom,m.mouse[0]=$e(M,u),m.mouse[1]),m.extent,a))}function A(M){b.on("mousemove.zoom mouseup.zoom",null),Zh(M.view,m.moved),Mn(M),m.event(M).end()}}function ht(p,...g){if(e.apply(this,arguments)){var u=this.__zoom,m=$e(p.changedTouches?p.changedTouches[0]:p,this),b=u.invert(m),w=u.k*(p.shiftKey?.5:2),I=n(it(Q(u,w),m,b),t.apply(this,g),a);Mn(p),o>0?pe(this).transition().duration(o).call(bt,I,m,p):pe(this).call(B.transform,I,m,p)}}function Zt(p,...g){if(e.apply(this,arguments)){var u=p.touches,m=u.length,b=gt(this,g,p.changedTouches.length===m).event(p),w,I,S,O;for(Ci(p),I=0;I<m;++I)S=u[I],O=$e(S,this),O=[O,this.__zoom.invert(O),S.identifier],b.touch0?!b.touch1&&b.touch0[2]!==O[2]&&(b.touch1=O,b.taps=0):(b.touch0=O,w=!0,b.taps=1+!!d);d&&(d=clearTimeout(d)),w&&(b.taps<2&&(y=O[0],d=setTimeout(function(){d=null},v)),vr(this),b.start())}}function R(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I,S,O;for(Mn(p),w=0;w<b;++w)I=m[w],S=$e(I,this),u.touch0&&u.touch0[2]===I.identifier?u.touch0[0]=S:u.touch1&&u.touch1[2]===I.identifier&&(u.touch1[0]=S);if(I=u.that.__zoom,u.touch1){var A=u.touch0[0],M=u.touch0[1],J=u.touch1[0],st=u.touch1[1],ct=(ct=J[0]-A[0])*ct+(ct=J[1]-A[1])*ct,St=(St=st[0]-M[0])*St+(St=st[1]-M[1])*St;I=Q(I,Math.sqrt(ct/St)),S=[(A[0]+J[0])/2,(A[1]+J[1])/2],O=[(M[0]+st[0])/2,(M[1]+st[1])/2]}else if(u.touch0)S=u.touch0[0],O=u.touch0[1];else return;u.zoom("touch",n(it(I,S,O),u.extent,a))}}function F(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I;for(Ci(p),_&&clearTimeout(_),_=setTimeout(function(){_=null},v),w=0;w<b;++w)I=m[w],u.touch0&&u.touch0[2]===I.identifier?delete u.touch0:u.touch1&&u.touch1[2]===I.identifier&&delete u.touch1;if(u.touch1&&!u.touch0&&(u.touch0=u.touch1,delete u.touch1),u.touch0)u.touch0[1]=this.__zoom.invert(u.touch0[0]);else if(u.end(),u.taps===2&&(I=$e(I,this),Math.hypot(y[0]-I[0],y[1]-I[1])<N)){var S=pe(this).on("dblclick.zoom");S&&S.apply(this,arguments)}}}return B.wheelDelta=function(p){return arguments.length?(r=typeof p=="function"?p:wr(+p),B):r},B.filter=function(p){return arguments.length?(e=typeof p=="function"?p:wr(!!p),B):e},B.touchable=function(p){return arguments.length?(i=typeof p=="function"?p:wr(!!p),B):i},B.extent=function(p){return arguments.length?(t=typeof p=="function"?p:wr([[+p[0][0],+p[0][1]],[+p[1][0],+p[1][1]]]),B):t},B.scaleExtent=function(p){return arguments.length?(s[0]=+p[0],s[1]=+p[1],B):[s[0],s[1]]},B.translateExtent=function(p){return arguments.length?(a[0][0]=+p[0][0],a[1][0]=+p[1][0],a[0][1]=+p[0][1],a[1][1]=+p[1][1],B):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},B.constrain=function(p){return arguments.length?(n=p,B):n},B.duration=function(p){return arguments.length?(o=+p,B):o},B.interpolate=function(p){return arguments.length?(l=p,B):l},B.on=function(){var p=c.on.apply(c,arguments);return p===c?B:p},B.clickDistance=function(p){return arguments.length?(T=(p=+p)*p,B):Math.sqrt(T)},B.tapDistance=function(p){return arguments.length?(N=+p,B):N},B}const Wf=h.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=h.ref(null),i=h.ref(null),s=h.ref(null),a=h.ref(null);let o=null,l=null,c=null,d=[],y=null,_=null,v=null,E=0,T=0,N=1;h.watch(()=>n.colorMap,g,{deep:!0});function B(u){if(!u||u.length<7)return[1,0,0];const m=parseInt(u.slice(1,3),16)/255,b=parseInt(u.slice(3,5),16)/255,w=parseInt(u.slice(5,7),16)/255;return[m,b,w].some(Number.isNaN)?[1,0,0]:[m,b,w]}const Q=(u,m,b)=>u+(m-u)*b;function it(u,m){const b=u.parentElement;b&&(N=window.devicePixelRatio||1,E=b.clientWidth||800,T=b.clientHeight||400,u.style.width=`${E}px`,u.style.height=`${T}px`,u.width=Math.round(E*N),u.height=Math.round(T*N),m.viewport(0,0,u.width,u.height))}function mt(u,m){var Hn,Kn,Qn,Rc,Oc,Dc,Fc,Mc,Lc,xc,Uc,Cc;const b=(Dc=(Oc=(Rc=(Qn=(Kn=(Hn=n.metaData)==null?void 0:Hn.row_groups)==null?void 0:Kn[0])==null?void 0:Qn.columns)==null?void 0:Rc[0])==null?void 0:Oc.meta_data)==null?void 0:Dc.statistics,w=(Cc=(Uc=(xc=(Lc=(Mc=(Fc=n.metaData)==null?void 0:Fc.row_groups)==null?void 0:Mc[0])==null?void 0:Lc.columns)==null?void 0:xc[1])==null?void 0:Uc.meta_data)==null?void 0:Cc.statistics,I=Number((b==null?void 0:b.min_value)??-1),S=Number((b==null?void 0:b.max_value)??1),O=Number((w==null?void 0:w.min_value)??-1),A=Number((w==null?void 0:w.max_value)??1),M=(I+S)/2,J=(O+A)/2,st=Math.max(1e-9,S-I),ct=Math.max(1e-9,A-O),St=2/Math.max(st,ct),Ke=y.x/u*2-1,gi=-y.y/m*2+1,Gn=y.k*St,$s=Ke-Gn*M,Ps=gi-Gn*J;return{s:Gn,tx:$s,ty:Ps}}function bt(u,m,b,w){const{s:I,tx:S,ty:O}=mt(b,w),A=u/b*2-1,M=-(m/w*2-1),J=(A-S)/I,st=(M-O)/I;return{x:J,y:st}}function gt(u,m,b,w,I){if(!u.length||!y)return null;const S=bt(m,b,w,I);let O=1/0,A=null;for(const M of u){const J=M.x-S.x,st=M.y-S.y,ct=Math.hypot(J,st),St=3/(y.k/2);ct<O&&ct<St&&(O=ct,A=M)}return A}function It(){const u=[];for(let m=0;m<n.data.length;m++){const b=n.data[m],w=Number(b[0]),I=Number(b[1]);u.push({x:w,y:I,rawX:w,rawY:I,color:[.5,.5,.5],id:m})}return u}function $t(u,m,b){const w=u.createShader(u.VERTEX_SHADER);if(u.shaderSource(w,m),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))return console.error("Vertex shader error:",u.getShaderInfoLog(w)),null;const I=u.createShader(u.FRAGMENT_SHADER);if(u.shaderSource(I,b),u.compileShader(I),!u.getShaderParameter(I,u.COMPILE_STATUS))return console.error("Fragment shader error:",u.getShaderInfoLog(I)),null;const S=u.createProgram();return u.attachShader(S,w),u.attachShader(S,I),u.linkProgram(S),u.getProgramParameter(S,u.LINK_STATUS)?(u.validateProgram(S),u.getProgramParameter(S,u.VALIDATE_STATUS)?S:(console.error("Program validate error:",u.getProgramInfoLog(S)),null)):(console.error("Program link error:",u.getProgramInfoLog(S)),null)}function dt(u,m,b){if(!b.length)return null;const w=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,w);const I=new Float32Array(b.flatMap(ct=>[ct.x,ct.y]));u.bufferData(u.ARRAY_BUFFER,I,u.STATIC_DRAW);const S=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,S);const O=new Float32Array(b.flatMap(ct=>ct.color));u.bufferData(u.ARRAY_BUFFER,O,u.STATIC_DRAW);const A=u.getAttribLocation(m,"a_position"),M=u.getAttribLocation(m,"a_color"),J=u.getUniformLocation(m,"u_viewMatrix"),st=u.getUniformLocation(m,"u_pointSize");return{program:m,positionBuffer:w,colorBuffer:S,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:b.length}}function ht(u,m,b,w=null){if(!u||!m||!y)return;const{program:I,positionBuffer:S,colorBuffer:O,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:ct}=m;u.clearColor(0,0,0,1),u.clear(u.COLOR_BUFFER_BIT),u.useProgram(I),u.enableVertexAttribArray(A),u.bindBuffer(u.ARRAY_BUFFER,S),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0),u.enableVertexAttribArray(M),u.bindBuffer(u.ARRAY_BUFFER,O),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0);const St=u.canvas.clientWidth,Ke=u.canvas.clientHeight,{s:gi,tx:Gn,ty:$s}=mt(St,Ke),Ps=new Float32Array([gi,0,0,0,0,gi,0,0,0,0,1,0,Gn,$s,0,1]);if(u.uniformMatrix4fv(J,!1,Ps),u.uniform1f(st,Math.max(1.5,b*Math.sqrt(y.k)*N)),u.enable(u.BLEND),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawArrays(u.POINTS,0,ct),w){const Hn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Hn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([w.x,w.y]),u.STATIC_DRAW),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0);const Kn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Kn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,1,.5]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(2.5,b*Math.sqrt(y.k)*2.5*N)),u.drawArrays(u.POINTS,0,1);const Qn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Qn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,.8,.2]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(3,b*Math.sqrt(y.k)*3*N)),u.drawArrays(u.POINTS,0,1),u.deleteBuffer(Hn),u.deleteBuffer(Kn),u.deleteBuffer(Qn)}}function Zt(){if(!(!i.value||!r.value)){if(o=i.value.getContext("webgl",{preserveDrawingBuffer:!0,antialias:!0,alpha:!0})||i.value.getContext("experimental-webgl"),!o){console.error("WebGL not supported");return}it(i.value,o),l=$t(o,`
|
|
19
15
|
attribute vec2 a_position;
|
|
20
16
|
attribute vec3 a_color;
|
|
21
17
|
uniform mat4 u_viewMatrix;
|
|
@@ -33,17 +29,14 @@
|
|
|
33
29
|
float dist = length(gl_PointCoord.xy - vec2(0.5));
|
|
34
30
|
if (dist > 0.5) discard;
|
|
35
31
|
float alpha = 1.0;
|
|
36
|
-
if (dist > 0.4) {
|
|
37
|
-
alpha = 1.0 - (dist - 0.4) * 2.0;
|
|
38
|
-
}
|
|
32
|
+
if (dist > 0.4) { alpha = 1.0 - (dist - 0.4) * 2.0; }
|
|
39
33
|
gl_FragColor = vec4(v_color, alpha);
|
|
40
34
|
}
|
|
41
|
-
`)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Category: ${R.category}
|
|
46
|
-
`,m=R,G(a,l,d,2,m)}else s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,G(a,l,d,2,null))}function g(){s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,G(a,l,d,2,null))}function v(){!i.value||!a||(L(i.value,a),G(a,l,d,2,m))}return f.watch(()=>n.forceRegenerate,()=>{!a||!c||(u=O(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer)),l=Y(a,c,u),d=Or,i.value&&y&&be(i.value).call(y.transform,d),G(a,l,d,2,null))}),f.watch(()=>n.data,()=>{ct()}),f.watch(()=>n.colorMode,()=>{var R;if(!a||!l||!u.length)return;let h=0;const w=((R=n.metaData)==null?void 0:R.schema)||[];for(let B=0;B<w.length;B++)if(w[B].name===n.colorMode){h=B-1;break}const I=new Float32Array(n.data.flatMap(B=>n.colorMap.get(B[h])));a.deleteBuffer(l.colorBuffer);const S=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,S),a.bufferData(a.ARRAY_BUFFER,I,a.STATIC_DRAW),l.colorBuffer=S,G(a,l,d,2,m)}),f.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],()=>{if(["species","sex"].includes(n.colorMode)||!a||!l)return;u=O(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),a.deleteBuffer(l.colorBuffer);const h=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,h);const w=new Float32Array(u.flatMap(I=>I.color));a.bufferData(a.ARRAY_BUFFER,w,a.STATIC_DRAW),l.colorBuffer=h,G(a,l,d,2,m)}),f.watch(()=>n.pointCount,h=>{!a||!c||Math.abs(h-u.length)<=10||(u=O(h,n.colorMode,n.startColor,n.endColor,n.singleColor),l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer)),l=Y(a,c,u),G(a,l,d,2,null))}),f.onMounted(()=>{window.addEventListener("resize",v)}),f.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",yt),i.value.removeEventListener("mouseleave",g)),window.removeEventListener("resize",v),a&&l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer),c&&a.deleteProgram(c))}),(h,w)=>(f.openBlock(),f.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),f.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),f.withDirectives(f.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:o},null,512),[[f.vShow,!1]])],512))}}),Cp=Dn(xp,[["__scopeId","data-v-4779cd2a"]]),$p={class:"control-panel"},kp={class:"color-option"},Pp=["value"],Vp={class:"color-option"},zp={class:"legend"},Yp={class:"legend-label"},jp=f.defineComponent({__name:"control",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},options:{type:Array,default:["Type","Species"]},colorScheme:{type:Map,default:new Map},colorMapMap:{type:Map,default:new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate"],setup(e,{emit:t}){const n=e,r=t,i=f.ref(n.pointCount),s=f.ref(n.colorMode),o=f.ref(n.startColor),a=f.ref(n.endColor),c=f.ref(n.singleColor);function l(d){const y=Math.round(d[0]*255),m=Math.round(d[1]*255),b=Math.round(d[2]*255);return`rgb(${y}, ${m}, ${b})`}function u(){r("updateColorMap",[s.value,n.colorMapMap.get(s.value)]),r("update:colorMode",s.value),r("update:startColor",o.value),r("update:endColor",a.value),r("update:singleColor",c.value)}return f.watch(()=>n.pointCount,d=>{i.value=d}),f.watch(()=>n.colorMode,d=>{s.value=d}),f.watch(()=>n.startColor,d=>{o.value=d}),f.watch(()=>n.endColor,d=>{a.value=d}),f.watch(()=>n.singleColor,d=>{c.value=d}),f.watch(()=>s.value,d=>{u()}),f.watch(i,d=>{r("update:pointCount",d)}),(d,y)=>(f.openBlock(),f.createElementBlock("div",$p,[y[3]||(y[3]=f.createElementVNode("h3",null,"Color Controls",-1)),f.createElementVNode("div",kp,[y[1]||(y[1]=f.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),f.withDirectives(f.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":y[0]||(y[0]=m=>s.value=m)},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(n.colorMapMap,([m,b],E)=>(f.openBlock(),f.createElementBlock("option",{key:m,value:m},f.toDisplayString(m),9,Pp))),128))],512),[[f.vModelSelect,s.value]])]),f.createElementVNode("div",Vp,[f.createElementVNode("div",zp,[y[2]||(y[2]=f.createElementVNode("h4",null," Legend",-1)),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(e.colorScheme,(m,b)=>(f.openBlock(),f.createElementBlock("div",{class:"legend-item",key:b},[f.createElementVNode("div",{class:"legend-color",style:f.normalizeStyle({backgroundColor:l(m[1])})},null,4),f.createElementVNode("div",Yp,f.toDisplayString(m[0]),1)]))),128))])])]))}}),qp=Dn(jp,[["__scopeId","data-v-0a5cce16"]]),Ko=["BOOLEAN","INT32","INT64","INT96","FLOAT","DOUBLE","BYTE_ARRAY","FIXED_LEN_BYTE_ARRAY"],Qe=["PLAIN","GROUP_VAR_INT","PLAIN_DICTIONARY","RLE","BIT_PACKED","DELTA_BINARY_PACKED","DELTA_LENGTH_BYTE_ARRAY","DELTA_BYTE_ARRAY","RLE_DICTIONARY","BYTE_STREAM_SPLIT"],Gp=["REQUIRED","OPTIONAL","REPEATED"],Wp=["UTF8","MAP","MAP_KEY_VALUE","LIST","ENUM","DECIMAL","DATE","TIME_MILLIS","TIME_MICROS","TIMESTAMP_MILLIS","TIMESTAMP_MICROS","UINT_8","UINT_16","UINT_32","UINT_64","INT_8","INT_16","INT_32","INT_64","JSON","BSON","INTERVAL"],Hp=["UNCOMPRESSED","SNAPPY","GZIP","LZO","BROTLI","LZ4","ZSTD","LZ4_RAW"],Qo=["DATA_PAGE","INDEX_PAGE","DICTIONARY_PAGE","DATA_PAGE_V2"],Xo={timestampFromMilliseconds(e){return new Date(Number(e))},timestampFromMicroseconds(e){return new Date(Number(e/1000n))},timestampFromNanoseconds(e){return new Date(Number(e/1000000n))},dateFromDays(e){return new Date(e*864e5)}};function Jo(e,t,n,r){if(t&&n.endsWith("_DICTIONARY")){let i=e;e instanceof Uint8Array&&!(t instanceof Uint8Array)&&(i=new t.constructor(e.length));for(let s=0;s<e.length;s++)i[s]=t[e[s]];return i}else return Zo(e,r)}function Zo(e,t){const{element:n,parsers:r,utf8:i=!0}=t,{type:s,converted_type:o,logical_type:a}=n;if(o==="DECIMAL"){const c=10**-(n.scale||0),l=new Array(e.length);for(let u=0;u<l.length;u++)e[0]instanceof Uint8Array?l[u]=ta(e[u])*c:l[u]=Number(e[u])*c;return l}if(!o&&s==="INT96"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromNanoseconds(Kp(e[l]));return c}if(o==="DATE"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.dateFromDays(e[l]);return c}if(o==="TIMESTAMP_MILLIS"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromMilliseconds(e[l]);return c}if(o==="TIMESTAMP_MICROS"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromMicroseconds(e[l]);return c}if(o==="JSON"){const c=new TextDecoder;return e.map(l=>JSON.parse(c.decode(l)))}if(o==="BSON")throw new Error("parquet bson not supported");if(o==="INTERVAL")throw new Error("parquet interval not supported");if(o==="UTF8"||(a==null?void 0:a.type)==="STRING"||i&&s==="BYTE_ARRAY"){const c=new TextDecoder,l=new Array(e.length);for(let u=0;u<l.length;u++)l[u]=e[u]&&c.decode(e[u]);return l}if(o==="UINT_64"||(a==null?void 0:a.type)==="INTEGER"&&a.bitWidth===64&&!a.isSigned){if(e instanceof BigInt64Array)return new BigUint64Array(e.buffer,e.byteOffset,e.length);const c=new BigUint64Array(e.length);for(let l=0;l<c.length;l++)c[l]=BigInt(e[l]);return c}if(o==="UINT_32"||(a==null?void 0:a.type)==="INTEGER"&&a.bitWidth===32&&!a.isSigned){if(e instanceof Int32Array)return new Uint32Array(e.buffer,e.byteOffset,e.length);const c=new Uint32Array(e.length);for(let l=0;l<c.length;l++)c[l]=e[l];return c}if((a==null?void 0:a.type)==="FLOAT16")return Array.from(e).map(ea);if((a==null?void 0:a.type)==="TIMESTAMP"){const{unit:c}=a;let l=r.timestampFromMilliseconds;c==="MICROS"&&(l=r.timestampFromMicroseconds),c==="NANOS"&&(l=r.timestampFromNanoseconds);const u=new Array(e.length);for(let d=0;d<u.length;d++)u[d]=l(e[d]);return u}return e}function ta(e){let t=0;for(const r of e)t=t*256+r;const n=e.length*8;return t>=2**(n-1)&&(t-=2**n),t}function Kp(e){const t=(e>>64n)-2440588n,n=e&0xffffffffffffffffn;return t*86400000000000n+n}function ea(e){if(!e)return;const t=e[1]<<8|e[0],n=t>>15?-1:1,r=t>>10&31,i=t&1023;return r===0?n*2**-14*(i/1024):r===31?i?NaN:n*(1/0):n*2**(r-15)*(1+i/1024)}function na(e,t,n){const r=e[t],i=[];let s=1;if(r.num_children)for(;i.length<r.num_children;){const o=e[t+s],a=na(e,t+s,[...n,o.name]);s+=a.count,i.push(a)}return{count:s,element:r,children:i,path:n}}function ra(e,t){let n=na(e,0,[]);const r=[n];for(const i of t){const s=n.children.find(o=>o.element.name===i);if(!s)throw new Error(`parquet schema element not found: ${t}`);r.push(s),n=s}return r}function ia(e){let t=0;for(const{element:n}of e)n.repetition_type==="REPEATED"&&t++;return t}function Xi(e){let t=0;for(const{element:n}of e.slice(1))n.repetition_type!=="REQUIRED"&&t++;return t}function Qp(e){if(!e||e.element.converted_type!=="LIST"||e.children.length>1)return!1;const t=e.children[0];return!(t.children.length>1||t.element.repetition_type!=="REPEATED")}function Xp(e){var n,r;if(!e||e.element.converted_type!=="MAP"||e.children.length>1)return!1;const t=e.children[0];return!(t.children.length!==2||t.element.repetition_type!=="REPEATED"||((n=t.children.find(i=>i.element.name==="key"))==null?void 0:n.element.repetition_type)==="REPEATED"||((r=t.children.find(i=>i.element.name==="value"))==null?void 0:r.element.repetition_type)==="REPEATED")}function Jp(e){if(e.length!==2)return!1;const[,t]=e;return!(t.element.repetition_type==="REPEATED"||t.children.length)}const At={STOP:0,TRUE:1,FALSE:2,BYTE:3,I16:4,I32:5,I64:6,DOUBLE:7,BINARY:8,LIST:9,STRUCT:12};function sa(e){let t=0;const n={};for(;e.offset<e.view.byteLength;){const[r,i,s]=aa(e,t);if(t=s,r===At.STOP)break;n[`field_${i}`]=Dr(e,r)}return n}function Dr(e,t){switch(t){case At.TRUE:return!0;case At.FALSE:return!1;case At.BYTE:return e.view.getInt8(e.offset++);case At.I16:case At.I32:return ty(e);case At.I64:return Ji(e);case At.DOUBLE:{const n=e.view.getFloat64(e.offset,!0);return e.offset+=8,n}case At.BINARY:{const n=Xe(e),r=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n);return e.offset+=n,r}case At.LIST:{const[n,r]=ey(e),i=n===At.TRUE||n===At.FALSE,s=new Array(r);for(let o=0;o<r;o++)s[o]=i?Dr(e,At.BYTE)===1:Dr(e,n);return s}case At.STRUCT:{const n={};let r=0;for(;;){let i,s;if([i,s,r]=aa(e,r),i===At.STOP)break;n[`field_${s}`]=Dr(e,i)}return n}default:throw new Error(`thrift unhandled type: ${t}`)}}function Xe(e){let t=0,n=0;for(;;){const r=e.view.getUint8(e.offset++);if(t|=(r&127)<<n,!(r&128))return t;n+=7}}function Zp(e){let t=0n,n=0n;for(;;){const r=e.view.getUint8(e.offset++);if(t|=BigInt(r&127)<<n,!(r&128))return t;n+=7n}}function ty(e){const t=Xe(e);return t>>>1^-(t&1)}function Ji(e){const t=Zp(e);return t>>1n^-(t&1n)}function oa(e){return e&15}function aa(e,t){const n=e.view.getUint8(e.offset++);if((n&15)===At.STOP)return[0,0,t];const r=n>>4;let i;if(r)i=t+r;else throw new Error("non-delta field id not supported");return[oa(n),i,i]}function ey(e){const t=e.view.getUint8(e.offset++),n=t>>4,r=oa(t);if(n===15){const i=Xe(e);return[r,i]}return[r,n]}const ny=1<<19;async function ry(e,{parsers:t,initialFetchSize:n=ny}={}){if(!e||!(e.byteLength>=0))throw new Error("parquet expected AsyncBuffer");const r=Math.max(0,e.byteLength-n),i=await e.slice(r,e.byteLength),s=new DataView(i);if(s.getUint32(i.byteLength-4,!0)!==827474256)throw new Error("parquet file invalid (footer != PAR1)");const o=s.getUint32(i.byteLength-8,!0);if(o>e.byteLength-8)throw new Error(`parquet metadata length ${o} exceeds available buffer ${e.byteLength-8}`);if(o+8>n){const a=e.byteLength-o-8,c=await e.slice(a,r),l=new ArrayBuffer(o+8),u=new Uint8Array(l);return u.set(new Uint8Array(c)),u.set(new Uint8Array(i),r-a),Zi(l,{parsers:t})}else return Zi(i,{parsers:t})}function Zi(e,{parsers:t}={}){var A;if(!(e instanceof ArrayBuffer))throw new Error("parquet expected ArrayBuffer");const n=new DataView(e);if(t={...Xo,...t},n.byteLength<8)throw new Error("parquet file is too short");if(n.getUint32(n.byteLength-4,!0)!==827474256)throw new Error("parquet file invalid (footer != PAR1)");const r=n.byteLength-8,i=n.getUint32(r,!0);if(i>n.byteLength-8)throw new Error(`parquet metadata length ${i} exceeds available buffer ${n.byteLength-8}`);const s=r-i,o=sa({view:n,offset:s}),a=new TextDecoder;function c(_){return _&&a.decode(_)}const l=o.field_1,u=o.field_2.map(_=>({type:Ko[_.field_1],type_length:_.field_2,repetition_type:Gp[_.field_3],name:c(_.field_4),num_children:_.field_5,converted_type:Wp[_.field_6],scale:_.field_7,precision:_.field_8,field_id:_.field_9,logical_type:sy(_.field_10)})),d=u.filter(_=>_.type),y=o.field_3,m=o.field_4.map(_=>{var H;return{columns:_.field_1.map((L,vt)=>{var N,O;return{file_path:c(L.field_1),file_offset:L.field_2,meta_data:L.field_3&&{type:Ko[L.field_3.field_1],encodings:(N=L.field_3.field_2)==null?void 0:N.map(T=>Qe[T]),path_in_schema:L.field_3.field_3.map(c),codec:Hp[L.field_3.field_4],num_values:L.field_3.field_5,total_uncompressed_size:L.field_3.field_6,total_compressed_size:L.field_3.field_7,key_value_metadata:L.field_3.field_8,data_page_offset:L.field_3.field_9,index_page_offset:L.field_3.field_10,dictionary_page_offset:L.field_3.field_11,statistics:oy(L.field_3.field_12,d[vt],t),encoding_stats:(O=L.field_3.field_13)==null?void 0:O.map(T=>({page_type:Qo[T.field_1],encoding:Qe[T.field_2],count:T.field_3})),bloom_filter_offset:L.field_3.field_14,bloom_filter_length:L.field_3.field_15,size_statistics:L.field_3.field_16&&{unencoded_byte_array_data_bytes:L.field_3.field_16.field_1,repetition_level_histogram:L.field_3.field_16.field_2,definition_level_histogram:L.field_3.field_16.field_3}},offset_index_offset:L.field_4,offset_index_length:L.field_5,column_index_offset:L.field_6,column_index_length:L.field_7,crypto_metadata:L.field_8,encrypted_column_metadata:L.field_9}}),total_byte_size:_.field_2,num_rows:_.field_3,sorting_columns:(H=_.field_4)==null?void 0:H.map(L=>({column_idx:L.field_1,descending:L.field_2,nulls_first:L.field_3})),file_offset:_.field_5,total_compressed_size:_.field_6,ordinal:_.field_7}}),b=(A=o.field_5)==null?void 0:A.map(_=>({key:c(_.field_1),value:c(_.field_2)})),E=c(o.field_6);return{version:l,schema:u,num_rows:y,row_groups:m,key_value_metadata:b,created_by:E,metadata_length:i}}function iy({schema:e}){return ra(e,[])[0]}function sy(e){return e!=null&&e.field_1?{type:"STRING"}:e!=null&&e.field_2?{type:"MAP"}:e!=null&&e.field_3?{type:"LIST"}:e!=null&&e.field_4?{type:"ENUM"}:e!=null&&e.field_5?{type:"DECIMAL",scale:e.field_5.field_1,precision:e.field_5.field_2}:e!=null&&e.field_6?{type:"DATE"}:e!=null&&e.field_7?{type:"TIME",isAdjustedToUTC:e.field_7.field_1,unit:la(e.field_7.field_2)}:e!=null&&e.field_8?{type:"TIMESTAMP",isAdjustedToUTC:e.field_8.field_1,unit:la(e.field_8.field_2)}:e!=null&&e.field_10?{type:"INTEGER",bitWidth:e.field_10.field_1,isSigned:e.field_10.field_2}:e!=null&&e.field_11?{type:"NULL"}:e!=null&&e.field_12?{type:"JSON"}:e!=null&&e.field_13?{type:"BSON"}:e!=null&&e.field_14?{type:"UUID"}:e!=null&&e.field_15?{type:"FLOAT16"}:e}function la(e){if(e.field_1)return"MILLIS";if(e.field_2)return"MICROS";if(e.field_3)return"NANOS";throw new Error("parquet time unit required")}function oy(e,t,n){return e&&{max:Lr(e.field_1,t,n),min:Lr(e.field_2,t,n),null_count:e.field_3,distinct_count:e.field_4,max_value:Lr(e.field_5,t,n),min_value:Lr(e.field_6,t,n),is_max_value_exact:e.field_7,is_min_value_exact:e.field_8}}function Lr(e,t,n){const{type:r,converted_type:i,logical_type:s}=t;if(e===void 0)return e;if(r==="BOOLEAN")return e[0]===1;if(r==="BYTE_ARRAY")return new TextDecoder().decode(e);const o=new DataView(e.buffer,e.byteOffset,e.byteLength);return r==="FLOAT"&&o.byteLength===4?o.getFloat32(0,!0):r==="DOUBLE"&&o.byteLength===8?o.getFloat64(0,!0):r==="INT32"&&i==="DATE"?n.dateFromDays(o.getInt32(0,!0)):r==="INT64"&&i==="TIMESTAMP_MILLIS"?n.timestampFromMilliseconds(o.getBigInt64(0,!0)):r==="INT64"&&i==="TIMESTAMP_MICROS"?n.timestampFromMicroseconds(o.getBigInt64(0,!0)):r==="INT64"&&(s==null?void 0:s.type)==="TIMESTAMP"&&(s==null?void 0:s.unit)==="NANOS"?n.timestampFromNanoseconds(o.getBigInt64(0,!0)):r==="INT64"&&(s==null?void 0:s.type)==="TIMESTAMP"&&(s==null?void 0:s.unit)==="MICROS"?n.timestampFromMicroseconds(o.getBigInt64(0,!0)):r==="INT64"&&(s==null?void 0:s.type)==="TIMESTAMP"?n.timestampFromMilliseconds(o.getBigInt64(0,!0)):r==="INT32"&&o.byteLength===4?o.getInt32(0,!0):r==="INT64"&&o.byteLength===8?o.getBigInt64(0,!0):i==="DECIMAL"?ta(e)*10**-(t.scale||0):(s==null?void 0:s.type)==="FLOAT16"?ea(e):e}function ts(e,t){for(let n=0;n<t.length;n+=1e4)e.push(...t.slice(n,n+1e4))}function ca(e){if(!e)return[];if(e.length===1)return e[0];const t=[];for(const n of e)ts(t,n);return t}const ay=1<<25;function ly({metadata:e,rowStart:t=0,rowEnd:n=1/0,columns:r}){var a,c;if(!e)throw new Error("parquetPlan requires metadata");const i=[],s=[];let o=0;for(const l of e.row_groups){const u=Number(l.num_rows),d=o+u;if(u>0&&d>=t&&o<n){const y=[];for(const{file_path:A,meta_data:_}of l.columns){if(A)throw new Error("parquet file_path not supported");if(!_)throw new Error("parquet column metadata is undefined");(!r||r.includes(_.path_in_schema[0]))&&y.push(ua(_))}const m=Math.max(t-o,0),b=Math.min(n-o,u);i.push({ranges:y,rowGroup:l,groupStart:o,groupRows:u,selectStart:m,selectEnd:b});const E=((a=y[y.length-1])==null?void 0:a.endByte)-((c=y[0])==null?void 0:c.startByte);if(!r&&E<ay)s.push({startByte:y[0].startByte,endByte:y[y.length-1].endByte});else if(y.length)ts(s,y);else if(r!=null&&r.length)throw new Error(`parquet columns not found: ${r.join(", ")}`)}o=d}return isFinite(n)||(n=o),{metadata:e,rowStart:t,rowEnd:n,columns:r,fetches:s,groups:i}}function ua({dictionary_page_offset:e,data_page_offset:t,total_compressed_size:n}){const r=e||t;return{startByte:Number(r),endByte:Number(r+n)}}function cy(e,{fetches:t}){const n=t.map(({startByte:r,endByte:i})=>e.slice(r,i));return{byteLength:e.byteLength,slice(r,i=e.byteLength){const s=t.findIndex(({startByte:o,endByte:a})=>o<=r&&i<=a);if(s<0)throw new Error(`no prefetch for range [${r}, ${i}]`);if(t[s].startByte!==r||t[s].endByte!==i){const o=r-t[s].startByte,a=i-t[s].startByte;return n[s]instanceof Promise?n[s].then(c=>c.slice(o,a)):n[s].slice(o,a)}else return n[s]}}}function ha(e,t,n,r,i){const s=(t==null?void 0:t.length)||n.length;if(!s)return r;const o=Xi(i),a=i.map(({element:b})=>b.repetition_type);let c=0;const l=[e];let u=e,d=0,y=0,m=0;if(n[0])for(;d<a.length-2&&m<n[0];)d++,a[d]!=="REQUIRED"&&(u=u.at(-1),l.push(u),y++),a[d]==="REPEATED"&&m++;for(let b=0;b<s;b++){const E=t!=null&&t.length?t[b]:o,A=n[b];for(;d&&(A<m||a[d]!=="REPEATED");)a[d]!=="REQUIRED"&&(l.pop(),y--),a[d]==="REPEATED"&&m--,d--;for(u=l.at(-1);(d<a.length-2||a[d+1]==="REPEATED")&&(y<E||a[d+1]==="REQUIRED");){if(d++,a[d]!=="REQUIRED"){const _=[];u.push(_),u=_,l.push(_),y++}a[d]==="REPEATED"&&m++}E===o?u.push(r[c++]):d===a.length-2?u.push(null):u.push([])}if(!e.length)for(let b=0;b<o;b++){const E=[];u.push(E),u=E}return e}function zn(e,t,n=0){const r=t.path.join("."),i=t.element.repetition_type==="OPTIONAL",s=i?n+1:n;if(Qp(t)){let o=t.children[0],a=s;o.children.length===1&&(o=o.children[0],a++),zn(e,o,a);const c=o.path.join("."),l=e.get(c);if(!l)throw new Error("parquet list column missing values");i&&Fr(l,n),e.set(r,l),e.delete(c);return}if(Xp(t)){const o=t.children[0].element.name;zn(e,t.children[0].children[0],s+1),zn(e,t.children[0].children[1],s+1);const a=e.get(`${r}.${o}.key`),c=e.get(`${r}.${o}.value`);if(!a)throw new Error("parquet map column missing keys");if(!c)throw new Error("parquet map column missing values");if(a.length!==c.length)throw new Error("parquet map column key/value length mismatch");const l=da(a,c,s);i&&Fr(l,n),e.delete(`${r}.${o}.key`),e.delete(`${r}.${o}.value`),e.set(r,l);return}if(t.children.length){const o=t.element.repetition_type==="REQUIRED"?n:n+1,a={};for(const l of t.children){zn(e,l,o);const u=e.get(l.path.join("."));if(!u)throw new Error("parquet struct missing child data");a[l.element.name]=u}for(const l of t.children)e.delete(l.path.join("."));const c=fa(a,o);i&&Fr(c,n),e.set(r,c)}}function Fr(e,t){for(let n=0;n<e.length;n++)t?Fr(e[n],t-1):e[n]=e[n][0]}function da(e,t,n){const r=[];for(let i=0;i<e.length;i++)if(n)r.push(da(e[i],t[i],n-1));else if(e[i]){const s={};for(let o=0;o<e[i].length;o++){const a=t[i][o];s[e[i][o]]=a===void 0?null:a}r.push(s)}else r.push(void 0);return r}function fa(e,t){var s;const n=Object.keys(e),r=(s=e[n[0]])==null?void 0:s.length,i=[];for(let o=0;o<r;o++){const a={};for(const c of n){if(e[c].length!==r)throw new Error("parquet struct parsing error");a[c]=e[c][o]}t?i.push(fa(a,t-1)):i.push(a)}return i}function Yn(e,t,n){const r=n instanceof Int32Array,i=Xe(e),s=Xe(e);Xe(e);let o=Ji(e),a=0;n[a++]=r?Number(o):o;const c=i/s;for(;a<t;){const l=Ji(e),u=new Uint8Array(s);for(let d=0;d<s;d++)u[d]=e.view.getUint8(e.offset++);for(let d=0;d<s&&a<t;d++){const y=BigInt(u[d]);if(y){let m=0n,b=c;const E=(1n<<y)-1n;for(;b&&a<t;){let A=BigInt(e.view.getUint8(e.offset))>>m&E;for(m+=y;m>=8;)m-=8n,e.offset++,m&&(A|=BigInt(e.view.getUint8(e.offset))<<y-m&E);const _=l+A;o+=_,n[a++]=r?Number(o):o,b--}b&&(e.offset+=Math.ceil((b*Number(y)+Number(m))/8))}else for(let m=0;m<c&&a<t;m++)o+=l,n[a++]=r?Number(o):o}}}function pa(e,t,n){const r=new Int32Array(t);Yn(e,t,r);for(let i=0;i<t;i++)n[i]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,r[i]),e.offset+=r[i]}function uy(e,t,n){const r=new Int32Array(t);Yn(e,t,r);const i=new Int32Array(t);Yn(e,t,i);for(let s=0;s<t;s++){const o=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,i[s]);r[s]?(n[s]=new Uint8Array(r[s]+i[s]),n[s].set(n[s-1].subarray(0,r[s])),n[s].set(o,r[s])):n[s]=o,e.offset+=i[s]}}function Mr(e){return 32-Math.clz32(e)}function Ue(e,t,n,r){r===void 0&&(r=e.view.getUint32(e.offset,!0),e.offset+=4);const i=e.offset;let s=0;for(;s<n.length;){const o=Xe(e);if(o&1)s=dy(e,o,t,n,s);else{const a=o>>>1;hy(e,a,t,n,s),s+=a}}e.offset=i+r}function hy(e,t,n,r,i){const s=n+7>>3;let o=0;for(let a=0;a<s;a++)o|=e.view.getUint8(e.offset++)<<(a<<3);for(let a=0;a<t;a++)r[i+a]=o}function dy(e,t,n,r,i){let s=t>>1<<3;const o=(1<<n)-1;let a=0;if(e.offset<e.view.byteLength)a=e.view.getUint8(e.offset++);else if(o)throw new Error(`parquet bitpack offset ${e.offset} out of range`);let c=8,l=0;for(;s;)l>8?(l-=8,c-=8,a>>>=8):c-l<n?(a|=e.view.getUint8(e.offset)<<c,e.offset++,c+=8):(i<r.length&&(r[i++]=a>>l&o),s--,l+=n);return i}function ya(e,t,n,r){const i=fy(n,r),s=new Uint8Array(t*i);for(let o=0;o<i;o++)for(let a=0;a<t;a++)s[a*i+o]=e.view.getUint8(e.offset++);if(n==="FLOAT")return new Float32Array(s.buffer);if(n==="DOUBLE")return new Float64Array(s.buffer);if(n==="INT32")return new Int32Array(s.buffer);if(n==="INT64")return new BigInt64Array(s.buffer);if(n==="FIXED_LEN_BYTE_ARRAY"){const o=new Array(t);for(let a=0;a<t;a++)o[a]=s.subarray(a*i,(a+1)*i);return o}throw new Error(`parquet byte_stream_split unsupported type: ${n}`)}function fy(e,t){switch(e){case"INT32":case"FLOAT":return 4;case"INT64":case"DOUBLE":return 8;case"FIXED_LEN_BYTE_ARRAY":if(!t)throw new Error("parquet byteWidth missing type_length");return t;default:throw new Error(`parquet unsupported type: ${e}`)}}function es(e,t,n,r){if(n===0)return[];if(t==="BOOLEAN")return py(e,n);if(t==="INT32")return yy(e,n);if(t==="INT64")return my(e,n);if(t==="INT96")return gy(e,n);if(t==="FLOAT")return _y(e,n);if(t==="DOUBLE")return by(e,n);if(t==="BYTE_ARRAY")return vy(e,n);if(t==="FIXED_LEN_BYTE_ARRAY"){if(!r)throw new Error("parquet missing fixed length");return wy(e,n,r)}else throw new Error(`parquet unhandled type: ${t}`)}function py(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.offset+(r/8|0),s=r%8,o=e.view.getUint8(i);n[r]=(o&1<<s)!==0}return e.offset+=Math.ceil(t/8),n}function yy(e,t){const n=(e.view.byteOffset+e.offset)%4?new Int32Array(Ur(e.view.buffer,e.view.byteOffset+e.offset,t*4)):new Int32Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*4,n}function my(e,t){const n=(e.view.byteOffset+e.offset)%8?new BigInt64Array(Ur(e.view.buffer,e.view.byteOffset+e.offset,t*8)):new BigInt64Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*8,n}function gy(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.view.getBigInt64(e.offset+r*12,!0),s=e.view.getInt32(e.offset+r*12+8,!0);n[r]=BigInt(s)<<64n|i}return e.offset+=t*12,n}function _y(e,t){const n=(e.view.byteOffset+e.offset)%4?new Float32Array(Ur(e.view.buffer,e.view.byteOffset+e.offset,t*4)):new Float32Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*4,n}function by(e,t){const n=(e.view.byteOffset+e.offset)%8?new Float64Array(Ur(e.view.buffer,e.view.byteOffset+e.offset,t*8)):new Float64Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*8,n}function vy(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.view.getUint32(e.offset,!0);e.offset+=4,n[r]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,i),e.offset+=i}return n}function wy(e,t,n){const r=new Array(t);for(let i=0;i<t;i++)r[i]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n),e.offset+=n;return r}function Ur(e,t,n){const r=new ArrayBuffer(n);return new Uint8Array(r).set(new Uint8Array(e,t,n)),r}const Iy=[0,255,65535,16777215,4294967295];function ma(e,t,n,r,i){for(let s=0;s<i;s++)n[r+s]=e[t+s]}function Sy(e,t){const n=e.byteLength,r=t.byteLength;let i=0,s=0;for(;i<n;){const o=e[i];if(i++,o<128)break}if(r&&i>=n)throw new Error("invalid snappy length header");for(;i<n;){const o=e[i];let a=0;if(i++,i>=n)throw new Error("missing eof marker");if(o&3){let c=0;switch(o&3){case 1:a=(o>>>2&7)+4,c=e[i]+(o>>>5<<8),i++;break;case 2:if(n<=i+1)throw new Error("snappy error end of input");a=(o>>>2)+1,c=e[i]+(e[i+1]<<8),i+=2;break;case 3:if(n<=i+3)throw new Error("snappy error end of input");a=(o>>>2)+1,c=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),i+=4;break}if(c===0||isNaN(c))throw new Error(`invalid offset ${c} pos ${i} inputLength ${n}`);if(c>s)throw new Error("cannot copy from before start of buffer");ma(t,s-c,t,s,a),s+=a}else{let c=(o>>>2)+1;if(c>60){if(i+3>=n)throw new Error("snappy error literal pos + 3 >= inputLength");const l=c-60;c=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),c=(c&Iy[l])+1,i+=l}if(i+c>n)throw new Error("snappy error literal exceeds input length");ma(e,i,t,s,c),i+=c,s+=c}}if(s!==r)throw new Error("premature end of input")}function Ey(e,t,{type:n,element:r,schemaPath:i}){const s=new DataView(e.buffer,e.byteOffset,e.byteLength),o={view:s,offset:0};let a;const c=Ty(o,t,i),{definitionLevels:l,numNulls:u}=Ay(o,t,i),d=t.num_values-u;if(t.encoding==="PLAIN")a=es(o,n,d,r.type_length);else if(t.encoding==="PLAIN_DICTIONARY"||t.encoding==="RLE_DICTIONARY"||t.encoding==="RLE"){const y=n==="BOOLEAN"?1:s.getUint8(o.offset++);y?(a=new Array(d),n==="BOOLEAN"?(Ue(o,y,a),a=a.map(m=>!!m)):Ue(o,y,a,s.byteLength-o.offset)):a=new Uint8Array(d)}else if(t.encoding==="BYTE_STREAM_SPLIT")a=ya(o,d,n,r.type_length);else if(t.encoding==="DELTA_BINARY_PACKED")a=n==="INT32"?new Int32Array(d):new BigInt64Array(d),Yn(o,d,a);else if(t.encoding==="DELTA_LENGTH_BYTE_ARRAY")a=new Array(d),pa(o,d,a);else throw new Error(`parquet unsupported encoding: ${t.encoding}`);return{definitionLevels:l,repetitionLevels:c,dataPage:a}}function Ty(e,t,n){if(n.length>1){const r=ia(n);if(r){const i=new Array(t.num_values);return Ue(e,Mr(r),i),i}}return[]}function Ay(e,t,n){const r=Xi(n);if(!r)return{definitionLevels:[],numNulls:0};const i=new Array(t.num_values);Ue(e,Mr(r),i);let s=t.num_values;for(const o of i)o===r&&s--;return s===0&&(i.length=0),{definitionLevels:i,numNulls:s}}function ns(e,t,n,r){let i;const s=r==null?void 0:r[n];if(n==="UNCOMPRESSED")i=e;else if(s)i=s(e,t);else if(n==="SNAPPY")i=new Uint8Array(t),Sy(e,i);else throw new Error(`parquet unsupported compression codec: ${n}`);if((i==null?void 0:i.length)!==t)throw new Error(`parquet decompressed page length ${i==null?void 0:i.length} does not match header ${t}`);return i}function Ny(e,t,n){const r={view:new DataView(e.buffer,e.byteOffset,e.byteLength),offset:0},{type:i,element:s,schemaPath:o,codec:a,compressors:c}=n,l=t.data_page_header_v2;if(!l)throw new Error("parquet data page header v2 is undefined");const u=Ry(r,l,o);r.offset=l.repetition_levels_byte_length;const d=By(r,l,o),y=t.uncompressed_page_size-l.definition_levels_byte_length-l.repetition_levels_byte_length;let m=e.subarray(r.offset);l.is_compressed!==!1&&(m=ns(m,y,a,c));const b=new DataView(m.buffer,m.byteOffset,m.byteLength),E={view:b,offset:0};let A;const _=l.num_values-l.num_nulls;if(l.encoding==="PLAIN")A=es(E,i,_,s.type_length);else if(l.encoding==="RLE")A=new Array(_),Ue(E,1,A),A=A.map(H=>!!H);else if(l.encoding==="PLAIN_DICTIONARY"||l.encoding==="RLE_DICTIONARY"){const H=b.getUint8(E.offset++);A=new Array(_),Ue(E,H,A,y-1)}else if(l.encoding==="DELTA_BINARY_PACKED")A=i==="INT32"?new Int32Array(_):new BigInt64Array(_),Yn(E,_,A);else if(l.encoding==="DELTA_LENGTH_BYTE_ARRAY")A=new Array(_),pa(E,_,A);else if(l.encoding==="DELTA_BYTE_ARRAY")A=new Array(_),uy(E,_,A);else if(l.encoding==="BYTE_STREAM_SPLIT")A=ya(r,_,i,s.type_length);else throw new Error(`parquet unsupported encoding: ${l.encoding}`);return{definitionLevels:d,repetitionLevels:u,dataPage:A}}function Ry(e,t,n){const r=ia(n);if(!r)return[];const i=new Array(t.num_values);return Ue(e,Mr(r),i,t.repetition_levels_byte_length),i}function By(e,t,n){const r=Xi(n);if(r){const i=new Array(t.num_values);return Ue(e,Mr(r),i,t.definition_levels_byte_length),i}}function Oy(e,{groupStart:t,selectStart:n,selectEnd:r},i,s){const{columnName:o}=i,a=[];let c,l,u=0;const d=s&&(()=>{l&&s({columnName:o,columnData:l,rowStart:t+u-l.length,rowEnd:t+u})});for(;u<r&&!(e.offset>=e.view.byteLength-1);){const y=Dy(e);if(y.type==="DICTIONARY_PAGE")c=ga(e,y,i,c,void 0,0),c=Zo(c,i);else{const m=(l==null?void 0:l.length)||0,b=ga(e,y,i,c,l,n-u);l===b?u+=b.length-m:(d==null||d(),a.push(b),u+=b.length,l=b)}}return d==null||d(),u>r&&l&&(a[a.length-1]=l.slice(0,r-(u-l.length))),a}function ga(e,t,n,r,i,s){const{type:o,element:a,schemaPath:c,codec:l,compressors:u}=n,d=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,t.compressed_page_size);if(e.offset+=t.compressed_page_size,t.type==="DATA_PAGE"){const y=t.data_page_header;if(!y)throw new Error("parquet data page header is undefined");if(s>y.num_values&&Jp(c))return new Array(y.num_values);const m=ns(d,Number(t.uncompressed_page_size),l,u),{definitionLevels:b,repetitionLevels:E,dataPage:A}=Ey(m,y,n);let _=Jo(A,r,y.encoding,n);if(E.length||b!=null&&b.length){const H=Array.isArray(i)?i:[];return ha(H,b,E,_,c)}else{for(let H=2;H<c.length;H++)c[H].element.repetition_type!=="REQUIRED"&&(_=Array.from(_,L=>[L]));return _}}else if(t.type==="DATA_PAGE_V2"){const y=t.data_page_header_v2;if(!y)throw new Error("parquet data page header v2 is undefined");if(s>y.num_rows)return new Array(y.num_values);const{definitionLevels:m,repetitionLevels:b,dataPage:E}=Ny(d,t,n),A=Jo(E,r,y.encoding,n),_=Array.isArray(i)?i:[];return ha(_,m,b,A,c)}else if(t.type==="DICTIONARY_PAGE"){const y=t.dictionary_page_header;if(!y)throw new Error("parquet dictionary page header is undefined");const m=ns(d,Number(t.uncompressed_page_size),l,u),b={view:new DataView(m.buffer,m.byteOffset,m.byteLength),offset:0};return es(b,o,y.num_values,a.type_length)}else throw new Error(`parquet unsupported page type: ${t.type}`)}function Dy(e){const t=sa(e),n=Qo[t.field_1],r=t.field_2,i=t.field_3,s=t.field_4,o=t.field_5&&{num_values:t.field_5.field_1,encoding:Qe[t.field_5.field_2],definition_level_encoding:Qe[t.field_5.field_3],repetition_level_encoding:Qe[t.field_5.field_4],statistics:t.field_5.field_5&&{max:t.field_5.field_5.field_1,min:t.field_5.field_5.field_2,null_count:t.field_5.field_5.field_3,distinct_count:t.field_5.field_5.field_4,max_value:t.field_5.field_5.field_5,min_value:t.field_5.field_5.field_6}},a=t.field_6,c=t.field_7&&{num_values:t.field_7.field_1,encoding:Qe[t.field_7.field_2],is_sorted:t.field_7.field_3},l=t.field_8&&{num_values:t.field_8.field_1,num_nulls:t.field_8.field_2,num_rows:t.field_8.field_3,encoding:Qe[t.field_8.field_4],definition_levels_byte_length:t.field_8.field_5,repetition_levels_byte_length:t.field_8.field_6,is_compressed:t.field_8.field_7===void 0?!0:t.field_8.field_7,statistics:t.field_8.field_8};return{type:n,uncompressed_page_size:r,compressed_page_size:i,crc:s,data_page_header:o,index_page_header:a,dictionary_page_header:c,data_page_header_v2:l}}function Ly(e,{metadata:t,columns:n},r){const{file:i,compressors:s,utf8:o}=e,a=[],c={...Xo,...e.parsers};for(const{file_path:l,meta_data:u}of r.rowGroup.columns){if(l)throw new Error("parquet file_path not supported");if(!u)throw new Error("parquet column metadata is undefined");const d=u.path_in_schema[0];if(n&&!n.includes(d))continue;const{startByte:y,endByte:m}=ua(u),b=m-y;if(b>1<<30){console.warn(`parquet skipping huge column "${u.path_in_schema}" ${b} bytes`);continue}const E=Promise.resolve(i.slice(y,m));a.push({pathInSchema:u.path_in_schema,data:E.then(A=>{const _=ra(t.schema,u.path_in_schema),H={view:new DataView(A),offset:0},L={columnName:u.path_in_schema.join("."),type:u.type,element:_[_.length-1].element,schemaPath:_,codec:u.codec,parsers:c,compressors:s,utf8:o};return Oy(H,r,L,e.onPage)})})}return{groupStart:r.groupStart,groupRows:r.groupRows,asyncColumns:a}}async function Fy({asyncColumns:e},t,n,r,i){const s=new Array(n),o=await Promise.all(e.map(({data:u})=>u.then(ca))),a=e.map(u=>u.pathInSchema[0]).filter(u=>!r||r.includes(u)),c=r??a,l=c.map(u=>e.findIndex(d=>d.pathInSchema[0]===u));for(let u=t;u<n;u++)if(i==="object"){const d={};for(let y=0;y<e.length;y++)d[e[y].pathInSchema[0]]=o[y][u];s[u]=d}else{const d=new Array(e.length);for(let y=0;y<c.length;y++)l[y]>=0&&(d[y]=o[l[y]][u]);s[u]=d}return s}function My(e,t){const{asyncColumns:n}=e,r=[];for(const i of t.children)if(i.children.length){const s=n.filter(c=>c.pathInSchema[0]===i.element.name);if(!s.length)continue;const o=new Map,a=Promise.all(s.map(c=>c.data.then(l=>{o.set(c.pathInSchema.join("."),ca(l))}))).then(()=>{zn(o,i);const c=o.get(i.path.join("."));if(!c)throw new Error("parquet column data not assembled");return[c]});r.push({pathInSchema:i.path,data:a})}else{const s=n.find(o=>o.pathInSchema[0]===i.element.name);s&&r.push(s)}return{...e,asyncColumns:r}}async function Uy(e){e.metadata??(e.metadata=await ry(e.file));const t=xy(e),{rowStart:n=0,rowEnd:r,columns:i,onChunk:s,onComplete:o,rowFormat:a}=e;if(!o&&!s){for(const{asyncColumns:u}of t)for(const{data:d}of u)await d;return}const c=iy(e.metadata),l=t.map(u=>My(u,c));if(s)for(const u of l)for(const d of u.asyncColumns)d.data.then(y=>{let m=u.groupStart;for(const b of y)s({columnName:d.pathInSchema[0],columnData:b,rowStart:m,rowEnd:m+b.length}),m+=b.length});if(o){const u=[];for(const d of l){const y=Math.max(n-d.groupStart,0),m=Math.min((r??1/0)-d.groupStart,d.groupRows),b=await Fy(d,y,m,i,a);ts(u,b.slice(y,m))}o(u)}else for(const{asyncColumns:u}of l)for(const{data:d}of u)await d}function xy(e){if(!e.metadata)throw new Error("parquet requires metadata");const t=ly(e);return e.file=cy(e.file,t),t.groups.map(n=>Ly(e,t,n))}const Cy={class:"app-container"},$y=f.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=f.ref(5e3),r=f.ref("random"),i=f.ref("#ff0000"),s=f.ref("#0000ff"),o=f.ref("#4285f4"),a=f.ref(!1),c=f.ref(0),l=f.ref(""),u=f.ref(),d=f.ref(),y=f.ref(new Map),m=f.ref(new Map),b=f.ref([]);f.watch(()=>{var T,D,Y,G;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((D=(T=t.pkg)==null?void 0:T.content)==null?void 0:D.id)||"",pkgType:((G=(Y=t.pkg)==null?void 0:Y.content)==null?void 0:G.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:T,srcFileType:D,srcFileId:Y,pkgId:G,pkgType:ct,apiUrl:bt})=>{var yt,g,v;try{if(u.value=void 0,d.value=void 0,T){const I=D??(T.toLowerCase().endsWith(".csv")?"csv":"parquet");await H(T,I,Y);return}if(!G||!bt)return;await A(G,bt);const h=(v=(g=(yt=b.value)==null?void 0:yt[0])==null?void 0:g.content)==null?void 0:v.id;if(!h){console.error("[UMAP Wrapper] No files returned from /view");return}const w=await _(G,h,bt);await H(w,ct==="CSV"?"csv":"parquet",h)}catch(h){console.error("[UMAP Wrapper] Load failed:",(h==null?void 0:h.message)||h)}},{immediate:!0});async function E(){const{useGetToken:T}=await Promise.resolve().then(()=>hu);return T()}async function A(T,D){const Y=await E(),G=`${D}/packages/${T}/view?api_key=${Y}`,ct=await fetch(G);if(!ct.ok)throw new Error(`view failed: ${ct.status}`);b.value=await ct.json()}async function _(T,D,Y){const G=await E(),ct=`${Y}/packages/${T}/files/${D}?api_key=${G}`,bt=await fetch(ct);if(!bt.ok)throw new Error(`file url failed: ${bt.status}`);return(await bt.json()).url}async function H(T,D,Y){if(D==="csv")throw new Error("CSV not yet supported by UMAP wrapper. Provide a Parquet file.");const G=await fetch(T);if(!G.ok)throw new Error(`fetch failed: ${G.status}`);const ct=await G.arrayBuffer();await Uy({file:ct,onComplete:bt=>{var yt,g;d.value=Zi(ct);try{const v=(g=(yt=d.value)==null?void 0:yt.key_value_metadata)==null?void 0:g[0];v!=null&&v.key&&(r.value=v.key)}catch{}u.value=bt}}),N()}function L(){a.value=!a.value,c.value++}function vt(T){try{if(!T||T.length<7)return[1,0,0];const D=parseInt(T.slice(1,3),16)/255,Y=parseInt(T.slice(3,5),16)/255,G=parseInt(T.slice(5,7),16)/255;return Number.isNaN(D)||Number.isNaN(Y)||Number.isNaN(G)?[1,0,0]:[D,Y,G]}catch{return[1,0,0]}}function N(){if(!d.value)return;const T=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(vt),D=d.value.key_value_metadata||[];for(let Y=0;Y<D.length-1;Y++){const G=D[Y].key,ct=JSON.parse(D[Y].value);let bt=new Map,yt=0;for(const g of ct)bt.set(g,T[yt%T.length]),yt++;m.value.set(G,bt),m.value.get(G)||m.value.set(G,new Map)}}function O(T){l.value=T[0],y.value=T[1]}return(T,D)=>(f.openBlock(),f.createElementBlock("div",Cy,[(f.openBlock(),f.createBlock(Cp,{data:u.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:o.value,forceRegenerate:a.value,key:c.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),f.createVNode(qp,{pointCount:n.value,"onUpdate:pointCount":D[0]||(D[0]=Y=>n.value=Y),colorMode:r.value,"onUpdate:colorMode":D[1]||(D[1]=Y=>r.value=Y),startColor:i.value,"onUpdate:startColor":D[2]||(D[2]=Y=>i.value=Y),endColor:s.value,"onUpdate:endColor":D[3]||(D[3]=Y=>s.value=Y),singleColor:o.value,"onUpdate:singleColor":D[4]||(D[4]=Y=>o.value=Y),"color-scheme":y.value,"color-map-map":m.value,onRegenerate:L,onUpdateColorMap:O},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),ky=Dn($y,[["__scopeId","data-v-2197517e"]]),Py="dashboard:globalVars";function _a(e=!1){const t=f.inject(Py,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const Vy={class:"data-explorer-wrap"},zy={class:"data-explorer-info"},Yy=f.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=_a(),n=f.ref("Data Explorer"),r=f.computed(()=>f.unref(t.s3Url));return f.watchEffect(()=>{}),(i,s)=>{const o=f.resolveComponent("el-icon");return f.openBlock(),f.createElementBlock(f.Fragment,null,[f.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),f.createElementVNode("div",Vy,[f.createElementVNode("div",zy,[f.createVNode(f.unref(Ou.ElTooltip),{placement:"top-start"},{content:f.withCtx(()=>[...s[0]||(s[0]=[f.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:f.withCtx(()=>[f.createVNode(o,{color:"#8300BF"},{default:f.withCtx(()=>[f.createVNode(f.unref(Fu))]),_:1})]),_:1})]),f.createVNode(f.unref(oh),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),ba=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},jy=ba(Yy,[["__scopeId","data-v-08f7f19e"]]),qy={class:"umap-wrap"},Gy=ba(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=_a(),n=f.ref("Data Explorer"),r=f.computed(()=>f.unref(t==null?void 0:t.s3Url));return(i,s)=>(f.openBlock(),f.createElementBlock(f.Fragment,null,[f.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),f.createElementVNode("div",qy,[f.createVNode(f.unref(ky),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function q(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(d){o(d)}}function c(u){try{l(r.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})}function va(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function ae(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(m){return function(b){return Promise.resolve(b).then(m,d)}}function a(m,b){r[m]&&(i[m]=function(E){return new Promise(function(A,_){s.push([m,E,A,_])>1||c(m,E)})},b&&(i[m]=b(i[m])))}function c(m,b){try{l(r[m](b))}catch(E){y(s[0][3],E)}}function l(m){m.value instanceof W?Promise.resolve(m.value.v).then(u,d):y(s[0][2],m)}function u(m){c("next",m)}function d(m){c("throw",m)}function y(m,b){m(b),s.shift(),s.length&&c(s[0][0],s[0][1])}}function xr(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(o){return(n=!n)?{value:W(e[i](o)),done:!1}:s?s(o):o}:s}}function Je(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof va=="function"?va(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}const Wy=new TextDecoder("utf-8"),rs=e=>Wy.decode(e),Hy=new TextEncoder,is=e=>Hy.encode(e),Ky=e=>typeof e=="number",wa=e=>typeof e=="boolean",St=e=>typeof e=="function",xt=e=>e!=null&&Object(e)===e,Ze=e=>xt(e)&&St(e.then),jn=e=>xt(e)&&St(e[Symbol.iterator]),ln=e=>xt(e)&&St(e[Symbol.asyncIterator]),ss=e=>xt(e)&&xt(e.schema),Ia=e=>xt(e)&&"done"in e&&"value"in e,Sa=e=>xt(e)&&St(e.stat)&&Ky(e.fd),Ea=e=>xt(e)&&os(e.body),Cr=e=>"_getDOMStream"in e&&"_getNodeStream"in e,Qy=e=>xt(e)&&St(e.abort)&&St(e.getWriter)&&!Cr(e),os=e=>xt(e)&&St(e.cancel)&&St(e.getReader)&&!Cr(e),Xy=e=>xt(e)&&St(e.end)&&St(e.write)&&wa(e.writable)&&!Cr(e),Ta=e=>xt(e)&&St(e.read)&&St(e.pipe)&&wa(e.readable)&&!Cr(e),Jy=e=>xt(e)&&St(e.clear)&&St(e.bytes)&&St(e.position)&&St(e.setPosition)&&St(e.capacity)&&St(e.getBufferIdentifier)&&St(e.createLong),as=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Zy(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let o,a,c=0,l=0,u=e.length;++c<u;){if(o=t[l],a=e[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:n,byteLength:i}=o,{byteOffset:r,byteLength:s}=a,n+i<r||r+s<n){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,n,r-n+s)}return t}function Aa(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(o,n),e}function le(e,t){const n=Zy(e),r=n.reduce((u,d)=>u+d.byteLength,0);let i,s,o,a=0,c=-1;const l=Math.min(t||Number.POSITIVE_INFINITY,r);for(const u=n.length;++c<u;){if(i=n[c],s=i.subarray(0,Math.min(i.length,l-a)),l<=a+s.length){s.length<i.length?n[c]=i.subarray(s.length):s.length===i.length&&c++,o?Aa(o,s,a):o=s;break}Aa(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),n.slice(c),r-(o?o.byteLength:0)]}function ht(e,t){let n=Ia(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=is(n)),n instanceof ArrayBuffer?new e(n):n instanceof as?new e(n):Jy(n)?ht(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const qn=e=>ht(Int32Array,e),Na=e=>ht(BigInt64Array,e),J=e=>ht(Uint8Array,e),ls=e=>(e.next(),e);function*tm(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof as?n(t):jn(t)?t:n(t);return yield*ls(function*(i){let s=null;do s=i.next(yield ht(e,s));while(!s.done)}(r[Symbol.iterator]())),new e}const em=e=>tm(Uint8Array,e);function Ra(e,t){return ae(this,arguments,function*(){if(Ze(t))return yield W(yield W(yield*xr(Je(Ra(e,yield W(t))))));const n=function(s){return ae(this,arguments,function*(){yield yield W(yield W(s))})},r=function(s){return ae(this,arguments,function*(){yield W(yield*xr(Je(ls(function*(o){let a=null;do a=o.next(yield a==null?void 0:a.value);while(!a.done)}(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof as?n(t):jn(t)?r(t):ln(t)?t:n(t);return yield W(yield*xr(Je(ls(function(s){return ae(this,arguments,function*(){let o=null;do o=yield W(s.next(yield yield W(ht(e,o))));while(!o.done)})}(i[Symbol.asyncIterator]()))))),yield W(new e)})}const nm=e=>Ra(Uint8Array,e);function Ba(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function rm(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const qt={fromIterable(e){return $r(im(e))},fromAsyncIterable(e){return $r(sm(e))},fromDOMStream(e){return $r(om(e))},fromNodeStream(e){return $r(lm(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},$r=e=>(e.next(),e);function*im(e){let t,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?le(r,o)[0]:([i,r,a]=le(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});const l=em(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){(n=!0)&&typeof l.throw=="function"&&l.throw(u)}finally{n===!1&&typeof l.return=="function"&&l.return(null)}return null}function sm(e){return ae(this,arguments,function*(){let t,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?le(r,o)[0]:([i,r,a]=le(r,o),i)}({cmd:s,size:o}=(yield yield W(null))||{cmd:"read",size:0});const l=nm(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?yield W(l.next()):yield W(l.next(o-a)),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield W(c()));while(o<a);while(!t)}catch(u){(n=!0)&&typeof l.throw=="function"&&(yield W(l.throw(u)))}finally{n===!1&&typeof l.return=="function"&&(yield W(l.return(new Uint8Array(0))))}return yield W(null)})}function om(e){return ae(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?le(r,o)[0]:([i,r,a]=le(r,o),i)}({cmd:s,size:o}=(yield yield W(null))||{cmd:"read",size:0});const l=new am(e);try{do if({done:t,value:i}=Number.isNaN(o-a)?yield W(l.read()):yield W(l.read(o-a)),!t&&i.byteLength>0&&(r.push(J(i)),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield W(c()));while(o<a);while(!t)}catch(u){(n=!0)&&(yield W(l.cancel(u)))}finally{n===!1?yield W(l.cancel()):e.locked&&l.releaseLock()}return yield W(null)})}class am{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 q(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return q(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=J(n)),n})}}const cs=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function lm(e){return ae(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,o,a=0,c=[],l;function u(){return s==="peek"?le(c,o)[0]:([l,c,a]=le(c,o),l)}if({cmd:s,size:o}=(yield yield W(null))||{cmd:"read",size:0},e.isTTY)return yield yield W(new Uint8Array(0)),yield W(null);try{t[0]=cs(e,"end"),t[1]=cs(e,"error");do{if(t[2]=cs(e,"readable"),[n,i]=yield W(Promise.race(t.map(y=>y[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(o-a)?(l=J(e.read(o-a)),l.byteLength<o-a&&(l=J(e.read()))):l=J(e.read()),l.byteLength>0&&(c.push(l),a+=l.byteLength)),r||o<=a)do({cmd:s,size:o}=yield yield W(u()));while(o<a)}while(!r)}finally{yield W(d(t,n==="error"?i:null))}return yield W(null);function d(y,m){return l=c=null,new Promise((b,E)=>{for(const[A,_]of y)e.off(A,_);try{const A=e.destroy;A&&A.call(e,m),m=void 0}catch(A){m=A||m}finally{m!=null?E(m):b()}})}})}var wt;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(wt||(wt={}));var Nt;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Nt||(Nt={}));var Rt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Rt||(Rt={}));var Gt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Gt||(Gt={}));var $;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})($||($={}));var ce;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(ce||(ce={}));const us=2,ue=4,Se=4,it=4,xe=new Int32Array(2),Oa=new Float32Array(xe.buffer),Da=new Float64Array(xe.buffer),kr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var hs;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(hs||(hs={}));let cn=class Ru{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Ru(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 xe[0]=this.readInt32(t),Oa[0]}readFloat64(t){return xe[kr?0:1]=this.readInt32(t),xe[kr?1:0]=this.readInt32(t+4),Da[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){Oa[0]=n,this.writeInt32(t,xe[0])}writeFloat64(t,n){Da[0]=n,this.writeInt32(t,xe[kr?0:1]),this.writeInt32(t+4,xe[kr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+ue+Se)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<Se;n++)t+=String.fromCharCode(this.readInt8(this.position_+ue+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=ue;const i=this.bytes_.subarray(t,t+r);return n===hs.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+ue}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=Se)throw new Error("FlatBuffers: file identifier must be length "+Se);for(let n=0;n<Se;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+ue+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},La=class Bu{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 n;t?n=t:n=1024,this.bb=cn.allocate(n),this.space=n}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,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=Bu.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)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,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),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){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=cn.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(ue,0),this.writeInt32(this.offset()-t+ue)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=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);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*us;this.addInt16(s);let o=0;const a=this.space;t:for(n=0;n<this.vtables.length;n++){const c=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(c)){for(let l=us;l<s;l+=us)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[n];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?it:0;if(n){const s=n;if(this.prep(this.minalign,ue+Se+i),s.length!=Se)throw new TypeError("FlatBuffers: file identifier must be length "+Se);for(let o=Se-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,ue+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(ue,t*n),this.prep(r,t*n)}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);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,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){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Pr;(function(e){e[e.BUFFER=0]="BUFFER"})(Pr||(Pr={}));var Vr;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Vr||(Vr={}));class Ce{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Ce).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+it),(n||new Ce).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Vr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Pr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Vr.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,Pr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Ce.startBodyCompression(t),Ce.addCodec(t,n),Ce.addMethod(t,r),Ce.endBodyCompression(t)}}class Fa{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,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,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Ma=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},Ee=class no{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new no).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+it),(n||new no).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Ma).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Fa).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Ce).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},un=class ro{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new ro).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+it),(n||new ro).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ee).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var hn;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(hn||(hn={}));var zr;(function(e){e[e.DenseArray=0]="DenseArray"})(zr||(zr={}));class Vt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+it),(n||new Vt).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Vt.startInt(t),Vt.addBitWidth(t,n),Vt.addIsSigned(t,r),Vt.endInt(t)}}class Te{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new Te).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+it),(n||new Te).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Vt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):zr.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,zr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Et{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+it),(n||new Et).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return Et.startKeyValue(t),Et.addKey(t,n),Et.addValue(t,r),Et.endKeyValue(t)}}let Ua=class sr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new sr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+it),(n||new sr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return sr.startBinary(t),sr.endBinary(t)}},xa=class or{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new or).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+it),(n||new or).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return or.startBool(t),or.endBool(t)}},Yr=class An{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new An).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+it),(n||new An).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Gt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Gt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return An.startDate(t),An.addUnit(t,n),An.endDate(t)}},dn=class je{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+it),(n||new je).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return je.startDecimal(t),je.addPrecision(t,n),je.addScale(t,r),je.addBitWidth(t,i),je.endDecimal(t)}},jr=class Nn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new Nn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+it),(n||new Nn).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,$.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Nn.startDuration(t),Nn.addUnit(t,n),Nn.endDuration(t)}},qr=class Rn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new Rn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+it),(n||new Rn).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return Rn.startFixedSizeBinary(t),Rn.addByteWidth(t,n),Rn.endFixedSizeBinary(t)}},Gr=class Bn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new Bn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+it),(n||new Bn).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return Bn.startFixedSizeList(t),Bn.addListSize(t,n),Bn.endFixedSizeList(t)}};class he{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new he).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+it),(n||new he).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Rt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Rt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return he.startFloatingPoint(t),he.addPrecision(t,n),he.endFloatingPoint(t)}}class de{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new de).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+it),(n||new de).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ce.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,ce.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return de.startInterval(t),de.addUnit(t,n),de.endInterval(t)}}let Ca=class ar{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+it),(n||new ar).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return ar.startLargeBinary(t),ar.endLargeBinary(t)}},$a=class lr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+it),(n||new lr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return lr.startLargeUtf8(t),lr.endLargeUtf8(t)}},ka=class cr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+it),(n||new cr).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return cr.startList(t),cr.endList(t)}},Wr=class On{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new On).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+it),(n||new On).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return On.startMap(t),On.addKeysSorted(t,n),On.endMap(t)}},Pa=class ur{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new ur).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+it),(n||new ur).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return ur.startNull(t),ur.endNull(t)}};class tn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new tn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+it),(n||new tn).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return tn.startStruct_(t),tn.endStruct_(t)}}class Wt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new Wt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+it),(n||new Wt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,$.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return Wt.startTime(t),Wt.addUnit(t,n),Wt.addBitWidth(t,r),Wt.endTime(t)}}class Ht{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new Ht).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+it),(n||new Ht).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,$.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return Ht.startTimestamp(t),Ht.addUnit(t,n),Ht.addTimezone(t,r),Ht.endTimestamp(t)}}class Ct{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+it),(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Nt.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Nt.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return Ct.startUnion(t),Ct.addMode(t,n),Ct.addTypeIds(t,r),Ct.endUnion(t)}}let Va=class hr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+it),(n||new hr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return hr.startUtf8(t),hr.endUtf8(t)}};var ft;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(ft||(ft={}));let Kt=class Li{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new Li).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+it),(n||new Li).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):ft.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new Te).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Li).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,ft.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},fe=class Le{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+it),(n||new Le).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):hn.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Kt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,hn.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Le.startSchema(t),Le.addEndianness(t,n),Le.addFields(t,r),Le.addCustomMetadata(t,i),Le.addFeatures(t,s),Le.endSchema(t)}};var et;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(et||(et={}));var p;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var Ae;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(Ae||(Ae={}));const cm=void 0;function Gn(e){if(e===null)return"null";if(e===cm)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>Gn(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function dt(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function za(e,t){return dt(e/t)+dt(e%t)/dt(t)}const um=Symbol.for("isArrowBigNum");function ee(e,...t){return t.length===0?Object.setPrototypeOf(ht(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}ee.prototype[um]=!0,ee.prototype.toJSON=function(){return`"${Hn(this)}"`},ee.prototype.valueOf=function(e){return Ya(this,e)},ee.prototype.toString=function(){return Hn(this)},ee.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Ya(this);case"string":return Hn(this);case"default":return fm(this)}return Hn(this)};function fn(...e){return ee.apply(this,e)}function pn(...e){return ee.apply(this,e)}function Wn(...e){return ee.apply(this,e)}Object.setPrototypeOf(fn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(pn.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Wn.prototype,Object.create(Uint32Array.prototype)),Object.assign(fn.prototype,ee.prototype,{constructor:fn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(pn.prototype,ee.prototype,{constructor:pn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Wn.prototype,ee.prototype,{constructor:Wn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const hm=BigInt(4294967296)*BigInt(4294967296),dm=hm-BigInt(1);function Ya(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63);let c=BigInt(0),l=0;if(a){for(const u of o)c|=(u^dm)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(const u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"){const u=BigInt(Math.pow(10,t)),d=c/u,y=c%u;return dt(d)+dt(y)/dt(u)}return dt(c)}function Hn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return ds(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ds(e);t=t.slice();let n=1;for(let r=0;r<t.length;r++){const i=t[r],s=~i+n;t[r]=s,n&=i===0?1:0}return`-${ds(t)}`}function fm(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Hn(e)}function ds(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const o=r.length-1;do{for(n[0]=r[s=0];s<o;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class fs{static new(t,n){switch(n){case!0:return new fn(t);case!1:return new pn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new fn(t)}return t.byteLength===16?new Wn(t):new pn(t)}static signed(t){return new fn(t)}static unsigned(t){return new pn(t)}static decimal(t){return new Wn(t)}constructor(t,n){return fs.new(t,n)}}var ja,qa,Ga,Wa,Ha,Ka,Qa,Xa,Ja,Za,tl,el,nl,rl,il,sl,ol,al,ll,cl,ul,hl;class F{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 F.isUnion(t)&&t.mode===Nt.Dense}static isSparseUnion(t){return F.isUnion(t)&&t.mode===Nt.Sparse}constructor(t){this.typeId=t}}ja=Symbol.toStringTag,F[ja]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(F.prototype);class $e extends F{constructor(){super(p.Null)}toString(){return"Null"}}qa=Symbol.toStringTag,$e[qa]=(e=>e[Symbol.toStringTag]="Null")($e.prototype);class en extends F{constructor(t,n){super(p.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Ga=Symbol.toStringTag,en[Ga]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(en.prototype);class Kn extends en{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Kn.prototype,"ArrayType",{value:Int32Array});class Hr extends F{constructor(t){super(p.Float),this.precision=t}get ArrayType(){switch(this.precision){case Rt.HALF:return Uint16Array;case Rt.SINGLE:return Float32Array;case Rt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Wa=Symbol.toStringTag,Hr[Wa]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(Hr.prototype);class Kr extends F{constructor(){super(p.Binary)}toString(){return"Binary"}}Ha=Symbol.toStringTag,Kr[Ha]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Kr.prototype);class Qr extends F{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}}Ka=Symbol.toStringTag,Qr[Ka]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Qr.prototype);class Xr extends F{constructor(){super(p.Utf8)}toString(){return"Utf8"}}Qa=Symbol.toStringTag,Xr[Qa]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Xr.prototype);class Jr extends F{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}}Xa=Symbol.toStringTag,Jr[Xa]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(Jr.prototype);class Zr extends F{constructor(){super(p.Bool)}toString(){return"Bool"}}Ja=Symbol.toStringTag,Zr[Ja]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Zr.prototype);class ti extends F{constructor(t,n,r=128){super(p.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Za=Symbol.toStringTag,ti[Za]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(ti.prototype);class ei extends F{constructor(t){super(p.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Gt[this.unit]}>`}get ArrayType(){return this.unit===Gt.DAY?Int32Array:BigInt64Array}}tl=Symbol.toStringTag,ei[tl]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(ei.prototype);class ni extends F{constructor(t,n){super(p.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${$[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}el=Symbol.toStringTag,ni[el]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(ni.prototype);class ri extends F{constructor(t,n){super(p.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${$[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}nl=Symbol.toStringTag,ri[nl]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(ri.prototype);class ii extends F{constructor(t){super(p.Interval),this.unit=t}toString(){return`Interval<${ce[this.unit]}>`}}rl=Symbol.toStringTag,ii[rl]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(ii.prototype);class si extends F{constructor(t){super(p.Duration),this.unit=t}toString(){return`Duration<${$[this.unit]}>`}}il=Symbol.toStringTag,si[il]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(si.prototype);class oi extends F{constructor(t){super(p.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}sl=Symbol.toStringTag,oi[sl]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(oi.prototype);class Dt extends F{constructor(t){super(p.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}ol=Symbol.toStringTag,Dt[ol]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(Dt.prototype);class ai extends F{constructor(t,n,r){super(p.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}al=Symbol.toStringTag,ai[al]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(ai.prototype);class li extends F{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}ll=Symbol.toStringTag,li[ll]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(li.prototype);class ci extends F{constructor(t,n){super(p.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}cl=Symbol.toStringTag,ci[cl]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(ci.prototype);class ui extends F{constructor(t,n=!1){var r,i,s;if(super(p.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}ul=Symbol.toStringTag,ui[ul]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(ui.prototype);const pm=(e=>()=>++e)(-1);class yn extends F{constructor(t,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?pm():dt(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}hl=Symbol.toStringTag,yn[hl]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(yn.prototype);function Ne(e){const t=e;switch(e.typeId){case p.Decimal:return e.bitWidth/32;case p.Interval:return 1+t.unit;case p.FixedSizeList:return t.listSize;case p.FixedSizeBinary:return t.byteWidth;default:return 1}}class K{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return ym(this,t,n)}getVisitFnByTypeId(t,n=!0){return mn(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function ym(e,t,n=!0){return typeof t=="number"?mn(e,t,n):typeof t=="string"&&t in p?mn(e,p[t],n):t&&t instanceof F?mn(e,dl(t),n):t!=null&&t.type&&t.type instanceof F?mn(e,dl(t.type),n):mn(e,p.NONE,n)}function mn(e,t,n=!0){let r=null;switch(t){case p.Null:r=e.visitNull;break;case p.Bool:r=e.visitBool;break;case p.Int:r=e.visitInt;break;case p.Int8:r=e.visitInt8||e.visitInt;break;case p.Int16:r=e.visitInt16||e.visitInt;break;case p.Int32:r=e.visitInt32||e.visitInt;break;case p.Int64:r=e.visitInt64||e.visitInt;break;case p.Uint8:r=e.visitUint8||e.visitInt;break;case p.Uint16:r=e.visitUint16||e.visitInt;break;case p.Uint32:r=e.visitUint32||e.visitInt;break;case p.Uint64:r=e.visitUint64||e.visitInt;break;case p.Float:r=e.visitFloat;break;case p.Float16:r=e.visitFloat16||e.visitFloat;break;case p.Float32:r=e.visitFloat32||e.visitFloat;break;case p.Float64:r=e.visitFloat64||e.visitFloat;break;case p.Utf8:r=e.visitUtf8;break;case p.LargeUtf8:r=e.visitLargeUtf8;break;case p.Binary:r=e.visitBinary;break;case p.LargeBinary:r=e.visitLargeBinary;break;case p.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case p.Date:r=e.visitDate;break;case p.DateDay:r=e.visitDateDay||e.visitDate;break;case p.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case p.Timestamp:r=e.visitTimestamp;break;case p.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case p.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case p.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case p.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case p.Time:r=e.visitTime;break;case p.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case p.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case p.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case p.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case p.Decimal:r=e.visitDecimal;break;case p.List:r=e.visitList;break;case p.Struct:r=e.visitStruct;break;case p.Union:r=e.visitUnion;break;case p.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case p.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case p.Dictionary:r=e.visitDictionary;break;case p.Interval:r=e.visitInterval;break;case p.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case p.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case p.Duration:r=e.visitDuration;break;case p.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case p.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case p.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case p.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case p.FixedSizeList:r=e.visitFixedSizeList;break;case p.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[t]}'`)}function dl(e){switch(e.typeId){case p.Null:return p.Null;case p.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(e.precision){case Rt.HALF:return p.Float16;case Rt.SINGLE:return p.Float32;case Rt.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(e.unit){case $.SECOND:return p.TimeSecond;case $.MILLISECOND:return p.TimeMillisecond;case $.MICROSECOND:return p.TimeMicrosecond;case $.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(e.unit){case $.SECOND:return p.TimestampSecond;case $.MILLISECOND:return p.TimestampMillisecond;case $.MICROSECOND:return p.TimestampMicrosecond;case $.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(e.unit){case Gt.DAY:return p.DateDay;case Gt.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(e.unit){case ce.DAY_TIME:return p.IntervalDayTime;case ce.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(e.unit){case $.SECOND:return p.DurationSecond;case $.MILLISECOND:return p.DurationMillisecond;case $.MICROSECOND:return p.DurationMicrosecond;case $.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(e.mode){case Nt.Dense:return p.DenseUnion;case Nt.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 '${p[e.typeId]}'`)}K.prototype.visitInt8=null,K.prototype.visitInt16=null,K.prototype.visitInt32=null,K.prototype.visitInt64=null,K.prototype.visitUint8=null,K.prototype.visitUint16=null,K.prototype.visitUint32=null,K.prototype.visitUint64=null,K.prototype.visitFloat16=null,K.prototype.visitFloat32=null,K.prototype.visitFloat64=null,K.prototype.visitDateDay=null,K.prototype.visitDateMillisecond=null,K.prototype.visitTimestampSecond=null,K.prototype.visitTimestampMillisecond=null,K.prototype.visitTimestampMicrosecond=null,K.prototype.visitTimestampNanosecond=null,K.prototype.visitTimeSecond=null,K.prototype.visitTimeMillisecond=null,K.prototype.visitTimeMicrosecond=null,K.prototype.visitTimeNanosecond=null,K.prototype.visitDenseUnion=null,K.prototype.visitSparseUnion=null,K.prototype.visitIntervalDayTime=null,K.prototype.visitIntervalYearMonth=null,K.prototype.visitDuration=null,K.prototype.visitDurationSecond=null,K.prototype.visitDurationMillisecond=null,K.prototype.visitDurationMicrosecond=null,K.prototype.visitDurationNanosecond=null;const fl=new Float64Array(1),gn=new Uint32Array(fl.buffer);function pl(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function mm(e){if(e!==e)return 32256;fl[0]=e;const t=(gn[1]&2147483648)>>16&65535;let n=gn[1]&2146435072,r=0;return n>=1089470464?gn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(gn[1]&1048575)>>10):n<=1056964608?(r=1048576+(gn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(gn[1]&1048575)+512>>10),t|n|r&65535}class k extends K{}function z(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const gm=(e,t,n)=>{e[t]=Math.floor(n/864e5)},yl=(e,t,n,r)=>{if(n+1<t.length){const i=dt(t[n]),s=dt(t[n+1]);e.set(r.subarray(0,s-i),i)}},_m=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Re=({values:e},t,n)=>{e[t]=n},ps=({values:e},t,n)=>{e[t]=n},ml=({values:e},t,n)=>{e[t]=mm(n)},bm=(e,t,n)=>{switch(e.type.precision){case Rt.HALF:return ml(e,t,n);case Rt.SINGLE:case Rt.DOUBLE:return ps(e,t,n)}},gl=({values:e},t,n)=>{gm(e,t,n.valueOf())},_l=({values:e},t,n)=>{e[t]=BigInt(n)},vm=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},bl=({values:e,valueOffsets:t},n,r)=>yl(e,t,n,r),vl=({values:e,valueOffsets:t},n,r)=>yl(e,t,n,is(r)),wm=(e,t,n)=>{e.type.unit===Gt.DAY?gl(e,t,n):_l(e,t,n)},wl=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},Il=({values:e},t,n)=>{e[t]=BigInt(n)},Sl=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},El=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Im=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return wl(e,t,n);case $.MILLISECOND:return Il(e,t,n);case $.MICROSECOND:return Sl(e,t,n);case $.NANOSECOND:return El(e,t,n)}},Tl=({values:e},t,n)=>{e[t]=n},Al=({values:e},t,n)=>{e[t]=n},Nl=({values:e},t,n)=>{e[t]=n},Rl=({values:e},t,n)=>{e[t]=n},Sm=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return Tl(e,t,n);case $.MILLISECOND:return Al(e,t,n);case $.MICROSECOND:return Nl(e,t,n);case $.NANOSECOND:return Rl(e,t,n)}},Em=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},Tm=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Qt.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[t],c=i[t+1];a<c;)s(r,a++,n[++o]);else for(let o=-1,a=i[t],c=i[t+1];a<c;)s(r,a++,n.get(++o))},Am=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Qt.getVisitFn(r);let{[t]:o,[t+1]:a}=i;const c=n instanceof Map?n.entries():Object.entries(n);for(const l of c)if(s(r,o,l),++o>=a)break},Nm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),Rm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),Bm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),Om=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),Dm=(e,t,n)=>{const r=e.type.children.map(s=>Qt.getVisitFn(s.type)),i=n instanceof Map?Bm(t,n):n instanceof st?Rm(t,n):Array.isArray(n)?Nm(t,n):Om(t,n);e.type.children.forEach((s,o)=>i(r[o],e.children[o],s,o))},Lm=(e,t,n)=>{e.type.mode===Nt.Dense?Bl(e,t,n):Ol(e,t,n)},Bl=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Qt.visit(i,e.valueOffsets[t],n)},Ol=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Qt.visit(i,t,n)},Fm=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Mm=(e,t,n)=>{e.type.unit===ce.DAY_TIME?Dl(e,t,n):Ll(e,t,n)},Dl=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ll=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Fl=({values:e},t,n)=>{e[t]=n},Ml=({values:e},t,n)=>{e[t]=n},Ul=({values:e},t,n)=>{e[t]=n},xl=({values:e},t,n)=>{e[t]=n},Um=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return Fl(e,t,n);case $.MILLISECOND:return Ml(e,t,n);case $.MICROSECOND:return Ul(e,t,n);case $.NANOSECOND:return xl(e,t,n)}},xm=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Qt.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=t*r;++o<r;)s(i,a+o,n[o]);else for(let o=-1,a=t*r;++o<r;)s(i,a+o,n.get(o))};k.prototype.visitBool=z(_m),k.prototype.visitInt=z(Re),k.prototype.visitInt8=z(Re),k.prototype.visitInt16=z(Re),k.prototype.visitInt32=z(Re),k.prototype.visitInt64=z(Re),k.prototype.visitUint8=z(Re),k.prototype.visitUint16=z(Re),k.prototype.visitUint32=z(Re),k.prototype.visitUint64=z(Re),k.prototype.visitFloat=z(bm),k.prototype.visitFloat16=z(ml),k.prototype.visitFloat32=z(ps),k.prototype.visitFloat64=z(ps),k.prototype.visitUtf8=z(vl),k.prototype.visitLargeUtf8=z(vl),k.prototype.visitBinary=z(bl),k.prototype.visitLargeBinary=z(bl),k.prototype.visitFixedSizeBinary=z(vm),k.prototype.visitDate=z(wm),k.prototype.visitDateDay=z(gl),k.prototype.visitDateMillisecond=z(_l),k.prototype.visitTimestamp=z(Im),k.prototype.visitTimestampSecond=z(wl),k.prototype.visitTimestampMillisecond=z(Il),k.prototype.visitTimestampMicrosecond=z(Sl),k.prototype.visitTimestampNanosecond=z(El),k.prototype.visitTime=z(Sm),k.prototype.visitTimeSecond=z(Tl),k.prototype.visitTimeMillisecond=z(Al),k.prototype.visitTimeMicrosecond=z(Nl),k.prototype.visitTimeNanosecond=z(Rl),k.prototype.visitDecimal=z(Em),k.prototype.visitList=z(Tm),k.prototype.visitStruct=z(Dm),k.prototype.visitUnion=z(Lm),k.prototype.visitDenseUnion=z(Bl),k.prototype.visitSparseUnion=z(Ol),k.prototype.visitDictionary=z(Fm),k.prototype.visitInterval=z(Mm),k.prototype.visitIntervalDayTime=z(Dl),k.prototype.visitIntervalYearMonth=z(Ll),k.prototype.visitDuration=z(Um),k.prototype.visitDurationSecond=z(Fl),k.prototype.visitDurationMillisecond=z(Ml),k.prototype.visitDurationMicrosecond=z(Ul),k.prototype.visitDurationNanosecond=z(xl),k.prototype.visitFixedSizeList=z(xm),k.prototype.visitMap=z(Am);const Qt=new k,ne=Symbol.for("parent"),_n=Symbol.for("rowIndex");class ys{constructor(t,n){return this[ne]=t,this[_n]=n,new Proxy(this,new $m)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[_n],n=this[ne],r=n.type.children,i={};for(let s=-1,o=r.length;++s<o;)i[r[s].name]=$t.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Gn(t)}: ${Gn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Cm(this[ne],this[_n])}}class Cm{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,$t.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(ys.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ne]:{writable:!0,enumerable:!1,configurable:!1,value:null},[_n]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class $m{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ne].type.children.map(n=>n.name)}has(t,n){return t[ne].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ne].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[ne].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=$t.visit(t[ne].children[r],t[_n]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ne].type.children.findIndex(s=>s.name===n);return i!==-1?(Qt.visit(t[ne].children[i],t[_n],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class M extends K{}function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const km=(e,t)=>864e5*e[t],Pm=(e,t)=>null,Cl=(e,t,n)=>{if(n+1>=t.length)return null;const r=dt(t[n]),i=dt(t[n+1]);return e.subarray(r,i)},Vm=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},$l=({values:e},t)=>km(e,t),kl=({values:e},t)=>dt(e[t]),ke=({stride:e,values:t},n)=>t[e*n],zm=({stride:e,values:t},n)=>pl(t[e*n]),Pl=({values:e},t)=>e[t],Ym=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Vl=({values:e,valueOffsets:t},n)=>Cl(e,t,n),zl=({values:e,valueOffsets:t},n)=>{const r=Cl(e,t,n);return r!==null?rs(r):null},jm=({values:e},t)=>e[t],qm=({type:e,values:t},n)=>e.precision!==Rt.HALF?t[n]:pl(t[n]),Gm=(e,t)=>e.type.unit===Gt.DAY?$l(e,t):kl(e,t),Yl=({values:e},t)=>1e3*dt(e[t]),jl=({values:e},t)=>dt(e[t]),ql=({values:e},t)=>za(e[t],BigInt(1e3)),Gl=({values:e},t)=>za(e[t],BigInt(1e6)),Wm=(e,t)=>{switch(e.type.unit){case $.SECOND:return Yl(e,t);case $.MILLISECOND:return jl(e,t);case $.MICROSECOND:return ql(e,t);case $.NANOSECOND:return Gl(e,t)}},Wl=({values:e},t)=>e[t],Hl=({values:e},t)=>e[t],Kl=({values:e},t)=>e[t],Ql=({values:e},t)=>e[t],Hm=(e,t)=>{switch(e.type.unit){case $.SECOND:return Wl(e,t);case $.MILLISECOND:return Hl(e,t);case $.MICROSECOND:return Kl(e,t);case $.NANOSECOND:return Ql(e,t)}},Km=({values:e,stride:t},n)=>fs.decimal(e.subarray(t*n,t*(n+1))),Qm=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:o}=n,a=i[0].slice(s,o-s);return new st([a])},Xm=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,o=r[0];return new gs(o.slice(i,s-i))},Jm=(e,t)=>new ys(e,t),Zm=(e,t)=>e.type.mode===Nt.Dense?Xl(e,t):Jl(e,t),Xl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return $t.visit(r,e.valueOffsets[t])},Jl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return $t.visit(r,t)},tg=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},eg=(e,t)=>e.type.unit===ce.DAY_TIME?Zl(e,t):tc(e,t),Zl=({values:e},t)=>e.subarray(2*t,2*(t+1)),tc=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},ec=({values:e},t)=>e[t],nc=({values:e},t)=>e[t],rc=({values:e},t)=>e[t],ic=({values:e},t)=>e[t],ng=(e,t)=>{switch(e.type.unit){case $.SECOND:return ec(e,t);case $.MILLISECOND:return nc(e,t);case $.MICROSECOND:return rc(e,t);case $.NANOSECOND:return ic(e,t)}},rg=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new st([i])};M.prototype.visitNull=P(Pm),M.prototype.visitBool=P(Vm),M.prototype.visitInt=P(jm),M.prototype.visitInt8=P(ke),M.prototype.visitInt16=P(ke),M.prototype.visitInt32=P(ke),M.prototype.visitInt64=P(Pl),M.prototype.visitUint8=P(ke),M.prototype.visitUint16=P(ke),M.prototype.visitUint32=P(ke),M.prototype.visitUint64=P(Pl),M.prototype.visitFloat=P(qm),M.prototype.visitFloat16=P(zm),M.prototype.visitFloat32=P(ke),M.prototype.visitFloat64=P(ke),M.prototype.visitUtf8=P(zl),M.prototype.visitLargeUtf8=P(zl),M.prototype.visitBinary=P(Vl),M.prototype.visitLargeBinary=P(Vl),M.prototype.visitFixedSizeBinary=P(Ym),M.prototype.visitDate=P(Gm),M.prototype.visitDateDay=P($l),M.prototype.visitDateMillisecond=P(kl),M.prototype.visitTimestamp=P(Wm),M.prototype.visitTimestampSecond=P(Yl),M.prototype.visitTimestampMillisecond=P(jl),M.prototype.visitTimestampMicrosecond=P(ql),M.prototype.visitTimestampNanosecond=P(Gl),M.prototype.visitTime=P(Hm),M.prototype.visitTimeSecond=P(Wl),M.prototype.visitTimeMillisecond=P(Hl),M.prototype.visitTimeMicrosecond=P(Kl),M.prototype.visitTimeNanosecond=P(Ql),M.prototype.visitDecimal=P(Km),M.prototype.visitList=P(Qm),M.prototype.visitStruct=P(Jm),M.prototype.visitUnion=P(Zm),M.prototype.visitDenseUnion=P(Xl),M.prototype.visitSparseUnion=P(Jl),M.prototype.visitDictionary=P(tg),M.prototype.visitInterval=P(eg),M.prototype.visitIntervalDayTime=P(Zl),M.prototype.visitIntervalYearMonth=P(tc),M.prototype.visitDuration=P(ng),M.prototype.visitDurationSecond=P(ec),M.prototype.visitDurationMillisecond=P(nc),M.prototype.visitDurationMicrosecond=P(rc),M.prototype.visitDurationNanosecond=P(ic),M.prototype.visitFixedSizeList=P(rg),M.prototype.visitMap=P(Xm);const $t=new M,bn=Symbol.for("keys"),vn=Symbol.for("vals"),wn=Symbol.for("kKeysAsStrings"),ms=Symbol.for("_kKeysAsStrings");class gs{constructor(t){return this[bn]=new st([t.children[0]]).memoize(),this[vn]=t.children[1],new Proxy(this,new sg)}get[wn](){return this[ms]||(this[ms]=Array.from(this[bn].toArray(),String))}[Symbol.iterator](){return new ig(this[bn],this[vn])}get size(){return this[bn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[bn],n=this[vn],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=$t.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Gn(t)}: ${Gn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class ig{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),$t.visit(this.vals,t)]})}}class sg{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[wn]}has(t,n){return t[wn].includes(n)}getOwnPropertyDescriptor(t,n){if(t[wn].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[wn].indexOf(n);if(r!==-1){const i=$t.visit(Reflect.get(t,vn),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[wn].indexOf(n);return i!==-1?(Qt.visit(Reflect.get(t,vn),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(gs.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[vn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ms]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let sc;function oc(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(sc=s,s=o,o=sc),o>i&&(o=i),r?r(e,s,o):[s,o]}const _s=(e,t)=>e<0?t+e:e,ac=e=>e!==e;function In(e){if(typeof e!="object"||e===null)return ac(e)?ac:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?rm(e,t):!1:e instanceof Map?ag(e):Array.isArray(e)?og(e):e instanceof st?lg(e):cg(e,!0)}function og(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=In(e[n]);return hi(t)}function ag(e){let t=-1;const n=[];for(const r of e.values())n[++t]=In(r);return hi(n)}function lg(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=In(e.get(n));return hi(t)}function cg(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=In(e[n[i]]);return hi(r,n)}function hi(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return ug(e,n);case Map:return lc(e,n,n.keys());case gs:case ys:case Object:case void 0:return lc(e,n,t||Object.keys(n))}return n instanceof st?hg(e,n):!1}}function ug(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function hg(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function lc(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let o=0;const a=e.length;let c=s.next(),l=r.next(),u=i.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!e[o](c.value));++o,l=r.next(),u=i.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function cc(e,t,n,r){return(n&1<<r)!==0}function dg(e,t,n,r){return(n&1<<r)>>r}function di(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):fi(new bs(n,e,t,null,cc)).subarray(0,r)),i}return n}function fi(e){const t=[];let n=0,r=0,i=0;for(const o of e)o&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class bs{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>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 vs(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const o of new bs(e,t,n-t,e,dg))s+=o;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return vs(e,t,i)+vs(e,r,n)+fg(e,i>>3,r-i>>3)}function fg(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=ws(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=ws(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=ws(s.getUint8(i)),i+=1;return r}function ws(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const pg=-1;class at{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){const{type:t}=this;return F.isSparseUnion(t)?this.children.some(n=>n.nullable):F.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(F.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=pg&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-vs(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof at?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ne(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){const{type:n}=this;if(F.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Nt.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(F.isUnion(i)){const s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===Nt.Dense?this.valueOffsets[t]:t;r=o.getValid(a),o.setValid(a,n)}else{let{nullBitmap:s}=this;const{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(di(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const d=s[u];r=(d&l)!==0,s[u]=n?d|l:d&~l}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new at(t,n,r,i,s,o,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,c=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===p.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(di(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[Ae.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:o}=this;return(s=o[Ae.TYPE])&&(o[Ae.TYPE]=s.subarray(t,t+n)),(s=o[Ae.OFFSET])&&(o[Ae.OFFSET]=s.subarray(t,t+n+1))||(s=o[Ae.DATA])&&(o[Ae.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),o}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}at.prototype.children=Object.freeze([]);class Qn extends K{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new at(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.data),s=J(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.data),s=J(t.nullBitmap),o=Na(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.data),s=J(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.data),s=J(t.nullBitmap),o=Na(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=J(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=J(t.nullBitmap),{length:o=i.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=ht(n.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(F.isSparseUnion(n))return new at(n,r,o,a,[void 0,void 0,void 0,s],i);const c=qn(t.valueOffsets);return new at(n,r,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.indices.ArrayType,t.data),{["dictionary"]:o=new st([new Qn().visit({type:n.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[void 0,s,i],[],o)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=J(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Qn().visit({type:n.valueType})}=t,s=J(t.nullBitmap),{["length"]:o=i.length/Ne(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new at(n,r,o,a,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Qn().visit({type:n.childType})}=t,s=J(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new at(n,r,a,c,[o,void 0,s],[i])}}const yg=new Qn;function X(e){return yg.visit(e)}class uc{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const 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 mg(e){return e.some(t=>t.nullable)}function hc(e){return e.reduce((t,n)=>t+n.nullCount,0)}function dc(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function fc(e,t,n,r){const i=[];for(let s=-1,o=e.length;++s<o;){const a=e[s],c=t[s],{length:l}=a;if(c>=r)break;if(n>=c+l)continue;if(c>=n&&c+l<=r){i.push(a);continue}const u=Math.max(0,n-c),d=Math.min(r-c,l);i.push(a.slice(u,d-u))}return i.length===0&&i.push(e[0].slice(0,0)),i}function Is(e,t,n,r){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return n<t[o]?r(e,i,n-t[i]):null;s=i+Math.trunc((o-i)*.5),n<t[s]?o=s:i=s}while(i<o)}function Ss(e,t){return e.getValid(t)}function pi(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return Is(r,this._offsets,n,t)}}function pc(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const o=Is(s,this._offsets,r,n);return t=void 0,o}}function yc(e){let t;function n(r,i,s){let o=s,a=0,c=0;for(let l=i-1,u=r.length;++l<u;){const d=r[l];if(~(a=e(d,t,o)))return c+a;o=0,c+=d.length}return-1}return function(r,i){t=r;const s=this.data,o=typeof i!="number"?n(s,0,0):Is(s,this._offsets,i,n);return t=void 0,o}}class U extends K{}function gg(e,t){return t===null&&e.length>0?0:-1}function _g(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new bs(n,e.offset+(t||0),e.length,n,cc)){if(!i)return r;++r}return-1}function j(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case p.Union:break;case p.Dictionary:break;default:return _g(e,n)}const r=$t.getVisitFn(e),i=In(t);for(let s=(n||0)-1,o=e.length;++s<o;)if(i(r(e,s)))return s;return-1}function mc(e,t,n){const r=$t.getVisitFn(e),i=In(t);for(let s=(n||0)-1,o=e.length;++s<o;)if(i(r(e,s)))return s;return-1}U.prototype.visitNull=gg,U.prototype.visitBool=j,U.prototype.visitInt=j,U.prototype.visitInt8=j,U.prototype.visitInt16=j,U.prototype.visitInt32=j,U.prototype.visitInt64=j,U.prototype.visitUint8=j,U.prototype.visitUint16=j,U.prototype.visitUint32=j,U.prototype.visitUint64=j,U.prototype.visitFloat=j,U.prototype.visitFloat16=j,U.prototype.visitFloat32=j,U.prototype.visitFloat64=j,U.prototype.visitUtf8=j,U.prototype.visitLargeUtf8=j,U.prototype.visitBinary=j,U.prototype.visitLargeBinary=j,U.prototype.visitFixedSizeBinary=j,U.prototype.visitDate=j,U.prototype.visitDateDay=j,U.prototype.visitDateMillisecond=j,U.prototype.visitTimestamp=j,U.prototype.visitTimestampSecond=j,U.prototype.visitTimestampMillisecond=j,U.prototype.visitTimestampMicrosecond=j,U.prototype.visitTimestampNanosecond=j,U.prototype.visitTime=j,U.prototype.visitTimeSecond=j,U.prototype.visitTimeMillisecond=j,U.prototype.visitTimeMicrosecond=j,U.prototype.visitTimeNanosecond=j,U.prototype.visitDecimal=j,U.prototype.visitList=j,U.prototype.visitStruct=j,U.prototype.visitUnion=j,U.prototype.visitDenseUnion=mc,U.prototype.visitSparseUnion=mc,U.prototype.visitDictionary=j,U.prototype.visitInterval=j,U.prototype.visitIntervalDayTime=j,U.prototype.visitIntervalYearMonth=j,U.prototype.visitDuration=j,U.prototype.visitDurationSecond=j,U.prototype.visitDurationMillisecond=j,U.prototype.visitDurationMicrosecond=j,U.prototype.visitDurationNanosecond=j,U.prototype.visitFixedSizeList=j,U.prototype.visitMap=j;const yi=new U;class x extends K{}function V(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(F.isInt(t)&&t.bitWidth!==64||F.isTime(t)&&t.bitWidth!==64||F.isFloat(t)&&t.precision!==Rt.HALF))return new uc(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new uc(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new bg(s)})}class bg{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}}x.prototype.visitNull=V,x.prototype.visitBool=V,x.prototype.visitInt=V,x.prototype.visitInt8=V,x.prototype.visitInt16=V,x.prototype.visitInt32=V,x.prototype.visitInt64=V,x.prototype.visitUint8=V,x.prototype.visitUint16=V,x.prototype.visitUint32=V,x.prototype.visitUint64=V,x.prototype.visitFloat=V,x.prototype.visitFloat16=V,x.prototype.visitFloat32=V,x.prototype.visitFloat64=V,x.prototype.visitUtf8=V,x.prototype.visitLargeUtf8=V,x.prototype.visitBinary=V,x.prototype.visitLargeBinary=V,x.prototype.visitFixedSizeBinary=V,x.prototype.visitDate=V,x.prototype.visitDateDay=V,x.prototype.visitDateMillisecond=V,x.prototype.visitTimestamp=V,x.prototype.visitTimestampSecond=V,x.prototype.visitTimestampMillisecond=V,x.prototype.visitTimestampMicrosecond=V,x.prototype.visitTimestampNanosecond=V,x.prototype.visitTime=V,x.prototype.visitTimeSecond=V,x.prototype.visitTimeMillisecond=V,x.prototype.visitTimeMicrosecond=V,x.prototype.visitTimeNanosecond=V,x.prototype.visitDecimal=V,x.prototype.visitList=V,x.prototype.visitStruct=V,x.prototype.visitUnion=V,x.prototype.visitDenseUnion=V,x.prototype.visitSparseUnion=V,x.prototype.visitDictionary=V,x.prototype.visitInterval=V,x.prototype.visitIntervalDayTime=V,x.prototype.visitIntervalYearMonth=V,x.prototype.visitDuration=V,x.prototype.visitDurationSecond=V,x.prototype.visitDurationMillisecond=V,x.prototype.visitDurationMicrosecond=V,x.prototype.visitDurationNanosecond=V,x.prototype.visitFixedSizeList=V,x.prototype.visitMap=V;const Es=new x;var gc;const _c={},bc={};class st{constructor(t){var n,r,i;const s=t[0]instanceof st?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof at)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:c,indexOf:l}=_c[o.typeId],u=s[0];this.isValid=d=>Ss(u,d),this.get=d=>a(u,d),this.set=(d,y)=>c(u,d,y),this.indexOf=d=>l(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,bc[o.typeId]),this._offsets=dc(s);break}this.data=s,this.type=o,this.stride=Ne(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return mg(this.data)}get nullCount(){return hc(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(_s(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return Es.visit(this)}concat(...t){return new st(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new st(oc(this,t,n,({data:r,_offsets:i},s,o)=>fc(r,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new st(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return F.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(F.isDictionary(this.type)){const t=new mi(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new st(n)}return new mi(this)}unmemoize(){if(F.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new st(n)}return this}}gc=Symbol.toStringTag,st[gc]=(e=>{e.type=F.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(const n of t){const r=$t.getVisitFnByTypeId(n),i=Qt.getVisitFnByTypeId(n),s=yi.getVisitFnByTypeId(n);_c[n]={get:r,set:i,indexOf:s},bc[n]=Object.create(e,{isValid:{value:pi(Ss)},get:{value:pi($t.getVisitFnByTypeId(n))},set:{value:pc(Qt.getVisitFnByTypeId(n))},indexOf:{value:yc(yi.getVisitFnByTypeId(n))}})}return"Vector"})(st.prototype);class mi extends st{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const c=n.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new mi(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new st(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ts{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,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,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class zt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+it),(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):wt.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new fe).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ts).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new Ts).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,wt.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class ot{constructor(t=[],n,r,i=wt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=As(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new ot(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new ot(n,this.metadata)}assign(...t){const n=t[0]instanceof ot?t[0]:Array.isArray(t[0])?new ot(t[0]):new ot(t),r=[...this.fields],i=gi(gi(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{const c=r.findIndex(l=>l.name===a.name);return~c?(r[c]=a.clone({metadata:gi(gi(new Map,r[c].metadata),a.metadata)}))&&!1:!0}),o=As(s,new Map);return new ot([...r,...s],i,new Map([...this.dictionaries,...o]))}}ot.prototype.fields=null,ot.prototype.metadata=null,ot.prototype.dictionaries=null;class pt{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new pt(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],pt.new(n,r,i,s)}}pt.prototype.type=null,pt.prototype.name=null,pt.prototype.nullable=null,pt.prototype.metadata=null;function gi(e,t){return new Map([...e||new Map,...t||new Map])}function As(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(F.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&As(i.children,t)}return t}var vg=La,wg=cn;class Xn{static decode(t){t=new wg(J(t));const n=zt.getRootAsFooter(t),r=ot.decode(n.schema(),new Map,n.version());return new Ig(r,n)}static encode(t){const n=new vg,r=ot.encode(n,t.schema);zt.startRecordBatchesVector(n,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())Pe.encode(n,o);const i=n.endVector();zt.startDictionariesVector(n,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())Pe.encode(n,o);const s=n.endVector();return zt.startFooter(n),zt.addSchema(n,r),zt.addVersion(n,wt.V5),zt.addRecordBatches(n,i),zt.addDictionaries(n,s),zt.finishFooterBuffer(n,zt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=wt.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(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}}class Ig extends Xn{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Pe.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Pe.decode(n)}return null}}class Pe{static decode(t){return new Pe(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return Ts.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=dt(r),this.bodyLength=dt(n)}}const Tt=Object.freeze({done:!0,value:void 0});class vc{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Ns{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class Sg extends Ns{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return q(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Tt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return qt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return qt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return q(this,void 0,void 0,function*(){return yield this.abort(t),Tt})}return(t){return q(this,void 0,void 0,function*(){return yield this.close(),Tt})}read(t){return q(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return q(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((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(Tt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class _i extends Sg{write(t){if((t=J(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?rs(this.toUint8Array(!0)):this.toUint8Array(!1).then(rs)}toUint8Array(t=!1){return t?le(this._values)[0]:q(this,void 0,void 0,function*(){var n,r,i,s;const o=[];let a=0;try{for(var c=!0,l=Je(this),u;u=yield l.next(),n=u.done,!n;c=!0){s=u.value,c=!1;const d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!c&&!n&&(i=l.return)&&(yield i.call(l))}finally{if(r)throw r.error}}return le(o,a)[0]})}}class bi{constructor(t){t&&(this.source=new Eg(qt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Sn{constructor(t){t instanceof Sn?this.source=t.source:t instanceof _i?this.source=new nn(qt.fromAsyncIterable(t)):Ta(t)?this.source=new nn(qt.fromNodeStream(t)):os(t)?this.source=new nn(qt.fromDOMStream(t)):Ea(t)?this.source=new nn(qt.fromDOMStream(t.body)):jn(t)?this.source=new nn(qt.fromIterable(t)):Ze(t)?this.source=new nn(qt.fromAsyncIterable(t)):ln(t)&&(this.source=new nn(qt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Eg{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,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Tt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Tt)}}class nn{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return q(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return q(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return q(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return q(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return q(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||Tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return q(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||Tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class wc extends bi{constructor(t,n){super(),this.position=0,this.buffer=J(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class vi extends Sn{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=q(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return q(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return q(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 q(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0;const c=Math.min(r,s+Math.min(r-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield n.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,n){return q(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),o=new Uint8Array(s-t);return(yield r.read(o,0,n,t)).buffer}return new Uint8Array(n)})}close(){return q(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return q(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return q(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const Tg=65536;function En(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Tn=8,Rs=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class Ic{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?Tg:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}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`${En(this.buffer[1])} ${En(this.buffer[0])}`}}class lt extends Ic{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return lt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return lt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new lt(n);for(let s=0;s<r;){const o=Tn<r-s?Tn:r-s,a=new lt(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new lt(new Uint32Array([Rs[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)lt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new lt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new lt(new Uint32Array(t.buffer)).plus(n)}}class Xt extends Ic{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){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return Xt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Xt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new Xt(n);for(let o=r?1:0;o<i;){const a=Tn<i-o?Tn:i-o,c=new Xt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new Xt(new Uint32Array([Rs[a],0]));s.times(l),s.plus(c),o+=a}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Xt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Xt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Xt(new Uint32Array(t.buffer)).plus(n)}}class pe{constructor(t){this.buffer=t}high(){return new Xt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Xt(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){const n=new lt(new Uint32Array([this.buffer[3],0])),r=new lt(new Uint32Array([this.buffer[2],0])),i=new lt(new Uint32Array([this.buffer[1],0])),s=new lt(new Uint32Array([this.buffer[0],0])),o=new lt(new Uint32Array([t.buffer[3],0])),a=new lt(new Uint32Array([t.buffer[2],0])),c=new lt(new Uint32Array([t.buffer[1],0])),l=new lt(new Uint32Array([t.buffer[0],0]));let u=lt.multiply(s,l);this.buffer[0]=u.low();const d=new lt(new Uint32Array([u.high(),0]));return u=lt.multiply(i,l),d.plus(u),u=lt.multiply(s,c),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new lt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(lt.multiply(r,l)).plus(lt.multiply(i,c)).plus(lt.multiply(s,a)),this.buffer[3]+=lt.multiply(n,l).plus(lt.multiply(r,c)).plus(lt.multiply(i,a)).plus(lt.multiply(s,o)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${En(this.buffer[3])} ${En(this.buffer[2])} ${En(this.buffer[1])} ${En(this.buffer[0])}`}static multiply(t,n){return new pe(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new pe(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return pe.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return pe.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new pe(n);for(let o=r?1:0;o<i;){const a=Tn<i-o?Tn:i-o,c=new pe(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new pe(new Uint32Array([Rs[a],0,0,0]));s.times(l),s.plus(c),o+=a}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)pe.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class Sc extends K{constructor(t,n,r,i,s=wt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof pt?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return X({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<wt.V5&&this.readNullBitmap(t,r),t.mode===Nt.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return X({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class Ag extends Sc{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):fi(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return ht(Uint8Array,ht(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return ht(Uint8Array,ht(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return F.isTimestamp(t)||(F.isInt(t)||F.isTime(t))&&t.bitWidth===64||F.isDuration(t)||F.isDate(t)&&t.unit===Gt.MILLISECOND?ht(Uint8Array,Xt.convertArray(r[n])):F.isDecimal(t)?ht(Uint8Array,pe.convertArray(r[n])):F.isBinary(t)||F.isLargeBinary(t)||F.isFixedSizeBinary(t)?Ng(r[n]):F.isBool(t)?fi(r[n]):F.isUtf8(t)||F.isLargeUtf8(t)?is(r[n].join("")):ht(Uint8Array,ht(t.ArrayType,r[n].map(i=>+i)))}}function Ng(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class C extends K{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function Lt(e,t){return t instanceof e.constructor}function rn(e,t){return e===t||Lt(e,t)}function Be(e,t){return e===t||Lt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function wi(e,t){return e===t||Lt(e,t)&&e.precision===t.precision}function Rg(e,t){return e===t||Lt(e,t)&&e.byteWidth===t.byteWidth}function Bs(e,t){return e===t||Lt(e,t)&&e.unit===t.unit}function Jn(e,t){return e===t||Lt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Zn(e,t){return e===t||Lt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Bg(e,t){return e===t||Lt(e,t)&&e.children.length===t.children.length&&Ve.compareManyFields(e.children,t.children)}function Og(e,t){return e===t||Lt(e,t)&&e.children.length===t.children.length&&Ve.compareManyFields(e.children,t.children)}function Os(e,t){return e===t||Lt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&Ve.compareManyFields(e.children,t.children)}function Dg(e,t){return e===t||Lt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Ve.visit(e.indices,t.indices)&&Ve.visit(e.dictionary,t.dictionary)}function Ds(e,t){return e===t||Lt(e,t)&&e.unit===t.unit}function tr(e,t){return e===t||Lt(e,t)&&e.unit===t.unit}function Lg(e,t){return e===t||Lt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Ve.compareManyFields(e.children,t.children)}function Fg(e,t){return e===t||Lt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Ve.compareManyFields(e.children,t.children)}C.prototype.visitNull=rn,C.prototype.visitBool=rn,C.prototype.visitInt=Be,C.prototype.visitInt8=Be,C.prototype.visitInt16=Be,C.prototype.visitInt32=Be,C.prototype.visitInt64=Be,C.prototype.visitUint8=Be,C.prototype.visitUint16=Be,C.prototype.visitUint32=Be,C.prototype.visitUint64=Be,C.prototype.visitFloat=wi,C.prototype.visitFloat16=wi,C.prototype.visitFloat32=wi,C.prototype.visitFloat64=wi,C.prototype.visitUtf8=rn,C.prototype.visitLargeUtf8=rn,C.prototype.visitBinary=rn,C.prototype.visitLargeBinary=rn,C.prototype.visitFixedSizeBinary=Rg,C.prototype.visitDate=Bs,C.prototype.visitDateDay=Bs,C.prototype.visitDateMillisecond=Bs,C.prototype.visitTimestamp=Jn,C.prototype.visitTimestampSecond=Jn,C.prototype.visitTimestampMillisecond=Jn,C.prototype.visitTimestampMicrosecond=Jn,C.prototype.visitTimestampNanosecond=Jn,C.prototype.visitTime=Zn,C.prototype.visitTimeSecond=Zn,C.prototype.visitTimeMillisecond=Zn,C.prototype.visitTimeMicrosecond=Zn,C.prototype.visitTimeNanosecond=Zn,C.prototype.visitDecimal=rn,C.prototype.visitList=Bg,C.prototype.visitStruct=Og,C.prototype.visitUnion=Os,C.prototype.visitDenseUnion=Os,C.prototype.visitSparseUnion=Os,C.prototype.visitDictionary=Dg,C.prototype.visitInterval=Ds,C.prototype.visitIntervalDayTime=Ds,C.prototype.visitIntervalYearMonth=Ds,C.prototype.visitDuration=tr,C.prototype.visitDurationSecond=tr,C.prototype.visitDurationMillisecond=tr,C.prototype.visitDurationMicrosecond=tr,C.prototype.visitDurationNanosecond=tr,C.prototype.visitFixedSizeList=Lg,C.prototype.visitMap=Fg;const Ve=new C;function Ls(e,t){return Ve.compareSchemas(e,t)}function Fs(e,t){return Mg(e,t.map(n=>n.data.concat()))}function Mg(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((d,y)=>Math.max(d,y.length),0)};let s=0,o=0,a=-1;const c=t.length;let l,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=Ug(n,o,u,t,i),o>0&&(r[s++]=X({type:new Dt(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(d=>new kt(e,d))]}function Ug(e,t,n,r,i){var s;const o=(t+63&-64)>>3;for(let a=-1,c=r.length;++a<c;){const l=n[a],u=l==null?void 0:l.length;if(u>=t)u===t?n[a]=l:(n[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,r[a].unshift(l.slice(t,u-t))));else{const d=e[a];e[a]=d.clone({nullable:!0}),n[a]=(s=l==null?void 0:l._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:X({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var Ec;class Ft{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new ot([]),this._offsets=[0],this;let i,s;t[0]instanceof ot&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=c=>{if(c){if(c instanceof kt)return[c];if(c instanceof Ft)return c.batches;if(c instanceof at){if(c.type instanceof Dt)return[new kt(new ot(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){const l=Object.keys(c),u=l.map(m=>new st([c[m]])),d=i??new ot(l.map((m,b)=>new pt(String(m),u[b].type,u[b].nullable))),[,y]=Fs(d,u);return y.length===0?[new kt(c)]:y}}}return[]},a=t.flatMap(c=>o(c));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new ot([]),!(i instanceof ot))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const c of a){if(!(c instanceof kt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Ls(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??dc(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,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=hc(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(_s(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?Es.visit(new st(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
35
|
+
`),l&&(o.useProgram(l),d=It(),c=dt(o,l,d),y=Ir.translate(E/2,T/2).scale(1),_=Yf().scaleExtent([.1,100]).on("zoom",u=>{y=u.transform,ht(o,c,2,v)}),pe(i.value).call(_),requestAnimationFrame(()=>ht(o,c,2,null)),i.value.addEventListener("mousemove",R),i.value.addEventListener("mouseleave",F))}}function R(u){if(!i.value)return;const m=i.value.getBoundingClientRect(),b=u.clientX-m.left,w=u.clientY-m.top,I=gt(d,b,w,E,T);if(I){const S=s.value;S.style.left=`${u.clientX+15}px`,S.style.top=`${u.clientY-15}px`,S.style.opacity="1",S.innerHTML=`<strong>(${I.rawX.toFixed(2)}, ${I.rawY.toFixed(2)})</strong>`,v=I,ht(o,c,2,v)}else s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function F(){s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function p(){!i.value||!o||(it(i.value,o),ht(o,c,2,v))}function g(){var O;if(!o||!c||!n.data.length)return;const u=(((O=n.metaData)==null?void 0:O.schema)||[]).findIndex(A=>(A==null?void 0:A.name)===n.colorMode),m=u>=0?u:-1,b=B(n.startColor),w=B(n.endColor);let I=[];if(n.colorMap&&n.colorMap.size>0&&m>=0)I=n.data.flatMap(A=>n.colorMap.get(A[m])||[.6,.6,.6]);else if(m>=0){const A=n.data.map(st=>Number(st[m])).filter(Number.isFinite),M=Math.min(...A),J=Math.max(...A)-M||1;I=n.data.flatMap(st=>{const ct=Number(st[m]),St=Math.max(0,Math.min(1,(ct-M)/J));return[Q(b[0],w[0],St),Q(b[1],w[1],St),Q(b[2],w[2],St)]})}else{const A=B(n.singleColor);I=n.data.flatMap(()=>A)}o.deleteBuffer(c.colorBuffer);const S=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,S),o.bufferData(o.ARRAY_BUFFER,new Float32Array(I),o.STATIC_DRAW),c.colorBuffer=S,ht(o,c,2,v)}return h.watch(()=>n.forceRegenerate,()=>{!o||!l||(d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),y=Ir,i.value&&_&&pe(i.value).call(_.transform,y),g(),ht(o,c,2,null))}),h.watch(()=>n.data,()=>{if(!o||!l){Zt();return}d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null)}),h.watch(()=>n.colorMode,g),h.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],g),h.watch(()=>n.pointCount,u=>{!o||!l||(d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null))}),h.onMounted(()=>{window.addEventListener("resize",p)}),h.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",R),i.value.removeEventListener("mouseleave",F)),window.removeEventListener("resize",p),o&&c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer),l&&o.deleteProgram(l))}),(u,m)=>(h.openBlock(),h.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[h.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),h.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),h.withDirectives(h.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:a},null,512),[[h.vShow,!1]])],512))}}),qf=Sn(Wf,[["__scopeId","data-v-2c0af95e"]]),Gf={class:"control-panel"},Hf={class:"color-option"},Kf=["value"],Qf={key:0,class:"color-option"},Xf={class:"legend"},Jf={class:"legend-label"},Zf=h.defineComponent({__name:"control",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},colorScheme:{type:Map,default:()=>new Map},colorMapMap:{type:Map,default:()=>new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate","updateColorMap"],setup(e,{emit:t}){const n=e,r=t,i=h.ref(n.pointCount),s=h.ref(n.colorMode),a=h.ref(n.startColor),o=h.ref(n.endColor),l=h.ref(n.singleColor),c=h.computed(()=>n.colorMapMap instanceof Map?Array.from(n.colorMapMap.keys()):[]),d=h.computed(()=>n.colorMapMap instanceof Map?n.colorMapMap.get(s.value):void 0),y=h.computed(()=>d.value?Array.from(d.value.entries()):[]);function _(E){if(!E)return"rgb(150,150,150)";const[T,N,B]=E;return`rgb(${Math.round(T*255)}, ${Math.round(N*255)}, ${Math.round(B*255)})`}function v(){r("update:colorMode",s.value),r("updateColorMap",[s.value,d.value??new Map]),r("update:startColor",a.value),r("update:endColor",o.value),r("update:singleColor",l.value)}return h.watch(()=>n.pointCount,E=>i.value=E),h.watch(()=>n.colorMode,E=>s.value=E),h.watch(()=>n.startColor,E=>a.value=E),h.watch(()=>n.endColor,E=>o.value=E),h.watch(()=>n.singleColor,E=>l.value=E),h.watch(s,v),h.watch(()=>n.colorMapMap,()=>{n.colorMapMap instanceof Map&&(s.value!=="random"&&!n.colorMapMap.has(s.value)&&(s.value="random"),v())}),(E,T)=>(h.openBlock(),h.createElementBlock("div",Gf,[T[4]||(T[4]=h.createElementVNode("h3",null,"Color Controls",-1)),h.createElementVNode("div",Hf,[T[2]||(T[2]=h.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),h.withDirectives(h.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":T[0]||(T[0]=N=>s.value=N)},[T[1]||(T[1]=h.createElementVNode("option",{value:"random"},"random",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(c.value,N=>(h.openBlock(),h.createElementBlock("option",{key:N,value:N},h.toDisplayString(N),9,Kf))),128))],512),[[h.vModelSelect,s.value]])]),y.value.length?(h.openBlock(),h.createElementBlock("div",Qf,[h.createElementVNode("div",Xf,[T[3]||(T[3]=h.createElementVNode("h4",null,"Legend",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(y.value,([N,B],Q)=>(h.openBlock(),h.createElementBlock("div",{class:"legend-item",key:`${N}-${Q}`},[h.createElementVNode("div",{class:"legend-color",style:h.normalizeStyle({backgroundColor:_(B)})},null,4),h.createElementVNode("div",Jf,h.toDisplayString(N),1)]))),128))])])):h.createCommentVNode("",!0)]))}}),tp=Sn(Zf,[["__scopeId","data-v-91c1f44e"]]),ep={class:"app-container"},ki="UMAP_1",$i="UMAP_2",np=h.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=h.ref(5e3),r=h.ref("random"),i=h.ref("#ff0000"),s=h.ref("#0000ff"),a=h.ref("#4285f4"),o=h.ref(!1),l=h.ref(0),c=h.ref([]),d=h.ref(null),y=h.ref(new Map),_=h.ref(new Map),v=h.ref([]),E=js(),T=h.ref(null),N=h.ref(null);h.watch(()=>{var p,g,u,m;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((g=(p=t.pkg)==null?void 0:p.content)==null?void 0:g.id)||"",pkgType:((m=(u=t.pkg)==null?void 0:u.content)==null?void 0:m.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:p,srcFileType:g,srcFileId:u,pkgId:m,pkgType:b,apiUrl:w})=>{var I,S,O;try{if(c.value=[],d.value=null,await B(),p){const A=g??(p.toLowerCase().endsWith(".csv")?"csv":"parquet");await Q(p,A,u||"umap_file"),await it();return}if(m&&w){await It(m,w);const A=(O=(S=(I=v.value)==null?void 0:I[0])==null?void 0:S.content)==null?void 0:O.id;if(!A)return;const M=await $t(m,A,w);await Q(M,b==="CSV"?"csv":"parquet",A),await it()}}catch(A){console.error("[UMAP Wrapper] Load failed:",(A==null?void 0:A.message)||A)}},{immediate:!0}),h.watch(n,async()=>{N.value&&T.value&&await mt()}),h.watch([()=>E.sharedVersion,()=>E.sharedResultName],async()=>{E.sharedResultName&&(await B(),N.value=E.sharedResultName,await it())});async function B(){if(T.value)return;const{connectionId:p}=await E.createConnection(`umap_${Date.now()}`);T.value=p}async function Q(p,g,u){const m=`umap_${u.replace(/[^a-zA-Z0-9_]/g,"_")}`;N.value=await E.loadFile(p,g,m,{},T.value,u)}async function it(){var b,w,I,S;if(!N.value||!T.value)return;const p=await F(N.value),g=p.filter(O=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(O.type)),u=p.some(O=>O.name===ki)?ki:((b=g[0])==null?void 0:b.name)||((w=p[0])==null?void 0:w.name),m=p.some(O=>O.name===$i)?$i:((I=g[1])==null?void 0:I.name)||((S=p[1])==null?void 0:S.name)||u;await mt(u,m,p.map(O=>O.name)),await bt(p,u,m)}async function mt(p=ki,g=$i,u){var O;if(!N.value||!T.value)return;const m=(u||(await F(N.value)).map(A=>A.name)).filter(A=>A!==p&&A!==g),b=`SELECT ${[`CAST(${dt(p)} AS DOUBLE) AS __x`,`CAST(${dt(g)} AS DOUBLE) AS __y`,...m.map(A=>dt(A))].join(", ")} FROM ${N.value} LIMIT ${n.value}`,w=await E.executeQuery(b,T.value);c.value=w.map(A=>[A.__x,A.__y,...m.map(M=>A[M])]);const I=`
|
|
36
|
+
SELECT min(${dt(p)}) AS xmin, max(${dt(p)}) AS xmax,
|
|
37
|
+
min(${dt(g)}) AS ymin, max(${dt(g)}) AS ymax
|
|
38
|
+
FROM ${N.value}
|
|
39
|
+
`,S=((O=await E.executeQuery(I,T.value))==null?void 0:O[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};d.value={schema:[{name:p},{name:g},...m.map(A=>({name:A}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:S.xmin,max_value:S.xmax}}},{meta_data:{statistics:{min_value:S.ymin,max_value:S.ymax}}}]}]}}async function bt(p,g,u){_.value=new Map;const m=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],b=w=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(w);for(const w of p){if(w.name===g||w.name===u){_.value.set(w.name,new Map);continue}if(b(w.type))_.value.set(w.name,new Map);else{const I=`SELECT DISTINCT ${dt(w.name)} AS v FROM ${N.value} LIMIT 10000`,S=(await E.executeQuery(I,T.value)).map(A=>A.v).filter(A=>A!=null),O=new Map;S.forEach((A,M)=>O.set(A,Zt(m[M%m.length]))),_.value.set(w.name,O)}}(d.value||(d.value={})).key_value_metadata=Array.from(_.value.keys()).map(w=>{var I;return{key:w,value:JSON.stringify(Array.from(((I=_.value.get(w))==null?void 0:I.keys())??[]))}}),r.value!=="random"&&!_.value.has(r.value)&&(r.value="random")}async function gt(){const{useGetToken:p}=await Promise.resolve().then(()=>Bc);return p()}async function It(p,g){const u=await gt(),m=`${g}/packages/${p}/view?api_key=${u}`,b=await fetch(m);if(!b.ok)throw new Error(`view failed: ${b.status}`);v.value=await b.json()}async function $t(p,g,u){const m=await gt(),b=`${u}/packages/${p}/files/${g}?api_key=${m}`,w=await fetch(b);if(!w.ok)throw new Error(`file url failed: ${w.status}`);return(await w.json()).url}function dt(p){return`"${p.replace(/"/g,'""')}"`}function ht(){o.value=!o.value,l.value++}function Zt(p){try{if(!p||p.length<7)return[1,0,0];const g=parseInt(p.slice(1,3),16)/255,u=parseInt(p.slice(3,5),16)/255,m=parseInt(p.slice(5,7),16)/255;return Number.isNaN(g)||Number.isNaN(u)||Number.isNaN(m)?[1,0,0]:[g,u,m]}catch{return[1,0,0]}}function R(p){y.value=p[1]}async function F(p){return(await E.executeQuery(`PRAGMA table_info(${p});`,T.value)).map(g=>({name:g.name,type:g.type}))}return h.onMounted(async()=>{await B()}),h.onBeforeUnmount(async()=>{T.value&&await E.closeConnection(T.value)}),(p,g)=>(h.openBlock(),h.createElementBlock("div",ep,[(h.openBlock(),h.createBlock(qf,{data:c.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),h.createVNode(tp,{pointCount:n.value,"onUpdate:pointCount":g[0]||(g[0]=u=>n.value=u),colorMode:r.value,"onUpdate:colorMode":g[1]||(g[1]=u=>r.value=u),startColor:i.value,"onUpdate:startColor":g[2]||(g[2]=u=>i.value=u),endColor:s.value,"onUpdate:endColor":g[3]||(g[3]=u=>s.value=u),singleColor:a.value,"onUpdate:singleColor":g[4]||(g[4]=u=>a.value=u),"color-scheme":y.value,"color-map-map":_.value,onRegenerate:ht,onUpdateColorMap:R},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),rp=Sn(np,[["__scopeId","data-v-244cd07d"]]),ip="dashboard:globalVars";function La(e=!1){const t=h.inject(ip,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const sp={class:"data-explorer-wrap"},ap={class:"data-explorer-info"},op=h.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t.s3Url));return h.watchEffect(()=>{}),(i,s)=>{const a=h.resolveComponent("el-icon");return h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",sp,[h.createElementVNode("div",ap,[h.createVNode(h.unref(Pc.ElTooltip),{placement:"top-start"},{content:h.withCtx(()=>[...s[0]||(s[0]=[h.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:h.withCtx(()=>[h.createVNode(a,{color:"#8300BF"},{default:h.withCtx(()=>[h.createVNode(h.unref(jc))]),_:1})]),_:1})]),h.createVNode(h.unref(yu),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),xa=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},lp=xa(op,[["__scopeId","data-v-2908b590"]]),cp={class:"umap-wrap"},up=xa(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t==null?void 0:t.s3Url));return(i,s)=>(h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",cp,[h.createVNode(h.unref(rp),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function Y(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(d){try{c(r.next(d))}catch(y){a(y)}}function l(d){try{c(r.throw(d))}catch(y){a(y)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((r=r.apply(e,t||[])).next())})}function Ua(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function re(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(E){return Promise.resolve(E).then(v,y)}}function o(v,E){r[v]&&(i[v]=function(T){return new Promise(function(N,B){s.push([v,T,N,B])>1||l(v,T)})},E&&(i[v]=E(i[v])))}function l(v,E){try{c(r[v](E))}catch(T){_(s[0][3],T)}}function c(v){v.value instanceof W?Promise.resolve(v.value.v).then(d,y):_(s[0][2],v)}function d(v){l("next",v)}function y(v){l("throw",v)}function _(v,E){v(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Sr(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:W(e[i](a)),done:!1}:s?s(a):a}:s}}function je(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ua=="function"?Ua(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(c){s({value:c,done:o})},a)}}const hp=new TextDecoder("utf-8"),Pi=e=>hp.decode(e),dp=new TextEncoder,Vi=e=>dp.encode(e),fp=e=>typeof e=="number",Ca=e=>typeof e=="boolean",_t=e=>typeof e=="function",Dt=e=>e!=null&&Object(e)===e,Ye=e=>Dt(e)&&_t(e.then),Ln=e=>Dt(e)&&_t(e[Symbol.iterator]),Ze=e=>Dt(e)&&_t(e[Symbol.asyncIterator]),zi=e=>Dt(e)&&Dt(e.schema),ka=e=>Dt(e)&&"done"in e&&"value"in e,$a=e=>Dt(e)&&_t(e.stat)&&fp(e.fd),Pa=e=>Dt(e)&&ji(e.body),Er=e=>"_getDOMStream"in e&&"_getNodeStream"in e,pp=e=>Dt(e)&&_t(e.abort)&&_t(e.getWriter)&&!Er(e),ji=e=>Dt(e)&&_t(e.cancel)&&_t(e.getReader)&&!Er(e),yp=e=>Dt(e)&&_t(e.end)&&_t(e.write)&&Ca(e.writable)&&!Er(e),Va=e=>Dt(e)&&_t(e.read)&&_t(e.pipe)&&Ca(e.readable)&&!Er(e),mp=e=>Dt(e)&&_t(e.clear)&&_t(e.bytes)&&_t(e.position)&&_t(e.setPosition)&&_t(e.capacity)&&_t(e.getBufferIdentifier)&&_t(e.createLong),Yi=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function bp(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,c=0,d=e.length;++l<d;){if(a=t[c],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++c]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++c]=o);continue}t[c]=new Uint8Array(a.buffer,n,r-n+s)}return t}function za(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function ie(e,t){const n=bp(e),r=n.reduce((d,y)=>d+y.byteLength,0);let i,s,a,o=0,l=-1;const c=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=n.length;++l<d;){if(i=n[l],s=i.subarray(0,Math.min(i.length,c-o)),c<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?za(a,s,o):a=s;break}za(a||(a=new Uint8Array(c)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function at(e,t){let n=ka(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Vi(n)),n instanceof ArrayBuffer?new e(n):n instanceof Yi?new e(n):mp(n)?at(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const xn=e=>at(Int32Array,e),ja=e=>at(BigInt64Array,e),H=e=>at(Uint8Array,e),Wi=e=>(e.next(),e);function*gp(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Yi?n(t):Ln(t)?t:n(t);return yield*Wi(function*(i){let s=null;do s=i.next(yield at(e,s));while(!s.done)}(r[Symbol.iterator]())),new e}const _p=e=>gp(Uint8Array,e);function Ya(e,t){return re(this,arguments,function*(){if(Ye(t))return yield W(yield W(yield*Sr(je(Ya(e,yield W(t))))));const n=function(s){return re(this,arguments,function*(){yield yield W(yield W(s))})},r=function(s){return re(this,arguments,function*(){yield W(yield*Sr(je(Wi(function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)}(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Yi?n(t):Ln(t)?r(t):Ze(t)?t:n(t);return yield W(yield*Sr(je(Wi(function(s){return re(this,arguments,function*(){let a=null;do a=yield W(s.next(yield yield W(at(e,a))));while(!a.done)})}(i[Symbol.asyncIterator]()))))),yield W(new e)})}const vp=e=>Ya(Uint8Array,e);function Wa(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function wp(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const Pt={fromIterable(e){return Tr(Ip(e))},fromAsyncIterable(e){return Tr(Sp(e))},fromDOMStream(e){return Tr(Ep(e))},fromNodeStream(e){return Tr(Ap(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},Tr=e=>(e.next(),e);function*Ip(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const c=_p(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?c.next():c.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&c.throw(d)}finally{n===!1&&typeof c.return=="function"&&c.return(null)}return null}function Sp(e){return re(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=vp(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.next()):yield W(c.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&(yield W(c.throw(d)))}finally{n===!1&&typeof c.return=="function"&&(yield W(c.return(new Uint8Array(0))))}return yield W(null)})}function Ep(e){return re(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=new Tp(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.read()):yield W(c.read(a-o)),!t&&i.byteLength>0&&(r.push(H(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&(yield W(c.cancel(d)))}finally{n===!1?yield W(c.cancel()):e.locked&&c.releaseLock()}return yield W(null)})}class Tp{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 Y(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Y(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=H(n)),n})}}const qi=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Ap(e){return re(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],c;function d(){return s==="peek"?ie(l,a)[0]:([c,l,o]=ie(l,a),c)}if({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0},e.isTTY)return yield yield W(new Uint8Array(0)),yield W(null);try{t[0]=qi(e,"end"),t[1]=qi(e,"error");do{if(t[2]=qi(e,"readable"),[n,i]=yield W(Promise.race(t.map(_=>_[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(c=H(e.read(a-o)),c.byteLength<a-o&&(c=H(e.read()))):c=H(e.read()),c.byteLength>0&&(l.push(c),o+=c.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield W(d()));while(a<o)}while(!r)}finally{yield W(y(t,n==="error"?i:null))}return yield W(null);function y(_,v){return c=l=null,new Promise((E,T)=>{for(const[N,B]of _)e.off(N,B);try{const N=e.destroy;N&&N.call(e,v),v=void 0}catch(N){v=N||v}finally{v!=null?T(v):E()}})}})}var yt;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(yt||(yt={}));var Et;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Et||(Et={}));var Tt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Tt||(Tt={}));var Vt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Vt||(Vt={}));var k;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var se;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(se||(se={}));const Gi=2,ae=4,ge=4,Z=4,Be=new Int32Array(2),qa=new Float32Array(Be.buffer),Ga=new Float64Array(Be.buffer),Ar=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Hi;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Hi||(Hi={}));let tn=class kc{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new kc(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 Be[0]=this.readInt32(t),qa[0]}readFloat64(t){return Be[Ar?0:1]=this.readInt32(t),Be[Ar?1:0]=this.readInt32(t+4),Ga[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){qa[0]=n,this.writeInt32(t,Be[0])}writeFloat64(t,n){Ga[0]=n,this.writeInt32(t,Be[Ar?0:1]),this.writeInt32(t+4,Be[Ar?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+ae+ge)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<ge;n++)t+=String.fromCharCode(this.readInt8(this.position_+ae+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=ae;const i=this.bytes_.subarray(t,t+r);return n===Hi.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+ae}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ge)throw new Error("FlatBuffers: file identifier must be length "+ge);for(let n=0;n<ge;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+ae+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},Ha=class $c{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 n;t?n=t:n=1024,this.bb=tn.allocate(n),this.space=n}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,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=$c.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)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,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),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){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=tn.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(ae,0),this.writeInt32(this.offset()-t+ae)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=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);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*Gi;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let c=Gi;c<s;c+=Gi)if(this.bb.readInt16(o+c)!=this.bb.readInt16(l+c))continue t;a=this.vtables[n];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,n,r){const i=r?Z:0;if(n){const s=n;if(this.prep(this.minalign,ae+ge+i),s.length!=ge)throw new TypeError("FlatBuffers: file identifier must be length "+ge);for(let a=ge-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,ae+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(ae,t*n),this.prep(r,t*n)}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);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,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){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Nr;(function(e){e[e.BUFFER=0]="BUFFER"})(Nr||(Nr={}));var Br;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Br||(Br={}));class Re{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Re).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Z),(n||new Re).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Br.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Nr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Br.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,Nr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Re.startBodyCompression(t),Re.addCodec(t,n),Re.addMethod(t,r),Re.endBodyCompression(t)}}class Ka{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,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,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Qa=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},_e=class Vs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Z),(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Qa).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ka).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Re).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},en=class zs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Z),(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new _e).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var nn;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(nn||(nn={}));var Rr;(function(e){e[e.DenseArray=0]="DenseArray"})(Rr||(Rr={}));class Ut{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Z),(n||new Ut).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Ut.startInt(t),Ut.addBitWidth(t,n),Ut.addIsSigned(t,r),Ut.endInt(t)}}class ve{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Z),(n||new ve).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ut).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Rr.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,Rr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class vt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Z),(n||new vt).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return vt.startKeyValue(t),vt.addKey(t,n),vt.addValue(t,r),vt.endKeyValue(t)}}let Xa=class Xn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Z),(n||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Xn.startBinary(t),Xn.endBinary(t)}},Ja=class Jn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new Jn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Z),(n||new Jn).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Jn.startBool(t),Jn.endBool(t)}},Or=class gn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new gn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Z),(n||new gn).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Vt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Vt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return gn.startDate(t),gn.addUnit(t,n),gn.endDate(t)}},rn=class Ue{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new Ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Z),(n||new Ue).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return Ue.startDecimal(t),Ue.addPrecision(t,n),Ue.addScale(t,r),Ue.addBitWidth(t,i),Ue.endDecimal(t)}},Dr=class _n{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new _n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Z),(n||new _n).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,k.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return _n.startDuration(t),_n.addUnit(t,n),_n.endDuration(t)}},Fr=class vn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new vn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Z),(n||new vn).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return vn.startFixedSizeBinary(t),vn.addByteWidth(t,n),vn.endFixedSizeBinary(t)}},Mr=class wn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new wn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Z),(n||new wn).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return wn.startFixedSizeList(t),wn.addListSize(t,n),wn.endFixedSizeList(t)}};class oe{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Z),(n||new oe).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Tt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Tt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return oe.startFloatingPoint(t),oe.addPrecision(t,n),oe.endFloatingPoint(t)}}class le{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Z),(n||new le).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):se.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,se.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return le.startInterval(t),le.addUnit(t,n),le.endInterval(t)}}let Za=class Zn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Z),(n||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Zn.startLargeBinary(t),Zn.endLargeBinary(t)}},to=class tr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Z),(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return tr.startLargeUtf8(t),tr.endLargeUtf8(t)}},eo=class er{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Z),(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return er.startList(t),er.endList(t)}},Lr=class In{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new In).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Z),(n||new In).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return In.startMap(t),In.addKeysSorted(t,n),In.endMap(t)}},no=class nr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Z),(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return nr.startNull(t),nr.endNull(t)}};class We{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Z),(n||new We).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return We.startStruct_(t),We.endStruct_(t)}}class zt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Z),(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,k.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return zt.startTime(t),zt.addUnit(t,n),zt.addBitWidth(t,r),zt.endTime(t)}}class jt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Z),(n||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,k.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return jt.startTimestamp(t),jt.addUnit(t,n),jt.addTimezone(t,r),jt.endTimestamp(t)}}class Ft{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Z),(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Et.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Et.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return Ft.startUnion(t),Ft.addMode(t,n),Ft.addTypeIds(t,r),Ft.endUnion(t)}}let ro=class rr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Z),(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return rr.startUtf8(t),rr.endUtf8(t)}};var lt;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(lt||(lt={}));let Yt=class _i{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Z),(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):lt.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new ve).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new _i).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,lt.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},ce=class Ae{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Z),(n||new Ae).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):nn.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Yt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,nn.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Ae.startSchema(t),Ae.addEndianness(t,n),Ae.addFields(t,r),Ae.addCustomMetadata(t,i),Ae.addFeatures(t,s),Ae.endSchema(t)}};var X;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(X||(X={}));var f;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(f||(f={}));var we;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(we||(we={}));const Np=void 0;function Un(e){if(e===null)return"null";if(e===Np)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>Un(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function ot(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function io(e,t){return ot(e/t)+ot(e%t)/ot(t)}const Bp=Symbol.for("isArrowBigNum");function Qt(e,...t){return t.length===0?Object.setPrototypeOf(at(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Qt.prototype[Bp]=!0,Qt.prototype.toJSON=function(){return`"${kn(this)}"`},Qt.prototype.valueOf=function(e){return so(this,e)},Qt.prototype.toString=function(){return kn(this)},Qt.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return so(this);case"string":return kn(this);case"default":return Dp(this)}return kn(this)};function sn(...e){return Qt.apply(this,e)}function an(...e){return Qt.apply(this,e)}function Cn(...e){return Qt.apply(this,e)}Object.setPrototypeOf(sn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(an.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Cn.prototype,Object.create(Uint32Array.prototype)),Object.assign(sn.prototype,Qt.prototype,{constructor:sn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(an.prototype,Qt.prototype,{constructor:an,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Cn.prototype,Qt.prototype,{constructor:Cn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Rp=BigInt(4294967296)*BigInt(4294967296),Op=Rp-BigInt(1);function so(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),c=0;if(o){for(const d of a)l|=(d^Op)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*c++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),y=l/d,_=l%d;return ot(y)+ot(_)/ot(d)}return ot(l)}function kn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Ki(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ki(e);t=t.slice();let n=1;for(let r=0;r<t.length;r++){const i=t[r],s=~i+n;t[r]=s,n&=i===0?1:0}return`-${Ki(t)}`}function Dp(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:kn(e)}function Ki(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class Qi{static new(t,n){switch(n){case!0:return new sn(t);case!1:return new an(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new sn(t)}return t.byteLength===16?new Cn(t):new an(t)}static signed(t){return new sn(t)}static unsigned(t){return new an(t)}static decimal(t){return new Cn(t)}constructor(t,n){return Qi.new(t,n)}}var ao,oo,lo,co,uo,ho,fo,po,yo,mo,bo,go,_o,vo,wo,Io,So,Eo,To,Ao,No,Bo;class D{static isNull(t){return(t==null?void 0:t.typeId)===f.Null}static isInt(t){return(t==null?void 0:t.typeId)===f.Int}static isFloat(t){return(t==null?void 0:t.typeId)===f.Float}static isBinary(t){return(t==null?void 0:t.typeId)===f.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===f.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===f.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===f.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===f.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===f.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===f.Date}static isTime(t){return(t==null?void 0:t.typeId)===f.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===f.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===f.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===f.Duration}static isList(t){return(t==null?void 0:t.typeId)===f.List}static isStruct(t){return(t==null?void 0:t.typeId)===f.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===f.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===f.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===f.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===f.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===f.Dictionary}static isDenseUnion(t){return D.isUnion(t)&&t.mode===Et.Dense}static isSparseUnion(t){return D.isUnion(t)&&t.mode===Et.Sparse}constructor(t){this.typeId=t}}ao=Symbol.toStringTag,D[ao]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(D.prototype);class Oe extends D{constructor(){super(f.Null)}toString(){return"Null"}}oo=Symbol.toStringTag,Oe[oo]=(e=>e[Symbol.toStringTag]="Null")(Oe.prototype);class qe extends D{constructor(t,n){super(f.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}lo=Symbol.toStringTag,qe[lo]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(qe.prototype);class $n extends qe{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty($n.prototype,"ArrayType",{value:Int32Array});class xr extends D{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Tt.HALF:return Uint16Array;case Tt.SINGLE:return Float32Array;case Tt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}co=Symbol.toStringTag,xr[co]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(xr.prototype);class Ur extends D{constructor(){super(f.Binary)}toString(){return"Binary"}}uo=Symbol.toStringTag,Ur[uo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Ur.prototype);class Cr extends D{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}}ho=Symbol.toStringTag,Cr[ho]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Cr.prototype);class kr extends D{constructor(){super(f.Utf8)}toString(){return"Utf8"}}fo=Symbol.toStringTag,kr[fo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(kr.prototype);class $r extends D{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}}po=Symbol.toStringTag,$r[po]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))($r.prototype);class Pr extends D{constructor(){super(f.Bool)}toString(){return"Bool"}}yo=Symbol.toStringTag,Pr[yo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Pr.prototype);class Vr extends D{constructor(t,n,r=128){super(f.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}mo=Symbol.toStringTag,Vr[mo]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Vr.prototype);class zr extends D{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Vt[this.unit]}>`}get ArrayType(){return this.unit===Vt.DAY?Int32Array:BigInt64Array}}bo=Symbol.toStringTag,zr[bo]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(zr.prototype);class jr extends D{constructor(t,n){super(f.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}go=Symbol.toStringTag,jr[go]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(jr.prototype);class Yr extends D{constructor(t,n){super(f.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}_o=Symbol.toStringTag,Yr[_o]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Yr.prototype);class Wr extends D{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${se[this.unit]}>`}}vo=Symbol.toStringTag,Wr[vo]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Wr.prototype);class qr extends D{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${k[this.unit]}>`}}wo=Symbol.toStringTag,qr[wo]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(qr.prototype);class Gr extends D{constructor(t){super(f.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}Io=Symbol.toStringTag,Gr[Io]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Gr.prototype);class At extends D{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}So=Symbol.toStringTag,At[So]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(At.prototype);class Hr extends D{constructor(t,n,r){super(f.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}Eo=Symbol.toStringTag,Hr[Eo]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Hr.prototype);class Kr extends D{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}To=Symbol.toStringTag,Kr[To]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Kr.prototype);class Qr extends D{constructor(t,n){super(f.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Ao=Symbol.toStringTag,Qr[Ao]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Qr.prototype);class Xr extends D{constructor(t,n=!1){var r,i,s;if(super(f.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.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<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}No=Symbol.toStringTag,Xr[No]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Xr.prototype);const Fp=(e=>()=>++e)(-1);class on extends D{constructor(t,n,r,i){super(f.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?Fp():ot(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}Bo=Symbol.toStringTag,on[Bo]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(on.prototype);function Ie(e){const t=e;switch(e.typeId){case f.Decimal:return e.bitWidth/32;case f.Interval:return 1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}class q{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return Mp(this,t,n)}getVisitFnByTypeId(t,n=!0){return ln(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function Mp(e,t,n=!0){return typeof t=="number"?ln(e,t,n):typeof t=="string"&&t in f?ln(e,f[t],n):t&&t instanceof D?ln(e,Ro(t),n):t!=null&&t.type&&t.type instanceof D?ln(e,Ro(t.type),n):ln(e,f.NONE,n)}function ln(e,t,n=!0){let r=null;switch(t){case f.Null:r=e.visitNull;break;case f.Bool:r=e.visitBool;break;case f.Int:r=e.visitInt;break;case f.Int8:r=e.visitInt8||e.visitInt;break;case f.Int16:r=e.visitInt16||e.visitInt;break;case f.Int32:r=e.visitInt32||e.visitInt;break;case f.Int64:r=e.visitInt64||e.visitInt;break;case f.Uint8:r=e.visitUint8||e.visitInt;break;case f.Uint16:r=e.visitUint16||e.visitInt;break;case f.Uint32:r=e.visitUint32||e.visitInt;break;case f.Uint64:r=e.visitUint64||e.visitInt;break;case f.Float:r=e.visitFloat;break;case f.Float16:r=e.visitFloat16||e.visitFloat;break;case f.Float32:r=e.visitFloat32||e.visitFloat;break;case f.Float64:r=e.visitFloat64||e.visitFloat;break;case f.Utf8:r=e.visitUtf8;break;case f.LargeUtf8:r=e.visitLargeUtf8;break;case f.Binary:r=e.visitBinary;break;case f.LargeBinary:r=e.visitLargeBinary;break;case f.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case f.Date:r=e.visitDate;break;case f.DateDay:r=e.visitDateDay||e.visitDate;break;case f.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case f.Timestamp:r=e.visitTimestamp;break;case f.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case f.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case f.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case f.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case f.Time:r=e.visitTime;break;case f.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case f.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case f.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case f.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case f.Decimal:r=e.visitDecimal;break;case f.List:r=e.visitList;break;case f.Struct:r=e.visitStruct;break;case f.Union:r=e.visitUnion;break;case f.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case f.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case f.Dictionary:r=e.visitDictionary;break;case f.Interval:r=e.visitInterval;break;case f.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case f.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case f.Duration:r=e.visitDuration;break;case f.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case f.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case f.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case f.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case f.FixedSizeList:r=e.visitFixedSizeList;break;case f.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function Ro(e){switch(e.typeId){case f.Null:return f.Null;case f.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?f.Int8:f.Uint8;case 16:return n?f.Int16:f.Uint16;case 32:return n?f.Int32:f.Uint32;case 64:return n?f.Int64:f.Uint64}return f.Int}case f.Float:switch(e.precision){case Tt.HALF:return f.Float16;case Tt.SINGLE:return f.Float32;case Tt.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(e.unit){case k.SECOND:return f.TimeSecond;case k.MILLISECOND:return f.TimeMillisecond;case k.MICROSECOND:return f.TimeMicrosecond;case k.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(e.unit){case k.SECOND:return f.TimestampSecond;case k.MILLISECOND:return f.TimestampMillisecond;case k.MICROSECOND:return f.TimestampMicrosecond;case k.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(e.unit){case Vt.DAY:return f.DateDay;case Vt.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(e.unit){case se.DAY_TIME:return f.IntervalDayTime;case se.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(e.unit){case k.SECOND:return f.DurationSecond;case k.MILLISECOND:return f.DurationMillisecond;case k.MICROSECOND:return f.DurationMicrosecond;case k.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(e.mode){case Et.Dense:return f.DenseUnion;case Et.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[e.typeId]}'`)}q.prototype.visitInt8=null,q.prototype.visitInt16=null,q.prototype.visitInt32=null,q.prototype.visitInt64=null,q.prototype.visitUint8=null,q.prototype.visitUint16=null,q.prototype.visitUint32=null,q.prototype.visitUint64=null,q.prototype.visitFloat16=null,q.prototype.visitFloat32=null,q.prototype.visitFloat64=null,q.prototype.visitDateDay=null,q.prototype.visitDateMillisecond=null,q.prototype.visitTimestampSecond=null,q.prototype.visitTimestampMillisecond=null,q.prototype.visitTimestampMicrosecond=null,q.prototype.visitTimestampNanosecond=null,q.prototype.visitTimeSecond=null,q.prototype.visitTimeMillisecond=null,q.prototype.visitTimeMicrosecond=null,q.prototype.visitTimeNanosecond=null,q.prototype.visitDenseUnion=null,q.prototype.visitSparseUnion=null,q.prototype.visitIntervalDayTime=null,q.prototype.visitIntervalYearMonth=null,q.prototype.visitDuration=null,q.prototype.visitDurationSecond=null,q.prototype.visitDurationMillisecond=null,q.prototype.visitDurationMicrosecond=null,q.prototype.visitDurationNanosecond=null;const Oo=new Float64Array(1),cn=new Uint32Array(Oo.buffer);function Do(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function Lp(e){if(e!==e)return 32256;Oo[0]=e;const t=(cn[1]&2147483648)>>16&65535;let n=cn[1]&2146435072,r=0;return n>=1089470464?cn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(cn[1]&1048575)>>10):n<=1056964608?(r=1048576+(cn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(cn[1]&1048575)+512>>10),t|n|r&65535}class $ extends q{}function z(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const xp=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Fo=(e,t,n,r)=>{if(n+1<t.length){const i=ot(t[n]),s=ot(t[n+1]);e.set(r.subarray(0,s-i),i)}},Up=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Se=({values:e},t,n)=>{e[t]=n},Xi=({values:e},t,n)=>{e[t]=n},Mo=({values:e},t,n)=>{e[t]=Lp(n)},Cp=(e,t,n)=>{switch(e.type.precision){case Tt.HALF:return Mo(e,t,n);case Tt.SINGLE:case Tt.DOUBLE:return Xi(e,t,n)}},Lo=({values:e},t,n)=>{xp(e,t,n.valueOf())},xo=({values:e},t,n)=>{e[t]=BigInt(n)},kp=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Uo=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,r),Co=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,Vi(r)),$p=(e,t,n)=>{e.type.unit===Vt.DAY?Lo(e,t,n):xo(e,t,n)},ko=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},$o=({values:e},t,n)=>{e[t]=BigInt(n)},Po=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Vo=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Pp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return ko(e,t,n);case k.MILLISECOND:return $o(e,t,n);case k.MICROSECOND:return Po(e,t,n);case k.NANOSECOND:return Vo(e,t,n)}},zo=({values:e},t,n)=>{e[t]=n},jo=({values:e},t,n)=>{e[t]=n},Yo=({values:e},t,n)=>{e[t]=n},Wo=({values:e},t,n)=>{e[t]=n},Vp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return zo(e,t,n);case k.MILLISECOND:return jo(e,t,n);case k.MICROSECOND:return Yo(e,t,n);case k.NANOSECOND:return Wo(e,t,n)}},zp=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},jp=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Wt.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},Yp=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Wt.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const c of l)if(s(r,a,c),++a>=o)break},Wp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),qp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),Gp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),Hp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),Kp=(e,t,n)=>{const r=e.type.children.map(s=>Wt.getVisitFn(s.type)),i=n instanceof Map?Gp(t,n):n instanceof tt?qp(t,n):Array.isArray(n)?Wp(t,n):Hp(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},Qp=(e,t,n)=>{e.type.mode===Et.Dense?qo(e,t,n):Go(e,t,n)},qo=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,e.valueOffsets[t],n)},Go=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,t,n)},Xp=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Jp=(e,t,n)=>{e.type.unit===se.DAY_TIME?Ho(e,t,n):Ko(e,t,n)},Ho=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ko=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Qo=({values:e},t,n)=>{e[t]=n},Xo=({values:e},t,n)=>{e[t]=n},Jo=({values:e},t,n)=>{e[t]=n},Zo=({values:e},t,n)=>{e[t]=n},Zp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return Qo(e,t,n);case k.MILLISECOND:return Xo(e,t,n);case k.MICROSECOND:return Jo(e,t,n);case k.NANOSECOND:return Zo(e,t,n)}},ty=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Wt.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};$.prototype.visitBool=z(Up),$.prototype.visitInt=z(Se),$.prototype.visitInt8=z(Se),$.prototype.visitInt16=z(Se),$.prototype.visitInt32=z(Se),$.prototype.visitInt64=z(Se),$.prototype.visitUint8=z(Se),$.prototype.visitUint16=z(Se),$.prototype.visitUint32=z(Se),$.prototype.visitUint64=z(Se),$.prototype.visitFloat=z(Cp),$.prototype.visitFloat16=z(Mo),$.prototype.visitFloat32=z(Xi),$.prototype.visitFloat64=z(Xi),$.prototype.visitUtf8=z(Co),$.prototype.visitLargeUtf8=z(Co),$.prototype.visitBinary=z(Uo),$.prototype.visitLargeBinary=z(Uo),$.prototype.visitFixedSizeBinary=z(kp),$.prototype.visitDate=z($p),$.prototype.visitDateDay=z(Lo),$.prototype.visitDateMillisecond=z(xo),$.prototype.visitTimestamp=z(Pp),$.prototype.visitTimestampSecond=z(ko),$.prototype.visitTimestampMillisecond=z($o),$.prototype.visitTimestampMicrosecond=z(Po),$.prototype.visitTimestampNanosecond=z(Vo),$.prototype.visitTime=z(Vp),$.prototype.visitTimeSecond=z(zo),$.prototype.visitTimeMillisecond=z(jo),$.prototype.visitTimeMicrosecond=z(Yo),$.prototype.visitTimeNanosecond=z(Wo),$.prototype.visitDecimal=z(zp),$.prototype.visitList=z(jp),$.prototype.visitStruct=z(Kp),$.prototype.visitUnion=z(Qp),$.prototype.visitDenseUnion=z(qo),$.prototype.visitSparseUnion=z(Go),$.prototype.visitDictionary=z(Xp),$.prototype.visitInterval=z(Jp),$.prototype.visitIntervalDayTime=z(Ho),$.prototype.visitIntervalYearMonth=z(Ko),$.prototype.visitDuration=z(Zp),$.prototype.visitDurationSecond=z(Qo),$.prototype.visitDurationMillisecond=z(Xo),$.prototype.visitDurationMicrosecond=z(Jo),$.prototype.visitDurationNanosecond=z(Zo),$.prototype.visitFixedSizeList=z(ty),$.prototype.visitMap=z(Yp);const Wt=new $,Xt=Symbol.for("parent"),un=Symbol.for("rowIndex");class Ji{constructor(t,n){return this[Xt]=t,this[un]=n,new Proxy(this,new ny)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[un],n=this[Xt],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=Mt.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ey(this[Xt],this[un])}}class ey{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Ji.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Xt]:{writable:!0,enumerable:!1,configurable:!1,value:null},[un]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class ny{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Xt].type.children.map(n=>n.name)}has(t,n){return t[Xt].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[Xt].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[Xt].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Mt.visit(t[Xt].children[r],t[un]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[Xt].type.children.findIndex(s=>s.name===n);return i!==-1?(Wt.visit(t[Xt].children[i],t[un],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class L extends q{}function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const ry=(e,t)=>864e5*e[t],iy=(e,t)=>null,tl=(e,t,n)=>{if(n+1>=t.length)return null;const r=ot(t[n]),i=ot(t[n+1]);return e.subarray(r,i)},sy=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},el=({values:e},t)=>ry(e,t),nl=({values:e},t)=>ot(e[t]),De=({stride:e,values:t},n)=>t[e*n],ay=({stride:e,values:t},n)=>Do(t[e*n]),rl=({values:e},t)=>e[t],oy=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),il=({values:e,valueOffsets:t},n)=>tl(e,t,n),sl=({values:e,valueOffsets:t},n)=>{const r=tl(e,t,n);return r!==null?Pi(r):null},ly=({values:e},t)=>e[t],cy=({type:e,values:t},n)=>e.precision!==Tt.HALF?t[n]:Do(t[n]),uy=(e,t)=>e.type.unit===Vt.DAY?el(e,t):nl(e,t),al=({values:e},t)=>1e3*ot(e[t]),ol=({values:e},t)=>ot(e[t]),ll=({values:e},t)=>io(e[t],BigInt(1e3)),cl=({values:e},t)=>io(e[t],BigInt(1e6)),hy=(e,t)=>{switch(e.type.unit){case k.SECOND:return al(e,t);case k.MILLISECOND:return ol(e,t);case k.MICROSECOND:return ll(e,t);case k.NANOSECOND:return cl(e,t)}},ul=({values:e},t)=>e[t],hl=({values:e},t)=>e[t],dl=({values:e},t)=>e[t],fl=({values:e},t)=>e[t],dy=(e,t)=>{switch(e.type.unit){case k.SECOND:return ul(e,t);case k.MILLISECOND:return hl(e,t);case k.MICROSECOND:return dl(e,t);case k.NANOSECOND:return fl(e,t)}},fy=({values:e,stride:t},n)=>Qi.decimal(e.subarray(t*n,t*(n+1))),py=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,o=i[0].slice(s,a-s);return new tt([o])},yy=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new ts(a.slice(i,s-i))},my=(e,t)=>new Ji(e,t),by=(e,t)=>e.type.mode===Et.Dense?pl(e,t):yl(e,t),pl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,e.valueOffsets[t])},yl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,t)},gy=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},_y=(e,t)=>e.type.unit===se.DAY_TIME?ml(e,t):bl(e,t),ml=({values:e},t)=>e.subarray(2*t,2*(t+1)),bl=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},gl=({values:e},t)=>e[t],_l=({values:e},t)=>e[t],vl=({values:e},t)=>e[t],wl=({values:e},t)=>e[t],vy=(e,t)=>{switch(e.type.unit){case k.SECOND:return gl(e,t);case k.MILLISECOND:return _l(e,t);case k.MICROSECOND:return vl(e,t);case k.NANOSECOND:return wl(e,t)}},wy=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new tt([i])};L.prototype.visitNull=P(iy),L.prototype.visitBool=P(sy),L.prototype.visitInt=P(ly),L.prototype.visitInt8=P(De),L.prototype.visitInt16=P(De),L.prototype.visitInt32=P(De),L.prototype.visitInt64=P(rl),L.prototype.visitUint8=P(De),L.prototype.visitUint16=P(De),L.prototype.visitUint32=P(De),L.prototype.visitUint64=P(rl),L.prototype.visitFloat=P(cy),L.prototype.visitFloat16=P(ay),L.prototype.visitFloat32=P(De),L.prototype.visitFloat64=P(De),L.prototype.visitUtf8=P(sl),L.prototype.visitLargeUtf8=P(sl),L.prototype.visitBinary=P(il),L.prototype.visitLargeBinary=P(il),L.prototype.visitFixedSizeBinary=P(oy),L.prototype.visitDate=P(uy),L.prototype.visitDateDay=P(el),L.prototype.visitDateMillisecond=P(nl),L.prototype.visitTimestamp=P(hy),L.prototype.visitTimestampSecond=P(al),L.prototype.visitTimestampMillisecond=P(ol),L.prototype.visitTimestampMicrosecond=P(ll),L.prototype.visitTimestampNanosecond=P(cl),L.prototype.visitTime=P(dy),L.prototype.visitTimeSecond=P(ul),L.prototype.visitTimeMillisecond=P(hl),L.prototype.visitTimeMicrosecond=P(dl),L.prototype.visitTimeNanosecond=P(fl),L.prototype.visitDecimal=P(fy),L.prototype.visitList=P(py),L.prototype.visitStruct=P(my),L.prototype.visitUnion=P(by),L.prototype.visitDenseUnion=P(pl),L.prototype.visitSparseUnion=P(yl),L.prototype.visitDictionary=P(gy),L.prototype.visitInterval=P(_y),L.prototype.visitIntervalDayTime=P(ml),L.prototype.visitIntervalYearMonth=P(bl),L.prototype.visitDuration=P(vy),L.prototype.visitDurationSecond=P(gl),L.prototype.visitDurationMillisecond=P(_l),L.prototype.visitDurationMicrosecond=P(vl),L.prototype.visitDurationNanosecond=P(wl),L.prototype.visitFixedSizeList=P(wy),L.prototype.visitMap=P(yy);const Mt=new L,hn=Symbol.for("keys"),dn=Symbol.for("vals"),fn=Symbol.for("kKeysAsStrings"),Zi=Symbol.for("_kKeysAsStrings");class ts{constructor(t){return this[hn]=new tt([t.children[0]]).memoize(),this[dn]=t.children[1],new Proxy(this,new Sy)}get[fn](){return this[Zi]||(this[Zi]=Array.from(this[hn].toArray(),String))}[Symbol.iterator](){return new Iy(this[hn],this[dn])}get size(){return this[hn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[hn],n=this[dn],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Mt.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Iy{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Mt.visit(this.vals,t)]})}}class Sy{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[fn]}has(t,n){return t[fn].includes(n)}getOwnPropertyDescriptor(t,n){if(t[fn].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[fn].indexOf(n);if(r!==-1){const i=Mt.visit(Reflect.get(t,dn),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[fn].indexOf(n);return i!==-1?(Wt.visit(Reflect.get(t,dn),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(ts.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[hn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[dn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Zi]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Il;function Sl(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(Il=s,s=a,a=Il),a>i&&(a=i),r?r(e,s,a):[s,a]}const es=(e,t)=>e<0?t+e:e,El=e=>e!==e;function pn(e){if(typeof e!="object"||e===null)return El(e)?El:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?wp(e,t):!1:e instanceof Map?Ty(e):Array.isArray(e)?Ey(e):e instanceof tt?Ay(e):Ny(e,!0)}function Ey(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e[n]);return Jr(t)}function Ty(e){let t=-1;const n=[];for(const r of e.values())n[++t]=pn(r);return Jr(n)}function Ay(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e.get(n));return Jr(t)}function Ny(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=pn(e[n[i]]);return Jr(r,n)}function Jr(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return By(e,n);case Map:return Tl(e,n,n.keys());case ts:case Ji:case Object:case void 0:return Tl(e,n,t||Object.keys(n))}return n instanceof tt?Ry(e,n):!1}}function By(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function Ry(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Tl(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),c=r.next(),d=i.next();for(;a<o&&!c.done&&!d.done&&!l.done&&!(c.value!==d.value||!e[a](l.value));++a,c=r.next(),d=i.next(),l=s.next());return a===o&&c.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function Al(e,t,n,r){return(n&1<<r)!==0}function Oy(e,t,n,r){return(n&1<<r)>>r}function Zr(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):ti(new ns(n,e,t,null,Al)).subarray(0,r)),i}return n}function ti(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class ns{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>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 rs(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new ns(e,t,n-t,e,Oy))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return rs(e,t,i)+rs(e,r,n)+Dy(e,i>>3,r-i>>3)}function Dy(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=is(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=is(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=is(s.getUint8(i)),i+=1;return r}function is(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const Fy=-1;class nt{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){const{type:t}=this;return D.isSparseUnion(t)?this.children.some(n=>n.nullable):D.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(D.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=Fy&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-rs(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof nt?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ie(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(D.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Et.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(D.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Et.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,c=1<<l%8,d=l>>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Zr(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const y=s[d];r=(y&c)!==0,s[d]=n?y|c:y&~c}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new nt(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===f.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Zr(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[we.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[we.TYPE])&&(a[we.TYPE]=s.subarray(t,t+n)),(s=a[we.OFFSET])&&(a[we.OFFSET]=s.subarray(t,t+n+1))||(s=a[we.DATA])&&(a[we.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}nt.prototype.children=Object.freeze([]);class Pn extends q{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new nt(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=H(t.nullBitmap),{length:a=i.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=at(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(D.isSparseUnion(n))return new nt(n,r,a,o,[void 0,void 0,void 0,s],i);const l=xn(t.valueOffsets);return new nt(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.indices.ArrayType,t.data),{["dictionary"]:a=new tt([new Pn().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.valueType})}=t,s=H(t.nullBitmap),{["length"]:a=i.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.childType})}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}}const My=new Pn;function G(e){return My.visit(e)}class Nl{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const 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 Ly(e){return e.some(t=>t.nullable)}function Bl(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Rl(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function Ol(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:c}=o;if(l>=r)break;if(n>=l+c)continue;if(l>=n&&l+c<=r){i.push(o);continue}const d=Math.max(0,n-l),y=Math.min(r-l,c);i.push(o.slice(d,y-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function ss(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function as(e,t){return e.getValid(t)}function ei(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return ss(r,this._offsets,n,t)}}function Dl(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=ss(s,this._offsets,r,n);return t=void 0,a}}function Fl(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let c=i-1,d=r.length;++c<d;){const y=r[c];if(~(o=e(y,t,a)))return l+o;a=0,l+=y.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):ss(s,this._offsets,i,n);return t=void 0,a}}class x extends q{}function xy(e,t){return t===null&&e.length>0?0:-1}function Uy(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new ns(n,e.offset+(t||0),e.length,n,Al)){if(!i)return r;++r}return-1}function j(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case f.Union:break;case f.Dictionary:break;default:return Uy(e,n)}const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function Ml(e,t,n){const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}x.prototype.visitNull=xy,x.prototype.visitBool=j,x.prototype.visitInt=j,x.prototype.visitInt8=j,x.prototype.visitInt16=j,x.prototype.visitInt32=j,x.prototype.visitInt64=j,x.prototype.visitUint8=j,x.prototype.visitUint16=j,x.prototype.visitUint32=j,x.prototype.visitUint64=j,x.prototype.visitFloat=j,x.prototype.visitFloat16=j,x.prototype.visitFloat32=j,x.prototype.visitFloat64=j,x.prototype.visitUtf8=j,x.prototype.visitLargeUtf8=j,x.prototype.visitBinary=j,x.prototype.visitLargeBinary=j,x.prototype.visitFixedSizeBinary=j,x.prototype.visitDate=j,x.prototype.visitDateDay=j,x.prototype.visitDateMillisecond=j,x.prototype.visitTimestamp=j,x.prototype.visitTimestampSecond=j,x.prototype.visitTimestampMillisecond=j,x.prototype.visitTimestampMicrosecond=j,x.prototype.visitTimestampNanosecond=j,x.prototype.visitTime=j,x.prototype.visitTimeSecond=j,x.prototype.visitTimeMillisecond=j,x.prototype.visitTimeMicrosecond=j,x.prototype.visitTimeNanosecond=j,x.prototype.visitDecimal=j,x.prototype.visitList=j,x.prototype.visitStruct=j,x.prototype.visitUnion=j,x.prototype.visitDenseUnion=Ml,x.prototype.visitSparseUnion=Ml,x.prototype.visitDictionary=j,x.prototype.visitInterval=j,x.prototype.visitIntervalDayTime=j,x.prototype.visitIntervalYearMonth=j,x.prototype.visitDuration=j,x.prototype.visitDurationSecond=j,x.prototype.visitDurationMillisecond=j,x.prototype.visitDurationMicrosecond=j,x.prototype.visitDurationNanosecond=j,x.prototype.visitFixedSizeList=j,x.prototype.visitMap=j;const ni=new x;class U extends q{}function V(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(D.isInt(t)&&t.bitWidth!==64||D.isTime(t)&&t.bitWidth!==64||D.isFloat(t)&&t.precision!==Tt.HALF))return new Nl(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Nl(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new Cy(s)})}class Cy{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}}U.prototype.visitNull=V,U.prototype.visitBool=V,U.prototype.visitInt=V,U.prototype.visitInt8=V,U.prototype.visitInt16=V,U.prototype.visitInt32=V,U.prototype.visitInt64=V,U.prototype.visitUint8=V,U.prototype.visitUint16=V,U.prototype.visitUint32=V,U.prototype.visitUint64=V,U.prototype.visitFloat=V,U.prototype.visitFloat16=V,U.prototype.visitFloat32=V,U.prototype.visitFloat64=V,U.prototype.visitUtf8=V,U.prototype.visitLargeUtf8=V,U.prototype.visitBinary=V,U.prototype.visitLargeBinary=V,U.prototype.visitFixedSizeBinary=V,U.prototype.visitDate=V,U.prototype.visitDateDay=V,U.prototype.visitDateMillisecond=V,U.prototype.visitTimestamp=V,U.prototype.visitTimestampSecond=V,U.prototype.visitTimestampMillisecond=V,U.prototype.visitTimestampMicrosecond=V,U.prototype.visitTimestampNanosecond=V,U.prototype.visitTime=V,U.prototype.visitTimeSecond=V,U.prototype.visitTimeMillisecond=V,U.prototype.visitTimeMicrosecond=V,U.prototype.visitTimeNanosecond=V,U.prototype.visitDecimal=V,U.prototype.visitList=V,U.prototype.visitStruct=V,U.prototype.visitUnion=V,U.prototype.visitDenseUnion=V,U.prototype.visitSparseUnion=V,U.prototype.visitDictionary=V,U.prototype.visitInterval=V,U.prototype.visitIntervalDayTime=V,U.prototype.visitIntervalYearMonth=V,U.prototype.visitDuration=V,U.prototype.visitDurationSecond=V,U.prototype.visitDurationMillisecond=V,U.prototype.visitDurationMicrosecond=V,U.prototype.visitDurationNanosecond=V,U.prototype.visitFixedSizeList=V,U.prototype.visitMap=V;const os=new U;var Ll;const xl={},Ul={};class tt{constructor(t){var n,r,i;const s=t[0]instanceof tt?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof nt)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:c}=xl[a.typeId],d=s[0];this.isValid=y=>as(d,y),this.get=y=>o(d,y),this.set=(y,_)=>l(d,y,_),this.indexOf=y=>c(d,y),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,Ul[a.typeId]),this._offsets=Rl(s);break}this.data=s,this.type=a,this.stride=Ie(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return Ly(this.data)}get nullCount(){return Bl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(es(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return os.visit(this)}concat(...t){return new tt(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new tt(Sl(this,t,n,({data:r,_offsets:i},s,a)=>Ol(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new tt(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return D.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(D.isDictionary(this.type)){const t=new ri(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new tt(n)}return new ri(this)}unmemoize(){if(D.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new tt(n)}return this}}Ll=Symbol.toStringTag,tt[Ll]=(e=>{e.type=D.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(f).map(n=>f[n]).filter(n=>typeof n=="number"&&n!==f.NONE);for(const n of t){const r=Mt.getVisitFnByTypeId(n),i=Wt.getVisitFnByTypeId(n),s=ni.getVisitFnByTypeId(n);xl[n]={get:r,set:i,indexOf:s},Ul[n]=Object.create(e,{isValid:{value:ei(as)},get:{value:ei(Mt.getVisitFnByTypeId(n))},set:{value:Dl(Wt.getVisitFnByTypeId(n))},indexOf:{value:Fl(ni.getVisitFnByTypeId(n))}})}return"Vector"})(tt.prototype);class ri extends tt{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new ri(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new tt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class ls{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,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,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Ct{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Z),(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yt.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new ce).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new ls).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new ls).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yt.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class et{constructor(t=[],n,r,i=yt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=cs(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new et(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new et(n,this.metadata)}assign(...t){const n=t[0]instanceof et?t[0]:Array.isArray(t[0])?new et(t[0]):new et(t),r=[...this.fields],i=ii(ii(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(c=>c.name===o.name);return~l?(r[l]=o.clone({metadata:ii(ii(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=cs(s,new Map);return new et([...r,...s],i,new Map([...this.dictionaries,...a]))}}et.prototype.fields=null,et.prototype.metadata=null,et.prototype.dictionaries=null;class ut{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new ut(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],ut.new(n,r,i,s)}}ut.prototype.type=null,ut.prototype.name=null,ut.prototype.nullable=null,ut.prototype.metadata=null;function ii(e,t){return new Map([...e||new Map,...t||new Map])}function cs(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(D.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&cs(i.children,t)}return t}var ky=Ha,$y=tn;class Vn{static decode(t){t=new $y(H(t));const n=Ct.getRootAsFooter(t),r=et.decode(n.schema(),new Map,n.version());return new Py(r,n)}static encode(t){const n=new ky,r=et.encode(n,t.schema);Ct.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Fe.encode(n,a);const i=n.endVector();Ct.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Fe.encode(n,a);const s=n.endVector();return Ct.startFooter(n),Ct.addSchema(n,r),Ct.addVersion(n,yt.V5),Ct.addRecordBatches(n,i),Ct.addDictionaries(n,s),Ct.finishFooterBuffer(n,Ct.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=yt.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(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}}class Py extends Vn{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Fe.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Fe.decode(n)}return null}}class Fe{static decode(t){return new Fe(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return ls.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=ot(r),this.bodyLength=ot(n)}}const wt=Object.freeze({done:!0,value:void 0});class Cl{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class us{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class Vy extends us{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(wt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Pt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Pt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Y(this,void 0,void 0,function*(){return yield this.abort(t),wt})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),wt})}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(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((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(wt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class si extends Vy{write(t){if((t=H(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Pi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Pi)}toUint8Array(t=!1){return t?ie(this._values)[0]:Y(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,c=je(this),d;d=yield c.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const y=s;a.push(y),o+=y.byteLength}}catch(y){r={error:y}}finally{try{!l&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}return ie(a,o)[0]})}}class ai{constructor(t){t&&(this.source=new zy(Pt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class yn{constructor(t){t instanceof yn?this.source=t.source:t instanceof si?this.source=new Ge(Pt.fromAsyncIterable(t)):Va(t)?this.source=new Ge(Pt.fromNodeStream(t)):ji(t)?this.source=new Ge(Pt.fromDOMStream(t)):Pa(t)?this.source=new Ge(Pt.fromDOMStream(t.body)):Ln(t)?this.source=new Ge(Pt.fromIterable(t)):Ye(t)?this.source=new Ge(Pt.fromAsyncIterable(t)):Ze(t)&&(this.source=new Ge(Pt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class zy{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,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||wt)}return(t){return Object.create(this.source.return&&this.source.return(t)||wt)}}class Ge{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Y(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Y(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Y(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class kl extends ai{constructor(t,n){super(),this.position=0,this.buffer=H(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class oi extends yn{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Y(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return Y(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 Y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),c=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<c.byteLength;)({bytesRead:o}=yield n.read(c,a,c.byteLength-a,s));return c}return null})}readAt(t,n){return Y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Y(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const jy=65536;function mn(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const bn=8,hs=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class $l{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?jy:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}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`${mn(this.buffer[1])} ${mn(this.buffer[0])}`}}class rt extends $l{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return rt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return rt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new rt(n);for(let s=0;s<r;){const a=bn<r-s?bn:r-s,o=new rt(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new rt(new Uint32Array([hs[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)rt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new rt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new rt(new Uint32Array(t.buffer)).plus(n)}}class qt extends $l{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){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return qt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return qt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new qt(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new qt(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),c=new qt(new Uint32Array([hs[o],0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)qt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new qt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new qt(new Uint32Array(t.buffer)).plus(n)}}class ue{constructor(t){this.buffer=t}high(){return new qt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new qt(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){const n=new rt(new Uint32Array([this.buffer[3],0])),r=new rt(new Uint32Array([this.buffer[2],0])),i=new rt(new Uint32Array([this.buffer[1],0])),s=new rt(new Uint32Array([this.buffer[0],0])),a=new rt(new Uint32Array([t.buffer[3],0])),o=new rt(new Uint32Array([t.buffer[2],0])),l=new rt(new Uint32Array([t.buffer[1],0])),c=new rt(new Uint32Array([t.buffer[0],0]));let d=rt.multiply(s,c);this.buffer[0]=d.low();const y=new rt(new Uint32Array([d.high(),0]));return d=rt.multiply(i,c),y.plus(d),d=rt.multiply(s,l),y.plus(d),this.buffer[1]=y.low(),this.buffer[3]=y.lessThan(d)?1:0,this.buffer[2]=y.high(),new rt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(rt.multiply(r,c)).plus(rt.multiply(i,l)).plus(rt.multiply(s,o)),this.buffer[3]+=rt.multiply(n,c).plus(rt.multiply(r,l)).plus(rt.multiply(i,o)).plus(rt.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${mn(this.buffer[3])} ${mn(this.buffer[2])} ${mn(this.buffer[1])} ${mn(this.buffer[0])}`}static multiply(t,n){return new ue(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new ue(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return ue.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return ue.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new ue(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new ue(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),c=new ue(new Uint32Array([hs[o],0,0,0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)ue.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class Pl extends q{constructor(t,n,r,i,s=yt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof ut?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return G({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<yt.V5&&this.readNullBitmap(t,r),t.mode===Et.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class Yy extends Pl{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):ti(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return D.isTimestamp(t)||(D.isInt(t)||D.isTime(t))&&t.bitWidth===64||D.isDuration(t)||D.isDate(t)&&t.unit===Vt.MILLISECOND?at(Uint8Array,qt.convertArray(r[n])):D.isDecimal(t)?at(Uint8Array,ue.convertArray(r[n])):D.isBinary(t)||D.isLargeBinary(t)||D.isFixedSizeBinary(t)?Wy(r[n]):D.isBool(t)?ti(r[n]):D.isUtf8(t)||D.isLargeUtf8(t)?Vi(r[n].join("")):at(Uint8Array,at(t.ArrayType,r[n].map(i=>+i)))}}function Wy(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class C extends q{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function Nt(e,t){return t instanceof e.constructor}function He(e,t){return e===t||Nt(e,t)}function Ee(e,t){return e===t||Nt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function li(e,t){return e===t||Nt(e,t)&&e.precision===t.precision}function qy(e,t){return e===t||Nt(e,t)&&e.byteWidth===t.byteWidth}function ds(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function zn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function jn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Gy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Hy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function fs(e,t){return e===t||Nt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&Me.compareManyFields(e.children,t.children)}function Ky(e,t){return e===t||Nt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Me.visit(e.indices,t.indices)&&Me.visit(e.dictionary,t.dictionary)}function ps(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Yn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Qy(e,t){return e===t||Nt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Xy(e,t){return e===t||Nt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}C.prototype.visitNull=He,C.prototype.visitBool=He,C.prototype.visitInt=Ee,C.prototype.visitInt8=Ee,C.prototype.visitInt16=Ee,C.prototype.visitInt32=Ee,C.prototype.visitInt64=Ee,C.prototype.visitUint8=Ee,C.prototype.visitUint16=Ee,C.prototype.visitUint32=Ee,C.prototype.visitUint64=Ee,C.prototype.visitFloat=li,C.prototype.visitFloat16=li,C.prototype.visitFloat32=li,C.prototype.visitFloat64=li,C.prototype.visitUtf8=He,C.prototype.visitLargeUtf8=He,C.prototype.visitBinary=He,C.prototype.visitLargeBinary=He,C.prototype.visitFixedSizeBinary=qy,C.prototype.visitDate=ds,C.prototype.visitDateDay=ds,C.prototype.visitDateMillisecond=ds,C.prototype.visitTimestamp=zn,C.prototype.visitTimestampSecond=zn,C.prototype.visitTimestampMillisecond=zn,C.prototype.visitTimestampMicrosecond=zn,C.prototype.visitTimestampNanosecond=zn,C.prototype.visitTime=jn,C.prototype.visitTimeSecond=jn,C.prototype.visitTimeMillisecond=jn,C.prototype.visitTimeMicrosecond=jn,C.prototype.visitTimeNanosecond=jn,C.prototype.visitDecimal=He,C.prototype.visitList=Gy,C.prototype.visitStruct=Hy,C.prototype.visitUnion=fs,C.prototype.visitDenseUnion=fs,C.prototype.visitSparseUnion=fs,C.prototype.visitDictionary=Ky,C.prototype.visitInterval=ps,C.prototype.visitIntervalDayTime=ps,C.prototype.visitIntervalYearMonth=ps,C.prototype.visitDuration=Yn,C.prototype.visitDurationSecond=Yn,C.prototype.visitDurationMillisecond=Yn,C.prototype.visitDurationMicrosecond=Yn,C.prototype.visitDurationNanosecond=Yn,C.prototype.visitFixedSizeList=Qy,C.prototype.visitMap=Xy;const Me=new C;function ys(e,t){return Me.compareSchemas(e,t)}function ms(e,t){return Jy(e,t.map(n=>n.data.concat()))}function Jy(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((y,_)=>Math.max(y,_.length),0)};let s=0,a=0,o=-1;const l=t.length;let c,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=c=t[o].shift(),a=Math.min(a,c?c.length:a);Number.isFinite(a)&&(d=Zy(n,a,d,t,i),a>0&&(r[s++]=G({type:new At(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(y=>new Lt(e,y))]}function Zy(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const c=n[o],d=c==null?void 0:c.length;if(d>=t)d===t?n[o]=c:(n[o]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(c.slice(t,d-t))));else{const y=e[o];e[o]=y.clone({nullable:!0}),n[o]=(s=c==null?void 0:c._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:G({type:y.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var Vl;class Bt{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new et([]),this._offsets=[0],this;let i,s;t[0]instanceof et&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof Lt)return[l];if(l instanceof Bt)return l.batches;if(l instanceof nt){if(l.type instanceof At)return[new Lt(new et(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>a(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>a(c));if(typeof l=="object"){const c=Object.keys(l),d=c.map(v=>new tt([l[v]])),y=i??new et(c.map((v,E)=>new ut(String(v),d[E].type,d[E].nullable))),[,_]=ms(y,d);return _.length===0?[new Lt(l)]:_}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new et([]),!(i instanceof et))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof Lt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!ys(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Rl(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,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Bl(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(es(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?os.visit(new tt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
47
40
|
${this.toArray().join(`,
|
|
48
41
|
`)}
|
|
49
|
-
]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Ft(n,r.map(i=>new kt(n,i)))}slice(t,n){const r=this.schema;[t,n]=oc({length:this.numRows},t,n);const i=fc(this.data,this._offsets,t,n);return new Ft(r,i.map(s=>new kt(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=X({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new st(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new st([X({type:new $e,length:this.numRows})]));const s=r.fields.slice(),o=s[t].clone({type:n.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,n],[r,i]=Fs(r,a)}return new Ft(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Ft(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((a,c,l)=>{const[u,d]=a,y=n.findIndex(m=>m.name===c.name);return~y?d[y]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...n.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...r.map(a=>t.getChildAt(a))].filter(Boolean);return new Ft(...Fs(s,o))}}Ec=Symbol.toStringTag,Ft[Ec]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=pi(Ss),e.get=pi($t.getVisitFn(p.Struct)),e.set=pc(Qt.getVisitFn(p.Struct)),e.indexOf=yc(yi.getVisitFn(p.Struct)),"Table"))(Ft.prototype);var Tc;let kt=class dr{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof ot))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=X({nullCount:0,type:new Dt(this.schema.fields),children:this.schema.fields.map(n=>X({type:n.type,nullCount:0}))})]=t,!(this.data instanceof at))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ac(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((c,l,u)=>(c.children[u]=n[l],c.length=Math.max(c.length,n[l].length),c.fields[u]=pt.new({name:l,type:n[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new ot(r),a=X({type:new Dt(r),length:s,children:i,nullCount:0});[this.schema,this.data]=Ac(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Nc(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 $t.visit(this.data,t)}at(t){return this.get(_s(t,this.numRows))}set(t,n){return Qt.visit(this.data,t,n)}indexOf(t,n){return yi.visit(this.data,t,n)}[Symbol.iterator](){return Es.visit(new st([this.data]))}toArray(){return[...this]}concat(...t){return new Ft(this.schema,[this,...t])}slice(t,n){const[r]=new st([this.data]).slice(t,n).data;return new dr(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new st([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new st([X({type:new $e,length:this.numRows})]));const s=r.fields.slice(),o=i.children.slice(),a=s[t].clone({type:n.type});[s[t],o[t]]=[a,n.data[0]],r=new ot(s,new Map(this.schema.metadata)),i=X({type:new Dt(s),children:o})}return new dr(r,i)}select(t){const n=this.schema.select(t),r=new Dt(n.fields),i=[];for(const s of t){const o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new dr(n,X({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=X({type:new Dt(n.fields),length:this.numRows,children:r});return new dr(n,i)}};Tc=Symbol.toStringTag,kt[Tc]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(kt.prototype);function Ac(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],o=(n+63&-64)>>3;for(const[a,c]of e.fields.entries()){const l=t[a];(!l||l.length!==n)&&(i[a]=c.clone({nullable:!0}),s[a]=(r=l==null?void 0:l._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:X({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),X({type:new Dt(i),length:n,children:s})]}function Nc(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,o=e.length;++s<o;){const{type:a}=e[s],c=t[s];for(const l of[c,...((i=c==null?void 0:c.dictionary)===null||i===void 0?void 0:i.data)||[]])Nc(a.children,l==null?void 0:l.children,n);if(F.isDictionary(a)){const{id:l}=a;if(!n.has(l))c!=null&&c.dictionary&&n.set(l,c.dictionary);else if(n.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class Ms extends kt{constructor(t){const n=t.fields.map(i=>X({type:i.type})),r=X({type:new Dt(t.fields),nullCount:0,children:n});super(t,r)}}let ze=class _e{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new _e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+it),(n||new _e).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):wt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):et.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Et).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,wt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,et.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,o){return _e.startMessage(t),_e.addVersion(t,n),_e.addHeaderType(t,r),_e.addHeader(t,i),_e.addBodyLength(t,s),_e.addCustomMetadata(t,o),_e.endMessage(t)}};class xg extends K{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return Pa.startNull(n),Pa.endNull(n)}visitInt(t,n){return Vt.startInt(n),Vt.addBitWidth(n,t.bitWidth),Vt.addIsSigned(n,t.isSigned),Vt.endInt(n)}visitFloat(t,n){return he.startFloatingPoint(n),he.addPrecision(n,t.precision),he.endFloatingPoint(n)}visitBinary(t,n){return Ua.startBinary(n),Ua.endBinary(n)}visitLargeBinary(t,n){return Ca.startLargeBinary(n),Ca.endLargeBinary(n)}visitBool(t,n){return xa.startBool(n),xa.endBool(n)}visitUtf8(t,n){return Va.startUtf8(n),Va.endUtf8(n)}visitLargeUtf8(t,n){return $a.startLargeUtf8(n),$a.endLargeUtf8(n)}visitDecimal(t,n){return dn.startDecimal(n),dn.addScale(n,t.scale),dn.addPrecision(n,t.precision),dn.addBitWidth(n,t.bitWidth),dn.endDecimal(n)}visitDate(t,n){return Yr.startDate(n),Yr.addUnit(n,t.unit),Yr.endDate(n)}visitTime(t,n){return Wt.startTime(n),Wt.addUnit(n,t.unit),Wt.addBitWidth(n,t.bitWidth),Wt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return Ht.startTimestamp(n),Ht.addUnit(n,t.unit),r!==void 0&&Ht.addTimezone(n,r),Ht.endTimestamp(n)}visitInterval(t,n){return de.startInterval(n),de.addUnit(n,t.unit),de.endInterval(n)}visitDuration(t,n){return jr.startDuration(n),jr.addUnit(n,t.unit),jr.endDuration(n)}visitList(t,n){return ka.startList(n),ka.endList(n)}visitStruct(t,n){return tn.startStruct_(n),tn.endStruct_(n)}visitUnion(t,n){Ct.startTypeIdsVector(n,t.typeIds.length);const r=Ct.createTypeIdsVector(n,t.typeIds);return Ct.startUnion(n),Ct.addMode(n,t.mode),Ct.addTypeIds(n,r),Ct.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return Te.startDictionaryEncoding(n),Te.addId(n,BigInt(t.id)),Te.addIsOrdered(n,t.isOrdered),r!==void 0&&Te.addIndexType(n,r),Te.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return qr.startFixedSizeBinary(n),qr.addByteWidth(n,t.byteWidth),qr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Gr.startFixedSizeList(n),Gr.addListSize(n,t.listSize),Gr.endFixedSizeList(n)}visitMap(t,n){return Wr.startMap(n),Wr.addKeysSorted(n,t.keysSorted),Wr.endMap(n)}}const Us=new xg;function Cg(e,t=new Map){return new ot(kg(e,t),Ii(e.metadata),t)}function Rc(e){return new Yt(e.count,Oc(e.columns),Dc(e.columns))}function $g(e){return new ye(Rc(e.data),e.id,e.isDelta)}function kg(e,t){return(e.fields||[]).filter(Boolean).map(n=>pt.fromJSON(n,t))}function Bc(e,t){return(e.children||[]).filter(Boolean).map(n=>pt.fromJSON(n,t))}function Oc(e){return(e||[]).reduce((t,n)=>[...t,new Ye(n.count,Pg(n.VALIDITY)),...Oc(n.children)],[])}function Dc(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new me(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new me(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new me(t.length,i.OFFSET.length)),i.DATA&&t.push(new me(t.length,i.DATA.length)),t=Dc(i.children,t)}return t}function Pg(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function Vg(e,t){let n,r,i,s,o,a;return!t||!(s=e.dictionary)?(o=Fc(e,Bc(e,t)),i=new pt(e.name,o,e.nullable,Ii(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Lc(r):new Kn,a=new yn(t.get(n),r,n,s.isOrdered),i=new pt(e.name,a,e.nullable,Ii(e.metadata))):(r=(r=s.indexType)?Lc(r):new Kn,t.set(n,o=Fc(e,Bc(e,t))),a=new yn(o,r,n,s.isOrdered),i=new pt(e.name,a,e.nullable,Ii(e.metadata))),i||null}function Ii(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Lc(e){return new en(e.isSigned,e.bitWidth)}function Fc(e,t){const n=e.type.name;switch(n){case"NONE":return new $e;case"null":return new $e;case"binary":return new Kr;case"largebinary":return new Qr;case"utf8":return new Xr;case"largeutf8":return new Jr;case"bool":return new Zr;case"list":return new oi((t||[])[0]);case"struct":return new Dt(t||[]);case"struct_":return new Dt(t||[])}switch(n){case"int":{const r=e.type;return new en(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new Hr(Rt[r.precision])}case"decimal":{const r=e.type;return new ti(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new ei(Gt[r.unit])}case"time":{const r=e.type;return new ni($[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new ri($[r.unit],r.timezone)}case"interval":{const r=e.type;return new ii(ce[r.unit])}case"duration":{const r=e.type;return new si($[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ai(Nt[o],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new li(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new ci(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new ui((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var zg=La,Yg=cn;class Mt{static fromJSON(t,n){const r=new Mt(0,wt.V5,n);return r._createHeader=jg(t,n),r}static decode(t){t=new Yg(J(t));const n=ze.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new Mt(r,i,s);return o._createHeader=qg(n,s),o}static encode(t){const n=new zg;let r=-1;return t.isSchema()?r=ot.encode(n,t.header()):t.isRecordBatch()?r=Yt.encode(n,t.header()):t.isDictionaryBatch()&&(r=ye.encode(n,t.header())),ze.startMessage(n),ze.addVersion(n,wt.V5),ze.addHeader(n,r),ze.addHeaderType(n,t.headerType),ze.addBodyLength(n,BigInt(t.bodyLength)),ze.finishMessageBuffer(n,ze.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof ot)return new Mt(0,wt.V5,et.Schema,t);if(t instanceof Yt)return new Mt(n,wt.V5,et.RecordBatch,t);if(t instanceof ye)return new Mt(n,wt.V5,et.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===et.Schema}isRecordBatch(){return this.headerType===et.RecordBatch}isDictionaryBatch(){return this.headerType===et.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=dt(t)}}class Yt{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=dt(t)}}class ye{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,n,r=!1){this._data=t,this._isDelta=r,this._id=dt(n)}}class me{constructor(t,n){this.offset=dt(t),this.length=dt(n)}}class Ye{constructor(t,n){this.length=dt(t),this.nullCount=dt(n)}}function jg(e,t){return()=>{switch(t){case et.Schema:return ot.fromJSON(e);case et.RecordBatch:return Yt.fromJSON(e);case et.DictionaryBatch:return ye.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${et[t]}, type: ${t} }`)}}function qg(e,t){return()=>{switch(t){case et.Schema:return ot.decode(e.header(new fe),new Map,e.version());case et.RecordBatch:return Yt.decode(e.header(new Ee),e.version());case et.DictionaryBatch:return ye.decode(e.header(new un),e.version())}throw new Error(`Unrecognized Message type: { name: ${et[t]}, type: ${t} }`)}}pt.encode=n_,pt.decode=t_,pt.fromJSON=Vg,ot.encode=e_,ot.decode=Gg,ot.fromJSON=Cg,Yt.encode=r_,Yt.decode=Wg,Yt.fromJSON=Rc,ye.encode=i_,ye.decode=Hg,ye.fromJSON=$g,Ye.encode=s_,Ye.decode=Qg,me.encode=o_,me.decode=Kg;function Gg(e,t=new Map,n=wt.V5){const r=Zg(e,t);return new ot(r,Si(e),t,n)}function Wg(e,t=wt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new Yt(e.length(),Xg(e),Jg(e,t))}function Hg(e,t=wt.V5){return new ye(Yt.decode(e.data(),t),e.id(),e.isDelta())}function Kg(e){return new me(e.offset(),e.length())}function Qg(e){return new Ye(e.length(),e.nullCount())}function Xg(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Ye.decode(n));return t}function Jg(e,t){const n=[];for(let r,i=-1,s=-1,o=e.buffersLength();++i<o;)(r=e.buffers(i))&&(t<wt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=me.decode(r));return n}function Zg(e,t){const n=[];for(let r,i=-1,s=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++s]=pt.decode(r,t));return n}function Mc(e,t){const n=[];for(let r,i=-1,s=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++s]=pt.decode(r,t));return n}function t_(e,t){let n,r,i,s,o,a;return!t||!(a=e.dictionary())?(i=xc(e,Mc(e,t)),r=new pt(e.name(),i,e.nullable(),Si(e))):t.has(n=dt(a.id()))?(s=(s=a.indexType())?Uc(s):new Kn,o=new yn(t.get(n),s,n,a.isOrdered()),r=new pt(e.name(),o,e.nullable(),Si(e))):(s=(s=a.indexType())?Uc(s):new Kn,t.set(n,i=xc(e,Mc(e,t))),o=new yn(i,s,n,a.isOrdered()),r=new pt(e.name(),o,e.nullable(),Si(e))),r||null}function Si(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function Uc(e){return new en(e.isSigned(),e.bitWidth())}function xc(e,t){const n=e.typeType();switch(n){case ft.NONE:return new $e;case ft.Null:return new $e;case ft.Binary:return new Kr;case ft.LargeBinary:return new Qr;case ft.Utf8:return new Xr;case ft.LargeUtf8:return new Jr;case ft.Bool:return new Zr;case ft.List:return new oi((t||[])[0]);case ft.Struct_:return new Dt(t||[])}switch(n){case ft.Int:{const r=e.type(new Vt);return new en(r.isSigned(),r.bitWidth())}case ft.FloatingPoint:{const r=e.type(new he);return new Hr(r.precision())}case ft.Decimal:{const r=e.type(new dn);return new ti(r.scale(),r.precision(),r.bitWidth())}case ft.Date:{const r=e.type(new Yr);return new ei(r.unit())}case ft.Time:{const r=e.type(new Wt);return new ni(r.unit(),r.bitWidth())}case ft.Timestamp:{const r=e.type(new Ht);return new ri(r.unit(),r.timezone())}case ft.Interval:{const r=e.type(new de);return new ii(r.unit())}case ft.Duration:{const r=e.type(new jr);return new si(r.unit())}case ft.Union:{const r=e.type(new Ct);return new ai(r.mode(),r.typeIdsArray()||[],t||[])}case ft.FixedSizeBinary:{const r=e.type(new qr);return new li(r.byteWidth())}case ft.FixedSizeList:{const r=e.type(new Gr);return new ci(r.listSize(),(t||[])[0])}case ft.Map:{const r=e.type(new Wr);return new ui((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${ft[n]}" (${n})`)}function e_(e,t){const n=t.fields.map(s=>pt.encode(e,s));fe.startFieldsVector(e,n.length);const r=fe.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?fe.createCustomMetadataVector(e,[...t.metadata].map(([s,o])=>{const a=e.createString(`${s}`),c=e.createString(`${o}`);return Et.startKeyValue(e),Et.addKey(e,a),Et.addValue(e,c),Et.endKeyValue(e)})):-1;return fe.startSchema(e),fe.addFields(e,r),fe.addEndianness(e,a_?hn.Little:hn.Big),i!==-1&&fe.addCustomMetadata(e,i),fe.endSchema(e)}function n_(e,t){let n=-1,r=-1,i=-1;const s=t.type;let o=t.typeId;F.isDictionary(s)?(o=s.dictionary.typeId,i=Us.visit(s,e),r=Us.visit(s.dictionary,e)):r=Us.visit(s,e);const a=(s.children||[]).map(u=>pt.encode(e,u)),c=Kt.createChildrenVector(e,a),l=t.metadata&&t.metadata.size>0?Kt.createCustomMetadataVector(e,[...t.metadata].map(([u,d])=>{const y=e.createString(`${u}`),m=e.createString(`${d}`);return Et.startKeyValue(e),Et.addKey(e,y),Et.addValue(e,m),Et.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Kt.startField(e),Kt.addType(e,r),Kt.addTypeType(e,o),Kt.addChildren(e,c),Kt.addNullable(e,!!t.nullable),n!==-1&&Kt.addName(e,n),i!==-1&&Kt.addDictionary(e,i),l!==-1&&Kt.addCustomMetadata(e,l),Kt.endField(e)}function r_(e,t){const n=t.nodes||[],r=t.buffers||[];Ee.startNodesVector(e,n.length);for(const o of n.slice().reverse())Ye.encode(e,o);const i=e.endVector();Ee.startBuffersVector(e,r.length);for(const o of r.slice().reverse())me.encode(e,o);const s=e.endVector();return Ee.startRecordBatch(e),Ee.addLength(e,BigInt(t.length)),Ee.addNodes(e,i),Ee.addBuffers(e,s),Ee.endRecordBatch(e)}function i_(e,t){const n=Yt.encode(e,t.data);return un.startDictionaryBatch(e),un.addId(e,BigInt(t.id)),un.addIsDelta(e,t.isDelta),un.addData(e,n),un.endDictionaryBatch(e)}function s_(e,t){return Ma.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function o_(e,t){return Fa.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const a_=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),xs=e=>`Expected ${et[e]} Message in stream, but was null or length 0.`,Cs=e=>`Header pointer of flatbuffer-encoded ${et[e]} Message is null or length 0.`,Cc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,$c=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class kc{constructor(t){this.source=t instanceof bi?t:new bi(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Tt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(xs(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=J(this.source.read(t));if(n.byteLength<t)throw new Error($c(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=et.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Cs(n));return i}readMetadataLength(){const t=this.source.read(Ei),n=t&&new cn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return Tt;if(n.byteLength<t)throw new Error(Cc(t,n.byteLength));return{done:!1,value:Mt.decode(n)}}}class l_{constructor(t,n){this.source=t instanceof Sn?t:Sa(t)?new vi(t,n):new Sn(t)}[Symbol.asyncIterator](){return this}next(){return q(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?Tt:t})}throw(t){return q(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return q(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return q(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(xs(t));return n.value})}readMessageBody(t){return q(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=J(yield this.source.read(t));if(n.byteLength<t)throw new Error($c(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return q(this,arguments,void 0,function*(t=!1){const n=et.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Cs(n));return i})}readMetadataLength(){return q(this,void 0,void 0,function*(){const t=yield this.source.read(Ei),n=t&&new cn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return q(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return Tt;if(n.byteLength<t)throw new Error(Cc(t,n.byteLength));return{done:!1,value:Mt.decode(n)}})}}class c_ extends kc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof vc?t:new vc(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Mt.fromJSON(t.schema,et.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Mt.fromJSON(n,et.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Mt.fromJSON(n,et.RecordBatch)}}return this._body=[],Tt}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(xs(t));return n.value}readSchema(){const t=et.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(Cs(t));return r}}const Ei=4,$s="ARROW1",er=new Uint8Array($s.length);for(let e=0;e<$s.length;e+=1)er[e]=$s.codePointAt(e);function ks(e,t=0){for(let n=-1,r=er.length;++n<r;)if(er[n]!==e[t+n])return!1;return!0}const nr=er.length,Pc=nr+Ei,u_=nr*2+Ei;class Jt extends Ns{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return Ze(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return qt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return qt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Jt?t:ss(t)?p_(t):Sa(t)?g_(t):Ze(t)?q(this,void 0,void 0,function*(){return yield Jt.from(yield t)}):Ea(t)||os(t)||Ta(t)||ln(t)?m_(new Sn(t)):y_(new bi(t))}static readAll(t){return t instanceof Jt?t.isSync()?qc(t):Gc(t):ss(t)||ArrayBuffer.isView(t)||jn(t)||Ia(t)?qc(t):Gc(t)}}class Ti extends Jt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ae(this,arguments,function*(){yield W(yield*xr(Je(this[Symbol.iterator]())))})}}class Ai extends Jt{constructor(t){super(t),this._impl=t}readAll(){return q(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var o=!0,a=Je(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;const l=i;s.push(l)}}catch(l){n={error:l}}finally{try{!o&&!t&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Vc extends Ti{constructor(t){super(t),this._impl=t}}class h_ extends Ai{constructor(t){super(t),this._impl=t}}class zc{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,n){const r=this._loadVectors(t,n,this.schema.fields),i=X({type:new Dt(this.schema.fields),length:t.length,children:r});return new kt(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(r),c=o.dictionaries.get(r),l=this._loadVectors(t.data,n,[c]);return(a&&i?a.concat(new st(l)):new st(l)).memoize()}_loadVectors(t,n,r){return new Sc(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class Ni extends zc{constructor(t,n){super(n),this._reader=ss(t)?new c_(this._handle=t):new kc(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=jc(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):Tt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Tt}next(){if(this.closed)return Tt;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ms(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ri extends zc{constructor(t,n){super(n),this._reader=new l_(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return q(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 q(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=jc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return q(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Tt})}return(t){return q(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Tt})}next(){return q(this,void 0,void 0,function*(){if(this.closed)return Tt;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ms(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return q(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Yc extends Ni{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof wc?t:new wc(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(et.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(et.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,n=t.size-Pc,r=t.readInt32(n),i=t.readAt(n-r,r);return Xn.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class d_ extends Ri{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof vi?t:new vi(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return q(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return q(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(et.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return q(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(et.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return q(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-Pc,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Xn.decode(i)})}_readNextMessageAndValidate(t){return q(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class f_ extends Ni{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new Ag(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function jc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*qc(e){const t=Jt.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Gc(e){return ae(this,arguments,function*(){const t=yield W(Jt.from(e));try{if(!(yield W(t.open({autoDestroy:!1}))).closed)do yield yield W(t);while(!(yield W(t.reset().open())).closed)}finally{yield W(t.cancel())}})}function p_(e){return new Ti(new f_(e))}function y_(e){const t=e.peek(nr+7&-8);return t&&t.byteLength>=4?ks(t)?new Vc(new Yc(e.read())):new Ti(new Ni(e)):new Ti(new Ni(function*(){}()))}function m_(e){return q(this,void 0,void 0,function*(){const t=yield e.peek(nr+7&-8);return t&&t.byteLength>=4?ks(t)?new Vc(new Yc(yield e.read())):new Ai(new Ri(e)):new Ai(new Ri(function(){return ae(this,arguments,function*(){})}()))})}function g_(e){return q(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new vi(e,t);return t>=u_&&ks(yield n.readAt(0,nr+7&-8))?new h_(new d_(n)):new Ai(new Ri(n))})}class _t extends K{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof kt?s.data.children:s.data),r=new _t;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof st)return this.visitMany(t.data),this;const{type:n}=t;if(!F.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(F.isUnion(n))this.nodes.push(new Ye(r,0));else{const{nullCount:i}=t;F.isNull(n)||re.call(this,i<=0?new Uint8Array(0):di(t.offset,r,t.nullBitmap)),this.nodes.push(new Ye(r,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 re(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new me(this._byteLength,t)),this._byteLength+=t,this}function __(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(re.call(this,i),n.mode===Nt.Sparse)return Vs.call(this,e);if(n.mode===Nt.Dense){if(e.offset<=0)return re.call(this,s),Vs.call(this,e);{const o=new Int32Array(r),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<r;)(l=i[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);re.call(this,o),this.visitMany(e.children.map((l,u)=>{const d=n.typeIds[u],y=a[d],m=c[d];return l.slice(y,Math.min(r,m))}))}}return this}function b_(e){let t;return e.nullCount>=e.length?re.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?re.call(this,di(e.offset,e.length,t)):re.call(this,fi(e.values))}function Oe(e){return re.call(this,e.values.subarray(0,e.length*e.stride))}function Bi(e){const{length:t,values:n,valueOffsets:r}=e,i=dt(r[0]),s=dt(r[t]),o=Math.min(s-i,n.byteLength-i);return re.call(this,Ba(-i,t+1,r)),re.call(this,n.subarray(i,i+o)),this}function Ps(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return re.call(this,Ba(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Vs(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}_t.prototype.visitBool=b_,_t.prototype.visitInt=Oe,_t.prototype.visitFloat=Oe,_t.prototype.visitUtf8=Bi,_t.prototype.visitLargeUtf8=Bi,_t.prototype.visitBinary=Bi,_t.prototype.visitLargeBinary=Bi,_t.prototype.visitFixedSizeBinary=Oe,_t.prototype.visitDate=Oe,_t.prototype.visitTimestamp=Oe,_t.prototype.visitTime=Oe,_t.prototype.visitDecimal=Oe,_t.prototype.visitList=Ps,_t.prototype.visitStruct=Vs,_t.prototype.visitUnion=__,_t.prototype.visitInterval=Oe,_t.prototype.visitDuration=Oe,_t.prototype.visitFixedSizeList=Ps,_t.prototype.visitMap=Ps;class Wc extends Ns{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new _i,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,xt(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 Ze(t)?t.then(n=>this.writeAll(n)):ln(t)?qs(this,t):js(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,n=null){return t===this._sink||t instanceof _i?this._sink=t:(this._sink=new _i,t&&Qy(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Xy(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,(!n||!Ls(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Ft&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof kt&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Ls(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof kt?t instanceof Ms||this._writeRecordBatch(t):t instanceof Ft?this.writeAll(t.batches):jn(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Mt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,c=a-s-o;return t.headerType===et.RecordBatch?this._recordBatchBlocks.push(new Pe(a,t.bodyLength,this._position)):t.headerType===et.DictionaryBatch&&this._dictionaryBlocks.push(new Pe(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){const n=J(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Mt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(er)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=_t.assemble(t),o=new Yt(t.numRows,r,i),a=Mt.from(o,n);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=_t.assemble(new st([t])),c=new Yt(t.length,s,o),l=new ye(c,n,r),u=Mt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,o=t.length;++s<o;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const o=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),c=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(const[l,u]of o.entries())this._writeDictionaryBatch(u,i,l>0);else if(c<o.length)for(const l of o.slice(c))this._writeDictionaryBatch(l,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}}class zs extends Wc{static writeAll(t,n){const r=new zs(n);return Ze(t)?t.then(i=>r.writeAll(i)):ln(t)?qs(r,t):js(r,t)}}class Ys extends Wc{static writeAll(t){const n=new Ys;return Ze(t)?t.then(r=>n.writeAll(r)):ln(t)?qs(n,t):js(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Xn.encode(new Xn(t,wt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function js(e,t){let n=t;t instanceof Ft&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function qs(e,t){return q(this,void 0,void 0,function*(){var n,r,i,s,o,a,c;try{for(n=!0,r=Je(t);i=yield r.next(),s=i.done,!s;n=!0){c=i.value,n=!1;const l=c;e.write(l)}}catch(l){o={error:l}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return e.finish()})}function v_(e,t="stream"){return(t==="stream"?zs:Ys).writeAll(e).toUint8Array(!0)}var w_=Object.create,Hc=Object.defineProperty,I_=Object.getOwnPropertyDescriptor,S_=Object.getOwnPropertyNames,E_=Object.getPrototypeOf,T_=Object.prototype.hasOwnProperty,A_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),N_=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S_(t))!T_.call(e,i)&&i!==n&&Hc(e,i,{get:()=>t[i],enumerable:!(r=I_(t,i))||r.enumerable});return e},R_=(e,t,n)=>(n=e!=null?w_(E_(e)):{},N_(!e||!e.__esModule?Hc(n,"default",{value:e,enumerable:!0}):n,e)),B_=A_((e,t)=>{t.exports=Worker}),Kc=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(Kc||{}),Qc=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(Qc||{}),Xc=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(Xc||{}),Jc=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(Jc||{}),Zc=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(Zc||{}),tu=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(tu||{}),O_=class{log(e){}},D_=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function L_(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function F_(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function M_(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function U_(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var eu=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(eu||{}),nu=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Jt.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Ft(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new Gs(this._bindings,this._conn,n),i=await Jt.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new ru(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=v_(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},Gs=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},ru=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Jt.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Ft(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Gs(this.bindings,this.connectionId,t),r=await Jt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},iu=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(iu||{}),su=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(su||{}),Z=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function Oi(e){switch(e.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=e;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:Oi(e.valueType)};case p.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case p.Null:return{sqlType:"null"};case p.Utf8:return{sqlType:"utf8"};case p.Struct:return{sqlType:"struct",fields:e.children.map(t=>Ws(t.name,t.type))};case p.Map:{let t=e;return{sqlType:"map",keyType:Oi(t.keyType),valueType:Oi(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:e.timezone||void 0};case p.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case p.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case p.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case p.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Ws(e,t){let n=Oi(t);return n.name=e,n}var x_=new TextEncoder,C_=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new Z("RESET",null);return await this.postTask(e)}async ping(){let e=new Z("PING",null);await this.postTask(e)}async dropFile(e){let t=new Z("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new Z("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new Z("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new Z("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new Z("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new Z("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new Z("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new Z("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new Z("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new nu(this,e)}async disconnect(e){let t=new Z("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new Z("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new Z("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new Z("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new Z("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new Z("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new Z("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new Z("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new Z("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new Z("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new Z("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new Z("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=x_.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new Z("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new Z("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new Z("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new Z("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new Z("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new Z("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new Z("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new Z("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new Z("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let o=n.columns[s];i.push(Ws(s,o))}n.columnsFlat=i,delete n.columns}let r=new Z("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let o=n.columns[s];i.push(Ws(s,o))}n.columnsFlat=i,delete n.columns}let r=new Z("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function $_(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}$_();var ou=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(ou||{}),k_=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},P_=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),V_=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),z_=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),Y_=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Hs={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},au=Hs.name,lu=Hs.version,Ks=Hs.version.split("."),j_=Ks[0],q_=Ks[1],G_=Ks[2],Qs=()=>typeof navigator>"u",cu=()=>Qs()?"node":navigator.userAgent,W_=()=>cu().includes("Firefox"),H_=()=>/^((?!chrome|android).)*safari/i.test(cu());function K_(){let e="https://cdn.jsdelivr.net/npm/".concat(au,"@").concat(lu,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Xs=null,Js=null,Zs=null,to=null,eo=null;async function uu(){return Xs==null&&(Xs=typeof BigInt64Array<"u"),Js==null&&(Js=await V_()),Zs==null&&(Zs=await Y_()),to==null&&(to=await z_()),eo==null&&(eo=await P_()),{bigInt64Array:Xs,crossOriginIsolated:Qs()||globalThis.crossOriginIsolated||!1,wasmExceptions:Js,wasmSIMD:to,wasmThreads:Zs,wasmBulkMemory:eo}}async function Q_(e){let t=await uu();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var X_=R_(B_());async function J_(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new X_.default(r)}const Z_=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:C_,AsyncDuckDBConnection:nu,AsyncDuckDBDispatcher:k_,AsyncPreparedStatement:ru,AsyncResultStreamIterator:Gs,ConsoleLogger:D_,DuckDBAccessMode:Kc,DuckDBDataProtocol:ou,LogEvent:Zc,LogLevel:Xc,LogOrigin:tu,LogTopic:Jc,PACKAGE_NAME:au,PACKAGE_VERSION:lu,PACKAGE_VERSION_MAJOR:j_,PACKAGE_VERSION_MINOR:q_,PACKAGE_VERSION_PATCH:G_,StatusCode:eu,TokenType:Qc,VoidLogger:O_,WorkerRequestType:iu,WorkerResponseType:su,WorkerTask:Z,createWorker:J_,getJsDelivrBundles:K_,getLogEventLabel:F_,getLogLevelLabel:L_,getLogOriginLabel:U_,getLogTopicLabel:M_,getPlatformFeatures:uu,isFirefox:W_,isNode:Qs,isSafari:H_,selectBundle:Q_},Symbol.toStringTag,{value:"Module"}));async function tb(){var r,i,s,o;const e="@aws-amplify/auth";let t;try{t=await import(e)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:n}=t;return{token:((o=(s=(i=(r=await n())==null?void 0:r.tokens)==null?void 0:i.idToken)==null?void 0:s.toString)==null?void 0:o.call(s))??null,provider:"amplify"}}const hu=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:tb},Symbol.toStringTag,{value:"Module"}));ie.DataExplorer=jy,ie.UMAP=Gy,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})});
|
|
42
|
+
]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Bt(n,r.map(i=>new Lt(n,i)))}slice(t,n){const r=this.schema;[t,n]=Sl({length:this.numRows},t,n);const i=Ol(this.data,this._offsets,t,n);return new Bt(r,i.map(s=>new Lt(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=G({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new tt(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new tt([G({type:new Oe,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,c)=>this.getChildAt(c));[s[t],o[t]]=[a,n],[r,i]=ms(r,o)}return new Bt(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Bt(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,c)=>{const[d,y]=o,_=n.findIndex(v=>v.name===l.name);return~_?y[_]=c:d.push(c),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new Bt(...ms(s,a))}}Vl=Symbol.toStringTag,Bt[Vl]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=ei(as),e.get=ei(Mt.getVisitFn(f.Struct)),e.set=Dl(Wt.getVisitFn(f.Struct)),e.indexOf=Fl(ni.getVisitFn(f.Struct)),"Table"))(Bt.prototype);var zl;let Lt=class ir{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof et))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=G({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(n=>G({type:n.type,nullCount:0}))})]=t,!(this.data instanceof nt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=jl(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,c,d)=>(l.children[d]=n[c],l.length=Math.max(l.length,n[c].length),l.fields[d]=ut.new({name:c,type:n[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new et(r),o=G({type:new At(r),length:s,children:i,nullCount:0});[this.schema,this.data]=jl(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Yl(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 Mt.visit(this.data,t)}at(t){return this.get(es(t,this.numRows))}set(t,n){return Wt.visit(this.data,t,n)}indexOf(t,n){return ni.visit(this.data,t,n)}[Symbol.iterator](){return os.visit(new tt([this.data]))}toArray(){return[...this]}concat(...t){return new Bt(this.schema,[this,...t])}slice(t,n){const[r]=new tt([this.data]).slice(t,n).data;return new ir(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new tt([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new tt([G({type:new Oe,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new et(s,new Map(this.schema.metadata)),i=G({type:new At(s),children:a})}return new ir(r,i)}select(t){const n=this.schema.select(t),r=new At(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new ir(n,G({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=G({type:new At(n.fields),length:this.numRows,children:r});return new ir(n,i)}};zl=Symbol.toStringTag,Lt[zl]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Lt.prototype);function jl(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const c=t[o];(!c||c.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=c==null?void 0:c._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:G({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),G({type:new At(i),length:n,children:s})]}function Yl(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const c of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Yl(o.children,c==null?void 0:c.children,n);if(D.isDictionary(o)){const{id:c}=o;if(!n.has(c))l!=null&&l.dictionary&&n.set(c,l.dictionary);else if(n.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class bs extends Lt{constructor(t){const n=t.fields.map(i=>G({type:i.type})),r=G({type:new At(t.fields),nullCount:0,children:n});super(t,r)}}let Le=class fe{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Z),(n||new fe).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):X.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,X.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return fe.startMessage(t),fe.addVersion(t,n),fe.addHeaderType(t,r),fe.addHeader(t,i),fe.addBodyLength(t,s),fe.addCustomMetadata(t,a),fe.endMessage(t)}};class tm extends q{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return no.startNull(n),no.endNull(n)}visitInt(t,n){return Ut.startInt(n),Ut.addBitWidth(n,t.bitWidth),Ut.addIsSigned(n,t.isSigned),Ut.endInt(n)}visitFloat(t,n){return oe.startFloatingPoint(n),oe.addPrecision(n,t.precision),oe.endFloatingPoint(n)}visitBinary(t,n){return Xa.startBinary(n),Xa.endBinary(n)}visitLargeBinary(t,n){return Za.startLargeBinary(n),Za.endLargeBinary(n)}visitBool(t,n){return Ja.startBool(n),Ja.endBool(n)}visitUtf8(t,n){return ro.startUtf8(n),ro.endUtf8(n)}visitLargeUtf8(t,n){return to.startLargeUtf8(n),to.endLargeUtf8(n)}visitDecimal(t,n){return rn.startDecimal(n),rn.addScale(n,t.scale),rn.addPrecision(n,t.precision),rn.addBitWidth(n,t.bitWidth),rn.endDecimal(n)}visitDate(t,n){return Or.startDate(n),Or.addUnit(n,t.unit),Or.endDate(n)}visitTime(t,n){return zt.startTime(n),zt.addUnit(n,t.unit),zt.addBitWidth(n,t.bitWidth),zt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return jt.startTimestamp(n),jt.addUnit(n,t.unit),r!==void 0&&jt.addTimezone(n,r),jt.endTimestamp(n)}visitInterval(t,n){return le.startInterval(n),le.addUnit(n,t.unit),le.endInterval(n)}visitDuration(t,n){return Dr.startDuration(n),Dr.addUnit(n,t.unit),Dr.endDuration(n)}visitList(t,n){return eo.startList(n),eo.endList(n)}visitStruct(t,n){return We.startStruct_(n),We.endStruct_(n)}visitUnion(t,n){Ft.startTypeIdsVector(n,t.typeIds.length);const r=Ft.createTypeIdsVector(n,t.typeIds);return Ft.startUnion(n),Ft.addMode(n,t.mode),Ft.addTypeIds(n,r),Ft.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return ve.startDictionaryEncoding(n),ve.addId(n,BigInt(t.id)),ve.addIsOrdered(n,t.isOrdered),r!==void 0&&ve.addIndexType(n,r),ve.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return Fr.startFixedSizeBinary(n),Fr.addByteWidth(n,t.byteWidth),Fr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Mr.startFixedSizeList(n),Mr.addListSize(n,t.listSize),Mr.endFixedSizeList(n)}visitMap(t,n){return Lr.startMap(n),Lr.addKeysSorted(n,t.keysSorted),Lr.endMap(n)}}const gs=new tm;function em(e,t=new Map){return new et(rm(e,t),ci(e.metadata),t)}function Wl(e){return new kt(e.count,Gl(e.columns),Hl(e.columns))}function nm(e){return new he(Wl(e.data),e.id,e.isDelta)}function rm(e,t){return(e.fields||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function ql(e,t){return(e.children||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function Gl(e){return(e||[]).reduce((t,n)=>[...t,new xe(n.count,im(n.VALIDITY)),...Gl(n.children)],[])}function Hl(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new de(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new de(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new de(t.length,i.OFFSET.length)),i.DATA&&t.push(new de(t.length,i.DATA.length)),t=Hl(i.children,t)}return t}function im(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function sm(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=Ql(e,ql(e,t)),i=new ut(e.name,a,e.nullable,ci(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Kl(r):new $n,o=new on(t.get(n),r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))):(r=(r=s.indexType)?Kl(r):new $n,t.set(n,a=Ql(e,ql(e,t))),o=new on(a,r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))),i||null}function ci(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Kl(e){return new qe(e.isSigned,e.bitWidth)}function Ql(e,t){const n=e.type.name;switch(n){case"NONE":return new Oe;case"null":return new Oe;case"binary":return new Ur;case"largebinary":return new Cr;case"utf8":return new kr;case"largeutf8":return new $r;case"bool":return new Pr;case"list":return new Gr((t||[])[0]);case"struct":return new At(t||[]);case"struct_":return new At(t||[])}switch(n){case"int":{const r=e.type;return new qe(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new xr(Tt[r.precision])}case"decimal":{const r=e.type;return new Vr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new zr(Vt[r.unit])}case"time":{const r=e.type;return new jr(k[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Yr(k[r.unit],r.timezone)}case"interval":{const r=e.type;return new Wr(se[r.unit])}case"duration":{const r=e.type;return new qr(k[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Hr(Et[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Kr(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Qr(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Xr((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var am=Ha,om=tn;class Rt{static fromJSON(t,n){const r=new Rt(0,yt.V5,n);return r._createHeader=lm(t,n),r}static decode(t){t=new om(H(t));const n=Le.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new Rt(r,i,s);return a._createHeader=cm(n,s),a}static encode(t){const n=new am;let r=-1;return t.isSchema()?r=et.encode(n,t.header()):t.isRecordBatch()?r=kt.encode(n,t.header()):t.isDictionaryBatch()&&(r=he.encode(n,t.header())),Le.startMessage(n),Le.addVersion(n,yt.V5),Le.addHeader(n,r),Le.addHeaderType(n,t.headerType),Le.addBodyLength(n,BigInt(t.bodyLength)),Le.finishMessageBuffer(n,Le.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof et)return new Rt(0,yt.V5,X.Schema,t);if(t instanceof kt)return new Rt(n,yt.V5,X.RecordBatch,t);if(t instanceof he)return new Rt(n,yt.V5,X.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===X.Schema}isRecordBatch(){return this.headerType===X.RecordBatch}isDictionaryBatch(){return this.headerType===X.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ot(t)}}class kt{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=ot(t)}}class he{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,n,r=!1){this._data=t,this._isDelta=r,this._id=ot(n)}}class de{constructor(t,n){this.offset=ot(t),this.length=ot(n)}}class xe{constructor(t,n){this.length=ot(t),this.nullCount=ot(n)}}function lm(e,t){return()=>{switch(t){case X.Schema:return et.fromJSON(e);case X.RecordBatch:return kt.fromJSON(e);case X.DictionaryBatch:return he.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}function cm(e,t){return()=>{switch(t){case X.Schema:return et.decode(e.header(new ce),new Map,e.version());case X.RecordBatch:return kt.decode(e.header(new _e),e.version());case X.DictionaryBatch:return he.decode(e.header(new en),e.version())}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}ut.encode=vm,ut.decode=gm,ut.fromJSON=sm,et.encode=_m,et.decode=um,et.fromJSON=em,kt.encode=wm,kt.decode=hm,kt.fromJSON=Wl,he.encode=Im,he.decode=dm,he.fromJSON=nm,xe.encode=Sm,xe.decode=pm,de.encode=Em,de.decode=fm;function um(e,t=new Map,n=yt.V5){const r=bm(e,t);return new et(r,ui(e),t,n)}function hm(e,t=yt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new kt(e.length(),ym(e),mm(e,t))}function dm(e,t=yt.V5){return new he(kt.decode(e.data(),t),e.id(),e.isDelta())}function fm(e){return new de(e.offset(),e.length())}function pm(e){return new xe(e.length(),e.nullCount())}function ym(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=xe.decode(n));return t}function mm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<yt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=de.decode(r));return n}function bm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=ut.decode(r,t));return n}function Xl(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=ut.decode(r,t));return n}function gm(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=Zl(e,Xl(e,t)),r=new ut(e.name(),i,e.nullable(),ui(e))):t.has(n=ot(o.id()))?(s=(s=o.indexType())?Jl(s):new $n,a=new on(t.get(n),s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))):(s=(s=o.indexType())?Jl(s):new $n,t.set(n,i=Zl(e,Xl(e,t))),a=new on(i,s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))),r||null}function ui(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function Jl(e){return new qe(e.isSigned(),e.bitWidth())}function Zl(e,t){const n=e.typeType();switch(n){case lt.NONE:return new Oe;case lt.Null:return new Oe;case lt.Binary:return new Ur;case lt.LargeBinary:return new Cr;case lt.Utf8:return new kr;case lt.LargeUtf8:return new $r;case lt.Bool:return new Pr;case lt.List:return new Gr((t||[])[0]);case lt.Struct_:return new At(t||[])}switch(n){case lt.Int:{const r=e.type(new Ut);return new qe(r.isSigned(),r.bitWidth())}case lt.FloatingPoint:{const r=e.type(new oe);return new xr(r.precision())}case lt.Decimal:{const r=e.type(new rn);return new Vr(r.scale(),r.precision(),r.bitWidth())}case lt.Date:{const r=e.type(new Or);return new zr(r.unit())}case lt.Time:{const r=e.type(new zt);return new jr(r.unit(),r.bitWidth())}case lt.Timestamp:{const r=e.type(new jt);return new Yr(r.unit(),r.timezone())}case lt.Interval:{const r=e.type(new le);return new Wr(r.unit())}case lt.Duration:{const r=e.type(new Dr);return new qr(r.unit())}case lt.Union:{const r=e.type(new Ft);return new Hr(r.mode(),r.typeIdsArray()||[],t||[])}case lt.FixedSizeBinary:{const r=e.type(new Fr);return new Kr(r.byteWidth())}case lt.FixedSizeList:{const r=e.type(new Mr);return new Qr(r.listSize(),(t||[])[0])}case lt.Map:{const r=e.type(new Lr);return new Xr((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${lt[n]}" (${n})`)}function _m(e,t){const n=t.fields.map(s=>ut.encode(e,s));ce.startFieldsVector(e,n.length);const r=ce.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?ce.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return vt.startKeyValue(e),vt.addKey(e,o),vt.addValue(e,l),vt.endKeyValue(e)})):-1;return ce.startSchema(e),ce.addFields(e,r),ce.addEndianness(e,Tm?nn.Little:nn.Big),i!==-1&&ce.addCustomMetadata(e,i),ce.endSchema(e)}function vm(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;D.isDictionary(s)?(a=s.dictionary.typeId,i=gs.visit(s,e),r=gs.visit(s.dictionary,e)):r=gs.visit(s,e);const o=(s.children||[]).map(d=>ut.encode(e,d)),l=Yt.createChildrenVector(e,o),c=t.metadata&&t.metadata.size>0?Yt.createCustomMetadataVector(e,[...t.metadata].map(([d,y])=>{const _=e.createString(`${d}`),v=e.createString(`${y}`);return vt.startKeyValue(e),vt.addKey(e,_),vt.addValue(e,v),vt.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Yt.startField(e),Yt.addType(e,r),Yt.addTypeType(e,a),Yt.addChildren(e,l),Yt.addNullable(e,!!t.nullable),n!==-1&&Yt.addName(e,n),i!==-1&&Yt.addDictionary(e,i),c!==-1&&Yt.addCustomMetadata(e,c),Yt.endField(e)}function wm(e,t){const n=t.nodes||[],r=t.buffers||[];_e.startNodesVector(e,n.length);for(const a of n.slice().reverse())xe.encode(e,a);const i=e.endVector();_e.startBuffersVector(e,r.length);for(const a of r.slice().reverse())de.encode(e,a);const s=e.endVector();return _e.startRecordBatch(e),_e.addLength(e,BigInt(t.length)),_e.addNodes(e,i),_e.addBuffers(e,s),_e.endRecordBatch(e)}function Im(e,t){const n=kt.encode(e,t.data);return en.startDictionaryBatch(e),en.addId(e,BigInt(t.id)),en.addIsDelta(e,t.isDelta),en.addData(e,n),en.endDictionaryBatch(e)}function Sm(e,t){return Qa.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Em(e,t){return Ka.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Tm=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),_s=e=>`Expected ${X[e]} Message in stream, but was null or length 0.`,vs=e=>`Header pointer of flatbuffer-encoded ${X[e]} Message is null or length 0.`,tc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,ec=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class nc{constructor(t){this.source=t instanceof ai?t:new ai(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?wt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=H(this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=X.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i}readMetadataLength(){const t=this.source.read(hi),n=t&&new tn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}}}class Am{constructor(t,n){this.source=t instanceof yn?t:$a(t)?new oi(t,n):new yn(t)}[Symbol.asyncIterator](){return this}next(){return Y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?wt:t})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Y(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value})}readMessageBody(t){return Y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=H(yield this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Y(this,arguments,void 0,function*(t=!1){const n=X.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(hi),n=t&&new tn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Y(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}})}}class Nm extends nc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Cl?t:new Cl(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Rt.fromJSON(t.schema,X.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Rt.fromJSON(n,X.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Rt.fromJSON(n,X.RecordBatch)}}return this._body=[],wt}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value}readSchema(){const t=X.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(vs(t));return r}}const hi=4,ws="ARROW1",Wn=new Uint8Array(ws.length);for(let e=0;e<ws.length;e+=1)Wn[e]=ws.codePointAt(e);function Is(e,t=0){for(let n=-1,r=Wn.length;++n<r;)if(Wn[n]!==e[t+n])return!1;return!0}const qn=Wn.length,rc=qn+hi,Bm=qn*2+hi;class Gt extends us{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return Ye(n)?n.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 Pt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Pt.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,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Gt?t:zi(t)?Fm(t):$a(t)?xm(t):Ye(t)?Y(this,void 0,void 0,function*(){return yield Gt.from(yield t)}):Pa(t)||ji(t)||Va(t)||Ze(t)?Lm(new yn(t)):Mm(new ai(t))}static readAll(t){return t instanceof Gt?t.isSync()?lc(t):cc(t):zi(t)||ArrayBuffer.isView(t)||Ln(t)||ka(t)?lc(t):cc(t)}}class di extends Gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return re(this,arguments,function*(){yield W(yield*Sr(je(this[Symbol.iterator]())))})}}class fi extends Gt{constructor(t){super(t),this._impl=t}readAll(){return Y(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=je(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const c=i;s.push(c)}}catch(c){n={error:c}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class ic extends di{constructor(t){super(t),this._impl=t}}class Rm extends fi{constructor(t){super(t),this._impl=t}}class sc{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,n){const r=this._loadVectors(t,n,this.schema.fields),i=G({type:new At(this.schema.fields),length:t.length,children:r});return new Lt(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),c=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new tt(c)):new tt(c)).memoize()}_loadVectors(t,n,r){return new Pl(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class pi extends sc{constructor(t,n){super(n),this._reader=zi(t)?new Nm(this._handle=t):new nc(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=oc(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):wt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):wt}next(){if(this.closed)return wt;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bs(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class yi extends sc{constructor(t,n){super(n),this._reader=new Am(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Y(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 Y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):wt})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):wt})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return wt;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bs(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class ac extends pi{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,n){super(t instanceof kl?t:new kl(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(X.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(X.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-rc,r=t.readInt32(n),i=t.readAt(n-r,r);return Vn.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class Om extends yi{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,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof oi?t:new oi(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return Y(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(X.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return Y(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(X.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return Y(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-rc,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Vn.decode(i)})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class Dm extends pi{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new Yy(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function oc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*lc(e){const t=Gt.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function cc(e){return re(this,arguments,function*(){const t=yield W(Gt.from(e));try{if(!(yield W(t.open({autoDestroy:!1}))).closed)do yield yield W(t);while(!(yield W(t.reset().open())).closed)}finally{yield W(t.cancel())}})}function Fm(e){return new di(new Dm(e))}function Mm(e){const t=e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(e.read())):new di(new pi(e)):new di(new pi(function*(){}()))}function Lm(e){return Y(this,void 0,void 0,function*(){const t=yield e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(yield e.read())):new fi(new yi(e)):new fi(new yi(function(){return re(this,arguments,function*(){})}()))})}function xm(e){return Y(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new oi(e,t);return t>=Bm&&Is(yield n.readAt(0,qn+7&-8))?new Rm(new Om(n)):new fi(new yi(n))})}class pt extends q{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Lt?s.data.children:s.data),r=new pt;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof tt)return this.visitMany(t.data),this;const{type:n}=t;if(!D.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(D.isUnion(n))this.nodes.push(new xe(r,0));else{const{nullCount:i}=t;D.isNull(n)||Jt.call(this,i<=0?new Uint8Array(0):Zr(t.offset,r,t.nullBitmap)),this.nodes.push(new xe(r,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 Jt(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new de(this._byteLength,t)),this._byteLength+=t,this}function Um(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(Jt.call(this,i),n.mode===Et.Sparse)return Es.call(this,e);if(n.mode===Et.Dense){if(e.offset<=0)return Jt.call(this,s),Es.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let c,d,y=-1;++y<r;)(c=i[y])!==void 0&&((d=o[c])===void 0&&(d=o[c]=s[y]),a[y]=s[y]-d,l[c]=((t=l[c])!==null&&t!==void 0?t:0)+1);Jt.call(this,a),this.visitMany(e.children.map((c,d)=>{const y=n.typeIds[d],_=o[y],v=l[y];return c.slice(_,Math.min(r,v))}))}}return this}function Cm(e){let t;return e.nullCount>=e.length?Jt.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?Jt.call(this,Zr(e.offset,e.length,t)):Jt.call(this,ti(e.values))}function Te(e){return Jt.call(this,e.values.subarray(0,e.length*e.stride))}function mi(e){const{length:t,values:n,valueOffsets:r}=e,i=ot(r[0]),s=ot(r[t]),a=Math.min(s-i,n.byteLength-i);return Jt.call(this,Wa(-i,t+1,r)),Jt.call(this,n.subarray(i,i+a)),this}function Ss(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return Jt.call(this,Wa(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Es(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}pt.prototype.visitBool=Cm,pt.prototype.visitInt=Te,pt.prototype.visitFloat=Te,pt.prototype.visitUtf8=mi,pt.prototype.visitLargeUtf8=mi,pt.prototype.visitBinary=mi,pt.prototype.visitLargeBinary=mi,pt.prototype.visitFixedSizeBinary=Te,pt.prototype.visitDate=Te,pt.prototype.visitTimestamp=Te,pt.prototype.visitTime=Te,pt.prototype.visitDecimal=Te,pt.prototype.visitList=Ss,pt.prototype.visitStruct=Es,pt.prototype.visitUnion=Um,pt.prototype.visitInterval=Te,pt.prototype.visitDuration=Te,pt.prototype.visitFixedSizeList=Ss,pt.prototype.visitMap=Ss;class uc extends us{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new si,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Dt(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 Ye(t)?t.then(n=>this.writeAll(n)):Ze(t)?Bs(this,t):Ns(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,n=null){return t===this._sink||t instanceof si?this._sink=t:(this._sink=new si,t&&pp(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&yp(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,(!n||!ys(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Bt&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof Lt&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!ys(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof Lt?t instanceof bs||this._writeRecordBatch(t):t instanceof Bt?this.writeAll(t.batches):Ln(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Rt.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===X.RecordBatch?this._recordBatchBlocks.push(new Fe(o,t.bodyLength,this._position)):t.headerType===X.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=H(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Rt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Wn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=pt.assemble(t),a=new kt(t.numRows,r,i),o=Rt.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=pt.assemble(new tt([t])),l=new kt(t.length,s,a),c=new he(l,n,r),d=Rt.from(c,i);return this._writeMessage(d)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[c,d]of a.entries())this._writeDictionaryBatch(d,i,c>0);else if(l<a.length)for(const c of a.slice(l))this._writeDictionaryBatch(c,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class Ts extends uc{static writeAll(t,n){const r=new Ts(n);return Ye(t)?t.then(i=>r.writeAll(i)):Ze(t)?Bs(r,t):Ns(r,t)}}class As extends uc{static writeAll(t){const n=new As;return Ye(t)?t.then(r=>n.writeAll(r)):Ze(t)?Bs(n,t):Ns(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Vn.encode(new Vn(t,yt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Ns(e,t){let n=t;t instanceof Bt&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Bs(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=je(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const c=l;e.write(c)}}catch(c){a={error:c}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function km(e,t="stream"){return(t==="stream"?Ts:As).writeAll(e).toUint8Array(!0)}var $m=Object.create,hc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Vm=Object.getOwnPropertyNames,zm=Object.getPrototypeOf,jm=Object.prototype.hasOwnProperty,Ym=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vm(t))!jm.call(e,i)&&i!==n&&hc(e,i,{get:()=>t[i],enumerable:!(r=Pm(t,i))||r.enumerable});return e},qm=(e,t,n)=>(n=e!=null?$m(zm(e)):{},Wm(!e||!e.__esModule?hc(n,"default",{value:e,enumerable:!0}):n,e)),Gm=Ym((e,t)=>{t.exports=Worker}),dc=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(dc||{}),fc=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(fc||{}),pc=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(pc||{}),yc=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(yc||{}),mc=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(mc||{}),bc=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(bc||{}),Hm=class{log(e){}},Km=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function Qm(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function Xm(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function Jm(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function Zm(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var gc=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(gc||{}),_c=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Gt.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Bt(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new Rs(this._bindings,this._conn,n),i=await Gt.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new vc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=km(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},Rs=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},vc=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Gt.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Rs(this.bindings,this.connectionId,t),r=await Gt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},wc=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(wc||{}),Ic=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(Ic||{}),K=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function bi(e){switch(e.typeId){case f.Binary:return{sqlType:"binary"};case f.Bool:return{sqlType:"bool"};case f.Date:return{sqlType:"date"};case f.DateDay:return{sqlType:"date32[d]"};case f.DateMillisecond:return{sqlType:"date64[ms]"};case f.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case f.Float:return{sqlType:"float"};case f.Float16:return{sqlType:"float16"};case f.Float32:return{sqlType:"float32"};case f.Float64:return{sqlType:"float64"};case f.Int:return{sqlType:"int32"};case f.Int16:return{sqlType:"int16"};case f.Int32:return{sqlType:"int32"};case f.Int64:return{sqlType:"int64"};case f.Uint16:return{sqlType:"uint16"};case f.Uint32:return{sqlType:"uint32"};case f.Uint64:return{sqlType:"uint64"};case f.Uint8:return{sqlType:"uint8"};case f.IntervalDayTime:return{sqlType:"interval[dt]"};case f.IntervalYearMonth:return{sqlType:"interval[m]"};case f.List:return{sqlType:"list",valueType:bi(e.valueType)};case f.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case f.Null:return{sqlType:"null"};case f.Utf8:return{sqlType:"utf8"};case f.Struct:return{sqlType:"struct",fields:e.children.map(t=>Os(t.name,t.type))};case f.Map:{let t=e;return{sqlType:"map",keyType:bi(t.keyType),valueType:bi(t.valueType)}}case f.Time:return{sqlType:"time[s]"};case f.TimeMicrosecond:return{sqlType:"time[us]"};case f.TimeMillisecond:return{sqlType:"time[ms]"};case f.TimeNanosecond:return{sqlType:"time[ns]"};case f.TimeSecond:return{sqlType:"time[s]"};case f.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case f.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case f.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case f.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case f.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Os(e,t){let n=bi(t);return n.name=e,n}var tb=new TextEncoder,eb=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new K("RESET",null);return await this.postTask(e)}async ping(){let e=new K("PING",null);await this.postTask(e)}async dropFile(e){let t=new K("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new K("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new K("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new K("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new K("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new K("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new K("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new K("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new K("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new _c(this,e)}async disconnect(e){let t=new K("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new K("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new K("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new K("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new K("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new K("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new K("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new K("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new K("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new K("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new K("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new K("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=tb.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new K("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new K("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new K("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new K("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new K("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new K("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new K("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new K("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new K("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function nb(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}nb();var Sc=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(Sc||{}),rb=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},ib=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),sb=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),ab=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),ob=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Ds={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},Ec=Ds.name,Tc=Ds.version,Fs=Ds.version.split("."),lb=Fs[0],cb=Fs[1],ub=Fs[2],Ms=()=>typeof navigator>"u",Ac=()=>Ms()?"node":navigator.userAgent,hb=()=>Ac().includes("Firefox"),db=()=>/^((?!chrome|android).)*safari/i.test(Ac());function fb(){let e="https://cdn.jsdelivr.net/npm/".concat(Ec,"@").concat(Tc,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Ls=null,xs=null,Us=null,Cs=null,ks=null;async function Nc(){return Ls==null&&(Ls=typeof BigInt64Array<"u"),xs==null&&(xs=await sb()),Us==null&&(Us=await ob()),Cs==null&&(Cs=await ab()),ks==null&&(ks=await ib()),{bigInt64Array:Ls,crossOriginIsolated:Ms()||globalThis.crossOriginIsolated||!1,wasmExceptions:xs,wasmSIMD:Cs,wasmThreads:Us,wasmBulkMemory:ks}}async function pb(e){let t=await Nc();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var yb=qm(Gm());async function mb(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new yb.default(r)}const bb=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:eb,AsyncDuckDBConnection:_c,AsyncDuckDBDispatcher:rb,AsyncPreparedStatement:vc,AsyncResultStreamIterator:Rs,ConsoleLogger:Km,DuckDBAccessMode:dc,DuckDBDataProtocol:Sc,LogEvent:mc,LogLevel:pc,LogOrigin:bc,LogTopic:yc,PACKAGE_NAME:Ec,PACKAGE_VERSION:Tc,PACKAGE_VERSION_MAJOR:lb,PACKAGE_VERSION_MINOR:cb,PACKAGE_VERSION_PATCH:ub,StatusCode:gc,TokenType:fc,VoidLogger:Hm,WorkerRequestType:wc,WorkerResponseType:Ic,WorkerTask:K,createWorker:mb,getJsDelivrBundles:fb,getLogEventLabel:Xm,getLogLevelLabel:Qm,getLogOriginLabel:Zm,getLogTopicLabel:Jm,getPlatformFeatures:Nc,isFirefox:hb,isNode:Ms,isSafari:db,selectBundle:pb},Symbol.toStringTag,{value:"Module"}));async function gb(){var r,i,s,a;const e="@aws-amplify/auth";let t;try{t=await import(e)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:n}=t;return{token:((a=(s=(i=(r=await n())==null?void 0:r.tokens)==null?void 0:i.idToken)==null?void 0:s.toString)==null?void 0:a.call(s))??null,provider:"amplify"}}const Bc=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:gb},Symbol.toStringTag,{value:"Module"}));te.DataExplorer=lp,te.UMAP=up,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
|