@influxdata/influxdb3-client 1.1.0 → 1.2.0-nightly.8263
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/index.browser.js +1 -1
- package/dist/index.browser.js.gz +0 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.browser.mjs.gz +0 -0
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/influxdb.js +1 -1
- package/dist/influxdb.js.gz +0 -0
- package/dist/influxdb.js.map +1 -1
- package/package.json +2 -2
package/dist/influxdb.js
CHANGED
|
@@ -13,6 +13,6 @@ ${t}`),new Function("x",`${t}
|
|
|
13
13
|
return true;`)}function Sh(r){return typeof r!="bigint"?ae(r):`${ae(r)}n`}function Ya(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function Wu(r,t=0){return r.length>=t?r.subarray(0,t):Vi(new r.constructor(t),r,0)}var pe=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?Ya(i*1,this.BYTES_PER_ELEMENT):Ya(i*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Ya(t*this.stride,this.BYTES_PER_ELEMENT);let e=Wu(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=Wu(this.buffer,t)}},Xe=class extends pe{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}},ui=class extends Xe{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()}},fi=class extends Xe{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=zt(t),this._nulls=new ui,e&&e.length>0&&(this._isValid=zu(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(I=>I.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 ht=class extends st{constructor(t){super(t),this._values=new Xe(this.ArrayType,0,this.stride)}setValue(t,e){let i=this._values;return i.reserve(t-i.length+1),super.setValue(t,e)}},At=class extends st{constructor(t){super(t),this._pendingLength=0,this._offsets=new fi(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 xe?e[wr].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 kr=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 Wt=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):H.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ft).__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 kr).__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 kr).__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 gt).__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,H.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 q=class r{constructor(t=[],e,i,n=H.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=Za(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=io(io(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:io(io(new Map,i[c].metadata),a.metadata)}))&&!1:!0}),o=Za(s,new Map);return new r([...i,...s],n,new Map([...this.dictionaries,...o]))}};q.prototype.fields=null;q.prototype.metadata=null;q.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 io(r,t){return new Map([...r||new Map,...t||new Map])}function Za(r,t=new Map){for(let e=-1,i=r.length;++e<i;){let s=r[e].type;if(g.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&&Za(s.children,t)}return t}var xh=Nr,Th=Vt,Ye=class{static decode(t){t=new Th(D(t));let e=Wt.getRootAsFooter(t),i=q.decode(e.schema(),new Map,e.version());return new Qa(i,e)}static encode(t){let e=new xh,i=q.encode(e,t.schema);Wt.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Ze.encode(e,o);let n=e.endVector();Wt.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Ze.encode(e,o);let s=e.endVector();return Wt.startFooter(e),Wt.addSchema(e,i),Wt.addVersion(e,H.V5),Wt.addRecordBatches(e,n),Wt.addDictionaries(e,s),Wt.finishFooterBuffer(e,Wt.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=H.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 Qa=class extends Ye{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 Ze.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Ze.decode(e)}return null}},Ze=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 kr.createBlock(t,n,i,s)}constructor(t,e,i){this.metaDataLength=t,this.offset=j(i),this.bodyLength=j(e)}};var it=Object.freeze({done:!0,value:void 0}),on=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Cr=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())}},no=class extends Cr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){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 _t.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return _t.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return y(this,void 0,void 0,function*(){return yield this.abort(t),it})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),it})}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((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 Te=class extends no{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?ki(this.toUint8Array(!0)):this.toUint8Array(!1).then(ki)}toUint8Array(t=!1){return t?Ct(this._values)[0]:y(this,void 0,void 0,function*(){var e,i,n,s;let o=[],a=0;try{for(var c=!0,l=te(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 Ct(o,a)[0]})}},Be=class{constructor(t){t&&(this.source=new tc(_t.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)}},Yt=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof Te?this.source=new Qe(_t.fromAsyncIterable(t)):hs(t)?this.source=new Qe(_t.fromNodeStream(t)):Ci(t)?this.source=new Qe(_t.fromDOMStream(t)):fs(t)?this.source=new Qe(_t.fromDOMStream(t.body)):re(t)?this.source=new Qe(_t.fromIterable(t)):ee(t)?this.source=new Qe(_t.fromAsyncIterable(t)):qt(t)&&(this.source=new Qe(_t.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)}},tc=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)}},Qe=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return y(this,arguments,void 0,function*(e,i="read"){return yield this.source.next({cmd:i,size:e})})}throw(t){return y(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 y(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 an=class extends Be{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}}},vr=class extends Yt{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return y(this,void 0,void 0,function*(){let{buffer:e,byteOffset:i}=yield this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)})}seek(t){return y(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);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 y(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 y(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var rc={};or(rc,{BaseInt64:()=>cn,Int128:()=>ln,Int64:()=>tr,Uint64:()=>at});function di(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var hi=8,ec=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],cn=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`${di(this.buffer[1])} ${di(this.buffer[0])}`}},at=class r extends cn{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=hi<i-s?hi:i-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([ec[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)}},tr=class r extends cn{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=hi<n-o?hi:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([ec[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)}},ln=class r{constructor(t){this.buffer=t}high(){return new tr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new tr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new at(new Uint32Array([this.buffer[3],0])),i=new at(new Uint32Array([this.buffer[2],0])),n=new at(new Uint32Array([this.buffer[1],0])),s=new at(new Uint32Array([this.buffer[0],0])),o=new at(new Uint32Array([t.buffer[3],0])),a=new at(new Uint32Array([t.buffer[2],0])),c=new at(new Uint32Array([t.buffer[1],0])),l=new at(new Uint32Array([t.buffer[0],0])),u=at.multiply(s,l);this.buffer[0]=u.low();let d=new at(new Uint32Array([u.high(),0]));return u=at.multiply(n,l),d.plus(u),u=at.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 at(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(at.multiply(i,l)).plus(at.multiply(n,c)).plus(at.multiply(s,a)),this.buffer[3]+=at.multiply(e,l).plus(at.multiply(i,c)).plus(at.multiply(n,a)).plus(at.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`${di(this.buffer[3])} ${di(this.buffer[2])} ${di(this.buffer[1])} ${di(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=hi<n-o?hi:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([ec[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+4*4*i,4));return e}};var un=class extends v{constructor(t,e,i,n,s=H.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<H.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)}},so=class extends un{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):Mr(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 g.isTimestamp(t)?R(Uint8Array,tr.convertArray(i[e])):(g.isInt(t)||g.isTime(t))&&t.bitWidth===64||g.isDuration(t)?R(Uint8Array,tr.convertArray(i[e])):g.isDate(t)&&t.unit===ct.MILLISECOND?R(Uint8Array,tr.convertArray(i[e])):g.isDecimal(t)?R(Uint8Array,ln.convertArray(i[e])):g.isBinary(t)||g.isLargeBinary(t)||g.isFixedSizeBinary(t)?Bh(i[e]):g.isBool(t)?Mr(i[e]):g.isUtf8(t)||g.isLargeUtf8(t)?be(i[e].join("")):R(Uint8Array,R(t.ArrayType,i[e].map(n=>+n)))}};function Bh(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 pi=class extends At{constructor(t){super(t),this._values=new pe(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 mi=class extends At{constructor(t){super(t),this._values=new pe(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 oo=class extends st{constructor(t){super(t),this._values=new ui}setValue(t,e){this._values.set(t,+e)}};var Vr=class extends ht{};Vr.prototype._setValue=Ma;var fn=class extends Vr{};fn.prototype._setValue=Es;var dn=class extends Vr{};dn.prototype._setValue=Ls;var hn=class extends ht{};hn.prototype._setValue=Ca;var ao=class extends st{constructor({type:t,nullValues:e,dictionaryHashFunction:i}){super({type:new jt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Pr({type:this.type.indices,nullValues:e}),this.dictionary=Pr({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 pn=class extends ht{};pn.prototype._setValue=Ua;var co=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 fe(this.type.listSize,new k(e,t.type,!0)),i}};var jr=class extends ht{setValue(t,e){this._values.set(t,e)}},lo=class extends jr{setValue(t,e){super.setValue(t,tn(e))}},uo=class extends jr{},fo=class extends jr{};var zr=class extends ht{};zr.prototype._setValue=Va;var mn=class extends zr{};mn.prototype._setValue=zs;var yn=class extends zr{};yn.prototype._setValue=Ws;var er=class extends ht{};er.prototype._setValue=Pa;var gn=class extends er{};gn.prototype._setValue=$s;var bn=class extends er{};bn.prototype._setValue=Hs;var _n=class extends er{};_n.prototype._setValue=Js;var wn=class extends er{};wn.prototype._setValue=qs;var Zt=class extends ht{setValue(t,e){this._values.set(t,e)}},ho=class extends Zt{},po=class extends Zt{},mo=class extends Zt{},yo=class extends Zt{},go=class extends Zt{},bo=class extends Zt{},_o=class extends Zt{},wo=class extends Zt{};var Io=class extends At{constructor(t){super(t),this._offsets=new fi(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 le(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 vo=class extends At{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 de(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 So=class extends st{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var xo=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 rr=class extends ht{};rr.prototype._setValue=Ra;var In=class extends rr{};In.prototype._setValue=Us;var vn=class extends rr{};vn.prototype._setValue=Ms;var Sn=class extends rr{};Sn.prototype._setValue=Rs;var xn=class extends rr{};xn.prototype._setValue=ks;var ir=class extends ht{};ir.prototype._setValue=ka;var Tn=class extends ir{};Tn.prototype._setValue=Cs;var Bn=class extends ir{};Bn.prototype._setValue=Vs;var On=class extends ir{};On.prototype._setValue=Ps;var Dn=class extends ir{};Dn.prototype._setValue=js;var yi=class extends st{constructor(t){super(t),this._typeIds=new Xe(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 ue(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.")}},To=class extends yi{},Bo=class extends yi{constructor(t){super(t),this._offsets=new Xe(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 Fn=class extends At{constructor(t){super(t),this._values=new pe(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,be(e))}_flushPending(t,e){}};Fn.prototype._flushPending=pi.prototype._flushPending;var An=class extends At{constructor(t){super(t),this._values=new pe(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,be(e))}_flushPending(t,e){}};An.prototype._flushPending=mi.prototype._flushPending;var ic=class extends v{visitNull(){return So}visitBool(){return oo}visitInt(){return Zt}visitInt8(){return ho}visitInt16(){return po}visitInt32(){return mo}visitInt64(){return yo}visitUint8(){return go}visitUint16(){return bo}visitUint32(){return _o}visitUint64(){return wo}visitFloat(){return jr}visitFloat16(){return lo}visitFloat32(){return uo}visitFloat64(){return fo}visitUtf8(){return Fn}visitLargeUtf8(){return An}visitBinary(){return pi}visitLargeBinary(){return mi}visitFixedSizeBinary(){return pn}visitDate(){return Vr}visitDateDay(){return fn}visitDateMillisecond(){return dn}visitTimestamp(){return rr}visitTimestampSecond(){return In}visitTimestampMillisecond(){return vn}visitTimestampMicrosecond(){return Sn}visitTimestampNanosecond(){return xn}visitTime(){return ir}visitTimeSecond(){return Tn}visitTimeMillisecond(){return Bn}visitTimeMicrosecond(){return On}visitTimeNanosecond(){return Dn}visitDecimal(){return hn}visitList(){return Io}visitStruct(){return xo}visitUnion(){return yi}visitDenseUnion(){return Bo}visitSparseUnion(){return To}visitDictionary(){return ao}visitInterval(){return zr}visitIntervalDayTime(){return mn}visitIntervalYearMonth(){return yn}visitDuration(){return er}visitDurationSecond(){return gn}visitDurationMillisecond(){return bn}visitDurationMicrosecond(){return _n}visitDurationNanosecond(){return wn}visitFixedSizeList(){return co}visitMap(){return vo}},$u=new ic;var B=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 Bt(r,t){return t instanceof r.constructor}function Wr(r,t){return r===t||Bt(r,t)}function nr(r,t){return r===t||Bt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Oo(r,t){return r===t||Bt(r,t)&&r.precision===t.precision}function Oh(r,t){return r===t||Bt(r,t)&&r.byteWidth===t.byteWidth}function nc(r,t){return r===t||Bt(r,t)&&r.unit===t.unit}function Nn(r,t){return r===t||Bt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function En(r,t){return r===t||Bt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Dh(r,t){return r===t||Bt(r,t)&&r.children.length===t.children.length&&Oe.compareManyFields(r.children,t.children)}function Fh(r,t){return r===t||Bt(r,t)&&r.children.length===t.children.length&&Oe.compareManyFields(r.children,t.children)}function sc(r,t){return r===t||Bt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Oe.compareManyFields(r.children,t.children)}function Ah(r,t){return r===t||Bt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Oe.visit(r.indices,t.indices)&&Oe.visit(r.dictionary,t.dictionary)}function oc(r,t){return r===t||Bt(r,t)&&r.unit===t.unit}function Ln(r,t){return r===t||Bt(r,t)&&r.unit===t.unit}function Nh(r,t){return r===t||Bt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Oe.compareManyFields(r.children,t.children)}function Eh(r,t){return r===t||Bt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Oe.compareManyFields(r.children,t.children)}B.prototype.visitNull=Wr;B.prototype.visitBool=Wr;B.prototype.visitInt=nr;B.prototype.visitInt8=nr;B.prototype.visitInt16=nr;B.prototype.visitInt32=nr;B.prototype.visitInt64=nr;B.prototype.visitUint8=nr;B.prototype.visitUint16=nr;B.prototype.visitUint32=nr;B.prototype.visitUint64=nr;B.prototype.visitFloat=Oo;B.prototype.visitFloat16=Oo;B.prototype.visitFloat32=Oo;B.prototype.visitFloat64=Oo;B.prototype.visitUtf8=Wr;B.prototype.visitLargeUtf8=Wr;B.prototype.visitBinary=Wr;B.prototype.visitLargeBinary=Wr;B.prototype.visitFixedSizeBinary=Oh;B.prototype.visitDate=nc;B.prototype.visitDateDay=nc;B.prototype.visitDateMillisecond=nc;B.prototype.visitTimestamp=Nn;B.prototype.visitTimestampSecond=Nn;B.prototype.visitTimestampMillisecond=Nn;B.prototype.visitTimestampMicrosecond=Nn;B.prototype.visitTimestampNanosecond=Nn;B.prototype.visitTime=En;B.prototype.visitTimeSecond=En;B.prototype.visitTimeMillisecond=En;B.prototype.visitTimeMicrosecond=En;B.prototype.visitTimeNanosecond=En;B.prototype.visitDecimal=Wr;B.prototype.visitList=Dh;B.prototype.visitStruct=Fh;B.prototype.visitUnion=sc;B.prototype.visitDenseUnion=sc;B.prototype.visitSparseUnion=sc;B.prototype.visitDictionary=Ah;B.prototype.visitInterval=oc;B.prototype.visitIntervalDayTime=oc;B.prototype.visitIntervalYearMonth=oc;B.prototype.visitDuration=Ln;B.prototype.visitDurationSecond=Ln;B.prototype.visitDurationMillisecond=Ln;B.prototype.visitDurationMicrosecond=Ln;B.prototype.visitDurationNanosecond=Ln;B.prototype.visitFixedSizeList=Nh;B.prototype.visitMap=Eh;var Oe=new B;function $r(r,t){return Oe.compareSchemas(r,t)}function Hu(r,t){return Oe.compareFields(r,t)}function Ju(r,t){return Oe.visit(r,t)}function Pr(r){let t=r.type,e=new($u.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(Pr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Do(r,t){return Lh(r,t.map(e=>e.data.concat()))}function Lh(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=Uh(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 lt(r,d))]}function Uh(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 qu,me=class r{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new q([]),this._offsets=[0],this;let n,s;t[0]instanceof q&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof lt)return[c];if(c instanceof r)return c.batches;if(c instanceof W){if(c.type instanceof rt)return[new lt(new q(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(I=>new P([c[I]])),d=n!=null?n:new q(l.map((I,_)=>new k(String(I),u[_].type,u[_].nullable))),[,p]=Do(d,u);return p.length===0?[new lt(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 q([]),!(n instanceof q))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof lt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!$r(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:Zs(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=Ys(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Er(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?li.visit(new P(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
14
14
|
${this.toArray().join(`,
|
|
15
15
|
`)}
|
|
16
|
-
]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new lt(e,n)))}slice(t,e){let i=this.schema;[t,e]=en({length:this.numRows},t,e);let n=Qs(this.data,this._offsets,t,e);return new r(i,n.map(s=>new lt(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 Tt,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]=Do(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(I=>I.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(...Do(s,o))}};qu=Symbol.toStringTag;me[qu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=ci(sn),r.get=ci(dt.getVisitFn(f.Struct)),r.set=to(wt.getVisitFn(f.Struct)),r.indexOf=eo(Rr.getVisitFn(f.Struct)),"Table"))(me.prototype);var Gu,lt=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof q))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=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 W))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ku(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 q(i),a=E({type:new rt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ku(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=Xu(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 dt.visit(this.data,t)}at(t){return this.get(Er(t,this.numRows))}set(t,e){return wt.visit(this.data,t,e)}indexOf(t,e){return Rr.visit(this.data,t,e)}[Symbol.iterator](){return li.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new me(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 Tt,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 q(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)}};Gu=Symbol.toStringTag;lt[Gu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(lt.prototype);function Ku(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 Xu(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)||[]])Xu(a.children,l==null?void 0:l.children,e);if(g.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 Hr=class extends lt{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 ye=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.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 gt).__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,H.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 ac=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Gi.startNull(e),Gi.endNull(e)}visitInt(t,e){return se.startInt(e),se.addBitWidth(e,t.bitWidth),se.addIsSigned(e,t.isSigned),se.endInt(e)}visitFloat(t,e){return mr.startFloatingPoint(e),mr.addPrecision(e,t.precision),mr.endFloatingPoint(e)}visitBinary(t,e){return $i.startBinary(e),$i.endBinary(e)}visitLargeBinary(t,e){return Ji.startLargeBinary(e),Ji.endLargeBinary(e)}visitBool(t,e){return Hi.startBool(e),Hi.endBool(e)}visitUtf8(t,e){return Yi.startUtf8(e),Yi.endUtf8(e)}visitLargeUtf8(t,e){return qi.startLargeUtf8(e),qi.endLargeUtf8(e)}visitDecimal(t,e){return ve.startDecimal(e),ve.addScale(e,t.scale),ve.addPrecision(e,t.precision),ve.addBitWidth(e,t.bitWidth),ve.endDecimal(e)}visitDate(t,e){return fr.startDate(e),fr.addUnit(e,t.unit),fr.endDate(e)}visitTime(t,e){return Me.startTime(e),Me.addUnit(e,t.unit),Me.addBitWidth(e,t.bitWidth),Me.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Re.startTimestamp(e),Re.addUnit(e,t.unit),i!==void 0&&Re.addTimezone(e,i),Re.endTimestamp(e)}visitInterval(t,e){return yr.startInterval(e),yr.addUnit(e,t.unit),yr.endInterval(e)}visitDuration(t,e){return dr.startDuration(e),dr.addUnit(e,t.unit),dr.endDuration(e)}visitList(t,e){return Ki.startList(e),Ki.endList(e)}visitStruct(t,e){return Xi.startStruct_(e),Xi.endStruct_(e)}visitUnion(t,e){oe.startTypeIdsVector(e,t.typeIds.length);let i=oe.createTypeIdsVector(e,t.typeIds);return oe.startUnion(e),oe.addMode(e,t.mode),oe.addTypeIds(e,i),oe.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return Ie.startDictionaryEncoding(e),Ie.addId(e,BigInt(t.id)),Ie.addIsOrdered(e,t.isOrdered),i!==void 0&&Ie.addIndexType(e,i),Ie.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return hr.startFixedSizeBinary(e),hr.addByteWidth(e,t.byteWidth),hr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return pr.startFixedSizeList(e),pr.addListSize(e,t.listSize),pr.endFixedSizeList(e)}visitMap(t,e){return gr.startMap(e),gr.addKeysSorted(e,t.keysSorted),gr.endMap(e)}},Fo=new ac;function tf(r,t=new Map){return new q(Rh(r,t),Ao(r.metadata),t)}function cc(r){return new It(r.count,rf(r.columns),nf(r.columns))}function ef(r){return new Et(cc(r.data),r.id,r.isDelta)}function Rh(r,t){return(r.fields||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function Yu(r,t){return(r.children||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function rf(r){return(r||[]).reduce((t,e)=>[...t,new Qt(e.count,kh(e.VALIDITY)),...rf(e.children)],[])}function nf(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new Nt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new Nt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new Nt(t.length,n.OFFSET.length)),n.DATA&&t.push(new Nt(t.length,n.DATA.length)),t=nf(n.children,t)}return t}function kh(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function sf(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=Qu(r,Yu(r,t)),n=new k(r.name,o,r.nullable,Ao(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?Zu(i):new Se,a=new jt(t.get(e),i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Ao(r.metadata))):(i=(i=s.indexType)?Zu(i):new Se,t.set(e,o=Qu(r,Yu(r,t))),a=new jt(o,i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Ao(r.metadata))),n||null}function Ao(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Zu(r){return new bt(r.isSigned,r.bitWidth)}function Qu(r,t){let e=r.type.name;switch(e){case"NONE":return new Tt;case"null":return new Tt;case"binary":return new ke;case"largebinary":return new Ce;case"utf8":return new Ve;case"largeutf8":return new Pe;case"bool":return new je;case"list":return new le((t||[])[0]);case"struct":return new rt(t||[]);case"struct_":return new rt(t||[])}switch(e){case"int":{let i=r.type;return new bt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Xt(G[i.precision])}case"decimal":{let i=r.type;return new ze(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new We(ct[i.unit])}case"time":{let i=r.type;return new $e(b[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new He(b[i.unit],i.timezone)}case"interval":{let i=r.type;return new Je(yt[i.unit])}case"duration":{let i=r.type;return new qe(b[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new ue(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Ke(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new fe(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new de((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var Ch=Nr,Vh=Vt,Lt=class r{static fromJSON(t,e){let i=new r(0,H.V5,e);return i._createHeader=Ph(t,e),i}static decode(t){t=new Vh(D(t));let e=ye.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=jh(e,s),o}static encode(t){let e=new Ch,i=-1;return t.isSchema()?i=q.encode(e,t.header()):t.isRecordBatch()?i=It.encode(e,t.header()):t.isDictionaryBatch()&&(i=Et.encode(e,t.header())),ye.startMessage(e),ye.addVersion(e,H.V5),ye.addHeader(e,i),ye.addHeaderType(e,t.headerType),ye.addBodyLength(e,BigInt(t.bodyLength)),ye.finishMessageBuffer(e,ye.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof q)return new r(0,H.V5,V.Schema,t);if(t instanceof It)return new r(e,H.V5,V.RecordBatch,t);if(t instanceof Et)return new r(e,H.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=j(t)}},It=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=j(t)}},Et=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=j(e)}},Nt=class{constructor(t,e){this.offset=j(t),this.length=j(e)}},Qt=class{constructor(t,e){this.length=j(t),this.nullCount=j(e)}};function Ph(r,t){return()=>{switch(t){case V.Schema:return q.fromJSON(r);case V.RecordBatch:return It.fromJSON(r);case V.DictionaryBatch:return Et.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)}}function jh(r,t){return()=>{switch(t){case V.Schema:return q.decode(r.header(new Ft),new Map,r.version());case V.RecordBatch:return It.decode(r.header(new Pt),r.version());case V.DictionaryBatch:return Et.decode(r.header(new Ue),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)}}k.encode=Zh;k.decode=Xh;k.fromJSON=sf;q.encode=Yh;q.decode=zh;q.fromJSON=tf;It.encode=Qh;It.decode=Wh;It.fromJSON=cc;Et.encode=tp;Et.decode=$h;Et.fromJSON=ef;Qt.encode=ep;Qt.decode=Jh;Nt.encode=rp;Nt.decode=Hh;function zh(r,t=new Map,e=H.V5){let i=Gh(r,t);return new q(i,No(r),t,e)}function Wh(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new It(r.length(),qh(r),Kh(r,t))}function $h(r,t=H.V5){return new Et(It.decode(r.data(),t),r.id(),r.isDelta())}function Hh(r){return new Nt(r.offset(),r.length())}function Jh(r){return new Qt(r.length(),r.nullCount())}function qh(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=Qt.decode(e));return t}function Kh(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<H.V4&&(i.bb_pos+=8*(n+1)),e[++s]=Nt.decode(i));return e}function Gh(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 of(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 Xh(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=cf(r,of(r,t)),i=new k(r.name(),n,r.nullable(),No(r))):t.has(e=j(a.id()))?(s=(s=a.indexType())?af(s):new Se,o=new jt(t.get(e),s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),No(r))):(s=(s=a.indexType())?af(s):new Se,t.set(e,n=cf(r,of(r,t))),o=new jt(n,s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),No(r))),i||null}function No(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 af(r){return new bt(r.isSigned(),r.bitWidth())}function cf(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Tt;case Q.Null:return new Tt;case Q.Binary:return new ke;case Q.LargeBinary:return new Ce;case Q.Utf8:return new Ve;case Q.LargeUtf8:return new Pe;case Q.Bool:return new je;case Q.List:return new le((t||[])[0]);case Q.Struct_:return new rt(t||[])}switch(e){case Q.Int:{let i=r.type(new se);return new bt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new mr);return new Xt(i.precision())}case Q.Decimal:{let i=r.type(new ve);return new ze(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new fr);return new We(i.unit())}case Q.Time:{let i=r.type(new Me);return new $e(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Re);return new He(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new yr);return new Je(i.unit())}case Q.Duration:{let i=r.type(new dr);return new qe(i.unit())}case Q.Union:{let i=r.type(new oe);return new ue(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new hr);return new Ke(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new pr);return new fe(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new gr);return new de((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function Yh(r,t){let e=t.fields.map(s=>k.encode(r,s));Ft.startFieldsVector(r,e.length);let i=Ft.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Ft.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return gt.startKeyValue(r),gt.addKey(r,a),gt.addValue(r,c),gt.endKeyValue(r)})):-1;return Ft.startSchema(r),Ft.addFields(r,i),Ft.addEndianness(r,ip?ur.Little:ur.Big),n!==-1&&Ft.addCustomMetadata(r,n),Ft.endSchema(r)}function Zh(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;g.isDictionary(s)?(o=s.dictionary.typeId,n=Fo.visit(s,r),i=Fo.visit(s.dictionary,r)):i=Fo.visit(s,r);let a=(s.children||[]).map(u=>k.encode(r,u)),c=vt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?vt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),I=r.createString(`${d}`);return gt.startKeyValue(r),gt.addKey(r,p),gt.addValue(r,I),gt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),vt.startField(r),vt.addType(r,i),vt.addTypeType(r,o),vt.addChildren(r,c),vt.addNullable(r,!!t.nullable),e!==-1&&vt.addName(r,e),n!==-1&&vt.addDictionary(r,n),l!==-1&&vt.addCustomMetadata(r,l),vt.endField(r)}function Qh(r,t){let e=t.nodes||[],i=t.buffers||[];Pt.startNodesVector(r,e.length);for(let o of e.slice().reverse())Qt.encode(r,o);let n=r.endVector();Pt.startBuffersVector(r,i.length);for(let o of i.slice().reverse())Nt.encode(r,o);let s=r.endVector();return Pt.startRecordBatch(r),Pt.addLength(r,BigInt(t.length)),Pt.addNodes(r,n),Pt.addBuffers(r,s),Pt.endRecordBatch(r)}function tp(r,t){let e=It.encode(r,t.data);return Ue.startDictionaryBatch(r),Ue.addId(r,BigInt(t.id)),Ue.addIsDelta(r,t.isDelta),Ue.addData(r,e),Ue.endDictionaryBatch(r)}function ep(r,t){return Qr.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function rp(r,t){return Zr.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var ip=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var uc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,fc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,lf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,uf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,gi=class{constructor(t){this.source=t instanceof Be?t:new Be(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(uc(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(uf(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(fc(e));return n}readMetadataLength(){let t=this.source.read(Eo),e=t&&new Vt(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(lf(t,e.byteLength));return{done:!1,value:Lt.decode(e)}}},Un=class{constructor(t,e){this.source=t instanceof Yt?t:us(t)?new vr(t,e):new Yt(t)}[Symbol.asyncIterator](){return this}next(){return y(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 y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(uc(t));return e.value})}readMessageBody(t){return y(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(uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return y(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(fc(e));return n})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(Eo),e=t&&new Vt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(lf(t,e.byteLength));return{done:!1,value:Lt.decode(e)}})}},Mn=class extends gi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof on?t:new on(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Lt.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:Lt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Lt.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(uc(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(fc(t));return i}},Eo=4,lc="ARROW1",bi=new Uint8Array(lc.length);for(let r=0;r<lc.length;r+=1)bi[r]=lc.codePointAt(r);function Lo(r,t=0){for(let e=-1,i=bi.length;++e<i;)if(bi[e]!==r[t+e])return!1;return!0}var _i=bi.length,dc=_i+Eo,ff=_i*2+Eo;var Ut=class r extends Cr{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 ee(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 _t.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return _t.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:cs(t)?sp(t):us(t)?cp(t):ee(t)?y(this,void 0,void 0,function*(){return yield r.from(yield t)}):fs(t)||Ci(t)||hs(t)||qt(t)?ap(new Yt(t)):op(new Be(t))}static readAll(t){return t instanceof r?t.isSync()?df(t):hf(t):cs(t)||ArrayBuffer.isView(t)||re(t)||ls(t)?df(t):hf(t)}},De=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return kt(this,arguments,function*(){yield U(yield*Xr(te(this[Symbol.iterator]())))})}},Sr=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return y(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=te(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]()}},xr=class extends De{constructor(t){super(t),this._impl=t}},Rn=class extends Sr{constructor(t){super(t),this._impl=t}},Uo=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 lt(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 un(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}},wi=class extends Uo{constructor(t,e){super(e),this._reader=cs(t)?new Mn(this._handle=t):new gi(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=pf(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 Hr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ii=class extends Uo{constructor(t,e){super(e),this._reader=new Un(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=pf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):it})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):it})}next(){return y(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 Hr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Mo=class extends wi{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 an?t:new an(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-dc,i=t.readInt32(e),n=t.readAt(e-i,i);return Ye.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}},hc=class extends Ii{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 vr?t:new vr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return y(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 y(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 y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-dc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Ye.decode(n)})}_readNextMessageAndValidate(t){return y(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})}},pc=class extends wi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new so(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function pf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*df(r){let t=Ut.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function hf(r){return kt(this,arguments,function*(){let e=yield U(Ut.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 sp(r){return new De(new pc(r))}function op(r){let t=r.peek(_i+7&-8);return t&&t.byteLength>=4?Lo(t)?new xr(new Mo(r.read())):new De(new wi(r)):new De(new wi(function*(){}()))}function ap(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(_i+7&-8);return t&&t.byteLength>=4?Lo(t)?new xr(new Mo(yield r.read())):new Sr(new Ii(r)):new Sr(new Ii(function(){return kt(this,arguments,function*(){})}()))})}function cp(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new vr(r,t);return t>=ff&&Lo(yield e.readAt(0,_i+7&-8))?new Rn(new hc(e)):new Sr(new Ii(e))})}var ot=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof lt?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(!g.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(g.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;g.isNull(e)||ge.call(this,n<=0?new Uint8Array(0):Ur(t.offset,i,t.nullBitmap)),this.nodes.push(new Qt(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 ge(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Nt(this._byteLength,t)),this._byteLength+=t,this}function lp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(ge.call(this,n),e.mode===Z.Sparse)return mc.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return ge.call(this,s),mc.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);ge.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],I=c[d];return l.slice(p,Math.min(i,I))}))}}return this}function up(r){let t;return r.nullCount>=r.length?ge.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?ge.call(this,Ur(r.offset,r.length,t)):ge.call(this,Mr(r.values))}function sr(r){return ge.call(this,r.values.subarray(0,r.length*r.stride))}function Ro(r){let{length:t,values:e,valueOffsets:i}=r,n=j(i[0]),s=j(i[t]),o=Math.min(s-n,e.byteLength-n);return ge.call(this,ms(-n,t+1,i)),ge.call(this,e.subarray(n,n+o)),this}function yc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return ge.call(this,ms(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function mc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}ot.prototype.visitBool=up;ot.prototype.visitInt=sr;ot.prototype.visitFloat=sr;ot.prototype.visitUtf8=Ro;ot.prototype.visitLargeUtf8=Ro;ot.prototype.visitBinary=Ro;ot.prototype.visitLargeBinary=Ro;ot.prototype.visitFixedSizeBinary=sr;ot.prototype.visitDate=sr;ot.prototype.visitTimestamp=sr;ot.prototype.visitTime=sr;ot.prototype.visitDecimal=sr;ot.prototype.visitList=yc;ot.prototype.visitStruct=mc;ot.prototype.visitUnion=lp;ot.prototype.visitInterval=sr;ot.prototype.visitDuration=sr;ot.prototype.visitFixedSizeList=yc;ot.prototype.visitMap=yc;var Jr=class extends Cr{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 Te,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,xt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ee(t)?t.then(e=>this.writeAll(e)):qt(t)?bc(this,t):gc(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 Te?this._sink=t:(this._sink=new Te,t&&Fl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Al(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||!$r(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 me&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof lt&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!$r(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof lt?t instanceof Hr||this._writeRecordBatch(t):t instanceof me?this.writeAll(t.batches):re(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Lt.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 Ze(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new Ze(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(Lt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bi)}_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 It(t.numRows,i,n),a=Lt.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 It(t.length,s,o),l=new Et(c,e,i),u=Lt.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}},kn=class r extends Jr{static writeAll(t,e){let i=new r(e);return ee(t)?t.then(n=>i.writeAll(n)):qt(t)?bc(i,t):gc(i,t)}},Cn=class r extends Jr{static writeAll(t){let e=new r;return ee(t)?t.then(i=>e.writeAll(i)):qt(t)?bc(e,t):gc(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=Ye.encode(new Ye(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function gc(r,t){let e=t;t instanceof me&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function bc(r,t){return y(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=te(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 mf(r,t){if(qt(r))return dp(r,t);if(re(r))return fp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function fp(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 dp(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 y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(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 y(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 bf(r){return new _c(r)}var _c=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ol(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Pr(s),this._getSize=n!=="bytes"?yf:gf;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"?yf:gf}),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)}},yf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},gf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function ko(r,t){let e=new Te,i=null,n=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return y(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 y(this,void 0,void 0,function*(){return yield(yield Ut.from(e)).open(t)})}function o(a,c){return y(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 Co(r,t){let e=new this(r),i=new Yt(e),n=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(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 y(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 hp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Na),rc),qa),Ea),xa),Ja),Oa),{compareSchemas:$r,compareFields:Hu,compareTypes:Ju});_t.toDOMStream=mf;st.throughDOM=bf;Ut.throughDOM=ko;xr.throughDOM=ko;De.throughDOM=ko;Jr.throughDOM=Co;Cn.throughDOM=Co;kn.throughDOM=Co;var wc=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=K.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(K.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=K.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=K.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 "+Or(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=K.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},Ic=new wc;var _f=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(_f||{}),wf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(wf||{}),vc=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}])}},pp=new vc,Sc=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}])}},mp=new Sc,xc=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}])}},dB=new xc,Tc=class extends et{constructor(){super("arrow.flight.protocol.Empty",[])}},yp=new Tc,Bc=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}])}},gp=new Bc,Oc=class extends et{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},bp=new Oc,Dc=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}])}},_p=new Dc,Fc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Po}])}},hB=new Fc,Ac=class extends et{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>If}])}},pB=new Ac,Nc=class extends et{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},wp=new Nc,Ec=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",wf,"CANCEL_STATUS_"]}])}},mB=new Ec,Lc=class extends et{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Ip=new Lc,Uc=class extends et{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",_f]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},vi=new Uc,Mc=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:()=>vi},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>If},{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}])}},Po=new Mc,Rc=class extends et{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Po},{no:2,name:"flight_descriptor",kind:"message",T:()=>vi},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Ic}])}},vp=new Rc,kc=class extends et{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>jo},{no:2,name:"location",kind:"message",repeat:1,T:()=>Sp},{no:3,name:"expiration_time",kind:"message",T:()=>Ic},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},If=new kc,Cc=class extends et{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Sp=new Cc,Vc=class extends et{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},jo=new Vc,Pc=class extends et{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>vi},{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}])}},Vo=new Pc,jc=class extends et{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},xp=new jc,zo=new Ai("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:pp,O:mp},{name:"ListFlights",serverStreaming:!0,options:{},I:bp,O:Po},{name:"GetFlightInfo",options:{},I:vi,O:Po},{name:"PollFlightInfo",options:{},I:vi,O:vp},{name:"GetSchema",options:{},I:vi,O:Ip},{name:"DoGet",serverStreaming:!0,options:{},I:jo,O:Vo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Vo,O:xp},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Vo,O:Vo},{name:"DoAction",serverStreaming:!0,options:{},I:_p,O:wp},{name:"ListActions",serverStreaming:!0,options:{},I:yp,O:gp}]);var Wo=class{constructor(t){this._transport=t;this.typeName=zo.typeName;this.methods=zo.methods;this.options=zo.options}handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}};var vf=/\$(\w+)/g;function Sf(r){return!!r.match(vf)}function xf(r,t){let e=r.match(vf);if(e)for(let i of e)t[i.trim().replace("$","")]||qr(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var Tp="1.1.0",Tf=`influxdb3-js/${Tp}`;function zc(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 Kr(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return il(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return Kr(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 Vn=class{constructor(t){this._options=t;this._closed=!1;let{host:e,queryTimeout:i}=this._options;this._defaultHeaders=this._options.headers,this._transport=Mi.queryTransport({host:e,timeout:i}),this._flightClient=new Wo(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 jo.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Tf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){if(i.params&&Sf(t)&&xf(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 el(d.dataHeader.length),yield d.dataHeader,yield d.dataBody}();yield*await Ut.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n){let o={};for(let a of s){for(let c of s.schema.fields){let l=a[c.name];o[c.name]=zc(c,l)}yield o}}}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 cr;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),I=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"&&I===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,X,Y]=_.split("::");if(X==="field"){if(Y&&p!==void 0&&p!==null){let ft=zc(u,p);c.setField(d,ft,Y)}}else X==="tag"?c.setTag(d,p):X==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var Wc=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
16
|
+
]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new lt(e,n)))}slice(t,e){let i=this.schema;[t,e]=en({length:this.numRows},t,e);let n=Qs(this.data,this._offsets,t,e);return new r(i,n.map(s=>new lt(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 Tt,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]=Do(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(I=>I.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(...Do(s,o))}};qu=Symbol.toStringTag;me[qu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=ci(sn),r.get=ci(dt.getVisitFn(f.Struct)),r.set=to(wt.getVisitFn(f.Struct)),r.indexOf=eo(Rr.getVisitFn(f.Struct)),"Table"))(me.prototype);var Gu,lt=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof q))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=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 W))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ku(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 q(i),a=E({type:new rt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ku(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=Xu(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 dt.visit(this.data,t)}at(t){return this.get(Er(t,this.numRows))}set(t,e){return wt.visit(this.data,t,e)}indexOf(t,e){return Rr.visit(this.data,t,e)}[Symbol.iterator](){return li.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new me(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 Tt,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 q(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)}};Gu=Symbol.toStringTag;lt[Gu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(lt.prototype);function Ku(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 Xu(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)||[]])Xu(a.children,l==null?void 0:l.children,e);if(g.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 Hr=class extends lt{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 ye=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.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 gt).__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,H.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 ac=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Gi.startNull(e),Gi.endNull(e)}visitInt(t,e){return se.startInt(e),se.addBitWidth(e,t.bitWidth),se.addIsSigned(e,t.isSigned),se.endInt(e)}visitFloat(t,e){return mr.startFloatingPoint(e),mr.addPrecision(e,t.precision),mr.endFloatingPoint(e)}visitBinary(t,e){return $i.startBinary(e),$i.endBinary(e)}visitLargeBinary(t,e){return Ji.startLargeBinary(e),Ji.endLargeBinary(e)}visitBool(t,e){return Hi.startBool(e),Hi.endBool(e)}visitUtf8(t,e){return Yi.startUtf8(e),Yi.endUtf8(e)}visitLargeUtf8(t,e){return qi.startLargeUtf8(e),qi.endLargeUtf8(e)}visitDecimal(t,e){return ve.startDecimal(e),ve.addScale(e,t.scale),ve.addPrecision(e,t.precision),ve.addBitWidth(e,t.bitWidth),ve.endDecimal(e)}visitDate(t,e){return fr.startDate(e),fr.addUnit(e,t.unit),fr.endDate(e)}visitTime(t,e){return Me.startTime(e),Me.addUnit(e,t.unit),Me.addBitWidth(e,t.bitWidth),Me.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Re.startTimestamp(e),Re.addUnit(e,t.unit),i!==void 0&&Re.addTimezone(e,i),Re.endTimestamp(e)}visitInterval(t,e){return yr.startInterval(e),yr.addUnit(e,t.unit),yr.endInterval(e)}visitDuration(t,e){return dr.startDuration(e),dr.addUnit(e,t.unit),dr.endDuration(e)}visitList(t,e){return Ki.startList(e),Ki.endList(e)}visitStruct(t,e){return Xi.startStruct_(e),Xi.endStruct_(e)}visitUnion(t,e){oe.startTypeIdsVector(e,t.typeIds.length);let i=oe.createTypeIdsVector(e,t.typeIds);return oe.startUnion(e),oe.addMode(e,t.mode),oe.addTypeIds(e,i),oe.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return Ie.startDictionaryEncoding(e),Ie.addId(e,BigInt(t.id)),Ie.addIsOrdered(e,t.isOrdered),i!==void 0&&Ie.addIndexType(e,i),Ie.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return hr.startFixedSizeBinary(e),hr.addByteWidth(e,t.byteWidth),hr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return pr.startFixedSizeList(e),pr.addListSize(e,t.listSize),pr.endFixedSizeList(e)}visitMap(t,e){return gr.startMap(e),gr.addKeysSorted(e,t.keysSorted),gr.endMap(e)}},Fo=new ac;function tf(r,t=new Map){return new q(Rh(r,t),Ao(r.metadata),t)}function cc(r){return new It(r.count,rf(r.columns),nf(r.columns))}function ef(r){return new Et(cc(r.data),r.id,r.isDelta)}function Rh(r,t){return(r.fields||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function Yu(r,t){return(r.children||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function rf(r){return(r||[]).reduce((t,e)=>[...t,new Qt(e.count,kh(e.VALIDITY)),...rf(e.children)],[])}function nf(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new Nt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new Nt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new Nt(t.length,n.OFFSET.length)),n.DATA&&t.push(new Nt(t.length,n.DATA.length)),t=nf(n.children,t)}return t}function kh(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function sf(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=Qu(r,Yu(r,t)),n=new k(r.name,o,r.nullable,Ao(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?Zu(i):new Se,a=new jt(t.get(e),i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Ao(r.metadata))):(i=(i=s.indexType)?Zu(i):new Se,t.set(e,o=Qu(r,Yu(r,t))),a=new jt(o,i,e,s.isOrdered),n=new k(r.name,a,r.nullable,Ao(r.metadata))),n||null}function Ao(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Zu(r){return new bt(r.isSigned,r.bitWidth)}function Qu(r,t){let e=r.type.name;switch(e){case"NONE":return new Tt;case"null":return new Tt;case"binary":return new ke;case"largebinary":return new Ce;case"utf8":return new Ve;case"largeutf8":return new Pe;case"bool":return new je;case"list":return new le((t||[])[0]);case"struct":return new rt(t||[]);case"struct_":return new rt(t||[])}switch(e){case"int":{let i=r.type;return new bt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Xt(G[i.precision])}case"decimal":{let i=r.type;return new ze(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new We(ct[i.unit])}case"time":{let i=r.type;return new $e(b[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new He(b[i.unit],i.timezone)}case"interval":{let i=r.type;return new Je(yt[i.unit])}case"duration":{let i=r.type;return new qe(b[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new ue(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Ke(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new fe(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new de((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var Ch=Nr,Vh=Vt,Lt=class r{static fromJSON(t,e){let i=new r(0,H.V5,e);return i._createHeader=Ph(t,e),i}static decode(t){t=new Vh(D(t));let e=ye.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=jh(e,s),o}static encode(t){let e=new Ch,i=-1;return t.isSchema()?i=q.encode(e,t.header()):t.isRecordBatch()?i=It.encode(e,t.header()):t.isDictionaryBatch()&&(i=Et.encode(e,t.header())),ye.startMessage(e),ye.addVersion(e,H.V5),ye.addHeader(e,i),ye.addHeaderType(e,t.headerType),ye.addBodyLength(e,BigInt(t.bodyLength)),ye.finishMessageBuffer(e,ye.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof q)return new r(0,H.V5,V.Schema,t);if(t instanceof It)return new r(e,H.V5,V.RecordBatch,t);if(t instanceof Et)return new r(e,H.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=j(t)}},It=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=j(t)}},Et=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=j(e)}},Nt=class{constructor(t,e){this.offset=j(t),this.length=j(e)}},Qt=class{constructor(t,e){this.length=j(t),this.nullCount=j(e)}};function Ph(r,t){return()=>{switch(t){case V.Schema:return q.fromJSON(r);case V.RecordBatch:return It.fromJSON(r);case V.DictionaryBatch:return Et.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)}}function jh(r,t){return()=>{switch(t){case V.Schema:return q.decode(r.header(new Ft),new Map,r.version());case V.RecordBatch:return It.decode(r.header(new Pt),r.version());case V.DictionaryBatch:return Et.decode(r.header(new Ue),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)}}k.encode=Zh;k.decode=Xh;k.fromJSON=sf;q.encode=Yh;q.decode=zh;q.fromJSON=tf;It.encode=Qh;It.decode=Wh;It.fromJSON=cc;Et.encode=tp;Et.decode=$h;Et.fromJSON=ef;Qt.encode=ep;Qt.decode=Jh;Nt.encode=rp;Nt.decode=Hh;function zh(r,t=new Map,e=H.V5){let i=Gh(r,t);return new q(i,No(r),t,e)}function Wh(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new It(r.length(),qh(r),Kh(r,t))}function $h(r,t=H.V5){return new Et(It.decode(r.data(),t),r.id(),r.isDelta())}function Hh(r){return new Nt(r.offset(),r.length())}function Jh(r){return new Qt(r.length(),r.nullCount())}function qh(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=Qt.decode(e));return t}function Kh(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<H.V4&&(i.bb_pos+=8*(n+1)),e[++s]=Nt.decode(i));return e}function Gh(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 of(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 Xh(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=cf(r,of(r,t)),i=new k(r.name(),n,r.nullable(),No(r))):t.has(e=j(a.id()))?(s=(s=a.indexType())?af(s):new Se,o=new jt(t.get(e),s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),No(r))):(s=(s=a.indexType())?af(s):new Se,t.set(e,n=cf(r,of(r,t))),o=new jt(n,s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),No(r))),i||null}function No(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 af(r){return new bt(r.isSigned(),r.bitWidth())}function cf(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Tt;case Q.Null:return new Tt;case Q.Binary:return new ke;case Q.LargeBinary:return new Ce;case Q.Utf8:return new Ve;case Q.LargeUtf8:return new Pe;case Q.Bool:return new je;case Q.List:return new le((t||[])[0]);case Q.Struct_:return new rt(t||[])}switch(e){case Q.Int:{let i=r.type(new se);return new bt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new mr);return new Xt(i.precision())}case Q.Decimal:{let i=r.type(new ve);return new ze(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new fr);return new We(i.unit())}case Q.Time:{let i=r.type(new Me);return new $e(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Re);return new He(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new yr);return new Je(i.unit())}case Q.Duration:{let i=r.type(new dr);return new qe(i.unit())}case Q.Union:{let i=r.type(new oe);return new ue(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new hr);return new Ke(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new pr);return new fe(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new gr);return new de((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function Yh(r,t){let e=t.fields.map(s=>k.encode(r,s));Ft.startFieldsVector(r,e.length);let i=Ft.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Ft.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return gt.startKeyValue(r),gt.addKey(r,a),gt.addValue(r,c),gt.endKeyValue(r)})):-1;return Ft.startSchema(r),Ft.addFields(r,i),Ft.addEndianness(r,ip?ur.Little:ur.Big),n!==-1&&Ft.addCustomMetadata(r,n),Ft.endSchema(r)}function Zh(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;g.isDictionary(s)?(o=s.dictionary.typeId,n=Fo.visit(s,r),i=Fo.visit(s.dictionary,r)):i=Fo.visit(s,r);let a=(s.children||[]).map(u=>k.encode(r,u)),c=vt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?vt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),I=r.createString(`${d}`);return gt.startKeyValue(r),gt.addKey(r,p),gt.addValue(r,I),gt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),vt.startField(r),vt.addType(r,i),vt.addTypeType(r,o),vt.addChildren(r,c),vt.addNullable(r,!!t.nullable),e!==-1&&vt.addName(r,e),n!==-1&&vt.addDictionary(r,n),l!==-1&&vt.addCustomMetadata(r,l),vt.endField(r)}function Qh(r,t){let e=t.nodes||[],i=t.buffers||[];Pt.startNodesVector(r,e.length);for(let o of e.slice().reverse())Qt.encode(r,o);let n=r.endVector();Pt.startBuffersVector(r,i.length);for(let o of i.slice().reverse())Nt.encode(r,o);let s=r.endVector();return Pt.startRecordBatch(r),Pt.addLength(r,BigInt(t.length)),Pt.addNodes(r,n),Pt.addBuffers(r,s),Pt.endRecordBatch(r)}function tp(r,t){let e=It.encode(r,t.data);return Ue.startDictionaryBatch(r),Ue.addId(r,BigInt(t.id)),Ue.addIsDelta(r,t.isDelta),Ue.addData(r,e),Ue.endDictionaryBatch(r)}function ep(r,t){return Qr.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function rp(r,t){return Zr.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var ip=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var uc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,fc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,lf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,uf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,gi=class{constructor(t){this.source=t instanceof Be?t:new Be(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(uc(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(uf(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(fc(e));return n}readMetadataLength(){let t=this.source.read(Eo),e=t&&new Vt(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(lf(t,e.byteLength));return{done:!1,value:Lt.decode(e)}}},Un=class{constructor(t,e){this.source=t instanceof Yt?t:us(t)?new vr(t,e):new Yt(t)}[Symbol.asyncIterator](){return this}next(){return y(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 y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(uc(t));return e.value})}readMessageBody(t){return y(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(uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return y(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(fc(e));return n})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(Eo),e=t&&new Vt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return it;if(e.byteLength<t)throw new Error(lf(t,e.byteLength));return{done:!1,value:Lt.decode(e)}})}},Mn=class extends gi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof on?t:new on(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Lt.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:Lt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Lt.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(uc(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(fc(t));return i}},Eo=4,lc="ARROW1",bi=new Uint8Array(lc.length);for(let r=0;r<lc.length;r+=1)bi[r]=lc.codePointAt(r);function Lo(r,t=0){for(let e=-1,i=bi.length;++e<i;)if(bi[e]!==r[t+e])return!1;return!0}var _i=bi.length,dc=_i+Eo,ff=_i*2+Eo;var Ut=class r extends Cr{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 ee(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 _t.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return _t.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:cs(t)?sp(t):us(t)?cp(t):ee(t)?y(this,void 0,void 0,function*(){return yield r.from(yield t)}):fs(t)||Ci(t)||hs(t)||qt(t)?ap(new Yt(t)):op(new Be(t))}static readAll(t){return t instanceof r?t.isSync()?df(t):hf(t):cs(t)||ArrayBuffer.isView(t)||re(t)||ls(t)?df(t):hf(t)}},De=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return kt(this,arguments,function*(){yield U(yield*Xr(te(this[Symbol.iterator]())))})}},Sr=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return y(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=te(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]()}},xr=class extends De{constructor(t){super(t),this._impl=t}},Rn=class extends Sr{constructor(t){super(t),this._impl=t}},Uo=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 lt(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 un(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}},wi=class extends Uo{constructor(t,e){super(e),this._reader=cs(t)?new Mn(this._handle=t):new gi(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=pf(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 Hr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ii=class extends Uo{constructor(t,e){super(e),this._reader=new Un(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=pf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):it})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):it})}next(){return y(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 Hr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Mo=class extends wi{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 an?t:new an(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-dc,i=t.readInt32(e),n=t.readAt(e-i,i);return Ye.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}},hc=class extends Ii{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 vr?t:new vr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return y(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 y(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 y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-dc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Ye.decode(n)})}_readNextMessageAndValidate(t){return y(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})}},pc=class extends wi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new so(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function pf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*df(r){let t=Ut.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function hf(r){return kt(this,arguments,function*(){let e=yield U(Ut.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 sp(r){return new De(new pc(r))}function op(r){let t=r.peek(_i+7&-8);return t&&t.byteLength>=4?Lo(t)?new xr(new Mo(r.read())):new De(new wi(r)):new De(new wi(function*(){}()))}function ap(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(_i+7&-8);return t&&t.byteLength>=4?Lo(t)?new xr(new Mo(yield r.read())):new Sr(new Ii(r)):new Sr(new Ii(function(){return kt(this,arguments,function*(){})}()))})}function cp(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new vr(r,t);return t>=ff&&Lo(yield e.readAt(0,_i+7&-8))?new Rn(new hc(e)):new Sr(new Ii(e))})}var ot=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof lt?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(!g.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(g.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;g.isNull(e)||ge.call(this,n<=0?new Uint8Array(0):Ur(t.offset,i,t.nullBitmap)),this.nodes.push(new Qt(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 ge(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Nt(this._byteLength,t)),this._byteLength+=t,this}function lp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(ge.call(this,n),e.mode===Z.Sparse)return mc.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return ge.call(this,s),mc.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);ge.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],I=c[d];return l.slice(p,Math.min(i,I))}))}}return this}function up(r){let t;return r.nullCount>=r.length?ge.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?ge.call(this,Ur(r.offset,r.length,t)):ge.call(this,Mr(r.values))}function sr(r){return ge.call(this,r.values.subarray(0,r.length*r.stride))}function Ro(r){let{length:t,values:e,valueOffsets:i}=r,n=j(i[0]),s=j(i[t]),o=Math.min(s-n,e.byteLength-n);return ge.call(this,ms(-n,t+1,i)),ge.call(this,e.subarray(n,n+o)),this}function yc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return ge.call(this,ms(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function mc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}ot.prototype.visitBool=up;ot.prototype.visitInt=sr;ot.prototype.visitFloat=sr;ot.prototype.visitUtf8=Ro;ot.prototype.visitLargeUtf8=Ro;ot.prototype.visitBinary=Ro;ot.prototype.visitLargeBinary=Ro;ot.prototype.visitFixedSizeBinary=sr;ot.prototype.visitDate=sr;ot.prototype.visitTimestamp=sr;ot.prototype.visitTime=sr;ot.prototype.visitDecimal=sr;ot.prototype.visitList=yc;ot.prototype.visitStruct=mc;ot.prototype.visitUnion=lp;ot.prototype.visitInterval=sr;ot.prototype.visitDuration=sr;ot.prototype.visitFixedSizeList=yc;ot.prototype.visitMap=yc;var Jr=class extends Cr{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 Te,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,xt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ee(t)?t.then(e=>this.writeAll(e)):qt(t)?bc(this,t):gc(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 Te?this._sink=t:(this._sink=new Te,t&&Fl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Al(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||!$r(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 me&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof lt&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!$r(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof lt?t instanceof Hr||this._writeRecordBatch(t):t instanceof me?this.writeAll(t.batches):re(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Lt.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 Ze(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new Ze(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(Lt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bi)}_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 It(t.numRows,i,n),a=Lt.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 It(t.length,s,o),l=new Et(c,e,i),u=Lt.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}},kn=class r extends Jr{static writeAll(t,e){let i=new r(e);return ee(t)?t.then(n=>i.writeAll(n)):qt(t)?bc(i,t):gc(i,t)}},Cn=class r extends Jr{static writeAll(t){let e=new r;return ee(t)?t.then(i=>e.writeAll(i)):qt(t)?bc(e,t):gc(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=Ye.encode(new Ye(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function gc(r,t){let e=t;t instanceof me&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function bc(r,t){return y(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=te(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 mf(r,t){if(qt(r))return dp(r,t);if(re(r))return fp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function fp(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 dp(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 y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(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 y(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 bf(r){return new _c(r)}var _c=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ol(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Pr(s),this._getSize=n!=="bytes"?yf:gf;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"?yf:gf}),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)}},yf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},gf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function ko(r,t){let e=new Te,i=null,n=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return y(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 y(this,void 0,void 0,function*(){return yield(yield Ut.from(e)).open(t)})}function o(a,c){return y(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 Co(r,t){let e=new this(r),i=new Yt(e),n=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(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 y(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 hp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Na),rc),qa),Ea),xa),Ja),Oa),{compareSchemas:$r,compareFields:Hu,compareTypes:Ju});_t.toDOMStream=mf;st.throughDOM=bf;Ut.throughDOM=ko;xr.throughDOM=ko;De.throughDOM=ko;Jr.throughDOM=Co;Cn.throughDOM=Co;kn.throughDOM=Co;var wc=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=K.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(K.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=K.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=K.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 "+Or(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=K.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},Ic=new wc;var _f=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(_f||{}),wf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(wf||{}),vc=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}])}},pp=new vc,Sc=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}])}},mp=new Sc,xc=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}])}},dB=new xc,Tc=class extends et{constructor(){super("arrow.flight.protocol.Empty",[])}},yp=new Tc,Bc=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}])}},gp=new Bc,Oc=class extends et{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},bp=new Oc,Dc=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}])}},_p=new Dc,Fc=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Po}])}},hB=new Fc,Ac=class extends et{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>If}])}},pB=new Ac,Nc=class extends et{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},wp=new Nc,Ec=class extends et{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",wf,"CANCEL_STATUS_"]}])}},mB=new Ec,Lc=class extends et{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Ip=new Lc,Uc=class extends et{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",_f]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},vi=new Uc,Mc=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:()=>vi},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>If},{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}])}},Po=new Mc,Rc=class extends et{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Po},{no:2,name:"flight_descriptor",kind:"message",T:()=>vi},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Ic}])}},vp=new Rc,kc=class extends et{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>jo},{no:2,name:"location",kind:"message",repeat:1,T:()=>Sp},{no:3,name:"expiration_time",kind:"message",T:()=>Ic},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},If=new kc,Cc=class extends et{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Sp=new Cc,Vc=class extends et{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},jo=new Vc,Pc=class extends et{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>vi},{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}])}},Vo=new Pc,jc=class extends et{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},xp=new jc,zo=new Ai("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:pp,O:mp},{name:"ListFlights",serverStreaming:!0,options:{},I:bp,O:Po},{name:"GetFlightInfo",options:{},I:vi,O:Po},{name:"PollFlightInfo",options:{},I:vi,O:vp},{name:"GetSchema",options:{},I:vi,O:Ip},{name:"DoGet",serverStreaming:!0,options:{},I:jo,O:Vo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Vo,O:xp},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Vo,O:Vo},{name:"DoAction",serverStreaming:!0,options:{},I:_p,O:wp},{name:"ListActions",serverStreaming:!0,options:{},I:yp,O:gp}]);var Wo=class{constructor(t){this._transport=t;this.typeName=zo.typeName;this.methods=zo.methods;this.options=zo.options}handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return Ht("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return Ht("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return Ht("serverStreaming",this._transport,i,n,t)}};var vf=/\$(\w+)/g;function Sf(r){return!!r.match(vf)}function xf(r,t){let e=r.match(vf);if(e)for(let i of e)t[i.trim().replace("$","")]||qr(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var Tp="1.2.0.nightly",Tf=`influxdb3-js/${Tp}`;function zc(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 Kr(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return il(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return Kr(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 Vn=class{constructor(t){this._options=t;this._closed=!1;let{host:e,queryTimeout:i}=this._options;this._defaultHeaders=this._options.headers,this._transport=Mi.queryTransport({host:e,timeout:i}),this._flightClient=new Wo(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 jo.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Tf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){if(i.params&&Sf(t)&&xf(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 el(d.dataHeader.length),yield d.dataHeader,yield d.dataBody}();yield*await Ut.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n){let o={};for(let a of s){for(let c of s.schema.fields){let l=a[c.name];o[c.name]=zc(c,l)}yield o}}}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 cr;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),I=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"&&I===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,X,Y]=_.split("::");if(X==="field"){if(Y&&p!==void 0&&p!==null){let ft=zc(u,p);c.setField(d,ft,Y)}}else X==="tag"?c.setTag(d,p):X==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var Wc=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
17
17
|
`,Pn=class{constructor(...t){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};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};let e;switch(t.length){case 0:{e=Xo();break}case 1:{if(t[0]==null)throw new ar("No configuration specified!");typeof t[0]=="string"?e=Go(t[0]):e=t[0];break}default:throw new ar("Multiple arguments specified!")}this._options={...qo,...e};let i=this._options.host;if(typeof i!="string")throw new ar("No host specified!");if(i.endsWith("/")&&(this._options.host=i.substring(0,i.length-1)),typeof this._options.token!="string")throw new ar("No token specified!");this._queryApi=new Vn(this._options),this._writeApi=new Ri(this._options)}async write(t,e,i,n){var o;let s=this._mergeWriteOptions(n);await this._writeApi.doWrite(ra(t,s==null?void 0:s.defaultTags),(o=e!=null?e:this._options.database)!=null?o:qr(new Error(Wc)),i,s)}query(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:jn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.query(t,(o=e!=null?e:this._options.database)!=null?o:qr(new Error(Wc)),s)}queryPoints(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:jn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.queryPoints(t,(o=e!=null?e:this._options.database)!=null?o:qr(new Error(Wc)),s)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return Af(Bp);})();
|
|
18
18
|
//# sourceMappingURL=influxdb.js.map
|
package/dist/influxdb.js.gz
CHANGED
|
Binary file
|