@influxdata/influxdb3-client 2.2.0-nightly.16311 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/influxdb.js CHANGED
@@ -1,22 +1,26 @@
1
- "use strict";var influxdb=(()=>{var Jn=Object.defineProperty;var Zf=Object.getOwnPropertyDescriptor;var Qf=Object.getOwnPropertyNames;var td=Object.prototype.hasOwnProperty;var ed=(r,t,e)=>t in r?Jn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Ue=(r,t)=>{for(var e in t)Jn(r,e,{get:t[e],enumerable:!0})},rd=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qf(t))!td.call(r,n)&&n!==e&&Jn(r,n,{get:()=>t[n],enumerable:!(i=Zf(t,n))||i.enumerable});return r};var id=r=>rd(Jn({},"__esModule",{value:!0}),r);var z=(r,t,e)=>ed(r,typeof t!="symbol"?t+"":t,e);var im={};Ue(im,{AbortError:()=>Li,DEFAULT_ConnectionOptions:()=>ra,DEFAULT_QueryOptions:()=>Kn,DEFAULT_WriteOptions:()=>ia,GetFieldTypeMissmatchError:()=>Yn,HttpError:()=>re,IllegalArgumentError:()=>ur,InfluxDBClient:()=>qn,Log:()=>Nr,Point:()=>Ui,PointValues:()=>fr,RequestTimedOutError:()=>ta,collectAll:()=>wl,consoleLogger:()=>cl,convertTime:()=>ha,convertTimeToNanos:()=>da,createTextDecoderCombiner:()=>ea,currentTime:()=>ml,dateToProtocolTimestamp:()=>yl,escape:()=>Er,fromConnectionString:()=>na,fromEnv:()=>sa,isNumber:()=>ri,parsePrecision:()=>ca,precisionToV2ApiString:()=>oa,precisionToV3ApiString:()=>aa,setLogger:()=>sd,useProcessHrtime:()=>pl,writableDataToLineProtocol:()=>pa});function nd(r){if(!r||typeof r!="object"||Array.isArray(r))return;let t=typeof r.message=="string"?r.message:void 0;if(t)return t;let e=typeof r.error=="string"?r.error:void 0,i=r.data;if(e&&Array.isArray(i)){let n=[];for(let s of i){if(!s||typeof s!="object"||Array.isArray(s))continue;let o=s.line_number,a=s.error_message,c=s.original_line;o!=null&&typeof a=="string"&&a.length>0&&typeof c=="string"&&c.length>0?n.push(` line ${o}: ${a} (${c})`):typeof a=="string"&&a.length>0&&n.push(` ${a}`)}return n.length?`${e}:
2
- ${n.join(`
3
- `)}`:e}if(i&&typeof i=="object"&&!Array.isArray(i)){let n=i.error_message;if(typeof n=="string"&&n.length>0)return n}if(e)return e}var ur=class r extends Error{constructor(t){super(t),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},re=class r extends Error{constructor(e,i,n,s,o,a){var c;super();this.statusCode=e;this.statusMessage=i;this.body=n;this.contentType=s;this.headers=o;z(this,"code");z(this,"json");if(Object.setPrototypeOf(this,r.prototype),a)this.message=a;else if(n&&(s!=null&&s.startsWith("application/json")||!s))try{this.json=JSON.parse(n),typeof((c=this.json)==null?void 0:c.code)=="string"&&(this.code=this.json.code);let l=nd(this.json);l&&(this.message=l)}catch(l){}this.message||(this.message=`${e} ${i} : ${n}`),this.name="HttpError"}statusCode;statusMessage;body;contentType;headers},ta=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},Li=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function ea(){let r=new TextDecoder("utf-8");return{concat(t,e){let i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i},copy(t,e,i){let n=new Uint8Array(i-e);return n.set(t.subarray(e,i)),n},toUtf8String(t,e,i){return r.decode(t.subarray(e,i))}}}var ra={timeout:void 0,writeTimeout:1e4,queryTimeout:6e4},ia={precision:"ns",gzipThreshold:1e3,noSync:!1},Kn={type:"sql"};function na(r){if(!r)throw Error("Connection string not set!");let t=new URL(r.trim(),"http://localhost"),e={host:r.indexOf("://")>0?t.origin+t.pathname:t.pathname};return t.searchParams.has("token")&&(e.token=t.searchParams.get("token")),t.searchParams.has("authScheme")&&(e.authScheme=t.searchParams.get("authScheme")),t.searchParams.has("database")&&(e.database=t.searchParams.get("database")),t.searchParams.has("timeout")&&(e.timeout=parseInt(t.searchParams.get("timeout"))),t.searchParams.has("precision")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.precision=ca(t.searchParams.get("precision"))),t.searchParams.has("gzipThreshold")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.gzipThreshold=parseInt(t.searchParams.get("gzipThreshold"))),t.searchParams.has("writeNoSync")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.noSync=al(t.searchParams.get("writeNoSync"))),e}function sa(){if(!process.env.INFLUX_HOST)throw Error("INFLUX_HOST variable not set!");if(!process.env.INFLUX_TOKEN)throw Error("INFLUX_TOKEN variable not set!");let r={host:process.env.INFLUX_HOST.trim()};if(process.env.INFLUX_TOKEN&&(r.token=process.env.INFLUX_TOKEN.trim()),process.env.INFLUX_AUTH_SCHEME&&(r.authScheme=process.env.INFLUX_AUTH_SCHEME.trim()),process.env.INFLUX_DATABASE&&(r.database=process.env.INFLUX_DATABASE.trim()),process.env.INFLUX_TIMEOUT&&(r.timeout=parseInt(process.env.INFLUX_TIMEOUT.trim())),process.env.INFLUX_PRECISION&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.precision=ca(process.env.INFLUX_PRECISION)),process.env.INFLUX_GZIP_THRESHOLD&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.gzipThreshold=parseInt(process.env.INFLUX_GZIP_THRESHOLD)),process.env.INFLUX_WRITE_NO_SYNC&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.noSync=al(process.env.INFLUX_WRITE_NO_SYNC)),process.env.INFLUX_GRPC_OPTIONS){let t=process.env.INFLUX_GRPC_OPTIONS.split(",");r.grpcOptions||(r.grpcOptions={});for(let e of t){let i=e.split("=");if(i.length!=2)continue;let n=parseInt(i[1]);Number.isNaN(n)&&(n=parseFloat(i[1]),Number.isNaN(n)&&(n=i[1])),r.grpcOptions[i[0]]=n}}return r}function al(r){return["true","1","t","y","yes"].includes(r.trim().toLowerCase())}function oa(r){switch(r){case"ns":case"us":case"ms":case"s":return r;default:throw Error(`Unsupported precision '${r}'`)}}function aa(r){switch(r){case"ns":return"nanosecond";case"us":return"microsecond";case"ms":return"millisecond";case"s":return"second";default:throw Error(`Unsupported precision '${r}'`)}}function ca(r){switch(r.trim().toLowerCase()){case"ns":case"nanosecond":return"ns";case"us":case"microsecond":return"us";case"ms":case"millisecond":return"ms";case"s":case"second":return"s";default:throw Error(`Unsupported precision '${r}'`)}}var cl={error(r,t){console.error(`ERROR: ${r}`,t||"")},warn(r,t){console.warn(`WARN: ${r}`,t||"")}},Xn=cl,Nr={error(r,t){Xn.error(r,t)},warn(r,t){Xn.warn(r,t)}};function sd(r){let t=Xn;return Xn=r,t}function la(r,t){return function(e){let i="",n=0,s=0;for(;s<e.length;){let o=r.indexOf(e[s]);o>=0&&(i+=e.substring(n,s),i+=t[o],n=s+1),s++}return n==0?e:(n<e.length&&(i+=e.substring(n,e.length)),i)}}function od(r,t){let e=la(r,t);return i=>`"${e(i)}"`}var Er={measurement:la(`,
4
- \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:od('"\\',['\\"',"\\\\"]),tag:la(`, =
5
- \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var hl="000000000";function pl(r){return!1}pl(!0);var ll=Date.now(),ua=0;function fa(){{let r=Date.now();r!==ll?(ll=r,ua=0):ua++;let t=String(ua);return String(r)+hl.substr(0,6-t.length)+t}}function ul(){return String(Date.now())+hl.substr(0,3)}function fl(){return String(Date.now())}function dl(){return String(Math.floor(Date.now()/1e3))}var ml={s:dl,ms:fl,us:ul,ns:fa,seconds:dl,millis:fl,micros:ul,nanos:fa},yl={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function da(r){return r===void 0?fa():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var ha=(r,t="ns")=>r===void 0?ml[t]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?yl[t](r):String(typeof r=="number"?Math.floor(r):r);var ei=r=>{throw r},gl=r=>r!==void 0,bl=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(t=>t==="0")),_l=r=>{let t=new Uint8Array(4);return t[0]=r>>0,t[1]=r>>8,t[2]=r>>16,t[3]=r>>24,t},wl=async r=>{let t=[];for await(let e of r)t.push(e);return t},ri=r=>r===null||typeof r=="string"&&(r===""||r.indexOf(" ")!==-1)?!1:r!==""&&!isNaN(Number(r==null?void 0:r.toString())),Il=r=>ri(r)?typeof r=="string"?Number(r)>=0:typeof r=="number"&&r>=0:!1;var pa=(r,t,e)=>{let i=bl(r)&&typeof r!="string"?Array.from(r):[r];return i.length===0?[]:typeof i[0]=="string"?i:i.map(s=>s.toLineProtocol(void 0,t,e)).filter(gl)};var ad=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,Yn=class r extends Error{constructor(t,e,i){super(`field ${t} of type ${i} doesn't match expected type ${e}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},fr=class r{constructor(){z(this,"_name");z(this,"_time");z(this,"_tags",{});z(this,"_fields",{})}getMeasurement(){return this._name}setMeasurement(t){return this._name=t,this}getTimestamp(){return this._time}setTimestamp(t){return this._time=t,this}getTag(t){return this._tags[t]}setTag(t,e){return this._tags[t]=e,this}removeTag(t){return delete this._tags[t],this}getTagNames(){return Object.keys(this._tags)}getFloatField(t){return this.getField(t,"float")}setFloatField(t,e){let i;if(typeof e=="number"?i=e:i=parseFloat(e),!isFinite(i))throw new Error(`invalid float value for field '${t}': '${e}'!`);return this._fields[t]=["float",i],this}getIntegerField(t){return this.getField(t,"integer")}setIntegerField(t,e){let i;if(typeof e=="number"?i=e:i=parseInt(String(e)),isNaN(i)||i<=-9223372036854776e3||i>=9223372036854776e3)throw new Error(`invalid integer value for field '${t}': '${e}'!`);return this._fields[t]=["integer",Math.floor(i)],this}getUintegerField(t){return this.getField(t,"uinteger")}setUintegerField(t,e){if(typeof e=="number"){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${t}' out of range: ${e}`);this._fields[t]=["uinteger",Math.floor(e)]}else{let i=String(e);for(let n=0;n<i.length;n++){let s=i.charCodeAt(n);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${n}: ${e}`)}if(i.length>20||i.length===20&&i.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${t}' out of range: ${i}`);this._fields[t]=["uinteger",+i]}return this}getStringField(t){return this.getField(t,"string")}setStringField(t,e){return e!=null&&(typeof e!="string"&&(e=String(e)),this._fields[t]=["string",e]),this}getBooleanField(t){return this.getField(t,"boolean")}setBooleanField(t,e){return this._fields[t]=["boolean",!!e],this}getField(t,e){let i=this._fields[t];if(!i)return;let[n,s]=i;if(e!==void 0&&e!==n)throw new Yn(t,e,n);return s}getFieldType(t){let e=this._fields[t];if(e)return e[0]}setField(t,e,i){switch(i!=null?i:ad(e)){case"string":return this.setStringField(t,e);case"boolean":return this.setBooleanField(t,e);case"float":return this.setFloatField(t,e);case"integer":return this.setIntegerField(t,e);case"uinteger":return this.setUintegerField(t,e);case void 0:return this;default:throw new Error(`invalid field type for field '${t}': type -> ${i}, value -> ${e}!`)}}setFields(t){for(let[e,i]of Object.entries(t))this.setField(e,i);return this}removeField(t){return delete this._fields[t],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let t=new r;return t._name=this._name,t._time=this._time,t._tags=Object.fromEntries(Object.entries(this._tags)),t._fields=Object.fromEntries(Object.entries(this._fields).map(e=>[...e])),t}asPoint(t){return Ui.fromValues(t?this.setMeasurement(t):this)}};var cd=(r,t)=>{switch(r){case"string":return Er.quoted(t);case"boolean":return t?"T":"F";case"float":return`${t}`;case"integer":return`${t}i`;case"uinteger":return`${t}u`}},ld=(r,t)=>{if(!t)return[];let e=new Set(r);return Object.keys(t).filter(i=>!e.has(i)).sort()},ud=(r,t)=>{if(!t||t.length===0)return r;let e=new Set(r),i=[],n=new Set;for(let o of t)!o||n.has(o)||!e.has(o)||(i.push(o),n.add(o),e.delete(o));let s=Array.from(e).sort();return i.concat(s)},Ui=class r{constructor(t){z(this,"_values");t instanceof fr?this._values=t:this._values=new fr,typeof t=="string"&&this._values.setMeasurement(t)}static measurement(t){return new r(t)}static fromValues(t){if(!t.getMeasurement()||t.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(t)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(t){return t!==""&&this._values.setMeasurement(t),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(t){return this._values.setTimestamp(t),this}getTag(t){return this._values.getTag(t)}setTag(t,e){return this._values.setTag(t,e),this}removeTag(t){return this._values.removeTag(t),this}getTagNames(){return this._values.getTagNames()}getFloatField(t){return this._values.getFloatField(t)}setFloatField(t,e){return this._values.setFloatField(t,e),this}getIntegerField(t){return this._values.getIntegerField(t)}setIntegerField(t,e){return this._values.setIntegerField(t,e),this}getUintegerField(t){return this._values.getUintegerField(t)}setUintegerField(t,e){return this._values.setUintegerField(t,e),this}getStringField(t){return this._values.getStringField(t)}setStringField(t,e){return this._values.setStringField(t,e),this}getBooleanField(t){return this._values.getBooleanField(t)}setBooleanField(t,e){return this._values.setBooleanField(t,e),this}getField(t,e){return this._values.getField(t,e)}getFieldType(t){return this._values.getFieldType(t)}setField(t,e,i){return this._values.setField(t,e,i),this}setFields(t){return this._values.setFields(t),this}removeField(t){return this._values.removeField(t),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(t,e,i){if(!this._values.getMeasurement())return;let n="";if(this._values.getFieldNames().sort().forEach(u=>{if(u){let d=this._values.getFieldType(u),p=this._values.getField(u);if(d===void 0||p===void 0)return;let m=cd(d,p);n.length>0&&(n+=","),n+=`${Er.tag(u)}=${m}`}}),n.length===0)return;let s="",o=this._values.getTagNames().sort(),a=ld(o,e);ud(a.concat(o),i).forEach(u=>{if(u){let d=this._values.getTag(u),p=d!==void 0?d:e==null?void 0:e[u];p&&(s+=",",s+=`${Er.tag(u)}=${Er.tag(p)}`)}});let l=this._values.getTimestamp();return t?typeof t=="string"?l=ha(l,t):l=t(l):l=da(l),`${Er.measurement(this.getMeasurement())}${s} ${n}${l!==void 0?` ${l}`:""}`}toString(){let t=this.toLineProtocol(void 0);return t||`invalid point: ${JSON.stringify(this,void 0)}`}};function ma(r={}){let t=0,e={next:i=>{if(t===0&&r.next&&i!==null&&i!==void 0)return r.next(i)},error:i=>{t===0&&(t=1,r.error&&r.error(i))},complete:()=>{t===0&&(t=2,r.complete&&r.complete())},responseStarted:(i,n)=>{r.responseStarted&&r.responseStarted(i,n)}};return r.useCancellable&&(e.useCancellable=r.useCancellable.bind(r)),r.useResume&&(e.useResume=r.useResume.bind(r)),e}function Zn(r){let t={};return r.headers.forEach((e,i)=>{let n=t[i];n===void 0?t[i]=e:Array.isArray(n)?n.push(e):t[i]=[n,e]}),t}var Mi=class{constructor(t){this._connectionOptions=t;z(this,"chunkCombiner",ea());z(this,"_defaultHeaders");z(this,"_url");z(this,"requestDecorator",function(){});var e;if(this._defaultHeaders={"content-type":"application/json; charset=utf-8",...t.headers},this._connectionOptions.token){let i=(e=this._connectionOptions.authScheme)!=null?e:"Token";this._defaultHeaders.Authorization=`${i} ${this._connectionOptions.token}`}this._url=String(this._connectionOptions.host),this._url.endsWith("/")&&(this._url=this._url.substring(0,this._url.length-1)),this._url.endsWith("/api/v2")&&(this._url=this._url.substring(0,this._url.length-7),Nr.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this._url} !`))}_connectionOptions;send(t,e,i,n){let s=ma(n),o=!1,a=i.signal,c,l=()=>{},u=l;if(n&&n.useCancellable){let d=new AbortController;a||(a=d.signal,i={...i,signal:a}),a.addEventListener("abort",()=>{u()}),n.useCancellable({cancel(){o=!0,d.abort()},isCancelled(){return o||a.aborted}})}this._fetch(t,e,i).then(async d=>{if(n!=null&&n.responseStarted&&s.responseStarted(Zn(d),d.status),await this._throwOnErrorResponse(d),d.body){let p=d.body.getReader(),m;do{if(c&&await c,o)break;if(m=await p.read(),s.next(m.value)===!1){let _=s.useResume;if(!_){let j="Unable to pause, useResume is not configured!";return await p.cancel(j),Promise.reject(new Error(j))}c=new Promise(j=>{u=()=>{j(),c=void 0,u=l},_(u)})}}while(!m.done)}else if(d.arrayBuffer){let p=await d.arrayBuffer();s.next(new Uint8Array(p))}else{let p=await d.text();s.next(new TextEncoder().encode(p))}}).catch(d=>{o||s.error(d)}).finally(()=>s.complete())}async _throwOnErrorResponse(t){if(t.status>=300){let e="";try{if(e=await t.text(),!e){let i=t.headers.get("x-influxdb-error");i&&(e=i)}}catch(i){throw Nr.warn("Unable to receive error body",i),new re(t.status,t.statusText,void 0,t.headers.get("content-type"),Zn(t))}throw new re(t.status,t.statusText,e,t.headers.get("content-type"),Zn(t))}}async*iterate(t,e,i){var s;let n=await this._fetch(t,e,i);if(await this._throwOnErrorResponse(n),n.body){let o=n.body.getReader();for(;;){let{value:a,done:c}=await o.read();if(c)break;if((s=i.signal)!=null&&s.aborted)throw await n.body.cancel(),new Li;yield a}}else if(n.arrayBuffer){let o=await n.arrayBuffer();yield new Uint8Array(o)}else{let o=await n.text();yield new TextEncoder().encode(o)}}async request(t,e,i,n){var l,u;let s=await this._fetch(t,e,i),{headers:o}=s,a=o.get("content-type")||"";n&&n(Zn(s),s.status),await this._throwOnErrorResponse(s);let c=(u=(l=i.headers)==null?void 0:l.accept)!=null?u:a;if(c.includes("json"))return await s.json();if(c.includes("text")||c.startsWith("application/csv"))return await s.text()}_fetch(t,e,i){let{method:n,headers:s,...o}=i,a=`${this._url}${t}`,c={method:n,body:n==="GET"||n==="HEAD"?void 0:typeof e=="string"?e:JSON.stringify(e),headers:{...this._defaultHeaders,...s},credentials:"omit",...this._connectionOptions.transportOptions,...o};return this.requestDecorator(c,i,a),fetch(a,c)}};function Lr(r){let t=typeof r;if(t=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return t}function ya(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var Me="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Qn=[];for(let r=0;r<Me.length;r++)Qn[Me[r].charCodeAt(0)]=r;Qn[45]=Me.indexOf("+");Qn[95]=Me.indexOf("/");function Ri(r){let t=r.length*3/4;r[r.length-2]=="="?t-=2:r[r.length-1]=="="&&(t-=1);let e=new Uint8Array(t),i=0,n=0,s,o=0;for(let a=0;a<r.length;a++){if(s=Qn[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":n=0;case`
6
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(n){case 0:o=s,n=1;break;case 1:e[i++]=o<<2|(s&48)>>4,o=s,n=2;break;case 2:e[i++]=(o&15)<<4|(s&60)>>2,o=s,n=3;break;case 3:e[i++]=(o&3)<<6|s,n=0;break}}if(n==1)throw Error("invalid base64 string.");return e.subarray(0,i)}function Ci(r){let t="",e=0,i,n=0;for(let s=0;s<r.length;s++)switch(i=r[s],e){case 0:t+=Me[i>>2],n=(i&3)<<4,e=1;break;case 1:t+=Me[n|i>>4],n=(i&15)<<2,e=2;break;case 2:t+=Me[n|i>>6],t+=Me[i&63],e=0;break}return e&&(t+=Me[n],t+="=",e==1&&(t+="=")),t}var Ur;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(e,i,n,s,o)=>{(t(i)?i[r.symbol]:i[r.symbol]=[]).push({no:n,wireType:s,data:o})},r.onWrite=(e,i,n)=>{for(let{no:s,wireType:o,data:a}of r.list(i))n.tag(s,o).raw(a)},r.list=(e,i)=>{if(t(e)){let n=e[r.symbol];return i?n.filter(s=>s.no==i):n}return[]},r.last=(e,i)=>r.list(e,i).slice(-1)[0];let t=e=>e&&Array.isArray(e[r.symbol])})(Ur||(Ur={}));function ga(r,t){return Object.assign(Object.assign({},r),t)}var st;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(st||(st={}));function vl(){let r=0,t=0;for(let i=0;i<28;i+=7){let n=this.buf[this.pos++];if(r|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}let e=this.buf[this.pos++];if(r|=(e&15)<<28,t=(e&112)>>4,(e&128)==0)return this.assertBounds(),[r,t];for(let i=3;i<=31;i+=7){let n=this.buf[this.pos++];if(t|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}throw new Error("invalid varint")}function es(r,t,e){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&t==0),c=(a?o|128:o)&255;if(e.push(c),!a)return}let i=r>>>28&15|(t&7)<<4,n=t>>3!=0;if(e.push((n?i|128:i)&255),!!n){for(let s=3;s<31;s=s+7){let o=t>>>s,a=!!(o>>>7),c=(a?o|128:o)&255;if(e.push(c),!a)return}e.push(t>>>31&1)}}var ts=65536*65536;function ba(r){let t=r[0]=="-";t&&(r=r.slice(1));let e=1e6,i=0,n=0;function s(o,a){let c=Number(r.slice(o,a));n*=e,i=i*e+c,i>=ts&&(n=n+(i/ts|0),i=i%ts)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[t,i,n]}function rs(r,t){if(t>>>0<=2097151)return""+(ts*t+(r>>>0));let e=r&16777215,i=(r>>>24|t<<8)>>>0&16777215,n=t>>16&65535,s=e+i*6777216+n*6710656,o=i+n*8147497,a=n*2,c=1e7;s>=c&&(o+=Math.floor(s/c),s%=c),o>=c&&(a+=Math.floor(o/c),o%=c);function l(u,d){let p=u?String(u):"";return d?"0000000".slice(p.length)+p:p}return l(a,0)+l(o,a)+l(s,1)}function _a(r,t){if(r>=0){for(;r>127;)t.push(r&127|128),r=r>>>7;t.push(r)}else{for(let e=0;e<9;e++)t.push(r&127|128),r=r>>7;t.push(1)}}function Sl(){let r=this.buf[this.pos++],t=r&127;if((r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<7,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<14,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<21,(r&128)==0)return this.assertBounds(),t;r=this.buf[this.pos++],t|=(r&15)<<28;for(let e=5;(r&128)!==0&&e<10;e++)r=this.buf[this.pos++];if((r&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var tt;function fd(){let r=new DataView(new ArrayBuffer(8));tt=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}fd();function xl(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Tl=/^-?[0-9]+$/,ns=4294967296,is=2147483648,ss=class{constructor(t,e){this.lo=t|0,this.hi=e|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let t=this.hi*ns+(this.lo>>>0);if(!Number.isSafeInteger(t))throw new Error("cannot convert to safe number");return t}},ht=class r extends ss{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.UMIN)throw new Error("signed value for ulong");if(t>tt.UMAX)throw new Error("ulong too large");return tt.V.setBigUint64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!Tl.test(t))throw new Error("string is no integer");let[e,i,n]=ba(t);if(e)throw new Error("signed value for ulong");return new r(i,n);case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");if(t<0)throw new Error("signed value for ulong");return new r(t,t/ns)}throw new Error("unknown value "+typeof t)}toString(){return tt?this.toBigInt().toString():rs(this.lo,this.hi)}toBigInt(){return xl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigUint64(0,!0)}};ht.ZERO=new ht(0,0);var X=class r extends ss{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.MIN)throw new Error("signed long too small");if(t>tt.MAX)throw new Error("signed long too large");return tt.V.setBigInt64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!Tl.test(t))throw new Error("string is no integer");let[e,i,n]=ba(t);if(e){if(n>is||n==is&&i!=0)throw new Error("signed long too small")}else if(n>=is)throw new Error("signed long too large");let s=new r(i,n);return e?s.negate():s;case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");return t>0?new r(t,t/ns):new r(-t,-t/ns).negate()}throw new Error("unknown value "+typeof t)}isNegative(){return(this.hi&is)!==0}negate(){let t=~this.hi,e=this.lo;return e?e=~e+1:t+=1,new r(e,t)}toString(){if(tt)return this.toBigInt().toString();if(this.isNegative()){let t=this.negate();return"-"+rs(t.lo,t.hi)}return rs(this.lo,this.hi)}toBigInt(){return xl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigInt64(0,!0)}};X.ZERO=new X(0,0);var Bl={readUnknownField:!0,readerFactory:r=>new wa(r)};function Ol(r){return r?Object.assign(Object.assign({},Bl),r):Bl}var wa=class{constructor(t,e){this.varint64=vl,this.uint32=Sl,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e!=null?e:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let t=this.uint32(),e=t>>>3,i=t&7;if(e<=0||i<0||i>5)throw new Error("illegal tag: field no "+e+" wire type "+i);return[e,i]}skip(t){let e=this.pos;switch(t){case st.Varint:for(;this.buf[this.pos++]&128;);break;case st.Bit64:this.pos+=4;case st.Bit32:this.pos+=4;break;case st.LengthDelimited:let i=this.uint32();this.pos+=i;break;case st.StartGroup:let n;for(;(n=this.tag()[1])!==st.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(e,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return new X(...this.varint64())}uint64(){return new ht(...this.varint64())}sint64(){let[t,e]=this.varint64(),i=-(t&1);return t=(t>>>1|(e&1)<<31)^i,e=e>>>1^i,new X(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new ht(this.sfixed32(),this.sfixed32())}sfixed64(){return new X(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}};function M(r,t){if(!r)throw new Error(t)}function Ia(r,t){throw new Error(t!=null?t:"Unexpected object: "+r)}var dd=34028234663852886e22,hd=-34028234663852886e22,pd=4294967295,md=2147483647,yd=-2147483648;function Re(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>md||r<yd)throw new Error("invalid int 32: "+r)}function dr(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>pd||r<0)throw new Error("invalid uint 32: "+r)}function Mr(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>dd||r<hd))throw new Error("invalid float 32: "+r)}var Dl={writeUnknownFields:!0,writerFactory:()=>new va};function Al(r){return r?Object.assign(Object.assign({},Dl),r):Dl}var va=class{constructor(t){this.stack=[],this.textEncoder=t!=null?t:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let t=0;for(let n=0;n<this.chunks.length;n++)t+=this.chunks[n].length;let e=new Uint8Array(t),i=0;for(let n=0;n<this.chunks.length;n++)e.set(this.chunks[n],i),i+=this.chunks[n].length;return this.chunks=[],e}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),e=this.stack.pop();if(!e)throw new Error("invalid state, fork stack empty");return this.chunks=e.chunks,this.buf=e.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(dr(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Re(t),_a(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){Mr(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){dr(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Re(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Re(t),t=(t<<1^t>>31)>>>0,_a(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=X.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=ht.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}int64(t){let e=X.from(t);return es(e.lo,e.hi,this.buf),this}sint64(t){let e=X.from(t),i=e.hi>>31,n=e.lo<<1^i,s=(e.hi<<1|e.lo>>>31)^i;return es(n,s,this.buf),this}uint64(t){let e=ht.from(t);return es(e.lo,e.hi,this.buf),this}};var Fl={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Nl={ignoreUnknownFields:!1};function Sa(r){return r?Object.assign(Object.assign({},Nl),r):Nl}function xa(r){return r?Object.assign(Object.assign({},Fl),r):Fl}function Ta(r,t){var e,i;let n=Object.assign(Object.assign({},r),t);return n.typeRegistry=[...(e=r==null?void 0:r.typeRegistry)!==null&&e!==void 0?e:[],...(i=t==null?void 0:t.typeRegistry)!==null&&i!==void 0?i:[]],n}var os=Symbol.for("protobuf-ts/message-type");function ii(r){let t=!1,e=[];for(let i=0;i<r.length;i++){let n=r.charAt(i);n=="_"?t=!0:/\d/.test(n)?(e.push(n),t=!0):t?(e.push(n.toUpperCase()),t=!1):i==0?e.push(n.toLowerCase()):e.push(n)}return e.join("")}var h;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(h||(h={}));var Dt;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(Dt||(Dt={}));var ki;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(ki||(ki={}));function El(r){var t,e,i,n;return r.localName=(t=r.localName)!==null&&t!==void 0?t:ii(r.name),r.jsonName=(e=r.jsonName)!==null&&e!==void 0?e:ii(r.name),r.repeat=(i=r.repeat)!==null&&i!==void 0?i:ki.NO,r.opt=(n=r.opt)!==null&&n!==void 0?n:r.repeat||r.oneof?!1:r.kind=="message",r}function Ll(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var as=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}prepare(){if(this.data)return;let t=[],e=[],i=[];for(let n of this.fields)if(n.oneof)i.includes(n.oneof)||(i.push(n.oneof),t.push(n.oneof),e.push(n.oneof));else switch(e.push(n.localName),n.kind){case"scalar":case"enum":(!n.opt||n.repeat)&&t.push(n.localName);break;case"message":n.repeat&&t.push(n.localName);break;case"map":t.push(n.localName);break}this.data={req:t,known:e,oneofs:Object.values(i)}}is(t,e,i=!1){if(e<0)return!0;if(t==null||typeof t!="object")return!1;this.prepare();let n=Object.keys(t),s=this.data;if(n.length<s.req.length||s.req.some(o=>!n.includes(o))||!i&&n.some(o=>!s.known.includes(o)))return!1;if(e<1)return!0;for(let o of s.oneofs){let a=t[o];if(!Ll(a))return!1;if(a.oneofKind===void 0)continue;let c=this.fields.find(l=>l.localName===a.oneofKind);if(!c||!this.field(a[a.oneofKind],c,i,e))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(t[o.localName],o,i,e))return!1;return!0}field(t,e,i,n){let s=e.repeat;switch(e.kind){case"scalar":return t===void 0?e.opt:s?this.scalars(t,e.T,n,e.L):this.scalar(t,e.T,e.L);case"enum":return t===void 0?e.opt:s?this.scalars(t,h.INT32,n):this.scalar(t,h.INT32);case"message":return t===void 0?!0:s?this.messages(t,e.T(),i,n):this.message(t,e.T(),i,n);case"map":if(typeof t!="object"||t===null)return!1;if(n<2)return!0;if(!this.mapKeys(t,e.K,n))return!1;switch(e.V.kind){case"scalar":return this.scalars(Object.values(t),e.V.T,n,e.V.L);case"enum":return this.scalars(Object.values(t),h.INT32,n);case"message":return this.messages(Object.values(t),e.V.T(),i,n)}break}return!0}message(t,e,i,n){return i?e.isAssignable(t,n):e.is(t,n)}messages(t,e,i,n){if(!Array.isArray(t))return!1;if(n<2)return!0;if(i){for(let s=0;s<t.length&&s<n;s++)if(!e.isAssignable(t[s],n-1))return!1}else for(let s=0;s<t.length&&s<n;s++)if(!e.is(t[s],n-1))return!1;return!0}scalar(t,e,i){let n=typeof t;switch(e){case h.UINT64:case h.FIXED64:case h.INT64:case h.SFIXED64:case h.SINT64:switch(i){case Dt.BIGINT:return n=="bigint";case Dt.NUMBER:return n=="number"&&!isNaN(t);default:return n=="string"}case h.BOOL:return n=="boolean";case h.STRING:return n=="string";case h.BYTES:return t instanceof Uint8Array;case h.DOUBLE:case h.FLOAT:return n=="number"&&!isNaN(t);default:return n=="number"&&Number.isInteger(t)}}scalars(t,e,i,n){if(!Array.isArray(t))return!1;if(i<2)return!0;if(Array.isArray(t)){for(let s=0;s<t.length&&s<i;s++)if(!this.scalar(t[s],e,n))return!1}return!0}mapKeys(t,e,i){let n=Object.keys(t);switch(e){case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:return this.scalars(n.slice(0,i).map(s=>parseInt(s)),e,i);case h.BOOL:return this.scalars(n.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),e,i);default:return this.scalars(n,e,i,Dt.STRING)}}};function Lt(r,t){switch(t){case Dt.BIGINT:return r.toBigInt();case Dt.NUMBER:return r.toNumber();default:return r.toString()}}var cs=class{constructor(t){this.info=t}prepare(){var t;if(this.fMap===void 0){this.fMap={};let e=(t=this.info.fields)!==null&&t!==void 0?t:[];for(let i of e)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(t,e,i){if(!t){let n=Lr(i);throw(n=="number"||n=="boolean")&&(n=i.toString()),new Error(`Cannot parse JSON ${n} for ${this.info.typeName}#${e}`)}}read(t,e,i){this.prepare();let n=[];for(let[s,o]of Object.entries(t)){let a=this.fMap[s];if(!a){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let c=a.localName,l;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(n.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);n.push(a.oneof),l=e[a.oneof]={oneofKind:c}}else l=e;if(a.kind=="map"){if(o===null)continue;this.assert(ya(o),a.name,o);let u=l[c];for(let[d,p]of Object.entries(o)){this.assert(p!==null,a.name+" map value",null);let m;switch(a.V.kind){case"message":m=a.V.T().internalJsonRead(p,i);break;case"enum":if(m=this.enum(a.V.T(),p,a.name,i.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.V.T,a.V.L,a.name);break}this.assert(m!==void 0,a.name+" map value",p);let _=d;a.K==h.BOOL&&(_=_=="true"?!0:_=="false"?!1:_),_=this.scalar(_,a.K,Dt.STRING,a.name).toString(),u[_]=m}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let u=l[c];for(let d of o){this.assert(d!==null,a.name,null);let p;switch(a.kind){case"message":p=a.T().internalJsonRead(d,i);break;case"enum":if(p=this.enum(a.T(),d,a.name,i.ignoreUnknownFields),p===!1)continue;break;case"scalar":p=this.scalar(d,a.T,a.L,a.name);break}this.assert(p!==void 0,a.name,o),u.push(p)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}l[c]=a.T().internalJsonRead(o,i,l[c]);break;case"enum":if(o===null)continue;let u=this.enum(a.T(),o,a.name,i.ignoreUnknownFields);if(u===!1)continue;l[c]=u;break;case"scalar":if(o===null)continue;l[c]=this.scalar(o,a.T,a.L,a.name);break}}}enum(t,e,i,n){if(t[0]=="google.protobuf.NullValue"&&M(e===null||e==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} only accepts null.`),e===null)return 0;switch(typeof e){case"number":return M(Number.isInteger(e),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${e}.`),e;case"string":let s=e;t[2]&&e.substring(0,t[2].length)===t[2]&&(s=e.substring(t[2].length));let o=t[1][s];return typeof o=="undefined"&&n?!1:(M(typeof o=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} has no value for "${e}".`),o)}M(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof e}".`)}scalar(t,e,i,n){let s;try{switch(e){case h.DOUBLE:case h.FLOAT:if(t===null)return 0;if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""){s="empty string";break}if(typeof t=="string"&&t.trim().length!==t.length){s="extra whitespace";break}if(typeof t!="string"&&typeof t!="number")break;let o=Number(t);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return e==h.FLOAT&&Mr(o),o;case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:if(t===null)return 0;let a;if(typeof t=="number"?a=t:t===""?s="empty string":typeof t=="string"&&(t.trim().length!==t.length?s="extra whitespace":a=Number(t)),a===void 0)break;return e==h.UINT32?dr(a):Re(a),a;case h.INT64:case h.SFIXED64:case h.SINT64:if(t===null)return Lt(X.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Lt(X.from(t),i);case h.FIXED64:case h.UINT64:if(t===null)return Lt(ht.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Lt(ht.from(t),i);case h.BOOL:if(t===null)return!1;if(typeof t!="boolean")break;return t;case h.STRING:if(t===null)return"";if(typeof t!="string"){s="extra whitespace";break}try{encodeURIComponent(t)}catch(c){c="invalid UTF8";break}return t;case h.BYTES:if(t===null||t==="")return new Uint8Array(0);if(typeof t!="string")break;return Ri(t)}}catch(o){s=o.message}this.assert(!1,n+(s?" - "+s:""),t)}};var ls=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}write(t,e){let i={},n=t;for(let s of this.fields){if(!s.oneof){let l=this.field(s,n[s.localName],e);l!==void 0&&(i[e.useProtoFieldName?s.name:s.jsonName]=l);continue}let o=n[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},e),{emitDefaultValues:!0}):e,c=this.field(s,o[s.localName],a);M(c!==void 0),i[e.useProtoFieldName?s.name:s.jsonName]=c}return i}field(t,e,i){let n;if(t.kind=="map"){M(typeof e=="object"&&e!==null);let s={};switch(t.V.kind){case"scalar":for(let[c,l]of Object.entries(e)){let u=this.scalar(t.V.T,l,t.name,!1,!0);M(u!==void 0),s[c.toString()]=u}break;case"message":let o=t.V.T();for(let[c,l]of Object.entries(e)){let u=this.message(o,l,t.name,i);M(u!==void 0),s[c.toString()]=u}break;case"enum":let a=t.V.T();for(let[c,l]of Object.entries(e)){M(l===void 0||typeof l=="number");let u=this.enum(a,l,t.name,!1,!0,i.enumAsInteger);M(u!==void 0),s[c.toString()]=u}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(n=s)}else if(t.repeat){M(Array.isArray(e));let s=[];switch(t.kind){case"scalar":for(let c=0;c<e.length;c++){let l=this.scalar(t.T,e[c],t.name,t.opt,!0);M(l!==void 0),s.push(l)}break;case"enum":let o=t.T();for(let c=0;c<e.length;c++){M(e[c]===void 0||typeof e[c]=="number");let l=this.enum(o,e[c],t.name,t.opt,!0,i.enumAsInteger);M(l!==void 0),s.push(l)}break;case"message":let a=t.T();for(let c=0;c<e.length;c++){let l=this.message(a,e[c],t.name,i);M(l!==void 0),s.push(l)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(n=s)}else switch(t.kind){case"scalar":n=this.scalar(t.T,e,t.name,t.opt,i.emitDefaultValues);break;case"enum":n=this.enum(t.T(),e,t.name,t.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":n=this.message(t.T(),e,t.name,i);break}return n}enum(t,e,i,n,s,o){if(t[0]=="google.protobuf.NullValue")return!s&&!n?void 0:null;if(e===void 0){M(n);return}if(!(e===0&&!s&&!n))return M(typeof e=="number"),M(Number.isInteger(e)),o||!t[1].hasOwnProperty(e)?e:t[2]?t[2]+t[1][e]:t[1][e]}message(t,e,i,n){return e===void 0?n.emitDefaultValues?null:void 0:t.internalJsonWrite(e,n)}scalar(t,e,i,n,s){if(e===void 0){M(n);return}let o=s||n;switch(t){case h.INT32:case h.SFIXED32:case h.SINT32:return e===0?o?0:void 0:(Re(e),e);case h.FIXED32:case h.UINT32:return e===0?o?0:void 0:(dr(e),e);case h.FLOAT:Mr(e);case h.DOUBLE:return e===0?o?0:void 0:(M(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e);case h.STRING:return e===""?o?"":void 0:(M(typeof e=="string"),e);case h.BOOL:return e===!1?o?!1:void 0:(M(typeof e=="boolean"),e);case h.UINT64:case h.FIXED64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let a=ht.from(e);return a.isZero()&&!o?void 0:a.toString();case h.INT64:case h.SFIXED64:case h.SINT64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let c=X.from(e);return c.isZero()&&!o?void 0:c.toString();case h.BYTES:return M(e instanceof Uint8Array),e.byteLength?Ci(e):o?"":void 0}}};function Vi(r,t=Dt.STRING){switch(r){case h.BOOL:return!1;case h.UINT64:case h.FIXED64:return Lt(ht.ZERO,t);case h.INT64:case h.SFIXED64:case h.SINT64:return Lt(X.ZERO,t);case h.DOUBLE:case h.FLOAT:return 0;case h.BYTES:return new Uint8Array(0);case h.STRING:return"";default:return 0}}var us=class{constructor(t){this.info=t}prepare(){var t;if(!this.fieldNoToField){let e=(t=this.info.fields)!==null&&t!==void 0?t:[];this.fieldNoToField=new Map(e.map(i=>[i.no,i]))}}read(t,e,i,n){this.prepare();let s=n===void 0?t.len:t.pos+n;for(;t.pos<s;){let[o,a]=t.tag(),c=this.fieldNoToField.get(o);if(!c){let p=i.readUnknownField;if(p=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let m=t.skip(a);p!==!1&&(p===!0?Ur.onRead:p)(this.info.typeName,e,o,a,m);continue}let l=e,u=c.repeat,d=c.localName;switch(c.oneof&&(l=l[c.oneof],l.oneofKind!==d&&(l=e[c.oneof]={oneofKind:d})),c.kind){case"scalar":case"enum":let p=c.kind=="enum"?h.INT32:c.T,m=c.kind=="scalar"?c.L:void 0;if(u){let at=l[d];if(a==st.LengthDelimited&&p!=h.STRING&&p!=h.BYTES){let dt=t.uint32()+t.pos;for(;t.pos<dt;)at.push(this.scalar(t,p,m))}else at.push(this.scalar(t,p,m))}else l[d]=this.scalar(t,p,m);break;case"message":if(u){let at=l[d],dt=c.T().internalBinaryRead(t,t.uint32(),i);at.push(dt)}else l[d]=c.T().internalBinaryRead(t,t.uint32(),i,l[d]);break;case"map":let[_,j]=this.mapEntry(c,t,i);l[d][_]=j;break}}}mapEntry(t,e,i){let n=e.uint32(),s=e.pos+n,o,a;for(;e.pos<s;){let[c,l]=e.tag();switch(c){case 1:t.K==h.BOOL?o=e.bool().toString():o=this.scalar(e,t.K,Dt.STRING);break;case 2:switch(t.V.kind){case"scalar":a=this.scalar(e,t.V.T,t.V.L);break;case"enum":a=e.int32();break;case"message":a=t.V.T().internalBinaryRead(e,e.uint32(),i);break}break;default:throw new Error(`Unknown field ${c} (wire type ${l}) in map entry for ${this.info.typeName}#${t.name}`)}}if(o===void 0){let c=Vi(t.K);o=t.K==h.BOOL?c.toString():c}if(a===void 0)switch(t.V.kind){case"scalar":a=Vi(t.V.T,t.V.L);break;case"enum":a=0;break;case"message":a=t.V.T().create();break}return[o,a]}scalar(t,e,i){switch(e){case h.INT32:return t.int32();case h.STRING:return t.string();case h.BOOL:return t.bool();case h.DOUBLE:return t.double();case h.FLOAT:return t.float();case h.INT64:return Lt(t.int64(),i);case h.UINT64:return Lt(t.uint64(),i);case h.FIXED64:return Lt(t.fixed64(),i);case h.FIXED32:return t.fixed32();case h.BYTES:return t.bytes();case h.UINT32:return t.uint32();case h.SFIXED32:return t.sfixed32();case h.SFIXED64:return Lt(t.sfixed64(),i);case h.SINT32:return t.sint32();case h.SINT64:return Lt(t.sint64(),i)}}};var fs=class{constructor(t){this.info=t}prepare(){if(!this.fields){let t=this.info.fields?this.info.fields.concat():[];this.fields=t.sort((e,i)=>e.no-i.no)}}write(t,e,i){this.prepare();for(let s of this.fields){let o,a,c=s.repeat,l=s.localName;if(s.oneof){let u=t[s.oneof];if(u.oneofKind!==l)continue;o=u[l],a=!0}else o=t[l],a=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?h.INT32:s.T;if(c)if(M(Array.isArray(o)),c==ki.PACKED)this.packed(e,u,s.no,o);else for(let d of o)this.scalar(e,u,s.no,d,!0);else o===void 0?M(s.opt):this.scalar(e,u,s.no,o,a||s.opt);break;case"message":if(c){M(Array.isArray(o));for(let d of o)this.message(e,i,s.T(),s.no,d)}else this.message(e,i,s.T(),s.no,o);break;case"map":M(typeof o=="object"&&o!==null);for(let[d,p]of Object.entries(o))this.mapEntry(e,i,s,d,p);break}}let n=i.writeUnknownFields;n!==!1&&(n===!0?Ur.onWrite:n)(this.info.typeName,t,e)}mapEntry(t,e,i,n,s){t.tag(i.no,st.LengthDelimited),t.fork();let o=n;switch(i.K){case h.INT32:case h.FIXED32:case h.UINT32:case h.SFIXED32:case h.SINT32:o=Number.parseInt(n);break;case h.BOOL:M(n=="true"||n=="false"),o=n=="true";break}switch(this.scalar(t,i.K,1,o,!0),i.V.kind){case"scalar":this.scalar(t,i.V.T,2,s,!0);break;case"enum":this.scalar(t,h.INT32,2,s,!0);break;case"message":this.message(t,e,i.V.T(),2,s);break}t.join()}message(t,e,i,n,s){s!==void 0&&(i.internalBinaryWrite(s,t.tag(n,st.LengthDelimited).fork(),e),t.join())}scalar(t,e,i,n,s){let[o,a,c]=this.scalarInfo(e,n);(!c||s)&&(t.tag(i,o),t[a](n))}packed(t,e,i,n){if(!n.length)return;M(e!==h.BYTES&&e!==h.STRING),t.tag(i,st.LengthDelimited),t.fork();let[,s]=this.scalarInfo(e);for(let o=0;o<n.length;o++)t[s](n[o]);t.join()}scalarInfo(t,e){let i=st.Varint,n,s=e===void 0,o=e===0;switch(t){case h.INT32:n="int32";break;case h.STRING:o=s||!e.length,i=st.LengthDelimited,n="string";break;case h.BOOL:o=e===!1,n="bool";break;case h.UINT32:n="uint32";break;case h.DOUBLE:i=st.Bit64,n="double";break;case h.FLOAT:i=st.Bit32,n="float";break;case h.INT64:o=s||X.from(e).isZero(),n="int64";break;case h.UINT64:o=s||ht.from(e).isZero(),n="uint64";break;case h.FIXED64:o=s||ht.from(e).isZero(),i=st.Bit64,n="fixed64";break;case h.BYTES:o=s||!e.byteLength,i=st.LengthDelimited,n="bytes";break;case h.FIXED32:i=st.Bit32,n="fixed32";break;case h.SFIXED32:i=st.Bit32,n="sfixed32";break;case h.SFIXED64:o=s||X.from(e).isZero(),i=st.Bit64,n="sfixed64";break;case h.SINT32:n="sint32";break;case h.SINT64:o=s||X.from(e).isZero(),n="sint64";break}return[i,n,s||o]}};function Ul(r){let t=r.messagePrototype?Object.create(r.messagePrototype):Object.defineProperty({},os,{value:r});for(let e of r.fields){let i=e.localName;if(!e.opt)if(e.oneof)t[e.oneof]={oneofKind:void 0};else if(e.repeat)t[i]=[];else switch(e.kind){case"scalar":t[i]=Vi(e.T,e.L);break;case"enum":t[i]=0;break;case"map":t[i]={};break}}return t}function ds(r,t,e){let i,n=e,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let c=n[o.oneof];if((c==null?void 0:c.oneofKind)==null)continue;if(i=c[a],s=t[o.oneof],s.oneofKind=c.oneofKind,i==null){delete s[a];continue}}else if(i=n[a],s=t,i==null)continue;switch(o.repeat&&(s[a].length=i.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=i[l];else s[a]=i;break;case"message":let c=o.T();if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=c.create(i[l]);else s[a]===void 0?s[a]=c.create(i):c.mergePartial(s[a],i);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],i);break;case"message":let l=o.V.T();for(let u of Object.keys(i))s[a][u]=l.create(i[u]);break}break}}}function Cl(r,t,e){if(t===e)return!0;if(!t||!e)return!1;for(let i of r.fields){let n=i.localName,s=i.oneof?t[i.oneof][n]:t[n],o=i.oneof?e[i.oneof][n]:e[n];switch(i.kind){case"enum":case"scalar":let a=i.kind=="enum"?h.INT32:i.T;if(!(i.repeat?Ml(a,s,o):kl(a,s,o)))return!1;break;case"map":if(!(i.V.kind=="message"?Rl(i.V.T(),hs(s),hs(o)):Ml(i.V.kind=="enum"?h.INT32:i.V.T,hs(s),hs(o))))return!1;break;case"message":let c=i.T();if(!(i.repeat?Rl(c,s,o):c.equals(s,o)))return!1;break}}return!0}var hs=Object.values;function kl(r,t,e){if(t===e)return!0;if(r!==h.BYTES)return!1;let i=t,n=e;if(i.length!==n.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=n[s])return!1;return!0}function Ml(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!kl(r,t[i],e[i]))return!1;return!0}function Rl(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!r.equals(t[i],e[i]))return!1;return!0}var Vl=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),gd=Vl[os]={},rt=class{constructor(t,e,i){this.defaultCheckDepth=16,this.typeName=t,this.fields=e.map(El),this.options=i!=null?i:{},gd.value=this,this.messagePrototype=Object.create(null,Vl),this.refTypeCheck=new as(this),this.refJsonReader=new cs(this),this.refJsonWriter=new ls(this),this.refBinReader=new us(this),this.refBinWriter=new fs(this)}create(t){let e=Ul(this);return t!==void 0&&ds(this,e,t),e}clone(t){let e=this.create();return ds(this,e,t),e}equals(t,e){return Cl(this,t,e)}is(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!1)}isAssignable(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!0)}mergePartial(t,e){ds(this,t,e)}fromBinary(t,e){let i=Ol(e);return this.internalBinaryRead(i.readerFactory(t),t.byteLength,i)}fromJson(t,e){return this.internalJsonRead(t,Sa(e))}fromJsonString(t,e){let i=JSON.parse(t);return this.fromJson(i,e)}toJson(t,e){return this.internalJsonWrite(t,xa(e))}toJsonString(t,e){var i;let n=this.toJson(t,e);return JSON.stringify(n,null,(i=e==null?void 0:e.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(t,e){let i=Al(e);return this.internalBinaryWrite(t,i.writerFactory(),i).finish()}internalJsonRead(t,e,i){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n=i!=null?i:this.create();return this.refJsonReader.read(t,n,e),n}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Lr(t)}.`)}internalJsonWrite(t,e){return this.refJsonWriter.write(t,e)}internalBinaryWrite(t,e,i){return this.refBinWriter.write(t,e,i),e}internalBinaryRead(t,e,i,n){let s=n!=null?n:this.create();return this.refBinReader.read(t,s,i,e),s}};function Pl(r,t){var e,i,n;let s=r;return s.service=t,s.localName=(e=s.localName)!==null&&e!==void 0?e:ii(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(i=s.options)!==null&&i!==void 0?i:{},s.idempotency=(n=s.idempotency)!==null&&n!==void 0?n:void 0,s}var Pi=class{constructor(t,e,i){this.typeName=t,this.methods=e.map(n=>Pl(n,this)),this.options=i!=null?i:{}}};var H=class extends Error{constructor(t,e="UNKNOWN",i){super(t),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.meta=i!=null?i:{}}toString(){let t=[this.name+": "+this.message];this.code&&(t.push(""),t.push("Code: "+this.code)),this.serviceName&&this.methodName&&t.push("Method: "+this.serviceName+"/"+this.methodName);let e=Object.entries(this.meta);if(e.length){t.push(""),t.push("Meta:");for(let[i,n]of e)t.push(` ${i}: ${n}`)}return t.join(`
7
- `)}};function Ba(r,t){if(!t)return r;let e={};ps(r,e),ps(t,e);for(let i of Object.keys(t)){let n=t[i];switch(i){case"jsonOptions":e.jsonOptions=Ta(r.jsonOptions,e.jsonOptions);break;case"binaryOptions":e.binaryOptions=ga(r.binaryOptions,e.binaryOptions);break;case"meta":e.meta={},ps(r.meta,e.meta),ps(t.meta,e.meta);break;case"interceptors":e.interceptors=r.interceptors?r.interceptors.concat(n):n.concat();break}}return e}function ps(r,t){if(!r)return;let e=t;for(let[i,n]of Object.entries(r))n instanceof Date?e[i]=new Date(n.getTime()):Array.isArray(n)?e[i]=n.concat():e[i]=n}var Ut;(function(r){r[r.PENDING=0]="PENDING",r[r.REJECTED=1]="REJECTED",r[r.RESOLVED=2]="RESOLVED"})(Ut||(Ut={}));var jt=class{constructor(t=!0){this._state=Ut.PENDING,this._promise=new Promise((e,i)=>{this._resolve=e,this._reject=i}),t&&this._promise.catch(e=>{})}get state(){return this._state}get promise(){return this._promise}resolve(t){if(this.state!==Ut.PENDING)throw new Error(`cannot resolve ${Ut[this.state].toLowerCase()}`);this._resolve(t),this._state=Ut.RESOLVED}reject(t){if(this.state!==Ut.PENDING)throw new Error(`cannot reject ${Ut[this.state].toLowerCase()}`);this._reject(t),this._state=Ut.REJECTED}resolvePending(t){this._state===Ut.PENDING&&this.resolve(t)}rejectPending(t){this._state===Ut.PENDING&&this.reject(t)}};var ji=class{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1,this._itState={q:[]}}onNext(t){return this.addLis(t,this._lis.nxt)}onMessage(t){return this.addLis(t,this._lis.msg)}onError(t){return this.addLis(t,this._lis.err)}onComplete(t){return this.addLis(t,this._lis.cmp)}addLis(t,e){return e.push(t),()=>{let i=e.indexOf(t);i>=0&&e.splice(i,1)}}clearLis(){for(let t of Object.values(this._lis))t.splice(0,t.length)}get closed(){return this._closed!==!1}notifyNext(t,e,i){M((t?1:0)+(e?1:0)+(i?1:0)<=1,"only one emission at a time"),t&&this.notifyMessage(t),e&&this.notifyError(e),i&&this.notifyComplete()}notifyMessage(t){M(!this.closed,"stream is closed"),this.pushIt({value:t,done:!1}),this._lis.msg.forEach(e=>e(t)),this._lis.nxt.forEach(e=>e(t,void 0,!1))}notifyError(t){M(!this.closed,"stream is closed"),this._closed=t,this.pushIt(t),this._lis.err.forEach(e=>e(t)),this._lis.nxt.forEach(e=>e(void 0,t,!1)),this.clearLis()}notifyComplete(){M(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(t=>t()),this._lis.nxt.forEach(t=>t(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return this._closed===!0?this.pushIt({value:null,done:!0}):this._closed!==!1&&this.pushIt(this._closed),{next:()=>{let t=this._itState;M(t,"bad state"),M(!t.p,"iterator contract broken");let e=t.q.shift();return e?"value"in e?Promise.resolve(e):Promise.reject(e):(t.p=new jt,t.p.promise)}}}pushIt(t){let e=this._itState;if(e.p){let i=e.p;M(i.state==Ut.PENDING,"iterator contract broken"),"value"in t?i.resolve(t):i.reject(t),delete e.p}else e.q.push(t)}};var bd=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})},zi=class{constructor(t,e,i,n,s,o,a){this.method=t,this.requestHeaders=e,this.request=i,this.headers=n,this.response=s,this.status=o,this.trailers=a}then(t,e){return this.promiseFinished().then(i=>t?Promise.resolve(t(i)):i,i=>e?Promise.resolve(e(i)):Promise.reject(i))}promiseFinished(){return bd(this,void 0,void 0,function*(){let[t,e,i,n]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:t,response:e,status:i,trailers:n}})}};var _d=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})},Wi=class{constructor(t,e,i,n,s,o,a){this.method=t,this.requestHeaders=e,this.request=i,this.headers=n,this.responses=s,this.status=o,this.trailers=a}then(t,e){return this.promiseFinished().then(i=>t?Promise.resolve(t(i)):i,i=>e?Promise.resolve(e(i)):Promise.reject(i))}promiseFinished(){return _d(this,void 0,void 0,function*(){let[t,e,i]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:t,status:e,trailers:i}})}};function qt(r,t,e,i,n){var s,o,a,c;if(r=="unary"){let l=(u,d,p)=>t.unary(u,d,p);for(let u of((s=i.interceptors)!==null&&s!==void 0?s:[]).filter(d=>d.interceptUnary).reverse()){let d=l;l=(p,m,_)=>u.interceptUnary(d,p,m,_)}return l(e,n,i)}if(r=="serverStreaming"){let l=(u,d,p)=>t.serverStreaming(u,d,p);for(let u of((o=i.interceptors)!==null&&o!==void 0?o:[]).filter(d=>d.interceptServerStreaming).reverse()){let d=l;l=(p,m,_)=>u.interceptServerStreaming(d,p,m,_)}return l(e,n,i)}if(r=="clientStreaming"){let l=(u,d)=>t.clientStreaming(u,d);for(let u of((a=i.interceptors)!==null&&a!==void 0?a:[]).filter(d=>d.interceptClientStreaming).reverse()){let d=l;l=(p,m)=>u.interceptClientStreaming(d,p,m)}return l(e,i)}if(r=="duplex"){let l=(u,d)=>t.duplex(u,d);for(let u of((c=i.interceptors)!==null&&c!==void 0?c:[]).filter(d=>d.interceptDuplex).reverse()){let d=l;l=(p,m)=>u.interceptDuplex(d,p,m)}return l(e,i)}Ia(r)}var y;(function(r){r[r.OK=0]="OK",r[r.CANCELLED=1]="CANCELLED",r[r.UNKNOWN=2]="UNKNOWN",r[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.ALREADY_EXISTS=6]="ALREADY_EXISTS",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.OUT_OF_RANGE=11]="OUT_OF_RANGE",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.DATA_LOSS=15]="DATA_LOSS"})(y||(y={}));var wd=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})};function Oa(r,t,e,i,n){if(i)for(let[s,o]of Object.entries(i))if(typeof o=="string")r.append(s,o);else for(let a of o)r.append(s,a);if(r.set("Content-Type",t==="text"?"application/grpc-web-text":"application/grpc-web+proto"),t=="text"&&r.set("Accept","application/grpc-web-text"),r.set("X-Grpc-Web","1"),n&&r.set("X-User-Agent",n),typeof e=="number"){if(e<=0)throw new H(`timeout ${e} ms exceeded`,y[y.DEADLINE_EXCEEDED]);r.set("grpc-timeout",`${e}m`)}else if(e){let s=e.getTime(),o=Date.now();if(s<=o)throw new H(`deadline ${e} exceeded`,y[y.DEADLINE_EXCEEDED]);r.set("grpc-timeout",`${s-o}m`)}return r}function Da(r,t){let e=new Uint8Array(5+r.length);e[0]=Jt.DATA;for(let i=r.length,n=4;n>0;n--)e[n]=i%256,i>>>=8;return e.set(r,5),t==="binary"?e:Ci(e)}function ms(r,t,e){if(arguments.length===1){let c=r,l;try{l=c.type}catch(u){}switch(l){case"error":case"opaque":case"opaqueredirect":throw new H(`fetch response type ${c.type}`,y[y.UNKNOWN])}return ms(xd(c.headers),c.status,c.statusText)}let i=r,n=t>=200&&t<300,s=Wl(i),[o,a]=zl(i);return(o===void 0||o===y.OK)&&!n&&(o=Td(t),a=e),[o,a,s]}function Aa(r){let t=Sd(r),[e,i]=zl(t),n=Wl(t);return[e!=null?e:y.OK,i,n]}var Jt;(function(r){r[r.DATA=0]="DATA",r[r.TRAILER=128]="TRAILER"})(Jt||(Jt={}));function Fa(r,t,e){return wd(this,void 0,void 0,function*(){let i,n="",s=new Uint8Array(0),o=vd(t);if(Id(r)){let a=r.getReader();i={next:()=>a.read()}}else i=r[Symbol.asyncIterator]();for(;;){let a=yield i.next();if(a.value!==void 0){if(o==="text"){for(let l=0;l<a.value.length;l++)n+=String.fromCharCode(a.value[l]);let c=n.length-n.length%4;if(c===0)continue;s=jl(s,Ri(n.substring(0,c))),n=n.substring(c)}else s=jl(s,a.value);for(;s.length>=5&&s[0]===Jt.DATA;){let c=0;for(let l=1;l<5;l++)c=(c<<8)+s[l];if(s.length-5>=c)e(Jt.DATA,s.subarray(5,5+c)),s=s.subarray(5+c);else break}}if(a.done){if(s.length===0)break;if(s[0]!==Jt.TRAILER||s.length<5)throw new H("premature EOF",y[y.DATA_LOSS]);e(Jt.TRAILER,s.subarray(5));break}}})}var Id=r=>typeof r.getReader=="function";function jl(r,t){let e=new Uint8Array(r.length+t.length);return e.set(r),e.set(t,r.length),e}function vd(r){switch(r){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new H("missing response content type",y[y.INTERNAL]);default:throw new H("unexpected response content type: "+r,y[y.INTERNAL])}}function zl(r){let t,e,i=r["grpc-message"];if(i!==void 0){if(Array.isArray(i))return[y.INTERNAL,"invalid grpc-web message"];e=i}let n=r["grpc-status"];if(n!==void 0){if(Array.isArray(n))return[y.INTERNAL,"invalid grpc-web status"];if(t=parseInt(n,10),y[t]===void 0)return[y.INTERNAL,"invalid grpc-web status"]}return[t,e]}function Wl(r){let t={};for(let[e,i]of Object.entries(r))switch(e){case"grpc-message":case"grpc-status":case"content-type":break;default:t[e]=i}return t}function Sd(r){let t={};for(let e of String.fromCharCode.apply(String,r).trim().split(`\r
8
- `)){if(e=="")continue;let[i,...n]=e.split(":"),s=n.join(":").trim();i=i.trim();let o=t[i];typeof o=="string"?t[i]=[o,s]:Array.isArray(o)?o.push(s):t[i]=s}return t}function xd(r){let t={};return r.forEach((e,i)=>{let n=t[i];typeof n=="string"?t[i]=[n,e]:Array.isArray(n)?n.push(e):t[i]=e}),t}function Td(r){switch(r){case 200:return y.OK;case 400:return y.INVALID_ARGUMENT;case 401:return y.UNAUTHENTICATED;case 403:return y.PERMISSION_DENIED;case 404:return y.NOT_FOUND;case 409:return y.ABORTED;case 412:return y.FAILED_PRECONDITION;case 429:return y.RESOURCE_EXHAUSTED;case 499:return y.CANCELLED;case 500:return y.UNKNOWN;case 501:return y.UNIMPLEMENTED;case 503:return y.UNAVAILABLE;case 504:return y.DEADLINE_EXCEEDED;default:return y.UNKNOWN}}var $i=class{constructor(t){this.defaultOptions=t}mergeOptions(t){return Ba(this.defaultOptions,t)}makeUrl(t,e){let i=e.baseUrl;return i.endsWith("/")&&(i=i.substring(0,i.length-1)),`${i}/${t.service.typeName}/${t.name}`}clientStreaming(t){let e=new H("Client streaming is not supported by grpc-web",y[y.UNIMPLEMENTED]);throw e.methodName=t.name,e.serviceName=t.service.typeName,e}duplex(t){let e=new H("Duplex streaming is not supported by grpc-web",y[y.UNIMPLEMENTED]);throw e.methodName=t.name,e.serviceName=t.service.typeName,e}serverStreaming(t,e,i){var n,s,o,a,c;let l=i,u=(n=l.format)!==null&&n!==void 0?n:"text",d=(s=l.fetch)!==null&&s!==void 0?s:globalThis.fetch,p=(o=l.fetchInit)!==null&&o!==void 0?o:{},m=this.makeUrl(t,l),_=t.I.toBinary(e,l.binaryOptions),j=new jt,at=new ji,dt=!0,pt,Ar=new jt,Ie,Fr=new jt;return d(m,Object.assign(Object.assign({},p),{method:"POST",headers:Oa(new globalThis.Headers,u,l.timeout,l.meta),body:Da(_,u),signal:(a=i.abort)!==null&&a!==void 0?a:null})).then(q=>{let[k,_t,Pt]=ms(q);if(j.resolve(Pt),k!=null&&k!==y.OK)throw new H(_t!=null?_t:y[k],y[k],Pt);return k!=null&&(pt={code:y[k],detail:_t!=null?_t:y[k]}),q}).then(q=>{if(!q.body)throw new H("missing response body",y[y.INTERNAL]);return Fa(q.body,q.headers.get("content-type"),(k,_t)=>{switch(k){case Jt.DATA:at.notifyMessage(t.O.fromBinary(_t,l.binaryOptions)),dt=!1;break;case Jt.TRAILER:let Pt,Le;[Pt,Le,Ie]=Aa(_t),pt={code:y[Pt],detail:Le!=null?Le:y[Pt]};break}})}).then(()=>{if(!Ie&&!dt)throw new H("missing trailers",y[y.DATA_LOSS]);if(!pt)throw new H("missing status",y[y.INTERNAL]);if(pt.code!=="OK")throw new H(pt.detail,pt.code,Ie);at.notifyComplete(),Ar.resolve(pt),Fr.resolve(Ie||{})}).catch(q=>{let k;q instanceof H?k=q:q instanceof Error&&q.name==="AbortError"?k=new H(q.message,y[y.CANCELLED]):k=new H(q instanceof Error?q.message:""+q,y[y.INTERNAL]),k.methodName=t.name,k.serviceName=t.service.typeName,j.rejectPending(k),at.notifyError(k),Ar.rejectPending(k),Fr.rejectPending(k)}),new Wi(t,(c=l.meta)!==null&&c!==void 0?c:{},e,j.promise,at,Ar.promise,Fr.promise)}unary(t,e,i){var n,s,o,a,c;let l=i,u=(n=l.format)!==null&&n!==void 0?n:"text",d=(s=l.fetch)!==null&&s!==void 0?s:globalThis.fetch,p=(o=l.fetchInit)!==null&&o!==void 0?o:{},m=this.makeUrl(t,l),_=t.I.toBinary(e,l.binaryOptions),j=new jt,at,dt=new jt,pt,Ar=new jt,Ie,Fr=new jt;return d(m,Object.assign(Object.assign({},p),{method:"POST",headers:Oa(new globalThis.Headers,u,l.timeout,l.meta),body:Da(_,u),signal:(a=i.abort)!==null&&a!==void 0?a:null})).then(q=>{let[k,_t,Pt]=ms(q);if(j.resolve(Pt),k!=null&&k!==y.OK)throw new H(_t!=null?_t:y[k],y[k],Pt);return k!=null&&(pt={code:y[k],detail:_t!=null?_t:y[k]}),q}).then(q=>{if(!q.body)throw new H("missing response body",y[y.INTERNAL]);return Fa(q.body,q.headers.get("content-type"),(k,_t)=>{switch(k){case Jt.DATA:if(at)throw new H("unary call received 2nd message",y[y.DATA_LOSS]);at=t.O.fromBinary(_t,l.binaryOptions);break;case Jt.TRAILER:let Pt,Le;[Pt,Le,Ie]=Aa(_t),pt={code:y[Pt],detail:Le!=null?Le:y[Pt]};break}})}).then(()=>{if(!Ie&&at)throw new H("missing trailers",y[y.DATA_LOSS]);if(!pt)throw new H("missing status",y[y.INTERNAL]);if(!at&&pt.code==="OK")throw new H("expected error status",y[y.DATA_LOSS]);if(!at)throw new H(pt.detail,pt.code,Ie);if(dt.resolve(at),pt.code!=="OK")throw new H(pt.detail,pt.code,Ie);Ar.resolve(pt),Fr.resolve(Ie||{})}).catch(q=>{let k;q instanceof H?k=q:q instanceof Error&&q.name==="AbortError"?k=new H(q.message,y[y.CANCELLED]):k=new H(q instanceof Error?q.message:""+q,y[y.INTERNAL]),k.methodName=t.name,k.serviceName=t.service.typeName,j.rejectPending(k),dt.rejectPending(k),Ar.rejectPending(k),Fr.rejectPending(k)}),new zi(t,(c=l.meta)!==null&&c!==void 0?c:{},e,j.promise,dt.promise,Ar.promise,Fr.promise)}};var $l=({host:r,timeout:t,clientOptions:e})=>{var n;(e!=null&&e.grpcOptions||(n=e==null?void 0:e.queryOptions)!=null&&n.grpcOptions)&&console.warn(`Detected grpcClientOptions: such options are ignored in the GrpcWebFetchTransport:
1
+ "use strict";var influxdb=(()=>{var Yn=Object.defineProperty;var sd=Object.getOwnPropertyDescriptor;var od=Object.getOwnPropertyNames;var ad=Object.prototype.hasOwnProperty;var cd=(r,t,e)=>t in r?Yn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Re=(r,t)=>{for(var e in t)Yn(r,e,{get:t[e],enumerable:!0})},ld=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of od(t))!ad.call(r,n)&&n!==e&&Yn(r,n,{get:()=>t[n],enumerable:!(i=sd(t,n))||i.enumerable});return r};var ud=r=>ld(Yn({},"__esModule",{value:!0}),r);var z=(r,t,e)=>cd(r,typeof t!="symbol"?t+"":t,e);var dm={};Re(dm,{AbortError:()=>Ri,DEFAULT_ConnectionOptions:()=>sa,DEFAULT_QueryOptions:()=>Zn,DEFAULT_WriteOptions:()=>oa,GetFieldTypeMissmatchError:()=>ts,HttpError:()=>re,IllegalArgumentError:()=>ve,InfluxDBClient:()=>Kn,Log:()=>Er,PartialWriteError:()=>Mi,Point:()=>ki,PointValues:()=>dr,RequestTimedOutError:()=>ia,collectAll:()=>Ol,consoleLogger:()=>ml,convertTime:()=>ya,convertTimeToNanos:()=>ma,createTextDecoderCombiner:()=>na,currentTime:()=>vl,dateToProtocolTimestamp:()=>Sl,escape:()=>Lr,fromConnectionString:()=>aa,fromEnv:()=>ca,isNumber:()=>ni,parsePrecision:()=>fa,precisionToV2ApiString:()=>la,precisionToV3ApiString:()=>ua,setLogger:()=>pd,useProcessHrtime:()=>Il,writableDataToLineProtocol:()=>ga});function fl(r){if(typeof r!="string"||r.length===0)return!1;let t=r.toLowerCase();return t.includes("partial write of line protocol occurred")||t.includes("parsing failed for write_lp endpoint")}function fd(r){if(r==null)return 0;if(typeof r=="number"&&Number.isFinite(r))return r;throw new Error("line_number must be number")}function dd(r){if(r==null)return"";if(typeof r=="string")return r;throw new Error("original_line must be string")}function dl(r){if(r==null)return null;if(typeof r!="object"||Array.isArray(r))throw new Error("item is not an object");let t=r.error_message;if(typeof t!="string")throw new Error("error_message must be string");if(t.length===0)return null;let e=fd(r.line_number),i=dd(r.original_line);return{lineNumber:e,errorMessage:t,originalLine:i}}function hl(r){if(!Array.isArray(r))return;let t=[];try{for(let e of r){let i=dl(e);i&&t.push(i)}}catch(e){return}return t.length>0?t:void 0}function pl(r){var t;try{return(t=dl(r))!=null?t:void 0}catch(e){return}}function ul(r){let t=[];for(let e of r)e.lineNumber!==0?e.originalLine.length>0?t.push(` line ${e.lineNumber}: ${e.errorMessage} (${e.originalLine})`):t.push(` line ${e.lineNumber}: ${e.errorMessage}`):t.push(` ${e.errorMessage}`);return t}function hd(r){if(!r||typeof r!="object"||Array.isArray(r))return;let t=typeof r.message=="string"?r.message:void 0;if(t)return t;let e=typeof r.error=="string"?r.error:void 0,i=r.data;if(e&&fl(e)){let n=hl(i);if(n){let o=ul(n);return`${e}:
2
+ ${o.join(`
3
+ `)}`}if(Array.isArray(i)){let o=[];for(let a of i){if(a==null)continue;let c=JSON.stringify(a);c&&c.toLowerCase()!=="null"&&o.push(` ${c}`)}return o.length?`${e}:
4
+ ${o.join(`
5
+ `)}`:e}let s=pl(i);return s?`${e}:
6
+ ${ul([s]).join(`
7
+ `)}`:e}if(e)return e}var ve=class r extends Error{constructor(t){super(t),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},re=class r extends Error{constructor(e,i,n,s,o,a){var c;super();this.statusCode=e;this.statusMessage=i;this.body=n;this.contentType=s;this.headers=o;z(this,"code");z(this,"json");if(Object.setPrototypeOf(this,r.prototype),a)this.message=a;else if(n&&(s!=null&&s.startsWith("application/json")||!s))try{this.json=JSON.parse(n),typeof((c=this.json)==null?void 0:c.code)=="string"&&(this.code=this.json.code);let l=hd(this.json);l&&(this.message=l)}catch(l){}this.message||(this.message=`${e} ${i} : ${n}`),this.name="HttpError"}statusCode;statusMessage;body;contentType;headers},Mi=class r extends re{constructor(e,i,n,s,o,a,c){super(e,i,n,s,o);this.lineErrors=c;this.message=a,this.name="PartialWriteError",Object.setPrototypeOf(this,r.prototype)}lineErrors;static fromHttpError(e){let i=e.json;if(!i||typeof i!="object"||Array.isArray(i))return;let n=i.error;if(!fl(n))return;let s=i.data,o=hl(s);if(o)return new r(e.statusCode,e.statusMessage,e.body,e.contentType,e.headers,e.message,o);let a=pl(s);if(a)return new r(e.statusCode,e.statusMessage,e.body,e.contentType,e.headers,e.message,[a])}},ia=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},Ri=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function na(){let r=new TextDecoder("utf-8");return{concat(t,e){let i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i},copy(t,e,i){let n=new Uint8Array(i-e);return n.set(t.subarray(e,i)),n},toUtf8String(t,e,i){return r.decode(t.subarray(e,i))}}}var sa={timeout:void 0,writeTimeout:1e4,queryTimeout:6e4},oa={precision:"ns",gzipThreshold:1e3,noSync:!1,acceptPartial:!0,useV2Api:!0},Zn={type:"sql"};function Se(r){return r.writeOptions||(r.writeOptions={}),r.writeOptions}function aa(r){if(!r)throw Error("Connection string not set!");let t=new URL(r.trim(),"http://localhost"),e={host:r.indexOf("://")>0?t.origin+t.pathname:t.pathname};return t.searchParams.has("token")&&(e.token=t.searchParams.get("token")),t.searchParams.has("authScheme")&&(e.authScheme=t.searchParams.get("authScheme")),t.searchParams.has("database")&&(e.database=t.searchParams.get("database")),t.searchParams.has("timeout")&&(e.timeout=parseInt(t.searchParams.get("timeout"))),t.searchParams.has("precision")&&(Se(e).precision=fa(t.searchParams.get("precision"))),t.searchParams.has("gzipThreshold")&&(Se(e).gzipThreshold=parseInt(t.searchParams.get("gzipThreshold"))),t.searchParams.has("writeNoSync")&&(Se(e).noSync=ri(t.searchParams.get("writeNoSync"))),t.searchParams.has("writeAcceptPartial")&&(Se(e).acceptPartial=ri(t.searchParams.get("writeAcceptPartial"))),t.searchParams.has("writeUseV2Api")&&(Se(e).useV2Api=ri(t.searchParams.get("writeUseV2Api"))),e}function ca(){if(!process.env.INFLUX_HOST)throw Error("INFLUX_HOST variable not set!");if(!process.env.INFLUX_TOKEN)throw Error("INFLUX_TOKEN variable not set!");let r={host:process.env.INFLUX_HOST.trim()};if(process.env.INFLUX_TOKEN&&(r.token=process.env.INFLUX_TOKEN.trim()),process.env.INFLUX_AUTH_SCHEME&&(r.authScheme=process.env.INFLUX_AUTH_SCHEME.trim()),process.env.INFLUX_DATABASE&&(r.database=process.env.INFLUX_DATABASE.trim()),process.env.INFLUX_TIMEOUT&&(r.timeout=parseInt(process.env.INFLUX_TIMEOUT.trim())),process.env.INFLUX_PRECISION&&(Se(r).precision=fa(process.env.INFLUX_PRECISION)),process.env.INFLUX_GZIP_THRESHOLD&&(Se(r).gzipThreshold=parseInt(process.env.INFLUX_GZIP_THRESHOLD)),process.env.INFLUX_WRITE_NO_SYNC&&(Se(r).noSync=ri(process.env.INFLUX_WRITE_NO_SYNC)),process.env.INFLUX_WRITE_ACCEPT_PARTIAL&&(Se(r).acceptPartial=ri(process.env.INFLUX_WRITE_ACCEPT_PARTIAL)),process.env.INFLUX_WRITE_USE_V2_API&&(Se(r).useV2Api=ri(process.env.INFLUX_WRITE_USE_V2_API)),process.env.INFLUX_GRPC_OPTIONS){let t=process.env.INFLUX_GRPC_OPTIONS.split(",");r.grpcOptions||(r.grpcOptions={});for(let e of t){let i=e.split("=");if(i.length!=2)continue;let n=parseInt(i[1]);Number.isNaN(n)&&(n=parseFloat(i[1]),Number.isNaN(n)&&(n=i[1])),r.grpcOptions[i[0]]=n}}return r}function ri(r){return["true","1","t","y","yes"].includes(r.trim().toLowerCase())}function la(r){switch(r){case"ns":case"us":case"ms":case"s":return r;default:throw Error(`Unsupported precision '${r}'`)}}function ua(r){switch(r){case"ns":return"nanosecond";case"us":return"microsecond";case"ms":return"millisecond";case"s":return"second";default:throw Error(`Unsupported precision '${r}'`)}}function fa(r){switch(r.trim().toLowerCase()){case"ns":case"nanosecond":return"ns";case"us":case"microsecond":return"us";case"ms":case"millisecond":return"ms";case"s":case"second":return"s";default:throw Error(`Unsupported precision '${r}'`)}}var ml={error(r,t){console.error(`ERROR: ${r}`,t||"")},warn(r,t){console.warn(`WARN: ${r}`,t||"")}},Qn=ml,Er={error(r,t){Qn.error(r,t)},warn(r,t){Qn.warn(r,t)}};function pd(r){let t=Qn;return Qn=r,t}function da(r,t){return function(e){let i="",n=0,s=0;for(;s<e.length;){let o=r.indexOf(e[s]);o>=0&&(i+=e.substring(n,s),i+=t[o],n=s+1),s++}return n==0?e:(n<e.length&&(i+=e.substring(n,e.length)),i)}}function md(r,t){let e=da(r,t);return i=>`"${e(i)}"`}var Lr={measurement:da(`,
8
+ \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:md('"\\',['\\"',"\\\\"]),tag:da(`, =
9
+ \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var wl="000000000";function Il(r){return!1}Il(!0);var yl=Date.now(),ha=0;function pa(){{let r=Date.now();r!==yl?(yl=r,ha=0):ha++;let t=String(ha);return String(r)+wl.substr(0,6-t.length)+t}}function gl(){return String(Date.now())+wl.substr(0,3)}function bl(){return String(Date.now())}function _l(){return String(Math.floor(Date.now()/1e3))}var vl={s:_l,ms:bl,us:gl,ns:pa,seconds:_l,millis:bl,micros:gl,nanos:pa},Sl={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function ma(r){return r===void 0?pa():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var ya=(r,t="ns")=>r===void 0?vl[t]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?Sl[t](r):String(typeof r=="number"?Math.floor(r):r);var ii=r=>{throw r},xl=r=>r!==void 0,Tl=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(t=>t==="0")),Bl=r=>{let t=new Uint8Array(4);return t[0]=r>>0,t[1]=r>>8,t[2]=r>>16,t[3]=r>>24,t},Ol=async r=>{let t=[];for await(let e of r)t.push(e);return t},ni=r=>r===null||typeof r=="string"&&(r===""||r.indexOf(" ")!==-1)?!1:r!==""&&!isNaN(Number(r==null?void 0:r.toString())),Al=r=>ni(r)?typeof r=="string"?Number(r)>=0:typeof r=="number"&&r>=0:!1;var ga=(r,t,e,i)=>{let n=Tl(r)&&typeof r!="string"?Array.from(r):[r];return n.length===0?[]:typeof n[0]=="string"?n:n.map(o=>o.getTimestamp()instanceof Date||o.getTimestamp()===void 0?o.toLineProtocol(i,t,e):o.toLineProtocol(void 0,t,e)).filter(xl)};var yd=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,ts=class r extends Error{constructor(t,e,i){super(`field ${t} of type ${i} doesn't match expected type ${e}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},dr=class r{constructor(){z(this,"_name");z(this,"_time");z(this,"_tags",{});z(this,"_fields",{})}getMeasurement(){return this._name}setMeasurement(t){return this._name=t,this}getTimestamp(){return this._time}setTimestamp(t){return this._time=t,this}getTag(t){return this._tags[t]}setTag(t,e){return this._tags[t]=e,this}removeTag(t){return delete this._tags[t],this}getTagNames(){return Object.keys(this._tags)}getFloatField(t){return this.getField(t,"float")}setFloatField(t,e){let i;if(typeof e=="number"?i=e:i=parseFloat(e),!isFinite(i))throw new Error(`invalid float value for field '${t}': '${e}'!`);return this._fields[t]=["float",i],this}getIntegerField(t){return this.getField(t,"integer")}setIntegerField(t,e){let i;if(typeof e=="number"?i=e:i=parseInt(String(e)),isNaN(i)||i<=-9223372036854776e3||i>=9223372036854776e3)throw new Error(`invalid integer value for field '${t}': '${e}'!`);return this._fields[t]=["integer",Math.floor(i)],this}getUintegerField(t){return this.getField(t,"uinteger")}setUintegerField(t,e){if(typeof e=="number"){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${t}' out of range: ${e}`);this._fields[t]=["uinteger",Math.floor(e)]}else{let i=String(e);for(let n=0;n<i.length;n++){let s=i.charCodeAt(n);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${n}: ${e}`)}if(i.length>20||i.length===20&&i.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${t}' out of range: ${i}`);this._fields[t]=["uinteger",+i]}return this}getStringField(t){return this.getField(t,"string")}setStringField(t,e){return e!=null&&(typeof e!="string"&&(e=String(e)),this._fields[t]=["string",e]),this}getBooleanField(t){return this.getField(t,"boolean")}setBooleanField(t,e){return this._fields[t]=["boolean",!!e],this}getField(t,e){let i=this._fields[t];if(!i)return;let[n,s]=i;if(e!==void 0&&e!==n)throw new ts(t,e,n);return s}getFieldType(t){let e=this._fields[t];if(e)return e[0]}setField(t,e,i){switch(i!=null?i:yd(e)){case"string":return this.setStringField(t,e);case"boolean":return this.setBooleanField(t,e);case"float":return this.setFloatField(t,e);case"integer":return this.setIntegerField(t,e);case"uinteger":return this.setUintegerField(t,e);case void 0:return this;default:throw new Error(`invalid field type for field '${t}': type -> ${i}, value -> ${e}!`)}}setFields(t){for(let[e,i]of Object.entries(t))this.setField(e,i);return this}removeField(t){return delete this._fields[t],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let t=new r;return t._name=this._name,t._time=this._time,t._tags=Object.fromEntries(Object.entries(this._tags)),t._fields=Object.fromEntries(Object.entries(this._fields).map(e=>[...e])),t}asPoint(t){return ki.fromValues(t?this.setMeasurement(t):this)}};var gd=(r,t)=>{switch(r){case"string":return Lr.quoted(t);case"boolean":return t?"T":"F";case"float":return`${t}`;case"integer":return`${t}i`;case"uinteger":return`${t}u`}},bd=(r,t)=>{if(!t)return[];let e=new Set(r);return Object.keys(t).filter(i=>!e.has(i)).sort()},_d=(r,t)=>{if(!t||t.length===0)return r;let e=new Set(r),i=[],n=new Set;for(let o of t)!o||n.has(o)||!e.has(o)||(i.push(o),n.add(o),e.delete(o));let s=Array.from(e).sort();return i.concat(s)},ki=class r{constructor(t){z(this,"_values");t instanceof dr?this._values=t:this._values=new dr,typeof t=="string"&&this._values.setMeasurement(t)}static measurement(t){return new r(t)}static fromValues(t){if(!t.getMeasurement()||t.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(t)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(t){return t!==""&&this._values.setMeasurement(t),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(t){return this._values.setTimestamp(t),this}getTag(t){return this._values.getTag(t)}setTag(t,e){return this._values.setTag(t,e),this}removeTag(t){return this._values.removeTag(t),this}getTagNames(){return this._values.getTagNames()}getFloatField(t){return this._values.getFloatField(t)}setFloatField(t,e){return this._values.setFloatField(t,e),this}getIntegerField(t){return this._values.getIntegerField(t)}setIntegerField(t,e){return this._values.setIntegerField(t,e),this}getUintegerField(t){return this._values.getUintegerField(t)}setUintegerField(t,e){return this._values.setUintegerField(t,e),this}getStringField(t){return this._values.getStringField(t)}setStringField(t,e){return this._values.setStringField(t,e),this}getBooleanField(t){return this._values.getBooleanField(t)}setBooleanField(t,e){return this._values.setBooleanField(t,e),this}getField(t,e){return this._values.getField(t,e)}getFieldType(t){return this._values.getFieldType(t)}setField(t,e,i){return this._values.setField(t,e,i),this}setFields(t){return this._values.setFields(t),this}removeField(t){return this._values.removeField(t),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(t,e,i){if(!this._values.getMeasurement())return;let n="";if(this._values.getFieldNames().sort().forEach(u=>{if(u){let d=this._values.getFieldType(u),p=this._values.getField(u);if(d===void 0||p===void 0)return;let m=gd(d,p);n.length>0&&(n+=","),n+=`${Lr.tag(u)}=${m}`}}),n.length===0)return;let s="",o=this._values.getTagNames().sort(),a=bd(o,e);_d(a.concat(o),i).forEach(u=>{if(u){let d=this._values.getTag(u),p=d!==void 0?d:e==null?void 0:e[u];p&&(s+=",",s+=`${Lr.tag(u)}=${Lr.tag(p)}`)}});let l=this._values.getTimestamp();return t?typeof t=="string"?l=ya(l,t):l=t(l):l=ma(l),`${Lr.measurement(this.getMeasurement())}${s} ${n}${l!==void 0?` ${l}`:""}`}toString(){let t=this.toLineProtocol(void 0);return t||`invalid point: ${JSON.stringify(this,void 0)}`}};function ba(r={}){let t=0,e={next:i=>{if(t===0&&r.next&&i!==null&&i!==void 0)return r.next(i)},error:i=>{t===0&&(t=1,r.error&&r.error(i))},complete:()=>{t===0&&(t=2,r.complete&&r.complete())},responseStarted:(i,n)=>{r.responseStarted&&r.responseStarted(i,n)}};return r.useCancellable&&(e.useCancellable=r.useCancellable.bind(r)),r.useResume&&(e.useResume=r.useResume.bind(r)),e}function es(r){let t={};return r.headers.forEach((e,i)=>{let n=t[i];n===void 0?t[i]=e:Array.isArray(n)?n.push(e):t[i]=[n,e]}),t}var Ci=class{constructor(t){this._connectionOptions=t;z(this,"chunkCombiner",na());z(this,"_defaultHeaders");z(this,"_url");z(this,"requestDecorator",function(){});var e;if(this._defaultHeaders={"content-type":"application/json; charset=utf-8",...t.headers},this._connectionOptions.token){let i=(e=this._connectionOptions.authScheme)!=null?e:"Token";this._defaultHeaders.Authorization=`${i} ${this._connectionOptions.token}`}this._url=String(this._connectionOptions.host),this._url.endsWith("/")&&(this._url=this._url.substring(0,this._url.length-1)),this._url.endsWith("/api/v2")&&(this._url=this._url.substring(0,this._url.length-7),Er.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this._url} !`))}_connectionOptions;send(t,e,i,n){let s=ba(n),o=!1,a=i.signal,c,l=()=>{},u=l;if(n&&n.useCancellable){let d=new AbortController;a||(a=d.signal,i={...i,signal:a}),a.addEventListener("abort",()=>{u()}),n.useCancellable({cancel(){o=!0,d.abort()},isCancelled(){return o||a.aborted}})}this._fetch(t,e,i).then(async d=>{if(n!=null&&n.responseStarted&&s.responseStarted(es(d),d.status),await this._throwOnErrorResponse(d),d.body){let p=d.body.getReader(),m;do{if(c&&await c,o)break;if(m=await p.read(),s.next(m.value)===!1){let _=s.useResume;if(!_){let C="Unable to pause, useResume is not configured!";return await p.cancel(C),Promise.reject(new Error(C))}c=new Promise(C=>{u=()=>{C(),c=void 0,u=l},_(u)})}}while(!m.done)}else if(d.arrayBuffer){let p=await d.arrayBuffer();s.next(new Uint8Array(p))}else{let p=await d.text();s.next(new TextEncoder().encode(p))}}).catch(d=>{o||s.error(d)}).finally(()=>s.complete())}async _throwOnErrorResponse(t){if(t.status>=300){let e="";try{if(e=await t.text(),!e){let i=t.headers.get("x-influxdb-error");i&&(e=i)}}catch(i){throw Er.warn("Unable to receive error body",i),new re(t.status,t.statusText,void 0,t.headers.get("content-type"),es(t))}throw new re(t.status,t.statusText,e,t.headers.get("content-type"),es(t))}}async*iterate(t,e,i){var s;let n=await this._fetch(t,e,i);if(await this._throwOnErrorResponse(n),n.body){let o=n.body.getReader();for(;;){let{value:a,done:c}=await o.read();if(c)break;if((s=i.signal)!=null&&s.aborted)throw await n.body.cancel(),new Ri;yield a}}else if(n.arrayBuffer){let o=await n.arrayBuffer();yield new Uint8Array(o)}else{let o=await n.text();yield new TextEncoder().encode(o)}}async request(t,e,i,n){var l,u;let s=await this._fetch(t,e,i),{headers:o}=s,a=o.get("content-type")||"";n&&n(es(s),s.status),await this._throwOnErrorResponse(s);let c=(u=(l=i.headers)==null?void 0:l.accept)!=null?u:a;if(c.includes("json"))return await s.json();if(c.includes("text")||c.startsWith("application/csv"))return await s.text()}_fetch(t,e,i){let{method:n,headers:s,...o}=i,a=`${this._url}${t}`,c={method:n,body:n==="GET"||n==="HEAD"?void 0:typeof e=="string"?e:JSON.stringify(e),headers:{...this._defaultHeaders,...s},credentials:"omit",...this._connectionOptions.transportOptions,...o};return this.requestDecorator(c,i,a),fetch(a,c)}};function Ur(r){let t=typeof r;if(t=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return t}function _a(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),rs=[];for(let r=0;r<ke.length;r++)rs[ke[r].charCodeAt(0)]=r;rs[45]=ke.indexOf("+");rs[95]=ke.indexOf("/");function Pi(r){let t=r.length*3/4;r[r.length-2]=="="?t-=2:r[r.length-1]=="="&&(t-=1);let e=new Uint8Array(t),i=0,n=0,s,o=0;for(let a=0;a<r.length;a++){if(s=rs[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":n=0;case`
10
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(n){case 0:o=s,n=1;break;case 1:e[i++]=o<<2|(s&48)>>4,o=s,n=2;break;case 2:e[i++]=(o&15)<<4|(s&60)>>2,o=s,n=3;break;case 3:e[i++]=(o&3)<<6|s,n=0;break}}if(n==1)throw Error("invalid base64 string.");return e.subarray(0,i)}function Vi(r){let t="",e=0,i,n=0;for(let s=0;s<r.length;s++)switch(i=r[s],e){case 0:t+=ke[i>>2],n=(i&3)<<4,e=1;break;case 1:t+=ke[n|i>>4],n=(i&15)<<2,e=2;break;case 2:t+=ke[n|i>>6],t+=ke[i&63],e=0;break}return e&&(t+=ke[n],t+="=",e==1&&(t+="=")),t}var Mr;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(e,i,n,s,o)=>{(t(i)?i[r.symbol]:i[r.symbol]=[]).push({no:n,wireType:s,data:o})},r.onWrite=(e,i,n)=>{for(let{no:s,wireType:o,data:a}of r.list(i))n.tag(s,o).raw(a)},r.list=(e,i)=>{if(t(e)){let n=e[r.symbol];return i?n.filter(s=>s.no==i):n}return[]},r.last=(e,i)=>r.list(e,i).slice(-1)[0];let t=e=>e&&Array.isArray(e[r.symbol])})(Mr||(Mr={}));function wa(r,t){return Object.assign(Object.assign({},r),t)}var ot;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(ot||(ot={}));function Dl(){let r=0,t=0;for(let i=0;i<28;i+=7){let n=this.buf[this.pos++];if(r|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}let e=this.buf[this.pos++];if(r|=(e&15)<<28,t=(e&112)>>4,(e&128)==0)return this.assertBounds(),[r,t];for(let i=3;i<=31;i+=7){let n=this.buf[this.pos++];if(t|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}throw new Error("invalid varint")}function ns(r,t,e){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&t==0),c=(a?o|128:o)&255;if(e.push(c),!a)return}let i=r>>>28&15|(t&7)<<4,n=t>>3!=0;if(e.push((n?i|128:i)&255),!!n){for(let s=3;s<31;s=s+7){let o=t>>>s,a=!!(o>>>7),c=(a?o|128:o)&255;if(e.push(c),!a)return}e.push(t>>>31&1)}}var is=65536*65536;function Ia(r){let t=r[0]=="-";t&&(r=r.slice(1));let e=1e6,i=0,n=0;function s(o,a){let c=Number(r.slice(o,a));n*=e,i=i*e+c,i>=is&&(n=n+(i/is|0),i=i%is)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[t,i,n]}function ss(r,t){if(t>>>0<=2097151)return""+(is*t+(r>>>0));let e=r&16777215,i=(r>>>24|t<<8)>>>0&16777215,n=t>>16&65535,s=e+i*6777216+n*6710656,o=i+n*8147497,a=n*2,c=1e7;s>=c&&(o+=Math.floor(s/c),s%=c),o>=c&&(a+=Math.floor(o/c),o%=c);function l(u,d){let p=u?String(u):"";return d?"0000000".slice(p.length)+p:p}return l(a,0)+l(o,a)+l(s,1)}function va(r,t){if(r>=0){for(;r>127;)t.push(r&127|128),r=r>>>7;t.push(r)}else{for(let e=0;e<9;e++)t.push(r&127|128),r=r>>7;t.push(1)}}function Fl(){let r=this.buf[this.pos++],t=r&127;if((r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<7,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<14,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<21,(r&128)==0)return this.assertBounds(),t;r=this.buf[this.pos++],t|=(r&15)<<28;for(let e=5;(r&128)!==0&&e<10;e++)r=this.buf[this.pos++];if((r&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var tt;function wd(){let r=new DataView(new ArrayBuffer(8));tt=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}wd();function Nl(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var El=/^-?[0-9]+$/,as=4294967296,os=2147483648,cs=class{constructor(t,e){this.lo=t|0,this.hi=e|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let t=this.hi*as+(this.lo>>>0);if(!Number.isSafeInteger(t))throw new Error("cannot convert to safe number");return t}},ht=class r extends cs{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.UMIN)throw new Error("signed value for ulong");if(t>tt.UMAX)throw new Error("ulong too large");return tt.V.setBigUint64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!El.test(t))throw new Error("string is no integer");let[e,i,n]=Ia(t);if(e)throw new Error("signed value for ulong");return new r(i,n);case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");if(t<0)throw new Error("signed value for ulong");return new r(t,t/as)}throw new Error("unknown value "+typeof t)}toString(){return tt?this.toBigInt().toString():ss(this.lo,this.hi)}toBigInt(){return Nl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigUint64(0,!0)}};ht.ZERO=new ht(0,0);var K=class r extends cs{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.MIN)throw new Error("signed long too small");if(t>tt.MAX)throw new Error("signed long too large");return tt.V.setBigInt64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!El.test(t))throw new Error("string is no integer");let[e,i,n]=Ia(t);if(e){if(n>os||n==os&&i!=0)throw new Error("signed long too small")}else if(n>=os)throw new Error("signed long too large");let s=new r(i,n);return e?s.negate():s;case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");return t>0?new r(t,t/as):new r(-t,-t/as).negate()}throw new Error("unknown value "+typeof t)}isNegative(){return(this.hi&os)!==0}negate(){let t=~this.hi,e=this.lo;return e?e=~e+1:t+=1,new r(e,t)}toString(){if(tt)return this.toBigInt().toString();if(this.isNegative()){let t=this.negate();return"-"+ss(t.lo,t.hi)}return ss(this.lo,this.hi)}toBigInt(){return Nl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigInt64(0,!0)}};K.ZERO=new K(0,0);var Ll={readUnknownField:!0,readerFactory:r=>new Sa(r)};function Ul(r){return r?Object.assign(Object.assign({},Ll),r):Ll}var Sa=class{constructor(t,e){this.varint64=Dl,this.uint32=Fl,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e!=null?e:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let t=this.uint32(),e=t>>>3,i=t&7;if(e<=0||i<0||i>5)throw new Error("illegal tag: field no "+e+" wire type "+i);return[e,i]}skip(t){let e=this.pos;switch(t){case ot.Varint:for(;this.buf[this.pos++]&128;);break;case ot.Bit64:this.pos+=4;case ot.Bit32:this.pos+=4;break;case ot.LengthDelimited:let i=this.uint32();this.pos+=i;break;case ot.StartGroup:let n;for(;(n=this.tag()[1])!==ot.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(e,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return new K(...this.varint64())}uint64(){return new ht(...this.varint64())}sint64(){let[t,e]=this.varint64(),i=-(t&1);return t=(t>>>1|(e&1)<<31)^i,e=e>>>1^i,new K(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new ht(this.sfixed32(),this.sfixed32())}sfixed64(){return new K(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}};function M(r,t){if(!r)throw new Error(t)}function xa(r,t){throw new Error(t!=null?t:"Unexpected object: "+r)}var Id=34028234663852886e22,vd=-34028234663852886e22,Sd=4294967295,xd=2147483647,Td=-2147483648;function Ce(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>xd||r<Td)throw new Error("invalid int 32: "+r)}function hr(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>Sd||r<0)throw new Error("invalid uint 32: "+r)}function Rr(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Id||r<vd))throw new Error("invalid float 32: "+r)}var Ml={writeUnknownFields:!0,writerFactory:()=>new Ta};function Rl(r){return r?Object.assign(Object.assign({},Ml),r):Ml}var Ta=class{constructor(t){this.stack=[],this.textEncoder=t!=null?t:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let t=0;for(let n=0;n<this.chunks.length;n++)t+=this.chunks[n].length;let e=new Uint8Array(t),i=0;for(let n=0;n<this.chunks.length;n++)e.set(this.chunks[n],i),i+=this.chunks[n].length;return this.chunks=[],e}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),e=this.stack.pop();if(!e)throw new Error("invalid state, fork stack empty");return this.chunks=e.chunks,this.buf=e.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(hr(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Ce(t),va(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){Rr(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){hr(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Ce(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Ce(t),t=(t<<1^t>>31)>>>0,va(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=K.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=ht.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}int64(t){let e=K.from(t);return ns(e.lo,e.hi,this.buf),this}sint64(t){let e=K.from(t),i=e.hi>>31,n=e.lo<<1^i,s=(e.hi<<1|e.lo>>>31)^i;return ns(n,s,this.buf),this}uint64(t){let e=ht.from(t);return ns(e.lo,e.hi,this.buf),this}};var kl={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Cl={ignoreUnknownFields:!1};function Ba(r){return r?Object.assign(Object.assign({},Cl),r):Cl}function Oa(r){return r?Object.assign(Object.assign({},kl),r):kl}function Aa(r,t){var e,i;let n=Object.assign(Object.assign({},r),t);return n.typeRegistry=[...(e=r==null?void 0:r.typeRegistry)!==null&&e!==void 0?e:[],...(i=t==null?void 0:t.typeRegistry)!==null&&i!==void 0?i:[]],n}var ls=Symbol.for("protobuf-ts/message-type");function si(r){let t=!1,e=[];for(let i=0;i<r.length;i++){let n=r.charAt(i);n=="_"?t=!0:/\d/.test(n)?(e.push(n),t=!0):t?(e.push(n.toUpperCase()),t=!1):i==0?e.push(n.toLowerCase()):e.push(n)}return e.join("")}var h;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(h||(h={}));var At;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(At||(At={}));var ji;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(ji||(ji={}));function Pl(r){var t,e,i,n;return r.localName=(t=r.localName)!==null&&t!==void 0?t:si(r.name),r.jsonName=(e=r.jsonName)!==null&&e!==void 0?e:si(r.name),r.repeat=(i=r.repeat)!==null&&i!==void 0?i:ji.NO,r.opt=(n=r.opt)!==null&&n!==void 0?n:r.repeat||r.oneof?!1:r.kind=="message",r}function Vl(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var us=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}prepare(){if(this.data)return;let t=[],e=[],i=[];for(let n of this.fields)if(n.oneof)i.includes(n.oneof)||(i.push(n.oneof),t.push(n.oneof),e.push(n.oneof));else switch(e.push(n.localName),n.kind){case"scalar":case"enum":(!n.opt||n.repeat)&&t.push(n.localName);break;case"message":n.repeat&&t.push(n.localName);break;case"map":t.push(n.localName);break}this.data={req:t,known:e,oneofs:Object.values(i)}}is(t,e,i=!1){if(e<0)return!0;if(t==null||typeof t!="object")return!1;this.prepare();let n=Object.keys(t),s=this.data;if(n.length<s.req.length||s.req.some(o=>!n.includes(o))||!i&&n.some(o=>!s.known.includes(o)))return!1;if(e<1)return!0;for(let o of s.oneofs){let a=t[o];if(!Vl(a))return!1;if(a.oneofKind===void 0)continue;let c=this.fields.find(l=>l.localName===a.oneofKind);if(!c||!this.field(a[a.oneofKind],c,i,e))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(t[o.localName],o,i,e))return!1;return!0}field(t,e,i,n){let s=e.repeat;switch(e.kind){case"scalar":return t===void 0?e.opt:s?this.scalars(t,e.T,n,e.L):this.scalar(t,e.T,e.L);case"enum":return t===void 0?e.opt:s?this.scalars(t,h.INT32,n):this.scalar(t,h.INT32);case"message":return t===void 0?!0:s?this.messages(t,e.T(),i,n):this.message(t,e.T(),i,n);case"map":if(typeof t!="object"||t===null)return!1;if(n<2)return!0;if(!this.mapKeys(t,e.K,n))return!1;switch(e.V.kind){case"scalar":return this.scalars(Object.values(t),e.V.T,n,e.V.L);case"enum":return this.scalars(Object.values(t),h.INT32,n);case"message":return this.messages(Object.values(t),e.V.T(),i,n)}break}return!0}message(t,e,i,n){return i?e.isAssignable(t,n):e.is(t,n)}messages(t,e,i,n){if(!Array.isArray(t))return!1;if(n<2)return!0;if(i){for(let s=0;s<t.length&&s<n;s++)if(!e.isAssignable(t[s],n-1))return!1}else for(let s=0;s<t.length&&s<n;s++)if(!e.is(t[s],n-1))return!1;return!0}scalar(t,e,i){let n=typeof t;switch(e){case h.UINT64:case h.FIXED64:case h.INT64:case h.SFIXED64:case h.SINT64:switch(i){case At.BIGINT:return n=="bigint";case At.NUMBER:return n=="number"&&!isNaN(t);default:return n=="string"}case h.BOOL:return n=="boolean";case h.STRING:return n=="string";case h.BYTES:return t instanceof Uint8Array;case h.DOUBLE:case h.FLOAT:return n=="number"&&!isNaN(t);default:return n=="number"&&Number.isInteger(t)}}scalars(t,e,i,n){if(!Array.isArray(t))return!1;if(i<2)return!0;if(Array.isArray(t)){for(let s=0;s<t.length&&s<i;s++)if(!this.scalar(t[s],e,n))return!1}return!0}mapKeys(t,e,i){let n=Object.keys(t);switch(e){case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:return this.scalars(n.slice(0,i).map(s=>parseInt(s)),e,i);case h.BOOL:return this.scalars(n.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),e,i);default:return this.scalars(n,e,i,At.STRING)}}};function Lt(r,t){switch(t){case At.BIGINT:return r.toBigInt();case At.NUMBER:return r.toNumber();default:return r.toString()}}var fs=class{constructor(t){this.info=t}prepare(){var t;if(this.fMap===void 0){this.fMap={};let e=(t=this.info.fields)!==null&&t!==void 0?t:[];for(let i of e)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(t,e,i){if(!t){let n=Ur(i);throw(n=="number"||n=="boolean")&&(n=i.toString()),new Error(`Cannot parse JSON ${n} for ${this.info.typeName}#${e}`)}}read(t,e,i){this.prepare();let n=[];for(let[s,o]of Object.entries(t)){let a=this.fMap[s];if(!a){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let c=a.localName,l;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(n.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);n.push(a.oneof),l=e[a.oneof]={oneofKind:c}}else l=e;if(a.kind=="map"){if(o===null)continue;this.assert(_a(o),a.name,o);let u=l[c];for(let[d,p]of Object.entries(o)){this.assert(p!==null,a.name+" map value",null);let m;switch(a.V.kind){case"message":m=a.V.T().internalJsonRead(p,i);break;case"enum":if(m=this.enum(a.V.T(),p,a.name,i.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.V.T,a.V.L,a.name);break}this.assert(m!==void 0,a.name+" map value",p);let _=d;a.K==h.BOOL&&(_=_=="true"?!0:_=="false"?!1:_),_=this.scalar(_,a.K,At.STRING,a.name).toString(),u[_]=m}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let u=l[c];for(let d of o){this.assert(d!==null,a.name,null);let p;switch(a.kind){case"message":p=a.T().internalJsonRead(d,i);break;case"enum":if(p=this.enum(a.T(),d,a.name,i.ignoreUnknownFields),p===!1)continue;break;case"scalar":p=this.scalar(d,a.T,a.L,a.name);break}this.assert(p!==void 0,a.name,o),u.push(p)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}l[c]=a.T().internalJsonRead(o,i,l[c]);break;case"enum":if(o===null)continue;let u=this.enum(a.T(),o,a.name,i.ignoreUnknownFields);if(u===!1)continue;l[c]=u;break;case"scalar":if(o===null)continue;l[c]=this.scalar(o,a.T,a.L,a.name);break}}}enum(t,e,i,n){if(t[0]=="google.protobuf.NullValue"&&M(e===null||e==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} only accepts null.`),e===null)return 0;switch(typeof e){case"number":return M(Number.isInteger(e),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${e}.`),e;case"string":let s=e;t[2]&&e.substring(0,t[2].length)===t[2]&&(s=e.substring(t[2].length));let o=t[1][s];return typeof o=="undefined"&&n?!1:(M(typeof o=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} has no value for "${e}".`),o)}M(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof e}".`)}scalar(t,e,i,n){let s;try{switch(e){case h.DOUBLE:case h.FLOAT:if(t===null)return 0;if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""){s="empty string";break}if(typeof t=="string"&&t.trim().length!==t.length){s="extra whitespace";break}if(typeof t!="string"&&typeof t!="number")break;let o=Number(t);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return e==h.FLOAT&&Rr(o),o;case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:if(t===null)return 0;let a;if(typeof t=="number"?a=t:t===""?s="empty string":typeof t=="string"&&(t.trim().length!==t.length?s="extra whitespace":a=Number(t)),a===void 0)break;return e==h.UINT32?hr(a):Ce(a),a;case h.INT64:case h.SFIXED64:case h.SINT64:if(t===null)return Lt(K.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Lt(K.from(t),i);case h.FIXED64:case h.UINT64:if(t===null)return Lt(ht.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Lt(ht.from(t),i);case h.BOOL:if(t===null)return!1;if(typeof t!="boolean")break;return t;case h.STRING:if(t===null)return"";if(typeof t!="string"){s="extra whitespace";break}try{encodeURIComponent(t)}catch(c){c="invalid UTF8";break}return t;case h.BYTES:if(t===null||t==="")return new Uint8Array(0);if(typeof t!="string")break;return Pi(t)}}catch(o){s=o.message}this.assert(!1,n+(s?" - "+s:""),t)}};var ds=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}write(t,e){let i={},n=t;for(let s of this.fields){if(!s.oneof){let l=this.field(s,n[s.localName],e);l!==void 0&&(i[e.useProtoFieldName?s.name:s.jsonName]=l);continue}let o=n[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},e),{emitDefaultValues:!0}):e,c=this.field(s,o[s.localName],a);M(c!==void 0),i[e.useProtoFieldName?s.name:s.jsonName]=c}return i}field(t,e,i){let n;if(t.kind=="map"){M(typeof e=="object"&&e!==null);let s={};switch(t.V.kind){case"scalar":for(let[c,l]of Object.entries(e)){let u=this.scalar(t.V.T,l,t.name,!1,!0);M(u!==void 0),s[c.toString()]=u}break;case"message":let o=t.V.T();for(let[c,l]of Object.entries(e)){let u=this.message(o,l,t.name,i);M(u!==void 0),s[c.toString()]=u}break;case"enum":let a=t.V.T();for(let[c,l]of Object.entries(e)){M(l===void 0||typeof l=="number");let u=this.enum(a,l,t.name,!1,!0,i.enumAsInteger);M(u!==void 0),s[c.toString()]=u}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(n=s)}else if(t.repeat){M(Array.isArray(e));let s=[];switch(t.kind){case"scalar":for(let c=0;c<e.length;c++){let l=this.scalar(t.T,e[c],t.name,t.opt,!0);M(l!==void 0),s.push(l)}break;case"enum":let o=t.T();for(let c=0;c<e.length;c++){M(e[c]===void 0||typeof e[c]=="number");let l=this.enum(o,e[c],t.name,t.opt,!0,i.enumAsInteger);M(l!==void 0),s.push(l)}break;case"message":let a=t.T();for(let c=0;c<e.length;c++){let l=this.message(a,e[c],t.name,i);M(l!==void 0),s.push(l)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(n=s)}else switch(t.kind){case"scalar":n=this.scalar(t.T,e,t.name,t.opt,i.emitDefaultValues);break;case"enum":n=this.enum(t.T(),e,t.name,t.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":n=this.message(t.T(),e,t.name,i);break}return n}enum(t,e,i,n,s,o){if(t[0]=="google.protobuf.NullValue")return!s&&!n?void 0:null;if(e===void 0){M(n);return}if(!(e===0&&!s&&!n))return M(typeof e=="number"),M(Number.isInteger(e)),o||!t[1].hasOwnProperty(e)?e:t[2]?t[2]+t[1][e]:t[1][e]}message(t,e,i,n){return e===void 0?n.emitDefaultValues?null:void 0:t.internalJsonWrite(e,n)}scalar(t,e,i,n,s){if(e===void 0){M(n);return}let o=s||n;switch(t){case h.INT32:case h.SFIXED32:case h.SINT32:return e===0?o?0:void 0:(Ce(e),e);case h.FIXED32:case h.UINT32:return e===0?o?0:void 0:(hr(e),e);case h.FLOAT:Rr(e);case h.DOUBLE:return e===0?o?0:void 0:(M(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e);case h.STRING:return e===""?o?"":void 0:(M(typeof e=="string"),e);case h.BOOL:return e===!1?o?!1:void 0:(M(typeof e=="boolean"),e);case h.UINT64:case h.FIXED64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let a=ht.from(e);return a.isZero()&&!o?void 0:a.toString();case h.INT64:case h.SFIXED64:case h.SINT64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let c=K.from(e);return c.isZero()&&!o?void 0:c.toString();case h.BYTES:return M(e instanceof Uint8Array),e.byteLength?Vi(e):o?"":void 0}}};function zi(r,t=At.STRING){switch(r){case h.BOOL:return!1;case h.UINT64:case h.FIXED64:return Lt(ht.ZERO,t);case h.INT64:case h.SFIXED64:case h.SINT64:return Lt(K.ZERO,t);case h.DOUBLE:case h.FLOAT:return 0;case h.BYTES:return new Uint8Array(0);case h.STRING:return"";default:return 0}}var hs=class{constructor(t){this.info=t}prepare(){var t;if(!this.fieldNoToField){let e=(t=this.info.fields)!==null&&t!==void 0?t:[];this.fieldNoToField=new Map(e.map(i=>[i.no,i]))}}read(t,e,i,n){this.prepare();let s=n===void 0?t.len:t.pos+n;for(;t.pos<s;){let[o,a]=t.tag(),c=this.fieldNoToField.get(o);if(!c){let p=i.readUnknownField;if(p=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let m=t.skip(a);p!==!1&&(p===!0?Mr.onRead:p)(this.info.typeName,e,o,a,m);continue}let l=e,u=c.repeat,d=c.localName;switch(c.oneof&&(l=l[c.oneof],l.oneofKind!==d&&(l=e[c.oneof]={oneofKind:d})),c.kind){case"scalar":case"enum":let p=c.kind=="enum"?h.INT32:c.T,m=c.kind=="scalar"?c.L:void 0;if(u){let rt=l[d];if(a==ot.LengthDelimited&&p!=h.STRING&&p!=h.BYTES){let dt=t.uint32()+t.pos;for(;t.pos<dt;)rt.push(this.scalar(t,p,m))}else rt.push(this.scalar(t,p,m))}else l[d]=this.scalar(t,p,m);break;case"message":if(u){let rt=l[d],dt=c.T().internalBinaryRead(t,t.uint32(),i);rt.push(dt)}else l[d]=c.T().internalBinaryRead(t,t.uint32(),i,l[d]);break;case"map":let[_,C]=this.mapEntry(c,t,i);l[d][_]=C;break}}}mapEntry(t,e,i){let n=e.uint32(),s=e.pos+n,o,a;for(;e.pos<s;){let[c,l]=e.tag();switch(c){case 1:t.K==h.BOOL?o=e.bool().toString():o=this.scalar(e,t.K,At.STRING);break;case 2:switch(t.V.kind){case"scalar":a=this.scalar(e,t.V.T,t.V.L);break;case"enum":a=e.int32();break;case"message":a=t.V.T().internalBinaryRead(e,e.uint32(),i);break}break;default:throw new Error(`Unknown field ${c} (wire type ${l}) in map entry for ${this.info.typeName}#${t.name}`)}}if(o===void 0){let c=zi(t.K);o=t.K==h.BOOL?c.toString():c}if(a===void 0)switch(t.V.kind){case"scalar":a=zi(t.V.T,t.V.L);break;case"enum":a=0;break;case"message":a=t.V.T().create();break}return[o,a]}scalar(t,e,i){switch(e){case h.INT32:return t.int32();case h.STRING:return t.string();case h.BOOL:return t.bool();case h.DOUBLE:return t.double();case h.FLOAT:return t.float();case h.INT64:return Lt(t.int64(),i);case h.UINT64:return Lt(t.uint64(),i);case h.FIXED64:return Lt(t.fixed64(),i);case h.FIXED32:return t.fixed32();case h.BYTES:return t.bytes();case h.UINT32:return t.uint32();case h.SFIXED32:return t.sfixed32();case h.SFIXED64:return Lt(t.sfixed64(),i);case h.SINT32:return t.sint32();case h.SINT64:return Lt(t.sint64(),i)}}};var ps=class{constructor(t){this.info=t}prepare(){if(!this.fields){let t=this.info.fields?this.info.fields.concat():[];this.fields=t.sort((e,i)=>e.no-i.no)}}write(t,e,i){this.prepare();for(let s of this.fields){let o,a,c=s.repeat,l=s.localName;if(s.oneof){let u=t[s.oneof];if(u.oneofKind!==l)continue;o=u[l],a=!0}else o=t[l],a=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?h.INT32:s.T;if(c)if(M(Array.isArray(o)),c==ji.PACKED)this.packed(e,u,s.no,o);else for(let d of o)this.scalar(e,u,s.no,d,!0);else o===void 0?M(s.opt):this.scalar(e,u,s.no,o,a||s.opt);break;case"message":if(c){M(Array.isArray(o));for(let d of o)this.message(e,i,s.T(),s.no,d)}else this.message(e,i,s.T(),s.no,o);break;case"map":M(typeof o=="object"&&o!==null);for(let[d,p]of Object.entries(o))this.mapEntry(e,i,s,d,p);break}}let n=i.writeUnknownFields;n!==!1&&(n===!0?Mr.onWrite:n)(this.info.typeName,t,e)}mapEntry(t,e,i,n,s){t.tag(i.no,ot.LengthDelimited),t.fork();let o=n;switch(i.K){case h.INT32:case h.FIXED32:case h.UINT32:case h.SFIXED32:case h.SINT32:o=Number.parseInt(n);break;case h.BOOL:M(n=="true"||n=="false"),o=n=="true";break}switch(this.scalar(t,i.K,1,o,!0),i.V.kind){case"scalar":this.scalar(t,i.V.T,2,s,!0);break;case"enum":this.scalar(t,h.INT32,2,s,!0);break;case"message":this.message(t,e,i.V.T(),2,s);break}t.join()}message(t,e,i,n,s){s!==void 0&&(i.internalBinaryWrite(s,t.tag(n,ot.LengthDelimited).fork(),e),t.join())}scalar(t,e,i,n,s){let[o,a,c]=this.scalarInfo(e,n);(!c||s)&&(t.tag(i,o),t[a](n))}packed(t,e,i,n){if(!n.length)return;M(e!==h.BYTES&&e!==h.STRING),t.tag(i,ot.LengthDelimited),t.fork();let[,s]=this.scalarInfo(e);for(let o=0;o<n.length;o++)t[s](n[o]);t.join()}scalarInfo(t,e){let i=ot.Varint,n,s=e===void 0,o=e===0;switch(t){case h.INT32:n="int32";break;case h.STRING:o=s||!e.length,i=ot.LengthDelimited,n="string";break;case h.BOOL:o=e===!1,n="bool";break;case h.UINT32:n="uint32";break;case h.DOUBLE:i=ot.Bit64,n="double";break;case h.FLOAT:i=ot.Bit32,n="float";break;case h.INT64:o=s||K.from(e).isZero(),n="int64";break;case h.UINT64:o=s||ht.from(e).isZero(),n="uint64";break;case h.FIXED64:o=s||ht.from(e).isZero(),i=ot.Bit64,n="fixed64";break;case h.BYTES:o=s||!e.byteLength,i=ot.LengthDelimited,n="bytes";break;case h.FIXED32:i=ot.Bit32,n="fixed32";break;case h.SFIXED32:i=ot.Bit32,n="sfixed32";break;case h.SFIXED64:o=s||K.from(e).isZero(),i=ot.Bit64,n="sfixed64";break;case h.SINT32:n="sint32";break;case h.SINT64:o=s||K.from(e).isZero(),n="sint64";break}return[i,n,s||o]}};function jl(r){let t=r.messagePrototype?Object.create(r.messagePrototype):Object.defineProperty({},ls,{value:r});for(let e of r.fields){let i=e.localName;if(!e.opt)if(e.oneof)t[e.oneof]={oneofKind:void 0};else if(e.repeat)t[i]=[];else switch(e.kind){case"scalar":t[i]=zi(e.T,e.L);break;case"enum":t[i]=0;break;case"map":t[i]={};break}}return t}function ms(r,t,e){let i,n=e,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let c=n[o.oneof];if((c==null?void 0:c.oneofKind)==null)continue;if(i=c[a],s=t[o.oneof],s.oneofKind=c.oneofKind,i==null){delete s[a];continue}}else if(i=n[a],s=t,i==null)continue;switch(o.repeat&&(s[a].length=i.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=i[l];else s[a]=i;break;case"message":let c=o.T();if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=c.create(i[l]);else s[a]===void 0?s[a]=c.create(i):c.mergePartial(s[a],i);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],i);break;case"message":let l=o.V.T();for(let u of Object.keys(i))s[a][u]=l.create(i[u]);break}break}}}function $l(r,t,e){if(t===e)return!0;if(!t||!e)return!1;for(let i of r.fields){let n=i.localName,s=i.oneof?t[i.oneof][n]:t[n],o=i.oneof?e[i.oneof][n]:e[n];switch(i.kind){case"enum":case"scalar":let a=i.kind=="enum"?h.INT32:i.T;if(!(i.repeat?zl(a,s,o):Hl(a,s,o)))return!1;break;case"map":if(!(i.V.kind=="message"?Wl(i.V.T(),ys(s),ys(o)):zl(i.V.kind=="enum"?h.INT32:i.V.T,ys(s),ys(o))))return!1;break;case"message":let c=i.T();if(!(i.repeat?Wl(c,s,o):c.equals(s,o)))return!1;break}}return!0}var ys=Object.values;function Hl(r,t,e){if(t===e)return!0;if(r!==h.BYTES)return!1;let i=t,n=e;if(i.length!==n.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=n[s])return!1;return!0}function zl(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Hl(r,t[i],e[i]))return!1;return!0}function Wl(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!r.equals(t[i],e[i]))return!1;return!0}var Gl=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Bd=Gl[ls]={},it=class{constructor(t,e,i){this.defaultCheckDepth=16,this.typeName=t,this.fields=e.map(Pl),this.options=i!=null?i:{},Bd.value=this,this.messagePrototype=Object.create(null,Gl),this.refTypeCheck=new us(this),this.refJsonReader=new fs(this),this.refJsonWriter=new ds(this),this.refBinReader=new hs(this),this.refBinWriter=new ps(this)}create(t){let e=jl(this);return t!==void 0&&ms(this,e,t),e}clone(t){let e=this.create();return ms(this,e,t),e}equals(t,e){return $l(this,t,e)}is(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!1)}isAssignable(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!0)}mergePartial(t,e){ms(this,t,e)}fromBinary(t,e){let i=Ul(e);return this.internalBinaryRead(i.readerFactory(t),t.byteLength,i)}fromJson(t,e){return this.internalJsonRead(t,Ba(e))}fromJsonString(t,e){let i=JSON.parse(t);return this.fromJson(i,e)}toJson(t,e){return this.internalJsonWrite(t,Oa(e))}toJsonString(t,e){var i;let n=this.toJson(t,e);return JSON.stringify(n,null,(i=e==null?void 0:e.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(t,e){let i=Rl(e);return this.internalBinaryWrite(t,i.writerFactory(),i).finish()}internalJsonRead(t,e,i){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n=i!=null?i:this.create();return this.refJsonReader.read(t,n,e),n}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Ur(t)}.`)}internalJsonWrite(t,e){return this.refJsonWriter.write(t,e)}internalBinaryWrite(t,e,i){return this.refBinWriter.write(t,e,i),e}internalBinaryRead(t,e,i,n){let s=n!=null?n:this.create();return this.refBinReader.read(t,s,i,e),s}};function ql(r,t){var e,i,n;let s=r;return s.service=t,s.localName=(e=s.localName)!==null&&e!==void 0?e:si(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(i=s.options)!==null&&i!==void 0?i:{},s.idempotency=(n=s.idempotency)!==null&&n!==void 0?n:void 0,s}var Wi=class{constructor(t,e,i){this.typeName=t,this.methods=e.map(n=>ql(n,this)),this.options=i!=null?i:{}}};var H=class extends Error{constructor(t,e="UNKNOWN",i){super(t),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.meta=i!=null?i:{}}toString(){let t=[this.name+": "+this.message];this.code&&(t.push(""),t.push("Code: "+this.code)),this.serviceName&&this.methodName&&t.push("Method: "+this.serviceName+"/"+this.methodName);let e=Object.entries(this.meta);if(e.length){t.push(""),t.push("Meta:");for(let[i,n]of e)t.push(` ${i}: ${n}`)}return t.join(`
11
+ `)}};function Da(r,t){if(!t)return r;let e={};gs(r,e),gs(t,e);for(let i of Object.keys(t)){let n=t[i];switch(i){case"jsonOptions":e.jsonOptions=Aa(r.jsonOptions,e.jsonOptions);break;case"binaryOptions":e.binaryOptions=wa(r.binaryOptions,e.binaryOptions);break;case"meta":e.meta={},gs(r.meta,e.meta),gs(t.meta,e.meta);break;case"interceptors":e.interceptors=r.interceptors?r.interceptors.concat(n):n.concat();break}}return e}function gs(r,t){if(!r)return;let e=t;for(let[i,n]of Object.entries(r))n instanceof Date?e[i]=new Date(n.getTime()):Array.isArray(n)?e[i]=n.concat():e[i]=n}var Ut;(function(r){r[r.PENDING=0]="PENDING",r[r.REJECTED=1]="REJECTED",r[r.RESOLVED=2]="RESOLVED"})(Ut||(Ut={}));var jt=class{constructor(t=!0){this._state=Ut.PENDING,this._promise=new Promise((e,i)=>{this._resolve=e,this._reject=i}),t&&this._promise.catch(e=>{})}get state(){return this._state}get promise(){return this._promise}resolve(t){if(this.state!==Ut.PENDING)throw new Error(`cannot resolve ${Ut[this.state].toLowerCase()}`);this._resolve(t),this._state=Ut.RESOLVED}reject(t){if(this.state!==Ut.PENDING)throw new Error(`cannot reject ${Ut[this.state].toLowerCase()}`);this._reject(t),this._state=Ut.REJECTED}resolvePending(t){this._state===Ut.PENDING&&this.resolve(t)}rejectPending(t){this._state===Ut.PENDING&&this.reject(t)}};var $i=class{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1,this._itState={q:[]}}onNext(t){return this.addLis(t,this._lis.nxt)}onMessage(t){return this.addLis(t,this._lis.msg)}onError(t){return this.addLis(t,this._lis.err)}onComplete(t){return this.addLis(t,this._lis.cmp)}addLis(t,e){return e.push(t),()=>{let i=e.indexOf(t);i>=0&&e.splice(i,1)}}clearLis(){for(let t of Object.values(this._lis))t.splice(0,t.length)}get closed(){return this._closed!==!1}notifyNext(t,e,i){M((t?1:0)+(e?1:0)+(i?1:0)<=1,"only one emission at a time"),t&&this.notifyMessage(t),e&&this.notifyError(e),i&&this.notifyComplete()}notifyMessage(t){M(!this.closed,"stream is closed"),this.pushIt({value:t,done:!1}),this._lis.msg.forEach(e=>e(t)),this._lis.nxt.forEach(e=>e(t,void 0,!1))}notifyError(t){M(!this.closed,"stream is closed"),this._closed=t,this.pushIt(t),this._lis.err.forEach(e=>e(t)),this._lis.nxt.forEach(e=>e(void 0,t,!1)),this.clearLis()}notifyComplete(){M(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(t=>t()),this._lis.nxt.forEach(t=>t(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return this._closed===!0?this.pushIt({value:null,done:!0}):this._closed!==!1&&this.pushIt(this._closed),{next:()=>{let t=this._itState;M(t,"bad state"),M(!t.p,"iterator contract broken");let e=t.q.shift();return e?"value"in e?Promise.resolve(e):Promise.reject(e):(t.p=new jt,t.p.promise)}}}pushIt(t){let e=this._itState;if(e.p){let i=e.p;M(i.state==Ut.PENDING,"iterator contract broken"),"value"in t?i.resolve(t):i.reject(t),delete e.p}else e.q.push(t)}};var Od=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})},Hi=class{constructor(t,e,i,n,s,o,a){this.method=t,this.requestHeaders=e,this.request=i,this.headers=n,this.response=s,this.status=o,this.trailers=a}then(t,e){return this.promiseFinished().then(i=>t?Promise.resolve(t(i)):i,i=>e?Promise.resolve(e(i)):Promise.reject(i))}promiseFinished(){return Od(this,void 0,void 0,function*(){let[t,e,i,n]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:t,response:e,status:i,trailers:n}})}};var Ad=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})},Gi=class{constructor(t,e,i,n,s,o,a){this.method=t,this.requestHeaders=e,this.request=i,this.headers=n,this.responses=s,this.status=o,this.trailers=a}then(t,e){return this.promiseFinished().then(i=>t?Promise.resolve(t(i)):i,i=>e?Promise.resolve(e(i)):Promise.reject(i))}promiseFinished(){return Ad(this,void 0,void 0,function*(){let[t,e,i]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:t,status:e,trailers:i}})}};function qt(r,t,e,i,n){var s,o,a,c;if(r=="unary"){let l=(u,d,p)=>t.unary(u,d,p);for(let u of((s=i.interceptors)!==null&&s!==void 0?s:[]).filter(d=>d.interceptUnary).reverse()){let d=l;l=(p,m,_)=>u.interceptUnary(d,p,m,_)}return l(e,n,i)}if(r=="serverStreaming"){let l=(u,d,p)=>t.serverStreaming(u,d,p);for(let u of((o=i.interceptors)!==null&&o!==void 0?o:[]).filter(d=>d.interceptServerStreaming).reverse()){let d=l;l=(p,m,_)=>u.interceptServerStreaming(d,p,m,_)}return l(e,n,i)}if(r=="clientStreaming"){let l=(u,d)=>t.clientStreaming(u,d);for(let u of((a=i.interceptors)!==null&&a!==void 0?a:[]).filter(d=>d.interceptClientStreaming).reverse()){let d=l;l=(p,m)=>u.interceptClientStreaming(d,p,m)}return l(e,i)}if(r=="duplex"){let l=(u,d)=>t.duplex(u,d);for(let u of((c=i.interceptors)!==null&&c!==void 0?c:[]).filter(d=>d.interceptDuplex).reverse()){let d=l;l=(p,m)=>u.interceptDuplex(d,p,m)}return l(e,i)}xa(r)}var y;(function(r){r[r.OK=0]="OK",r[r.CANCELLED=1]="CANCELLED",r[r.UNKNOWN=2]="UNKNOWN",r[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.ALREADY_EXISTS=6]="ALREADY_EXISTS",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.OUT_OF_RANGE=11]="OUT_OF_RANGE",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.DATA_LOSS=15]="DATA_LOSS"})(y||(y={}));var Dd=function(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})};function Fa(r,t,e,i,n){if(i)for(let[s,o]of Object.entries(i))if(typeof o=="string")r.append(s,o);else for(let a of o)r.append(s,a);if(r.set("Content-Type",t==="text"?"application/grpc-web-text":"application/grpc-web+proto"),t=="text"&&r.set("Accept","application/grpc-web-text"),r.set("X-Grpc-Web","1"),n&&r.set("X-User-Agent",n),typeof e=="number"){if(e<=0)throw new H(`timeout ${e} ms exceeded`,y[y.DEADLINE_EXCEEDED]);r.set("grpc-timeout",`${e}m`)}else if(e){let s=e.getTime(),o=Date.now();if(s<=o)throw new H(`deadline ${e} exceeded`,y[y.DEADLINE_EXCEEDED]);r.set("grpc-timeout",`${s-o}m`)}return r}function Na(r,t){let e=new Uint8Array(5+r.length);e[0]=Jt.DATA;for(let i=r.length,n=4;n>0;n--)e[n]=i%256,i>>>=8;return e.set(r,5),t==="binary"?e:Vi(e)}function bs(r,t,e){if(arguments.length===1){let c=r,l;try{l=c.type}catch(u){}switch(l){case"error":case"opaque":case"opaqueredirect":throw new H(`fetch response type ${c.type}`,y[y.UNKNOWN])}return bs(Ld(c.headers),c.status,c.statusText)}let i=r,n=t>=200&&t<300,s=Kl(i),[o,a]=Xl(i);return(o===void 0||o===y.OK)&&!n&&(o=Ud(t),a=e),[o,a,s]}function Ea(r){let t=Ed(r),[e,i]=Xl(t),n=Kl(t);return[e!=null?e:y.OK,i,n]}var Jt;(function(r){r[r.DATA=0]="DATA",r[r.TRAILER=128]="TRAILER"})(Jt||(Jt={}));function La(r,t,e){return Dd(this,void 0,void 0,function*(){let i,n="",s=new Uint8Array(0),o=Nd(t);if(Fd(r)){let a=r.getReader();i={next:()=>a.read()}}else i=r[Symbol.asyncIterator]();for(;;){let a=yield i.next();if(a.value!==void 0){if(o==="text"){for(let l=0;l<a.value.length;l++)n+=String.fromCharCode(a.value[l]);let c=n.length-n.length%4;if(c===0)continue;s=Jl(s,Pi(n.substring(0,c))),n=n.substring(c)}else s=Jl(s,a.value);for(;s.length>=5&&s[0]===Jt.DATA;){let c=0;for(let l=1;l<5;l++)c=(c<<8)+s[l];if(s.length-5>=c)e(Jt.DATA,s.subarray(5,5+c)),s=s.subarray(5+c);else break}}if(a.done){if(s.length===0)break;if(s[0]!==Jt.TRAILER||s.length<5)throw new H("premature EOF",y[y.DATA_LOSS]);e(Jt.TRAILER,s.subarray(5));break}}})}var Fd=r=>typeof r.getReader=="function";function Jl(r,t){let e=new Uint8Array(r.length+t.length);return e.set(r),e.set(t,r.length),e}function Nd(r){switch(r){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new H("missing response content type",y[y.INTERNAL]);default:throw new H("unexpected response content type: "+r,y[y.INTERNAL])}}function Xl(r){let t,e,i=r["grpc-message"];if(i!==void 0){if(Array.isArray(i))return[y.INTERNAL,"invalid grpc-web message"];e=i}let n=r["grpc-status"];if(n!==void 0){if(Array.isArray(n))return[y.INTERNAL,"invalid grpc-web status"];if(t=parseInt(n,10),y[t]===void 0)return[y.INTERNAL,"invalid grpc-web status"]}return[t,e]}function Kl(r){let t={};for(let[e,i]of Object.entries(r))switch(e){case"grpc-message":case"grpc-status":case"content-type":break;default:t[e]=i}return t}function Ed(r){let t={};for(let e of String.fromCharCode.apply(String,r).trim().split(`\r
12
+ `)){if(e=="")continue;let[i,...n]=e.split(":"),s=n.join(":").trim();i=i.trim();let o=t[i];typeof o=="string"?t[i]=[o,s]:Array.isArray(o)?o.push(s):t[i]=s}return t}function Ld(r){let t={};return r.forEach((e,i)=>{let n=t[i];typeof n=="string"?t[i]=[n,e]:Array.isArray(n)?n.push(e):t[i]=e}),t}function Ud(r){switch(r){case 200:return y.OK;case 400:return y.INVALID_ARGUMENT;case 401:return y.UNAUTHENTICATED;case 403:return y.PERMISSION_DENIED;case 404:return y.NOT_FOUND;case 409:return y.ABORTED;case 412:return y.FAILED_PRECONDITION;case 429:return y.RESOURCE_EXHAUSTED;case 499:return y.CANCELLED;case 500:return y.UNKNOWN;case 501:return y.UNIMPLEMENTED;case 503:return y.UNAVAILABLE;case 504:return y.DEADLINE_EXCEEDED;default:return y.UNKNOWN}}var qi=class{constructor(t){this.defaultOptions=t}mergeOptions(t){return Da(this.defaultOptions,t)}makeUrl(t,e){let i=e.baseUrl;return i.endsWith("/")&&(i=i.substring(0,i.length-1)),`${i}/${t.service.typeName}/${t.name}`}clientStreaming(t){let e=new H("Client streaming is not supported by grpc-web",y[y.UNIMPLEMENTED]);throw e.methodName=t.name,e.serviceName=t.service.typeName,e}duplex(t){let e=new H("Duplex streaming is not supported by grpc-web",y[y.UNIMPLEMENTED]);throw e.methodName=t.name,e.serviceName=t.service.typeName,e}serverStreaming(t,e,i){var n,s,o,a,c;let l=i,u=(n=l.format)!==null&&n!==void 0?n:"text",d=(s=l.fetch)!==null&&s!==void 0?s:globalThis.fetch,p=(o=l.fetchInit)!==null&&o!==void 0?o:{},m=this.makeUrl(t,l),_=t.I.toBinary(e,l.binaryOptions),C=new jt,rt=new $i,dt=!0,pt,Fr=new jt,Ie,Nr=new jt;return d(m,Object.assign(Object.assign({},p),{method:"POST",headers:Fa(new globalThis.Headers,u,l.timeout,l.meta),body:Na(_,u),signal:(a=i.abort)!==null&&a!==void 0?a:null})).then(q=>{let[P,_t,Vt]=bs(q);if(C.resolve(Vt),P!=null&&P!==y.OK)throw new H(_t!=null?_t:y[P],y[P],Vt);return P!=null&&(pt={code:y[P],detail:_t!=null?_t:y[P]}),q}).then(q=>{if(!q.body)throw new H("missing response body",y[y.INTERNAL]);return La(q.body,q.headers.get("content-type"),(P,_t)=>{switch(P){case Jt.DATA:rt.notifyMessage(t.O.fromBinary(_t,l.binaryOptions)),dt=!1;break;case Jt.TRAILER:let Vt,Me;[Vt,Me,Ie]=Ea(_t),pt={code:y[Vt],detail:Me!=null?Me:y[Vt]};break}})}).then(()=>{if(!Ie&&!dt)throw new H("missing trailers",y[y.DATA_LOSS]);if(!pt)throw new H("missing status",y[y.INTERNAL]);if(pt.code!=="OK")throw new H(pt.detail,pt.code,Ie);rt.notifyComplete(),Fr.resolve(pt),Nr.resolve(Ie||{})}).catch(q=>{let P;q instanceof H?P=q:q instanceof Error&&q.name==="AbortError"?P=new H(q.message,y[y.CANCELLED]):P=new H(q instanceof Error?q.message:""+q,y[y.INTERNAL]),P.methodName=t.name,P.serviceName=t.service.typeName,C.rejectPending(P),rt.notifyError(P),Fr.rejectPending(P),Nr.rejectPending(P)}),new Gi(t,(c=l.meta)!==null&&c!==void 0?c:{},e,C.promise,rt,Fr.promise,Nr.promise)}unary(t,e,i){var n,s,o,a,c;let l=i,u=(n=l.format)!==null&&n!==void 0?n:"text",d=(s=l.fetch)!==null&&s!==void 0?s:globalThis.fetch,p=(o=l.fetchInit)!==null&&o!==void 0?o:{},m=this.makeUrl(t,l),_=t.I.toBinary(e,l.binaryOptions),C=new jt,rt,dt=new jt,pt,Fr=new jt,Ie,Nr=new jt;return d(m,Object.assign(Object.assign({},p),{method:"POST",headers:Fa(new globalThis.Headers,u,l.timeout,l.meta),body:Na(_,u),signal:(a=i.abort)!==null&&a!==void 0?a:null})).then(q=>{let[P,_t,Vt]=bs(q);if(C.resolve(Vt),P!=null&&P!==y.OK)throw new H(_t!=null?_t:y[P],y[P],Vt);return P!=null&&(pt={code:y[P],detail:_t!=null?_t:y[P]}),q}).then(q=>{if(!q.body)throw new H("missing response body",y[y.INTERNAL]);return La(q.body,q.headers.get("content-type"),(P,_t)=>{switch(P){case Jt.DATA:if(rt)throw new H("unary call received 2nd message",y[y.DATA_LOSS]);rt=t.O.fromBinary(_t,l.binaryOptions);break;case Jt.TRAILER:let Vt,Me;[Vt,Me,Ie]=Ea(_t),pt={code:y[Vt],detail:Me!=null?Me:y[Vt]};break}})}).then(()=>{if(!Ie&&rt)throw new H("missing trailers",y[y.DATA_LOSS]);if(!pt)throw new H("missing status",y[y.INTERNAL]);if(!rt&&pt.code==="OK")throw new H("expected error status",y[y.DATA_LOSS]);if(!rt)throw new H(pt.detail,pt.code,Ie);if(dt.resolve(rt),pt.code!=="OK")throw new H(pt.detail,pt.code,Ie);Fr.resolve(pt),Nr.resolve(Ie||{})}).catch(q=>{let P;q instanceof H?P=q:q instanceof Error&&q.name==="AbortError"?P=new H(q.message,y[y.CANCELLED]):P=new H(q instanceof Error?q.message:""+q,y[y.INTERNAL]),P.methodName=t.name,P.serviceName=t.service.typeName,C.rejectPending(P),dt.rejectPending(P),Fr.rejectPending(P),Nr.rejectPending(P)}),new Hi(t,(c=l.meta)!==null&&c!==void 0?c:{},e,C.promise,dt.promise,Fr.promise,Nr.promise)}};var Yl=({host:r,timeout:t,clientOptions:e})=>{var n;(e!=null&&e.grpcOptions||(n=e==null?void 0:e.queryOptions)!=null&&n.grpcOptions)&&console.warn(`Detected grpcClientOptions: such options are ignored in the GrpcWebFetchTransport:
9
13
 
10
- ${JSON.stringify(e)}`);let{interceptors:i}=e!=null?e:{};return new $i({baseUrl:r,timeout:t,interceptors:i})};var Bd={writeTransport:r=>new Mi(r),queryTransport:$l},Rr=Bd;var Hi=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_transport");var e;this._transport=(e=this._options.transport)!=null?e:Rr.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_options;_createWritePath(t,e,i){let n=e.precision,s,o=[];return i&&o.push(`org=${encodeURIComponent(i)}`),e.noSync?(s="/api/v3/write_lp",o.push(`db=${encodeURIComponent(t)}`),o.push(`precision=${aa(n)}`),o.push("no_sync=true")):(s="/api/v2/write",o.push(`bucket=${encodeURIComponent(t)}`),o.push(`precision=${oa(n)}`)),`${s}?${o.join("&")}`}doWrite(t,e,i,n){if(this._closed)return Promise.reject(new Error("writeApi: already closed!"));if(t.length<=0||t.length===1&&t[0]==="")return Promise.resolve();let o,a,c=new Promise((_,j)=>{o=_,a=j}),l={...ia,...n},u,d,p={responseStarted(_,j){u=j,d=_},error(_){if(_ instanceof re&&_.json&&typeof _.json.error=="string"&&_.json.error.includes("hinted handoff queue not empty")){Nr.warn(`Write to InfluxDB returns: ${_.json.error}`),u=204,p.complete();return}_ instanceof re&&_.statusCode==405&&l.noSync&&(_=new re(_.statusCode,"Server doesn't support write with noSync=true (supported by InfluxDB 3 Core/Enterprise servers only).",_.body,_.contentType,_.headers)),Nr.error("Write to InfluxDB failed.",_),a(_)},complete(){if(u==null||u>=200&&u<300)o();else{let _=`2xx HTTP response status code expected, but ${u} returned`,j=new re(u,_,void 0,"0",d);j.message=_,p.error(j)}}},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...n==null?void 0:n.headers},gzipThreshold:l.gzipThreshold,timeout:l.timeout};return this._transport.send(this._createWritePath(e,l,i),t.join(`
11
- `),m,p),c}async close(){this._closed=!0}};function Gl(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(e[i[n]]=r[i[n]]);return e}function g(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})}function Hl(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function U(r){return this instanceof U?(this.v=r,this):new U(r)}function zt(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),n,s=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(m){return function(_){return Promise.resolve(_).then(m,d)}}function a(m,_){i[m]&&(n[m]=function(j){return new Promise(function(at,dt){s.push([m,j,at,dt])>1||c(m,j)})},_&&(n[m]=_(n[m])))}function c(m,_){try{l(i[m](_))}catch(j){p(s[0][3],j)}}function l(m){m.value instanceof U?Promise.resolve(m.value.v).then(u,d):p(s[0][2],m)}function u(m){c("next",m)}function d(m){c("throw",m)}function p(m,_){m(_),s.shift(),s.length&&c(s[0][0],s[0][1])}}function ni(r){var t,e;return t={},i("next"),i("throw",function(n){throw n}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(n,s){t[n]=r[n]?function(o){return(e=!e)?{value:U(r[n](o)),done:!1}:s?s(o):o}:s}}function ie(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Hl=="function"?Hl(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(s){e[s]=r[s]&&function(o){return new Promise(function(a,c){o=r[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var Ra={};Ue(Ra,{compareArrayLike:()=>Ma,joinUint8Arrays:()=>Wt,memcpy:()=>Ji,rebaseValueOffsets:()=>Ss,toArrayBufferView:()=>R,toArrayBufferViewAsyncIterator:()=>oe,toArrayBufferViewIterator:()=>Se,toBigInt64Array:()=>vs,toBigUint64Array:()=>Ud,toFloat32Array:()=>Md,toFloat32ArrayAsyncIterator:()=>Yd,toFloat32ArrayIterator:()=>Wd,toFloat64Array:()=>Rd,toFloat64ArrayAsyncIterator:()=>Zd,toFloat64ArrayIterator:()=>$d,toInt16Array:()=>Nd,toInt16ArrayAsyncIterator:()=>qd,toInt16ArrayIterator:()=>Vd,toInt32Array:()=>Cr,toInt32ArrayAsyncIterator:()=>Jd,toInt32ArrayIterator:()=>Pd,toInt8Array:()=>Fd,toInt8ArrayAsyncIterator:()=>Gd,toInt8ArrayIterator:()=>kd,toUint16Array:()=>Ed,toUint16ArrayAsyncIterator:()=>Kd,toUint16ArrayIterator:()=>jd,toUint32Array:()=>Ld,toUint32ArrayAsyncIterator:()=>Xd,toUint32ArrayIterator:()=>zd,toUint8Array:()=>D,toUint8ArrayAsyncIterator:()=>Ua,toUint8ArrayIterator:()=>La,toUint8ClampedArray:()=>Cd,toUint8ClampedArrayAsyncIterator:()=>Qd,toUint8ClampedArrayIterator:()=>Hd});var ql=new TextDecoder("utf-8"),Gi=ql.decode.bind(ql),Od=new TextEncoder,ve=r=>Od.encode(r);var Dd=r=>typeof r=="number",Jl=r=>typeof r=="boolean",wt=r=>typeof r=="function",At=r=>r!=null&&Object(r)===r,ne=r=>At(r)&&wt(r.then);var se=r=>At(r)&&wt(r[Symbol.iterator]),Kt=r=>At(r)&&wt(r[Symbol.asyncIterator]),ys=r=>At(r)&&At(r.schema);var gs=r=>At(r)&&"done"in r&&"value"in r;var bs=r=>At(r)&&wt(r.stat)&&Dd(r.fd);var _s=r=>At(r)&&qi(r.body),ws=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Kl=r=>At(r)&&wt(r.abort)&&wt(r.getWriter)&&!ws(r),qi=r=>At(r)&&wt(r.cancel)&&wt(r.getReader)&&!ws(r),Xl=r=>At(r)&&wt(r.end)&&wt(r.write)&&Jl(r.writable)&&!ws(r),Is=r=>At(r)&&wt(r.read)&&wt(r.pipe)&&Jl(r.readable)&&!ws(r),Yl=r=>At(r)&&wt(r.clear)&&wt(r.bytes)&&wt(r.position)&&wt(r.setPosition)&&wt(r.capacity)&&wt(r.getBufferIdentifier)&&wt(r.createLong);var Ea=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:ArrayBuffer;function Ad(r){let t=r[0]?[r[0]]:[],e,i,n,s;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:n}=o,{byteOffset:i,byteLength:s}=a,e+n<i||i+s<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,i-e+s)}return t}function Ji(r,t,e=0,i=t.byteLength){let n=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,n),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(i,n));return s.set(o,e),r}function Wt(r,t){let e=Ad(r),i=e.reduce((u,d)=>u+d.byteLength,0),n,s,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,i);for(let u=e.length;++c<u;){if(n=e[c],s=n.subarray(0,Math.min(n.length,l-a)),l<=a+s.length){s.length<n.length?e[c]=n.subarray(s.length):s.length===n.length&&c++,o?Ji(o,s,a):o=s;break}Ji(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),i-(o?o.byteLength:0)]}function R(r,t){let e=gs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=ve(e)),e instanceof ArrayBuffer?new r(e):e instanceof Ea?new r(e):Yl(e)?R(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Fd=r=>R(Int8Array,r),Nd=r=>R(Int16Array,r),Cr=r=>R(Int32Array,r),vs=r=>R(BigInt64Array,r),D=r=>R(Uint8Array,r),Ed=r=>R(Uint16Array,r),Ld=r=>R(Uint32Array,r),Ud=r=>R(BigUint64Array,r),Md=r=>R(Float32Array,r),Rd=r=>R(Float64Array,r),Cd=r=>R(Uint8ClampedArray,r),Na=r=>(r.next(),r);function*Se(r,t){let e=function*(n){yield n},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ea?e(t):se(t)?t:e(t);return yield*Na((function*(n){let s=null;do s=n.next(yield R(r,s));while(!s.done)})(i[Symbol.iterator]())),new r}var kd=r=>Se(Int8Array,r),Vd=r=>Se(Int16Array,r),Pd=r=>Se(Int32Array,r),La=r=>Se(Uint8Array,r),jd=r=>Se(Uint16Array,r),zd=r=>Se(Uint32Array,r),Wd=r=>Se(Float32Array,r),$d=r=>Se(Float64Array,r),Hd=r=>Se(Uint8ClampedArray,r);function oe(r,t){return zt(this,arguments,function*(){if(ne(t))return yield U(yield U(yield*ni(ie(oe(r,yield U(t))))));let i=function(o){return zt(this,arguments,function*(){yield yield U(yield U(o))})},n=function(o){return zt(this,arguments,function*(){yield U(yield*ni(ie(Na((function*(a){let c=null;do c=a.next(yield c==null?void 0:c.value);while(!c.done)})(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ea?i(t):se(t)?n(t):Kt(t)?t:i(t);return yield U(yield*ni(ie(Na((function(o){return zt(this,arguments,function*(){let a=null;do a=yield U(o.next(yield yield U(R(r,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield U(new r)})}var Gd=r=>oe(Int8Array,r),qd=r=>oe(Int16Array,r),Jd=r=>oe(Int32Array,r),Ua=r=>oe(Uint8Array,r),Kd=r=>oe(Uint16Array,r),Xd=r=>oe(Uint32Array,r),Yd=r=>oe(Float32Array,r),Zd=r=>oe(Float64Array,r),Qd=r=>oe(Uint8ClampedArray,r);function Ss(r,t,e){if(r!==0){e=e.slice(0,t);for(let i=-1,n=e.length;++i<n;)e[i]+=r}return e.subarray(0,t)}function Ma(r,t){let e=0,i=r.length;if(i!==t.length)return!1;if(i>0)do if(r[e]!==t[e])return!1;while(++e<i);return!0}var St={fromIterable(r){return xs(th(r))},fromAsyncIterable(r){return xs(eh(r))},fromDOMStream(r){return xs(rh(r))},fromNodeStream(r){return xs(ih(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},xs=r=>(r.next(),r);function*th(r){let t,e=!1,i=[],n,s,o,a=0;function c(){return s==="peek"?Wt(i,o)[0]:([n,i,a]=Wt(i,o),n)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let l=La(r)[Symbol.iterator]();try{do if({done:t,value:n}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&n.byteLength>0&&(i.push(n),a+=n.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){e=!0,typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function eh(r){return zt(this,arguments,function*(){let e,i=!1,n=[],s,o,a,c=0;function l(){return o==="peek"?Wt(n,a)[0]:([s,n,c]=Wt(n,a),s)}({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0});let u=Ua(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.next()):yield U(u.next(a-c)),!e&&s.byteLength>0&&(n.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield U(l()));while(a<c);while(!e)}catch(d){i=!0,typeof u.throw=="function"&&(yield U(u.throw(d)))}finally{i===!1&&typeof u.return=="function"&&(yield U(u.return(new Uint8Array(0))))}return yield U(null)})}function rh(r){return zt(this,arguments,function*(){let e=!1,i=!1,n=[],s,o,a,c=0;function l(){return o==="peek"?Wt(n,a)[0]:([s,n,c]=Wt(n,a),s)}({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0});let u=new ka(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.read()):yield U(u.read(a-c)),!e&&s.byteLength>0&&(n.push(D(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield U(l()));while(a<c);while(!e)}catch(d){i=!0,yield U(u.cancel(d))}finally{i===!1?yield U(u.cancel()):r.locked&&u.releaseLock()}return yield U(null)})}var ka=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return g(this,void 0,void 0,function*(){let{reader:e,source:i}=this;e&&(yield e.cancel(t).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(t){return g(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=D(e)),e})}},Ca=(r,t)=>{let e=n=>i([t,n]),i;return[t,e,new Promise(n=>(i=n)&&r.once(t,e))]};function ih(r){return zt(this,arguments,function*(){let e=[],i="error",n=!1,s=null,o,a,c=0,l=[],u;function d(){return o==="peek"?Wt(l,a)[0]:([u,l,c]=Wt(l,a),u)}if({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0},r.isTTY)return yield yield U(new Uint8Array(0)),yield U(null);try{e[0]=Ca(r,"end"),e[1]=Ca(r,"error");do{if(e[2]=Ca(r,"readable"),[i,s]=yield U(Promise.race(e.map(m=>m[2]))),i==="error")break;if((n=i==="end")||(Number.isFinite(a-c)?(u=D(r.read(a-c)),u.byteLength<a-c&&(u=D(r.read()))):u=D(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),n||a<=c)do({cmd:o,size:a}=yield yield U(d()));while(a<c)}while(!n)}finally{yield U(p(e,i==="error"?s:null))}return yield U(null);function p(m,_){return u=l=null,new Promise((j,at)=>{for(let[dt,pt]of m)r.off(dt,pt);try{let dt=r.destroy;dt&&dt.call(r,_),_=void 0}catch(dt){_=dt||_}finally{_!=null?at(_):j()}})}})}var J;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(J||(J={}));var Z;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(Z||(Z={}));var Y;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Y||(Y={}));var ut;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(ut||(ut={}));var w;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(w||(w={}));var et;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(et||(et={}));var xe=new Int32Array(2),Ts=new Float32Array(xe.buffer),Bs=new Float64Array(xe.buffer),si=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Ki;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Ki||(Ki={}));var xt=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return xe[0]=this.readInt32(t),Ts[0]}readFloat64(t){return xe[si?0:1]=this.readInt32(t),xe[si?1:0]=this.readInt32(t+4),Bs[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Ts[0]=e,this.writeInt32(t,xe[0])}writeFloat64(t,e){Bs[0]=e,this.writeInt32(t,xe[si?0:1]),this.writeInt32(t+4,xe[si?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let i=this.readInt32(t);t+=4;let n=this.bytes_.subarray(t,t+i);return e===Ki.UTF8_BYTES?n:this.text_decoder_.decode(n)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let i=[];for(let n=0;n<e;++n){let s=t(n);s!==null&&i.push(s)}return i}createObjList(t,e){let i=[];for(let n=0;n<e;++n){let s=t(n);s!==null&&i.push(s.unpack())}return i}};var kr=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=xt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){let n=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||e!==i)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let i=e<<1,n=xt.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let n=2;this.addInt16(t-this.object_start);let s=(i+n)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=2;l<s;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){let n=i?4:0;if(e){let s=e;if(this.prep(this.minalign,8+n),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(!(e<this.bb.readInt16(n)&&this.bb.readInt16(n+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let i=0;i<t.length;++i){let n=t[i];if(n!==null)e.push(this.createObjectOffset(n));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Vr;(function(r){r[r.BUFFER=0]="BUFFER"})(Vr||(Vr={}));var Ft;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ft||(Ft={}));var Ce=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Ft.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Vr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ft.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Vr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,i){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,i),r.endBodyCompression(t)}};var oi=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,i){return t.prep(8,16),t.writeInt64(BigInt(i!=null?i:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var ai=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,i){return t.prep(8,16),t.writeInt64(BigInt(i!=null?i:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Mt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let i=this.bb.__offset(this.bb_pos,6);return i?(e||new ai).__init(this.bb.__vector(this.bb_pos+i)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new oi).__init(this.bb.__vector(this.bb_pos+i)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new Ce).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var ke=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Mt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var hr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(hr||(hr={}));var Xi;(function(r){r[r.DenseArray=0]="DenseArray"})(Xi||(Xi={}));var ce=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,i){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,i),r.endInt(t)}};var Te=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ce).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Xi.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,Xi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var It=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,i){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,i),r.endKeyValue(t)}};var Yi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}};var Zi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}};var pr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ut.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,ut.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};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 getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,i,n){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,i),r.addBitWidth(t,n),r.endDecimal(t)}};var mr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,w.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}};var yr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}};var gr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}};var br=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Y.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Y.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}};var _r=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):et.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,et.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var Qi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}};var tn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}};var en=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}};var wr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}};var rn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}};var nn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}};var Ve=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,w.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,i){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,i),r.endTime(t)}};var Pe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,w.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,i){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,i),r.endTimestamp(t)}};var le=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Z.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,Z.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,i){return r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,i),r.endUnion(t)}};var sn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}};var Q;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(Q||(Q={}));var Bt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Q.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Te).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let i=this.bb.__offset(this.bb_pos,14);return i?(e||new r).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,16);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,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Q.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(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 startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,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 endField(t){return t.endObject()}};var Rt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):hr.Little}fields(t,e){let i=this.bb.__offset(this.bb_pos,6);return i?(e||new Bt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,8);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,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,hr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(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 startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,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 addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,i,n,s){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,i),r.addCustomMetadata(t,n),r.addFeatures(t,s),r.endSchema(t)}};var V;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(V||(V={}));var f;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond",r[r.IntervalMonthDayNano=-31]="IntervalMonthDayNano"})(f||(f={}));var Yt;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Yt||(Yt={}));var nc={};Ue(nc,{clampRange:()=>ln,createElementComparator:()=>xr,wrapIndex:()=>Pr});var Va={};Ue(Va,{valueToString:()=>ue});function ue(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>ue(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Wa={};Ue(Wa,{BN:()=>an,bigNumToBigInt:()=>Ql,bigNumToNumber:()=>za,bigNumToString:()=>ui,isArrowBigNumSymbol:()=>Zl});function W(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function Pa(r,t){return W(r/t)+W(r%t)/W(t)}var Zl=Symbol.for("isArrowBigNum");function fe(r,...t){return t.length===0?Object.setPrototypeOf(R(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}fe.prototype[Zl]=!0;fe.prototype.toJSON=function(){return`"${ui(this)}"`};fe.prototype.valueOf=function(r){return za(this,r)};fe.prototype.toString=function(){return ui(this)};fe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return za(this);case"string":return ui(this);case"default":return Ql(this)}return ui(this)};function ci(...r){return fe.apply(this,r)}function li(...r){return fe.apply(this,r)}function on(...r){return fe.apply(this,r)}Object.setPrototypeOf(ci.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(li.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(on.prototype,Object.create(Uint32Array.prototype));Object.assign(ci.prototype,fe.prototype,{constructor:ci,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(li.prototype,fe.prototype,{constructor:li,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(on.prototype,fe.prototype,{constructor:on,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var nh=BigInt(4294967296)*BigInt(4294967296),sh=nh-BigInt(1);function za(r,t){let{buffer:e,byteOffset:i,byteLength:n,signed:s}=r,o=new BigUint64Array(e,i,n/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^sh)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"&&t>0){let u=BigInt("1".padEnd(t+1,"0")),d=c/u,p=a?-(c%u):c%u,m=W(d),_=`${p}`.padStart(t,"0");return+`${a&&m===0?"-":""}${m}.${_}`}return W(c)}function ui(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return ja(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ja(r);t=t.slice();let i=1;for(let s=0;s<t.length;s++){let o=t[s],a=~o+i;t[s]=a,i&=o===0?1:0}return`-${ja(t)}`}function Ql(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:ui(r)}function ja(r){let t="",e=new Uint32Array(2),i=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),n=new Uint32Array((i=new Uint16Array(i).reverse()).buffer),s=-1,o=i.length-1;do{for(e[0]=i[s=0];s<o;)i[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+i[s];i[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(n[0]||n[1]||n[2]||n[3]);return t!=null?t:"0"}var an=class r{static new(t,e){switch(e){case!0:return new ci(t);case!1:return new li(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new ci(t)}return t.byteLength===16?new on(t):new li(t)}static signed(t){return new ci(t)}static unsigned(t){return new li(t)}static decimal(t){return new on(t)}constructor(t,e){return r.new(t,e)}};var tu,eu,ru,iu,nu,su,ou,au,cu,lu,uu,fu,du,hu,pu,mu,yu,gu,bu,_u,wu,Iu,b=class r{static isNull(t){return(t==null?void 0:t.typeId)===f.Null}static isInt(t){return(t==null?void 0:t.typeId)===f.Int}static isFloat(t){return(t==null?void 0:t.typeId)===f.Float}static isBinary(t){return(t==null?void 0:t.typeId)===f.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===f.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===f.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===f.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===f.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===f.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===f.Date}static isTime(t){return(t==null?void 0:t.typeId)===f.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===f.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===f.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===f.Duration}static isList(t){return(t==null?void 0:t.typeId)===f.List}static isStruct(t){return(t==null?void 0:t.typeId)===f.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===f.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===f.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===f.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===f.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===f.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===Z.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===Z.Sparse}constructor(t){this.typeId=t}};tu=Symbol.toStringTag;b[tu]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(b.prototype);var Nt=class extends b{constructor(){super(f.Null)}toString(){return"Null"}};eu=Symbol.toStringTag;Nt[eu]=(r=>r[Symbol.toStringTag]="Null")(Nt.prototype);var vt=class extends b{constructor(t,e){super(f.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};ru=Symbol.toStringTag;vt[ru]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(vt.prototype);var Ds=class extends vt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},As=class extends vt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Oe=class extends vt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Fs=class extends vt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ns=class extends vt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Es=class extends vt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ls=class extends vt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Us=class extends vt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ds.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(As.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Oe.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Fs.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ns.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Es.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ls.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Us.prototype,"ArrayType",{value:BigUint64Array});var Zt=class extends b{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Y.HALF:return Uint16Array;case Y.SINGLE:return Float32Array;case Y.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};iu=Symbol.toStringTag;Zt[iu]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Zt.prototype);var Ms=class extends Zt{constructor(){super(Y.HALF)}},Rs=class extends Zt{constructor(){super(Y.SINGLE)}},Cs=class extends Zt{constructor(){super(Y.DOUBLE)}};Object.defineProperty(Ms.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Rs.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Cs.prototype,"ArrayType",{value:Float64Array});var je=class extends b{constructor(){super(f.Binary)}toString(){return"Binary"}};nu=Symbol.toStringTag;je[nu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(je.prototype);var ze=class extends b{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}};su=Symbol.toStringTag;ze[su]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(ze.prototype);var We=class extends b{constructor(){super(f.Utf8)}toString(){return"Utf8"}};ou=Symbol.toStringTag;We[ou]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(We.prototype);var $e=class extends b{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}};au=Symbol.toStringTag;$e[au]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))($e.prototype);var He=class extends b{constructor(){super(f.Bool)}toString(){return"Bool"}};cu=Symbol.toStringTag;He[cu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(He.prototype);var Ge=class extends b{constructor(t,e,i=128){super(f.Decimal),this.scale=t,this.precision=e,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lu=Symbol.toStringTag;Ge[lu]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Ge.prototype);var qe=class extends b{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${ut[this.unit]}>`}get ArrayType(){return this.unit===ut.DAY?Int32Array:BigInt64Array}};uu=Symbol.toStringTag;qe[uu]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(qe.prototype);var Je=class extends b{constructor(t,e){super(f.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${w[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};fu=Symbol.toStringTag;Je[fu]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Je.prototype);var Ke=class extends b{constructor(t,e){super(f.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${w[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};du=Symbol.toStringTag;Ke[du]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Ke.prototype);var Xe=class extends b{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${et[this.unit]}>`}};hu=Symbol.toStringTag;Xe[hu]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Xe.prototype);var Ye=class extends b{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${w[this.unit]}>`}};pu=Symbol.toStringTag;Ye[pu]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Ye.prototype);var de=class extends b{constructor(t){super(f.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};mu=Symbol.toStringTag;de[mu]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(de.prototype);var it=class extends b{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};yu=Symbol.toStringTag;it[yu]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(it.prototype);var he=class extends b{constructor(t,e,i){super(f.Union),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((n,s,o)=>(n[s]=o)&&n||n,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};gu=Symbol.toStringTag;he[gu]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(he.prototype);var Ze=class extends b{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};bu=Symbol.toStringTag;Ze[bu]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Ze.prototype);var pe=class extends b{constructor(t,e){super(f.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};_u=Symbol.toStringTag;pe[_u]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(pe.prototype);var me=class extends b{constructor(t,e=!1){var i,n,s;if(super(f.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((i=t==null?void 0:t.type)===null||i===void 0)&&i.children)){let o=(n=t==null?void 0:t.type)===null||n===void 0?void 0:n.children[0];o&&(o.name="key");let a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};wu=Symbol.toStringTag;me[wu]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(me.prototype);var oh=(r=>()=>++r)(-1),$t=class extends b{constructor(t,e,i,n){super(f.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=i==null?oh():W(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};Iu=Symbol.toStringTag;$t[Iu]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))($t.prototype);function Ht(r){let t=r;switch(r.typeId){case f.Decimal:return r.bitWidth/32;case f.Interval:return t.unit===et.MONTH_DAY_NANO?4:1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}var v=class{visitMany(t,...e){return t.map((i,n)=>this.visit(i,...e.map(s=>s[n])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return ah(this,t,e)}getVisitFnByTypeId(t,e=!0){return fi(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function ah(r,t,e=!0){return typeof t=="number"?fi(r,t,e):typeof t=="string"&&t in f?fi(r,f[t],e):t&&t instanceof b?fi(r,vu(t),e):t!=null&&t.type&&t.type instanceof b?fi(r,vu(t.type),e):fi(r,f.NONE,e)}function fi(r,t,e=!0){let i=null;switch(t){case f.Null:i=r.visitNull;break;case f.Bool:i=r.visitBool;break;case f.Int:i=r.visitInt;break;case f.Int8:i=r.visitInt8||r.visitInt;break;case f.Int16:i=r.visitInt16||r.visitInt;break;case f.Int32:i=r.visitInt32||r.visitInt;break;case f.Int64:i=r.visitInt64||r.visitInt;break;case f.Uint8:i=r.visitUint8||r.visitInt;break;case f.Uint16:i=r.visitUint16||r.visitInt;break;case f.Uint32:i=r.visitUint32||r.visitInt;break;case f.Uint64:i=r.visitUint64||r.visitInt;break;case f.Float:i=r.visitFloat;break;case f.Float16:i=r.visitFloat16||r.visitFloat;break;case f.Float32:i=r.visitFloat32||r.visitFloat;break;case f.Float64:i=r.visitFloat64||r.visitFloat;break;case f.Utf8:i=r.visitUtf8;break;case f.LargeUtf8:i=r.visitLargeUtf8;break;case f.Binary:i=r.visitBinary;break;case f.LargeBinary:i=r.visitLargeBinary;break;case f.FixedSizeBinary:i=r.visitFixedSizeBinary;break;case f.Date:i=r.visitDate;break;case f.DateDay:i=r.visitDateDay||r.visitDate;break;case f.DateMillisecond:i=r.visitDateMillisecond||r.visitDate;break;case f.Timestamp:i=r.visitTimestamp;break;case f.TimestampSecond:i=r.visitTimestampSecond||r.visitTimestamp;break;case f.TimestampMillisecond:i=r.visitTimestampMillisecond||r.visitTimestamp;break;case f.TimestampMicrosecond:i=r.visitTimestampMicrosecond||r.visitTimestamp;break;case f.TimestampNanosecond:i=r.visitTimestampNanosecond||r.visitTimestamp;break;case f.Time:i=r.visitTime;break;case f.TimeSecond:i=r.visitTimeSecond||r.visitTime;break;case f.TimeMillisecond:i=r.visitTimeMillisecond||r.visitTime;break;case f.TimeMicrosecond:i=r.visitTimeMicrosecond||r.visitTime;break;case f.TimeNanosecond:i=r.visitTimeNanosecond||r.visitTime;break;case f.Decimal:i=r.visitDecimal;break;case f.List:i=r.visitList;break;case f.Struct:i=r.visitStruct;break;case f.Union:i=r.visitUnion;break;case f.DenseUnion:i=r.visitDenseUnion||r.visitUnion;break;case f.SparseUnion:i=r.visitSparseUnion||r.visitUnion;break;case f.Dictionary:i=r.visitDictionary;break;case f.Interval:i=r.visitInterval;break;case f.IntervalDayTime:i=r.visitIntervalDayTime||r.visitInterval;break;case f.IntervalYearMonth:i=r.visitIntervalYearMonth||r.visitInterval;break;case f.IntervalMonthDayNano:i=r.visitIntervalMonthDayNano||r.visitInterval;break;case f.Duration:i=r.visitDuration;break;case f.DurationSecond:i=r.visitDurationSecond||r.visitDuration;break;case f.DurationMillisecond:i=r.visitDurationMillisecond||r.visitDuration;break;case f.DurationMicrosecond:i=r.visitDurationMicrosecond||r.visitDuration;break;case f.DurationNanosecond:i=r.visitDurationNanosecond||r.visitDuration;break;case f.FixedSizeList:i=r.visitFixedSizeList;break;case f.Map:i=r.visitMap;break}if(typeof i=="function")return i;if(!e)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function vu(r){switch(r.typeId){case f.Null:return f.Null;case f.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?f.Int8:f.Uint8;case 16:return e?f.Int16:f.Uint16;case 32:return e?f.Int32:f.Uint32;case 64:return e?f.Int64:f.Uint64}return f.Int}case f.Float:switch(r.precision){case Y.HALF:return f.Float16;case Y.SINGLE:return f.Float32;case Y.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(r.unit){case w.SECOND:return f.TimeSecond;case w.MILLISECOND:return f.TimeMillisecond;case w.MICROSECOND:return f.TimeMicrosecond;case w.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(r.unit){case w.SECOND:return f.TimestampSecond;case w.MILLISECOND:return f.TimestampMillisecond;case w.MICROSECOND:return f.TimestampMicrosecond;case w.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(r.unit){case ut.DAY:return f.DateDay;case ut.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(r.unit){case et.DAY_TIME:return f.IntervalDayTime;case et.YEAR_MONTH:return f.IntervalYearMonth;case et.MONTH_DAY_NANO:return f.IntervalMonthDayNano}return f.Interval;case f.Duration:switch(r.unit){case w.SECOND:return f.DurationSecond;case w.MILLISECOND:return f.DurationMillisecond;case w.MICROSECOND:return f.DurationMicrosecond;case w.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(r.mode){case Z.Dense:return f.DenseUnion;case Z.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[r.typeId]}'`)}v.prototype.visitInt8=null;v.prototype.visitInt16=null;v.prototype.visitInt32=null;v.prototype.visitInt64=null;v.prototype.visitUint8=null;v.prototype.visitUint16=null;v.prototype.visitUint32=null;v.prototype.visitUint64=null;v.prototype.visitFloat16=null;v.prototype.visitFloat32=null;v.prototype.visitFloat64=null;v.prototype.visitDateDay=null;v.prototype.visitDateMillisecond=null;v.prototype.visitTimestampSecond=null;v.prototype.visitTimestampMillisecond=null;v.prototype.visitTimestampMicrosecond=null;v.prototype.visitTimestampNanosecond=null;v.prototype.visitTimeSecond=null;v.prototype.visitTimeMillisecond=null;v.prototype.visitTimeMicrosecond=null;v.prototype.visitTimeNanosecond=null;v.prototype.visitDenseUnion=null;v.prototype.visitSparseUnion=null;v.prototype.visitIntervalDayTime=null;v.prototype.visitIntervalYearMonth=null;v.prototype.visitIntervalMonthDayNano=null;v.prototype.visitDuration=null;v.prototype.visitDurationSecond=null;v.prototype.visitDurationMillisecond=null;v.prototype.visitDurationMicrosecond=null;v.prototype.visitDurationNanosecond=null;var $a={};Ue($a,{float64ToUint16:()=>cn,uint16ToFloat64:()=>ks});var Su=new Float64Array(1),di=new Uint32Array(Su.buffer);function ks(r){let t=(r&31744)>>10,e=(r&1023)/1024,i=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return i*(e?Number.NaN:1/0);case 0:return i*(e?6103515625e-14*e:0)}return i*Math.pow(2,t-15)*(1+e)}function cn(r){if(r!==r)return 32256;Su[0]=r;let t=(di[1]&2147483648)>>16&65535,e=di[1]&2146435072,i=0;return e>=1089470464?di[0]>0?e=31744:(e=(e&2080374784)>>16,i=(di[1]&1048575)>>10):e<=1056964608?(i=1048576+(di[1]&1048575),i=1048576+(i<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,i=(di[1]&1048575)+512>>10),t|e|i&65535}var O=class extends v{};function N(r){return(t,e,i)=>{if(t.setValid(e,i!=null))return r(t,e,i)}}var ch=(r,t,e)=>{r[t]=Math.floor(e/864e5)},xu=(r,t,e,i)=>{if(e+1<t.length){let n=W(t[e]),s=W(t[e+1]);r.set(i.subarray(0,s-n),n)}},lh=({offset:r,values:t},e,i)=>{let n=r+e;i?t[n>>3]|=1<<n%8:t[n>>3]&=~(1<<n%8)},Qe=({values:r},t,e)=>{r[t]=e},Ha=({values:r},t,e)=>{r[t]=e},Tu=({values:r},t,e)=>{r[t]=cn(e)},uh=(r,t,e)=>{switch(r.type.precision){case Y.HALF:return Tu(r,t,e);case Y.SINGLE:case Y.DOUBLE:return Ha(r,t,e)}},Vs=({values:r},t,e)=>{ch(r,t,e.valueOf())},Ps=({values:r},t,e)=>{r[t]=BigInt(e)},Ga=({stride:r,values:t},e,i)=>{t.set(i.subarray(0,r),r*e)},Bu=({values:r,valueOffsets:t},e,i)=>xu(r,t,e,i),Ou=({values:r,valueOffsets:t},e,i)=>xu(r,t,e,ve(i)),qa=(r,t,e)=>{r.type.unit===ut.DAY?Vs(r,t,e):Ps(r,t,e)},js=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},zs=({values:r},t,e)=>{r[t]=BigInt(e)},Ws=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},$s=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Ja=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return js(r,t,e);case w.MILLISECOND:return zs(r,t,e);case w.MICROSECOND:return Ws(r,t,e);case w.NANOSECOND:return $s(r,t,e)}},Hs=({values:r},t,e)=>{r[t]=e},Gs=({values:r},t,e)=>{r[t]=e},qs=({values:r},t,e)=>{r[t]=e},Js=({values:r},t,e)=>{r[t]=e},Ka=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return Hs(r,t,e);case w.MILLISECOND:return Gs(r,t,e);case w.MICROSECOND:return qs(r,t,e);case w.NANOSECOND:return Js(r,t,e)}},Xa=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},fh=(r,t,e)=>{let i=r.children[0],n=r.valueOffsets,s=Tt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=n[t],c=n[t+1];a<c;)s(i,a++,e[++o]);else for(let o=-1,a=n[t],c=n[t+1];a<c;)s(i,a++,e.get(++o))},dh=(r,t,e)=>{let i=r.children[0],{valueOffsets:n}=r,s=Tt.getVisitFn(i),{[t]:o,[t+1]:a}=n,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(s(i,o,l),++o>=a)break},hh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[s]),ph=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(s)),mh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(n.name)),yh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[n.name]),gh=(r,t,e)=>{let i=r.type.children.map(s=>Tt.getVisitFn(s.type)),n=e instanceof Map?mh(t,e):e instanceof P?ph(t,e):Array.isArray(e)?hh(t,e):yh(t,e);r.type.children.forEach((s,o)=>n(i[o],r.children[o],s,o))},bh=(r,t,e)=>{r.type.mode===Z.Dense?Du(r,t,e):Au(r,t,e)},Du=(r,t,e)=>{let i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Tt.visit(n,r.valueOffsets[t],e)},Au=(r,t,e)=>{let i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Tt.visit(n,t,e)},_h=(r,t,e)=>{var i;(i=r.dictionary)===null||i===void 0||i.set(r.values[t],e)},Ya=(r,t,e)=>{switch(r.type.unit){case et.YEAR_MONTH:return Xs(r,t,e);case et.DAY_TIME:return Ks(r,t,e);case et.MONTH_DAY_NANO:return Ys(r,t,e)}},Ks=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Xs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Ys=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},Zs=({values:r},t,e)=>{r[t]=e},Qs=({values:r},t,e)=>{r[t]=e},to=({values:r},t,e)=>{r[t]=e},eo=({values:r},t,e)=>{r[t]=e},Za=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return Zs(r,t,e);case w.MILLISECOND:return Qs(r,t,e);case w.MICROSECOND:return to(r,t,e);case w.NANOSECOND:return eo(r,t,e)}},wh=(r,t,e)=>{let{stride:i}=r,n=r.children[0],s=Tt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=t*i;++o<i;)s(n,a+o,e[o]);else for(let o=-1,a=t*i;++o<i;)s(n,a+o,e.get(o))};O.prototype.visitBool=N(lh);O.prototype.visitInt=N(Qe);O.prototype.visitInt8=N(Qe);O.prototype.visitInt16=N(Qe);O.prototype.visitInt32=N(Qe);O.prototype.visitInt64=N(Qe);O.prototype.visitUint8=N(Qe);O.prototype.visitUint16=N(Qe);O.prototype.visitUint32=N(Qe);O.prototype.visitUint64=N(Qe);O.prototype.visitFloat=N(uh);O.prototype.visitFloat16=N(Tu);O.prototype.visitFloat32=N(Ha);O.prototype.visitFloat64=N(Ha);O.prototype.visitUtf8=N(Ou);O.prototype.visitLargeUtf8=N(Ou);O.prototype.visitBinary=N(Bu);O.prototype.visitLargeBinary=N(Bu);O.prototype.visitFixedSizeBinary=N(Ga);O.prototype.visitDate=N(qa);O.prototype.visitDateDay=N(Vs);O.prototype.visitDateMillisecond=N(Ps);O.prototype.visitTimestamp=N(Ja);O.prototype.visitTimestampSecond=N(js);O.prototype.visitTimestampMillisecond=N(zs);O.prototype.visitTimestampMicrosecond=N(Ws);O.prototype.visitTimestampNanosecond=N($s);O.prototype.visitTime=N(Ka);O.prototype.visitTimeSecond=N(Hs);O.prototype.visitTimeMillisecond=N(Gs);O.prototype.visitTimeMicrosecond=N(qs);O.prototype.visitTimeNanosecond=N(Js);O.prototype.visitDecimal=N(Xa);O.prototype.visitList=N(fh);O.prototype.visitStruct=N(gh);O.prototype.visitUnion=N(bh);O.prototype.visitDenseUnion=N(Du);O.prototype.visitSparseUnion=N(Au);O.prototype.visitDictionary=N(_h);O.prototype.visitInterval=N(Ya);O.prototype.visitIntervalDayTime=N(Ks);O.prototype.visitIntervalYearMonth=N(Xs);O.prototype.visitIntervalMonthDayNano=N(Ys);O.prototype.visitDuration=N(Za);O.prototype.visitDurationSecond=N(Zs);O.prototype.visitDurationMillisecond=N(Qs);O.prototype.visitDurationMicrosecond=N(to);O.prototype.visitDurationNanosecond=N(eo);O.prototype.visitFixedSizeList=N(wh);O.prototype.visitMap=N(dh);var Tt=new O;var ye=Symbol.for("parent"),hi=Symbol.for("rowIndex"),Ir=class{constructor(t,e){return this[ye]=t,this[hi]=e,new Proxy(this,Ih)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[hi],e=this[ye],i=e.type.children,n={};for(let s=-1,o=i.length;++s<o;)n[i[s].name]=mt.visit(e.children[s],t);return n}toString(){return`{${[...this].map(([t,e])=>`${ue(t)}: ${ue(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Qa(this[ye],this[hi])}},Qa=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Ir.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ye]:{writable:!0,enumerable:!1,configurable:!1,value:null},[hi]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var tc=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ye].type.children.map(e=>e.name)}has(t,e){return t[ye].type.children.some(i=>i.name===e)}getOwnPropertyDescriptor(t,e){if(t[ye].type.children.some(i=>i.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let i=t[ye].type.children.findIndex(n=>n.name===e);if(i!==-1){let n=mt.visit(t[ye].children[i],t[hi]);return Reflect.set(t,e,n),n}}set(t,e,i){let n=t[ye].type.children.findIndex(s=>s.name===e);return n!==-1?(Tt.visit(t[ye].children[n],t[hi],i),Reflect.set(t,e,i)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,i):!1}},Ih=new tc;var S=class extends v{};function A(r){return(t,e)=>t.getValid(e)?r(t,e):null}var vh=(r,t)=>864e5*r[t],Sh=(r,t)=>null,Fu=(r,t,e)=>{if(e+1>=t.length)return null;let i=W(t[e]),n=W(t[e+1]);return r.subarray(i,n)},xh=({offset:r,values:t},e)=>{let i=r+e;return(t[i>>3]&1<<i%8)!==0},Nu=({values:r},t)=>vh(r,t),Eu=({values:r},t)=>W(r[t]),vr=({stride:r,values:t},e)=>t[r*e],Th=({stride:r,values:t},e)=>ks(t[r*e]),Lu=({values:r},t)=>r[t],Bh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Uu=({values:r,valueOffsets:t},e)=>Fu(r,t,e),Mu=({values:r,valueOffsets:t},e)=>{let i=Fu(r,t,e);return i!==null?Gi(i):null},Oh=({values:r},t)=>r[t],Dh=({type:r,values:t},e)=>r.precision!==Y.HALF?t[e]:ks(t[e]),Ah=(r,t)=>r.type.unit===ut.DAY?Nu(r,t):Eu(r,t),Ru=({values:r},t)=>1e3*W(r[t]),Cu=({values:r},t)=>W(r[t]),ku=({values:r},t)=>Pa(r[t],BigInt(1e3)),Vu=({values:r},t)=>Pa(r[t],BigInt(1e6)),Fh=(r,t)=>{switch(r.type.unit){case w.SECOND:return Ru(r,t);case w.MILLISECOND:return Cu(r,t);case w.MICROSECOND:return ku(r,t);case w.NANOSECOND:return Vu(r,t)}},Pu=({values:r},t)=>r[t],ju=({values:r},t)=>r[t],zu=({values:r},t)=>r[t],Wu=({values:r},t)=>r[t],Nh=(r,t)=>{switch(r.type.unit){case w.SECOND:return Pu(r,t);case w.MILLISECOND:return ju(r,t);case w.MICROSECOND:return zu(r,t);case w.NANOSECOND:return Wu(r,t)}},Eh=({values:r,stride:t},e)=>an.decimal(r.subarray(t*e,t*(e+1))),Lh=(r,t)=>{let{valueOffsets:e,stride:i,children:n}=r,{[t*i]:s,[t*i+1]:o}=e,c=n[0].slice(s,o-s);return new P([c])},Uh=(r,t)=>{let{valueOffsets:e,children:i}=r,{[t]:n,[t+1]:s}=e,o=i[0];return new De(o.slice(n,s-n))},Mh=(r,t)=>new Ir(r,t),Rh=(r,t)=>r.type.mode===Z.Dense?$u(r,t):Hu(r,t),$u=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mt.visit(i,r.valueOffsets[t])},Hu=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mt.visit(i,t)},Ch=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},kh=(r,t)=>r.type.unit===et.MONTH_DAY_NANO?Ju(r,t):r.type.unit===et.DAY_TIME?Gu(r,t):qu(r,t),Gu=({values:r},t)=>r.subarray(2*t,2*(t+1)),qu=({values:r},t)=>{let e=r[t],i=new Int32Array(2);return i[0]=Math.trunc(e/12),i[1]=Math.trunc(e%12),i},Ju=({values:r},t)=>r.subarray(4*t,4*(t+1)),Ku=({values:r},t)=>r[t],Xu=({values:r},t)=>r[t],Yu=({values:r},t)=>r[t],Zu=({values:r},t)=>r[t],Vh=(r,t)=>{switch(r.type.unit){case w.SECOND:return Ku(r,t);case w.MILLISECOND:return Xu(r,t);case w.MICROSECOND:return Yu(r,t);case w.NANOSECOND:return Zu(r,t)}},Ph=(r,t)=>{let{stride:e,children:i}=r,s=i[0].slice(t*e,e);return new P([s])};S.prototype.visitNull=A(Sh);S.prototype.visitBool=A(xh);S.prototype.visitInt=A(Oh);S.prototype.visitInt8=A(vr);S.prototype.visitInt16=A(vr);S.prototype.visitInt32=A(vr);S.prototype.visitInt64=A(Lu);S.prototype.visitUint8=A(vr);S.prototype.visitUint16=A(vr);S.prototype.visitUint32=A(vr);S.prototype.visitUint64=A(Lu);S.prototype.visitFloat=A(Dh);S.prototype.visitFloat16=A(Th);S.prototype.visitFloat32=A(vr);S.prototype.visitFloat64=A(vr);S.prototype.visitUtf8=A(Mu);S.prototype.visitLargeUtf8=A(Mu);S.prototype.visitBinary=A(Uu);S.prototype.visitLargeBinary=A(Uu);S.prototype.visitFixedSizeBinary=A(Bh);S.prototype.visitDate=A(Ah);S.prototype.visitDateDay=A(Nu);S.prototype.visitDateMillisecond=A(Eu);S.prototype.visitTimestamp=A(Fh);S.prototype.visitTimestampSecond=A(Ru);S.prototype.visitTimestampMillisecond=A(Cu);S.prototype.visitTimestampMicrosecond=A(ku);S.prototype.visitTimestampNanosecond=A(Vu);S.prototype.visitTime=A(Nh);S.prototype.visitTimeSecond=A(Pu);S.prototype.visitTimeMillisecond=A(ju);S.prototype.visitTimeMicrosecond=A(zu);S.prototype.visitTimeNanosecond=A(Wu);S.prototype.visitDecimal=A(Eh);S.prototype.visitList=A(Lh);S.prototype.visitStruct=A(Mh);S.prototype.visitUnion=A(Rh);S.prototype.visitDenseUnion=A($u);S.prototype.visitSparseUnion=A(Hu);S.prototype.visitDictionary=A(Ch);S.prototype.visitInterval=A(kh);S.prototype.visitIntervalDayTime=A(Gu);S.prototype.visitIntervalYearMonth=A(qu);S.prototype.visitIntervalMonthDayNano=A(Ju);S.prototype.visitDuration=A(Vh);S.prototype.visitDurationSecond=A(Ku);S.prototype.visitDurationMillisecond=A(Xu);S.prototype.visitDurationMicrosecond=A(Yu);S.prototype.visitDurationNanosecond=A(Zu);S.prototype.visitFixedSizeList=A(Ph);S.prototype.visitMap=A(Uh);var mt=new S;var Sr=Symbol.for("keys"),mi=Symbol.for("vals"),pi=Symbol.for("kKeysAsStrings"),ec=Symbol.for("_kKeysAsStrings"),De=class{constructor(t){return this[Sr]=new P([t.children[0]]).memoize(),this[mi]=t.children[1],new Proxy(this,new ic)}get[pi](){return this[ec]||(this[ec]=Array.from(this[Sr].toArray(),String))}[Symbol.iterator](){return new rc(this[Sr],this[mi])}get size(){return this[Sr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Sr],e=this[mi],i={};for(let n=-1,s=t.length;++n<s;)i[t.get(n)]=mt.visit(e,n);return i}toString(){return`{${[...this].map(([t,e])=>`${ue(t)}: ${ue(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},rc=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),mt.visit(this.vals,t)]})}},ic=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[pi]}has(t,e){return t[pi].includes(e)}getOwnPropertyDescriptor(t,e){if(t[pi].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let i=t[pi].indexOf(e);if(i!==-1){let n=mt.visit(Reflect.get(t,mi),i);return Reflect.set(t,e,n),n}}set(t,e,i){let n=t[pi].indexOf(e);return n!==-1?(Tt.visit(Reflect.get(t,mi),n,i),Reflect.set(t,e,i)):Reflect.has(t,e)?Reflect.set(t,e,i):!1}};Object.defineProperties(De.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Sr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[mi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ec]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Qu;function ln(r,t,e,i){let{length:n=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?n:e;return s<0&&(s=(s%n+n)%n),o<0&&(o=(o%n+n)%n),o<s&&(Qu=s,s=o,o=Qu),o>n&&(o=n),i?i(r,s,o):[s,o]}var Pr=(r,t)=>r<0?t+r:r,tf=r=>r!==r;function xr(r){if(typeof r!=="object"||r===null)return tf(r)?tf:e=>e===r;if(r instanceof Date){let e=r.valueOf();return i=>i instanceof Date?i.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?Ma(r,e):!1:r instanceof Map?zh(r):Array.isArray(r)?jh(r):r instanceof P?Wh(r):$h(r,!0)}function jh(r){let t=[];for(let e=-1,i=r.length;++e<i;)t[e]=xr(r[e]);return ro(t)}function zh(r){let t=-1,e=[];for(let i of r.values())e[++t]=xr(i);return ro(e)}function Wh(r){let t=[];for(let e=-1,i=r.length;++e<i;)t[e]=xr(r.get(e));return ro(t)}function $h(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let i=[];for(let n=-1,s=e.length;++n<s;)i[n]=xr(r[e[n]]);return ro(i,e)}function ro(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Hh(r,e);case Map:return ef(r,e,e.keys());case De:case Ir:case Object:case void 0:return ef(r,e,t||Object.keys(e))}return e instanceof P?Gh(r,e):!1}}function Hh(r,t){let e=r.length;if(t.length!==e)return!1;for(let i=-1;++i<e;)if(!r[i](t[i]))return!1;return!0}function Gh(r,t){let e=r.length;if(t.length!==e)return!1;for(let i=-1;++i<e;)if(!r[i](t.get(i)))return!1;return!0}function ef(r,t,e){let i=e[Symbol.iterator](),n=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,a=r.length,c=s.next(),l=i.next(),u=n.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=i.next(),u=n.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(i.return&&i.return(),n.return&&n.return(),s.return&&s.return(),!1)}var sc={};Ue(sc,{BitIterator:()=>jr,getBit:()=>rf,getBool:()=>no,packBools:()=>Wr,popcnt_array:()=>nf,popcnt_bit_range:()=>un,popcnt_uint32:()=>io,setBool:()=>qh,truncateBitmap:()=>zr});function no(r,t,e,i){return(e&1<<i)!==0}function rf(r,t,e,i){return(e&1<<i)>>i}function qh(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function zr(r,t,e){let i=e.byteLength+7&-8;if(r>0||e.byteLength<i){let n=new Uint8Array(i);return n.set(r%8===0?e.subarray(r>>3):Wr(new jr(e,r,t,null,no)).subarray(0,i)),n}return e}function Wr(r){let t=[],e=0,i=0,n=0;for(let o of r)o&&(n|=1<<i),++i===8&&(t[e++]=n,n=i=0);(e===0||i>0)&&(t[e++]=n);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var jr=class{constructor(t,e,i,n,s){this.bytes=t,this.length=i,this.context=n,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function un(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new jr(r,t,e-t,r,rf))s+=o;return s}let i=e>>3<<3,n=t+(t%8===0?0:8-t%8);return un(r,t,n)+un(r,i,e)+nf(r,n>>3,i-n>>3)}function nf(r,t,e){let i=0,n=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:n+e;for(;o-n>=4;)i+=io(s.getUint32(n)),n+=4;for(;o-n>=2;)i+=io(s.getUint16(n)),n+=2;for(;o-n>=1;)i+=io(s.getUint8(n)),n+=1;return i}function io(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Jh=-1,G=class r{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return b.isSparseUnion(t)?this.children.some(e=>e.nullable):b.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:i,nullBitmap:n,typeIds:s}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(b.isUnion(this.type))return this.children.reduce((i,n)=>i+n.nullCount,0);let t=this._nullCount,e;return t<=Jh&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-un(e,this.offset,this.offset+this.length)),t}constructor(t,e,i,n,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1));let c;s instanceof r?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ht(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(b.isUnion(e)){let i=e,n=this.children[i.typeIdToChildIndex[this.typeIds[t]]],s=i.mode===Z.Dense?this.valueOffsets[t]:t;return n.getValid(s)}if(this.nullable&&this.nullCount>0){let i=this.offset+t;return(this.nullBitmap[i>>3]&1<<i%8)!==0}return!0}setValid(t,e){let i,{type:n}=this;if(b.isUnion(n)){let s=n,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===Z.Dense?this.valueOffsets[t]:t;i=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(zr(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[u];i=(d&l)!==0,s[u]=e?d|l:d&~l}return i!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,i=this.length,n=this._nullCount,s=this,o=this.children){return new r(t,e,i,n,s,o,this.dictionary)}slice(t,e){let{stride:i,typeId:n,children:s}=this,o=+(this._nullCount===0)-1,a=n===16?i:1,c=this._sliceBuffers(t,e,i,n);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===f.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:i}=this,n=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);n[e>>3]=(1<<e-(e&-8))-1,i>0&&n.set(zr(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[Yt.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),s)}_sliceBuffers(t,e,i,n){let s,{buffers:o}=this;return(s=o[Yt.TYPE])&&(o[Yt.TYPE]=s.subarray(t,t+e)),(s=o[Yt.OFFSET])&&(o[Yt.OFFSET]=s.subarray(t,t+e+1))||(s=o[Yt.DATA])&&(o[Yt.DATA]=n===6?s:s.subarray(i*t,i*(t+e))),o}_sliceChildren(t,e,i){return t.map(n=>n.slice(e,i))}};G.prototype.children=Object.freeze([]);var oc=class r extends v{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:i=0,["length"]:n=0}=t;return new G(e,i,n,n)}visitBool(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitInt(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitFloat(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitUtf8(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.data),s=D(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.data),s=D(t.nullBitmap),o=vs(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.data),s=D(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.data),s=D(t.nullBitmap),o=vs(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDate(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitTimestamp(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitTime(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDecimal(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitList(t){let{["type"]:e,["offset"]:i=0,["child"]:n}=t,s=D(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,void 0,s],[n])}visitStruct(t){let{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=D(t.nullBitmap),{length:o=n.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,void 0,s],n)}visitUnion(t){let{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=R(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(b.isSparseUnion(e))return new G(e,i,o,a,[void 0,void 0,void 0,s],n);let c=Cr(t.valueOffsets);return new G(e,i,o,a,[c,void 0,void 0,s],n)}visitDictionary(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.indices.ArrayType,t.data),{["dictionary"]:o=new P([new r().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[void 0,s,n],[],o)}visitInterval(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDuration(t){let{["type"]:e,["offset"]:i=0}=t,n=D(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitFixedSizeList(t){let{["type"]:e,["offset"]:i=0,["child"]:n=new r().visit({type:e.valueType})}=t,s=D(t.nullBitmap),{["length"]:o=n.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,void 0,s],[n])}visitMap(t){let{["type"]:e,["offset"]:i=0,["child"]:n=new r().visit({type:e.childType})}=t,s=D(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,void 0,s],[n])}},Kh=new oc;function L(r){return Kh.visit(r)}var fn=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function sf(r){return r.some(t=>t.nullable)}function so(r){return r.reduce((t,e)=>t+e.nullCount,0)}function oo(r){return r.reduce((t,e,i)=>(t[i+1]=t[i]+e.length,t),new Uint32Array(r.length+1))}function ao(r,t,e,i){let n=[];for(let s=-1,o=r.length;++s<o;){let a=r[s],c=t[s],{length:l}=a;if(c>=i)break;if(e>=c+l)continue;if(c>=e&&c+l<=i){n.push(a);continue}let u=Math.max(0,e-c),d=Math.min(i-c,l);n.push(a.slice(u,d-u))}return n.length===0&&n.push(r[0].slice(0,0)),n}function ac(r,t,e,i){let n=0,s=0,o=t.length-1;do{if(n>=o-1)return e<t[o]?i(r,n,e-t[n]):null;s=n+Math.trunc((o-n)*.5),e<t[s]?o=s:n=s}while(n<o)}function dn(r,t){return r.getValid(t)}function yi(r){function t(e,i,n){return r(e[i],n)}return function(e){let i=this.data;return ac(i,this._offsets,e,t)}}function co(r){let t;function e(i,n,s){return r(i[n],s,t)}return function(i,n){let s=this.data;t=n;let o=ac(s,this._offsets,i,e);return t=void 0,o}}function lo(r){let t;function e(i,n,s){let o=s,a=0,c=0;for(let l=n-1,u=i.length;++l<u;){let d=i[l];if(~(a=r(d,t,o)))return c+a;o=0,c+=d.length}return-1}return function(i,n){t=i;let s=this.data,o=typeof n!="number"?e(s,0,0):ac(s,this._offsets,n,e);return t=void 0,o}}var x=class extends v{};function Xh(r,t){return t===null&&r.length>0?0:-1}function Yh(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let i=0;for(let n of new jr(e,r.offset+(t||0),r.length,e,no)){if(!n)return i;++i}return-1}function E(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case f.Union:break;case f.Dictionary:break;default:return Yh(r,e)}let i=mt.getVisitFn(r),n=xr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(n(i(r,s)))return s;return-1}function of(r,t,e){let i=mt.getVisitFn(r),n=xr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(n(i(r,s)))return s;return-1}x.prototype.visitNull=Xh;x.prototype.visitBool=E;x.prototype.visitInt=E;x.prototype.visitInt8=E;x.prototype.visitInt16=E;x.prototype.visitInt32=E;x.prototype.visitInt64=E;x.prototype.visitUint8=E;x.prototype.visitUint16=E;x.prototype.visitUint32=E;x.prototype.visitUint64=E;x.prototype.visitFloat=E;x.prototype.visitFloat16=E;x.prototype.visitFloat32=E;x.prototype.visitFloat64=E;x.prototype.visitUtf8=E;x.prototype.visitLargeUtf8=E;x.prototype.visitBinary=E;x.prototype.visitLargeBinary=E;x.prototype.visitFixedSizeBinary=E;x.prototype.visitDate=E;x.prototype.visitDateDay=E;x.prototype.visitDateMillisecond=E;x.prototype.visitTimestamp=E;x.prototype.visitTimestampSecond=E;x.prototype.visitTimestampMillisecond=E;x.prototype.visitTimestampMicrosecond=E;x.prototype.visitTimestampNanosecond=E;x.prototype.visitTime=E;x.prototype.visitTimeSecond=E;x.prototype.visitTimeMillisecond=E;x.prototype.visitTimeMicrosecond=E;x.prototype.visitTimeNanosecond=E;x.prototype.visitDecimal=E;x.prototype.visitList=E;x.prototype.visitStruct=E;x.prototype.visitUnion=E;x.prototype.visitDenseUnion=of;x.prototype.visitSparseUnion=of;x.prototype.visitDictionary=E;x.prototype.visitInterval=E;x.prototype.visitIntervalDayTime=E;x.prototype.visitIntervalYearMonth=E;x.prototype.visitIntervalMonthDayNano=E;x.prototype.visitDuration=E;x.prototype.visitDurationSecond=E;x.prototype.visitDurationMillisecond=E;x.prototype.visitDurationMicrosecond=E;x.prototype.visitDurationNanosecond=E;x.prototype.visitFixedSizeList=E;x.prototype.visitMap=E;var $r=new x;var T=class extends v{};function F(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(b.isInt(t)&&t.bitWidth!==64||b.isTime(t)&&t.bitWidth!==64||b.isFloat(t)&&t.precision!==Y.HALF))return new fn(r.data.length,i=>{let n=r.data[i];return n.values.subarray(0,n.length)[Symbol.iterator]()});let e=0;return new fn(r.data.length,i=>{let s=r.data[i].length,o=r.slice(e,e+s);return e+=s,new cc(o)})}var cc=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};T.prototype.visitNull=F;T.prototype.visitBool=F;T.prototype.visitInt=F;T.prototype.visitInt8=F;T.prototype.visitInt16=F;T.prototype.visitInt32=F;T.prototype.visitInt64=F;T.prototype.visitUint8=F;T.prototype.visitUint16=F;T.prototype.visitUint32=F;T.prototype.visitUint64=F;T.prototype.visitFloat=F;T.prototype.visitFloat16=F;T.prototype.visitFloat32=F;T.prototype.visitFloat64=F;T.prototype.visitUtf8=F;T.prototype.visitLargeUtf8=F;T.prototype.visitBinary=F;T.prototype.visitLargeBinary=F;T.prototype.visitFixedSizeBinary=F;T.prototype.visitDate=F;T.prototype.visitDateDay=F;T.prototype.visitDateMillisecond=F;T.prototype.visitTimestamp=F;T.prototype.visitTimestampSecond=F;T.prototype.visitTimestampMillisecond=F;T.prototype.visitTimestampMicrosecond=F;T.prototype.visitTimestampNanosecond=F;T.prototype.visitTime=F;T.prototype.visitTimeSecond=F;T.prototype.visitTimeMillisecond=F;T.prototype.visitTimeMicrosecond=F;T.prototype.visitTimeNanosecond=F;T.prototype.visitDecimal=F;T.prototype.visitList=F;T.prototype.visitStruct=F;T.prototype.visitUnion=F;T.prototype.visitDenseUnion=F;T.prototype.visitSparseUnion=F;T.prototype.visitDictionary=F;T.prototype.visitInterval=F;T.prototype.visitIntervalDayTime=F;T.prototype.visitIntervalYearMonth=F;T.prototype.visitIntervalMonthDayNano=F;T.prototype.visitDuration=F;T.prototype.visitDurationSecond=F;T.prototype.visitDurationMillisecond=F;T.prototype.visitDurationMicrosecond=F;T.prototype.visitDurationNanosecond=F;T.prototype.visitFixedSizeList=F;T.prototype.visitMap=F;var gi=new T;var af,cf={},lf={},P=class r{constructor(t){var e,i,n;let s=t[0]instanceof r?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof G)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=cf[o.typeId],u=s[0];this.isValid=d=>dn(u,d),this.get=d=>a(u,d),this.set=(d,p)=>c(u,d,p),this.indexOf=d=>l(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,lf[o.typeId]),this._offsets=oo(s);break}this.data=s,this.type=o,this.stride=Ht(o),this.numChildren=(n=(i=o.children)===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return sf(this.data)}get nullCount(){return so(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Pr(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return gi.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(ln(this,t,e,({data:i,_offsets:n},s,o)=>ao(i,n,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:i,stride:n,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*n),o.offset),o.offset+=c*n,o),{array:new s(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return b.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(b.isDictionary(this.type)){let t=new uo(this.data[0].dictionary),e=this.data.map(i=>{let n=i.clone();return n.dictionary=t,n});return new r(e)}return new uo(this)}unmemoize(){if(b.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(i=>{let n=i.clone();return n.dictionary=t,n});return new r(e)}return this}};af=Symbol.toStringTag;P[af]=(r=>{r.type=b.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(f).map(e=>f[e]).filter(e=>typeof e=="number"&&e!==f.NONE);for(let e of t){let i=mt.getVisitFnByTypeId(e),n=Tt.getVisitFnByTypeId(e),s=$r.getVisitFnByTypeId(e);cf[e]={get:i,set:n,indexOf:s},lf[e]=Object.create(r,{isValid:{value:yi(dn)},get:{value:yi(mt.getVisitFnByTypeId(e))},set:{value:co(Tt.getVisitFnByTypeId(e))},indexOf:{value:lo($r.getVisitFnByTypeId(e))}})}return"Vector"})(P.prototype);var uo=class r extends P{constructor(t){super(t.data);let e=this.get,i=this.set,n=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){i.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new r(n.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new P(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function uf(r){if(!r||r.length<=0)return function(n){return!0};let t="",e=r.filter(i=>i===i);return e.length>0&&(t=`
14
+ ${JSON.stringify(e)}`);let{interceptors:i}=e!=null?e:{};return new qi({baseUrl:r,timeout:t,interceptors:i})};var Md={writeTransport:r=>new Ci(r),queryTransport:Yl},kr=Md;var Ji=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_transport");var e;this._transport=(e=this._options.transport)!=null?e:kr.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_options;_createWritePath(t,e,i){let n=e.precision,s,o=[];return i&&o.push(`org=${encodeURIComponent(i)}`),e.useV2Api?(s="/api/v2/write",o.push(`bucket=${encodeURIComponent(t)}`),o.push(`precision=${la(n)}`)):(s="/api/v3/write_lp",o.push(`db=${encodeURIComponent(t)}`),o.push(`precision=${ua(n)}`),e.noSync&&o.push("no_sync=true"),e.acceptPartial===!1&&o.push("accept_partial=false")),`${s}?${o.join("&")}`}doWrite(t,e,i,n){if(this._closed)return Promise.reject(new Error("writeApi: already closed!"));let o={...oa,...n};if(o.useV2Api&&o.noSync)return Promise.reject(new ve("invalid write options: noSync requires useV2Api=false"));if(t.length<=0||t.length===1&&t[0]==="")return Promise.resolve();let a,c,l=new Promise((_,C)=>{a=_,c=C}),u,d,p={responseStarted(_,C){u=C,d=_},error(_){if(_ instanceof re&&_.json&&typeof _.json.error=="string"&&_.json.error.includes("hinted handoff queue not empty")){Er.warn(`Write to InfluxDB returns: ${_.json.error}`),u=204,p.complete();return}if(_ instanceof re){let C=u!=null?u:_.statusCode;C===405&&o.useV2Api&&(_.message="Server doesn't support the V2 API endpoint (/api/v2/write). Set useV2Api=false to use the V3 API endpoint."),C===405&&!o.useV2Api&&(_.message="Server doesn't support the V3 API endpoint (/api/v3/write_lp). Set useV2Api=true to use the V2 API endpoint.");let rt=Mi.fromHttpError(_);rt&&(_=rt)}Er.error("Write to InfluxDB failed.",_),c(_)},complete(){if(u==null||u>=200&&u<300)a();else{let _=`2xx HTTP response status code expected, but ${u} returned`,C=new re(u,_,void 0,"0",d);C.message=_,p.error(C)}}},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...n==null?void 0:n.headers},gzipThreshold:o.gzipThreshold,timeout:o.timeout};return this._transport.send(this._createWritePath(e,o,i),t.join(`
15
+ `),m,p),l}async close(){this._closed=!0}};function Ql(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(e[i[n]]=r[i[n]]);return e}function g(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(r,t||[])).next())})}function Zl(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function U(r){return this instanceof U?(this.v=r,this):new U(r)}function zt(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),n,s=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(m){return function(_){return Promise.resolve(_).then(m,d)}}function a(m,_){i[m]&&(n[m]=function(C){return new Promise(function(rt,dt){s.push([m,C,rt,dt])>1||c(m,C)})},_&&(n[m]=_(n[m])))}function c(m,_){try{l(i[m](_))}catch(C){p(s[0][3],C)}}function l(m){m.value instanceof U?Promise.resolve(m.value.v).then(u,d):p(s[0][2],m)}function u(m){c("next",m)}function d(m){c("throw",m)}function p(m,_){m(_),s.shift(),s.length&&c(s[0][0],s[0][1])}}function oi(r){var t,e;return t={},i("next"),i("throw",function(n){throw n}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(n,s){t[n]=r[n]?function(o){return(e=!e)?{value:U(r[n](o)),done:!1}:s?s(o):o}:s}}function ie(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Zl=="function"?Zl(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(s){e[s]=r[s]&&function(o){return new Promise(function(a,c){o=r[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var Pa={};Re(Pa,{compareArrayLike:()=>Ca,joinUint8Arrays:()=>Wt,memcpy:()=>Yi,rebaseValueOffsets:()=>Bs,toArrayBufferView:()=>R,toArrayBufferViewAsyncIterator:()=>oe,toArrayBufferViewIterator:()=>Te,toBigInt64Array:()=>Ts,toBigUint64Array:()=>Wd,toFloat32Array:()=>$d,toFloat32ArrayAsyncIterator:()=>oh,toFloat32ArrayIterator:()=>Zd,toFloat64Array:()=>Hd,toFloat64ArrayAsyncIterator:()=>ah,toFloat64ArrayIterator:()=>Qd,toInt16Array:()=>Vd,toInt16ArrayAsyncIterator:()=>rh,toInt16ArrayIterator:()=>Jd,toInt32Array:()=>Cr,toInt32ArrayAsyncIterator:()=>ih,toInt32ArrayIterator:()=>Xd,toInt8Array:()=>Pd,toInt8ArrayAsyncIterator:()=>eh,toInt8ArrayIterator:()=>qd,toUint16Array:()=>jd,toUint16ArrayAsyncIterator:()=>nh,toUint16ArrayIterator:()=>Kd,toUint32Array:()=>zd,toUint32ArrayAsyncIterator:()=>sh,toUint32ArrayIterator:()=>Yd,toUint8Array:()=>A,toUint8ArrayAsyncIterator:()=>ka,toUint8ArrayIterator:()=>Ra,toUint8ClampedArray:()=>Gd,toUint8ClampedArrayAsyncIterator:()=>ch,toUint8ClampedArrayIterator:()=>th});var tu=new TextDecoder("utf-8"),Xi=tu.decode.bind(tu),Rd=new TextEncoder,xe=r=>Rd.encode(r);var kd=r=>typeof r=="number",eu=r=>typeof r=="boolean",wt=r=>typeof r=="function",Dt=r=>r!=null&&Object(r)===r,ne=r=>Dt(r)&&wt(r.then);var se=r=>Dt(r)&&wt(r[Symbol.iterator]),Xt=r=>Dt(r)&&wt(r[Symbol.asyncIterator]),_s=r=>Dt(r)&&Dt(r.schema);var ws=r=>Dt(r)&&"done"in r&&"value"in r;var Is=r=>Dt(r)&&wt(r.stat)&&kd(r.fd);var vs=r=>Dt(r)&&Ki(r.body),Ss=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ru=r=>Dt(r)&&wt(r.abort)&&wt(r.getWriter)&&!Ss(r),Ki=r=>Dt(r)&&wt(r.cancel)&&wt(r.getReader)&&!Ss(r),iu=r=>Dt(r)&&wt(r.end)&&wt(r.write)&&eu(r.writable)&&!Ss(r),xs=r=>Dt(r)&&wt(r.read)&&wt(r.pipe)&&eu(r.readable)&&!Ss(r),nu=r=>Dt(r)&&wt(r.clear)&&wt(r.bytes)&&wt(r.position)&&wt(r.setPosition)&&wt(r.capacity)&&wt(r.getBufferIdentifier)&&wt(r.createLong);var Ma=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:ArrayBuffer;function Cd(r){let t=r[0]?[r[0]]:[],e,i,n,s;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:n}=o,{byteOffset:i,byteLength:s}=a,e+n<i||i+s<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,i-e+s)}return t}function Yi(r,t,e=0,i=t.byteLength){let n=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,n),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(i,n));return s.set(o,e),r}function Wt(r,t){let e=Cd(r),i=e.reduce((u,d)=>u+d.byteLength,0),n,s,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,i);for(let u=e.length;++c<u;){if(n=e[c],s=n.subarray(0,Math.min(n.length,l-a)),l<=a+s.length){s.length<n.length?e[c]=n.subarray(s.length):s.length===n.length&&c++,o?Yi(o,s,a):o=s;break}Yi(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),i-(o?o.byteLength:0)]}function R(r,t){let e=ws(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=xe(e)),e instanceof ArrayBuffer?new r(e):e instanceof Ma?new r(e):nu(e)?R(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Pd=r=>R(Int8Array,r),Vd=r=>R(Int16Array,r),Cr=r=>R(Int32Array,r),Ts=r=>R(BigInt64Array,r),A=r=>R(Uint8Array,r),jd=r=>R(Uint16Array,r),zd=r=>R(Uint32Array,r),Wd=r=>R(BigUint64Array,r),$d=r=>R(Float32Array,r),Hd=r=>R(Float64Array,r),Gd=r=>R(Uint8ClampedArray,r),Ua=r=>(r.next(),r);function*Te(r,t){let e=function*(n){yield n},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ma?e(t):se(t)?t:e(t);return yield*Ua((function*(n){let s=null;do s=n.next(yield R(r,s));while(!s.done)})(i[Symbol.iterator]())),new r}var qd=r=>Te(Int8Array,r),Jd=r=>Te(Int16Array,r),Xd=r=>Te(Int32Array,r),Ra=r=>Te(Uint8Array,r),Kd=r=>Te(Uint16Array,r),Yd=r=>Te(Uint32Array,r),Zd=r=>Te(Float32Array,r),Qd=r=>Te(Float64Array,r),th=r=>Te(Uint8ClampedArray,r);function oe(r,t){return zt(this,arguments,function*(){if(ne(t))return yield U(yield U(yield*oi(ie(oe(r,yield U(t))))));let i=function(o){return zt(this,arguments,function*(){yield yield U(yield U(o))})},n=function(o){return zt(this,arguments,function*(){yield U(yield*oi(ie(Ua((function*(a){let c=null;do c=a.next(yield c==null?void 0:c.value);while(!c.done)})(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ma?i(t):se(t)?n(t):Xt(t)?t:i(t);return yield U(yield*oi(ie(Ua((function(o){return zt(this,arguments,function*(){let a=null;do a=yield U(o.next(yield yield U(R(r,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield U(new r)})}var eh=r=>oe(Int8Array,r),rh=r=>oe(Int16Array,r),ih=r=>oe(Int32Array,r),ka=r=>oe(Uint8Array,r),nh=r=>oe(Uint16Array,r),sh=r=>oe(Uint32Array,r),oh=r=>oe(Float32Array,r),ah=r=>oe(Float64Array,r),ch=r=>oe(Uint8ClampedArray,r);function Bs(r,t,e){if(r!==0){e=e.slice(0,t);for(let i=-1,n=e.length;++i<n;)e[i]+=r}return e.subarray(0,t)}function Ca(r,t){let e=0,i=r.length;if(i!==t.length)return!1;if(i>0)do if(r[e]!==t[e])return!1;while(++e<i);return!0}var St={fromIterable(r){return Os(lh(r))},fromAsyncIterable(r){return Os(uh(r))},fromDOMStream(r){return Os(fh(r))},fromNodeStream(r){return Os(dh(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},Os=r=>(r.next(),r);function*lh(r){let t,e=!1,i=[],n,s,o,a=0;function c(){return s==="peek"?Wt(i,o)[0]:([n,i,a]=Wt(i,o),n)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let l=Ra(r)[Symbol.iterator]();try{do if({done:t,value:n}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&n.byteLength>0&&(i.push(n),a+=n.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){e=!0,typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function uh(r){return zt(this,arguments,function*(){let e,i=!1,n=[],s,o,a,c=0;function l(){return o==="peek"?Wt(n,a)[0]:([s,n,c]=Wt(n,a),s)}({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0});let u=ka(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.next()):yield U(u.next(a-c)),!e&&s.byteLength>0&&(n.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield U(l()));while(a<c);while(!e)}catch(d){i=!0,typeof u.throw=="function"&&(yield U(u.throw(d)))}finally{i===!1&&typeof u.return=="function"&&(yield U(u.return(new Uint8Array(0))))}return yield U(null)})}function fh(r){return zt(this,arguments,function*(){let e=!1,i=!1,n=[],s,o,a,c=0;function l(){return o==="peek"?Wt(n,a)[0]:([s,n,c]=Wt(n,a),s)}({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0});let u=new ja(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.read()):yield U(u.read(a-c)),!e&&s.byteLength>0&&(n.push(A(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield U(l()));while(a<c);while(!e)}catch(d){i=!0,yield U(u.cancel(d))}finally{i===!1?yield U(u.cancel()):r.locked&&u.releaseLock()}return yield U(null)})}var ja=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return g(this,void 0,void 0,function*(){let{reader:e,source:i}=this;e&&(yield e.cancel(t).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(t){return g(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=A(e)),e})}},Va=(r,t)=>{let e=n=>i([t,n]),i;return[t,e,new Promise(n=>(i=n)&&r.once(t,e))]};function dh(r){return zt(this,arguments,function*(){let e=[],i="error",n=!1,s=null,o,a,c=0,l=[],u;function d(){return o==="peek"?Wt(l,a)[0]:([u,l,c]=Wt(l,a),u)}if({cmd:o,size:a}=(yield yield U(null))||{cmd:"read",size:0},r.isTTY)return yield yield U(new Uint8Array(0)),yield U(null);try{e[0]=Va(r,"end"),e[1]=Va(r,"error");do{if(e[2]=Va(r,"readable"),[i,s]=yield U(Promise.race(e.map(m=>m[2]))),i==="error")break;if((n=i==="end")||(Number.isFinite(a-c)?(u=A(r.read(a-c)),u.byteLength<a-c&&(u=A(r.read()))):u=A(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),n||a<=c)do({cmd:o,size:a}=yield yield U(d()));while(a<c)}while(!n)}finally{yield U(p(e,i==="error"?s:null))}return yield U(null);function p(m,_){return u=l=null,new Promise((C,rt)=>{for(let[dt,pt]of m)r.off(dt,pt);try{let dt=r.destroy;dt&&dt.call(r,_),_=void 0}catch(dt){_=dt||_}finally{_!=null?rt(_):C()}})}})}var J;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(J||(J={}));var Z;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(Z||(Z={}));var Y;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Y||(Y={}));var ut;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(ut||(ut={}));var w;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(w||(w={}));var et;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(et||(et={}));var Be=new Int32Array(2),As=new Float32Array(Be.buffer),Ds=new Float64Array(Be.buffer),ai=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Zi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Zi||(Zi={}));var xt=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Be[0]=this.readInt32(t),As[0]}readFloat64(t){return Be[ai?0:1]=this.readInt32(t),Be[ai?1:0]=this.readInt32(t+4),Ds[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){As[0]=e,this.writeInt32(t,Be[0])}writeFloat64(t,e){Ds[0]=e,this.writeInt32(t,Be[ai?0:1]),this.writeInt32(t+4,Be[ai?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let i=this.readInt32(t);t+=4;let n=this.bytes_.subarray(t,t+i);return e===Zi.UTF8_BYTES?n:this.text_decoder_.decode(n)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let i=[];for(let n=0;n<e;++n){let s=t(n);s!==null&&i.push(s)}return i}createObjList(t,e){let i=[];for(let n=0;n<e;++n){let s=t(n);s!==null&&i.push(s.unpack())}return i}};var Pr=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=xt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){let n=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||e!==i)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let i=e<<1,n=xt.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let n=2;this.addInt16(t-this.object_start);let s=(i+n)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=2;l<s;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){let n=i?4:0;if(e){let s=e;if(this.prep(this.minalign,8+n),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=3;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(!(e<this.bb.readInt16(n)&&this.bb.readInt16(n+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let i=0;i<t.length;++i){let n=t[i];if(n!==null)e.push(this.createObjectOffset(n));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Vr;(function(r){r[r.BUFFER=0]="BUFFER"})(Vr||(Vr={}));var Ft;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ft||(Ft={}));var Pe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Ft.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Vr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ft.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Vr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,i){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,i),r.endBodyCompression(t)}};var ci=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,i){return t.prep(8,16),t.writeInt64(BigInt(i!=null?i:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var li=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,i){return t.prep(8,16),t.writeInt64(BigInt(i!=null?i:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Mt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let i=this.bb.__offset(this.bb_pos,6);return i?(e||new li).__init(this.bb.__vector(this.bb_pos+i)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new ci).__init(this.bb.__vector(this.bb_pos+i)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new Pe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var Ve=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Mt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var pr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(pr||(pr={}));var Qi;(function(r){r[r.DenseArray=0]="DenseArray"})(Qi||(Qi={}));var ce=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,i){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,i),r.endInt(t)}};var Oe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ce).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Qi.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,Qi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var It=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,i){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,i),r.endKeyValue(t)}};var tn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}};var en=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}};var mr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ut.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,ut.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var Ae=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,i,n){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,i),r.addBitWidth(t,n),r.endDecimal(t)}};var yr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,w.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}};var gr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}};var br=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}};var _r=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Y.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Y.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}};var wr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):et.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,et.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var rn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}};var nn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}};var sn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}};var Ir=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}};var on=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}};var an=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}};var je=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,w.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,i){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,i),r.endTime(t)}};var ze=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):w.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,w.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,i){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,i),r.endTimestamp(t)}};var le=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Z.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,Z.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,i){return r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,i),r.endUnion(t)}};var cn=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}};var Q;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(Q||(Q={}));var Bt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Q.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Oe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let i=this.bb.__offset(this.bb_pos,14);return i?(e||new r).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,16);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,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Q.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(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 startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,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 endField(t){return t.endObject()}};var Rt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):pr.Little}fields(t,e){let i=this.bb.__offset(this.bb_pos,6);return i?(e||new Bt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,8);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,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,pr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(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 startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,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 addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,i,n,s){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,i),r.addCustomMetadata(t,n),r.addFeatures(t,s),r.endSchema(t)}};var V;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(V||(V={}));var f;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond",r[r.IntervalMonthDayNano=-31]="IntervalMonthDayNano"})(f||(f={}));var Yt;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Yt||(Yt={}));var ac={};Re(ac,{clampRange:()=>dn,createElementComparator:()=>Tr,wrapIndex:()=>jr});var za={};Re(za,{valueToString:()=>ue});function ue(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>ue(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Ga={};Re(Ga,{BN:()=>un,bigNumToBigInt:()=>ou,bigNumToNumber:()=>Ha,bigNumToString:()=>di,isArrowBigNumSymbol:()=>su});function W(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function Wa(r,t){return W(r/t)+W(r%t)/W(t)}var su=Symbol.for("isArrowBigNum");function fe(r,...t){return t.length===0?Object.setPrototypeOf(R(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}fe.prototype[su]=!0;fe.prototype.toJSON=function(){return`"${di(this)}"`};fe.prototype.valueOf=function(r){return Ha(this,r)};fe.prototype.toString=function(){return di(this)};fe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Ha(this);case"string":return di(this);case"default":return ou(this)}return di(this)};function ui(...r){return fe.apply(this,r)}function fi(...r){return fe.apply(this,r)}function ln(...r){return fe.apply(this,r)}Object.setPrototypeOf(ui.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(fi.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(ln.prototype,Object.create(Uint32Array.prototype));Object.assign(ui.prototype,fe.prototype,{constructor:ui,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(fi.prototype,fe.prototype,{constructor:fi,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(ln.prototype,fe.prototype,{constructor:ln,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var hh=BigInt(4294967296)*BigInt(4294967296),ph=hh-BigInt(1);function Ha(r,t){let{buffer:e,byteOffset:i,byteLength:n,signed:s}=r,o=new BigUint64Array(e,i,n/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^ph)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"&&t>0){let u=BigInt("1".padEnd(t+1,"0")),d=c/u,p=a?-(c%u):c%u,m=W(d),_=`${p}`.padStart(t,"0");return+`${a&&m===0?"-":""}${m}.${_}`}return W(c)}function di(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return $a(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return $a(r);t=t.slice();let i=1;for(let s=0;s<t.length;s++){let o=t[s],a=~o+i;t[s]=a,i&=o===0?1:0}return`-${$a(t)}`}function ou(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:di(r)}function $a(r){let t="",e=new Uint32Array(2),i=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),n=new Uint32Array((i=new Uint16Array(i).reverse()).buffer),s=-1,o=i.length-1;do{for(e[0]=i[s=0];s<o;)i[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+i[s];i[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(n[0]||n[1]||n[2]||n[3]);return t!=null?t:"0"}var un=class r{static new(t,e){switch(e){case!0:return new ui(t);case!1:return new fi(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new ui(t)}return t.byteLength===16?new ln(t):new fi(t)}static signed(t){return new ui(t)}static unsigned(t){return new fi(t)}static decimal(t){return new ln(t)}constructor(t,e){return r.new(t,e)}};var au,cu,lu,uu,fu,du,hu,pu,mu,yu,gu,bu,_u,wu,Iu,vu,Su,xu,Tu,Bu,Ou,Au,b=class r{static isNull(t){return(t==null?void 0:t.typeId)===f.Null}static isInt(t){return(t==null?void 0:t.typeId)===f.Int}static isFloat(t){return(t==null?void 0:t.typeId)===f.Float}static isBinary(t){return(t==null?void 0:t.typeId)===f.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===f.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===f.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===f.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===f.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===f.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===f.Date}static isTime(t){return(t==null?void 0:t.typeId)===f.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===f.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===f.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===f.Duration}static isList(t){return(t==null?void 0:t.typeId)===f.List}static isStruct(t){return(t==null?void 0:t.typeId)===f.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===f.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===f.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===f.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===f.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===f.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===Z.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===Z.Sparse}constructor(t){this.typeId=t}};au=Symbol.toStringTag;b[au]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(b.prototype);var Nt=class extends b{constructor(){super(f.Null)}toString(){return"Null"}};cu=Symbol.toStringTag;Nt[cu]=(r=>r[Symbol.toStringTag]="Null")(Nt.prototype);var vt=class extends b{constructor(t,e){super(f.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};lu=Symbol.toStringTag;vt[lu]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(vt.prototype);var Ns=class extends vt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Es=class extends vt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},De=class extends vt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Ls=class extends vt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Us=class extends vt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Ms=class extends vt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Rs=class extends vt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},ks=class extends vt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ns.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Es.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(De.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Ls.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Us.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Ms.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Rs.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(ks.prototype,"ArrayType",{value:BigUint64Array});var Zt=class extends b{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Y.HALF:return Uint16Array;case Y.SINGLE:return Float32Array;case Y.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};uu=Symbol.toStringTag;Zt[uu]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Zt.prototype);var Cs=class extends Zt{constructor(){super(Y.HALF)}},Ps=class extends Zt{constructor(){super(Y.SINGLE)}},Vs=class extends Zt{constructor(){super(Y.DOUBLE)}};Object.defineProperty(Cs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ps.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Vs.prototype,"ArrayType",{value:Float64Array});var We=class extends b{constructor(){super(f.Binary)}toString(){return"Binary"}};fu=Symbol.toStringTag;We[fu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(We.prototype);var $e=class extends b{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}};du=Symbol.toStringTag;$e[du]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))($e.prototype);var He=class extends b{constructor(){super(f.Utf8)}toString(){return"Utf8"}};hu=Symbol.toStringTag;He[hu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(He.prototype);var Ge=class extends b{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}};pu=Symbol.toStringTag;Ge[pu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Ge.prototype);var qe=class extends b{constructor(){super(f.Bool)}toString(){return"Bool"}};mu=Symbol.toStringTag;qe[mu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(qe.prototype);var Je=class extends b{constructor(t,e,i=128){super(f.Decimal),this.scale=t,this.precision=e,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};yu=Symbol.toStringTag;Je[yu]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Je.prototype);var Xe=class extends b{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${ut[this.unit]}>`}get ArrayType(){return this.unit===ut.DAY?Int32Array:BigInt64Array}};gu=Symbol.toStringTag;Xe[gu]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Xe.prototype);var Ke=class extends b{constructor(t,e){super(f.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${w[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};bu=Symbol.toStringTag;Ke[bu]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Ke.prototype);var Ye=class extends b{constructor(t,e){super(f.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${w[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};_u=Symbol.toStringTag;Ye[_u]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Ye.prototype);var Ze=class extends b{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${et[this.unit]}>`}};wu=Symbol.toStringTag;Ze[wu]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Ze.prototype);var Qe=class extends b{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${w[this.unit]}>`}};Iu=Symbol.toStringTag;Qe[Iu]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Qe.prototype);var de=class extends b{constructor(t){super(f.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};vu=Symbol.toStringTag;de[vu]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(de.prototype);var nt=class extends b{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};Su=Symbol.toStringTag;nt[Su]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(nt.prototype);var he=class extends b{constructor(t,e,i){super(f.Union),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((n,s,o)=>(n[s]=o)&&n||n,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};xu=Symbol.toStringTag;he[xu]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(he.prototype);var tr=class extends b{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Tu=Symbol.toStringTag;tr[Tu]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(tr.prototype);var pe=class extends b{constructor(t,e){super(f.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};Bu=Symbol.toStringTag;pe[Bu]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(pe.prototype);var me=class extends b{constructor(t,e=!1){var i,n,s;if(super(f.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((i=t==null?void 0:t.type)===null||i===void 0)&&i.children)){let o=(n=t==null?void 0:t.type)===null||n===void 0?void 0:n.children[0];o&&(o.name="key");let a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};Ou=Symbol.toStringTag;me[Ou]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(me.prototype);var mh=(r=>()=>++r)(-1),$t=class extends b{constructor(t,e,i,n){super(f.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=i==null?mh():W(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};Au=Symbol.toStringTag;$t[Au]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))($t.prototype);function Ht(r){let t=r;switch(r.typeId){case f.Decimal:return r.bitWidth/32;case f.Interval:return t.unit===et.MONTH_DAY_NANO?4:1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}var v=class{visitMany(t,...e){return t.map((i,n)=>this.visit(i,...e.map(s=>s[n])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return yh(this,t,e)}getVisitFnByTypeId(t,e=!0){return hi(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function yh(r,t,e=!0){return typeof t=="number"?hi(r,t,e):typeof t=="string"&&t in f?hi(r,f[t],e):t&&t instanceof b?hi(r,Du(t),e):t!=null&&t.type&&t.type instanceof b?hi(r,Du(t.type),e):hi(r,f.NONE,e)}function hi(r,t,e=!0){let i=null;switch(t){case f.Null:i=r.visitNull;break;case f.Bool:i=r.visitBool;break;case f.Int:i=r.visitInt;break;case f.Int8:i=r.visitInt8||r.visitInt;break;case f.Int16:i=r.visitInt16||r.visitInt;break;case f.Int32:i=r.visitInt32||r.visitInt;break;case f.Int64:i=r.visitInt64||r.visitInt;break;case f.Uint8:i=r.visitUint8||r.visitInt;break;case f.Uint16:i=r.visitUint16||r.visitInt;break;case f.Uint32:i=r.visitUint32||r.visitInt;break;case f.Uint64:i=r.visitUint64||r.visitInt;break;case f.Float:i=r.visitFloat;break;case f.Float16:i=r.visitFloat16||r.visitFloat;break;case f.Float32:i=r.visitFloat32||r.visitFloat;break;case f.Float64:i=r.visitFloat64||r.visitFloat;break;case f.Utf8:i=r.visitUtf8;break;case f.LargeUtf8:i=r.visitLargeUtf8;break;case f.Binary:i=r.visitBinary;break;case f.LargeBinary:i=r.visitLargeBinary;break;case f.FixedSizeBinary:i=r.visitFixedSizeBinary;break;case f.Date:i=r.visitDate;break;case f.DateDay:i=r.visitDateDay||r.visitDate;break;case f.DateMillisecond:i=r.visitDateMillisecond||r.visitDate;break;case f.Timestamp:i=r.visitTimestamp;break;case f.TimestampSecond:i=r.visitTimestampSecond||r.visitTimestamp;break;case f.TimestampMillisecond:i=r.visitTimestampMillisecond||r.visitTimestamp;break;case f.TimestampMicrosecond:i=r.visitTimestampMicrosecond||r.visitTimestamp;break;case f.TimestampNanosecond:i=r.visitTimestampNanosecond||r.visitTimestamp;break;case f.Time:i=r.visitTime;break;case f.TimeSecond:i=r.visitTimeSecond||r.visitTime;break;case f.TimeMillisecond:i=r.visitTimeMillisecond||r.visitTime;break;case f.TimeMicrosecond:i=r.visitTimeMicrosecond||r.visitTime;break;case f.TimeNanosecond:i=r.visitTimeNanosecond||r.visitTime;break;case f.Decimal:i=r.visitDecimal;break;case f.List:i=r.visitList;break;case f.Struct:i=r.visitStruct;break;case f.Union:i=r.visitUnion;break;case f.DenseUnion:i=r.visitDenseUnion||r.visitUnion;break;case f.SparseUnion:i=r.visitSparseUnion||r.visitUnion;break;case f.Dictionary:i=r.visitDictionary;break;case f.Interval:i=r.visitInterval;break;case f.IntervalDayTime:i=r.visitIntervalDayTime||r.visitInterval;break;case f.IntervalYearMonth:i=r.visitIntervalYearMonth||r.visitInterval;break;case f.IntervalMonthDayNano:i=r.visitIntervalMonthDayNano||r.visitInterval;break;case f.Duration:i=r.visitDuration;break;case f.DurationSecond:i=r.visitDurationSecond||r.visitDuration;break;case f.DurationMillisecond:i=r.visitDurationMillisecond||r.visitDuration;break;case f.DurationMicrosecond:i=r.visitDurationMicrosecond||r.visitDuration;break;case f.DurationNanosecond:i=r.visitDurationNanosecond||r.visitDuration;break;case f.FixedSizeList:i=r.visitFixedSizeList;break;case f.Map:i=r.visitMap;break}if(typeof i=="function")return i;if(!e)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function Du(r){switch(r.typeId){case f.Null:return f.Null;case f.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?f.Int8:f.Uint8;case 16:return e?f.Int16:f.Uint16;case 32:return e?f.Int32:f.Uint32;case 64:return e?f.Int64:f.Uint64}return f.Int}case f.Float:switch(r.precision){case Y.HALF:return f.Float16;case Y.SINGLE:return f.Float32;case Y.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(r.unit){case w.SECOND:return f.TimeSecond;case w.MILLISECOND:return f.TimeMillisecond;case w.MICROSECOND:return f.TimeMicrosecond;case w.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(r.unit){case w.SECOND:return f.TimestampSecond;case w.MILLISECOND:return f.TimestampMillisecond;case w.MICROSECOND:return f.TimestampMicrosecond;case w.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(r.unit){case ut.DAY:return f.DateDay;case ut.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(r.unit){case et.DAY_TIME:return f.IntervalDayTime;case et.YEAR_MONTH:return f.IntervalYearMonth;case et.MONTH_DAY_NANO:return f.IntervalMonthDayNano}return f.Interval;case f.Duration:switch(r.unit){case w.SECOND:return f.DurationSecond;case w.MILLISECOND:return f.DurationMillisecond;case w.MICROSECOND:return f.DurationMicrosecond;case w.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(r.mode){case Z.Dense:return f.DenseUnion;case Z.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[r.typeId]}'`)}v.prototype.visitInt8=null;v.prototype.visitInt16=null;v.prototype.visitInt32=null;v.prototype.visitInt64=null;v.prototype.visitUint8=null;v.prototype.visitUint16=null;v.prototype.visitUint32=null;v.prototype.visitUint64=null;v.prototype.visitFloat16=null;v.prototype.visitFloat32=null;v.prototype.visitFloat64=null;v.prototype.visitDateDay=null;v.prototype.visitDateMillisecond=null;v.prototype.visitTimestampSecond=null;v.prototype.visitTimestampMillisecond=null;v.prototype.visitTimestampMicrosecond=null;v.prototype.visitTimestampNanosecond=null;v.prototype.visitTimeSecond=null;v.prototype.visitTimeMillisecond=null;v.prototype.visitTimeMicrosecond=null;v.prototype.visitTimeNanosecond=null;v.prototype.visitDenseUnion=null;v.prototype.visitSparseUnion=null;v.prototype.visitIntervalDayTime=null;v.prototype.visitIntervalYearMonth=null;v.prototype.visitIntervalMonthDayNano=null;v.prototype.visitDuration=null;v.prototype.visitDurationSecond=null;v.prototype.visitDurationMillisecond=null;v.prototype.visitDurationMicrosecond=null;v.prototype.visitDurationNanosecond=null;var qa={};Re(qa,{float64ToUint16:()=>fn,uint16ToFloat64:()=>js});var Fu=new Float64Array(1),pi=new Uint32Array(Fu.buffer);function js(r){let t=(r&31744)>>10,e=(r&1023)/1024,i=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return i*(e?Number.NaN:1/0);case 0:return i*(e?6103515625e-14*e:0)}return i*Math.pow(2,t-15)*(1+e)}function fn(r){if(r!==r)return 32256;Fu[0]=r;let t=(pi[1]&2147483648)>>16&65535,e=pi[1]&2146435072,i=0;return e>=1089470464?pi[0]>0?e=31744:(e=(e&2080374784)>>16,i=(pi[1]&1048575)>>10):e<=1056964608?(i=1048576+(pi[1]&1048575),i=1048576+(i<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,i=(pi[1]&1048575)+512>>10),t|e|i&65535}var O=class extends v{};function N(r){return(t,e,i)=>{if(t.setValid(e,i!=null))return r(t,e,i)}}var gh=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Nu=(r,t,e,i)=>{if(e+1<t.length){let n=W(t[e]),s=W(t[e+1]);r.set(i.subarray(0,s-n),n)}},bh=({offset:r,values:t},e,i)=>{let n=r+e;i?t[n>>3]|=1<<n%8:t[n>>3]&=~(1<<n%8)},er=({values:r},t,e)=>{r[t]=e},Ja=({values:r},t,e)=>{r[t]=e},Eu=({values:r},t,e)=>{r[t]=fn(e)},_h=(r,t,e)=>{switch(r.type.precision){case Y.HALF:return Eu(r,t,e);case Y.SINGLE:case Y.DOUBLE:return Ja(r,t,e)}},zs=({values:r},t,e)=>{gh(r,t,e.valueOf())},Ws=({values:r},t,e)=>{r[t]=BigInt(e)},Xa=({stride:r,values:t},e,i)=>{t.set(i.subarray(0,r),r*e)},Lu=({values:r,valueOffsets:t},e,i)=>Nu(r,t,e,i),Uu=({values:r,valueOffsets:t},e,i)=>Nu(r,t,e,xe(i)),Ka=(r,t,e)=>{r.type.unit===ut.DAY?zs(r,t,e):Ws(r,t,e)},$s=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Hs=({values:r},t,e)=>{r[t]=BigInt(e)},Gs=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},qs=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Ya=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return $s(r,t,e);case w.MILLISECOND:return Hs(r,t,e);case w.MICROSECOND:return Gs(r,t,e);case w.NANOSECOND:return qs(r,t,e)}},Js=({values:r},t,e)=>{r[t]=e},Xs=({values:r},t,e)=>{r[t]=e},Ks=({values:r},t,e)=>{r[t]=e},Ys=({values:r},t,e)=>{r[t]=e},Za=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return Js(r,t,e);case w.MILLISECOND:return Xs(r,t,e);case w.MICROSECOND:return Ks(r,t,e);case w.NANOSECOND:return Ys(r,t,e)}},Qa=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},wh=(r,t,e)=>{let i=r.children[0],n=r.valueOffsets,s=Tt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=n[t],c=n[t+1];a<c;)s(i,a++,e[++o]);else for(let o=-1,a=n[t],c=n[t+1];a<c;)s(i,a++,e.get(++o))},Ih=(r,t,e)=>{let i=r.children[0],{valueOffsets:n}=r,s=Tt.getVisitFn(i),{[t]:o,[t+1]:a}=n,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(s(i,o,l),++o>=a)break},vh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[s]),Sh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(s)),xh=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(n.name)),Th=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[n.name]),Bh=(r,t,e)=>{let i=r.type.children.map(s=>Tt.getVisitFn(s.type)),n=e instanceof Map?xh(t,e):e instanceof j?Sh(t,e):Array.isArray(e)?vh(t,e):Th(t,e);r.type.children.forEach((s,o)=>n(i[o],r.children[o],s,o))},Oh=(r,t,e)=>{r.type.mode===Z.Dense?Mu(r,t,e):Ru(r,t,e)},Mu=(r,t,e)=>{let i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Tt.visit(n,r.valueOffsets[t],e)},Ru=(r,t,e)=>{let i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Tt.visit(n,t,e)},Ah=(r,t,e)=>{var i;(i=r.dictionary)===null||i===void 0||i.set(r.values[t],e)},tc=(r,t,e)=>{switch(r.type.unit){case et.YEAR_MONTH:return Qs(r,t,e);case et.DAY_TIME:return Zs(r,t,e);case et.MONTH_DAY_NANO:return to(r,t,e)}},Zs=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Qs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},to=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},eo=({values:r},t,e)=>{r[t]=e},ro=({values:r},t,e)=>{r[t]=e},io=({values:r},t,e)=>{r[t]=e},no=({values:r},t,e)=>{r[t]=e},ec=(r,t,e)=>{switch(r.type.unit){case w.SECOND:return eo(r,t,e);case w.MILLISECOND:return ro(r,t,e);case w.MICROSECOND:return io(r,t,e);case w.NANOSECOND:return no(r,t,e)}},Dh=(r,t,e)=>{let{stride:i}=r,n=r.children[0],s=Tt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=t*i;++o<i;)s(n,a+o,e[o]);else for(let o=-1,a=t*i;++o<i;)s(n,a+o,e.get(o))};O.prototype.visitBool=N(bh);O.prototype.visitInt=N(er);O.prototype.visitInt8=N(er);O.prototype.visitInt16=N(er);O.prototype.visitInt32=N(er);O.prototype.visitInt64=N(er);O.prototype.visitUint8=N(er);O.prototype.visitUint16=N(er);O.prototype.visitUint32=N(er);O.prototype.visitUint64=N(er);O.prototype.visitFloat=N(_h);O.prototype.visitFloat16=N(Eu);O.prototype.visitFloat32=N(Ja);O.prototype.visitFloat64=N(Ja);O.prototype.visitUtf8=N(Uu);O.prototype.visitLargeUtf8=N(Uu);O.prototype.visitBinary=N(Lu);O.prototype.visitLargeBinary=N(Lu);O.prototype.visitFixedSizeBinary=N(Xa);O.prototype.visitDate=N(Ka);O.prototype.visitDateDay=N(zs);O.prototype.visitDateMillisecond=N(Ws);O.prototype.visitTimestamp=N(Ya);O.prototype.visitTimestampSecond=N($s);O.prototype.visitTimestampMillisecond=N(Hs);O.prototype.visitTimestampMicrosecond=N(Gs);O.prototype.visitTimestampNanosecond=N(qs);O.prototype.visitTime=N(Za);O.prototype.visitTimeSecond=N(Js);O.prototype.visitTimeMillisecond=N(Xs);O.prototype.visitTimeMicrosecond=N(Ks);O.prototype.visitTimeNanosecond=N(Ys);O.prototype.visitDecimal=N(Qa);O.prototype.visitList=N(wh);O.prototype.visitStruct=N(Bh);O.prototype.visitUnion=N(Oh);O.prototype.visitDenseUnion=N(Mu);O.prototype.visitSparseUnion=N(Ru);O.prototype.visitDictionary=N(Ah);O.prototype.visitInterval=N(tc);O.prototype.visitIntervalDayTime=N(Zs);O.prototype.visitIntervalYearMonth=N(Qs);O.prototype.visitIntervalMonthDayNano=N(to);O.prototype.visitDuration=N(ec);O.prototype.visitDurationSecond=N(eo);O.prototype.visitDurationMillisecond=N(ro);O.prototype.visitDurationMicrosecond=N(io);O.prototype.visitDurationNanosecond=N(no);O.prototype.visitFixedSizeList=N(Dh);O.prototype.visitMap=N(Ih);var Tt=new O;var ye=Symbol.for("parent"),mi=Symbol.for("rowIndex"),vr=class{constructor(t,e){return this[ye]=t,this[mi]=e,new Proxy(this,Fh)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[mi],e=this[ye],i=e.type.children,n={};for(let s=-1,o=i.length;++s<o;)n[i[s].name]=mt.visit(e.children[s],t);return n}toString(){return`{${[...this].map(([t,e])=>`${ue(t)}: ${ue(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new rc(this[ye],this[mi])}},rc=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(vr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ye]:{writable:!0,enumerable:!1,configurable:!1,value:null},[mi]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var ic=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ye].type.children.map(e=>e.name)}has(t,e){return t[ye].type.children.some(i=>i.name===e)}getOwnPropertyDescriptor(t,e){if(t[ye].type.children.some(i=>i.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let i=t[ye].type.children.findIndex(n=>n.name===e);if(i!==-1){let n=mt.visit(t[ye].children[i],t[mi]);return Reflect.set(t,e,n),n}}set(t,e,i){let n=t[ye].type.children.findIndex(s=>s.name===e);return n!==-1?(Tt.visit(t[ye].children[n],t[mi],i),Reflect.set(t,e,i)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,i):!1}},Fh=new ic;var S=class extends v{};function D(r){return(t,e)=>t.getValid(e)?r(t,e):null}var Nh=(r,t)=>864e5*r[t],Eh=(r,t)=>null,ku=(r,t,e)=>{if(e+1>=t.length)return null;let i=W(t[e]),n=W(t[e+1]);return r.subarray(i,n)},Lh=({offset:r,values:t},e)=>{let i=r+e;return(t[i>>3]&1<<i%8)!==0},Cu=({values:r},t)=>Nh(r,t),Pu=({values:r},t)=>W(r[t]),Sr=({stride:r,values:t},e)=>t[r*e],Uh=({stride:r,values:t},e)=>js(t[r*e]),Vu=({values:r},t)=>r[t],Mh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),ju=({values:r,valueOffsets:t},e)=>ku(r,t,e),zu=({values:r,valueOffsets:t},e)=>{let i=ku(r,t,e);return i!==null?Xi(i):null},Rh=({values:r},t)=>r[t],kh=({type:r,values:t},e)=>r.precision!==Y.HALF?t[e]:js(t[e]),Ch=(r,t)=>r.type.unit===ut.DAY?Cu(r,t):Pu(r,t),Wu=({values:r},t)=>1e3*W(r[t]),$u=({values:r},t)=>W(r[t]),Hu=({values:r},t)=>Wa(r[t],BigInt(1e3)),Gu=({values:r},t)=>Wa(r[t],BigInt(1e6)),Ph=(r,t)=>{switch(r.type.unit){case w.SECOND:return Wu(r,t);case w.MILLISECOND:return $u(r,t);case w.MICROSECOND:return Hu(r,t);case w.NANOSECOND:return Gu(r,t)}},qu=({values:r},t)=>r[t],Ju=({values:r},t)=>r[t],Xu=({values:r},t)=>r[t],Ku=({values:r},t)=>r[t],Vh=(r,t)=>{switch(r.type.unit){case w.SECOND:return qu(r,t);case w.MILLISECOND:return Ju(r,t);case w.MICROSECOND:return Xu(r,t);case w.NANOSECOND:return Ku(r,t)}},jh=({values:r,stride:t},e)=>un.decimal(r.subarray(t*e,t*(e+1))),zh=(r,t)=>{let{valueOffsets:e,stride:i,children:n}=r,{[t*i]:s,[t*i+1]:o}=e,c=n[0].slice(s,o-s);return new j([c])},Wh=(r,t)=>{let{valueOffsets:e,children:i}=r,{[t]:n,[t+1]:s}=e,o=i[0];return new Fe(o.slice(n,s-n))},$h=(r,t)=>new vr(r,t),Hh=(r,t)=>r.type.mode===Z.Dense?Yu(r,t):Zu(r,t),Yu=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mt.visit(i,r.valueOffsets[t])},Zu=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mt.visit(i,t)},Gh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},qh=(r,t)=>r.type.unit===et.MONTH_DAY_NANO?ef(r,t):r.type.unit===et.DAY_TIME?Qu(r,t):tf(r,t),Qu=({values:r},t)=>r.subarray(2*t,2*(t+1)),tf=({values:r},t)=>{let e=r[t],i=new Int32Array(2);return i[0]=Math.trunc(e/12),i[1]=Math.trunc(e%12),i},ef=({values:r},t)=>r.subarray(4*t,4*(t+1)),rf=({values:r},t)=>r[t],nf=({values:r},t)=>r[t],sf=({values:r},t)=>r[t],of=({values:r},t)=>r[t],Jh=(r,t)=>{switch(r.type.unit){case w.SECOND:return rf(r,t);case w.MILLISECOND:return nf(r,t);case w.MICROSECOND:return sf(r,t);case w.NANOSECOND:return of(r,t)}},Xh=(r,t)=>{let{stride:e,children:i}=r,s=i[0].slice(t*e,e);return new j([s])};S.prototype.visitNull=D(Eh);S.prototype.visitBool=D(Lh);S.prototype.visitInt=D(Rh);S.prototype.visitInt8=D(Sr);S.prototype.visitInt16=D(Sr);S.prototype.visitInt32=D(Sr);S.prototype.visitInt64=D(Vu);S.prototype.visitUint8=D(Sr);S.prototype.visitUint16=D(Sr);S.prototype.visitUint32=D(Sr);S.prototype.visitUint64=D(Vu);S.prototype.visitFloat=D(kh);S.prototype.visitFloat16=D(Uh);S.prototype.visitFloat32=D(Sr);S.prototype.visitFloat64=D(Sr);S.prototype.visitUtf8=D(zu);S.prototype.visitLargeUtf8=D(zu);S.prototype.visitBinary=D(ju);S.prototype.visitLargeBinary=D(ju);S.prototype.visitFixedSizeBinary=D(Mh);S.prototype.visitDate=D(Ch);S.prototype.visitDateDay=D(Cu);S.prototype.visitDateMillisecond=D(Pu);S.prototype.visitTimestamp=D(Ph);S.prototype.visitTimestampSecond=D(Wu);S.prototype.visitTimestampMillisecond=D($u);S.prototype.visitTimestampMicrosecond=D(Hu);S.prototype.visitTimestampNanosecond=D(Gu);S.prototype.visitTime=D(Vh);S.prototype.visitTimeSecond=D(qu);S.prototype.visitTimeMillisecond=D(Ju);S.prototype.visitTimeMicrosecond=D(Xu);S.prototype.visitTimeNanosecond=D(Ku);S.prototype.visitDecimal=D(jh);S.prototype.visitList=D(zh);S.prototype.visitStruct=D($h);S.prototype.visitUnion=D(Hh);S.prototype.visitDenseUnion=D(Yu);S.prototype.visitSparseUnion=D(Zu);S.prototype.visitDictionary=D(Gh);S.prototype.visitInterval=D(qh);S.prototype.visitIntervalDayTime=D(Qu);S.prototype.visitIntervalYearMonth=D(tf);S.prototype.visitIntervalMonthDayNano=D(ef);S.prototype.visitDuration=D(Jh);S.prototype.visitDurationSecond=D(rf);S.prototype.visitDurationMillisecond=D(nf);S.prototype.visitDurationMicrosecond=D(sf);S.prototype.visitDurationNanosecond=D(of);S.prototype.visitFixedSizeList=D(Xh);S.prototype.visitMap=D(Wh);var mt=new S;var xr=Symbol.for("keys"),gi=Symbol.for("vals"),yi=Symbol.for("kKeysAsStrings"),nc=Symbol.for("_kKeysAsStrings"),Fe=class{constructor(t){return this[xr]=new j([t.children[0]]).memoize(),this[gi]=t.children[1],new Proxy(this,new oc)}get[yi](){return this[nc]||(this[nc]=Array.from(this[xr].toArray(),String))}[Symbol.iterator](){return new sc(this[xr],this[gi])}get size(){return this[xr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[xr],e=this[gi],i={};for(let n=-1,s=t.length;++n<s;)i[t.get(n)]=mt.visit(e,n);return i}toString(){return`{${[...this].map(([t,e])=>`${ue(t)}: ${ue(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},sc=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),mt.visit(this.vals,t)]})}},oc=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[yi]}has(t,e){return t[yi].includes(e)}getOwnPropertyDescriptor(t,e){if(t[yi].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let i=t[yi].indexOf(e);if(i!==-1){let n=mt.visit(Reflect.get(t,gi),i);return Reflect.set(t,e,n),n}}set(t,e,i){let n=t[yi].indexOf(e);return n!==-1?(Tt.visit(Reflect.get(t,gi),n,i),Reflect.set(t,e,i)):Reflect.has(t,e)?Reflect.set(t,e,i):!1}};Object.defineProperties(Fe.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[xr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[nc]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var af;function dn(r,t,e,i){let{length:n=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?n:e;return s<0&&(s=(s%n+n)%n),o<0&&(o=(o%n+n)%n),o<s&&(af=s,s=o,o=af),o>n&&(o=n),i?i(r,s,o):[s,o]}var jr=(r,t)=>r<0?t+r:r,cf=r=>r!==r;function Tr(r){if(typeof r!=="object"||r===null)return cf(r)?cf:e=>e===r;if(r instanceof Date){let e=r.valueOf();return i=>i instanceof Date?i.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?Ca(r,e):!1:r instanceof Map?Yh(r):Array.isArray(r)?Kh(r):r instanceof j?Zh(r):Qh(r,!0)}function Kh(r){let t=[];for(let e=-1,i=r.length;++e<i;)t[e]=Tr(r[e]);return so(t)}function Yh(r){let t=-1,e=[];for(let i of r.values())e[++t]=Tr(i);return so(e)}function Zh(r){let t=[];for(let e=-1,i=r.length;++e<i;)t[e]=Tr(r.get(e));return so(t)}function Qh(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let i=[];for(let n=-1,s=e.length;++n<s;)i[n]=Tr(r[e[n]]);return so(i,e)}function so(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return tp(r,e);case Map:return lf(r,e,e.keys());case Fe:case vr:case Object:case void 0:return lf(r,e,t||Object.keys(e))}return e instanceof j?ep(r,e):!1}}function tp(r,t){let e=r.length;if(t.length!==e)return!1;for(let i=-1;++i<e;)if(!r[i](t[i]))return!1;return!0}function ep(r,t){let e=r.length;if(t.length!==e)return!1;for(let i=-1;++i<e;)if(!r[i](t.get(i)))return!1;return!0}function lf(r,t,e){let i=e[Symbol.iterator](),n=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,a=r.length,c=s.next(),l=i.next(),u=n.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=i.next(),u=n.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(i.return&&i.return(),n.return&&n.return(),s.return&&s.return(),!1)}var cc={};Re(cc,{BitIterator:()=>zr,getBit:()=>uf,getBool:()=>ao,packBools:()=>$r,popcnt_array:()=>ff,popcnt_bit_range:()=>hn,popcnt_uint32:()=>oo,setBool:()=>rp,truncateBitmap:()=>Wr});function ao(r,t,e,i){return(e&1<<i)!==0}function uf(r,t,e,i){return(e&1<<i)>>i}function rp(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Wr(r,t,e){let i=e.byteLength+7&-8;if(r>0||e.byteLength<i){let n=new Uint8Array(i);return n.set(r%8===0?e.subarray(r>>3):$r(new zr(e,r,t,null,ao)).subarray(0,i)),n}return e}function $r(r){let t=[],e=0,i=0,n=0;for(let o of r)o&&(n|=1<<i),++i===8&&(t[e++]=n,n=i=0);(e===0||i>0)&&(t[e++]=n);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var zr=class{constructor(t,e,i,n,s){this.bytes=t,this.length=i,this.context=n,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function hn(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new zr(r,t,e-t,r,uf))s+=o;return s}let i=e>>3<<3,n=t+(t%8===0?0:8-t%8);return hn(r,t,n)+hn(r,i,e)+ff(r,n>>3,i-n>>3)}function ff(r,t,e){let i=0,n=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:n+e;for(;o-n>=4;)i+=oo(s.getUint32(n)),n+=4;for(;o-n>=2;)i+=oo(s.getUint16(n)),n+=2;for(;o-n>=1;)i+=oo(s.getUint8(n)),n+=1;return i}function oo(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var ip=-1,G=class r{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return b.isSparseUnion(t)?this.children.some(e=>e.nullable):b.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:i,nullBitmap:n,typeIds:s}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(b.isUnion(this.type))return this.children.reduce((i,n)=>i+n.nullCount,0);let t=this._nullCount,e;return t<=ip&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-hn(e,this.offset,this.offset+this.length)),t}constructor(t,e,i,n,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1));let c;s instanceof r?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ht(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(b.isUnion(e)){let i=e,n=this.children[i.typeIdToChildIndex[this.typeIds[t]]],s=i.mode===Z.Dense?this.valueOffsets[t]:t;return n.getValid(s)}if(this.nullable&&this.nullCount>0){let i=this.offset+t;return(this.nullBitmap[i>>3]&1<<i%8)!==0}return!0}setValid(t,e){let i,{type:n}=this;if(b.isUnion(n)){let s=n,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===Z.Dense?this.valueOffsets[t]:t;i=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Wr(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[u];i=(d&l)!==0,s[u]=e?d|l:d&~l}return i!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,i=this.length,n=this._nullCount,s=this,o=this.children){return new r(t,e,i,n,s,o,this.dictionary)}slice(t,e){let{stride:i,typeId:n,children:s}=this,o=+(this._nullCount===0)-1,a=n===16?i:1,c=this._sliceBuffers(t,e,i,n);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===f.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:i}=this,n=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);n[e>>3]=(1<<e-(e&-8))-1,i>0&&n.set(Wr(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[Yt.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),s)}_sliceBuffers(t,e,i,n){let s,{buffers:o}=this;return(s=o[Yt.TYPE])&&(o[Yt.TYPE]=s.subarray(t,t+e)),(s=o[Yt.OFFSET])&&(o[Yt.OFFSET]=s.subarray(t,t+e+1))||(s=o[Yt.DATA])&&(o[Yt.DATA]=n===6?s:s.subarray(i*t,i*(t+e))),o}_sliceChildren(t,e,i){return t.map(n=>n.slice(e,i))}};G.prototype.children=Object.freeze([]);var lc=class r extends v{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:i=0,["length"]:n=0}=t;return new G(e,i,n,n)}visitBool(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitInt(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitFloat(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitUtf8(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.data),s=A(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.data),s=A(t.nullBitmap),o=Ts(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.data),s=A(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.data),s=A(t.nullBitmap),o=Ts(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,n,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDate(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitTimestamp(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitTime(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDecimal(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitList(t){let{["type"]:e,["offset"]:i=0,["child"]:n}=t,s=A(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,void 0,s],[n])}visitStruct(t){let{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=A(t.nullBitmap),{length:o=n.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,void 0,s],n)}visitUnion(t){let{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=R(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(b.isSparseUnion(e))return new G(e,i,o,a,[void 0,void 0,void 0,s],n);let c=Cr(t.valueOffsets);return new G(e,i,o,a,[c,void 0,void 0,s],n)}visitDictionary(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.indices.ArrayType,t.data),{["dictionary"]:o=new j([new r().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[void 0,s,n],[],o)}visitInterval(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitDuration(t){let{["type"]:e,["offset"]:i=0}=t,n=A(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,s,n])}visitFixedSizeList(t){let{["type"]:e,["offset"]:i=0,["child"]:n=new r().visit({type:e.valueType})}=t,s=A(t.nullBitmap),{["length"]:o=n.length/Ht(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new G(e,i,o,a,[void 0,void 0,s],[n])}visitMap(t){let{["type"]:e,["offset"]:i=0,["child"]:n=new r().visit({type:e.childType})}=t,s=A(t.nullBitmap),o=Cr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new G(e,i,a,c,[o,void 0,s],[n])}},np=new lc;function L(r){return np.visit(r)}var pn=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function df(r){return r.some(t=>t.nullable)}function co(r){return r.reduce((t,e)=>t+e.nullCount,0)}function lo(r){return r.reduce((t,e,i)=>(t[i+1]=t[i]+e.length,t),new Uint32Array(r.length+1))}function uo(r,t,e,i){let n=[];for(let s=-1,o=r.length;++s<o;){let a=r[s],c=t[s],{length:l}=a;if(c>=i)break;if(e>=c+l)continue;if(c>=e&&c+l<=i){n.push(a);continue}let u=Math.max(0,e-c),d=Math.min(i-c,l);n.push(a.slice(u,d-u))}return n.length===0&&n.push(r[0].slice(0,0)),n}function uc(r,t,e,i){let n=0,s=0,o=t.length-1;do{if(n>=o-1)return e<t[o]?i(r,n,e-t[n]):null;s=n+Math.trunc((o-n)*.5),e<t[s]?o=s:n=s}while(n<o)}function mn(r,t){return r.getValid(t)}function bi(r){function t(e,i,n){return r(e[i],n)}return function(e){let i=this.data;return uc(i,this._offsets,e,t)}}function fo(r){let t;function e(i,n,s){return r(i[n],s,t)}return function(i,n){let s=this.data;t=n;let o=uc(s,this._offsets,i,e);return t=void 0,o}}function ho(r){let t;function e(i,n,s){let o=s,a=0,c=0;for(let l=n-1,u=i.length;++l<u;){let d=i[l];if(~(a=r(d,t,o)))return c+a;o=0,c+=d.length}return-1}return function(i,n){t=i;let s=this.data,o=typeof n!="number"?e(s,0,0):uc(s,this._offsets,n,e);return t=void 0,o}}var x=class extends v{};function sp(r,t){return t===null&&r.length>0?0:-1}function op(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let i=0;for(let n of new zr(e,r.offset+(t||0),r.length,e,ao)){if(!n)return i;++i}return-1}function E(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case f.Union:break;case f.Dictionary:break;default:return op(r,e)}let i=mt.getVisitFn(r),n=Tr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(n(i(r,s)))return s;return-1}function hf(r,t,e){let i=mt.getVisitFn(r),n=Tr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(n(i(r,s)))return s;return-1}x.prototype.visitNull=sp;x.prototype.visitBool=E;x.prototype.visitInt=E;x.prototype.visitInt8=E;x.prototype.visitInt16=E;x.prototype.visitInt32=E;x.prototype.visitInt64=E;x.prototype.visitUint8=E;x.prototype.visitUint16=E;x.prototype.visitUint32=E;x.prototype.visitUint64=E;x.prototype.visitFloat=E;x.prototype.visitFloat16=E;x.prototype.visitFloat32=E;x.prototype.visitFloat64=E;x.prototype.visitUtf8=E;x.prototype.visitLargeUtf8=E;x.prototype.visitBinary=E;x.prototype.visitLargeBinary=E;x.prototype.visitFixedSizeBinary=E;x.prototype.visitDate=E;x.prototype.visitDateDay=E;x.prototype.visitDateMillisecond=E;x.prototype.visitTimestamp=E;x.prototype.visitTimestampSecond=E;x.prototype.visitTimestampMillisecond=E;x.prototype.visitTimestampMicrosecond=E;x.prototype.visitTimestampNanosecond=E;x.prototype.visitTime=E;x.prototype.visitTimeSecond=E;x.prototype.visitTimeMillisecond=E;x.prototype.visitTimeMicrosecond=E;x.prototype.visitTimeNanosecond=E;x.prototype.visitDecimal=E;x.prototype.visitList=E;x.prototype.visitStruct=E;x.prototype.visitUnion=E;x.prototype.visitDenseUnion=hf;x.prototype.visitSparseUnion=hf;x.prototype.visitDictionary=E;x.prototype.visitInterval=E;x.prototype.visitIntervalDayTime=E;x.prototype.visitIntervalYearMonth=E;x.prototype.visitIntervalMonthDayNano=E;x.prototype.visitDuration=E;x.prototype.visitDurationSecond=E;x.prototype.visitDurationMillisecond=E;x.prototype.visitDurationMicrosecond=E;x.prototype.visitDurationNanosecond=E;x.prototype.visitFixedSizeList=E;x.prototype.visitMap=E;var Hr=new x;var T=class extends v{};function F(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(b.isInt(t)&&t.bitWidth!==64||b.isTime(t)&&t.bitWidth!==64||b.isFloat(t)&&t.precision!==Y.HALF))return new pn(r.data.length,i=>{let n=r.data[i];return n.values.subarray(0,n.length)[Symbol.iterator]()});let e=0;return new pn(r.data.length,i=>{let s=r.data[i].length,o=r.slice(e,e+s);return e+=s,new fc(o)})}var fc=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};T.prototype.visitNull=F;T.prototype.visitBool=F;T.prototype.visitInt=F;T.prototype.visitInt8=F;T.prototype.visitInt16=F;T.prototype.visitInt32=F;T.prototype.visitInt64=F;T.prototype.visitUint8=F;T.prototype.visitUint16=F;T.prototype.visitUint32=F;T.prototype.visitUint64=F;T.prototype.visitFloat=F;T.prototype.visitFloat16=F;T.prototype.visitFloat32=F;T.prototype.visitFloat64=F;T.prototype.visitUtf8=F;T.prototype.visitLargeUtf8=F;T.prototype.visitBinary=F;T.prototype.visitLargeBinary=F;T.prototype.visitFixedSizeBinary=F;T.prototype.visitDate=F;T.prototype.visitDateDay=F;T.prototype.visitDateMillisecond=F;T.prototype.visitTimestamp=F;T.prototype.visitTimestampSecond=F;T.prototype.visitTimestampMillisecond=F;T.prototype.visitTimestampMicrosecond=F;T.prototype.visitTimestampNanosecond=F;T.prototype.visitTime=F;T.prototype.visitTimeSecond=F;T.prototype.visitTimeMillisecond=F;T.prototype.visitTimeMicrosecond=F;T.prototype.visitTimeNanosecond=F;T.prototype.visitDecimal=F;T.prototype.visitList=F;T.prototype.visitStruct=F;T.prototype.visitUnion=F;T.prototype.visitDenseUnion=F;T.prototype.visitSparseUnion=F;T.prototype.visitDictionary=F;T.prototype.visitInterval=F;T.prototype.visitIntervalDayTime=F;T.prototype.visitIntervalYearMonth=F;T.prototype.visitIntervalMonthDayNano=F;T.prototype.visitDuration=F;T.prototype.visitDurationSecond=F;T.prototype.visitDurationMillisecond=F;T.prototype.visitDurationMicrosecond=F;T.prototype.visitDurationNanosecond=F;T.prototype.visitFixedSizeList=F;T.prototype.visitMap=F;var _i=new T;var pf,mf={},yf={},j=class r{constructor(t){var e,i,n;let s=t[0]instanceof r?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof G)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=mf[o.typeId],u=s[0];this.isValid=d=>mn(u,d),this.get=d=>a(u,d),this.set=(d,p)=>c(u,d,p),this.indexOf=d=>l(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,yf[o.typeId]),this._offsets=lo(s);break}this.data=s,this.type=o,this.stride=Ht(o),this.numChildren=(n=(i=o.children)===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return df(this.data)}get nullCount(){return co(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(jr(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return _i.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(dn(this,t,e,({data:i,_offsets:n},s,o)=>uo(i,n,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:i,stride:n,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*n),o.offset),o.offset+=c*n,o),{array:new s(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return b.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(b.isDictionary(this.type)){let t=new po(this.data[0].dictionary),e=this.data.map(i=>{let n=i.clone();return n.dictionary=t,n});return new r(e)}return new po(this)}unmemoize(){if(b.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(i=>{let n=i.clone();return n.dictionary=t,n});return new r(e)}return this}};pf=Symbol.toStringTag;j[pf]=(r=>{r.type=b.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(f).map(e=>f[e]).filter(e=>typeof e=="number"&&e!==f.NONE);for(let e of t){let i=mt.getVisitFnByTypeId(e),n=Tt.getVisitFnByTypeId(e),s=Hr.getVisitFnByTypeId(e);mf[e]={get:i,set:n,indexOf:s},yf[e]=Object.create(r,{isValid:{value:bi(mn)},get:{value:bi(mt.getVisitFnByTypeId(e))},set:{value:fo(Tt.getVisitFnByTypeId(e))},indexOf:{value:ho(Hr.getVisitFnByTypeId(e))}})}return"Vector"})(j.prototype);var po=class r extends j{constructor(t){super(t.data);let e=this.get,i=this.set,n=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){i.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new r(n.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new j(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function gf(r){if(!r||r.length<=0)return function(n){return!0};let t="",e=r.filter(i=>i===i);return e.length>0&&(t=`
12
16
  switch (x) {${e.map(i=>`
13
- case ${Zh(i)}:`).join("")}
17
+ case ${ap(i)}:`).join("")}
14
18
  return false;
15
19
  }`),r.length!==e.length&&(t=`if (x !== x) return false;
16
20
  ${t}`),new Function("x",`${t}
17
- return true;`)}function Zh(r){return typeof r!="bigint"?ue(r):`${ue(r)}n`}function lc(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function ff(r,t=0){return r.length>=t?r.subarray(0,t):Ji(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?lc(i*1,this.BYTES_PER_ELEMENT):lc(i*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=lc(t*this.stride,this.BYTES_PER_ELEMENT);let e=ff(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=ff(this.buffer,t)}},tr=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}},bi=class extends tr{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()}},_i=class extends tr{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 ot=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 bi,e&&e.length>0&&(this._isValid=uf(e))}toVector(){return new P([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:i,_nulls:n,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,i)=>e+i.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,i,n,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:d}=this;(e=c==null?void 0:c.flush(o))?n=l==null?void 0:l.flush(o):(n=l==null?void 0:l.flush(o))?t=u==null?void 0:u.flush(l.last()):t=u==null?void 0:u.flush(o),a>0&&(i=d==null?void 0:d.flush(o));let p=this.children.map(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}};ot.prototype.length=1;ot.prototype.stride=1;ot.prototype.children=null;ot.prototype.finished=!1;ot.prototype.nullValues=null;ot.prototype._isValid=()=>!0;var yt=class extends ot{constructor(t){super(t),this._values=new tr(this.ArrayType,0,this.stride)}setValue(t,e){let i=this._values;return i.reserve(t-i.length+1),super.setValue(t,e)}},Ct=class extends ot{constructor(t){super(t),this._pendingLength=0,this._offsets=new _i(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 De?e[Sr].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 Hr=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 Hr).__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 Hr).__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 K=class r{constructor(t=[],e,i,n=J.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=uc(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=fo(fo(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:fo(fo(new Map,i[c].metadata),a.metadata)}))&&!1:!0}),o=uc(s,new Map);return new r([...i,...s],n,new Map([...this.dictionaries,...o]))}};K.prototype.fields=null;K.prototype.metadata=null;K.prototype.dictionaries=null;var C=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)}};C.prototype.type=null;C.prototype.name=null;C.prototype.nullable=null;C.prototype.metadata=null;function fo(r,t){return new Map([...r||new Map,...t||new Map])}function uc(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&&uc(s.children,t)}return t}var Qh=kr,tp=xt,er=class{static decode(t){t=new tp(D(t));let e=Gt.getRootAsFooter(t),i=K.decode(e.schema(),new Map,e.version());return new fc(i,e)}static encode(t){let e=new Qh,i=K.encode(e,t.schema);Gt.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())rr.encode(e,o);let n=e.endVector();Gt.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())rr.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 fc=class extends er{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 rr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return rr.decode(e)}return null}},rr=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 Hr.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 dc=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return rn.startNull(e),rn.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 br.startFloatingPoint(e),br.addPrecision(e,t.precision),br.endFloatingPoint(e)}visitBinary(t,e){return Yi.startBinary(e),Yi.endBinary(e)}visitLargeBinary(t,e){return Qi.startLargeBinary(e),Qi.endLargeBinary(e)}visitBool(t,e){return Zi.startBool(e),Zi.endBool(e)}visitUtf8(t,e){return sn.startUtf8(e),sn.endUtf8(e)}visitLargeUtf8(t,e){return tn.startLargeUtf8(e),tn.endLargeUtf8(e)}visitDecimal(t,e){return Be.startDecimal(e),Be.addScale(e,t.scale),Be.addPrecision(e,t.precision),Be.addBitWidth(e,t.bitWidth),Be.endDecimal(e)}visitDate(t,e){return pr.startDate(e),pr.addUnit(e,t.unit),pr.endDate(e)}visitTime(t,e){return Ve.startTime(e),Ve.addUnit(e,t.unit),Ve.addBitWidth(e,t.bitWidth),Ve.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Pe.startTimestamp(e),Pe.addUnit(e,t.unit),i!==void 0&&Pe.addTimezone(e,i),Pe.endTimestamp(e)}visitInterval(t,e){return _r.startInterval(e),_r.addUnit(e,t.unit),_r.endInterval(e)}visitDuration(t,e){return mr.startDuration(e),mr.addUnit(e,t.unit),mr.endDuration(e)}visitList(t,e){return en.startList(e),en.endList(e)}visitStruct(t,e){return nn.startStruct_(e),nn.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 Te.startDictionaryEncoding(e),Te.addId(e,BigInt(t.id)),Te.addIsOrdered(e,t.isOrdered),i!==void 0&&Te.addIndexType(e,i),Te.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return yr.startFixedSizeBinary(e),yr.addByteWidth(e,t.byteWidth),yr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return gr.startFixedSizeList(e),gr.addListSize(e,t.listSize),gr.endFixedSizeList(e)}visitMap(t,e){return wr.startMap(e),wr.addKeysSorted(e,t.keysSorted),wr.endMap(e)}},ho=new dc;function mf(r,t=new Map){return new K(ep(r,t),po(r.metadata),t)}function hc(r){return new bt(r.count,gf(r.columns),bf(r.columns),null)}function yf(r){return new Ot(hc(r.data),r.id,r.isDelta)}function ep(r,t){return(r.fields||[]).filter(Boolean).map(e=>C.fromJSON(e,t))}function df(r,t){return(r.children||[]).filter(Boolean).map(e=>C.fromJSON(e,t))}function gf(r){return(r||[]).reduce((t,e)=>[...t,new Qt(e.count,rp(e.VALIDITY)),...gf(e.children)],[])}function bf(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=bf(n.children,t)}return t}function rp(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function _f(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=pf(r,df(r,t)),n=new C(r.name,o,r.nullable,po(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?hf(i):new Oe,a=new $t(t.get(e),i,e,s.isOrdered),n=new C(r.name,a,r.nullable,po(r.metadata))):(i=(i=s.indexType)?hf(i):new Oe,t.set(e,o=pf(r,df(r,t))),a=new $t(o,i,e,s.isOrdered),n=new C(r.name,a,r.nullable,po(r.metadata))),n||null}function po(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function hf(r){return new vt(r.isSigned,r.bitWidth)}function pf(r,t){let e=r.type.name;switch(e){case"NONE":return new Nt;case"null":return new Nt;case"binary":return new je;case"largebinary":return new ze;case"utf8":return new We;case"largeutf8":return new $e;case"bool":return new He;case"list":return new de((t||[])[0]);case"struct":return new it(t||[]);case"struct_":return new it(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 Ge(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new qe(ut[i.unit])}case"time":{let i=r.type;return new Je(w[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new Ke(w[i.unit],i.timezone)}case"interval":{let i=r.type;return new Xe(et[i.unit])}case"duration":{let i=r.type;return new Ye(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 Ze(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 ip=kr,np=xt,kt=class r{static fromJSON(t,e){let i=new r(0,J.V5,e);return i._createHeader=sp(t,e),i}static decode(t){t=new np(D(t));let e=be.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=op(e,s),o}static encode(t){let e=new ip,i=-1;return t.isSchema()?i=K.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 K)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)}},Gr=class{constructor(t,e=Vr.BUFFER){this.type=t,this.method=e}};function sp(r,t){return(()=>{switch(t){case V.Schema:return K.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 op(r,t){return(()=>{switch(t){case V.Schema:return K.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 ke),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}C.encode=gp;C.decode=mp;C.fromJSON=_f;K.encode=yp;K.decode=ap;K.fromJSON=mf;bt.encode=bp;bt.decode=cp;bt.fromJSON=hc;Ot.encode=_p;Ot.decode=lp;Ot.fromJSON=yf;Qt.encode=wp;Qt.decode=fp;gt.encode=Ip;gt.decode=up;Gr.encode=xf;Gr.decode=Sf;function ap(r,t=new Map,e=J.V5){let i=pp(r,t);return new K(i,mo(r),t,e)}function cp(r,t=J.V5){return new bt(r.length(),dp(r),hp(r,t),Sf(r.compression()))}function lp(r,t=J.V5){return new Ot(bt.decode(r.data(),t),r.id(),r.isDelta())}function up(r){return new gt(r.offset(),r.length())}function fp(r){return new Qt(r.length(),r.nullCount())}function dp(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 hp(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 pp(r,t){let e=[];for(let i,n=-1,s=-1,o=r.fieldsLength();++n<o;)(i=r.fields(n))&&(e[++s]=C.decode(i,t));return e}function wf(r,t){let e=[];for(let i,n=-1,s=-1,o=r.childrenLength();++n<o;)(i=r.children(n))&&(e[++s]=C.decode(i,t));return e}function mp(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=vf(r,wf(r,t)),i=new C(r.name(),n,r.nullable(),mo(r))):t.has(e=W(a.id()))?(s=(s=a.indexType())?If(s):new Oe,o=new $t(t.get(e),s,e,a.isOrdered()),i=new C(r.name(),o,r.nullable(),mo(r))):(s=(s=a.indexType())?If(s):new Oe,t.set(e,n=vf(r,wf(r,t))),o=new $t(n,s,e,a.isOrdered()),i=new C(r.name(),o,r.nullable(),mo(r))),i||null}function mo(r){let t=new Map;if(r)for(let e,i,n=-1,s=Math.trunc(r.customMetadataLength());++n<s;)(e=r.customMetadata(n))&&(i=e.key())!=null&&t.set(i,e.value());return t}function If(r){return new vt(r.isSigned(),r.bitWidth())}function vf(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 je;case Q.LargeBinary:return new ze;case Q.Utf8:return new We;case Q.LargeUtf8:return new $e;case Q.Bool:return new He;case Q.List:return new de((t||[])[0]);case Q.Struct_:return new it(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 br);return new Zt(i.precision())}case Q.Decimal:{let i=r.type(new Be);return new Ge(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new pr);return new qe(i.unit())}case Q.Time:{let i=r.type(new Ve);return new Je(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Pe);return new Ke(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new _r);return new Xe(i.unit())}case Q.Duration:{let i=r.type(new mr);return new Ye(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 yr);return new Ze(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new gr);return new pe(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new wr);return new me((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function Sf(r){return r?new Gr(r.codec(),r.method()):null}function yp(r,t){let e=t.fields.map(s=>C.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,vp?hr.Little:hr.Big),n!==-1&&Rt.addCustomMetadata(r,n),Rt.endSchema(r)}function gp(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;b.isDictionary(s)?(o=s.dictionary.typeId,n=ho.visit(s,r),i=ho.visit(s.dictionary,r)):i=ho.visit(s,r);let a=(s.children||[]).map(u=>C.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 bp(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=xf(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 xf(r,t){return Ce.startBodyCompression(r),Ce.addCodec(r,t.type),Ce.addMethod(r,t.method),Ce.endBodyCompression(r)}function _p(r,t){let e=bt.encode(r,t.data);return ke.startDictionaryBatch(r),ke.addId(r,BigInt(t.id)),ke.addIsDelta(r,t.isDelta),ke.addData(r,e),ke.endDictionaryBatch(r)}function wp(r,t){return ai.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Ip(r,t){return oi.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var vp=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var nt=Object.freeze({done:!0,value:void 0}),hn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},qr=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())}},yo=class extends qr{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(nt);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),nt})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),nt})}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(nt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Ae=class extends yo{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Gi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Gi)}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]})}},Fe=class{constructor(t){t&&(this.source=new pc(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 Ae?this.source=new ir(St.fromAsyncIterable(t)):Is(t)?this.source=new ir(St.fromNodeStream(t)):qi(t)?this.source=new ir(St.fromDOMStream(t)):_s(t)?this.source=new ir(St.fromDOMStream(t.body)):se(t)?this.source=new ir(St.fromIterable(t)):ne(t)?this.source=new ir(St.fromAsyncIterable(t)):Kt(t)&&(this.source=new ir(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)}},pc=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)||nt)}return(t){return Object.create(this.source.return&&this.source.return(t)||nt)}},ir=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))||nt;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))||nt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var pn=class extends Fe{constructor(t,e){super(),this.position=0,this.buffer=D(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:i}=this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:i,position:n}=this;return e&&n<i?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(i,n+Math.min(i-n,t)),e.subarray(n,this.position)):null}readAt(t,e){let i=this.buffer,n=Math.min(this.size,t+e);return i?i.subarray(t,n):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},Tr=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 yc={};Ue(yc,{BaseInt64:()=>mn,Int128:()=>yn,Int64:()=>nr,Uint64:()=>ct});function wi(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Ii=8,mc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],mn=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`${wi(this.buffer[1])} ${wi(this.buffer[0])}`}},ct=class r extends mn{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=Ii<i-s?Ii:i-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([mc[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)}},nr=class r extends mn{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=Ii<n-o?Ii:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([mc[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)}},yn=class r{constructor(t){this.buffer=t}high(){return new nr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new nr(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`${wi(this.buffer[3])} ${wi(this.buffer[2])} ${wi(this.buffer[1])} ${wi(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=Ii<n-o?Ii:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([mc[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 _c={};Ue(_c,{toIntervalDayTimeInt32Array:()=>gc,toIntervalDayTimeObjects:()=>Sp,toIntervalMonthDayNanoInt32Array:()=>bc,toIntervalMonthDayNanoObjects:()=>xp});function gc(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 bc(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 Sp(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 xp(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 vi=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 C?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)}},go=class extends vi{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):Wr(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,nr.convertArray(i[e]));if((b.isInt(t)||b.isTime(t))&&t.bitWidth===64||b.isDuration(t))return R(Uint8Array,nr.convertArray(i[e]));if(b.isDate(t)&&t.unit===ut.MILLISECOND)return R(Uint8Array,nr.convertArray(i[e]));if(b.isDecimal(t))return R(Uint8Array,yn.convertArray(i[e]));if(b.isBinary(t)||b.isLargeBinary(t)||b.isFixedSizeBinary(t))return Tp(i[e]);if(b.isBool(t))return Wr(i[e]);if(b.isUtf8(t)||b.isLargeUtf8(t))return ve(i[e].join(""));if(b.isInterval(t))switch(t.unit){case et.DAY_TIME:return gc(i[e]);case et.MONTH_DAY_NANO:return bc(i[e]);default:break}return R(Uint8Array,R(t.ArrayType,i[e].map(n=>+n)))}};function Tp(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 bo=class extends vi{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 Si=class extends Ct{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,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,0);else{let c=a.length;n.set(a,s),i.set(o,c),s+=c}}};var xi=class extends Ct{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,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,BigInt(0));else{let c=a.length;n.set(a,s),i.set(o,BigInt(c)),s+=c}}};var _o=class extends ot{constructor(t){super(t),this._values=new bi}setValue(t,e){this._values.set(t,+e)}};var Jr=class extends yt{};Jr.prototype._setValue=qa;var gn=class extends Jr{};gn.prototype._setValue=Vs;var bn=class extends Jr{};bn.prototype._setValue=Ps;var _n=class extends yt{};_n.prototype._setValue=Xa;var wo=class extends ot{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 wn=class extends yt{};wn.prototype._setValue=Ga;var Io=class extends ot{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 C(e,t.type,!0)),i}};var Xr=class extends yt{setValue(t,e){this._values.set(t,e)}},vo=class extends Xr{setValue(t,e){super.setValue(t,cn(e))}},So=class extends Xr{},xo=class extends Xr{};var Br=class extends yt{};Br.prototype._setValue=Ya;var In=class extends Br{};In.prototype._setValue=Ks;var vn=class extends Br{};vn.prototype._setValue=Xs;var Sn=class extends Br{};Sn.prototype._setValue=Ys;var sr=class extends yt{};sr.prototype._setValue=Za;var xn=class extends sr{};xn.prototype._setValue=Zs;var Tn=class extends sr{};Tn.prototype._setValue=Qs;var Bn=class extends sr{};Bn.prototype._setValue=to;var On=class extends sr{};On.prototype._setValue=eo;var ee=class extends yt{setValue(t,e){this._values.set(t,e)}},To=class extends ee{},Bo=class extends ee{},Oo=class extends ee{},Do=class extends ee{},Ao=class extends ee{},Fo=class extends ee{},No=class extends ee{},Eo=class extends ee{};var Lo=class extends Ct{constructor(t){super(t),this._offsets=new _i(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 C(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 Uo=class extends Ct{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 C(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 Mo=class extends ot{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Ro=class extends ot{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 it([...this.type.children,new C(e,t.type,!0)]),i}};var or=class extends yt{};or.prototype._setValue=Ja;var Dn=class extends or{};Dn.prototype._setValue=js;var An=class extends or{};An.prototype._setValue=zs;var Fn=class extends or{};Fn.prototype._setValue=Ws;var Nn=class extends or{};Nn.prototype._setValue=$s;var ar=class extends yt{};ar.prototype._setValue=Ka;var En=class extends ar{};En.prototype._setValue=Hs;var Ln=class extends ar{};Ln.prototype._setValue=Gs;var Un=class extends ar{};Un.prototype._setValue=qs;var Mn=class extends ar{};Mn.prototype._setValue=Js;var Ti=class extends ot{constructor(t){super(t),this._typeIds=new tr(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 C(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.")}},Co=class extends Ti{},ko=class extends Ti{constructor(t){super(t),this._offsets=new tr(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 Rn=class extends Ct{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,ve(e))}_flushPending(t,e){}};Rn.prototype._flushPending=Si.prototype._flushPending;var Cn=class extends Ct{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,ve(e))}_flushPending(t,e){}};Cn.prototype._flushPending=xi.prototype._flushPending;var wc=class extends v{visitNull(){return Mo}visitBool(){return _o}visitInt(){return ee}visitInt8(){return To}visitInt16(){return Bo}visitInt32(){return Oo}visitInt64(){return Do}visitUint8(){return Ao}visitUint16(){return Fo}visitUint32(){return No}visitUint64(){return Eo}visitFloat(){return Xr}visitFloat16(){return vo}visitFloat32(){return So}visitFloat64(){return xo}visitUtf8(){return Rn}visitLargeUtf8(){return Cn}visitBinary(){return Si}visitLargeBinary(){return xi}visitFixedSizeBinary(){return wn}visitDate(){return Jr}visitDateDay(){return gn}visitDateMillisecond(){return bn}visitTimestamp(){return or}visitTimestampSecond(){return Dn}visitTimestampMillisecond(){return An}visitTimestampMicrosecond(){return Fn}visitTimestampNanosecond(){return Nn}visitTime(){return ar}visitTimeSecond(){return En}visitTimeMillisecond(){return Ln}visitTimeMicrosecond(){return Un}visitTimeNanosecond(){return Mn}visitDecimal(){return _n}visitList(){return Lo}visitStruct(){return Ro}visitUnion(){return Ti}visitDenseUnion(){return ko}visitSparseUnion(){return Co}visitDictionary(){return wo}visitInterval(){return Br}visitIntervalDayTime(){return In}visitIntervalYearMonth(){return vn}visitIntervalMonthDayNano(){return Sn}visitDuration(){return sr}visitDurationSecond(){return xn}visitDurationMillisecond(){return Tn}visitDurationMicrosecond(){return Bn}visitDurationNanosecond(){return On}visitFixedSizeList(){return Io}visitMap(){return Uo}},Bf=new wc;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 Yr(r,t){return r===t||Et(r,t)}function cr(r,t){return r===t||Et(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Vo(r,t){return r===t||Et(r,t)&&r.precision===t.precision}function Bp(r,t){return r===t||Et(r,t)&&r.byteWidth===t.byteWidth}function Ic(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function kn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Vn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Op(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function Dp(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function vc(r,t){return r===t||Et(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Ne.compareManyFields(r.children,t.children)}function Ap(r,t){return r===t||Et(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ne.visit(r.indices,t.indices)&&Ne.visit(r.dictionary,t.dictionary)}function Po(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Pn(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Fp(r,t){return r===t||Et(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function Np(r,t){return r===t||Et(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}B.prototype.visitNull=Yr;B.prototype.visitBool=Yr;B.prototype.visitInt=cr;B.prototype.visitInt8=cr;B.prototype.visitInt16=cr;B.prototype.visitInt32=cr;B.prototype.visitInt64=cr;B.prototype.visitUint8=cr;B.prototype.visitUint16=cr;B.prototype.visitUint32=cr;B.prototype.visitUint64=cr;B.prototype.visitFloat=Vo;B.prototype.visitFloat16=Vo;B.prototype.visitFloat32=Vo;B.prototype.visitFloat64=Vo;B.prototype.visitUtf8=Yr;B.prototype.visitLargeUtf8=Yr;B.prototype.visitBinary=Yr;B.prototype.visitLargeBinary=Yr;B.prototype.visitFixedSizeBinary=Bp;B.prototype.visitDate=Ic;B.prototype.visitDateDay=Ic;B.prototype.visitDateMillisecond=Ic;B.prototype.visitTimestamp=kn;B.prototype.visitTimestampSecond=kn;B.prototype.visitTimestampMillisecond=kn;B.prototype.visitTimestampMicrosecond=kn;B.prototype.visitTimestampNanosecond=kn;B.prototype.visitTime=Vn;B.prototype.visitTimeSecond=Vn;B.prototype.visitTimeMillisecond=Vn;B.prototype.visitTimeMicrosecond=Vn;B.prototype.visitTimeNanosecond=Vn;B.prototype.visitDecimal=Yr;B.prototype.visitList=Op;B.prototype.visitStruct=Dp;B.prototype.visitUnion=vc;B.prototype.visitDenseUnion=vc;B.prototype.visitSparseUnion=vc;B.prototype.visitDictionary=Ap;B.prototype.visitInterval=Po;B.prototype.visitIntervalDayTime=Po;B.prototype.visitIntervalYearMonth=Po;B.prototype.visitIntervalMonthDayNano=Po;B.prototype.visitDuration=Pn;B.prototype.visitDurationSecond=Pn;B.prototype.visitDurationMillisecond=Pn;B.prototype.visitDurationMicrosecond=Pn;B.prototype.visitDurationNanosecond=Pn;B.prototype.visitFixedSizeList=Fp;B.prototype.visitMap=Np;var Ne=new B;function Zr(r,t){return Ne.compareSchemas(r,t)}function Of(r,t){return Ne.compareFields(r,t)}function Df(r,t){return Ne.visit(r,t)}function Kr(r){let t=r.type,e=new(Bf.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 jo(r,t){return Ep(r,t.map(e=>e.data.concat()))}function Ep(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=Lp(e,o,u,t,n),o>0&&(i[s++]=L({type:new it(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),i.map(d=>new ft(r,d))]}function Lp(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 Af,_e=class r{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new K([]),this._offsets=[0],this;let n,s;t[0]instanceof K&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof ft)return[c];if(c instanceof r)return c.batches;if(c instanceof G){if(c.type instanceof it)return[new ft(new K(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(m=>new P([c[m]])),d=n!=null?n:new K(l.map((m,_)=>new C(String(m),u[_].type,u[_].nullable))),[,p]=jo(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 K([]),!(n instanceof K))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(!Zr(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:oo(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=so(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Pr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?gi.visit(new P(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
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`[
18
22
  ${this.toArray().join(`,
19
23
  `)}
20
- ]`}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]=ln({length:this.numRows},t,e);let n=ao(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 P(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new P([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]=jo(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(...jo(s,o))}};Af=Symbol.toStringTag;_e[Af]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=yi(dn),r.get=yi(mt.getVisitFn(f.Struct)),r.set=co(Tt.getVisitFn(f.Struct)),r.indexOf=lo($r.getVisitFn(f.Struct)),"Table"))(_e.prototype);var Nf,ft=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof K))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=L({nullCount:0,type:new it(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]=Ff(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]=C.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new K(i),a=L({type:new it(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ff(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=Ef(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(Pr(t,this.numRows))}set(t,e){return Tt.visit(this.data,t,e)}indexOf(t,e){return $r.visit(this.data,t,e)}[Symbol.iterator](){return gi.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new _e(this.schema,[this,...t])}slice(t,e){let[i]=new P([this.data]).slice(t,e).data;return new r(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new P([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new P([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 K(s,new Map(this.schema.metadata)),n=L({type:new it(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new it(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 it(e.fields),length:this.numRows,children:i});return new r(e,n)}};Nf=Symbol.toStringTag;ft[Nf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function Ff(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 it(n),length:e,children:s})]}function Ef(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)||[]])Ef(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 Qr=class extends ft{constructor(t){let e=t.fields.map(n=>L({type:n.type})),i=L({type:new it(t.fields),nullCount:0,children:e});super(t,i)}};var xc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,Tc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,Lf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Uf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Bi=class{constructor(t){this.source=t instanceof Fe?t:new Fe(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?nt:t.value===-1&&(t=this.readMetadataLength()).done?nt:(t=this.readMetadata(t.value)).done?nt: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(xc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=V.Schema,i=this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Tc(e));return n}readMetadataLength(){let t=this.source.read(zo),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 nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}}},jn=class{constructor(t,e){this.source=t instanceof te?t:bs(t)?new Tr(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?nt:t.value===-1&&(t=yield this.readMetadataLength()).done?nt:(t=yield this.readMetadata(t.value)).done?nt: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(xc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Uf(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(Tc(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(zo),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 nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}})}},zn=class extends Bi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof hn?t:new hn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:kt.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:kt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:kt.fromJSON(e,V.RecordBatch)}}return this._body=[],nt}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(xc(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(Tc(t));return i}},zo=4,Sc="ARROW1",Oi=new Uint8Array(Sc.length);for(let r=0;r<Sc.length;r+=1)Oi[r]=Sc.codePointAt(r);function Wo(r,t=0){for(let e=-1,i=Oi.length;++e<i;)if(Oi[e]!==r[t+e])return!1;return!0}var Di=Oi.length,Bc=Di+zo,Mf=Di*2+zo;var Oc=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}},Dc=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)}},Rf={[Ft.LZ4_FRAME]:new Oc,[Ft.ZSTD]:new Dc};var Ac=class{constructor(){this.registry={}}set(t,e){if(e!=null&&e.encode&&typeof e.encode=="function"&&!Rf[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}},Ai=new Ac;var Vt=class r extends qr{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:ys(t)?Rp(t):bs(t)?Vp(t):ne(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):_s(t)||qi(t)||Is(t)||Kt(t)?kp(new te(t)):Cp(new Fe(t))}static readAll(t){return t instanceof r?t.isSync()?Cf(t):kf(t):ys(t)||ArrayBuffer.isView(t)||se(t)||gs(t)?Cf(t):kf(t)}},Ee=class extends Vt{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*ni(ie(this[Symbol.iterator]())))})}},Or=class extends Vt{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 Ee{constructor(t){super(t),this._impl=t}},Wn=class extends Or{constructor(t){super(t),this._impl=t}},$o=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=Ai.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 it(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=Ai.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 P(l)):new P(l)).memoize()}_loadVectors(t,e,i){return new vi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_loadCompressedVectors(t,e,i){return new bo(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}}},Fi=class extends $o{constructor(t,e){super(e),this._reader=ys(t)?new zn(this._handle=t):new Bi(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Pf(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):nt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):nt}next(){if(this.closed)return nt;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 Qr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ni=class extends $o{constructor(t,e){super(e),this._reader=new jn(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=Pf(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):nt})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):nt})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return nt;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 Qr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ho=class extends Fi{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 pn?t:new pn(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Bc,i=t.readInt32(e),n=t.readAt(e-i,i);return er.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}},Fc=class extends Ni{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof Tr?t:new Tr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Bc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return er.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})}},Nc=class extends Fi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new go(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function Pf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Cf(r){let t=Vt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function kf(r){return zt(this,arguments,function*(){let e=yield U(Vt.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 Rp(r){return new Ee(new Nc(r))}function Cp(r){let t=r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(r.read())):new Ee(new Fi(r)):new Ee(new Fi((function*(){})()))}function kp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(yield r.read())):new Or(new Ni(r)):new Or(new Ni((function(){return zt(this,arguments,function*(){})})()))})}function Vp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Tr(r,t);return t>=Mf&&Wo(yield e.readAt(0,Di+7&-8))?new Wn(new Fc(e)):new Or(new Ni(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 P)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;b.isNull(e)||we.call(this,n<=0?new Uint8Array(0):zr(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 Pp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(we.call(this,n),e.mode===Z.Sparse)return Ec.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return we.call(this,s),Ec.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 jp(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,zr(r.offset,r.length,t)):we.call(this,Wr(r.values))}function lr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Go(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,Ss(-n,t+1,i)),we.call(this,e.subarray(n,n+o)),this}function Lc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return we.call(this,Ss(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Ec(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}lt.prototype.visitBool=jp;lt.prototype.visitInt=lr;lt.prototype.visitFloat=lr;lt.prototype.visitUtf8=Go;lt.prototype.visitLargeUtf8=Go;lt.prototype.visitBinary=Go;lt.prototype.visitLargeBinary=Go;lt.prototype.visitFixedSizeBinary=lr;lt.prototype.visitDate=lr;lt.prototype.visitTimestamp=lr;lt.prototype.visitTime=lr;lt.prototype.visitDecimal=lr;lt.prototype.visitList=Lc;lt.prototype.visitStruct=Ec;lt.prototype.visitUnion=Pp;lt.prototype.visitInterval=lr;lt.prototype.visitDuration=lr;lt.prototype.visitFixedSizeList=Lc;lt.prototype.visitMap=Lc;var ti=class extends qr{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 Ae,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,At(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 Gr(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)):Kt(t)?Mc(this,t):Uc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof Ae?this._sink=t:(this._sink=new Ae,t&&Kl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Xl(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||!Zr(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&&!Zr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof Qr||this._writeRecordBatch(t):t instanceof _e?this.writeAll(t.batches):se(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=kt.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 rr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new rr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(kt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Oi)}_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=kt.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=Ai.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=D(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 j=8+d.length;s.push(new gt(i,j)),i+=j}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 P([t])),c=new bt(t.length,s,o,this._compression),l=new Ot(c,e,i),u=kt.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}},$n=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(i,t)}},Hn=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(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=er.encode(new er(t,J.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Uc(r,t){let e=t;t instanceof _e&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Mc(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(Kt(r))return Wp(r,t);if(se(r))return zp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}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){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=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Wp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){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=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function $f(r){return new Rc(r)}var Rc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Gl(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Kr(s),this._getSize=n!=="bytes"?zf:Wf;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"?zf:Wf}),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)}},zf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Wf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function qo(r,t){let e=new Ae,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 Vt.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 Jo(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 $p=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Wa),yc),sc),$a),Ra),nc),Va),_c),{compareSchemas:Zr,compareFields:Of,compareTypes:Df});St.toDOMStream=jf;ot.throughDOM=$f;Vt.throughDOM=qo;Dr.throughDOM=qo;Ee.throughDOM=qo;ti.throughDOM=Jo;Hn.throughDOM=Jo;$n.throughDOM=Jo;var Cc=class extends rt{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let t=this.create(),e=Date.now();return t.seconds=X.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(X.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=X.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=X.from(t.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(t.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(t.nanos>0){let s=(t.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(t,e,i){if(typeof t!="string")throw new Error("Unable to parse Timestamp from JSON "+Lr(t)+".");let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=X.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},kc=new Cc;var Hf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Hf||{}),Gf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Gf||{}),Vc=class extends rt{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}])}},Hp=new Vc,Pc=class extends rt{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}])}},Gp=new Pc,jc=class extends rt{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},nO=new jc,zc=class extends rt{constructor(){super("arrow.flight.protocol.Empty",[])}},qp=new zc,Wc=class extends rt{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Jp=new Wc,$c=class extends rt{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Kp=new $c,Hc=class extends rt{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Xp=new Hc,Gc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Xo}])}},sO=new Gc,qc=class extends rt{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>qf}])}},oO=new qc,Jc=class extends rt{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Yp=new Jc,Kc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Gf,"CANCEL_STATUS_"]}])}},aO=new Kc,Xc=class extends rt{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Zp=new Xc,Yc=class extends rt{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Hf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Ei=new Yc,Zc=class extends rt{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>qf},{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}])}},Xo=new Zc,Qc=class extends rt{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Xo},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>kc}])}},Qp=new Qc,tl=class extends rt{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Yo},{no:2,name:"location",kind:"message",repeat:1,T:()=>tm},{no:3,name:"expiration_time",kind:"message",T:()=>kc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},qf=new tl,el=class extends rt{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},tm=new el,rl=class extends rt{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Yo=new rl,il=class extends rt{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Ei},{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}])}},Ko=new il,nl=class extends rt{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},em=new nl,Zo=new Pi("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Hp,O:Gp},{name:"ListFlights",serverStreaming:!0,options:{},I:Kp,O:Xo},{name:"GetFlightInfo",options:{},I:Ei,O:Xo},{name:"PollFlightInfo",options:{},I:Ei,O:Qp},{name:"GetSchema",options:{},I:Ei,O:Zp},{name:"DoGet",serverStreaming:!0,options:{},I:Yo,O:Ko},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:em},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:Ko},{name:"DoAction",serverStreaming:!0,options:{},I:Xp,O:Yp},{name:"ListActions",serverStreaming:!0,options:{},I:qp,O:Jp}]);var Qo=class{constructor(t){this._transport=t;z(this,"typeName",Zo.typeName);z(this,"methods",Zo.methods);z(this,"options",Zo.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 Jf=/\$(\w+)/g;function Kf(r){return!!r.match(Jf)}function Xf(r,t){let e=r.match(Jf);if(e)for(let i of e)t[i.trim().replace("$","")]||ei(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var rm="2.2.0.nightly",Yf=`influxdb3-js/${rm}`;function sl(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 ri(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return Il(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return ri(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 Gn=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=Rr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new Qo(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 Yo.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Yf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){var d;if(i.params&&Kf(t)&&Xf(t,i.params),this._closed)throw new Error("queryApi: already closed!");let n=this._flightClient,s=this.prepareTicket(e,t,i),a={meta:this.prepareMetadata(i.headers)};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 _l(p.dataHeader.length),yield p.dataHeader,yield p.dataBody})();yield*await Vt.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]=sl(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 fr;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[,,j,at]=_.split("::");if(j==="field"){if(at&&p!==void 0&&p!==null){let dt=sl(u,p);c.setField(d,dt,at)}}else j==="tag"?c.setTag(d,p):j==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var ol=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
21
- `,qn=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=sa();break}case 1:{if(t[0]==null)throw new ur("No configuration specified!");typeof t[0]=="string"?e=na(t[0]):e=t[0];break}default:throw new ur("Multiple arguments specified!")}this._options={...ra,...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 ur("No host specified!");if(i.endsWith("/")&&(this._options.host=i.substring(0,i.length-1)),typeof this._options.token!="string")throw new ur("No token specified!");this._queryApi=new Gn({...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=Rr.writeTransport({...this._options,writeTimeout:n}),this._writeApi=new Hi({transport:this._transport,...this._options})}async write(t,e,i,n){var o;let s=this._mergeWriteOptions(n);await this._writeApi.doWrite(pa(t,s==null?void 0:s.defaultTags,s==null?void 0:s.tagOrder),(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),i,s)}query(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Kn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.query(t,(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),s)}queryPoints(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Kn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.queryPoints(t,(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),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 id(im);})();
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'
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);})();
22
26
  //# sourceMappingURL=influxdb.js.map