@influxdata/influxdb3-client 2.3.0 → 2.4.0-nightly.20664

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/influxdb.js CHANGED
@@ -21,6 +21,6 @@ ${t}`),new Function("x",`${t}
21
21
  return true;`)}function ap(r){return typeof r!="bigint"?ue(r):`${ue(r)}n`}function dc(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function bf(r,t=0){return r.length>=t?r.subarray(0,t):Yi(new r.constructor(t),r,0)}var ge=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?dc(i*1,this.BYTES_PER_ELEMENT):dc(i*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=dc(t*this.stride,this.BYTES_PER_ELEMENT);let e=bf(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=bf(this.buffer,t)}},rr=class extends ge{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}},wi=class extends rr{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()}},Ii=class extends rr{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 at=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=Ht(t),this._nulls=new wi,e&&e.length>0&&(this._isValid=gf(e))}toVector(){return new j([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(m=>m.flush());return this.clear(),L({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}};at.prototype.length=1;at.prototype.stride=1;at.prototype.children=null;at.prototype.finished=!1;at.prototype.nullValues=null;at.prototype._isValid=()=>!0;var yt=class extends at{constructor(t){super(t),this._values=new rr(this.ArrayType,0,this.stride)}setValue(t,e){let i=this._values;return i.reserve(t-i.length+1),super.setValue(t,e)}},kt=class extends at{constructor(t){super(t),this._pendingLength=0,this._offsets=new Ii(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 Fe?e[xr].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 Gr=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 Gt=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):J.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Rt).__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 Gr).__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 Gr).__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 It).__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,J.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 X=class r{constructor(t=[],e,i,n=J.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=hc(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=mo(mo(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:mo(mo(new Map,i[c].metadata),a.metadata)}))&&!1:!0}),o=hc(s,new Map);return new r([...i,...s],n,new Map([...this.dictionaries,...o]))}};X.prototype.fields=null;X.prototype.metadata=null;X.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 mo(r,t){return new Map([...r||new Map,...t||new Map])}function hc(r,t=new Map){for(let e=-1,i=r.length;++e<i;){let s=r[e].type;if(b.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&hc(s.children,t)}return t}var cp=Pr,lp=xt,ir=class{static decode(t){t=new lp(A(t));let e=Gt.getRootAsFooter(t),i=X.decode(e.schema(),new Map,e.version());return new pc(i,e)}static encode(t){let e=new cp,i=X.encode(e,t.schema);Gt.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())nr.encode(e,o);let n=e.endVector();Gt.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())nr.encode(e,o);let s=e.endVector();return Gt.startFooter(e),Gt.addSchema(e,i),Gt.addVersion(e,J.V5),Gt.addRecordBatches(e,n),Gt.addDictionaries(e,s),Gt.finishFooterBuffer(e,Gt.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=J.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 pc=class extends ir{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 nr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return nr.decode(e)}return null}},nr=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 Gr.createBlock(t,n,i,s)}constructor(t,e,i){this.metaDataLength=t,this.offset=W(i),this.bodyLength=W(e)}};var be=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):J.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 It).__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,J.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 mc=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return on.startNull(e),on.endNull(e)}visitInt(t,e){return ce.startInt(e),ce.addBitWidth(e,t.bitWidth),ce.addIsSigned(e,t.isSigned),ce.endInt(e)}visitFloat(t,e){return _r.startFloatingPoint(e),_r.addPrecision(e,t.precision),_r.endFloatingPoint(e)}visitBinary(t,e){return tn.startBinary(e),tn.endBinary(e)}visitLargeBinary(t,e){return rn.startLargeBinary(e),rn.endLargeBinary(e)}visitBool(t,e){return en.startBool(e),en.endBool(e)}visitUtf8(t,e){return cn.startUtf8(e),cn.endUtf8(e)}visitLargeUtf8(t,e){return nn.startLargeUtf8(e),nn.endLargeUtf8(e)}visitDecimal(t,e){return Ae.startDecimal(e),Ae.addScale(e,t.scale),Ae.addPrecision(e,t.precision),Ae.addBitWidth(e,t.bitWidth),Ae.endDecimal(e)}visitDate(t,e){return mr.startDate(e),mr.addUnit(e,t.unit),mr.endDate(e)}visitTime(t,e){return je.startTime(e),je.addUnit(e,t.unit),je.addBitWidth(e,t.bitWidth),je.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return ze.startTimestamp(e),ze.addUnit(e,t.unit),i!==void 0&&ze.addTimezone(e,i),ze.endTimestamp(e)}visitInterval(t,e){return wr.startInterval(e),wr.addUnit(e,t.unit),wr.endInterval(e)}visitDuration(t,e){return yr.startDuration(e),yr.addUnit(e,t.unit),yr.endDuration(e)}visitList(t,e){return sn.startList(e),sn.endList(e)}visitStruct(t,e){return an.startStruct_(e),an.endStruct_(e)}visitUnion(t,e){le.startTypeIdsVector(e,t.typeIds.length);let i=le.createTypeIdsVector(e,t.typeIds);return le.startUnion(e),le.addMode(e,t.mode),le.addTypeIds(e,i),le.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return Oe.startDictionaryEncoding(e),Oe.addId(e,BigInt(t.id)),Oe.addIsOrdered(e,t.isOrdered),i!==void 0&&Oe.addIndexType(e,i),Oe.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return gr.startFixedSizeBinary(e),gr.addByteWidth(e,t.byteWidth),gr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return br.startFixedSizeList(e),br.addListSize(e,t.listSize),br.endFixedSizeList(e)}visitMap(t,e){return Ir.startMap(e),Ir.addKeysSorted(e,t.keysSorted),Ir.endMap(e)}},yo=new mc;function vf(r,t=new Map){return new X(up(r,t),go(r.metadata),t)}function yc(r){return new bt(r.count,xf(r.columns),Tf(r.columns),null)}function Sf(r){return new Ot(yc(r.data),r.id,r.isDelta)}function up(r,t){return(r.fields||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function _f(r,t){return(r.children||[]).filter(Boolean).map(e=>k.fromJSON(e,t))}function xf(r){return(r||[]).reduce((t,e)=>[...t,new Qt(e.count,fp(e.VALIDITY)),...xf(e.children)],[])}function Tf(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new gt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new gt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new gt(t.length,n.OFFSET.length)),n.DATA&&t.push(new gt(t.length,n.DATA.length)),t=Tf(n.children,t)}return t}function fp(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Bf(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=If(r,_f(r,t)),n=new k(r.name,o,r.nullable,go(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?wf(i):new De,a=new $t(t.get(e),i,e,s.isOrdered),n=new k(r.name,a,r.nullable,go(r.metadata))):(i=(i=s.indexType)?wf(i):new De,t.set(e,o=If(r,_f(r,t))),a=new $t(o,i,e,s.isOrdered),n=new k(r.name,a,r.nullable,go(r.metadata))),n||null}function go(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function wf(r){return new vt(r.isSigned,r.bitWidth)}function If(r,t){let e=r.type.name;switch(e){case"NONE":return new Nt;case"null":return new Nt;case"binary":return new We;case"largebinary":return new $e;case"utf8":return new He;case"largeutf8":return new Ge;case"bool":return new qe;case"list":return new de((t||[])[0]);case"struct":return new nt(t||[]);case"struct_":return new nt(t||[])}switch(e){case"int":{let i=r.type;return new vt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Zt(Y[i.precision])}case"decimal":{let i=r.type;return new Je(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new Xe(ut[i.unit])}case"time":{let i=r.type;return new Ke(w[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new Ye(w[i.unit],i.timezone)}case"interval":{let i=r.type;return new Ze(et[i.unit])}case"duration":{let i=r.type;return new Qe(w[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new he(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new tr(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new pe(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new me((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var dp=Pr,hp=xt,Ct=class r{static fromJSON(t,e){let i=new r(0,J.V5,e);return i._createHeader=pp(t,e),i}static decode(t){t=new hp(A(t));let e=be.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=mp(e,s),o}static encode(t){let e=new dp,i=-1;return t.isSchema()?i=X.encode(e,t.header()):t.isRecordBatch()?i=bt.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ot.encode(e,t.header())),be.startMessage(e),be.addVersion(e,J.V5),be.addHeader(e,i),be.addHeaderType(e,t.headerType),be.addBodyLength(e,BigInt(t.bodyLength)),be.finishMessageBuffer(e,be.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof X)return new r(0,J.V5,V.Schema,t);if(t instanceof bt)return new r(e,J.V5,V.RecordBatch,t);if(t instanceof Ot)return new r(e,J.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 compression(){return this._compression}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),this._compression=n==null?void 0:n.compression,n&&(this._createHeader=()=>n),this._bodyLength=W(t)}},bt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}get compression(){return this._compression}constructor(t,e,i,n){this._nodes=e,this._buffers=i,this._length=W(t),this._compression=n}},Ot=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=W(e)}},gt=class{constructor(t,e){this.offset=W(t),this.length=W(e)}},Qt=class{constructor(t,e){this.length=W(t),this.nullCount=W(e)}},qr=class{constructor(t,e=Vr.BUFFER){this.type=t,this.method=e}};function pp(r,t){return(()=>{switch(t){case V.Schema:return X.fromJSON(r);case V.RecordBatch:return bt.fromJSON(r);case V.DictionaryBatch:return Ot.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}function mp(r,t){return(()=>{switch(t){case V.Schema:return X.decode(r.header(new Rt),new Map,r.version());case V.RecordBatch:return bt.decode(r.header(new Mt),r.version());case V.DictionaryBatch:return Ot.decode(r.header(new Ve),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}k.encode=Bp;k.decode=xp;k.fromJSON=Bf;X.encode=Tp;X.decode=yp;X.fromJSON=vf;bt.encode=Op;bt.decode=gp;bt.fromJSON=yc;Ot.encode=Ap;Ot.decode=bp;Ot.fromJSON=Sf;Qt.encode=Dp;Qt.decode=wp;gt.encode=Fp;gt.decode=_p;qr.encode=Nf;qr.decode=Ff;function yp(r,t=new Map,e=J.V5){let i=Sp(r,t);return new X(i,bo(r),t,e)}function gp(r,t=J.V5){return new bt(r.length(),Ip(r),vp(r,t),Ff(r.compression()))}function bp(r,t=J.V5){return new Ot(bt.decode(r.data(),t),r.id(),r.isDelta())}function _p(r){return new gt(r.offset(),r.length())}function wp(r){return new Qt(r.length(),r.nullCount())}function Ip(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 vp(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<J.V4&&(i.bb_pos+=8*(n+1)),e[++s]=gt.decode(i));return e}function Sp(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 xp(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=Df(r,Of(r,t)),i=new k(r.name(),n,r.nullable(),bo(r))):t.has(e=W(a.id()))?(s=(s=a.indexType())?Af(s):new De,o=new $t(t.get(e),s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),bo(r))):(s=(s=a.indexType())?Af(s):new De,t.set(e,n=Df(r,Of(r,t))),o=new $t(n,s,e,a.isOrdered()),i=new k(r.name(),o,r.nullable(),bo(r))),i||null}function bo(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 vt(r.isSigned(),r.bitWidth())}function Df(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Nt;case Q.Null:return new Nt;case Q.Binary:return new We;case Q.LargeBinary:return new $e;case Q.Utf8:return new He;case Q.LargeUtf8:return new Ge;case Q.Bool:return new qe;case Q.List:return new de((t||[])[0]);case Q.Struct_:return new nt(t||[])}switch(e){case Q.Int:{let i=r.type(new ce);return new vt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new _r);return new Zt(i.precision())}case Q.Decimal:{let i=r.type(new Ae);return new Je(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new mr);return new Xe(i.unit())}case Q.Time:{let i=r.type(new je);return new Ke(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new ze);return new Ye(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new wr);return new Ze(i.unit())}case Q.Duration:{let i=r.type(new yr);return new Qe(i.unit())}case Q.Union:{let i=r.type(new le);return new he(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new gr);return new tr(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new br);return new pe(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new Ir);return new me((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function Ff(r){return r?new qr(r.codec(),r.method()):null}function Tp(r,t){let e=t.fields.map(s=>k.encode(r,s));Rt.startFieldsVector(r,e.length);let i=Rt.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Rt.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return It.startKeyValue(r),It.addKey(r,a),It.addValue(r,c),It.endKeyValue(r)})):-1;return Rt.startSchema(r),Rt.addFields(r,i),Rt.addEndianness(r,Np?pr.Little:pr.Big),n!==-1&&Rt.addCustomMetadata(r,n),Rt.endSchema(r)}function Bp(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;b.isDictionary(s)?(o=s.dictionary.typeId,n=yo.visit(s,r),i=yo.visit(s.dictionary,r)):i=yo.visit(s,r);let a=(s.children||[]).map(u=>k.encode(r,u)),c=Bt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?Bt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),m=r.createString(`${d}`);return It.startKeyValue(r),It.addKey(r,p),It.addValue(r,m),It.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Bt.startField(r),Bt.addType(r,i),Bt.addTypeType(r,o),Bt.addChildren(r,c),Bt.addNullable(r,!!t.nullable),e!==-1&&Bt.addName(r,e),n!==-1&&Bt.addDictionary(r,n),l!==-1&&Bt.addCustomMetadata(r,l),Bt.endField(r)}function Op(r,t){let e=t.nodes||[],i=t.buffers||[];Mt.startNodesVector(r,e.length);for(let a of e.slice().reverse())Qt.encode(r,a);let n=r.endVector();Mt.startBuffersVector(r,i.length);for(let a of i.slice().reverse())gt.encode(r,a);let s=r.endVector(),o=null;return t.compression!==null&&(o=Nf(r,t.compression)),Mt.startRecordBatch(r),Mt.addLength(r,BigInt(t.length)),Mt.addNodes(r,n),Mt.addBuffers(r,s),t.compression!==null&&o&&Mt.addCompression(r,o),Mt.endRecordBatch(r)}function Nf(r,t){return Pe.startBodyCompression(r),Pe.addCodec(r,t.type),Pe.addMethod(r,t.method),Pe.endBodyCompression(r)}function Ap(r,t){let e=bt.encode(r,t.data);return Ve.startDictionaryBatch(r),Ve.addId(r,BigInt(t.id)),Ve.addIsDelta(r,t.isDelta),Ve.addData(r,e),Ve.endDictionaryBatch(r)}function Dp(r,t){return li.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Fp(r,t){return ci.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Np=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var st=Object.freeze({done:!0,value:void 0}),yn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Jr=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())}},_o=class extends Jr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(st);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return St.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return St.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return g(this,void 0,void 0,function*(){return yield this.abort(t),st})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),st})}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,i)=>{this.resolvers.push({resolve:e,reject:i})}):Promise.resolve(st)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Ne=class extends _o{write(t){if((t=A(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Xi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Xi)}toUint8Array(t=!1){return t?Wt(this._values)[0]:g(this,void 0,void 0,function*(){var e,i,n,s;let o=[],a=0;try{for(var c=!0,l=ie(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 Wt(o,a)[0]})}},Ee=class{constructor(t){t&&(this.source=new gc(St.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)}},te=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof Ne?this.source=new sr(St.fromAsyncIterable(t)):xs(t)?this.source=new sr(St.fromNodeStream(t)):Ki(t)?this.source=new sr(St.fromDOMStream(t)):vs(t)?this.source=new sr(St.fromDOMStream(t.body)):se(t)?this.source=new sr(St.fromIterable(t)):ne(t)?this.source=new sr(St.fromAsyncIterable(t)):Xt(t)&&(this.source=new sr(St.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)}},gc=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)||st)}return(t){return Object.create(this.source.return&&this.source.return(t)||st)}},sr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return g(this,arguments,void 0,function*(e,i="read"){return yield this.source.next({cmd:i,size:e})})}throw(t){return g(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||st;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return g(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||st;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var gn=class extends Ee{constructor(t,e){super(),this.position=0,this.buffer=A(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}}},Br=class extends te{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=g(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return g(this,void 0,void 0,function*(){let{buffer:e,byteOffset:i}=yield this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)})}seek(t){return g(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:i,position:n}=this;if(e&&n<i){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=n,o=0,a=0,c=Math.min(i,s+Math.min(i-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:i,size:n}=this;if(i&&t+e<n){let s=Math.min(n,t+e),o=new Uint8Array(s-t);return(yield i.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return g(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var _c={};Re(_c,{BaseInt64:()=>bn,Int128:()=>_n,Int64:()=>or,Uint64:()=>ct});function vi(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Si=8,bc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],bn=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`${vi(this.buffer[1])} ${vi(this.buffer[0])}`}},ct=class r extends bn{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=Si<i-s?Si:i-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([bc[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)}},or=class r extends bn{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=Si<n-o?Si:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([bc[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)}},_n=class r{constructor(t){this.buffer=t}high(){return new or(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new or(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new ct(new Uint32Array([this.buffer[3],0])),i=new ct(new Uint32Array([this.buffer[2],0])),n=new ct(new Uint32Array([this.buffer[1],0])),s=new ct(new Uint32Array([this.buffer[0],0])),o=new ct(new Uint32Array([t.buffer[3],0])),a=new ct(new Uint32Array([t.buffer[2],0])),c=new ct(new Uint32Array([t.buffer[1],0])),l=new ct(new Uint32Array([t.buffer[0],0])),u=ct.multiply(s,l);this.buffer[0]=u.low();let d=new ct(new Uint32Array([u.high(),0]));return u=ct.multiply(n,l),d.plus(u),u=ct.multiply(s,c),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new ct(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(ct.multiply(i,l)).plus(ct.multiply(n,c)).plus(ct.multiply(s,a)),this.buffer[3]+=ct.multiply(e,l).plus(ct.multiply(i,c)).plus(ct.multiply(n,a)).plus(ct.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${vi(this.buffer[3])} ${vi(this.buffer[2])} ${vi(this.buffer[1])} ${vi(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=Si<n-o?Si:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([bc[a],0,0,0]));s.times(l),s.plus(c),o+=a}return i?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+16*i,4));return e}};var vc={};Re(vc,{toIntervalDayTimeInt32Array:()=>wc,toIntervalDayTimeObjects:()=>Ep,toIntervalMonthDayNanoInt32Array:()=>Ic,toIntervalMonthDayNanoObjects:()=>Lp});function wc(r){var t,e;let i=r.length,n=new Int32Array(i*2);for(let s=0,o=0;s<i;s++){let a=r[s];n[o++]=(t=a.days)!==null&&t!==void 0?t:0,n[o++]=(e=a.milliseconds)!==null&&e!==void 0?e:0}return n}function Ic(r){var t,e;let i=r.length,n=new Int32Array(i*4);for(let s=0,o=0;s<i;s++){let a=r[s];n[o++]=(t=a.months)!==null&&t!==void 0?t:0,n[o++]=(e=a.days)!==null&&e!==void 0?e:0;let c=a.nanoseconds;c?(n[o++]=Number(BigInt(c)&BigInt(4294967295)),n[o++]=Number(BigInt(c)>>BigInt(32))):o+=2}return n}function Ep(r){let t=r.length,e=new Array(t/2);for(let i=0,n=0;i<t;i+=2)e[n++]={days:r[i],milliseconds:r[i+1]};return e}function Lp(r,t){let e=r.length,i=new Array(e/4);for(let n=0,s=0;n<e;n+=4){let o=BigInt(r[n+3])<<BigInt(32)|BigInt(r[n+2]>>>0);i[s++]={months:r[n],days:r[n+1],nanoseconds:t?`${o}`:o}}return i}var xi=class extends v{constructor(t,e,i,n,s=J.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 L({type:t,length:e})}visitBool(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitInt(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({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 L({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 L({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 L({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 L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDate(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTime(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitList(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({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 L({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<J.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 L({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 L({type:t,length:e,nullCount:i,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({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 L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({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 L({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)}},wo=class extends xi{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):$r(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;if(b.isTimestamp(t))return R(Uint8Array,or.convertArray(i[e]));if((b.isInt(t)||b.isTime(t))&&t.bitWidth===64||b.isDuration(t))return R(Uint8Array,or.convertArray(i[e]));if(b.isDate(t)&&t.unit===ut.MILLISECOND)return R(Uint8Array,or.convertArray(i[e]));if(b.isDecimal(t))return R(Uint8Array,_n.convertArray(i[e]));if(b.isBinary(t)||b.isLargeBinary(t)||b.isFixedSizeBinary(t))return Up(i[e]);if(b.isBool(t))return $r(i[e]);if(b.isUtf8(t)||b.isLargeUtf8(t))return xe(i[e].join(""));if(b.isInterval(t))switch(t.unit){case et.DAY_TIME:return wc(i[e]);case et.MONTH_DAY_NANO:return Ic(i[e]);default:break}return R(Uint8Array,R(t.ArrayType,i[e].map(n=>+n)))}};function Up(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 Io=class extends xi{constructor(t,e,i,n,s){super(new Uint8Array(0),e,i,n,s),this.bodyChunks=t}readData(t,e=this.nextBufferRange()){return this.bodyChunks[this.buffersIndex]}};var Ti=class extends kt{constructor(t){super(t),this._values=new ge(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,A(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 Bi=class extends kt{constructor(t){super(t),this._values=new ge(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,A(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 vo=class extends at{constructor(t){super(t),this._values=new wi}setValue(t,e){this._values.set(t,+e)}};var Xr=class extends yt{};Xr.prototype._setValue=Ka;var wn=class extends Xr{};wn.prototype._setValue=zs;var In=class extends Xr{};In.prototype._setValue=Ws;var vn=class extends yt{};vn.prototype._setValue=Qa;var So=class extends at{constructor({type:t,nullValues:e,dictionaryHashFunction:i}){super({type:new $t(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Kr({type:this.type.indices,nullValues:e}),this.dictionary=Kr({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 Sn=class extends yt{};Sn.prototype._setValue=Xa;var xo=class extends at{setValue(t,e){let[i]=this.children,n=t*this.stride;for(let s=-1,o=this.stride;++s<o;)i.set(n+s,e[s])}setValid(t,e){return super.setValid(t,e)||this.children[0].setValid((t+1)*this.stride-1,!1),e}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 pe(this.type.listSize,new k(e,t.type,!0)),i}};var Yr=class extends yt{setValue(t,e){this._values.set(t,e)}},To=class extends Yr{setValue(t,e){super.setValue(t,fn(e))}},Bo=class extends Yr{},Oo=class extends Yr{};var Or=class extends yt{};Or.prototype._setValue=tc;var xn=class extends Or{};xn.prototype._setValue=Zs;var Tn=class extends Or{};Tn.prototype._setValue=Qs;var Bn=class extends Or{};Bn.prototype._setValue=to;var ar=class extends yt{};ar.prototype._setValue=ec;var On=class extends ar{};On.prototype._setValue=eo;var An=class extends ar{};An.prototype._setValue=ro;var Dn=class extends ar{};Dn.prototype._setValue=io;var Fn=class extends ar{};Fn.prototype._setValue=no;var ee=class extends yt{setValue(t,e){this._values.set(t,e)}},Ao=class extends ee{},Do=class extends ee{},Fo=class extends ee{},No=class extends ee{},Eo=class extends ee{},Lo=class extends ee{},Uo=class extends ee{},Mo=class extends ee{};var Ro=class extends kt{constructor(t){super(t),this._offsets=new Ii(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 de(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 ko=class extends kt{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 me(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 Co=class extends at{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Po=class extends at{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 nt([...this.type.children,new k(e,t.type,!0)]),i}};var cr=class extends yt{};cr.prototype._setValue=Ya;var Nn=class extends cr{};Nn.prototype._setValue=$s;var En=class extends cr{};En.prototype._setValue=Hs;var Ln=class extends cr{};Ln.prototype._setValue=Gs;var Un=class extends cr{};Un.prototype._setValue=qs;var lr=class extends yt{};lr.prototype._setValue=Za;var Mn=class extends lr{};Mn.prototype._setValue=Js;var Rn=class extends lr{};Rn.prototype._setValue=Xs;var kn=class extends lr{};kn.prototype._setValue=Ks;var Cn=class extends lr{};Cn.prototype._setValue=Ys;var Oi=class extends at{constructor(t){super(t),this._typeIds=new rr(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),this.length=Math.max(t+1,this.length)}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 he(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.")}},Vo=class extends Oi{},jo=class extends Oi{constructor(t){super(t),this._offsets=new rr(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),this.length=Math.max(t+1,this.length)}};var Pn=class extends kt{constructor(t){super(t),this._values=new ge(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,xe(e))}_flushPending(t,e){}};Pn.prototype._flushPending=Ti.prototype._flushPending;var Vn=class extends kt{constructor(t){super(t),this._values=new ge(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,xe(e))}_flushPending(t,e){}};Vn.prototype._flushPending=Bi.prototype._flushPending;var Sc=class extends v{visitNull(){return Co}visitBool(){return vo}visitInt(){return ee}visitInt8(){return Ao}visitInt16(){return Do}visitInt32(){return Fo}visitInt64(){return No}visitUint8(){return Eo}visitUint16(){return Lo}visitUint32(){return Uo}visitUint64(){return Mo}visitFloat(){return Yr}visitFloat16(){return To}visitFloat32(){return Bo}visitFloat64(){return Oo}visitUtf8(){return Pn}visitLargeUtf8(){return Vn}visitBinary(){return Ti}visitLargeBinary(){return Bi}visitFixedSizeBinary(){return Sn}visitDate(){return Xr}visitDateDay(){return wn}visitDateMillisecond(){return In}visitTimestamp(){return cr}visitTimestampSecond(){return Nn}visitTimestampMillisecond(){return En}visitTimestampMicrosecond(){return Ln}visitTimestampNanosecond(){return Un}visitTime(){return lr}visitTimeSecond(){return Mn}visitTimeMillisecond(){return Rn}visitTimeMicrosecond(){return kn}visitTimeNanosecond(){return Cn}visitDecimal(){return vn}visitList(){return Ro}visitStruct(){return Po}visitUnion(){return Oi}visitDenseUnion(){return jo}visitSparseUnion(){return Vo}visitDictionary(){return So}visitInterval(){return Or}visitIntervalDayTime(){return xn}visitIntervalYearMonth(){return Tn}visitIntervalMonthDayNano(){return Bn}visitDuration(){return ar}visitDurationSecond(){return On}visitDurationMillisecond(){return An}visitDurationMicrosecond(){return Dn}visitDurationNanosecond(){return Fn}visitFixedSizeList(){return xo}visitMap(){return ko}},Lf=new Sc;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 Et(r,t){return t instanceof r.constructor}function Zr(r,t){return r===t||Et(r,t)}function ur(r,t){return r===t||Et(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function zo(r,t){return r===t||Et(r,t)&&r.precision===t.precision}function Mp(r,t){return r===t||Et(r,t)&&r.byteWidth===t.byteWidth}function xc(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function jn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function zn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Rp(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Le.compareManyFields(r.children,t.children)}function kp(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Le.compareManyFields(r.children,t.children)}function Tc(r,t){return r===t||Et(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Le.compareManyFields(r.children,t.children)}function Cp(r,t){return r===t||Et(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Le.visit(r.indices,t.indices)&&Le.visit(r.dictionary,t.dictionary)}function Wo(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Wn(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Pp(r,t){return r===t||Et(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Le.compareManyFields(r.children,t.children)}function Vp(r,t){return r===t||Et(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Le.compareManyFields(r.children,t.children)}B.prototype.visitNull=Zr;B.prototype.visitBool=Zr;B.prototype.visitInt=ur;B.prototype.visitInt8=ur;B.prototype.visitInt16=ur;B.prototype.visitInt32=ur;B.prototype.visitInt64=ur;B.prototype.visitUint8=ur;B.prototype.visitUint16=ur;B.prototype.visitUint32=ur;B.prototype.visitUint64=ur;B.prototype.visitFloat=zo;B.prototype.visitFloat16=zo;B.prototype.visitFloat32=zo;B.prototype.visitFloat64=zo;B.prototype.visitUtf8=Zr;B.prototype.visitLargeUtf8=Zr;B.prototype.visitBinary=Zr;B.prototype.visitLargeBinary=Zr;B.prototype.visitFixedSizeBinary=Mp;B.prototype.visitDate=xc;B.prototype.visitDateDay=xc;B.prototype.visitDateMillisecond=xc;B.prototype.visitTimestamp=jn;B.prototype.visitTimestampSecond=jn;B.prototype.visitTimestampMillisecond=jn;B.prototype.visitTimestampMicrosecond=jn;B.prototype.visitTimestampNanosecond=jn;B.prototype.visitTime=zn;B.prototype.visitTimeSecond=zn;B.prototype.visitTimeMillisecond=zn;B.prototype.visitTimeMicrosecond=zn;B.prototype.visitTimeNanosecond=zn;B.prototype.visitDecimal=Zr;B.prototype.visitList=Rp;B.prototype.visitStruct=kp;B.prototype.visitUnion=Tc;B.prototype.visitDenseUnion=Tc;B.prototype.visitSparseUnion=Tc;B.prototype.visitDictionary=Cp;B.prototype.visitInterval=Wo;B.prototype.visitIntervalDayTime=Wo;B.prototype.visitIntervalYearMonth=Wo;B.prototype.visitIntervalMonthDayNano=Wo;B.prototype.visitDuration=Wn;B.prototype.visitDurationSecond=Wn;B.prototype.visitDurationMillisecond=Wn;B.prototype.visitDurationMicrosecond=Wn;B.prototype.visitDurationNanosecond=Wn;B.prototype.visitFixedSizeList=Pp;B.prototype.visitMap=Vp;var Le=new B;function Qr(r,t){return Le.compareSchemas(r,t)}function Uf(r,t){return Le.compareFields(r,t)}function Mf(r,t){return Le.visit(r,t)}function Kr(r){let t=r.type,e=new(Lf.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(Kr(Object.assign(Object.assign({},l),{type:c})))}}return e}function $o(r,t){return jp(r,t.map(e=>e.data.concat()))}function jp(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=zp(e,o,u,t,n),o>0&&(i[s++]=L({type:new nt(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),i.map(d=>new ft(r,d))]}function zp(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:L({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var Rf,_e=class r{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new X([]),this._offsets=[0],this;let n,s;t[0]instanceof X&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof ft)return[c];if(c instanceof r)return c.batches;if(c instanceof G){if(c.type instanceof nt)return[new ft(new X(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(m=>new j([c[m]])),d=n!=null?n:new X(l.map((m,_)=>new k(String(m),u[_].type,u[_].nullable))),[,p]=$o(d,u);return p.length===0?[new ft(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 X([]),!(n instanceof X))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof ft))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Qr(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:lo(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=co(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(jr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?_i.visit(new j(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
22
22
  ${this.toArray().join(`,
23
23
  `)}
24
- ]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ft(e,n)))}slice(t,e){let i=this.schema;[t,e]=dn({length:this.numRows},t,e);let n=uo(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ft(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=L({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new j(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 j([L({type:new Nt,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]=$o(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(m=>m.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(...$o(s,o))}};Rf=Symbol.toStringTag;_e[Rf]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=bi(mn),r.get=bi(mt.getVisitFn(f.Struct)),r.set=fo(Tt.getVisitFn(f.Struct)),r.indexOf=ho(Hr.getVisitFn(f.Struct)),"Table"))(_e.prototype);var Cf,ft=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof X))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=L({nullCount:0,type:new nt(this.schema.fields),children:this.schema.fields.map(e=>L({type:e.type,nullCount:0}))})]=t,!(this.data instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=kf(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 X(i),a=L({type:new nt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=kf(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=Pf(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mt.visit(this.data,t)}at(t){return this.get(jr(t,this.numRows))}set(t,e){return Tt.visit(this.data,t,e)}indexOf(t,e){return Hr.visit(this.data,t,e)}[Symbol.iterator](){return _i.visit(new j([this.data]))}toArray(){return[...this]}concat(...t){return new _e(this.schema,[this,...t])}slice(t,e){let[i]=new j([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 j([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 j([L({type:new Nt,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 X(s,new Map(this.schema.metadata)),n=L({type:new nt(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new nt(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,L({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=L({type:new nt(e.fields),length:this.numRows,children:i});return new r(e,n)}};Cf=Symbol.toStringTag;ft[Cf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function kf(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:L({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),L({type:new nt(n),length:e,children:s})]}function Pf(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)||[]])Pf(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var ti=class extends ft{constructor(t){let e=t.fields.map(n=>L({type:n.type})),i=L({type:new nt(t.fields),nullCount:0,children:e});super(t,i)}};var Oc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,Ac=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,Vf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,jf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Ai=class{constructor(t){this.source=t instanceof Ee?t:new Ee(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?st:t.value===-1&&(t=this.readMetadataLength()).done?st:(t=this.readMetadata(t.value)).done?st: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(Oc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=A(this.source.read(t));if(e.byteLength<t)throw new Error(jf(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(Ac(e));return n}readMetadataLength(){let t=this.source.read(Ho),e=t&&new xt(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 st;if(e.byteLength<t)throw new Error(Vf(t,e.byteLength));return{done:!1,value:Ct.decode(e)}}},$n=class{constructor(t,e){this.source=t instanceof te?t:Is(t)?new Br(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?st:t.value===-1&&(t=yield this.readMetadataLength()).done?st:(t=yield this.readMetadata(t.value)).done?st:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Oc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=A(yield this.source.read(t));if(e.byteLength<t)throw new Error(jf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Ac(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(Ho),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return st;if(e.byteLength<t)throw new Error(Vf(t,e.byteLength));return{done:!1,value:Ct.decode(e)}})}},Hn=class extends Ai{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof yn?t:new yn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Ct.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:Ct.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Ct.fromJSON(e,V.RecordBatch)}}return this._body=[],st}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(Oc(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(Ac(t));return i}},Ho=4,Bc="ARROW1",Di=new Uint8Array(Bc.length);for(let r=0;r<Bc.length;r+=1)Di[r]=Bc.codePointAt(r);function Go(r,t=0){for(let e=-1,i=Di.length;++e<i;)if(Di[e]!==r[t+e])return!1;return!0}var Fi=Di.length,Dc=Fi+Ho,zf=Fi*2+Ho;var Fc=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,i)=>t[i]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Nc=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,i)=>t[i]===e)}},Wf={[Ft.LZ4_FRAME]:new Fc,[Ft.ZSTD]:new Nc};var Ec=class{constructor(){this.registry={}}set(t,e){if(e!=null&&e.encode&&typeof e.encode=="function"&&!Wf[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ft[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Ni=new Ec;var Pt=class r extends Jr{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 ne(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 St.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return St.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:_s(t)?Hp(t):Is(t)?Jp(t):ne(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):vs(t)||Ki(t)||xs(t)||Xt(t)?qp(new te(t)):Gp(new Ee(t))}static readAll(t){return t instanceof r?t.isSync()?$f(t):Hf(t):_s(t)||ArrayBuffer.isView(t)||se(t)||ws(t)?$f(t):Hf(t)}},Ue=class extends Pt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return zt(this,arguments,function*(){yield U(yield*oi(ie(this[Symbol.iterator]())))})}},Ar=class extends Pt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=ie(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]()}},Dr=class extends Ue{constructor(t){super(t),this._impl=t}},Gn=class extends Ar{constructor(t){super(t),this._impl=t}},qo=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;if(t.compression!=null){let s=Ni.get(t.compression.type);if(s!=null&&s.decode&&typeof s.decode=="function"){let{decommpressedBody:o,buffers:a}=this._decompressBuffers(t,e,s);i=this._loadCompressedVectors(t,o,this.schema.fields),t=new bt(t.length,t.nodes,a,null)}else throw new Error("Record batch is compressed but codec not found")}else i=this._loadVectors(t,e,this.schema.fields);let n=L({type:new nt(this.schema.fields),length:t.length,children:i});return new ft(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;if(t.data.compression!=null){let u=Ni.get(t.data.compression.type);if(u!=null&&u.decode&&typeof u.decode=="function"){let{decommpressedBody:d,buffers:p}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,d,[c]),t=new Ot(new bt(t.data.length,t.data.nodes,p,null),i,n)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new j(l)):new j(l)).memoize()}_loadVectors(t,e,i){return new xi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_loadCompressedVectors(t,e,i){return new Io(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_decompressBuffers(t,e,i){let n=[],s=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){n.push(new Uint8Array(0)),s.push(new gt(o,0));continue}let l=new xt(e.subarray(a,a+c)),u=W(l.readInt64(0)),d=l.bytes().subarray(8),p=u===-1?d:i.decode(d);n.push(p);let m=(o+7&-8)-o;o+=m,s.push(new gt(o,p.length)),o+=p.length}return{decommpressedBody:n,buffers:s}}},Ei=class extends qo{constructor(t,e){super(e),this._reader=_s(t)?new Hn(this._handle=t):new Ai(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=qf(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):st}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):st}next(){if(this.closed)return st;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 ti(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Li=class extends qo{constructor(t,e){super(e),this._reader=new $n(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=qf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):st})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):st})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return st;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 ti(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Jo=class extends Ei{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 gn?t:new gn(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 ir.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}},Lc=class extends Li{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 Br?t:new Br(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Dc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return ir.decode(n)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Uc=class extends Ei{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new wo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function qf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*$f(r){let t=Pt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Hf(r){return zt(this,arguments,function*(){let e=yield U(Pt.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 Hp(r){return new Ue(new Uc(r))}function Gp(r){let t=r.peek(Fi+7&-8);return t&&t.byteLength>=4?Go(t)?new Dr(new Jo(r.read())):new Ue(new Ei(r)):new Ue(new Ei((function*(){})()))}function qp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Fi+7&-8);return t&&t.byteLength>=4?Go(t)?new Dr(new Jo(yield r.read())):new Ar(new Li(r)):new Ar(new Li((function(){return zt(this,arguments,function*(){})})()))})}function Jp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Br(r,t);return t>=zf&&Go(yield e.readAt(0,Fi+7&-8))?new Gn(new Lc(e)):new Ar(new Li(e))})}var lt=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ft?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 j)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;b.isNull(e)||we.call(this,n<=0?new Uint8Array(0):Wr(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 we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new gt(this._byteLength,t)),this._byteLength+=t,this}function Xp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(we.call(this,n),e.mode===Z.Sparse)return Mc.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return we.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);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],m=c[d];return l.slice(p,Math.min(i,m))}))}}return this}function Kp(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,Wr(r.offset,r.length,t)):we.call(this,$r(r.values))}function fr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Xo(r){let{length:t,values:e,valueOffsets:i}=r,n=W(i[0]),s=W(i[t]),o=Math.min(s-n,e.byteLength-n);return we.call(this,Bs(-n,t+1,i)),we.call(this,e.subarray(n,n+o)),this}function Rc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return we.call(this,Bs(-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]}lt.prototype.visitBool=Kp;lt.prototype.visitInt=fr;lt.prototype.visitFloat=fr;lt.prototype.visitUtf8=Xo;lt.prototype.visitLargeUtf8=Xo;lt.prototype.visitBinary=Xo;lt.prototype.visitLargeBinary=Xo;lt.prototype.visitFixedSizeBinary=fr;lt.prototype.visitDate=fr;lt.prototype.visitTimestamp=fr;lt.prototype.visitTime=fr;lt.prototype.visitDecimal=fr;lt.prototype.visitList=Rc;lt.prototype.visitStruct=Mc;lt.prototype.visitUnion=Xp;lt.prototype.visitInterval=fr;lt.prototype.visitDuration=fr;lt.prototype.visitFixedSizeList=Rc;lt.prototype.visitMap=Rc;var ei=class extends Jr{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){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new Ne,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Dt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ft).includes(t.compressionType))this._compression=new qr(t.compressionType);else{let e=Object.values(Ft).filter(i=>typeof i=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ne(t)?t.then(e=>this.writeAll(e)):Xt(t)?Cc(this,t):kc(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 Ne?this._sink=t:(this._sink=new Ne,t&&ru(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&iu(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||!Qr(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 _e&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ft&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Qr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof ti||this._writeRecordBatch(t):t instanceof _e?this.writeAll(t.batches):se(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Ct.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 nr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new nr(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=A(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Ct.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Di)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=this._assembleRecordBatch(t),o=new bt(t.numRows,i,n,this._compression),a=Ct.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_assembleRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=lt.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:n,buffers:s}=this._compressBodyBuffers(s)),{byteLength:e,nodes:i,bufferRegions:n,buffers:s}}_compressBodyBuffers(t){let e=Ni.get(this._compression.type);if(!(e!=null&&e.encode)||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ft[this._compression.type]}" has invalid encode method`);let i=0,n=[],s=[];for(let a of t){let c=A(a);if(c.length===0){n.push(new Uint8Array(0),new Uint8Array(0)),s.push(new gt(i,0));continue}let l=e.encode(c),u=l.length<c.length,d=u?l:c,p=u?d.length:-1,m=new xt(new Uint8Array(8));m.writeInt64(0,BigInt(p)),n.push(m.bytes(),new Uint8Array(d));let _=(i+7&-8)-i;i+=_;let C=8+d.length;s.push(new gt(i,C)),i+=C}let o=(i+7&-8)-i;return i+=o,{byteLength:i,bufferRegions:s,buffers:n}}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=this._assembleRecordBatch(new j([t])),c=new bt(t.length,s,o,this._compression),l=new Ot(c,e,i),u=Ct.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,i=new Array(e);for(let n=0;n<t.length;n+=e){let s=0;for(let a=-1;++a<e;)i[a]=t[n+a],s+=i[a].byteLength;if(s===0)continue;for(let a of i)this._write(a);let o=(s+7&-8)-s;o>0&&this._writePadding(o)}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}},qn=class r extends ei{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Xt(t)?Cc(i,t):kc(i,t)}},Jn=class r extends ei{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Xt(t)?Cc(i,t):kc(i,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_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=ir.encode(new ir(t,J.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function kc(r,t){let e=t;t instanceof _e&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Cc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=ie(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 Jf(r,t){if(Xt(r))return Zp(r,t);if(se(r))return Yp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Yp(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(),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=A(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 Zp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){e!=null&&e.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=A(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 Yf(r){return new Pc(r)}var Pc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ql(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Kr(s),this._getSize=n!=="bytes"?Xf:Kf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?Xf:Kf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Xf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Kf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function Ko(r,t){let e=new Ne,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Pt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Yo(r,t){let e=new this(r),i=new te(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var Qp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ga),_c),cc),qa),Pa),ac),za),vc),{compareSchemas:Qr,compareFields:Uf,compareTypes:Mf});St.toDOMStream=Jf;at.throughDOM=Yf;Pt.throughDOM=Ko;Dr.throughDOM=Ko;Ue.throughDOM=Ko;ei.throughDOM=Yo;Jn.throughDOM=Yo;qn.throughDOM=Yo;var Vc=class extends it{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 "+Ur(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}},jc=new Vc;var Zf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Zf||{}),Qf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Qf||{}),zc=class extends it{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}])}},tm=new zc,Wc=class extends it{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}])}},em=new Wc,$c=class extends it{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},hO=new $c,Hc=class extends it{constructor(){super("arrow.flight.protocol.Empty",[])}},rm=new Hc,Gc=class extends it{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},im=new Gc,qc=class extends it{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},nm=new qc,Jc=class extends it{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},sm=new Jc,Xc=class extends it{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Qo}])}},pO=new Xc,Kc=class extends it{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>td}])}},mO=new Kc,Yc=class extends it{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},om=new Yc,Zc=class extends it{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Qf,"CANCEL_STATUS_"]}])}},yO=new Zc,Qc=class extends it{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},am=new Qc,tl=class extends it{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Zf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Ui=new tl,el=class extends it{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ui},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>td},{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}])}},Qo=new el,rl=class extends it{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Qo},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ui},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>jc}])}},cm=new rl,il=class extends it{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>ta},{no:2,name:"location",kind:"message",repeat:1,T:()=>lm},{no:3,name:"expiration_time",kind:"message",T:()=>jc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},td=new il,nl=class extends it{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},lm=new nl,sl=class extends it{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},ta=new sl,ol=class extends it{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Ui},{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}])}},Zo=new ol,al=class extends it{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},um=new al,ea=new Wi("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:tm,O:em},{name:"ListFlights",serverStreaming:!0,options:{},I:nm,O:Qo},{name:"GetFlightInfo",options:{},I:Ui,O:Qo},{name:"PollFlightInfo",options:{},I:Ui,O:cm},{name:"GetSchema",options:{},I:Ui,O:am},{name:"DoGet",serverStreaming:!0,options:{},I:ta,O:Zo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Zo,O:um},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Zo,O:Zo},{name:"DoAction",serverStreaming:!0,options:{},I:sm,O:om},{name:"ListActions",serverStreaming:!0,options:{},I:rm,O:im}]);var ra=class{constructor(t){this._transport=t;z(this,"typeName",ea.typeName);z(this,"methods",ea.methods);z(this,"options",ea.options)}_transport;handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}};var ed=/\$(\w+)/g;function rd(r){return!!r.match(ed)}function id(r,t){let e=r.match(ed);if(e)for(let i of e)t[i.trim().replace("$","")]||ii(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var fm="2.3.0",nd=`influxdb3-js/${fm}`;function cl(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 ni(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return Al(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return ni(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 Xn=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_flightClient");z(this,"_transport");z(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=kr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new ra(this._transport)}_options;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 ta.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":nd,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){var d;if(i.params&&rd(t)&&id(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)};a.timeout=(d=i.timeout)!=null?d:this._options.queryTimeout;let c=n.doGet(s,a),l=(async function*(){for await(let p of c.responses)yield Bl(p.dataHeader.length),yield p.dataHeader,yield p.dataBody})();yield*await Pt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=cl(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new dr;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),m=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"&&m===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,C,rt]=_.split("::");if(C==="field"){if(rt&&p!==void 0&&p!==null){let dt=cl(u,p);c.setField(d,dt,rt)}}else C==="tag"?c.setTag(d,p):C==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var ll=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
24
+ ]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ft(e,n)))}slice(t,e){let i=this.schema;[t,e]=dn({length:this.numRows},t,e);let n=uo(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ft(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=L({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new j(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 j([L({type:new Nt,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]=$o(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(m=>m.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(...$o(s,o))}};Rf=Symbol.toStringTag;_e[Rf]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=bi(mn),r.get=bi(mt.getVisitFn(f.Struct)),r.set=fo(Tt.getVisitFn(f.Struct)),r.indexOf=ho(Hr.getVisitFn(f.Struct)),"Table"))(_e.prototype);var Cf,ft=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof X))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=L({nullCount:0,type:new nt(this.schema.fields),children:this.schema.fields.map(e=>L({type:e.type,nullCount:0}))})]=t,!(this.data instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=kf(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 X(i),a=L({type:new nt(i),length:s,children:n,nullCount:0});[this.schema,this.data]=kf(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=Pf(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mt.visit(this.data,t)}at(t){return this.get(jr(t,this.numRows))}set(t,e){return Tt.visit(this.data,t,e)}indexOf(t,e){return Hr.visit(this.data,t,e)}[Symbol.iterator](){return _i.visit(new j([this.data]))}toArray(){return[...this]}concat(...t){return new _e(this.schema,[this,...t])}slice(t,e){let[i]=new j([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 j([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 j([L({type:new Nt,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 X(s,new Map(this.schema.metadata)),n=L({type:new nt(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new nt(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,L({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=L({type:new nt(e.fields),length:this.numRows,children:i});return new r(e,n)}};Cf=Symbol.toStringTag;ft[Cf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function kf(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:L({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),L({type:new nt(n),length:e,children:s})]}function Pf(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)||[]])Pf(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var ti=class extends ft{constructor(t){let e=t.fields.map(n=>L({type:n.type})),i=L({type:new nt(t.fields),nullCount:0,children:e});super(t,i)}};var Oc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,Ac=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,Vf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,jf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Ai=class{constructor(t){this.source=t instanceof Ee?t:new Ee(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?st:t.value===-1&&(t=this.readMetadataLength()).done?st:(t=this.readMetadata(t.value)).done?st: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(Oc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=A(this.source.read(t));if(e.byteLength<t)throw new Error(jf(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(Ac(e));return n}readMetadataLength(){let t=this.source.read(Ho),e=t&&new xt(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 st;if(e.byteLength<t)throw new Error(Vf(t,e.byteLength));return{done:!1,value:Ct.decode(e)}}},$n=class{constructor(t,e){this.source=t instanceof te?t:Is(t)?new Br(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?st:t.value===-1&&(t=yield this.readMetadataLength()).done?st:(t=yield this.readMetadata(t.value)).done?st:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Oc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=A(yield this.source.read(t));if(e.byteLength<t)throw new Error(jf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Ac(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(Ho),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return st;if(e.byteLength<t)throw new Error(Vf(t,e.byteLength));return{done:!1,value:Ct.decode(e)}})}},Hn=class extends Ai{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof yn?t:new yn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Ct.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:Ct.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:Ct.fromJSON(e,V.RecordBatch)}}return this._body=[],st}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(Oc(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(Ac(t));return i}},Ho=4,Bc="ARROW1",Di=new Uint8Array(Bc.length);for(let r=0;r<Bc.length;r+=1)Di[r]=Bc.codePointAt(r);function Go(r,t=0){for(let e=-1,i=Di.length;++e<i;)if(Di[e]!==r[t+e])return!1;return!0}var Fi=Di.length,Dc=Fi+Ho,zf=Fi*2+Ho;var Fc=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,i)=>t[i]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Nc=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,i)=>t[i]===e)}},Wf={[Ft.LZ4_FRAME]:new Fc,[Ft.ZSTD]:new Nc};var Ec=class{constructor(){this.registry={}}set(t,e){if(e!=null&&e.encode&&typeof e.encode=="function"&&!Wf[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ft[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Ni=new Ec;var Pt=class r extends Jr{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 ne(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 St.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return St.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:_s(t)?Hp(t):Is(t)?Jp(t):ne(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):vs(t)||Ki(t)||xs(t)||Xt(t)?qp(new te(t)):Gp(new Ee(t))}static readAll(t){return t instanceof r?t.isSync()?$f(t):Hf(t):_s(t)||ArrayBuffer.isView(t)||se(t)||ws(t)?$f(t):Hf(t)}},Ue=class extends Pt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return zt(this,arguments,function*(){yield U(yield*oi(ie(this[Symbol.iterator]())))})}},Ar=class extends Pt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=ie(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]()}},Dr=class extends Ue{constructor(t){super(t),this._impl=t}},Gn=class extends Ar{constructor(t){super(t),this._impl=t}},qo=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;if(t.compression!=null){let s=Ni.get(t.compression.type);if(s!=null&&s.decode&&typeof s.decode=="function"){let{decommpressedBody:o,buffers:a}=this._decompressBuffers(t,e,s);i=this._loadCompressedVectors(t,o,this.schema.fields),t=new bt(t.length,t.nodes,a,null)}else throw new Error("Record batch is compressed but codec not found")}else i=this._loadVectors(t,e,this.schema.fields);let n=L({type:new nt(this.schema.fields),length:t.length,children:i});return new ft(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;if(t.data.compression!=null){let u=Ni.get(t.data.compression.type);if(u!=null&&u.decode&&typeof u.decode=="function"){let{decommpressedBody:d,buffers:p}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,d,[c]),t=new Ot(new bt(t.data.length,t.data.nodes,p,null),i,n)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new j(l)):new j(l)).memoize()}_loadVectors(t,e,i){return new xi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_loadCompressedVectors(t,e,i){return new Io(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_decompressBuffers(t,e,i){let n=[],s=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){n.push(new Uint8Array(0)),s.push(new gt(o,0));continue}let l=new xt(e.subarray(a,a+c)),u=W(l.readInt64(0)),d=l.bytes().subarray(8),p=u===-1?d:i.decode(d);n.push(p);let m=(o+7&-8)-o;o+=m,s.push(new gt(o,p.length)),o+=p.length}return{decommpressedBody:n,buffers:s}}},Ei=class extends qo{constructor(t,e){super(e),this._reader=_s(t)?new Hn(this._handle=t):new Ai(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=qf(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):st}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):st}next(){if(this.closed)return st;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 ti(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Li=class extends qo{constructor(t,e){super(e),this._reader=new $n(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=qf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):st})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):st})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return st;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 ti(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Jo=class extends Ei{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 gn?t:new gn(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 ir.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}},Lc=class extends Li{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 Br?t:new Br(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Dc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return ir.decode(n)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Uc=class extends Ei{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new wo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function qf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*$f(r){let t=Pt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Hf(r){return zt(this,arguments,function*(){let e=yield U(Pt.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 Hp(r){return new Ue(new Uc(r))}function Gp(r){let t=r.peek(Fi+7&-8);return t&&t.byteLength>=4?Go(t)?new Dr(new Jo(r.read())):new Ue(new Ei(r)):new Ue(new Ei((function*(){})()))}function qp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Fi+7&-8);return t&&t.byteLength>=4?Go(t)?new Dr(new Jo(yield r.read())):new Ar(new Li(r)):new Ar(new Li((function(){return zt(this,arguments,function*(){})})()))})}function Jp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Br(r,t);return t>=zf&&Go(yield e.readAt(0,Fi+7&-8))?new Gn(new Lc(e)):new Ar(new Li(e))})}var lt=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ft?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 j)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;b.isNull(e)||we.call(this,n<=0?new Uint8Array(0):Wr(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 we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new gt(this._byteLength,t)),this._byteLength+=t,this}function Xp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(we.call(this,n),e.mode===Z.Sparse)return Mc.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return we.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);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],m=c[d];return l.slice(p,Math.min(i,m))}))}}return this}function Kp(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,Wr(r.offset,r.length,t)):we.call(this,$r(r.values))}function fr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Xo(r){let{length:t,values:e,valueOffsets:i}=r,n=W(i[0]),s=W(i[t]),o=Math.min(s-n,e.byteLength-n);return we.call(this,Bs(-n,t+1,i)),we.call(this,e.subarray(n,n+o)),this}function Rc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return we.call(this,Bs(-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]}lt.prototype.visitBool=Kp;lt.prototype.visitInt=fr;lt.prototype.visitFloat=fr;lt.prototype.visitUtf8=Xo;lt.prototype.visitLargeUtf8=Xo;lt.prototype.visitBinary=Xo;lt.prototype.visitLargeBinary=Xo;lt.prototype.visitFixedSizeBinary=fr;lt.prototype.visitDate=fr;lt.prototype.visitTimestamp=fr;lt.prototype.visitTime=fr;lt.prototype.visitDecimal=fr;lt.prototype.visitList=Rc;lt.prototype.visitStruct=Mc;lt.prototype.visitUnion=Xp;lt.prototype.visitInterval=fr;lt.prototype.visitDuration=fr;lt.prototype.visitFixedSizeList=Rc;lt.prototype.visitMap=Rc;var ei=class extends Jr{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){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new Ne,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Dt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ft).includes(t.compressionType))this._compression=new qr(t.compressionType);else{let e=Object.values(Ft).filter(i=>typeof i=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ne(t)?t.then(e=>this.writeAll(e)):Xt(t)?Cc(this,t):kc(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 Ne?this._sink=t:(this._sink=new Ne,t&&ru(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&iu(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||!Qr(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 _e&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ft&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Qr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof ti||this._writeRecordBatch(t):t instanceof _e?this.writeAll(t.batches):se(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=Ct.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 nr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new nr(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=A(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Ct.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Di)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=this._assembleRecordBatch(t),o=new bt(t.numRows,i,n,this._compression),a=Ct.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_assembleRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=lt.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:n,buffers:s}=this._compressBodyBuffers(s)),{byteLength:e,nodes:i,bufferRegions:n,buffers:s}}_compressBodyBuffers(t){let e=Ni.get(this._compression.type);if(!(e!=null&&e.encode)||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ft[this._compression.type]}" has invalid encode method`);let i=0,n=[],s=[];for(let a of t){let c=A(a);if(c.length===0){n.push(new Uint8Array(0),new Uint8Array(0)),s.push(new gt(i,0));continue}let l=e.encode(c),u=l.length<c.length,d=u?l:c,p=u?d.length:-1,m=new xt(new Uint8Array(8));m.writeInt64(0,BigInt(p)),n.push(m.bytes(),new Uint8Array(d));let _=(i+7&-8)-i;i+=_;let C=8+d.length;s.push(new gt(i,C)),i+=C}let o=(i+7&-8)-i;return i+=o,{byteLength:i,bufferRegions:s,buffers:n}}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=this._assembleRecordBatch(new j([t])),c=new bt(t.length,s,o,this._compression),l=new Ot(c,e,i),u=Ct.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,i=new Array(e);for(let n=0;n<t.length;n+=e){let s=0;for(let a=-1;++a<e;)i[a]=t[n+a],s+=i[a].byteLength;if(s===0)continue;for(let a of i)this._write(a);let o=(s+7&-8)-s;o>0&&this._writePadding(o)}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}},qn=class r extends ei{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Xt(t)?Cc(i,t):kc(i,t)}},Jn=class r extends ei{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Xt(t)?Cc(i,t):kc(i,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_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=ir.encode(new ir(t,J.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function kc(r,t){let e=t;t instanceof _e&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Cc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=ie(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 Jf(r,t){if(Xt(r))return Zp(r,t);if(se(r))return Yp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Yp(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(),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=A(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 Zp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){e!=null&&e.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=A(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 Yf(r){return new Pc(r)}var Pc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Ql(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Kr(s),this._getSize=n!=="bytes"?Xf:Kf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?Xf:Kf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Xf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Kf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function Ko(r,t){let e=new Ne,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Pt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Yo(r,t){let e=new this(r),i=new te(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var Qp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ga),_c),cc),qa),Pa),ac),za),vc),{compareSchemas:Qr,compareFields:Uf,compareTypes:Mf});St.toDOMStream=Jf;at.throughDOM=Yf;Pt.throughDOM=Ko;Dr.throughDOM=Ko;Ue.throughDOM=Ko;ei.throughDOM=Yo;Jn.throughDOM=Yo;qn.throughDOM=Yo;var Vc=class extends it{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 "+Ur(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}},jc=new Vc;var Zf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Zf||{}),Qf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Qf||{}),zc=class extends it{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}])}},tm=new zc,Wc=class extends it{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}])}},em=new Wc,$c=class extends it{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},hO=new $c,Hc=class extends it{constructor(){super("arrow.flight.protocol.Empty",[])}},rm=new Hc,Gc=class extends it{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},im=new Gc,qc=class extends it{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},nm=new qc,Jc=class extends it{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},sm=new Jc,Xc=class extends it{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Qo}])}},pO=new Xc,Kc=class extends it{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>td}])}},mO=new Kc,Yc=class extends it{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},om=new Yc,Zc=class extends it{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Qf,"CANCEL_STATUS_"]}])}},yO=new Zc,Qc=class extends it{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},am=new Qc,tl=class extends it{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Zf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Ui=new tl,el=class extends it{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ui},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>td},{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}])}},Qo=new el,rl=class extends it{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Qo},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ui},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>jc}])}},cm=new rl,il=class extends it{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>ta},{no:2,name:"location",kind:"message",repeat:1,T:()=>lm},{no:3,name:"expiration_time",kind:"message",T:()=>jc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},td=new il,nl=class extends it{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},lm=new nl,sl=class extends it{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},ta=new sl,ol=class extends it{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Ui},{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}])}},Zo=new ol,al=class extends it{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},um=new al,ea=new Wi("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:tm,O:em},{name:"ListFlights",serverStreaming:!0,options:{},I:nm,O:Qo},{name:"GetFlightInfo",options:{},I:Ui,O:Qo},{name:"PollFlightInfo",options:{},I:Ui,O:cm},{name:"GetSchema",options:{},I:Ui,O:am},{name:"DoGet",serverStreaming:!0,options:{},I:ta,O:Zo},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Zo,O:um},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Zo,O:Zo},{name:"DoAction",serverStreaming:!0,options:{},I:sm,O:om},{name:"ListActions",serverStreaming:!0,options:{},I:rm,O:im}]);var ra=class{constructor(t){this._transport=t;z(this,"typeName",ea.typeName);z(this,"methods",ea.methods);z(this,"options",ea.options)}_transport;handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}};var ed=/\$(\w+)/g;function rd(r){return!!r.match(ed)}function id(r,t){let e=r.match(ed);if(e)for(let i of e)t[i.trim().replace("$","")]||ii(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var fm="2.4.0.nightly",nd=`influxdb3-js/${fm}`;function cl(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 ni(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return Al(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return ni(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 Xn=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_flightClient");z(this,"_transport");z(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=kr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new ra(this._transport)}_options;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 ta.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":nd,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){var d;if(i.params&&rd(t)&&id(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)};a.timeout=(d=i.timeout)!=null?d:this._options.queryTimeout;let c=n.doGet(s,a),l=(async function*(){for await(let p of c.responses)yield Bl(p.dataHeader.length),yield p.dataHeader,yield p.dataBody})();yield*await Pt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=cl(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new dr;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),m=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"&&m===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,C,rt]=_.split("::");if(C==="field"){if(rt&&p!==void 0&&p!==null){let dt=cl(u,p);c.setField(d,dt,rt)}}else C==="tag"?c.setTag(d,p):C==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var ll=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
25
25
  `,Kn=class{constructor(...t){z(this,"_options");z(this,"_writeApi");z(this,"_queryApi");z(this,"_transport");z(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});z(this,"_mergeQueryOptions",t=>{var s,o;let e={...(s=this._options.queryOptions)==null?void 0:s.headers,...t==null?void 0:t.headers},i={...(o=this._options.queryOptions)==null?void 0:o.params,...t==null?void 0:t.params},n={...this._options.queryOptions,...t};return n.headers=e,n.params=i,n});var s,o,a,c,l,u,d,p;let e;switch(t.length){case 0:{e=ca();break}case 1:{if(t[0]==null)throw new ve("No configuration specified!");typeof t[0]=="string"?e=aa(t[0]):e=t[0];break}default:throw new ve("Multiple arguments specified!")}this._options={...sa,...e},this._options.grpcOptions?this._options.queryOptions={...e.queryOptions,grpcOptions:{...this._options.grpcOptions}}:(s=e.queryOptions)!=null&&s.grpcOptions&&(this._options.grpcOptions=(o=e.queryOptions)==null?void 0:o.grpcOptions);let i=this._options.host;if(typeof i!="string")throw new ve("No host specified!");if(i.endsWith("/")&&(this._options.host=i.substring(0,i.length-1)),typeof this._options.token!="string")throw new ve("No token specified!");this._queryApi=new Xn({...this._options,queryTimeout:(l=(a=this._options.queryOptions)==null?void 0:a.timeout)!=null?l:(c=this._options)==null?void 0:c.queryTimeout});let n=(p=(d=this._options.timeout)!=null?d:(u=this._options.writeOptions)==null?void 0:u.timeout)!=null?p:this._options.writeTimeout;this._transport=kr.writeTransport({...this._options,writeTimeout:n}),this._writeApi=new Ji({transport:this._transport,...this._options})}async write(t,e,i,n){var o;let s=this._mergeWriteOptions(n);await this._writeApi.doWrite(ga(t,s==null?void 0:s.defaultTags,s==null?void 0:s.tagOrder,s==null?void 0:s.precision),(o=e!=null?e:this._options.database)!=null?o:ii(new Error(ll)),i,s)}query(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Zn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.query(t,(o=e!=null?e:this._options.database)!=null?o:ii(new Error(ll)),s)}queryPoints(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Zn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.queryPoints(t,(o=e!=null?e:this._options.database)!=null?o:ii(new Error(ll)),s)}async getServerVersion(){let t;try{let e=await this._transport.request("/ping",null,{method:"GET"},(i,n)=>{var s;t=(s=i["X-Influxdb-Version"])!=null?s:i["x-influxdb-version"]});e&&!t&&(t=e.version)}catch(e){return Promise.reject(e)}return Promise.resolve(t)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return ud(dm);})();
26
26
  //# sourceMappingURL=influxdb.js.map
Binary file