@duckdb/duckdb-wasm 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/duckdb-browser-blocking.cjs +11 -11
- package/dist/duckdb-browser-blocking.cjs.map +3 -3
- package/dist/duckdb-browser-blocking.mjs +11 -11
- package/dist/duckdb-browser-blocking.mjs.map +3 -3
- package/dist/duckdb-browser-coi.pthread.worker.js +1 -1
- package/dist/duckdb-browser-coi.pthread.worker.js.map +1 -1
- package/dist/duckdb-browser-coi.worker.js +1 -1
- package/dist/duckdb-browser-coi.worker.js.map +1 -1
- package/dist/duckdb-browser-mvp.worker.js +8 -8
- package/dist/duckdb-browser-mvp.worker.js.map +3 -3
- package/dist/duckdb-browser.cjs +1 -1
- package/dist/duckdb-browser.mjs +1 -1
- package/dist/duckdb-coi.wasm +0 -0
- package/dist/duckdb-eh.wasm +0 -0
- package/dist/duckdb-mvp.wasm +0 -0
- package/dist/duckdb-node-blocking.cjs +4 -4
- package/dist/duckdb-node-blocking.cjs.map +3 -3
- package/dist/duckdb-node-eh.worker.cjs +4 -4
- package/dist/duckdb-node-eh.worker.cjs.map +3 -3
- package/dist/duckdb-node-mvp.worker.cjs +3 -3
- package/dist/duckdb-node-mvp.worker.cjs.map +3 -3
- package/dist/duckdb-node.cjs +1 -1
- package/dist/img/duckdb_version_badge.svg +1 -1
- package/dist/tests-browser.js +901 -739
- package/dist/tests-browser.js.map +2 -2
- package/dist/tests-node.cjs +900 -738
- package/dist/tests-node.cjs.map +2 -2
- package/package.json +4 -4
|
@@ -10,7 +10,7 @@ return true;`)}function y_(r){return typeof r!="bigint"?je(r):ws?`${je(r)}n`:`"$
|
|
|
10
10
|
]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new Bt(e,n.map(i=>new ft(e,i)))}slice(t,e){let n=this.schema;[t,e]=bi({length:this.numRows},t,e);let i=no(this.data,this._offsets,t,e);return new Bt(n,i.map(s=>new ft(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=P({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new C(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new C([P({type:new ae,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),c=this.schema.fields.map((a,f)=>this.getChildAt(f));[s[t],c[t]]=[o,e],[n,i]=Uo(n,c)}return new Bt(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new Bt(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((c,a,f)=>{let[m,y]=c,b=e.findIndex(I=>I.name===a.name);return~b?y[b]=f:m.push(f),c},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((c,a)=>[a,i[a]]).map(([c,a])=>a===void 0?this.getChildAt(c):t.getChildAt(a)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new Bt(...Uo(s,o))}};xd=Symbol.toStringTag;Bt[xd]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Yr(vi),r.get=Yr(Mt.getVisitFn(h.Struct)),r.set=io(Zt.getVisitFn(h.Struct)),r.indexOf=so(mn.getVisitFn(h.Struct)),r.getByteLength=Yr(Fe.getVisitFn(h.Struct)),"Table"))(Bt.prototype);var Td,ft=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof q))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=P({nullCount:0,type:new pt(this.schema.fields),children:this.schema.fields.map(e=>P({type:e.type,nullCount:0}))})]=t,!(this.data instanceof nt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Fd(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((a,f,m)=>(a.children[m]=e[f],a.length=Math.max(a.length,e[f].length),a.fields[m]=z.new({name:f,type:e[f].type,nullable:!0}),a),{length:0,fields:new Array,children:new Array}),o=new q(n),c=P({type:new pt(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Fd(o,c.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Bd(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)}set(t,e){return Zt.visit(this.data,t,e)}indexOf(t,e){return mn.visit(this.data,t,e)}getByteLength(t){return Fe.visit(this.data,t)}[Symbol.iterator](){return Vn.visit(new C([this.data]))}toArray(){return[...this]}concat(...t){return new Bt(this.schema,[this,...t])}slice(t,e){let[n]=new C([this.data]).slice(t,e).data;return new ft(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new C([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new C([P({type:new ae,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),c=s[t].clone({type:e.type});[s[t],o[t]]=[c,e.data[0]],n=new q(s,new Map(this.schema.metadata)),i=P({type:new pt(s),children:o})}return new ft(n,i)}select(t){let e=this.schema.select(t),n=new pt(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(c=>c.name===s);~o&&(i[o]=this.data.children[o])}return new ft(e,P({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=P({type:new pt(e.fields),length:this.numRows,children:n});return new ft(e,i)}};Td=Symbol.toStringTag;ft[Td]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function Fd(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[c,a]of r.fields.entries()){let f=t[c];(!f||f.length!==e)&&(i[c]=a.clone({nullable:!0}),s[c]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:P({type:a.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),P({type:new pt(i),length:e,children:s})]}function Bd(r,t,e=new Map){for(let n=-1,i=r.length;++n<i;){let o=r[n].type,c=t[n];if(T.isDictionary(o)){if(!e.has(o.id))c.dictionary&&e.set(o.id,c.dictionary);else if(e.get(o.id)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}o.children&&o.children.length>0&&Bd(o.children,c.children,e)}return e}var In=class extends ft{constructor(t){let e=t.fields.map(i=>P({type:i.type})),n=P({type:new pt(t.fields),nullCount:0,children:e});super(t,n)}};var Ji;(function(r){r[r.BUFFER=0]="BUFFER"})(Ji||(Ji={}));var qi;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(qi||(qi={}));var Qe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new Qe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new Qe).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):qi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Ji.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,qi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Ji.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return Qe.startBodyCompression(t),Qe.addCodec(t,e),Qe.addMethod(t,n),Qe.endBodyCompression(t)}};var Kn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}};var Jn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}};var ie=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new ie).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new ie).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new Jn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Kn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new Qe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var Le=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new Le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new Le).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ie).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var qn;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(qn||(qn={}));var Et=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Gr.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):qn.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new mt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,Gr.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,qn.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,t.createLong(0,0))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return Et.startMessage(t),Et.addVersion(t,e),Et.addHeaderType(t,n),Et.addHeader(t,i),Et.addBodyLength(t,s),Et.addCustomMetadata(t,o),Et.endMessage(t)}};var O_=Rt,tc=class extends D{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return hr.startNull(e),hr.endNull(e)}visitInt(t,e){return zt.startInt(e),zt.addBitWidth(e,t.bitWidth),zt.addIsSigned(e,t.isSigned),zt.endInt(e)}visitFloat(t,e){return pe.startFloatingPoint(e),pe.addPrecision(e,t.precision),pe.endFloatingPoint(e)}visitBinary(t,e){return ur.startBinary(e),ur.endBinary(e)}visitBool(t,e){return dr.startBool(e),dr.endBool(e)}visitUtf8(t,e){return mr.startUtf8(e),mr.endUtf8(e)}visitDecimal(t,e){return jt.startDecimal(e),jt.addScale(e,t.scale),jt.addPrecision(e,t.precision),jt.addBitWidth(e,t.bitWidth),jt.endDecimal(e)}visitDate(t,e){return de.startDate(e),de.addUnit(e,t.unit),de.endDate(e)}visitTime(t,e){return ee.startTime(e),ee.addUnit(e,t.unit),ee.addBitWidth(e,t.bitWidth),ee.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return re.startTimestamp(e),re.addUnit(e,t.unit),n!==void 0&&re.addTimezone(e,n),re.endTimestamp(e)}visitInterval(t,e){return me.startInterval(e),me.addUnit(e,t.unit),me.endInterval(e)}visitList(t,e){return fr.startList(e),fr.endList(e)}visitStruct(t,e){return pr.startStruct_(e),pr.endStruct_(e)}visitUnion(t,e){Wt.startTypeIdsVector(e,t.typeIds.length);let n=Wt.createTypeIdsVector(e,t.typeIds);return Wt.startUnion(e),Wt.addMode(e,t.mode),Wt.addTypeIds(e,n),Wt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return Te.startDictionaryEncoding(e),Te.addId(e,new O_(t.id,0)),Te.addIsOrdered(e,t.isOrdered),n!==void 0&&Te.addIndexType(e,n),Te.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return fe.startFixedSizeBinary(e),fe.addByteWidth(e,t.byteWidth),fe.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return he.startFixedSizeList(e),he.addListSize(e,t.listSize),he.endFixedSizeList(e)}visitMap(t,e){return _e.startMap(e),_e.addKeysSorted(e,t.keysSorted),_e.endMap(e)}},ko=new tc;function Md(r,t=new Map){return new q(M_(r,t),No(r.customMetadata),t)}function ec(r){return new Qt(r.count,Ud(r.columns),kd(r.columns))}function Rd(r){return new ve(ec(r.data),r.id,r.isDelta)}function M_(r,t){return(r.fields||[]).filter(Boolean).map(e=>z.fromJSON(e,t))}function Dd(r,t){return(r.children||[]).filter(Boolean).map(e=>z.fromJSON(e,t))}function Ud(r){return(r||[]).reduce((t,e)=>[...t,new tr(e.count,R_(e.VALIDITY)),...Ud(e.children)],[])}function kd(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new we(t.length,i.VALIDITY.length)),i.TYPE&&t.push(new we(t.length,i.TYPE.length)),i.OFFSET&&t.push(new we(t.length,i.OFFSET.length)),i.DATA&&t.push(new we(t.length,i.DATA.length)),t=kd(i.children,t)}return t}function R_(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Nd(r,t){let e,n,i,s,o,c;return!t||!(s=r.dictionary)?(o=Od(r,Dd(r,t)),i=new z(r.name,o,r.nullable,No(r.customMetadata))):t.has(e=s.id)?(n=(n=s.indexType)?Ed(n):new sr,c=new Ae(t.get(e),n,e,s.isOrdered),i=new z(r.name,c,r.nullable,No(r.customMetadata))):(n=(n=s.indexType)?Ed(n):new sr,t.set(e,o=Od(r,Dd(r,t))),c=new Ae(o,n,e,s.isOrdered),i=new z(r.name,c,r.nullable,No(r.customMetadata))),i||null}function No(r){return new Map(Object.entries(r||{}))}function Ed(r){return new Dt(r.isSigned,r.bitWidth)}function Od(r,t){let e=r.type.name;switch(e){case"NONE":return new ae;case"null":return new ae;case"binary":return new Sr;case"utf8":return new Ir;case"bool":return new Ar;case"list":return new Ye((t||[])[0]);case"struct":return new pt(t||[]);case"struct_":return new pt(t||[])}switch(e){case"int":{let n=r.type;return new Dt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new ue(gt[n.precision])}case"decimal":{let n=r.type;return new xr(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Fr(qt[n.unit])}case"time":{let n=r.type;return new $e(G[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Tr(G[n.unit],n.timezone)}case"interval":{let n=r.type;return new Br(oe[n.unit])}case"union":{let n=r.type;return new Xe(xt[n.mode],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Dr(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Ge(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new Ke((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var An=Rt,U_=Mr,k_=ce,kt=class{constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=typeof t=="number"?t:t.low}static fromJSON(t,e){let n=new kt(0,Vt.V4,e);return n._createHeader=N_(t,e),n}static decode(t){t=new k_(N(t));let e=Et.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new kt(n,i,s);return o._createHeader=L_(e,s),o}static encode(t){let e=new U_,n=-1;return t.isSchema()?n=q.encode(e,t.header()):t.isRecordBatch()?n=Qt.encode(e,t.header()):t.isDictionaryBatch()&&(n=ve.encode(e,t.header())),Et.startMessage(e),Et.addVersion(e,Vt.V4),Et.addHeader(e,n),Et.addHeaderType(e,t.headerType),Et.addBodyLength(e,new An(t.bodyLength,0)),Et.finishMessageBuffer(e,Et.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof q)return new kt(0,Vt.V4,rt.Schema,t);if(t instanceof Qt)return new kt(e,Vt.V4,rt.RecordBatch,t);if(t instanceof ve)return new kt(e,Vt.V4,rt.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===rt.Schema}isRecordBatch(){return this.headerType===rt.RecordBatch}isDictionaryBatch(){return this.headerType===rt.DictionaryBatch}},Qt=class{constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=typeof t=="number"?t:t.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}},ve=class{constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=typeof e=="number"?e:e.low}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}},we=class{constructor(t,e){this.offset=typeof t=="number"?t:t.low,this.length=typeof e=="number"?e:e.low}},tr=class{constructor(t,e){this.length=typeof t=="number"?t:t.low,this.nullCount=typeof e=="number"?e:e.low}};function N_(r,t){return()=>{switch(t){case rt.Schema:return q.fromJSON(r);case rt.RecordBatch:return Qt.fromJSON(r);case rt.DictionaryBatch:return ve.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${rt[t]}, type: ${t} }`)}}function L_(r,t){return()=>{switch(t){case rt.Schema:return q.decode(r.header(new Ft));case rt.RecordBatch:return Qt.decode(r.header(new ie),r.version());case rt.DictionaryBatch:return ve.decode(r.header(new Le),r.version())}throw new Error(`Unrecognized Message type: { name: ${rt[t]}, type: ${t} }`)}}z.encode=G_;z.decode=Y_;z.fromJSON=Nd;q.encode=X_;q.decode=C_;q.fromJSON=Md;Qt.encode=K_;Qt.decode=P_;Qt.fromJSON=ec;ve.encode=J_;ve.decode=V_;ve.fromJSON=Rd;tr.encode=q_;tr.decode=z_;we.encode=Z_;we.decode=H_;function C_(r,t=new Map){let e=$_(r,t);return new q(e,Lo(r),t)}function P_(r,t=Vt.V4){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Qt(r.length(),j_(r),W_(r,t))}function V_(r,t=Vt.V4){return new ve(Qt.decode(r.data(),t),r.id(),r.isDelta())}function H_(r){return new we(r.offset(),r.length())}function z_(r){return new tr(r.length(),r.nullCount())}function j_(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=tr.decode(e));return t}function W_(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<Vt.V4&&(n.bb_pos+=8*(i+1)),e[++s]=we.decode(n));return e}function $_(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=z.decode(n,t));return e}function Ld(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=z.decode(n,t));return e}function Y_(r,t){let e,n,i,s,o,c;return!t||!(c=r.dictionary())?(i=Pd(r,Ld(r,t)),n=new z(r.name(),i,r.nullable(),Lo(r))):t.has(e=c.id().low)?(s=(s=c.indexType())?Cd(s):new sr,o=new Ae(t.get(e),s,e,c.isOrdered()),n=new z(r.name(),o,r.nullable(),Lo(r))):(s=(s=c.indexType())?Cd(s):new sr,t.set(e,i=Pd(r,Ld(r,t))),o=new Ae(i,s,e,c.isOrdered()),n=new z(r.name(),o,r.nullable(),Lo(r))),n||null}function Lo(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function Cd(r){return new Dt(r.isSigned(),r.bitWidth())}function Pd(r,t){let e=r.typeType();switch(e){case vt.NONE:return new ae;case vt.Null:return new ae;case vt.Binary:return new Sr;case vt.Utf8:return new Ir;case vt.Bool:return new Ar;case vt.List:return new Ye((t||[])[0]);case vt.Struct_:return new pt(t||[])}switch(e){case vt.Int:{let n=r.type(new zt);return new Dt(n.isSigned(),n.bitWidth())}case vt.FloatingPoint:{let n=r.type(new pe);return new ue(n.precision())}case vt.Decimal:{let n=r.type(new jt);return new xr(n.scale(),n.precision(),n.bitWidth())}case vt.Date:{let n=r.type(new de);return new Fr(n.unit())}case vt.Time:{let n=r.type(new ee);return new $e(n.unit(),n.bitWidth())}case vt.Timestamp:{let n=r.type(new re);return new Tr(n.unit(),n.timezone())}case vt.Interval:{let n=r.type(new me);return new Br(n.unit())}case vt.Union:{let n=r.type(new Wt);return new Xe(n.mode(),n.typeIdsArray()||[],t||[])}case vt.FixedSizeBinary:{let n=r.type(new fe);return new Dr(n.byteWidth())}case vt.FixedSizeList:{let n=r.type(new he);return new Ge(n.listSize(),(t||[])[0])}case vt.Map:{let n=r.type(new _e);return new Ke((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${vt[e]}" (${e})`)}function X_(r,t){let e=t.fields.map(s=>z.encode(r,s));Ft.startFieldsVector(r,e.length);let n=Ft.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?Ft.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let c=r.createString(`${s}`),a=r.createString(`${o}`);return mt.startKeyValue(r),mt.addKey(r,c),mt.addValue(r,a),mt.endKeyValue(r)})):-1;return Ft.startSchema(r),Ft.addFields(r,n),Ft.addEndianness(r,Q_?Kr.Little:Kr.Big),i!==-1&&Ft.addCustomMetadata(r,i),Ft.endSchema(r)}function G_(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;T.isDictionary(s)?(o=s.dictionary.typeId,i=ko.visit(s,r),n=ko.visit(s.dictionary,r)):n=ko.visit(s,r);let c=(s.children||[]).map(m=>z.encode(r,m)),a=Ut.createChildrenVector(r,c),f=t.metadata&&t.metadata.size>0?Ut.createCustomMetadataVector(r,[...t.metadata].map(([m,y])=>{let b=r.createString(`${m}`),I=r.createString(`${y}`);return mt.startKeyValue(r),mt.addKey(r,b),mt.addValue(r,I),mt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Ut.startField(r),Ut.addType(r,n),Ut.addTypeType(r,o),Ut.addChildren(r,a),Ut.addNullable(r,!!t.nullable),e!==-1&&Ut.addName(r,e),i!==-1&&Ut.addDictionary(r,i),f!==-1&&Ut.addCustomMetadata(r,f),Ut.endField(r)}function K_(r,t){let e=t.nodes||[],n=t.buffers||[];ie.startNodesVector(r,e.length);for(let o of e.slice().reverse())tr.encode(r,o);let i=r.endVector();ie.startBuffersVector(r,n.length);for(let o of n.slice().reverse())we.encode(r,o);let s=r.endVector();return ie.startRecordBatch(r),ie.addLength(r,new An(t.length,0)),ie.addNodes(r,i),ie.addBuffers(r,s),ie.endRecordBatch(r)}function J_(r,t){let e=Qt.encode(r,t.data);return Le.startDictionaryBatch(r),Le.addId(r,new An(t.id,0)),Le.addIsDelta(r,t.isDelta),Le.addData(r,e),Le.endDictionaryBatch(r)}function q_(r,t){return Jn.createFieldNode(r,new An(t.length,0),new An(t.nullCount,0))}function Z_(r,t){return Kn.createBuffer(r,new An(t.offset,0),new An(t.length,0))}var Q_=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var nc=r=>`Expected ${rt[r]} Message in stream, but was null or length 0.`,ic=r=>`Header pointer of flatbuffer-encoded ${rt[r]} Message is null or length 0.`,Vd=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Hd=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Zn=class{constructor(t){this.source=t instanceof yr?t:new yr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?_t:t.value===-1&&(t=this.readMetadataLength()).done?_t:(t=this.readMetadata(t.value)).done?_t:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(nc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=N(this.source.read(t));if(e.byteLength<t)throw new Error(Hd(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=rt.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ic(e));return i}readMetadataLength(){let t=this.source.read(Co),e=t&&new ce(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return _t;if(e.byteLength<t)throw new Error(Vd(t,e.byteLength));return{done:!1,value:kt.decode(e)}}},Zi=class{constructor(t,e){this.source=t instanceof ye?t:Is(t)?new qr(t,e):new ye(t)}[Symbol.asyncIterator](){return this}next(){return A(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?_t:t.value===-1&&(t=yield this.readMetadataLength()).done?_t:(t=yield this.readMetadata(t.value)).done?_t:t})}throw(t){return A(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return A(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return A(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(nc(t));return e.value})}readMessageBody(t){return A(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=N(yield this.source.read(t));if(e.byteLength<t)throw new Error(Hd(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return A(this,void 0,void 0,function*(){let e=rt.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ic(e));return i})}readMetadataLength(){return A(this,void 0,void 0,function*(){let t=yield this.source.read(Co),e=t&&new ce(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(t){return A(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return _t;if(e.byteLength<t)throw new Error(Vd(t,e.byteLength));return{done:!1,value:kt.decode(e)}})}},Qi=class extends Zn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Bi?t:new Bi(t)}next(){let{_json:t}=this;if(!this._schema){this._schema=!0;let e=kt.fromJSON(t.schema,rt.Schema);return{done:!1,value:e}}if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];this._body=e.data.columns;let n=kt.fromJSON(e,rt.DictionaryBatch);return{done:!1,value:n}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];this._body=e.columns;let n=kt.fromJSON(e,rt.RecordBatch);return{done:!1,value:n}}return this._body=[],_t}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE&&[s.TYPE]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(nc(t));return e.value}readSchema(){let t=rt.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(ic(t));return n}},Co=4,rc="ARROW1",Qn=new Uint8Array(rc.length);for(let r=0;r<rc.length;r+=1)Qn[r]=rc.codePointAt(r);function Po(r,t=0){for(let e=-1,n=Qn.length;++e<n;)if(Qn[e]!==r[t+e])return!1;return!0}var ti=Qn.length,sc=ti+Co,zd=ti*2+Co;var Ot=class extends yn{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return Ve(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Jt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Jt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Ot?t:vs(t)?ey(t):Is(t)?iy(t):Ve(t)?(()=>A(this,void 0,void 0,function*(){return yield Ot.from(yield t)}))():As(t)||pi(t)||Fs(t)||Me(t)?ny(new ye(t)):ry(new yr(t))}static readAll(t){return t instanceof Ot?t.isSync()?jd(t):Wd(t):vs(t)||ArrayBuffer.isView(t)||He(t)||Ss(t)?jd(t):Wd(t)}},gr=class extends Ot{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return le(this,arguments,function*(){yield $(yield*En(Oe(this[Symbol.iterator]())))})}},Zr=class extends Ot{constructor(t){super(t),this._impl=t}readAll(){var t,e;return A(this,void 0,void 0,function*(){let n=new Array;try{for(var i=Oe(this),s;s=yield i.next(),!s.done;){let o=s.value;n.push(o)}}catch(o){t={error:o}}finally{try{s&&!s.done&&(e=i.return)&&(yield e.call(i))}finally{if(t)throw t.error}}return n})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Qr=class extends gr{constructor(t){super(t),this._impl=t}},ts=class extends Zr{constructor(t){super(t),this._impl=t}},Vo=class{constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=P({type:new pt(this.schema.fields),length:t.length,children:n});return new ft(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,c=s.get(n);if(i||!c){let a=o.dictionaries.get(n),f=this._loadVectors(t.data,e,[a]);return(c&&i?c.concat(new C(f)):new C(f)).memoize()}return c.memoize()}_loadVectors(t,e,n){return new Oi(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}},ei=class extends Vo{constructor(t,e){super(e),this._reader=vs(t)?new Qi(this._handle=t):new Zn(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=$d(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):_t}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):_t}next(){if(this.closed)return _t;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadRecordBatch(n,i);return{done:!1,value:s}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new In(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ri=class extends Vo{constructor(t,e){super(e),this._reader=new Zi(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return A(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 A(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=$d(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return A(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):_t})}return(t){return A(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):_t})}next(){return A(this,void 0,void 0,function*(){if(this.closed)return _t;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadRecordBatch(n,i);return{done:!1,value:s}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new In(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return A(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ho=class extends ei{constructor(t,e){super(t instanceof Di?t:new Di(t),e)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(rt.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(rt.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}}_readFooter(){let{_handle:t}=this,e=t.size-sc,n=t.readInt32(e),i=t.readAt(e-n,n);return Rr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},oc=class extends ri{constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof qr?t:new qr(t,n),i)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return A(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return A(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(rt.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){var e;return A(this,void 0,void 0,function*(){let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(rt.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}})}_readFooter(){return A(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-sc,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Rr.decode(i)})}_readNextMessageAndValidate(t){return A(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},ac=class extends ei{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new fo(e,t.nodes,t.buffers,this.dictionaries).visitMany(n)}};function $d(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*jd(r){let t=Ot.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Wd(r){return le(this,arguments,function*(){let e=yield $(Ot.from(r));try{if(!(yield $(e.open({autoDestroy:!1}))).closed)do yield yield $(e);while(!(yield $(e.reset().open())).closed)}finally{yield $(e.cancel())}})}function ey(r){return new gr(new ac(r))}function ry(r){let t=r.peek(ti+7&-8);return t&&t.byteLength>=4?Po(t)?new Qr(new Ho(r.read())):new gr(new ei(r)):new gr(new ei(function*(){}()))}function ny(r){return A(this,void 0,void 0,function*(){let t=yield r.peek(ti+7&-8);return t&&t.byteLength>=4?Po(t)?new Qr(new Ho(yield r.read())):new Zr(new ri(r)):new Zr(new ri(function(){return le(this,arguments,function*(){})}()))})}function iy(r){return A(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new qr(r,t);return t>=zd&&Po(yield e.readAt(0,ti+7&-8))?new ts(new oc(e)):new Zr(new ri(e))})}var Tt=class extends D{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof ft?s.data.children:s.data),n=new Tt;return n.visitMany(e(t)),n}visit(t){if(t instanceof C)return this.visitMany(t.data),this;let{type:e}=t;if(!T.isDictionary(e)){let{length:n,nullCount:i}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");T.isNull(e)||er.call(this,i<=0?new Uint8Array(0):Pn(t.offset,n,t.nullBitmap)),this.nodes.push(new tr(n,i))}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function er(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new we(this._byteLength,t)),this._byteLength+=t,this}function sy(r){let{type:t,length:e,typeIds:n,valueOffsets:i}=r;if(er.call(this,n),t.mode===xt.Sparse)return cc.call(this,r);if(t.mode===xt.Dense){if(r.offset<=0)return er.call(this,i),cc.call(this,r);{let s=n.reduce((m,y)=>Math.max(m,y),n[0]),o=new Int32Array(s+1),c=new Int32Array(s+1).fill(-1),a=new Int32Array(e),f=mi(-i[0],e,i);for(let m,y,b=-1;++b<e;)(y=c[m=n[b]])===-1&&(y=c[m]=f[m]),a[b]=f[b]-y,++o[m];er.call(this,a);for(let m,y=-1,b=t.children.length;++y<b;)if(m=r.children[y]){let I=t.typeIds[y],J=Math.min(e,o[I]);this.visit(m.slice(c[I],J))}}}return this}function oy(r){let t;return r.nullCount>=r.length?er.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?er.call(this,Pn(r.offset,r.length,t)):er.call(this,hn(r.values))}function tn(r){return er.call(this,r.values.subarray(0,r.length*r.stride))}function Yd(r){let{length:t,values:e,valueOffsets:n}=r,i=n[0],s=n[t],o=Math.min(s-i,e.byteLength-i);return er.call(this,mi(-n[0],t,n)),er.call(this,e.subarray(i,i+o)),this}function lc(r){let{length:t,valueOffsets:e}=r;return e&&er.call(this,mi(e[0],t,e)),this.visit(r.children[0])}function cc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Tt.prototype.visitBool=oy;Tt.prototype.visitInt=tn;Tt.prototype.visitFloat=tn;Tt.prototype.visitUtf8=Yd;Tt.prototype.visitBinary=Yd;Tt.prototype.visitFixedSizeBinary=tn;Tt.prototype.visitDate=tn;Tt.prototype.visitTimestamp=tn;Tt.prototype.visitTime=tn;Tt.prototype.visitDecimal=tn;Tt.prototype.visitList=lc;Tt.prototype.visitStruct=cc;Tt.prototype.visitUnion=sy;Tt.prototype.visitInterval=tn;Tt.prototype.visitFixedSizeList=lc;Tt.prototype.visitMap=lc;var xn=class extends yn{constructor(t){super(),this._position=0,this._started=!1,this._sink=new _r,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,se(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Ve(t)?t.then(e=>this.writeAll(e)):Me(t)?dc(this,t):uc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof _r?this._sink=t:(this._sink=new _r,t&&_u(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&yu(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!e||!Sn(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Bt&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ft&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Sn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof In||this._writeRecordBatch(t):t instanceof Bt?this.writeAll(t.batches):He(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=kt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,c=s+o+n&~n,a=c-s-o;return t.headerType===rt.RecordBatch?this._recordBatchBlocks.push(new Ze(c,t.bodyLength,this._position)):t.headerType===rt.DictionaryBatch&&this._dictionaryBlocks.push(new Ze(c,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(c-o)),s>0&&this._write(i),this._writePadding(a)}_write(t){if(this._started){let e=N(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(kt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Qn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=Tt.assemble(t),o=new Qt(t.numRows,n,i),c=kt.from(o,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));let{byteLength:i,nodes:s,bufferRegions:o,buffers:c}=Tt.assemble(new C([t])),a=new Qt(t.length,s,o),f=new ve(a,e,n),m=kt.from(f,i);return this._writeMessage(m)._writeBodyBuffers(c)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let i=this._dictionaryDeltaOffsets.get(e)||0;if(i===0||(n=n==null?void 0:n.slice(i)).length>0)for(let s of n.data)this._writeDictionaryBatch(s,e,i>0),i+=s.length}return this}},Cr=class extends xn{static writeAll(t,e){let n=new Cr(e);return Ve(t)?t.then(i=>n.writeAll(i)):Me(t)?dc(n,t):uc(n,t)}},Pr=class extends xn{static writeAll(t){let e=new Pr;return Ve(t)?t.then(n=>e.writeAll(n)):Me(t)?dc(e,t):uc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=Rr.encode(new Rr(t,Vt.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function uc(r,t){let e=t;t instanceof Bt&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function dc(r,t){var e,n,i,s;return A(this,void 0,void 0,function*(){try{for(e=Oe(t);n=yield e.next(),!n.done;){let o=n.value;r.write(o)}}catch(o){i={error:o}}finally{try{n&&!n.done&&(s=e.return)&&(yield s.call(e))}finally{if(i)throw i.error}}return r.finish()})}function Xd(r,t){if(Me(r))return cy(r,t);if(He(r))return ay(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function ay(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){((e==null?void 0:e.return)&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,c){let a,f=null,m=o.desiredSize||null;for(;!(f=c.next(n?m:null)).done;)if(ArrayBuffer.isView(f.value)&&(a=N(f.value))&&(m!=null&&n&&(m=m-a.byteLength+1),f.value=a),o.enqueue(f.value),m!=null&&--m<=0)return;o.close()}}function cy(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return A(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return A(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return A(this,void 0,void 0,function*(){((e==null?void 0:e.return)&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,c){return A(this,void 0,void 0,function*(){let a,f=null,m=o.desiredSize||null;for(;!(f=yield c.next(n?m:null)).done;)if(ArrayBuffer.isView(f.value)&&(a=N(f.value))&&(m!=null&&n&&(m=m-a.byteLength+1),f.value=a),o.enqueue(f.value),m!=null&&--m<=0)return;o.close()})}}function Jd(r){return new fc(r)}var fc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=pu(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=gn(s),this._getSize=i!=="bytes"?Gd:Kd;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:c=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:a=>{this._maybeFlush(this._builder,this._controller=a)},start:a=>{this._maybeFlush(this._builder,this._controller=a)}},{highWaterMark:o,size:i!=="bytes"?Gd:Kd}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:c,size:a=>this._writeValueAndReturnChunkSize(a)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Gd=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Kd=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function zo(r,t){let e=new _r,n=null,i=new ReadableStream({cancel(){return A(this,void 0,void 0,function*(){yield e.close()})},start(c){return A(this,void 0,void 0,function*(){yield o(c,n||(n=yield s()))})},pull(c){return A(this,void 0,void 0,function*(){n?yield o(c,n):c.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return A(this,void 0,void 0,function*(){return yield(yield Ot.from(e)).open(t)})}function o(c,a){return A(this,void 0,void 0,function*(){let f=c.desiredSize,m=null;for(;!(m=yield a.next()).done;)if(c.enqueue(m.value),f!=null&&--f<=0)return;c.close()})}}function jo(r,t){let e=new this(r),n=new ye(e),i=new ReadableStream({cancel(){return A(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return A(this,void 0,void 0,function*(){yield s(o)})},start(o){return A(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return A(this,void 0,void 0,function*(){let c=null,a=o.desiredSize;for(;c=yield n.read(a||null);)if(o.enqueue(c),a!=null&&(a-=c.byteLength)<=0)return;o.close()})}}function Wo(r,t="stream"){return(t==="stream"?Cr:Pr).writeAll(r).toUint8Array(!0)}var fy=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},xa),Ka),Ha),Fa),va),Va),{compareSchemas:Sn,compareFields:Id,compareTypes:Ad});Jt.toDOMStream=Xd;wt.throughDOM=Jd;Ot.throughDOM=zo;Qr.throughDOM=zo;gr.throughDOM=zo;xn.throughDOM=jo;Pr.throughDOM=jo;Cr.throughDOM=jo;function ni(r){switch(r.typeId){case h.Binary:return{sqlType:"binary"};case h.Bool:return{sqlType:"bool"};case h.Date:return{sqlType:"date"};case h.DateDay:return{sqlType:"date32[d]"};case h.DateMillisecond:return{sqlType:"date64[ms]"};case h.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case h.Float:return{sqlType:"float"};case h.Float16:return{sqlType:"float16"};case h.Float32:return{sqlType:"float32"};case h.Float64:return{sqlType:"float64"};case h.Int:return{sqlType:"int32"};case h.Int16:return{sqlType:"int16"};case h.Int32:return{sqlType:"int32"};case h.Int64:return{sqlType:"int64"};case h.Uint16:return{sqlType:"uint16"};case h.Uint32:return{sqlType:"uint32"};case h.Uint64:return{sqlType:"uint64"};case h.Uint8:return{sqlType:"uint8"};case h.IntervalDayTime:return{sqlType:"interval[dt]"};case h.IntervalYearMonth:return{sqlType:"interval[m]"};case h.List:return{sqlType:"list",valueType:ni(r.valueType)};case h.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case h.Null:return{sqlType:"null"};case h.Utf8:return{sqlType:"utf8"};case h.Struct:return{sqlType:"struct",fields:r.children.map(e=>$o(e.name,e.type))};case h.Map:{let t=r;return{sqlType:"map",keyType:ni(t.keyType),valueType:ni(t.valueType)}}case h.Time:return{sqlType:"time[s]"};case h.TimeMicrosecond:return{sqlType:"time[us]"};case h.TimeMillisecond:return{sqlType:"time[ms]"};case h.TimeNanosecond:return{sqlType:"time[ns]"};case h.TimeSecond:return{sqlType:"time[s]"};case h.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case h.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case h.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case h.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case h.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error(`unsupported arrow type: ${r.toString()}`)}function $o(r,t){let e=ni(t);return e.name=r,e}var Yo=class{constructor(){this._bindings=null;this._nextMessageId=0}log(t){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:t},[])}sendOK(t){this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"OK",data:null},[])}failWith(t,e){let n={name:e.name,message:e.message,stack:e.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"ERROR",data:n},[])}async onMessage(t){switch(t.type){case"PING":this.sendOK(t);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(t,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(t.data[0],t.data[1],e=>{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"INSTANTIATE_PROGRESS",data:e},[])}),this.sendOK(t)}catch(e){this._bindings=null,this.failWith(t,e)}return;default:break}if(!this._bindings)return this.failWith(t,new Error("duckdb is not initialized"));try{switch(t.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(t);break;case"OPEN":this._bindings.open(t.data),this.sendOK(t);break;case"DROP_FILE":this._bindings.dropFile(t.data),this.sendOK(t);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(t);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(t);break;case"CONNECT":{let e=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"CONNECTION_INFO",data:e.useUnsafe((n,i)=>i)},[]);break}case"DISCONNECT":this._bindings.disconnect(t.data),this.sendOK(t);break;case"CREATE_PREPARED":{let e=this._bindings.createPrepared(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"PREPARED_STATEMENT_ID",data:e},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(t.data[0],t.data[1]),this.sendOK(t);break}case"RUN_PREPARED":{let e=this._bindings.runPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"RUN_QUERY":{let e=this._bindings.runQuery(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"SEND_PREPARED":{let e=this._bindings.sendPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER",data:e},[e.buffer]);break}case"START_PENDING_QUERY":{let e=this._bindings.startPendingQuery(t.data[0],t.data[1]),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"POLL_PENDING_QUERY":{let e=this._bindings.pollPendingQuery(t.data),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"CANCEL_PENDING_QUERY":{let e=this._bindings.cancelPendingQuery(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SUCCESS",data:e},[]);break}case"FETCH_QUERY_RESULTS":{let e=this._bindings.fetchQueryResults(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_CHUNK",data:e},[e.buffer]);break}case"GET_TABLE_NAMES":{let e=this._bindings.getTableNames(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"TABLE_NAMES",data:e},[]);break}case"GLOB_FILE_INFOS":{let e=this._bindings.globFiles(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_INFOS",data:e},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_FILE_HANDLE":this._bindings.registerFileHandle(t.data[0],t.data[1]),this.sendOK(t);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(t.data[0],t.data[1]),this.sendOK(t);break;case"COPY_FILE_TO_BUFFER":{let e=this._bindings.copyFileToBuffer(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_BUFFER",data:e},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(t.data[0],t.data[1]),this.sendOK(t);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(t.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"TOKENIZE":{let e=this._bindings.tokenize(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SCRIPT_TOKENS",data:e},[]);break}}}catch(e){return this.failWith(t,e)}}};var pc={},hy=(()=>{var r=pc.url;return function(t){t=t||{};function e(){return It.buffer!=Se&&Vr(It.buffer),Tc}function n(){return It.buffer!=Se&&Vr(It.buffer),Bc}function i(){return It.buffer!=Se&&Vr(It.buffer),Dc}function s(){return It.buffer!=Se&&Vr(It.buffer),Ec}function o(){return It.buffer!=Se&&Vr(It.buffer),Oc}function c(){return It.buffer!=Se&&Vr(It.buffer),Mc}var a=typeof t<"u"?t:{},f,m;a.ready=new Promise(function(l,u){f=l,m=u});var y=Object.assign({},a),b=[],I="./this.program",J=(l,u)=>{throw u},Z=typeof window=="object",ct=typeof importScripts=="function",st=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",x=a.ENVIRONMENT_IS_PTHREAD||!1,St="";function Tn(l){return a.locateFile?a.locateFile(l,St):St+l}var sn,es,on,ii;function Q(l){if(l instanceof ui)return;dt("exiting due to exception: "+l)}var Nt,te,Yt;if(st){ct?St=hc().dirname(St)+"/":St=__dirname+"/",Yt=()=>{te||(Nt=Zd(),te=hc())},sn=function(d,p){return Yt(),d=te.normalize(d),Nt.readFileSync(d,p?void 0:"utf8")},on=u=>{var d=sn(u,!0);return d.buffer||(d=new Uint8Array(d)),d},es=(u,d,p)=>{Yt(),u=te.normalize(u),Nt.readFile(u,function(_,S){_?p(_):d(S.buffer)})},process.argv.length>1&&(I=process.argv[1].replace(/\\/g,"/")),b=process.argv.slice(2),process.on("uncaughtException",function(u){if(!(u instanceof ui))throw u}),process.on("unhandledRejection",function(u){throw u}),J=(u,d)=>{if(ra())throw process.exitCode=u,d;Q(d),process.exit(u)},a.inspect=function(){return"[Emscripten Module object]"};let l;try{l=Qd()}catch(u){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),u}global.Worker=l.Worker}else(Z||ct)&&(ct?St=self.location.href:typeof document<"u"&&document.currentScript&&(St=document.currentScript.src),r&&(St=r),St.indexOf("blob:")!==0?St=St.substr(0,St.replace(/[?#].*/,"").lastIndexOf("/")+1):St="",st||(sn=l=>{var u=new XMLHttpRequest;return u.open("GET",l,!1),u.send(null),u.responseText},ct&&(on=l=>{var u=new XMLHttpRequest;return u.open("GET",l,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}),es=(l,u,d)=>{var p=new XMLHttpRequest;p.open("GET",l,!0),p.responseType="arraybuffer",p.onload=()=>{if(p.status==200||p.status==0&&p.response){u(p.response);return}d()},p.onerror=d,p.send(null)}),ii=l=>document.title=l);st&&typeof performance>"u"&&(global.performance=tf().performance);var Xt=console.log.bind(console),Pt=console.warn.bind(console);st&&(Yt(),Xt=l=>Nt.writeSync(1,l+`
|
|
11
11
|
`),Pt=l=>Nt.writeSync(2,l+`
|
|
12
12
|
`));var ut=a.print||Xt,dt=a.printErr||Pt;Object.assign(a,y),y=null,a.arguments&&(b=a.arguments),a.thisProgram&&(I=a.thisProgram),a.quit&&(J=a.quit);function rr(l){rr.shown||(rr.shown={}),rr.shown[l]||(rr.shown[l]=1,dt(l))}var Iy=Atomics.load,Ay=Atomics.store,xy=Atomics.compareExchange,si;a.wasmBinary&&(si=a.wasmBinary);var wc=a.noExitRuntime||!0;typeof WebAssembly!="object"&&Ce("no native wasm support detected");var It,vc,ta=!1,oi;function Sc(l,u){l||Ce(u)}function ff(l){var u=a["_"+l];return u}function hf(l,u,d,p,_){var S={string:function(Lt){var Pe=0;if(Lt!=null&&Lt!==0){var nr=(Lt.length<<2)+1;Pe=hs(nr),ea(Lt,Pe,nr)}return Pe},array:function(Lt){var Pe=hs(Lt.length);return Fc(Lt,Pe),Pe}};function g(Lt){return u==="string"?vr(Lt):u==="boolean"?Boolean(Lt):Lt}var v=ff(l),F=[],et=0;if(p)for(var ot=0;ot<p.length;ot++){var Ee=S[d[ot]];Ee?(et===0&&(et=ha()),F[ot]=Ee(p[ot])):F[ot]=p[ot]}var bt=v.apply(null,F);function Bn(Lt){return et!==0&&fs(et),g(Lt)}return bt=Bn(bt),bt}var Ic=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ac(l,u,d){u>>>=0;for(var p=u+d,_=u;l[_]&&!(_>=p);)++_;if(_-u>16&&l.buffer&&Ic)return Ic.decode(l.buffer instanceof SharedArrayBuffer?l.slice(u,_):l.subarray(u,_));for(var S="";u<_;){var g=l[u++];if(!(g&128)){S+=String.fromCharCode(g);continue}var v=l[u++]&63;if((g&224)==192){S+=String.fromCharCode((g&31)<<6|v);continue}var F=l[u++]&63;if((g&240)==224?g=(g&15)<<12|v<<6|F:g=(g&7)<<18|v<<12|F<<6|l[u++]&63,g<65536)S+=String.fromCharCode(g);else{var et=g-65536;S+=String.fromCharCode(55296|et>>10,56320|et&1023)}}return S}function vr(l,u){return l>>>=0,l?Ac(n(),l,u):""}function xc(l,u,d,p){if(d>>>=0,!(p>0))return 0;for(var _=d,S=d+p-1,g=0;g<l.length;++g){var v=l.charCodeAt(g);if(v>=55296&&v<=57343){var F=l.charCodeAt(++g);v=65536+((v&1023)<<10)|F&1023}if(v<=127){if(d>=S)break;u[d++>>>0]=v}else if(v<=2047){if(d+1>=S)break;u[d++>>>0]=192|v>>6,u[d++>>>0]=128|v&63}else if(v<=65535){if(d+2>=S)break;u[d++>>>0]=224|v>>12,u[d++>>>0]=128|v>>6&63,u[d++>>>0]=128|v&63}else{if(d+3>=S)break;u[d++>>>0]=240|v>>18,u[d++>>>0]=128|v>>12&63,u[d++>>>0]=128|v>>6&63,u[d++>>>0]=128|v&63}}return u[d>>>0]=0,d-_}function ea(l,u,d){return xc(l,n(),u,d)}function pf(l){for(var u=0,d=0;d<l.length;++d){var p=l.charCodeAt(d);p>=55296&&p<=57343&&(p=65536+((p&1023)<<10)|l.charCodeAt(++d)&1023),p<=127?++u:p<=2047?u+=2:p<=65535?u+=3:u+=4}return u}function Fc(l,u){e().set(l,u>>>0)}function mf(l,u,d){for(var p=0;p<l.length;++p)e()[u++>>>0]=l.charCodeAt(p);d||(e()[u>>>0]=0)}var Se,Tc,Bc,Dc,Ec,Oc,_f,yf,Mc;x&&(Se=a.buffer);function Vr(l){Se=l,a.HEAP8=Tc=new Int8Array(l),a.HEAP16=Dc=new Int16Array(l),a.HEAP32=Oc=new Int32Array(l),a.HEAPU8=Bc=new Uint8Array(l),a.HEAPU16=Ec=new Uint16Array(l),a.HEAPU32=_f=new Uint32Array(l),a.HEAPF32=yf=new Float32Array(l),a.HEAPF64=Mc=new Float64Array(l)}var Rc=a.INITIAL_MEMORY||16777216;if(x)It=a.wasmMemory,Se=a.buffer;else if(a.wasmMemory)It=a.wasmMemory;else if(It=new WebAssembly.Memory({initial:Rc/65536,maximum:65536,shared:!0}),!(It.buffer instanceof SharedArrayBuffer))throw dt("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),st&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");It&&(Se=It.buffer),Rc=Se.byteLength,Vr(Se);var Uc,kc=[],Nc=[],bf=[],Lc=[],gf=!1;function ra(){return wc}function wf(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)If(a.preRun.shift());rs(kc)}function Cc(){gf=!0,!x&&rs(Nc)}function vf(){x||rs(bf)}function Sf(){if(!x){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)xf(a.postRun.shift());rs(Lc)}}function If(l){kc.unshift(l)}function Af(l){Nc.unshift(l)}function xf(l){Lc.unshift(l)}var an=0,na=null,ai=null;function Ff(l){an++,a.monitorRunDependencies&&a.monitorRunDependencies(an)}function Tf(l){if(an--,a.monitorRunDependencies&&a.monitorRunDependencies(an),an==0&&(na!==null&&(clearInterval(na),na=null),ai)){var u=ai;ai=null,u()}}function Ce(l){x?postMessage({cmd:"onAbort",arg:l}):a.onAbort&&a.onAbort(l),l="Aborted("+l+")",dt(l),ta=!0,oi=1,l+=". Build with -sASSERTIONS for more info.";var u=new WebAssembly.RuntimeError(l);throw m(u),u}var Bf="data:application/octet-stream;base64,";function Pc(l){return l.startsWith(Bf)}var Be;a.locateFile?(Be="./duckdb-coi.wasm",Pc(Be)||(Be=Tn(Be))):Be=new URL("./duckdb-coi.wasm",pc.url).toString();function Vc(l){try{if(l==Be&&si)return new Uint8Array(si);if(on)return on(l);throw"both async and sync fetching of the wasm failed"}catch(u){Ce(u)}}function Df(){return!si&&(Z||ct)&&typeof fetch=="function"?fetch(Be,{credentials:"same-origin"}).then(function(l){if(!l.ok)throw"failed to load wasm binary file at '"+Be+"'";return l.arrayBuffer()}).catch(function(){return Vc(Be)}):Promise.resolve().then(function(){return Vc(Be)})}function Ef(){var l={a:Dh};function u(g,v){var F=g.exports;if(a.asm=F,Lf(a.asm.gb),Uc=a.asm.tb,Af(a.asm.ta),vc=v,!x){var et=E.unusedWorkers.length;E.unusedWorkers.forEach(function(ot){E.loadWasmModuleToWorker(ot,function(){--et||Tf("wasm-instantiate")})})}}x||Ff("wasm-instantiate");function d(g){u(g.instance,g.module)}function p(g){return Df().then(function(v){return WebAssembly.instantiate(v,l)}).then(function(v){return v}).then(g,function(v){dt("failed to asynchronously prepare wasm: "+v),Ce(v)})}function _(){return!si&&typeof WebAssembly.instantiateStreaming=="function"&&!Pc(Be)&&typeof fetch=="function"?fetch(Be,{credentials:"same-origin"}).then(function(g){var v=WebAssembly.instantiateStreaming(g,l);return v.then(d,function(F){return dt("wasm streaming compile failed: "+F),dt("falling back to ArrayBuffer instantiation"),p(d)})}):p(d)}if(a.instantiateWasm)try{var S=a.instantiateWasm(l,u);return S}catch(g){return dt("Module.instantiateWasm callback failed with error: "+g),!1}return _().catch(m),{}}var Of={};function rs(l){for(;l.length>0;){var u=l.shift();if(typeof u=="function"){u(a);continue}var d=u.func;typeof d=="number"?u.arg===void 0?ia(d)():ia(d)(u.arg):d(u.arg===void 0?null:u.arg)}}function Mf(l){var u=ha(),d=l();return fs(u),d}function Rf(l){o()[l>>>2]=0;var u=E.pthreads[l];delete E.pthreads[l],u.worker.terminate(),da(l),E.runningWorkers.splice(E.runningWorkers.indexOf(u.worker),1),u.worker.pthread=void 0}function Uf(l){var u=E.pthreads[l];u.worker.postMessage({cmd:"cancel"})}function Hc(l){var u=E.pthreads[l];if(u){o()[l>>>2]=0;var d=u.worker;E.returnWorkerToPool(d)}}function zc(l,u){n().fill(0,l,l+u)}function jc(l){var u=E.getNewWorker();if(!u)return 6;E.runningWorkers.push(u);var d=E.pthreads[l.pthread_ptr]={worker:u,threadInfoStruct:l.pthread_ptr};u.pthread=d;var p={cmd:"run",start_routine:l.startRoutine,arg:l.arg,threadInfoStruct:l.pthread_ptr};return u.runPthread=()=>{p.time=performance.now(),u.postMessage(p,l.transferList)},u.loaded&&(u.runPthread(),delete u.runPthread),0}function Wc(l){Hl(l)}function $c(l){if(l instanceof ui||l=="unwind")return oi;J(1,l)}var E={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){x?E.initWorker():E.initMainThread()},initMainThread:function(){for(var l=4,u=0;u<l;++u)E.allocateUnusedWorker()},initWorker:function(){wc=!1},pthreads:{},setExitStatus:function(l){oi=l},terminateAllThreads:function(){for(var l in E.pthreads){var u=E.pthreads[l];u&&u.worker&&E.returnWorkerToPool(u.worker)}for(var d=0;d<E.unusedWorkers.length;++d){var p=E.unusedWorkers[d];p.terminate()}E.unusedWorkers=[]},returnWorkerToPool:function(l){E.runWithoutMainThreadQueuedCalls(function(){delete E.pthreads[l.pthread.threadInfoStruct],E.unusedWorkers.push(l),E.runningWorkers.splice(E.runningWorkers.indexOf(l),1),da(l.pthread.threadInfoStruct),l.pthread=void 0})},runWithoutMainThreadQueuedCalls:function(l){o()[Vl>>>2]=0;try{l()}finally{o()[Vl>>>2]=1}},receiveObjectTransfer:function(l){},threadInit:function(){for(var l in E.tlsInitFunctions)E.tlsInitFunctions.hasOwnProperty(l)&&E.tlsInitFunctions[l]()},loadWasmModuleToWorker:function(l,u){l.onmessage=d=>{var p=d.data,_=p.cmd;if(l.pthread&&(E.currentProxiedOperationCallerThread=l.pthread.threadInfoStruct),p.targetThread&&p.targetThread!=ds()){var S=E.pthreads[p.targetThread];S?S.worker.postMessage(p,p.transferList):dt('Internal error! Worker sent a message "'+_+'" to target pthread '+p.targetThread+", but that thread no longer exists!"),E.currentProxiedOperationCallerThread=void 0;return}_==="processProxyingQueue"?Sl(p.queue):_==="spawnThread"?jc(p):_==="cleanupThread"?Hc(p.thread):_==="killThread"?Rf(p.thread):_==="cancelThread"?Uf(p.thread):_==="loaded"?(l.loaded=!0,u&&u(l),l.runPthread&&(l.runPthread(),delete l.runPthread)):_==="print"?ut("Thread "+p.threadId+": "+p.text):_==="printErr"?dt("Thread "+p.threadId+": "+p.text):_==="alert"?alert("Thread "+p.threadId+": "+p.text):p.target==="setimmediate"?l.postMessage(p):_==="onAbort"?a.onAbort&&a.onAbort(p.arg):_&&dt("worker sent an unknown command "+_),E.currentProxiedOperationCallerThread=void 0},l.onerror=d=>{var p="worker sent an error!";throw dt(p+" "+d.filename+":"+d.lineno+": "+d.message),d},st&&(l.on("message",function(d){l.onmessage({data:d})}),l.on("error",function(d){l.onerror(d)}),l.on("detachedExit",function(){})),l.postMessage({cmd:"load",urlOrBlob:a.mainScriptUrlOrBlob,wasmMemory:It,wasmModule:vc})},allocateUnusedWorker:function(){if(!a.locateFile){E.unusedWorkers.push(new Worker(new URL("duckdb_wasm.worker.js",pc.url)));return}var l=Tn("duckdb_wasm.worker.js");E.unusedWorkers.push(new Worker(l))},getNewWorker:function(){return E.unusedWorkers.length==0&&(E.allocateUnusedWorker(),E.loadWasmModuleToWorker(E.unusedWorkers[0])),E.unusedWorkers.pop()}};function kf(){var l=ds(),u=o()[l+44>>>2],d=o()[l+48>>>2],p=u-d;Pl(u,p),fs(u)}a.establishStackSpace=kf;function Yc(l){if(x)return tt(1,0,l);try{Wc(l)}catch(u){$c(u)}}var ns=[];function ia(l){var u=ns[l];return u||(l>=ns.length&&(ns.length=l+1),ns[l]=u=Uc.get(l)),u}function Nf(l,u){return ia(l)(u)}a.invokeEntryPoint=Nf;function Lf(l){E.tlsInitFunctions.push(l)}function Cf(l,u,d,p){Ce("Assertion failed: "+vr(l)+", at: "+[u?vr(u):"unknown filename",d,p?vr(p):"unknown function"])}function Pf(l){Nl(l,!ct,1,!Z),E.threadInit()}function Vf(l){x?postMessage({cmd:"cleanupThread",thread:l}):Hc(l)}function Xc(l,u,d,p){return x?tt(2,1,l,u,d,p):Gc(l,u,d,p)}function Gc(l,u,d,p){if(typeof SharedArrayBuffer>"u")return dt("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var _=[],S=0;if(x&&(_.length===0||S))return Xc(l,u,d,p);if(S)return S;var g={startRoutine:d,pthread_ptr:l,arg:p,transferList:_};return x?(g.cmd="spawnThread",postMessage(g,_),0):jc(g)}var Gt={buffers:[null,[],[]],printChar:function(l,u){var d=Gt.buffers[l];u===0||u===10?((l===1?ut:dt)(Ac(d,0)),d.length=0):d.push(u)},varargs:void 0,get:function(){Gt.varargs+=4;var l=o()[Gt.varargs-4>>>2];return l},getStr:function(l){var u=vr(l);return u}};function Kc(l,u,d,p,_){if(x)return tt(3,1,l,u,d,p,_)}function Hf(){dt("missing function: $SOCKFS"),Ce(-1)}function Jc(){dt("missing function: $FS"),Ce(-1)}function ci(l){var u=Hf.getSocket(l);if(!u)throw new Jc.ErrnoError(8);return u}function sa(l){return(l&255)+"."+(l>>8&255)+"."+(l>>16&255)+"."+(l>>24&255)}function qc(l){var u="",d=0,p=0,_=0,S=0,g=0,v=0,F=[l[0]&65535,l[0]>>16,l[1]&65535,l[1]>>16,l[2]&65535,l[2]>>16,l[3]&65535,l[3]>>16],et=!0,ot="";for(v=0;v<5;v++)if(F[v]!==0){et=!1;break}if(et){if(ot=sa(F[6]|F[7]<<16),F[5]===-1)return u="::ffff:",u+=ot,u;if(F[5]===0)return u="::",ot==="0.0.0.0"&&(ot=""),ot==="0.0.0.1"&&(ot="1"),u+=ot,u}for(d=0;d<8;d++)F[d]===0&&(d-_>1&&(g=0),_=d,g++),g>p&&(p=g,S=d-p+1);for(d=0;d<8;d++){if(p>1&&F[d]===0&&d>=S&&d<S+p){d===S&&(u+=":",S===0&&(u+=":"));continue}u+=Number(ua(F[d]&65535)).toString(16),u+=d<7?":":""}return u}function Zc(l,u){var d=i()[l>>>1],p=ua(s()[l+2>>>1]),_;switch(d){case 2:if(u!==16)return{errno:28};_=o()[l+4>>>2],_=sa(_);break;case 10:if(u!==28)return{errno:28};_=[o()[l+8>>>2],o()[l+12>>>2],o()[l+16>>>2],o()[l+20>>>2]],_=qc(_);break;default:return{errno:5}}return{family:d,addr:_,port:p}}function is(l){for(var u=l.split("."),d=0;d<4;d++){var p=Number(u[d]);if(isNaN(p))return null;u[d]=p}return(u[0]|u[1]<<8|u[2]<<16|u[3]<<24)>>>0}function ss(l){return parseInt(l)}function oa(l){var u,d,p,_,S=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,g=[];if(!S.test(l))return null;if(l==="::")return[0,0,0,0,0,0,0,0];for(l.startsWith("::")?l=l.replace("::","Z:"):l=l.replace("::",":Z:"),l.indexOf(".")>0?(l=l.replace(new RegExp("[.]","g"),":"),u=l.split(":"),u[u.length-4]=ss(u[u.length-4])+ss(u[u.length-3])*256,u[u.length-3]=ss(u[u.length-2])+ss(u[u.length-1])*256,u=u.slice(0,u.length-2)):u=l.split(":"),p=0,_=0,d=0;d<u.length;d++)if(typeof u[d]=="string")if(u[d]==="Z"){for(_=0;_<8-u.length+1;_++)g[d+_]=0;p=_-1}else g[d+p]=us(parseInt(u[d],16));else g[d+p]=u[d];return[g[1]<<16|g[0],g[3]<<16|g[2],g[5]<<16|g[4],g[7]<<16|g[6]]}var De={address_map:{id:1,addrs:{},names:{}},lookup_name:function(l){var u=is(l);if(u!==null||(u=oa(l),u!==null))return l;var d;if(De.address_map.addrs[l])d=De.address_map.addrs[l];else{var p=De.address_map.id++;Sc(p<65535,"exceeded max address mappings of 65535"),d="172.29."+(p&255)+"."+(p&65280),De.address_map.names[d]=l,De.address_map.addrs[l]=d}return d},lookup_addr:function(l){return De.address_map.names[l]?De.address_map.names[l]:null}};function Qc(l,u,d){if(d&&l===0)return null;var p=Zc(l,u);if(p.errno)throw new Jc.ErrnoError(p.errno);return p.addr=De.lookup_addr(p.addr)||p.addr,p}function tl(l,u,d){if(x)return tt(4,1,l,u,d);var p=ci(l),_=Qc(u,d);return p.sock_ops.bind(p,_.addr,_.port),0}function el(l,u,d){if(x)return tt(5,1,l,u,d);var p=ci(l),_=Qc(u,d);return p.sock_ops.connect(p,_.addr,_.port),0}function rl(l,u,d,p){return x?tt(6,1,l,u,d,p):(u=Gt.getStr(u),u=Gt.calculateAt(l,u),Gt.doAccess(u,d))}function nl(l,u,d){return x?tt(7,1,l,u,d):(Gt.varargs=d,0)}function il(l,u){if(x)return tt(8,1,l,u)}function sl(l,u,d){if(x)return tt(9,1,l,u,d)}function ol(l,u,d){if(x)return tt(10,1,l,u,d)}function aa(l,u,d,p,_){switch(u){case 2:d=is(d),zc(l,16),_&&(o()[_>>>2]=16),i()[l>>>1]=u,o()[l+4>>>2]=d,i()[l+2>>>1]=us(p);break;case 10:d=oa(d),zc(l,28),_&&(o()[_>>>2]=28),o()[l>>>2]=u,o()[l+8>>>2]=d[0],o()[l+12>>>2]=d[1],o()[l+16>>>2]=d[2],o()[l+20>>>2]=d[3],i()[l+2>>>1]=us(p);break;default:return 5}return 0}function al(l,u,d){if(x)return tt(11,1,l,u,d);var p=ci(l);if(!p.daddr)return-53;var _=aa(u,p.family,De.lookup_name(p.daddr),p.dport,d);return 0}function cl(l,u,d,p,_){if(x)return tt(12,1,l,u,d,p,_);var S=ci(l);return u===1&&d===4?(o()[p>>>2]=S.error,o()[_>>>2]=4,S.error=null,0):-50}function ll(l,u,d){return x?tt(13,1,l,u,d):(Gt.varargs=d,0)}function ul(l,u){if(x)return tt(14,1,l,u)}function dl(l,u,d){if(x)return tt(15,1,l,u,d)}function fl(l,u,d,p){if(x)return tt(16,1,l,u,d,p)}function hl(l,u,d,p){if(x)return tt(17,1,l,u,d,p);Gt.varargs=p}function pl(l,u,d,p,_,S){if(x)return tt(18,1,l,u,d,p,_,S);var g=ci(l),v=g.sock_ops.recvmsg(g,d);if(!v)return 0;if(_)var F=aa(_,g.family,De.lookup_name(v.addr),v.port,S);return n().set(v.buffer,u>>>0),v.buffer.byteLength}function ml(l,u,d,p){if(x)return tt(19,1,l,u,d,p)}function _l(l){if(x)return tt(20,1,l)}function yl(l,u,d,p,_,S){if(x)return tt(21,1,l,u,d,p,_,S)}function bl(l,u,d){if(x)return tt(22,1,l,u,d)}function gl(l,u){if(x)return tt(23,1,l,u)}function wl(l,u,d){if(x)return tt(24,1,l,u,d)}function zf(l){}var vl="To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking";function jf(l,u){Ce(vl)}function Wf(l,u){Ce(vl)}function $f(){return Date.now()}function Yf(){return 2097152}var Xf=!0;function Gf(){return Xf}function Sl(l){try{ds()&&Cl(l)}finally{Atomics.sub(o(),l>>2,1)}}function Kf(l,u,d,p){if(l==u)setTimeout(()=>Sl(p));else if(x)postMessage({targetThread:l,cmd:"processProxyingQueue",queue:p});else{var _=E.pthreads[l],S=_&&_.worker;if(!S)return;S.postMessage({cmd:"processProxyingQueue",queue:p})}return 1}function Jf(l,u,d){return-1}function qf(){Ce("")}function Zf(l,u){return globalThis.DUCKDB_RUNTIME.createDirectory(a,l,u)}function Qf(l,u){return globalThis.DUCKDB_RUNTIME.checkDirectory(a,l,u)}function th(l,u){return globalThis.DUCKDB_RUNTIME.listDirectoryEntries(a,l,u)}function eh(l,u){return globalThis.DUCKDB_RUNTIME.removeDirectory(a,l,u)}function rh(l){return globalThis.DUCKDB_RUNTIME.closeFile(a,l)}function nh(l,u){return globalThis.DUCKDB_RUNTIME.checkFile(a,l,u)}function ih(l){return globalThis.DUCKDB_RUNTIME.getLastFileModificationTime(a,l)}function sh(l,u,d,p){return globalThis.DUCKDB_RUNTIME.moveFile(a,l,u,d,p)}function oh(l,u){return globalThis.DUCKDB_RUNTIME.openFile(a,l,u)}function ah(l,u,d,p){return globalThis.DUCKDB_RUNTIME.readFile(a,l,u,d,p)}function ch(l,u){return globalThis.DUCKDB_RUNTIME.truncateFile(a,l,u)}function lh(l,u,d,p){return globalThis.DUCKDB_RUNTIME.writeFile(a,l,u,d,p)}function uh(l,u){return globalThis.DUCKDB_RUNTIME.glob(a,l,u)}function dh(l){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(a,l)}function fh(l,u,d,p,_,S){return globalThis.DUCKDB_RUNTIME.callScalarUDF(a,l,u,d,p,_,S)}function hh(){st||ct||rr("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Il(){return 4294901760}var os;st?os=()=>{var l=process.hrtime();return l[0]*1e3+l[1]/1e6}:x?os=()=>performance.now()-a.__performance_now_clock_drift:os=()=>performance.now();function ph(l,u,d){n().copyWithin(l>>>0,u>>>0,u+d>>>0)}function mh(){return st?ef().cpus().length:navigator.hardwareConcurrency}function tt(l,u){var d=arguments.length-2,p=arguments;return Mf(function(){for(var _=d,S=hs(_*8),g=S>>3,v=0;v<d;v++){var F=p[2+v];c()[g+v>>>0]=F}return Ll(l,_,S,u)})}var ca=[];function _h(l,u,d){ca.length=u;for(var p=d>>3,_=0;_<u;_++)ca[_]=c()[p+_>>>0];var S=l<0,g=S?Of[-l-1]:Th[l];return g.apply(null,ca)}function yh(l){try{return It.grow(l-Se.byteLength+65535>>>16),Vr(It.buffer),1}catch(u){}}function bh(l){var u=n().length;if(l=l>>>0,l<=u)return!1;var d=Il();if(l>d)return!1;let p=(F,et)=>F+(et-F%et)%et;for(var _=1;_<=4;_*=2){var S=u*(1+.2/_);S=Math.min(S,l+100663296);var g=Math.min(d,p(Math.max(l,S),65536)),v=yh(g);if(v)return!0}return!1}function gh(){throw"unwind"}var la={};function wh(){return I||"./this.program"}function li(){if(!li.strings){var l=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",u={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:l,_:wh()};for(var d in la)la[d]===void 0?delete u[d]:u[d]=la[d];var p=[];for(var d in u)p.push(d+"="+u[d]);li.strings=p}return li.strings}function Al(l,u){if(x)return tt(25,1,l,u);var d=0;return li().forEach(function(p,_){var S=u+d;o()[l+_*4>>>2]=S,mf(p,S),d+=p.length+1}),0}function xl(l,u){if(x)return tt(26,1,l,u);var d=li();o()[l>>>2]=d.length;var p=0;return d.forEach(function(_){p+=_.length+1}),o()[u>>>2]=p,0}function Fl(l){return x?tt(27,1,l):0}function Tl(l,u,d,p,_,S){if(x)return tt(28,1,l,u,d,p,_,S);var g=Gt.getStreamFromFD(l),v=Gt.doReadv(g,u,d,p);return o()[S>>>2]=v,0}function Bl(l,u,d,p,_,S){if(x)return tt(29,1,l,u,d,p,_,S);var g=Gt.getStreamFromFD(l),v=Gt.doWritev(g,u,d,p);return o()[S>>>2]=v,0}function Dl(l,u,d,p){if(x)return tt(30,1,l,u,d,p);var _=Gt.getStreamFromFD(l),S=Gt.doReadv(_,u,d);return o()[p>>>2]=S,0}function El(l,u,d,p,_){if(x)return tt(31,1,l,u,d,p,_)}function Ol(l){if(x)return tt(32,1,l);var u=Gt.getStreamFromFD(l);return u.stream_ops&&u.stream_ops.fsync?-u.stream_ops.fsync(u):0}function Ml(l,u,d,p){if(x)return tt(33,1,l,u,d,p);for(var _=0,S=0;S<d;S++){var g=o()[u>>>2],v=o()[u+4>>>2];u+=8;for(var F=0;F<v;F++)Gt.printChar(l,n()[g+F>>>0]);_+=v}return o()[p>>>2]=_,0}function Rl(l,u,d,p){if(x)return tt(34,1,l,u,d,p);var _=0,S=0,g=0,v=0,F=0,et=0,ot;function Ee(bt,Bn,Lt,Pe,nr,di){var w,O,At,Kt;return O=bt===10?28:16,nr=bt===10?qc(nr):sa(nr),w=fa(O),Kt=aa(w,bt,nr,di),Sc(!Kt),At=fa(32),o()[At+4>>>2]=bt,o()[At+8>>>2]=Bn,o()[At+12>>>2]=Lt,o()[At+24>>>2]=Pe,o()[At+20>>>2]=w,bt===10?o()[At+16>>>2]=28:o()[At+16>>>2]=16,o()[At+28>>>2]=0,At}if(d&&(g=o()[d>>>2],v=o()[d+4>>>2],F=o()[d+8>>>2],et=o()[d+12>>>2]),F&&!et&&(et=F===2?17:6),!F&&et&&(F=et===17?2:1),et===0&&(et=6),F===0&&(F=1),!l&&!u)return-2;if(g&-1088||d!==0&&o()[d>>>2]&2&&!l)return-1;if(g&32)return-2;if(F!==0&&F!==1&&F!==2)return-7;if(v!==0&&v!==2&&v!==10)return-6;if(u&&(u=vr(u),S=parseInt(u,10),isNaN(S)))return g&1024?-2:-8;if(!l)return v===0&&(v=2),(g&1)===0&&(v===2?_=ls(2130706433):_=[0,0,0,1]),ot=Ee(v,F,et,null,_,S),o()[p>>>2]=ot,0;if(l=vr(l),_=is(l),_!==null)if(v===0||v===2)v=2;else if(v===10&&g&8)_=[0,0,ls(65535),_],v=10;else return-2;else if(_=oa(l),_!==null)if(v===0||v===10)v=10;else return-2;return _!=null?(ot=Ee(v,F,et,l,_,S),o()[p>>>2]=ot,0):g&4?-2:(l=De.lookup_name(l),_=is(l),v===0?v=2:v===10&&(_=[0,0,ls(65535),_]),ot=Ee(v,F,et,null,_,S),o()[p>>>2]=ot,0)}function vh(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var l=new Uint8Array(1);return function(){return crypto.getRandomValues(l),l[0]}}else if(st)try{var u=Ep("crypto");return function(){return u.randomBytes(1)[0]}}catch(d){}return function(){Ce("randomDevice")}}function as(l,u){as.randomDevice||(as.randomDevice=vh());for(var d=0;d<u;d++)e()[l+d>>>0]=as.randomDevice();return 0}function Sh(l,u,d,p,_,S,g){var v=Zc(l,u);if(v.errno)return-6;var F=v.port,et=v.addr,ot=!1;if(d&&p){var Ee;if(g&1||!(Ee=De.lookup_addr(et))){if(g&8)return-2}else et=Ee;var bt=ea(et,d,p);bt+1>=p&&(ot=!0)}if(_&&S){F=""+F;var bt=ea(F,_,S);bt+1>=S&&(ot=!0)}return ot?-12:0}function cs(l){return l%4===0&&(l%100!==0||l%400===0)}function Ih(l,u){for(var d=0,p=0;p<=u;d+=l[p++]);return d}var Ul=[31,29,31,30,31,30,31,31,30,31,30,31],kl=[31,28,31,30,31,30,31,31,30,31,30,31];function Ah(l,u){for(var d=new Date(l.getTime());u>0;){var p=cs(d.getFullYear()),_=d.getMonth(),S=(p?Ul:kl)[_];if(u>S-d.getDate())u-=S-d.getDate()+1,d.setDate(1),_<11?d.setMonth(_+1):(d.setMonth(0),d.setFullYear(d.getFullYear()+1));else return d.setDate(d.getDate()+u),d}return d}function xh(l,u,d,p){var _=o()[p+40>>>2],S={tm_sec:o()[p>>>2],tm_min:o()[p+4>>>2],tm_hour:o()[p+8>>>2],tm_mday:o()[p+12>>>2],tm_mon:o()[p+16>>>2],tm_year:o()[p+20>>>2],tm_wday:o()[p+24>>>2],tm_yday:o()[p+28>>>2],tm_isdst:o()[p+32>>>2],tm_gmtoff:o()[p+36>>>2],tm_zone:_?vr(_):""},g=vr(d),v={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var F in v)g=g.replace(new RegExp(F,"g"),v[F]);var et=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ot=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ee(w,O,At){for(var Kt=typeof w=="number"?w.toString():w||"";Kt.length<O;)Kt=At[0]+Kt;return Kt}function bt(w,O){return Ee(w,O,"0")}function Bn(w,O){function At(ms){return ms<0?-1:ms>0?1:0}var Kt;return(Kt=At(w.getFullYear()-O.getFullYear()))===0&&(Kt=At(w.getMonth()-O.getMonth()))===0&&(Kt=At(w.getDate()-O.getDate())),Kt}function Lt(w){switch(w.getDay()){case 0:return new Date(w.getFullYear()-1,11,29);case 1:return w;case 2:return new Date(w.getFullYear(),0,3);case 3:return new Date(w.getFullYear(),0,2);case 4:return new Date(w.getFullYear(),0,1);case 5:return new Date(w.getFullYear()-1,11,31);case 6:return new Date(w.getFullYear()-1,11,30)}}function Pe(w){var O=Ah(new Date(w.tm_year+1900,0,1),w.tm_yday),At=new Date(O.getFullYear(),0,4),Kt=new Date(O.getFullYear()+1,0,4),ms=Lt(At),Ap=Lt(Kt);return Bn(ms,O)<=0?Bn(Ap,O)<=0?O.getFullYear()+1:O.getFullYear():O.getFullYear()-1}var nr={"%a":function(w){return et[w.tm_wday].substring(0,3)},"%A":function(w){return et[w.tm_wday]},"%b":function(w){return ot[w.tm_mon].substring(0,3)},"%B":function(w){return ot[w.tm_mon]},"%C":function(w){var O=w.tm_year+1900;return bt(O/100|0,2)},"%d":function(w){return bt(w.tm_mday,2)},"%e":function(w){return Ee(w.tm_mday,2," ")},"%g":function(w){return Pe(w).toString().substring(2)},"%G":function(w){return Pe(w)},"%H":function(w){return bt(w.tm_hour,2)},"%I":function(w){var O=w.tm_hour;return O==0?O=12:O>12&&(O-=12),bt(O,2)},"%j":function(w){return bt(w.tm_mday+Ih(cs(w.tm_year+1900)?Ul:kl,w.tm_mon-1),3)},"%m":function(w){return bt(w.tm_mon+1,2)},"%M":function(w){return bt(w.tm_min,2)},"%n":function(){return`
|
|
13
|
-
`},"%p":function(w){return w.tm_hour>=0&&w.tm_hour<12?"AM":"PM"},"%S":function(w){return bt(w.tm_sec,2)},"%t":function(){return" "},"%u":function(w){return w.tm_wday||7},"%U":function(w){var O=w.tm_yday+7-w.tm_wday;return bt(Math.floor(O/7),2)},"%V":function(w){var O=Math.floor((w.tm_yday+7-(w.tm_wday+6)%7)/7);if((w.tm_wday+371-w.tm_yday-2)%7<=2&&O++,O){if(O==53){var Kt=(w.tm_wday+371-w.tm_yday)%7;Kt!=4&&(Kt!=3||!cs(w.tm_year))&&(O=1)}}else{O=52;var At=(w.tm_wday+7-w.tm_yday-1)%7;(At==4||At==5&&cs(w.tm_year%400-1))&&O++}return bt(O,2)},"%w":function(w){return w.tm_wday},"%W":function(w){var O=w.tm_yday+7-(w.tm_wday+6)%7;return bt(Math.floor(O/7),2)},"%y":function(w){return(w.tm_year+1900).toString().substring(2)},"%Y":function(w){return w.tm_year+1900},"%z":function(w){var O=w.tm_gmtoff,At=O>=0;return O=Math.abs(O)/60,O=O/60*100+O%60,(At?"+":"-")+String("0000"+O).slice(-4)},"%Z":function(w){return w.tm_zone},"%%":function(){return"%"}};g=g.replace(/%%/g,"\0\0");for(var F in nr)g.includes(F)&&(g=g.replace(new RegExp(F,"g"),nr[F](S)));g=g.replace(/\0\0/g,"%");var di=Bh(g,!1);return di.length>u?0:(Fc(di,l),di.length-1)}function Fh(l,u,d,p){return xh(l,u,d,p)}E.init();var Th=[null,Yc,Xc,Kc,tl,el,rl,nl,il,sl,ol,al,cl,ll,ul,dl,fl,hl,pl,ml,_l,yl,bl,gl,wl,Al,xl,Fl,Tl,Bl,Dl,El,Ol,Ml,Rl];function Bh(l,u,d){var p=d>0?d:pf(l)+1,_=new Array(p),S=xc(l,_,0,_.length);return u&&(_.length=S),_}var Dh={b:Cf,v:Pf,s:Vf,aa:Gc,W:Kc,Y:tl,X:el,Q:rl,c:nl,ia:il,y:sl,ea:ol,S:al,V:cl,ka:ll,fa:ul,ja:dl,ga:fl,r:hl,T:pl,N:ml,p:_l,U:yl,l:bl,ha:gl,q:wl,Z:zf,o:jf,_:Wf,sa:$f,ba:Yf,ra:Gf,da:Kf,I:Jf,f:qf,G:Zf,H:Qf,E:th,F:eh,k:rh,C:nh,K:ih,D:sh,L:oh,g:ah,J:ch,h:lh,B:uh,j:dh,M:fh,m:hh,la:Il,d:os,P:ph,ma:mh,z:_h,qa:bh,u:gh,oa:Al,pa:xl,$:Wc,e:Fl,x:Tl,w:Bl,t:Dl,A:El,O:Ol,i:Ml,n:Rl,ca:as,R:Sh,a:It||a.wasmMemory,na:Fh},Fy=Ef(),Eh=a.___wasm_call_ctors=function(){return(Eh=a.___wasm_call_ctors=a.asm.ta).apply(null,arguments)},Oh=a._main=function(){return(Oh=a._main=a.asm.ua).apply(null,arguments)},Mh=a._duckdb_web_fs_glob_add_path=function(){return(Mh=a._duckdb_web_fs_glob_add_path=a.asm.va).apply(null,arguments)},Rh=a._duckdb_web_clear_response=function(){return(Rh=a._duckdb_web_clear_response=a.asm.wa).apply(null,arguments)},Uh=a._duckdb_web_fail_with=function(){return(Uh=a._duckdb_web_fail_with=a.asm.xa).apply(null,arguments)},kh=a._duckdb_web_reset=function(){return(kh=a._duckdb_web_reset=a.asm.ya).apply(null,arguments)},Nh=a._duckdb_web_connect=function(){return(Nh=a._duckdb_web_connect=a.asm.za).apply(null,arguments)},Lh=a._duckdb_web_disconnect=function(){return(Lh=a._duckdb_web_disconnect=a.asm.Aa).apply(null,arguments)},Ch=a._duckdb_web_flush_files=function(){return(Ch=a._duckdb_web_flush_files=a.asm.Ba).apply(null,arguments)},Ph=a._duckdb_web_flush_file=function(){return(Ph=a._duckdb_web_flush_file=a.asm.Ca).apply(null,arguments)},Vh=a._duckdb_web_open=function(){return(Vh=a._duckdb_web_open=a.asm.Da).apply(null,arguments)},Hh=a._duckdb_web_get_global_file_info=function(){return(Hh=a._duckdb_web_get_global_file_info=a.asm.Ea).apply(null,arguments)},zh=a._duckdb_web_collect_file_stats=function(){return(zh=a._duckdb_web_collect_file_stats=a.asm.Fa).apply(null,arguments)},jh=a._duckdb_web_export_file_stats=function(){return(jh=a._duckdb_web_export_file_stats=a.asm.Ga).apply(null,arguments)},Wh=a._duckdb_web_fs_drop_file=function(){return(Wh=a._duckdb_web_fs_drop_file=a.asm.Ha).apply(null,arguments)},$h=a._duckdb_web_fs_drop_files=function(){return($h=a._duckdb_web_fs_drop_files=a.asm.Ia).apply(null,arguments)},Yh=a._duckdb_web_fs_glob_file_infos=function(){return(Yh=a._duckdb_web_fs_glob_file_infos=a.asm.Ja).apply(null,arguments)},Xh=a._duckdb_web_fs_get_file_info_by_id=function(){return(Xh=a._duckdb_web_fs_get_file_info_by_id=a.asm.Ka).apply(null,arguments)},Gh=a._duckdb_web_fs_get_file_info_by_name=function(){return(Gh=a._duckdb_web_fs_get_file_info_by_name=a.asm.La).apply(null,arguments)},Kh=a._duckdb_web_fs_set_file_descriptor=function(){return(Kh=a._duckdb_web_fs_set_file_descriptor=a.asm.Ma).apply(null,arguments)},Jh=a._duckdb_web_fs_register_file_url=function(){return(Jh=a._duckdb_web_fs_register_file_url=a.asm.Na).apply(null,arguments)},qh=a._duckdb_web_fs_register_file_buffer=function(){return(qh=a._duckdb_web_fs_register_file_buffer=a.asm.Oa).apply(null,arguments)},Zh=a._duckdb_web_copy_file_to_buffer=function(){return(Zh=a._duckdb_web_copy_file_to_buffer=a.asm.Pa).apply(null,arguments)},Qh=a._duckdb_web_copy_file_to_path=function(){return(Qh=a._duckdb_web_copy_file_to_path=a.asm.Qa).apply(null,arguments)},tp=a._duckdb_web_get_version=function(){return(tp=a._duckdb_web_get_version=a.asm.Ra).apply(null,arguments)},ep=a._duckdb_web_get_feature_flags=function(){return(ep=a._duckdb_web_get_feature_flags=a.asm.Sa).apply(null,arguments)},rp=a._duckdb_web_tokenize=function(){return(rp=a._duckdb_web_tokenize=a.asm.Ta).apply(null,arguments)},np=a._duckdb_web_udf_scalar_create=function(){return(np=a._duckdb_web_udf_scalar_create=a.asm.Ua).apply(null,arguments)},ip=a._duckdb_web_prepared_create=function(){return(ip=a._duckdb_web_prepared_create=a.asm.Va).apply(null,arguments)},sp=a._duckdb_web_prepared_close=function(){return(sp=a._duckdb_web_prepared_close=a.asm.Wa).apply(null,arguments)},op=a._duckdb_web_prepared_run=function(){return(op=a._duckdb_web_prepared_run=a.asm.Xa).apply(null,arguments)},ap=a._duckdb_web_prepared_send=function(){return(ap=a._duckdb_web_prepared_send=a.asm.Ya).apply(null,arguments)},cp=a._duckdb_web_query_run=function(){return(cp=a._duckdb_web_query_run=a.asm.Za).apply(null,arguments)},lp=a._duckdb_web_pending_query_start=function(){return(lp=a._duckdb_web_pending_query_start=a.asm._a).apply(null,arguments)},up=a._duckdb_web_pending_query_poll=function(){return(up=a._duckdb_web_pending_query_poll=a.asm.$a).apply(null,arguments)},dp=a._duckdb_web_pending_query_cancel=function(){return(dp=a._duckdb_web_pending_query_cancel=a.asm.ab).apply(null,arguments)},fp=a._duckdb_web_query_fetch_results=function(){return(fp=a._duckdb_web_query_fetch_results=a.asm.bb).apply(null,arguments)},hp=a._duckdb_web_get_tablenames=function(){return(hp=a._duckdb_web_get_tablenames=a.asm.cb).apply(null,arguments)},pp=a._duckdb_web_insert_arrow_from_ipc_stream=function(){return(pp=a._duckdb_web_insert_arrow_from_ipc_stream=a.asm.db).apply(null,arguments)},mp=a._duckdb_web_insert_csv_from_path=function(){return(mp=a._duckdb_web_insert_csv_from_path=a.asm.eb).apply(null,arguments)},_p=a._duckdb_web_insert_json_from_path=function(){return(_p=a._duckdb_web_insert_json_from_path=a.asm.fb).apply(null,arguments)},yp=a._emscripten_tls_init=function(){return(yp=a._emscripten_tls_init=a.asm.gb).apply(null,arguments)},Nl=a.__emscripten_thread_init=function(){return(Nl=a.__emscripten_thread_init=a.asm.hb).apply(null,arguments)},bp=a.__emscripten_thread_crashed=function(){return(bp=a.__emscripten_thread_crashed=a.asm.ib).apply(null,arguments)},ls=a._htonl=function(){return(ls=a._htonl=a.asm.jb).apply(null,arguments)},us=a._htons=function(){return(us=a._htons=a.asm.kb).apply(null,arguments)},Ll=a._emscripten_run_in_main_runtime_thread_js=function(){return(Ll=a._emscripten_run_in_main_runtime_thread_js=a.asm.lb).apply(null,arguments)},ua=a._ntohs=function(){return(ua=a._ntohs=a.asm.mb).apply(null,arguments)},Cl=a._emscripten_proxy_execute_queue=function(){return(Cl=a._emscripten_proxy_execute_queue=a.asm.nb).apply(null,arguments)},da=a.__emscripten_thread_free_data=function(){return(da=a.__emscripten_thread_free_data=a.asm.ob).apply(null,arguments)},gp=a.__emscripten_thread_exit=function(){return(gp=a.__emscripten_thread_exit=a.asm.pb).apply(null,arguments)},ds=a._pthread_self=function(){return(ds=a._pthread_self=a.asm.qb).apply(null,arguments)},fa=a._malloc=function(){return(fa=a._malloc=a.asm.rb).apply(null,arguments)},wp=a._free=function(){return(wp=a._free=a.asm.sb).apply(null,arguments)},Pl=a._emscripten_stack_set_limits=function(){return(Pl=a._emscripten_stack_set_limits=a.asm.ub).apply(null,arguments)},ha=a.stackSave=function(){return(ha=a.stackSave=a.asm.vb).apply(null,arguments)},fs=a.stackRestore=function(){return(fs=a.stackRestore=a.asm.wb).apply(null,arguments)},hs=a.stackAlloc=function(){return(hs=a.stackAlloc=a.asm.xb).apply(null,arguments)},Vl=a.__emscripten_allow_main_runtime_queued_calls=1073680;a.ccall=hf,a.keepRuntimeAlive=ra,a.PThread=E,a.PThread=E,a.wasmMemory=It,a.ExitStatus=ui;var ps;function ui(l){this.name="ExitStatus",this.message="Program terminated with exit("+l+")",this.status=l}var vp=!1;ai=function l(){ps||pa(),ps||(ai=l)};function Sp(l){var u=a._main,d=0,p=0;try{var _=u(d,p);return Hl(_,!0),_}catch(S){return $c(S)}finally{vp=!0}}function pa(l){if(l=l||b,an>0)return;if(x){f(a),Cc(),postMessage({cmd:"loaded"});return}if(wf(),an>0)return;function u(){ps||(ps=!0,a.calledRun=!0,!ta&&(Cc(),vf(),f(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),zl&&Sp(l),Sf()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),u()},1)):u()}a.run=pa;function Hl(l,u){if(oi=l,!u&&x)throw Yc(l),"unwind";Ip(l)}function Ip(l){oi=l,ra()||(E.terminateAllThreads(),a.onExit&&a.onExit(l),ta=!0),J(l,new ui(l))}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();var zl=!0;return a.noInitialRun&&(zl=!1),pa(),t.ready}})(),rf=hy;var Xo=class{constructor(t,e){this._bindings=t,this._conn=e}close(){this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}query(t){let e=this._bindings.runQuery(this._conn,t),n=Ot.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(t){let e=this._bindings.startPendingQuery(this._conn,t);for(;e==null;)e=await new Promise((s,o)=>{try{s(this._bindings.pollPendingQuery(this._conn))}catch(c){o(c)}});let n=new Go(this._bindings,this._conn,e),i=Ot.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(t){return this._bindings.getTableNames(this._conn,t)}prepare(t){let e=this._bindings.createPrepared(this._conn,t);return new mc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=Wo(t,"stream");this.insertArrowFromIPCStream(n,e)}insertArrowFromIPCStream(t,e){this._bindings.insertArrowFromIPCStream(this._conn,t,e)}insertCSVFromPath(t,e){this._bindings.insertCSVFromPath(this._conn,t,e)}insertJSONFromPath(t,e){this._bindings.insertJSONFromPath(this._conn,t,e)}},Go=class{constructor(t,e,n){this.bindings=t;this.conn=e;this.header=n;this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let t=this.bindings.fetchQueryResults(this.conn);return this._depleted=t.length==0,{done:this._depleted,value:t}}[Symbol.iterator](){return this}},mc=class{constructor(t,e,n){this.bindings=t,this.connectionId=e,this.statementId=n}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...t){let e=this.bindings.runPrepared(this.connectionId,this.statementId,t),n=Ot.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new Go(this.bindings,this.connectionId,e),i=Ot.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};var of=new TextEncoder,nf=new TextDecoder("utf-8");function _c(r,t,e){let n=of.encode(e),i=r._malloc(n.byteLength),s=r.HEAPU8.subarray(i,i+n.byteLength);s.set(n),r.HEAPF64[(t>>3)+0]=1,r.HEAPF64[(t>>3)+1]=i,r.HEAPF64[(t>>3)+2]=s.byteLength}function bc(r){switch(r){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function yc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*bc(e));switch(e){case"UINT8":return new Uint8Array(i.buffer,i.byteOffset,n);case"INT8":return new Int8Array(i.buffer,i.byteOffset,n);case"INT32":return new Int32Array(i.buffer,i.byteOffset,n);case"FLOAT":return new Float32Array(i.buffer,i.byteOffset,n);case"DOUBLE":return new Float64Array(i.buffer,i.byteOffset,n);case"VARCHAR":return new Float64Array(i.buffer,i.byteOffset,n);default:return new Array(0)}}function sf(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function Ko(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function af(r,t,e,n,i,s,o,c){try{let a=r._udfFunctions.get(n);if(!a){_c(t,e,"Unknown UDF with id: "+n);return}let f=nf.decode(t.HEAPU8.subarray(i,i+s)),m=JSON.parse(f),y=Ko(t,o,c/8),b=Q=>{var te;let Nt=null;switch(Q.validityBuffer!==void 0&&(Nt=sf(t,y[Q.validityBuffer],m.rows)),Q.physicalType){case"VARCHAR":{if(Q.dataBuffer===null||Q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(Q.lengthBuffer===null||Q.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let Yt=yc(t,y[Q.dataBuffer],Q.physicalType,m.rows),Xt=[],Pt=Ko(t,y[Q.lengthBuffer],m.rows);for(let ut=0;ut<m.rows;++ut){if(Nt!=null&&!Nt[ut]){Xt.push(null);continue}let dt=t.HEAPU8.subarray(Yt[ut],Yt[ut]+Pt[ut]),rr=nf.decode(dt);Xt.push(rr)}return ut=>Xt[ut]}case"STRUCT":{let Yt={},Xt=[];for(let Pt=0;Pt<(((te=Q.children)==null?void 0:te.length)||0);++Pt){let ut=Q.children[Pt],dt=b(ut);Xt.push(rr=>{Yt[ut.name]=dt(rr)})}return Nt!=null?Pt=>{if(!Nt[Pt])return null;for(let ut of Xt)ut(Pt);return Yt}:Pt=>{for(let ut of Xt)ut(Pt);return Yt}}default:{if(Q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+Q.physicalType);let Yt=yc(t,y[Q.dataBuffer],Q.physicalType,m.rows);return Nt!=null?Xt=>Nt[Xt]?Yt[Xt]:null:Xt=>Yt[Xt]}}},I=[];for(let Q=0;Q<m.args.length;++Q)I.push(b(m.args[Q]));let J=m.rows*bc(m.ret.physicalType),Z=t._malloc(J),ct=yc(t,Z,m.ret.physicalType,m.rows),st=t._malloc(m.rows),x=sf(t,st,m.rows);if(ct.length==0||x.length==0){_c(t,e,"Can't create physical arrays for result");return}let St=ct;m.ret.physicalType=="VARCHAR"&&(St=new Array(m.rows));let Tn=[];for(let Q=0;Q<m.args.length;++Q)Tn.push(null);for(let Q=0;Q<m.rows;++Q){for(let te=0;te<m.args.length;++te)Tn[te]=I[te](Q);let Nt=a.func(...Tn);St[Q]=Nt,x[Q]=Nt==null?0:1}let sn=0;switch(m.ret.physicalType){case"VARCHAR":{let Q=new Array(0);sn=t._malloc(m.rows*bc("DOUBLE"));let Nt=Ko(t,sn,m.rows),te=0;for(let ut=0;ut<m.rows;++ut){let dt=of.encode(St[ut]||"");Q.push(dt),Nt[ut]=dt.length,te+=dt.length}let Yt=t._malloc(te),Xt=t.HEAPU8.subarray(Yt,Yt+te),Pt=0;for(let ut=0;ut<m.rows;++ut){ct[ut]=Pt;let dt=Q[ut];Xt.subarray(Pt,Pt+dt.length).set(dt),Pt+=dt.length}}}let es=3*8,on=t._malloc(es),ii=Ko(t,on,3);ii[0]=Z,ii[1]=st,ii[2]=sn,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=on,t.HEAPF64[(e>>3)+2]=0}catch(a){_c(t,e,a.toString())}}function my(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var _y=my();function wr(r,t){r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Fn(r,t,e){let n=r.HEAPU8.subarray(t,t+e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function j(r,t,e){return _y(r.HEAPU8.subarray(t,t+e))}function at(r,t,e,n){let i=r.stackSave(),s=r.stackAlloc(3*8);e.unshift("number"),n.unshift(s),r.ccall(t,null,e,n);let o=r.HEAPF64[(s>>3)+0],c=r.HEAPF64[(s>>3)+1],a=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[o,c,a]}function yt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var Jo=class{constructor(t){let e=new Float64Array(t.buffer,t.byteOffset,t.byteLength/8),n=new Uint8Array(new ArrayBuffer(t.byteLength));n.set(t.subarray(7*8)),this.totalFileReadsCold=e[0],this.totalFileReadsAhead=e[1],this.totalFileReadsCached=e[2],this.totalFileWrites=e[3],this.totalPageAccesses=e[4],this.totalPageLoads=e[5],this.blockSize=e[6],this.blockStats=n}getBlockStats(t,e){return e=e||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},e.file_writes=this.blockStats[t*3+0]&15,e.file_reads_cold=this.blockStats[t*3+0]>>4,e.file_reads_ahead=this.blockStats[t*3+1]&15,e.file_reads_cached=this.blockStats[t*3+1]>>4,e.page_accesses=this.blockStats[t*3+1]&15,e.page_loads=this.blockStats[t*3+1]>>4,e}};var yy=new TextEncoder;var qo=class{constructor(t,e){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=t,this._runtime=e,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(t=e=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(t),await this._initPromise),this._initPromise=new Promise(e=>{this._initPromiseResolver=e}),this.onInstantiationProgress=[t],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(e=>e!=t),this)}open(t){let[e,n,i]=at(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(j(this.mod,n,i));yt(this.mod)}reset(){let[t,e,n]=at(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));yt(this.mod)}getVersion(){let[t,e,n]=at(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));let i=j(this.mod,e,n);return yt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let[e,n,i]=at(this.mod,"duckdb_web_tokenize",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=j(this.mod,n,i);return yt(this.mod),JSON.parse(s)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Xo(this,t)}disconnect(t){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[t]),this.pthread)for(let e of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])e.postMessage({cmd:"dropUDFFunctions",connectionId:t})}runQuery(t,e){let[n,i,s]=at(this.mod,"duckdb_web_query_run",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));let o=Fn(this.mod,i,s);return yt(this.mod),o}startPendingQuery(t,e){let[n,i,s]=at(this.mod,"duckdb_web_pending_query_start",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));if(i==0)return null;let o=Fn(this.mod,i,s);return yt(this.mod),o}pollPendingQuery(t){let[e,n,i]=at(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));if(n==0)return null;let s=Fn(this.mod,n,i);return yt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=at(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=Fn(this.mod,n,i);return yt(this.mod),s}getTableNames(t,e){let[n,i,s]=at(this.mod,"duckdb_web_get_tablenames",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));let o=j(this.mod,i,s);return yt(this.mod),JSON.parse(o)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:ni(n)},o={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[c,a,f]=at(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(c!==0)throw new Error(j(this.mod,a,f));if(yt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(o.functionId,o),this.pthread)for(let m of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])m.postMessage({cmd:"registerUDFFunction",udf:o})}createPrepared(t,e){let[n,i,s]=at(this.mod,"duckdb_web_prepared_create",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));return yt(this.mod),i}closePrepared(t,e){let[n,i,s]=at(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}runPrepared(t,e,n){let[i,s,o]=at(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(j(this.mod,s,o));let c=Fn(this.mod,s,o);return yt(this.mod),c}sendPrepared(t,e,n){let[i,s,o]=at(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(j(this.mod,s,o));let c=Fn(this.mod,s,o);return yt(this.mod),c}insertArrowFromIPCStream(t,e,n){if(e.length==0)return;let i=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(i,i+e.length).set(e);let o=n?JSON.stringify(n):"",[c,a,f]=at(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,o]);if(c!==0)throw new Error(j(this.mod,a,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push($o(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,a]=at(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(j(this.mod,c,a))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push($o(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,a]=at(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(j(this.mod,c,a))}globFiles(t){let[e,n,i]=at(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=j(this.mod,n,i);yt(this.mod);let o=JSON.parse(s);return o==null?[]:o}registerFileURL(t,e){e===void 0&&(e=t);let[n,i,s]=at(this.mod,"duckdb_web_fs_register_file_url",["string","string","number"],[t,e,-1]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}registerFileText(t,e){let n=yy.encode(e);this.registerFileBuffer(t,n)}registerFileBuffer(t,e){let n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,o,c]=at(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(j(this.mod,o,c));yt(this.mod)}registerFileHandle(t,e){let[n,i,s]=at(this.mod,"duckdb_web_fs_register_file_url",["string","string","number"],[t,t,-1]);if(n!==0)throw new Error(j(this.mod,i,s));if(yt(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),this.pthread){for(let o of this.pthread.runningWorkers)o.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e});for(let o of this.pthread.unusedWorkers)o.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=at(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));yt(this.mod)}dropFiles(){let[t,e,n]=at(this.mod,"duckdb_web_fs_drop_files",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));yt(this.mod)}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(t,e){let[n,i,s]=at(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}copyFileToBuffer(t){let[e,n,i]=at(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=this.mod.HEAPU8.subarray(n,n+i),o=new Uint8Array(s.length);return o.set(s),yt(this.mod),o}collectFileStatistics(t,e){let[n,i,s]=at(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=at(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));return new Jo(this.mod.HEAPU8.subarray(n,n+i))}};var Zo=class extends qo{constructor(e,n,i,s){super(e,n);this.mainModuleURL=i,this.pthreadWorkerURL=s}locateFile(e,n){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error(`WASM instantiation requested unexpected file: prefix=${n} path=${e}`)}instantiateWasm(e,n){globalThis.DUCKDB_RUNTIME=this._runtime;let i=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let o=(async()=>{var Z;let c=new Request(this.mainModuleURL),a=await fetch(c),f=a.headers.get("content-length"),m=f&&parseInt(f,10)||0,y=new Date,b={startedAt:y,updatedAt:y,bytesTotal:m||0,bytesLoaded:0},I={transform(ct,st){b.bytesLoaded+=ct.byteLength;let x=new Date;if(x.getTime()-b.updatedAt.getTime()<20){b.updatedAt=x,st.enqueue(ct);return}for(let St of i)St(b);st.enqueue(ct)}},J=new TransformStream(I);return new Response((Z=a.body)==null?void 0:Z.pipeThrough(J),a)})();WebAssembly.instantiateStreaming(o,e).then(c=>{n(c.instance,c.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let s=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(s),e).then(o=>{n(o.instance,o.module)})}else if(typeof XMLHttpRequest=="function"){let s=new XMLHttpRequest,o=this.mainModuleURL,c=new Date,a={startedAt:c,updatedAt:c,bytesTotal:0,bytesLoaded:0};s.open("GET",o),s.responseType="arraybuffer",s.onerror=f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+f}),new Error(f.toString())},s.onprogress=f=>{a.bytesTotal=f.total,a.bytesLoaded=f.loaded;let m=new Date;if(m.getTime()-a.updatedAt.getTime()<20){a.updatedAt=m;return}for(let y of i)y(a)},s.onload=()=>{WebAssembly.instantiate(s.response,e).then(f=>{n(f.instance,f.module)}).catch(f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+f}),new Error(f)})},s.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let o=new Request(this.mainModuleURL),a=await(await fetch(o)).arrayBuffer();WebAssembly.instantiate(a,e).then(f=>{n(f.instance,f.module)})})();return[]}};var Qo=class extends Zo{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return rf({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var en=Wl(cf()),lf=function(r,t,e){var n;if((n=r==null?void 0:r.endpoint)!=null&&n.startsWith("http")){let i=`${r==null?void 0:r.endpoint}`,s=i.indexOf("://")+3;return i.substring(s)}else return r!=null&&r.endpoint?`${e}.${r==null?void 0:r.endpoint}`:`${e}.s3.amazonaws.com`};function by(r,t,e){var i,s,o,c;let n=uf(t);return{url:n.path,query:"",host:lf(r,t,n.bucket),region:(i=r==null?void 0:r.region)!=null?i:"",service:"s3",method:e,accessKeyId:(s=r==null?void 0:r.accessKeyId)!=null?s:"",secretAccessKey:(o=r==null?void 0:r.secretAccessKey)!=null?o:"",sessionToken:(c=r==null?void 0:r.sessionToken)!=null?c:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function gy(r,t=!1){let e="0123456789ABCDEF",n="";for(let i=0;i<r.length;i++){let s=r[i];s>="A"&&s<="Z"||s>="a"&&s<="z"||s>="0"&&s<="9"||s=="_"||s=="-"||s=="~"||s=="."?n+=s:s=="/"?t?n+="%2F":n+=s:(n+="%",n+=e[s.charCodeAt(0)>>4],n+=e[s.charCodeAt(0)&15])}return n}function wy(r,t=null){var J;let e=(J=t==null?void 0:t.contentHash)!=null?J:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n=new Map;n.set("x-amz-date",r.datetimeNow),n.set("x-amz-content-sha256",e),r.sessionToken&&n.set("x-amz-security-token",r.sessionToken);let i="";t!=null&&t.contentType&&(i+="content-type;"),i+="host;x-amz-content-sha256;x-amz-date",r.sessionToken&&(i+=";x-amz-security-token");let s=r.method+`
|
|
13
|
+
`},"%p":function(w){return w.tm_hour>=0&&w.tm_hour<12?"AM":"PM"},"%S":function(w){return bt(w.tm_sec,2)},"%t":function(){return" "},"%u":function(w){return w.tm_wday||7},"%U":function(w){var O=w.tm_yday+7-w.tm_wday;return bt(Math.floor(O/7),2)},"%V":function(w){var O=Math.floor((w.tm_yday+7-(w.tm_wday+6)%7)/7);if((w.tm_wday+371-w.tm_yday-2)%7<=2&&O++,O){if(O==53){var Kt=(w.tm_wday+371-w.tm_yday)%7;Kt!=4&&(Kt!=3||!cs(w.tm_year))&&(O=1)}}else{O=52;var At=(w.tm_wday+7-w.tm_yday-1)%7;(At==4||At==5&&cs(w.tm_year%400-1))&&O++}return bt(O,2)},"%w":function(w){return w.tm_wday},"%W":function(w){var O=w.tm_yday+7-(w.tm_wday+6)%7;return bt(Math.floor(O/7),2)},"%y":function(w){return(w.tm_year+1900).toString().substring(2)},"%Y":function(w){return w.tm_year+1900},"%z":function(w){var O=w.tm_gmtoff,At=O>=0;return O=Math.abs(O)/60,O=O/60*100+O%60,(At?"+":"-")+String("0000"+O).slice(-4)},"%Z":function(w){return w.tm_zone},"%%":function(){return"%"}};g=g.replace(/%%/g,"\0\0");for(var F in nr)g.includes(F)&&(g=g.replace(new RegExp(F,"g"),nr[F](S)));g=g.replace(/\0\0/g,"%");var di=Bh(g,!1);return di.length>u?0:(Fc(di,l),di.length-1)}function Fh(l,u,d,p){return xh(l,u,d,p)}E.init();var Th=[null,Yc,Xc,Kc,tl,el,rl,nl,il,sl,ol,al,cl,ll,ul,dl,fl,hl,pl,ml,_l,yl,bl,gl,wl,Al,xl,Fl,Tl,Bl,Dl,El,Ol,Ml,Rl];function Bh(l,u,d){var p=d>0?d:pf(l)+1,_=new Array(p),S=xc(l,_,0,_.length);return u&&(_.length=S),_}var Dh={b:Cf,v:Pf,s:Vf,aa:Gc,W:Kc,Y:tl,X:el,Q:rl,c:nl,ia:il,y:sl,ea:ol,S:al,V:cl,ka:ll,fa:ul,ja:dl,ga:fl,r:hl,T:pl,N:ml,p:_l,U:yl,l:bl,ha:gl,q:wl,Z:zf,o:jf,_:Wf,sa:$f,ba:Yf,ra:Gf,da:Kf,I:Jf,f:qf,G:Zf,H:Qf,E:th,F:eh,k:rh,C:nh,K:ih,D:sh,L:oh,g:ah,J:ch,h:lh,B:uh,j:dh,M:fh,m:hh,la:Il,d:os,P:ph,ma:mh,z:_h,qa:bh,u:gh,oa:Al,pa:xl,$:Wc,e:Fl,x:Tl,w:Bl,t:Dl,A:El,O:Ol,i:Ml,n:Rl,ca:as,R:Sh,a:It||a.wasmMemory,na:Fh},Fy=Ef(),Eh=a.___wasm_call_ctors=function(){return(Eh=a.___wasm_call_ctors=a.asm.ta).apply(null,arguments)},Oh=a._main=function(){return(Oh=a._main=a.asm.ua).apply(null,arguments)},Mh=a._duckdb_web_fs_glob_add_path=function(){return(Mh=a._duckdb_web_fs_glob_add_path=a.asm.va).apply(null,arguments)},Rh=a._duckdb_web_clear_response=function(){return(Rh=a._duckdb_web_clear_response=a.asm.wa).apply(null,arguments)},Uh=a._duckdb_web_fail_with=function(){return(Uh=a._duckdb_web_fail_with=a.asm.xa).apply(null,arguments)},kh=a._duckdb_web_reset=function(){return(kh=a._duckdb_web_reset=a.asm.ya).apply(null,arguments)},Nh=a._duckdb_web_connect=function(){return(Nh=a._duckdb_web_connect=a.asm.za).apply(null,arguments)},Lh=a._duckdb_web_disconnect=function(){return(Lh=a._duckdb_web_disconnect=a.asm.Aa).apply(null,arguments)},Ch=a._duckdb_web_flush_files=function(){return(Ch=a._duckdb_web_flush_files=a.asm.Ba).apply(null,arguments)},Ph=a._duckdb_web_flush_file=function(){return(Ph=a._duckdb_web_flush_file=a.asm.Ca).apply(null,arguments)},Vh=a._duckdb_web_open=function(){return(Vh=a._duckdb_web_open=a.asm.Da).apply(null,arguments)},Hh=a._duckdb_web_get_global_file_info=function(){return(Hh=a._duckdb_web_get_global_file_info=a.asm.Ea).apply(null,arguments)},zh=a._duckdb_web_collect_file_stats=function(){return(zh=a._duckdb_web_collect_file_stats=a.asm.Fa).apply(null,arguments)},jh=a._duckdb_web_export_file_stats=function(){return(jh=a._duckdb_web_export_file_stats=a.asm.Ga).apply(null,arguments)},Wh=a._duckdb_web_fs_drop_file=function(){return(Wh=a._duckdb_web_fs_drop_file=a.asm.Ha).apply(null,arguments)},$h=a._duckdb_web_fs_drop_files=function(){return($h=a._duckdb_web_fs_drop_files=a.asm.Ia).apply(null,arguments)},Yh=a._duckdb_web_fs_glob_file_infos=function(){return(Yh=a._duckdb_web_fs_glob_file_infos=a.asm.Ja).apply(null,arguments)},Xh=a._duckdb_web_fs_get_file_info_by_id=function(){return(Xh=a._duckdb_web_fs_get_file_info_by_id=a.asm.Ka).apply(null,arguments)},Gh=a._duckdb_web_fs_get_file_info_by_name=function(){return(Gh=a._duckdb_web_fs_get_file_info_by_name=a.asm.La).apply(null,arguments)},Kh=a._duckdb_web_fs_set_file_descriptor=function(){return(Kh=a._duckdb_web_fs_set_file_descriptor=a.asm.Ma).apply(null,arguments)},Jh=a._duckdb_web_fs_register_file_url=function(){return(Jh=a._duckdb_web_fs_register_file_url=a.asm.Na).apply(null,arguments)},qh=a._duckdb_web_fs_register_file_buffer=function(){return(qh=a._duckdb_web_fs_register_file_buffer=a.asm.Oa).apply(null,arguments)},Zh=a._duckdb_web_copy_file_to_buffer=function(){return(Zh=a._duckdb_web_copy_file_to_buffer=a.asm.Pa).apply(null,arguments)},Qh=a._duckdb_web_copy_file_to_path=function(){return(Qh=a._duckdb_web_copy_file_to_path=a.asm.Qa).apply(null,arguments)},tp=a._duckdb_web_get_version=function(){return(tp=a._duckdb_web_get_version=a.asm.Ra).apply(null,arguments)},ep=a._duckdb_web_get_feature_flags=function(){return(ep=a._duckdb_web_get_feature_flags=a.asm.Sa).apply(null,arguments)},rp=a._duckdb_web_tokenize=function(){return(rp=a._duckdb_web_tokenize=a.asm.Ta).apply(null,arguments)},np=a._duckdb_web_udf_scalar_create=function(){return(np=a._duckdb_web_udf_scalar_create=a.asm.Ua).apply(null,arguments)},ip=a._duckdb_web_prepared_create=function(){return(ip=a._duckdb_web_prepared_create=a.asm.Va).apply(null,arguments)},sp=a._duckdb_web_prepared_close=function(){return(sp=a._duckdb_web_prepared_close=a.asm.Wa).apply(null,arguments)},op=a._duckdb_web_prepared_run=function(){return(op=a._duckdb_web_prepared_run=a.asm.Xa).apply(null,arguments)},ap=a._duckdb_web_prepared_send=function(){return(ap=a._duckdb_web_prepared_send=a.asm.Ya).apply(null,arguments)},cp=a._duckdb_web_query_run=function(){return(cp=a._duckdb_web_query_run=a.asm.Za).apply(null,arguments)},lp=a._duckdb_web_pending_query_start=function(){return(lp=a._duckdb_web_pending_query_start=a.asm._a).apply(null,arguments)},up=a._duckdb_web_pending_query_poll=function(){return(up=a._duckdb_web_pending_query_poll=a.asm.$a).apply(null,arguments)},dp=a._duckdb_web_pending_query_cancel=function(){return(dp=a._duckdb_web_pending_query_cancel=a.asm.ab).apply(null,arguments)},fp=a._duckdb_web_query_fetch_results=function(){return(fp=a._duckdb_web_query_fetch_results=a.asm.bb).apply(null,arguments)},hp=a._duckdb_web_get_tablenames=function(){return(hp=a._duckdb_web_get_tablenames=a.asm.cb).apply(null,arguments)},pp=a._duckdb_web_insert_arrow_from_ipc_stream=function(){return(pp=a._duckdb_web_insert_arrow_from_ipc_stream=a.asm.db).apply(null,arguments)},mp=a._duckdb_web_insert_csv_from_path=function(){return(mp=a._duckdb_web_insert_csv_from_path=a.asm.eb).apply(null,arguments)},_p=a._duckdb_web_insert_json_from_path=function(){return(_p=a._duckdb_web_insert_json_from_path=a.asm.fb).apply(null,arguments)},yp=a._emscripten_tls_init=function(){return(yp=a._emscripten_tls_init=a.asm.gb).apply(null,arguments)},Nl=a.__emscripten_thread_init=function(){return(Nl=a.__emscripten_thread_init=a.asm.hb).apply(null,arguments)},bp=a.__emscripten_thread_crashed=function(){return(bp=a.__emscripten_thread_crashed=a.asm.ib).apply(null,arguments)},ls=a._htonl=function(){return(ls=a._htonl=a.asm.jb).apply(null,arguments)},us=a._htons=function(){return(us=a._htons=a.asm.kb).apply(null,arguments)},Ll=a._emscripten_run_in_main_runtime_thread_js=function(){return(Ll=a._emscripten_run_in_main_runtime_thread_js=a.asm.lb).apply(null,arguments)},ua=a._ntohs=function(){return(ua=a._ntohs=a.asm.mb).apply(null,arguments)},Cl=a._emscripten_proxy_execute_queue=function(){return(Cl=a._emscripten_proxy_execute_queue=a.asm.nb).apply(null,arguments)},da=a.__emscripten_thread_free_data=function(){return(da=a.__emscripten_thread_free_data=a.asm.ob).apply(null,arguments)},gp=a.__emscripten_thread_exit=function(){return(gp=a.__emscripten_thread_exit=a.asm.pb).apply(null,arguments)},ds=a._pthread_self=function(){return(ds=a._pthread_self=a.asm.qb).apply(null,arguments)},fa=a._malloc=function(){return(fa=a._malloc=a.asm.rb).apply(null,arguments)},wp=a._free=function(){return(wp=a._free=a.asm.sb).apply(null,arguments)},Pl=a._emscripten_stack_set_limits=function(){return(Pl=a._emscripten_stack_set_limits=a.asm.ub).apply(null,arguments)},ha=a.stackSave=function(){return(ha=a.stackSave=a.asm.vb).apply(null,arguments)},fs=a.stackRestore=function(){return(fs=a.stackRestore=a.asm.wb).apply(null,arguments)},hs=a.stackAlloc=function(){return(hs=a.stackAlloc=a.asm.xb).apply(null,arguments)},Vl=a.__emscripten_allow_main_runtime_queued_calls=1110544;a.ccall=hf,a.keepRuntimeAlive=ra,a.PThread=E,a.PThread=E,a.wasmMemory=It,a.ExitStatus=ui;var ps;function ui(l){this.name="ExitStatus",this.message="Program terminated with exit("+l+")",this.status=l}var vp=!1;ai=function l(){ps||pa(),ps||(ai=l)};function Sp(l){var u=a._main,d=0,p=0;try{var _=u(d,p);return Hl(_,!0),_}catch(S){return $c(S)}finally{vp=!0}}function pa(l){if(l=l||b,an>0)return;if(x){f(a),Cc(),postMessage({cmd:"loaded"});return}if(wf(),an>0)return;function u(){ps||(ps=!0,a.calledRun=!0,!ta&&(Cc(),vf(),f(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),zl&&Sp(l),Sf()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),u()},1)):u()}a.run=pa;function Hl(l,u){if(oi=l,!u&&x)throw Yc(l),"unwind";Ip(l)}function Ip(l){oi=l,ra()||(E.terminateAllThreads(),a.onExit&&a.onExit(l),ta=!0),J(l,new ui(l))}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();var zl=!0;return a.noInitialRun&&(zl=!1),pa(),t.ready}})(),rf=hy;var Xo=class{constructor(t,e){this._bindings=t,this._conn=e}close(){this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}query(t){let e=this._bindings.runQuery(this._conn,t),n=Ot.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(t){let e=this._bindings.startPendingQuery(this._conn,t);for(;e==null;)e=await new Promise((s,o)=>{try{s(this._bindings.pollPendingQuery(this._conn))}catch(c){o(c)}});let n=new Go(this._bindings,this._conn,e),i=Ot.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(t){return this._bindings.getTableNames(this._conn,t)}prepare(t){let e=this._bindings.createPrepared(this._conn,t);return new mc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=Wo(t,"stream");this.insertArrowFromIPCStream(n,e)}insertArrowFromIPCStream(t,e){this._bindings.insertArrowFromIPCStream(this._conn,t,e)}insertCSVFromPath(t,e){this._bindings.insertCSVFromPath(this._conn,t,e)}insertJSONFromPath(t,e){this._bindings.insertJSONFromPath(this._conn,t,e)}},Go=class{constructor(t,e,n){this.bindings=t;this.conn=e;this.header=n;this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let t=this.bindings.fetchQueryResults(this.conn);return this._depleted=t.length==0,{done:this._depleted,value:t}}[Symbol.iterator](){return this}},mc=class{constructor(t,e,n){this.bindings=t,this.connectionId=e,this.statementId=n}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...t){let e=this.bindings.runPrepared(this.connectionId,this.statementId,t),n=Ot.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new Go(this.bindings,this.connectionId,e),i=Ot.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};var of=new TextEncoder,nf=new TextDecoder("utf-8");function _c(r,t,e){let n=of.encode(e),i=r._malloc(n.byteLength),s=r.HEAPU8.subarray(i,i+n.byteLength);s.set(n),r.HEAPF64[(t>>3)+0]=1,r.HEAPF64[(t>>3)+1]=i,r.HEAPF64[(t>>3)+2]=s.byteLength}function bc(r){switch(r){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function yc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*bc(e));switch(e){case"UINT8":return new Uint8Array(i.buffer,i.byteOffset,n);case"INT8":return new Int8Array(i.buffer,i.byteOffset,n);case"INT32":return new Int32Array(i.buffer,i.byteOffset,n);case"FLOAT":return new Float32Array(i.buffer,i.byteOffset,n);case"DOUBLE":return new Float64Array(i.buffer,i.byteOffset,n);case"VARCHAR":return new Float64Array(i.buffer,i.byteOffset,n);default:return new Array(0)}}function sf(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function Ko(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function af(r,t,e,n,i,s,o,c){try{let a=r._udfFunctions.get(n);if(!a){_c(t,e,"Unknown UDF with id: "+n);return}let f=nf.decode(t.HEAPU8.subarray(i,i+s)),m=JSON.parse(f),y=Ko(t,o,c/8),b=Q=>{var te;let Nt=null;switch(Q.validityBuffer!==void 0&&(Nt=sf(t,y[Q.validityBuffer],m.rows)),Q.physicalType){case"VARCHAR":{if(Q.dataBuffer===null||Q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(Q.lengthBuffer===null||Q.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let Yt=yc(t,y[Q.dataBuffer],Q.physicalType,m.rows),Xt=[],Pt=Ko(t,y[Q.lengthBuffer],m.rows);for(let ut=0;ut<m.rows;++ut){if(Nt!=null&&!Nt[ut]){Xt.push(null);continue}let dt=t.HEAPU8.subarray(Yt[ut],Yt[ut]+Pt[ut]),rr=nf.decode(dt);Xt.push(rr)}return ut=>Xt[ut]}case"STRUCT":{let Yt={},Xt=[];for(let Pt=0;Pt<(((te=Q.children)==null?void 0:te.length)||0);++Pt){let ut=Q.children[Pt],dt=b(ut);Xt.push(rr=>{Yt[ut.name]=dt(rr)})}return Nt!=null?Pt=>{if(!Nt[Pt])return null;for(let ut of Xt)ut(Pt);return Yt}:Pt=>{for(let ut of Xt)ut(Pt);return Yt}}default:{if(Q.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+Q.physicalType);let Yt=yc(t,y[Q.dataBuffer],Q.physicalType,m.rows);return Nt!=null?Xt=>Nt[Xt]?Yt[Xt]:null:Xt=>Yt[Xt]}}},I=[];for(let Q=0;Q<m.args.length;++Q)I.push(b(m.args[Q]));let J=m.rows*bc(m.ret.physicalType),Z=t._malloc(J),ct=yc(t,Z,m.ret.physicalType,m.rows),st=t._malloc(m.rows),x=sf(t,st,m.rows);if(ct.length==0||x.length==0){_c(t,e,"Can't create physical arrays for result");return}let St=ct;m.ret.physicalType=="VARCHAR"&&(St=new Array(m.rows));let Tn=[];for(let Q=0;Q<m.args.length;++Q)Tn.push(null);for(let Q=0;Q<m.rows;++Q){for(let te=0;te<m.args.length;++te)Tn[te]=I[te](Q);let Nt=a.func(...Tn);St[Q]=Nt,x[Q]=Nt==null?0:1}let sn=0;switch(m.ret.physicalType){case"VARCHAR":{let Q=new Array(0);sn=t._malloc(m.rows*bc("DOUBLE"));let Nt=Ko(t,sn,m.rows),te=0;for(let ut=0;ut<m.rows;++ut){let dt=of.encode(St[ut]||"");Q.push(dt),Nt[ut]=dt.length,te+=dt.length}let Yt=t._malloc(te),Xt=t.HEAPU8.subarray(Yt,Yt+te),Pt=0;for(let ut=0;ut<m.rows;++ut){ct[ut]=Pt;let dt=Q[ut];Xt.subarray(Pt,Pt+dt.length).set(dt),Pt+=dt.length}}}let es=3*8,on=t._malloc(es),ii=Ko(t,on,3);ii[0]=Z,ii[1]=st,ii[2]=sn,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=on,t.HEAPF64[(e>>3)+2]=0}catch(a){_c(t,e,a.toString())}}function my(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var _y=my();function wr(r,t){r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Fn(r,t,e){let n=r.HEAPU8.subarray(t,t+e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function j(r,t,e){return _y(r.HEAPU8.subarray(t,t+e))}function at(r,t,e,n){let i=r.stackSave(),s=r.stackAlloc(3*8);e.unshift("number"),n.unshift(s),r.ccall(t,null,e,n);let o=r.HEAPF64[(s>>3)+0],c=r.HEAPF64[(s>>3)+1],a=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[o,c,a]}function yt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var Jo=class{constructor(t){let e=new Float64Array(t.buffer,t.byteOffset,t.byteLength/8),n=new Uint8Array(new ArrayBuffer(t.byteLength));n.set(t.subarray(7*8)),this.totalFileReadsCold=e[0],this.totalFileReadsAhead=e[1],this.totalFileReadsCached=e[2],this.totalFileWrites=e[3],this.totalPageAccesses=e[4],this.totalPageLoads=e[5],this.blockSize=e[6],this.blockStats=n}getBlockStats(t,e){return e=e||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},e.file_writes=this.blockStats[t*3+0]&15,e.file_reads_cold=this.blockStats[t*3+0]>>4,e.file_reads_ahead=this.blockStats[t*3+1]&15,e.file_reads_cached=this.blockStats[t*3+1]>>4,e.page_accesses=this.blockStats[t*3+1]&15,e.page_loads=this.blockStats[t*3+1]>>4,e}};var yy=new TextEncoder;var qo=class{constructor(t,e){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=t,this._runtime=e,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(t=e=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(t),await this._initPromise),this._initPromise=new Promise(e=>{this._initPromiseResolver=e}),this.onInstantiationProgress=[t],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(e=>e!=t),this)}open(t){let[e,n,i]=at(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(j(this.mod,n,i));yt(this.mod)}reset(){let[t,e,n]=at(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));yt(this.mod)}getVersion(){let[t,e,n]=at(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));let i=j(this.mod,e,n);return yt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let[e,n,i]=at(this.mod,"duckdb_web_tokenize",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=j(this.mod,n,i);return yt(this.mod),JSON.parse(s)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Xo(this,t)}disconnect(t){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[t]),this.pthread)for(let e of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])e.postMessage({cmd:"dropUDFFunctions",connectionId:t})}runQuery(t,e){let[n,i,s]=at(this.mod,"duckdb_web_query_run",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));let o=Fn(this.mod,i,s);return yt(this.mod),o}startPendingQuery(t,e){let[n,i,s]=at(this.mod,"duckdb_web_pending_query_start",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));if(i==0)return null;let o=Fn(this.mod,i,s);return yt(this.mod),o}pollPendingQuery(t){let[e,n,i]=at(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));if(n==0)return null;let s=Fn(this.mod,n,i);return yt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=at(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=Fn(this.mod,n,i);return yt(this.mod),s}getTableNames(t,e){let[n,i,s]=at(this.mod,"duckdb_web_get_tablenames",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));let o=j(this.mod,i,s);return yt(this.mod),JSON.parse(o)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:ni(n)},o={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[c,a,f]=at(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(c!==0)throw new Error(j(this.mod,a,f));if(yt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(o.functionId,o),this.pthread)for(let m of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])m.postMessage({cmd:"registerUDFFunction",udf:o})}createPrepared(t,e){let[n,i,s]=at(this.mod,"duckdb_web_prepared_create",["number","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));return yt(this.mod),i}closePrepared(t,e){let[n,i,s]=at(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}runPrepared(t,e,n){let[i,s,o]=at(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(j(this.mod,s,o));let c=Fn(this.mod,s,o);return yt(this.mod),c}sendPrepared(t,e,n){let[i,s,o]=at(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(j(this.mod,s,o));let c=Fn(this.mod,s,o);return yt(this.mod),c}insertArrowFromIPCStream(t,e,n){if(e.length==0)return;let i=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(i,i+e.length).set(e);let o=n?JSON.stringify(n):"",[c,a,f]=at(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,o]);if(c!==0)throw new Error(j(this.mod,a,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push($o(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,a]=at(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(j(this.mod,c,a))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push($o(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,a]=at(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(j(this.mod,c,a))}globFiles(t){let[e,n,i]=at(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=j(this.mod,n,i);yt(this.mod);let o=JSON.parse(s);return o==null?[]:o}registerFileURL(t,e){e===void 0&&(e=t);let[n,i,s]=at(this.mod,"duckdb_web_fs_register_file_url",["string","string","number"],[t,e,-1]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}registerFileText(t,e){let n=yy.encode(e);this.registerFileBuffer(t,n)}registerFileBuffer(t,e){let n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,o,c]=at(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(j(this.mod,o,c));yt(this.mod)}registerFileHandle(t,e){let[n,i,s]=at(this.mod,"duckdb_web_fs_register_file_url",["string","string","number"],[t,t,-1]);if(n!==0)throw new Error(j(this.mod,i,s));if(yt(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),this.pthread){for(let o of this.pthread.runningWorkers)o.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e});for(let o of this.pthread.unusedWorkers)o.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=at(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));yt(this.mod)}dropFiles(){let[t,e,n]=at(this.mod,"duckdb_web_fs_drop_files",[],[]);if(t!==0)throw new Error(j(this.mod,e,n));yt(this.mod)}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(t,e){let[n,i,s]=at(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s));yt(this.mod)}copyFileToBuffer(t){let[e,n,i]=at(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));let s=this.mod.HEAPU8.subarray(n,n+i),o=new Uint8Array(s.length);return o.set(s),yt(this.mod),o}collectFileStatistics(t,e){let[n,i,s]=at(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(j(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=at(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(j(this.mod,n,i));return new Jo(this.mod.HEAPU8.subarray(n,n+i))}};var Zo=class extends qo{constructor(e,n,i,s){super(e,n);this.mainModuleURL=i,this.pthreadWorkerURL=s}locateFile(e,n){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error(`WASM instantiation requested unexpected file: prefix=${n} path=${e}`)}instantiateWasm(e,n){globalThis.DUCKDB_RUNTIME=this._runtime;let i=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let o=(async()=>{var Z;let c=new Request(this.mainModuleURL),a=await fetch(c),f=a.headers.get("content-length"),m=f&&parseInt(f,10)||0,y=new Date,b={startedAt:y,updatedAt:y,bytesTotal:m||0,bytesLoaded:0},I={transform(ct,st){b.bytesLoaded+=ct.byteLength;let x=new Date;if(x.getTime()-b.updatedAt.getTime()<20){b.updatedAt=x,st.enqueue(ct);return}for(let St of i)St(b);st.enqueue(ct)}},J=new TransformStream(I);return new Response((Z=a.body)==null?void 0:Z.pipeThrough(J),a)})();WebAssembly.instantiateStreaming(o,e).then(c=>{n(c.instance,c.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let s=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(s),e).then(o=>{n(o.instance,o.module)})}else if(typeof XMLHttpRequest=="function"){let s=new XMLHttpRequest,o=this.mainModuleURL,c=new Date,a={startedAt:c,updatedAt:c,bytesTotal:0,bytesLoaded:0};s.open("GET",o),s.responseType="arraybuffer",s.onerror=f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+f}),new Error(f.toString())},s.onprogress=f=>{a.bytesTotal=f.total,a.bytesLoaded=f.loaded;let m=new Date;if(m.getTime()-a.updatedAt.getTime()<20){a.updatedAt=m;return}for(let y of i)y(a)},s.onload=()=>{WebAssembly.instantiate(s.response,e).then(f=>{n(f.instance,f.module)}).catch(f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+f}),new Error(f)})},s.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let o=new Request(this.mainModuleURL),a=await(await fetch(o)).arrayBuffer();WebAssembly.instantiate(a,e).then(f=>{n(f.instance,f.module)})})();return[]}};var Qo=class extends Zo{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return rf({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var en=Wl(cf()),lf=function(r,t,e){var n;if((n=r==null?void 0:r.endpoint)!=null&&n.startsWith("http")){let i=`${r==null?void 0:r.endpoint}`,s=i.indexOf("://")+3;return i.substring(s)}else return r!=null&&r.endpoint?`${e}.${r==null?void 0:r.endpoint}`:`${e}.s3.amazonaws.com`};function by(r,t,e){var i,s,o,c;let n=uf(t);return{url:n.path,query:"",host:lf(r,t,n.bucket),region:(i=r==null?void 0:r.region)!=null?i:"",service:"s3",method:e,accessKeyId:(s=r==null?void 0:r.accessKeyId)!=null?s:"",secretAccessKey:(o=r==null?void 0:r.secretAccessKey)!=null?o:"",sessionToken:(c=r==null?void 0:r.sessionToken)!=null?c:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function gy(r,t=!1){let e="0123456789ABCDEF",n="";for(let i=0;i<r.length;i++){let s=r[i];s>="A"&&s<="Z"||s>="a"&&s<="z"||s>="0"&&s<="9"||s=="_"||s=="-"||s=="~"||s=="."?n+=s:s=="/"?t?n+="%2F":n+=s:(n+="%",n+=e[s.charCodeAt(0)>>4],n+=e[s.charCodeAt(0)&15])}return n}function wy(r,t=null){var J;let e=(J=t==null?void 0:t.contentHash)!=null?J:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n=new Map;n.set("x-amz-date",r.datetimeNow),n.set("x-amz-content-sha256",e),r.sessionToken&&n.set("x-amz-security-token",r.sessionToken);let i="";t!=null&&t.contentType&&(i+="content-type;"),i+="host;x-amz-content-sha256;x-amz-date",r.sessionToken&&(i+=";x-amz-security-token");let s=r.method+`
|
|
14
14
|
`+gy(r.url)+`
|
|
15
15
|
`+r.query;t!=null&&t.contentType&&(s+=`
|
|
16
16
|
content-type:`+(t==null?void 0:t.contentType)),s+=`
|