@influxdata/influxdb3-client 2.0.0 → 2.1.0-nightly.11532

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/influxdb.js CHANGED
@@ -15,6 +15,6 @@ ${t}`),new Function("x",`${t}
15
15
  return true;`)}function Eh(r){return typeof r!="bigint"?le(r):`${le(r)}n`}function ic(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function Yu(r,t=0){return r.length>=t?r.subarray(0,t):zi(new r.constructor(t),r,0)}var ye=class{constructor(t,e=0,i=1){this.length=Math.ceil(e/i),this.buffer=new t(this.length),this.stride=i,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,i=this.length*e,n=this.buffer.length;i>=n&&this._resize(n===0?ic(i*1,this.BYTES_PER_ELEMENT):ic(i*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=ic(t*this.stride,this.BYTES_PER_ELEMENT);let e=Yu(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=Yu(this.buffer,t)}},Ze=class extends ye{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},pi=class extends Ze{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:i}=this.reserve(t-this.length+1),n=t>>3,s=t%8,o=i[n]>>s&1;return e?o===0&&(i[n]|=1<<s,++this.numValid):o===1&&(i[n]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},mi=class extends Ze{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let i=this.length-1,n=this.reserve(t-i+1).buffer;return i<t++&&i>=0&&n.fill(n[i],i,t),n[t]=n[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var st=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=$t(t),this._nulls=new pi,e&&e.length>0&&(this._isValid=Xu(e))}toVector(){return new P([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:i,_nulls:n,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,i)=>e+i.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,i,n,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:d}=this;(e=c==null?void 0:c.flush(o))?n=l==null?void 0:l.flush(o):(n=l==null?void 0:l.flush(o))?t=u==null?void 0:u.flush(l.last()):t=u==null?void 0:u.flush(o),a>0&&(i=d==null?void 0:d.flush(o));let p=this.children.map(y=>y.flush());return this.clear(),E({type:s,length:o,nullCount:a,children:p,child:p[0],data:t,typeIds:e,nullBitmap:i,valueOffsets:n})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,i,n;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(i=this._offsets)===null||i===void 0||i.clear(),(n=this._typeIds)===null||n===void 0||n.clear();for(let s of this.children)s.clear();return this}};st.prototype.length=1;st.prototype.stride=1;st.prototype.children=null;st.prototype.finished=!1;st.prototype.nullValues=null;st.prototype._isValid=()=>!0;var mt=class extends st{constructor(t){super(t),this._values=new Ze(this.ArrayType,0,this.stride)}setValue(t,e){let i=this._values;return i.reserve(t-i.length+1),super.setValue(t,e)}},Et=class extends st{constructor(t){super(t),this._pendingLength=0,this._offsets=new mi(t.type)}setValue(t,e){let i=this._pending||(this._pending=new Map),n=i.get(t);n&&(this._pendingLength-=n.length),this._pendingLength+=e instanceof Be?e[vr].length:e.length,i.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var jr=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,i,n){return t.prep(8,24),t.writeInt64(BigInt(n!=null?n:0)),t.pad(4),t.writeInt32(i),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Ht=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):q.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Nt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new jr).__init(this.bb.__vector(this.bb_pos+i)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let i=this.bb.__offset(this.bb_pos,10);return i?(e||new jr).__init(this.bb.__vector(this.bb_pos+i)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new _t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,q.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var K=class r{constructor(t=[],e,i,n=q.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=nc(this.fields)),this.dictionaries=i,this.metadataVersion=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),i=this.fields.filter(n=>e.has(n.name));return new r(i,this.metadata)}selectAt(t){let e=t.map(i=>this.fields[i]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),i=[...this.fields],n=ao(ao(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=i.findIndex(l=>l.name===a.name);return~c?(i[c]=a.clone({metadata:ao(ao(new Map,i[c].metadata),a.metadata)}))&&!1:!0}),o=nc(s,new Map);return new r([...i,...s],n,new Map([...this.dictionaries,...o]))}};K.prototype.fields=null;K.prototype.metadata=null;K.prototype.dictionaries=null;var k=class r{static new(...t){let[e,i,n,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],i===void 0&&(i=t[0].type),n===void 0&&(n=t[0].nullable),s===void 0&&(s=t[0].metadata)),new r(`${e}`,i,n,s)}constructor(t,e,i=!1,n){this.name=t,this.type=e,this.nullable=i,this.metadata=n||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,i,n,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,i=this.type,n=this.nullable,s=this.metadata]=t:{name:e=this.name,type:i=this.type,nullable:n=this.nullable,metadata:s=this.metadata}=t[0],r.new(e,i,n,s)}};k.prototype.type=null;k.prototype.name=null;k.prototype.nullable=null;k.prototype.metadata=null;function ao(r,t){return new Map([...r||new Map,...t||new Map])}function nc(r,t=new Map){for(let e=-1,i=r.length;++e<i;){let s=r[e].type;if(b.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&nc(s.children,t)}return t}var Lh=Mr,Uh=jt,Qe=class{static decode(t){t=new Uh(D(t));let e=Ht.getRootAsFooter(t),i=K.decode(e.schema(),new Map,e.version());return new sc(i,e)}static encode(t){let e=new Lh,i=K.encode(e,t.schema);Ht.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())tr.encode(e,o);let n=e.endVector();Ht.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())tr.encode(e,o);let s=e.endVector();return Ht.startFooter(e),Ht.addSchema(e,i),Ht.addVersion(e,q.V5),Ht.addRecordBatches(e,n),Ht.addDictionaries(e,s),Ht.finishFooterBuffer(e,Ht.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=q.V5,i,n){this.schema=t,this.version=e,i&&(this._recordBatches=i),n&&(this._dictionaryBatches=n)}*recordBatches(){for(let t,e=-1,i=this.numRecordBatches;++e<i;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,i=this.numDictionaries;++e<i;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var sc=class extends Qe{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return tr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return tr.decode(e)}return null}},tr=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:i}=e,n=BigInt(e.offset),s=BigInt(e.bodyLength);return jr.createBlock(t,n,i,s)}constructor(t,e,i){this.metaDataLength=t,this.offset=z(i),this.bodyLength=z(e)}};var it=Object.freeze({done:!0,value:void 0}),ln=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},zr=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},co=class extends zr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(it);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return It.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return It.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return g(this,void 0,void 0,function*(){return yield this.abort(t),it})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),it})}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,i)=>{this.resolvers.push({resolve:e,reject:i})}):Promise.resolve(it)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var De=class extends co{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Pi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Pi)}toUint8Array(t=!1){return t?Pt(this._values)[0]:g(this,void 0,void 0,function*(){var e,i,n,s;let o=[],a=0;try{for(var c=!0,l=re(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){i={error:d}}finally{try{!c&&!e&&(n=l.return)&&(yield n.call(l))}finally{if(i)throw i.error}}return Pt(o,a)[0]})}},Fe=class{constructor(t){t&&(this.source=new oc(It.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Zt=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof De?this.source=new er(It.fromAsyncIterable(t)):gs(t)?this.source=new er(It.fromNodeStream(t)):ji(t)?this.source=new er(It.fromDOMStream(t)):ms(t)?this.source=new er(It.fromDOMStream(t.body)):ne(t)?this.source=new er(It.fromIterable(t)):ie(t)?this.source=new er(It.fromAsyncIterable(t)):Gt(t)&&(this.source=new er(It.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},oc=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||it)}return(t){return Object.create(this.source.return&&this.source.return(t)||it)}},er=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return g(this,arguments,void 0,function*(e,i="read"){return yield this.source.next({cmd:i,size:e})})}throw(t){return g(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||it;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return g(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||it;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var un=class extends Fe{constructor(t,e){super(),this.position=0,this.buffer=D(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:i}=this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:i,position:n}=this;return e&&n<i?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(i,n+Math.min(i-n,t)),e.subarray(n,this.position)):null}readAt(t,e){let i=this.buffer,n=Math.min(this.size,t+e);return i?i.subarray(t,n):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},xr=class extends Zt{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=g(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return g(this,void 0,void 0,function*(){let{buffer:e,byteOffset:i}=yield this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)})}seek(t){return g(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:i,position:n}=this;if(e&&n<i){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=n,o=0,a=0,c=Math.min(i,s+Math.min(i-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:i,size:n}=this;if(i&&t+e<n){let s=Math.min(n,t+e),o=new Uint8Array(s-t);return(yield i.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return g(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var cc={};cr(cc,{BaseInt64:()=>fn,Int128:()=>dn,Int64:()=>rr,Uint64:()=>ct});function yi(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var gi=8,ac=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],fn=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),n=e[3]*i[3];this.buffer[0]=n&65535;let s=n>>>16;return n=e[2]*i[3],s+=n,n=e[3]*i[2]>>>0,s+=n,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<n?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${yi(this.buffer[1])} ${yi(this.buffer[0])}`}},ct=class r extends fn{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let i=t.length,n=new r(e);for(let s=0;s<i;){let o=gi<i-s?gi:i-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([ac[o],0]));n.times(c),n.plus(a),s+=o}return n}static convertArray(t){let e=new Uint32Array(t.length*2);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+2*i*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},rr=class r extends fn{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,i=t.buffer[1]<<0;return e<i||e===i&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let i=t.startsWith("-"),n=t.length,s=new r(e);for(let o=i?1:0;o<n;){let a=gi<n-o?gi:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([ac[a],0]));s.times(l),s.plus(c),o+=a}return i?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+2*i*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},dn=class r{constructor(t){this.buffer=t}high(){return new rr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new rr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new ct(new Uint32Array([this.buffer[3],0])),i=new ct(new Uint32Array([this.buffer[2],0])),n=new ct(new Uint32Array([this.buffer[1],0])),s=new ct(new Uint32Array([this.buffer[0],0])),o=new ct(new Uint32Array([t.buffer[3],0])),a=new ct(new Uint32Array([t.buffer[2],0])),c=new ct(new Uint32Array([t.buffer[1],0])),l=new ct(new Uint32Array([t.buffer[0],0])),u=ct.multiply(s,l);this.buffer[0]=u.low();let d=new ct(new Uint32Array([u.high(),0]));return u=ct.multiply(n,l),d.plus(u),u=ct.multiply(s,c),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new ct(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(ct.multiply(i,l)).plus(ct.multiply(n,c)).plus(ct.multiply(s,a)),this.buffer[3]+=ct.multiply(e,l).plus(ct.multiply(i,c)).plus(ct.multiply(n,a)).plus(ct.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${yi(this.buffer[3])} ${yi(this.buffer[2])} ${yi(this.buffer[1])} ${yi(this.buffer[0])}`}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let i=t.startsWith("-"),n=t.length,s=new r(e);for(let o=i?1:0;o<n;){let a=gi<n-o?gi:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([ac[a],0,0,0]));s.times(l),s.plus(c),o+=a}return i?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+16*i,4));return e}};var hn=class extends v{constructor(t,e,i,n,s=q.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=i,this.dictionaries=n,this.metadataVersion=s}visit(t){return super.visit(t instanceof k?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return E({type:t,length:e})}visitBool(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitInt(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDate(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTime(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitList(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return this.metadataVersion<q.V5&&this.readNullBitmap(t,i),t.mode===Z.Sparse?this.visitSparseUnion(t,{length:e,nullCount:i}):this.visitDenseUnion(t,{length:e,nullCount:i})}visitDenseUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:i}=this.nextFieldNode()){return E({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,i=this.nextBufferRange()){return e>0&&this.readData(t,i)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+e)}readDictionary(t){return this.dictionaries.get(t.id)}},lo=class extends hn{constructor(t,e,i,n,s){super(new Uint8Array(0),e,i,n,s),this.sources=t}readNullBitmap(t,e,{offset:i}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Vr(this.sources[i])}readOffsets(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:i}=this;return b.isTimestamp(t)?R(Uint8Array,rr.convertArray(i[e])):(b.isInt(t)||b.isTime(t))&&t.bitWidth===64||b.isDuration(t)?R(Uint8Array,rr.convertArray(i[e])):b.isDate(t)&&t.unit===lt.MILLISECOND?R(Uint8Array,rr.convertArray(i[e])):b.isDecimal(t)?R(Uint8Array,dn.convertArray(i[e])):b.isBinary(t)||b.isLargeBinary(t)||b.isFixedSizeBinary(t)?Mh(i[e]):b.isBool(t)?Vr(i[e]):b.isUtf8(t)||b.isLargeUtf8(t)?Ie(i[e].join("")):R(Uint8Array,R(t.ArrayType,i[e].map(n=>+n)))}};function Mh(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)e[i>>1]=Number.parseInt(t.slice(i,i+2),16);return e}var bi=class extends Et{constructor(t){super(t),this._values=new ye(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,0);else{let c=a.length;n.set(a,s),i.set(o,c),s+=c}}};var _i=class extends Et{constructor(t){super(t),this._values=new ye(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,BigInt(0));else{let c=a.length;n.set(a,s),i.set(o,BigInt(c)),s+=c}}};var uo=class extends st{constructor(t){super(t),this._values=new pi}setValue(t,e){this._values.set(t,+e)}};var Wr=class extends mt{};Wr.prototype._setValue=ja;var pn=class extends Wr{};pn.prototype._setValue=Rs;var mn=class extends Wr{};mn.prototype._setValue=ks;var yn=class extends mt{};yn.prototype._setValue=$a;var fo=class extends st{constructor({type:t,nullValues:e,dictionaryHashFunction:i}){super({type:new Wt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=$r({type:this.type.indices,nullValues:e}),this.dictionary=$r({type:this.type.dictionary,nullValues:null}),typeof i=="function"&&(this.valueToKey=i)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let i=this.indices;return e=i.setValid(t,e),this.length=i.length,e}setValue(t,e){let i=this._keysToIndices,n=this.valueToKey(e),s=i[n];return s===void 0&&(i[n]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,i=this.dictionary.toVector(),n=this.indices.flush().clone(t);return n.dictionary=e?e.concat(i):i,this.finished||(this._dictionaryOffset+=i.length),this._dictionary=n.dictionary,this.clear(),n}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}};var gn=class extends mt{};gn.prototype._setValue=Pa;var ho=class extends st{setValue(t,e){let[i]=this.children,n=t*this.stride;for(let s=-1,o=e.length;++s<o;)i.set(n+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let i=this.children.push(t);return this.type=new he(this.type.listSize,new k(e,t.type,!0)),i}};var Hr=class extends mt{setValue(t,e){this._values.set(t,e)}},po=class extends Hr{setValue(t,e){super.setValue(t,nn(e))}},mo=class extends Hr{},yo=class extends Hr{};var Jr=class extends mt{};Jr.prototype._setValue=Ha;var bn=class extends Jr{};bn.prototype._setValue=Js;var _n=class extends Jr{};_n.prototype._setValue=qs;var ir=class extends mt{};ir.prototype._setValue=Ja;var wn=class extends ir{};wn.prototype._setValue=Gs;var In=class extends ir{};In.prototype._setValue=Ks;var vn=class extends ir{};vn.prototype._setValue=Xs;var Sn=class extends ir{};Sn.prototype._setValue=Ys;var Qt=class extends mt{setValue(t,e){this._values.set(t,e)}},go=class extends Qt{},bo=class extends Qt{},_o=class extends Qt{},wo=class extends Qt{},Io=class extends Qt{},vo=class extends Qt{},So=class extends Qt{},xo=class extends Qt{};var To=class extends Et{constructor(t){super(t),this._offsets=new mi(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new fe(new k(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[i]=this.children;for(let[n,s]of t)if(typeof s=="undefined")e.set(n,0);else{let o=s,a=o.length,c=e.set(n,a).buffer[n];for(let l=-1;++l<a;)i.set(c+l,o[l])}}};var Oo=class extends Et{set(t,e){return super.set(t,e)}setValue(t,e){let i=e instanceof Map?e:new Map(Object.entries(e)),n=this._pending||(this._pending=new Map),s=n.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=i.size,n.set(t,i)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new pe(new k(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[i]=this.children;for(let[n,s]of t)if(s===void 0)e.set(n,0);else{let{[n]:o,[n+1]:a}=e.set(n,s.size).buffer;for(let c of s.entries())if(i.set(o,c),++o>=a)break}}};var Bo=class extends st{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Do=class extends st{setValue(t,e){let{children:i,type:n}=this;switch(Array.isArray(e)||e.constructor){case!0:return n.children.forEach((s,o)=>i[o].set(t,e[o]));case Map:return n.children.forEach((s,o)=>i[o].set(t,e.get(s.name)));default:return n.children.forEach((s,o)=>i[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(i=>i.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let i=this.children.push(t);return this.type=new rt([...this.type.children,new k(e,t.type,!0)]),i}};var nr=class extends mt{};nr.prototype._setValue=za;var xn=class extends nr{};xn.prototype._setValue=Cs;var Tn=class extends nr{};Tn.prototype._setValue=Vs;var On=class extends nr{};On.prototype._setValue=Ps;var Bn=class extends nr{};Bn.prototype._setValue=js;var sr=class extends mt{};sr.prototype._setValue=Wa;var Dn=class extends sr{};Dn.prototype._setValue=zs;var Fn=class extends sr{};Fn.prototype._setValue=Ws;var An=class extends sr{};An.prototype._setValue=$s;var Nn=class extends sr{};Nn.prototype._setValue=Hs;var wi=class extends st{constructor(t){super(t),this._typeIds=new Ze(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,i){return i===void 0&&(i=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,i),this}setValue(t,e,i){this._typeIds.set(t,i);let n=this.type.typeIdToChildIndex[i],s=this.children[n];s==null||s.set(t,e)}addChild(t,e=`${this.children.length}`){let i=this.children.push(t),{type:{children:n,mode:s,typeIds:o}}=this,a=[...n,new k(e,t.type)];return this.type=new de(s,[...o,i],a),i}_valueToChildTypeId(t,e,i){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Fo=class extends wi{},Ao=class extends wi{constructor(t){super(t),this._offsets=new Ze(Int32Array)}setValue(t,e,i){let n=this._typeIds.set(t,i).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[n]),o=this._offsets.set(t,s.length).buffer[t];s==null||s.set(o,e)}};var En=class extends Et{constructor(t){super(t),this._values=new ye(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ie(e))}_flushPending(t,e){}};En.prototype._flushPending=bi.prototype._flushPending;var Ln=class extends Et{constructor(t){super(t),this._values=new ye(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ie(e))}_flushPending(t,e){}};Ln.prototype._flushPending=_i.prototype._flushPending;var lc=class extends v{visitNull(){return Bo}visitBool(){return uo}visitInt(){return Qt}visitInt8(){return go}visitInt16(){return bo}visitInt32(){return _o}visitInt64(){return wo}visitUint8(){return Io}visitUint16(){return vo}visitUint32(){return So}visitUint64(){return xo}visitFloat(){return Hr}visitFloat16(){return po}visitFloat32(){return mo}visitFloat64(){return yo}visitUtf8(){return En}visitLargeUtf8(){return Ln}visitBinary(){return bi}visitLargeBinary(){return _i}visitFixedSizeBinary(){return gn}visitDate(){return Wr}visitDateDay(){return pn}visitDateMillisecond(){return mn}visitTimestamp(){return nr}visitTimestampSecond(){return xn}visitTimestampMillisecond(){return Tn}visitTimestampMicrosecond(){return On}visitTimestampNanosecond(){return Bn}visitTime(){return sr}visitTimeSecond(){return Dn}visitTimeMillisecond(){return Fn}visitTimeMicrosecond(){return An}visitTimeNanosecond(){return Nn}visitDecimal(){return yn}visitList(){return To}visitStruct(){return Do}visitUnion(){return wi}visitDenseUnion(){return Ao}visitSparseUnion(){return Fo}visitDictionary(){return fo}visitInterval(){return Jr}visitIntervalDayTime(){return bn}visitIntervalYearMonth(){return _n}visitDuration(){return ir}visitDurationSecond(){return wn}visitDurationMillisecond(){return In}visitDurationMicrosecond(){return vn}visitDurationNanosecond(){return Sn}visitFixedSizeList(){return ho}visitMap(){return Oo}},Zu=new lc;var O=class extends v{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((i,n)=>this.compareFields(i,e[n]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function Dt(r,t){return t instanceof r.constructor}function qr(r,t){return r===t||Dt(r,t)}function or(r,t){return r===t||Dt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function No(r,t){return r===t||Dt(r,t)&&r.precision===t.precision}function Rh(r,t){return r===t||Dt(r,t)&&r.byteWidth===t.byteWidth}function uc(r,t){return r===t||Dt(r,t)&&r.unit===t.unit}function Un(r,t){return r===t||Dt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Mn(r,t){return r===t||Dt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function kh(r,t){return r===t||Dt(r,t)&&r.children.length===t.children.length&&Ae.compareManyFields(r.children,t.children)}function Ch(r,t){return r===t||Dt(r,t)&&r.children.length===t.children.length&&Ae.compareManyFields(r.children,t.children)}function fc(r,t){return r===t||Dt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Ae.compareManyFields(r.children,t.children)}function Vh(r,t){return r===t||Dt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ae.visit(r.indices,t.indices)&&Ae.visit(r.dictionary,t.dictionary)}function dc(r,t){return r===t||Dt(r,t)&&r.unit===t.unit}function Rn(r,t){return r===t||Dt(r,t)&&r.unit===t.unit}function Ph(r,t){return r===t||Dt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ae.compareManyFields(r.children,t.children)}function jh(r,t){return r===t||Dt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ae.compareManyFields(r.children,t.children)}O.prototype.visitNull=qr;O.prototype.visitBool=qr;O.prototype.visitInt=or;O.prototype.visitInt8=or;O.prototype.visitInt16=or;O.prototype.visitInt32=or;O.prototype.visitInt64=or;O.prototype.visitUint8=or;O.prototype.visitUint16=or;O.prototype.visitUint32=or;O.prototype.visitUint64=or;O.prototype.visitFloat=No;O.prototype.visitFloat16=No;O.prototype.visitFloat32=No;O.prototype.visitFloat64=No;O.prototype.visitUtf8=qr;O.prototype.visitLargeUtf8=qr;O.prototype.visitBinary=qr;O.prototype.visitLargeBinary=qr;O.prototype.visitFixedSizeBinary=Rh;O.prototype.visitDate=uc;O.prototype.visitDateDay=uc;O.prototype.visitDateMillisecond=uc;O.prototype.visitTimestamp=Un;O.prototype.visitTimestampSecond=Un;O.prototype.visitTimestampMillisecond=Un;O.prototype.visitTimestampMicrosecond=Un;O.prototype.visitTimestampNanosecond=Un;O.prototype.visitTime=Mn;O.prototype.visitTimeSecond=Mn;O.prototype.visitTimeMillisecond=Mn;O.prototype.visitTimeMicrosecond=Mn;O.prototype.visitTimeNanosecond=Mn;O.prototype.visitDecimal=qr;O.prototype.visitList=kh;O.prototype.visitStruct=Ch;O.prototype.visitUnion=fc;O.prototype.visitDenseUnion=fc;O.prototype.visitSparseUnion=fc;O.prototype.visitDictionary=Vh;O.prototype.visitInterval=dc;O.prototype.visitIntervalDayTime=dc;O.prototype.visitIntervalYearMonth=dc;O.prototype.visitDuration=Rn;O.prototype.visitDurationSecond=Rn;O.prototype.visitDurationMillisecond=Rn;O.prototype.visitDurationMicrosecond=Rn;O.prototype.visitDurationNanosecond=Rn;O.prototype.visitFixedSizeList=Ph;O.prototype.visitMap=jh;var Ae=new O;function Gr(r,t){return Ae.compareSchemas(r,t)}function Qu(r,t){return Ae.compareFields(r,t)}function tf(r,t){return Ae.visit(r,t)}function $r(r){let t=r.type,e=new(Zu.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let i=r.children||[],n={nullValues:r.nullValues},s=Array.isArray(i)?((o,a)=>i[a]||n):(({name:o})=>i[o]||n);for(let[o,a]of t.children.entries()){let{type:c}=a,l=s(a,o);e.children.push($r(Object.assign(Object.assign({},l),{type:c})))}}return e}function Eo(r,t){return zh(r,t.map(e=>e.data.concat()))}function zh(r,t){let e=[...r.fields],i=[],n={numBatches:t.reduce((d,p)=>Math.max(d,p.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;n.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=Wh(e,o,u,t,n),o>0&&(i[s++]=E({type:new rt(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),i.map(d=>new ut(r,d))]}function Wh(r,t,e,i,n){var s;let o=(t+63&-64)>>3;for(let a=-1,c=i.length;++a<c;){let l=e[a],u=l==null?void 0:l.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),n.numBatches=Math.max(n.numBatches,i[a].unshift(l.slice(t,u-t))));else{let d=r[a];r[a]=d.clone({nullable:!0}),e[a]=(s=l==null?void 0:l._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:E({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var ef,ge=class r{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new K([]),this._offsets=[0],this;let n,s;t[0]instanceof K&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof ut)return[c];if(c instanceof r)return c.batches;if(c instanceof H){if(c.type instanceof rt)return[new ut(new K(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(y=>new P([c[y]])),d=n!=null?n:new K(l.map((y,_)=>new k(String(y),u[_].type,u[_].nullable))),[,p]=Eo(d,u);return p.length===0?[new ut(c)]:p}}}return[]},a=t.flatMap(c=>o(c));if(n=(i=n!=null?n:(e=a[0])===null||e===void 0?void 0:e.schema)!==null&&i!==void 0?i:new K([]),!(n instanceof K))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof ut))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Gr(n,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=n,this.batches=a,this._offsets=s!=null?s:ro(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=eo(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Rr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?hi.visit(new P(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
16
16
  ${this.toArray().join(`,
17
17
  `)}
18
- ]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ut(e,n)))}slice(t,e){let i=this.schema;[t,e]=sn({length:this.numRows},t,e);let n=io(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ut(i,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(i=>i.children[t]);if(e.length===0){let{type:i}=this.schema.fields[t],n=E({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new P(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new P([E({type:new Bt,length:this.numRows})]));let s=i.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[i,n]=Eo(i,a)}return new r(i,n)}select(t){let e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){let e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new r(e,i)}assign(t){let e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,c,l)=>{let[u,d]=a,p=e.findIndex(y=>y.name===c.name);return~p?d[p]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,n[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...Eo(s,o))}};ef=Symbol.toStringTag;ge[ef]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=di(cn),r.get=di(pt.getVisitFn(f.Struct)),r.set=no(vt.getVisitFn(f.Struct)),r.indexOf=so(Pr.getVisitFn(f.Struct)),"Table"))(ge.prototype);var nf,ut=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof K))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=E({nullCount:0,type:new rt(this.schema.fields),children:this.schema.fields.map(e=>E({type:e.type,nullCount:0}))})]=t,!(this.data instanceof H))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=rf(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=k.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new K(i),a=E({type:new rt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=rf(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=sf(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 pt.visit(this.data,t)}at(t){return this.get(Rr(t,this.numRows))}set(t,e){return vt.visit(this.data,t,e)}indexOf(t,e){return Pr.visit(this.data,t,e)}[Symbol.iterator](){return hi.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new ge(this.schema,[this,...t])}slice(t,e){let[i]=new P([this.data]).slice(t,e).data;return new r(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new P([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new P([E({type:new Bt,length:this.numRows})]));let s=i.fields.slice(),o=n.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],i=new K(s,new Map(this.schema.metadata)),n=E({type:new rt(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new rt(e.fields),n=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(n[o]=this.data.children[o])}return new r(e,E({type:i,length:this.numRows,children:n}))}selectAt(t){let e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=E({type:new rt(e.fields),length:this.numRows,children:i});return new r(e,n)}};nf=Symbol.toStringTag;ut[nf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ut.prototype);function rf(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;let n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(n[a]=c.clone({nullable:!0}),s[a]=(i=l==null?void 0:l._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:E({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),E({type:new rt(n),length:e,children:s})]}function sf(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((n=c==null?void 0:c.dictionary)===null||n===void 0?void 0:n.data)||[]])sf(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Kr=class extends ut{constructor(t){let e=t.fields.map(n=>E({type:n.type})),i=E({type:new rt(t.fields),nullCount:0,children:e});super(t,i)}};var be=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):q.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):V.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new _t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,q.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,V.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);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,i,n,s,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,i),r.addHeader(t,n),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var hc=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Zi.startNull(e),Zi.endNull(e)}visitInt(t,e){return ae.startInt(e),ae.addBitWidth(e,t.bitWidth),ae.addIsSigned(e,t.isSigned),ae.endInt(e)}visitFloat(t,e){return gr.startFloatingPoint(e),gr.addPrecision(e,t.precision),gr.endFloatingPoint(e)}visitBinary(t,e){return qi.startBinary(e),qi.endBinary(e)}visitLargeBinary(t,e){return Ki.startLargeBinary(e),Ki.endLargeBinary(e)}visitBool(t,e){return Gi.startBool(e),Gi.endBool(e)}visitUtf8(t,e){return tn.startUtf8(e),tn.endUtf8(e)}visitLargeUtf8(t,e){return Xi.startLargeUtf8(e),Xi.endLargeUtf8(e)}visitDecimal(t,e){return Te.startDecimal(e),Te.addScale(e,t.scale),Te.addPrecision(e,t.precision),Te.addBitWidth(e,t.bitWidth),Te.endDecimal(e)}visitDate(t,e){return hr.startDate(e),hr.addUnit(e,t.unit),hr.endDate(e)}visitTime(t,e){return ke.startTime(e),ke.addUnit(e,t.unit),ke.addBitWidth(e,t.bitWidth),ke.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Ce.startTimestamp(e),Ce.addUnit(e,t.unit),i!==void 0&&Ce.addTimezone(e,i),Ce.endTimestamp(e)}visitInterval(t,e){return br.startInterval(e),br.addUnit(e,t.unit),br.endInterval(e)}visitDuration(t,e){return pr.startDuration(e),pr.addUnit(e,t.unit),pr.endDuration(e)}visitList(t,e){return Yi.startList(e),Yi.endList(e)}visitStruct(t,e){return Qi.startStruct_(e),Qi.endStruct_(e)}visitUnion(t,e){ce.startTypeIdsVector(e,t.typeIds.length);let i=ce.createTypeIdsVector(e,t.typeIds);return ce.startUnion(e),ce.addMode(e,t.mode),ce.addTypeIds(e,i),ce.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return xe.startDictionaryEncoding(e),xe.addId(e,BigInt(t.id)),xe.addIsOrdered(e,t.isOrdered),i!==void 0&&xe.addIndexType(e,i),xe.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return mr.startFixedSizeBinary(e),mr.addByteWidth(e,t.byteWidth),mr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return yr.startFixedSizeList(e),yr.addListSize(e,t.listSize),yr.endFixedSizeList(e)}visitMap(t,e){return _r.startMap(e),_r.addKeysSorted(e,t.keysSorted),_r.endMap(e)}},Lo=new hc;function lf(r,t=new Map){return new K(Hh(r,t),Uo(r.metadata),t)}function pc(r){return new St(r.count,ff(r.columns),df(r.columns))}function uf(r){return new Ut(pc(r.data),r.id,r.isDelta)}function Hh(r,t){return(r.fields||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function of(r,t){return(r.children||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function ff(r){return(r||[]).reduce((t,e)=>[...t,new te(e.count,Jh(e.VALIDITY)),...ff(e.children)],[])}function df(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new Lt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new Lt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new Lt(t.length,n.OFFSET.length)),n.DATA&&t.push(new Lt(t.length,n.DATA.length)),t=df(n.children,t)}return t}function Jh(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function hf(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=cf(r,of(r,t)),n=new k(r.name,o,r.nullable,Uo(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?af(i):new Oe,a=new Wt(t.get(e),i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Uo(r.metadata))):(i=(i=s.indexType)?af(i):new Oe,t.set(e,o=cf(r,of(r,t))),a=new Wt(o,i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Uo(r.metadata))),n||null}function Uo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function af(r){return new wt(r.isSigned,r.bitWidth)}function cf(r,t){let e=r.type.name;switch(e){case"NONE":return new Bt;case"null":return new Bt;case"binary":return new Ve;case"largebinary":return new Pe;case"utf8":return new je;case"largeutf8":return new ze;case"bool":return new We;case"list":return new fe((t||[])[0]);case"struct":return new rt(t||[]);case"struct_":return new rt(t||[])}switch(e){case"int":{let i=r.type;return new wt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Yt(Y[i.precision])}case"decimal":{let i=r.type;return new $e(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new He(lt[i.unit])}case"time":{let i=r.type;return new Je(w[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new qe(w[i.unit],i.timezone)}case"interval":{let i=r.type;return new Ge(bt[i.unit])}case"duration":{let i=r.type;return new Ke(w[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new de(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Xe(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new he(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new pe((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var qh=Mr,Gh=jt,Mt=class r{static fromJSON(t,e){let i=new r(0,q.V5,e);return i._createHeader=Kh(t,e),i}static decode(t){t=new Gh(D(t));let e=be.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=Xh(e,s),o}static encode(t){let e=new qh,i=-1;return t.isSchema()?i=K.encode(e,t.header()):t.isRecordBatch()?i=St.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ut.encode(e,t.header())),be.startMessage(e),be.addVersion(e,q.V5),be.addHeader(e,i),be.addHeaderType(e,t.headerType),be.addBodyLength(e,BigInt(t.bodyLength)),be.finishMessageBuffer(e,be.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof K)return new r(0,q.V5,V.Schema,t);if(t instanceof St)return new r(e,q.V5,V.RecordBatch,t);if(t instanceof Ut)return new r(e,q.V5,V.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===V.Schema}isRecordBatch(){return this.headerType===V.RecordBatch}isDictionaryBatch(){return this.headerType===V.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),n&&(this._createHeader=()=>n),this._bodyLength=z(t)}},St=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,i){this._nodes=e,this._buffers=i,this._length=z(t)}},Ut=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,i=!1){this._data=t,this._isDelta=i,this._id=z(e)}},Lt=class{constructor(t,e){this.offset=z(t),this.length=z(e)}},te=class{constructor(t,e){this.length=z(t),this.nullCount=z(e)}};function Kh(r,t){return(()=>{switch(t){case V.Schema:return K.fromJSON(r);case V.RecordBatch:return St.fromJSON(r);case V.DictionaryBatch:return Ut.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}function Xh(r,t){return(()=>{switch(t){case V.Schema:return K.decode(r.header(new Nt),new Map,r.version());case V.RecordBatch:return St.decode(r.header(new zt),r.version());case V.DictionaryBatch:return Ut.decode(r.header(new Re),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}k.encode=ap;k.decode=sp;k.fromJSON=hf;K.encode=op;K.decode=Yh;K.fromJSON=lf;St.encode=cp;St.decode=Zh;St.fromJSON=pc;Ut.encode=lp;Ut.decode=Qh;Ut.fromJSON=uf;te.encode=up;te.decode=ep;Lt.encode=fp;Lt.decode=tp;function Yh(r,t=new Map,e=q.V5){let i=np(r,t);return new K(i,Mo(r),t,e)}function Zh(r,t=q.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new St(r.length(),rp(r),ip(r,t))}function Qh(r,t=q.V5){return new Ut(St.decode(r.data(),t),r.id(),r.isDelta())}function tp(r){return new Lt(r.offset(),r.length())}function ep(r){return new te(r.length(),r.nullCount())}function rp(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=te.decode(e));return t}function ip(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<q.V4&&(i.bb_pos+=8*(n+1)),e[++s]=Lt.decode(i));return e}function np(r,t){let e=[];for(let i,n=-1,s=-1,o=r.fieldsLength();++n<o;)(i=r.fields(n))&&(e[++s]=k.decode(i,t));return e}function pf(r,t){let e=[];for(let i,n=-1,s=-1,o=r.childrenLength();++n<o;)(i=r.children(n))&&(e[++s]=k.decode(i,t));return e}function sp(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=yf(r,pf(r,t)),i=new k(r.name(),n,r.nullable(),Mo(r))):t.has(e=z(a.id()))?(s=(s=a.indexType())?mf(s):new Oe,o=new Wt(t.get(e),s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),Mo(r))):(s=(s=a.indexType())?mf(s):new Oe,t.set(e,n=yf(r,pf(r,t))),o=new Wt(n,s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),Mo(r))),i||null}function Mo(r){let t=new Map;if(r)for(let e,i,n=-1,s=Math.trunc(r.customMetadataLength());++n<s;)(e=r.customMetadata(n))&&(i=e.key())!=null&&t.set(i,e.value());return t}function mf(r){return new wt(r.isSigned(),r.bitWidth())}function yf(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Bt;case Q.Null:return new Bt;case Q.Binary:return new Ve;case Q.LargeBinary:return new Pe;case Q.Utf8:return new je;case Q.LargeUtf8:return new ze;case Q.Bool:return new We;case Q.List:return new fe((t||[])[0]);case Q.Struct_:return new rt(t||[])}switch(e){case Q.Int:{let i=r.type(new ae);return new wt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new gr);return new Yt(i.precision())}case Q.Decimal:{let i=r.type(new Te);return new $e(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new hr);return new He(i.unit())}case Q.Time:{let i=r.type(new ke);return new Je(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Ce);return new qe(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new br);return new Ge(i.unit())}case Q.Duration:{let i=r.type(new pr);return new Ke(i.unit())}case Q.Union:{let i=r.type(new ce);return new de(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new mr);return new Xe(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new yr);return new he(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new _r);return new pe((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function op(r,t){let e=t.fields.map(s=>k.encode(r,s));Nt.startFieldsVector(r,e.length);let i=Nt.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Nt.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return _t.startKeyValue(r),_t.addKey(r,a),_t.addValue(r,c),_t.endKeyValue(r)})):-1;return Nt.startSchema(r),Nt.addFields(r,i),Nt.addEndianness(r,dp?dr.Little:dr.Big),n!==-1&&Nt.addCustomMetadata(r,n),Nt.endSchema(r)}function ap(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;b.isDictionary(s)?(o=s.dictionary.typeId,n=Lo.visit(s,r),i=Lo.visit(s.dictionary,r)):i=Lo.visit(s,r);let a=(s.children||[]).map(u=>k.encode(r,u)),c=xt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?xt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),y=r.createString(`${d}`);return _t.startKeyValue(r),_t.addKey(r,p),_t.addValue(r,y),_t.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),xt.startField(r),xt.addType(r,i),xt.addTypeType(r,o),xt.addChildren(r,c),xt.addNullable(r,!!t.nullable),e!==-1&&xt.addName(r,e),n!==-1&&xt.addDictionary(r,n),l!==-1&&xt.addCustomMetadata(r,l),xt.endField(r)}function cp(r,t){let e=t.nodes||[],i=t.buffers||[];zt.startNodesVector(r,e.length);for(let o of e.slice().reverse())te.encode(r,o);let n=r.endVector();zt.startBuffersVector(r,i.length);for(let o of i.slice().reverse())Lt.encode(r,o);let s=r.endVector();return zt.startRecordBatch(r),zt.addLength(r,BigInt(t.length)),zt.addNodes(r,n),zt.addBuffers(r,s),zt.endRecordBatch(r)}function lp(r,t){let e=St.encode(r,t.data);return Re.startDictionaryBatch(r),Re.addId(r,BigInt(t.id)),Re.addIsDelta(r,t.isDelta),Re.addData(r,e),Re.endDictionaryBatch(r)}function up(r,t){return ii.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function fp(r,t){return ri.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var dp=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var yc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,gc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,gf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,bf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Ii=class{constructor(t){this.source=t instanceof Fe?t:new Fe(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?it:t.value===-1&&(t=this.readMetadataLength()).done?it:(t=this.readMetadata(t.value)).done?it: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(yc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(bf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=V.Schema,i=this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(gc(e));return n}readMetadataLength(){let t=this.source.read(Ro),e=t&&new jt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}}readMetadata(t){let e=this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(gf(t,e.byteLength));return{done:!1,value:Mt.decode(e)}}},kn=class{constructor(t,e){this.source=t instanceof Zt?t:ps(t)?new xr(t,e):new Zt(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?it:t.value===-1&&(t=yield this.readMetadataLength()).done?it:(t=yield this.readMetadata(t.value)).done?it:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(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(yc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(bf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(gc(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(Ro),e=t&&new jt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(gf(t,e.byteLength));return{done:!1,value:Mt.decode(e)}})}},Cn=class extends Ii{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ln?t:new ln(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Mt.fromJSON(t.schema,V.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:Mt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Mt.fromJSON(e,V.RecordBatch)}}return this._body=[],it}readMessageBody(t){return e(this._body);function e(i){return(i||[]).reduce((n,s)=>[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(yc(t));return e.value}readSchema(){let t=V.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(gc(t));return i}},Ro=4,mc="ARROW1",vi=new Uint8Array(mc.length);for(let r=0;r<mc.length;r+=1)vi[r]=mc.codePointAt(r);function ko(r,t=0){for(let e=-1,i=vi.length;++e<i;)if(vi[e]!==r[t+e])return!1;return!0}var Si=vi.length,bc=Si+Ro,_f=Si*2+Ro;var Rt=class r extends zr{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 ie(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 It.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return It.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:ds(t)?pp(t):ps(t)?gp(t):ie(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):ms(t)||ji(t)||gs(t)||Gt(t)?yp(new Zt(t)):mp(new Fe(t))}static readAll(t){return t instanceof r?t.isSync()?wf(t):If(t):ds(t)||ArrayBuffer.isView(t)||ne(t)||hs(t)?wf(t):If(t)}},Ne=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Vt(this,arguments,function*(){yield U(yield*ti(re(this[Symbol.iterator]())))})}},Tr=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=re(this),c;c=yield a.next(),t=c.done,!t;o=!0){n=c.value,o=!1;let l=n;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Or=class extends Ne{constructor(t){super(t),this._impl=t}},Vn=class extends Tr{constructor(t){super(t),this._impl=t}},Co=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let i=this._loadVectors(t,e,this.schema.fields),n=E({type:new rt(this.schema.fields),length:t.length,children:i});return new ut(this.schema,n)}_loadDictionaryBatch(t,e){let{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),c=o.dictionaries.get(i),l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new P(l)):new P(l)).memoize()}_loadVectors(t,e,i){return new hn(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}},xi=class extends Co{constructor(t,e){super(e),this._reader=ds(t)?new Cn(this._handle=t):new Ii(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=vf(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):it}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):it}next(){if(this.closed)return it;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Kr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ti=class extends Co{constructor(t,e){super(e),this._reader=new kn(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(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 g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=vf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):it})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):it})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return it;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 i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Kr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Vo=class extends xi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof un?t:new un(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-bc,i=t.readInt32(e),n=t.readAt(e-i,i);return Qe.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(t)}return null}},_c=class extends Ti{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof xr?t:new xr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-bc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Qe.decode(n)})}_readNextMessageAndValidate(t){return g(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})}},wc=class extends xi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new lo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function vf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*wf(r){let t=Rt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function If(r){return Vt(this,arguments,function*(){let e=yield U(Rt.from(r));try{if(!(yield U(e.open({autoDestroy:!1}))).closed)do yield yield U(e);while(!(yield U(e.reset().open())).closed)}finally{yield U(e.cancel())}})}function pp(r){return new Ne(new wc(r))}function mp(r){let t=r.peek(Si+7&-8);return t&&t.byteLength>=4?ko(t)?new Or(new Vo(r.read())):new Ne(new xi(r)):new Ne(new xi((function*(){})()))}function yp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Si+7&-8);return t&&t.byteLength>=4?ko(t)?new Or(new Vo(yield r.read())):new Tr(new Ti(r)):new Tr(new Ti((function(){return Vt(this,arguments,function*(){})})()))})}function gp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new xr(r,t);return t>=_f&&ko(yield e.readAt(0,Si+7&-8))?new Vn(new _c(e)):new Tr(new Ti(e))})}var ot=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ut?s.data.children:s.data),i=new r;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof P)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new te(i,0));else{let{nullCount:n}=t;b.isNull(e)||_e.call(this,n<=0?new Uint8Array(0):Cr(t.offset,i,t.nullBitmap)),this.nodes.push(new te(i,n))}}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 _e(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Lt(this._byteLength,t)),this._byteLength+=t,this}function bp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(_e.call(this,n),e.mode===Z.Sparse)return Ic.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return _e.call(this,s),Ic.call(this,r);{let o=new Int32Array(i),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<i;)(l=n[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);_e.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],y=c[d];return l.slice(p,Math.min(i,y))}))}}return this}function _p(r){let t;return r.nullCount>=r.length?_e.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?_e.call(this,Cr(r.offset,r.length,t)):_e.call(this,Vr(r.values))}function ar(r){return _e.call(this,r.values.subarray(0,r.length*r.stride))}function Po(r){let{length:t,values:e,valueOffsets:i}=r,n=z(i[0]),s=z(i[t]),o=Math.min(s-n,e.byteLength-n);return _e.call(this,_s(-n,t+1,i)),_e.call(this,e.subarray(n,n+o)),this}function vc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return _e.call(this,_s(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Ic(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}ot.prototype.visitBool=_p;ot.prototype.visitInt=ar;ot.prototype.visitFloat=ar;ot.prototype.visitUtf8=Po;ot.prototype.visitLargeUtf8=Po;ot.prototype.visitBinary=Po;ot.prototype.visitLargeBinary=Po;ot.prototype.visitFixedSizeBinary=ar;ot.prototype.visitDate=ar;ot.prototype.visitTimestamp=ar;ot.prototype.visitTime=ar;ot.prototype.visitDecimal=ar;ot.prototype.visitList=vc;ot.prototype.visitStruct=Ic;ot.prototype.visitUnion=bp;ot.prototype.visitInterval=ar;ot.prototype.visitDuration=ar;ot.prototype.visitFixedSizeList=vc;ot.prototype.visitMap=vc;var Xr=class extends zr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new De,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Ot(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ie(t)?t.then(e=>this.writeAll(e)):Gt(t)?xc(this,t):Sc(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 De?this._sink=t:(this._sink=new De,t&&kl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Cl(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Gr(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 ge&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ut&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Gr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ut?t instanceof Kr||this._writeRecordBatch(t):t instanceof ge?this.writeAll(t.batches):ne(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Mt.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,c=a-s-o;return t.headerType===V.RecordBatch?this._recordBatchBlocks.push(new tr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new tr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Mt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(vi)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=ot.assemble(t),o=new St(t.numRows,i,n),a=Mt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=ot.assemble(new P([t])),c=new St(t.length,s,o),l=new Ut(c,e,i),u=Mt.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,i,n;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(i=e.byteLength)>0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){var e,i;for(let[n,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),c=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,n,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,n,!0);this._seenDictionaries.set(n,s),this._dictionaryDeltaOffsets.set(n,o.length)}return this}},Pn=class r extends Xr{static writeAll(t,e){let i=new r(e);return ie(t)?t.then(n=>i.writeAll(n)):Gt(t)?xc(i,t):Sc(i,t)}},jn=class r extends Xr{static writeAll(t){let e=new r;return ie(t)?t.then(i=>e.writeAll(i)):Gt(t)?xc(e,t):Sc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){let e=Qe.encode(new Qe(t,q.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Sc(r,t){let e=t;t instanceof ge&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function xc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=re(t);n=yield i.next(),s=n.done,!s;e=!0){c=n.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function Sf(r,t){if(Gt(r))return Ip(r,t);if(ne(r))return wp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function wp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Ip(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){(e!=null&&e.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Of(r){return new Tc(r)}var Tc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ml(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=$r(s),this._getSize=n!=="bytes"?xf:Tf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?xf:Tf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},xf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Tf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function jo(r,t){let e=new De,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Rt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function zo(r,t){let e=new this(r),i=new Zt(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var vp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ka),cc),Qa),Ca),Aa),Za),La),{compareSchemas:Gr,compareFields:Qu,compareTypes:tf});It.toDOMStream=Sf;st.throughDOM=Of;Rt.throughDOM=jo;Or.throughDOM=jo;Ne.throughDOM=jo;Xr.throughDOM=zo;jn.throughDOM=zo;Pn.throughDOM=zo;var Oc=class extends et{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let t=this.create(),e=Date.now();return t.seconds=X.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(X.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=X.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=X.from(t.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(t.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(t.nanos>0){let s=(t.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(t,e,i){if(typeof t!="string")throw new Error("Unable to parse Timestamp from JSON "+Ar(t)+".");let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=X.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},Bc=new Oc;var Bf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Bf||{}),Df=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Df||{}),Dc=class extends et{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Sp=new Dc,Fc=class extends et{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},xp=new Fc,Ac=class extends et{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},OO=new Ac,Nc=class extends et{constructor(){super("arrow.flight.protocol.Empty",[])}},Tp=new Nc,Ec=class extends et{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Op=new Ec,Lc=class extends et{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Bp=new Lc,Uc=class extends et{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Dp=new Uc,Mc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>$o}])}},BO=new Mc,Rc=class extends et{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>Ff}])}},DO=new Rc,kc=class extends et{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Fp=new kc,Cc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Df,"CANCEL_STATUS_"]}])}},FO=new Cc,Vc=class extends et{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Ap=new Vc,Pc=class extends et{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Bf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Oi=new Pc,jc=class extends et{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>Ff},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},$o=new jc,zc=class extends et{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>$o},{no:2,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Bc}])}},Np=new zc,Wc=class extends et{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Ho},{no:2,name:"location",kind:"message",repeat:1,T:()=>Ep},{no:3,name:"expiration_time",kind:"message",T:()=>Bc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},Ff=new Wc,$c=class extends et{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Ep=new $c,Hc=class extends et{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Ho=new Hc,Jc=class extends et{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},Wo=new Jc,qc=class extends et{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},Lp=new qc,Jo=new Ui("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Sp,O:xp},{name:"ListFlights",serverStreaming:!0,options:{},I:Bp,O:$o},{name:"GetFlightInfo",options:{},I:Oi,O:$o},{name:"PollFlightInfo",options:{},I:Oi,O:Np},{name:"GetSchema",options:{},I:Oi,O:Ap},{name:"DoGet",serverStreaming:!0,options:{},I:Ho,O:Wo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Wo,O:Lp},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Wo,O:Wo},{name:"DoAction",serverStreaming:!0,options:{},I:Dp,O:Fp},{name:"ListActions",serverStreaming:!0,options:{},I:Tp,O:Op}]);var qo=class{constructor(t){this._transport=t;j(this,"typeName",Jo.typeName);j(this,"methods",Jo.methods);j(this,"options",Jo.options)}handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}};var Af=/\$(\w+)/g;function Nf(r){return!!r.match(Af)}function Ef(r,t){let e=r.match(Af);if(e)for(let i of e)t[i.trim().replace("$","")]||Yr(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var Up="2.0.0",Lf=`influxdb3-js/${Up}`;function Gc(r,t){if(t==null)return null;let e=r.metadata.get("iox::column::type");if(!e||r.typeId===f.Timestamp)return t;let[,,i,n]=e.split("::");if(i==="field")switch(n){case"integer":return Zr(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return ul(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return Zr(t)?parseFloat(t):(console.warn(`Value ${t} is not a float`),t);case"boolean":return typeof t=="boolean"||console.warn(`Value ${t} is not a boolean`),t;case"string":return typeof t=="string"?String(t):(console.warn(`Value ${t} is not a string`),t);default:return t}return t}var zn=class{constructor(t){this._options=t;j(this,"_closed",!1);j(this,"_flightClient");j(this,"_transport");j(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=Lr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new qo(this._transport)}prepareTicket(t,e,i){let n={database:t,sql_query:e,query_type:i.type};if(i.params){let s={};for(let o of Object.keys(i.params))i.params[o]&&(s[o]=i.params[o]);n.params=s}return Ho.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Lf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){if(i.params&&Nf(t)&&Ef(t,i.params),this._closed)throw new Error("queryApi: already closed!");let n=this._flightClient,s=this.prepareTicket(e,t,i),a={meta:this.prepareMetadata(i.headers)},c=n.doGet(s,a),l=(async function*(){for await(let d of c.responses)yield cl(d.dataHeader.length),yield d.dataHeader,yield d.dataBody})();yield*await Rt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=Gc(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new ur;for(let l=0;l<o.numCols;l++){let u=o.schema.fields[l],d=u.name,p=(s=o.getChildAt(l))==null?void 0:s.get(a),y=u.typeId,_=u.metadata.get("iox::column::type");if(p==null)continue;if((d==="measurement"||d=="iox::measurement")&&typeof p=="string"){c.setMeasurement(p);continue}if(!_){d==="time"&&y===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,W,at]=_.split("::");if(W==="field"){if(at&&p!==void 0&&p!==null){let ft=Gc(u,p);c.setField(d,ft,at)}}else W==="tag"?c.setTag(d,p):W==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var Kc=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
18
+ ]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ut(e,n)))}slice(t,e){let i=this.schema;[t,e]=sn({length:this.numRows},t,e);let n=io(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ut(i,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(i=>i.children[t]);if(e.length===0){let{type:i}=this.schema.fields[t],n=E({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new P(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new P([E({type:new Bt,length:this.numRows})]));let s=i.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[i,n]=Eo(i,a)}return new r(i,n)}select(t){let e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){let e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new r(e,i)}assign(t){let e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,c,l)=>{let[u,d]=a,p=e.findIndex(y=>y.name===c.name);return~p?d[p]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,n[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...Eo(s,o))}};ef=Symbol.toStringTag;ge[ef]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=di(cn),r.get=di(pt.getVisitFn(f.Struct)),r.set=no(vt.getVisitFn(f.Struct)),r.indexOf=so(Pr.getVisitFn(f.Struct)),"Table"))(ge.prototype);var nf,ut=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof K))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=E({nullCount:0,type:new rt(this.schema.fields),children:this.schema.fields.map(e=>E({type:e.type,nullCount:0}))})]=t,!(this.data instanceof H))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=rf(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=k.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new K(i),a=E({type:new rt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=rf(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=sf(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 pt.visit(this.data,t)}at(t){return this.get(Rr(t,this.numRows))}set(t,e){return vt.visit(this.data,t,e)}indexOf(t,e){return Pr.visit(this.data,t,e)}[Symbol.iterator](){return hi.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new ge(this.schema,[this,...t])}slice(t,e){let[i]=new P([this.data]).slice(t,e).data;return new r(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new P([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new P([E({type:new Bt,length:this.numRows})]));let s=i.fields.slice(),o=n.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],i=new K(s,new Map(this.schema.metadata)),n=E({type:new rt(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new rt(e.fields),n=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(n[o]=this.data.children[o])}return new r(e,E({type:i,length:this.numRows,children:n}))}selectAt(t){let e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=E({type:new rt(e.fields),length:this.numRows,children:i});return new r(e,n)}};nf=Symbol.toStringTag;ut[nf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ut.prototype);function rf(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;let n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(n[a]=c.clone({nullable:!0}),s[a]=(i=l==null?void 0:l._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:E({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),E({type:new rt(n),length:e,children:s})]}function sf(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((n=c==null?void 0:c.dictionary)===null||n===void 0?void 0:n.data)||[]])sf(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Kr=class extends ut{constructor(t){let e=t.fields.map(n=>E({type:n.type})),i=E({type:new rt(t.fields),nullCount:0,children:e});super(t,i)}};var be=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):q.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):V.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new _t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,q.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,V.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);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,i,n,s,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,i),r.addHeader(t,n),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var hc=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Zi.startNull(e),Zi.endNull(e)}visitInt(t,e){return ae.startInt(e),ae.addBitWidth(e,t.bitWidth),ae.addIsSigned(e,t.isSigned),ae.endInt(e)}visitFloat(t,e){return gr.startFloatingPoint(e),gr.addPrecision(e,t.precision),gr.endFloatingPoint(e)}visitBinary(t,e){return qi.startBinary(e),qi.endBinary(e)}visitLargeBinary(t,e){return Ki.startLargeBinary(e),Ki.endLargeBinary(e)}visitBool(t,e){return Gi.startBool(e),Gi.endBool(e)}visitUtf8(t,e){return tn.startUtf8(e),tn.endUtf8(e)}visitLargeUtf8(t,e){return Xi.startLargeUtf8(e),Xi.endLargeUtf8(e)}visitDecimal(t,e){return Te.startDecimal(e),Te.addScale(e,t.scale),Te.addPrecision(e,t.precision),Te.addBitWidth(e,t.bitWidth),Te.endDecimal(e)}visitDate(t,e){return hr.startDate(e),hr.addUnit(e,t.unit),hr.endDate(e)}visitTime(t,e){return ke.startTime(e),ke.addUnit(e,t.unit),ke.addBitWidth(e,t.bitWidth),ke.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Ce.startTimestamp(e),Ce.addUnit(e,t.unit),i!==void 0&&Ce.addTimezone(e,i),Ce.endTimestamp(e)}visitInterval(t,e){return br.startInterval(e),br.addUnit(e,t.unit),br.endInterval(e)}visitDuration(t,e){return pr.startDuration(e),pr.addUnit(e,t.unit),pr.endDuration(e)}visitList(t,e){return Yi.startList(e),Yi.endList(e)}visitStruct(t,e){return Qi.startStruct_(e),Qi.endStruct_(e)}visitUnion(t,e){ce.startTypeIdsVector(e,t.typeIds.length);let i=ce.createTypeIdsVector(e,t.typeIds);return ce.startUnion(e),ce.addMode(e,t.mode),ce.addTypeIds(e,i),ce.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return xe.startDictionaryEncoding(e),xe.addId(e,BigInt(t.id)),xe.addIsOrdered(e,t.isOrdered),i!==void 0&&xe.addIndexType(e,i),xe.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return mr.startFixedSizeBinary(e),mr.addByteWidth(e,t.byteWidth),mr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return yr.startFixedSizeList(e),yr.addListSize(e,t.listSize),yr.endFixedSizeList(e)}visitMap(t,e){return _r.startMap(e),_r.addKeysSorted(e,t.keysSorted),_r.endMap(e)}},Lo=new hc;function lf(r,t=new Map){return new K(Hh(r,t),Uo(r.metadata),t)}function pc(r){return new St(r.count,ff(r.columns),df(r.columns))}function uf(r){return new Ut(pc(r.data),r.id,r.isDelta)}function Hh(r,t){return(r.fields||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function of(r,t){return(r.children||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function ff(r){return(r||[]).reduce((t,e)=>[...t,new te(e.count,Jh(e.VALIDITY)),...ff(e.children)],[])}function df(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new Lt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new Lt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new Lt(t.length,n.OFFSET.length)),n.DATA&&t.push(new Lt(t.length,n.DATA.length)),t=df(n.children,t)}return t}function Jh(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function hf(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=cf(r,of(r,t)),n=new k(r.name,o,r.nullable,Uo(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?af(i):new Oe,a=new Wt(t.get(e),i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Uo(r.metadata))):(i=(i=s.indexType)?af(i):new Oe,t.set(e,o=cf(r,of(r,t))),a=new Wt(o,i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Uo(r.metadata))),n||null}function Uo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function af(r){return new wt(r.isSigned,r.bitWidth)}function cf(r,t){let e=r.type.name;switch(e){case"NONE":return new Bt;case"null":return new Bt;case"binary":return new Ve;case"largebinary":return new Pe;case"utf8":return new je;case"largeutf8":return new ze;case"bool":return new We;case"list":return new fe((t||[])[0]);case"struct":return new rt(t||[]);case"struct_":return new rt(t||[])}switch(e){case"int":{let i=r.type;return new wt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Yt(Y[i.precision])}case"decimal":{let i=r.type;return new $e(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new He(lt[i.unit])}case"time":{let i=r.type;return new Je(w[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new qe(w[i.unit],i.timezone)}case"interval":{let i=r.type;return new Ge(bt[i.unit])}case"duration":{let i=r.type;return new Ke(w[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new de(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Xe(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new he(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new pe((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var qh=Mr,Gh=jt,Mt=class r{static fromJSON(t,e){let i=new r(0,q.V5,e);return i._createHeader=Kh(t,e),i}static decode(t){t=new Gh(D(t));let e=be.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=Xh(e,s),o}static encode(t){let e=new qh,i=-1;return t.isSchema()?i=K.encode(e,t.header()):t.isRecordBatch()?i=St.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ut.encode(e,t.header())),be.startMessage(e),be.addVersion(e,q.V5),be.addHeader(e,i),be.addHeaderType(e,t.headerType),be.addBodyLength(e,BigInt(t.bodyLength)),be.finishMessageBuffer(e,be.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof K)return new r(0,q.V5,V.Schema,t);if(t instanceof St)return new r(e,q.V5,V.RecordBatch,t);if(t instanceof Ut)return new r(e,q.V5,V.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===V.Schema}isRecordBatch(){return this.headerType===V.RecordBatch}isDictionaryBatch(){return this.headerType===V.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),n&&(this._createHeader=()=>n),this._bodyLength=z(t)}},St=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,i){this._nodes=e,this._buffers=i,this._length=z(t)}},Ut=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,i=!1){this._data=t,this._isDelta=i,this._id=z(e)}},Lt=class{constructor(t,e){this.offset=z(t),this.length=z(e)}},te=class{constructor(t,e){this.length=z(t),this.nullCount=z(e)}};function Kh(r,t){return(()=>{switch(t){case V.Schema:return K.fromJSON(r);case V.RecordBatch:return St.fromJSON(r);case V.DictionaryBatch:return Ut.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}function Xh(r,t){return(()=>{switch(t){case V.Schema:return K.decode(r.header(new Nt),new Map,r.version());case V.RecordBatch:return St.decode(r.header(new zt),r.version());case V.DictionaryBatch:return Ut.decode(r.header(new Re),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}k.encode=ap;k.decode=sp;k.fromJSON=hf;K.encode=op;K.decode=Yh;K.fromJSON=lf;St.encode=cp;St.decode=Zh;St.fromJSON=pc;Ut.encode=lp;Ut.decode=Qh;Ut.fromJSON=uf;te.encode=up;te.decode=ep;Lt.encode=fp;Lt.decode=tp;function Yh(r,t=new Map,e=q.V5){let i=np(r,t);return new K(i,Mo(r),t,e)}function Zh(r,t=q.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new St(r.length(),rp(r),ip(r,t))}function Qh(r,t=q.V5){return new Ut(St.decode(r.data(),t),r.id(),r.isDelta())}function tp(r){return new Lt(r.offset(),r.length())}function ep(r){return new te(r.length(),r.nullCount())}function rp(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=te.decode(e));return t}function ip(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<q.V4&&(i.bb_pos+=8*(n+1)),e[++s]=Lt.decode(i));return e}function np(r,t){let e=[];for(let i,n=-1,s=-1,o=r.fieldsLength();++n<o;)(i=r.fields(n))&&(e[++s]=k.decode(i,t));return e}function pf(r,t){let e=[];for(let i,n=-1,s=-1,o=r.childrenLength();++n<o;)(i=r.children(n))&&(e[++s]=k.decode(i,t));return e}function sp(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=yf(r,pf(r,t)),i=new k(r.name(),n,r.nullable(),Mo(r))):t.has(e=z(a.id()))?(s=(s=a.indexType())?mf(s):new Oe,o=new Wt(t.get(e),s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),Mo(r))):(s=(s=a.indexType())?mf(s):new Oe,t.set(e,n=yf(r,pf(r,t))),o=new Wt(n,s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),Mo(r))),i||null}function Mo(r){let t=new Map;if(r)for(let e,i,n=-1,s=Math.trunc(r.customMetadataLength());++n<s;)(e=r.customMetadata(n))&&(i=e.key())!=null&&t.set(i,e.value());return t}function mf(r){return new wt(r.isSigned(),r.bitWidth())}function yf(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Bt;case Q.Null:return new Bt;case Q.Binary:return new Ve;case Q.LargeBinary:return new Pe;case Q.Utf8:return new je;case Q.LargeUtf8:return new ze;case Q.Bool:return new We;case Q.List:return new fe((t||[])[0]);case Q.Struct_:return new rt(t||[])}switch(e){case Q.Int:{let i=r.type(new ae);return new wt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new gr);return new Yt(i.precision())}case Q.Decimal:{let i=r.type(new Te);return new $e(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new hr);return new He(i.unit())}case Q.Time:{let i=r.type(new ke);return new Je(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Ce);return new qe(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new br);return new Ge(i.unit())}case Q.Duration:{let i=r.type(new pr);return new Ke(i.unit())}case Q.Union:{let i=r.type(new ce);return new de(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new mr);return new Xe(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new yr);return new he(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new _r);return new pe((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function op(r,t){let e=t.fields.map(s=>k.encode(r,s));Nt.startFieldsVector(r,e.length);let i=Nt.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Nt.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return _t.startKeyValue(r),_t.addKey(r,a),_t.addValue(r,c),_t.endKeyValue(r)})):-1;return Nt.startSchema(r),Nt.addFields(r,i),Nt.addEndianness(r,dp?dr.Little:dr.Big),n!==-1&&Nt.addCustomMetadata(r,n),Nt.endSchema(r)}function ap(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;b.isDictionary(s)?(o=s.dictionary.typeId,n=Lo.visit(s,r),i=Lo.visit(s.dictionary,r)):i=Lo.visit(s,r);let a=(s.children||[]).map(u=>k.encode(r,u)),c=xt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?xt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),y=r.createString(`${d}`);return _t.startKeyValue(r),_t.addKey(r,p),_t.addValue(r,y),_t.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),xt.startField(r),xt.addType(r,i),xt.addTypeType(r,o),xt.addChildren(r,c),xt.addNullable(r,!!t.nullable),e!==-1&&xt.addName(r,e),n!==-1&&xt.addDictionary(r,n),l!==-1&&xt.addCustomMetadata(r,l),xt.endField(r)}function cp(r,t){let e=t.nodes||[],i=t.buffers||[];zt.startNodesVector(r,e.length);for(let o of e.slice().reverse())te.encode(r,o);let n=r.endVector();zt.startBuffersVector(r,i.length);for(let o of i.slice().reverse())Lt.encode(r,o);let s=r.endVector();return zt.startRecordBatch(r),zt.addLength(r,BigInt(t.length)),zt.addNodes(r,n),zt.addBuffers(r,s),zt.endRecordBatch(r)}function lp(r,t){let e=St.encode(r,t.data);return Re.startDictionaryBatch(r),Re.addId(r,BigInt(t.id)),Re.addIsDelta(r,t.isDelta),Re.addData(r,e),Re.endDictionaryBatch(r)}function up(r,t){return ii.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function fp(r,t){return ri.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var dp=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var yc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,gc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,gf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,bf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Ii=class{constructor(t){this.source=t instanceof Fe?t:new Fe(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?it:t.value===-1&&(t=this.readMetadataLength()).done?it:(t=this.readMetadata(t.value)).done?it: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(yc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(bf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=V.Schema,i=this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(gc(e));return n}readMetadataLength(){let t=this.source.read(Ro),e=t&&new jt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}}readMetadata(t){let e=this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(gf(t,e.byteLength));return{done:!1,value:Mt.decode(e)}}},kn=class{constructor(t,e){this.source=t instanceof Zt?t:ps(t)?new xr(t,e):new Zt(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?it:t.value===-1&&(t=yield this.readMetadataLength()).done?it:(t=yield this.readMetadata(t.value)).done?it:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(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(yc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(bf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(gc(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(Ro),e=t&&new jt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(gf(t,e.byteLength));return{done:!1,value:Mt.decode(e)}})}},Cn=class extends Ii{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ln?t:new ln(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Mt.fromJSON(t.schema,V.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:Mt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Mt.fromJSON(e,V.RecordBatch)}}return this._body=[],it}readMessageBody(t){return e(this._body);function e(i){return(i||[]).reduce((n,s)=>[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(yc(t));return e.value}readSchema(){let t=V.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(gc(t));return i}},Ro=4,mc="ARROW1",vi=new Uint8Array(mc.length);for(let r=0;r<mc.length;r+=1)vi[r]=mc.codePointAt(r);function ko(r,t=0){for(let e=-1,i=vi.length;++e<i;)if(vi[e]!==r[t+e])return!1;return!0}var Si=vi.length,bc=Si+Ro,_f=Si*2+Ro;var Rt=class r extends zr{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 ie(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 It.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return It.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:ds(t)?pp(t):ps(t)?gp(t):ie(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):ms(t)||ji(t)||gs(t)||Gt(t)?yp(new Zt(t)):mp(new Fe(t))}static readAll(t){return t instanceof r?t.isSync()?wf(t):If(t):ds(t)||ArrayBuffer.isView(t)||ne(t)||hs(t)?wf(t):If(t)}},Ne=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Vt(this,arguments,function*(){yield U(yield*ti(re(this[Symbol.iterator]())))})}},Tr=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=re(this),c;c=yield a.next(),t=c.done,!t;o=!0){n=c.value,o=!1;let l=n;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Or=class extends Ne{constructor(t){super(t),this._impl=t}},Vn=class extends Tr{constructor(t){super(t),this._impl=t}},Co=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let i=this._loadVectors(t,e,this.schema.fields),n=E({type:new rt(this.schema.fields),length:t.length,children:i});return new ut(this.schema,n)}_loadDictionaryBatch(t,e){let{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),c=o.dictionaries.get(i),l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new P(l)):new P(l)).memoize()}_loadVectors(t,e,i){return new hn(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}},xi=class extends Co{constructor(t,e){super(e),this._reader=ds(t)?new Cn(this._handle=t):new Ii(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=vf(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):it}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):it}next(){if(this.closed)return it;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Kr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ti=class extends Co{constructor(t,e){super(e),this._reader=new kn(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(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 g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=vf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):it})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):it})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return it;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 i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Kr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Vo=class extends xi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof un?t:new un(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-bc,i=t.readInt32(e),n=t.readAt(e-i,i);return Qe.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(t)}return null}},_c=class extends Ti{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof xr?t:new xr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-bc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Qe.decode(n)})}_readNextMessageAndValidate(t){return g(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})}},wc=class extends xi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new lo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function vf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*wf(r){let t=Rt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function If(r){return Vt(this,arguments,function*(){let e=yield U(Rt.from(r));try{if(!(yield U(e.open({autoDestroy:!1}))).closed)do yield yield U(e);while(!(yield U(e.reset().open())).closed)}finally{yield U(e.cancel())}})}function pp(r){return new Ne(new wc(r))}function mp(r){let t=r.peek(Si+7&-8);return t&&t.byteLength>=4?ko(t)?new Or(new Vo(r.read())):new Ne(new xi(r)):new Ne(new xi((function*(){})()))}function yp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Si+7&-8);return t&&t.byteLength>=4?ko(t)?new Or(new Vo(yield r.read())):new Tr(new Ti(r)):new Tr(new Ti((function(){return Vt(this,arguments,function*(){})})()))})}function gp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new xr(r,t);return t>=_f&&ko(yield e.readAt(0,Si+7&-8))?new Vn(new _c(e)):new Tr(new Ti(e))})}var ot=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ut?s.data.children:s.data),i=new r;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof P)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new te(i,0));else{let{nullCount:n}=t;b.isNull(e)||_e.call(this,n<=0?new Uint8Array(0):Cr(t.offset,i,t.nullBitmap)),this.nodes.push(new te(i,n))}}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 _e(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Lt(this._byteLength,t)),this._byteLength+=t,this}function bp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(_e.call(this,n),e.mode===Z.Sparse)return Ic.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return _e.call(this,s),Ic.call(this,r);{let o=new Int32Array(i),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<i;)(l=n[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);_e.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],y=c[d];return l.slice(p,Math.min(i,y))}))}}return this}function _p(r){let t;return r.nullCount>=r.length?_e.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?_e.call(this,Cr(r.offset,r.length,t)):_e.call(this,Vr(r.values))}function ar(r){return _e.call(this,r.values.subarray(0,r.length*r.stride))}function Po(r){let{length:t,values:e,valueOffsets:i}=r,n=z(i[0]),s=z(i[t]),o=Math.min(s-n,e.byteLength-n);return _e.call(this,_s(-n,t+1,i)),_e.call(this,e.subarray(n,n+o)),this}function vc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return _e.call(this,_s(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Ic(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}ot.prototype.visitBool=_p;ot.prototype.visitInt=ar;ot.prototype.visitFloat=ar;ot.prototype.visitUtf8=Po;ot.prototype.visitLargeUtf8=Po;ot.prototype.visitBinary=Po;ot.prototype.visitLargeBinary=Po;ot.prototype.visitFixedSizeBinary=ar;ot.prototype.visitDate=ar;ot.prototype.visitTimestamp=ar;ot.prototype.visitTime=ar;ot.prototype.visitDecimal=ar;ot.prototype.visitList=vc;ot.prototype.visitStruct=Ic;ot.prototype.visitUnion=bp;ot.prototype.visitInterval=ar;ot.prototype.visitDuration=ar;ot.prototype.visitFixedSizeList=vc;ot.prototype.visitMap=vc;var Xr=class extends zr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new De,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Ot(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ie(t)?t.then(e=>this.writeAll(e)):Gt(t)?xc(this,t):Sc(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 De?this._sink=t:(this._sink=new De,t&&kl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Cl(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Gr(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 ge&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ut&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Gr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ut?t instanceof Kr||this._writeRecordBatch(t):t instanceof ge?this.writeAll(t.batches):ne(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Mt.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,c=a-s-o;return t.headerType===V.RecordBatch?this._recordBatchBlocks.push(new tr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new tr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Mt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(vi)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=ot.assemble(t),o=new St(t.numRows,i,n),a=Mt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=ot.assemble(new P([t])),c=new St(t.length,s,o),l=new Ut(c,e,i),u=Mt.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,i,n;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(i=e.byteLength)>0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){var e,i;for(let[n,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),c=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,n,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,n,!0);this._seenDictionaries.set(n,s),this._dictionaryDeltaOffsets.set(n,o.length)}return this}},Pn=class r extends Xr{static writeAll(t,e){let i=new r(e);return ie(t)?t.then(n=>i.writeAll(n)):Gt(t)?xc(i,t):Sc(i,t)}},jn=class r extends Xr{static writeAll(t){let e=new r;return ie(t)?t.then(i=>e.writeAll(i)):Gt(t)?xc(e,t):Sc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){let e=Qe.encode(new Qe(t,q.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Sc(r,t){let e=t;t instanceof ge&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function xc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=re(t);n=yield i.next(),s=n.done,!s;e=!0){c=n.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function Sf(r,t){if(Gt(r))return Ip(r,t);if(ne(r))return wp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function wp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Ip(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){(e!=null&&e.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Of(r){return new Tc(r)}var Tc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ml(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=$r(s),this._getSize=n!=="bytes"?xf:Tf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?xf:Tf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},xf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Tf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function jo(r,t){let e=new De,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Rt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function zo(r,t){let e=new this(r),i=new Zt(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var vp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ka),cc),Qa),Ca),Aa),Za),La),{compareSchemas:Gr,compareFields:Qu,compareTypes:tf});It.toDOMStream=Sf;st.throughDOM=Of;Rt.throughDOM=jo;Or.throughDOM=jo;Ne.throughDOM=jo;Xr.throughDOM=zo;jn.throughDOM=zo;Pn.throughDOM=zo;var Oc=class extends et{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let t=this.create(),e=Date.now();return t.seconds=X.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(X.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=X.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=X.from(t.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(t.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(t.nanos>0){let s=(t.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(t,e,i){if(typeof t!="string")throw new Error("Unable to parse Timestamp from JSON "+Ar(t)+".");let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=X.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},Bc=new Oc;var Bf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Bf||{}),Df=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Df||{}),Dc=class extends et{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Sp=new Dc,Fc=class extends et{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},xp=new Fc,Ac=class extends et{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},OO=new Ac,Nc=class extends et{constructor(){super("arrow.flight.protocol.Empty",[])}},Tp=new Nc,Ec=class extends et{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Op=new Ec,Lc=class extends et{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Bp=new Lc,Uc=class extends et{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Dp=new Uc,Mc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>$o}])}},BO=new Mc,Rc=class extends et{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>Ff}])}},DO=new Rc,kc=class extends et{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Fp=new kc,Cc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Df,"CANCEL_STATUS_"]}])}},FO=new Cc,Vc=class extends et{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Ap=new Vc,Pc=class extends et{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Bf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Oi=new Pc,jc=class extends et{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>Ff},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},$o=new jc,zc=class extends et{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>$o},{no:2,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Bc}])}},Np=new zc,Wc=class extends et{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Ho},{no:2,name:"location",kind:"message",repeat:1,T:()=>Ep},{no:3,name:"expiration_time",kind:"message",T:()=>Bc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},Ff=new Wc,$c=class extends et{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Ep=new $c,Hc=class extends et{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Ho=new Hc,Jc=class extends et{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Oi},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},Wo=new Jc,qc=class extends et{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},Lp=new qc,Jo=new Ui("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Sp,O:xp},{name:"ListFlights",serverStreaming:!0,options:{},I:Bp,O:$o},{name:"GetFlightInfo",options:{},I:Oi,O:$o},{name:"PollFlightInfo",options:{},I:Oi,O:Np},{name:"GetSchema",options:{},I:Oi,O:Ap},{name:"DoGet",serverStreaming:!0,options:{},I:Ho,O:Wo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Wo,O:Lp},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Wo,O:Wo},{name:"DoAction",serverStreaming:!0,options:{},I:Dp,O:Fp},{name:"ListActions",serverStreaming:!0,options:{},I:Tp,O:Op}]);var qo=class{constructor(t){this._transport=t;j(this,"typeName",Jo.typeName);j(this,"methods",Jo.methods);j(this,"options",Jo.options)}handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return Jt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return Jt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return Jt("serverStreaming",this._transport,i,n,t)}};var Af=/\$(\w+)/g;function Nf(r){return!!r.match(Af)}function Ef(r,t){let e=r.match(Af);if(e)for(let i of e)t[i.trim().replace("$","")]||Yr(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var Up="2.1.0.nightly",Lf=`influxdb3-js/${Up}`;function Gc(r,t){if(t==null)return null;let e=r.metadata.get("iox::column::type");if(!e||r.typeId===f.Timestamp)return t;let[,,i,n]=e.split("::");if(i==="field")switch(n){case"integer":return Zr(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return ul(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return Zr(t)?parseFloat(t):(console.warn(`Value ${t} is not a float`),t);case"boolean":return typeof t=="boolean"||console.warn(`Value ${t} is not a boolean`),t;case"string":return typeof t=="string"?String(t):(console.warn(`Value ${t} is not a string`),t);default:return t}return t}var zn=class{constructor(t){this._options=t;j(this,"_closed",!1);j(this,"_flightClient");j(this,"_transport");j(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=Lr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new qo(this._transport)}prepareTicket(t,e,i){let n={database:t,sql_query:e,query_type:i.type};if(i.params){let s={};for(let o of Object.keys(i.params))i.params[o]&&(s[o]=i.params[o]);n.params=s}return Ho.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Lf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){if(i.params&&Nf(t)&&Ef(t,i.params),this._closed)throw new Error("queryApi: already closed!");let n=this._flightClient,s=this.prepareTicket(e,t,i),a={meta:this.prepareMetadata(i.headers)},c=n.doGet(s,a),l=(async function*(){for await(let d of c.responses)yield cl(d.dataHeader.length),yield d.dataHeader,yield d.dataBody})();yield*await Rt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=Gc(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new ur;for(let l=0;l<o.numCols;l++){let u=o.schema.fields[l],d=u.name,p=(s=o.getChildAt(l))==null?void 0:s.get(a),y=u.typeId,_=u.metadata.get("iox::column::type");if(p==null)continue;if((d==="measurement"||d=="iox::measurement")&&typeof p=="string"){c.setMeasurement(p);continue}if(!_){d==="time"&&y===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,W,at]=_.split("::");if(W==="field"){if(at&&p!==void 0&&p!==null){let ft=Gc(u,p);c.setField(d,ft,at)}}else W==="tag"?c.setTag(d,p):W==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var Kc=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
19
19
  `,Wn=class{constructor(...t){j(this,"_options");j(this,"_writeApi");j(this,"_queryApi");j(this,"_transport");j(this,"_mergeWriteOptions",t=>{var n;let e={...(n=this._options.writeOptions)==null?void 0:n.headers,...t==null?void 0:t.headers},i={...this._options.writeOptions,...t};return i.headers=e,i});j(this,"_mergeQueryOptions",t=>{var s,o;let e={...(s=this._options.queryOptions)==null?void 0:s.headers,...t==null?void 0:t.headers},i={...(o=this._options.queryOptions)==null?void 0:o.params,...t==null?void 0:t.params},n={...this._options.queryOptions,...t};return n.headers=e,n.params=i,n});var n,s;let e;switch(t.length){case 0:{e=Qo();break}case 1:{if(t[0]==null)throw new lr("No configuration specified!");typeof t[0]=="string"?e=Zo(t[0]):e=t[0];break}default:throw new lr("Multiple arguments specified!")}this._options={...Xo,...e},this._options.grpcOptions?this._options.queryOptions={...e.queryOptions,grpcOptions:{...this._options.grpcOptions}}:(n=e.queryOptions)!=null&&n.grpcOptions&&(this._options.grpcOptions=(s=e.queryOptions)==null?void 0:s.grpcOptions);let i=this._options.host;if(typeof i!="string")throw new lr("No host specified!");if(i.endsWith("/")&&(this._options.host=i.substring(0,i.length-1)),typeof this._options.token!="string")throw new lr("No token specified!");this._queryApi=new zn(this._options),this._transport=Lr.writeTransport(this._options),this._writeApi=new Vi({transport:this._transport,...this._options})}async write(t,e,i,n){var o;let s=this._mergeWriteOptions(n);await this._writeApi.doWrite(ca(t,s==null?void 0:s.defaultTags),(o=e!=null?e:this._options.database)!=null?o:Yr(new Error(Kc)),i,s)}query(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Hn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.query(t,(o=e!=null?e:this._options.database)!=null?o:Yr(new Error(Kc)),s)}queryPoints(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Hn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.queryPoints(t,(o=e!=null?e:this._options.database)!=null?o:Yr(new Error(Kc)),s)}async getServerVersion(){let t;try{let e=await this._transport.request("/ping",null,{method:"GET"},(i,n)=>{var s;t=(s=i["X-Influxdb-Version"])!=null?s:i["x-influxdb-version"]});e&&!t&&(t=e.version)}catch(e){return Promise.reject(e)}return Promise.resolve(t)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return Vf(Mp);})();
20
20
  //# sourceMappingURL=influxdb.js.map
Binary file